compiler-sfc.esm-browser.js 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571
  1. /**
  2. * @vue/compiler-sfc v3.5.22
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. // @__NO_SIDE_EFFECTS__
  7. function makeMap(str) {
  8. const map = /* @__PURE__ */ Object.create(null);
  9. for (const key of str.split(",")) map[key] = 1;
  10. return (val) => val in map;
  11. }
  12. const EMPTY_OBJ = Object.freeze({}) ;
  13. const NOOP = () => {
  14. };
  15. const NO = () => false;
  16. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  17. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  18. const extend = Object.assign;
  19. const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
  20. const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
  21. const isArray$3 = Array.isArray;
  22. const isMap = (val) => toTypeString(val) === "[object Map]";
  23. const isSet = (val) => toTypeString(val) === "[object Set]";
  24. const isFunction$1 = (val) => typeof val === "function";
  25. const isString$1 = (val) => typeof val === "string";
  26. const isSymbol$1 = (val) => typeof val === "symbol";
  27. const isObject$2 = (val) => val !== null && typeof val === "object";
  28. const objectToString$1 = Object.prototype.toString;
  29. const toTypeString = (value) => objectToString$1.call(value);
  30. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  31. const isReservedProp = /* @__PURE__ */ makeMap(
  32. // the leading comma is intentional so empty string "" is also included
  33. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  34. );
  35. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  36. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  37. );
  38. const cacheStringFunction = (fn) => {
  39. const cache = /* @__PURE__ */ Object.create(null);
  40. return ((str) => {
  41. const hit = cache[str];
  42. return hit || (cache[str] = fn(str));
  43. });
  44. };
  45. const camelizeRE = /-\w/g;
  46. const camelize = cacheStringFunction(
  47. (str) => {
  48. return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
  49. }
  50. );
  51. const hyphenateRE = /\B([A-Z])/g;
  52. const hyphenate = cacheStringFunction(
  53. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  54. );
  55. const capitalize = cacheStringFunction((str) => {
  56. return str.charAt(0).toUpperCase() + str.slice(1);
  57. });
  58. const toHandlerKey = cacheStringFunction(
  59. (str) => {
  60. const s = str ? `on${capitalize(str)}` : ``;
  61. return s;
  62. }
  63. );
  64. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  65. function genPropsAccessExp(name) {
  66. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  67. }
  68. function genCacheKey(source, options) {
  69. return source + JSON.stringify(
  70. options,
  71. (_, val) => typeof val === "function" ? val.toString() : val
  72. );
  73. }
  74. const PatchFlagNames = {
  75. [1]: `TEXT`,
  76. [2]: `CLASS`,
  77. [4]: `STYLE`,
  78. [8]: `PROPS`,
  79. [16]: `FULL_PROPS`,
  80. [32]: `NEED_HYDRATION`,
  81. [64]: `STABLE_FRAGMENT`,
  82. [128]: `KEYED_FRAGMENT`,
  83. [256]: `UNKEYED_FRAGMENT`,
  84. [512]: `NEED_PATCH`,
  85. [1024]: `DYNAMIC_SLOTS`,
  86. [2048]: `DEV_ROOT_FRAGMENT`,
  87. [-1]: `CACHED`,
  88. [-2]: `BAIL`
  89. };
  90. const slotFlagsText = {
  91. [1]: "STABLE",
  92. [2]: "DYNAMIC",
  93. [3]: "FORWARDED"
  94. };
  95. const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
  96. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  97. const range = 2;
  98. function generateCodeFrame(source, start = 0, end = source.length) {
  99. start = Math.max(0, Math.min(start, source.length));
  100. end = Math.max(0, Math.min(end, source.length));
  101. if (start > end) return "";
  102. let lines = source.split(/(\r?\n)/);
  103. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  104. lines = lines.filter((_, idx) => idx % 2 === 0);
  105. let count = 0;
  106. const res = [];
  107. for (let i = 0; i < lines.length; i++) {
  108. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  109. if (count >= start) {
  110. for (let j = i - range; j <= i + range || end > count; j++) {
  111. if (j < 0 || j >= lines.length) continue;
  112. const line = j + 1;
  113. res.push(
  114. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  115. );
  116. const lineLength = lines[j].length;
  117. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  118. if (j === i) {
  119. const pad = start - (count - (lineLength + newLineSeqLength));
  120. const length = Math.max(
  121. 1,
  122. end > count ? lineLength - pad : end - start
  123. );
  124. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  125. } else if (j > i) {
  126. if (end > count) {
  127. const length = Math.max(Math.min(end - count, lineLength), 1);
  128. res.push(` | ` + "^".repeat(length));
  129. }
  130. count += lineLength + newLineSeqLength;
  131. }
  132. }
  133. break;
  134. }
  135. }
  136. return res.join("\n");
  137. }
  138. function normalizeStyle(value) {
  139. if (isArray$3(value)) {
  140. const res = {};
  141. for (let i = 0; i < value.length; i++) {
  142. const item = value[i];
  143. const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
  144. if (normalized) {
  145. for (const key in normalized) {
  146. res[key] = normalized[key];
  147. }
  148. }
  149. }
  150. return res;
  151. } else if (isString$1(value) || isObject$2(value)) {
  152. return value;
  153. }
  154. }
  155. const listDelimiterRE = /;(?![^(]*\))/g;
  156. const propertyDelimiterRE = /:([^]+)/;
  157. const styleCommentRE = /\/\*[^]*?\*\//g;
  158. function parseStringStyle(cssText) {
  159. const ret = {};
  160. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  161. if (item) {
  162. const tmp = item.split(propertyDelimiterRE);
  163. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  164. }
  165. });
  166. return ret;
  167. }
  168. function stringifyStyle(styles) {
  169. if (!styles) return "";
  170. if (isString$1(styles)) return styles;
  171. let ret = "";
  172. for (const key in styles) {
  173. const value = styles[key];
  174. if (isString$1(value) || typeof value === "number") {
  175. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  176. ret += `${normalizedKey}:${value};`;
  177. }
  178. }
  179. return ret;
  180. }
  181. function normalizeClass(value) {
  182. let res = "";
  183. if (isString$1(value)) {
  184. res = value;
  185. } else if (isArray$3(value)) {
  186. for (let i = 0; i < value.length; i++) {
  187. const normalized = normalizeClass(value[i]);
  188. if (normalized) {
  189. res += normalized + " ";
  190. }
  191. }
  192. } else if (isObject$2(value)) {
  193. for (const name in value) {
  194. if (value[name]) {
  195. res += name + " ";
  196. }
  197. }
  198. }
  199. return res.trim();
  200. }
  201. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  202. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  203. const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
  204. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  205. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  206. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  207. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  208. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  209. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  210. const isBooleanAttr = /* @__PURE__ */ makeMap(
  211. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  212. );
  213. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  214. const attrValidationCache = {};
  215. function isSSRSafeAttrName(name) {
  216. if (attrValidationCache.hasOwnProperty(name)) {
  217. return attrValidationCache[name];
  218. }
  219. const isUnsafe = unsafeAttrCharRE.test(name);
  220. if (isUnsafe) {
  221. console.error(`unsafe attribute name: ${name}`);
  222. }
  223. return attrValidationCache[name] = !isUnsafe;
  224. }
  225. const propsToAttrMap = {
  226. acceptCharset: "accept-charset",
  227. className: "class",
  228. htmlFor: "for",
  229. httpEquiv: "http-equiv"
  230. };
  231. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  232. `accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
  233. );
  234. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  235. `xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
  236. );
  237. const isKnownMathMLAttr = /* @__PURE__ */ makeMap(
  238. `accent,accentunder,actiontype,align,alignmentscope,altimg,altimg-height,altimg-valign,altimg-width,alttext,bevelled,close,columnsalign,columnlines,columnspan,denomalign,depth,dir,display,displaystyle,encoding,equalcolumns,equalrows,fence,fontstyle,fontweight,form,frame,framespacing,groupalign,height,href,id,indentalign,indentalignfirst,indentalignlast,indentshift,indentshiftfirst,indentshiftlast,indextype,justify,largetop,largeop,lquote,lspace,mathbackground,mathcolor,mathsize,mathvariant,maxsize,minlabelspacing,mode,other,overflow,position,rowalign,rowlines,rowspan,rquote,rspace,scriptlevel,scriptminsize,scriptsizemultiplier,selection,separator,separators,shift,side,src,stackalign,stretchy,subscriptshift,superscriptshift,symmetric,voffset,width,widths,xlink:href,xlink:show,xlink:type,xmlns`
  239. );
  240. const escapeRE = /["'&<>]/;
  241. function escapeHtml(string) {
  242. const str = "" + string;
  243. const match = escapeRE.exec(str);
  244. if (!match) {
  245. return str;
  246. }
  247. let html = "";
  248. let escaped;
  249. let index;
  250. let lastIndex = 0;
  251. for (index = match.index; index < str.length; index++) {
  252. switch (str.charCodeAt(index)) {
  253. case 34:
  254. escaped = "&quot;";
  255. break;
  256. case 38:
  257. escaped = "&amp;";
  258. break;
  259. case 39:
  260. escaped = "&#39;";
  261. break;
  262. case 60:
  263. escaped = "&lt;";
  264. break;
  265. case 62:
  266. escaped = "&gt;";
  267. break;
  268. default:
  269. continue;
  270. }
  271. if (lastIndex !== index) {
  272. html += str.slice(lastIndex, index);
  273. }
  274. lastIndex = index + 1;
  275. html += escaped;
  276. }
  277. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  278. }
  279. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  280. function getEscapedCssVarName(key, doubleEscape) {
  281. return key.replace(
  282. cssVarNameEscapeSymbolsRE,
  283. (s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
  284. );
  285. }
  286. const isRef = (val) => {
  287. return !!(val && val["__v_isRef"] === true);
  288. };
  289. const toDisplayString = (val) => {
  290. return isString$1(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$1(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
  291. };
  292. const replacer = (_key, val) => {
  293. if (isRef(val)) {
  294. return replacer(_key, val.value);
  295. } else if (isMap(val)) {
  296. return {
  297. [`Map(${val.size})`]: [...val.entries()].reduce(
  298. (entries, [key, val2], i) => {
  299. entries[stringifySymbol(key, i) + " =>"] = val2;
  300. return entries;
  301. },
  302. {}
  303. )
  304. };
  305. } else if (isSet(val)) {
  306. return {
  307. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  308. };
  309. } else if (isSymbol$1(val)) {
  310. return stringifySymbol(val);
  311. } else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
  312. return String(val);
  313. }
  314. return val;
  315. };
  316. const stringifySymbol = (v, i = "") => {
  317. var _a;
  318. return (
  319. // Symbol.description in es2019+ so we need to cast here to pass
  320. // the lib: es2016 check
  321. isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  322. );
  323. };
  324. const FRAGMENT = Symbol(`Fragment` );
  325. const TELEPORT = Symbol(`Teleport` );
  326. const SUSPENSE = Symbol(`Suspense` );
  327. const KEEP_ALIVE = Symbol(`KeepAlive` );
  328. const BASE_TRANSITION = Symbol(
  329. `BaseTransition`
  330. );
  331. const OPEN_BLOCK = Symbol(`openBlock` );
  332. const CREATE_BLOCK = Symbol(`createBlock` );
  333. const CREATE_ELEMENT_BLOCK = Symbol(
  334. `createElementBlock`
  335. );
  336. const CREATE_VNODE = Symbol(`createVNode` );
  337. const CREATE_ELEMENT_VNODE = Symbol(
  338. `createElementVNode`
  339. );
  340. const CREATE_COMMENT = Symbol(
  341. `createCommentVNode`
  342. );
  343. const CREATE_TEXT = Symbol(
  344. `createTextVNode`
  345. );
  346. const CREATE_STATIC = Symbol(
  347. `createStaticVNode`
  348. );
  349. const RESOLVE_COMPONENT = Symbol(
  350. `resolveComponent`
  351. );
  352. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  353. `resolveDynamicComponent`
  354. );
  355. const RESOLVE_DIRECTIVE = Symbol(
  356. `resolveDirective`
  357. );
  358. const RESOLVE_FILTER = Symbol(
  359. `resolveFilter`
  360. );
  361. const WITH_DIRECTIVES = Symbol(
  362. `withDirectives`
  363. );
  364. const RENDER_LIST = Symbol(`renderList` );
  365. const RENDER_SLOT = Symbol(`renderSlot` );
  366. const CREATE_SLOTS = Symbol(`createSlots` );
  367. const TO_DISPLAY_STRING = Symbol(
  368. `toDisplayString`
  369. );
  370. const MERGE_PROPS = Symbol(`mergeProps` );
  371. const NORMALIZE_CLASS = Symbol(
  372. `normalizeClass`
  373. );
  374. const NORMALIZE_STYLE = Symbol(
  375. `normalizeStyle`
  376. );
  377. const NORMALIZE_PROPS = Symbol(
  378. `normalizeProps`
  379. );
  380. const GUARD_REACTIVE_PROPS = Symbol(
  381. `guardReactiveProps`
  382. );
  383. const TO_HANDLERS = Symbol(`toHandlers` );
  384. const CAMELIZE = Symbol(`camelize` );
  385. const CAPITALIZE = Symbol(`capitalize` );
  386. const TO_HANDLER_KEY = Symbol(
  387. `toHandlerKey`
  388. );
  389. const SET_BLOCK_TRACKING = Symbol(
  390. `setBlockTracking`
  391. );
  392. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  393. const POP_SCOPE_ID = Symbol(`popScopeId` );
  394. const WITH_CTX = Symbol(`withCtx` );
  395. const UNREF = Symbol(`unref` );
  396. const IS_REF = Symbol(`isRef` );
  397. const WITH_MEMO = Symbol(`withMemo` );
  398. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  399. const helperNameMap = {
  400. [FRAGMENT]: `Fragment`,
  401. [TELEPORT]: `Teleport`,
  402. [SUSPENSE]: `Suspense`,
  403. [KEEP_ALIVE]: `KeepAlive`,
  404. [BASE_TRANSITION]: `BaseTransition`,
  405. [OPEN_BLOCK]: `openBlock`,
  406. [CREATE_BLOCK]: `createBlock`,
  407. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  408. [CREATE_VNODE]: `createVNode`,
  409. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  410. [CREATE_COMMENT]: `createCommentVNode`,
  411. [CREATE_TEXT]: `createTextVNode`,
  412. [CREATE_STATIC]: `createStaticVNode`,
  413. [RESOLVE_COMPONENT]: `resolveComponent`,
  414. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  415. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  416. [RESOLVE_FILTER]: `resolveFilter`,
  417. [WITH_DIRECTIVES]: `withDirectives`,
  418. [RENDER_LIST]: `renderList`,
  419. [RENDER_SLOT]: `renderSlot`,
  420. [CREATE_SLOTS]: `createSlots`,
  421. [TO_DISPLAY_STRING]: `toDisplayString`,
  422. [MERGE_PROPS]: `mergeProps`,
  423. [NORMALIZE_CLASS]: `normalizeClass`,
  424. [NORMALIZE_STYLE]: `normalizeStyle`,
  425. [NORMALIZE_PROPS]: `normalizeProps`,
  426. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  427. [TO_HANDLERS]: `toHandlers`,
  428. [CAMELIZE]: `camelize`,
  429. [CAPITALIZE]: `capitalize`,
  430. [TO_HANDLER_KEY]: `toHandlerKey`,
  431. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  432. [PUSH_SCOPE_ID]: `pushScopeId`,
  433. [POP_SCOPE_ID]: `popScopeId`,
  434. [WITH_CTX]: `withCtx`,
  435. [UNREF]: `unref`,
  436. [IS_REF]: `isRef`,
  437. [WITH_MEMO]: `withMemo`,
  438. [IS_MEMO_SAME]: `isMemoSame`
  439. };
  440. function registerRuntimeHelpers(helpers) {
  441. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  442. helperNameMap[s] = helpers[s];
  443. });
  444. }
  445. const Namespaces = {
  446. "HTML": 0,
  447. "0": "HTML",
  448. "SVG": 1,
  449. "1": "SVG",
  450. "MATH_ML": 2,
  451. "2": "MATH_ML"
  452. };
  453. const NodeTypes = {
  454. "ROOT": 0,
  455. "0": "ROOT",
  456. "ELEMENT": 1,
  457. "1": "ELEMENT",
  458. "TEXT": 2,
  459. "2": "TEXT",
  460. "COMMENT": 3,
  461. "3": "COMMENT",
  462. "SIMPLE_EXPRESSION": 4,
  463. "4": "SIMPLE_EXPRESSION",
  464. "INTERPOLATION": 5,
  465. "5": "INTERPOLATION",
  466. "ATTRIBUTE": 6,
  467. "6": "ATTRIBUTE",
  468. "DIRECTIVE": 7,
  469. "7": "DIRECTIVE",
  470. "COMPOUND_EXPRESSION": 8,
  471. "8": "COMPOUND_EXPRESSION",
  472. "IF": 9,
  473. "9": "IF",
  474. "IF_BRANCH": 10,
  475. "10": "IF_BRANCH",
  476. "FOR": 11,
  477. "11": "FOR",
  478. "TEXT_CALL": 12,
  479. "12": "TEXT_CALL",
  480. "VNODE_CALL": 13,
  481. "13": "VNODE_CALL",
  482. "JS_CALL_EXPRESSION": 14,
  483. "14": "JS_CALL_EXPRESSION",
  484. "JS_OBJECT_EXPRESSION": 15,
  485. "15": "JS_OBJECT_EXPRESSION",
  486. "JS_PROPERTY": 16,
  487. "16": "JS_PROPERTY",
  488. "JS_ARRAY_EXPRESSION": 17,
  489. "17": "JS_ARRAY_EXPRESSION",
  490. "JS_FUNCTION_EXPRESSION": 18,
  491. "18": "JS_FUNCTION_EXPRESSION",
  492. "JS_CONDITIONAL_EXPRESSION": 19,
  493. "19": "JS_CONDITIONAL_EXPRESSION",
  494. "JS_CACHE_EXPRESSION": 20,
  495. "20": "JS_CACHE_EXPRESSION",
  496. "JS_BLOCK_STATEMENT": 21,
  497. "21": "JS_BLOCK_STATEMENT",
  498. "JS_TEMPLATE_LITERAL": 22,
  499. "22": "JS_TEMPLATE_LITERAL",
  500. "JS_IF_STATEMENT": 23,
  501. "23": "JS_IF_STATEMENT",
  502. "JS_ASSIGNMENT_EXPRESSION": 24,
  503. "24": "JS_ASSIGNMENT_EXPRESSION",
  504. "JS_SEQUENCE_EXPRESSION": 25,
  505. "25": "JS_SEQUENCE_EXPRESSION",
  506. "JS_RETURN_STATEMENT": 26,
  507. "26": "JS_RETURN_STATEMENT"
  508. };
  509. const ElementTypes = {
  510. "ELEMENT": 0,
  511. "0": "ELEMENT",
  512. "COMPONENT": 1,
  513. "1": "COMPONENT",
  514. "SLOT": 2,
  515. "2": "SLOT",
  516. "TEMPLATE": 3,
  517. "3": "TEMPLATE"
  518. };
  519. const ConstantTypes = {
  520. "NOT_CONSTANT": 0,
  521. "0": "NOT_CONSTANT",
  522. "CAN_SKIP_PATCH": 1,
  523. "1": "CAN_SKIP_PATCH",
  524. "CAN_CACHE": 2,
  525. "2": "CAN_CACHE",
  526. "CAN_STRINGIFY": 3,
  527. "3": "CAN_STRINGIFY"
  528. };
  529. const locStub = {
  530. start: { line: 1, column: 1, offset: 0 },
  531. end: { line: 1, column: 1, offset: 0 },
  532. source: ""
  533. };
  534. function createRoot(children, source = "") {
  535. return {
  536. type: 0,
  537. source,
  538. children,
  539. helpers: /* @__PURE__ */ new Set(),
  540. components: [],
  541. directives: [],
  542. hoists: [],
  543. imports: [],
  544. cached: [],
  545. temps: 0,
  546. codegenNode: void 0,
  547. loc: locStub
  548. };
  549. }
  550. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  551. if (context) {
  552. if (isBlock) {
  553. context.helper(OPEN_BLOCK);
  554. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  555. } else {
  556. context.helper(getVNodeHelper(context.inSSR, isComponent));
  557. }
  558. if (directives) {
  559. context.helper(WITH_DIRECTIVES);
  560. }
  561. }
  562. return {
  563. type: 13,
  564. tag,
  565. props,
  566. children,
  567. patchFlag,
  568. dynamicProps,
  569. directives,
  570. isBlock,
  571. disableTracking,
  572. isComponent,
  573. loc
  574. };
  575. }
  576. function createArrayExpression(elements, loc = locStub) {
  577. return {
  578. type: 17,
  579. loc,
  580. elements
  581. };
  582. }
  583. function createObjectExpression(properties, loc = locStub) {
  584. return {
  585. type: 15,
  586. loc,
  587. properties
  588. };
  589. }
  590. function createObjectProperty(key, value) {
  591. return {
  592. type: 16,
  593. loc: locStub,
  594. key: isString$1(key) ? createSimpleExpression(key, true) : key,
  595. value
  596. };
  597. }
  598. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  599. return {
  600. type: 4,
  601. loc,
  602. content,
  603. isStatic,
  604. constType: isStatic ? 3 : constType
  605. };
  606. }
  607. function createInterpolation(content, loc) {
  608. return {
  609. type: 5,
  610. loc,
  611. content: isString$1(content) ? createSimpleExpression(content, false, loc) : content
  612. };
  613. }
  614. function createCompoundExpression(children, loc = locStub) {
  615. return {
  616. type: 8,
  617. loc,
  618. children
  619. };
  620. }
  621. function createCallExpression(callee, args = [], loc = locStub) {
  622. return {
  623. type: 14,
  624. loc,
  625. callee,
  626. arguments: args
  627. };
  628. }
  629. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  630. return {
  631. type: 18,
  632. params,
  633. returns,
  634. newline,
  635. isSlot,
  636. loc
  637. };
  638. }
  639. function createConditionalExpression(test, consequent, alternate, newline = true) {
  640. return {
  641. type: 19,
  642. test,
  643. consequent,
  644. alternate,
  645. newline,
  646. loc: locStub
  647. };
  648. }
  649. function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
  650. return {
  651. type: 20,
  652. index,
  653. value,
  654. needPauseTracking,
  655. inVOnce,
  656. needArraySpread: false,
  657. loc: locStub
  658. };
  659. }
  660. function createBlockStatement(body) {
  661. return {
  662. type: 21,
  663. body,
  664. loc: locStub
  665. };
  666. }
  667. function createTemplateLiteral(elements) {
  668. return {
  669. type: 22,
  670. elements,
  671. loc: locStub
  672. };
  673. }
  674. function createIfStatement(test, consequent, alternate) {
  675. return {
  676. type: 23,
  677. test,
  678. consequent,
  679. alternate,
  680. loc: locStub
  681. };
  682. }
  683. function createAssignmentExpression(left, right) {
  684. return {
  685. type: 24,
  686. left,
  687. right,
  688. loc: locStub
  689. };
  690. }
  691. function createSequenceExpression(expressions) {
  692. return {
  693. type: 25,
  694. expressions,
  695. loc: locStub
  696. };
  697. }
  698. function createReturnStatement(returns) {
  699. return {
  700. type: 26,
  701. returns,
  702. loc: locStub
  703. };
  704. }
  705. function getVNodeHelper(ssr, isComponent) {
  706. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  707. }
  708. function getVNodeBlockHelper(ssr, isComponent) {
  709. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  710. }
  711. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  712. if (!node.isBlock) {
  713. node.isBlock = true;
  714. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  715. helper(OPEN_BLOCK);
  716. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  717. }
  718. }
  719. // Generated using scripts/write-decode-map.ts
  720. var htmlDecodeTree = new Uint16Array(
  721. // prettier-ignore
  722. "\u1d41<\xd5\u0131\u028a\u049d\u057b\u05d0\u0675\u06de\u07a2\u07d6\u080f\u0a4a\u0a91\u0da1\u0e6d\u0f09\u0f26\u10ca\u1228\u12e1\u1415\u149d\u14c3\u14df\u1525\0\0\0\0\0\0\u156b\u16cd\u198d\u1c12\u1ddd\u1f7e\u2060\u21b0\u228d\u23c0\u23fb\u2442\u2824\u2912\u2d08\u2e48\u2fce\u3016\u32ba\u3639\u37ac\u38fe\u3a28\u3a71\u3ae0\u3b2e\u0800EMabcfglmnoprstu\\bfms\x7f\x84\x8b\x90\x95\x98\xa6\xb3\xb9\xc8\xcflig\u803b\xc6\u40c6P\u803b&\u4026cute\u803b\xc1\u40c1reve;\u4102\u0100iyx}rc\u803b\xc2\u40c2;\u4410r;\uc000\ud835\udd04rave\u803b\xc0\u40c0pha;\u4391acr;\u4100d;\u6a53\u0100gp\x9d\xa1on;\u4104f;\uc000\ud835\udd38plyFunction;\u6061ing\u803b\xc5\u40c5\u0100cs\xbe\xc3r;\uc000\ud835\udc9cign;\u6254ilde\u803b\xc3\u40c3ml\u803b\xc4\u40c4\u0400aceforsu\xe5\xfb\xfe\u0117\u011c\u0122\u0127\u012a\u0100cr\xea\xf2kslash;\u6216\u0176\xf6\xf8;\u6ae7ed;\u6306y;\u4411\u0180crt\u0105\u010b\u0114ause;\u6235noullis;\u612ca;\u4392r;\uc000\ud835\udd05pf;\uc000\ud835\udd39eve;\u42d8c\xf2\u0113mpeq;\u624e\u0700HOacdefhilorsu\u014d\u0151\u0156\u0180\u019e\u01a2\u01b5\u01b7\u01ba\u01dc\u0215\u0273\u0278\u027ecy;\u4427PY\u803b\xa9\u40a9\u0180cpy\u015d\u0162\u017aute;\u4106\u0100;i\u0167\u0168\u62d2talDifferentialD;\u6145leys;\u612d\u0200aeio\u0189\u018e\u0194\u0198ron;\u410cdil\u803b\xc7\u40c7rc;\u4108nint;\u6230ot;\u410a\u0100dn\u01a7\u01adilla;\u40b8terDot;\u40b7\xf2\u017fi;\u43a7rcle\u0200DMPT\u01c7\u01cb\u01d1\u01d6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01e2\u01f8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020foubleQuote;\u601duote;\u6019\u0200lnpu\u021e\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6a74\u0180git\u022f\u0236\u023aruent;\u6261nt;\u622fourIntegral;\u622e\u0100fr\u024c\u024e;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6a2fcr;\uc000\ud835\udc9ep\u0100;C\u0284\u0285\u62d3ap;\u624d\u0580DJSZacefios\u02a0\u02ac\u02b0\u02b4\u02b8\u02cb\u02d7\u02e1\u02e6\u0333\u048d\u0100;o\u0179\u02a5trahd;\u6911cy;\u4402cy;\u4405cy;\u440f\u0180grs\u02bf\u02c4\u02c7ger;\u6021r;\u61a1hv;\u6ae4\u0100ay\u02d0\u02d5ron;\u410e;\u4414l\u0100;t\u02dd\u02de\u6207a;\u4394r;\uc000\ud835\udd07\u0100af\u02eb\u0327\u0100cm\u02f0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031ccute;\u40b4o\u0174\u030b\u030d;\u42d9bleAcute;\u42ddrave;\u4060ilde;\u42dcond;\u62c4ferentialD;\u6146\u0470\u033d\0\0\0\u0342\u0354\0\u0405f;\uc000\ud835\udd3b\u0180;DE\u0348\u0349\u034d\u40a8ot;\u60dcqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03cf\u03e2\u03f8ontourIntegra\xec\u0239o\u0274\u0379\0\0\u037b\xbb\u0349nArrow;\u61d3\u0100eo\u0387\u03a4ft\u0180ART\u0390\u0396\u03a1rrow;\u61d0ightArrow;\u61d4e\xe5\u02cang\u0100LR\u03ab\u03c4eft\u0100AR\u03b3\u03b9rrow;\u67f8ightArrow;\u67faightArrow;\u67f9ight\u0100AT\u03d8\u03derrow;\u61d2ee;\u62a8p\u0241\u03e9\0\0\u03efrrow;\u61d1ownArrow;\u61d5erticalBar;\u6225n\u0300ABLRTa\u0412\u042a\u0430\u045e\u047f\u037crrow\u0180;BU\u041d\u041e\u0422\u6193ar;\u6913pArrow;\u61f5reve;\u4311eft\u02d2\u043a\0\u0446\0\u0450ightVector;\u6950eeVector;\u695eector\u0100;B\u0459\u045a\u61bdar;\u6956ight\u01d4\u0467\0\u0471eeVector;\u695fector\u0100;B\u047a\u047b\u61c1ar;\u6957ee\u0100;A\u0486\u0487\u62a4rrow;\u61a7\u0100ct\u0492\u0497r;\uc000\ud835\udc9frok;\u4110\u0800NTacdfglmopqstux\u04bd\u04c0\u04c4\u04cb\u04de\u04e2\u04e7\u04ee\u04f5\u0521\u052f\u0536\u0552\u055d\u0560\u0565G;\u414aH\u803b\xd0\u40d0cute\u803b\xc9\u40c9\u0180aiy\u04d2\u04d7\u04dcron;\u411arc\u803b\xca\u40ca;\u442dot;\u4116r;\uc000\ud835\udd08rave\u803b\xc8\u40c8ement;\u6208\u0100ap\u04fa\u04fecr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65fberySmallSquare;\u65ab\u0100gp\u0526\u052aon;\u4118f;\uc000\ud835\udd3csilon;\u4395u\u0100ai\u053c\u0549l\u0100;T\u0542\u0543\u6a75ilde;\u6242librium;\u61cc\u0100ci\u0557\u055ar;\u6130m;\u6a73a;\u4397ml\u803b\xcb\u40cb\u0100ip\u056a\u056fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058d\u05b2\u05ccy;\u4424r;\uc000\ud835\udd09lled\u0253\u0597\0\0\u05a3mallSquare;\u65fcerySmallSquare;\u65aa\u0370\u05ba\0\u05bf\0\0\u05c4f;\uc000\ud835\udd3dAll;\u6200riertrf;\u6131c\xf2\u05cb\u0600JTabcdfgorst\u05e8\u05ec\u05ef\u05fa\u0600\u0612\u0616\u061b\u061d\u0623\u066c\u0672cy;\u4403\u803b>\u403emma\u0100;d\u05f7\u05f8\u4393;\u43dcreve;\u411e\u0180eiy\u0607\u060c\u0610dil;\u4122rc;\u411c;\u4413ot;\u4120r;\uc000\ud835\udd0a;\u62d9pf;\uc000\ud835\udd3eeater\u0300EFGLST\u0635\u0644\u064e\u0656\u065b\u0666qual\u0100;L\u063e\u063f\u6265ess;\u62dbullEqual;\u6267reater;\u6aa2ess;\u6277lantEqual;\u6a7eilde;\u6273cr;\uc000\ud835\udca2;\u626b\u0400Aacfiosu\u0685\u068b\u0696\u069b\u069e\u06aa\u06be\u06caRDcy;\u442a\u0100ct\u0690\u0694ek;\u42c7;\u405eirc;\u4124r;\u610clbertSpace;\u610b\u01f0\u06af\0\u06b2f;\u610dizontalLine;\u6500\u0100ct\u06c3\u06c5\xf2\u06a9rok;\u4126mp\u0144\u06d0\u06d8ownHum\xf0\u012fqual;\u624f\u0700EJOacdfgmnostu\u06fa\u06fe\u0703\u0707\u070e\u071a\u071e\u0721\u0728\u0744\u0778\u078b\u078f\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803b\xcd\u40cd\u0100iy\u0713\u0718rc\u803b\xce\u40ce;\u4418ot;\u4130r;\u6111rave\u803b\xcc\u40cc\u0180;ap\u0720\u072f\u073f\u0100cg\u0734\u0737r;\u412ainaryI;\u6148lie\xf3\u03dd\u01f4\u0749\0\u0762\u0100;e\u074d\u074e\u622c\u0100gr\u0753\u0758ral;\u622bsection;\u62c2isible\u0100CT\u076c\u0772omma;\u6063imes;\u6062\u0180gpt\u077f\u0783\u0788on;\u412ef;\uc000\ud835\udd40a;\u4399cr;\u6110ilde;\u4128\u01eb\u079a\0\u079ecy;\u4406l\u803b\xcf\u40cf\u0280cfosu\u07ac\u07b7\u07bc\u07c2\u07d0\u0100iy\u07b1\u07b5rc;\u4134;\u4419r;\uc000\ud835\udd0dpf;\uc000\ud835\udd41\u01e3\u07c7\0\u07ccr;\uc000\ud835\udca5rcy;\u4408kcy;\u4404\u0380HJacfos\u07e4\u07e8\u07ec\u07f1\u07fd\u0802\u0808cy;\u4425cy;\u440cppa;\u439a\u0100ey\u07f6\u07fbdil;\u4136;\u441ar;\uc000\ud835\udd0epf;\uc000\ud835\udd42cr;\uc000\ud835\udca6\u0580JTaceflmost\u0825\u0829\u082c\u0850\u0863\u09b3\u09b8\u09c7\u09cd\u0a37\u0a47cy;\u4409\u803b<\u403c\u0280cmnpr\u0837\u083c\u0841\u0844\u084dute;\u4139bda;\u439bg;\u67ealacetrf;\u6112r;\u619e\u0180aey\u0857\u085c\u0861ron;\u413ddil;\u413b;\u441b\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087e\u08a9\u08b1\u08e0\u08e6\u08fc\u092f\u095b\u0390\u096a\u0100nr\u0883\u088fgleBracket;\u67e8row\u0180;BR\u0899\u089a\u089e\u6190ar;\u61e4ightArrow;\u61c6eiling;\u6308o\u01f5\u08b7\0\u08c3bleBracket;\u67e6n\u01d4\u08c8\0\u08d2eeVector;\u6961ector\u0100;B\u08db\u08dc\u61c3ar;\u6959loor;\u630aight\u0100AV\u08ef\u08f5rrow;\u6194ector;\u694e\u0100er\u0901\u0917e\u0180;AV\u0909\u090a\u0910\u62a3rrow;\u61a4ector;\u695aiangle\u0180;BE\u0924\u0925\u0929\u62b2ar;\u69cfqual;\u62b4p\u0180DTV\u0937\u0942\u094cownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61bfar;\u6958ector\u0100;B\u0965\u0966\u61bcar;\u6952ight\xe1\u039cs\u0300EFGLST\u097e\u098b\u0995\u099d\u09a2\u09adqualGreater;\u62daullEqual;\u6266reater;\u6276ess;\u6aa1lantEqual;\u6a7dilde;\u6272r;\uc000\ud835\udd0f\u0100;e\u09bd\u09be\u62d8ftarrow;\u61daidot;\u413f\u0180npw\u09d4\u0a16\u0a1bg\u0200LRlr\u09de\u09f7\u0a02\u0a10eft\u0100AR\u09e6\u09ecrrow;\u67f5ightArrow;\u67f7ightArrow;\u67f6eft\u0100ar\u03b3\u0a0aight\xe1\u03bfight\xe1\u03caf;\uc000\ud835\udd43er\u0100LR\u0a22\u0a2ceftArrow;\u6199ightArrow;\u6198\u0180cht\u0a3e\u0a40\u0a42\xf2\u084c;\u61b0rok;\u4141;\u626a\u0400acefiosu\u0a5a\u0a5d\u0a60\u0a77\u0a7c\u0a85\u0a8b\u0a8ep;\u6905y;\u441c\u0100dl\u0a65\u0a6fiumSpace;\u605flintrf;\u6133r;\uc000\ud835\udd10nusPlus;\u6213pf;\uc000\ud835\udd44c\xf2\u0a76;\u439c\u0480Jacefostu\u0aa3\u0aa7\u0aad\u0ac0\u0b14\u0b19\u0d91\u0d97\u0d9ecy;\u440acute;\u4143\u0180aey\u0ab4\u0ab9\u0aberon;\u4147dil;\u4145;\u441d\u0180gsw\u0ac7\u0af0\u0b0eative\u0180MTV\u0ad3\u0adf\u0ae8ediumSpace;\u600bhi\u0100cn\u0ae6\u0ad8\xeb\u0ad9eryThi\xee\u0ad9ted\u0100GL\u0af8\u0b06reaterGreate\xf2\u0673essLes\xf3\u0a48Line;\u400ar;\uc000\ud835\udd11\u0200Bnpt\u0b22\u0b28\u0b37\u0b3areak;\u6060BreakingSpace;\u40a0f;\u6115\u0680;CDEGHLNPRSTV\u0b55\u0b56\u0b6a\u0b7c\u0ba1\u0beb\u0c04\u0c5e\u0c84\u0ca6\u0cd8\u0d61\u0d85\u6aec\u0100ou\u0b5b\u0b64ngruent;\u6262pCap;\u626doubleVerticalBar;\u6226\u0180lqx\u0b83\u0b8a\u0b9bement;\u6209ual\u0100;T\u0b92\u0b93\u6260ilde;\uc000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0bb6\u0bb7\u0bbd\u0bc9\u0bd3\u0bd8\u0be5\u626fqual;\u6271ullEqual;\uc000\u2267\u0338reater;\uc000\u226b\u0338ess;\u6279lantEqual;\uc000\u2a7e\u0338ilde;\u6275ump\u0144\u0bf2\u0bfdownHump;\uc000\u224e\u0338qual;\uc000\u224f\u0338e\u0100fs\u0c0a\u0c27tTriangle\u0180;BE\u0c1a\u0c1b\u0c21\u62eaar;\uc000\u29cf\u0338qual;\u62ecs\u0300;EGLST\u0c35\u0c36\u0c3c\u0c44\u0c4b\u0c58\u626equal;\u6270reater;\u6278ess;\uc000\u226a\u0338lantEqual;\uc000\u2a7d\u0338ilde;\u6274ested\u0100GL\u0c68\u0c79reaterGreater;\uc000\u2aa2\u0338essLess;\uc000\u2aa1\u0338recedes\u0180;ES\u0c92\u0c93\u0c9b\u6280qual;\uc000\u2aaf\u0338lantEqual;\u62e0\u0100ei\u0cab\u0cb9verseElement;\u620cghtTriangle\u0180;BE\u0ccb\u0ccc\u0cd2\u62ebar;\uc000\u29d0\u0338qual;\u62ed\u0100qu\u0cdd\u0d0cuareSu\u0100bp\u0ce8\u0cf9set\u0100;E\u0cf0\u0cf3\uc000\u228f\u0338qual;\u62e2erset\u0100;E\u0d03\u0d06\uc000\u2290\u0338qual;\u62e3\u0180bcp\u0d13\u0d24\u0d4eset\u0100;E\u0d1b\u0d1e\uc000\u2282\u20d2qual;\u6288ceeds\u0200;EST\u0d32\u0d33\u0d3b\u0d46\u6281qual;\uc000\u2ab0\u0338lantEqual;\u62e1ilde;\uc000\u227f\u0338erset\u0100;E\u0d58\u0d5b\uc000\u2283\u20d2qual;\u6289ilde\u0200;EFT\u0d6e\u0d6f\u0d75\u0d7f\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uc000\ud835\udca9ilde\u803b\xd1\u40d1;\u439d\u0700Eacdfgmoprstuv\u0dbd\u0dc2\u0dc9\u0dd5\u0ddb\u0de0\u0de7\u0dfc\u0e02\u0e20\u0e22\u0e32\u0e3f\u0e44lig;\u4152cute\u803b\xd3\u40d3\u0100iy\u0dce\u0dd3rc\u803b\xd4\u40d4;\u441eblac;\u4150r;\uc000\ud835\udd12rave\u803b\xd2\u40d2\u0180aei\u0dee\u0df2\u0df6cr;\u414cga;\u43a9cron;\u439fpf;\uc000\ud835\udd46enCurly\u0100DQ\u0e0e\u0e1aoubleQuote;\u601cuote;\u6018;\u6a54\u0100cl\u0e27\u0e2cr;\uc000\ud835\udcaaash\u803b\xd8\u40d8i\u016c\u0e37\u0e3cde\u803b\xd5\u40d5es;\u6a37ml\u803b\xd6\u40d6er\u0100BP\u0e4b\u0e60\u0100ar\u0e50\u0e53r;\u603eac\u0100ek\u0e5a\u0e5c;\u63deet;\u63b4arenthesis;\u63dc\u0480acfhilors\u0e7f\u0e87\u0e8a\u0e8f\u0e92\u0e94\u0e9d\u0eb0\u0efcrtialD;\u6202y;\u441fr;\uc000\ud835\udd13i;\u43a6;\u43a0usMinus;\u40b1\u0100ip\u0ea2\u0eadncareplan\xe5\u069df;\u6119\u0200;eio\u0eb9\u0eba\u0ee0\u0ee4\u6abbcedes\u0200;EST\u0ec8\u0ec9\u0ecf\u0eda\u627aqual;\u6aaflantEqual;\u627cilde;\u627eme;\u6033\u0100dp\u0ee9\u0eeeuct;\u620fortion\u0100;a\u0225\u0ef9l;\u621d\u0100ci\u0f01\u0f06r;\uc000\ud835\udcab;\u43a8\u0200Ufos\u0f11\u0f16\u0f1b\u0f1fOT\u803b\"\u4022r;\uc000\ud835\udd14pf;\u611acr;\uc000\ud835\udcac\u0600BEacefhiorsu\u0f3e\u0f43\u0f47\u0f60\u0f73\u0fa7\u0faa\u0fad\u1096\u10a9\u10b4\u10bearr;\u6910G\u803b\xae\u40ae\u0180cnr\u0f4e\u0f53\u0f56ute;\u4154g;\u67ebr\u0100;t\u0f5c\u0f5d\u61a0l;\u6916\u0180aey\u0f67\u0f6c\u0f71ron;\u4158dil;\u4156;\u4420\u0100;v\u0f78\u0f79\u611cerse\u0100EU\u0f82\u0f99\u0100lq\u0f87\u0f8eement;\u620builibrium;\u61cbpEquilibrium;\u696fr\xbb\u0f79o;\u43a1ght\u0400ACDFTUVa\u0fc1\u0feb\u0ff3\u1022\u1028\u105b\u1087\u03d8\u0100nr\u0fc6\u0fd2gleBracket;\u67e9row\u0180;BL\u0fdc\u0fdd\u0fe1\u6192ar;\u61e5eftArrow;\u61c4eiling;\u6309o\u01f5\u0ff9\0\u1005bleBracket;\u67e7n\u01d4\u100a\0\u1014eeVector;\u695dector\u0100;B\u101d\u101e\u61c2ar;\u6955loor;\u630b\u0100er\u102d\u1043e\u0180;AV\u1035\u1036\u103c\u62a2rrow;\u61a6ector;\u695biangle\u0180;BE\u1050\u1051\u1055\u62b3ar;\u69d0qual;\u62b5p\u0180DTV\u1063\u106e\u1078ownVector;\u694feeVector;\u695cector\u0100;B\u1082\u1083\u61bear;\u6954ector\u0100;B\u1091\u1092\u61c0ar;\u6953\u0100pu\u109b\u109ef;\u611dndImplies;\u6970ightarrow;\u61db\u0100ch\u10b9\u10bcr;\u611b;\u61b1leDelayed;\u69f4\u0680HOacfhimoqstu\u10e4\u10f1\u10f7\u10fd\u1119\u111e\u1151\u1156\u1161\u1167\u11b5\u11bb\u11bf\u0100Cc\u10e9\u10eeHcy;\u4429y;\u4428FTcy;\u442ccute;\u415a\u0280;aeiy\u1108\u1109\u110e\u1113\u1117\u6abcron;\u4160dil;\u415erc;\u415c;\u4421r;\uc000\ud835\udd16ort\u0200DLRU\u112a\u1134\u113e\u1149ownArrow\xbb\u041eeftArrow\xbb\u089aightArrow\xbb\u0fddpArrow;\u6191gma;\u43a3allCircle;\u6218pf;\uc000\ud835\udd4a\u0272\u116d\0\0\u1170t;\u621aare\u0200;ISU\u117b\u117c\u1189\u11af\u65a1ntersection;\u6293u\u0100bp\u118f\u119eset\u0100;E\u1197\u1198\u628fqual;\u6291erset\u0100;E\u11a8\u11a9\u6290qual;\u6292nion;\u6294cr;\uc000\ud835\udcaear;\u62c6\u0200bcmp\u11c8\u11db\u1209\u120b\u0100;s\u11cd\u11ce\u62d0et\u0100;E\u11cd\u11d5qual;\u6286\u0100ch\u11e0\u1205eeds\u0200;EST\u11ed\u11ee\u11f4\u11ff\u627bqual;\u6ab0lantEqual;\u627dilde;\u627fTh\xe1\u0f8c;\u6211\u0180;es\u1212\u1213\u1223\u62d1rset\u0100;E\u121c\u121d\u6283qual;\u6287et\xbb\u1213\u0580HRSacfhiors\u123e\u1244\u1249\u1255\u125e\u1271\u1276\u129f\u12c2\u12c8\u12d1ORN\u803b\xde\u40deADE;\u6122\u0100Hc\u124e\u1252cy;\u440by;\u4426\u0100bu\u125a\u125c;\u4009;\u43a4\u0180aey\u1265\u126a\u126fron;\u4164dil;\u4162;\u4422r;\uc000\ud835\udd17\u0100ei\u127b\u1289\u01f2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128e\u1298kSpace;\uc000\u205f\u200aSpace;\u6009lde\u0200;EFT\u12ab\u12ac\u12b2\u12bc\u623cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uc000\ud835\udd4bipleDot;\u60db\u0100ct\u12d6\u12dbr;\uc000\ud835\udcafrok;\u4166\u0ae1\u12f7\u130e\u131a\u1326\0\u132c\u1331\0\0\0\0\0\u1338\u133d\u1377\u1385\0\u13ff\u1404\u140a\u1410\u0100cr\u12fb\u1301ute\u803b\xda\u40dar\u0100;o\u1307\u1308\u619fcir;\u6949r\u01e3\u1313\0\u1316y;\u440eve;\u416c\u0100iy\u131e\u1323rc\u803b\xdb\u40db;\u4423blac;\u4170r;\uc000\ud835\udd18rave\u803b\xd9\u40d9acr;\u416a\u0100di\u1341\u1369er\u0100BP\u1348\u135d\u0100ar\u134d\u1350r;\u405fac\u0100ek\u1357\u1359;\u63dfet;\u63b5arenthesis;\u63ddon\u0100;P\u1370\u1371\u62c3lus;\u628e\u0100gp\u137b\u137fon;\u4172f;\uc000\ud835\udd4c\u0400ADETadps\u1395\u13ae\u13b8\u13c4\u03e8\u13d2\u13d7\u13f3rrow\u0180;BD\u1150\u13a0\u13a4ar;\u6912ownArrow;\u61c5ownArrow;\u6195quilibrium;\u696eee\u0100;A\u13cb\u13cc\u62a5rrow;\u61a5own\xe1\u03f3er\u0100LR\u13de\u13e8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13f9\u13fa\u43d2on;\u43a5ing;\u416ecr;\uc000\ud835\udcb0ilde;\u4168ml\u803b\xdc\u40dc\u0480Dbcdefosv\u1427\u142c\u1430\u1433\u143e\u1485\u148a\u1490\u1496ash;\u62abar;\u6aeby;\u4412ash\u0100;l\u143b\u143c\u62a9;\u6ae6\u0100er\u1443\u1445;\u62c1\u0180bty\u144c\u1450\u147aar;\u6016\u0100;i\u144f\u1455cal\u0200BLST\u1461\u1465\u146a\u1474ar;\u6223ine;\u407ceparator;\u6758ilde;\u6240ThinSpace;\u600ar;\uc000\ud835\udd19pf;\uc000\ud835\udd4dcr;\uc000\ud835\udcb1dash;\u62aa\u0280cefos\u14a7\u14ac\u14b1\u14b6\u14bcirc;\u4174dge;\u62c0r;\uc000\ud835\udd1apf;\uc000\ud835\udd4ecr;\uc000\ud835\udcb2\u0200fios\u14cb\u14d0\u14d2\u14d8r;\uc000\ud835\udd1b;\u439epf;\uc000\ud835\udd4fcr;\uc000\ud835\udcb3\u0480AIUacfosu\u14f1\u14f5\u14f9\u14fd\u1504\u150f\u1514\u151a\u1520cy;\u442fcy;\u4407cy;\u442ecute\u803b\xdd\u40dd\u0100iy\u1509\u150drc;\u4176;\u442br;\uc000\ud835\udd1cpf;\uc000\ud835\udd50cr;\uc000\ud835\udcb4ml;\u4178\u0400Hacdefos\u1535\u1539\u153f\u154b\u154f\u155d\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417d;\u4417ot;\u417b\u01f2\u1554\0\u155boWidt\xe8\u0ad9a;\u4396r;\u6128pf;\u6124cr;\uc000\ud835\udcb5\u0be1\u1583\u158a\u1590\0\u15b0\u15b6\u15bf\0\0\0\0\u15c6\u15db\u15eb\u165f\u166d\0\u1695\u169b\u16b2\u16b9\0\u16becute\u803b\xe1\u40e1reve;\u4103\u0300;Ediuy\u159c\u159d\u15a1\u15a3\u15a8\u15ad\u623e;\uc000\u223e\u0333;\u623frc\u803b\xe2\u40e2te\u80bb\xb4\u0306;\u4430lig\u803b\xe6\u40e6\u0100;r\xb2\u15ba;\uc000\ud835\udd1erave\u803b\xe0\u40e0\u0100ep\u15ca\u15d6\u0100fp\u15cf\u15d4sym;\u6135\xe8\u15d3ha;\u43b1\u0100ap\u15dfc\u0100cl\u15e4\u15e7r;\u4101g;\u6a3f\u0264\u15f0\0\0\u160a\u0280;adsv\u15fa\u15fb\u15ff\u1601\u1607\u6227nd;\u6a55;\u6a5clope;\u6a58;\u6a5a\u0380;elmrsz\u1618\u1619\u161b\u161e\u163f\u164f\u1659\u6220;\u69a4e\xbb\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163a\u163c\u163e;\u69a8;\u69a9;\u69aa;\u69ab;\u69ac;\u69ad;\u69ae;\u69aft\u0100;v\u1645\u1646\u621fb\u0100;d\u164c\u164d\u62be;\u699d\u0100pt\u1654\u1657h;\u6222\xbb\xb9arr;\u637c\u0100gp\u1663\u1667on;\u4105f;\uc000\ud835\udd52\u0380;Eaeiop\u12c1\u167b\u167d\u1682\u1684\u1687\u168a;\u6a70cir;\u6a6f;\u624ad;\u624bs;\u4027rox\u0100;e\u12c1\u1692\xf1\u1683ing\u803b\xe5\u40e5\u0180cty\u16a1\u16a6\u16a8r;\uc000\ud835\udcb6;\u402amp\u0100;e\u12c1\u16af\xf1\u0288ilde\u803b\xe3\u40e3ml\u803b\xe4\u40e4\u0100ci\u16c2\u16c8onin\xf4\u0272nt;\u6a11\u0800Nabcdefiklnoprsu\u16ed\u16f1\u1730\u173c\u1743\u1748\u1778\u177d\u17e0\u17e6\u1839\u1850\u170d\u193d\u1948\u1970ot;\u6aed\u0100cr\u16f6\u171ek\u0200ceps\u1700\u1705\u170d\u1713ong;\u624cpsilon;\u43f6rime;\u6035im\u0100;e\u171a\u171b\u623dq;\u62cd\u0176\u1722\u1726ee;\u62bded\u0100;g\u172c\u172d\u6305e\xbb\u172drk\u0100;t\u135c\u1737brk;\u63b6\u0100oy\u1701\u1741;\u4431quo;\u601e\u0280cmprt\u1753\u175b\u1761\u1764\u1768aus\u0100;e\u010a\u0109ptyv;\u69b0s\xe9\u170cno\xf5\u0113\u0180ahw\u176f\u1771\u1773;\u43b2;\u6136een;\u626cr;\uc000\ud835\udd1fg\u0380costuvw\u178d\u179d\u17b3\u17c1\u17d5\u17db\u17de\u0180aiu\u1794\u1796\u179a\xf0\u0760rc;\u65efp\xbb\u1371\u0180dpt\u17a4\u17a8\u17adot;\u6a00lus;\u6a01imes;\u6a02\u0271\u17b9\0\0\u17becup;\u6a06ar;\u6605riangle\u0100du\u17cd\u17d2own;\u65bdp;\u65b3plus;\u6a04e\xe5\u1444\xe5\u14adarow;\u690d\u0180ako\u17ed\u1826\u1835\u0100cn\u17f2\u1823k\u0180lst\u17fa\u05ab\u1802ozenge;\u69ebriangle\u0200;dlr\u1812\u1813\u1818\u181d\u65b4own;\u65beeft;\u65c2ight;\u65b8k;\u6423\u01b1\u182b\0\u1833\u01b2\u182f\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183e\u184d\u0100;q\u1843\u1846\uc000=\u20e5uiv;\uc000\u2261\u20e5t;\u6310\u0200ptwx\u1859\u185e\u1867\u186cf;\uc000\ud835\udd53\u0100;t\u13cb\u1863om\xbb\u13cctie;\u62c8\u0600DHUVbdhmptuv\u1885\u1896\u18aa\u18bb\u18d7\u18db\u18ec\u18ff\u1905\u190a\u1910\u1921\u0200LRlr\u188e\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18a1\u18a2\u18a4\u18a6\u18a8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18b3\u18b5\u18b7\u18b9;\u655d;\u655a;\u655c;\u6559\u0380;HLRhlr\u18ca\u18cb\u18cd\u18cf\u18d1\u18d3\u18d5\u6551;\u656c;\u6563;\u6560;\u656b;\u6562;\u655fox;\u69c9\u0200LRlr\u18e4\u18e6\u18e8\u18ea;\u6555;\u6552;\u6510;\u650c\u0280;DUdu\u06bd\u18f7\u18f9\u18fb\u18fd;\u6565;\u6568;\u652c;\u6534inus;\u629flus;\u629eimes;\u62a0\u0200LRlr\u1919\u191b\u191d\u191f;\u655b;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193b\u6502;\u656a;\u6561;\u655e;\u653c;\u6524;\u651c\u0100ev\u0123\u1942bar\u803b\xa6\u40a6\u0200ceio\u1951\u1956\u195a\u1960r;\uc000\ud835\udcb7mi;\u604fm\u0100;e\u171a\u171cl\u0180;bh\u1968\u1969\u196b\u405c;\u69c5sub;\u67c8\u016c\u1974\u197el\u0100;e\u1979\u197a\u6022t\xbb\u197ap\u0180;Ee\u012f\u1985\u1987;\u6aae\u0100;q\u06dc\u06db\u0ce1\u19a7\0\u19e8\u1a11\u1a15\u1a32\0\u1a37\u1a50\0\0\u1ab4\0\0\u1ac1\0\0\u1b21\u1b2e\u1b4d\u1b52\0\u1bfd\0\u1c0c\u0180cpr\u19ad\u19b2\u19ddute;\u4107\u0300;abcds\u19bf\u19c0\u19c4\u19ca\u19d5\u19d9\u6229nd;\u6a44rcup;\u6a49\u0100au\u19cf\u19d2p;\u6a4bp;\u6a47ot;\u6a40;\uc000\u2229\ufe00\u0100eo\u19e2\u19e5t;\u6041\xee\u0693\u0200aeiu\u19f0\u19fb\u1a01\u1a05\u01f0\u19f5\0\u19f8s;\u6a4don;\u410ddil\u803b\xe7\u40e7rc;\u4109ps\u0100;s\u1a0c\u1a0d\u6a4cm;\u6a50ot;\u410b\u0180dmn\u1a1b\u1a20\u1a26il\u80bb\xb8\u01adptyv;\u69b2t\u8100\xa2;e\u1a2d\u1a2e\u40a2r\xe4\u01b2r;\uc000\ud835\udd20\u0180cei\u1a3d\u1a40\u1a4dy;\u4447ck\u0100;m\u1a47\u1a48\u6713ark\xbb\u1a48;\u43c7r\u0380;Ecefms\u1a5f\u1a60\u1a62\u1a6b\u1aa4\u1aaa\u1aae\u65cb;\u69c3\u0180;el\u1a69\u1a6a\u1a6d\u42c6q;\u6257e\u0261\u1a74\0\0\u1a88rrow\u0100lr\u1a7c\u1a81eft;\u61baight;\u61bb\u0280RSacd\u1a92\u1a94\u1a96\u1a9a\u1a9f\xbb\u0f47;\u64c8st;\u629birc;\u629aash;\u629dnint;\u6a10id;\u6aefcir;\u69c2ubs\u0100;u\u1abb\u1abc\u6663it\xbb\u1abc\u02ec\u1ac7\u1ad4\u1afa\0\u1b0aon\u0100;e\u1acd\u1ace\u403a\u0100;q\xc7\xc6\u026d\u1ad9\0\0\u1ae2a\u0100;t\u1ade\u1adf\u402c;\u4040\u0180;fl\u1ae8\u1ae9\u1aeb\u6201\xee\u1160e\u0100mx\u1af1\u1af6ent\xbb\u1ae9e\xf3\u024d\u01e7\u1afe\0\u1b07\u0100;d\u12bb\u1b02ot;\u6a6dn\xf4\u0246\u0180fry\u1b10\u1b14\u1b17;\uc000\ud835\udd54o\xe4\u0254\u8100\xa9;s\u0155\u1b1dr;\u6117\u0100ao\u1b25\u1b29rr;\u61b5ss;\u6717\u0100cu\u1b32\u1b37r;\uc000\ud835\udcb8\u0100bp\u1b3c\u1b44\u0100;e\u1b41\u1b42\u6acf;\u6ad1\u0100;e\u1b49\u1b4a\u6ad0;\u6ad2dot;\u62ef\u0380delprvw\u1b60\u1b6c\u1b77\u1b82\u1bac\u1bd4\u1bf9arr\u0100lr\u1b68\u1b6a;\u6938;\u6935\u0270\u1b72\0\0\u1b75r;\u62dec;\u62dfarr\u0100;p\u1b7f\u1b80\u61b6;\u693d\u0300;bcdos\u1b8f\u1b90\u1b96\u1ba1\u1ba5\u1ba8\u622arcap;\u6a48\u0100au\u1b9b\u1b9ep;\u6a46p;\u6a4aot;\u628dr;\u6a45;\uc000\u222a\ufe00\u0200alrv\u1bb5\u1bbf\u1bde\u1be3rr\u0100;m\u1bbc\u1bbd\u61b7;\u693cy\u0180evw\u1bc7\u1bd4\u1bd8q\u0270\u1bce\0\0\u1bd2re\xe3\u1b73u\xe3\u1b75ee;\u62ceedge;\u62cfen\u803b\xa4\u40a4earrow\u0100lr\u1bee\u1bf3eft\xbb\u1b80ight\xbb\u1bbde\xe4\u1bdd\u0100ci\u1c01\u1c07onin\xf4\u01f7nt;\u6231lcty;\u632d\u0980AHabcdefhijlorstuwz\u1c38\u1c3b\u1c3f\u1c5d\u1c69\u1c75\u1c8a\u1c9e\u1cac\u1cb7\u1cfb\u1cff\u1d0d\u1d7b\u1d91\u1dab\u1dbb\u1dc6\u1dcdr\xf2\u0381ar;\u6965\u0200glrs\u1c48\u1c4d\u1c52\u1c54ger;\u6020eth;\u6138\xf2\u1133h\u0100;v\u1c5a\u1c5b\u6010\xbb\u090a\u016b\u1c61\u1c67arow;\u690fa\xe3\u0315\u0100ay\u1c6e\u1c73ron;\u410f;\u4434\u0180;ao\u0332\u1c7c\u1c84\u0100gr\u02bf\u1c81r;\u61catseq;\u6a77\u0180glm\u1c91\u1c94\u1c98\u803b\xb0\u40b0ta;\u43b4ptyv;\u69b1\u0100ir\u1ca3\u1ca8sht;\u697f;\uc000\ud835\udd21ar\u0100lr\u1cb3\u1cb5\xbb\u08dc\xbb\u101e\u0280aegsv\u1cc2\u0378\u1cd6\u1cdc\u1ce0m\u0180;os\u0326\u1cca\u1cd4nd\u0100;s\u0326\u1cd1uit;\u6666amma;\u43ddin;\u62f2\u0180;io\u1ce7\u1ce8\u1cf8\u40f7de\u8100\xf7;o\u1ce7\u1cf0ntimes;\u62c7n\xf8\u1cf7cy;\u4452c\u026f\u1d06\0\0\u1d0arn;\u631eop;\u630d\u0280lptuw\u1d18\u1d1d\u1d22\u1d49\u1d55lar;\u4024f;\uc000\ud835\udd55\u0280;emps\u030b\u1d2d\u1d37\u1d3d\u1d42q\u0100;d\u0352\u1d33ot;\u6251inus;\u6238lus;\u6214quare;\u62a1blebarwedg\xe5\xfan\u0180adh\u112e\u1d5d\u1d67ownarrow\xf3\u1c83arpoon\u0100lr\u1d72\u1d76ef\xf4\u1cb4igh\xf4\u1cb6\u0162\u1d7f\u1d85karo\xf7\u0f42\u026f\u1d8a\0\0\u1d8ern;\u631fop;\u630c\u0180cot\u1d98\u1da3\u1da6\u0100ry\u1d9d\u1da1;\uc000\ud835\udcb9;\u4455l;\u69f6rok;\u4111\u0100dr\u1db0\u1db4ot;\u62f1i\u0100;f\u1dba\u1816\u65bf\u0100ah\u1dc0\u1dc3r\xf2\u0429a\xf2\u0fa6angle;\u69a6\u0100ci\u1dd2\u1dd5y;\u445fgrarr;\u67ff\u0900Dacdefglmnopqrstux\u1e01\u1e09\u1e19\u1e38\u0578\u1e3c\u1e49\u1e61\u1e7e\u1ea5\u1eaf\u1ebd\u1ee1\u1f2a\u1f37\u1f44\u1f4e\u1f5a\u0100Do\u1e06\u1d34o\xf4\u1c89\u0100cs\u1e0e\u1e14ute\u803b\xe9\u40e9ter;\u6a6e\u0200aioy\u1e22\u1e27\u1e31\u1e36ron;\u411br\u0100;c\u1e2d\u1e2e\u6256\u803b\xea\u40ealon;\u6255;\u444dot;\u4117\u0100Dr\u1e41\u1e45ot;\u6252;\uc000\ud835\udd22\u0180;rs\u1e50\u1e51\u1e57\u6a9aave\u803b\xe8\u40e8\u0100;d\u1e5c\u1e5d\u6a96ot;\u6a98\u0200;ils\u1e6a\u1e6b\u1e72\u1e74\u6a99nters;\u63e7;\u6113\u0100;d\u1e79\u1e7a\u6a95ot;\u6a97\u0180aps\u1e85\u1e89\u1e97cr;\u4113ty\u0180;sv\u1e92\u1e93\u1e95\u6205et\xbb\u1e93p\u01001;\u1e9d\u1ea4\u0133\u1ea1\u1ea3;\u6004;\u6005\u6003\u0100gs\u1eaa\u1eac;\u414bp;\u6002\u0100gp\u1eb4\u1eb8on;\u4119f;\uc000\ud835\udd56\u0180als\u1ec4\u1ece\u1ed2r\u0100;s\u1eca\u1ecb\u62d5l;\u69e3us;\u6a71i\u0180;lv\u1eda\u1edb\u1edf\u43b5on\xbb\u1edb;\u43f5\u0200csuv\u1eea\u1ef3\u1f0b\u1f23\u0100io\u1eef\u1e31rc\xbb\u1e2e\u0269\u1ef9\0\0\u1efb\xed\u0548ant\u0100gl\u1f02\u1f06tr\xbb\u1e5dess\xbb\u1e7a\u0180aei\u1f12\u1f16\u1f1als;\u403dst;\u625fv\u0100;D\u0235\u1f20D;\u6a78parsl;\u69e5\u0100Da\u1f2f\u1f33ot;\u6253rr;\u6971\u0180cdi\u1f3e\u1f41\u1ef8r;\u612fo\xf4\u0352\u0100ah\u1f49\u1f4b;\u43b7\u803b\xf0\u40f0\u0100mr\u1f53\u1f57l\u803b\xeb\u40ebo;\u60ac\u0180cip\u1f61\u1f64\u1f67l;\u4021s\xf4\u056e\u0100eo\u1f6c\u1f74ctatio\xee\u0559nential\xe5\u0579\u09e1\u1f92\0\u1f9e\0\u1fa1\u1fa7\0\0\u1fc6\u1fcc\0\u1fd3\0\u1fe6\u1fea\u2000\0\u2008\u205allingdotse\xf1\u1e44y;\u4444male;\u6640\u0180ilr\u1fad\u1fb3\u1fc1lig;\u8000\ufb03\u0269\u1fb9\0\0\u1fbdg;\u8000\ufb00ig;\u8000\ufb04;\uc000\ud835\udd23lig;\u8000\ufb01lig;\uc000fj\u0180alt\u1fd9\u1fdc\u1fe1t;\u666dig;\u8000\ufb02ns;\u65b1of;\u4192\u01f0\u1fee\0\u1ff3f;\uc000\ud835\udd57\u0100ak\u05bf\u1ff7\u0100;v\u1ffc\u1ffd\u62d4;\u6ad9artint;\u6a0d\u0100ao\u200c\u2055\u0100cs\u2011\u2052\u03b1\u201a\u2030\u2038\u2045\u2048\0\u2050\u03b2\u2022\u2025\u2027\u202a\u202c\0\u202e\u803b\xbd\u40bd;\u6153\u803b\xbc\u40bc;\u6155;\u6159;\u615b\u01b3\u2034\0\u2036;\u6154;\u6156\u02b4\u203e\u2041\0\0\u2043\u803b\xbe\u40be;\u6157;\u615c5;\u6158\u01b6\u204c\0\u204e;\u615a;\u615d8;\u615el;\u6044wn;\u6322cr;\uc000\ud835\udcbb\u0880Eabcdefgijlnorstv\u2082\u2089\u209f\u20a5\u20b0\u20b4\u20f0\u20f5\u20fa\u20ff\u2103\u2112\u2138\u0317\u213e\u2152\u219e\u0100;l\u064d\u2087;\u6a8c\u0180cmp\u2090\u2095\u209dute;\u41f5ma\u0100;d\u209c\u1cda\u43b3;\u6a86reve;\u411f\u0100iy\u20aa\u20aerc;\u411d;\u4433ot;\u4121\u0200;lqs\u063e\u0642\u20bd\u20c9\u0180;qs\u063e\u064c\u20c4lan\xf4\u0665\u0200;cdl\u0665\u20d2\u20d5\u20e5c;\u6aa9ot\u0100;o\u20dc\u20dd\u6a80\u0100;l\u20e2\u20e3\u6a82;\u6a84\u0100;e\u20ea\u20ed\uc000\u22db\ufe00s;\u6a94r;\uc000\ud835\udd24\u0100;g\u0673\u061bmel;\u6137cy;\u4453\u0200;Eaj\u065a\u210c\u210e\u2110;\u6a92;\u6aa5;\u6aa4\u0200Eaes\u211b\u211d\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6a8arox\xbb\u2124\u0100;q\u212e\u212f\u6a88\u0100;q\u212e\u211bim;\u62e7pf;\uc000\ud835\udd58\u0100ci\u2143\u2146r;\u610am\u0180;el\u066b\u214e\u2150;\u6a8e;\u6a90\u8300>;cdlqr\u05ee\u2160\u216a\u216e\u2173\u2179\u0100ci\u2165\u2167;\u6aa7r;\u6a7aot;\u62d7Par;\u6995uest;\u6a7c\u0280adels\u2184\u216a\u2190\u0656\u219b\u01f0\u2189\0\u218epro\xf8\u209er;\u6978q\u0100lq\u063f\u2196les\xf3\u2088i\xed\u066b\u0100en\u21a3\u21adrtneqq;\uc000\u2269\ufe00\xc5\u21aa\u0500Aabcefkosy\u21c4\u21c7\u21f1\u21f5\u21fa\u2218\u221d\u222f\u2268\u227dr\xf2\u03a0\u0200ilmr\u21d0\u21d4\u21d7\u21dbrs\xf0\u1484f\xbb\u2024il\xf4\u06a9\u0100dr\u21e0\u21e4cy;\u444a\u0180;cw\u08f4\u21eb\u21efir;\u6948;\u61adar;\u610firc;\u4125\u0180alr\u2201\u220e\u2213rts\u0100;u\u2209\u220a\u6665it\xbb\u220alip;\u6026con;\u62b9r;\uc000\ud835\udd25s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223a\u223e\u2243\u225e\u2263rr;\u61fftht;\u623bk\u0100lr\u2249\u2253eftarrow;\u61a9ightarrow;\u61aaf;\uc000\ud835\udd59bar;\u6015\u0180clt\u226f\u2274\u2278r;\uc000\ud835\udcbdas\xe8\u21f4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xbb\u1c5b\u0ae1\u22a3\0\u22aa\0\u22b8\u22c5\u22ce\0\u22d5\u22f3\0\0\u22f8\u2322\u2367\u2362\u237f\0\u2386\u23aa\u23b4cute\u803b\xed\u40ed\u0180;iy\u0771\u22b0\u22b5rc\u803b\xee\u40ee;\u4438\u0100cx\u22bc\u22bfy;\u4435cl\u803b\xa1\u40a1\u0100fr\u039f\u22c9;\uc000\ud835\udd26rave\u803b\xec\u40ec\u0200;ino\u073e\u22dd\u22e9\u22ee\u0100in\u22e2\u22e6nt;\u6a0ct;\u622dfin;\u69dcta;\u6129lig;\u4133\u0180aop\u22fe\u231a\u231d\u0180cgt\u2305\u2308\u2317r;\u412b\u0180elp\u071f\u230f\u2313in\xe5\u078ear\xf4\u0720h;\u4131f;\u62b7ed;\u41b5\u0280;cfot\u04f4\u232c\u2331\u233d\u2341are;\u6105in\u0100;t\u2338\u2339\u621eie;\u69dddo\xf4\u2319\u0280;celp\u0757\u234c\u2350\u235b\u2361al;\u62ba\u0100gr\u2355\u2359er\xf3\u1563\xe3\u234darhk;\u6a17rod;\u6a3c\u0200cgpt\u236f\u2372\u2376\u237by;\u4451on;\u412ff;\uc000\ud835\udd5aa;\u43b9uest\u803b\xbf\u40bf\u0100ci\u238a\u238fr;\uc000\ud835\udcben\u0280;Edsv\u04f4\u239b\u239d\u23a1\u04f3;\u62f9ot;\u62f5\u0100;v\u23a6\u23a7\u62f4;\u62f3\u0100;i\u0777\u23aelde;\u4129\u01eb\u23b8\0\u23bccy;\u4456l\u803b\xef\u40ef\u0300cfmosu\u23cc\u23d7\u23dc\u23e1\u23e7\u23f5\u0100iy\u23d1\u23d5rc;\u4135;\u4439r;\uc000\ud835\udd27ath;\u4237pf;\uc000\ud835\udd5b\u01e3\u23ec\0\u23f1r;\uc000\ud835\udcbfrcy;\u4458kcy;\u4454\u0400acfghjos\u240b\u2416\u2422\u2427\u242d\u2431\u2435\u243bppa\u0100;v\u2413\u2414\u43ba;\u43f0\u0100ey\u241b\u2420dil;\u4137;\u443ar;\uc000\ud835\udd28reen;\u4138cy;\u4445cy;\u445cpf;\uc000\ud835\udd5ccr;\uc000\ud835\udcc0\u0b80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248d\u2491\u250e\u253d\u255a\u2580\u264e\u265e\u2665\u2679\u267d\u269a\u26b2\u26d8\u275d\u2768\u278b\u27c0\u2801\u2812\u0180art\u2477\u247a\u247cr\xf2\u09c6\xf2\u0395ail;\u691barr;\u690e\u0100;g\u0994\u248b;\u6a8bar;\u6962\u0963\u24a5\0\u24aa\0\u24b1\0\0\0\0\0\u24b5\u24ba\0\u24c6\u24c8\u24cd\0\u24f9ute;\u413amptyv;\u69b4ra\xee\u084cbda;\u43bbg\u0180;dl\u088e\u24c1\u24c3;\u6991\xe5\u088e;\u6a85uo\u803b\xab\u40abr\u0400;bfhlpst\u0899\u24de\u24e6\u24e9\u24eb\u24ee\u24f1\u24f5\u0100;f\u089d\u24e3s;\u691fs;\u691d\xeb\u2252p;\u61abl;\u6939im;\u6973l;\u61a2\u0180;ae\u24ff\u2500\u2504\u6aabil;\u6919\u0100;s\u2509\u250a\u6aad;\uc000\u2aad\ufe00\u0180abr\u2515\u2519\u251drr;\u690crk;\u6772\u0100ak\u2522\u252cc\u0100ek\u2528\u252a;\u407b;\u405b\u0100es\u2531\u2533;\u698bl\u0100du\u2539\u253b;\u698f;\u698d\u0200aeuy\u2546\u254b\u2556\u2558ron;\u413e\u0100di\u2550\u2554il;\u413c\xec\u08b0\xe2\u2529;\u443b\u0200cqrs\u2563\u2566\u256d\u257da;\u6936uo\u0100;r\u0e19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694bh;\u61b2\u0280;fgqs\u258b\u258c\u0989\u25f3\u25ff\u6264t\u0280ahlrt\u2598\u25a4\u25b7\u25c2\u25e8rrow\u0100;t\u0899\u25a1a\xe9\u24f6arpoon\u0100du\u25af\u25b4own\xbb\u045ap\xbb\u0966eftarrows;\u61c7ight\u0180ahs\u25cd\u25d6\u25derrow\u0100;s\u08f4\u08a7arpoon\xf3\u0f98quigarro\xf7\u21f0hreetimes;\u62cb\u0180;qs\u258b\u0993\u25falan\xf4\u09ac\u0280;cdgs\u09ac\u260a\u260d\u261d\u2628c;\u6aa8ot\u0100;o\u2614\u2615\u6a7f\u0100;r\u261a\u261b\u6a81;\u6a83\u0100;e\u2622\u2625\uc000\u22da\ufe00s;\u6a93\u0280adegs\u2633\u2639\u263d\u2649\u264bppro\xf8\u24c6ot;\u62d6q\u0100gq\u2643\u2645\xf4\u0989gt\xf2\u248c\xf4\u099bi\xed\u09b2\u0180ilr\u2655\u08e1\u265asht;\u697c;\uc000\ud835\udd29\u0100;E\u099c\u2663;\u6a91\u0161\u2669\u2676r\u0100du\u25b2\u266e\u0100;l\u0965\u2673;\u696alk;\u6584cy;\u4459\u0280;acht\u0a48\u2688\u268b\u2691\u2696r\xf2\u25c1orne\xf2\u1d08ard;\u696bri;\u65fa\u0100io\u269f\u26a4dot;\u4140ust\u0100;a\u26ac\u26ad\u63b0che\xbb\u26ad\u0200Eaes\u26bb\u26bd\u26c9\u26d4;\u6268p\u0100;p\u26c3\u26c4\u6a89rox\xbb\u26c4\u0100;q\u26ce\u26cf\u6a87\u0100;q\u26ce\u26bbim;\u62e6\u0400abnoptwz\u26e9\u26f4\u26f7\u271a\u272f\u2741\u2747\u2750\u0100nr\u26ee\u26f1g;\u67ecr;\u61fdr\xeb\u08c1g\u0180lmr\u26ff\u270d\u2714eft\u0100ar\u09e6\u2707ight\xe1\u09f2apsto;\u67fcight\xe1\u09fdparrow\u0100lr\u2725\u2729ef\xf4\u24edight;\u61ac\u0180afl\u2736\u2739\u273dr;\u6985;\uc000\ud835\udd5dus;\u6a2dimes;\u6a34\u0161\u274b\u274fst;\u6217\xe1\u134e\u0180;ef\u2757\u2758\u1800\u65cange\xbb\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277c\u2785\u2787r\xf2\u08a8orne\xf2\u1d8car\u0100;d\u0f98\u2783;\u696d;\u600eri;\u62bf\u0300achiqt\u2798\u279d\u0a40\u27a2\u27ae\u27bbquo;\u6039r;\uc000\ud835\udcc1m\u0180;eg\u09b2\u27aa\u27ac;\u6a8d;\u6a8f\u0100bu\u252a\u27b3o\u0100;r\u0e1f\u27b9;\u601arok;\u4142\u8400<;cdhilqr\u082b\u27d2\u2639\u27dc\u27e0\u27e5\u27ea\u27f0\u0100ci\u27d7\u27d9;\u6aa6r;\u6a79re\xe5\u25f2mes;\u62c9arr;\u6976uest;\u6a7b\u0100Pi\u27f5\u27f9ar;\u6996\u0180;ef\u2800\u092d\u181b\u65c3r\u0100du\u2807\u280dshar;\u694ahar;\u6966\u0100en\u2817\u2821rtneqq;\uc000\u2268\ufe00\xc5\u281e\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288e\u2893\u28a0\u28a5\u28a8\u28da\u28e2\u28e4\u0a83\u28f3\u2902Dot;\u623a\u0200clpr\u284e\u2852\u2863\u287dr\u803b\xaf\u40af\u0100et\u2857\u2859;\u6642\u0100;e\u285e\u285f\u6720se\xbb\u285f\u0100;s\u103b\u2868to\u0200;dlu\u103b\u2873\u2877\u287bow\xee\u048cef\xf4\u090f\xf0\u13d1ker;\u65ae\u0100oy\u2887\u288cmma;\u6a29;\u443cash;\u6014asuredangle\xbb\u1626r;\uc000\ud835\udd2ao;\u6127\u0180cdn\u28af\u28b4\u28c9ro\u803b\xb5\u40b5\u0200;acd\u1464\u28bd\u28c0\u28c4s\xf4\u16a7ir;\u6af0ot\u80bb\xb7\u01b5us\u0180;bd\u28d2\u1903\u28d3\u6212\u0100;u\u1d3c\u28d8;\u6a2a\u0163\u28de\u28e1p;\u6adb\xf2\u2212\xf0\u0a81\u0100dp\u28e9\u28eeels;\u62a7f;\uc000\ud835\udd5e\u0100ct\u28f8\u28fdr;\uc000\ud835\udcc2pos\xbb\u159d\u0180;lm\u2909\u290a\u290d\u43bctimap;\u62b8\u0c00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297e\u2989\u2998\u29da\u29e9\u2a15\u2a1a\u2a58\u2a5d\u2a83\u2a95\u2aa4\u2aa8\u2b04\u2b07\u2b44\u2b7f\u2bae\u2c34\u2c67\u2c7c\u2ce9\u0100gt\u2947\u294b;\uc000\u22d9\u0338\u0100;v\u2950\u0bcf\uc000\u226b\u20d2\u0180elt\u295a\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61cdightarrow;\u61ce;\uc000\u22d8\u0338\u0100;v\u297b\u0c47\uc000\u226a\u20d2ightarrow;\u61cf\u0100Dd\u298e\u2993ash;\u62afash;\u62ae\u0280bcnpt\u29a3\u29a7\u29ac\u29b1\u29ccla\xbb\u02deute;\u4144g;\uc000\u2220\u20d2\u0280;Eiop\u0d84\u29bc\u29c0\u29c5\u29c8;\uc000\u2a70\u0338d;\uc000\u224b\u0338s;\u4149ro\xf8\u0d84ur\u0100;a\u29d3\u29d4\u666el\u0100;s\u29d3\u0b38\u01f3\u29df\0\u29e3p\u80bb\xa0\u0b37mp\u0100;e\u0bf9\u0c00\u0280aeouy\u29f4\u29fe\u2a03\u2a10\u2a13\u01f0\u29f9\0\u29fb;\u6a43on;\u4148dil;\u4146ng\u0100;d\u0d7e\u2a0aot;\uc000\u2a6d\u0338p;\u6a42;\u443dash;\u6013\u0380;Aadqsx\u0b92\u2a29\u2a2d\u2a3b\u2a41\u2a45\u2a50rr;\u61d7r\u0100hr\u2a33\u2a36k;\u6924\u0100;o\u13f2\u13f0ot;\uc000\u2250\u0338ui\xf6\u0b63\u0100ei\u2a4a\u2a4ear;\u6928\xed\u0b98ist\u0100;s\u0ba0\u0b9fr;\uc000\ud835\udd2b\u0200Eest\u0bc5\u2a66\u2a79\u2a7c\u0180;qs\u0bbc\u2a6d\u0be1\u0180;qs\u0bbc\u0bc5\u2a74lan\xf4\u0be2i\xed\u0bea\u0100;r\u0bb6\u2a81\xbb\u0bb7\u0180Aap\u2a8a\u2a8d\u2a91r\xf2\u2971rr;\u61aear;\u6af2\u0180;sv\u0f8d\u2a9c\u0f8c\u0100;d\u2aa1\u2aa2\u62fc;\u62facy;\u445a\u0380AEadest\u2ab7\u2aba\u2abe\u2ac2\u2ac5\u2af6\u2af9r\xf2\u2966;\uc000\u2266\u0338rr;\u619ar;\u6025\u0200;fqs\u0c3b\u2ace\u2ae3\u2aeft\u0100ar\u2ad4\u2ad9rro\xf7\u2ac1ightarro\xf7\u2a90\u0180;qs\u0c3b\u2aba\u2aealan\xf4\u0c55\u0100;s\u0c55\u2af4\xbb\u0c36i\xed\u0c5d\u0100;r\u0c35\u2afei\u0100;e\u0c1a\u0c25i\xe4\u0d90\u0100pt\u2b0c\u2b11f;\uc000\ud835\udd5f\u8180\xac;in\u2b19\u2b1a\u2b36\u40acn\u0200;Edv\u0b89\u2b24\u2b28\u2b2e;\uc000\u22f9\u0338ot;\uc000\u22f5\u0338\u01e1\u0b89\u2b33\u2b35;\u62f7;\u62f6i\u0100;v\u0cb8\u2b3c\u01e1\u0cb8\u2b41\u2b43;\u62fe;\u62fd\u0180aor\u2b4b\u2b63\u2b69r\u0200;ast\u0b7b\u2b55\u2b5a\u2b5flle\xec\u0b7bl;\uc000\u2afd\u20e5;\uc000\u2202\u0338lint;\u6a14\u0180;ce\u0c92\u2b70\u2b73u\xe5\u0ca5\u0100;c\u0c98\u2b78\u0100;e\u0c92\u2b7d\xf1\u0c98\u0200Aait\u2b88\u2b8b\u2b9d\u2ba7r\xf2\u2988rr\u0180;cw\u2b94\u2b95\u2b99\u619b;\uc000\u2933\u0338;\uc000\u219d\u0338ghtarrow\xbb\u2b95ri\u0100;e\u0ccb\u0cd6\u0380chimpqu\u2bbd\u2bcd\u2bd9\u2b04\u0b78\u2be4\u2bef\u0200;cer\u0d32\u2bc6\u0d37\u2bc9u\xe5\u0d45;\uc000\ud835\udcc3ort\u026d\u2b05\0\0\u2bd6ar\xe1\u2b56m\u0100;e\u0d6e\u2bdf\u0100;q\u0d74\u0d73su\u0100bp\u2beb\u2bed\xe5\u0cf8\xe5\u0d0b\u0180bcp\u2bf6\u2c11\u2c19\u0200;Ees\u2bff\u2c00\u0d22\u2c04\u6284;\uc000\u2ac5\u0338et\u0100;e\u0d1b\u2c0bq\u0100;q\u0d23\u2c00c\u0100;e\u0d32\u2c17\xf1\u0d38\u0200;Ees\u2c22\u2c23\u0d5f\u2c27\u6285;\uc000\u2ac6\u0338et\u0100;e\u0d58\u2c2eq\u0100;q\u0d60\u2c23\u0200gilr\u2c3d\u2c3f\u2c45\u2c47\xec\u0bd7lde\u803b\xf1\u40f1\xe7\u0c43iangle\u0100lr\u2c52\u2c5ceft\u0100;e\u0c1a\u2c5a\xf1\u0c26ight\u0100;e\u0ccb\u2c65\xf1\u0cd7\u0100;m\u2c6c\u2c6d\u43bd\u0180;es\u2c74\u2c75\u2c79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2c8f\u2c94\u2c99\u2c9e\u2ca3\u2cb0\u2cb6\u2cd3\u2ce3ash;\u62adarr;\u6904p;\uc000\u224d\u20d2ash;\u62ac\u0100et\u2ca8\u2cac;\uc000\u2265\u20d2;\uc000>\u20d2nfin;\u69de\u0180Aet\u2cbd\u2cc1\u2cc5rr;\u6902;\uc000\u2264\u20d2\u0100;r\u2cca\u2ccd\uc000<\u20d2ie;\uc000\u22b4\u20d2\u0100At\u2cd8\u2cdcrr;\u6903rie;\uc000\u22b5\u20d2im;\uc000\u223c\u20d2\u0180Aan\u2cf0\u2cf4\u2d02rr;\u61d6r\u0100hr\u2cfa\u2cfdk;\u6923\u0100;o\u13e7\u13e5ear;\u6927\u1253\u1a95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2d2d\0\u2d38\u2d48\u2d60\u2d65\u2d72\u2d84\u1b07\0\0\u2d8d\u2dab\0\u2dc8\u2dce\0\u2ddc\u2e19\u2e2b\u2e3e\u2e43\u0100cs\u2d31\u1a97ute\u803b\xf3\u40f3\u0100iy\u2d3c\u2d45r\u0100;c\u1a9e\u2d42\u803b\xf4\u40f4;\u443e\u0280abios\u1aa0\u2d52\u2d57\u01c8\u2d5alac;\u4151v;\u6a38old;\u69bclig;\u4153\u0100cr\u2d69\u2d6dir;\u69bf;\uc000\ud835\udd2c\u036f\u2d79\0\0\u2d7c\0\u2d82n;\u42dbave\u803b\xf2\u40f2;\u69c1\u0100bm\u2d88\u0df4ar;\u69b5\u0200acit\u2d95\u2d98\u2da5\u2da8r\xf2\u1a80\u0100ir\u2d9d\u2da0r;\u69beoss;\u69bbn\xe5\u0e52;\u69c0\u0180aei\u2db1\u2db5\u2db9cr;\u414dga;\u43c9\u0180cdn\u2dc0\u2dc5\u01cdron;\u43bf;\u69b6pf;\uc000\ud835\udd60\u0180ael\u2dd4\u2dd7\u01d2r;\u69b7rp;\u69b9\u0380;adiosv\u2dea\u2deb\u2dee\u2e08\u2e0d\u2e10\u2e16\u6228r\xf2\u1a86\u0200;efm\u2df7\u2df8\u2e02\u2e05\u6a5dr\u0100;o\u2dfe\u2dff\u6134f\xbb\u2dff\u803b\xaa\u40aa\u803b\xba\u40bagof;\u62b6r;\u6a56lope;\u6a57;\u6a5b\u0180clo\u2e1f\u2e21\u2e27\xf2\u2e01ash\u803b\xf8\u40f8l;\u6298i\u016c\u2e2f\u2e34de\u803b\xf5\u40f5es\u0100;a\u01db\u2e3as;\u6a36ml\u803b\xf6\u40f6bar;\u633d\u0ae1\u2e5e\0\u2e7d\0\u2e80\u2e9d\0\u2ea2\u2eb9\0\0\u2ecb\u0e9c\0\u2f13\0\0\u2f2b\u2fbc\0\u2fc8r\u0200;ast\u0403\u2e67\u2e72\u0e85\u8100\xb6;l\u2e6d\u2e6e\u40b6le\xec\u0403\u0269\u2e78\0\0\u2e7bm;\u6af3;\u6afdy;\u443fr\u0280cimpt\u2e8b\u2e8f\u2e93\u1865\u2e97nt;\u4025od;\u402eil;\u6030enk;\u6031r;\uc000\ud835\udd2d\u0180imo\u2ea8\u2eb0\u2eb4\u0100;v\u2ead\u2eae\u43c6;\u43d5ma\xf4\u0a76ne;\u660e\u0180;tv\u2ebf\u2ec0\u2ec8\u43c0chfork\xbb\u1ffd;\u43d6\u0100au\u2ecf\u2edfn\u0100ck\u2ed5\u2eddk\u0100;h\u21f4\u2edb;\u610e\xf6\u21f4s\u0480;abcdemst\u2ef3\u2ef4\u1908\u2ef9\u2efd\u2f04\u2f06\u2f0a\u2f0e\u402bcir;\u6a23ir;\u6a22\u0100ou\u1d40\u2f02;\u6a25;\u6a72n\u80bb\xb1\u0e9dim;\u6a26wo;\u6a27\u0180ipu\u2f19\u2f20\u2f25ntint;\u6a15f;\uc000\ud835\udd61nd\u803b\xa3\u40a3\u0500;Eaceinosu\u0ec8\u2f3f\u2f41\u2f44\u2f47\u2f81\u2f89\u2f92\u2f7e\u2fb6;\u6ab3p;\u6ab7u\xe5\u0ed9\u0100;c\u0ece\u2f4c\u0300;acens\u0ec8\u2f59\u2f5f\u2f66\u2f68\u2f7eppro\xf8\u2f43urlye\xf1\u0ed9\xf1\u0ece\u0180aes\u2f6f\u2f76\u2f7approx;\u6ab9qq;\u6ab5im;\u62e8i\xed\u0edfme\u0100;s\u2f88\u0eae\u6032\u0180Eas\u2f78\u2f90\u2f7a\xf0\u2f75\u0180dfp\u0eec\u2f99\u2faf\u0180als\u2fa0\u2fa5\u2faalar;\u632eine;\u6312urf;\u6313\u0100;t\u0efb\u2fb4\xef\u0efbrel;\u62b0\u0100ci\u2fc0\u2fc5r;\uc000\ud835\udcc5;\u43c8ncsp;\u6008\u0300fiopsu\u2fda\u22e2\u2fdf\u2fe5\u2feb\u2ff1r;\uc000\ud835\udd2epf;\uc000\ud835\udd62rime;\u6057cr;\uc000\ud835\udcc6\u0180aeo\u2ff8\u3009\u3013t\u0100ei\u2ffe\u3005rnion\xf3\u06b0nt;\u6a16st\u0100;e\u3010\u3011\u403f\xf1\u1f19\xf4\u0f14\u0a80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30e0\u310e\u312b\u3147\u3162\u3172\u318e\u3206\u3215\u3224\u3229\u3258\u326e\u3272\u3290\u32b0\u32b7\u0180art\u3047\u304a\u304cr\xf2\u10b3\xf2\u03ddail;\u691car\xf2\u1c65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307f\u308f\u3094\u30cc\u0100eu\u306d\u3071;\uc000\u223d\u0331te;\u4155i\xe3\u116emptyv;\u69b3g\u0200;del\u0fd1\u3089\u308b\u308d;\u6992;\u69a5\xe5\u0fd1uo\u803b\xbb\u40bbr\u0580;abcfhlpstw\u0fdc\u30ac\u30af\u30b7\u30b9\u30bc\u30be\u30c0\u30c3\u30c7\u30cap;\u6975\u0100;f\u0fe0\u30b4s;\u6920;\u6933s;\u691e\xeb\u225d\xf0\u272el;\u6945im;\u6974l;\u61a3;\u619d\u0100ai\u30d1\u30d5il;\u691ao\u0100;n\u30db\u30dc\u6236al\xf3\u0f1e\u0180abr\u30e7\u30ea\u30eer\xf2\u17e5rk;\u6773\u0100ak\u30f3\u30fdc\u0100ek\u30f9\u30fb;\u407d;\u405d\u0100es\u3102\u3104;\u698cl\u0100du\u310a\u310c;\u698e;\u6990\u0200aeuy\u3117\u311c\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xec\u0ff2\xe2\u30fa;\u4440\u0200clqs\u3134\u3137\u313d\u3144a;\u6937dhar;\u6969uo\u0100;r\u020e\u020dh;\u61b3\u0180acg\u314e\u315f\u0f44l\u0200;ips\u0f78\u3158\u315b\u109cn\xe5\u10bbar\xf4\u0fa9t;\u65ad\u0180ilr\u3169\u1023\u316esht;\u697d;\uc000\ud835\udd2f\u0100ao\u3177\u3186r\u0100du\u317d\u317f\xbb\u047b\u0100;l\u1091\u3184;\u696c\u0100;v\u318b\u318c\u43c1;\u43f1\u0180gns\u3195\u31f9\u31fcht\u0300ahlrst\u31a4\u31b0\u31c2\u31d8\u31e4\u31eerrow\u0100;t\u0fdc\u31ada\xe9\u30c8arpoon\u0100du\u31bb\u31bfow\xee\u317ep\xbb\u1092eft\u0100ah\u31ca\u31d0rrow\xf3\u0feaarpoon\xf3\u0551ightarrows;\u61c9quigarro\xf7\u30cbhreetimes;\u62ccg;\u42daingdotse\xf1\u1f32\u0180ahm\u320d\u3210\u3213r\xf2\u0feaa\xf2\u0551;\u600foust\u0100;a\u321e\u321f\u63b1che\xbb\u321fmid;\u6aee\u0200abpt\u3232\u323d\u3240\u3252\u0100nr\u3237\u323ag;\u67edr;\u61fer\xeb\u1003\u0180afl\u3247\u324a\u324er;\u6986;\uc000\ud835\udd63us;\u6a2eimes;\u6a35\u0100ap\u325d\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6a12ar\xf2\u31e3\u0200achq\u327b\u3280\u10bc\u3285quo;\u603ar;\uc000\ud835\udcc7\u0100bu\u30fb\u328ao\u0100;r\u0214\u0213\u0180hir\u3297\u329b\u32a0re\xe5\u31f8mes;\u62cai\u0200;efl\u32aa\u1059\u1821\u32ab\u65b9tri;\u69celuhar;\u6968;\u611e\u0d61\u32d5\u32db\u32df\u332c\u3338\u3371\0\u337a\u33a4\0\0\u33ec\u33f0\0\u3428\u3448\u345a\u34ad\u34b1\u34ca\u34f1\0\u3616\0\0\u3633cute;\u415bqu\xef\u27ba\u0500;Eaceinpsy\u11ed\u32f3\u32f5\u32ff\u3302\u330b\u330f\u331f\u3326\u3329;\u6ab4\u01f0\u32fa\0\u32fc;\u6ab8on;\u4161u\xe5\u11fe\u0100;d\u11f3\u3307il;\u415frc;\u415d\u0180Eas\u3316\u3318\u331b;\u6ab6p;\u6abaim;\u62e9olint;\u6a13i\xed\u1204;\u4441ot\u0180;be\u3334\u1d47\u3335\u62c5;\u6a66\u0380Aacmstx\u3346\u334a\u3357\u335b\u335e\u3363\u336drr;\u61d8r\u0100hr\u3350\u3352\xeb\u2228\u0100;o\u0a36\u0a34t\u803b\xa7\u40a7i;\u403bwar;\u6929m\u0100in\u3369\xf0nu\xf3\xf1t;\u6736r\u0100;o\u3376\u2055\uc000\ud835\udd30\u0200acoy\u3382\u3386\u3391\u33a0rp;\u666f\u0100hy\u338b\u338fcy;\u4449;\u4448rt\u026d\u3399\0\0\u339ci\xe4\u1464ara\xec\u2e6f\u803b\xad\u40ad\u0100gm\u33a8\u33b4ma\u0180;fv\u33b1\u33b2\u33b2\u43c3;\u43c2\u0400;deglnpr\u12ab\u33c5\u33c9\u33ce\u33d6\u33de\u33e1\u33e6ot;\u6a6a\u0100;q\u12b1\u12b0\u0100;E\u33d3\u33d4\u6a9e;\u6aa0\u0100;E\u33db\u33dc\u6a9d;\u6a9fe;\u6246lus;\u6a24arr;\u6972ar\xf2\u113d\u0200aeit\u33f8\u3408\u340f\u3417\u0100ls\u33fd\u3404lsetm\xe9\u336ahp;\u6a33parsl;\u69e4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341c\u341d\u6aaa\u0100;s\u3422\u3423\u6aac;\uc000\u2aac\ufe00\u0180flp\u342e\u3433\u3442tcy;\u444c\u0100;b\u3438\u3439\u402f\u0100;a\u343e\u343f\u69c4r;\u633ff;\uc000\ud835\udd64a\u0100dr\u344d\u0402es\u0100;u\u3454\u3455\u6660it\xbb\u3455\u0180csu\u3460\u3479\u349f\u0100au\u3465\u346fp\u0100;s\u1188\u346b;\uc000\u2293\ufe00p\u0100;s\u11b4\u3475;\uc000\u2294\ufe00u\u0100bp\u347f\u348f\u0180;es\u1197\u119c\u3486et\u0100;e\u1197\u348d\xf1\u119d\u0180;es\u11a8\u11ad\u3496et\u0100;e\u11a8\u349d\xf1\u11ae\u0180;af\u117b\u34a6\u05b0r\u0165\u34ab\u05b1\xbb\u117car\xf2\u1148\u0200cemt\u34b9\u34be\u34c2\u34c5r;\uc000\ud835\udcc8tm\xee\xf1i\xec\u3415ar\xe6\u11be\u0100ar\u34ce\u34d5r\u0100;f\u34d4\u17bf\u6606\u0100an\u34da\u34edight\u0100ep\u34e3\u34eapsilo\xee\u1ee0h\xe9\u2eafs\xbb\u2852\u0280bcmnp\u34fb\u355e\u1209\u358b\u358e\u0480;Edemnprs\u350e\u350f\u3511\u3515\u351e\u3523\u352c\u3531\u3536\u6282;\u6ac5ot;\u6abd\u0100;d\u11da\u351aot;\u6ac3ult;\u6ac1\u0100Ee\u3528\u352a;\u6acb;\u628alus;\u6abfarr;\u6979\u0180eiu\u353d\u3552\u3555t\u0180;en\u350e\u3545\u354bq\u0100;q\u11da\u350feq\u0100;q\u352b\u3528m;\u6ac7\u0100bp\u355a\u355c;\u6ad5;\u6ad3c\u0300;acens\u11ed\u356c\u3572\u3579\u357b\u3326ppro\xf8\u32faurlye\xf1\u11fe\xf1\u11f3\u0180aes\u3582\u3588\u331bppro\xf8\u331aq\xf1\u3317g;\u666a\u0680123;Edehlmnps\u35a9\u35ac\u35af\u121c\u35b2\u35b4\u35c0\u35c9\u35d5\u35da\u35df\u35e8\u35ed\u803b\xb9\u40b9\u803b\xb2\u40b2\u803b\xb3\u40b3;\u6ac6\u0100os\u35b9\u35bct;\u6abeub;\u6ad8\u0100;d\u1222\u35c5ot;\u6ac4s\u0100ou\u35cf\u35d2l;\u67c9b;\u6ad7arr;\u697bult;\u6ac2\u0100Ee\u35e4\u35e6;\u6acc;\u628blus;\u6ac0\u0180eiu\u35f4\u3609\u360ct\u0180;en\u121c\u35fc\u3602q\u0100;q\u1222\u35b2eq\u0100;q\u35e7\u35e4m;\u6ac8\u0100bp\u3611\u3613;\u6ad4;\u6ad6\u0180Aan\u361c\u3620\u362drr;\u61d9r\u0100hr\u3626\u3628\xeb\u222e\u0100;o\u0a2b\u0a29war;\u692alig\u803b\xdf\u40df\u0be1\u3651\u365d\u3660\u12ce\u3673\u3679\0\u367e\u36c2\0\0\0\0\0\u36db\u3703\0\u3709\u376c\0\0\0\u3787\u0272\u3656\0\0\u365bget;\u6316;\u43c4r\xeb\u0e5f\u0180aey\u3666\u366b\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uc000\ud835\udd31\u0200eiko\u3686\u369d\u36b5\u36bc\u01f2\u368b\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369b\u43b8ym;\u43d1\u0100cn\u36a2\u36b2k\u0100as\u36a8\u36aeppro\xf8\u12c1im\xbb\u12acs\xf0\u129e\u0100as\u36ba\u36ae\xf0\u12c1rn\u803b\xfe\u40fe\u01ec\u031f\u36c6\u22e7es\u8180\xd7;bd\u36cf\u36d0\u36d8\u40d7\u0100;a\u190f\u36d5r;\u6a31;\u6a30\u0180eps\u36e1\u36e3\u3700\xe1\u2a4d\u0200;bcf\u0486\u36ec\u36f0\u36f4ot;\u6336ir;\u6af1\u0100;o\u36f9\u36fc\uc000\ud835\udd65rk;\u6ada\xe1\u3362rime;\u6034\u0180aip\u370f\u3712\u3764d\xe5\u1248\u0380adempst\u3721\u374d\u3740\u3751\u3757\u375c\u375fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65b5own\xbb\u1dbbeft\u0100;e\u2800\u373e\xf1\u092e;\u625cight\u0100;e\u32aa\u374b\xf1\u105aot;\u65ecinus;\u6a3alus;\u6a39b;\u69cdime;\u6a3bezium;\u63e2\u0180cht\u3772\u377d\u3781\u0100ry\u3777\u377b;\uc000\ud835\udcc9;\u4446cy;\u445brok;\u4167\u0100io\u378b\u378ex\xf4\u1777head\u0100lr\u3797\u37a0eftarro\xf7\u084fightarrow\xbb\u0f5d\u0900AHabcdfghlmoprstuw\u37d0\u37d3\u37d7\u37e4\u37f0\u37fc\u380e\u381c\u3823\u3834\u3851\u385d\u386b\u38a9\u38cc\u38d2\u38ea\u38f6r\xf2\u03edar;\u6963\u0100cr\u37dc\u37e2ute\u803b\xfa\u40fa\xf2\u1150r\u01e3\u37ea\0\u37edy;\u445eve;\u416d\u0100iy\u37f5\u37farc\u803b\xfb\u40fb;\u4443\u0180abh\u3803\u3806\u380br\xf2\u13adlac;\u4171a\xf2\u13c3\u0100ir\u3813\u3818sht;\u697e;\uc000\ud835\udd32rave\u803b\xf9\u40f9\u0161\u3827\u3831r\u0100lr\u382c\u382e\xbb\u0957\xbb\u1083lk;\u6580\u0100ct\u3839\u384d\u026f\u383f\0\0\u384arn\u0100;e\u3845\u3846\u631cr\xbb\u3846op;\u630fri;\u65f8\u0100al\u3856\u385acr;\u416b\u80bb\xa8\u0349\u0100gp\u3862\u3866on;\u4173f;\uc000\ud835\udd66\u0300adhlsu\u114b\u3878\u387d\u1372\u3891\u38a0own\xe1\u13b3arpoon\u0100lr\u3888\u388cef\xf4\u382digh\xf4\u382fi\u0180;hl\u3899\u389a\u389c\u43c5\xbb\u13faon\xbb\u389aparrows;\u61c8\u0180cit\u38b0\u38c4\u38c8\u026f\u38b6\0\0\u38c1rn\u0100;e\u38bc\u38bd\u631dr\xbb\u38bdop;\u630eng;\u416fri;\u65f9cr;\uc000\ud835\udcca\u0180dir\u38d9\u38dd\u38e2ot;\u62f0lde;\u4169i\u0100;f\u3730\u38e8\xbb\u1813\u0100am\u38ef\u38f2r\xf2\u38a8l\u803b\xfc\u40fcangle;\u69a7\u0780ABDacdeflnoprsz\u391c\u391f\u3929\u392d\u39b5\u39b8\u39bd\u39df\u39e4\u39e8\u39f3\u39f9\u39fd\u3a01\u3a20r\xf2\u03f7ar\u0100;v\u3926\u3927\u6ae8;\u6ae9as\xe8\u03e1\u0100nr\u3932\u3937grt;\u699c\u0380eknprst\u34e3\u3946\u394b\u3952\u395d\u3964\u3996app\xe1\u2415othin\xe7\u1e96\u0180hir\u34eb\u2ec8\u3959op\xf4\u2fb5\u0100;h\u13b7\u3962\xef\u318d\u0100iu\u3969\u396dgm\xe1\u33b3\u0100bp\u3972\u3984setneq\u0100;q\u397d\u3980\uc000\u228a\ufe00;\uc000\u2acb\ufe00setneq\u0100;q\u398f\u3992\uc000\u228b\ufe00;\uc000\u2acc\ufe00\u0100hr\u399b\u399fet\xe1\u369ciangle\u0100lr\u39aa\u39afeft\xbb\u0925ight\xbb\u1051y;\u4432ash\xbb\u1036\u0180elr\u39c4\u39d2\u39d7\u0180;be\u2dea\u39cb\u39cfar;\u62bbq;\u625alip;\u62ee\u0100bt\u39dc\u1468a\xf2\u1469r;\uc000\ud835\udd33tr\xe9\u39aesu\u0100bp\u39ef\u39f1\xbb\u0d1c\xbb\u0d59pf;\uc000\ud835\udd67ro\xf0\u0efbtr\xe9\u39b4\u0100cu\u3a06\u3a0br;\uc000\ud835\udccb\u0100bp\u3a10\u3a18n\u0100Ee\u3980\u3a16\xbb\u397en\u0100Ee\u3992\u3a1e\xbb\u3990igzag;\u699a\u0380cefoprs\u3a36\u3a3b\u3a56\u3a5b\u3a54\u3a61\u3a6airc;\u4175\u0100di\u3a40\u3a51\u0100bg\u3a45\u3a49ar;\u6a5fe\u0100;q\u15fa\u3a4f;\u6259erp;\u6118r;\uc000\ud835\udd34pf;\uc000\ud835\udd68\u0100;e\u1479\u3a66at\xe8\u1479cr;\uc000\ud835\udccc\u0ae3\u178e\u3a87\0\u3a8b\0\u3a90\u3a9b\0\0\u3a9d\u3aa8\u3aab\u3aaf\0\0\u3ac3\u3ace\0\u3ad8\u17dc\u17dftr\xe9\u17d1r;\uc000\ud835\udd35\u0100Aa\u3a94\u3a97r\xf2\u03c3r\xf2\u09f6;\u43be\u0100Aa\u3aa1\u3aa4r\xf2\u03b8r\xf2\u09eba\xf0\u2713is;\u62fb\u0180dpt\u17a4\u3ab5\u3abe\u0100fl\u3aba\u17a9;\uc000\ud835\udd69im\xe5\u17b2\u0100Aa\u3ac7\u3acar\xf2\u03cer\xf2\u0a01\u0100cq\u3ad2\u17b8r;\uc000\ud835\udccd\u0100pt\u17d6\u3adcr\xe9\u17d4\u0400acefiosu\u3af0\u3afd\u3b08\u3b0c\u3b11\u3b15\u3b1b\u3b21c\u0100uy\u3af6\u3afbte\u803b\xfd\u40fd;\u444f\u0100iy\u3b02\u3b06rc;\u4177;\u444bn\u803b\xa5\u40a5r;\uc000\ud835\udd36cy;\u4457pf;\uc000\ud835\udd6acr;\uc000\ud835\udcce\u0100cm\u3b26\u3b29y;\u444el\u803b\xff\u40ff\u0500acdefhiosw\u3b42\u3b48\u3b54\u3b58\u3b64\u3b69\u3b6d\u3b74\u3b7a\u3b80cute;\u417a\u0100ay\u3b4d\u3b52ron;\u417e;\u4437ot;\u417c\u0100et\u3b5d\u3b61tr\xe6\u155fa;\u43b6r;\uc000\ud835\udd37cy;\u4436grarr;\u61ddpf;\uc000\ud835\udd6bcr;\uc000\ud835\udccf\u0100jn\u3b85\u3b87;\u600dj;\u600c"
  723. .split("")
  724. .map((c) => c.charCodeAt(0)));
  725. // Generated using scripts/write-decode-map.ts
  726. var xmlDecodeTree = new Uint16Array(
  727. // prettier-ignore
  728. "\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022"
  729. .split("")
  730. .map((c) => c.charCodeAt(0)));
  731. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  732. var _a$1;
  733. const decodeMap = new Map([
  734. [0, 65533],
  735. // C1 Unicode control character reference replacements
  736. [128, 8364],
  737. [130, 8218],
  738. [131, 402],
  739. [132, 8222],
  740. [133, 8230],
  741. [134, 8224],
  742. [135, 8225],
  743. [136, 710],
  744. [137, 8240],
  745. [138, 352],
  746. [139, 8249],
  747. [140, 338],
  748. [142, 381],
  749. [145, 8216],
  750. [146, 8217],
  751. [147, 8220],
  752. [148, 8221],
  753. [149, 8226],
  754. [150, 8211],
  755. [151, 8212],
  756. [152, 732],
  757. [153, 8482],
  758. [154, 353],
  759. [155, 8250],
  760. [156, 339],
  761. [158, 382],
  762. [159, 376],
  763. ]);
  764. /**
  765. * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
  766. */
  767. const fromCodePoint =
  768. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  769. (_a$1 = String.fromCodePoint) !== null && _a$1 !== void 0 ? _a$1 : function (codePoint) {
  770. let output = "";
  771. if (codePoint > 0xffff) {
  772. codePoint -= 0x10000;
  773. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  774. codePoint = 0xdc00 | (codePoint & 0x3ff);
  775. }
  776. output += String.fromCharCode(codePoint);
  777. return output;
  778. };
  779. /**
  780. * Replace the given code point with a replacement character if it is a
  781. * surrogate or is outside the valid range. Otherwise return the code
  782. * point unchanged.
  783. */
  784. function replaceCodePoint(codePoint) {
  785. var _a;
  786. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  787. return 0xfffd;
  788. }
  789. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  790. }
  791. var CharCodes;
  792. (function (CharCodes) {
  793. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  794. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  795. CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
  796. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  797. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  798. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  799. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  800. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  801. CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
  802. CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
  803. CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
  804. CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
  805. })(CharCodes || (CharCodes = {}));
  806. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  807. const TO_LOWER_BIT = 0b100000;
  808. var BinTrieFlags;
  809. (function (BinTrieFlags) {
  810. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  811. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  812. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  813. })(BinTrieFlags || (BinTrieFlags = {}));
  814. function isNumber$1(code) {
  815. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  816. }
  817. function isHexadecimalCharacter(code) {
  818. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
  819. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
  820. }
  821. function isAsciiAlphaNumeric(code) {
  822. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
  823. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
  824. isNumber$1(code));
  825. }
  826. /**
  827. * Checks if the given character is a valid end character for an entity in an attribute.
  828. *
  829. * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  830. * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  831. */
  832. function isEntityInAttributeInvalidEnd(code) {
  833. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  834. }
  835. var EntityDecoderState;
  836. (function (EntityDecoderState) {
  837. EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
  838. EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
  839. EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
  840. EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
  841. EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
  842. })(EntityDecoderState || (EntityDecoderState = {}));
  843. var DecodingMode;
  844. (function (DecodingMode) {
  845. /** Entities in text nodes that can end with any character. */
  846. DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
  847. /** Only allow entities terminated with a semicolon. */
  848. DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
  849. /** Entities in attributes have limitations on ending characters. */
  850. DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
  851. })(DecodingMode || (DecodingMode = {}));
  852. /**
  853. * Token decoder with support of writing partial entities.
  854. */
  855. class EntityDecoder {
  856. constructor(
  857. /** The tree used to decode entities. */
  858. decodeTree,
  859. /**
  860. * The function that is called when a codepoint is decoded.
  861. *
  862. * For multi-byte named entities, this will be called multiple times,
  863. * with the second codepoint, and the same `consumed` value.
  864. *
  865. * @param codepoint The decoded codepoint.
  866. * @param consumed The number of bytes consumed by the decoder.
  867. */
  868. emitCodePoint,
  869. /** An object that is used to produce errors. */
  870. errors) {
  871. this.decodeTree = decodeTree;
  872. this.emitCodePoint = emitCodePoint;
  873. this.errors = errors;
  874. /** The current state of the decoder. */
  875. this.state = EntityDecoderState.EntityStart;
  876. /** Characters that were consumed while parsing an entity. */
  877. this.consumed = 1;
  878. /**
  879. * The result of the entity.
  880. *
  881. * Either the result index of a numeric entity, or the codepoint of a
  882. * numeric entity.
  883. */
  884. this.result = 0;
  885. /** The current index in the decode tree. */
  886. this.treeIndex = 0;
  887. /** The number of characters that were consumed in excess. */
  888. this.excess = 1;
  889. /** The mode in which the decoder is operating. */
  890. this.decodeMode = DecodingMode.Strict;
  891. }
  892. /** Resets the instance to make it reusable. */
  893. startEntity(decodeMode) {
  894. this.decodeMode = decodeMode;
  895. this.state = EntityDecoderState.EntityStart;
  896. this.result = 0;
  897. this.treeIndex = 0;
  898. this.excess = 1;
  899. this.consumed = 1;
  900. }
  901. /**
  902. * Write an entity to the decoder. This can be called multiple times with partial entities.
  903. * If the entity is incomplete, the decoder will return -1.
  904. *
  905. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  906. * entity is incomplete, and resume when the next string is written.
  907. *
  908. * @param string The string containing the entity (or a continuation of the entity).
  909. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  910. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  911. */
  912. write(str, offset) {
  913. switch (this.state) {
  914. case EntityDecoderState.EntityStart: {
  915. if (str.charCodeAt(offset) === CharCodes.NUM) {
  916. this.state = EntityDecoderState.NumericStart;
  917. this.consumed += 1;
  918. return this.stateNumericStart(str, offset + 1);
  919. }
  920. this.state = EntityDecoderState.NamedEntity;
  921. return this.stateNamedEntity(str, offset);
  922. }
  923. case EntityDecoderState.NumericStart: {
  924. return this.stateNumericStart(str, offset);
  925. }
  926. case EntityDecoderState.NumericDecimal: {
  927. return this.stateNumericDecimal(str, offset);
  928. }
  929. case EntityDecoderState.NumericHex: {
  930. return this.stateNumericHex(str, offset);
  931. }
  932. case EntityDecoderState.NamedEntity: {
  933. return this.stateNamedEntity(str, offset);
  934. }
  935. }
  936. }
  937. /**
  938. * Switches between the numeric decimal and hexadecimal states.
  939. *
  940. * Equivalent to the `Numeric character reference state` in the HTML spec.
  941. *
  942. * @param str The string containing the entity (or a continuation of the entity).
  943. * @param offset The current offset.
  944. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  945. */
  946. stateNumericStart(str, offset) {
  947. if (offset >= str.length) {
  948. return -1;
  949. }
  950. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  951. this.state = EntityDecoderState.NumericHex;
  952. this.consumed += 1;
  953. return this.stateNumericHex(str, offset + 1);
  954. }
  955. this.state = EntityDecoderState.NumericDecimal;
  956. return this.stateNumericDecimal(str, offset);
  957. }
  958. addToNumericResult(str, start, end, base) {
  959. if (start !== end) {
  960. const digitCount = end - start;
  961. this.result =
  962. this.result * Math.pow(base, digitCount) +
  963. parseInt(str.substr(start, digitCount), base);
  964. this.consumed += digitCount;
  965. }
  966. }
  967. /**
  968. * Parses a hexadecimal numeric entity.
  969. *
  970. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  971. *
  972. * @param str The string containing the entity (or a continuation of the entity).
  973. * @param offset The current offset.
  974. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  975. */
  976. stateNumericHex(str, offset) {
  977. const startIdx = offset;
  978. while (offset < str.length) {
  979. const char = str.charCodeAt(offset);
  980. if (isNumber$1(char) || isHexadecimalCharacter(char)) {
  981. offset += 1;
  982. }
  983. else {
  984. this.addToNumericResult(str, startIdx, offset, 16);
  985. return this.emitNumericEntity(char, 3);
  986. }
  987. }
  988. this.addToNumericResult(str, startIdx, offset, 16);
  989. return -1;
  990. }
  991. /**
  992. * Parses a decimal numeric entity.
  993. *
  994. * Equivalent to the `Decimal character reference state` in the HTML spec.
  995. *
  996. * @param str The string containing the entity (or a continuation of the entity).
  997. * @param offset The current offset.
  998. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  999. */
  1000. stateNumericDecimal(str, offset) {
  1001. const startIdx = offset;
  1002. while (offset < str.length) {
  1003. const char = str.charCodeAt(offset);
  1004. if (isNumber$1(char)) {
  1005. offset += 1;
  1006. }
  1007. else {
  1008. this.addToNumericResult(str, startIdx, offset, 10);
  1009. return this.emitNumericEntity(char, 2);
  1010. }
  1011. }
  1012. this.addToNumericResult(str, startIdx, offset, 10);
  1013. return -1;
  1014. }
  1015. /**
  1016. * Validate and emit a numeric entity.
  1017. *
  1018. * Implements the logic from the `Hexademical character reference start
  1019. * state` and `Numeric character reference end state` in the HTML spec.
  1020. *
  1021. * @param lastCp The last code point of the entity. Used to see if the
  1022. * entity was terminated with a semicolon.
  1023. * @param expectedLength The minimum number of characters that should be
  1024. * consumed. Used to validate that at least one digit
  1025. * was consumed.
  1026. * @returns The number of characters that were consumed.
  1027. */
  1028. emitNumericEntity(lastCp, expectedLength) {
  1029. var _a;
  1030. // Ensure we consumed at least one digit.
  1031. if (this.consumed <= expectedLength) {
  1032. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1033. return 0;
  1034. }
  1035. // Figure out if this is a legit end of the entity
  1036. if (lastCp === CharCodes.SEMI) {
  1037. this.consumed += 1;
  1038. }
  1039. else if (this.decodeMode === DecodingMode.Strict) {
  1040. return 0;
  1041. }
  1042. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  1043. if (this.errors) {
  1044. if (lastCp !== CharCodes.SEMI) {
  1045. this.errors.missingSemicolonAfterCharacterReference();
  1046. }
  1047. this.errors.validateNumericCharacterReference(this.result);
  1048. }
  1049. return this.consumed;
  1050. }
  1051. /**
  1052. * Parses a named entity.
  1053. *
  1054. * Equivalent to the `Named character reference state` in the HTML spec.
  1055. *
  1056. * @param str The string containing the entity (or a continuation of the entity).
  1057. * @param offset The current offset.
  1058. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1059. */
  1060. stateNamedEntity(str, offset) {
  1061. const { decodeTree } = this;
  1062. let current = decodeTree[this.treeIndex];
  1063. // The mask is the number of bytes of the value, including the current byte.
  1064. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1065. for (; offset < str.length; offset++, this.excess++) {
  1066. const char = str.charCodeAt(offset);
  1067. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1068. if (this.treeIndex < 0) {
  1069. return this.result === 0 ||
  1070. // If we are parsing an attribute
  1071. (this.decodeMode === DecodingMode.Attribute &&
  1072. // We shouldn't have consumed any characters after the entity,
  1073. (valueLength === 0 ||
  1074. // And there should be no invalid characters.
  1075. isEntityInAttributeInvalidEnd(char)))
  1076. ? 0
  1077. : this.emitNotTerminatedNamedEntity();
  1078. }
  1079. current = decodeTree[this.treeIndex];
  1080. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1081. // If the branch is a value, store it and continue
  1082. if (valueLength !== 0) {
  1083. // If the entity is terminated by a semicolon, we are done.
  1084. if (char === CharCodes.SEMI) {
  1085. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1086. }
  1087. // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
  1088. if (this.decodeMode !== DecodingMode.Strict) {
  1089. this.result = this.treeIndex;
  1090. this.consumed += this.excess;
  1091. this.excess = 0;
  1092. }
  1093. }
  1094. }
  1095. return -1;
  1096. }
  1097. /**
  1098. * Emit a named entity that was not terminated with a semicolon.
  1099. *
  1100. * @returns The number of characters consumed.
  1101. */
  1102. emitNotTerminatedNamedEntity() {
  1103. var _a;
  1104. const { result, decodeTree } = this;
  1105. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1106. this.emitNamedEntityData(result, valueLength, this.consumed);
  1107. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
  1108. return this.consumed;
  1109. }
  1110. /**
  1111. * Emit a named entity.
  1112. *
  1113. * @param result The index of the entity in the decode tree.
  1114. * @param valueLength The number of bytes in the entity.
  1115. * @param consumed The number of characters consumed.
  1116. *
  1117. * @returns The number of characters consumed.
  1118. */
  1119. emitNamedEntityData(result, valueLength, consumed) {
  1120. const { decodeTree } = this;
  1121. this.emitCodePoint(valueLength === 1
  1122. ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
  1123. : decodeTree[result + 1], consumed);
  1124. if (valueLength === 3) {
  1125. // For multi-byte values, we need to emit the second byte.
  1126. this.emitCodePoint(decodeTree[result + 2], consumed);
  1127. }
  1128. return consumed;
  1129. }
  1130. /**
  1131. * Signal to the parser that the end of the input was reached.
  1132. *
  1133. * Remaining data will be emitted and relevant errors will be produced.
  1134. *
  1135. * @returns The number of characters consumed.
  1136. */
  1137. end() {
  1138. var _a;
  1139. switch (this.state) {
  1140. case EntityDecoderState.NamedEntity: {
  1141. // Emit a named entity if we have one.
  1142. return this.result !== 0 &&
  1143. (this.decodeMode !== DecodingMode.Attribute ||
  1144. this.result === this.treeIndex)
  1145. ? this.emitNotTerminatedNamedEntity()
  1146. : 0;
  1147. }
  1148. // Otherwise, emit a numeric entity if we have one.
  1149. case EntityDecoderState.NumericDecimal: {
  1150. return this.emitNumericEntity(0, 2);
  1151. }
  1152. case EntityDecoderState.NumericHex: {
  1153. return this.emitNumericEntity(0, 3);
  1154. }
  1155. case EntityDecoderState.NumericStart: {
  1156. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1157. return 0;
  1158. }
  1159. case EntityDecoderState.EntityStart: {
  1160. // Return 0 if we have no entity.
  1161. return 0;
  1162. }
  1163. }
  1164. }
  1165. }
  1166. /**
  1167. * Creates a function that decodes entities in a string.
  1168. *
  1169. * @param decodeTree The decode tree.
  1170. * @returns A function that decodes entities in a string.
  1171. */
  1172. function getDecoder(decodeTree) {
  1173. let ret = "";
  1174. const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));
  1175. return function decodeWithTrie(str, decodeMode) {
  1176. let lastIndex = 0;
  1177. let offset = 0;
  1178. while ((offset = str.indexOf("&", offset)) >= 0) {
  1179. ret += str.slice(lastIndex, offset);
  1180. decoder.startEntity(decodeMode);
  1181. const len = decoder.write(str,
  1182. // Skip the "&"
  1183. offset + 1);
  1184. if (len < 0) {
  1185. lastIndex = offset + decoder.end();
  1186. break;
  1187. }
  1188. lastIndex = offset + len;
  1189. // If `len` is 0, skip the current `&` and continue.
  1190. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1191. }
  1192. const result = ret + str.slice(lastIndex);
  1193. // Make sure we don't keep a reference to the final string.
  1194. ret = "";
  1195. return result;
  1196. };
  1197. }
  1198. /**
  1199. * Determines the branch of the current node that is taken given the current
  1200. * character. This function is used to traverse the trie.
  1201. *
  1202. * @param decodeTree The trie.
  1203. * @param current The current node.
  1204. * @param nodeIdx The index right after the current node and its value.
  1205. * @param char The current character.
  1206. * @returns The index of the next node, or -1 if no branch is taken.
  1207. */
  1208. function determineBranch(decodeTree, current, nodeIdx, char) {
  1209. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1210. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1211. // Case 1: Single branch encoded in jump offset
  1212. if (branchCount === 0) {
  1213. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1214. }
  1215. // Case 2: Multiple branches encoded in jump table
  1216. if (jumpOffset) {
  1217. const value = char - jumpOffset;
  1218. return value < 0 || value >= branchCount
  1219. ? -1
  1220. : decodeTree[nodeIdx + value] - 1;
  1221. }
  1222. // Case 3: Multiple branches encoded in dictionary
  1223. // Binary search for the character.
  1224. let lo = nodeIdx;
  1225. let hi = lo + branchCount - 1;
  1226. while (lo <= hi) {
  1227. const mid = (lo + hi) >>> 1;
  1228. const midVal = decodeTree[mid];
  1229. if (midVal < char) {
  1230. lo = mid + 1;
  1231. }
  1232. else if (midVal > char) {
  1233. hi = mid - 1;
  1234. }
  1235. else {
  1236. return decodeTree[mid + branchCount];
  1237. }
  1238. }
  1239. return -1;
  1240. }
  1241. const htmlDecoder = getDecoder(htmlDecodeTree);
  1242. getDecoder(xmlDecodeTree);
  1243. /**
  1244. * Decodes an HTML string.
  1245. *
  1246. * @param str The string to decode.
  1247. * @param mode The decoding mode.
  1248. * @returns The decoded string.
  1249. */
  1250. function decodeHTML(str, mode = DecodingMode.Legacy) {
  1251. return htmlDecoder(str, mode);
  1252. }
  1253. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  1254. const defaultDelimitersClose = new Uint8Array([125, 125]);
  1255. function isTagStartChar(c) {
  1256. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  1257. }
  1258. function isWhitespace(c) {
  1259. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  1260. }
  1261. function isEndOfTagSection(c) {
  1262. return c === 47 || c === 62 || isWhitespace(c);
  1263. }
  1264. function toCharCodes(str) {
  1265. const ret = new Uint8Array(str.length);
  1266. for (let i = 0; i < str.length; i++) {
  1267. ret[i] = str.charCodeAt(i);
  1268. }
  1269. return ret;
  1270. }
  1271. const Sequences = {
  1272. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  1273. // CDATA[
  1274. CdataEnd: new Uint8Array([93, 93, 62]),
  1275. // ]]>
  1276. CommentEnd: new Uint8Array([45, 45, 62]),
  1277. // `-->`
  1278. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  1279. // `<\/script`
  1280. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  1281. // `</style`
  1282. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  1283. // `</title`
  1284. TextareaEnd: new Uint8Array([
  1285. 60,
  1286. 47,
  1287. 116,
  1288. 101,
  1289. 120,
  1290. 116,
  1291. 97,
  1292. 114,
  1293. 101,
  1294. 97
  1295. ])
  1296. // `</textarea
  1297. };
  1298. class Tokenizer {
  1299. constructor(stack, cbs) {
  1300. this.stack = stack;
  1301. this.cbs = cbs;
  1302. /** The current state the tokenizer is in. */
  1303. this.state = 1;
  1304. /** The read buffer. */
  1305. this.buffer = "";
  1306. /** The beginning of the section that is currently being read. */
  1307. this.sectionStart = 0;
  1308. /** The index within the buffer that we are currently looking at. */
  1309. this.index = 0;
  1310. /** The start of the last entity. */
  1311. this.entityStart = 0;
  1312. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  1313. this.baseState = 1;
  1314. /** For special parsing behavior inside of script and style tags. */
  1315. this.inRCDATA = false;
  1316. /** For disabling RCDATA tags handling */
  1317. this.inXML = false;
  1318. /** For disabling interpolation parsing in v-pre */
  1319. this.inVPre = false;
  1320. /** Record newline positions for fast line / column calculation */
  1321. this.newlines = [];
  1322. this.mode = 0;
  1323. this.delimiterOpen = defaultDelimitersOpen;
  1324. this.delimiterClose = defaultDelimitersClose;
  1325. this.delimiterIndex = -1;
  1326. this.currentSequence = void 0;
  1327. this.sequenceIndex = 0;
  1328. {
  1329. this.entityDecoder = new EntityDecoder(
  1330. htmlDecodeTree,
  1331. (cp, consumed) => this.emitCodePoint(cp, consumed)
  1332. );
  1333. }
  1334. }
  1335. get inSFCRoot() {
  1336. return this.mode === 2 && this.stack.length === 0;
  1337. }
  1338. reset() {
  1339. this.state = 1;
  1340. this.mode = 0;
  1341. this.buffer = "";
  1342. this.sectionStart = 0;
  1343. this.index = 0;
  1344. this.baseState = 1;
  1345. this.inRCDATA = false;
  1346. this.currentSequence = void 0;
  1347. this.newlines.length = 0;
  1348. this.delimiterOpen = defaultDelimitersOpen;
  1349. this.delimiterClose = defaultDelimitersClose;
  1350. }
  1351. /**
  1352. * Generate Position object with line / column information using recorded
  1353. * newline positions. We know the index is always going to be an already
  1354. * processed index, so all the newlines up to this index should have been
  1355. * recorded.
  1356. */
  1357. getPos(index) {
  1358. let line = 1;
  1359. let column = index + 1;
  1360. for (let i = this.newlines.length - 1; i >= 0; i--) {
  1361. const newlineIndex = this.newlines[i];
  1362. if (index > newlineIndex) {
  1363. line = i + 2;
  1364. column = index - newlineIndex;
  1365. break;
  1366. }
  1367. }
  1368. return {
  1369. column,
  1370. line,
  1371. offset: index
  1372. };
  1373. }
  1374. peek() {
  1375. return this.buffer.charCodeAt(this.index + 1);
  1376. }
  1377. stateText(c) {
  1378. if (c === 60) {
  1379. if (this.index > this.sectionStart) {
  1380. this.cbs.ontext(this.sectionStart, this.index);
  1381. }
  1382. this.state = 5;
  1383. this.sectionStart = this.index;
  1384. } else if (c === 38) {
  1385. this.startEntity();
  1386. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1387. this.state = 2;
  1388. this.delimiterIndex = 0;
  1389. this.stateInterpolationOpen(c);
  1390. }
  1391. }
  1392. stateInterpolationOpen(c) {
  1393. if (c === this.delimiterOpen[this.delimiterIndex]) {
  1394. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  1395. const start = this.index + 1 - this.delimiterOpen.length;
  1396. if (start > this.sectionStart) {
  1397. this.cbs.ontext(this.sectionStart, start);
  1398. }
  1399. this.state = 3;
  1400. this.sectionStart = start;
  1401. } else {
  1402. this.delimiterIndex++;
  1403. }
  1404. } else if (this.inRCDATA) {
  1405. this.state = 32;
  1406. this.stateInRCDATA(c);
  1407. } else {
  1408. this.state = 1;
  1409. this.stateText(c);
  1410. }
  1411. }
  1412. stateInterpolation(c) {
  1413. if (c === this.delimiterClose[0]) {
  1414. this.state = 4;
  1415. this.delimiterIndex = 0;
  1416. this.stateInterpolationClose(c);
  1417. }
  1418. }
  1419. stateInterpolationClose(c) {
  1420. if (c === this.delimiterClose[this.delimiterIndex]) {
  1421. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  1422. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  1423. if (this.inRCDATA) {
  1424. this.state = 32;
  1425. } else {
  1426. this.state = 1;
  1427. }
  1428. this.sectionStart = this.index + 1;
  1429. } else {
  1430. this.delimiterIndex++;
  1431. }
  1432. } else {
  1433. this.state = 3;
  1434. this.stateInterpolation(c);
  1435. }
  1436. }
  1437. stateSpecialStartSequence(c) {
  1438. const isEnd = this.sequenceIndex === this.currentSequence.length;
  1439. const isMatch = isEnd ? (
  1440. // If we are at the end of the sequence, make sure the tag name has ended
  1441. isEndOfTagSection(c)
  1442. ) : (
  1443. // Otherwise, do a case-insensitive comparison
  1444. (c | 32) === this.currentSequence[this.sequenceIndex]
  1445. );
  1446. if (!isMatch) {
  1447. this.inRCDATA = false;
  1448. } else if (!isEnd) {
  1449. this.sequenceIndex++;
  1450. return;
  1451. }
  1452. this.sequenceIndex = 0;
  1453. this.state = 6;
  1454. this.stateInTagName(c);
  1455. }
  1456. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  1457. stateInRCDATA(c) {
  1458. if (this.sequenceIndex === this.currentSequence.length) {
  1459. if (c === 62 || isWhitespace(c)) {
  1460. const endOfText = this.index - this.currentSequence.length;
  1461. if (this.sectionStart < endOfText) {
  1462. const actualIndex = this.index;
  1463. this.index = endOfText;
  1464. this.cbs.ontext(this.sectionStart, endOfText);
  1465. this.index = actualIndex;
  1466. }
  1467. this.sectionStart = endOfText + 2;
  1468. this.stateInClosingTagName(c);
  1469. this.inRCDATA = false;
  1470. return;
  1471. }
  1472. this.sequenceIndex = 0;
  1473. }
  1474. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  1475. this.sequenceIndex += 1;
  1476. } else if (this.sequenceIndex === 0) {
  1477. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  1478. if (c === 38) {
  1479. this.startEntity();
  1480. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1481. this.state = 2;
  1482. this.delimiterIndex = 0;
  1483. this.stateInterpolationOpen(c);
  1484. }
  1485. } else if (this.fastForwardTo(60)) {
  1486. this.sequenceIndex = 1;
  1487. }
  1488. } else {
  1489. this.sequenceIndex = Number(c === 60);
  1490. }
  1491. }
  1492. stateCDATASequence(c) {
  1493. if (c === Sequences.Cdata[this.sequenceIndex]) {
  1494. if (++this.sequenceIndex === Sequences.Cdata.length) {
  1495. this.state = 28;
  1496. this.currentSequence = Sequences.CdataEnd;
  1497. this.sequenceIndex = 0;
  1498. this.sectionStart = this.index + 1;
  1499. }
  1500. } else {
  1501. this.sequenceIndex = 0;
  1502. this.state = 23;
  1503. this.stateInDeclaration(c);
  1504. }
  1505. }
  1506. /**
  1507. * When we wait for one specific character, we can speed things up
  1508. * by skipping through the buffer until we find it.
  1509. *
  1510. * @returns Whether the character was found.
  1511. */
  1512. fastForwardTo(c) {
  1513. while (++this.index < this.buffer.length) {
  1514. const cc = this.buffer.charCodeAt(this.index);
  1515. if (cc === 10) {
  1516. this.newlines.push(this.index);
  1517. }
  1518. if (cc === c) {
  1519. return true;
  1520. }
  1521. }
  1522. this.index = this.buffer.length - 1;
  1523. return false;
  1524. }
  1525. /**
  1526. * Comments and CDATA end with `-->` and `]]>`.
  1527. *
  1528. * Their common qualities are:
  1529. * - Their end sequences have a distinct character they start with.
  1530. * - That character is then repeated, so we have to check multiple repeats.
  1531. * - All characters but the start character of the sequence can be skipped.
  1532. */
  1533. stateInCommentLike(c) {
  1534. if (c === this.currentSequence[this.sequenceIndex]) {
  1535. if (++this.sequenceIndex === this.currentSequence.length) {
  1536. if (this.currentSequence === Sequences.CdataEnd) {
  1537. this.cbs.oncdata(this.sectionStart, this.index - 2);
  1538. } else {
  1539. this.cbs.oncomment(this.sectionStart, this.index - 2);
  1540. }
  1541. this.sequenceIndex = 0;
  1542. this.sectionStart = this.index + 1;
  1543. this.state = 1;
  1544. }
  1545. } else if (this.sequenceIndex === 0) {
  1546. if (this.fastForwardTo(this.currentSequence[0])) {
  1547. this.sequenceIndex = 1;
  1548. }
  1549. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  1550. this.sequenceIndex = 0;
  1551. }
  1552. }
  1553. startSpecial(sequence, offset) {
  1554. this.enterRCDATA(sequence, offset);
  1555. this.state = 31;
  1556. }
  1557. enterRCDATA(sequence, offset) {
  1558. this.inRCDATA = true;
  1559. this.currentSequence = sequence;
  1560. this.sequenceIndex = offset;
  1561. }
  1562. stateBeforeTagName(c) {
  1563. if (c === 33) {
  1564. this.state = 22;
  1565. this.sectionStart = this.index + 1;
  1566. } else if (c === 63) {
  1567. this.state = 24;
  1568. this.sectionStart = this.index + 1;
  1569. } else if (isTagStartChar(c)) {
  1570. this.sectionStart = this.index;
  1571. if (this.mode === 0) {
  1572. this.state = 6;
  1573. } else if (this.inSFCRoot) {
  1574. this.state = 34;
  1575. } else if (!this.inXML) {
  1576. if (c === 116) {
  1577. this.state = 30;
  1578. } else {
  1579. this.state = c === 115 ? 29 : 6;
  1580. }
  1581. } else {
  1582. this.state = 6;
  1583. }
  1584. } else if (c === 47) {
  1585. this.state = 8;
  1586. } else {
  1587. this.state = 1;
  1588. this.stateText(c);
  1589. }
  1590. }
  1591. stateInTagName(c) {
  1592. if (isEndOfTagSection(c)) {
  1593. this.handleTagName(c);
  1594. }
  1595. }
  1596. stateInSFCRootTagName(c) {
  1597. if (isEndOfTagSection(c)) {
  1598. const tag = this.buffer.slice(this.sectionStart, this.index);
  1599. if (tag !== "template") {
  1600. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  1601. }
  1602. this.handleTagName(c);
  1603. }
  1604. }
  1605. handleTagName(c) {
  1606. this.cbs.onopentagname(this.sectionStart, this.index);
  1607. this.sectionStart = -1;
  1608. this.state = 11;
  1609. this.stateBeforeAttrName(c);
  1610. }
  1611. stateBeforeClosingTagName(c) {
  1612. if (isWhitespace(c)) ; else if (c === 62) {
  1613. {
  1614. this.cbs.onerr(14, this.index);
  1615. }
  1616. this.state = 1;
  1617. this.sectionStart = this.index + 1;
  1618. } else {
  1619. this.state = isTagStartChar(c) ? 9 : 27;
  1620. this.sectionStart = this.index;
  1621. }
  1622. }
  1623. stateInClosingTagName(c) {
  1624. if (c === 62 || isWhitespace(c)) {
  1625. this.cbs.onclosetag(this.sectionStart, this.index);
  1626. this.sectionStart = -1;
  1627. this.state = 10;
  1628. this.stateAfterClosingTagName(c);
  1629. }
  1630. }
  1631. stateAfterClosingTagName(c) {
  1632. if (c === 62) {
  1633. this.state = 1;
  1634. this.sectionStart = this.index + 1;
  1635. }
  1636. }
  1637. stateBeforeAttrName(c) {
  1638. if (c === 62) {
  1639. this.cbs.onopentagend(this.index);
  1640. if (this.inRCDATA) {
  1641. this.state = 32;
  1642. } else {
  1643. this.state = 1;
  1644. }
  1645. this.sectionStart = this.index + 1;
  1646. } else if (c === 47) {
  1647. this.state = 7;
  1648. if (this.peek() !== 62) {
  1649. this.cbs.onerr(22, this.index);
  1650. }
  1651. } else if (c === 60 && this.peek() === 47) {
  1652. this.cbs.onopentagend(this.index);
  1653. this.state = 5;
  1654. this.sectionStart = this.index;
  1655. } else if (!isWhitespace(c)) {
  1656. if (c === 61) {
  1657. this.cbs.onerr(
  1658. 19,
  1659. this.index
  1660. );
  1661. }
  1662. this.handleAttrStart(c);
  1663. }
  1664. }
  1665. handleAttrStart(c) {
  1666. if (c === 118 && this.peek() === 45) {
  1667. this.state = 13;
  1668. this.sectionStart = this.index;
  1669. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  1670. this.cbs.ondirname(this.index, this.index + 1);
  1671. this.state = 14;
  1672. this.sectionStart = this.index + 1;
  1673. } else {
  1674. this.state = 12;
  1675. this.sectionStart = this.index;
  1676. }
  1677. }
  1678. stateInSelfClosingTag(c) {
  1679. if (c === 62) {
  1680. this.cbs.onselfclosingtag(this.index);
  1681. this.state = 1;
  1682. this.sectionStart = this.index + 1;
  1683. this.inRCDATA = false;
  1684. } else if (!isWhitespace(c)) {
  1685. this.state = 11;
  1686. this.stateBeforeAttrName(c);
  1687. }
  1688. }
  1689. stateInAttrName(c) {
  1690. if (c === 61 || isEndOfTagSection(c)) {
  1691. this.cbs.onattribname(this.sectionStart, this.index);
  1692. this.handleAttrNameEnd(c);
  1693. } else if (c === 34 || c === 39 || c === 60) {
  1694. this.cbs.onerr(
  1695. 17,
  1696. this.index
  1697. );
  1698. }
  1699. }
  1700. stateInDirName(c) {
  1701. if (c === 61 || isEndOfTagSection(c)) {
  1702. this.cbs.ondirname(this.sectionStart, this.index);
  1703. this.handleAttrNameEnd(c);
  1704. } else if (c === 58) {
  1705. this.cbs.ondirname(this.sectionStart, this.index);
  1706. this.state = 14;
  1707. this.sectionStart = this.index + 1;
  1708. } else if (c === 46) {
  1709. this.cbs.ondirname(this.sectionStart, this.index);
  1710. this.state = 16;
  1711. this.sectionStart = this.index + 1;
  1712. }
  1713. }
  1714. stateInDirArg(c) {
  1715. if (c === 61 || isEndOfTagSection(c)) {
  1716. this.cbs.ondirarg(this.sectionStart, this.index);
  1717. this.handleAttrNameEnd(c);
  1718. } else if (c === 91) {
  1719. this.state = 15;
  1720. } else if (c === 46) {
  1721. this.cbs.ondirarg(this.sectionStart, this.index);
  1722. this.state = 16;
  1723. this.sectionStart = this.index + 1;
  1724. }
  1725. }
  1726. stateInDynamicDirArg(c) {
  1727. if (c === 93) {
  1728. this.state = 14;
  1729. } else if (c === 61 || isEndOfTagSection(c)) {
  1730. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  1731. this.handleAttrNameEnd(c);
  1732. {
  1733. this.cbs.onerr(
  1734. 27,
  1735. this.index
  1736. );
  1737. }
  1738. }
  1739. }
  1740. stateInDirModifier(c) {
  1741. if (c === 61 || isEndOfTagSection(c)) {
  1742. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1743. this.handleAttrNameEnd(c);
  1744. } else if (c === 46) {
  1745. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1746. this.sectionStart = this.index + 1;
  1747. }
  1748. }
  1749. handleAttrNameEnd(c) {
  1750. this.sectionStart = this.index;
  1751. this.state = 17;
  1752. this.cbs.onattribnameend(this.index);
  1753. this.stateAfterAttrName(c);
  1754. }
  1755. stateAfterAttrName(c) {
  1756. if (c === 61) {
  1757. this.state = 18;
  1758. } else if (c === 47 || c === 62) {
  1759. this.cbs.onattribend(0, this.sectionStart);
  1760. this.sectionStart = -1;
  1761. this.state = 11;
  1762. this.stateBeforeAttrName(c);
  1763. } else if (!isWhitespace(c)) {
  1764. this.cbs.onattribend(0, this.sectionStart);
  1765. this.handleAttrStart(c);
  1766. }
  1767. }
  1768. stateBeforeAttrValue(c) {
  1769. if (c === 34) {
  1770. this.state = 19;
  1771. this.sectionStart = this.index + 1;
  1772. } else if (c === 39) {
  1773. this.state = 20;
  1774. this.sectionStart = this.index + 1;
  1775. } else if (!isWhitespace(c)) {
  1776. this.sectionStart = this.index;
  1777. this.state = 21;
  1778. this.stateInAttrValueNoQuotes(c);
  1779. }
  1780. }
  1781. handleInAttrValue(c, quote) {
  1782. if (c === quote || false) {
  1783. this.cbs.onattribdata(this.sectionStart, this.index);
  1784. this.sectionStart = -1;
  1785. this.cbs.onattribend(
  1786. quote === 34 ? 3 : 2,
  1787. this.index + 1
  1788. );
  1789. this.state = 11;
  1790. } else if (c === 38) {
  1791. this.startEntity();
  1792. }
  1793. }
  1794. stateInAttrValueDoubleQuotes(c) {
  1795. this.handleInAttrValue(c, 34);
  1796. }
  1797. stateInAttrValueSingleQuotes(c) {
  1798. this.handleInAttrValue(c, 39);
  1799. }
  1800. stateInAttrValueNoQuotes(c) {
  1801. if (isWhitespace(c) || c === 62) {
  1802. this.cbs.onattribdata(this.sectionStart, this.index);
  1803. this.sectionStart = -1;
  1804. this.cbs.onattribend(1, this.index);
  1805. this.state = 11;
  1806. this.stateBeforeAttrName(c);
  1807. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1808. this.cbs.onerr(
  1809. 18,
  1810. this.index
  1811. );
  1812. } else if (c === 38) {
  1813. this.startEntity();
  1814. }
  1815. }
  1816. stateBeforeDeclaration(c) {
  1817. if (c === 91) {
  1818. this.state = 26;
  1819. this.sequenceIndex = 0;
  1820. } else {
  1821. this.state = c === 45 ? 25 : 23;
  1822. }
  1823. }
  1824. stateInDeclaration(c) {
  1825. if (c === 62 || this.fastForwardTo(62)) {
  1826. this.state = 1;
  1827. this.sectionStart = this.index + 1;
  1828. }
  1829. }
  1830. stateInProcessingInstruction(c) {
  1831. if (c === 62 || this.fastForwardTo(62)) {
  1832. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1833. this.state = 1;
  1834. this.sectionStart = this.index + 1;
  1835. }
  1836. }
  1837. stateBeforeComment(c) {
  1838. if (c === 45) {
  1839. this.state = 28;
  1840. this.currentSequence = Sequences.CommentEnd;
  1841. this.sequenceIndex = 2;
  1842. this.sectionStart = this.index + 1;
  1843. } else {
  1844. this.state = 23;
  1845. }
  1846. }
  1847. stateInSpecialComment(c) {
  1848. if (c === 62 || this.fastForwardTo(62)) {
  1849. this.cbs.oncomment(this.sectionStart, this.index);
  1850. this.state = 1;
  1851. this.sectionStart = this.index + 1;
  1852. }
  1853. }
  1854. stateBeforeSpecialS(c) {
  1855. if (c === Sequences.ScriptEnd[3]) {
  1856. this.startSpecial(Sequences.ScriptEnd, 4);
  1857. } else if (c === Sequences.StyleEnd[3]) {
  1858. this.startSpecial(Sequences.StyleEnd, 4);
  1859. } else {
  1860. this.state = 6;
  1861. this.stateInTagName(c);
  1862. }
  1863. }
  1864. stateBeforeSpecialT(c) {
  1865. if (c === Sequences.TitleEnd[3]) {
  1866. this.startSpecial(Sequences.TitleEnd, 4);
  1867. } else if (c === Sequences.TextareaEnd[3]) {
  1868. this.startSpecial(Sequences.TextareaEnd, 4);
  1869. } else {
  1870. this.state = 6;
  1871. this.stateInTagName(c);
  1872. }
  1873. }
  1874. startEntity() {
  1875. {
  1876. this.baseState = this.state;
  1877. this.state = 33;
  1878. this.entityStart = this.index;
  1879. this.entityDecoder.startEntity(
  1880. this.baseState === 1 || this.baseState === 32 ? DecodingMode.Legacy : DecodingMode.Attribute
  1881. );
  1882. }
  1883. }
  1884. stateInEntity() {
  1885. {
  1886. const length = this.entityDecoder.write(this.buffer, this.index);
  1887. if (length >= 0) {
  1888. this.state = this.baseState;
  1889. if (length === 0) {
  1890. this.index = this.entityStart;
  1891. }
  1892. } else {
  1893. this.index = this.buffer.length - 1;
  1894. }
  1895. }
  1896. }
  1897. /**
  1898. * Iterates through the buffer, calling the function corresponding to the current state.
  1899. *
  1900. * States that are more likely to be hit are higher up, as a performance improvement.
  1901. */
  1902. parse(input) {
  1903. this.buffer = input;
  1904. while (this.index < this.buffer.length) {
  1905. const c = this.buffer.charCodeAt(this.index);
  1906. if (c === 10 && this.state !== 33) {
  1907. this.newlines.push(this.index);
  1908. }
  1909. switch (this.state) {
  1910. case 1: {
  1911. this.stateText(c);
  1912. break;
  1913. }
  1914. case 2: {
  1915. this.stateInterpolationOpen(c);
  1916. break;
  1917. }
  1918. case 3: {
  1919. this.stateInterpolation(c);
  1920. break;
  1921. }
  1922. case 4: {
  1923. this.stateInterpolationClose(c);
  1924. break;
  1925. }
  1926. case 31: {
  1927. this.stateSpecialStartSequence(c);
  1928. break;
  1929. }
  1930. case 32: {
  1931. this.stateInRCDATA(c);
  1932. break;
  1933. }
  1934. case 26: {
  1935. this.stateCDATASequence(c);
  1936. break;
  1937. }
  1938. case 19: {
  1939. this.stateInAttrValueDoubleQuotes(c);
  1940. break;
  1941. }
  1942. case 12: {
  1943. this.stateInAttrName(c);
  1944. break;
  1945. }
  1946. case 13: {
  1947. this.stateInDirName(c);
  1948. break;
  1949. }
  1950. case 14: {
  1951. this.stateInDirArg(c);
  1952. break;
  1953. }
  1954. case 15: {
  1955. this.stateInDynamicDirArg(c);
  1956. break;
  1957. }
  1958. case 16: {
  1959. this.stateInDirModifier(c);
  1960. break;
  1961. }
  1962. case 28: {
  1963. this.stateInCommentLike(c);
  1964. break;
  1965. }
  1966. case 27: {
  1967. this.stateInSpecialComment(c);
  1968. break;
  1969. }
  1970. case 11: {
  1971. this.stateBeforeAttrName(c);
  1972. break;
  1973. }
  1974. case 6: {
  1975. this.stateInTagName(c);
  1976. break;
  1977. }
  1978. case 34: {
  1979. this.stateInSFCRootTagName(c);
  1980. break;
  1981. }
  1982. case 9: {
  1983. this.stateInClosingTagName(c);
  1984. break;
  1985. }
  1986. case 5: {
  1987. this.stateBeforeTagName(c);
  1988. break;
  1989. }
  1990. case 17: {
  1991. this.stateAfterAttrName(c);
  1992. break;
  1993. }
  1994. case 20: {
  1995. this.stateInAttrValueSingleQuotes(c);
  1996. break;
  1997. }
  1998. case 18: {
  1999. this.stateBeforeAttrValue(c);
  2000. break;
  2001. }
  2002. case 8: {
  2003. this.stateBeforeClosingTagName(c);
  2004. break;
  2005. }
  2006. case 10: {
  2007. this.stateAfterClosingTagName(c);
  2008. break;
  2009. }
  2010. case 29: {
  2011. this.stateBeforeSpecialS(c);
  2012. break;
  2013. }
  2014. case 30: {
  2015. this.stateBeforeSpecialT(c);
  2016. break;
  2017. }
  2018. case 21: {
  2019. this.stateInAttrValueNoQuotes(c);
  2020. break;
  2021. }
  2022. case 7: {
  2023. this.stateInSelfClosingTag(c);
  2024. break;
  2025. }
  2026. case 23: {
  2027. this.stateInDeclaration(c);
  2028. break;
  2029. }
  2030. case 22: {
  2031. this.stateBeforeDeclaration(c);
  2032. break;
  2033. }
  2034. case 25: {
  2035. this.stateBeforeComment(c);
  2036. break;
  2037. }
  2038. case 24: {
  2039. this.stateInProcessingInstruction(c);
  2040. break;
  2041. }
  2042. case 33: {
  2043. this.stateInEntity();
  2044. break;
  2045. }
  2046. }
  2047. this.index++;
  2048. }
  2049. this.cleanup();
  2050. this.finish();
  2051. }
  2052. /**
  2053. * Remove data that has already been consumed from the buffer.
  2054. */
  2055. cleanup() {
  2056. if (this.sectionStart !== this.index) {
  2057. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  2058. this.cbs.ontext(this.sectionStart, this.index);
  2059. this.sectionStart = this.index;
  2060. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  2061. this.cbs.onattribdata(this.sectionStart, this.index);
  2062. this.sectionStart = this.index;
  2063. }
  2064. }
  2065. }
  2066. finish() {
  2067. if (this.state === 33) {
  2068. this.entityDecoder.end();
  2069. this.state = this.baseState;
  2070. }
  2071. this.handleTrailingData();
  2072. this.cbs.onend();
  2073. }
  2074. /** Handle any trailing data. */
  2075. handleTrailingData() {
  2076. const endIndex = this.buffer.length;
  2077. if (this.sectionStart >= endIndex) {
  2078. return;
  2079. }
  2080. if (this.state === 28) {
  2081. if (this.currentSequence === Sequences.CdataEnd) {
  2082. this.cbs.oncdata(this.sectionStart, endIndex);
  2083. } else {
  2084. this.cbs.oncomment(this.sectionStart, endIndex);
  2085. }
  2086. } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
  2087. this.cbs.ontext(this.sectionStart, endIndex);
  2088. }
  2089. }
  2090. emitCodePoint(cp, consumed) {
  2091. {
  2092. if (this.baseState !== 1 && this.baseState !== 32) {
  2093. if (this.sectionStart < this.entityStart) {
  2094. this.cbs.onattribdata(this.sectionStart, this.entityStart);
  2095. }
  2096. this.sectionStart = this.entityStart + consumed;
  2097. this.index = this.sectionStart - 1;
  2098. this.cbs.onattribentity(
  2099. fromCodePoint(cp),
  2100. this.entityStart,
  2101. this.sectionStart
  2102. );
  2103. } else {
  2104. if (this.sectionStart < this.entityStart) {
  2105. this.cbs.ontext(this.sectionStart, this.entityStart);
  2106. }
  2107. this.sectionStart = this.entityStart + consumed;
  2108. this.index = this.sectionStart - 1;
  2109. this.cbs.ontextentity(
  2110. fromCodePoint(cp),
  2111. this.entityStart,
  2112. this.sectionStart
  2113. );
  2114. }
  2115. }
  2116. }
  2117. }
  2118. const CompilerDeprecationTypes = {
  2119. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  2120. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  2121. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  2122. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  2123. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2124. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  2125. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  2126. "COMPILER_FILTERS": "COMPILER_FILTERS"
  2127. };
  2128. const deprecationData = {
  2129. ["COMPILER_IS_ON_ELEMENT"]: {
  2130. message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
  2131. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  2132. },
  2133. ["COMPILER_V_BIND_SYNC"]: {
  2134. message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
  2135. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  2136. },
  2137. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  2138. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
  2139. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  2140. },
  2141. ["COMPILER_V_ON_NATIVE"]: {
  2142. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  2143. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  2144. },
  2145. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  2146. message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
  2147. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  2148. },
  2149. ["COMPILER_NATIVE_TEMPLATE"]: {
  2150. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  2151. },
  2152. ["COMPILER_INLINE_TEMPLATE"]: {
  2153. message: `"inline-template" has been removed in Vue 3.`,
  2154. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  2155. },
  2156. ["COMPILER_FILTERS"]: {
  2157. message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
  2158. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  2159. }
  2160. };
  2161. function getCompatValue(key, { compatConfig }) {
  2162. const value = compatConfig && compatConfig[key];
  2163. if (key === "MODE") {
  2164. return value || 3;
  2165. } else {
  2166. return value;
  2167. }
  2168. }
  2169. function isCompatEnabled(key, context) {
  2170. const mode = getCompatValue("MODE", context);
  2171. const value = getCompatValue(key, context);
  2172. return mode === 3 ? value === true : value !== false;
  2173. }
  2174. function checkCompatEnabled(key, context, loc, ...args) {
  2175. const enabled = isCompatEnabled(key, context);
  2176. if (enabled) {
  2177. warnDeprecation(key, context, loc, ...args);
  2178. }
  2179. return enabled;
  2180. }
  2181. function warnDeprecation(key, context, loc, ...args) {
  2182. const val = getCompatValue(key, context);
  2183. if (val === "suppress-warning") {
  2184. return;
  2185. }
  2186. const { message, link } = deprecationData[key];
  2187. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  2188. Details: ${link}` : ``}`;
  2189. const err = new SyntaxError(msg);
  2190. err.code = key;
  2191. if (loc) err.loc = loc;
  2192. context.onWarn(err);
  2193. }
  2194. function defaultOnError(error) {
  2195. throw error;
  2196. }
  2197. function defaultOnWarn(msg) {
  2198. console.warn(`[Vue warn] ${msg.message}`);
  2199. }
  2200. function createCompilerError(code, loc, messages, additionalMessage) {
  2201. const msg = (messages || errorMessages$1)[code] + (additionalMessage || ``) ;
  2202. const error = new SyntaxError(String(msg));
  2203. error.code = code;
  2204. error.loc = loc;
  2205. return error;
  2206. }
  2207. const ErrorCodes = {
  2208. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  2209. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  2210. "CDATA_IN_HTML_CONTENT": 1,
  2211. "1": "CDATA_IN_HTML_CONTENT",
  2212. "DUPLICATE_ATTRIBUTE": 2,
  2213. "2": "DUPLICATE_ATTRIBUTE",
  2214. "END_TAG_WITH_ATTRIBUTES": 3,
  2215. "3": "END_TAG_WITH_ATTRIBUTES",
  2216. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  2217. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  2218. "EOF_BEFORE_TAG_NAME": 5,
  2219. "5": "EOF_BEFORE_TAG_NAME",
  2220. "EOF_IN_CDATA": 6,
  2221. "6": "EOF_IN_CDATA",
  2222. "EOF_IN_COMMENT": 7,
  2223. "7": "EOF_IN_COMMENT",
  2224. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  2225. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  2226. "EOF_IN_TAG": 9,
  2227. "9": "EOF_IN_TAG",
  2228. "INCORRECTLY_CLOSED_COMMENT": 10,
  2229. "10": "INCORRECTLY_CLOSED_COMMENT",
  2230. "INCORRECTLY_OPENED_COMMENT": 11,
  2231. "11": "INCORRECTLY_OPENED_COMMENT",
  2232. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  2233. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  2234. "MISSING_ATTRIBUTE_VALUE": 13,
  2235. "13": "MISSING_ATTRIBUTE_VALUE",
  2236. "MISSING_END_TAG_NAME": 14,
  2237. "14": "MISSING_END_TAG_NAME",
  2238. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  2239. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  2240. "NESTED_COMMENT": 16,
  2241. "16": "NESTED_COMMENT",
  2242. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  2243. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  2244. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  2245. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  2246. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  2247. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  2248. "UNEXPECTED_NULL_CHARACTER": 20,
  2249. "20": "UNEXPECTED_NULL_CHARACTER",
  2250. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  2251. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  2252. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  2253. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  2254. "X_INVALID_END_TAG": 23,
  2255. "23": "X_INVALID_END_TAG",
  2256. "X_MISSING_END_TAG": 24,
  2257. "24": "X_MISSING_END_TAG",
  2258. "X_MISSING_INTERPOLATION_END": 25,
  2259. "25": "X_MISSING_INTERPOLATION_END",
  2260. "X_MISSING_DIRECTIVE_NAME": 26,
  2261. "26": "X_MISSING_DIRECTIVE_NAME",
  2262. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  2263. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  2264. "X_V_IF_NO_EXPRESSION": 28,
  2265. "28": "X_V_IF_NO_EXPRESSION",
  2266. "X_V_IF_SAME_KEY": 29,
  2267. "29": "X_V_IF_SAME_KEY",
  2268. "X_V_ELSE_NO_ADJACENT_IF": 30,
  2269. "30": "X_V_ELSE_NO_ADJACENT_IF",
  2270. "X_V_FOR_NO_EXPRESSION": 31,
  2271. "31": "X_V_FOR_NO_EXPRESSION",
  2272. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  2273. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  2274. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  2275. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  2276. "X_V_BIND_NO_EXPRESSION": 34,
  2277. "34": "X_V_BIND_NO_EXPRESSION",
  2278. "X_V_ON_NO_EXPRESSION": 35,
  2279. "35": "X_V_ON_NO_EXPRESSION",
  2280. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  2281. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  2282. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  2283. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  2284. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  2285. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  2286. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  2287. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  2288. "X_V_SLOT_MISPLACED": 40,
  2289. "40": "X_V_SLOT_MISPLACED",
  2290. "X_V_MODEL_NO_EXPRESSION": 41,
  2291. "41": "X_V_MODEL_NO_EXPRESSION",
  2292. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  2293. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  2294. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  2295. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  2296. "X_V_MODEL_ON_PROPS": 44,
  2297. "44": "X_V_MODEL_ON_PROPS",
  2298. "X_INVALID_EXPRESSION": 45,
  2299. "45": "X_INVALID_EXPRESSION",
  2300. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  2301. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  2302. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  2303. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  2304. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  2305. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  2306. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  2307. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  2308. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  2309. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  2310. "X_VNODE_HOOKS": 51,
  2311. "51": "X_VNODE_HOOKS",
  2312. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  2313. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  2314. "__EXTEND_POINT__": 53,
  2315. "53": "__EXTEND_POINT__"
  2316. };
  2317. const errorMessages$1 = {
  2318. // parse errors
  2319. [0]: "Illegal comment.",
  2320. [1]: "CDATA section is allowed only in XML context.",
  2321. [2]: "Duplicate attribute.",
  2322. [3]: "End tag cannot have attributes.",
  2323. [4]: "Illegal '/' in tags.",
  2324. [5]: "Unexpected EOF in tag.",
  2325. [6]: "Unexpected EOF in CDATA section.",
  2326. [7]: "Unexpected EOF in comment.",
  2327. [8]: "Unexpected EOF in script.",
  2328. [9]: "Unexpected EOF in tag.",
  2329. [10]: "Incorrectly closed comment.",
  2330. [11]: "Incorrectly opened comment.",
  2331. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  2332. [13]: "Attribute value was expected.",
  2333. [14]: "End tag name was expected.",
  2334. [15]: "Whitespace was expected.",
  2335. [16]: "Unexpected '<!--' in comment.",
  2336. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  2337. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  2338. [19]: "Attribute name cannot start with '='.",
  2339. [21]: "'<?' is allowed only in XML context.",
  2340. [20]: `Unexpected null character.`,
  2341. [22]: "Illegal '/' in tags.",
  2342. // Vue-specific parse errors
  2343. [23]: "Invalid end tag.",
  2344. [24]: "Element is missing end tag.",
  2345. [25]: "Interpolation end sign was not found.",
  2346. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  2347. [26]: "Legal directive name was expected.",
  2348. // transform errors
  2349. [28]: `v-if/v-else-if is missing expression.`,
  2350. [29]: `v-if/else branches must use unique keys.`,
  2351. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  2352. [31]: `v-for is missing expression.`,
  2353. [32]: `v-for has invalid expression.`,
  2354. [33]: `<template v-for> key should be placed on the <template> tag.`,
  2355. [34]: `v-bind is missing expression.`,
  2356. [52]: `v-bind with same-name shorthand only allows static argument.`,
  2357. [35]: `v-on is missing expression.`,
  2358. [36]: `Unexpected custom directive on <slot> outlet.`,
  2359. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  2360. [38]: `Duplicate slot names found. `,
  2361. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  2362. [40]: `v-slot can only be used on components or <template> tags.`,
  2363. [41]: `v-model is missing expression.`,
  2364. [42]: `v-model value must be a valid JavaScript member expression.`,
  2365. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  2366. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  2367. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  2368. [45]: `Error parsing JavaScript expression: `,
  2369. [46]: `<KeepAlive> expects exactly one child component.`,
  2370. [51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
  2371. // generic errors
  2372. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  2373. [48]: `ES module mode is not supported in this build of compiler.`,
  2374. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  2375. [50]: `"scopeId" option is only supported in module mode.`,
  2376. // just to fulfill types
  2377. [53]: ``
  2378. };
  2379. function getDefaultExportFromCjs (x) {
  2380. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2381. }
  2382. function getAugmentedNamespace(n) {
  2383. if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
  2384. var f = n.default;
  2385. if (typeof f == "function") {
  2386. var a = function a () {
  2387. var isInstance = false;
  2388. try {
  2389. isInstance = this instanceof a;
  2390. } catch {}
  2391. if (isInstance) {
  2392. return Reflect.construct(f, arguments, this.constructor);
  2393. }
  2394. return f.apply(this, arguments);
  2395. };
  2396. a.prototype = f.prototype;
  2397. } else a = {};
  2398. Object.defineProperty(a, '__esModule', {value: true});
  2399. Object.keys(n).forEach(function (k) {
  2400. var d = Object.getOwnPropertyDescriptor(n, k);
  2401. Object.defineProperty(a, k, d.get ? d : {
  2402. enumerable: true,
  2403. get: function () {
  2404. return n[k];
  2405. }
  2406. });
  2407. });
  2408. return a;
  2409. }
  2410. var lib = {};
  2411. var hasRequiredLib;
  2412. function requireLib () {
  2413. if (hasRequiredLib) return lib;
  2414. hasRequiredLib = 1;
  2415. Object.defineProperty(lib, '__esModule', {
  2416. value: true
  2417. });
  2418. function _objectWithoutPropertiesLoose(r, e) {
  2419. if (null == r) return {};
  2420. var t = {};
  2421. for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
  2422. if (-1 !== e.indexOf(n)) continue;
  2423. t[n] = r[n];
  2424. }
  2425. return t;
  2426. }
  2427. class Position {
  2428. constructor(line, col, index) {
  2429. this.line = void 0;
  2430. this.column = void 0;
  2431. this.index = void 0;
  2432. this.line = line;
  2433. this.column = col;
  2434. this.index = index;
  2435. }
  2436. }
  2437. class SourceLocation {
  2438. constructor(start, end) {
  2439. this.start = void 0;
  2440. this.end = void 0;
  2441. this.filename = void 0;
  2442. this.identifierName = void 0;
  2443. this.start = start;
  2444. this.end = end;
  2445. }
  2446. }
  2447. function createPositionWithColumnOffset(position, columnOffset) {
  2448. const {
  2449. line,
  2450. column,
  2451. index
  2452. } = position;
  2453. return new Position(line, column + columnOffset, index + columnOffset);
  2454. }
  2455. const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
  2456. var ModuleErrors = {
  2457. ImportMetaOutsideModule: {
  2458. message: `import.meta may appear only with 'sourceType: "module"'`,
  2459. code
  2460. },
  2461. ImportOutsideModule: {
  2462. message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
  2463. code
  2464. }
  2465. };
  2466. const NodeDescriptions = {
  2467. ArrayPattern: "array destructuring pattern",
  2468. AssignmentExpression: "assignment expression",
  2469. AssignmentPattern: "assignment expression",
  2470. ArrowFunctionExpression: "arrow function expression",
  2471. ConditionalExpression: "conditional expression",
  2472. CatchClause: "catch clause",
  2473. ForOfStatement: "for-of statement",
  2474. ForInStatement: "for-in statement",
  2475. ForStatement: "for-loop",
  2476. FormalParameters: "function parameter list",
  2477. Identifier: "identifier",
  2478. ImportSpecifier: "import specifier",
  2479. ImportDefaultSpecifier: "import default specifier",
  2480. ImportNamespaceSpecifier: "import namespace specifier",
  2481. ObjectPattern: "object destructuring pattern",
  2482. ParenthesizedExpression: "parenthesized expression",
  2483. RestElement: "rest element",
  2484. UpdateExpression: {
  2485. true: "prefix operation",
  2486. false: "postfix operation"
  2487. },
  2488. VariableDeclarator: "variable declaration",
  2489. YieldExpression: "yield expression"
  2490. };
  2491. const toNodeDescription = node => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type];
  2492. var StandardErrors = {
  2493. AccessorIsGenerator: ({
  2494. kind
  2495. }) => `A ${kind}ter cannot be a generator.`,
  2496. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  2497. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  2498. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  2499. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  2500. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  2501. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  2502. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  2503. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  2504. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  2505. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  2506. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  2507. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  2508. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  2509. ConstructorIsAsync: "Constructor can't be an async function.",
  2510. ConstructorIsGenerator: "Constructor can't be a generator.",
  2511. DeclarationMissingInitializer: ({
  2512. kind
  2513. }) => `Missing initializer in ${kind} declaration.`,
  2514. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  2515. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  2516. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  2517. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  2518. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  2519. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  2520. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  2521. DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
  2522. DeletePrivateField: "Deleting a private field is not allowed.",
  2523. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  2524. DuplicateConstructor: "Duplicate constructor in the same class.",
  2525. DuplicateDefaultExport: "Only one default export allowed per module.",
  2526. DuplicateExport: ({
  2527. exportName
  2528. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  2529. DuplicateProto: "Redefinition of __proto__ property.",
  2530. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  2531. ElementAfterRest: "Rest element must be last element.",
  2532. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  2533. ExportBindingIsString: ({
  2534. localName,
  2535. exportName
  2536. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  2537. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  2538. ForInOfLoopInitializer: ({
  2539. type
  2540. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  2541. ForInUsing: "For-in loop may not start with 'using' declaration.",
  2542. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  2543. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  2544. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  2545. IllegalBreakContinue: ({
  2546. type
  2547. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  2548. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  2549. IllegalReturn: "'return' outside of function.",
  2550. ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedImportAssert` parser plugin to suppress this error.",
  2551. ImportBindingIsString: ({
  2552. importName
  2553. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  2554. ImportCallArity: `\`import()\` requires exactly one or two arguments.`,
  2555. ImportCallNotNewExpression: "Cannot use new with import(...).",
  2556. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  2557. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  2558. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  2559. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  2560. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  2561. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  2562. InvalidCodePoint: "Code point out of bounds.",
  2563. InvalidCoverDiscardElement: "'void' must be followed by an expression when not used in a binding position.",
  2564. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  2565. InvalidDecimal: "Invalid decimal.",
  2566. InvalidDigit: ({
  2567. radix
  2568. }) => `Expected number in radix ${radix}.`,
  2569. InvalidEscapeSequence: "Bad character escape sequence.",
  2570. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  2571. InvalidEscapedReservedWord: ({
  2572. reservedWord
  2573. }) => `Escape sequence in keyword ${reservedWord}.`,
  2574. InvalidIdentifier: ({
  2575. identifierName
  2576. }) => `Invalid identifier ${identifierName}.`,
  2577. InvalidLhs: ({
  2578. ancestor
  2579. }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2580. InvalidLhsBinding: ({
  2581. ancestor
  2582. }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2583. InvalidLhsOptionalChaining: ({
  2584. ancestor
  2585. }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
  2586. InvalidNumber: "Invalid number.",
  2587. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  2588. InvalidOrUnexpectedToken: ({
  2589. unexpected
  2590. }) => `Unexpected character '${unexpected}'.`,
  2591. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  2592. InvalidPrivateFieldResolution: ({
  2593. identifierName
  2594. }) => `Private name #${identifierName} is not defined.`,
  2595. InvalidPropertyBindingPattern: "Binding member expression.",
  2596. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  2597. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  2598. LabelRedeclaration: ({
  2599. labelName
  2600. }) => `Label '${labelName}' is already declared.`,
  2601. LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
  2602. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  2603. MalformedRegExpFlags: "Invalid regular expression flag.",
  2604. MissingClassName: "A class name is required.",
  2605. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  2606. MissingSemicolon: "Missing semicolon.",
  2607. MissingPlugin: ({
  2608. missingPlugin
  2609. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2610. MissingOneOfPlugins: ({
  2611. missingPlugin
  2612. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2613. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  2614. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  2615. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  2616. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  2617. ModuleAttributesWithDuplicateKeys: ({
  2618. key
  2619. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  2620. ModuleExportNameHasLoneSurrogate: ({
  2621. surrogateCharCode
  2622. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  2623. ModuleExportUndefined: ({
  2624. localName
  2625. }) => `Export '${localName}' is not defined.`,
  2626. MultipleDefaultsInSwitch: "Multiple default clauses.",
  2627. NewlineAfterThrow: "Illegal newline after throw.",
  2628. NoCatchOrFinally: "Missing catch or finally clause.",
  2629. NumberIdentifier: "Identifier directly after number.",
  2630. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  2631. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  2632. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  2633. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  2634. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  2635. ParamDupe: "Argument name clash.",
  2636. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  2637. PatternHasMethod: "Object pattern can't contain methods.",
  2638. PrivateInExpectedIn: ({
  2639. identifierName
  2640. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  2641. PrivateNameRedeclaration: ({
  2642. identifierName
  2643. }) => `Duplicate private name #${identifierName}.`,
  2644. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2645. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2646. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2647. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  2648. RestTrailingComma: "Unexpected trailing comma after rest element.",
  2649. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  2650. SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
  2651. SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
  2652. StaticPrototype: "Classes may not have static property named prototype.",
  2653. SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
  2654. SuperPrivateField: "Private fields can't be accessed on super.",
  2655. TrailingDecorator: "Decorators must be attached to a class element.",
  2656. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2657. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2658. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2659. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  2660. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  2661. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  2662. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  2663. UnexpectedKeyword: ({
  2664. keyword
  2665. }) => `Unexpected keyword '${keyword}'.`,
  2666. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  2667. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  2668. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  2669. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  2670. UnexpectedPrivateField: "Unexpected private name.",
  2671. UnexpectedReservedWord: ({
  2672. reservedWord
  2673. }) => `Unexpected reserved word '${reservedWord}'.`,
  2674. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  2675. UnexpectedToken: ({
  2676. expected,
  2677. unexpected
  2678. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  2679. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  2680. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",
  2681. UnexpectedVoidPattern: "Unexpected void binding.",
  2682. UnsupportedBind: "Binding should be performed on object property.",
  2683. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  2684. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  2685. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  2686. UnsupportedMetaProperty: ({
  2687. target,
  2688. onlyValidPropertyName
  2689. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  2690. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  2691. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  2692. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  2693. UnterminatedComment: "Unterminated comment.",
  2694. UnterminatedRegExp: "Unterminated regular expression.",
  2695. UnterminatedString: "Unterminated string constant.",
  2696. UnterminatedTemplate: "Unterminated template.",
  2697. UsingDeclarationExport: "Using declaration cannot be exported.",
  2698. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  2699. VarRedeclaration: ({
  2700. identifierName
  2701. }) => `Identifier '${identifierName}' has already been declared.`,
  2702. VoidPatternCatchClauseParam: "A void binding can not be the catch clause parameter. Use `try { ... } catch { ... }` if you want to discard the caught error.",
  2703. VoidPatternInitializer: "A void binding may not have an initializer.",
  2704. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  2705. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  2706. YieldNotInGeneratorFunction: "'yield' is only allowed within generator functions.",
  2707. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  2708. };
  2709. var StrictModeErrors = {
  2710. StrictDelete: "Deleting local variable in strict mode.",
  2711. StrictEvalArguments: ({
  2712. referenceName
  2713. }) => `Assigning to '${referenceName}' in strict mode.`,
  2714. StrictEvalArgumentsBinding: ({
  2715. bindingName
  2716. }) => `Binding '${bindingName}' in strict mode.`,
  2717. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  2718. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  2719. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  2720. StrictWith: "'with' in strict mode."
  2721. };
  2722. var ParseExpressionErrors = {
  2723. ParseExpressionEmptyInput: "Unexpected parseExpression() input: The input is empty or contains only comments.",
  2724. ParseExpressionExpectsEOF: ({
  2725. unexpected
  2726. }) => `Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`${String.fromCodePoint(unexpected)}\`.`
  2727. };
  2728. const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
  2729. var PipelineOperatorErrors = Object.assign({
  2730. PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  2731. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  2732. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  2733. PipeTopicUnconfiguredToken: ({
  2734. token
  2735. }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
  2736. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  2737. PipeUnparenthesizedBody: ({
  2738. type
  2739. }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
  2740. type
  2741. })}; please wrap it in parentheses.`
  2742. }, {
  2743. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  2744. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  2745. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  2746. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  2747. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  2748. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
  2749. });
  2750. const _excluded = ["message"];
  2751. function defineHidden(obj, key, value) {
  2752. Object.defineProperty(obj, key, {
  2753. enumerable: false,
  2754. configurable: true,
  2755. value
  2756. });
  2757. }
  2758. function toParseErrorConstructor({
  2759. toMessage,
  2760. code,
  2761. reasonCode,
  2762. syntaxPlugin
  2763. }) {
  2764. const hasMissingPlugin = reasonCode === "MissingPlugin" || reasonCode === "MissingOneOfPlugins";
  2765. {
  2766. const oldReasonCodes = {
  2767. AccessorCannotDeclareThisParameter: "AccesorCannotDeclareThisParameter",
  2768. AccessorCannotHaveTypeParameters: "AccesorCannotHaveTypeParameters",
  2769. ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference: "ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference",
  2770. SetAccessorCannotHaveOptionalParameter: "SetAccesorCannotHaveOptionalParameter",
  2771. SetAccessorCannotHaveRestParameter: "SetAccesorCannotHaveRestParameter",
  2772. SetAccessorCannotHaveReturnType: "SetAccesorCannotHaveReturnType"
  2773. };
  2774. if (oldReasonCodes[reasonCode]) {
  2775. reasonCode = oldReasonCodes[reasonCode];
  2776. }
  2777. }
  2778. return function constructor(loc, details) {
  2779. const error = new SyntaxError();
  2780. error.code = code;
  2781. error.reasonCode = reasonCode;
  2782. error.loc = loc;
  2783. error.pos = loc.index;
  2784. error.syntaxPlugin = syntaxPlugin;
  2785. if (hasMissingPlugin) {
  2786. error.missingPlugin = details.missingPlugin;
  2787. }
  2788. defineHidden(error, "clone", function clone(overrides = {}) {
  2789. var _overrides$loc;
  2790. const {
  2791. line,
  2792. column,
  2793. index
  2794. } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
  2795. return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
  2796. });
  2797. defineHidden(error, "details", details);
  2798. Object.defineProperty(error, "message", {
  2799. configurable: true,
  2800. get() {
  2801. const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
  2802. this.message = message;
  2803. return message;
  2804. },
  2805. set(value) {
  2806. Object.defineProperty(this, "message", {
  2807. value,
  2808. writable: true
  2809. });
  2810. }
  2811. });
  2812. return error;
  2813. };
  2814. }
  2815. function ParseErrorEnum(argument, syntaxPlugin) {
  2816. if (Array.isArray(argument)) {
  2817. return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
  2818. }
  2819. const ParseErrorConstructors = {};
  2820. for (const reasonCode of Object.keys(argument)) {
  2821. const template = argument[reasonCode];
  2822. const _ref = typeof template === "string" ? {
  2823. message: () => template
  2824. } : typeof template === "function" ? {
  2825. message: template
  2826. } : template,
  2827. {
  2828. message
  2829. } = _ref,
  2830. rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  2831. const toMessage = typeof message === "string" ? () => message : message;
  2832. ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
  2833. code: "BABEL_PARSER_SYNTAX_ERROR",
  2834. reasonCode,
  2835. toMessage
  2836. }, syntaxPlugin ? {
  2837. syntaxPlugin
  2838. } : {}, rest));
  2839. }
  2840. return ParseErrorConstructors;
  2841. }
  2842. const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum(ParseExpressionErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
  2843. function createDefaultOptions() {
  2844. return {
  2845. sourceType: "script",
  2846. sourceFilename: undefined,
  2847. startIndex: 0,
  2848. startColumn: 0,
  2849. startLine: 1,
  2850. allowAwaitOutsideFunction: false,
  2851. allowReturnOutsideFunction: false,
  2852. allowNewTargetOutsideFunction: false,
  2853. allowImportExportEverywhere: false,
  2854. allowSuperOutsideMethod: false,
  2855. allowUndeclaredExports: false,
  2856. allowYieldOutsideFunction: false,
  2857. plugins: [],
  2858. strictMode: null,
  2859. ranges: false,
  2860. tokens: false,
  2861. createImportExpressions: false,
  2862. createParenthesizedExpressions: false,
  2863. errorRecovery: false,
  2864. attachComment: true,
  2865. annexB: true
  2866. };
  2867. }
  2868. function getOptions(opts) {
  2869. const options = createDefaultOptions();
  2870. if (opts == null) {
  2871. return options;
  2872. }
  2873. if (opts.annexB != null && opts.annexB !== false) {
  2874. throw new Error("The `annexB` option can only be set to `false`.");
  2875. }
  2876. for (const key of Object.keys(options)) {
  2877. if (opts[key] != null) options[key] = opts[key];
  2878. }
  2879. if (options.startLine === 1) {
  2880. if (opts.startIndex == null && options.startColumn > 0) {
  2881. options.startIndex = options.startColumn;
  2882. } else if (opts.startColumn == null && options.startIndex > 0) {
  2883. options.startColumn = options.startIndex;
  2884. }
  2885. } else if (opts.startColumn == null || opts.startIndex == null) {
  2886. if (opts.startIndex != null) {
  2887. throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");
  2888. }
  2889. }
  2890. if (options.sourceType === "commonjs") {
  2891. if (opts.allowAwaitOutsideFunction != null) {
  2892. throw new Error("The `allowAwaitOutsideFunction` option cannot be used with `sourceType: 'commonjs'`.");
  2893. }
  2894. if (opts.allowReturnOutsideFunction != null) {
  2895. throw new Error("`sourceType: 'commonjs'` implies `allowReturnOutsideFunction: true`, please remove the `allowReturnOutsideFunction` option or use `sourceType: 'script'`.");
  2896. }
  2897. if (opts.allowNewTargetOutsideFunction != null) {
  2898. throw new Error("`sourceType: 'commonjs'` implies `allowNewTargetOutsideFunction: true`, please remove the `allowNewTargetOutsideFunction` option or use `sourceType: 'script'`.");
  2899. }
  2900. }
  2901. return options;
  2902. }
  2903. const {
  2904. defineProperty
  2905. } = Object;
  2906. const toUnenumerable = (object, key) => {
  2907. if (object) {
  2908. defineProperty(object, key, {
  2909. enumerable: false,
  2910. value: object[key]
  2911. });
  2912. }
  2913. };
  2914. function toESTreeLocation(node) {
  2915. toUnenumerable(node.loc.start, "index");
  2916. toUnenumerable(node.loc.end, "index");
  2917. return node;
  2918. }
  2919. var estree = superClass => class ESTreeParserMixin extends superClass {
  2920. parse() {
  2921. const file = toESTreeLocation(super.parse());
  2922. if (this.optionFlags & 256) {
  2923. file.tokens = file.tokens.map(toESTreeLocation);
  2924. }
  2925. return file;
  2926. }
  2927. parseRegExpLiteral({
  2928. pattern,
  2929. flags
  2930. }) {
  2931. let regex = null;
  2932. try {
  2933. regex = new RegExp(pattern, flags);
  2934. } catch (_) {}
  2935. const node = this.estreeParseLiteral(regex);
  2936. node.regex = {
  2937. pattern,
  2938. flags
  2939. };
  2940. return node;
  2941. }
  2942. parseBigIntLiteral(value) {
  2943. let bigInt;
  2944. try {
  2945. bigInt = BigInt(value);
  2946. } catch (_unused) {
  2947. bigInt = null;
  2948. }
  2949. const node = this.estreeParseLiteral(bigInt);
  2950. node.bigint = String(node.value || value);
  2951. return node;
  2952. }
  2953. parseDecimalLiteral(value) {
  2954. const decimal = null;
  2955. const node = this.estreeParseLiteral(decimal);
  2956. node.decimal = String(node.value || value);
  2957. return node;
  2958. }
  2959. estreeParseLiteral(value) {
  2960. return this.parseLiteral(value, "Literal");
  2961. }
  2962. parseStringLiteral(value) {
  2963. return this.estreeParseLiteral(value);
  2964. }
  2965. parseNumericLiteral(value) {
  2966. return this.estreeParseLiteral(value);
  2967. }
  2968. parseNullLiteral() {
  2969. return this.estreeParseLiteral(null);
  2970. }
  2971. parseBooleanLiteral(value) {
  2972. return this.estreeParseLiteral(value);
  2973. }
  2974. estreeParseChainExpression(node, endLoc) {
  2975. const chain = this.startNodeAtNode(node);
  2976. chain.expression = node;
  2977. return this.finishNodeAt(chain, "ChainExpression", endLoc);
  2978. }
  2979. directiveToStmt(directive) {
  2980. const expression = directive.value;
  2981. delete directive.value;
  2982. this.castNodeTo(expression, "Literal");
  2983. expression.raw = expression.extra.raw;
  2984. expression.value = expression.extra.expressionValue;
  2985. const stmt = this.castNodeTo(directive, "ExpressionStatement");
  2986. stmt.expression = expression;
  2987. stmt.directive = expression.extra.rawValue;
  2988. delete expression.extra;
  2989. return stmt;
  2990. }
  2991. fillOptionalPropertiesForTSESLint(node) {}
  2992. cloneEstreeStringLiteral(node) {
  2993. const {
  2994. start,
  2995. end,
  2996. loc,
  2997. range,
  2998. raw,
  2999. value
  3000. } = node;
  3001. const cloned = Object.create(node.constructor.prototype);
  3002. cloned.type = "Literal";
  3003. cloned.start = start;
  3004. cloned.end = end;
  3005. cloned.loc = loc;
  3006. cloned.range = range;
  3007. cloned.raw = raw;
  3008. cloned.value = value;
  3009. return cloned;
  3010. }
  3011. initFunction(node, isAsync) {
  3012. super.initFunction(node, isAsync);
  3013. node.expression = false;
  3014. }
  3015. checkDeclaration(node) {
  3016. if (node != null && this.isObjectProperty(node)) {
  3017. this.checkDeclaration(node.value);
  3018. } else {
  3019. super.checkDeclaration(node);
  3020. }
  3021. }
  3022. getObjectOrClassMethodParams(method) {
  3023. return method.value.params;
  3024. }
  3025. isValidDirective(stmt) {
  3026. var _stmt$expression$extr;
  3027. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  3028. }
  3029. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  3030. super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
  3031. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  3032. node.body = directiveStatements.concat(node.body);
  3033. delete node.directives;
  3034. }
  3035. parsePrivateName() {
  3036. const node = super.parsePrivateName();
  3037. {
  3038. if (!this.getPluginOption("estree", "classFeatures")) {
  3039. return node;
  3040. }
  3041. }
  3042. return this.convertPrivateNameToPrivateIdentifier(node);
  3043. }
  3044. convertPrivateNameToPrivateIdentifier(node) {
  3045. const name = super.getPrivateNameSV(node);
  3046. node = node;
  3047. delete node.id;
  3048. node.name = name;
  3049. return this.castNodeTo(node, "PrivateIdentifier");
  3050. }
  3051. isPrivateName(node) {
  3052. {
  3053. if (!this.getPluginOption("estree", "classFeatures")) {
  3054. return super.isPrivateName(node);
  3055. }
  3056. }
  3057. return node.type === "PrivateIdentifier";
  3058. }
  3059. getPrivateNameSV(node) {
  3060. {
  3061. if (!this.getPluginOption("estree", "classFeatures")) {
  3062. return super.getPrivateNameSV(node);
  3063. }
  3064. }
  3065. return node.name;
  3066. }
  3067. parseLiteral(value, type) {
  3068. const node = super.parseLiteral(value, type);
  3069. node.raw = node.extra.raw;
  3070. delete node.extra;
  3071. return node;
  3072. }
  3073. parseFunctionBody(node, allowExpression, isMethod = false) {
  3074. super.parseFunctionBody(node, allowExpression, isMethod);
  3075. node.expression = node.body.type !== "BlockStatement";
  3076. }
  3077. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  3078. let funcNode = this.startNode();
  3079. funcNode.kind = node.kind;
  3080. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  3081. delete funcNode.kind;
  3082. const {
  3083. typeParameters
  3084. } = node;
  3085. if (typeParameters) {
  3086. delete node.typeParameters;
  3087. funcNode.typeParameters = typeParameters;
  3088. this.resetStartLocationFromNode(funcNode, typeParameters);
  3089. }
  3090. const valueNode = this.castNodeTo(funcNode, "FunctionExpression");
  3091. node.value = valueNode;
  3092. if (type === "ClassPrivateMethod") {
  3093. node.computed = false;
  3094. }
  3095. if (type === "ObjectMethod") {
  3096. if (node.kind === "method") {
  3097. node.kind = "init";
  3098. }
  3099. node.shorthand = false;
  3100. return this.finishNode(node, "Property");
  3101. } else {
  3102. return this.finishNode(node, "MethodDefinition");
  3103. }
  3104. }
  3105. nameIsConstructor(key) {
  3106. if (key.type === "Literal") return key.value === "constructor";
  3107. return super.nameIsConstructor(key);
  3108. }
  3109. parseClassProperty(...args) {
  3110. const propertyNode = super.parseClassProperty(...args);
  3111. {
  3112. if (!this.getPluginOption("estree", "classFeatures")) {
  3113. return propertyNode;
  3114. }
  3115. }
  3116. {
  3117. this.castNodeTo(propertyNode, "PropertyDefinition");
  3118. }
  3119. return propertyNode;
  3120. }
  3121. parseClassPrivateProperty(...args) {
  3122. const propertyNode = super.parseClassPrivateProperty(...args);
  3123. {
  3124. if (!this.getPluginOption("estree", "classFeatures")) {
  3125. return propertyNode;
  3126. }
  3127. }
  3128. {
  3129. this.castNodeTo(propertyNode, "PropertyDefinition");
  3130. }
  3131. propertyNode.computed = false;
  3132. return propertyNode;
  3133. }
  3134. parseClassAccessorProperty(node) {
  3135. const accessorPropertyNode = super.parseClassAccessorProperty(node);
  3136. {
  3137. if (!this.getPluginOption("estree", "classFeatures")) {
  3138. return accessorPropertyNode;
  3139. }
  3140. }
  3141. if (accessorPropertyNode.abstract && this.hasPlugin("typescript")) {
  3142. delete accessorPropertyNode.abstract;
  3143. this.castNodeTo(accessorPropertyNode, "TSAbstractAccessorProperty");
  3144. } else {
  3145. this.castNodeTo(accessorPropertyNode, "AccessorProperty");
  3146. }
  3147. return accessorPropertyNode;
  3148. }
  3149. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  3150. const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  3151. if (node) {
  3152. node.kind = "init";
  3153. this.castNodeTo(node, "Property");
  3154. }
  3155. return node;
  3156. }
  3157. finishObjectProperty(node) {
  3158. node.kind = "init";
  3159. return this.finishNode(node, "Property");
  3160. }
  3161. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  3162. return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  3163. }
  3164. isAssignable(node, isBinding) {
  3165. if (node != null && this.isObjectProperty(node)) {
  3166. return this.isAssignable(node.value, isBinding);
  3167. }
  3168. return super.isAssignable(node, isBinding);
  3169. }
  3170. toAssignable(node, isLHS = false) {
  3171. if (node != null && this.isObjectProperty(node)) {
  3172. const {
  3173. key,
  3174. value
  3175. } = node;
  3176. if (this.isPrivateName(key)) {
  3177. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  3178. }
  3179. this.toAssignable(value, isLHS);
  3180. } else {
  3181. super.toAssignable(node, isLHS);
  3182. }
  3183. }
  3184. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  3185. if (prop.type === "Property" && (prop.kind === "get" || prop.kind === "set")) {
  3186. this.raise(Errors.PatternHasAccessor, prop.key);
  3187. } else if (prop.type === "Property" && prop.method) {
  3188. this.raise(Errors.PatternHasMethod, prop.key);
  3189. } else {
  3190. super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  3191. }
  3192. }
  3193. finishCallExpression(unfinished, optional) {
  3194. const node = super.finishCallExpression(unfinished, optional);
  3195. if (node.callee.type === "Import") {
  3196. var _ref;
  3197. this.castNodeTo(node, "ImportExpression");
  3198. node.source = node.arguments[0];
  3199. node.options = (_ref = node.arguments[1]) != null ? _ref : null;
  3200. {
  3201. var _ref2;
  3202. node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
  3203. }
  3204. delete node.arguments;
  3205. delete node.callee;
  3206. } else if (node.type === "OptionalCallExpression") {
  3207. this.castNodeTo(node, "CallExpression");
  3208. } else {
  3209. node.optional = false;
  3210. }
  3211. return node;
  3212. }
  3213. toReferencedArguments(node) {
  3214. if (node.type === "ImportExpression") {
  3215. return;
  3216. }
  3217. super.toReferencedArguments(node);
  3218. }
  3219. parseExport(unfinished, decorators) {
  3220. const exportStartLoc = this.state.lastTokStartLoc;
  3221. const node = super.parseExport(unfinished, decorators);
  3222. switch (node.type) {
  3223. case "ExportAllDeclaration":
  3224. node.exported = null;
  3225. break;
  3226. case "ExportNamedDeclaration":
  3227. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  3228. this.castNodeTo(node, "ExportAllDeclaration");
  3229. node.exported = node.specifiers[0].exported;
  3230. delete node.specifiers;
  3231. }
  3232. case "ExportDefaultDeclaration":
  3233. {
  3234. var _declaration$decorato;
  3235. const {
  3236. declaration
  3237. } = node;
  3238. if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) {
  3239. this.resetStartLocation(node, exportStartLoc);
  3240. }
  3241. }
  3242. break;
  3243. }
  3244. return node;
  3245. }
  3246. stopParseSubscript(base, state) {
  3247. const node = super.stopParseSubscript(base, state);
  3248. if (state.optionalChainMember) {
  3249. return this.estreeParseChainExpression(node, base.loc.end);
  3250. }
  3251. return node;
  3252. }
  3253. parseMember(base, startLoc, state, computed, optional) {
  3254. const node = super.parseMember(base, startLoc, state, computed, optional);
  3255. if (node.type === "OptionalMemberExpression") {
  3256. this.castNodeTo(node, "MemberExpression");
  3257. } else {
  3258. node.optional = false;
  3259. }
  3260. return node;
  3261. }
  3262. isOptionalMemberExpression(node) {
  3263. if (node.type === "ChainExpression") {
  3264. return node.expression.type === "MemberExpression";
  3265. }
  3266. return super.isOptionalMemberExpression(node);
  3267. }
  3268. hasPropertyAsPrivateName(node) {
  3269. if (node.type === "ChainExpression") {
  3270. node = node.expression;
  3271. }
  3272. return super.hasPropertyAsPrivateName(node);
  3273. }
  3274. isObjectProperty(node) {
  3275. return node.type === "Property" && node.kind === "init" && !node.method;
  3276. }
  3277. isObjectMethod(node) {
  3278. return node.type === "Property" && (node.method || node.kind === "get" || node.kind === "set");
  3279. }
  3280. castNodeTo(node, type) {
  3281. const result = super.castNodeTo(node, type);
  3282. this.fillOptionalPropertiesForTSESLint(result);
  3283. return result;
  3284. }
  3285. cloneIdentifier(node) {
  3286. const cloned = super.cloneIdentifier(node);
  3287. this.fillOptionalPropertiesForTSESLint(cloned);
  3288. return cloned;
  3289. }
  3290. cloneStringLiteral(node) {
  3291. if (node.type === "Literal") {
  3292. return this.cloneEstreeStringLiteral(node);
  3293. }
  3294. return super.cloneStringLiteral(node);
  3295. }
  3296. finishNodeAt(node, type, endLoc) {
  3297. return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
  3298. }
  3299. finishNode(node, type) {
  3300. const result = super.finishNode(node, type);
  3301. this.fillOptionalPropertiesForTSESLint(result);
  3302. return result;
  3303. }
  3304. resetStartLocation(node, startLoc) {
  3305. super.resetStartLocation(node, startLoc);
  3306. toESTreeLocation(node);
  3307. }
  3308. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  3309. super.resetEndLocation(node, endLoc);
  3310. toESTreeLocation(node);
  3311. }
  3312. };
  3313. class TokContext {
  3314. constructor(token, preserveSpace) {
  3315. this.token = void 0;
  3316. this.preserveSpace = void 0;
  3317. this.token = token;
  3318. this.preserveSpace = !!preserveSpace;
  3319. }
  3320. }
  3321. const types = {
  3322. brace: new TokContext("{"),
  3323. j_oTag: new TokContext("<tag"),
  3324. j_cTag: new TokContext("</tag"),
  3325. j_expr: new TokContext("<tag>...</tag>", true)
  3326. };
  3327. {
  3328. types.template = new TokContext("`", true);
  3329. }
  3330. const beforeExpr = true;
  3331. const startsExpr = true;
  3332. const isLoop = true;
  3333. const isAssign = true;
  3334. const prefix = true;
  3335. const postfix = true;
  3336. class ExportedTokenType {
  3337. constructor(label, conf = {}) {
  3338. this.label = void 0;
  3339. this.keyword = void 0;
  3340. this.beforeExpr = void 0;
  3341. this.startsExpr = void 0;
  3342. this.rightAssociative = void 0;
  3343. this.isLoop = void 0;
  3344. this.isAssign = void 0;
  3345. this.prefix = void 0;
  3346. this.postfix = void 0;
  3347. this.binop = void 0;
  3348. this.label = label;
  3349. this.keyword = conf.keyword;
  3350. this.beforeExpr = !!conf.beforeExpr;
  3351. this.startsExpr = !!conf.startsExpr;
  3352. this.rightAssociative = !!conf.rightAssociative;
  3353. this.isLoop = !!conf.isLoop;
  3354. this.isAssign = !!conf.isAssign;
  3355. this.prefix = !!conf.prefix;
  3356. this.postfix = !!conf.postfix;
  3357. this.binop = conf.binop != null ? conf.binop : null;
  3358. {
  3359. this.updateContext = null;
  3360. }
  3361. }
  3362. }
  3363. const keywords$1 = new Map();
  3364. function createKeyword(name, options = {}) {
  3365. options.keyword = name;
  3366. const token = createToken(name, options);
  3367. keywords$1.set(name, token);
  3368. return token;
  3369. }
  3370. function createBinop(name, binop) {
  3371. return createToken(name, {
  3372. beforeExpr,
  3373. binop
  3374. });
  3375. }
  3376. let tokenTypeCounter = -1;
  3377. const tokenTypes = [];
  3378. const tokenLabels = [];
  3379. const tokenBinops = [];
  3380. const tokenBeforeExprs = [];
  3381. const tokenStartsExprs = [];
  3382. const tokenPrefixes = [];
  3383. function createToken(name, options = {}) {
  3384. var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
  3385. ++tokenTypeCounter;
  3386. tokenLabels.push(name);
  3387. tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
  3388. tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
  3389. tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
  3390. tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
  3391. tokenTypes.push(new ExportedTokenType(name, options));
  3392. return tokenTypeCounter;
  3393. }
  3394. function createKeywordLike(name, options = {}) {
  3395. var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
  3396. ++tokenTypeCounter;
  3397. keywords$1.set(name, tokenTypeCounter);
  3398. tokenLabels.push(name);
  3399. tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
  3400. tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
  3401. tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
  3402. tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
  3403. tokenTypes.push(new ExportedTokenType("name", options));
  3404. return tokenTypeCounter;
  3405. }
  3406. const tt = {
  3407. bracketL: createToken("[", {
  3408. beforeExpr,
  3409. startsExpr
  3410. }),
  3411. bracketHashL: createToken("#[", {
  3412. beforeExpr,
  3413. startsExpr
  3414. }),
  3415. bracketBarL: createToken("[|", {
  3416. beforeExpr,
  3417. startsExpr
  3418. }),
  3419. bracketR: createToken("]"),
  3420. bracketBarR: createToken("|]"),
  3421. braceL: createToken("{", {
  3422. beforeExpr,
  3423. startsExpr
  3424. }),
  3425. braceBarL: createToken("{|", {
  3426. beforeExpr,
  3427. startsExpr
  3428. }),
  3429. braceHashL: createToken("#{", {
  3430. beforeExpr,
  3431. startsExpr
  3432. }),
  3433. braceR: createToken("}"),
  3434. braceBarR: createToken("|}"),
  3435. parenL: createToken("(", {
  3436. beforeExpr,
  3437. startsExpr
  3438. }),
  3439. parenR: createToken(")"),
  3440. comma: createToken(",", {
  3441. beforeExpr
  3442. }),
  3443. semi: createToken(";", {
  3444. beforeExpr
  3445. }),
  3446. colon: createToken(":", {
  3447. beforeExpr
  3448. }),
  3449. doubleColon: createToken("::", {
  3450. beforeExpr
  3451. }),
  3452. dot: createToken("."),
  3453. question: createToken("?", {
  3454. beforeExpr
  3455. }),
  3456. questionDot: createToken("?."),
  3457. arrow: createToken("=>", {
  3458. beforeExpr
  3459. }),
  3460. template: createToken("template"),
  3461. ellipsis: createToken("...", {
  3462. beforeExpr
  3463. }),
  3464. backQuote: createToken("`", {
  3465. startsExpr
  3466. }),
  3467. dollarBraceL: createToken("${", {
  3468. beforeExpr,
  3469. startsExpr
  3470. }),
  3471. templateTail: createToken("...`", {
  3472. startsExpr
  3473. }),
  3474. templateNonTail: createToken("...${", {
  3475. beforeExpr,
  3476. startsExpr
  3477. }),
  3478. at: createToken("@"),
  3479. hash: createToken("#", {
  3480. startsExpr
  3481. }),
  3482. interpreterDirective: createToken("#!..."),
  3483. eq: createToken("=", {
  3484. beforeExpr,
  3485. isAssign
  3486. }),
  3487. assign: createToken("_=", {
  3488. beforeExpr,
  3489. isAssign
  3490. }),
  3491. slashAssign: createToken("_=", {
  3492. beforeExpr,
  3493. isAssign
  3494. }),
  3495. xorAssign: createToken("_=", {
  3496. beforeExpr,
  3497. isAssign
  3498. }),
  3499. moduloAssign: createToken("_=", {
  3500. beforeExpr,
  3501. isAssign
  3502. }),
  3503. incDec: createToken("++/--", {
  3504. prefix,
  3505. postfix,
  3506. startsExpr
  3507. }),
  3508. bang: createToken("!", {
  3509. beforeExpr,
  3510. prefix,
  3511. startsExpr
  3512. }),
  3513. tilde: createToken("~", {
  3514. beforeExpr,
  3515. prefix,
  3516. startsExpr
  3517. }),
  3518. doubleCaret: createToken("^^", {
  3519. startsExpr
  3520. }),
  3521. doubleAt: createToken("@@", {
  3522. startsExpr
  3523. }),
  3524. pipeline: createBinop("|>", 0),
  3525. nullishCoalescing: createBinop("??", 1),
  3526. logicalOR: createBinop("||", 1),
  3527. logicalAND: createBinop("&&", 2),
  3528. bitwiseOR: createBinop("|", 3),
  3529. bitwiseXOR: createBinop("^", 4),
  3530. bitwiseAND: createBinop("&", 5),
  3531. equality: createBinop("==/!=/===/!==", 6),
  3532. lt: createBinop("</>/<=/>=", 7),
  3533. gt: createBinop("</>/<=/>=", 7),
  3534. relational: createBinop("</>/<=/>=", 7),
  3535. bitShift: createBinop("<</>>/>>>", 8),
  3536. bitShiftL: createBinop("<</>>/>>>", 8),
  3537. bitShiftR: createBinop("<</>>/>>>", 8),
  3538. plusMin: createToken("+/-", {
  3539. beforeExpr,
  3540. binop: 9,
  3541. prefix,
  3542. startsExpr
  3543. }),
  3544. modulo: createToken("%", {
  3545. binop: 10,
  3546. startsExpr
  3547. }),
  3548. star: createToken("*", {
  3549. binop: 10
  3550. }),
  3551. slash: createBinop("/", 10),
  3552. exponent: createToken("**", {
  3553. beforeExpr,
  3554. binop: 11,
  3555. rightAssociative: true
  3556. }),
  3557. _in: createKeyword("in", {
  3558. beforeExpr,
  3559. binop: 7
  3560. }),
  3561. _instanceof: createKeyword("instanceof", {
  3562. beforeExpr,
  3563. binop: 7
  3564. }),
  3565. _break: createKeyword("break"),
  3566. _case: createKeyword("case", {
  3567. beforeExpr
  3568. }),
  3569. _catch: createKeyword("catch"),
  3570. _continue: createKeyword("continue"),
  3571. _debugger: createKeyword("debugger"),
  3572. _default: createKeyword("default", {
  3573. beforeExpr
  3574. }),
  3575. _else: createKeyword("else", {
  3576. beforeExpr
  3577. }),
  3578. _finally: createKeyword("finally"),
  3579. _function: createKeyword("function", {
  3580. startsExpr
  3581. }),
  3582. _if: createKeyword("if"),
  3583. _return: createKeyword("return", {
  3584. beforeExpr
  3585. }),
  3586. _switch: createKeyword("switch"),
  3587. _throw: createKeyword("throw", {
  3588. beforeExpr,
  3589. prefix,
  3590. startsExpr
  3591. }),
  3592. _try: createKeyword("try"),
  3593. _var: createKeyword("var"),
  3594. _const: createKeyword("const"),
  3595. _with: createKeyword("with"),
  3596. _new: createKeyword("new", {
  3597. beforeExpr,
  3598. startsExpr
  3599. }),
  3600. _this: createKeyword("this", {
  3601. startsExpr
  3602. }),
  3603. _super: createKeyword("super", {
  3604. startsExpr
  3605. }),
  3606. _class: createKeyword("class", {
  3607. startsExpr
  3608. }),
  3609. _extends: createKeyword("extends", {
  3610. beforeExpr
  3611. }),
  3612. _export: createKeyword("export"),
  3613. _import: createKeyword("import", {
  3614. startsExpr
  3615. }),
  3616. _null: createKeyword("null", {
  3617. startsExpr
  3618. }),
  3619. _true: createKeyword("true", {
  3620. startsExpr
  3621. }),
  3622. _false: createKeyword("false", {
  3623. startsExpr
  3624. }),
  3625. _typeof: createKeyword("typeof", {
  3626. beforeExpr,
  3627. prefix,
  3628. startsExpr
  3629. }),
  3630. _void: createKeyword("void", {
  3631. beforeExpr,
  3632. prefix,
  3633. startsExpr
  3634. }),
  3635. _delete: createKeyword("delete", {
  3636. beforeExpr,
  3637. prefix,
  3638. startsExpr
  3639. }),
  3640. _do: createKeyword("do", {
  3641. isLoop,
  3642. beforeExpr
  3643. }),
  3644. _for: createKeyword("for", {
  3645. isLoop
  3646. }),
  3647. _while: createKeyword("while", {
  3648. isLoop
  3649. }),
  3650. _as: createKeywordLike("as", {
  3651. startsExpr
  3652. }),
  3653. _assert: createKeywordLike("assert", {
  3654. startsExpr
  3655. }),
  3656. _async: createKeywordLike("async", {
  3657. startsExpr
  3658. }),
  3659. _await: createKeywordLike("await", {
  3660. startsExpr
  3661. }),
  3662. _defer: createKeywordLike("defer", {
  3663. startsExpr
  3664. }),
  3665. _from: createKeywordLike("from", {
  3666. startsExpr
  3667. }),
  3668. _get: createKeywordLike("get", {
  3669. startsExpr
  3670. }),
  3671. _let: createKeywordLike("let", {
  3672. startsExpr
  3673. }),
  3674. _meta: createKeywordLike("meta", {
  3675. startsExpr
  3676. }),
  3677. _of: createKeywordLike("of", {
  3678. startsExpr
  3679. }),
  3680. _sent: createKeywordLike("sent", {
  3681. startsExpr
  3682. }),
  3683. _set: createKeywordLike("set", {
  3684. startsExpr
  3685. }),
  3686. _source: createKeywordLike("source", {
  3687. startsExpr
  3688. }),
  3689. _static: createKeywordLike("static", {
  3690. startsExpr
  3691. }),
  3692. _using: createKeywordLike("using", {
  3693. startsExpr
  3694. }),
  3695. _yield: createKeywordLike("yield", {
  3696. startsExpr
  3697. }),
  3698. _asserts: createKeywordLike("asserts", {
  3699. startsExpr
  3700. }),
  3701. _checks: createKeywordLike("checks", {
  3702. startsExpr
  3703. }),
  3704. _exports: createKeywordLike("exports", {
  3705. startsExpr
  3706. }),
  3707. _global: createKeywordLike("global", {
  3708. startsExpr
  3709. }),
  3710. _implements: createKeywordLike("implements", {
  3711. startsExpr
  3712. }),
  3713. _intrinsic: createKeywordLike("intrinsic", {
  3714. startsExpr
  3715. }),
  3716. _infer: createKeywordLike("infer", {
  3717. startsExpr
  3718. }),
  3719. _is: createKeywordLike("is", {
  3720. startsExpr
  3721. }),
  3722. _mixins: createKeywordLike("mixins", {
  3723. startsExpr
  3724. }),
  3725. _proto: createKeywordLike("proto", {
  3726. startsExpr
  3727. }),
  3728. _require: createKeywordLike("require", {
  3729. startsExpr
  3730. }),
  3731. _satisfies: createKeywordLike("satisfies", {
  3732. startsExpr
  3733. }),
  3734. _keyof: createKeywordLike("keyof", {
  3735. startsExpr
  3736. }),
  3737. _readonly: createKeywordLike("readonly", {
  3738. startsExpr
  3739. }),
  3740. _unique: createKeywordLike("unique", {
  3741. startsExpr
  3742. }),
  3743. _abstract: createKeywordLike("abstract", {
  3744. startsExpr
  3745. }),
  3746. _declare: createKeywordLike("declare", {
  3747. startsExpr
  3748. }),
  3749. _enum: createKeywordLike("enum", {
  3750. startsExpr
  3751. }),
  3752. _module: createKeywordLike("module", {
  3753. startsExpr
  3754. }),
  3755. _namespace: createKeywordLike("namespace", {
  3756. startsExpr
  3757. }),
  3758. _interface: createKeywordLike("interface", {
  3759. startsExpr
  3760. }),
  3761. _type: createKeywordLike("type", {
  3762. startsExpr
  3763. }),
  3764. _opaque: createKeywordLike("opaque", {
  3765. startsExpr
  3766. }),
  3767. name: createToken("name", {
  3768. startsExpr
  3769. }),
  3770. placeholder: createToken("%%", {
  3771. startsExpr
  3772. }),
  3773. string: createToken("string", {
  3774. startsExpr
  3775. }),
  3776. num: createToken("num", {
  3777. startsExpr
  3778. }),
  3779. bigint: createToken("bigint", {
  3780. startsExpr
  3781. }),
  3782. decimal: createToken("decimal", {
  3783. startsExpr
  3784. }),
  3785. regexp: createToken("regexp", {
  3786. startsExpr
  3787. }),
  3788. privateName: createToken("#name", {
  3789. startsExpr
  3790. }),
  3791. eof: createToken("eof"),
  3792. jsxName: createToken("jsxName"),
  3793. jsxText: createToken("jsxText", {
  3794. beforeExpr
  3795. }),
  3796. jsxTagStart: createToken("jsxTagStart", {
  3797. startsExpr
  3798. }),
  3799. jsxTagEnd: createToken("jsxTagEnd")
  3800. };
  3801. function tokenIsIdentifier(token) {
  3802. return token >= 93 && token <= 133;
  3803. }
  3804. function tokenKeywordOrIdentifierIsKeyword(token) {
  3805. return token <= 92;
  3806. }
  3807. function tokenIsKeywordOrIdentifier(token) {
  3808. return token >= 58 && token <= 133;
  3809. }
  3810. function tokenIsLiteralPropertyName(token) {
  3811. return token >= 58 && token <= 137;
  3812. }
  3813. function tokenComesBeforeExpression(token) {
  3814. return tokenBeforeExprs[token];
  3815. }
  3816. function tokenCanStartExpression(token) {
  3817. return tokenStartsExprs[token];
  3818. }
  3819. function tokenIsAssignment(token) {
  3820. return token >= 29 && token <= 33;
  3821. }
  3822. function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
  3823. return token >= 129 && token <= 131;
  3824. }
  3825. function tokenIsLoop(token) {
  3826. return token >= 90 && token <= 92;
  3827. }
  3828. function tokenIsKeyword(token) {
  3829. return token >= 58 && token <= 92;
  3830. }
  3831. function tokenIsOperator(token) {
  3832. return token >= 39 && token <= 59;
  3833. }
  3834. function tokenIsPostfix(token) {
  3835. return token === 34;
  3836. }
  3837. function tokenIsPrefix(token) {
  3838. return tokenPrefixes[token];
  3839. }
  3840. function tokenIsTSTypeOperator(token) {
  3841. return token >= 121 && token <= 123;
  3842. }
  3843. function tokenIsTSDeclarationStart(token) {
  3844. return token >= 124 && token <= 130;
  3845. }
  3846. function tokenLabelName(token) {
  3847. return tokenLabels[token];
  3848. }
  3849. function tokenOperatorPrecedence(token) {
  3850. return tokenBinops[token];
  3851. }
  3852. function tokenIsRightAssociative(token) {
  3853. return token === 57;
  3854. }
  3855. function tokenIsTemplate(token) {
  3856. return token >= 24 && token <= 25;
  3857. }
  3858. function getExportedToken(token) {
  3859. return tokenTypes[token];
  3860. }
  3861. {
  3862. tokenTypes[8].updateContext = context => {
  3863. context.pop();
  3864. };
  3865. tokenTypes[5].updateContext = tokenTypes[7].updateContext = tokenTypes[23].updateContext = context => {
  3866. context.push(types.brace);
  3867. };
  3868. tokenTypes[22].updateContext = context => {
  3869. if (context[context.length - 1] === types.template) {
  3870. context.pop();
  3871. } else {
  3872. context.push(types.template);
  3873. }
  3874. };
  3875. tokenTypes[143].updateContext = context => {
  3876. context.push(types.j_expr, types.j_oTag);
  3877. };
  3878. }
  3879. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7cd\ua7d0\ua7d1\ua7d3\ua7d5-\ua7dc\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  3880. let nonASCIIidentifierChars = "\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
  3881. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3882. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3883. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  3884. const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 2, 60, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 496, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
  3885. const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 80, 3, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 343, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  3886. function isInAstralSet(code, set) {
  3887. let pos = 0x10000;
  3888. for (let i = 0, length = set.length; i < length; i += 2) {
  3889. pos += set[i];
  3890. if (pos > code) return false;
  3891. pos += set[i + 1];
  3892. if (pos >= code) return true;
  3893. }
  3894. return false;
  3895. }
  3896. function isIdentifierStart(code) {
  3897. if (code < 65) return code === 36;
  3898. if (code <= 90) return true;
  3899. if (code < 97) return code === 95;
  3900. if (code <= 122) return true;
  3901. if (code <= 0xffff) {
  3902. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  3903. }
  3904. return isInAstralSet(code, astralIdentifierStartCodes);
  3905. }
  3906. function isIdentifierChar(code) {
  3907. if (code < 48) return code === 36;
  3908. if (code < 58) return true;
  3909. if (code < 65) return false;
  3910. if (code <= 90) return true;
  3911. if (code < 97) return code === 95;
  3912. if (code <= 122) return true;
  3913. if (code <= 0xffff) {
  3914. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  3915. }
  3916. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  3917. }
  3918. const reservedWords = {
  3919. keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
  3920. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  3921. strictBind: ["eval", "arguments"]
  3922. };
  3923. const keywords = new Set(reservedWords.keyword);
  3924. const reservedWordsStrictSet = new Set(reservedWords.strict);
  3925. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  3926. function isReservedWord(word, inModule) {
  3927. return inModule && word === "await" || word === "enum";
  3928. }
  3929. function isStrictReservedWord(word, inModule) {
  3930. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  3931. }
  3932. function isStrictBindOnlyReservedWord(word) {
  3933. return reservedWordsStrictBindSet.has(word);
  3934. }
  3935. function isStrictBindReservedWord(word, inModule) {
  3936. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  3937. }
  3938. function isKeyword(word) {
  3939. return keywords.has(word);
  3940. }
  3941. function isIteratorStart(current, next, next2) {
  3942. return current === 64 && next === 64 && isIdentifierStart(next2);
  3943. }
  3944. const reservedWordLikeSet = new Set(["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "eval", "arguments", "enum", "await"]);
  3945. function canBeReservedWord(word) {
  3946. return reservedWordLikeSet.has(word);
  3947. }
  3948. class Scope {
  3949. constructor(flags) {
  3950. this.flags = 0;
  3951. this.names = new Map();
  3952. this.firstLexicalName = "";
  3953. this.flags = flags;
  3954. }
  3955. }
  3956. class ScopeHandler {
  3957. constructor(parser, inModule) {
  3958. this.parser = void 0;
  3959. this.scopeStack = [];
  3960. this.inModule = void 0;
  3961. this.undefinedExports = new Map();
  3962. this.parser = parser;
  3963. this.inModule = inModule;
  3964. }
  3965. get inTopLevel() {
  3966. return (this.currentScope().flags & 1) > 0;
  3967. }
  3968. get inFunction() {
  3969. return (this.currentVarScopeFlags() & 2) > 0;
  3970. }
  3971. get allowSuper() {
  3972. return (this.currentThisScopeFlags() & 16) > 0;
  3973. }
  3974. get allowDirectSuper() {
  3975. return (this.currentThisScopeFlags() & 32) > 0;
  3976. }
  3977. get allowNewTarget() {
  3978. return (this.currentThisScopeFlags() & 512) > 0;
  3979. }
  3980. get inClass() {
  3981. return (this.currentThisScopeFlags() & 64) > 0;
  3982. }
  3983. get inClassAndNotInNonArrowFunction() {
  3984. const flags = this.currentThisScopeFlags();
  3985. return (flags & 64) > 0 && (flags & 2) === 0;
  3986. }
  3987. get inStaticBlock() {
  3988. for (let i = this.scopeStack.length - 1;; i--) {
  3989. const {
  3990. flags
  3991. } = this.scopeStack[i];
  3992. if (flags & 128) {
  3993. return true;
  3994. }
  3995. if (flags & (1667 | 64)) {
  3996. return false;
  3997. }
  3998. }
  3999. }
  4000. get inNonArrowFunction() {
  4001. return (this.currentThisScopeFlags() & 2) > 0;
  4002. }
  4003. get inBareCaseStatement() {
  4004. return (this.currentScope().flags & 256) > 0;
  4005. }
  4006. get treatFunctionsAsVar() {
  4007. return this.treatFunctionsAsVarInScope(this.currentScope());
  4008. }
  4009. createScope(flags) {
  4010. return new Scope(flags);
  4011. }
  4012. enter(flags) {
  4013. this.scopeStack.push(this.createScope(flags));
  4014. }
  4015. exit() {
  4016. const scope = this.scopeStack.pop();
  4017. return scope.flags;
  4018. }
  4019. treatFunctionsAsVarInScope(scope) {
  4020. return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1);
  4021. }
  4022. declareName(name, bindingType, loc) {
  4023. let scope = this.currentScope();
  4024. if (bindingType & 8 || bindingType & 16) {
  4025. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  4026. let type = scope.names.get(name) || 0;
  4027. if (bindingType & 16) {
  4028. type = type | 4;
  4029. } else {
  4030. if (!scope.firstLexicalName) {
  4031. scope.firstLexicalName = name;
  4032. }
  4033. type = type | 2;
  4034. }
  4035. scope.names.set(name, type);
  4036. if (bindingType & 8) {
  4037. this.maybeExportDefined(scope, name);
  4038. }
  4039. } else if (bindingType & 4) {
  4040. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  4041. scope = this.scopeStack[i];
  4042. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  4043. scope.names.set(name, (scope.names.get(name) || 0) | 1);
  4044. this.maybeExportDefined(scope, name);
  4045. if (scope.flags & 1667) break;
  4046. }
  4047. }
  4048. if (this.parser.inModule && scope.flags & 1) {
  4049. this.undefinedExports.delete(name);
  4050. }
  4051. }
  4052. maybeExportDefined(scope, name) {
  4053. if (this.parser.inModule && scope.flags & 1) {
  4054. this.undefinedExports.delete(name);
  4055. }
  4056. }
  4057. checkRedeclarationInScope(scope, name, bindingType, loc) {
  4058. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  4059. this.parser.raise(Errors.VarRedeclaration, loc, {
  4060. identifierName: name
  4061. });
  4062. }
  4063. }
  4064. isRedeclaredInScope(scope, name, bindingType) {
  4065. if (!(bindingType & 1)) return false;
  4066. if (bindingType & 8) {
  4067. return scope.names.has(name);
  4068. }
  4069. const type = scope.names.get(name);
  4070. if (bindingType & 16) {
  4071. return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0;
  4072. }
  4073. return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0;
  4074. }
  4075. checkLocalExport(id) {
  4076. const {
  4077. name
  4078. } = id;
  4079. const topLevelScope = this.scopeStack[0];
  4080. if (!topLevelScope.names.has(name)) {
  4081. this.undefinedExports.set(name, id.loc.start);
  4082. }
  4083. }
  4084. currentScope() {
  4085. return this.scopeStack[this.scopeStack.length - 1];
  4086. }
  4087. currentVarScopeFlags() {
  4088. for (let i = this.scopeStack.length - 1;; i--) {
  4089. const {
  4090. flags
  4091. } = this.scopeStack[i];
  4092. if (flags & 1667) {
  4093. return flags;
  4094. }
  4095. }
  4096. }
  4097. currentThisScopeFlags() {
  4098. for (let i = this.scopeStack.length - 1;; i--) {
  4099. const {
  4100. flags
  4101. } = this.scopeStack[i];
  4102. if (flags & (1667 | 64) && !(flags & 4)) {
  4103. return flags;
  4104. }
  4105. }
  4106. }
  4107. }
  4108. class FlowScope extends Scope {
  4109. constructor(...args) {
  4110. super(...args);
  4111. this.declareFunctions = new Set();
  4112. }
  4113. }
  4114. class FlowScopeHandler extends ScopeHandler {
  4115. createScope(flags) {
  4116. return new FlowScope(flags);
  4117. }
  4118. declareName(name, bindingType, loc) {
  4119. const scope = this.currentScope();
  4120. if (bindingType & 2048) {
  4121. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  4122. this.maybeExportDefined(scope, name);
  4123. scope.declareFunctions.add(name);
  4124. return;
  4125. }
  4126. super.declareName(name, bindingType, loc);
  4127. }
  4128. isRedeclaredInScope(scope, name, bindingType) {
  4129. if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
  4130. if (bindingType & 2048 && !scope.declareFunctions.has(name)) {
  4131. const type = scope.names.get(name);
  4132. return (type & 4) > 0 || (type & 2) > 0;
  4133. }
  4134. return false;
  4135. }
  4136. checkLocalExport(id) {
  4137. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  4138. super.checkLocalExport(id);
  4139. }
  4140. }
  4141. }
  4142. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  4143. const FlowErrors = ParseErrorEnum`flow`({
  4144. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  4145. AmbiguousDeclareModuleKind: "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.",
  4146. AssignReservedType: ({
  4147. reservedType
  4148. }) => `Cannot overwrite reserved type ${reservedType}.`,
  4149. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  4150. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  4151. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  4152. EnumBooleanMemberNotInitialized: ({
  4153. memberName,
  4154. enumName
  4155. }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`,
  4156. EnumDuplicateMemberName: ({
  4157. memberName,
  4158. enumName
  4159. }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`,
  4160. EnumInconsistentMemberValues: ({
  4161. enumName
  4162. }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
  4163. EnumInvalidExplicitType: ({
  4164. invalidEnumType,
  4165. enumName
  4166. }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  4167. EnumInvalidExplicitTypeUnknownSupplied: ({
  4168. enumName
  4169. }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  4170. EnumInvalidMemberInitializerPrimaryType: ({
  4171. enumName,
  4172. memberName,
  4173. explicitType
  4174. }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`,
  4175. EnumInvalidMemberInitializerSymbolType: ({
  4176. enumName,
  4177. memberName
  4178. }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`,
  4179. EnumInvalidMemberInitializerUnknownType: ({
  4180. enumName,
  4181. memberName
  4182. }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
  4183. EnumInvalidMemberName: ({
  4184. enumName,
  4185. memberName,
  4186. suggestion
  4187. }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
  4188. EnumNumberMemberNotInitialized: ({
  4189. enumName,
  4190. memberName
  4191. }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`,
  4192. EnumStringMemberInconsistentlyInitialized: ({
  4193. enumName
  4194. }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
  4195. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  4196. ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.",
  4197. ImportTypeShorthandOnlyInPureImport: "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",
  4198. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  4199. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  4200. InexactVariance: "Explicit inexact syntax cannot have variance.",
  4201. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  4202. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  4203. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  4204. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  4205. PatternIsOptional: Object.assign({
  4206. message: "A binding pattern parameter cannot be optional in an implementation signature."
  4207. }, {
  4208. reasonCode: "OptionalBindingPattern"
  4209. }),
  4210. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  4211. SpreadVariance: "Spread properties cannot have variance.",
  4212. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  4213. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  4214. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  4215. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  4216. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  4217. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  4218. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  4219. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  4220. UnexpectedReservedType: ({
  4221. reservedType
  4222. }) => `Unexpected reserved type ${reservedType}.`,
  4223. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  4224. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  4225. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  4226. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  4227. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  4228. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  4229. UnsupportedDeclareExportKind: ({
  4230. unsupportedExportKind,
  4231. suggestion
  4232. }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,
  4233. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  4234. UnterminatedFlowComment: "Unterminated flow-comment."
  4235. });
  4236. function isEsModuleType(bodyElement) {
  4237. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  4238. }
  4239. function hasTypeImportKind(node) {
  4240. return node.importKind === "type" || node.importKind === "typeof";
  4241. }
  4242. const exportSuggestions = {
  4243. const: "declare export var",
  4244. let: "declare export var",
  4245. type: "export type",
  4246. interface: "export interface"
  4247. };
  4248. function partition(list, test) {
  4249. const list1 = [];
  4250. const list2 = [];
  4251. for (let i = 0; i < list.length; i++) {
  4252. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  4253. }
  4254. return [list1, list2];
  4255. }
  4256. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  4257. var flow = superClass => class FlowParserMixin extends superClass {
  4258. constructor(...args) {
  4259. super(...args);
  4260. this.flowPragma = undefined;
  4261. }
  4262. getScopeHandler() {
  4263. return FlowScopeHandler;
  4264. }
  4265. shouldParseTypes() {
  4266. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  4267. }
  4268. finishToken(type, val) {
  4269. if (type !== 134 && type !== 13 && type !== 28) {
  4270. if (this.flowPragma === undefined) {
  4271. this.flowPragma = null;
  4272. }
  4273. }
  4274. super.finishToken(type, val);
  4275. }
  4276. addComment(comment) {
  4277. if (this.flowPragma === undefined) {
  4278. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  4279. if (!matches) ;else if (matches[1] === "flow") {
  4280. this.flowPragma = "flow";
  4281. } else if (matches[1] === "noflow") {
  4282. this.flowPragma = "noflow";
  4283. } else {
  4284. throw new Error("Unexpected flow pragma");
  4285. }
  4286. }
  4287. super.addComment(comment);
  4288. }
  4289. flowParseTypeInitialiser(tok) {
  4290. const oldInType = this.state.inType;
  4291. this.state.inType = true;
  4292. this.expect(tok || 14);
  4293. const type = this.flowParseType();
  4294. this.state.inType = oldInType;
  4295. return type;
  4296. }
  4297. flowParsePredicate() {
  4298. const node = this.startNode();
  4299. const moduloLoc = this.state.startLoc;
  4300. this.next();
  4301. this.expectContextual(110);
  4302. if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
  4303. this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
  4304. }
  4305. if (this.eat(10)) {
  4306. node.value = super.parseExpression();
  4307. this.expect(11);
  4308. return this.finishNode(node, "DeclaredPredicate");
  4309. } else {
  4310. return this.finishNode(node, "InferredPredicate");
  4311. }
  4312. }
  4313. flowParseTypeAndPredicateInitialiser() {
  4314. const oldInType = this.state.inType;
  4315. this.state.inType = true;
  4316. this.expect(14);
  4317. let type = null;
  4318. let predicate = null;
  4319. if (this.match(54)) {
  4320. this.state.inType = oldInType;
  4321. predicate = this.flowParsePredicate();
  4322. } else {
  4323. type = this.flowParseType();
  4324. this.state.inType = oldInType;
  4325. if (this.match(54)) {
  4326. predicate = this.flowParsePredicate();
  4327. }
  4328. }
  4329. return [type, predicate];
  4330. }
  4331. flowParseDeclareClass(node) {
  4332. this.next();
  4333. this.flowParseInterfaceish(node, true);
  4334. return this.finishNode(node, "DeclareClass");
  4335. }
  4336. flowParseDeclareFunction(node) {
  4337. this.next();
  4338. const id = node.id = this.parseIdentifier();
  4339. const typeNode = this.startNode();
  4340. const typeContainer = this.startNode();
  4341. if (this.match(47)) {
  4342. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  4343. } else {
  4344. typeNode.typeParameters = null;
  4345. }
  4346. this.expect(10);
  4347. const tmp = this.flowParseFunctionTypeParams();
  4348. typeNode.params = tmp.params;
  4349. typeNode.rest = tmp.rest;
  4350. typeNode.this = tmp._this;
  4351. this.expect(11);
  4352. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  4353. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  4354. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  4355. this.resetEndLocation(id);
  4356. this.semicolon();
  4357. this.scope.declareName(node.id.name, 2048, node.id.loc.start);
  4358. return this.finishNode(node, "DeclareFunction");
  4359. }
  4360. flowParseDeclare(node, insideModule) {
  4361. if (this.match(80)) {
  4362. return this.flowParseDeclareClass(node);
  4363. } else if (this.match(68)) {
  4364. return this.flowParseDeclareFunction(node);
  4365. } else if (this.match(74)) {
  4366. return this.flowParseDeclareVariable(node);
  4367. } else if (this.eatContextual(127)) {
  4368. if (this.match(16)) {
  4369. return this.flowParseDeclareModuleExports(node);
  4370. } else {
  4371. if (insideModule) {
  4372. this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
  4373. }
  4374. return this.flowParseDeclareModule(node);
  4375. }
  4376. } else if (this.isContextual(130)) {
  4377. return this.flowParseDeclareTypeAlias(node);
  4378. } else if (this.isContextual(131)) {
  4379. return this.flowParseDeclareOpaqueType(node);
  4380. } else if (this.isContextual(129)) {
  4381. return this.flowParseDeclareInterface(node);
  4382. } else if (this.match(82)) {
  4383. return this.flowParseDeclareExportDeclaration(node, insideModule);
  4384. } else {
  4385. this.unexpected();
  4386. }
  4387. }
  4388. flowParseDeclareVariable(node) {
  4389. this.next();
  4390. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  4391. this.scope.declareName(node.id.name, 5, node.id.loc.start);
  4392. this.semicolon();
  4393. return this.finishNode(node, "DeclareVariable");
  4394. }
  4395. flowParseDeclareModule(node) {
  4396. this.scope.enter(0);
  4397. if (this.match(134)) {
  4398. node.id = super.parseExprAtom();
  4399. } else {
  4400. node.id = this.parseIdentifier();
  4401. }
  4402. const bodyNode = node.body = this.startNode();
  4403. const body = bodyNode.body = [];
  4404. this.expect(5);
  4405. while (!this.match(8)) {
  4406. let bodyNode = this.startNode();
  4407. if (this.match(83)) {
  4408. this.next();
  4409. if (!this.isContextual(130) && !this.match(87)) {
  4410. this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
  4411. }
  4412. super.parseImport(bodyNode);
  4413. } else {
  4414. this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
  4415. bodyNode = this.flowParseDeclare(bodyNode, true);
  4416. }
  4417. body.push(bodyNode);
  4418. }
  4419. this.scope.exit();
  4420. this.expect(8);
  4421. this.finishNode(bodyNode, "BlockStatement");
  4422. let kind = null;
  4423. let hasModuleExport = false;
  4424. body.forEach(bodyElement => {
  4425. if (isEsModuleType(bodyElement)) {
  4426. if (kind === "CommonJS") {
  4427. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  4428. }
  4429. kind = "ES";
  4430. } else if (bodyElement.type === "DeclareModuleExports") {
  4431. if (hasModuleExport) {
  4432. this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement);
  4433. }
  4434. if (kind === "ES") {
  4435. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  4436. }
  4437. kind = "CommonJS";
  4438. hasModuleExport = true;
  4439. }
  4440. });
  4441. node.kind = kind || "CommonJS";
  4442. return this.finishNode(node, "DeclareModule");
  4443. }
  4444. flowParseDeclareExportDeclaration(node, insideModule) {
  4445. this.expect(82);
  4446. if (this.eat(65)) {
  4447. if (this.match(68) || this.match(80)) {
  4448. node.declaration = this.flowParseDeclare(this.startNode());
  4449. } else {
  4450. node.declaration = this.flowParseType();
  4451. this.semicolon();
  4452. }
  4453. node.default = true;
  4454. return this.finishNode(node, "DeclareExportDeclaration");
  4455. } else {
  4456. if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) {
  4457. const label = this.state.value;
  4458. throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
  4459. unsupportedExportKind: label,
  4460. suggestion: exportSuggestions[label]
  4461. });
  4462. }
  4463. if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) {
  4464. node.declaration = this.flowParseDeclare(this.startNode());
  4465. node.default = false;
  4466. return this.finishNode(node, "DeclareExportDeclaration");
  4467. } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) {
  4468. node = this.parseExport(node, null);
  4469. if (node.type === "ExportNamedDeclaration") {
  4470. node.default = false;
  4471. delete node.exportKind;
  4472. return this.castNodeTo(node, "DeclareExportDeclaration");
  4473. } else {
  4474. return this.castNodeTo(node, "DeclareExportAllDeclaration");
  4475. }
  4476. }
  4477. }
  4478. this.unexpected();
  4479. }
  4480. flowParseDeclareModuleExports(node) {
  4481. this.next();
  4482. this.expectContextual(111);
  4483. node.typeAnnotation = this.flowParseTypeAnnotation();
  4484. this.semicolon();
  4485. return this.finishNode(node, "DeclareModuleExports");
  4486. }
  4487. flowParseDeclareTypeAlias(node) {
  4488. this.next();
  4489. const finished = this.flowParseTypeAlias(node);
  4490. this.castNodeTo(finished, "DeclareTypeAlias");
  4491. return finished;
  4492. }
  4493. flowParseDeclareOpaqueType(node) {
  4494. this.next();
  4495. const finished = this.flowParseOpaqueType(node, true);
  4496. this.castNodeTo(finished, "DeclareOpaqueType");
  4497. return finished;
  4498. }
  4499. flowParseDeclareInterface(node) {
  4500. this.next();
  4501. this.flowParseInterfaceish(node, false);
  4502. return this.finishNode(node, "DeclareInterface");
  4503. }
  4504. flowParseInterfaceish(node, isClass) {
  4505. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  4506. this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start);
  4507. if (this.match(47)) {
  4508. node.typeParameters = this.flowParseTypeParameterDeclaration();
  4509. } else {
  4510. node.typeParameters = null;
  4511. }
  4512. node.extends = [];
  4513. if (this.eat(81)) {
  4514. do {
  4515. node.extends.push(this.flowParseInterfaceExtends());
  4516. } while (!isClass && this.eat(12));
  4517. }
  4518. if (isClass) {
  4519. node.implements = [];
  4520. node.mixins = [];
  4521. if (this.eatContextual(117)) {
  4522. do {
  4523. node.mixins.push(this.flowParseInterfaceExtends());
  4524. } while (this.eat(12));
  4525. }
  4526. if (this.eatContextual(113)) {
  4527. do {
  4528. node.implements.push(this.flowParseInterfaceExtends());
  4529. } while (this.eat(12));
  4530. }
  4531. }
  4532. node.body = this.flowParseObjectType({
  4533. allowStatic: isClass,
  4534. allowExact: false,
  4535. allowSpread: false,
  4536. allowProto: isClass,
  4537. allowInexact: false
  4538. });
  4539. }
  4540. flowParseInterfaceExtends() {
  4541. const node = this.startNode();
  4542. node.id = this.flowParseQualifiedTypeIdentifier();
  4543. if (this.match(47)) {
  4544. node.typeParameters = this.flowParseTypeParameterInstantiation();
  4545. } else {
  4546. node.typeParameters = null;
  4547. }
  4548. return this.finishNode(node, "InterfaceExtends");
  4549. }
  4550. flowParseInterface(node) {
  4551. this.flowParseInterfaceish(node, false);
  4552. return this.finishNode(node, "InterfaceDeclaration");
  4553. }
  4554. checkNotUnderscore(word) {
  4555. if (word === "_") {
  4556. this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc);
  4557. }
  4558. }
  4559. checkReservedType(word, startLoc, declaration) {
  4560. if (!reservedTypes.has(word)) return;
  4561. this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, {
  4562. reservedType: word
  4563. });
  4564. }
  4565. flowParseRestrictedIdentifier(liberal, declaration) {
  4566. this.checkReservedType(this.state.value, this.state.startLoc, declaration);
  4567. return this.parseIdentifier(liberal);
  4568. }
  4569. flowParseTypeAlias(node) {
  4570. node.id = this.flowParseRestrictedIdentifier(false, true);
  4571. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  4572. if (this.match(47)) {
  4573. node.typeParameters = this.flowParseTypeParameterDeclaration();
  4574. } else {
  4575. node.typeParameters = null;
  4576. }
  4577. node.right = this.flowParseTypeInitialiser(29);
  4578. this.semicolon();
  4579. return this.finishNode(node, "TypeAlias");
  4580. }
  4581. flowParseOpaqueType(node, declare) {
  4582. this.expectContextual(130);
  4583. node.id = this.flowParseRestrictedIdentifier(true, true);
  4584. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  4585. if (this.match(47)) {
  4586. node.typeParameters = this.flowParseTypeParameterDeclaration();
  4587. } else {
  4588. node.typeParameters = null;
  4589. }
  4590. node.supertype = null;
  4591. if (this.match(14)) {
  4592. node.supertype = this.flowParseTypeInitialiser(14);
  4593. }
  4594. node.impltype = null;
  4595. if (!declare) {
  4596. node.impltype = this.flowParseTypeInitialiser(29);
  4597. }
  4598. this.semicolon();
  4599. return this.finishNode(node, "OpaqueType");
  4600. }
  4601. flowParseTypeParameter(requireDefault = false) {
  4602. const nodeStartLoc = this.state.startLoc;
  4603. const node = this.startNode();
  4604. const variance = this.flowParseVariance();
  4605. const ident = this.flowParseTypeAnnotatableIdentifier();
  4606. node.name = ident.name;
  4607. node.variance = variance;
  4608. node.bound = ident.typeAnnotation;
  4609. if (this.match(29)) {
  4610. this.eat(29);
  4611. node.default = this.flowParseType();
  4612. } else {
  4613. if (requireDefault) {
  4614. this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc);
  4615. }
  4616. }
  4617. return this.finishNode(node, "TypeParameter");
  4618. }
  4619. flowParseTypeParameterDeclaration() {
  4620. const oldInType = this.state.inType;
  4621. const node = this.startNode();
  4622. node.params = [];
  4623. this.state.inType = true;
  4624. if (this.match(47) || this.match(143)) {
  4625. this.next();
  4626. } else {
  4627. this.unexpected();
  4628. }
  4629. let defaultRequired = false;
  4630. do {
  4631. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  4632. node.params.push(typeParameter);
  4633. if (typeParameter.default) {
  4634. defaultRequired = true;
  4635. }
  4636. if (!this.match(48)) {
  4637. this.expect(12);
  4638. }
  4639. } while (!this.match(48));
  4640. this.expect(48);
  4641. this.state.inType = oldInType;
  4642. return this.finishNode(node, "TypeParameterDeclaration");
  4643. }
  4644. flowInTopLevelContext(cb) {
  4645. if (this.curContext() !== types.brace) {
  4646. const oldContext = this.state.context;
  4647. this.state.context = [oldContext[0]];
  4648. try {
  4649. return cb();
  4650. } finally {
  4651. this.state.context = oldContext;
  4652. }
  4653. } else {
  4654. return cb();
  4655. }
  4656. }
  4657. flowParseTypeParameterInstantiationInExpression() {
  4658. if (this.reScan_lt() !== 47) return;
  4659. return this.flowParseTypeParameterInstantiation();
  4660. }
  4661. flowParseTypeParameterInstantiation() {
  4662. const node = this.startNode();
  4663. const oldInType = this.state.inType;
  4664. this.state.inType = true;
  4665. node.params = [];
  4666. this.flowInTopLevelContext(() => {
  4667. this.expect(47);
  4668. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  4669. this.state.noAnonFunctionType = false;
  4670. while (!this.match(48)) {
  4671. node.params.push(this.flowParseType());
  4672. if (!this.match(48)) {
  4673. this.expect(12);
  4674. }
  4675. }
  4676. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  4677. });
  4678. this.state.inType = oldInType;
  4679. if (!this.state.inType && this.curContext() === types.brace) {
  4680. this.reScan_lt_gt();
  4681. }
  4682. this.expect(48);
  4683. return this.finishNode(node, "TypeParameterInstantiation");
  4684. }
  4685. flowParseTypeParameterInstantiationCallOrNew() {
  4686. if (this.reScan_lt() !== 47) return;
  4687. const node = this.startNode();
  4688. const oldInType = this.state.inType;
  4689. node.params = [];
  4690. this.state.inType = true;
  4691. this.expect(47);
  4692. while (!this.match(48)) {
  4693. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  4694. if (!this.match(48)) {
  4695. this.expect(12);
  4696. }
  4697. }
  4698. this.expect(48);
  4699. this.state.inType = oldInType;
  4700. return this.finishNode(node, "TypeParameterInstantiation");
  4701. }
  4702. flowParseInterfaceType() {
  4703. const node = this.startNode();
  4704. this.expectContextual(129);
  4705. node.extends = [];
  4706. if (this.eat(81)) {
  4707. do {
  4708. node.extends.push(this.flowParseInterfaceExtends());
  4709. } while (this.eat(12));
  4710. }
  4711. node.body = this.flowParseObjectType({
  4712. allowStatic: false,
  4713. allowExact: false,
  4714. allowSpread: false,
  4715. allowProto: false,
  4716. allowInexact: false
  4717. });
  4718. return this.finishNode(node, "InterfaceTypeAnnotation");
  4719. }
  4720. flowParseObjectPropertyKey() {
  4721. return this.match(135) || this.match(134) ? super.parseExprAtom() : this.parseIdentifier(true);
  4722. }
  4723. flowParseObjectTypeIndexer(node, isStatic, variance) {
  4724. node.static = isStatic;
  4725. if (this.lookahead().type === 14) {
  4726. node.id = this.flowParseObjectPropertyKey();
  4727. node.key = this.flowParseTypeInitialiser();
  4728. } else {
  4729. node.id = null;
  4730. node.key = this.flowParseType();
  4731. }
  4732. this.expect(3);
  4733. node.value = this.flowParseTypeInitialiser();
  4734. node.variance = variance;
  4735. return this.finishNode(node, "ObjectTypeIndexer");
  4736. }
  4737. flowParseObjectTypeInternalSlot(node, isStatic) {
  4738. node.static = isStatic;
  4739. node.id = this.flowParseObjectPropertyKey();
  4740. this.expect(3);
  4741. this.expect(3);
  4742. if (this.match(47) || this.match(10)) {
  4743. node.method = true;
  4744. node.optional = false;
  4745. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  4746. } else {
  4747. node.method = false;
  4748. if (this.eat(17)) {
  4749. node.optional = true;
  4750. }
  4751. node.value = this.flowParseTypeInitialiser();
  4752. }
  4753. return this.finishNode(node, "ObjectTypeInternalSlot");
  4754. }
  4755. flowParseObjectTypeMethodish(node) {
  4756. node.params = [];
  4757. node.rest = null;
  4758. node.typeParameters = null;
  4759. node.this = null;
  4760. if (this.match(47)) {
  4761. node.typeParameters = this.flowParseTypeParameterDeclaration();
  4762. }
  4763. this.expect(10);
  4764. if (this.match(78)) {
  4765. node.this = this.flowParseFunctionTypeParam(true);
  4766. node.this.name = null;
  4767. if (!this.match(11)) {
  4768. this.expect(12);
  4769. }
  4770. }
  4771. while (!this.match(11) && !this.match(21)) {
  4772. node.params.push(this.flowParseFunctionTypeParam(false));
  4773. if (!this.match(11)) {
  4774. this.expect(12);
  4775. }
  4776. }
  4777. if (this.eat(21)) {
  4778. node.rest = this.flowParseFunctionTypeParam(false);
  4779. }
  4780. this.expect(11);
  4781. node.returnType = this.flowParseTypeInitialiser();
  4782. return this.finishNode(node, "FunctionTypeAnnotation");
  4783. }
  4784. flowParseObjectTypeCallProperty(node, isStatic) {
  4785. const valueNode = this.startNode();
  4786. node.static = isStatic;
  4787. node.value = this.flowParseObjectTypeMethodish(valueNode);
  4788. return this.finishNode(node, "ObjectTypeCallProperty");
  4789. }
  4790. flowParseObjectType({
  4791. allowStatic,
  4792. allowExact,
  4793. allowSpread,
  4794. allowProto,
  4795. allowInexact
  4796. }) {
  4797. const oldInType = this.state.inType;
  4798. this.state.inType = true;
  4799. const nodeStart = this.startNode();
  4800. nodeStart.callProperties = [];
  4801. nodeStart.properties = [];
  4802. nodeStart.indexers = [];
  4803. nodeStart.internalSlots = [];
  4804. let endDelim;
  4805. let exact;
  4806. let inexact = false;
  4807. if (allowExact && this.match(6)) {
  4808. this.expect(6);
  4809. endDelim = 9;
  4810. exact = true;
  4811. } else {
  4812. this.expect(5);
  4813. endDelim = 8;
  4814. exact = false;
  4815. }
  4816. nodeStart.exact = exact;
  4817. while (!this.match(endDelim)) {
  4818. let isStatic = false;
  4819. let protoStartLoc = null;
  4820. let inexactStartLoc = null;
  4821. const node = this.startNode();
  4822. if (allowProto && this.isContextual(118)) {
  4823. const lookahead = this.lookahead();
  4824. if (lookahead.type !== 14 && lookahead.type !== 17) {
  4825. this.next();
  4826. protoStartLoc = this.state.startLoc;
  4827. allowStatic = false;
  4828. }
  4829. }
  4830. if (allowStatic && this.isContextual(106)) {
  4831. const lookahead = this.lookahead();
  4832. if (lookahead.type !== 14 && lookahead.type !== 17) {
  4833. this.next();
  4834. isStatic = true;
  4835. }
  4836. }
  4837. const variance = this.flowParseVariance();
  4838. if (this.eat(0)) {
  4839. if (protoStartLoc != null) {
  4840. this.unexpected(protoStartLoc);
  4841. }
  4842. if (this.eat(0)) {
  4843. if (variance) {
  4844. this.unexpected(variance.loc.start);
  4845. }
  4846. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  4847. } else {
  4848. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  4849. }
  4850. } else if (this.match(10) || this.match(47)) {
  4851. if (protoStartLoc != null) {
  4852. this.unexpected(protoStartLoc);
  4853. }
  4854. if (variance) {
  4855. this.unexpected(variance.loc.start);
  4856. }
  4857. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  4858. } else {
  4859. let kind = "init";
  4860. if (this.isContextual(99) || this.isContextual(104)) {
  4861. const lookahead = this.lookahead();
  4862. if (tokenIsLiteralPropertyName(lookahead.type)) {
  4863. kind = this.state.value;
  4864. this.next();
  4865. }
  4866. }
  4867. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  4868. if (propOrInexact === null) {
  4869. inexact = true;
  4870. inexactStartLoc = this.state.lastTokStartLoc;
  4871. } else {
  4872. nodeStart.properties.push(propOrInexact);
  4873. }
  4874. }
  4875. this.flowObjectTypeSemicolon();
  4876. if (inexactStartLoc && !this.match(8) && !this.match(9)) {
  4877. this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc);
  4878. }
  4879. }
  4880. this.expect(endDelim);
  4881. if (allowSpread) {
  4882. nodeStart.inexact = inexact;
  4883. }
  4884. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  4885. this.state.inType = oldInType;
  4886. return out;
  4887. }
  4888. flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
  4889. if (this.eat(21)) {
  4890. const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
  4891. if (isInexactToken) {
  4892. if (!allowSpread) {
  4893. this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc);
  4894. } else if (!allowInexact) {
  4895. this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc);
  4896. }
  4897. if (variance) {
  4898. this.raise(FlowErrors.InexactVariance, variance);
  4899. }
  4900. return null;
  4901. }
  4902. if (!allowSpread) {
  4903. this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc);
  4904. }
  4905. if (protoStartLoc != null) {
  4906. this.unexpected(protoStartLoc);
  4907. }
  4908. if (variance) {
  4909. this.raise(FlowErrors.SpreadVariance, variance);
  4910. }
  4911. node.argument = this.flowParseType();
  4912. return this.finishNode(node, "ObjectTypeSpreadProperty");
  4913. } else {
  4914. node.key = this.flowParseObjectPropertyKey();
  4915. node.static = isStatic;
  4916. node.proto = protoStartLoc != null;
  4917. node.kind = kind;
  4918. let optional = false;
  4919. if (this.match(47) || this.match(10)) {
  4920. node.method = true;
  4921. if (protoStartLoc != null) {
  4922. this.unexpected(protoStartLoc);
  4923. }
  4924. if (variance) {
  4925. this.unexpected(variance.loc.start);
  4926. }
  4927. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  4928. if (kind === "get" || kind === "set") {
  4929. this.flowCheckGetterSetterParams(node);
  4930. }
  4931. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  4932. this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this);
  4933. }
  4934. } else {
  4935. if (kind !== "init") this.unexpected();
  4936. node.method = false;
  4937. if (this.eat(17)) {
  4938. optional = true;
  4939. }
  4940. node.value = this.flowParseTypeInitialiser();
  4941. node.variance = variance;
  4942. }
  4943. node.optional = optional;
  4944. return this.finishNode(node, "ObjectTypeProperty");
  4945. }
  4946. }
  4947. flowCheckGetterSetterParams(property) {
  4948. const paramCount = property.kind === "get" ? 0 : 1;
  4949. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  4950. if (property.value.this) {
  4951. this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this);
  4952. }
  4953. if (length !== paramCount) {
  4954. this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property);
  4955. }
  4956. if (property.kind === "set" && property.value.rest) {
  4957. this.raise(Errors.BadSetterRestParameter, property);
  4958. }
  4959. }
  4960. flowObjectTypeSemicolon() {
  4961. if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) {
  4962. this.unexpected();
  4963. }
  4964. }
  4965. flowParseQualifiedTypeIdentifier(startLoc, id) {
  4966. startLoc != null ? startLoc : startLoc = this.state.startLoc;
  4967. let node = id || this.flowParseRestrictedIdentifier(true);
  4968. while (this.eat(16)) {
  4969. const node2 = this.startNodeAt(startLoc);
  4970. node2.qualification = node;
  4971. node2.id = this.flowParseRestrictedIdentifier(true);
  4972. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  4973. }
  4974. return node;
  4975. }
  4976. flowParseGenericType(startLoc, id) {
  4977. const node = this.startNodeAt(startLoc);
  4978. node.typeParameters = null;
  4979. node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id);
  4980. if (this.match(47)) {
  4981. node.typeParameters = this.flowParseTypeParameterInstantiation();
  4982. }
  4983. return this.finishNode(node, "GenericTypeAnnotation");
  4984. }
  4985. flowParseTypeofType() {
  4986. const node = this.startNode();
  4987. this.expect(87);
  4988. node.argument = this.flowParsePrimaryType();
  4989. return this.finishNode(node, "TypeofTypeAnnotation");
  4990. }
  4991. flowParseTupleType() {
  4992. const node = this.startNode();
  4993. node.types = [];
  4994. this.expect(0);
  4995. while (this.state.pos < this.length && !this.match(3)) {
  4996. node.types.push(this.flowParseType());
  4997. if (this.match(3)) break;
  4998. this.expect(12);
  4999. }
  5000. this.expect(3);
  5001. return this.finishNode(node, "TupleTypeAnnotation");
  5002. }
  5003. flowParseFunctionTypeParam(first) {
  5004. let name = null;
  5005. let optional = false;
  5006. let typeAnnotation = null;
  5007. const node = this.startNode();
  5008. const lh = this.lookahead();
  5009. const isThis = this.state.type === 78;
  5010. if (lh.type === 14 || lh.type === 17) {
  5011. if (isThis && !first) {
  5012. this.raise(FlowErrors.ThisParamMustBeFirst, node);
  5013. }
  5014. name = this.parseIdentifier(isThis);
  5015. if (this.eat(17)) {
  5016. optional = true;
  5017. if (isThis) {
  5018. this.raise(FlowErrors.ThisParamMayNotBeOptional, node);
  5019. }
  5020. }
  5021. typeAnnotation = this.flowParseTypeInitialiser();
  5022. } else {
  5023. typeAnnotation = this.flowParseType();
  5024. }
  5025. node.name = name;
  5026. node.optional = optional;
  5027. node.typeAnnotation = typeAnnotation;
  5028. return this.finishNode(node, "FunctionTypeParam");
  5029. }
  5030. reinterpretTypeAsFunctionTypeParam(type) {
  5031. const node = this.startNodeAt(type.loc.start);
  5032. node.name = null;
  5033. node.optional = false;
  5034. node.typeAnnotation = type;
  5035. return this.finishNode(node, "FunctionTypeParam");
  5036. }
  5037. flowParseFunctionTypeParams(params = []) {
  5038. let rest = null;
  5039. let _this = null;
  5040. if (this.match(78)) {
  5041. _this = this.flowParseFunctionTypeParam(true);
  5042. _this.name = null;
  5043. if (!this.match(11)) {
  5044. this.expect(12);
  5045. }
  5046. }
  5047. while (!this.match(11) && !this.match(21)) {
  5048. params.push(this.flowParseFunctionTypeParam(false));
  5049. if (!this.match(11)) {
  5050. this.expect(12);
  5051. }
  5052. }
  5053. if (this.eat(21)) {
  5054. rest = this.flowParseFunctionTypeParam(false);
  5055. }
  5056. return {
  5057. params,
  5058. rest,
  5059. _this
  5060. };
  5061. }
  5062. flowIdentToTypeAnnotation(startLoc, node, id) {
  5063. switch (id.name) {
  5064. case "any":
  5065. return this.finishNode(node, "AnyTypeAnnotation");
  5066. case "bool":
  5067. case "boolean":
  5068. return this.finishNode(node, "BooleanTypeAnnotation");
  5069. case "mixed":
  5070. return this.finishNode(node, "MixedTypeAnnotation");
  5071. case "empty":
  5072. return this.finishNode(node, "EmptyTypeAnnotation");
  5073. case "number":
  5074. return this.finishNode(node, "NumberTypeAnnotation");
  5075. case "string":
  5076. return this.finishNode(node, "StringTypeAnnotation");
  5077. case "symbol":
  5078. return this.finishNode(node, "SymbolTypeAnnotation");
  5079. default:
  5080. this.checkNotUnderscore(id.name);
  5081. return this.flowParseGenericType(startLoc, id);
  5082. }
  5083. }
  5084. flowParsePrimaryType() {
  5085. const startLoc = this.state.startLoc;
  5086. const node = this.startNode();
  5087. let tmp;
  5088. let type;
  5089. let isGroupedType = false;
  5090. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  5091. switch (this.state.type) {
  5092. case 5:
  5093. return this.flowParseObjectType({
  5094. allowStatic: false,
  5095. allowExact: false,
  5096. allowSpread: true,
  5097. allowProto: false,
  5098. allowInexact: true
  5099. });
  5100. case 6:
  5101. return this.flowParseObjectType({
  5102. allowStatic: false,
  5103. allowExact: true,
  5104. allowSpread: true,
  5105. allowProto: false,
  5106. allowInexact: false
  5107. });
  5108. case 0:
  5109. this.state.noAnonFunctionType = false;
  5110. type = this.flowParseTupleType();
  5111. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  5112. return type;
  5113. case 47:
  5114. {
  5115. const node = this.startNode();
  5116. node.typeParameters = this.flowParseTypeParameterDeclaration();
  5117. this.expect(10);
  5118. tmp = this.flowParseFunctionTypeParams();
  5119. node.params = tmp.params;
  5120. node.rest = tmp.rest;
  5121. node.this = tmp._this;
  5122. this.expect(11);
  5123. this.expect(19);
  5124. node.returnType = this.flowParseType();
  5125. return this.finishNode(node, "FunctionTypeAnnotation");
  5126. }
  5127. case 10:
  5128. {
  5129. const node = this.startNode();
  5130. this.next();
  5131. if (!this.match(11) && !this.match(21)) {
  5132. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  5133. const token = this.lookahead().type;
  5134. isGroupedType = token !== 17 && token !== 14;
  5135. } else {
  5136. isGroupedType = true;
  5137. }
  5138. }
  5139. if (isGroupedType) {
  5140. this.state.noAnonFunctionType = false;
  5141. type = this.flowParseType();
  5142. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  5143. if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) {
  5144. this.expect(11);
  5145. return type;
  5146. } else {
  5147. this.eat(12);
  5148. }
  5149. }
  5150. if (type) {
  5151. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  5152. } else {
  5153. tmp = this.flowParseFunctionTypeParams();
  5154. }
  5155. node.params = tmp.params;
  5156. node.rest = tmp.rest;
  5157. node.this = tmp._this;
  5158. this.expect(11);
  5159. this.expect(19);
  5160. node.returnType = this.flowParseType();
  5161. node.typeParameters = null;
  5162. return this.finishNode(node, "FunctionTypeAnnotation");
  5163. }
  5164. case 134:
  5165. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  5166. case 85:
  5167. case 86:
  5168. node.value = this.match(85);
  5169. this.next();
  5170. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  5171. case 53:
  5172. if (this.state.value === "-") {
  5173. this.next();
  5174. if (this.match(135)) {
  5175. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  5176. }
  5177. if (this.match(136)) {
  5178. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  5179. }
  5180. throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
  5181. }
  5182. this.unexpected();
  5183. return;
  5184. case 135:
  5185. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  5186. case 136:
  5187. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  5188. case 88:
  5189. this.next();
  5190. return this.finishNode(node, "VoidTypeAnnotation");
  5191. case 84:
  5192. this.next();
  5193. return this.finishNode(node, "NullLiteralTypeAnnotation");
  5194. case 78:
  5195. this.next();
  5196. return this.finishNode(node, "ThisTypeAnnotation");
  5197. case 55:
  5198. this.next();
  5199. return this.finishNode(node, "ExistsTypeAnnotation");
  5200. case 87:
  5201. return this.flowParseTypeofType();
  5202. default:
  5203. if (tokenIsKeyword(this.state.type)) {
  5204. const label = tokenLabelName(this.state.type);
  5205. this.next();
  5206. return super.createIdentifier(node, label);
  5207. } else if (tokenIsIdentifier(this.state.type)) {
  5208. if (this.isContextual(129)) {
  5209. return this.flowParseInterfaceType();
  5210. }
  5211. return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
  5212. }
  5213. }
  5214. this.unexpected();
  5215. }
  5216. flowParsePostfixType() {
  5217. const startLoc = this.state.startLoc;
  5218. let type = this.flowParsePrimaryType();
  5219. let seenOptionalIndexedAccess = false;
  5220. while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) {
  5221. const node = this.startNodeAt(startLoc);
  5222. const optional = this.eat(18);
  5223. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  5224. this.expect(0);
  5225. if (!optional && this.match(3)) {
  5226. node.elementType = type;
  5227. this.next();
  5228. type = this.finishNode(node, "ArrayTypeAnnotation");
  5229. } else {
  5230. node.objectType = type;
  5231. node.indexType = this.flowParseType();
  5232. this.expect(3);
  5233. if (seenOptionalIndexedAccess) {
  5234. node.optional = optional;
  5235. type = this.finishNode(node, "OptionalIndexedAccessType");
  5236. } else {
  5237. type = this.finishNode(node, "IndexedAccessType");
  5238. }
  5239. }
  5240. }
  5241. return type;
  5242. }
  5243. flowParsePrefixType() {
  5244. const node = this.startNode();
  5245. if (this.eat(17)) {
  5246. node.typeAnnotation = this.flowParsePrefixType();
  5247. return this.finishNode(node, "NullableTypeAnnotation");
  5248. } else {
  5249. return this.flowParsePostfixType();
  5250. }
  5251. }
  5252. flowParseAnonFunctionWithoutParens() {
  5253. const param = this.flowParsePrefixType();
  5254. if (!this.state.noAnonFunctionType && this.eat(19)) {
  5255. const node = this.startNodeAt(param.loc.start);
  5256. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  5257. node.rest = null;
  5258. node.this = null;
  5259. node.returnType = this.flowParseType();
  5260. node.typeParameters = null;
  5261. return this.finishNode(node, "FunctionTypeAnnotation");
  5262. }
  5263. return param;
  5264. }
  5265. flowParseIntersectionType() {
  5266. const node = this.startNode();
  5267. this.eat(45);
  5268. const type = this.flowParseAnonFunctionWithoutParens();
  5269. node.types = [type];
  5270. while (this.eat(45)) {
  5271. node.types.push(this.flowParseAnonFunctionWithoutParens());
  5272. }
  5273. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  5274. }
  5275. flowParseUnionType() {
  5276. const node = this.startNode();
  5277. this.eat(43);
  5278. const type = this.flowParseIntersectionType();
  5279. node.types = [type];
  5280. while (this.eat(43)) {
  5281. node.types.push(this.flowParseIntersectionType());
  5282. }
  5283. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  5284. }
  5285. flowParseType() {
  5286. const oldInType = this.state.inType;
  5287. this.state.inType = true;
  5288. const type = this.flowParseUnionType();
  5289. this.state.inType = oldInType;
  5290. return type;
  5291. }
  5292. flowParseTypeOrImplicitInstantiation() {
  5293. if (this.state.type === 132 && this.state.value === "_") {
  5294. const startLoc = this.state.startLoc;
  5295. const node = this.parseIdentifier();
  5296. return this.flowParseGenericType(startLoc, node);
  5297. } else {
  5298. return this.flowParseType();
  5299. }
  5300. }
  5301. flowParseTypeAnnotation() {
  5302. const node = this.startNode();
  5303. node.typeAnnotation = this.flowParseTypeInitialiser();
  5304. return this.finishNode(node, "TypeAnnotation");
  5305. }
  5306. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  5307. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  5308. if (this.match(14)) {
  5309. ident.typeAnnotation = this.flowParseTypeAnnotation();
  5310. this.resetEndLocation(ident);
  5311. }
  5312. return ident;
  5313. }
  5314. typeCastToParameter(node) {
  5315. node.expression.typeAnnotation = node.typeAnnotation;
  5316. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  5317. return node.expression;
  5318. }
  5319. flowParseVariance() {
  5320. let variance = null;
  5321. if (this.match(53)) {
  5322. variance = this.startNode();
  5323. if (this.state.value === "+") {
  5324. variance.kind = "plus";
  5325. } else {
  5326. variance.kind = "minus";
  5327. }
  5328. this.next();
  5329. return this.finishNode(variance, "Variance");
  5330. }
  5331. return variance;
  5332. }
  5333. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  5334. if (allowExpressionBody) {
  5335. this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  5336. return;
  5337. }
  5338. super.parseFunctionBody(node, false, isMethod);
  5339. }
  5340. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  5341. if (this.match(14)) {
  5342. const typeNode = this.startNode();
  5343. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  5344. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  5345. }
  5346. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  5347. }
  5348. parseStatementLike(flags) {
  5349. if (this.state.strict && this.isContextual(129)) {
  5350. const lookahead = this.lookahead();
  5351. if (tokenIsKeywordOrIdentifier(lookahead.type)) {
  5352. const node = this.startNode();
  5353. this.next();
  5354. return this.flowParseInterface(node);
  5355. }
  5356. } else if (this.isContextual(126)) {
  5357. const node = this.startNode();
  5358. this.next();
  5359. return this.flowParseEnumDeclaration(node);
  5360. }
  5361. const stmt = super.parseStatementLike(flags);
  5362. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  5363. this.flowPragma = null;
  5364. }
  5365. return stmt;
  5366. }
  5367. parseExpressionStatement(node, expr, decorators) {
  5368. if (expr.type === "Identifier") {
  5369. if (expr.name === "declare") {
  5370. if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) {
  5371. return this.flowParseDeclare(node);
  5372. }
  5373. } else if (tokenIsIdentifier(this.state.type)) {
  5374. if (expr.name === "interface") {
  5375. return this.flowParseInterface(node);
  5376. } else if (expr.name === "type") {
  5377. return this.flowParseTypeAlias(node);
  5378. } else if (expr.name === "opaque") {
  5379. return this.flowParseOpaqueType(node, false);
  5380. }
  5381. }
  5382. }
  5383. return super.parseExpressionStatement(node, expr, decorators);
  5384. }
  5385. shouldParseExportDeclaration() {
  5386. const {
  5387. type
  5388. } = this.state;
  5389. if (type === 126 || tokenIsFlowInterfaceOrTypeOrOpaque(type)) {
  5390. return !this.state.containsEsc;
  5391. }
  5392. return super.shouldParseExportDeclaration();
  5393. }
  5394. isExportDefaultSpecifier() {
  5395. const {
  5396. type
  5397. } = this.state;
  5398. if (type === 126 || tokenIsFlowInterfaceOrTypeOrOpaque(type)) {
  5399. return this.state.containsEsc;
  5400. }
  5401. return super.isExportDefaultSpecifier();
  5402. }
  5403. parseExportDefaultExpression() {
  5404. if (this.isContextual(126)) {
  5405. const node = this.startNode();
  5406. this.next();
  5407. return this.flowParseEnumDeclaration(node);
  5408. }
  5409. return super.parseExportDefaultExpression();
  5410. }
  5411. parseConditional(expr, startLoc, refExpressionErrors) {
  5412. if (!this.match(17)) return expr;
  5413. if (this.state.maybeInArrowParameters) {
  5414. const nextCh = this.lookaheadCharCode();
  5415. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  5416. this.setOptionalParametersError(refExpressionErrors);
  5417. return expr;
  5418. }
  5419. }
  5420. this.expect(17);
  5421. const state = this.state.clone();
  5422. const originalNoArrowAt = this.state.noArrowAt;
  5423. const node = this.startNodeAt(startLoc);
  5424. let {
  5425. consequent,
  5426. failed
  5427. } = this.tryParseConditionalConsequent();
  5428. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  5429. if (failed || invalid.length > 0) {
  5430. const noArrowAt = [...originalNoArrowAt];
  5431. if (invalid.length > 0) {
  5432. this.state = state;
  5433. this.state.noArrowAt = noArrowAt;
  5434. for (let i = 0; i < invalid.length; i++) {
  5435. noArrowAt.push(invalid[i].start);
  5436. }
  5437. ({
  5438. consequent,
  5439. failed
  5440. } = this.tryParseConditionalConsequent());
  5441. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  5442. }
  5443. if (failed && valid.length > 1) {
  5444. this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
  5445. }
  5446. if (failed && valid.length === 1) {
  5447. this.state = state;
  5448. noArrowAt.push(valid[0].start);
  5449. this.state.noArrowAt = noArrowAt;
  5450. ({
  5451. consequent,
  5452. failed
  5453. } = this.tryParseConditionalConsequent());
  5454. }
  5455. }
  5456. this.getArrowLikeExpressions(consequent, true);
  5457. this.state.noArrowAt = originalNoArrowAt;
  5458. this.expect(14);
  5459. node.test = expr;
  5460. node.consequent = consequent;
  5461. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  5462. return this.finishNode(node, "ConditionalExpression");
  5463. }
  5464. tryParseConditionalConsequent() {
  5465. this.state.noArrowParamsConversionAt.push(this.state.start);
  5466. const consequent = this.parseMaybeAssignAllowIn();
  5467. const failed = !this.match(14);
  5468. this.state.noArrowParamsConversionAt.pop();
  5469. return {
  5470. consequent,
  5471. failed
  5472. };
  5473. }
  5474. getArrowLikeExpressions(node, disallowInvalid) {
  5475. const stack = [node];
  5476. const arrows = [];
  5477. while (stack.length !== 0) {
  5478. const node = stack.pop();
  5479. if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
  5480. if (node.typeParameters || !node.returnType) {
  5481. this.finishArrowValidation(node);
  5482. } else {
  5483. arrows.push(node);
  5484. }
  5485. stack.push(node.body);
  5486. } else if (node.type === "ConditionalExpression") {
  5487. stack.push(node.consequent);
  5488. stack.push(node.alternate);
  5489. }
  5490. }
  5491. if (disallowInvalid) {
  5492. arrows.forEach(node => this.finishArrowValidation(node));
  5493. return [arrows, []];
  5494. }
  5495. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  5496. }
  5497. finishArrowValidation(node) {
  5498. var _node$extra;
  5499. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
  5500. this.scope.enter(514 | 4);
  5501. super.checkParams(node, false, true);
  5502. this.scope.exit();
  5503. }
  5504. forwardNoArrowParamsConversionAt(node, parse) {
  5505. let result;
  5506. if (this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
  5507. this.state.noArrowParamsConversionAt.push(this.state.start);
  5508. result = parse();
  5509. this.state.noArrowParamsConversionAt.pop();
  5510. } else {
  5511. result = parse();
  5512. }
  5513. return result;
  5514. }
  5515. parseParenItem(node, startLoc) {
  5516. const newNode = super.parseParenItem(node, startLoc);
  5517. if (this.eat(17)) {
  5518. newNode.optional = true;
  5519. this.resetEndLocation(node);
  5520. }
  5521. if (this.match(14)) {
  5522. const typeCastNode = this.startNodeAt(startLoc);
  5523. typeCastNode.expression = newNode;
  5524. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  5525. return this.finishNode(typeCastNode, "TypeCastExpression");
  5526. }
  5527. return newNode;
  5528. }
  5529. assertModuleNodeAllowed(node) {
  5530. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  5531. return;
  5532. }
  5533. super.assertModuleNodeAllowed(node);
  5534. }
  5535. parseExportDeclaration(node) {
  5536. if (this.isContextual(130)) {
  5537. node.exportKind = "type";
  5538. const declarationNode = this.startNode();
  5539. this.next();
  5540. if (this.match(5)) {
  5541. node.specifiers = this.parseExportSpecifiers(true);
  5542. super.parseExportFrom(node);
  5543. return null;
  5544. } else {
  5545. return this.flowParseTypeAlias(declarationNode);
  5546. }
  5547. } else if (this.isContextual(131)) {
  5548. node.exportKind = "type";
  5549. const declarationNode = this.startNode();
  5550. this.next();
  5551. return this.flowParseOpaqueType(declarationNode, false);
  5552. } else if (this.isContextual(129)) {
  5553. node.exportKind = "type";
  5554. const declarationNode = this.startNode();
  5555. this.next();
  5556. return this.flowParseInterface(declarationNode);
  5557. } else if (this.isContextual(126)) {
  5558. node.exportKind = "value";
  5559. const declarationNode = this.startNode();
  5560. this.next();
  5561. return this.flowParseEnumDeclaration(declarationNode);
  5562. } else {
  5563. return super.parseExportDeclaration(node);
  5564. }
  5565. }
  5566. eatExportStar(node) {
  5567. if (super.eatExportStar(node)) return true;
  5568. if (this.isContextual(130) && this.lookahead().type === 55) {
  5569. node.exportKind = "type";
  5570. this.next();
  5571. this.next();
  5572. return true;
  5573. }
  5574. return false;
  5575. }
  5576. maybeParseExportNamespaceSpecifier(node) {
  5577. const {
  5578. startLoc
  5579. } = this.state;
  5580. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  5581. if (hasNamespace && node.exportKind === "type") {
  5582. this.unexpected(startLoc);
  5583. }
  5584. return hasNamespace;
  5585. }
  5586. parseClassId(node, isStatement, optionalId) {
  5587. super.parseClassId(node, isStatement, optionalId);
  5588. if (this.match(47)) {
  5589. node.typeParameters = this.flowParseTypeParameterDeclaration();
  5590. }
  5591. }
  5592. parseClassMember(classBody, member, state) {
  5593. const {
  5594. startLoc
  5595. } = this.state;
  5596. if (this.isContextual(125)) {
  5597. if (super.parseClassMemberFromModifier(classBody, member)) {
  5598. return;
  5599. }
  5600. member.declare = true;
  5601. }
  5602. super.parseClassMember(classBody, member, state);
  5603. if (member.declare) {
  5604. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  5605. this.raise(FlowErrors.DeclareClassElement, startLoc);
  5606. } else if (member.value) {
  5607. this.raise(FlowErrors.DeclareClassFieldInitializer, member.value);
  5608. }
  5609. }
  5610. }
  5611. isIterator(word) {
  5612. return word === "iterator" || word === "asyncIterator";
  5613. }
  5614. readIterator() {
  5615. const word = super.readWord1();
  5616. const fullWord = "@@" + word;
  5617. if (!this.isIterator(word) || !this.state.inType) {
  5618. this.raise(Errors.InvalidIdentifier, this.state.curPosition(), {
  5619. identifierName: fullWord
  5620. });
  5621. }
  5622. this.finishToken(132, fullWord);
  5623. }
  5624. getTokenFromCode(code) {
  5625. const next = this.input.charCodeAt(this.state.pos + 1);
  5626. if (code === 123 && next === 124) {
  5627. this.finishOp(6, 2);
  5628. } else if (this.state.inType && (code === 62 || code === 60)) {
  5629. this.finishOp(code === 62 ? 48 : 47, 1);
  5630. } else if (this.state.inType && code === 63) {
  5631. if (next === 46) {
  5632. this.finishOp(18, 2);
  5633. } else {
  5634. this.finishOp(17, 1);
  5635. }
  5636. } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) {
  5637. this.state.pos += 2;
  5638. this.readIterator();
  5639. } else {
  5640. super.getTokenFromCode(code);
  5641. }
  5642. }
  5643. isAssignable(node, isBinding) {
  5644. if (node.type === "TypeCastExpression") {
  5645. return this.isAssignable(node.expression, isBinding);
  5646. } else {
  5647. return super.isAssignable(node, isBinding);
  5648. }
  5649. }
  5650. toAssignable(node, isLHS = false) {
  5651. if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
  5652. node.left = this.typeCastToParameter(node.left);
  5653. }
  5654. super.toAssignable(node, isLHS);
  5655. }
  5656. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  5657. for (let i = 0; i < exprList.length; i++) {
  5658. const expr = exprList[i];
  5659. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  5660. exprList[i] = this.typeCastToParameter(expr);
  5661. }
  5662. }
  5663. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  5664. }
  5665. toReferencedList(exprList, isParenthesizedExpr) {
  5666. for (let i = 0; i < exprList.length; i++) {
  5667. var _expr$extra;
  5668. const expr = exprList[i];
  5669. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  5670. this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation);
  5671. }
  5672. }
  5673. return exprList;
  5674. }
  5675. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  5676. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  5677. if (canBePattern && !this.state.maybeInArrowParameters) {
  5678. this.toReferencedList(node.elements);
  5679. }
  5680. return node;
  5681. }
  5682. isValidLVal(type, isParenthesized, binding) {
  5683. return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding);
  5684. }
  5685. parseClassProperty(node) {
  5686. if (this.match(14)) {
  5687. node.typeAnnotation = this.flowParseTypeAnnotation();
  5688. }
  5689. return super.parseClassProperty(node);
  5690. }
  5691. parseClassPrivateProperty(node) {
  5692. if (this.match(14)) {
  5693. node.typeAnnotation = this.flowParseTypeAnnotation();
  5694. }
  5695. return super.parseClassPrivateProperty(node);
  5696. }
  5697. isClassMethod() {
  5698. return this.match(47) || super.isClassMethod();
  5699. }
  5700. isClassProperty() {
  5701. return this.match(14) || super.isClassProperty();
  5702. }
  5703. isNonstaticConstructor(method) {
  5704. return !this.match(14) && super.isNonstaticConstructor(method);
  5705. }
  5706. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  5707. if (method.variance) {
  5708. this.unexpected(method.variance.loc.start);
  5709. }
  5710. delete method.variance;
  5711. if (this.match(47)) {
  5712. method.typeParameters = this.flowParseTypeParameterDeclaration();
  5713. }
  5714. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  5715. if (method.params && isConstructor) {
  5716. const params = method.params;
  5717. if (params.length > 0 && this.isThisParam(params[0])) {
  5718. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  5719. }
  5720. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  5721. const params = method.value.params;
  5722. if (params.length > 0 && this.isThisParam(params[0])) {
  5723. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  5724. }
  5725. }
  5726. }
  5727. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  5728. if (method.variance) {
  5729. this.unexpected(method.variance.loc.start);
  5730. }
  5731. delete method.variance;
  5732. if (this.match(47)) {
  5733. method.typeParameters = this.flowParseTypeParameterDeclaration();
  5734. }
  5735. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  5736. }
  5737. parseClassSuper(node) {
  5738. super.parseClassSuper(node);
  5739. if (node.superClass && (this.match(47) || this.match(51))) {
  5740. {
  5741. node.superTypeParameters = this.flowParseTypeParameterInstantiationInExpression();
  5742. }
  5743. }
  5744. if (this.isContextual(113)) {
  5745. this.next();
  5746. const implemented = node.implements = [];
  5747. do {
  5748. const node = this.startNode();
  5749. node.id = this.flowParseRestrictedIdentifier(true);
  5750. if (this.match(47)) {
  5751. node.typeParameters = this.flowParseTypeParameterInstantiation();
  5752. } else {
  5753. node.typeParameters = null;
  5754. }
  5755. implemented.push(this.finishNode(node, "ClassImplements"));
  5756. } while (this.eat(12));
  5757. }
  5758. }
  5759. checkGetterSetterParams(method) {
  5760. super.checkGetterSetterParams(method);
  5761. const params = this.getObjectOrClassMethodParams(method);
  5762. if (params.length > 0) {
  5763. const param = params[0];
  5764. if (this.isThisParam(param) && method.kind === "get") {
  5765. this.raise(FlowErrors.GetterMayNotHaveThisParam, param);
  5766. } else if (this.isThisParam(param)) {
  5767. this.raise(FlowErrors.SetterMayNotHaveThisParam, param);
  5768. }
  5769. }
  5770. }
  5771. parsePropertyNamePrefixOperator(node) {
  5772. node.variance = this.flowParseVariance();
  5773. }
  5774. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  5775. if (prop.variance) {
  5776. this.unexpected(prop.variance.loc.start);
  5777. }
  5778. delete prop.variance;
  5779. let typeParameters;
  5780. if (this.match(47) && !isAccessor) {
  5781. typeParameters = this.flowParseTypeParameterDeclaration();
  5782. if (!this.match(10)) this.unexpected();
  5783. }
  5784. const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  5785. if (typeParameters) {
  5786. (result.value || result).typeParameters = typeParameters;
  5787. }
  5788. return result;
  5789. }
  5790. parseFunctionParamType(param) {
  5791. if (this.eat(17)) {
  5792. if (param.type !== "Identifier") {
  5793. this.raise(FlowErrors.PatternIsOptional, param);
  5794. }
  5795. if (this.isThisParam(param)) {
  5796. this.raise(FlowErrors.ThisParamMayNotBeOptional, param);
  5797. }
  5798. param.optional = true;
  5799. }
  5800. if (this.match(14)) {
  5801. param.typeAnnotation = this.flowParseTypeAnnotation();
  5802. } else if (this.isThisParam(param)) {
  5803. this.raise(FlowErrors.ThisParamAnnotationRequired, param);
  5804. }
  5805. if (this.match(29) && this.isThisParam(param)) {
  5806. this.raise(FlowErrors.ThisParamNoDefault, param);
  5807. }
  5808. this.resetEndLocation(param);
  5809. return param;
  5810. }
  5811. parseMaybeDefault(startLoc, left) {
  5812. const node = super.parseMaybeDefault(startLoc, left);
  5813. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  5814. this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation);
  5815. }
  5816. return node;
  5817. }
  5818. checkImportReflection(node) {
  5819. super.checkImportReflection(node);
  5820. if (node.module && node.importKind !== "value") {
  5821. this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  5822. }
  5823. }
  5824. parseImportSpecifierLocal(node, specifier, type) {
  5825. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  5826. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  5827. }
  5828. isPotentialImportPhase(isExport) {
  5829. if (super.isPotentialImportPhase(isExport)) return true;
  5830. if (this.isContextual(130)) {
  5831. if (!isExport) return true;
  5832. const ch = this.lookaheadCharCode();
  5833. return ch === 123 || ch === 42;
  5834. }
  5835. return !isExport && this.isContextual(87);
  5836. }
  5837. applyImportPhase(node, isExport, phase, loc) {
  5838. super.applyImportPhase(node, isExport, phase, loc);
  5839. if (isExport) {
  5840. if (!phase && this.match(65)) {
  5841. return;
  5842. }
  5843. node.exportKind = phase === "type" ? phase : "value";
  5844. } else {
  5845. if (phase === "type" && this.match(55)) this.unexpected();
  5846. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  5847. }
  5848. }
  5849. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  5850. const firstIdent = specifier.imported;
  5851. let specifierTypeKind = null;
  5852. if (firstIdent.type === "Identifier") {
  5853. if (firstIdent.name === "type") {
  5854. specifierTypeKind = "type";
  5855. } else if (firstIdent.name === "typeof") {
  5856. specifierTypeKind = "typeof";
  5857. }
  5858. }
  5859. let isBinding = false;
  5860. if (this.isContextual(93) && !this.isLookaheadContextual("as")) {
  5861. const as_ident = this.parseIdentifier(true);
  5862. if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
  5863. specifier.imported = as_ident;
  5864. specifier.importKind = specifierTypeKind;
  5865. specifier.local = this.cloneIdentifier(as_ident);
  5866. } else {
  5867. specifier.imported = firstIdent;
  5868. specifier.importKind = null;
  5869. specifier.local = this.parseIdentifier();
  5870. }
  5871. } else {
  5872. if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) {
  5873. specifier.imported = this.parseIdentifier(true);
  5874. specifier.importKind = specifierTypeKind;
  5875. } else {
  5876. if (importedIsString) {
  5877. throw this.raise(Errors.ImportBindingIsString, specifier, {
  5878. importName: firstIdent.value
  5879. });
  5880. }
  5881. specifier.imported = firstIdent;
  5882. specifier.importKind = null;
  5883. }
  5884. if (this.eatContextual(93)) {
  5885. specifier.local = this.parseIdentifier();
  5886. } else {
  5887. isBinding = true;
  5888. specifier.local = this.cloneIdentifier(specifier.imported);
  5889. }
  5890. }
  5891. const specifierIsTypeImport = hasTypeImportKind(specifier);
  5892. if (isInTypeOnlyImport && specifierIsTypeImport) {
  5893. this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
  5894. }
  5895. if (isInTypeOnlyImport || specifierIsTypeImport) {
  5896. this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
  5897. }
  5898. if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
  5899. this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
  5900. }
  5901. return this.finishImportSpecifier(specifier, "ImportSpecifier");
  5902. }
  5903. parseBindingAtom() {
  5904. switch (this.state.type) {
  5905. case 78:
  5906. return this.parseIdentifier(true);
  5907. default:
  5908. return super.parseBindingAtom();
  5909. }
  5910. }
  5911. parseFunctionParams(node, isConstructor) {
  5912. const kind = node.kind;
  5913. if (kind !== "get" && kind !== "set" && this.match(47)) {
  5914. node.typeParameters = this.flowParseTypeParameterDeclaration();
  5915. }
  5916. super.parseFunctionParams(node, isConstructor);
  5917. }
  5918. parseVarId(decl, kind) {
  5919. super.parseVarId(decl, kind);
  5920. if (this.match(14)) {
  5921. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  5922. this.resetEndLocation(decl.id);
  5923. }
  5924. }
  5925. parseAsyncArrowFromCallExpression(node, call) {
  5926. if (this.match(14)) {
  5927. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  5928. this.state.noAnonFunctionType = true;
  5929. node.returnType = this.flowParseTypeAnnotation();
  5930. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  5931. }
  5932. return super.parseAsyncArrowFromCallExpression(node, call);
  5933. }
  5934. shouldParseAsyncArrow() {
  5935. return this.match(14) || super.shouldParseAsyncArrow();
  5936. }
  5937. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  5938. var _jsx;
  5939. let state = null;
  5940. let jsx;
  5941. if (this.hasPlugin("jsx") && (this.match(143) || this.match(47))) {
  5942. state = this.state.clone();
  5943. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  5944. if (!jsx.error) return jsx.node;
  5945. const {
  5946. context
  5947. } = this.state;
  5948. const currentContext = context[context.length - 1];
  5949. if (currentContext === types.j_oTag || currentContext === types.j_expr) {
  5950. context.pop();
  5951. }
  5952. }
  5953. if ((_jsx = jsx) != null && _jsx.error || this.match(47)) {
  5954. var _jsx2, _jsx3;
  5955. state = state || this.state.clone();
  5956. let typeParameters;
  5957. const arrow = this.tryParse(abort => {
  5958. var _arrowExpression$extr;
  5959. typeParameters = this.flowParseTypeParameterDeclaration();
  5960. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  5961. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  5962. this.resetStartLocationFromNode(result, typeParameters);
  5963. return result;
  5964. });
  5965. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  5966. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  5967. if (expr.type !== "ArrowFunctionExpression") abort();
  5968. expr.typeParameters = typeParameters;
  5969. this.resetStartLocationFromNode(expr, typeParameters);
  5970. return arrowExpression;
  5971. }, state);
  5972. let arrowExpression = null;
  5973. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  5974. if (!arrow.error && !arrow.aborted) {
  5975. if (arrow.node.async) {
  5976. this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters);
  5977. }
  5978. return arrow.node;
  5979. }
  5980. arrowExpression = arrow.node;
  5981. }
  5982. if ((_jsx2 = jsx) != null && _jsx2.node) {
  5983. this.state = jsx.failState;
  5984. return jsx.node;
  5985. }
  5986. if (arrowExpression) {
  5987. this.state = arrow.failState;
  5988. return arrowExpression;
  5989. }
  5990. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  5991. if (arrow.thrown) throw arrow.error;
  5992. throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters);
  5993. }
  5994. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  5995. }
  5996. parseArrow(node) {
  5997. if (this.match(14)) {
  5998. const result = this.tryParse(() => {
  5999. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  6000. this.state.noAnonFunctionType = true;
  6001. const typeNode = this.startNode();
  6002. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  6003. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  6004. if (this.canInsertSemicolon()) this.unexpected();
  6005. if (!this.match(19)) this.unexpected();
  6006. return typeNode;
  6007. });
  6008. if (result.thrown) return null;
  6009. if (result.error) this.state = result.failState;
  6010. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  6011. }
  6012. return super.parseArrow(node);
  6013. }
  6014. shouldParseArrow(params) {
  6015. return this.match(14) || super.shouldParseArrow(params);
  6016. }
  6017. setArrowFunctionParameters(node, params) {
  6018. if (this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
  6019. node.params = params;
  6020. } else {
  6021. super.setArrowFunctionParameters(node, params);
  6022. }
  6023. }
  6024. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  6025. if (isArrowFunction && this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
  6026. return;
  6027. }
  6028. for (let i = 0; i < node.params.length; i++) {
  6029. if (this.isThisParam(node.params[i]) && i > 0) {
  6030. this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
  6031. }
  6032. }
  6033. super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
  6034. }
  6035. parseParenAndDistinguishExpression(canBeArrow) {
  6036. return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)));
  6037. }
  6038. parseSubscripts(base, startLoc, noCalls) {
  6039. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.includes(startLoc.index)) {
  6040. this.next();
  6041. const node = this.startNodeAt(startLoc);
  6042. node.callee = base;
  6043. node.arguments = super.parseCallExpressionArguments();
  6044. base = this.finishNode(node, "CallExpression");
  6045. } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
  6046. const state = this.state.clone();
  6047. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
  6048. if (!arrow.error && !arrow.aborted) return arrow.node;
  6049. const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state);
  6050. if (result.node && !result.error) return result.node;
  6051. if (arrow.node) {
  6052. this.state = arrow.failState;
  6053. return arrow.node;
  6054. }
  6055. if (result.node) {
  6056. this.state = result.failState;
  6057. return result.node;
  6058. }
  6059. throw arrow.error || result.error;
  6060. }
  6061. return super.parseSubscripts(base, startLoc, noCalls);
  6062. }
  6063. parseSubscript(base, startLoc, noCalls, subscriptState) {
  6064. if (this.match(18) && this.isLookaheadToken_lt()) {
  6065. subscriptState.optionalChainMember = true;
  6066. if (noCalls) {
  6067. subscriptState.stop = true;
  6068. return base;
  6069. }
  6070. this.next();
  6071. const node = this.startNodeAt(startLoc);
  6072. node.callee = base;
  6073. node.typeArguments = this.flowParseTypeParameterInstantiationInExpression();
  6074. this.expect(10);
  6075. node.arguments = this.parseCallExpressionArguments();
  6076. node.optional = true;
  6077. return this.finishCallExpression(node, true);
  6078. } else if (!noCalls && this.shouldParseTypes() && (this.match(47) || this.match(51))) {
  6079. const node = this.startNodeAt(startLoc);
  6080. node.callee = base;
  6081. const result = this.tryParse(() => {
  6082. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  6083. this.expect(10);
  6084. node.arguments = super.parseCallExpressionArguments();
  6085. if (subscriptState.optionalChainMember) {
  6086. node.optional = false;
  6087. }
  6088. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  6089. });
  6090. if (result.node) {
  6091. if (result.error) this.state = result.failState;
  6092. return result.node;
  6093. }
  6094. }
  6095. return super.parseSubscript(base, startLoc, noCalls, subscriptState);
  6096. }
  6097. parseNewCallee(node) {
  6098. super.parseNewCallee(node);
  6099. let targs = null;
  6100. if (this.shouldParseTypes() && this.match(47)) {
  6101. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  6102. }
  6103. node.typeArguments = targs;
  6104. }
  6105. parseAsyncArrowWithTypeParameters(startLoc) {
  6106. const node = this.startNodeAt(startLoc);
  6107. this.parseFunctionParams(node, false);
  6108. if (!this.parseArrow(node)) return;
  6109. return super.parseArrowExpression(node, undefined, true);
  6110. }
  6111. readToken_mult_modulo(code) {
  6112. const next = this.input.charCodeAt(this.state.pos + 1);
  6113. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  6114. this.state.hasFlowComment = false;
  6115. this.state.pos += 2;
  6116. this.nextToken();
  6117. return;
  6118. }
  6119. super.readToken_mult_modulo(code);
  6120. }
  6121. readToken_pipe_amp(code) {
  6122. const next = this.input.charCodeAt(this.state.pos + 1);
  6123. if (code === 124 && next === 125) {
  6124. this.finishOp(9, 2);
  6125. return;
  6126. }
  6127. super.readToken_pipe_amp(code);
  6128. }
  6129. parseTopLevel(file, program) {
  6130. const fileNode = super.parseTopLevel(file, program);
  6131. if (this.state.hasFlowComment) {
  6132. this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition());
  6133. }
  6134. return fileNode;
  6135. }
  6136. skipBlockComment() {
  6137. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  6138. if (this.state.hasFlowComment) {
  6139. throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc);
  6140. }
  6141. this.hasFlowCommentCompletion();
  6142. const commentSkip = this.skipFlowComment();
  6143. if (commentSkip) {
  6144. this.state.pos += commentSkip;
  6145. this.state.hasFlowComment = true;
  6146. }
  6147. return;
  6148. }
  6149. return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/");
  6150. }
  6151. skipFlowComment() {
  6152. const {
  6153. pos
  6154. } = this.state;
  6155. let shiftToFirstNonWhiteSpace = 2;
  6156. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  6157. shiftToFirstNonWhiteSpace++;
  6158. }
  6159. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  6160. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  6161. if (ch2 === 58 && ch3 === 58) {
  6162. return shiftToFirstNonWhiteSpace + 2;
  6163. }
  6164. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  6165. return shiftToFirstNonWhiteSpace + 12;
  6166. }
  6167. if (ch2 === 58 && ch3 !== 58) {
  6168. return shiftToFirstNonWhiteSpace;
  6169. }
  6170. return false;
  6171. }
  6172. hasFlowCommentCompletion() {
  6173. const end = this.input.indexOf("*/", this.state.pos);
  6174. if (end === -1) {
  6175. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  6176. }
  6177. }
  6178. flowEnumErrorBooleanMemberNotInitialized(loc, {
  6179. enumName,
  6180. memberName
  6181. }) {
  6182. this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, {
  6183. memberName,
  6184. enumName
  6185. });
  6186. }
  6187. flowEnumErrorInvalidMemberInitializer(loc, enumContext) {
  6188. return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext);
  6189. }
  6190. flowEnumErrorNumberMemberNotInitialized(loc, details) {
  6191. this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details);
  6192. }
  6193. flowEnumErrorStringMemberInconsistentlyInitialized(node, details) {
  6194. this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details);
  6195. }
  6196. flowEnumMemberInit() {
  6197. const startLoc = this.state.startLoc;
  6198. const endOfInit = () => this.match(12) || this.match(8);
  6199. switch (this.state.type) {
  6200. case 135:
  6201. {
  6202. const literal = this.parseNumericLiteral(this.state.value);
  6203. if (endOfInit()) {
  6204. return {
  6205. type: "number",
  6206. loc: literal.loc.start,
  6207. value: literal
  6208. };
  6209. }
  6210. return {
  6211. type: "invalid",
  6212. loc: startLoc
  6213. };
  6214. }
  6215. case 134:
  6216. {
  6217. const literal = this.parseStringLiteral(this.state.value);
  6218. if (endOfInit()) {
  6219. return {
  6220. type: "string",
  6221. loc: literal.loc.start,
  6222. value: literal
  6223. };
  6224. }
  6225. return {
  6226. type: "invalid",
  6227. loc: startLoc
  6228. };
  6229. }
  6230. case 85:
  6231. case 86:
  6232. {
  6233. const literal = this.parseBooleanLiteral(this.match(85));
  6234. if (endOfInit()) {
  6235. return {
  6236. type: "boolean",
  6237. loc: literal.loc.start,
  6238. value: literal
  6239. };
  6240. }
  6241. return {
  6242. type: "invalid",
  6243. loc: startLoc
  6244. };
  6245. }
  6246. default:
  6247. return {
  6248. type: "invalid",
  6249. loc: startLoc
  6250. };
  6251. }
  6252. }
  6253. flowEnumMemberRaw() {
  6254. const loc = this.state.startLoc;
  6255. const id = this.parseIdentifier(true);
  6256. const init = this.eat(29) ? this.flowEnumMemberInit() : {
  6257. type: "none",
  6258. loc
  6259. };
  6260. return {
  6261. id,
  6262. init
  6263. };
  6264. }
  6265. flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
  6266. const {
  6267. explicitType
  6268. } = context;
  6269. if (explicitType === null) {
  6270. return;
  6271. }
  6272. if (explicitType !== expectedType) {
  6273. this.flowEnumErrorInvalidMemberInitializer(loc, context);
  6274. }
  6275. }
  6276. flowEnumMembers({
  6277. enumName,
  6278. explicitType
  6279. }) {
  6280. const seenNames = new Set();
  6281. const members = {
  6282. booleanMembers: [],
  6283. numberMembers: [],
  6284. stringMembers: [],
  6285. defaultedMembers: []
  6286. };
  6287. let hasUnknownMembers = false;
  6288. while (!this.match(8)) {
  6289. if (this.eat(21)) {
  6290. hasUnknownMembers = true;
  6291. break;
  6292. }
  6293. const memberNode = this.startNode();
  6294. const {
  6295. id,
  6296. init
  6297. } = this.flowEnumMemberRaw();
  6298. const memberName = id.name;
  6299. if (memberName === "") {
  6300. continue;
  6301. }
  6302. if (/^[a-z]/.test(memberName)) {
  6303. this.raise(FlowErrors.EnumInvalidMemberName, id, {
  6304. memberName,
  6305. suggestion: memberName[0].toUpperCase() + memberName.slice(1),
  6306. enumName
  6307. });
  6308. }
  6309. if (seenNames.has(memberName)) {
  6310. this.raise(FlowErrors.EnumDuplicateMemberName, id, {
  6311. memberName,
  6312. enumName
  6313. });
  6314. }
  6315. seenNames.add(memberName);
  6316. const context = {
  6317. enumName,
  6318. explicitType,
  6319. memberName
  6320. };
  6321. memberNode.id = id;
  6322. switch (init.type) {
  6323. case "boolean":
  6324. {
  6325. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
  6326. memberNode.init = init.value;
  6327. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  6328. break;
  6329. }
  6330. case "number":
  6331. {
  6332. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
  6333. memberNode.init = init.value;
  6334. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  6335. break;
  6336. }
  6337. case "string":
  6338. {
  6339. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
  6340. memberNode.init = init.value;
  6341. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  6342. break;
  6343. }
  6344. case "invalid":
  6345. {
  6346. throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
  6347. }
  6348. case "none":
  6349. {
  6350. switch (explicitType) {
  6351. case "boolean":
  6352. this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
  6353. break;
  6354. case "number":
  6355. this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
  6356. break;
  6357. default:
  6358. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  6359. }
  6360. }
  6361. }
  6362. if (!this.match(8)) {
  6363. this.expect(12);
  6364. }
  6365. }
  6366. return {
  6367. members,
  6368. hasUnknownMembers
  6369. };
  6370. }
  6371. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  6372. enumName
  6373. }) {
  6374. if (initializedMembers.length === 0) {
  6375. return defaultedMembers;
  6376. } else if (defaultedMembers.length === 0) {
  6377. return initializedMembers;
  6378. } else if (defaultedMembers.length > initializedMembers.length) {
  6379. for (const member of initializedMembers) {
  6380. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  6381. enumName
  6382. });
  6383. }
  6384. return defaultedMembers;
  6385. } else {
  6386. for (const member of defaultedMembers) {
  6387. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  6388. enumName
  6389. });
  6390. }
  6391. return initializedMembers;
  6392. }
  6393. }
  6394. flowEnumParseExplicitType({
  6395. enumName
  6396. }) {
  6397. if (!this.eatContextual(102)) return null;
  6398. if (!tokenIsIdentifier(this.state.type)) {
  6399. throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, {
  6400. enumName
  6401. });
  6402. }
  6403. const {
  6404. value
  6405. } = this.state;
  6406. this.next();
  6407. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  6408. this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, {
  6409. enumName,
  6410. invalidEnumType: value
  6411. });
  6412. }
  6413. return value;
  6414. }
  6415. flowEnumBody(node, id) {
  6416. const enumName = id.name;
  6417. const nameLoc = id.loc.start;
  6418. const explicitType = this.flowEnumParseExplicitType({
  6419. enumName
  6420. });
  6421. this.expect(5);
  6422. const {
  6423. members,
  6424. hasUnknownMembers
  6425. } = this.flowEnumMembers({
  6426. enumName,
  6427. explicitType
  6428. });
  6429. node.hasUnknownMembers = hasUnknownMembers;
  6430. switch (explicitType) {
  6431. case "boolean":
  6432. node.explicitType = true;
  6433. node.members = members.booleanMembers;
  6434. this.expect(8);
  6435. return this.finishNode(node, "EnumBooleanBody");
  6436. case "number":
  6437. node.explicitType = true;
  6438. node.members = members.numberMembers;
  6439. this.expect(8);
  6440. return this.finishNode(node, "EnumNumberBody");
  6441. case "string":
  6442. node.explicitType = true;
  6443. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  6444. enumName
  6445. });
  6446. this.expect(8);
  6447. return this.finishNode(node, "EnumStringBody");
  6448. case "symbol":
  6449. node.members = members.defaultedMembers;
  6450. this.expect(8);
  6451. return this.finishNode(node, "EnumSymbolBody");
  6452. default:
  6453. {
  6454. const empty = () => {
  6455. node.members = [];
  6456. this.expect(8);
  6457. return this.finishNode(node, "EnumStringBody");
  6458. };
  6459. node.explicitType = false;
  6460. const boolsLen = members.booleanMembers.length;
  6461. const numsLen = members.numberMembers.length;
  6462. const strsLen = members.stringMembers.length;
  6463. const defaultedLen = members.defaultedMembers.length;
  6464. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  6465. return empty();
  6466. } else if (!boolsLen && !numsLen) {
  6467. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  6468. enumName
  6469. });
  6470. this.expect(8);
  6471. return this.finishNode(node, "EnumStringBody");
  6472. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  6473. for (const member of members.defaultedMembers) {
  6474. this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
  6475. enumName,
  6476. memberName: member.id.name
  6477. });
  6478. }
  6479. node.members = members.booleanMembers;
  6480. this.expect(8);
  6481. return this.finishNode(node, "EnumBooleanBody");
  6482. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  6483. for (const member of members.defaultedMembers) {
  6484. this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, {
  6485. enumName,
  6486. memberName: member.id.name
  6487. });
  6488. }
  6489. node.members = members.numberMembers;
  6490. this.expect(8);
  6491. return this.finishNode(node, "EnumNumberBody");
  6492. } else {
  6493. this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, {
  6494. enumName
  6495. });
  6496. return empty();
  6497. }
  6498. }
  6499. }
  6500. }
  6501. flowParseEnumDeclaration(node) {
  6502. const id = this.parseIdentifier();
  6503. node.id = id;
  6504. node.body = this.flowEnumBody(this.startNode(), id);
  6505. return this.finishNode(node, "EnumDeclaration");
  6506. }
  6507. jsxParseOpeningElementAfterName(node) {
  6508. if (this.shouldParseTypes()) {
  6509. if (this.match(47) || this.match(51)) {
  6510. node.typeArguments = this.flowParseTypeParameterInstantiationInExpression();
  6511. }
  6512. }
  6513. return super.jsxParseOpeningElementAfterName(node);
  6514. }
  6515. isLookaheadToken_lt() {
  6516. const next = this.nextTokenStart();
  6517. if (this.input.charCodeAt(next) === 60) {
  6518. const afterNext = this.input.charCodeAt(next + 1);
  6519. return afterNext !== 60 && afterNext !== 61;
  6520. }
  6521. return false;
  6522. }
  6523. reScan_lt_gt() {
  6524. const {
  6525. type
  6526. } = this.state;
  6527. if (type === 47) {
  6528. this.state.pos -= 1;
  6529. this.readToken_lt();
  6530. } else if (type === 48) {
  6531. this.state.pos -= 1;
  6532. this.readToken_gt();
  6533. }
  6534. }
  6535. reScan_lt() {
  6536. const {
  6537. type
  6538. } = this.state;
  6539. if (type === 51) {
  6540. this.state.pos -= 2;
  6541. this.finishOp(47, 1);
  6542. return 47;
  6543. }
  6544. return type;
  6545. }
  6546. maybeUnwrapTypeCastExpression(node) {
  6547. return node.type === "TypeCastExpression" ? node.expression : node;
  6548. }
  6549. };
  6550. const entities = {
  6551. __proto__: null,
  6552. quot: "\u0022",
  6553. amp: "&",
  6554. apos: "\u0027",
  6555. lt: "<",
  6556. gt: ">",
  6557. nbsp: "\u00A0",
  6558. iexcl: "\u00A1",
  6559. cent: "\u00A2",
  6560. pound: "\u00A3",
  6561. curren: "\u00A4",
  6562. yen: "\u00A5",
  6563. brvbar: "\u00A6",
  6564. sect: "\u00A7",
  6565. uml: "\u00A8",
  6566. copy: "\u00A9",
  6567. ordf: "\u00AA",
  6568. laquo: "\u00AB",
  6569. not: "\u00AC",
  6570. shy: "\u00AD",
  6571. reg: "\u00AE",
  6572. macr: "\u00AF",
  6573. deg: "\u00B0",
  6574. plusmn: "\u00B1",
  6575. sup2: "\u00B2",
  6576. sup3: "\u00B3",
  6577. acute: "\u00B4",
  6578. micro: "\u00B5",
  6579. para: "\u00B6",
  6580. middot: "\u00B7",
  6581. cedil: "\u00B8",
  6582. sup1: "\u00B9",
  6583. ordm: "\u00BA",
  6584. raquo: "\u00BB",
  6585. frac14: "\u00BC",
  6586. frac12: "\u00BD",
  6587. frac34: "\u00BE",
  6588. iquest: "\u00BF",
  6589. Agrave: "\u00C0",
  6590. Aacute: "\u00C1",
  6591. Acirc: "\u00C2",
  6592. Atilde: "\u00C3",
  6593. Auml: "\u00C4",
  6594. Aring: "\u00C5",
  6595. AElig: "\u00C6",
  6596. Ccedil: "\u00C7",
  6597. Egrave: "\u00C8",
  6598. Eacute: "\u00C9",
  6599. Ecirc: "\u00CA",
  6600. Euml: "\u00CB",
  6601. Igrave: "\u00CC",
  6602. Iacute: "\u00CD",
  6603. Icirc: "\u00CE",
  6604. Iuml: "\u00CF",
  6605. ETH: "\u00D0",
  6606. Ntilde: "\u00D1",
  6607. Ograve: "\u00D2",
  6608. Oacute: "\u00D3",
  6609. Ocirc: "\u00D4",
  6610. Otilde: "\u00D5",
  6611. Ouml: "\u00D6",
  6612. times: "\u00D7",
  6613. Oslash: "\u00D8",
  6614. Ugrave: "\u00D9",
  6615. Uacute: "\u00DA",
  6616. Ucirc: "\u00DB",
  6617. Uuml: "\u00DC",
  6618. Yacute: "\u00DD",
  6619. THORN: "\u00DE",
  6620. szlig: "\u00DF",
  6621. agrave: "\u00E0",
  6622. aacute: "\u00E1",
  6623. acirc: "\u00E2",
  6624. atilde: "\u00E3",
  6625. auml: "\u00E4",
  6626. aring: "\u00E5",
  6627. aelig: "\u00E6",
  6628. ccedil: "\u00E7",
  6629. egrave: "\u00E8",
  6630. eacute: "\u00E9",
  6631. ecirc: "\u00EA",
  6632. euml: "\u00EB",
  6633. igrave: "\u00EC",
  6634. iacute: "\u00ED",
  6635. icirc: "\u00EE",
  6636. iuml: "\u00EF",
  6637. eth: "\u00F0",
  6638. ntilde: "\u00F1",
  6639. ograve: "\u00F2",
  6640. oacute: "\u00F3",
  6641. ocirc: "\u00F4",
  6642. otilde: "\u00F5",
  6643. ouml: "\u00F6",
  6644. divide: "\u00F7",
  6645. oslash: "\u00F8",
  6646. ugrave: "\u00F9",
  6647. uacute: "\u00FA",
  6648. ucirc: "\u00FB",
  6649. uuml: "\u00FC",
  6650. yacute: "\u00FD",
  6651. thorn: "\u00FE",
  6652. yuml: "\u00FF",
  6653. OElig: "\u0152",
  6654. oelig: "\u0153",
  6655. Scaron: "\u0160",
  6656. scaron: "\u0161",
  6657. Yuml: "\u0178",
  6658. fnof: "\u0192",
  6659. circ: "\u02C6",
  6660. tilde: "\u02DC",
  6661. Alpha: "\u0391",
  6662. Beta: "\u0392",
  6663. Gamma: "\u0393",
  6664. Delta: "\u0394",
  6665. Epsilon: "\u0395",
  6666. Zeta: "\u0396",
  6667. Eta: "\u0397",
  6668. Theta: "\u0398",
  6669. Iota: "\u0399",
  6670. Kappa: "\u039A",
  6671. Lambda: "\u039B",
  6672. Mu: "\u039C",
  6673. Nu: "\u039D",
  6674. Xi: "\u039E",
  6675. Omicron: "\u039F",
  6676. Pi: "\u03A0",
  6677. Rho: "\u03A1",
  6678. Sigma: "\u03A3",
  6679. Tau: "\u03A4",
  6680. Upsilon: "\u03A5",
  6681. Phi: "\u03A6",
  6682. Chi: "\u03A7",
  6683. Psi: "\u03A8",
  6684. Omega: "\u03A9",
  6685. alpha: "\u03B1",
  6686. beta: "\u03B2",
  6687. gamma: "\u03B3",
  6688. delta: "\u03B4",
  6689. epsilon: "\u03B5",
  6690. zeta: "\u03B6",
  6691. eta: "\u03B7",
  6692. theta: "\u03B8",
  6693. iota: "\u03B9",
  6694. kappa: "\u03BA",
  6695. lambda: "\u03BB",
  6696. mu: "\u03BC",
  6697. nu: "\u03BD",
  6698. xi: "\u03BE",
  6699. omicron: "\u03BF",
  6700. pi: "\u03C0",
  6701. rho: "\u03C1",
  6702. sigmaf: "\u03C2",
  6703. sigma: "\u03C3",
  6704. tau: "\u03C4",
  6705. upsilon: "\u03C5",
  6706. phi: "\u03C6",
  6707. chi: "\u03C7",
  6708. psi: "\u03C8",
  6709. omega: "\u03C9",
  6710. thetasym: "\u03D1",
  6711. upsih: "\u03D2",
  6712. piv: "\u03D6",
  6713. ensp: "\u2002",
  6714. emsp: "\u2003",
  6715. thinsp: "\u2009",
  6716. zwnj: "\u200C",
  6717. zwj: "\u200D",
  6718. lrm: "\u200E",
  6719. rlm: "\u200F",
  6720. ndash: "\u2013",
  6721. mdash: "\u2014",
  6722. lsquo: "\u2018",
  6723. rsquo: "\u2019",
  6724. sbquo: "\u201A",
  6725. ldquo: "\u201C",
  6726. rdquo: "\u201D",
  6727. bdquo: "\u201E",
  6728. dagger: "\u2020",
  6729. Dagger: "\u2021",
  6730. bull: "\u2022",
  6731. hellip: "\u2026",
  6732. permil: "\u2030",
  6733. prime: "\u2032",
  6734. Prime: "\u2033",
  6735. lsaquo: "\u2039",
  6736. rsaquo: "\u203A",
  6737. oline: "\u203E",
  6738. frasl: "\u2044",
  6739. euro: "\u20AC",
  6740. image: "\u2111",
  6741. weierp: "\u2118",
  6742. real: "\u211C",
  6743. trade: "\u2122",
  6744. alefsym: "\u2135",
  6745. larr: "\u2190",
  6746. uarr: "\u2191",
  6747. rarr: "\u2192",
  6748. darr: "\u2193",
  6749. harr: "\u2194",
  6750. crarr: "\u21B5",
  6751. lArr: "\u21D0",
  6752. uArr: "\u21D1",
  6753. rArr: "\u21D2",
  6754. dArr: "\u21D3",
  6755. hArr: "\u21D4",
  6756. forall: "\u2200",
  6757. part: "\u2202",
  6758. exist: "\u2203",
  6759. empty: "\u2205",
  6760. nabla: "\u2207",
  6761. isin: "\u2208",
  6762. notin: "\u2209",
  6763. ni: "\u220B",
  6764. prod: "\u220F",
  6765. sum: "\u2211",
  6766. minus: "\u2212",
  6767. lowast: "\u2217",
  6768. radic: "\u221A",
  6769. prop: "\u221D",
  6770. infin: "\u221E",
  6771. ang: "\u2220",
  6772. and: "\u2227",
  6773. or: "\u2228",
  6774. cap: "\u2229",
  6775. cup: "\u222A",
  6776. int: "\u222B",
  6777. there4: "\u2234",
  6778. sim: "\u223C",
  6779. cong: "\u2245",
  6780. asymp: "\u2248",
  6781. ne: "\u2260",
  6782. equiv: "\u2261",
  6783. le: "\u2264",
  6784. ge: "\u2265",
  6785. sub: "\u2282",
  6786. sup: "\u2283",
  6787. nsub: "\u2284",
  6788. sube: "\u2286",
  6789. supe: "\u2287",
  6790. oplus: "\u2295",
  6791. otimes: "\u2297",
  6792. perp: "\u22A5",
  6793. sdot: "\u22C5",
  6794. lceil: "\u2308",
  6795. rceil: "\u2309",
  6796. lfloor: "\u230A",
  6797. rfloor: "\u230B",
  6798. lang: "\u2329",
  6799. rang: "\u232A",
  6800. loz: "\u25CA",
  6801. spades: "\u2660",
  6802. clubs: "\u2663",
  6803. hearts: "\u2665",
  6804. diams: "\u2666"
  6805. };
  6806. const lineBreak = /\r\n|[\r\n\u2028\u2029]/;
  6807. const lineBreakG = new RegExp(lineBreak.source, "g");
  6808. function isNewLine(code) {
  6809. switch (code) {
  6810. case 10:
  6811. case 13:
  6812. case 8232:
  6813. case 8233:
  6814. return true;
  6815. default:
  6816. return false;
  6817. }
  6818. }
  6819. function hasNewLine(input, start, end) {
  6820. for (let i = start; i < end; i++) {
  6821. if (isNewLine(input.charCodeAt(i))) {
  6822. return true;
  6823. }
  6824. }
  6825. return false;
  6826. }
  6827. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  6828. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;
  6829. function isWhitespace(code) {
  6830. switch (code) {
  6831. case 0x0009:
  6832. case 0x000b:
  6833. case 0x000c:
  6834. case 32:
  6835. case 160:
  6836. case 5760:
  6837. case 0x2000:
  6838. case 0x2001:
  6839. case 0x2002:
  6840. case 0x2003:
  6841. case 0x2004:
  6842. case 0x2005:
  6843. case 0x2006:
  6844. case 0x2007:
  6845. case 0x2008:
  6846. case 0x2009:
  6847. case 0x200a:
  6848. case 0x202f:
  6849. case 0x205f:
  6850. case 0x3000:
  6851. case 0xfeff:
  6852. return true;
  6853. default:
  6854. return false;
  6855. }
  6856. }
  6857. const JsxErrors = ParseErrorEnum`jsx`({
  6858. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  6859. MissingClosingTagElement: ({
  6860. openingTagName
  6861. }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
  6862. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  6863. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  6864. UnexpectedToken: ({
  6865. unexpected,
  6866. HTMLEntity
  6867. }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
  6868. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  6869. UnterminatedJsxContent: "Unterminated JSX contents.",
  6870. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  6871. });
  6872. function isFragment(object) {
  6873. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  6874. }
  6875. function getQualifiedJSXName(object) {
  6876. if (object.type === "JSXIdentifier") {
  6877. return object.name;
  6878. }
  6879. if (object.type === "JSXNamespacedName") {
  6880. return object.namespace.name + ":" + object.name.name;
  6881. }
  6882. if (object.type === "JSXMemberExpression") {
  6883. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  6884. }
  6885. throw new Error("Node had unexpected type: " + object.type);
  6886. }
  6887. var jsx = superClass => class JSXParserMixin extends superClass {
  6888. jsxReadToken() {
  6889. let out = "";
  6890. let chunkStart = this.state.pos;
  6891. for (;;) {
  6892. if (this.state.pos >= this.length) {
  6893. throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc);
  6894. }
  6895. const ch = this.input.charCodeAt(this.state.pos);
  6896. switch (ch) {
  6897. case 60:
  6898. case 123:
  6899. if (this.state.pos === this.state.start) {
  6900. if (ch === 60 && this.state.canStartJSXElement) {
  6901. ++this.state.pos;
  6902. this.finishToken(143);
  6903. } else {
  6904. super.getTokenFromCode(ch);
  6905. }
  6906. return;
  6907. }
  6908. out += this.input.slice(chunkStart, this.state.pos);
  6909. this.finishToken(142, out);
  6910. return;
  6911. case 38:
  6912. out += this.input.slice(chunkStart, this.state.pos);
  6913. out += this.jsxReadEntity();
  6914. chunkStart = this.state.pos;
  6915. break;
  6916. case 62:
  6917. case 125:
  6918. default:
  6919. if (isNewLine(ch)) {
  6920. out += this.input.slice(chunkStart, this.state.pos);
  6921. out += this.jsxReadNewLine(true);
  6922. chunkStart = this.state.pos;
  6923. } else {
  6924. ++this.state.pos;
  6925. }
  6926. }
  6927. }
  6928. }
  6929. jsxReadNewLine(normalizeCRLF) {
  6930. const ch = this.input.charCodeAt(this.state.pos);
  6931. let out;
  6932. ++this.state.pos;
  6933. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  6934. ++this.state.pos;
  6935. out = normalizeCRLF ? "\n" : "\r\n";
  6936. } else {
  6937. out = String.fromCharCode(ch);
  6938. }
  6939. ++this.state.curLine;
  6940. this.state.lineStart = this.state.pos;
  6941. return out;
  6942. }
  6943. jsxReadString(quote) {
  6944. let out = "";
  6945. let chunkStart = ++this.state.pos;
  6946. for (;;) {
  6947. if (this.state.pos >= this.length) {
  6948. throw this.raise(Errors.UnterminatedString, this.state.startLoc);
  6949. }
  6950. const ch = this.input.charCodeAt(this.state.pos);
  6951. if (ch === quote) break;
  6952. if (ch === 38) {
  6953. out += this.input.slice(chunkStart, this.state.pos);
  6954. out += this.jsxReadEntity();
  6955. chunkStart = this.state.pos;
  6956. } else if (isNewLine(ch)) {
  6957. out += this.input.slice(chunkStart, this.state.pos);
  6958. out += this.jsxReadNewLine(false);
  6959. chunkStart = this.state.pos;
  6960. } else {
  6961. ++this.state.pos;
  6962. }
  6963. }
  6964. out += this.input.slice(chunkStart, this.state.pos++);
  6965. this.finishToken(134, out);
  6966. }
  6967. jsxReadEntity() {
  6968. const startPos = ++this.state.pos;
  6969. if (this.codePointAtPos(this.state.pos) === 35) {
  6970. ++this.state.pos;
  6971. let radix = 10;
  6972. if (this.codePointAtPos(this.state.pos) === 120) {
  6973. radix = 16;
  6974. ++this.state.pos;
  6975. }
  6976. const codePoint = this.readInt(radix, undefined, false, "bail");
  6977. if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
  6978. ++this.state.pos;
  6979. return String.fromCodePoint(codePoint);
  6980. }
  6981. } else {
  6982. let count = 0;
  6983. let semi = false;
  6984. while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) === 59)) {
  6985. ++this.state.pos;
  6986. }
  6987. if (semi) {
  6988. const desc = this.input.slice(startPos, this.state.pos);
  6989. const entity = entities[desc];
  6990. ++this.state.pos;
  6991. if (entity) {
  6992. return entity;
  6993. }
  6994. }
  6995. }
  6996. this.state.pos = startPos;
  6997. return "&";
  6998. }
  6999. jsxReadWord() {
  7000. let ch;
  7001. const start = this.state.pos;
  7002. do {
  7003. ch = this.input.charCodeAt(++this.state.pos);
  7004. } while (isIdentifierChar(ch) || ch === 45);
  7005. this.finishToken(141, this.input.slice(start, this.state.pos));
  7006. }
  7007. jsxParseIdentifier() {
  7008. const node = this.startNode();
  7009. if (this.match(141)) {
  7010. node.name = this.state.value;
  7011. } else if (tokenIsKeyword(this.state.type)) {
  7012. node.name = tokenLabelName(this.state.type);
  7013. } else {
  7014. this.unexpected();
  7015. }
  7016. this.next();
  7017. return this.finishNode(node, "JSXIdentifier");
  7018. }
  7019. jsxParseNamespacedName() {
  7020. const startLoc = this.state.startLoc;
  7021. const name = this.jsxParseIdentifier();
  7022. if (!this.eat(14)) return name;
  7023. const node = this.startNodeAt(startLoc);
  7024. node.namespace = name;
  7025. node.name = this.jsxParseIdentifier();
  7026. return this.finishNode(node, "JSXNamespacedName");
  7027. }
  7028. jsxParseElementName() {
  7029. const startLoc = this.state.startLoc;
  7030. let node = this.jsxParseNamespacedName();
  7031. if (node.type === "JSXNamespacedName") {
  7032. return node;
  7033. }
  7034. while (this.eat(16)) {
  7035. const newNode = this.startNodeAt(startLoc);
  7036. newNode.object = node;
  7037. newNode.property = this.jsxParseIdentifier();
  7038. node = this.finishNode(newNode, "JSXMemberExpression");
  7039. }
  7040. return node;
  7041. }
  7042. jsxParseAttributeValue() {
  7043. let node;
  7044. switch (this.state.type) {
  7045. case 5:
  7046. node = this.startNode();
  7047. this.setContext(types.brace);
  7048. this.next();
  7049. node = this.jsxParseExpressionContainer(node, types.j_oTag);
  7050. if (node.expression.type === "JSXEmptyExpression") {
  7051. this.raise(JsxErrors.AttributeIsEmpty, node);
  7052. }
  7053. return node;
  7054. case 143:
  7055. case 134:
  7056. return this.parseExprAtom();
  7057. default:
  7058. throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
  7059. }
  7060. }
  7061. jsxParseEmptyExpression() {
  7062. const node = this.startNodeAt(this.state.lastTokEndLoc);
  7063. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
  7064. }
  7065. jsxParseSpreadChild(node) {
  7066. this.next();
  7067. node.expression = this.parseExpression();
  7068. this.setContext(types.j_expr);
  7069. this.state.canStartJSXElement = true;
  7070. this.expect(8);
  7071. return this.finishNode(node, "JSXSpreadChild");
  7072. }
  7073. jsxParseExpressionContainer(node, previousContext) {
  7074. if (this.match(8)) {
  7075. node.expression = this.jsxParseEmptyExpression();
  7076. } else {
  7077. const expression = this.parseExpression();
  7078. node.expression = expression;
  7079. }
  7080. this.setContext(previousContext);
  7081. this.state.canStartJSXElement = true;
  7082. this.expect(8);
  7083. return this.finishNode(node, "JSXExpressionContainer");
  7084. }
  7085. jsxParseAttribute() {
  7086. const node = this.startNode();
  7087. if (this.match(5)) {
  7088. this.setContext(types.brace);
  7089. this.next();
  7090. this.expect(21);
  7091. node.argument = this.parseMaybeAssignAllowIn();
  7092. this.setContext(types.j_oTag);
  7093. this.state.canStartJSXElement = true;
  7094. this.expect(8);
  7095. return this.finishNode(node, "JSXSpreadAttribute");
  7096. }
  7097. node.name = this.jsxParseNamespacedName();
  7098. node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
  7099. return this.finishNode(node, "JSXAttribute");
  7100. }
  7101. jsxParseOpeningElementAt(startLoc) {
  7102. const node = this.startNodeAt(startLoc);
  7103. if (this.eat(144)) {
  7104. return this.finishNode(node, "JSXOpeningFragment");
  7105. }
  7106. node.name = this.jsxParseElementName();
  7107. return this.jsxParseOpeningElementAfterName(node);
  7108. }
  7109. jsxParseOpeningElementAfterName(node) {
  7110. const attributes = [];
  7111. while (!this.match(56) && !this.match(144)) {
  7112. attributes.push(this.jsxParseAttribute());
  7113. }
  7114. node.attributes = attributes;
  7115. node.selfClosing = this.eat(56);
  7116. this.expect(144);
  7117. return this.finishNode(node, "JSXOpeningElement");
  7118. }
  7119. jsxParseClosingElementAt(startLoc) {
  7120. const node = this.startNodeAt(startLoc);
  7121. if (this.eat(144)) {
  7122. return this.finishNode(node, "JSXClosingFragment");
  7123. }
  7124. node.name = this.jsxParseElementName();
  7125. this.expect(144);
  7126. return this.finishNode(node, "JSXClosingElement");
  7127. }
  7128. jsxParseElementAt(startLoc) {
  7129. const node = this.startNodeAt(startLoc);
  7130. const children = [];
  7131. const openingElement = this.jsxParseOpeningElementAt(startLoc);
  7132. let closingElement = null;
  7133. if (!openingElement.selfClosing) {
  7134. contents: for (;;) {
  7135. switch (this.state.type) {
  7136. case 143:
  7137. startLoc = this.state.startLoc;
  7138. this.next();
  7139. if (this.eat(56)) {
  7140. closingElement = this.jsxParseClosingElementAt(startLoc);
  7141. break contents;
  7142. }
  7143. children.push(this.jsxParseElementAt(startLoc));
  7144. break;
  7145. case 142:
  7146. children.push(this.parseLiteral(this.state.value, "JSXText"));
  7147. break;
  7148. case 5:
  7149. {
  7150. const node = this.startNode();
  7151. this.setContext(types.brace);
  7152. this.next();
  7153. if (this.match(21)) {
  7154. children.push(this.jsxParseSpreadChild(node));
  7155. } else {
  7156. children.push(this.jsxParseExpressionContainer(node, types.j_expr));
  7157. }
  7158. break;
  7159. }
  7160. default:
  7161. this.unexpected();
  7162. }
  7163. }
  7164. if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
  7165. this.raise(JsxErrors.MissingClosingTagFragment, closingElement);
  7166. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  7167. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  7168. openingTagName: getQualifiedJSXName(openingElement.name)
  7169. });
  7170. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  7171. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  7172. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  7173. openingTagName: getQualifiedJSXName(openingElement.name)
  7174. });
  7175. }
  7176. }
  7177. }
  7178. if (isFragment(openingElement)) {
  7179. node.openingFragment = openingElement;
  7180. node.closingFragment = closingElement;
  7181. } else {
  7182. node.openingElement = openingElement;
  7183. node.closingElement = closingElement;
  7184. }
  7185. node.children = children;
  7186. if (this.match(47)) {
  7187. throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc);
  7188. }
  7189. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  7190. }
  7191. jsxParseElement() {
  7192. const startLoc = this.state.startLoc;
  7193. this.next();
  7194. return this.jsxParseElementAt(startLoc);
  7195. }
  7196. setContext(newContext) {
  7197. const {
  7198. context
  7199. } = this.state;
  7200. context[context.length - 1] = newContext;
  7201. }
  7202. parseExprAtom(refExpressionErrors) {
  7203. if (this.match(143)) {
  7204. return this.jsxParseElement();
  7205. } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
  7206. this.replaceToken(143);
  7207. return this.jsxParseElement();
  7208. } else {
  7209. return super.parseExprAtom(refExpressionErrors);
  7210. }
  7211. }
  7212. skipSpace() {
  7213. const curContext = this.curContext();
  7214. if (!curContext.preserveSpace) super.skipSpace();
  7215. }
  7216. getTokenFromCode(code) {
  7217. const context = this.curContext();
  7218. if (context === types.j_expr) {
  7219. this.jsxReadToken();
  7220. return;
  7221. }
  7222. if (context === types.j_oTag || context === types.j_cTag) {
  7223. if (isIdentifierStart(code)) {
  7224. this.jsxReadWord();
  7225. return;
  7226. }
  7227. if (code === 62) {
  7228. ++this.state.pos;
  7229. this.finishToken(144);
  7230. return;
  7231. }
  7232. if ((code === 34 || code === 39) && context === types.j_oTag) {
  7233. this.jsxReadString(code);
  7234. return;
  7235. }
  7236. }
  7237. if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  7238. ++this.state.pos;
  7239. this.finishToken(143);
  7240. return;
  7241. }
  7242. super.getTokenFromCode(code);
  7243. }
  7244. updateContext(prevType) {
  7245. const {
  7246. context,
  7247. type
  7248. } = this.state;
  7249. if (type === 56 && prevType === 143) {
  7250. context.splice(-2, 2, types.j_cTag);
  7251. this.state.canStartJSXElement = false;
  7252. } else if (type === 143) {
  7253. context.push(types.j_oTag);
  7254. } else if (type === 144) {
  7255. const out = context[context.length - 1];
  7256. if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) {
  7257. context.pop();
  7258. this.state.canStartJSXElement = context[context.length - 1] === types.j_expr;
  7259. } else {
  7260. this.setContext(types.j_expr);
  7261. this.state.canStartJSXElement = true;
  7262. }
  7263. } else {
  7264. this.state.canStartJSXElement = tokenComesBeforeExpression(type);
  7265. }
  7266. }
  7267. };
  7268. class TypeScriptScope extends Scope {
  7269. constructor(...args) {
  7270. super(...args);
  7271. this.tsNames = new Map();
  7272. }
  7273. }
  7274. class TypeScriptScopeHandler extends ScopeHandler {
  7275. constructor(...args) {
  7276. super(...args);
  7277. this.importsStack = [];
  7278. }
  7279. createScope(flags) {
  7280. this.importsStack.push(new Set());
  7281. return new TypeScriptScope(flags);
  7282. }
  7283. enter(flags) {
  7284. if (flags === 1024) {
  7285. this.importsStack.push(new Set());
  7286. }
  7287. super.enter(flags);
  7288. }
  7289. exit() {
  7290. const flags = super.exit();
  7291. if (flags === 1024) {
  7292. this.importsStack.pop();
  7293. }
  7294. return flags;
  7295. }
  7296. hasImport(name, allowShadow) {
  7297. const len = this.importsStack.length;
  7298. if (this.importsStack[len - 1].has(name)) {
  7299. return true;
  7300. }
  7301. if (!allowShadow && len > 1) {
  7302. for (let i = 0; i < len - 1; i++) {
  7303. if (this.importsStack[i].has(name)) return true;
  7304. }
  7305. }
  7306. return false;
  7307. }
  7308. declareName(name, bindingType, loc) {
  7309. if (bindingType & 4096) {
  7310. if (this.hasImport(name, true)) {
  7311. this.parser.raise(Errors.VarRedeclaration, loc, {
  7312. identifierName: name
  7313. });
  7314. }
  7315. this.importsStack[this.importsStack.length - 1].add(name);
  7316. return;
  7317. }
  7318. const scope = this.currentScope();
  7319. let type = scope.tsNames.get(name) || 0;
  7320. if (bindingType & 1024) {
  7321. this.maybeExportDefined(scope, name);
  7322. scope.tsNames.set(name, type | 16);
  7323. return;
  7324. }
  7325. super.declareName(name, bindingType, loc);
  7326. if (bindingType & 2) {
  7327. if (!(bindingType & 1)) {
  7328. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  7329. this.maybeExportDefined(scope, name);
  7330. }
  7331. type = type | 1;
  7332. }
  7333. if (bindingType & 256) {
  7334. type = type | 2;
  7335. }
  7336. if (bindingType & 512) {
  7337. type = type | 4;
  7338. }
  7339. if (bindingType & 128) {
  7340. type = type | 8;
  7341. }
  7342. if (type) scope.tsNames.set(name, type);
  7343. }
  7344. isRedeclaredInScope(scope, name, bindingType) {
  7345. const type = scope.tsNames.get(name);
  7346. if ((type & 2) > 0) {
  7347. if (bindingType & 256) {
  7348. const isConst = !!(bindingType & 512);
  7349. const wasConst = (type & 4) > 0;
  7350. return isConst !== wasConst;
  7351. }
  7352. return true;
  7353. }
  7354. if (bindingType & 128 && (type & 8) > 0) {
  7355. if (scope.names.get(name) & 2) {
  7356. return !!(bindingType & 1);
  7357. } else {
  7358. return false;
  7359. }
  7360. }
  7361. if (bindingType & 2 && (type & 1) > 0) {
  7362. return true;
  7363. }
  7364. return super.isRedeclaredInScope(scope, name, bindingType);
  7365. }
  7366. checkLocalExport(id) {
  7367. const {
  7368. name
  7369. } = id;
  7370. if (this.hasImport(name)) return;
  7371. const len = this.scopeStack.length;
  7372. for (let i = len - 1; i >= 0; i--) {
  7373. const scope = this.scopeStack[i];
  7374. const type = scope.tsNames.get(name);
  7375. if ((type & 1) > 0 || (type & 16) > 0) {
  7376. return;
  7377. }
  7378. }
  7379. super.checkLocalExport(id);
  7380. }
  7381. }
  7382. class ProductionParameterHandler {
  7383. constructor() {
  7384. this.stacks = [];
  7385. }
  7386. enter(flags) {
  7387. this.stacks.push(flags);
  7388. }
  7389. exit() {
  7390. this.stacks.pop();
  7391. }
  7392. currentFlags() {
  7393. return this.stacks[this.stacks.length - 1];
  7394. }
  7395. get hasAwait() {
  7396. return (this.currentFlags() & 2) > 0;
  7397. }
  7398. get hasYield() {
  7399. return (this.currentFlags() & 1) > 0;
  7400. }
  7401. get hasReturn() {
  7402. return (this.currentFlags() & 4) > 0;
  7403. }
  7404. get hasIn() {
  7405. return (this.currentFlags() & 8) > 0;
  7406. }
  7407. }
  7408. function functionFlags(isAsync, isGenerator) {
  7409. return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
  7410. }
  7411. class BaseParser {
  7412. constructor() {
  7413. this.sawUnambiguousESM = false;
  7414. this.ambiguousScriptDifferentAst = false;
  7415. }
  7416. sourceToOffsetPos(sourcePos) {
  7417. return sourcePos + this.startIndex;
  7418. }
  7419. offsetToSourcePos(offsetPos) {
  7420. return offsetPos - this.startIndex;
  7421. }
  7422. hasPlugin(pluginConfig) {
  7423. if (typeof pluginConfig === "string") {
  7424. return this.plugins.has(pluginConfig);
  7425. } else {
  7426. const [pluginName, pluginOptions] = pluginConfig;
  7427. if (!this.hasPlugin(pluginName)) {
  7428. return false;
  7429. }
  7430. const actualOptions = this.plugins.get(pluginName);
  7431. for (const key of Object.keys(pluginOptions)) {
  7432. if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) {
  7433. return false;
  7434. }
  7435. }
  7436. return true;
  7437. }
  7438. }
  7439. getPluginOption(plugin, name) {
  7440. var _this$plugins$get;
  7441. return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name];
  7442. }
  7443. }
  7444. function setTrailingComments(node, comments) {
  7445. if (node.trailingComments === undefined) {
  7446. node.trailingComments = comments;
  7447. } else {
  7448. node.trailingComments.unshift(...comments);
  7449. }
  7450. }
  7451. function setLeadingComments(node, comments) {
  7452. if (node.leadingComments === undefined) {
  7453. node.leadingComments = comments;
  7454. } else {
  7455. node.leadingComments.unshift(...comments);
  7456. }
  7457. }
  7458. function setInnerComments(node, comments) {
  7459. if (node.innerComments === undefined) {
  7460. node.innerComments = comments;
  7461. } else {
  7462. node.innerComments.unshift(...comments);
  7463. }
  7464. }
  7465. function adjustInnerComments(node, elements, commentWS) {
  7466. let lastElement = null;
  7467. let i = elements.length;
  7468. while (lastElement === null && i > 0) {
  7469. lastElement = elements[--i];
  7470. }
  7471. if (lastElement === null || lastElement.start > commentWS.start) {
  7472. setInnerComments(node, commentWS.comments);
  7473. } else {
  7474. setTrailingComments(lastElement, commentWS.comments);
  7475. }
  7476. }
  7477. class CommentsParser extends BaseParser {
  7478. addComment(comment) {
  7479. if (this.filename) comment.loc.filename = this.filename;
  7480. const {
  7481. commentsLen
  7482. } = this.state;
  7483. if (this.comments.length !== commentsLen) {
  7484. this.comments.length = commentsLen;
  7485. }
  7486. this.comments.push(comment);
  7487. this.state.commentsLen++;
  7488. }
  7489. processComment(node) {
  7490. const {
  7491. commentStack
  7492. } = this.state;
  7493. const commentStackLength = commentStack.length;
  7494. if (commentStackLength === 0) return;
  7495. let i = commentStackLength - 1;
  7496. const lastCommentWS = commentStack[i];
  7497. if (lastCommentWS.start === node.end) {
  7498. lastCommentWS.leadingNode = node;
  7499. i--;
  7500. }
  7501. const {
  7502. start: nodeStart
  7503. } = node;
  7504. for (; i >= 0; i--) {
  7505. const commentWS = commentStack[i];
  7506. const commentEnd = commentWS.end;
  7507. if (commentEnd > nodeStart) {
  7508. commentWS.containingNode = node;
  7509. this.finalizeComment(commentWS);
  7510. commentStack.splice(i, 1);
  7511. } else {
  7512. if (commentEnd === nodeStart) {
  7513. commentWS.trailingNode = node;
  7514. }
  7515. break;
  7516. }
  7517. }
  7518. }
  7519. finalizeComment(commentWS) {
  7520. var _node$options;
  7521. const {
  7522. comments
  7523. } = commentWS;
  7524. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  7525. if (commentWS.leadingNode !== null) {
  7526. setTrailingComments(commentWS.leadingNode, comments);
  7527. }
  7528. if (commentWS.trailingNode !== null) {
  7529. setLeadingComments(commentWS.trailingNode, comments);
  7530. }
  7531. } else {
  7532. const {
  7533. containingNode: node,
  7534. start: commentStart
  7535. } = commentWS;
  7536. if (this.input.charCodeAt(this.offsetToSourcePos(commentStart) - 1) === 44) {
  7537. switch (node.type) {
  7538. case "ObjectExpression":
  7539. case "ObjectPattern":
  7540. case "RecordExpression":
  7541. adjustInnerComments(node, node.properties, commentWS);
  7542. break;
  7543. case "CallExpression":
  7544. case "OptionalCallExpression":
  7545. adjustInnerComments(node, node.arguments, commentWS);
  7546. break;
  7547. case "ImportExpression":
  7548. adjustInnerComments(node, [node.source, (_node$options = node.options) != null ? _node$options : null], commentWS);
  7549. break;
  7550. case "FunctionDeclaration":
  7551. case "FunctionExpression":
  7552. case "ArrowFunctionExpression":
  7553. case "ObjectMethod":
  7554. case "ClassMethod":
  7555. case "ClassPrivateMethod":
  7556. adjustInnerComments(node, node.params, commentWS);
  7557. break;
  7558. case "ArrayExpression":
  7559. case "ArrayPattern":
  7560. case "TupleExpression":
  7561. adjustInnerComments(node, node.elements, commentWS);
  7562. break;
  7563. case "ExportNamedDeclaration":
  7564. case "ImportDeclaration":
  7565. adjustInnerComments(node, node.specifiers, commentWS);
  7566. break;
  7567. case "TSEnumDeclaration":
  7568. {
  7569. adjustInnerComments(node, node.members, commentWS);
  7570. }
  7571. break;
  7572. case "TSEnumBody":
  7573. adjustInnerComments(node, node.members, commentWS);
  7574. break;
  7575. default:
  7576. {
  7577. setInnerComments(node, comments);
  7578. }
  7579. }
  7580. } else {
  7581. setInnerComments(node, comments);
  7582. }
  7583. }
  7584. }
  7585. finalizeRemainingComments() {
  7586. const {
  7587. commentStack
  7588. } = this.state;
  7589. for (let i = commentStack.length - 1; i >= 0; i--) {
  7590. this.finalizeComment(commentStack[i]);
  7591. }
  7592. this.state.commentStack = [];
  7593. }
  7594. resetPreviousNodeTrailingComments(node) {
  7595. const {
  7596. commentStack
  7597. } = this.state;
  7598. const {
  7599. length
  7600. } = commentStack;
  7601. if (length === 0) return;
  7602. const commentWS = commentStack[length - 1];
  7603. if (commentWS.leadingNode === node) {
  7604. commentWS.leadingNode = null;
  7605. }
  7606. }
  7607. takeSurroundingComments(node, start, end) {
  7608. const {
  7609. commentStack
  7610. } = this.state;
  7611. const commentStackLength = commentStack.length;
  7612. if (commentStackLength === 0) return;
  7613. let i = commentStackLength - 1;
  7614. for (; i >= 0; i--) {
  7615. const commentWS = commentStack[i];
  7616. const commentEnd = commentWS.end;
  7617. const commentStart = commentWS.start;
  7618. if (commentStart === end) {
  7619. commentWS.leadingNode = node;
  7620. } else if (commentEnd === start) {
  7621. commentWS.trailingNode = node;
  7622. } else if (commentEnd < start) {
  7623. break;
  7624. }
  7625. }
  7626. }
  7627. }
  7628. class State {
  7629. constructor() {
  7630. this.flags = 1024;
  7631. this.startIndex = void 0;
  7632. this.curLine = void 0;
  7633. this.lineStart = void 0;
  7634. this.startLoc = void 0;
  7635. this.endLoc = void 0;
  7636. this.errors = [];
  7637. this.potentialArrowAt = -1;
  7638. this.noArrowAt = [];
  7639. this.noArrowParamsConversionAt = [];
  7640. this.topicContext = {
  7641. maxNumOfResolvableTopics: 0,
  7642. maxTopicIndex: null
  7643. };
  7644. this.labels = [];
  7645. this.commentsLen = 0;
  7646. this.commentStack = [];
  7647. this.pos = 0;
  7648. this.type = 140;
  7649. this.value = null;
  7650. this.start = 0;
  7651. this.end = 0;
  7652. this.lastTokEndLoc = null;
  7653. this.lastTokStartLoc = null;
  7654. this.context = [types.brace];
  7655. this.firstInvalidTemplateEscapePos = null;
  7656. this.strictErrors = new Map();
  7657. this.tokensLength = 0;
  7658. }
  7659. get strict() {
  7660. return (this.flags & 1) > 0;
  7661. }
  7662. set strict(v) {
  7663. if (v) this.flags |= 1;else this.flags &= -2;
  7664. }
  7665. init({
  7666. strictMode,
  7667. sourceType,
  7668. startIndex,
  7669. startLine,
  7670. startColumn
  7671. }) {
  7672. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  7673. this.startIndex = startIndex;
  7674. this.curLine = startLine;
  7675. this.lineStart = -startColumn;
  7676. this.startLoc = this.endLoc = new Position(startLine, startColumn, startIndex);
  7677. }
  7678. get maybeInArrowParameters() {
  7679. return (this.flags & 2) > 0;
  7680. }
  7681. set maybeInArrowParameters(v) {
  7682. if (v) this.flags |= 2;else this.flags &= -3;
  7683. }
  7684. get inType() {
  7685. return (this.flags & 4) > 0;
  7686. }
  7687. set inType(v) {
  7688. if (v) this.flags |= 4;else this.flags &= -5;
  7689. }
  7690. get noAnonFunctionType() {
  7691. return (this.flags & 8) > 0;
  7692. }
  7693. set noAnonFunctionType(v) {
  7694. if (v) this.flags |= 8;else this.flags &= -9;
  7695. }
  7696. get hasFlowComment() {
  7697. return (this.flags & 16) > 0;
  7698. }
  7699. set hasFlowComment(v) {
  7700. if (v) this.flags |= 16;else this.flags &= -17;
  7701. }
  7702. get isAmbientContext() {
  7703. return (this.flags & 32) > 0;
  7704. }
  7705. set isAmbientContext(v) {
  7706. if (v) this.flags |= 32;else this.flags &= -33;
  7707. }
  7708. get inAbstractClass() {
  7709. return (this.flags & 64) > 0;
  7710. }
  7711. set inAbstractClass(v) {
  7712. if (v) this.flags |= 64;else this.flags &= -65;
  7713. }
  7714. get inDisallowConditionalTypesContext() {
  7715. return (this.flags & 128) > 0;
  7716. }
  7717. set inDisallowConditionalTypesContext(v) {
  7718. if (v) this.flags |= 128;else this.flags &= -129;
  7719. }
  7720. get soloAwait() {
  7721. return (this.flags & 256) > 0;
  7722. }
  7723. set soloAwait(v) {
  7724. if (v) this.flags |= 256;else this.flags &= -257;
  7725. }
  7726. get inFSharpPipelineDirectBody() {
  7727. return (this.flags & 512) > 0;
  7728. }
  7729. set inFSharpPipelineDirectBody(v) {
  7730. if (v) this.flags |= 512;else this.flags &= -513;
  7731. }
  7732. get canStartJSXElement() {
  7733. return (this.flags & 1024) > 0;
  7734. }
  7735. set canStartJSXElement(v) {
  7736. if (v) this.flags |= 1024;else this.flags &= -1025;
  7737. }
  7738. get containsEsc() {
  7739. return (this.flags & 2048) > 0;
  7740. }
  7741. set containsEsc(v) {
  7742. if (v) this.flags |= 2048;else this.flags &= -2049;
  7743. }
  7744. get hasTopLevelAwait() {
  7745. return (this.flags & 4096) > 0;
  7746. }
  7747. set hasTopLevelAwait(v) {
  7748. if (v) this.flags |= 4096;else this.flags &= -4097;
  7749. }
  7750. curPosition() {
  7751. return new Position(this.curLine, this.pos - this.lineStart, this.pos + this.startIndex);
  7752. }
  7753. clone() {
  7754. const state = new State();
  7755. state.flags = this.flags;
  7756. state.startIndex = this.startIndex;
  7757. state.curLine = this.curLine;
  7758. state.lineStart = this.lineStart;
  7759. state.startLoc = this.startLoc;
  7760. state.endLoc = this.endLoc;
  7761. state.errors = this.errors.slice();
  7762. state.potentialArrowAt = this.potentialArrowAt;
  7763. state.noArrowAt = this.noArrowAt.slice();
  7764. state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
  7765. state.topicContext = this.topicContext;
  7766. state.labels = this.labels.slice();
  7767. state.commentsLen = this.commentsLen;
  7768. state.commentStack = this.commentStack.slice();
  7769. state.pos = this.pos;
  7770. state.type = this.type;
  7771. state.value = this.value;
  7772. state.start = this.start;
  7773. state.end = this.end;
  7774. state.lastTokEndLoc = this.lastTokEndLoc;
  7775. state.lastTokStartLoc = this.lastTokStartLoc;
  7776. state.context = this.context.slice();
  7777. state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos;
  7778. state.strictErrors = this.strictErrors;
  7779. state.tokensLength = this.tokensLength;
  7780. return state;
  7781. }
  7782. }
  7783. var _isDigit = function isDigit(code) {
  7784. return code >= 48 && code <= 57;
  7785. };
  7786. const forbiddenNumericSeparatorSiblings = {
  7787. decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
  7788. hex: new Set([46, 88, 95, 120])
  7789. };
  7790. const isAllowedNumericSeparatorSibling = {
  7791. bin: ch => ch === 48 || ch === 49,
  7792. oct: ch => ch >= 48 && ch <= 55,
  7793. dec: ch => ch >= 48 && ch <= 57,
  7794. hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
  7795. };
  7796. function readStringContents(type, input, pos, lineStart, curLine, errors) {
  7797. const initialPos = pos;
  7798. const initialLineStart = lineStart;
  7799. const initialCurLine = curLine;
  7800. let out = "";
  7801. let firstInvalidLoc = null;
  7802. let chunkStart = pos;
  7803. const {
  7804. length
  7805. } = input;
  7806. for (;;) {
  7807. if (pos >= length) {
  7808. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  7809. out += input.slice(chunkStart, pos);
  7810. break;
  7811. }
  7812. const ch = input.charCodeAt(pos);
  7813. if (isStringEnd(type, ch, input, pos)) {
  7814. out += input.slice(chunkStart, pos);
  7815. break;
  7816. }
  7817. if (ch === 92) {
  7818. out += input.slice(chunkStart, pos);
  7819. const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
  7820. if (res.ch === null && !firstInvalidLoc) {
  7821. firstInvalidLoc = {
  7822. pos,
  7823. lineStart,
  7824. curLine
  7825. };
  7826. } else {
  7827. out += res.ch;
  7828. }
  7829. ({
  7830. pos,
  7831. lineStart,
  7832. curLine
  7833. } = res);
  7834. chunkStart = pos;
  7835. } else if (ch === 8232 || ch === 8233) {
  7836. ++pos;
  7837. ++curLine;
  7838. lineStart = pos;
  7839. } else if (ch === 10 || ch === 13) {
  7840. if (type === "template") {
  7841. out += input.slice(chunkStart, pos) + "\n";
  7842. ++pos;
  7843. if (ch === 13 && input.charCodeAt(pos) === 10) {
  7844. ++pos;
  7845. }
  7846. ++curLine;
  7847. chunkStart = lineStart = pos;
  7848. } else {
  7849. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  7850. }
  7851. } else {
  7852. ++pos;
  7853. }
  7854. }
  7855. return {
  7856. pos,
  7857. str: out,
  7858. firstInvalidLoc,
  7859. lineStart,
  7860. curLine,
  7861. containsInvalid: !!firstInvalidLoc
  7862. };
  7863. }
  7864. function isStringEnd(type, ch, input, pos) {
  7865. if (type === "template") {
  7866. return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
  7867. }
  7868. return ch === (type === "double" ? 34 : 39);
  7869. }
  7870. function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
  7871. const throwOnInvalid = !inTemplate;
  7872. pos++;
  7873. const res = ch => ({
  7874. pos,
  7875. ch,
  7876. lineStart,
  7877. curLine
  7878. });
  7879. const ch = input.charCodeAt(pos++);
  7880. switch (ch) {
  7881. case 110:
  7882. return res("\n");
  7883. case 114:
  7884. return res("\r");
  7885. case 120:
  7886. {
  7887. let code;
  7888. ({
  7889. code,
  7890. pos
  7891. } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
  7892. return res(code === null ? null : String.fromCharCode(code));
  7893. }
  7894. case 117:
  7895. {
  7896. let code;
  7897. ({
  7898. code,
  7899. pos
  7900. } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
  7901. return res(code === null ? null : String.fromCodePoint(code));
  7902. }
  7903. case 116:
  7904. return res("\t");
  7905. case 98:
  7906. return res("\b");
  7907. case 118:
  7908. return res("\u000b");
  7909. case 102:
  7910. return res("\f");
  7911. case 13:
  7912. if (input.charCodeAt(pos) === 10) {
  7913. ++pos;
  7914. }
  7915. case 10:
  7916. lineStart = pos;
  7917. ++curLine;
  7918. case 8232:
  7919. case 8233:
  7920. return res("");
  7921. case 56:
  7922. case 57:
  7923. if (inTemplate) {
  7924. return res(null);
  7925. } else {
  7926. errors.strictNumericEscape(pos - 1, lineStart, curLine);
  7927. }
  7928. default:
  7929. if (ch >= 48 && ch <= 55) {
  7930. const startPos = pos - 1;
  7931. const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2));
  7932. let octalStr = match[0];
  7933. let octal = parseInt(octalStr, 8);
  7934. if (octal > 255) {
  7935. octalStr = octalStr.slice(0, -1);
  7936. octal = parseInt(octalStr, 8);
  7937. }
  7938. pos += octalStr.length - 1;
  7939. const next = input.charCodeAt(pos);
  7940. if (octalStr !== "0" || next === 56 || next === 57) {
  7941. if (inTemplate) {
  7942. return res(null);
  7943. } else {
  7944. errors.strictNumericEscape(startPos, lineStart, curLine);
  7945. }
  7946. }
  7947. return res(String.fromCharCode(octal));
  7948. }
  7949. return res(String.fromCharCode(ch));
  7950. }
  7951. }
  7952. function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
  7953. const initialPos = pos;
  7954. let n;
  7955. ({
  7956. n,
  7957. pos
  7958. } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
  7959. if (n === null) {
  7960. if (throwOnInvalid) {
  7961. errors.invalidEscapeSequence(initialPos, lineStart, curLine);
  7962. } else {
  7963. pos = initialPos - 1;
  7964. }
  7965. }
  7966. return {
  7967. code: n,
  7968. pos
  7969. };
  7970. }
  7971. function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
  7972. const start = pos;
  7973. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  7974. const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
  7975. let invalid = false;
  7976. let total = 0;
  7977. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  7978. const code = input.charCodeAt(pos);
  7979. let val;
  7980. if (code === 95 && allowNumSeparator !== "bail") {
  7981. const prev = input.charCodeAt(pos - 1);
  7982. const next = input.charCodeAt(pos + 1);
  7983. if (!allowNumSeparator) {
  7984. if (bailOnError) return {
  7985. n: null,
  7986. pos
  7987. };
  7988. errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
  7989. } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
  7990. if (bailOnError) return {
  7991. n: null,
  7992. pos
  7993. };
  7994. errors.unexpectedNumericSeparator(pos, lineStart, curLine);
  7995. }
  7996. ++pos;
  7997. continue;
  7998. }
  7999. if (code >= 97) {
  8000. val = code - 97 + 10;
  8001. } else if (code >= 65) {
  8002. val = code - 65 + 10;
  8003. } else if (_isDigit(code)) {
  8004. val = code - 48;
  8005. } else {
  8006. val = Infinity;
  8007. }
  8008. if (val >= radix) {
  8009. if (val <= 9 && bailOnError) {
  8010. return {
  8011. n: null,
  8012. pos
  8013. };
  8014. } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
  8015. val = 0;
  8016. } else if (forceLen) {
  8017. val = 0;
  8018. invalid = true;
  8019. } else {
  8020. break;
  8021. }
  8022. }
  8023. ++pos;
  8024. total = total * radix + val;
  8025. }
  8026. if (pos === start || len != null && pos - start !== len || invalid) {
  8027. return {
  8028. n: null,
  8029. pos
  8030. };
  8031. }
  8032. return {
  8033. n: total,
  8034. pos
  8035. };
  8036. }
  8037. function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
  8038. const ch = input.charCodeAt(pos);
  8039. let code;
  8040. if (ch === 123) {
  8041. ++pos;
  8042. ({
  8043. code,
  8044. pos
  8045. } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
  8046. ++pos;
  8047. if (code !== null && code > 0x10ffff) {
  8048. if (throwOnInvalid) {
  8049. errors.invalidCodePoint(pos, lineStart, curLine);
  8050. } else {
  8051. return {
  8052. code: null,
  8053. pos
  8054. };
  8055. }
  8056. }
  8057. } else {
  8058. ({
  8059. code,
  8060. pos
  8061. } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
  8062. }
  8063. return {
  8064. code,
  8065. pos
  8066. };
  8067. }
  8068. function buildPosition(pos, lineStart, curLine) {
  8069. return new Position(curLine, pos - lineStart, pos);
  8070. }
  8071. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
  8072. class Token {
  8073. constructor(state) {
  8074. const startIndex = state.startIndex || 0;
  8075. this.type = state.type;
  8076. this.value = state.value;
  8077. this.start = startIndex + state.start;
  8078. this.end = startIndex + state.end;
  8079. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  8080. }
  8081. }
  8082. class Tokenizer extends CommentsParser {
  8083. constructor(options, input) {
  8084. super();
  8085. this.isLookahead = void 0;
  8086. this.tokens = [];
  8087. this.errorHandlers_readInt = {
  8088. invalidDigit: (pos, lineStart, curLine, radix) => {
  8089. if (!(this.optionFlags & 2048)) return false;
  8090. this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
  8091. radix
  8092. });
  8093. return true;
  8094. },
  8095. numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
  8096. unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
  8097. };
  8098. this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, {
  8099. invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
  8100. invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
  8101. });
  8102. this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, {
  8103. strictNumericEscape: (pos, lineStart, curLine) => {
  8104. this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
  8105. },
  8106. unterminated: (pos, lineStart, curLine) => {
  8107. throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
  8108. }
  8109. });
  8110. this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, {
  8111. strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
  8112. unterminated: (pos, lineStart, curLine) => {
  8113. throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
  8114. }
  8115. });
  8116. this.state = new State();
  8117. this.state.init(options);
  8118. this.input = input;
  8119. this.length = input.length;
  8120. this.comments = [];
  8121. this.isLookahead = false;
  8122. }
  8123. pushToken(token) {
  8124. this.tokens.length = this.state.tokensLength;
  8125. this.tokens.push(token);
  8126. ++this.state.tokensLength;
  8127. }
  8128. next() {
  8129. this.checkKeywordEscapes();
  8130. if (this.optionFlags & 256) {
  8131. this.pushToken(new Token(this.state));
  8132. }
  8133. this.state.lastTokEndLoc = this.state.endLoc;
  8134. this.state.lastTokStartLoc = this.state.startLoc;
  8135. this.nextToken();
  8136. }
  8137. eat(type) {
  8138. if (this.match(type)) {
  8139. this.next();
  8140. return true;
  8141. } else {
  8142. return false;
  8143. }
  8144. }
  8145. match(type) {
  8146. return this.state.type === type;
  8147. }
  8148. createLookaheadState(state) {
  8149. return {
  8150. pos: state.pos,
  8151. value: null,
  8152. type: state.type,
  8153. start: state.start,
  8154. end: state.end,
  8155. context: [this.curContext()],
  8156. inType: state.inType,
  8157. startLoc: state.startLoc,
  8158. lastTokEndLoc: state.lastTokEndLoc,
  8159. curLine: state.curLine,
  8160. lineStart: state.lineStart,
  8161. curPosition: state.curPosition
  8162. };
  8163. }
  8164. lookahead() {
  8165. const old = this.state;
  8166. this.state = this.createLookaheadState(old);
  8167. this.isLookahead = true;
  8168. this.nextToken();
  8169. this.isLookahead = false;
  8170. const curr = this.state;
  8171. this.state = old;
  8172. return curr;
  8173. }
  8174. nextTokenStart() {
  8175. return this.nextTokenStartSince(this.state.pos);
  8176. }
  8177. nextTokenStartSince(pos) {
  8178. skipWhiteSpace.lastIndex = pos;
  8179. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  8180. }
  8181. lookaheadCharCode() {
  8182. return this.lookaheadCharCodeSince(this.state.pos);
  8183. }
  8184. lookaheadCharCodeSince(pos) {
  8185. return this.input.charCodeAt(this.nextTokenStartSince(pos));
  8186. }
  8187. nextTokenInLineStart() {
  8188. return this.nextTokenInLineStartSince(this.state.pos);
  8189. }
  8190. nextTokenInLineStartSince(pos) {
  8191. skipWhiteSpaceInLine.lastIndex = pos;
  8192. return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
  8193. }
  8194. lookaheadInLineCharCode() {
  8195. return this.input.charCodeAt(this.nextTokenInLineStart());
  8196. }
  8197. codePointAtPos(pos) {
  8198. let cp = this.input.charCodeAt(pos);
  8199. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  8200. const trail = this.input.charCodeAt(pos);
  8201. if ((trail & 0xfc00) === 0xdc00) {
  8202. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  8203. }
  8204. }
  8205. return cp;
  8206. }
  8207. setStrict(strict) {
  8208. this.state.strict = strict;
  8209. if (strict) {
  8210. this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
  8211. this.state.strictErrors.clear();
  8212. }
  8213. }
  8214. curContext() {
  8215. return this.state.context[this.state.context.length - 1];
  8216. }
  8217. nextToken() {
  8218. this.skipSpace();
  8219. this.state.start = this.state.pos;
  8220. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  8221. if (this.state.pos >= this.length) {
  8222. this.finishToken(140);
  8223. return;
  8224. }
  8225. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  8226. }
  8227. skipBlockComment(commentEnd) {
  8228. let startLoc;
  8229. if (!this.isLookahead) startLoc = this.state.curPosition();
  8230. const start = this.state.pos;
  8231. const end = this.input.indexOf(commentEnd, start + 2);
  8232. if (end === -1) {
  8233. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  8234. }
  8235. this.state.pos = end + commentEnd.length;
  8236. lineBreakG.lastIndex = start + 2;
  8237. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  8238. ++this.state.curLine;
  8239. this.state.lineStart = lineBreakG.lastIndex;
  8240. }
  8241. if (this.isLookahead) return;
  8242. const comment = {
  8243. type: "CommentBlock",
  8244. value: this.input.slice(start + 2, end),
  8245. start: this.sourceToOffsetPos(start),
  8246. end: this.sourceToOffsetPos(end + commentEnd.length),
  8247. loc: new SourceLocation(startLoc, this.state.curPosition())
  8248. };
  8249. if (this.optionFlags & 256) this.pushToken(comment);
  8250. return comment;
  8251. }
  8252. skipLineComment(startSkip) {
  8253. const start = this.state.pos;
  8254. let startLoc;
  8255. if (!this.isLookahead) startLoc = this.state.curPosition();
  8256. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  8257. if (this.state.pos < this.length) {
  8258. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  8259. ch = this.input.charCodeAt(this.state.pos);
  8260. }
  8261. }
  8262. if (this.isLookahead) return;
  8263. const end = this.state.pos;
  8264. const value = this.input.slice(start + startSkip, end);
  8265. const comment = {
  8266. type: "CommentLine",
  8267. value,
  8268. start: this.sourceToOffsetPos(start),
  8269. end: this.sourceToOffsetPos(end),
  8270. loc: new SourceLocation(startLoc, this.state.curPosition())
  8271. };
  8272. if (this.optionFlags & 256) this.pushToken(comment);
  8273. return comment;
  8274. }
  8275. skipSpace() {
  8276. const spaceStart = this.state.pos;
  8277. const comments = this.optionFlags & 4096 ? [] : null;
  8278. loop: while (this.state.pos < this.length) {
  8279. const ch = this.input.charCodeAt(this.state.pos);
  8280. switch (ch) {
  8281. case 32:
  8282. case 160:
  8283. case 9:
  8284. ++this.state.pos;
  8285. break;
  8286. case 13:
  8287. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  8288. ++this.state.pos;
  8289. }
  8290. case 10:
  8291. case 8232:
  8292. case 8233:
  8293. ++this.state.pos;
  8294. ++this.state.curLine;
  8295. this.state.lineStart = this.state.pos;
  8296. break;
  8297. case 47:
  8298. switch (this.input.charCodeAt(this.state.pos + 1)) {
  8299. case 42:
  8300. {
  8301. const comment = this.skipBlockComment("*/");
  8302. if (comment !== undefined) {
  8303. this.addComment(comment);
  8304. comments == null || comments.push(comment);
  8305. }
  8306. break;
  8307. }
  8308. case 47:
  8309. {
  8310. const comment = this.skipLineComment(2);
  8311. if (comment !== undefined) {
  8312. this.addComment(comment);
  8313. comments == null || comments.push(comment);
  8314. }
  8315. break;
  8316. }
  8317. default:
  8318. break loop;
  8319. }
  8320. break;
  8321. default:
  8322. if (isWhitespace(ch)) {
  8323. ++this.state.pos;
  8324. } else if (ch === 45 && !this.inModule && this.optionFlags & 8192) {
  8325. const pos = this.state.pos;
  8326. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  8327. const comment = this.skipLineComment(3);
  8328. if (comment !== undefined) {
  8329. this.addComment(comment);
  8330. comments == null || comments.push(comment);
  8331. }
  8332. } else {
  8333. break loop;
  8334. }
  8335. } else if (ch === 60 && !this.inModule && this.optionFlags & 8192) {
  8336. const pos = this.state.pos;
  8337. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  8338. const comment = this.skipLineComment(4);
  8339. if (comment !== undefined) {
  8340. this.addComment(comment);
  8341. comments == null || comments.push(comment);
  8342. }
  8343. } else {
  8344. break loop;
  8345. }
  8346. } else {
  8347. break loop;
  8348. }
  8349. }
  8350. }
  8351. if ((comments == null ? void 0 : comments.length) > 0) {
  8352. const end = this.state.pos;
  8353. const commentWhitespace = {
  8354. start: this.sourceToOffsetPos(spaceStart),
  8355. end: this.sourceToOffsetPos(end),
  8356. comments,
  8357. leadingNode: null,
  8358. trailingNode: null,
  8359. containingNode: null
  8360. };
  8361. this.state.commentStack.push(commentWhitespace);
  8362. }
  8363. }
  8364. finishToken(type, val) {
  8365. this.state.end = this.state.pos;
  8366. this.state.endLoc = this.state.curPosition();
  8367. const prevType = this.state.type;
  8368. this.state.type = type;
  8369. this.state.value = val;
  8370. if (!this.isLookahead) {
  8371. this.updateContext(prevType);
  8372. }
  8373. }
  8374. replaceToken(type) {
  8375. this.state.type = type;
  8376. this.updateContext();
  8377. }
  8378. readToken_numberSign() {
  8379. if (this.state.pos === 0 && this.readToken_interpreter()) {
  8380. return;
  8381. }
  8382. const nextPos = this.state.pos + 1;
  8383. const next = this.codePointAtPos(nextPos);
  8384. if (next >= 48 && next <= 57) {
  8385. throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
  8386. }
  8387. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  8388. this.expectPlugin("recordAndTuple");
  8389. if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
  8390. throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
  8391. }
  8392. this.state.pos += 2;
  8393. if (next === 123) {
  8394. this.finishToken(7);
  8395. } else {
  8396. this.finishToken(1);
  8397. }
  8398. } else if (isIdentifierStart(next)) {
  8399. ++this.state.pos;
  8400. this.finishToken(139, this.readWord1(next));
  8401. } else if (next === 92) {
  8402. ++this.state.pos;
  8403. this.finishToken(139, this.readWord1());
  8404. } else {
  8405. this.finishOp(27, 1);
  8406. }
  8407. }
  8408. readToken_dot() {
  8409. const next = this.input.charCodeAt(this.state.pos + 1);
  8410. if (next >= 48 && next <= 57) {
  8411. this.readNumber(true);
  8412. return;
  8413. }
  8414. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  8415. this.state.pos += 3;
  8416. this.finishToken(21);
  8417. } else {
  8418. ++this.state.pos;
  8419. this.finishToken(16);
  8420. }
  8421. }
  8422. readToken_slash() {
  8423. const next = this.input.charCodeAt(this.state.pos + 1);
  8424. if (next === 61) {
  8425. this.finishOp(31, 2);
  8426. } else {
  8427. this.finishOp(56, 1);
  8428. }
  8429. }
  8430. readToken_interpreter() {
  8431. if (this.state.pos !== 0 || this.length < 2) return false;
  8432. let ch = this.input.charCodeAt(this.state.pos + 1);
  8433. if (ch !== 33) return false;
  8434. const start = this.state.pos;
  8435. this.state.pos += 1;
  8436. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  8437. ch = this.input.charCodeAt(this.state.pos);
  8438. }
  8439. const value = this.input.slice(start + 2, this.state.pos);
  8440. this.finishToken(28, value);
  8441. return true;
  8442. }
  8443. readToken_mult_modulo(code) {
  8444. let type = code === 42 ? 55 : 54;
  8445. let width = 1;
  8446. let next = this.input.charCodeAt(this.state.pos + 1);
  8447. if (code === 42 && next === 42) {
  8448. width++;
  8449. next = this.input.charCodeAt(this.state.pos + 2);
  8450. type = 57;
  8451. }
  8452. if (next === 61 && !this.state.inType) {
  8453. width++;
  8454. type = code === 37 ? 33 : 30;
  8455. }
  8456. this.finishOp(type, width);
  8457. }
  8458. readToken_pipe_amp(code) {
  8459. const next = this.input.charCodeAt(this.state.pos + 1);
  8460. if (next === code) {
  8461. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  8462. this.finishOp(30, 3);
  8463. } else {
  8464. this.finishOp(code === 124 ? 41 : 42, 2);
  8465. }
  8466. return;
  8467. }
  8468. if (code === 124) {
  8469. if (next === 62) {
  8470. this.finishOp(39, 2);
  8471. return;
  8472. }
  8473. if (this.hasPlugin("recordAndTuple") && next === 125) {
  8474. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  8475. throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  8476. }
  8477. this.state.pos += 2;
  8478. this.finishToken(9);
  8479. return;
  8480. }
  8481. if (this.hasPlugin("recordAndTuple") && next === 93) {
  8482. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  8483. throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  8484. }
  8485. this.state.pos += 2;
  8486. this.finishToken(4);
  8487. return;
  8488. }
  8489. }
  8490. if (next === 61) {
  8491. this.finishOp(30, 2);
  8492. return;
  8493. }
  8494. this.finishOp(code === 124 ? 43 : 45, 1);
  8495. }
  8496. readToken_caret() {
  8497. const next = this.input.charCodeAt(this.state.pos + 1);
  8498. if (next === 61 && !this.state.inType) {
  8499. this.finishOp(32, 2);
  8500. } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
  8501. proposal: "hack",
  8502. topicToken: "^^"
  8503. }])) {
  8504. this.finishOp(37, 2);
  8505. const lookaheadCh = this.input.codePointAt(this.state.pos);
  8506. if (lookaheadCh === 94) {
  8507. this.unexpected();
  8508. }
  8509. } else {
  8510. this.finishOp(44, 1);
  8511. }
  8512. }
  8513. readToken_atSign() {
  8514. const next = this.input.charCodeAt(this.state.pos + 1);
  8515. if (next === 64 && this.hasPlugin(["pipelineOperator", {
  8516. proposal: "hack",
  8517. topicToken: "@@"
  8518. }])) {
  8519. this.finishOp(38, 2);
  8520. } else {
  8521. this.finishOp(26, 1);
  8522. }
  8523. }
  8524. readToken_plus_min(code) {
  8525. const next = this.input.charCodeAt(this.state.pos + 1);
  8526. if (next === code) {
  8527. this.finishOp(34, 2);
  8528. return;
  8529. }
  8530. if (next === 61) {
  8531. this.finishOp(30, 2);
  8532. } else {
  8533. this.finishOp(53, 1);
  8534. }
  8535. }
  8536. readToken_lt() {
  8537. const {
  8538. pos
  8539. } = this.state;
  8540. const next = this.input.charCodeAt(pos + 1);
  8541. if (next === 60) {
  8542. if (this.input.charCodeAt(pos + 2) === 61) {
  8543. this.finishOp(30, 3);
  8544. return;
  8545. }
  8546. this.finishOp(51, 2);
  8547. return;
  8548. }
  8549. if (next === 61) {
  8550. this.finishOp(49, 2);
  8551. return;
  8552. }
  8553. this.finishOp(47, 1);
  8554. }
  8555. readToken_gt() {
  8556. const {
  8557. pos
  8558. } = this.state;
  8559. const next = this.input.charCodeAt(pos + 1);
  8560. if (next === 62) {
  8561. const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
  8562. if (this.input.charCodeAt(pos + size) === 61) {
  8563. this.finishOp(30, size + 1);
  8564. return;
  8565. }
  8566. this.finishOp(52, size);
  8567. return;
  8568. }
  8569. if (next === 61) {
  8570. this.finishOp(49, 2);
  8571. return;
  8572. }
  8573. this.finishOp(48, 1);
  8574. }
  8575. readToken_eq_excl(code) {
  8576. const next = this.input.charCodeAt(this.state.pos + 1);
  8577. if (next === 61) {
  8578. this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  8579. return;
  8580. }
  8581. if (code === 61 && next === 62) {
  8582. this.state.pos += 2;
  8583. this.finishToken(19);
  8584. return;
  8585. }
  8586. this.finishOp(code === 61 ? 29 : 35, 1);
  8587. }
  8588. readToken_question() {
  8589. const next = this.input.charCodeAt(this.state.pos + 1);
  8590. const next2 = this.input.charCodeAt(this.state.pos + 2);
  8591. if (next === 63) {
  8592. if (next2 === 61) {
  8593. this.finishOp(30, 3);
  8594. } else {
  8595. this.finishOp(40, 2);
  8596. }
  8597. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  8598. this.state.pos += 2;
  8599. this.finishToken(18);
  8600. } else {
  8601. ++this.state.pos;
  8602. this.finishToken(17);
  8603. }
  8604. }
  8605. getTokenFromCode(code) {
  8606. switch (code) {
  8607. case 46:
  8608. this.readToken_dot();
  8609. return;
  8610. case 40:
  8611. ++this.state.pos;
  8612. this.finishToken(10);
  8613. return;
  8614. case 41:
  8615. ++this.state.pos;
  8616. this.finishToken(11);
  8617. return;
  8618. case 59:
  8619. ++this.state.pos;
  8620. this.finishToken(13);
  8621. return;
  8622. case 44:
  8623. ++this.state.pos;
  8624. this.finishToken(12);
  8625. return;
  8626. case 91:
  8627. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  8628. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  8629. throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  8630. }
  8631. this.state.pos += 2;
  8632. this.finishToken(2);
  8633. } else {
  8634. ++this.state.pos;
  8635. this.finishToken(0);
  8636. }
  8637. return;
  8638. case 93:
  8639. ++this.state.pos;
  8640. this.finishToken(3);
  8641. return;
  8642. case 123:
  8643. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  8644. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  8645. throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  8646. }
  8647. this.state.pos += 2;
  8648. this.finishToken(6);
  8649. } else {
  8650. ++this.state.pos;
  8651. this.finishToken(5);
  8652. }
  8653. return;
  8654. case 125:
  8655. ++this.state.pos;
  8656. this.finishToken(8);
  8657. return;
  8658. case 58:
  8659. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  8660. this.finishOp(15, 2);
  8661. } else {
  8662. ++this.state.pos;
  8663. this.finishToken(14);
  8664. }
  8665. return;
  8666. case 63:
  8667. this.readToken_question();
  8668. return;
  8669. case 96:
  8670. this.readTemplateToken();
  8671. return;
  8672. case 48:
  8673. {
  8674. const next = this.input.charCodeAt(this.state.pos + 1);
  8675. if (next === 120 || next === 88) {
  8676. this.readRadixNumber(16);
  8677. return;
  8678. }
  8679. if (next === 111 || next === 79) {
  8680. this.readRadixNumber(8);
  8681. return;
  8682. }
  8683. if (next === 98 || next === 66) {
  8684. this.readRadixNumber(2);
  8685. return;
  8686. }
  8687. }
  8688. case 49:
  8689. case 50:
  8690. case 51:
  8691. case 52:
  8692. case 53:
  8693. case 54:
  8694. case 55:
  8695. case 56:
  8696. case 57:
  8697. this.readNumber(false);
  8698. return;
  8699. case 34:
  8700. case 39:
  8701. this.readString(code);
  8702. return;
  8703. case 47:
  8704. this.readToken_slash();
  8705. return;
  8706. case 37:
  8707. case 42:
  8708. this.readToken_mult_modulo(code);
  8709. return;
  8710. case 124:
  8711. case 38:
  8712. this.readToken_pipe_amp(code);
  8713. return;
  8714. case 94:
  8715. this.readToken_caret();
  8716. return;
  8717. case 43:
  8718. case 45:
  8719. this.readToken_plus_min(code);
  8720. return;
  8721. case 60:
  8722. this.readToken_lt();
  8723. return;
  8724. case 62:
  8725. this.readToken_gt();
  8726. return;
  8727. case 61:
  8728. case 33:
  8729. this.readToken_eq_excl(code);
  8730. return;
  8731. case 126:
  8732. this.finishOp(36, 1);
  8733. return;
  8734. case 64:
  8735. this.readToken_atSign();
  8736. return;
  8737. case 35:
  8738. this.readToken_numberSign();
  8739. return;
  8740. case 92:
  8741. this.readWord();
  8742. return;
  8743. default:
  8744. if (isIdentifierStart(code)) {
  8745. this.readWord(code);
  8746. return;
  8747. }
  8748. }
  8749. throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
  8750. unexpected: String.fromCodePoint(code)
  8751. });
  8752. }
  8753. finishOp(type, size) {
  8754. const str = this.input.slice(this.state.pos, this.state.pos + size);
  8755. this.state.pos += size;
  8756. this.finishToken(type, str);
  8757. }
  8758. readRegexp() {
  8759. const startLoc = this.state.startLoc;
  8760. const start = this.state.start + 1;
  8761. let escaped, inClass;
  8762. let {
  8763. pos
  8764. } = this.state;
  8765. for (;; ++pos) {
  8766. if (pos >= this.length) {
  8767. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  8768. }
  8769. const ch = this.input.charCodeAt(pos);
  8770. if (isNewLine(ch)) {
  8771. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  8772. }
  8773. if (escaped) {
  8774. escaped = false;
  8775. } else {
  8776. if (ch === 91) {
  8777. inClass = true;
  8778. } else if (ch === 93 && inClass) {
  8779. inClass = false;
  8780. } else if (ch === 47 && !inClass) {
  8781. break;
  8782. }
  8783. escaped = ch === 92;
  8784. }
  8785. }
  8786. const content = this.input.slice(start, pos);
  8787. ++pos;
  8788. let mods = "";
  8789. const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
  8790. while (pos < this.length) {
  8791. const cp = this.codePointAtPos(pos);
  8792. const char = String.fromCharCode(cp);
  8793. if (VALID_REGEX_FLAGS.has(cp)) {
  8794. if (cp === 118) {
  8795. if (mods.includes("u")) {
  8796. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  8797. }
  8798. } else if (cp === 117) {
  8799. if (mods.includes("v")) {
  8800. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  8801. }
  8802. }
  8803. if (mods.includes(char)) {
  8804. this.raise(Errors.DuplicateRegExpFlags, nextPos());
  8805. }
  8806. } else if (isIdentifierChar(cp) || cp === 92) {
  8807. this.raise(Errors.MalformedRegExpFlags, nextPos());
  8808. } else {
  8809. break;
  8810. }
  8811. ++pos;
  8812. mods += char;
  8813. }
  8814. this.state.pos = pos;
  8815. this.finishToken(138, {
  8816. pattern: content,
  8817. flags: mods
  8818. });
  8819. }
  8820. readInt(radix, len, forceLen = false, allowNumSeparator = true) {
  8821. const {
  8822. n,
  8823. pos
  8824. } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
  8825. this.state.pos = pos;
  8826. return n;
  8827. }
  8828. readRadixNumber(radix) {
  8829. const start = this.state.pos;
  8830. const startLoc = this.state.curPosition();
  8831. let isBigInt = false;
  8832. this.state.pos += 2;
  8833. const val = this.readInt(radix);
  8834. if (val == null) {
  8835. this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
  8836. radix
  8837. });
  8838. }
  8839. const next = this.input.charCodeAt(this.state.pos);
  8840. if (next === 110) {
  8841. ++this.state.pos;
  8842. isBigInt = true;
  8843. } else if (next === 109) {
  8844. throw this.raise(Errors.InvalidDecimal, startLoc);
  8845. }
  8846. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  8847. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  8848. }
  8849. if (isBigInt) {
  8850. const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
  8851. this.finishToken(136, str);
  8852. return;
  8853. }
  8854. this.finishToken(135, val);
  8855. }
  8856. readNumber(startsWithDot) {
  8857. const start = this.state.pos;
  8858. const startLoc = this.state.curPosition();
  8859. let isFloat = false;
  8860. let isBigInt = false;
  8861. let hasExponent = false;
  8862. let isOctal = false;
  8863. if (!startsWithDot && this.readInt(10) === null) {
  8864. this.raise(Errors.InvalidNumber, this.state.curPosition());
  8865. }
  8866. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  8867. if (hasLeadingZero) {
  8868. const integer = this.input.slice(start, this.state.pos);
  8869. this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
  8870. if (!this.state.strict) {
  8871. const underscorePos = integer.indexOf("_");
  8872. if (underscorePos > 0) {
  8873. this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
  8874. }
  8875. }
  8876. isOctal = hasLeadingZero && !/[89]/.test(integer);
  8877. }
  8878. let next = this.input.charCodeAt(this.state.pos);
  8879. if (next === 46 && !isOctal) {
  8880. ++this.state.pos;
  8881. this.readInt(10);
  8882. isFloat = true;
  8883. next = this.input.charCodeAt(this.state.pos);
  8884. }
  8885. if ((next === 69 || next === 101) && !isOctal) {
  8886. next = this.input.charCodeAt(++this.state.pos);
  8887. if (next === 43 || next === 45) {
  8888. ++this.state.pos;
  8889. }
  8890. if (this.readInt(10) === null) {
  8891. this.raise(Errors.InvalidOrMissingExponent, startLoc);
  8892. }
  8893. isFloat = true;
  8894. hasExponent = true;
  8895. next = this.input.charCodeAt(this.state.pos);
  8896. }
  8897. if (next === 110) {
  8898. if (isFloat || hasLeadingZero) {
  8899. this.raise(Errors.InvalidBigIntLiteral, startLoc);
  8900. }
  8901. ++this.state.pos;
  8902. isBigInt = true;
  8903. }
  8904. if (next === 109) {
  8905. this.expectPlugin("decimal", this.state.curPosition());
  8906. if (hasExponent || hasLeadingZero) {
  8907. this.raise(Errors.InvalidDecimal, startLoc);
  8908. }
  8909. ++this.state.pos;
  8910. var isDecimal = true;
  8911. }
  8912. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  8913. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  8914. }
  8915. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  8916. if (isBigInt) {
  8917. this.finishToken(136, str);
  8918. return;
  8919. }
  8920. if (isDecimal) {
  8921. this.finishToken(137, str);
  8922. return;
  8923. }
  8924. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  8925. this.finishToken(135, val);
  8926. }
  8927. readCodePoint(throwOnInvalid) {
  8928. const {
  8929. code,
  8930. pos
  8931. } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
  8932. this.state.pos = pos;
  8933. return code;
  8934. }
  8935. readString(quote) {
  8936. const {
  8937. str,
  8938. pos,
  8939. curLine,
  8940. lineStart
  8941. } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
  8942. this.state.pos = pos + 1;
  8943. this.state.lineStart = lineStart;
  8944. this.state.curLine = curLine;
  8945. this.finishToken(134, str);
  8946. }
  8947. readTemplateContinuation() {
  8948. if (!this.match(8)) {
  8949. this.unexpected(null, 8);
  8950. }
  8951. this.state.pos--;
  8952. this.readTemplateToken();
  8953. }
  8954. readTemplateToken() {
  8955. const opening = this.input[this.state.pos];
  8956. const {
  8957. str,
  8958. firstInvalidLoc,
  8959. pos,
  8960. curLine,
  8961. lineStart
  8962. } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
  8963. this.state.pos = pos + 1;
  8964. this.state.lineStart = lineStart;
  8965. this.state.curLine = curLine;
  8966. if (firstInvalidLoc) {
  8967. this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, this.sourceToOffsetPos(firstInvalidLoc.pos));
  8968. }
  8969. if (this.input.codePointAt(pos) === 96) {
  8970. this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
  8971. } else {
  8972. this.state.pos++;
  8973. this.finishToken(25, firstInvalidLoc ? null : opening + str + "${");
  8974. }
  8975. }
  8976. recordStrictModeErrors(toParseError, at) {
  8977. const index = at.index;
  8978. if (this.state.strict && !this.state.strictErrors.has(index)) {
  8979. this.raise(toParseError, at);
  8980. } else {
  8981. this.state.strictErrors.set(index, [toParseError, at]);
  8982. }
  8983. }
  8984. readWord1(firstCode) {
  8985. this.state.containsEsc = false;
  8986. let word = "";
  8987. const start = this.state.pos;
  8988. let chunkStart = this.state.pos;
  8989. if (firstCode !== undefined) {
  8990. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  8991. }
  8992. while (this.state.pos < this.length) {
  8993. const ch = this.codePointAtPos(this.state.pos);
  8994. if (isIdentifierChar(ch)) {
  8995. this.state.pos += ch <= 0xffff ? 1 : 2;
  8996. } else if (ch === 92) {
  8997. this.state.containsEsc = true;
  8998. word += this.input.slice(chunkStart, this.state.pos);
  8999. const escStart = this.state.curPosition();
  9000. const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
  9001. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  9002. this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
  9003. chunkStart = this.state.pos - 1;
  9004. continue;
  9005. }
  9006. ++this.state.pos;
  9007. const esc = this.readCodePoint(true);
  9008. if (esc !== null) {
  9009. if (!identifierCheck(esc)) {
  9010. this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
  9011. }
  9012. word += String.fromCodePoint(esc);
  9013. }
  9014. chunkStart = this.state.pos;
  9015. } else {
  9016. break;
  9017. }
  9018. }
  9019. return word + this.input.slice(chunkStart, this.state.pos);
  9020. }
  9021. readWord(firstCode) {
  9022. const word = this.readWord1(firstCode);
  9023. const type = keywords$1.get(word);
  9024. if (type !== undefined) {
  9025. this.finishToken(type, tokenLabelName(type));
  9026. } else {
  9027. this.finishToken(132, word);
  9028. }
  9029. }
  9030. checkKeywordEscapes() {
  9031. const {
  9032. type
  9033. } = this.state;
  9034. if (tokenIsKeyword(type) && this.state.containsEsc) {
  9035. this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
  9036. reservedWord: tokenLabelName(type)
  9037. });
  9038. }
  9039. }
  9040. raise(toParseError, at, details = {}) {
  9041. const loc = at instanceof Position ? at : at.loc.start;
  9042. const error = toParseError(loc, details);
  9043. if (!(this.optionFlags & 2048)) throw error;
  9044. if (!this.isLookahead) this.state.errors.push(error);
  9045. return error;
  9046. }
  9047. raiseOverwrite(toParseError, at, details = {}) {
  9048. const loc = at instanceof Position ? at : at.loc.start;
  9049. const pos = loc.index;
  9050. const errors = this.state.errors;
  9051. for (let i = errors.length - 1; i >= 0; i--) {
  9052. const error = errors[i];
  9053. if (error.loc.index === pos) {
  9054. return errors[i] = toParseError(loc, details);
  9055. }
  9056. if (error.loc.index < pos) break;
  9057. }
  9058. return this.raise(toParseError, at, details);
  9059. }
  9060. updateContext(prevType) {}
  9061. unexpected(loc, type) {
  9062. throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
  9063. expected: type ? tokenLabelName(type) : null
  9064. });
  9065. }
  9066. expectPlugin(pluginName, loc) {
  9067. if (this.hasPlugin(pluginName)) {
  9068. return true;
  9069. }
  9070. throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
  9071. missingPlugin: [pluginName]
  9072. });
  9073. }
  9074. expectOnePlugin(pluginNames) {
  9075. if (!pluginNames.some(name => this.hasPlugin(name))) {
  9076. throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
  9077. missingPlugin: pluginNames
  9078. });
  9079. }
  9080. }
  9081. errorBuilder(error) {
  9082. return (pos, lineStart, curLine) => {
  9083. this.raise(error, buildPosition(pos, lineStart, curLine));
  9084. };
  9085. }
  9086. }
  9087. class ClassScope {
  9088. constructor() {
  9089. this.privateNames = new Set();
  9090. this.loneAccessors = new Map();
  9091. this.undefinedPrivateNames = new Map();
  9092. }
  9093. }
  9094. class ClassScopeHandler {
  9095. constructor(parser) {
  9096. this.parser = void 0;
  9097. this.stack = [];
  9098. this.undefinedPrivateNames = new Map();
  9099. this.parser = parser;
  9100. }
  9101. current() {
  9102. return this.stack[this.stack.length - 1];
  9103. }
  9104. enter() {
  9105. this.stack.push(new ClassScope());
  9106. }
  9107. exit() {
  9108. const oldClassScope = this.stack.pop();
  9109. const current = this.current();
  9110. for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
  9111. if (current) {
  9112. if (!current.undefinedPrivateNames.has(name)) {
  9113. current.undefinedPrivateNames.set(name, loc);
  9114. }
  9115. } else {
  9116. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  9117. identifierName: name
  9118. });
  9119. }
  9120. }
  9121. }
  9122. declarePrivateName(name, elementType, loc) {
  9123. const {
  9124. privateNames,
  9125. loneAccessors,
  9126. undefinedPrivateNames
  9127. } = this.current();
  9128. let redefined = privateNames.has(name);
  9129. if (elementType & 3) {
  9130. const accessor = redefined && loneAccessors.get(name);
  9131. if (accessor) {
  9132. const oldStatic = accessor & 4;
  9133. const newStatic = elementType & 4;
  9134. const oldKind = accessor & 3;
  9135. const newKind = elementType & 3;
  9136. redefined = oldKind === newKind || oldStatic !== newStatic;
  9137. if (!redefined) loneAccessors.delete(name);
  9138. } else if (!redefined) {
  9139. loneAccessors.set(name, elementType);
  9140. }
  9141. }
  9142. if (redefined) {
  9143. this.parser.raise(Errors.PrivateNameRedeclaration, loc, {
  9144. identifierName: name
  9145. });
  9146. }
  9147. privateNames.add(name);
  9148. undefinedPrivateNames.delete(name);
  9149. }
  9150. usePrivateName(name, loc) {
  9151. let classScope;
  9152. for (classScope of this.stack) {
  9153. if (classScope.privateNames.has(name)) return;
  9154. }
  9155. if (classScope) {
  9156. classScope.undefinedPrivateNames.set(name, loc);
  9157. } else {
  9158. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  9159. identifierName: name
  9160. });
  9161. }
  9162. }
  9163. }
  9164. class ExpressionScope {
  9165. constructor(type = 0) {
  9166. this.type = type;
  9167. }
  9168. canBeArrowParameterDeclaration() {
  9169. return this.type === 2 || this.type === 1;
  9170. }
  9171. isCertainlyParameterDeclaration() {
  9172. return this.type === 3;
  9173. }
  9174. }
  9175. class ArrowHeadParsingScope extends ExpressionScope {
  9176. constructor(type) {
  9177. super(type);
  9178. this.declarationErrors = new Map();
  9179. }
  9180. recordDeclarationError(ParsingErrorClass, at) {
  9181. const index = at.index;
  9182. this.declarationErrors.set(index, [ParsingErrorClass, at]);
  9183. }
  9184. clearDeclarationError(index) {
  9185. this.declarationErrors.delete(index);
  9186. }
  9187. iterateErrors(iterator) {
  9188. this.declarationErrors.forEach(iterator);
  9189. }
  9190. }
  9191. class ExpressionScopeHandler {
  9192. constructor(parser) {
  9193. this.parser = void 0;
  9194. this.stack = [new ExpressionScope()];
  9195. this.parser = parser;
  9196. }
  9197. enter(scope) {
  9198. this.stack.push(scope);
  9199. }
  9200. exit() {
  9201. this.stack.pop();
  9202. }
  9203. recordParameterInitializerError(toParseError, node) {
  9204. const origin = node.loc.start;
  9205. const {
  9206. stack
  9207. } = this;
  9208. let i = stack.length - 1;
  9209. let scope = stack[i];
  9210. while (!scope.isCertainlyParameterDeclaration()) {
  9211. if (scope.canBeArrowParameterDeclaration()) {
  9212. scope.recordDeclarationError(toParseError, origin);
  9213. } else {
  9214. return;
  9215. }
  9216. scope = stack[--i];
  9217. }
  9218. this.parser.raise(toParseError, origin);
  9219. }
  9220. recordArrowParameterBindingError(error, node) {
  9221. const {
  9222. stack
  9223. } = this;
  9224. const scope = stack[stack.length - 1];
  9225. const origin = node.loc.start;
  9226. if (scope.isCertainlyParameterDeclaration()) {
  9227. this.parser.raise(error, origin);
  9228. } else if (scope.canBeArrowParameterDeclaration()) {
  9229. scope.recordDeclarationError(error, origin);
  9230. } else {
  9231. return;
  9232. }
  9233. }
  9234. recordAsyncArrowParametersError(at) {
  9235. const {
  9236. stack
  9237. } = this;
  9238. let i = stack.length - 1;
  9239. let scope = stack[i];
  9240. while (scope.canBeArrowParameterDeclaration()) {
  9241. if (scope.type === 2) {
  9242. scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
  9243. }
  9244. scope = stack[--i];
  9245. }
  9246. }
  9247. validateAsPattern() {
  9248. const {
  9249. stack
  9250. } = this;
  9251. const currentScope = stack[stack.length - 1];
  9252. if (!currentScope.canBeArrowParameterDeclaration()) return;
  9253. currentScope.iterateErrors(([toParseError, loc]) => {
  9254. this.parser.raise(toParseError, loc);
  9255. let i = stack.length - 2;
  9256. let scope = stack[i];
  9257. while (scope.canBeArrowParameterDeclaration()) {
  9258. scope.clearDeclarationError(loc.index);
  9259. scope = stack[--i];
  9260. }
  9261. });
  9262. }
  9263. }
  9264. function newParameterDeclarationScope() {
  9265. return new ExpressionScope(3);
  9266. }
  9267. function newArrowHeadScope() {
  9268. return new ArrowHeadParsingScope(1);
  9269. }
  9270. function newAsyncArrowScope() {
  9271. return new ArrowHeadParsingScope(2);
  9272. }
  9273. function newExpressionScope() {
  9274. return new ExpressionScope();
  9275. }
  9276. class UtilParser extends Tokenizer {
  9277. addExtra(node, key, value, enumerable = true) {
  9278. if (!node) return;
  9279. let {
  9280. extra
  9281. } = node;
  9282. if (extra == null) {
  9283. extra = {};
  9284. node.extra = extra;
  9285. }
  9286. if (enumerable) {
  9287. extra[key] = value;
  9288. } else {
  9289. Object.defineProperty(extra, key, {
  9290. enumerable,
  9291. value
  9292. });
  9293. }
  9294. }
  9295. isContextual(token) {
  9296. return this.state.type === token && !this.state.containsEsc;
  9297. }
  9298. isUnparsedContextual(nameStart, name) {
  9299. if (this.input.startsWith(name, nameStart)) {
  9300. const nextCh = this.input.charCodeAt(nameStart + name.length);
  9301. return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
  9302. }
  9303. return false;
  9304. }
  9305. isLookaheadContextual(name) {
  9306. const next = this.nextTokenStart();
  9307. return this.isUnparsedContextual(next, name);
  9308. }
  9309. eatContextual(token) {
  9310. if (this.isContextual(token)) {
  9311. this.next();
  9312. return true;
  9313. }
  9314. return false;
  9315. }
  9316. expectContextual(token, toParseError) {
  9317. if (!this.eatContextual(token)) {
  9318. if (toParseError != null) {
  9319. throw this.raise(toParseError, this.state.startLoc);
  9320. }
  9321. this.unexpected(null, token);
  9322. }
  9323. }
  9324. canInsertSemicolon() {
  9325. return this.match(140) || this.match(8) || this.hasPrecedingLineBreak();
  9326. }
  9327. hasPrecedingLineBreak() {
  9328. return hasNewLine(this.input, this.offsetToSourcePos(this.state.lastTokEndLoc.index), this.state.start);
  9329. }
  9330. hasFollowingLineBreak() {
  9331. return hasNewLine(this.input, this.state.end, this.nextTokenStart());
  9332. }
  9333. isLineTerminator() {
  9334. return this.eat(13) || this.canInsertSemicolon();
  9335. }
  9336. semicolon(allowAsi = true) {
  9337. if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
  9338. this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc);
  9339. }
  9340. expect(type, loc) {
  9341. if (!this.eat(type)) {
  9342. this.unexpected(loc, type);
  9343. }
  9344. }
  9345. tryParse(fn, oldState = this.state.clone()) {
  9346. const abortSignal = {
  9347. node: null
  9348. };
  9349. try {
  9350. const node = fn((node = null) => {
  9351. abortSignal.node = node;
  9352. throw abortSignal;
  9353. });
  9354. if (this.state.errors.length > oldState.errors.length) {
  9355. const failState = this.state;
  9356. this.state = oldState;
  9357. this.state.tokensLength = failState.tokensLength;
  9358. return {
  9359. node,
  9360. error: failState.errors[oldState.errors.length],
  9361. thrown: false,
  9362. aborted: false,
  9363. failState
  9364. };
  9365. }
  9366. return {
  9367. node,
  9368. error: null,
  9369. thrown: false,
  9370. aborted: false,
  9371. failState: null
  9372. };
  9373. } catch (error) {
  9374. const failState = this.state;
  9375. this.state = oldState;
  9376. if (error instanceof SyntaxError) {
  9377. return {
  9378. node: null,
  9379. error,
  9380. thrown: true,
  9381. aborted: false,
  9382. failState
  9383. };
  9384. }
  9385. if (error === abortSignal) {
  9386. return {
  9387. node: abortSignal.node,
  9388. error: null,
  9389. thrown: false,
  9390. aborted: true,
  9391. failState
  9392. };
  9393. }
  9394. throw error;
  9395. }
  9396. }
  9397. checkExpressionErrors(refExpressionErrors, andThrow) {
  9398. if (!refExpressionErrors) return false;
  9399. const {
  9400. shorthandAssignLoc,
  9401. doubleProtoLoc,
  9402. privateKeyLoc,
  9403. optionalParametersLoc,
  9404. voidPatternLoc
  9405. } = refExpressionErrors;
  9406. const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc || !!voidPatternLoc;
  9407. if (!andThrow) {
  9408. return hasErrors;
  9409. }
  9410. if (shorthandAssignLoc != null) {
  9411. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  9412. }
  9413. if (doubleProtoLoc != null) {
  9414. this.raise(Errors.DuplicateProto, doubleProtoLoc);
  9415. }
  9416. if (privateKeyLoc != null) {
  9417. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  9418. }
  9419. if (optionalParametersLoc != null) {
  9420. this.unexpected(optionalParametersLoc);
  9421. }
  9422. if (voidPatternLoc != null) {
  9423. this.raise(Errors.InvalidCoverDiscardElement, voidPatternLoc);
  9424. }
  9425. }
  9426. isLiteralPropertyName() {
  9427. return tokenIsLiteralPropertyName(this.state.type);
  9428. }
  9429. isPrivateName(node) {
  9430. return node.type === "PrivateName";
  9431. }
  9432. getPrivateNameSV(node) {
  9433. return node.id.name;
  9434. }
  9435. hasPropertyAsPrivateName(node) {
  9436. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  9437. }
  9438. isObjectProperty(node) {
  9439. return node.type === "ObjectProperty";
  9440. }
  9441. isObjectMethod(node) {
  9442. return node.type === "ObjectMethod";
  9443. }
  9444. initializeScopes(inModule = this.options.sourceType === "module") {
  9445. const oldLabels = this.state.labels;
  9446. this.state.labels = [];
  9447. const oldExportedIdentifiers = this.exportedIdentifiers;
  9448. this.exportedIdentifiers = new Set();
  9449. const oldInModule = this.inModule;
  9450. this.inModule = inModule;
  9451. const oldScope = this.scope;
  9452. const ScopeHandler = this.getScopeHandler();
  9453. this.scope = new ScopeHandler(this, inModule);
  9454. const oldProdParam = this.prodParam;
  9455. this.prodParam = new ProductionParameterHandler();
  9456. const oldClassScope = this.classScope;
  9457. this.classScope = new ClassScopeHandler(this);
  9458. const oldExpressionScope = this.expressionScope;
  9459. this.expressionScope = new ExpressionScopeHandler(this);
  9460. return () => {
  9461. this.state.labels = oldLabels;
  9462. this.exportedIdentifiers = oldExportedIdentifiers;
  9463. this.inModule = oldInModule;
  9464. this.scope = oldScope;
  9465. this.prodParam = oldProdParam;
  9466. this.classScope = oldClassScope;
  9467. this.expressionScope = oldExpressionScope;
  9468. };
  9469. }
  9470. enterInitialScopes() {
  9471. let paramFlags = 0;
  9472. if (this.inModule || this.optionFlags & 1) {
  9473. paramFlags |= 2;
  9474. }
  9475. if (this.optionFlags & 32) {
  9476. paramFlags |= 1;
  9477. }
  9478. const isCommonJS = !this.inModule && this.options.sourceType === "commonjs";
  9479. if (isCommonJS || this.optionFlags & 2) {
  9480. paramFlags |= 4;
  9481. }
  9482. this.prodParam.enter(paramFlags);
  9483. let scopeFlags = isCommonJS ? 514 : 1;
  9484. if (this.optionFlags & 4) {
  9485. scopeFlags |= 512;
  9486. }
  9487. this.scope.enter(scopeFlags);
  9488. }
  9489. checkDestructuringPrivate(refExpressionErrors) {
  9490. const {
  9491. privateKeyLoc
  9492. } = refExpressionErrors;
  9493. if (privateKeyLoc !== null) {
  9494. this.expectPlugin("destructuringPrivate", privateKeyLoc);
  9495. }
  9496. }
  9497. }
  9498. class ExpressionErrors {
  9499. constructor() {
  9500. this.shorthandAssignLoc = null;
  9501. this.doubleProtoLoc = null;
  9502. this.privateKeyLoc = null;
  9503. this.optionalParametersLoc = null;
  9504. this.voidPatternLoc = null;
  9505. }
  9506. }
  9507. class Node {
  9508. constructor(parser, pos, loc) {
  9509. this.type = "";
  9510. this.start = pos;
  9511. this.end = 0;
  9512. this.loc = new SourceLocation(loc);
  9513. if ((parser == null ? void 0 : parser.optionFlags) & 128) this.range = [pos, 0];
  9514. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  9515. }
  9516. }
  9517. const NodePrototype = Node.prototype;
  9518. {
  9519. NodePrototype.__clone = function () {
  9520. const newNode = new Node(undefined, this.start, this.loc.start);
  9521. const keys = Object.keys(this);
  9522. for (let i = 0, length = keys.length; i < length; i++) {
  9523. const key = keys[i];
  9524. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  9525. newNode[key] = this[key];
  9526. }
  9527. }
  9528. return newNode;
  9529. };
  9530. }
  9531. class NodeUtils extends UtilParser {
  9532. startNode() {
  9533. const loc = this.state.startLoc;
  9534. return new Node(this, loc.index, loc);
  9535. }
  9536. startNodeAt(loc) {
  9537. return new Node(this, loc.index, loc);
  9538. }
  9539. startNodeAtNode(type) {
  9540. return this.startNodeAt(type.loc.start);
  9541. }
  9542. finishNode(node, type) {
  9543. return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
  9544. }
  9545. finishNodeAt(node, type, endLoc) {
  9546. node.type = type;
  9547. node.end = endLoc.index;
  9548. node.loc.end = endLoc;
  9549. if (this.optionFlags & 128) node.range[1] = endLoc.index;
  9550. if (this.optionFlags & 4096) {
  9551. this.processComment(node);
  9552. }
  9553. return node;
  9554. }
  9555. resetStartLocation(node, startLoc) {
  9556. node.start = startLoc.index;
  9557. node.loc.start = startLoc;
  9558. if (this.optionFlags & 128) node.range[0] = startLoc.index;
  9559. }
  9560. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  9561. node.end = endLoc.index;
  9562. node.loc.end = endLoc;
  9563. if (this.optionFlags & 128) node.range[1] = endLoc.index;
  9564. }
  9565. resetStartLocationFromNode(node, locationNode) {
  9566. this.resetStartLocation(node, locationNode.loc.start);
  9567. }
  9568. castNodeTo(node, type) {
  9569. node.type = type;
  9570. return node;
  9571. }
  9572. cloneIdentifier(node) {
  9573. const {
  9574. type,
  9575. start,
  9576. end,
  9577. loc,
  9578. range,
  9579. name
  9580. } = node;
  9581. const cloned = Object.create(NodePrototype);
  9582. cloned.type = type;
  9583. cloned.start = start;
  9584. cloned.end = end;
  9585. cloned.loc = loc;
  9586. cloned.range = range;
  9587. cloned.name = name;
  9588. if (node.extra) cloned.extra = node.extra;
  9589. return cloned;
  9590. }
  9591. cloneStringLiteral(node) {
  9592. const {
  9593. type,
  9594. start,
  9595. end,
  9596. loc,
  9597. range,
  9598. extra
  9599. } = node;
  9600. const cloned = Object.create(NodePrototype);
  9601. cloned.type = type;
  9602. cloned.start = start;
  9603. cloned.end = end;
  9604. cloned.loc = loc;
  9605. cloned.range = range;
  9606. cloned.extra = extra;
  9607. cloned.value = node.value;
  9608. return cloned;
  9609. }
  9610. }
  9611. const unwrapParenthesizedExpression = node => {
  9612. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  9613. };
  9614. class LValParser extends NodeUtils {
  9615. toAssignable(node, isLHS = false) {
  9616. var _node$extra, _node$extra3;
  9617. let parenthesized = undefined;
  9618. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  9619. parenthesized = unwrapParenthesizedExpression(node);
  9620. if (isLHS) {
  9621. if (parenthesized.type === "Identifier") {
  9622. this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
  9623. } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
  9624. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9625. }
  9626. } else {
  9627. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9628. }
  9629. }
  9630. switch (node.type) {
  9631. case "Identifier":
  9632. case "ObjectPattern":
  9633. case "ArrayPattern":
  9634. case "AssignmentPattern":
  9635. case "RestElement":
  9636. case "VoidPattern":
  9637. break;
  9638. case "ObjectExpression":
  9639. this.castNodeTo(node, "ObjectPattern");
  9640. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  9641. var _node$extra2;
  9642. const prop = node.properties[i];
  9643. const isLast = i === last;
  9644. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  9645. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
  9646. this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
  9647. }
  9648. }
  9649. break;
  9650. case "ObjectProperty":
  9651. {
  9652. const {
  9653. key,
  9654. value
  9655. } = node;
  9656. if (this.isPrivateName(key)) {
  9657. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  9658. }
  9659. this.toAssignable(value, isLHS);
  9660. break;
  9661. }
  9662. case "SpreadElement":
  9663. {
  9664. throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
  9665. }
  9666. case "ArrayExpression":
  9667. this.castNodeTo(node, "ArrayPattern");
  9668. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
  9669. break;
  9670. case "AssignmentExpression":
  9671. if (node.operator !== "=") {
  9672. this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
  9673. }
  9674. this.castNodeTo(node, "AssignmentPattern");
  9675. delete node.operator;
  9676. if (node.left.type === "VoidPattern") {
  9677. this.raise(Errors.VoidPatternInitializer, node.left);
  9678. }
  9679. this.toAssignable(node.left, isLHS);
  9680. break;
  9681. case "ParenthesizedExpression":
  9682. this.toAssignable(parenthesized, isLHS);
  9683. break;
  9684. }
  9685. }
  9686. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  9687. if (prop.type === "ObjectMethod") {
  9688. this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
  9689. } else if (prop.type === "SpreadElement") {
  9690. this.castNodeTo(prop, "RestElement");
  9691. const arg = prop.argument;
  9692. this.checkToRestConversion(arg, false);
  9693. this.toAssignable(arg, isLHS);
  9694. if (!isLast) {
  9695. this.raise(Errors.RestTrailingComma, prop);
  9696. }
  9697. } else {
  9698. this.toAssignable(prop, isLHS);
  9699. }
  9700. }
  9701. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  9702. const end = exprList.length - 1;
  9703. for (let i = 0; i <= end; i++) {
  9704. const elt = exprList[i];
  9705. if (!elt) continue;
  9706. this.toAssignableListItem(exprList, i, isLHS);
  9707. if (elt.type === "RestElement") {
  9708. if (i < end) {
  9709. this.raise(Errors.RestTrailingComma, elt);
  9710. } else if (trailingCommaLoc) {
  9711. this.raise(Errors.RestTrailingComma, trailingCommaLoc);
  9712. }
  9713. }
  9714. }
  9715. }
  9716. toAssignableListItem(exprList, index, isLHS) {
  9717. const node = exprList[index];
  9718. if (node.type === "SpreadElement") {
  9719. this.castNodeTo(node, "RestElement");
  9720. const arg = node.argument;
  9721. this.checkToRestConversion(arg, true);
  9722. this.toAssignable(arg, isLHS);
  9723. } else {
  9724. this.toAssignable(node, isLHS);
  9725. }
  9726. }
  9727. isAssignable(node, isBinding) {
  9728. switch (node.type) {
  9729. case "Identifier":
  9730. case "ObjectPattern":
  9731. case "ArrayPattern":
  9732. case "AssignmentPattern":
  9733. case "RestElement":
  9734. case "VoidPattern":
  9735. return true;
  9736. case "ObjectExpression":
  9737. {
  9738. const last = node.properties.length - 1;
  9739. return node.properties.every((prop, i) => {
  9740. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  9741. });
  9742. }
  9743. case "ObjectProperty":
  9744. return this.isAssignable(node.value);
  9745. case "SpreadElement":
  9746. return this.isAssignable(node.argument);
  9747. case "ArrayExpression":
  9748. return node.elements.every(element => element === null || this.isAssignable(element));
  9749. case "AssignmentExpression":
  9750. return node.operator === "=";
  9751. case "ParenthesizedExpression":
  9752. return this.isAssignable(node.expression);
  9753. case "MemberExpression":
  9754. case "OptionalMemberExpression":
  9755. return !isBinding;
  9756. default:
  9757. return false;
  9758. }
  9759. }
  9760. toReferencedList(exprList, isParenthesizedExpr) {
  9761. return exprList;
  9762. }
  9763. toReferencedListDeep(exprList, isParenthesizedExpr) {
  9764. this.toReferencedList(exprList, isParenthesizedExpr);
  9765. for (const expr of exprList) {
  9766. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  9767. this.toReferencedListDeep(expr.elements);
  9768. }
  9769. }
  9770. }
  9771. parseSpread(refExpressionErrors) {
  9772. const node = this.startNode();
  9773. this.next();
  9774. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined);
  9775. return this.finishNode(node, "SpreadElement");
  9776. }
  9777. parseRestBinding() {
  9778. const node = this.startNode();
  9779. this.next();
  9780. const argument = this.parseBindingAtom();
  9781. if (argument.type === "VoidPattern") {
  9782. this.raise(Errors.UnexpectedVoidPattern, argument);
  9783. }
  9784. node.argument = argument;
  9785. return this.finishNode(node, "RestElement");
  9786. }
  9787. parseBindingAtom() {
  9788. switch (this.state.type) {
  9789. case 0:
  9790. {
  9791. const node = this.startNode();
  9792. this.next();
  9793. node.elements = this.parseBindingList(3, 93, 1);
  9794. return this.finishNode(node, "ArrayPattern");
  9795. }
  9796. case 5:
  9797. return this.parseObjectLike(8, true);
  9798. case 88:
  9799. return this.parseVoidPattern(null);
  9800. }
  9801. return this.parseIdentifier();
  9802. }
  9803. parseBindingList(close, closeCharCode, flags) {
  9804. const allowEmpty = flags & 1;
  9805. const elts = [];
  9806. let first = true;
  9807. while (!this.eat(close)) {
  9808. if (first) {
  9809. first = false;
  9810. } else {
  9811. this.expect(12);
  9812. }
  9813. if (allowEmpty && this.match(12)) {
  9814. elts.push(null);
  9815. } else if (this.eat(close)) {
  9816. break;
  9817. } else if (this.match(21)) {
  9818. let rest = this.parseRestBinding();
  9819. if (this.hasPlugin("flow") || flags & 2) {
  9820. rest = this.parseFunctionParamType(rest);
  9821. }
  9822. elts.push(rest);
  9823. if (!this.checkCommaAfterRest(closeCharCode)) {
  9824. this.expect(close);
  9825. break;
  9826. }
  9827. } else {
  9828. const decorators = [];
  9829. if (flags & 2) {
  9830. if (this.match(26) && this.hasPlugin("decorators")) {
  9831. this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
  9832. }
  9833. while (this.match(26)) {
  9834. decorators.push(this.parseDecorator());
  9835. }
  9836. }
  9837. elts.push(this.parseBindingElement(flags, decorators));
  9838. }
  9839. }
  9840. return elts;
  9841. }
  9842. parseBindingRestProperty(prop) {
  9843. this.next();
  9844. if (this.hasPlugin("discardBinding") && this.match(88)) {
  9845. prop.argument = this.parseVoidPattern(null);
  9846. this.raise(Errors.UnexpectedVoidPattern, prop.argument);
  9847. } else {
  9848. prop.argument = this.parseIdentifier();
  9849. }
  9850. this.checkCommaAfterRest(125);
  9851. return this.finishNode(prop, "RestElement");
  9852. }
  9853. parseBindingProperty() {
  9854. const {
  9855. type,
  9856. startLoc
  9857. } = this.state;
  9858. if (type === 21) {
  9859. return this.parseBindingRestProperty(this.startNode());
  9860. }
  9861. const prop = this.startNode();
  9862. if (type === 139) {
  9863. this.expectPlugin("destructuringPrivate", startLoc);
  9864. this.classScope.usePrivateName(this.state.value, startLoc);
  9865. prop.key = this.parsePrivateName();
  9866. } else {
  9867. this.parsePropertyName(prop);
  9868. }
  9869. prop.method = false;
  9870. return this.parseObjPropValue(prop, startLoc, false, false, true, false);
  9871. }
  9872. parseBindingElement(flags, decorators) {
  9873. const left = this.parseMaybeDefault();
  9874. if (this.hasPlugin("flow") || flags & 2) {
  9875. this.parseFunctionParamType(left);
  9876. }
  9877. if (decorators.length) {
  9878. left.decorators = decorators;
  9879. this.resetStartLocationFromNode(left, decorators[0]);
  9880. }
  9881. const elt = this.parseMaybeDefault(left.loc.start, left);
  9882. return elt;
  9883. }
  9884. parseFunctionParamType(param) {
  9885. return param;
  9886. }
  9887. parseMaybeDefault(startLoc, left) {
  9888. startLoc != null ? startLoc : startLoc = this.state.startLoc;
  9889. left = left != null ? left : this.parseBindingAtom();
  9890. if (!this.eat(29)) return left;
  9891. const node = this.startNodeAt(startLoc);
  9892. if (left.type === "VoidPattern") {
  9893. this.raise(Errors.VoidPatternInitializer, left);
  9894. }
  9895. node.left = left;
  9896. node.right = this.parseMaybeAssignAllowIn();
  9897. return this.finishNode(node, "AssignmentPattern");
  9898. }
  9899. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  9900. switch (type) {
  9901. case "AssignmentPattern":
  9902. return "left";
  9903. case "RestElement":
  9904. return "argument";
  9905. case "ObjectProperty":
  9906. return "value";
  9907. case "ParenthesizedExpression":
  9908. return "expression";
  9909. case "ArrayPattern":
  9910. return "elements";
  9911. case "ObjectPattern":
  9912. return "properties";
  9913. case "VoidPattern":
  9914. return true;
  9915. }
  9916. return false;
  9917. }
  9918. isOptionalMemberExpression(expression) {
  9919. return expression.type === "OptionalMemberExpression";
  9920. }
  9921. checkLVal(expression, ancestor, binding = 64, checkClashes = false, strictModeChanged = false, hasParenthesizedAncestor = false) {
  9922. var _expression$extra;
  9923. const type = expression.type;
  9924. if (this.isObjectMethod(expression)) return;
  9925. const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
  9926. if (isOptionalMemberExpression || type === "MemberExpression") {
  9927. if (isOptionalMemberExpression) {
  9928. this.expectPlugin("optionalChainingAssign", expression.loc.start);
  9929. if (ancestor.type !== "AssignmentExpression") {
  9930. this.raise(Errors.InvalidLhsOptionalChaining, expression, {
  9931. ancestor
  9932. });
  9933. }
  9934. }
  9935. if (binding !== 64) {
  9936. this.raise(Errors.InvalidPropertyBindingPattern, expression);
  9937. }
  9938. return;
  9939. }
  9940. if (type === "Identifier") {
  9941. this.checkIdentifier(expression, binding, strictModeChanged);
  9942. const {
  9943. name
  9944. } = expression;
  9945. if (checkClashes) {
  9946. if (checkClashes.has(name)) {
  9947. this.raise(Errors.ParamDupe, expression);
  9948. } else {
  9949. checkClashes.add(name);
  9950. }
  9951. }
  9952. return;
  9953. } else if (type === "VoidPattern" && ancestor.type === "CatchClause") {
  9954. this.raise(Errors.VoidPatternCatchClauseParam, expression);
  9955. }
  9956. const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
  9957. if (validity === true) return;
  9958. if (validity === false) {
  9959. const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
  9960. this.raise(ParseErrorClass, expression, {
  9961. ancestor
  9962. });
  9963. return;
  9964. }
  9965. let key, isParenthesizedExpression;
  9966. if (typeof validity === "string") {
  9967. key = validity;
  9968. isParenthesizedExpression = type === "ParenthesizedExpression";
  9969. } else {
  9970. [key, isParenthesizedExpression] = validity;
  9971. }
  9972. const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
  9973. type
  9974. } : ancestor;
  9975. const val = expression[key];
  9976. if (Array.isArray(val)) {
  9977. for (const child of val) {
  9978. if (child) {
  9979. this.checkLVal(child, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
  9980. }
  9981. }
  9982. } else if (val) {
  9983. this.checkLVal(val, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
  9984. }
  9985. }
  9986. checkIdentifier(at, bindingType, strictModeChanged = false) {
  9987. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
  9988. if (bindingType === 64) {
  9989. this.raise(Errors.StrictEvalArguments, at, {
  9990. referenceName: at.name
  9991. });
  9992. } else {
  9993. this.raise(Errors.StrictEvalArgumentsBinding, at, {
  9994. bindingName: at.name
  9995. });
  9996. }
  9997. }
  9998. if (bindingType & 8192 && at.name === "let") {
  9999. this.raise(Errors.LetInLexicalBinding, at);
  10000. }
  10001. if (!(bindingType & 64)) {
  10002. this.declareNameFromIdentifier(at, bindingType);
  10003. }
  10004. }
  10005. declareNameFromIdentifier(identifier, binding) {
  10006. this.scope.declareName(identifier.name, binding, identifier.loc.start);
  10007. }
  10008. checkToRestConversion(node, allowPattern) {
  10009. switch (node.type) {
  10010. case "ParenthesizedExpression":
  10011. this.checkToRestConversion(node.expression, allowPattern);
  10012. break;
  10013. case "Identifier":
  10014. case "MemberExpression":
  10015. break;
  10016. case "ArrayExpression":
  10017. case "ObjectExpression":
  10018. if (allowPattern) break;
  10019. default:
  10020. this.raise(Errors.InvalidRestAssignmentPattern, node);
  10021. }
  10022. }
  10023. checkCommaAfterRest(close) {
  10024. if (!this.match(12)) {
  10025. return false;
  10026. }
  10027. this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
  10028. return true;
  10029. }
  10030. }
  10031. function nonNull(x) {
  10032. if (x == null) {
  10033. throw new Error(`Unexpected ${x} value.`);
  10034. }
  10035. return x;
  10036. }
  10037. function assert(x) {
  10038. if (!x) {
  10039. throw new Error("Assert fail");
  10040. }
  10041. }
  10042. const TSErrors = ParseErrorEnum`typescript`({
  10043. AbstractMethodHasImplementation: ({
  10044. methodName
  10045. }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`,
  10046. AbstractPropertyHasInitializer: ({
  10047. propertyName
  10048. }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
  10049. AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
  10050. AccessorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  10051. AccessorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  10052. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  10053. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  10054. ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
  10055. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  10056. DeclareAccessor: ({
  10057. kind
  10058. }) => `'declare' is not allowed in ${kind}ters.`,
  10059. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  10060. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  10061. DuplicateAccessibilityModifier: ({
  10062. modifier
  10063. }) => `Accessibility modifier already seen: '${modifier}'.`,
  10064. DuplicateModifier: ({
  10065. modifier
  10066. }) => `Duplicate modifier: '${modifier}'.`,
  10067. EmptyHeritageClauseType: ({
  10068. token
  10069. }) => `'${token}' list cannot be empty.`,
  10070. EmptyTypeArguments: "Type argument list cannot be empty.",
  10071. EmptyTypeParameters: "Type parameter list cannot be empty.",
  10072. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  10073. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  10074. ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier",
  10075. IncompatibleModifiers: ({
  10076. modifiers
  10077. }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
  10078. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  10079. IndexSignatureHasAccessibility: ({
  10080. modifier
  10081. }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
  10082. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  10083. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  10084. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  10085. InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
  10086. InvalidHeritageClauseType: ({
  10087. token
  10088. }) => `'${token}' list can only include identifiers or qualified-names with optional type arguments.`,
  10089. InvalidModifierOnAwaitUsingDeclaration: modifier => `'${modifier}' modifier cannot appear on an await using declaration.`,
  10090. InvalidModifierOnTypeMember: ({
  10091. modifier
  10092. }) => `'${modifier}' modifier cannot appear on a type member.`,
  10093. InvalidModifierOnTypeParameter: ({
  10094. modifier
  10095. }) => `'${modifier}' modifier cannot appear on a type parameter.`,
  10096. InvalidModifierOnTypeParameterPositions: ({
  10097. modifier
  10098. }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
  10099. InvalidModifierOnUsingDeclaration: modifier => `'${modifier}' modifier cannot appear on a using declaration.`,
  10100. InvalidModifiersOrder: ({
  10101. orderedModifiers
  10102. }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
  10103. InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
  10104. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  10105. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  10106. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  10107. NonClassMethodPropertyHasAbstractModifier: "'abstract' modifier can only appear on a class, method, or property declaration.",
  10108. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  10109. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  10110. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  10111. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  10112. PrivateElementHasAccessibility: ({
  10113. modifier
  10114. }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
  10115. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  10116. ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
  10117. ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
  10118. SetAccessorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  10119. SetAccessorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  10120. SetAccessorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  10121. SingleTypeParameterWithoutTrailingComma: ({
  10122. typeParameterName
  10123. }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
  10124. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  10125. TupleOptionalAfterType: "A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",
  10126. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  10127. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  10128. TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
  10129. TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
  10130. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  10131. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  10132. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  10133. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  10134. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  10135. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  10136. UnsupportedSignatureParameterKind: ({
  10137. type
  10138. }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`,
  10139. UsingDeclarationInAmbientContext: kind => `'${kind}' declarations are not allowed in ambient contexts.`
  10140. });
  10141. function keywordTypeFromName(value) {
  10142. switch (value) {
  10143. case "any":
  10144. return "TSAnyKeyword";
  10145. case "boolean":
  10146. return "TSBooleanKeyword";
  10147. case "bigint":
  10148. return "TSBigIntKeyword";
  10149. case "never":
  10150. return "TSNeverKeyword";
  10151. case "number":
  10152. return "TSNumberKeyword";
  10153. case "object":
  10154. return "TSObjectKeyword";
  10155. case "string":
  10156. return "TSStringKeyword";
  10157. case "symbol":
  10158. return "TSSymbolKeyword";
  10159. case "undefined":
  10160. return "TSUndefinedKeyword";
  10161. case "unknown":
  10162. return "TSUnknownKeyword";
  10163. default:
  10164. return undefined;
  10165. }
  10166. }
  10167. function tsIsAccessModifier(modifier) {
  10168. return modifier === "private" || modifier === "public" || modifier === "protected";
  10169. }
  10170. function tsIsVarianceAnnotations(modifier) {
  10171. return modifier === "in" || modifier === "out";
  10172. }
  10173. var typescript = superClass => class TypeScriptParserMixin extends superClass {
  10174. constructor(...args) {
  10175. super(...args);
  10176. this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, {
  10177. allowedModifiers: ["in", "out"],
  10178. disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"],
  10179. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  10180. });
  10181. this.tsParseConstModifier = this.tsParseModifiers.bind(this, {
  10182. allowedModifiers: ["const"],
  10183. disallowedModifiers: ["in", "out"],
  10184. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  10185. });
  10186. this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, {
  10187. allowedModifiers: ["in", "out", "const"],
  10188. disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
  10189. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  10190. });
  10191. }
  10192. getScopeHandler() {
  10193. return TypeScriptScopeHandler;
  10194. }
  10195. tsIsIdentifier() {
  10196. return tokenIsIdentifier(this.state.type);
  10197. }
  10198. tsTokenCanFollowModifier() {
  10199. return this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(139) || this.isLiteralPropertyName();
  10200. }
  10201. tsNextTokenOnSameLineAndCanFollowModifier() {
  10202. this.next();
  10203. if (this.hasPrecedingLineBreak()) {
  10204. return false;
  10205. }
  10206. return this.tsTokenCanFollowModifier();
  10207. }
  10208. tsNextTokenCanFollowModifier() {
  10209. if (this.match(106)) {
  10210. this.next();
  10211. return this.tsTokenCanFollowModifier();
  10212. }
  10213. return this.tsNextTokenOnSameLineAndCanFollowModifier();
  10214. }
  10215. tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
  10216. if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) {
  10217. return undefined;
  10218. }
  10219. const modifier = this.state.value;
  10220. if (allowedModifiers.includes(modifier)) {
  10221. if (hasSeenStaticModifier && this.match(106)) {
  10222. return undefined;
  10223. }
  10224. if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) {
  10225. return undefined;
  10226. }
  10227. if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  10228. return modifier;
  10229. }
  10230. }
  10231. return undefined;
  10232. }
  10233. tsParseModifiers({
  10234. allowedModifiers,
  10235. disallowedModifiers,
  10236. stopOnStartOfClassStaticBlock,
  10237. errorTemplate = TSErrors.InvalidModifierOnTypeMember
  10238. }, modified) {
  10239. const enforceOrder = (loc, modifier, before, after) => {
  10240. if (modifier === before && modified[after]) {
  10241. this.raise(TSErrors.InvalidModifiersOrder, loc, {
  10242. orderedModifiers: [before, after]
  10243. });
  10244. }
  10245. };
  10246. const incompatible = (loc, modifier, mod1, mod2) => {
  10247. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  10248. this.raise(TSErrors.IncompatibleModifiers, loc, {
  10249. modifiers: [mod1, mod2]
  10250. });
  10251. }
  10252. };
  10253. for (;;) {
  10254. const {
  10255. startLoc
  10256. } = this.state;
  10257. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock, modified.static);
  10258. if (!modifier) break;
  10259. if (tsIsAccessModifier(modifier)) {
  10260. if (modified.accessibility) {
  10261. this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, {
  10262. modifier
  10263. });
  10264. } else {
  10265. enforceOrder(startLoc, modifier, modifier, "override");
  10266. enforceOrder(startLoc, modifier, modifier, "static");
  10267. enforceOrder(startLoc, modifier, modifier, "readonly");
  10268. modified.accessibility = modifier;
  10269. }
  10270. } else if (tsIsVarianceAnnotations(modifier)) {
  10271. if (modified[modifier]) {
  10272. this.raise(TSErrors.DuplicateModifier, startLoc, {
  10273. modifier
  10274. });
  10275. }
  10276. modified[modifier] = true;
  10277. enforceOrder(startLoc, modifier, "in", "out");
  10278. } else {
  10279. if (hasOwnProperty.call(modified, modifier)) {
  10280. this.raise(TSErrors.DuplicateModifier, startLoc, {
  10281. modifier
  10282. });
  10283. } else {
  10284. enforceOrder(startLoc, modifier, "static", "readonly");
  10285. enforceOrder(startLoc, modifier, "static", "override");
  10286. enforceOrder(startLoc, modifier, "override", "readonly");
  10287. enforceOrder(startLoc, modifier, "abstract", "override");
  10288. incompatible(startLoc, modifier, "declare", "override");
  10289. incompatible(startLoc, modifier, "static", "abstract");
  10290. }
  10291. modified[modifier] = true;
  10292. }
  10293. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  10294. this.raise(errorTemplate, startLoc, {
  10295. modifier
  10296. });
  10297. }
  10298. }
  10299. }
  10300. tsIsListTerminator(kind) {
  10301. switch (kind) {
  10302. case "EnumMembers":
  10303. case "TypeMembers":
  10304. return this.match(8);
  10305. case "HeritageClauseElement":
  10306. return this.match(5);
  10307. case "TupleElementTypes":
  10308. return this.match(3);
  10309. case "TypeParametersOrArguments":
  10310. return this.match(48);
  10311. }
  10312. }
  10313. tsParseList(kind, parseElement) {
  10314. const result = [];
  10315. while (!this.tsIsListTerminator(kind)) {
  10316. result.push(parseElement());
  10317. }
  10318. return result;
  10319. }
  10320. tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) {
  10321. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos));
  10322. }
  10323. tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) {
  10324. const result = [];
  10325. let trailingCommaPos = -1;
  10326. for (;;) {
  10327. if (this.tsIsListTerminator(kind)) {
  10328. break;
  10329. }
  10330. trailingCommaPos = -1;
  10331. const element = parseElement();
  10332. if (element == null) {
  10333. return undefined;
  10334. }
  10335. result.push(element);
  10336. if (this.eat(12)) {
  10337. trailingCommaPos = this.state.lastTokStartLoc.index;
  10338. continue;
  10339. }
  10340. if (this.tsIsListTerminator(kind)) {
  10341. break;
  10342. }
  10343. if (expectSuccess) {
  10344. this.expect(12);
  10345. }
  10346. return undefined;
  10347. }
  10348. if (refTrailingCommaPos) {
  10349. refTrailingCommaPos.value = trailingCommaPos;
  10350. }
  10351. return result;
  10352. }
  10353. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) {
  10354. if (!skipFirstToken) {
  10355. if (bracket) {
  10356. this.expect(0);
  10357. } else {
  10358. this.expect(47);
  10359. }
  10360. }
  10361. const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos);
  10362. if (bracket) {
  10363. this.expect(3);
  10364. } else {
  10365. this.expect(48);
  10366. }
  10367. return result;
  10368. }
  10369. tsParseImportType() {
  10370. const node = this.startNode();
  10371. this.expect(83);
  10372. this.expect(10);
  10373. if (!this.match(134)) {
  10374. this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
  10375. {
  10376. node.argument = super.parseExprAtom();
  10377. }
  10378. } else {
  10379. {
  10380. node.argument = this.parseStringLiteral(this.state.value);
  10381. }
  10382. }
  10383. if (this.eat(12)) {
  10384. node.options = this.tsParseImportTypeOptions();
  10385. } else {
  10386. node.options = null;
  10387. }
  10388. this.expect(11);
  10389. if (this.eat(16)) {
  10390. node.qualifier = this.tsParseEntityName(1 | 2);
  10391. }
  10392. if (this.match(47)) {
  10393. {
  10394. node.typeParameters = this.tsParseTypeArguments();
  10395. }
  10396. }
  10397. return this.finishNode(node, "TSImportType");
  10398. }
  10399. tsParseImportTypeOptions() {
  10400. const node = this.startNode();
  10401. this.expect(5);
  10402. const withProperty = this.startNode();
  10403. if (this.isContextual(76)) {
  10404. withProperty.method = false;
  10405. withProperty.key = this.parseIdentifier(true);
  10406. withProperty.computed = false;
  10407. withProperty.shorthand = false;
  10408. } else {
  10409. this.unexpected(null, 76);
  10410. }
  10411. this.expect(14);
  10412. withProperty.value = this.tsParseImportTypeWithPropertyValue();
  10413. node.properties = [this.finishObjectProperty(withProperty)];
  10414. this.eat(12);
  10415. this.expect(8);
  10416. return this.finishNode(node, "ObjectExpression");
  10417. }
  10418. tsParseImportTypeWithPropertyValue() {
  10419. const node = this.startNode();
  10420. const properties = [];
  10421. this.expect(5);
  10422. while (!this.match(8)) {
  10423. const type = this.state.type;
  10424. if (tokenIsIdentifier(type) || type === 134) {
  10425. properties.push(super.parsePropertyDefinition(null));
  10426. } else {
  10427. this.unexpected();
  10428. }
  10429. this.eat(12);
  10430. }
  10431. node.properties = properties;
  10432. this.next();
  10433. return this.finishNode(node, "ObjectExpression");
  10434. }
  10435. tsParseEntityName(flags) {
  10436. let entity;
  10437. if (flags & 1 && this.match(78)) {
  10438. if (flags & 2) {
  10439. entity = this.parseIdentifier(true);
  10440. } else {
  10441. const node = this.startNode();
  10442. this.next();
  10443. entity = this.finishNode(node, "ThisExpression");
  10444. }
  10445. } else {
  10446. entity = this.parseIdentifier(!!(flags & 1));
  10447. }
  10448. while (this.eat(16)) {
  10449. const node = this.startNodeAtNode(entity);
  10450. node.left = entity;
  10451. node.right = this.parseIdentifier(!!(flags & 1));
  10452. entity = this.finishNode(node, "TSQualifiedName");
  10453. }
  10454. return entity;
  10455. }
  10456. tsParseTypeReference() {
  10457. const node = this.startNode();
  10458. node.typeName = this.tsParseEntityName(1);
  10459. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10460. {
  10461. node.typeParameters = this.tsParseTypeArguments();
  10462. }
  10463. }
  10464. return this.finishNode(node, "TSTypeReference");
  10465. }
  10466. tsParseThisTypePredicate(lhs) {
  10467. this.next();
  10468. const node = this.startNodeAtNode(lhs);
  10469. node.parameterName = lhs;
  10470. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  10471. node.asserts = false;
  10472. return this.finishNode(node, "TSTypePredicate");
  10473. }
  10474. tsParseThisTypeNode() {
  10475. const node = this.startNode();
  10476. this.next();
  10477. return this.finishNode(node, "TSThisType");
  10478. }
  10479. tsParseTypeQuery() {
  10480. const node = this.startNode();
  10481. this.expect(87);
  10482. if (this.match(83)) {
  10483. node.exprName = this.tsParseImportType();
  10484. } else {
  10485. {
  10486. node.exprName = this.tsParseEntityName(1 | 2);
  10487. }
  10488. }
  10489. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10490. {
  10491. node.typeParameters = this.tsParseTypeArguments();
  10492. }
  10493. }
  10494. return this.finishNode(node, "TSTypeQuery");
  10495. }
  10496. tsParseTypeParameter(parseModifiers) {
  10497. const node = this.startNode();
  10498. parseModifiers(node);
  10499. node.name = this.tsParseTypeParameterName();
  10500. node.constraint = this.tsEatThenParseType(81);
  10501. node.default = this.tsEatThenParseType(29);
  10502. return this.finishNode(node, "TSTypeParameter");
  10503. }
  10504. tsTryParseTypeParameters(parseModifiers) {
  10505. if (this.match(47)) {
  10506. return this.tsParseTypeParameters(parseModifiers);
  10507. }
  10508. }
  10509. tsParseTypeParameters(parseModifiers) {
  10510. const node = this.startNode();
  10511. if (this.match(47) || this.match(143)) {
  10512. this.next();
  10513. } else {
  10514. this.unexpected();
  10515. }
  10516. const refTrailingCommaPos = {
  10517. value: -1
  10518. };
  10519. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
  10520. if (node.params.length === 0) {
  10521. this.raise(TSErrors.EmptyTypeParameters, node);
  10522. }
  10523. if (refTrailingCommaPos.value !== -1) {
  10524. this.addExtra(node, "trailingComma", refTrailingCommaPos.value);
  10525. }
  10526. return this.finishNode(node, "TSTypeParameterDeclaration");
  10527. }
  10528. tsFillSignature(returnToken, signature) {
  10529. const returnTokenRequired = returnToken === 19;
  10530. const paramsKey = "parameters";
  10531. const returnTypeKey = "typeAnnotation";
  10532. signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  10533. this.expect(10);
  10534. signature[paramsKey] = this.tsParseBindingListForSignature();
  10535. if (returnTokenRequired) {
  10536. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10537. } else if (this.match(returnToken)) {
  10538. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10539. }
  10540. }
  10541. tsParseBindingListForSignature() {
  10542. const list = super.parseBindingList(11, 41, 2);
  10543. for (const pattern of list) {
  10544. const {
  10545. type
  10546. } = pattern;
  10547. if (type === "AssignmentPattern" || type === "TSParameterProperty") {
  10548. this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, {
  10549. type
  10550. });
  10551. }
  10552. }
  10553. return list;
  10554. }
  10555. tsParseTypeMemberSemicolon() {
  10556. if (!this.eat(12) && !this.isLineTerminator()) {
  10557. this.expect(13);
  10558. }
  10559. }
  10560. tsParseSignatureMember(kind, node) {
  10561. this.tsFillSignature(14, node);
  10562. this.tsParseTypeMemberSemicolon();
  10563. return this.finishNode(node, kind);
  10564. }
  10565. tsIsUnambiguouslyIndexSignature() {
  10566. this.next();
  10567. if (tokenIsIdentifier(this.state.type)) {
  10568. this.next();
  10569. return this.match(14);
  10570. }
  10571. return false;
  10572. }
  10573. tsTryParseIndexSignature(node) {
  10574. if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  10575. return;
  10576. }
  10577. this.expect(0);
  10578. const id = this.parseIdentifier();
  10579. id.typeAnnotation = this.tsParseTypeAnnotation();
  10580. this.resetEndLocation(id);
  10581. this.expect(3);
  10582. node.parameters = [id];
  10583. const type = this.tsTryParseTypeAnnotation();
  10584. if (type) node.typeAnnotation = type;
  10585. this.tsParseTypeMemberSemicolon();
  10586. return this.finishNode(node, "TSIndexSignature");
  10587. }
  10588. tsParsePropertyOrMethodSignature(node, readonly) {
  10589. if (this.eat(17)) node.optional = true;
  10590. if (this.match(10) || this.match(47)) {
  10591. if (readonly) {
  10592. this.raise(TSErrors.ReadonlyForMethodSignature, node);
  10593. }
  10594. const method = node;
  10595. if (method.kind && this.match(47)) {
  10596. this.raise(TSErrors.AccessorCannotHaveTypeParameters, this.state.curPosition());
  10597. }
  10598. this.tsFillSignature(14, method);
  10599. this.tsParseTypeMemberSemicolon();
  10600. const paramsKey = "parameters";
  10601. const returnTypeKey = "typeAnnotation";
  10602. if (method.kind === "get") {
  10603. if (method[paramsKey].length > 0) {
  10604. this.raise(Errors.BadGetterArity, this.state.curPosition());
  10605. if (this.isThisParam(method[paramsKey][0])) {
  10606. this.raise(TSErrors.AccessorCannotDeclareThisParameter, this.state.curPosition());
  10607. }
  10608. }
  10609. } else if (method.kind === "set") {
  10610. if (method[paramsKey].length !== 1) {
  10611. this.raise(Errors.BadSetterArity, this.state.curPosition());
  10612. } else {
  10613. const firstParameter = method[paramsKey][0];
  10614. if (this.isThisParam(firstParameter)) {
  10615. this.raise(TSErrors.AccessorCannotDeclareThisParameter, this.state.curPosition());
  10616. }
  10617. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  10618. this.raise(TSErrors.SetAccessorCannotHaveOptionalParameter, this.state.curPosition());
  10619. }
  10620. if (firstParameter.type === "RestElement") {
  10621. this.raise(TSErrors.SetAccessorCannotHaveRestParameter, this.state.curPosition());
  10622. }
  10623. }
  10624. if (method[returnTypeKey]) {
  10625. this.raise(TSErrors.SetAccessorCannotHaveReturnType, method[returnTypeKey]);
  10626. }
  10627. } else {
  10628. method.kind = "method";
  10629. }
  10630. return this.finishNode(method, "TSMethodSignature");
  10631. } else {
  10632. const property = node;
  10633. if (readonly) property.readonly = true;
  10634. const type = this.tsTryParseTypeAnnotation();
  10635. if (type) property.typeAnnotation = type;
  10636. this.tsParseTypeMemberSemicolon();
  10637. return this.finishNode(property, "TSPropertySignature");
  10638. }
  10639. }
  10640. tsParseTypeMember() {
  10641. const node = this.startNode();
  10642. if (this.match(10) || this.match(47)) {
  10643. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  10644. }
  10645. if (this.match(77)) {
  10646. const id = this.startNode();
  10647. this.next();
  10648. if (this.match(10) || this.match(47)) {
  10649. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  10650. } else {
  10651. node.key = this.createIdentifier(id, "new");
  10652. return this.tsParsePropertyOrMethodSignature(node, false);
  10653. }
  10654. }
  10655. this.tsParseModifiers({
  10656. allowedModifiers: ["readonly"],
  10657. disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"]
  10658. }, node);
  10659. const idx = this.tsTryParseIndexSignature(node);
  10660. if (idx) {
  10661. return idx;
  10662. }
  10663. super.parsePropertyName(node);
  10664. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  10665. node.kind = node.key.name;
  10666. super.parsePropertyName(node);
  10667. if (!this.match(10) && !this.match(47)) {
  10668. this.unexpected(null, 10);
  10669. }
  10670. }
  10671. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  10672. }
  10673. tsParseTypeLiteral() {
  10674. const node = this.startNode();
  10675. node.members = this.tsParseObjectTypeMembers();
  10676. return this.finishNode(node, "TSTypeLiteral");
  10677. }
  10678. tsParseObjectTypeMembers() {
  10679. this.expect(5);
  10680. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  10681. this.expect(8);
  10682. return members;
  10683. }
  10684. tsIsStartOfMappedType() {
  10685. this.next();
  10686. if (this.eat(53)) {
  10687. return this.isContextual(122);
  10688. }
  10689. if (this.isContextual(122)) {
  10690. this.next();
  10691. }
  10692. if (!this.match(0)) {
  10693. return false;
  10694. }
  10695. this.next();
  10696. if (!this.tsIsIdentifier()) {
  10697. return false;
  10698. }
  10699. this.next();
  10700. return this.match(58);
  10701. }
  10702. tsParseMappedType() {
  10703. const node = this.startNode();
  10704. this.expect(5);
  10705. if (this.match(53)) {
  10706. node.readonly = this.state.value;
  10707. this.next();
  10708. this.expectContextual(122);
  10709. } else if (this.eatContextual(122)) {
  10710. node.readonly = true;
  10711. }
  10712. this.expect(0);
  10713. {
  10714. const typeParameter = this.startNode();
  10715. typeParameter.name = this.tsParseTypeParameterName();
  10716. typeParameter.constraint = this.tsExpectThenParseType(58);
  10717. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10718. }
  10719. node.nameType = this.eatContextual(93) ? this.tsParseType() : null;
  10720. this.expect(3);
  10721. if (this.match(53)) {
  10722. node.optional = this.state.value;
  10723. this.next();
  10724. this.expect(17);
  10725. } else if (this.eat(17)) {
  10726. node.optional = true;
  10727. }
  10728. node.typeAnnotation = this.tsTryParseType();
  10729. this.semicolon();
  10730. this.expect(8);
  10731. return this.finishNode(node, "TSMappedType");
  10732. }
  10733. tsParseTupleType() {
  10734. const node = this.startNode();
  10735. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  10736. let seenOptionalElement = false;
  10737. node.elementTypes.forEach(elementNode => {
  10738. const {
  10739. type
  10740. } = elementNode;
  10741. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  10742. this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode);
  10743. }
  10744. seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType");
  10745. });
  10746. return this.finishNode(node, "TSTupleType");
  10747. }
  10748. tsParseTupleElementType() {
  10749. const restStartLoc = this.state.startLoc;
  10750. const rest = this.eat(21);
  10751. const {
  10752. startLoc
  10753. } = this.state;
  10754. let labeled;
  10755. let label;
  10756. let optional;
  10757. let type;
  10758. const isWord = tokenIsKeywordOrIdentifier(this.state.type);
  10759. const chAfterWord = isWord ? this.lookaheadCharCode() : null;
  10760. if (chAfterWord === 58) {
  10761. labeled = true;
  10762. optional = false;
  10763. label = this.parseIdentifier(true);
  10764. this.expect(14);
  10765. type = this.tsParseType();
  10766. } else if (chAfterWord === 63) {
  10767. optional = true;
  10768. const wordName = this.state.value;
  10769. const typeOrLabel = this.tsParseNonArrayType();
  10770. if (this.lookaheadCharCode() === 58) {
  10771. labeled = true;
  10772. label = this.createIdentifier(this.startNodeAt(startLoc), wordName);
  10773. this.expect(17);
  10774. this.expect(14);
  10775. type = this.tsParseType();
  10776. } else {
  10777. labeled = false;
  10778. type = typeOrLabel;
  10779. this.expect(17);
  10780. }
  10781. } else {
  10782. type = this.tsParseType();
  10783. optional = this.eat(17);
  10784. labeled = this.eat(14);
  10785. }
  10786. if (labeled) {
  10787. let labeledNode;
  10788. if (label) {
  10789. labeledNode = this.startNodeAt(startLoc);
  10790. labeledNode.optional = optional;
  10791. labeledNode.label = label;
  10792. labeledNode.elementType = type;
  10793. if (this.eat(17)) {
  10794. labeledNode.optional = true;
  10795. this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc);
  10796. }
  10797. } else {
  10798. labeledNode = this.startNodeAt(startLoc);
  10799. labeledNode.optional = optional;
  10800. this.raise(TSErrors.InvalidTupleMemberLabel, type);
  10801. labeledNode.label = type;
  10802. labeledNode.elementType = this.tsParseType();
  10803. }
  10804. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  10805. } else if (optional) {
  10806. const optionalTypeNode = this.startNodeAt(startLoc);
  10807. optionalTypeNode.typeAnnotation = type;
  10808. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  10809. }
  10810. if (rest) {
  10811. const restNode = this.startNodeAt(restStartLoc);
  10812. restNode.typeAnnotation = type;
  10813. type = this.finishNode(restNode, "TSRestType");
  10814. }
  10815. return type;
  10816. }
  10817. tsParseParenthesizedType() {
  10818. const node = this.startNode();
  10819. this.expect(10);
  10820. node.typeAnnotation = this.tsParseType();
  10821. this.expect(11);
  10822. return this.finishNode(node, "TSParenthesizedType");
  10823. }
  10824. tsParseFunctionOrConstructorType(type, abstract) {
  10825. const node = this.startNode();
  10826. if (type === "TSConstructorType") {
  10827. node.abstract = !!abstract;
  10828. if (abstract) this.next();
  10829. this.next();
  10830. }
  10831. this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
  10832. return this.finishNode(node, type);
  10833. }
  10834. tsParseLiteralTypeNode() {
  10835. const node = this.startNode();
  10836. switch (this.state.type) {
  10837. case 135:
  10838. case 136:
  10839. case 134:
  10840. case 85:
  10841. case 86:
  10842. node.literal = super.parseExprAtom();
  10843. break;
  10844. default:
  10845. this.unexpected();
  10846. }
  10847. return this.finishNode(node, "TSLiteralType");
  10848. }
  10849. tsParseTemplateLiteralType() {
  10850. {
  10851. const node = this.startNode();
  10852. node.literal = super.parseTemplate(false);
  10853. return this.finishNode(node, "TSLiteralType");
  10854. }
  10855. }
  10856. parseTemplateSubstitution() {
  10857. if (this.state.inType) return this.tsParseType();
  10858. return super.parseTemplateSubstitution();
  10859. }
  10860. tsParseThisTypeOrThisTypePredicate() {
  10861. const thisKeyword = this.tsParseThisTypeNode();
  10862. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10863. return this.tsParseThisTypePredicate(thisKeyword);
  10864. } else {
  10865. return thisKeyword;
  10866. }
  10867. }
  10868. tsParseNonArrayType() {
  10869. switch (this.state.type) {
  10870. case 134:
  10871. case 135:
  10872. case 136:
  10873. case 85:
  10874. case 86:
  10875. return this.tsParseLiteralTypeNode();
  10876. case 53:
  10877. if (this.state.value === "-") {
  10878. const node = this.startNode();
  10879. const nextToken = this.lookahead();
  10880. if (nextToken.type !== 135 && nextToken.type !== 136) {
  10881. this.unexpected();
  10882. }
  10883. node.literal = this.parseMaybeUnary();
  10884. return this.finishNode(node, "TSLiteralType");
  10885. }
  10886. break;
  10887. case 78:
  10888. return this.tsParseThisTypeOrThisTypePredicate();
  10889. case 87:
  10890. return this.tsParseTypeQuery();
  10891. case 83:
  10892. return this.tsParseImportType();
  10893. case 5:
  10894. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  10895. case 0:
  10896. return this.tsParseTupleType();
  10897. case 10:
  10898. return this.tsParseParenthesizedType();
  10899. case 25:
  10900. case 24:
  10901. return this.tsParseTemplateLiteralType();
  10902. default:
  10903. {
  10904. const {
  10905. type
  10906. } = this.state;
  10907. if (tokenIsIdentifier(type) || type === 88 || type === 84) {
  10908. const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  10909. if (nodeType !== undefined && this.lookaheadCharCode() !== 46) {
  10910. const node = this.startNode();
  10911. this.next();
  10912. return this.finishNode(node, nodeType);
  10913. }
  10914. return this.tsParseTypeReference();
  10915. }
  10916. }
  10917. }
  10918. this.unexpected();
  10919. }
  10920. tsParseArrayTypeOrHigher() {
  10921. const {
  10922. startLoc
  10923. } = this.state;
  10924. let type = this.tsParseNonArrayType();
  10925. while (!this.hasPrecedingLineBreak() && this.eat(0)) {
  10926. if (this.match(3)) {
  10927. const node = this.startNodeAt(startLoc);
  10928. node.elementType = type;
  10929. this.expect(3);
  10930. type = this.finishNode(node, "TSArrayType");
  10931. } else {
  10932. const node = this.startNodeAt(startLoc);
  10933. node.objectType = type;
  10934. node.indexType = this.tsParseType();
  10935. this.expect(3);
  10936. type = this.finishNode(node, "TSIndexedAccessType");
  10937. }
  10938. }
  10939. return type;
  10940. }
  10941. tsParseTypeOperator() {
  10942. const node = this.startNode();
  10943. const operator = this.state.value;
  10944. this.next();
  10945. node.operator = operator;
  10946. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  10947. if (operator === "readonly") {
  10948. this.tsCheckTypeAnnotationForReadOnly(node);
  10949. }
  10950. return this.finishNode(node, "TSTypeOperator");
  10951. }
  10952. tsCheckTypeAnnotationForReadOnly(node) {
  10953. switch (node.typeAnnotation.type) {
  10954. case "TSTupleType":
  10955. case "TSArrayType":
  10956. return;
  10957. default:
  10958. this.raise(TSErrors.UnexpectedReadonly, node);
  10959. }
  10960. }
  10961. tsParseInferType() {
  10962. const node = this.startNode();
  10963. this.expectContextual(115);
  10964. const typeParameter = this.startNode();
  10965. typeParameter.name = this.tsParseTypeParameterName();
  10966. typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
  10967. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10968. return this.finishNode(node, "TSInferType");
  10969. }
  10970. tsParseConstraintForInferType() {
  10971. if (this.eat(81)) {
  10972. const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
  10973. if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
  10974. return constraint;
  10975. }
  10976. }
  10977. }
  10978. tsParseTypeOperatorOrHigher() {
  10979. const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
  10980. return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
  10981. }
  10982. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  10983. const node = this.startNode();
  10984. const hasLeadingOperator = this.eat(operator);
  10985. const types = [];
  10986. do {
  10987. types.push(parseConstituentType());
  10988. } while (this.eat(operator));
  10989. if (types.length === 1 && !hasLeadingOperator) {
  10990. return types[0];
  10991. }
  10992. node.types = types;
  10993. return this.finishNode(node, kind);
  10994. }
  10995. tsParseIntersectionTypeOrHigher() {
  10996. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45);
  10997. }
  10998. tsParseUnionTypeOrHigher() {
  10999. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43);
  11000. }
  11001. tsIsStartOfFunctionType() {
  11002. if (this.match(47)) {
  11003. return true;
  11004. }
  11005. return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  11006. }
  11007. tsSkipParameterStart() {
  11008. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  11009. this.next();
  11010. return true;
  11011. }
  11012. if (this.match(5)) {
  11013. const {
  11014. errors
  11015. } = this.state;
  11016. const previousErrorCount = errors.length;
  11017. try {
  11018. this.parseObjectLike(8, true);
  11019. return errors.length === previousErrorCount;
  11020. } catch (_unused) {
  11021. return false;
  11022. }
  11023. }
  11024. if (this.match(0)) {
  11025. this.next();
  11026. const {
  11027. errors
  11028. } = this.state;
  11029. const previousErrorCount = errors.length;
  11030. try {
  11031. super.parseBindingList(3, 93, 1);
  11032. return errors.length === previousErrorCount;
  11033. } catch (_unused2) {
  11034. return false;
  11035. }
  11036. }
  11037. return false;
  11038. }
  11039. tsIsUnambiguouslyStartOfFunctionType() {
  11040. this.next();
  11041. if (this.match(11) || this.match(21)) {
  11042. return true;
  11043. }
  11044. if (this.tsSkipParameterStart()) {
  11045. if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) {
  11046. return true;
  11047. }
  11048. if (this.match(11)) {
  11049. this.next();
  11050. if (this.match(19)) {
  11051. return true;
  11052. }
  11053. }
  11054. }
  11055. return false;
  11056. }
  11057. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  11058. return this.tsInType(() => {
  11059. const t = this.startNode();
  11060. this.expect(returnToken);
  11061. const node = this.startNode();
  11062. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  11063. if (asserts && this.match(78)) {
  11064. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  11065. if (thisTypePredicate.type === "TSThisType") {
  11066. node.parameterName = thisTypePredicate;
  11067. node.asserts = true;
  11068. node.typeAnnotation = null;
  11069. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  11070. } else {
  11071. this.resetStartLocationFromNode(thisTypePredicate, node);
  11072. thisTypePredicate.asserts = true;
  11073. }
  11074. t.typeAnnotation = thisTypePredicate;
  11075. return this.finishNode(t, "TSTypeAnnotation");
  11076. }
  11077. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  11078. if (!typePredicateVariable) {
  11079. if (!asserts) {
  11080. return this.tsParseTypeAnnotation(false, t);
  11081. }
  11082. node.parameterName = this.parseIdentifier();
  11083. node.asserts = asserts;
  11084. node.typeAnnotation = null;
  11085. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  11086. return this.finishNode(t, "TSTypeAnnotation");
  11087. }
  11088. const type = this.tsParseTypeAnnotation(false);
  11089. node.parameterName = typePredicateVariable;
  11090. node.typeAnnotation = type;
  11091. node.asserts = asserts;
  11092. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  11093. return this.finishNode(t, "TSTypeAnnotation");
  11094. });
  11095. }
  11096. tsTryParseTypeOrTypePredicateAnnotation() {
  11097. if (this.match(14)) {
  11098. return this.tsParseTypeOrTypePredicateAnnotation(14);
  11099. }
  11100. }
  11101. tsTryParseTypeAnnotation() {
  11102. if (this.match(14)) {
  11103. return this.tsParseTypeAnnotation();
  11104. }
  11105. }
  11106. tsTryParseType() {
  11107. return this.tsEatThenParseType(14);
  11108. }
  11109. tsParseTypePredicatePrefix() {
  11110. const id = this.parseIdentifier();
  11111. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  11112. this.next();
  11113. return id;
  11114. }
  11115. }
  11116. tsParseTypePredicateAsserts() {
  11117. if (this.state.type !== 109) {
  11118. return false;
  11119. }
  11120. const containsEsc = this.state.containsEsc;
  11121. this.next();
  11122. if (!tokenIsIdentifier(this.state.type) && !this.match(78)) {
  11123. return false;
  11124. }
  11125. if (containsEsc) {
  11126. this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, {
  11127. reservedWord: "asserts"
  11128. });
  11129. }
  11130. return true;
  11131. }
  11132. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  11133. this.tsInType(() => {
  11134. if (eatColon) this.expect(14);
  11135. t.typeAnnotation = this.tsParseType();
  11136. });
  11137. return this.finishNode(t, "TSTypeAnnotation");
  11138. }
  11139. tsParseType() {
  11140. assert(this.state.inType);
  11141. const type = this.tsParseNonConditionalType();
  11142. if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
  11143. return type;
  11144. }
  11145. const node = this.startNodeAtNode(type);
  11146. node.checkType = type;
  11147. node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
  11148. this.expect(17);
  11149. node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  11150. this.expect(14);
  11151. node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  11152. return this.finishNode(node, "TSConditionalType");
  11153. }
  11154. isAbstractConstructorSignature() {
  11155. return this.isContextual(124) && this.isLookaheadContextual("new");
  11156. }
  11157. tsParseNonConditionalType() {
  11158. if (this.tsIsStartOfFunctionType()) {
  11159. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  11160. }
  11161. if (this.match(77)) {
  11162. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  11163. } else if (this.isAbstractConstructorSignature()) {
  11164. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  11165. }
  11166. return this.tsParseUnionTypeOrHigher();
  11167. }
  11168. tsParseTypeAssertion() {
  11169. if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  11170. this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc);
  11171. }
  11172. const node = this.startNode();
  11173. node.typeAnnotation = this.tsInType(() => {
  11174. this.next();
  11175. return this.match(75) ? this.tsParseTypeReference() : this.tsParseType();
  11176. });
  11177. this.expect(48);
  11178. node.expression = this.parseMaybeUnary();
  11179. return this.finishNode(node, "TSTypeAssertion");
  11180. }
  11181. tsParseHeritageClause(token) {
  11182. const originalStartLoc = this.state.startLoc;
  11183. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
  11184. {
  11185. const node = this.startNode();
  11186. node.expression = this.tsParseEntityName(1 | 2);
  11187. if (this.match(47)) {
  11188. node.typeParameters = this.tsParseTypeArguments();
  11189. }
  11190. return this.finishNode(node, "TSExpressionWithTypeArguments");
  11191. }
  11192. });
  11193. if (!delimitedList.length) {
  11194. this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
  11195. token
  11196. });
  11197. }
  11198. return delimitedList;
  11199. }
  11200. tsParseInterfaceDeclaration(node, properties = {}) {
  11201. if (this.hasFollowingLineBreak()) return null;
  11202. this.expectContextual(129);
  11203. if (properties.declare) node.declare = true;
  11204. if (tokenIsIdentifier(this.state.type)) {
  11205. node.id = this.parseIdentifier();
  11206. this.checkIdentifier(node.id, 130);
  11207. } else {
  11208. node.id = null;
  11209. this.raise(TSErrors.MissingInterfaceName, this.state.startLoc);
  11210. }
  11211. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  11212. if (this.eat(81)) {
  11213. node.extends = this.tsParseHeritageClause("extends");
  11214. }
  11215. const body = this.startNode();
  11216. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  11217. node.body = this.finishNode(body, "TSInterfaceBody");
  11218. return this.finishNode(node, "TSInterfaceDeclaration");
  11219. }
  11220. tsParseTypeAliasDeclaration(node) {
  11221. node.id = this.parseIdentifier();
  11222. this.checkIdentifier(node.id, 2);
  11223. node.typeAnnotation = this.tsInType(() => {
  11224. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
  11225. this.expect(29);
  11226. if (this.isContextual(114) && this.lookaheadCharCode() !== 46) {
  11227. const node = this.startNode();
  11228. this.next();
  11229. return this.finishNode(node, "TSIntrinsicKeyword");
  11230. }
  11231. return this.tsParseType();
  11232. });
  11233. this.semicolon();
  11234. return this.finishNode(node, "TSTypeAliasDeclaration");
  11235. }
  11236. tsInTopLevelContext(cb) {
  11237. if (this.curContext() !== types.brace) {
  11238. const oldContext = this.state.context;
  11239. this.state.context = [oldContext[0]];
  11240. try {
  11241. return cb();
  11242. } finally {
  11243. this.state.context = oldContext;
  11244. }
  11245. } else {
  11246. return cb();
  11247. }
  11248. }
  11249. tsInType(cb) {
  11250. const oldInType = this.state.inType;
  11251. this.state.inType = true;
  11252. try {
  11253. return cb();
  11254. } finally {
  11255. this.state.inType = oldInType;
  11256. }
  11257. }
  11258. tsInDisallowConditionalTypesContext(cb) {
  11259. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  11260. this.state.inDisallowConditionalTypesContext = true;
  11261. try {
  11262. return cb();
  11263. } finally {
  11264. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  11265. }
  11266. }
  11267. tsInAllowConditionalTypesContext(cb) {
  11268. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  11269. this.state.inDisallowConditionalTypesContext = false;
  11270. try {
  11271. return cb();
  11272. } finally {
  11273. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  11274. }
  11275. }
  11276. tsEatThenParseType(token) {
  11277. if (this.match(token)) {
  11278. return this.tsNextThenParseType();
  11279. }
  11280. }
  11281. tsExpectThenParseType(token) {
  11282. return this.tsInType(() => {
  11283. this.expect(token);
  11284. return this.tsParseType();
  11285. });
  11286. }
  11287. tsNextThenParseType() {
  11288. return this.tsInType(() => {
  11289. this.next();
  11290. return this.tsParseType();
  11291. });
  11292. }
  11293. tsParseEnumMember() {
  11294. const node = this.startNode();
  11295. node.id = this.match(134) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
  11296. if (this.eat(29)) {
  11297. node.initializer = super.parseMaybeAssignAllowIn();
  11298. }
  11299. return this.finishNode(node, "TSEnumMember");
  11300. }
  11301. tsParseEnumDeclaration(node, properties = {}) {
  11302. if (properties.const) node.const = true;
  11303. if (properties.declare) node.declare = true;
  11304. this.expectContextual(126);
  11305. node.id = this.parseIdentifier();
  11306. this.checkIdentifier(node.id, node.const ? 8971 : 8459);
  11307. {
  11308. this.expect(5);
  11309. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  11310. this.expect(8);
  11311. }
  11312. return this.finishNode(node, "TSEnumDeclaration");
  11313. }
  11314. tsParseEnumBody() {
  11315. const node = this.startNode();
  11316. this.expect(5);
  11317. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  11318. this.expect(8);
  11319. return this.finishNode(node, "TSEnumBody");
  11320. }
  11321. tsParseModuleBlock() {
  11322. const node = this.startNode();
  11323. this.scope.enter(0);
  11324. this.expect(5);
  11325. super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8);
  11326. this.scope.exit();
  11327. return this.finishNode(node, "TSModuleBlock");
  11328. }
  11329. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  11330. node.id = this.parseIdentifier();
  11331. if (!nested) {
  11332. this.checkIdentifier(node.id, 1024);
  11333. }
  11334. if (this.eat(16)) {
  11335. const inner = this.startNode();
  11336. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  11337. node.body = inner;
  11338. } else {
  11339. this.scope.enter(1024);
  11340. this.prodParam.enter(0);
  11341. node.body = this.tsParseModuleBlock();
  11342. this.prodParam.exit();
  11343. this.scope.exit();
  11344. }
  11345. return this.finishNode(node, "TSModuleDeclaration");
  11346. }
  11347. tsParseAmbientExternalModuleDeclaration(node) {
  11348. if (this.isContextual(112)) {
  11349. node.kind = "global";
  11350. {
  11351. node.global = true;
  11352. }
  11353. node.id = this.parseIdentifier();
  11354. } else if (this.match(134)) {
  11355. node.kind = "module";
  11356. node.id = super.parseStringLiteral(this.state.value);
  11357. } else {
  11358. this.unexpected();
  11359. }
  11360. if (this.match(5)) {
  11361. this.scope.enter(1024);
  11362. this.prodParam.enter(0);
  11363. node.body = this.tsParseModuleBlock();
  11364. this.prodParam.exit();
  11365. this.scope.exit();
  11366. } else {
  11367. this.semicolon();
  11368. }
  11369. return this.finishNode(node, "TSModuleDeclaration");
  11370. }
  11371. tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) {
  11372. {
  11373. node.isExport = isExport || false;
  11374. }
  11375. node.id = maybeDefaultIdentifier || this.parseIdentifier();
  11376. this.checkIdentifier(node.id, 4096);
  11377. this.expect(29);
  11378. const moduleReference = this.tsParseModuleReference();
  11379. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  11380. this.raise(TSErrors.ImportAliasHasImportType, moduleReference);
  11381. }
  11382. node.moduleReference = moduleReference;
  11383. this.semicolon();
  11384. return this.finishNode(node, "TSImportEqualsDeclaration");
  11385. }
  11386. tsIsExternalModuleReference() {
  11387. return this.isContextual(119) && this.lookaheadCharCode() === 40;
  11388. }
  11389. tsParseModuleReference() {
  11390. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(0);
  11391. }
  11392. tsParseExternalModuleReference() {
  11393. const node = this.startNode();
  11394. this.expectContextual(119);
  11395. this.expect(10);
  11396. if (!this.match(134)) {
  11397. this.unexpected();
  11398. }
  11399. node.expression = super.parseExprAtom();
  11400. this.expect(11);
  11401. this.sawUnambiguousESM = true;
  11402. return this.finishNode(node, "TSExternalModuleReference");
  11403. }
  11404. tsLookAhead(f) {
  11405. const state = this.state.clone();
  11406. const res = f();
  11407. this.state = state;
  11408. return res;
  11409. }
  11410. tsTryParseAndCatch(f) {
  11411. const result = this.tryParse(abort => f() || abort());
  11412. if (result.aborted || !result.node) return;
  11413. if (result.error) this.state = result.failState;
  11414. return result.node;
  11415. }
  11416. tsTryParse(f) {
  11417. const state = this.state.clone();
  11418. const result = f();
  11419. if (result !== undefined && result !== false) {
  11420. return result;
  11421. }
  11422. this.state = state;
  11423. }
  11424. tsTryParseDeclare(node) {
  11425. if (this.isLineTerminator()) {
  11426. return;
  11427. }
  11428. const startType = this.state.type;
  11429. return this.tsInAmbientContext(() => {
  11430. switch (startType) {
  11431. case 68:
  11432. node.declare = true;
  11433. return super.parseFunctionStatement(node, false, false);
  11434. case 80:
  11435. node.declare = true;
  11436. return this.parseClass(node, true, false);
  11437. case 126:
  11438. return this.tsParseEnumDeclaration(node, {
  11439. declare: true
  11440. });
  11441. case 112:
  11442. return this.tsParseAmbientExternalModuleDeclaration(node);
  11443. case 100:
  11444. if (this.state.containsEsc) {
  11445. return;
  11446. }
  11447. case 75:
  11448. case 74:
  11449. if (!this.match(75) || !this.isLookaheadContextual("enum")) {
  11450. node.declare = true;
  11451. return this.parseVarStatement(node, this.state.value, true);
  11452. }
  11453. this.expect(75);
  11454. return this.tsParseEnumDeclaration(node, {
  11455. const: true,
  11456. declare: true
  11457. });
  11458. case 107:
  11459. if (this.isUsing()) {
  11460. this.raise(TSErrors.InvalidModifierOnUsingDeclaration, this.state.startLoc, "declare");
  11461. node.declare = true;
  11462. return this.parseVarStatement(node, "using", true);
  11463. }
  11464. break;
  11465. case 96:
  11466. if (this.isAwaitUsing()) {
  11467. this.raise(TSErrors.InvalidModifierOnAwaitUsingDeclaration, this.state.startLoc, "declare");
  11468. node.declare = true;
  11469. this.next();
  11470. return this.parseVarStatement(node, "await using", true);
  11471. }
  11472. break;
  11473. case 129:
  11474. {
  11475. const result = this.tsParseInterfaceDeclaration(node, {
  11476. declare: true
  11477. });
  11478. if (result) return result;
  11479. }
  11480. default:
  11481. if (tokenIsIdentifier(startType)) {
  11482. return this.tsParseDeclaration(node, this.state.value, true, null);
  11483. }
  11484. }
  11485. });
  11486. }
  11487. tsTryParseExportDeclaration() {
  11488. return this.tsParseDeclaration(this.startNode(), this.state.value, true, null);
  11489. }
  11490. tsParseExpressionStatement(node, expr, decorators) {
  11491. switch (expr.name) {
  11492. case "declare":
  11493. {
  11494. const declaration = this.tsTryParseDeclare(node);
  11495. if (declaration) {
  11496. declaration.declare = true;
  11497. }
  11498. return declaration;
  11499. }
  11500. case "global":
  11501. if (this.match(5)) {
  11502. this.scope.enter(1024);
  11503. this.prodParam.enter(0);
  11504. const mod = node;
  11505. mod.kind = "global";
  11506. {
  11507. node.global = true;
  11508. }
  11509. mod.id = expr;
  11510. mod.body = this.tsParseModuleBlock();
  11511. this.scope.exit();
  11512. this.prodParam.exit();
  11513. return this.finishNode(mod, "TSModuleDeclaration");
  11514. }
  11515. break;
  11516. default:
  11517. return this.tsParseDeclaration(node, expr.name, false, decorators);
  11518. }
  11519. }
  11520. tsParseDeclaration(node, value, next, decorators) {
  11521. switch (value) {
  11522. case "abstract":
  11523. if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
  11524. return this.tsParseAbstractDeclaration(node, decorators);
  11525. }
  11526. break;
  11527. case "module":
  11528. if (this.tsCheckLineTerminator(next)) {
  11529. if (this.match(134)) {
  11530. return this.tsParseAmbientExternalModuleDeclaration(node);
  11531. } else if (tokenIsIdentifier(this.state.type)) {
  11532. node.kind = "module";
  11533. return this.tsParseModuleOrNamespaceDeclaration(node);
  11534. }
  11535. }
  11536. break;
  11537. case "namespace":
  11538. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11539. node.kind = "namespace";
  11540. return this.tsParseModuleOrNamespaceDeclaration(node);
  11541. }
  11542. break;
  11543. case "type":
  11544. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11545. return this.tsParseTypeAliasDeclaration(node);
  11546. }
  11547. break;
  11548. }
  11549. }
  11550. tsCheckLineTerminator(next) {
  11551. if (next) {
  11552. if (this.hasFollowingLineBreak()) return false;
  11553. this.next();
  11554. return true;
  11555. }
  11556. return !this.isLineTerminator();
  11557. }
  11558. tsTryParseGenericAsyncArrowFunction(startLoc) {
  11559. if (!this.match(47)) return;
  11560. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  11561. this.state.maybeInArrowParameters = true;
  11562. const res = this.tsTryParseAndCatch(() => {
  11563. const node = this.startNodeAt(startLoc);
  11564. node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11565. super.parseFunctionParams(node);
  11566. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  11567. this.expect(19);
  11568. return node;
  11569. });
  11570. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  11571. if (!res) return;
  11572. return super.parseArrowExpression(res, null, true);
  11573. }
  11574. tsParseTypeArgumentsInExpression() {
  11575. if (this.reScan_lt() !== 47) return;
  11576. return this.tsParseTypeArguments();
  11577. }
  11578. tsParseTypeArguments() {
  11579. const node = this.startNode();
  11580. node.params = this.tsInType(() => this.tsInTopLevelContext(() => {
  11581. this.expect(47);
  11582. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  11583. }));
  11584. if (node.params.length === 0) {
  11585. this.raise(TSErrors.EmptyTypeArguments, node);
  11586. } else if (!this.state.inType && this.curContext() === types.brace) {
  11587. this.reScan_lt_gt();
  11588. }
  11589. this.expect(48);
  11590. return this.finishNode(node, "TSTypeParameterInstantiation");
  11591. }
  11592. tsIsDeclarationStart() {
  11593. return tokenIsTSDeclarationStart(this.state.type);
  11594. }
  11595. isExportDefaultSpecifier() {
  11596. if (this.tsIsDeclarationStart()) return false;
  11597. return super.isExportDefaultSpecifier();
  11598. }
  11599. parseBindingElement(flags, decorators) {
  11600. const startLoc = decorators.length ? decorators[0].loc.start : this.state.startLoc;
  11601. const modified = {};
  11602. this.tsParseModifiers({
  11603. allowedModifiers: ["public", "private", "protected", "override", "readonly"]
  11604. }, modified);
  11605. const accessibility = modified.accessibility;
  11606. const override = modified.override;
  11607. const readonly = modified.readonly;
  11608. if (!(flags & 4) && (accessibility || readonly || override)) {
  11609. this.raise(TSErrors.UnexpectedParameterModifier, startLoc);
  11610. }
  11611. const left = this.parseMaybeDefault();
  11612. if (flags & 2) {
  11613. this.parseFunctionParamType(left);
  11614. }
  11615. const elt = this.parseMaybeDefault(left.loc.start, left);
  11616. if (accessibility || readonly || override) {
  11617. const pp = this.startNodeAt(startLoc);
  11618. if (decorators.length) {
  11619. pp.decorators = decorators;
  11620. }
  11621. if (accessibility) pp.accessibility = accessibility;
  11622. if (readonly) pp.readonly = readonly;
  11623. if (override) pp.override = override;
  11624. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  11625. this.raise(TSErrors.UnsupportedParameterPropertyKind, pp);
  11626. }
  11627. pp.parameter = elt;
  11628. return this.finishNode(pp, "TSParameterProperty");
  11629. }
  11630. if (decorators.length) {
  11631. left.decorators = decorators;
  11632. }
  11633. return elt;
  11634. }
  11635. isSimpleParameter(node) {
  11636. return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node);
  11637. }
  11638. tsDisallowOptionalPattern(node) {
  11639. for (const param of node.params) {
  11640. if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) {
  11641. this.raise(TSErrors.PatternIsOptional, param);
  11642. }
  11643. }
  11644. }
  11645. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  11646. super.setArrowFunctionParameters(node, params, trailingCommaLoc);
  11647. this.tsDisallowOptionalPattern(node);
  11648. }
  11649. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  11650. if (this.match(14)) {
  11651. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11652. }
  11653. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined;
  11654. if (bodilessType && !this.match(5) && this.isLineTerminator()) {
  11655. return this.finishNode(node, bodilessType);
  11656. }
  11657. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  11658. this.raise(TSErrors.DeclareFunctionHasImplementation, node);
  11659. if (node.declare) {
  11660. return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  11661. }
  11662. }
  11663. this.tsDisallowOptionalPattern(node);
  11664. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  11665. }
  11666. registerFunctionStatementId(node) {
  11667. if (!node.body && node.id) {
  11668. this.checkIdentifier(node.id, 1024);
  11669. } else {
  11670. super.registerFunctionStatementId(node);
  11671. }
  11672. }
  11673. tsCheckForInvalidTypeCasts(items) {
  11674. items.forEach(node => {
  11675. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  11676. this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation);
  11677. }
  11678. });
  11679. }
  11680. toReferencedList(exprList, isInParens) {
  11681. this.tsCheckForInvalidTypeCasts(exprList);
  11682. return exprList;
  11683. }
  11684. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  11685. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  11686. if (node.type === "ArrayExpression") {
  11687. this.tsCheckForInvalidTypeCasts(node.elements);
  11688. }
  11689. return node;
  11690. }
  11691. parseSubscript(base, startLoc, noCalls, state) {
  11692. if (!this.hasPrecedingLineBreak() && this.match(35)) {
  11693. this.state.canStartJSXElement = false;
  11694. this.next();
  11695. const nonNullExpression = this.startNodeAt(startLoc);
  11696. nonNullExpression.expression = base;
  11697. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  11698. }
  11699. let isOptionalCall = false;
  11700. if (this.match(18) && this.lookaheadCharCode() === 60) {
  11701. if (noCalls) {
  11702. state.stop = true;
  11703. return base;
  11704. }
  11705. state.optionalChainMember = isOptionalCall = true;
  11706. this.next();
  11707. }
  11708. if (this.match(47) || this.match(51)) {
  11709. let missingParenErrorLoc;
  11710. const result = this.tsTryParseAndCatch(() => {
  11711. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  11712. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
  11713. if (asyncArrowFn) {
  11714. state.stop = true;
  11715. return asyncArrowFn;
  11716. }
  11717. }
  11718. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11719. if (!typeArguments) return;
  11720. if (isOptionalCall && !this.match(10)) {
  11721. missingParenErrorLoc = this.state.curPosition();
  11722. return;
  11723. }
  11724. if (tokenIsTemplate(this.state.type)) {
  11725. const result = super.parseTaggedTemplateExpression(base, startLoc, state);
  11726. {
  11727. result.typeParameters = typeArguments;
  11728. }
  11729. return result;
  11730. }
  11731. if (!noCalls && this.eat(10)) {
  11732. const node = this.startNodeAt(startLoc);
  11733. node.callee = base;
  11734. node.arguments = this.parseCallExpressionArguments();
  11735. this.tsCheckForInvalidTypeCasts(node.arguments);
  11736. {
  11737. node.typeParameters = typeArguments;
  11738. }
  11739. if (state.optionalChainMember) {
  11740. node.optional = isOptionalCall;
  11741. }
  11742. return this.finishCallExpression(node, state.optionalChainMember);
  11743. }
  11744. const tokenType = this.state.type;
  11745. if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
  11746. return;
  11747. }
  11748. const node = this.startNodeAt(startLoc);
  11749. node.expression = base;
  11750. {
  11751. node.typeParameters = typeArguments;
  11752. }
  11753. return this.finishNode(node, "TSInstantiationExpression");
  11754. });
  11755. if (missingParenErrorLoc) {
  11756. this.unexpected(missingParenErrorLoc, 10);
  11757. }
  11758. if (result) {
  11759. if (result.type === "TSInstantiationExpression") {
  11760. if (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40) {
  11761. this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc);
  11762. }
  11763. if (!this.match(16) && !this.match(18)) {
  11764. result.expression = super.stopParseSubscript(base, state);
  11765. }
  11766. }
  11767. return result;
  11768. }
  11769. }
  11770. return super.parseSubscript(base, startLoc, noCalls, state);
  11771. }
  11772. parseNewCallee(node) {
  11773. var _callee$extra;
  11774. super.parseNewCallee(node);
  11775. const {
  11776. callee
  11777. } = node;
  11778. if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
  11779. {
  11780. node.typeParameters = callee.typeParameters;
  11781. }
  11782. node.callee = callee.expression;
  11783. }
  11784. }
  11785. parseExprOp(left, leftStartLoc, minPrec) {
  11786. let isSatisfies;
  11787. if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) {
  11788. const node = this.startNodeAt(leftStartLoc);
  11789. node.expression = left;
  11790. node.typeAnnotation = this.tsInType(() => {
  11791. this.next();
  11792. if (this.match(75)) {
  11793. if (isSatisfies) {
  11794. this.raise(Errors.UnexpectedKeyword, this.state.startLoc, {
  11795. keyword: "const"
  11796. });
  11797. }
  11798. return this.tsParseTypeReference();
  11799. }
  11800. return this.tsParseType();
  11801. });
  11802. this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression");
  11803. this.reScan_lt_gt();
  11804. return this.parseExprOp(node, leftStartLoc, minPrec);
  11805. }
  11806. return super.parseExprOp(left, leftStartLoc, minPrec);
  11807. }
  11808. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  11809. if (!this.state.isAmbientContext) {
  11810. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  11811. }
  11812. }
  11813. checkImportReflection(node) {
  11814. super.checkImportReflection(node);
  11815. if (node.module && node.importKind !== "value") {
  11816. this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  11817. }
  11818. }
  11819. checkDuplicateExports() {}
  11820. isPotentialImportPhase(isExport) {
  11821. if (super.isPotentialImportPhase(isExport)) return true;
  11822. if (this.isContextual(130)) {
  11823. const ch = this.lookaheadCharCode();
  11824. return isExport ? ch === 123 || ch === 42 : ch !== 61;
  11825. }
  11826. return !isExport && this.isContextual(87);
  11827. }
  11828. applyImportPhase(node, isExport, phase, loc) {
  11829. super.applyImportPhase(node, isExport, phase, loc);
  11830. if (isExport) {
  11831. node.exportKind = phase === "type" ? "type" : "value";
  11832. } else {
  11833. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  11834. }
  11835. }
  11836. parseImport(node) {
  11837. if (this.match(134)) {
  11838. node.importKind = "value";
  11839. return super.parseImport(node);
  11840. }
  11841. let importNode;
  11842. if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) {
  11843. node.importKind = "value";
  11844. return this.tsParseImportEqualsDeclaration(node);
  11845. } else if (this.isContextual(130)) {
  11846. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11847. if (this.lookaheadCharCode() === 61) {
  11848. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier);
  11849. } else {
  11850. importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier);
  11851. }
  11852. } else {
  11853. importNode = super.parseImport(node);
  11854. }
  11855. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  11856. this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode);
  11857. }
  11858. return importNode;
  11859. }
  11860. parseExport(node, decorators) {
  11861. if (this.match(83)) {
  11862. const nodeImportEquals = node;
  11863. this.next();
  11864. let maybeDefaultIdentifier = null;
  11865. if (this.isContextual(130) && this.isPotentialImportPhase(false)) {
  11866. maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false);
  11867. } else {
  11868. nodeImportEquals.importKind = "value";
  11869. }
  11870. const declaration = this.tsParseImportEqualsDeclaration(nodeImportEquals, maybeDefaultIdentifier, true);
  11871. {
  11872. return declaration;
  11873. }
  11874. } else if (this.eat(29)) {
  11875. const assign = node;
  11876. assign.expression = super.parseExpression();
  11877. this.semicolon();
  11878. this.sawUnambiguousESM = true;
  11879. return this.finishNode(assign, "TSExportAssignment");
  11880. } else if (this.eatContextual(93)) {
  11881. const decl = node;
  11882. this.expectContextual(128);
  11883. decl.id = this.parseIdentifier();
  11884. this.semicolon();
  11885. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  11886. } else {
  11887. return super.parseExport(node, decorators);
  11888. }
  11889. }
  11890. isAbstractClass() {
  11891. return this.isContextual(124) && this.isLookaheadContextual("class");
  11892. }
  11893. parseExportDefaultExpression() {
  11894. if (this.isAbstractClass()) {
  11895. const cls = this.startNode();
  11896. this.next();
  11897. cls.abstract = true;
  11898. return this.parseClass(cls, true, true);
  11899. }
  11900. if (this.match(129)) {
  11901. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11902. if (result) return result;
  11903. }
  11904. return super.parseExportDefaultExpression();
  11905. }
  11906. parseVarStatement(node, kind, allowMissingInitializer = false) {
  11907. const {
  11908. isAmbientContext
  11909. } = this.state;
  11910. const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
  11911. if (!isAmbientContext) return declaration;
  11912. if (!node.declare && (kind === "using" || kind === "await using")) {
  11913. this.raiseOverwrite(TSErrors.UsingDeclarationInAmbientContext, node, kind);
  11914. return declaration;
  11915. }
  11916. for (const {
  11917. id,
  11918. init
  11919. } of declaration.declarations) {
  11920. if (!init) continue;
  11921. if (kind === "var" || kind === "let" || !!id.typeAnnotation) {
  11922. this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init);
  11923. } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) {
  11924. this.raise(TSErrors.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference, init);
  11925. }
  11926. }
  11927. return declaration;
  11928. }
  11929. parseStatementContent(flags, decorators) {
  11930. if (this.match(75) && this.isLookaheadContextual("enum")) {
  11931. const node = this.startNode();
  11932. this.expect(75);
  11933. return this.tsParseEnumDeclaration(node, {
  11934. const: true
  11935. });
  11936. }
  11937. if (this.isContextual(126)) {
  11938. return this.tsParseEnumDeclaration(this.startNode());
  11939. }
  11940. if (this.isContextual(129)) {
  11941. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11942. if (result) return result;
  11943. }
  11944. return super.parseStatementContent(flags, decorators);
  11945. }
  11946. parseAccessModifier() {
  11947. return this.tsParseModifier(["public", "protected", "private"]);
  11948. }
  11949. tsHasSomeModifiers(member, modifiers) {
  11950. return modifiers.some(modifier => {
  11951. if (tsIsAccessModifier(modifier)) {
  11952. return member.accessibility === modifier;
  11953. }
  11954. return !!member[modifier];
  11955. });
  11956. }
  11957. tsIsStartOfStaticBlocks() {
  11958. return this.isContextual(106) && this.lookaheadCharCode() === 123;
  11959. }
  11960. parseClassMember(classBody, member, state) {
  11961. const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"];
  11962. this.tsParseModifiers({
  11963. allowedModifiers: modifiers,
  11964. disallowedModifiers: ["in", "out"],
  11965. stopOnStartOfClassStaticBlock: true,
  11966. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  11967. }, member);
  11968. const callParseClassMemberWithIsStatic = () => {
  11969. if (this.tsIsStartOfStaticBlocks()) {
  11970. this.next();
  11971. this.next();
  11972. if (this.tsHasSomeModifiers(member, modifiers)) {
  11973. this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition());
  11974. }
  11975. super.parseClassStaticBlock(classBody, member);
  11976. } else {
  11977. this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static);
  11978. }
  11979. };
  11980. if (member.declare) {
  11981. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  11982. } else {
  11983. callParseClassMemberWithIsStatic();
  11984. }
  11985. }
  11986. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  11987. const idx = this.tsTryParseIndexSignature(member);
  11988. if (idx) {
  11989. classBody.body.push(idx);
  11990. if (member.abstract) {
  11991. this.raise(TSErrors.IndexSignatureHasAbstract, member);
  11992. }
  11993. if (member.accessibility) {
  11994. this.raise(TSErrors.IndexSignatureHasAccessibility, member, {
  11995. modifier: member.accessibility
  11996. });
  11997. }
  11998. if (member.declare) {
  11999. this.raise(TSErrors.IndexSignatureHasDeclare, member);
  12000. }
  12001. if (member.override) {
  12002. this.raise(TSErrors.IndexSignatureHasOverride, member);
  12003. }
  12004. return;
  12005. }
  12006. if (!this.state.inAbstractClass && member.abstract) {
  12007. this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member);
  12008. }
  12009. if (member.override) {
  12010. if (!state.hadSuperClass) {
  12011. this.raise(TSErrors.OverrideNotInSubClass, member);
  12012. }
  12013. }
  12014. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  12015. }
  12016. parsePostMemberNameModifiers(methodOrProp) {
  12017. const optional = this.eat(17);
  12018. if (optional) methodOrProp.optional = true;
  12019. if (methodOrProp.readonly && this.match(10)) {
  12020. this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp);
  12021. }
  12022. if (methodOrProp.declare && this.match(10)) {
  12023. this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
  12024. }
  12025. }
  12026. parseExpressionStatement(node, expr, decorators) {
  12027. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined;
  12028. return decl || super.parseExpressionStatement(node, expr, decorators);
  12029. }
  12030. shouldParseExportDeclaration() {
  12031. if (this.tsIsDeclarationStart()) return true;
  12032. return super.shouldParseExportDeclaration();
  12033. }
  12034. parseConditional(expr, startLoc, refExpressionErrors) {
  12035. if (!this.match(17)) return expr;
  12036. if (this.state.maybeInArrowParameters) {
  12037. const nextCh = this.lookaheadCharCode();
  12038. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  12039. this.setOptionalParametersError(refExpressionErrors);
  12040. return expr;
  12041. }
  12042. }
  12043. return super.parseConditional(expr, startLoc, refExpressionErrors);
  12044. }
  12045. parseParenItem(node, startLoc) {
  12046. const newNode = super.parseParenItem(node, startLoc);
  12047. if (this.eat(17)) {
  12048. newNode.optional = true;
  12049. this.resetEndLocation(node);
  12050. }
  12051. if (this.match(14)) {
  12052. const typeCastNode = this.startNodeAt(startLoc);
  12053. typeCastNode.expression = node;
  12054. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  12055. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  12056. }
  12057. return node;
  12058. }
  12059. parseExportDeclaration(node) {
  12060. if (!this.state.isAmbientContext && this.isContextual(125)) {
  12061. return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
  12062. }
  12063. const startLoc = this.state.startLoc;
  12064. const isDeclare = this.eatContextual(125);
  12065. if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) {
  12066. throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
  12067. }
  12068. const isIdentifier = tokenIsIdentifier(this.state.type);
  12069. const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
  12070. if (!declaration) return null;
  12071. if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) {
  12072. node.exportKind = "type";
  12073. }
  12074. if (isDeclare && declaration.type !== "TSImportEqualsDeclaration") {
  12075. this.resetStartLocation(declaration, startLoc);
  12076. declaration.declare = true;
  12077. }
  12078. return declaration;
  12079. }
  12080. parseClassId(node, isStatement, optionalId, bindingType) {
  12081. if ((!isStatement || optionalId) && this.isContextual(113)) {
  12082. return;
  12083. }
  12084. super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331);
  12085. const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  12086. if (typeParameters) node.typeParameters = typeParameters;
  12087. }
  12088. parseClassPropertyAnnotation(node) {
  12089. if (!node.optional) {
  12090. if (this.eat(35)) {
  12091. node.definite = true;
  12092. } else if (this.eat(17)) {
  12093. node.optional = true;
  12094. }
  12095. }
  12096. const type = this.tsTryParseTypeAnnotation();
  12097. if (type) node.typeAnnotation = type;
  12098. }
  12099. parseClassProperty(node) {
  12100. this.parseClassPropertyAnnotation(node);
  12101. if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) {
  12102. this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc);
  12103. }
  12104. if (node.abstract && this.match(29)) {
  12105. const {
  12106. key
  12107. } = node;
  12108. this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, {
  12109. propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(this.offsetToSourcePos(key.start), this.offsetToSourcePos(key.end))}]`
  12110. });
  12111. }
  12112. return super.parseClassProperty(node);
  12113. }
  12114. parseClassPrivateProperty(node) {
  12115. if (node.abstract) {
  12116. this.raise(TSErrors.PrivateElementHasAbstract, node);
  12117. }
  12118. if (node.accessibility) {
  12119. this.raise(TSErrors.PrivateElementHasAccessibility, node, {
  12120. modifier: node.accessibility
  12121. });
  12122. }
  12123. this.parseClassPropertyAnnotation(node);
  12124. return super.parseClassPrivateProperty(node);
  12125. }
  12126. parseClassAccessorProperty(node) {
  12127. this.parseClassPropertyAnnotation(node);
  12128. if (node.optional) {
  12129. this.raise(TSErrors.AccessorCannotBeOptional, node);
  12130. }
  12131. return super.parseClassAccessorProperty(node);
  12132. }
  12133. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  12134. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  12135. if (typeParameters && isConstructor) {
  12136. this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters);
  12137. }
  12138. const {
  12139. declare = false,
  12140. kind
  12141. } = method;
  12142. if (declare && (kind === "get" || kind === "set")) {
  12143. this.raise(TSErrors.DeclareAccessor, method, {
  12144. kind
  12145. });
  12146. }
  12147. if (typeParameters) method.typeParameters = typeParameters;
  12148. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  12149. }
  12150. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  12151. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  12152. if (typeParameters) method.typeParameters = typeParameters;
  12153. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  12154. }
  12155. declareClassPrivateMethodInScope(node, kind) {
  12156. if (node.type === "TSDeclareMethod") return;
  12157. if (node.type === "MethodDefinition" && node.value.body == null) {
  12158. return;
  12159. }
  12160. super.declareClassPrivateMethodInScope(node, kind);
  12161. }
  12162. parseClassSuper(node) {
  12163. super.parseClassSuper(node);
  12164. if (node.superClass && (this.match(47) || this.match(51))) {
  12165. {
  12166. node.superTypeParameters = this.tsParseTypeArgumentsInExpression();
  12167. }
  12168. }
  12169. if (this.eatContextual(113)) {
  12170. node.implements = this.tsParseHeritageClause("implements");
  12171. }
  12172. }
  12173. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  12174. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  12175. if (typeParameters) prop.typeParameters = typeParameters;
  12176. return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  12177. }
  12178. parseFunctionParams(node, isConstructor) {
  12179. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  12180. if (typeParameters) node.typeParameters = typeParameters;
  12181. super.parseFunctionParams(node, isConstructor);
  12182. }
  12183. parseVarId(decl, kind) {
  12184. super.parseVarId(decl, kind);
  12185. if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
  12186. decl.definite = true;
  12187. }
  12188. const type = this.tsTryParseTypeAnnotation();
  12189. if (type) {
  12190. decl.id.typeAnnotation = type;
  12191. this.resetEndLocation(decl.id);
  12192. }
  12193. }
  12194. parseAsyncArrowFromCallExpression(node, call) {
  12195. if (this.match(14)) {
  12196. node.returnType = this.tsParseTypeAnnotation();
  12197. }
  12198. return super.parseAsyncArrowFromCallExpression(node, call);
  12199. }
  12200. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  12201. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
  12202. let state;
  12203. let jsx;
  12204. let typeCast;
  12205. if (this.hasPlugin("jsx") && (this.match(143) || this.match(47))) {
  12206. state = this.state.clone();
  12207. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  12208. if (!jsx.error) return jsx.node;
  12209. const {
  12210. context
  12211. } = this.state;
  12212. const currentContext = context[context.length - 1];
  12213. if (currentContext === types.j_oTag || currentContext === types.j_expr) {
  12214. context.pop();
  12215. }
  12216. }
  12217. if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) {
  12218. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  12219. }
  12220. if (!state || state === this.state) state = this.state.clone();
  12221. let typeParameters;
  12222. const arrow = this.tryParse(abort => {
  12223. var _expr$extra, _typeParameters;
  12224. typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  12225. const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  12226. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12227. abort();
  12228. }
  12229. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  12230. this.resetStartLocationFromNode(expr, typeParameters);
  12231. }
  12232. expr.typeParameters = typeParameters;
  12233. return expr;
  12234. }, state);
  12235. if (!arrow.error && !arrow.aborted) {
  12236. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  12237. return arrow.node;
  12238. }
  12239. if (!jsx) {
  12240. assert(!this.hasPlugin("jsx"));
  12241. typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  12242. if (!typeCast.error) return typeCast.node;
  12243. }
  12244. if ((_jsx2 = jsx) != null && _jsx2.node) {
  12245. this.state = jsx.failState;
  12246. return jsx.node;
  12247. }
  12248. if (arrow.node) {
  12249. this.state = arrow.failState;
  12250. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  12251. return arrow.node;
  12252. }
  12253. if ((_typeCast = typeCast) != null && _typeCast.node) {
  12254. this.state = typeCast.failState;
  12255. return typeCast.node;
  12256. }
  12257. throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
  12258. }
  12259. reportReservedArrowTypeParam(node) {
  12260. var _node$extra2;
  12261. if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra2 = node.extra) != null && _node$extra2.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  12262. this.raise(TSErrors.ReservedArrowTypeParam, node);
  12263. }
  12264. }
  12265. parseMaybeUnary(refExpressionErrors, sawUnary) {
  12266. if (!this.hasPlugin("jsx") && this.match(47)) {
  12267. return this.tsParseTypeAssertion();
  12268. }
  12269. return super.parseMaybeUnary(refExpressionErrors, sawUnary);
  12270. }
  12271. parseArrow(node) {
  12272. if (this.match(14)) {
  12273. const result = this.tryParse(abort => {
  12274. const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  12275. if (this.canInsertSemicolon() || !this.match(19)) abort();
  12276. return returnType;
  12277. });
  12278. if (result.aborted) return;
  12279. if (!result.thrown) {
  12280. if (result.error) this.state = result.failState;
  12281. node.returnType = result.node;
  12282. }
  12283. }
  12284. return super.parseArrow(node);
  12285. }
  12286. parseFunctionParamType(param) {
  12287. if (this.eat(17)) {
  12288. param.optional = true;
  12289. }
  12290. const type = this.tsTryParseTypeAnnotation();
  12291. if (type) param.typeAnnotation = type;
  12292. this.resetEndLocation(param);
  12293. return param;
  12294. }
  12295. isAssignable(node, isBinding) {
  12296. switch (node.type) {
  12297. case "TSTypeCastExpression":
  12298. return this.isAssignable(node.expression, isBinding);
  12299. case "TSParameterProperty":
  12300. return true;
  12301. default:
  12302. return super.isAssignable(node, isBinding);
  12303. }
  12304. }
  12305. toAssignable(node, isLHS = false) {
  12306. switch (node.type) {
  12307. case "ParenthesizedExpression":
  12308. this.toAssignableParenthesizedExpression(node, isLHS);
  12309. break;
  12310. case "TSAsExpression":
  12311. case "TSSatisfiesExpression":
  12312. case "TSNonNullExpression":
  12313. case "TSTypeAssertion":
  12314. if (isLHS) {
  12315. this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
  12316. } else {
  12317. this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
  12318. }
  12319. this.toAssignable(node.expression, isLHS);
  12320. break;
  12321. case "AssignmentExpression":
  12322. if (!isLHS && node.left.type === "TSTypeCastExpression") {
  12323. node.left = this.typeCastToParameter(node.left);
  12324. }
  12325. default:
  12326. super.toAssignable(node, isLHS);
  12327. }
  12328. }
  12329. toAssignableParenthesizedExpression(node, isLHS) {
  12330. switch (node.expression.type) {
  12331. case "TSAsExpression":
  12332. case "TSSatisfiesExpression":
  12333. case "TSNonNullExpression":
  12334. case "TSTypeAssertion":
  12335. case "ParenthesizedExpression":
  12336. this.toAssignable(node.expression, isLHS);
  12337. break;
  12338. default:
  12339. super.toAssignable(node, isLHS);
  12340. }
  12341. }
  12342. checkToRestConversion(node, allowPattern) {
  12343. switch (node.type) {
  12344. case "TSAsExpression":
  12345. case "TSSatisfiesExpression":
  12346. case "TSTypeAssertion":
  12347. case "TSNonNullExpression":
  12348. this.checkToRestConversion(node.expression, false);
  12349. break;
  12350. default:
  12351. super.checkToRestConversion(node, allowPattern);
  12352. }
  12353. }
  12354. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  12355. switch (type) {
  12356. case "TSTypeCastExpression":
  12357. return true;
  12358. case "TSParameterProperty":
  12359. return "parameter";
  12360. case "TSNonNullExpression":
  12361. return "expression";
  12362. case "TSAsExpression":
  12363. case "TSSatisfiesExpression":
  12364. case "TSTypeAssertion":
  12365. return (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true];
  12366. default:
  12367. return super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  12368. }
  12369. }
  12370. parseBindingAtom() {
  12371. if (this.state.type === 78) {
  12372. return this.parseIdentifier(true);
  12373. }
  12374. return super.parseBindingAtom();
  12375. }
  12376. parseMaybeDecoratorArguments(expr, startLoc) {
  12377. if (this.match(47) || this.match(51)) {
  12378. const typeArguments = this.tsParseTypeArgumentsInExpression();
  12379. if (this.match(10)) {
  12380. const call = super.parseMaybeDecoratorArguments(expr, startLoc);
  12381. {
  12382. call.typeParameters = typeArguments;
  12383. }
  12384. return call;
  12385. }
  12386. this.unexpected(null, 10);
  12387. }
  12388. return super.parseMaybeDecoratorArguments(expr, startLoc);
  12389. }
  12390. checkCommaAfterRest(close) {
  12391. if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
  12392. this.next();
  12393. return false;
  12394. }
  12395. return super.checkCommaAfterRest(close);
  12396. }
  12397. isClassMethod() {
  12398. return this.match(47) || super.isClassMethod();
  12399. }
  12400. isClassProperty() {
  12401. return this.match(35) || this.match(14) || super.isClassProperty();
  12402. }
  12403. parseMaybeDefault(startLoc, left) {
  12404. const node = super.parseMaybeDefault(startLoc, left);
  12405. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  12406. this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation);
  12407. }
  12408. return node;
  12409. }
  12410. getTokenFromCode(code) {
  12411. if (this.state.inType) {
  12412. if (code === 62) {
  12413. this.finishOp(48, 1);
  12414. return;
  12415. }
  12416. if (code === 60) {
  12417. this.finishOp(47, 1);
  12418. return;
  12419. }
  12420. }
  12421. super.getTokenFromCode(code);
  12422. }
  12423. reScan_lt_gt() {
  12424. const {
  12425. type
  12426. } = this.state;
  12427. if (type === 47) {
  12428. this.state.pos -= 1;
  12429. this.readToken_lt();
  12430. } else if (type === 48) {
  12431. this.state.pos -= 1;
  12432. this.readToken_gt();
  12433. }
  12434. }
  12435. reScan_lt() {
  12436. const {
  12437. type
  12438. } = this.state;
  12439. if (type === 51) {
  12440. this.state.pos -= 2;
  12441. this.finishOp(47, 1);
  12442. return 47;
  12443. }
  12444. return type;
  12445. }
  12446. toAssignableListItem(exprList, index, isLHS) {
  12447. const node = exprList[index];
  12448. if (node.type === "TSTypeCastExpression") {
  12449. exprList[index] = this.typeCastToParameter(node);
  12450. }
  12451. super.toAssignableListItem(exprList, index, isLHS);
  12452. }
  12453. typeCastToParameter(node) {
  12454. node.expression.typeAnnotation = node.typeAnnotation;
  12455. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  12456. return node.expression;
  12457. }
  12458. shouldParseArrow(params) {
  12459. if (this.match(14)) {
  12460. return params.every(expr => this.isAssignable(expr, true));
  12461. }
  12462. return super.shouldParseArrow(params);
  12463. }
  12464. shouldParseAsyncArrow() {
  12465. return this.match(14) || super.shouldParseAsyncArrow();
  12466. }
  12467. canHaveLeadingDecorator() {
  12468. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  12469. }
  12470. jsxParseOpeningElementAfterName(node) {
  12471. if (this.match(47) || this.match(51)) {
  12472. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression());
  12473. if (typeArguments) {
  12474. {
  12475. node.typeParameters = typeArguments;
  12476. }
  12477. }
  12478. }
  12479. return super.jsxParseOpeningElementAfterName(node);
  12480. }
  12481. getGetterSetterExpectedParamCount(method) {
  12482. const baseCount = super.getGetterSetterExpectedParamCount(method);
  12483. const params = this.getObjectOrClassMethodParams(method);
  12484. const firstParam = params[0];
  12485. const hasContextParam = firstParam && this.isThisParam(firstParam);
  12486. return hasContextParam ? baseCount + 1 : baseCount;
  12487. }
  12488. parseCatchClauseParam() {
  12489. const param = super.parseCatchClauseParam();
  12490. const type = this.tsTryParseTypeAnnotation();
  12491. if (type) {
  12492. param.typeAnnotation = type;
  12493. this.resetEndLocation(param);
  12494. }
  12495. return param;
  12496. }
  12497. tsInAmbientContext(cb) {
  12498. const {
  12499. isAmbientContext: oldIsAmbientContext,
  12500. strict: oldStrict
  12501. } = this.state;
  12502. this.state.isAmbientContext = true;
  12503. this.state.strict = false;
  12504. try {
  12505. return cb();
  12506. } finally {
  12507. this.state.isAmbientContext = oldIsAmbientContext;
  12508. this.state.strict = oldStrict;
  12509. }
  12510. }
  12511. parseClass(node, isStatement, optionalId) {
  12512. const oldInAbstractClass = this.state.inAbstractClass;
  12513. this.state.inAbstractClass = !!node.abstract;
  12514. try {
  12515. return super.parseClass(node, isStatement, optionalId);
  12516. } finally {
  12517. this.state.inAbstractClass = oldInAbstractClass;
  12518. }
  12519. }
  12520. tsParseAbstractDeclaration(node, decorators) {
  12521. if (this.match(80)) {
  12522. node.abstract = true;
  12523. return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
  12524. } else if (this.isContextual(129)) {
  12525. if (!this.hasFollowingLineBreak()) {
  12526. node.abstract = true;
  12527. this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifier, node);
  12528. return this.tsParseInterfaceDeclaration(node);
  12529. }
  12530. } else {
  12531. this.unexpected(null, 80);
  12532. }
  12533. }
  12534. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) {
  12535. const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  12536. if (method.abstract || method.type === "TSAbstractMethodDefinition") {
  12537. const hasEstreePlugin = this.hasPlugin("estree");
  12538. const methodFn = hasEstreePlugin ? method.value : method;
  12539. if (methodFn.body) {
  12540. const {
  12541. key
  12542. } = method;
  12543. this.raise(TSErrors.AbstractMethodHasImplementation, method, {
  12544. methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(this.offsetToSourcePos(key.start), this.offsetToSourcePos(key.end))}]`
  12545. });
  12546. }
  12547. }
  12548. return method;
  12549. }
  12550. tsParseTypeParameterName() {
  12551. const typeName = this.parseIdentifier();
  12552. return typeName.name;
  12553. }
  12554. shouldParseAsAmbientContext() {
  12555. return !!this.getPluginOption("typescript", "dts");
  12556. }
  12557. parse() {
  12558. if (this.shouldParseAsAmbientContext()) {
  12559. this.state.isAmbientContext = true;
  12560. }
  12561. return super.parse();
  12562. }
  12563. getExpression() {
  12564. if (this.shouldParseAsAmbientContext()) {
  12565. this.state.isAmbientContext = true;
  12566. }
  12567. return super.getExpression();
  12568. }
  12569. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  12570. if (!isString && isMaybeTypeOnly) {
  12571. this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport);
  12572. return this.finishNode(node, "ExportSpecifier");
  12573. }
  12574. node.exportKind = "value";
  12575. return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
  12576. }
  12577. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  12578. if (!importedIsString && isMaybeTypeOnly) {
  12579. this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport);
  12580. return this.finishNode(specifier, "ImportSpecifier");
  12581. }
  12582. specifier.importKind = "value";
  12583. return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096);
  12584. }
  12585. parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) {
  12586. const leftOfAsKey = isImport ? "imported" : "local";
  12587. const rightOfAsKey = isImport ? "local" : "exported";
  12588. let leftOfAs = node[leftOfAsKey];
  12589. let rightOfAs;
  12590. let hasTypeSpecifier = false;
  12591. let canParseAsKeyword = true;
  12592. const loc = leftOfAs.loc.start;
  12593. if (this.isContextual(93)) {
  12594. const firstAs = this.parseIdentifier();
  12595. if (this.isContextual(93)) {
  12596. const secondAs = this.parseIdentifier();
  12597. if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12598. hasTypeSpecifier = true;
  12599. leftOfAs = firstAs;
  12600. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12601. canParseAsKeyword = false;
  12602. } else {
  12603. rightOfAs = secondAs;
  12604. canParseAsKeyword = false;
  12605. }
  12606. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12607. canParseAsKeyword = false;
  12608. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12609. } else {
  12610. hasTypeSpecifier = true;
  12611. leftOfAs = firstAs;
  12612. }
  12613. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12614. hasTypeSpecifier = true;
  12615. if (isImport) {
  12616. leftOfAs = this.parseIdentifier(true);
  12617. if (!this.isContextual(93)) {
  12618. this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
  12619. }
  12620. } else {
  12621. leftOfAs = this.parseModuleExportName();
  12622. }
  12623. }
  12624. if (hasTypeSpecifier && isInTypeOnlyImportExport) {
  12625. this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc);
  12626. }
  12627. node[leftOfAsKey] = leftOfAs;
  12628. node[rightOfAsKey] = rightOfAs;
  12629. const kindKey = isImport ? "importKind" : "exportKind";
  12630. node[kindKey] = hasTypeSpecifier ? "type" : "value";
  12631. if (canParseAsKeyword && this.eatContextual(93)) {
  12632. node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12633. }
  12634. if (!node[rightOfAsKey]) {
  12635. node[rightOfAsKey] = this.cloneIdentifier(node[leftOfAsKey]);
  12636. }
  12637. if (isImport) {
  12638. this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
  12639. }
  12640. }
  12641. fillOptionalPropertiesForTSESLint(node) {
  12642. var _node$directive, _node$decorators, _node$optional, _node$typeAnnotation, _node$accessibility, _node$decorators2, _node$override, _node$readonly, _node$static, _node$declare, _node$returnType, _node$typeParameters, _node$optional2, _node$optional3, _node$accessibility2, _node$readonly2, _node$static2, _node$declare2, _node$definite, _node$readonly3, _node$typeAnnotation2, _node$accessibility3, _node$decorators3, _node$override2, _node$optional4, _node$id, _node$abstract, _node$declare3, _node$decorators4, _node$implements, _node$superTypeArgume, _node$typeParameters2, _node$declare4, _node$definite2, _node$const, _node$declare5, _node$computed, _node$qualifier, _node$options, _node$declare6, _node$extends, _node$optional5, _node$readonly4, _node$declare7, _node$global, _node$const2, _node$in, _node$out;
  12643. switch (node.type) {
  12644. case "ExpressionStatement":
  12645. (_node$directive = node.directive) != null ? _node$directive : node.directive = undefined;
  12646. return;
  12647. case "RestElement":
  12648. node.value = undefined;
  12649. case "Identifier":
  12650. case "ArrayPattern":
  12651. case "AssignmentPattern":
  12652. case "ObjectPattern":
  12653. (_node$decorators = node.decorators) != null ? _node$decorators : node.decorators = [];
  12654. (_node$optional = node.optional) != null ? _node$optional : node.optional = false;
  12655. (_node$typeAnnotation = node.typeAnnotation) != null ? _node$typeAnnotation : node.typeAnnotation = undefined;
  12656. return;
  12657. case "TSParameterProperty":
  12658. (_node$accessibility = node.accessibility) != null ? _node$accessibility : node.accessibility = undefined;
  12659. (_node$decorators2 = node.decorators) != null ? _node$decorators2 : node.decorators = [];
  12660. (_node$override = node.override) != null ? _node$override : node.override = false;
  12661. (_node$readonly = node.readonly) != null ? _node$readonly : node.readonly = false;
  12662. (_node$static = node.static) != null ? _node$static : node.static = false;
  12663. return;
  12664. case "TSEmptyBodyFunctionExpression":
  12665. node.body = null;
  12666. case "TSDeclareFunction":
  12667. case "FunctionDeclaration":
  12668. case "FunctionExpression":
  12669. case "ClassMethod":
  12670. case "ClassPrivateMethod":
  12671. (_node$declare = node.declare) != null ? _node$declare : node.declare = false;
  12672. (_node$returnType = node.returnType) != null ? _node$returnType : node.returnType = undefined;
  12673. (_node$typeParameters = node.typeParameters) != null ? _node$typeParameters : node.typeParameters = undefined;
  12674. return;
  12675. case "Property":
  12676. (_node$optional2 = node.optional) != null ? _node$optional2 : node.optional = false;
  12677. return;
  12678. case "TSMethodSignature":
  12679. case "TSPropertySignature":
  12680. (_node$optional3 = node.optional) != null ? _node$optional3 : node.optional = false;
  12681. case "TSIndexSignature":
  12682. (_node$accessibility2 = node.accessibility) != null ? _node$accessibility2 : node.accessibility = undefined;
  12683. (_node$readonly2 = node.readonly) != null ? _node$readonly2 : node.readonly = false;
  12684. (_node$static2 = node.static) != null ? _node$static2 : node.static = false;
  12685. return;
  12686. case "TSAbstractPropertyDefinition":
  12687. case "PropertyDefinition":
  12688. case "TSAbstractAccessorProperty":
  12689. case "AccessorProperty":
  12690. (_node$declare2 = node.declare) != null ? _node$declare2 : node.declare = false;
  12691. (_node$definite = node.definite) != null ? _node$definite : node.definite = false;
  12692. (_node$readonly3 = node.readonly) != null ? _node$readonly3 : node.readonly = false;
  12693. (_node$typeAnnotation2 = node.typeAnnotation) != null ? _node$typeAnnotation2 : node.typeAnnotation = undefined;
  12694. case "TSAbstractMethodDefinition":
  12695. case "MethodDefinition":
  12696. (_node$accessibility3 = node.accessibility) != null ? _node$accessibility3 : node.accessibility = undefined;
  12697. (_node$decorators3 = node.decorators) != null ? _node$decorators3 : node.decorators = [];
  12698. (_node$override2 = node.override) != null ? _node$override2 : node.override = false;
  12699. (_node$optional4 = node.optional) != null ? _node$optional4 : node.optional = false;
  12700. return;
  12701. case "ClassExpression":
  12702. (_node$id = node.id) != null ? _node$id : node.id = null;
  12703. case "ClassDeclaration":
  12704. (_node$abstract = node.abstract) != null ? _node$abstract : node.abstract = false;
  12705. (_node$declare3 = node.declare) != null ? _node$declare3 : node.declare = false;
  12706. (_node$decorators4 = node.decorators) != null ? _node$decorators4 : node.decorators = [];
  12707. (_node$implements = node.implements) != null ? _node$implements : node.implements = [];
  12708. (_node$superTypeArgume = node.superTypeArguments) != null ? _node$superTypeArgume : node.superTypeArguments = undefined;
  12709. (_node$typeParameters2 = node.typeParameters) != null ? _node$typeParameters2 : node.typeParameters = undefined;
  12710. return;
  12711. case "TSTypeAliasDeclaration":
  12712. case "VariableDeclaration":
  12713. (_node$declare4 = node.declare) != null ? _node$declare4 : node.declare = false;
  12714. return;
  12715. case "VariableDeclarator":
  12716. (_node$definite2 = node.definite) != null ? _node$definite2 : node.definite = false;
  12717. return;
  12718. case "TSEnumDeclaration":
  12719. (_node$const = node.const) != null ? _node$const : node.const = false;
  12720. (_node$declare5 = node.declare) != null ? _node$declare5 : node.declare = false;
  12721. return;
  12722. case "TSEnumMember":
  12723. (_node$computed = node.computed) != null ? _node$computed : node.computed = false;
  12724. return;
  12725. case "TSImportType":
  12726. (_node$qualifier = node.qualifier) != null ? _node$qualifier : node.qualifier = null;
  12727. (_node$options = node.options) != null ? _node$options : node.options = null;
  12728. return;
  12729. case "TSInterfaceDeclaration":
  12730. (_node$declare6 = node.declare) != null ? _node$declare6 : node.declare = false;
  12731. (_node$extends = node.extends) != null ? _node$extends : node.extends = [];
  12732. return;
  12733. case "TSMappedType":
  12734. (_node$optional5 = node.optional) != null ? _node$optional5 : node.optional = false;
  12735. (_node$readonly4 = node.readonly) != null ? _node$readonly4 : node.readonly = undefined;
  12736. return;
  12737. case "TSModuleDeclaration":
  12738. (_node$declare7 = node.declare) != null ? _node$declare7 : node.declare = false;
  12739. (_node$global = node.global) != null ? _node$global : node.global = node.kind === "global";
  12740. return;
  12741. case "TSTypeParameter":
  12742. (_node$const2 = node.const) != null ? _node$const2 : node.const = false;
  12743. (_node$in = node.in) != null ? _node$in : node.in = false;
  12744. (_node$out = node.out) != null ? _node$out : node.out = false;
  12745. return;
  12746. }
  12747. }
  12748. };
  12749. function isPossiblyLiteralEnum(expression) {
  12750. if (expression.type !== "MemberExpression") return false;
  12751. const {
  12752. computed,
  12753. property
  12754. } = expression;
  12755. if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) {
  12756. return false;
  12757. }
  12758. return isUncomputedMemberExpressionChain(expression.object);
  12759. }
  12760. function isValidAmbientConstInitializer(expression, estree) {
  12761. var _expression$extra;
  12762. const {
  12763. type
  12764. } = expression;
  12765. if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) {
  12766. return false;
  12767. }
  12768. if (estree) {
  12769. if (type === "Literal") {
  12770. const {
  12771. value
  12772. } = expression;
  12773. if (typeof value === "string" || typeof value === "boolean") {
  12774. return true;
  12775. }
  12776. }
  12777. } else {
  12778. if (type === "StringLiteral" || type === "BooleanLiteral") {
  12779. return true;
  12780. }
  12781. }
  12782. if (isNumber(expression, estree) || isNegativeNumber(expression, estree)) {
  12783. return true;
  12784. }
  12785. if (type === "TemplateLiteral" && expression.expressions.length === 0) {
  12786. return true;
  12787. }
  12788. if (isPossiblyLiteralEnum(expression)) {
  12789. return true;
  12790. }
  12791. return false;
  12792. }
  12793. function isNumber(expression, estree) {
  12794. if (estree) {
  12795. return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression);
  12796. }
  12797. return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral";
  12798. }
  12799. function isNegativeNumber(expression, estree) {
  12800. if (expression.type === "UnaryExpression") {
  12801. const {
  12802. operator,
  12803. argument
  12804. } = expression;
  12805. if (operator === "-" && isNumber(argument, estree)) {
  12806. return true;
  12807. }
  12808. }
  12809. return false;
  12810. }
  12811. function isUncomputedMemberExpressionChain(expression) {
  12812. if (expression.type === "Identifier") return true;
  12813. if (expression.type !== "MemberExpression" || expression.computed) {
  12814. return false;
  12815. }
  12816. return isUncomputedMemberExpressionChain(expression.object);
  12817. }
  12818. const PlaceholderErrors = ParseErrorEnum`placeholders`({
  12819. ClassNameIsRequired: "A class name is required.",
  12820. UnexpectedSpace: "Unexpected space in placeholder."
  12821. });
  12822. var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
  12823. parsePlaceholder(expectedNode) {
  12824. if (this.match(133)) {
  12825. const node = this.startNode();
  12826. this.next();
  12827. this.assertNoSpace();
  12828. node.name = super.parseIdentifier(true);
  12829. this.assertNoSpace();
  12830. this.expect(133);
  12831. return this.finishPlaceholder(node, expectedNode);
  12832. }
  12833. }
  12834. finishPlaceholder(node, expectedNode) {
  12835. let placeholder = node;
  12836. if (!placeholder.expectedNode || !placeholder.type) {
  12837. placeholder = this.finishNode(placeholder, "Placeholder");
  12838. }
  12839. placeholder.expectedNode = expectedNode;
  12840. return placeholder;
  12841. }
  12842. getTokenFromCode(code) {
  12843. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  12844. this.finishOp(133, 2);
  12845. } else {
  12846. super.getTokenFromCode(code);
  12847. }
  12848. }
  12849. parseExprAtom(refExpressionErrors) {
  12850. return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors);
  12851. }
  12852. parseIdentifier(liberal) {
  12853. return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal);
  12854. }
  12855. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  12856. if (word !== undefined) {
  12857. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  12858. }
  12859. }
  12860. cloneIdentifier(node) {
  12861. const cloned = super.cloneIdentifier(node);
  12862. if (cloned.type === "Placeholder") {
  12863. cloned.expectedNode = node.expectedNode;
  12864. }
  12865. return cloned;
  12866. }
  12867. cloneStringLiteral(node) {
  12868. if (node.type === "Placeholder") {
  12869. return this.cloneIdentifier(node);
  12870. }
  12871. return super.cloneStringLiteral(node);
  12872. }
  12873. parseBindingAtom() {
  12874. return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
  12875. }
  12876. isValidLVal(type, isParenthesized, binding) {
  12877. return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding);
  12878. }
  12879. toAssignable(node, isLHS) {
  12880. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  12881. node.expectedNode = "Pattern";
  12882. } else {
  12883. super.toAssignable(node, isLHS);
  12884. }
  12885. }
  12886. chStartsBindingIdentifier(ch, pos) {
  12887. if (super.chStartsBindingIdentifier(ch, pos)) {
  12888. return true;
  12889. }
  12890. const next = this.nextTokenStart();
  12891. if (this.input.charCodeAt(next) === 37 && this.input.charCodeAt(next + 1) === 37) {
  12892. return true;
  12893. }
  12894. return false;
  12895. }
  12896. verifyBreakContinue(node, isBreak) {
  12897. if (node.label && node.label.type === "Placeholder") return;
  12898. super.verifyBreakContinue(node, isBreak);
  12899. }
  12900. parseExpressionStatement(node, expr) {
  12901. var _expr$extra;
  12902. if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12903. return super.parseExpressionStatement(node, expr);
  12904. }
  12905. if (this.match(14)) {
  12906. const stmt = node;
  12907. stmt.label = this.finishPlaceholder(expr, "Identifier");
  12908. this.next();
  12909. stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration();
  12910. return this.finishNode(stmt, "LabeledStatement");
  12911. }
  12912. this.semicolon();
  12913. const stmtPlaceholder = node;
  12914. stmtPlaceholder.name = expr.name;
  12915. return this.finishPlaceholder(stmtPlaceholder, "Statement");
  12916. }
  12917. parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) {
  12918. return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse);
  12919. }
  12920. parseFunctionId(requireId) {
  12921. return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId);
  12922. }
  12923. parseClass(node, isStatement, optionalId) {
  12924. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  12925. this.next();
  12926. const oldStrict = this.state.strict;
  12927. const placeholder = this.parsePlaceholder("Identifier");
  12928. if (placeholder) {
  12929. if (this.match(81) || this.match(133) || this.match(5)) {
  12930. node.id = placeholder;
  12931. } else if (optionalId || !isStatement) {
  12932. node.id = null;
  12933. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  12934. return this.finishNode(node, type);
  12935. } else {
  12936. throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc);
  12937. }
  12938. } else {
  12939. this.parseClassId(node, isStatement, optionalId);
  12940. }
  12941. super.parseClassSuper(node);
  12942. node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict);
  12943. return this.finishNode(node, type);
  12944. }
  12945. parseExport(node, decorators) {
  12946. const placeholder = this.parsePlaceholder("Identifier");
  12947. if (!placeholder) return super.parseExport(node, decorators);
  12948. const node2 = node;
  12949. if (!this.isContextual(98) && !this.match(12)) {
  12950. node2.specifiers = [];
  12951. node2.source = null;
  12952. node2.declaration = this.finishPlaceholder(placeholder, "Declaration");
  12953. return this.finishNode(node2, "ExportNamedDeclaration");
  12954. }
  12955. this.expectPlugin("exportDefaultFrom");
  12956. const specifier = this.startNode();
  12957. specifier.exported = placeholder;
  12958. node2.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  12959. return super.parseExport(node2, decorators);
  12960. }
  12961. isExportDefaultSpecifier() {
  12962. if (this.match(65)) {
  12963. const next = this.nextTokenStart();
  12964. if (this.isUnparsedContextual(next, "from")) {
  12965. if (this.input.startsWith(tokenLabelName(133), this.nextTokenStartSince(next + 4))) {
  12966. return true;
  12967. }
  12968. }
  12969. }
  12970. return super.isExportDefaultSpecifier();
  12971. }
  12972. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  12973. var _specifiers;
  12974. if ((_specifiers = node.specifiers) != null && _specifiers.length) {
  12975. return true;
  12976. }
  12977. return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  12978. }
  12979. checkExport(node) {
  12980. const {
  12981. specifiers
  12982. } = node;
  12983. if (specifiers != null && specifiers.length) {
  12984. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  12985. }
  12986. super.checkExport(node);
  12987. node.specifiers = specifiers;
  12988. }
  12989. parseImport(node) {
  12990. const placeholder = this.parsePlaceholder("Identifier");
  12991. if (!placeholder) return super.parseImport(node);
  12992. node.specifiers = [];
  12993. if (!this.isContextual(98) && !this.match(12)) {
  12994. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  12995. this.semicolon();
  12996. return this.finishNode(node, "ImportDeclaration");
  12997. }
  12998. const specifier = this.startNodeAtNode(placeholder);
  12999. specifier.local = placeholder;
  13000. node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
  13001. if (this.eat(12)) {
  13002. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  13003. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  13004. }
  13005. this.expectContextual(98);
  13006. node.source = this.parseImportSource();
  13007. this.semicolon();
  13008. return this.finishNode(node, "ImportDeclaration");
  13009. }
  13010. parseImportSource() {
  13011. return this.parsePlaceholder("StringLiteral") || super.parseImportSource();
  13012. }
  13013. assertNoSpace() {
  13014. if (this.state.start > this.offsetToSourcePos(this.state.lastTokEndLoc.index)) {
  13015. this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc);
  13016. }
  13017. }
  13018. };
  13019. var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
  13020. parseV8Intrinsic() {
  13021. if (this.match(54)) {
  13022. const v8IntrinsicStartLoc = this.state.startLoc;
  13023. const node = this.startNode();
  13024. this.next();
  13025. if (tokenIsIdentifier(this.state.type)) {
  13026. const name = this.parseIdentifierName();
  13027. const identifier = this.createIdentifier(node, name);
  13028. this.castNodeTo(identifier, "V8IntrinsicIdentifier");
  13029. if (this.match(10)) {
  13030. return identifier;
  13031. }
  13032. }
  13033. this.unexpected(v8IntrinsicStartLoc);
  13034. }
  13035. }
  13036. parseExprAtom(refExpressionErrors) {
  13037. return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
  13038. }
  13039. };
  13040. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  13041. const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
  13042. function validatePlugins(pluginsMap) {
  13043. if (pluginsMap.has("decorators")) {
  13044. if (pluginsMap.has("decorators-legacy")) {
  13045. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  13046. }
  13047. const decoratorsBeforeExport = pluginsMap.get("decorators").decoratorsBeforeExport;
  13048. if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
  13049. throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");
  13050. }
  13051. const allowCallParenthesized = pluginsMap.get("decorators").allowCallParenthesized;
  13052. if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
  13053. throw new Error("'allowCallParenthesized' must be a boolean.");
  13054. }
  13055. }
  13056. if (pluginsMap.has("flow") && pluginsMap.has("typescript")) {
  13057. throw new Error("Cannot combine flow and typescript plugins.");
  13058. }
  13059. if (pluginsMap.has("placeholders") && pluginsMap.has("v8intrinsic")) {
  13060. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  13061. }
  13062. if (pluginsMap.has("pipelineOperator")) {
  13063. var _pluginsMap$get2;
  13064. const proposal = pluginsMap.get("pipelineOperator").proposal;
  13065. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  13066. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  13067. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  13068. }
  13069. if (proposal === "hack") {
  13070. if (pluginsMap.has("placeholders")) {
  13071. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  13072. }
  13073. if (pluginsMap.has("v8intrinsic")) {
  13074. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  13075. }
  13076. const topicToken = pluginsMap.get("pipelineOperator").topicToken;
  13077. if (!TOPIC_TOKENS.includes(topicToken)) {
  13078. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  13079. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  13080. }
  13081. {
  13082. var _pluginsMap$get;
  13083. if (topicToken === "#" && ((_pluginsMap$get = pluginsMap.get("recordAndTuple")) == null ? void 0 : _pluginsMap$get.syntaxType) === "hash") {
  13084. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "hack", topicToken: "#" }]\` and \`${JSON.stringify(["recordAndTuple", pluginsMap.get("recordAndTuple")])}\`.`);
  13085. }
  13086. }
  13087. } else if (proposal === "smart" && ((_pluginsMap$get2 = pluginsMap.get("recordAndTuple")) == null ? void 0 : _pluginsMap$get2.syntaxType) === "hash") {
  13088. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "smart" }]\` and \`${JSON.stringify(["recordAndTuple", pluginsMap.get("recordAndTuple")])}\`.`);
  13089. }
  13090. }
  13091. if (pluginsMap.has("moduleAttributes")) {
  13092. {
  13093. if (pluginsMap.has("deprecatedImportAssert") || pluginsMap.has("importAssertions")) {
  13094. throw new Error("Cannot combine importAssertions, deprecatedImportAssert and moduleAttributes plugins.");
  13095. }
  13096. const moduleAttributesVersionPluginOption = pluginsMap.get("moduleAttributes").version;
  13097. if (moduleAttributesVersionPluginOption !== "may-2020") {
  13098. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  13099. }
  13100. }
  13101. }
  13102. if (pluginsMap.has("importAssertions")) {
  13103. if (pluginsMap.has("deprecatedImportAssert")) {
  13104. throw new Error("Cannot combine importAssertions and deprecatedImportAssert plugins.");
  13105. }
  13106. }
  13107. if (!pluginsMap.has("deprecatedImportAssert") && pluginsMap.has("importAttributes") && pluginsMap.get("importAttributes").deprecatedAssertSyntax) {
  13108. {
  13109. pluginsMap.set("deprecatedImportAssert", {});
  13110. }
  13111. }
  13112. if (pluginsMap.has("recordAndTuple")) {
  13113. {
  13114. const syntaxType = pluginsMap.get("recordAndTuple").syntaxType;
  13115. if (syntaxType != null) {
  13116. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  13117. if (!RECORD_AND_TUPLE_SYNTAX_TYPES.includes(syntaxType)) {
  13118. throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  13119. }
  13120. }
  13121. }
  13122. }
  13123. if (pluginsMap.has("asyncDoExpressions") && !pluginsMap.has("doExpressions")) {
  13124. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  13125. error.missingPlugins = "doExpressions";
  13126. throw error;
  13127. }
  13128. if (pluginsMap.has("optionalChainingAssign") && pluginsMap.get("optionalChainingAssign").version !== "2023-07") {
  13129. throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'.");
  13130. }
  13131. if (pluginsMap.has("discardBinding") && pluginsMap.get("discardBinding").syntaxType !== "void") {
  13132. throw new Error("The 'discardBinding' plugin requires a 'syntaxType' option. Currently the only supported value is 'void'.");
  13133. }
  13134. }
  13135. const mixinPlugins = {
  13136. estree,
  13137. jsx,
  13138. flow,
  13139. typescript,
  13140. v8intrinsic,
  13141. placeholders
  13142. };
  13143. const mixinPluginNames = Object.keys(mixinPlugins);
  13144. class ExpressionParser extends LValParser {
  13145. checkProto(prop, isRecord, sawProto, refExpressionErrors) {
  13146. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  13147. return sawProto;
  13148. }
  13149. const key = prop.key;
  13150. const name = key.type === "Identifier" ? key.name : key.value;
  13151. if (name === "__proto__") {
  13152. if (isRecord) {
  13153. this.raise(Errors.RecordNoProto, key);
  13154. return true;
  13155. }
  13156. if (sawProto) {
  13157. if (refExpressionErrors) {
  13158. if (refExpressionErrors.doubleProtoLoc === null) {
  13159. refExpressionErrors.doubleProtoLoc = key.loc.start;
  13160. }
  13161. } else {
  13162. this.raise(Errors.DuplicateProto, key);
  13163. }
  13164. }
  13165. return true;
  13166. }
  13167. return sawProto;
  13168. }
  13169. shouldExitDescending(expr, potentialArrowAt) {
  13170. return expr.type === "ArrowFunctionExpression" && this.offsetToSourcePos(expr.start) === potentialArrowAt;
  13171. }
  13172. getExpression() {
  13173. this.enterInitialScopes();
  13174. this.nextToken();
  13175. if (this.match(140)) {
  13176. throw this.raise(Errors.ParseExpressionEmptyInput, this.state.startLoc);
  13177. }
  13178. const expr = this.parseExpression();
  13179. if (!this.match(140)) {
  13180. throw this.raise(Errors.ParseExpressionExpectsEOF, this.state.startLoc, {
  13181. unexpected: this.input.codePointAt(this.state.start)
  13182. });
  13183. }
  13184. this.finalizeRemainingComments();
  13185. expr.comments = this.comments;
  13186. expr.errors = this.state.errors;
  13187. if (this.optionFlags & 256) {
  13188. expr.tokens = this.tokens;
  13189. }
  13190. return expr;
  13191. }
  13192. parseExpression(disallowIn, refExpressionErrors) {
  13193. if (disallowIn) {
  13194. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  13195. }
  13196. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  13197. }
  13198. parseExpressionBase(refExpressionErrors) {
  13199. const startLoc = this.state.startLoc;
  13200. const expr = this.parseMaybeAssign(refExpressionErrors);
  13201. if (this.match(12)) {
  13202. const node = this.startNodeAt(startLoc);
  13203. node.expressions = [expr];
  13204. while (this.eat(12)) {
  13205. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  13206. }
  13207. this.toReferencedList(node.expressions);
  13208. return this.finishNode(node, "SequenceExpression");
  13209. }
  13210. return expr;
  13211. }
  13212. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  13213. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  13214. }
  13215. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  13216. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  13217. }
  13218. setOptionalParametersError(refExpressionErrors) {
  13219. refExpressionErrors.optionalParametersLoc = this.state.startLoc;
  13220. }
  13221. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  13222. const startLoc = this.state.startLoc;
  13223. const isYield = this.isContextual(108);
  13224. if (isYield) {
  13225. if (this.prodParam.hasYield) {
  13226. this.next();
  13227. let left = this.parseYield(startLoc);
  13228. if (afterLeftParse) {
  13229. left = afterLeftParse.call(this, left, startLoc);
  13230. }
  13231. return left;
  13232. }
  13233. }
  13234. let ownExpressionErrors;
  13235. if (refExpressionErrors) {
  13236. ownExpressionErrors = false;
  13237. } else {
  13238. refExpressionErrors = new ExpressionErrors();
  13239. ownExpressionErrors = true;
  13240. }
  13241. const {
  13242. type
  13243. } = this.state;
  13244. if (type === 10 || tokenIsIdentifier(type)) {
  13245. this.state.potentialArrowAt = this.state.start;
  13246. }
  13247. let left = this.parseMaybeConditional(refExpressionErrors);
  13248. if (afterLeftParse) {
  13249. left = afterLeftParse.call(this, left, startLoc);
  13250. }
  13251. if (tokenIsAssignment(this.state.type)) {
  13252. const node = this.startNodeAt(startLoc);
  13253. const operator = this.state.value;
  13254. node.operator = operator;
  13255. if (this.match(29)) {
  13256. this.toAssignable(left, true);
  13257. node.left = left;
  13258. const startIndex = startLoc.index;
  13259. if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
  13260. refExpressionErrors.doubleProtoLoc = null;
  13261. }
  13262. if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
  13263. refExpressionErrors.shorthandAssignLoc = null;
  13264. }
  13265. if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
  13266. this.checkDestructuringPrivate(refExpressionErrors);
  13267. refExpressionErrors.privateKeyLoc = null;
  13268. }
  13269. if (refExpressionErrors.voidPatternLoc != null && refExpressionErrors.voidPatternLoc.index >= startIndex) {
  13270. refExpressionErrors.voidPatternLoc = null;
  13271. }
  13272. } else {
  13273. node.left = left;
  13274. }
  13275. this.next();
  13276. node.right = this.parseMaybeAssign();
  13277. this.checkLVal(left, this.finishNode(node, "AssignmentExpression"));
  13278. return node;
  13279. } else if (ownExpressionErrors) {
  13280. this.checkExpressionErrors(refExpressionErrors, true);
  13281. }
  13282. if (isYield) {
  13283. const {
  13284. type
  13285. } = this.state;
  13286. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  13287. if (startsExpr && !this.isAmbiguousPrefixOrIdentifier()) {
  13288. this.raiseOverwrite(Errors.YieldNotInGeneratorFunction, startLoc);
  13289. return this.parseYield(startLoc);
  13290. }
  13291. }
  13292. return left;
  13293. }
  13294. parseMaybeConditional(refExpressionErrors) {
  13295. const startLoc = this.state.startLoc;
  13296. const potentialArrowAt = this.state.potentialArrowAt;
  13297. const expr = this.parseExprOps(refExpressionErrors);
  13298. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  13299. return expr;
  13300. }
  13301. return this.parseConditional(expr, startLoc, refExpressionErrors);
  13302. }
  13303. parseConditional(expr, startLoc, refExpressionErrors) {
  13304. if (this.eat(17)) {
  13305. const node = this.startNodeAt(startLoc);
  13306. node.test = expr;
  13307. node.consequent = this.parseMaybeAssignAllowIn();
  13308. this.expect(14);
  13309. node.alternate = this.parseMaybeAssign();
  13310. return this.finishNode(node, "ConditionalExpression");
  13311. }
  13312. return expr;
  13313. }
  13314. parseMaybeUnaryOrPrivate(refExpressionErrors) {
  13315. return this.match(139) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
  13316. }
  13317. parseExprOps(refExpressionErrors) {
  13318. const startLoc = this.state.startLoc;
  13319. const potentialArrowAt = this.state.potentialArrowAt;
  13320. const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
  13321. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  13322. return expr;
  13323. }
  13324. return this.parseExprOp(expr, startLoc, -1);
  13325. }
  13326. parseExprOp(left, leftStartLoc, minPrec) {
  13327. if (this.isPrivateName(left)) {
  13328. const value = this.getPrivateNameSV(left);
  13329. if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) {
  13330. this.raise(Errors.PrivateInExpectedIn, left, {
  13331. identifierName: value
  13332. });
  13333. }
  13334. this.classScope.usePrivateName(value, left.loc.start);
  13335. }
  13336. const op = this.state.type;
  13337. if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) {
  13338. let prec = tokenOperatorPrecedence(op);
  13339. if (prec > minPrec) {
  13340. if (op === 39) {
  13341. this.expectPlugin("pipelineOperator");
  13342. if (this.state.inFSharpPipelineDirectBody) {
  13343. return left;
  13344. }
  13345. this.checkPipelineAtInfixOperator(left, leftStartLoc);
  13346. }
  13347. const node = this.startNodeAt(leftStartLoc);
  13348. node.left = left;
  13349. node.operator = this.state.value;
  13350. const logical = op === 41 || op === 42;
  13351. const coalesce = op === 40;
  13352. if (coalesce) {
  13353. prec = tokenOperatorPrecedence(42);
  13354. }
  13355. this.next();
  13356. if (op === 39 && this.hasPlugin(["pipelineOperator", {
  13357. proposal: "minimal"
  13358. }])) {
  13359. if (this.state.type === 96 && this.prodParam.hasAwait) {
  13360. throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
  13361. }
  13362. }
  13363. node.right = this.parseExprOpRightExpr(op, prec);
  13364. const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  13365. const nextOp = this.state.type;
  13366. if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) {
  13367. throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
  13368. }
  13369. return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
  13370. }
  13371. }
  13372. return left;
  13373. }
  13374. parseExprOpRightExpr(op, prec) {
  13375. const startLoc = this.state.startLoc;
  13376. switch (op) {
  13377. case 39:
  13378. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  13379. case "hack":
  13380. return this.withTopicBindingContext(() => {
  13381. return this.parseHackPipeBody();
  13382. });
  13383. case "fsharp":
  13384. return this.withSoloAwaitPermittingContext(() => {
  13385. return this.parseFSharpPipelineBody(prec);
  13386. });
  13387. }
  13388. if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
  13389. return this.withTopicBindingContext(() => {
  13390. if (this.prodParam.hasYield && this.isContextual(108)) {
  13391. throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
  13392. }
  13393. return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
  13394. });
  13395. }
  13396. default:
  13397. return this.parseExprOpBaseRightExpr(op, prec);
  13398. }
  13399. }
  13400. parseExprOpBaseRightExpr(op, prec) {
  13401. const startLoc = this.state.startLoc;
  13402. return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
  13403. }
  13404. parseHackPipeBody() {
  13405. var _body$extra;
  13406. const {
  13407. startLoc
  13408. } = this.state;
  13409. const body = this.parseMaybeAssign();
  13410. const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
  13411. if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
  13412. this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
  13413. type: body.type
  13414. });
  13415. }
  13416. if (!this.topicReferenceWasUsedInCurrentContext()) {
  13417. this.raise(Errors.PipeTopicUnused, startLoc);
  13418. }
  13419. return body;
  13420. }
  13421. checkExponentialAfterUnary(node) {
  13422. if (this.match(57)) {
  13423. this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
  13424. }
  13425. }
  13426. parseMaybeUnary(refExpressionErrors, sawUnary) {
  13427. const startLoc = this.state.startLoc;
  13428. const isAwait = this.isContextual(96);
  13429. if (isAwait && this.recordAwaitIfAllowed()) {
  13430. this.next();
  13431. const expr = this.parseAwait(startLoc);
  13432. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  13433. return expr;
  13434. }
  13435. const update = this.match(34);
  13436. const node = this.startNode();
  13437. if (tokenIsPrefix(this.state.type)) {
  13438. node.operator = this.state.value;
  13439. node.prefix = true;
  13440. if (this.match(72)) {
  13441. this.expectPlugin("throwExpressions");
  13442. }
  13443. const isDelete = this.match(89);
  13444. this.next();
  13445. node.argument = this.parseMaybeUnary(null, true);
  13446. this.checkExpressionErrors(refExpressionErrors, true);
  13447. if (this.state.strict && isDelete) {
  13448. const arg = node.argument;
  13449. if (arg.type === "Identifier") {
  13450. this.raise(Errors.StrictDelete, node);
  13451. } else if (this.hasPropertyAsPrivateName(arg)) {
  13452. this.raise(Errors.DeletePrivateField, node);
  13453. }
  13454. }
  13455. if (!update) {
  13456. if (!sawUnary) {
  13457. this.checkExponentialAfterUnary(node);
  13458. }
  13459. return this.finishNode(node, "UnaryExpression");
  13460. }
  13461. }
  13462. const expr = this.parseUpdate(node, update, refExpressionErrors);
  13463. if (isAwait) {
  13464. const {
  13465. type
  13466. } = this.state;
  13467. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  13468. if (startsExpr && !this.isAmbiguousPrefixOrIdentifier()) {
  13469. this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
  13470. return this.parseAwait(startLoc);
  13471. }
  13472. }
  13473. return expr;
  13474. }
  13475. parseUpdate(node, update, refExpressionErrors) {
  13476. if (update) {
  13477. const updateExpressionNode = node;
  13478. this.checkLVal(updateExpressionNode.argument, this.finishNode(updateExpressionNode, "UpdateExpression"));
  13479. return node;
  13480. }
  13481. const startLoc = this.state.startLoc;
  13482. let expr = this.parseExprSubscripts(refExpressionErrors);
  13483. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  13484. while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
  13485. const node = this.startNodeAt(startLoc);
  13486. node.operator = this.state.value;
  13487. node.prefix = false;
  13488. node.argument = expr;
  13489. this.next();
  13490. this.checkLVal(expr, expr = this.finishNode(node, "UpdateExpression"));
  13491. }
  13492. return expr;
  13493. }
  13494. parseExprSubscripts(refExpressionErrors) {
  13495. const startLoc = this.state.startLoc;
  13496. const potentialArrowAt = this.state.potentialArrowAt;
  13497. const expr = this.parseExprAtom(refExpressionErrors);
  13498. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  13499. return expr;
  13500. }
  13501. return this.parseSubscripts(expr, startLoc);
  13502. }
  13503. parseSubscripts(base, startLoc, noCalls) {
  13504. const state = {
  13505. optionalChainMember: false,
  13506. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  13507. stop: false
  13508. };
  13509. do {
  13510. base = this.parseSubscript(base, startLoc, noCalls, state);
  13511. state.maybeAsyncArrow = false;
  13512. } while (!state.stop);
  13513. return base;
  13514. }
  13515. parseSubscript(base, startLoc, noCalls, state) {
  13516. const {
  13517. type
  13518. } = this.state;
  13519. if (!noCalls && type === 15) {
  13520. return this.parseBind(base, startLoc, noCalls, state);
  13521. } else if (tokenIsTemplate(type)) {
  13522. return this.parseTaggedTemplateExpression(base, startLoc, state);
  13523. }
  13524. let optional = false;
  13525. if (type === 18) {
  13526. if (noCalls) {
  13527. this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
  13528. if (this.lookaheadCharCode() === 40) {
  13529. return this.stopParseSubscript(base, state);
  13530. }
  13531. }
  13532. state.optionalChainMember = optional = true;
  13533. this.next();
  13534. }
  13535. if (!noCalls && this.match(10)) {
  13536. return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
  13537. } else {
  13538. const computed = this.eat(0);
  13539. if (computed || optional || this.eat(16)) {
  13540. return this.parseMember(base, startLoc, state, computed, optional);
  13541. } else {
  13542. return this.stopParseSubscript(base, state);
  13543. }
  13544. }
  13545. }
  13546. stopParseSubscript(base, state) {
  13547. state.stop = true;
  13548. return base;
  13549. }
  13550. parseMember(base, startLoc, state, computed, optional) {
  13551. const node = this.startNodeAt(startLoc);
  13552. node.object = base;
  13553. node.computed = computed;
  13554. if (computed) {
  13555. node.property = this.parseExpression();
  13556. this.expect(3);
  13557. } else if (this.match(139)) {
  13558. if (base.type === "Super") {
  13559. this.raise(Errors.SuperPrivateField, startLoc);
  13560. }
  13561. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  13562. node.property = this.parsePrivateName();
  13563. } else {
  13564. node.property = this.parseIdentifier(true);
  13565. }
  13566. if (state.optionalChainMember) {
  13567. node.optional = optional;
  13568. return this.finishNode(node, "OptionalMemberExpression");
  13569. } else {
  13570. return this.finishNode(node, "MemberExpression");
  13571. }
  13572. }
  13573. parseBind(base, startLoc, noCalls, state) {
  13574. const node = this.startNodeAt(startLoc);
  13575. node.object = base;
  13576. this.next();
  13577. node.callee = this.parseNoCallExpr();
  13578. state.stop = true;
  13579. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls);
  13580. }
  13581. parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
  13582. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13583. let refExpressionErrors = null;
  13584. this.state.maybeInArrowParameters = true;
  13585. this.next();
  13586. const node = this.startNodeAt(startLoc);
  13587. node.callee = base;
  13588. const {
  13589. maybeAsyncArrow,
  13590. optionalChainMember
  13591. } = state;
  13592. if (maybeAsyncArrow) {
  13593. this.expressionScope.enter(newAsyncArrowScope());
  13594. refExpressionErrors = new ExpressionErrors();
  13595. }
  13596. if (optionalChainMember) {
  13597. node.optional = optional;
  13598. }
  13599. if (optional) {
  13600. node.arguments = this.parseCallExpressionArguments();
  13601. } else {
  13602. node.arguments = this.parseCallExpressionArguments(base.type !== "Super", node, refExpressionErrors);
  13603. }
  13604. let finishedNode = this.finishCallExpression(node, optionalChainMember);
  13605. if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  13606. state.stop = true;
  13607. this.checkDestructuringPrivate(refExpressionErrors);
  13608. this.expressionScope.validateAsPattern();
  13609. this.expressionScope.exit();
  13610. finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
  13611. } else {
  13612. if (maybeAsyncArrow) {
  13613. this.checkExpressionErrors(refExpressionErrors, true);
  13614. this.expressionScope.exit();
  13615. }
  13616. this.toReferencedArguments(finishedNode);
  13617. }
  13618. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13619. return finishedNode;
  13620. }
  13621. toReferencedArguments(node, isParenthesizedExpr) {
  13622. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  13623. }
  13624. parseTaggedTemplateExpression(base, startLoc, state) {
  13625. const node = this.startNodeAt(startLoc);
  13626. node.tag = base;
  13627. node.quasi = this.parseTemplate(true);
  13628. if (state.optionalChainMember) {
  13629. this.raise(Errors.OptionalChainingNoTemplate, startLoc);
  13630. }
  13631. return this.finishNode(node, "TaggedTemplateExpression");
  13632. }
  13633. atPossibleAsyncArrow(base) {
  13634. return base.type === "Identifier" && base.name === "async" && this.state.lastTokEndLoc.index === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && this.offsetToSourcePos(base.start) === this.state.potentialArrowAt;
  13635. }
  13636. finishCallExpression(node, optional) {
  13637. if (node.callee.type === "Import") {
  13638. if (node.arguments.length === 0 || node.arguments.length > 2) {
  13639. this.raise(Errors.ImportCallArity, node);
  13640. } else {
  13641. for (const arg of node.arguments) {
  13642. if (arg.type === "SpreadElement") {
  13643. this.raise(Errors.ImportCallSpreadArgument, arg);
  13644. }
  13645. }
  13646. }
  13647. }
  13648. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  13649. }
  13650. parseCallExpressionArguments(allowPlaceholder, nodeForExtra, refExpressionErrors) {
  13651. const elts = [];
  13652. let first = true;
  13653. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13654. this.state.inFSharpPipelineDirectBody = false;
  13655. while (!this.eat(11)) {
  13656. if (first) {
  13657. first = false;
  13658. } else {
  13659. this.expect(12);
  13660. if (this.match(11)) {
  13661. if (nodeForExtra) {
  13662. this.addTrailingCommaExtraToNode(nodeForExtra);
  13663. }
  13664. this.next();
  13665. break;
  13666. }
  13667. }
  13668. elts.push(this.parseExprListItem(11, false, refExpressionErrors, allowPlaceholder));
  13669. }
  13670. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13671. return elts;
  13672. }
  13673. shouldParseAsyncArrow() {
  13674. return this.match(19) && !this.canInsertSemicolon();
  13675. }
  13676. parseAsyncArrowFromCallExpression(node, call) {
  13677. var _call$extra;
  13678. this.resetPreviousNodeTrailingComments(call);
  13679. this.expect(19);
  13680. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
  13681. if (call.innerComments) {
  13682. setInnerComments(node, call.innerComments);
  13683. }
  13684. if (call.callee.trailingComments) {
  13685. setInnerComments(node, call.callee.trailingComments);
  13686. }
  13687. return node;
  13688. }
  13689. parseNoCallExpr() {
  13690. const startLoc = this.state.startLoc;
  13691. return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
  13692. }
  13693. parseExprAtom(refExpressionErrors) {
  13694. let node;
  13695. let decorators = null;
  13696. const {
  13697. type
  13698. } = this.state;
  13699. switch (type) {
  13700. case 79:
  13701. return this.parseSuper();
  13702. case 83:
  13703. node = this.startNode();
  13704. this.next();
  13705. if (this.match(16)) {
  13706. return this.parseImportMetaPropertyOrPhaseCall(node);
  13707. }
  13708. if (this.match(10)) {
  13709. if (this.optionFlags & 512) {
  13710. return this.parseImportCall(node);
  13711. } else {
  13712. return this.finishNode(node, "Import");
  13713. }
  13714. } else {
  13715. this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
  13716. return this.finishNode(node, "Import");
  13717. }
  13718. case 78:
  13719. node = this.startNode();
  13720. this.next();
  13721. return this.finishNode(node, "ThisExpression");
  13722. case 90:
  13723. {
  13724. return this.parseDo(this.startNode(), false);
  13725. }
  13726. case 56:
  13727. case 31:
  13728. {
  13729. this.readRegexp();
  13730. return this.parseRegExpLiteral(this.state.value);
  13731. }
  13732. case 135:
  13733. return this.parseNumericLiteral(this.state.value);
  13734. case 136:
  13735. return this.parseBigIntLiteral(this.state.value);
  13736. case 134:
  13737. return this.parseStringLiteral(this.state.value);
  13738. case 84:
  13739. return this.parseNullLiteral();
  13740. case 85:
  13741. return this.parseBooleanLiteral(true);
  13742. case 86:
  13743. return this.parseBooleanLiteral(false);
  13744. case 10:
  13745. {
  13746. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13747. return this.parseParenAndDistinguishExpression(canBeArrow);
  13748. }
  13749. case 0:
  13750. {
  13751. return this.parseArrayLike(3, true, false, refExpressionErrors);
  13752. }
  13753. case 5:
  13754. {
  13755. return this.parseObjectLike(8, false, false, refExpressionErrors);
  13756. }
  13757. case 68:
  13758. return this.parseFunctionOrFunctionSent();
  13759. case 26:
  13760. decorators = this.parseDecorators();
  13761. case 80:
  13762. return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
  13763. case 77:
  13764. return this.parseNewOrNewTarget();
  13765. case 25:
  13766. case 24:
  13767. return this.parseTemplate(false);
  13768. case 15:
  13769. {
  13770. node = this.startNode();
  13771. this.next();
  13772. node.object = null;
  13773. const callee = node.callee = this.parseNoCallExpr();
  13774. if (callee.type === "MemberExpression") {
  13775. return this.finishNode(node, "BindExpression");
  13776. } else {
  13777. throw this.raise(Errors.UnsupportedBind, callee);
  13778. }
  13779. }
  13780. case 139:
  13781. {
  13782. this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
  13783. identifierName: this.state.value
  13784. });
  13785. return this.parsePrivateName();
  13786. }
  13787. case 33:
  13788. {
  13789. return this.parseTopicReferenceThenEqualsSign(54, "%");
  13790. }
  13791. case 32:
  13792. {
  13793. return this.parseTopicReferenceThenEqualsSign(44, "^");
  13794. }
  13795. case 37:
  13796. case 38:
  13797. {
  13798. return this.parseTopicReference("hack");
  13799. }
  13800. case 44:
  13801. case 54:
  13802. case 27:
  13803. {
  13804. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13805. if (pipeProposal) {
  13806. return this.parseTopicReference(pipeProposal);
  13807. }
  13808. this.unexpected();
  13809. break;
  13810. }
  13811. case 47:
  13812. {
  13813. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  13814. if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
  13815. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  13816. } else {
  13817. this.unexpected();
  13818. }
  13819. break;
  13820. }
  13821. default:
  13822. {
  13823. if (type === 137) {
  13824. return this.parseDecimalLiteral(this.state.value);
  13825. } else if (type === 2 || type === 1) {
  13826. return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true);
  13827. } else if (type === 6 || type === 7) {
  13828. return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
  13829. }
  13830. }
  13831. if (tokenIsIdentifier(type)) {
  13832. if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) {
  13833. return this.parseModuleExpression();
  13834. }
  13835. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13836. const containsEsc = this.state.containsEsc;
  13837. const id = this.parseIdentifier();
  13838. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  13839. const {
  13840. type
  13841. } = this.state;
  13842. if (type === 68) {
  13843. this.resetPreviousNodeTrailingComments(id);
  13844. this.next();
  13845. return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
  13846. } else if (tokenIsIdentifier(type)) {
  13847. if (this.lookaheadCharCode() === 61) {
  13848. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  13849. } else {
  13850. return id;
  13851. }
  13852. } else if (type === 90) {
  13853. this.resetPreviousNodeTrailingComments(id);
  13854. return this.parseDo(this.startNodeAtNode(id), true);
  13855. }
  13856. }
  13857. if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) {
  13858. this.next();
  13859. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  13860. }
  13861. return id;
  13862. } else {
  13863. this.unexpected();
  13864. }
  13865. }
  13866. }
  13867. parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
  13868. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13869. if (pipeProposal) {
  13870. this.state.type = topicTokenType;
  13871. this.state.value = topicTokenValue;
  13872. this.state.pos--;
  13873. this.state.end--;
  13874. this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
  13875. return this.parseTopicReference(pipeProposal);
  13876. } else {
  13877. this.unexpected();
  13878. }
  13879. }
  13880. parseTopicReference(pipeProposal) {
  13881. const node = this.startNode();
  13882. const startLoc = this.state.startLoc;
  13883. const tokenType = this.state.type;
  13884. this.next();
  13885. return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
  13886. }
  13887. finishTopicReference(node, startLoc, pipeProposal, tokenType) {
  13888. if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
  13889. if (pipeProposal === "hack") {
  13890. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13891. this.raise(Errors.PipeTopicUnbound, startLoc);
  13892. }
  13893. this.registerTopicReference();
  13894. return this.finishNode(node, "TopicReference");
  13895. } else {
  13896. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13897. this.raise(Errors.PrimaryTopicNotAllowed, startLoc);
  13898. }
  13899. this.registerTopicReference();
  13900. return this.finishNode(node, "PipelinePrimaryTopicReference");
  13901. }
  13902. } else {
  13903. throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
  13904. token: tokenLabelName(tokenType)
  13905. });
  13906. }
  13907. }
  13908. testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
  13909. switch (pipeProposal) {
  13910. case "hack":
  13911. {
  13912. return this.hasPlugin(["pipelineOperator", {
  13913. topicToken: tokenLabelName(tokenType)
  13914. }]);
  13915. }
  13916. case "smart":
  13917. return tokenType === 27;
  13918. default:
  13919. throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
  13920. }
  13921. }
  13922. parseAsyncArrowUnaryFunction(node) {
  13923. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  13924. const params = [this.parseIdentifier()];
  13925. this.prodParam.exit();
  13926. if (this.hasPrecedingLineBreak()) {
  13927. this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
  13928. }
  13929. this.expect(19);
  13930. return this.parseArrowExpression(node, params, true);
  13931. }
  13932. parseDo(node, isAsync) {
  13933. this.expectPlugin("doExpressions");
  13934. if (isAsync) {
  13935. this.expectPlugin("asyncDoExpressions");
  13936. }
  13937. node.async = isAsync;
  13938. this.next();
  13939. const oldLabels = this.state.labels;
  13940. this.state.labels = [];
  13941. if (isAsync) {
  13942. this.prodParam.enter(2);
  13943. node.body = this.parseBlock();
  13944. this.prodParam.exit();
  13945. } else {
  13946. node.body = this.parseBlock();
  13947. }
  13948. this.state.labels = oldLabels;
  13949. return this.finishNode(node, "DoExpression");
  13950. }
  13951. parseSuper() {
  13952. const node = this.startNode();
  13953. this.next();
  13954. if (this.match(10) && !this.scope.allowDirectSuper && !(this.optionFlags & 16)) {
  13955. this.raise(Errors.SuperNotAllowed, node);
  13956. } else if (!this.scope.allowSuper && !(this.optionFlags & 16)) {
  13957. this.raise(Errors.UnexpectedSuper, node);
  13958. }
  13959. if (!this.match(10) && !this.match(0) && !this.match(16)) {
  13960. this.raise(Errors.UnsupportedSuper, node);
  13961. }
  13962. return this.finishNode(node, "Super");
  13963. }
  13964. parsePrivateName() {
  13965. const node = this.startNode();
  13966. const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
  13967. const name = this.state.value;
  13968. this.next();
  13969. node.id = this.createIdentifier(id, name);
  13970. return this.finishNode(node, "PrivateName");
  13971. }
  13972. parseFunctionOrFunctionSent() {
  13973. const node = this.startNode();
  13974. this.next();
  13975. if (this.prodParam.hasYield && this.match(16)) {
  13976. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  13977. this.next();
  13978. if (this.match(103)) {
  13979. this.expectPlugin("functionSent");
  13980. } else if (!this.hasPlugin("functionSent")) {
  13981. this.unexpected();
  13982. }
  13983. return this.parseMetaProperty(node, meta, "sent");
  13984. }
  13985. return this.parseFunction(node);
  13986. }
  13987. parseMetaProperty(node, meta, propertyName) {
  13988. node.meta = meta;
  13989. const containsEsc = this.state.containsEsc;
  13990. node.property = this.parseIdentifier(true);
  13991. if (node.property.name !== propertyName || containsEsc) {
  13992. this.raise(Errors.UnsupportedMetaProperty, node.property, {
  13993. target: meta.name,
  13994. onlyValidPropertyName: propertyName
  13995. });
  13996. }
  13997. return this.finishNode(node, "MetaProperty");
  13998. }
  13999. parseImportMetaPropertyOrPhaseCall(node) {
  14000. this.next();
  14001. if (this.isContextual(105) || this.isContextual(97)) {
  14002. const isSource = this.isContextual(105);
  14003. this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
  14004. this.next();
  14005. node.phase = isSource ? "source" : "defer";
  14006. return this.parseImportCall(node);
  14007. } else {
  14008. const id = this.createIdentifierAt(this.startNodeAtNode(node), "import", this.state.lastTokStartLoc);
  14009. if (this.isContextual(101)) {
  14010. if (!this.inModule) {
  14011. this.raise(Errors.ImportMetaOutsideModule, id);
  14012. }
  14013. this.sawUnambiguousESM = true;
  14014. }
  14015. return this.parseMetaProperty(node, id, "meta");
  14016. }
  14017. }
  14018. parseLiteralAtNode(value, type, node) {
  14019. this.addExtra(node, "rawValue", value);
  14020. this.addExtra(node, "raw", this.input.slice(this.offsetToSourcePos(node.start), this.state.end));
  14021. node.value = value;
  14022. this.next();
  14023. return this.finishNode(node, type);
  14024. }
  14025. parseLiteral(value, type) {
  14026. const node = this.startNode();
  14027. return this.parseLiteralAtNode(value, type, node);
  14028. }
  14029. parseStringLiteral(value) {
  14030. return this.parseLiteral(value, "StringLiteral");
  14031. }
  14032. parseNumericLiteral(value) {
  14033. return this.parseLiteral(value, "NumericLiteral");
  14034. }
  14035. parseBigIntLiteral(value) {
  14036. {
  14037. return this.parseLiteral(value, "BigIntLiteral");
  14038. }
  14039. }
  14040. parseDecimalLiteral(value) {
  14041. return this.parseLiteral(value, "DecimalLiteral");
  14042. }
  14043. parseRegExpLiteral(value) {
  14044. const node = this.startNode();
  14045. this.addExtra(node, "raw", this.input.slice(this.offsetToSourcePos(node.start), this.state.end));
  14046. node.pattern = value.pattern;
  14047. node.flags = value.flags;
  14048. this.next();
  14049. return this.finishNode(node, "RegExpLiteral");
  14050. }
  14051. parseBooleanLiteral(value) {
  14052. const node = this.startNode();
  14053. node.value = value;
  14054. this.next();
  14055. return this.finishNode(node, "BooleanLiteral");
  14056. }
  14057. parseNullLiteral() {
  14058. const node = this.startNode();
  14059. this.next();
  14060. return this.finishNode(node, "NullLiteral");
  14061. }
  14062. parseParenAndDistinguishExpression(canBeArrow) {
  14063. const startLoc = this.state.startLoc;
  14064. let val;
  14065. this.next();
  14066. this.expressionScope.enter(newArrowHeadScope());
  14067. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  14068. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14069. this.state.maybeInArrowParameters = true;
  14070. this.state.inFSharpPipelineDirectBody = false;
  14071. const innerStartLoc = this.state.startLoc;
  14072. const exprList = [];
  14073. const refExpressionErrors = new ExpressionErrors();
  14074. let first = true;
  14075. let spreadStartLoc;
  14076. let optionalCommaStartLoc;
  14077. while (!this.match(11)) {
  14078. if (first) {
  14079. first = false;
  14080. } else {
  14081. this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
  14082. if (this.match(11)) {
  14083. optionalCommaStartLoc = this.state.startLoc;
  14084. break;
  14085. }
  14086. }
  14087. if (this.match(21)) {
  14088. const spreadNodeStartLoc = this.state.startLoc;
  14089. spreadStartLoc = this.state.startLoc;
  14090. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
  14091. if (!this.checkCommaAfterRest(41)) {
  14092. break;
  14093. }
  14094. } else {
  14095. exprList.push(this.parseMaybeAssignAllowInOrVoidPattern(11, refExpressionErrors, this.parseParenItem));
  14096. }
  14097. }
  14098. const innerEndLoc = this.state.lastTokEndLoc;
  14099. this.expect(11);
  14100. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  14101. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14102. let arrowNode = this.startNodeAt(startLoc);
  14103. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  14104. this.checkDestructuringPrivate(refExpressionErrors);
  14105. this.expressionScope.validateAsPattern();
  14106. this.expressionScope.exit();
  14107. this.parseArrowExpression(arrowNode, exprList, false);
  14108. return arrowNode;
  14109. }
  14110. this.expressionScope.exit();
  14111. if (!exprList.length) {
  14112. this.unexpected(this.state.lastTokStartLoc);
  14113. }
  14114. if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
  14115. if (spreadStartLoc) this.unexpected(spreadStartLoc);
  14116. this.checkExpressionErrors(refExpressionErrors, true);
  14117. this.toReferencedListDeep(exprList, true);
  14118. if (exprList.length > 1) {
  14119. val = this.startNodeAt(innerStartLoc);
  14120. val.expressions = exprList;
  14121. this.finishNode(val, "SequenceExpression");
  14122. this.resetEndLocation(val, innerEndLoc);
  14123. } else {
  14124. val = exprList[0];
  14125. }
  14126. return this.wrapParenthesis(startLoc, val);
  14127. }
  14128. wrapParenthesis(startLoc, expression) {
  14129. if (!(this.optionFlags & 1024)) {
  14130. this.addExtra(expression, "parenthesized", true);
  14131. this.addExtra(expression, "parenStart", startLoc.index);
  14132. this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
  14133. return expression;
  14134. }
  14135. const parenExpression = this.startNodeAt(startLoc);
  14136. parenExpression.expression = expression;
  14137. return this.finishNode(parenExpression, "ParenthesizedExpression");
  14138. }
  14139. shouldParseArrow(params) {
  14140. return !this.canInsertSemicolon();
  14141. }
  14142. parseArrow(node) {
  14143. if (this.eat(19)) {
  14144. return node;
  14145. }
  14146. }
  14147. parseParenItem(node, startLoc) {
  14148. return node;
  14149. }
  14150. parseNewOrNewTarget() {
  14151. const node = this.startNode();
  14152. this.next();
  14153. if (this.match(16)) {
  14154. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  14155. this.next();
  14156. const metaProp = this.parseMetaProperty(node, meta, "target");
  14157. if (!this.scope.allowNewTarget) {
  14158. this.raise(Errors.UnexpectedNewTarget, metaProp);
  14159. }
  14160. return metaProp;
  14161. }
  14162. return this.parseNew(node);
  14163. }
  14164. parseNew(node) {
  14165. this.parseNewCallee(node);
  14166. if (this.eat(10)) {
  14167. const args = this.parseExprList(11);
  14168. this.toReferencedList(args);
  14169. node.arguments = args;
  14170. } else {
  14171. node.arguments = [];
  14172. }
  14173. return this.finishNode(node, "NewExpression");
  14174. }
  14175. parseNewCallee(node) {
  14176. const isImport = this.match(83);
  14177. const callee = this.parseNoCallExpr();
  14178. node.callee = callee;
  14179. if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) {
  14180. this.raise(Errors.ImportCallNotNewExpression, callee);
  14181. }
  14182. }
  14183. parseTemplateElement(isTagged) {
  14184. const {
  14185. start,
  14186. startLoc,
  14187. end,
  14188. value
  14189. } = this.state;
  14190. const elemStart = start + 1;
  14191. const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
  14192. if (value === null) {
  14193. if (!isTagged) {
  14194. this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
  14195. }
  14196. }
  14197. const isTail = this.match(24);
  14198. const endOffset = isTail ? -1 : -2;
  14199. const elemEnd = end + endOffset;
  14200. elem.value = {
  14201. raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
  14202. cooked: value === null ? null : value.slice(1, endOffset)
  14203. };
  14204. elem.tail = isTail;
  14205. this.next();
  14206. const finishedNode = this.finishNode(elem, "TemplateElement");
  14207. this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
  14208. return finishedNode;
  14209. }
  14210. parseTemplate(isTagged) {
  14211. const node = this.startNode();
  14212. let curElt = this.parseTemplateElement(isTagged);
  14213. const quasis = [curElt];
  14214. const substitutions = [];
  14215. while (!curElt.tail) {
  14216. substitutions.push(this.parseTemplateSubstitution());
  14217. this.readTemplateContinuation();
  14218. quasis.push(curElt = this.parseTemplateElement(isTagged));
  14219. }
  14220. node.expressions = substitutions;
  14221. node.quasis = quasis;
  14222. return this.finishNode(node, "TemplateLiteral");
  14223. }
  14224. parseTemplateSubstitution() {
  14225. return this.parseExpression();
  14226. }
  14227. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  14228. if (isRecord) {
  14229. this.expectPlugin("recordAndTuple");
  14230. }
  14231. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14232. this.state.inFSharpPipelineDirectBody = false;
  14233. let sawProto = false;
  14234. let first = true;
  14235. const node = this.startNode();
  14236. node.properties = [];
  14237. this.next();
  14238. while (!this.match(close)) {
  14239. if (first) {
  14240. first = false;
  14241. } else {
  14242. this.expect(12);
  14243. if (this.match(close)) {
  14244. this.addTrailingCommaExtraToNode(node);
  14245. break;
  14246. }
  14247. }
  14248. let prop;
  14249. if (isPattern) {
  14250. prop = this.parseBindingProperty();
  14251. } else {
  14252. prop = this.parsePropertyDefinition(refExpressionErrors);
  14253. sawProto = this.checkProto(prop, isRecord, sawProto, refExpressionErrors);
  14254. }
  14255. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  14256. this.raise(Errors.InvalidRecordProperty, prop);
  14257. }
  14258. {
  14259. if (prop.shorthand) {
  14260. this.addExtra(prop, "shorthand", true);
  14261. }
  14262. }
  14263. node.properties.push(prop);
  14264. }
  14265. this.next();
  14266. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14267. let type = "ObjectExpression";
  14268. if (isPattern) {
  14269. type = "ObjectPattern";
  14270. } else if (isRecord) {
  14271. type = "RecordExpression";
  14272. }
  14273. return this.finishNode(node, type);
  14274. }
  14275. addTrailingCommaExtraToNode(node) {
  14276. this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
  14277. this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
  14278. }
  14279. maybeAsyncOrAccessorProp(prop) {
  14280. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55));
  14281. }
  14282. parsePropertyDefinition(refExpressionErrors) {
  14283. let decorators = [];
  14284. if (this.match(26)) {
  14285. if (this.hasPlugin("decorators")) {
  14286. this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
  14287. }
  14288. while (this.match(26)) {
  14289. decorators.push(this.parseDecorator());
  14290. }
  14291. }
  14292. const prop = this.startNode();
  14293. let isAsync = false;
  14294. let isAccessor = false;
  14295. let startLoc;
  14296. if (this.match(21)) {
  14297. if (decorators.length) this.unexpected();
  14298. return this.parseSpread();
  14299. }
  14300. if (decorators.length) {
  14301. prop.decorators = decorators;
  14302. decorators = [];
  14303. }
  14304. prop.method = false;
  14305. if (refExpressionErrors) {
  14306. startLoc = this.state.startLoc;
  14307. }
  14308. let isGenerator = this.eat(55);
  14309. this.parsePropertyNamePrefixOperator(prop);
  14310. const containsEsc = this.state.containsEsc;
  14311. this.parsePropertyName(prop, refExpressionErrors);
  14312. if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  14313. const {
  14314. key
  14315. } = prop;
  14316. const keyName = key.name;
  14317. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  14318. isAsync = true;
  14319. this.resetPreviousNodeTrailingComments(key);
  14320. isGenerator = this.eat(55);
  14321. this.parsePropertyName(prop);
  14322. }
  14323. if (keyName === "get" || keyName === "set") {
  14324. isAccessor = true;
  14325. this.resetPreviousNodeTrailingComments(key);
  14326. prop.kind = keyName;
  14327. if (this.match(55)) {
  14328. isGenerator = true;
  14329. this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
  14330. kind: keyName
  14331. });
  14332. this.next();
  14333. }
  14334. this.parsePropertyName(prop);
  14335. }
  14336. }
  14337. return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
  14338. }
  14339. getGetterSetterExpectedParamCount(method) {
  14340. return method.kind === "get" ? 0 : 1;
  14341. }
  14342. getObjectOrClassMethodParams(method) {
  14343. return method.params;
  14344. }
  14345. checkGetterSetterParams(method) {
  14346. var _params;
  14347. const paramCount = this.getGetterSetterExpectedParamCount(method);
  14348. const params = this.getObjectOrClassMethodParams(method);
  14349. if (params.length !== paramCount) {
  14350. this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
  14351. }
  14352. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  14353. this.raise(Errors.BadSetterRestParameter, method);
  14354. }
  14355. }
  14356. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  14357. if (isAccessor) {
  14358. const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  14359. this.checkGetterSetterParams(finishedProp);
  14360. return finishedProp;
  14361. }
  14362. if (isAsync || isGenerator || this.match(10)) {
  14363. if (isPattern) this.unexpected();
  14364. prop.kind = "method";
  14365. prop.method = true;
  14366. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  14367. }
  14368. }
  14369. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  14370. prop.shorthand = false;
  14371. if (this.eat(14)) {
  14372. prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowInOrVoidPattern(8, refExpressionErrors);
  14373. return this.finishObjectProperty(prop);
  14374. }
  14375. if (!prop.computed && prop.key.type === "Identifier") {
  14376. this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
  14377. if (isPattern) {
  14378. prop.value = this.parseMaybeDefault(startLoc, this.cloneIdentifier(prop.key));
  14379. } else if (this.match(29)) {
  14380. const shorthandAssignLoc = this.state.startLoc;
  14381. if (refExpressionErrors != null) {
  14382. if (refExpressionErrors.shorthandAssignLoc === null) {
  14383. refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
  14384. }
  14385. } else {
  14386. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  14387. }
  14388. prop.value = this.parseMaybeDefault(startLoc, this.cloneIdentifier(prop.key));
  14389. } else {
  14390. prop.value = this.cloneIdentifier(prop.key);
  14391. }
  14392. prop.shorthand = true;
  14393. return this.finishObjectProperty(prop);
  14394. }
  14395. }
  14396. finishObjectProperty(node) {
  14397. return this.finishNode(node, "ObjectProperty");
  14398. }
  14399. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  14400. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  14401. if (!node) this.unexpected();
  14402. return node;
  14403. }
  14404. parsePropertyName(prop, refExpressionErrors) {
  14405. if (this.eat(0)) {
  14406. prop.computed = true;
  14407. prop.key = this.parseMaybeAssignAllowIn();
  14408. this.expect(3);
  14409. } else {
  14410. const {
  14411. type,
  14412. value
  14413. } = this.state;
  14414. let key;
  14415. if (tokenIsKeywordOrIdentifier(type)) {
  14416. key = this.parseIdentifier(true);
  14417. } else {
  14418. switch (type) {
  14419. case 135:
  14420. key = this.parseNumericLiteral(value);
  14421. break;
  14422. case 134:
  14423. key = this.parseStringLiteral(value);
  14424. break;
  14425. case 136:
  14426. key = this.parseBigIntLiteral(value);
  14427. break;
  14428. case 139:
  14429. {
  14430. const privateKeyLoc = this.state.startLoc;
  14431. if (refExpressionErrors != null) {
  14432. if (refExpressionErrors.privateKeyLoc === null) {
  14433. refExpressionErrors.privateKeyLoc = privateKeyLoc;
  14434. }
  14435. } else {
  14436. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  14437. }
  14438. key = this.parsePrivateName();
  14439. break;
  14440. }
  14441. default:
  14442. if (type === 137) {
  14443. key = this.parseDecimalLiteral(value);
  14444. break;
  14445. }
  14446. this.unexpected();
  14447. }
  14448. }
  14449. prop.key = key;
  14450. if (type !== 139) {
  14451. prop.computed = false;
  14452. }
  14453. }
  14454. }
  14455. initFunction(node, isAsync) {
  14456. node.id = null;
  14457. node.generator = false;
  14458. node.async = isAsync;
  14459. }
  14460. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  14461. this.initFunction(node, isAsync);
  14462. node.generator = isGenerator;
  14463. this.scope.enter(514 | 16 | (inClassScope ? 576 : 0) | (allowDirectSuper ? 32 : 0));
  14464. this.prodParam.enter(functionFlags(isAsync, node.generator));
  14465. this.parseFunctionParams(node, isConstructor);
  14466. const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
  14467. this.prodParam.exit();
  14468. this.scope.exit();
  14469. return finishedNode;
  14470. }
  14471. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  14472. if (isTuple) {
  14473. this.expectPlugin("recordAndTuple");
  14474. }
  14475. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14476. this.state.inFSharpPipelineDirectBody = false;
  14477. const node = this.startNode();
  14478. this.next();
  14479. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  14480. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14481. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  14482. }
  14483. parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
  14484. this.scope.enter(514 | 4);
  14485. let flags = functionFlags(isAsync, false);
  14486. if (!this.match(5) && this.prodParam.hasIn) {
  14487. flags |= 8;
  14488. }
  14489. this.prodParam.enter(flags);
  14490. this.initFunction(node, isAsync);
  14491. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  14492. if (params) {
  14493. this.state.maybeInArrowParameters = true;
  14494. this.setArrowFunctionParameters(node, params, trailingCommaLoc);
  14495. }
  14496. this.state.maybeInArrowParameters = false;
  14497. this.parseFunctionBody(node, true);
  14498. this.prodParam.exit();
  14499. this.scope.exit();
  14500. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  14501. return this.finishNode(node, "ArrowFunctionExpression");
  14502. }
  14503. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  14504. this.toAssignableList(params, trailingCommaLoc, false);
  14505. node.params = params;
  14506. }
  14507. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  14508. this.parseFunctionBody(node, false, isMethod);
  14509. return this.finishNode(node, type);
  14510. }
  14511. parseFunctionBody(node, allowExpression, isMethod = false) {
  14512. const isExpression = allowExpression && !this.match(5);
  14513. this.expressionScope.enter(newExpressionScope());
  14514. if (isExpression) {
  14515. node.body = this.parseMaybeAssign();
  14516. this.checkParams(node, false, allowExpression, false);
  14517. } else {
  14518. const oldStrict = this.state.strict;
  14519. const oldLabels = this.state.labels;
  14520. this.state.labels = [];
  14521. this.prodParam.enter(this.prodParam.currentFlags() | 4);
  14522. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  14523. const nonSimple = !this.isSimpleParamList(node.params);
  14524. if (hasStrictModeDirective && nonSimple) {
  14525. this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
  14526. }
  14527. const strictModeChanged = !oldStrict && this.state.strict;
  14528. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  14529. if (this.state.strict && node.id) {
  14530. this.checkIdentifier(node.id, 65, strictModeChanged);
  14531. }
  14532. });
  14533. this.prodParam.exit();
  14534. this.state.labels = oldLabels;
  14535. }
  14536. this.expressionScope.exit();
  14537. }
  14538. isSimpleParameter(node) {
  14539. return node.type === "Identifier";
  14540. }
  14541. isSimpleParamList(params) {
  14542. for (let i = 0, len = params.length; i < len; i++) {
  14543. if (!this.isSimpleParameter(params[i])) return false;
  14544. }
  14545. return true;
  14546. }
  14547. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  14548. const checkClashes = !allowDuplicates && new Set();
  14549. const formalParameters = {
  14550. type: "FormalParameters"
  14551. };
  14552. for (const param of node.params) {
  14553. this.checkLVal(param, formalParameters, 5, checkClashes, strictModeChanged);
  14554. }
  14555. }
  14556. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  14557. const elts = [];
  14558. let first = true;
  14559. while (!this.eat(close)) {
  14560. if (first) {
  14561. first = false;
  14562. } else {
  14563. this.expect(12);
  14564. if (this.match(close)) {
  14565. if (nodeForExtra) {
  14566. this.addTrailingCommaExtraToNode(nodeForExtra);
  14567. }
  14568. this.next();
  14569. break;
  14570. }
  14571. }
  14572. elts.push(this.parseExprListItem(close, allowEmpty, refExpressionErrors));
  14573. }
  14574. return elts;
  14575. }
  14576. parseExprListItem(close, allowEmpty, refExpressionErrors, allowPlaceholder) {
  14577. let elt;
  14578. if (this.match(12)) {
  14579. if (!allowEmpty) {
  14580. this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
  14581. unexpected: ","
  14582. });
  14583. }
  14584. elt = null;
  14585. } else if (this.match(21)) {
  14586. const spreadNodeStartLoc = this.state.startLoc;
  14587. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
  14588. } else if (this.match(17)) {
  14589. this.expectPlugin("partialApplication");
  14590. if (!allowPlaceholder) {
  14591. this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
  14592. }
  14593. const node = this.startNode();
  14594. this.next();
  14595. elt = this.finishNode(node, "ArgumentPlaceholder");
  14596. } else {
  14597. elt = this.parseMaybeAssignAllowInOrVoidPattern(close, refExpressionErrors, this.parseParenItem);
  14598. }
  14599. return elt;
  14600. }
  14601. parseIdentifier(liberal) {
  14602. const node = this.startNode();
  14603. const name = this.parseIdentifierName(liberal);
  14604. return this.createIdentifier(node, name);
  14605. }
  14606. createIdentifier(node, name) {
  14607. node.name = name;
  14608. node.loc.identifierName = name;
  14609. return this.finishNode(node, "Identifier");
  14610. }
  14611. createIdentifierAt(node, name, endLoc) {
  14612. node.name = name;
  14613. node.loc.identifierName = name;
  14614. return this.finishNodeAt(node, "Identifier", endLoc);
  14615. }
  14616. parseIdentifierName(liberal) {
  14617. let name;
  14618. const {
  14619. startLoc,
  14620. type
  14621. } = this.state;
  14622. if (tokenIsKeywordOrIdentifier(type)) {
  14623. name = this.state.value;
  14624. } else {
  14625. this.unexpected();
  14626. }
  14627. const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
  14628. if (liberal) {
  14629. if (tokenIsKeyword) {
  14630. this.replaceToken(132);
  14631. }
  14632. } else {
  14633. this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
  14634. }
  14635. this.next();
  14636. return name;
  14637. }
  14638. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  14639. if (word.length > 10) {
  14640. return;
  14641. }
  14642. if (!canBeReservedWord(word)) {
  14643. return;
  14644. }
  14645. if (checkKeywords && isKeyword(word)) {
  14646. this.raise(Errors.UnexpectedKeyword, startLoc, {
  14647. keyword: word
  14648. });
  14649. return;
  14650. }
  14651. const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
  14652. if (reservedTest(word, this.inModule)) {
  14653. this.raise(Errors.UnexpectedReservedWord, startLoc, {
  14654. reservedWord: word
  14655. });
  14656. return;
  14657. } else if (word === "yield") {
  14658. if (this.prodParam.hasYield) {
  14659. this.raise(Errors.YieldBindingIdentifier, startLoc);
  14660. return;
  14661. }
  14662. } else if (word === "await") {
  14663. if (this.prodParam.hasAwait) {
  14664. this.raise(Errors.AwaitBindingIdentifier, startLoc);
  14665. return;
  14666. }
  14667. if (this.scope.inStaticBlock) {
  14668. this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
  14669. return;
  14670. }
  14671. this.expressionScope.recordAsyncArrowParametersError(startLoc);
  14672. } else if (word === "arguments") {
  14673. if (this.scope.inClassAndNotInNonArrowFunction) {
  14674. this.raise(Errors.ArgumentsInClass, startLoc);
  14675. return;
  14676. }
  14677. }
  14678. }
  14679. recordAwaitIfAllowed() {
  14680. const isAwaitAllowed = this.prodParam.hasAwait;
  14681. if (isAwaitAllowed && !this.scope.inFunction) {
  14682. this.state.hasTopLevelAwait = true;
  14683. }
  14684. return isAwaitAllowed;
  14685. }
  14686. parseAwait(startLoc) {
  14687. const node = this.startNodeAt(startLoc);
  14688. this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
  14689. if (this.eat(55)) {
  14690. this.raise(Errors.ObsoleteAwaitStar, node);
  14691. }
  14692. if (!this.scope.inFunction && !(this.optionFlags & 1)) {
  14693. if (this.isAmbiguousPrefixOrIdentifier()) {
  14694. this.ambiguousScriptDifferentAst = true;
  14695. } else {
  14696. this.sawUnambiguousESM = true;
  14697. }
  14698. }
  14699. if (!this.state.soloAwait) {
  14700. node.argument = this.parseMaybeUnary(null, true);
  14701. }
  14702. return this.finishNode(node, "AwaitExpression");
  14703. }
  14704. isAmbiguousPrefixOrIdentifier() {
  14705. if (this.hasPrecedingLineBreak()) return true;
  14706. const {
  14707. type
  14708. } = this.state;
  14709. return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 138 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
  14710. }
  14711. parseYield(startLoc) {
  14712. const node = this.startNodeAt(startLoc);
  14713. this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
  14714. let delegating = false;
  14715. let argument = null;
  14716. if (!this.hasPrecedingLineBreak()) {
  14717. delegating = this.eat(55);
  14718. switch (this.state.type) {
  14719. case 13:
  14720. case 140:
  14721. case 8:
  14722. case 11:
  14723. case 3:
  14724. case 9:
  14725. case 14:
  14726. case 12:
  14727. if (!delegating) break;
  14728. default:
  14729. argument = this.parseMaybeAssign();
  14730. }
  14731. }
  14732. node.delegate = delegating;
  14733. node.argument = argument;
  14734. return this.finishNode(node, "YieldExpression");
  14735. }
  14736. parseImportCall(node) {
  14737. this.next();
  14738. node.source = this.parseMaybeAssignAllowIn();
  14739. node.options = null;
  14740. if (this.eat(12)) {
  14741. if (!this.match(11)) {
  14742. node.options = this.parseMaybeAssignAllowIn();
  14743. if (this.eat(12)) {
  14744. this.addTrailingCommaExtraToNode(node.options);
  14745. if (!this.match(11)) {
  14746. do {
  14747. this.parseMaybeAssignAllowIn();
  14748. } while (this.eat(12) && !this.match(11));
  14749. this.raise(Errors.ImportCallArity, node);
  14750. }
  14751. }
  14752. } else {
  14753. this.addTrailingCommaExtraToNode(node.source);
  14754. }
  14755. }
  14756. this.expect(11);
  14757. return this.finishNode(node, "ImportExpression");
  14758. }
  14759. checkPipelineAtInfixOperator(left, leftStartLoc) {
  14760. if (this.hasPlugin(["pipelineOperator", {
  14761. proposal: "smart"
  14762. }])) {
  14763. if (left.type === "SequenceExpression") {
  14764. this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
  14765. }
  14766. }
  14767. }
  14768. parseSmartPipelineBodyInStyle(childExpr, startLoc) {
  14769. if (this.isSimpleReference(childExpr)) {
  14770. const bodyNode = this.startNodeAt(startLoc);
  14771. bodyNode.callee = childExpr;
  14772. return this.finishNode(bodyNode, "PipelineBareFunction");
  14773. } else {
  14774. const bodyNode = this.startNodeAt(startLoc);
  14775. this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
  14776. bodyNode.expression = childExpr;
  14777. return this.finishNode(bodyNode, "PipelineTopicExpression");
  14778. }
  14779. }
  14780. isSimpleReference(expression) {
  14781. switch (expression.type) {
  14782. case "MemberExpression":
  14783. return !expression.computed && this.isSimpleReference(expression.object);
  14784. case "Identifier":
  14785. return true;
  14786. default:
  14787. return false;
  14788. }
  14789. }
  14790. checkSmartPipeTopicBodyEarlyErrors(startLoc) {
  14791. if (this.match(19)) {
  14792. throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
  14793. }
  14794. if (!this.topicReferenceWasUsedInCurrentContext()) {
  14795. this.raise(Errors.PipelineTopicUnused, startLoc);
  14796. }
  14797. }
  14798. withTopicBindingContext(callback) {
  14799. const outerContextTopicState = this.state.topicContext;
  14800. this.state.topicContext = {
  14801. maxNumOfResolvableTopics: 1,
  14802. maxTopicIndex: null
  14803. };
  14804. try {
  14805. return callback();
  14806. } finally {
  14807. this.state.topicContext = outerContextTopicState;
  14808. }
  14809. }
  14810. withSmartMixTopicForbiddingContext(callback) {
  14811. if (this.hasPlugin(["pipelineOperator", {
  14812. proposal: "smart"
  14813. }])) {
  14814. const outerContextTopicState = this.state.topicContext;
  14815. this.state.topicContext = {
  14816. maxNumOfResolvableTopics: 0,
  14817. maxTopicIndex: null
  14818. };
  14819. try {
  14820. return callback();
  14821. } finally {
  14822. this.state.topicContext = outerContextTopicState;
  14823. }
  14824. } else {
  14825. return callback();
  14826. }
  14827. }
  14828. withSoloAwaitPermittingContext(callback) {
  14829. const outerContextSoloAwaitState = this.state.soloAwait;
  14830. this.state.soloAwait = true;
  14831. try {
  14832. return callback();
  14833. } finally {
  14834. this.state.soloAwait = outerContextSoloAwaitState;
  14835. }
  14836. }
  14837. allowInAnd(callback) {
  14838. const flags = this.prodParam.currentFlags();
  14839. const prodParamToSet = 8 & ~flags;
  14840. if (prodParamToSet) {
  14841. this.prodParam.enter(flags | 8);
  14842. try {
  14843. return callback();
  14844. } finally {
  14845. this.prodParam.exit();
  14846. }
  14847. }
  14848. return callback();
  14849. }
  14850. disallowInAnd(callback) {
  14851. const flags = this.prodParam.currentFlags();
  14852. const prodParamToClear = 8 & flags;
  14853. if (prodParamToClear) {
  14854. this.prodParam.enter(flags & -9);
  14855. try {
  14856. return callback();
  14857. } finally {
  14858. this.prodParam.exit();
  14859. }
  14860. }
  14861. return callback();
  14862. }
  14863. registerTopicReference() {
  14864. this.state.topicContext.maxTopicIndex = 0;
  14865. }
  14866. topicReferenceIsAllowedInCurrentContext() {
  14867. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  14868. }
  14869. topicReferenceWasUsedInCurrentContext() {
  14870. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  14871. }
  14872. parseFSharpPipelineBody(prec) {
  14873. const startLoc = this.state.startLoc;
  14874. this.state.potentialArrowAt = this.state.start;
  14875. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14876. this.state.inFSharpPipelineDirectBody = true;
  14877. const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
  14878. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14879. return ret;
  14880. }
  14881. parseModuleExpression() {
  14882. this.expectPlugin("moduleBlocks");
  14883. const node = this.startNode();
  14884. this.next();
  14885. if (!this.match(5)) {
  14886. this.unexpected(null, 5);
  14887. }
  14888. const program = this.startNodeAt(this.state.endLoc);
  14889. this.next();
  14890. const revertScopes = this.initializeScopes(true);
  14891. this.enterInitialScopes();
  14892. try {
  14893. node.body = this.parseProgram(program, 8, "module");
  14894. } finally {
  14895. revertScopes();
  14896. }
  14897. return this.finishNode(node, "ModuleExpression");
  14898. }
  14899. parseVoidPattern(refExpressionErrors) {
  14900. this.expectPlugin("discardBinding");
  14901. const node = this.startNode();
  14902. if (refExpressionErrors != null) {
  14903. refExpressionErrors.voidPatternLoc = this.state.startLoc;
  14904. }
  14905. this.next();
  14906. return this.finishNode(node, "VoidPattern");
  14907. }
  14908. parseMaybeAssignAllowInOrVoidPattern(close, refExpressionErrors, afterLeftParse) {
  14909. if (refExpressionErrors != null && this.match(88)) {
  14910. const nextCode = this.lookaheadCharCode();
  14911. if (nextCode === 44 || nextCode === (close === 3 ? 93 : close === 8 ? 125 : 41) || nextCode === 61) {
  14912. return this.parseMaybeDefault(this.state.startLoc, this.parseVoidPattern(refExpressionErrors));
  14913. }
  14914. }
  14915. return this.parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse);
  14916. }
  14917. parsePropertyNamePrefixOperator(prop) {}
  14918. }
  14919. const loopLabel = {
  14920. kind: 1
  14921. },
  14922. switchLabel = {
  14923. kind: 2
  14924. };
  14925. const loneSurrogate = /[\uD800-\uDFFF]/u;
  14926. const keywordRelationalOperator = /in(?:stanceof)?/y;
  14927. function babel7CompatTokens(tokens, input, startIndex) {
  14928. for (let i = 0; i < tokens.length; i++) {
  14929. const token = tokens[i];
  14930. const {
  14931. type
  14932. } = token;
  14933. if (typeof type === "number") {
  14934. {
  14935. if (type === 139) {
  14936. const {
  14937. loc,
  14938. start,
  14939. value,
  14940. end
  14941. } = token;
  14942. const hashEndPos = start + 1;
  14943. const hashEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14944. tokens.splice(i, 1, new Token({
  14945. type: getExportedToken(27),
  14946. value: "#",
  14947. start: start,
  14948. end: hashEndPos,
  14949. startLoc: loc.start,
  14950. endLoc: hashEndLoc
  14951. }), new Token({
  14952. type: getExportedToken(132),
  14953. value: value,
  14954. start: hashEndPos,
  14955. end: end,
  14956. startLoc: hashEndLoc,
  14957. endLoc: loc.end
  14958. }));
  14959. i++;
  14960. continue;
  14961. }
  14962. if (tokenIsTemplate(type)) {
  14963. const {
  14964. loc,
  14965. start,
  14966. value,
  14967. end
  14968. } = token;
  14969. const backquoteEnd = start + 1;
  14970. const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14971. let startToken;
  14972. if (input.charCodeAt(start - startIndex) === 96) {
  14973. startToken = new Token({
  14974. type: getExportedToken(22),
  14975. value: "`",
  14976. start: start,
  14977. end: backquoteEnd,
  14978. startLoc: loc.start,
  14979. endLoc: backquoteEndLoc
  14980. });
  14981. } else {
  14982. startToken = new Token({
  14983. type: getExportedToken(8),
  14984. value: "}",
  14985. start: start,
  14986. end: backquoteEnd,
  14987. startLoc: loc.start,
  14988. endLoc: backquoteEndLoc
  14989. });
  14990. }
  14991. let templateValue, templateElementEnd, templateElementEndLoc, endToken;
  14992. if (type === 24) {
  14993. templateElementEnd = end - 1;
  14994. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1);
  14995. templateValue = value === null ? null : value.slice(1, -1);
  14996. endToken = new Token({
  14997. type: getExportedToken(22),
  14998. value: "`",
  14999. start: templateElementEnd,
  15000. end: end,
  15001. startLoc: templateElementEndLoc,
  15002. endLoc: loc.end
  15003. });
  15004. } else {
  15005. templateElementEnd = end - 2;
  15006. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2);
  15007. templateValue = value === null ? null : value.slice(1, -2);
  15008. endToken = new Token({
  15009. type: getExportedToken(23),
  15010. value: "${",
  15011. start: templateElementEnd,
  15012. end: end,
  15013. startLoc: templateElementEndLoc,
  15014. endLoc: loc.end
  15015. });
  15016. }
  15017. tokens.splice(i, 1, startToken, new Token({
  15018. type: getExportedToken(20),
  15019. value: templateValue,
  15020. start: backquoteEnd,
  15021. end: templateElementEnd,
  15022. startLoc: backquoteEndLoc,
  15023. endLoc: templateElementEndLoc
  15024. }), endToken);
  15025. i += 2;
  15026. continue;
  15027. }
  15028. }
  15029. token.type = getExportedToken(type);
  15030. }
  15031. }
  15032. return tokens;
  15033. }
  15034. class StatementParser extends ExpressionParser {
  15035. parseTopLevel(file, program) {
  15036. file.program = this.parseProgram(program, 140, this.options.sourceType === "module" ? "module" : "script");
  15037. file.comments = this.comments;
  15038. if (this.optionFlags & 256) {
  15039. file.tokens = babel7CompatTokens(this.tokens, this.input, this.startIndex);
  15040. }
  15041. return this.finishNode(file, "File");
  15042. }
  15043. parseProgram(program, end, sourceType) {
  15044. program.sourceType = sourceType;
  15045. program.interpreter = this.parseInterpreterDirective();
  15046. this.parseBlockBody(program, true, true, end);
  15047. if (this.inModule) {
  15048. if (!(this.optionFlags & 64) && this.scope.undefinedExports.size > 0) {
  15049. for (const [localName, at] of Array.from(this.scope.undefinedExports)) {
  15050. this.raise(Errors.ModuleExportUndefined, at, {
  15051. localName
  15052. });
  15053. }
  15054. }
  15055. this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait);
  15056. }
  15057. let finishedProgram;
  15058. if (end === 140) {
  15059. finishedProgram = this.finishNode(program, "Program");
  15060. } else {
  15061. finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
  15062. }
  15063. return finishedProgram;
  15064. }
  15065. stmtToDirective(stmt) {
  15066. const directive = this.castNodeTo(stmt, "Directive");
  15067. const directiveLiteral = this.castNodeTo(stmt.expression, "DirectiveLiteral");
  15068. const expressionValue = directiveLiteral.value;
  15069. const raw = this.input.slice(this.offsetToSourcePos(directiveLiteral.start), this.offsetToSourcePos(directiveLiteral.end));
  15070. const val = directiveLiteral.value = raw.slice(1, -1);
  15071. this.addExtra(directiveLiteral, "raw", raw);
  15072. this.addExtra(directiveLiteral, "rawValue", val);
  15073. this.addExtra(directiveLiteral, "expressionValue", expressionValue);
  15074. directive.value = directiveLiteral;
  15075. delete stmt.expression;
  15076. return directive;
  15077. }
  15078. parseInterpreterDirective() {
  15079. if (!this.match(28)) {
  15080. return null;
  15081. }
  15082. const node = this.startNode();
  15083. node.value = this.state.value;
  15084. this.next();
  15085. return this.finishNode(node, "InterpreterDirective");
  15086. }
  15087. isLet() {
  15088. if (!this.isContextual(100)) {
  15089. return false;
  15090. }
  15091. return this.hasFollowingBindingAtom();
  15092. }
  15093. isUsing() {
  15094. if (!this.isContextual(107)) {
  15095. return false;
  15096. }
  15097. const next = this.nextTokenInLineStart();
  15098. const nextCh = this.codePointAtPos(next);
  15099. return this.chStartsBindingIdentifier(nextCh, next);
  15100. }
  15101. isForUsing() {
  15102. if (!this.isContextual(107)) {
  15103. return false;
  15104. }
  15105. const next = this.nextTokenInLineStart();
  15106. const nextCh = this.codePointAtPos(next);
  15107. if (this.isUnparsedContextual(next, "of")) {
  15108. const nextCharAfterOf = this.lookaheadCharCodeSince(next + 2);
  15109. if (nextCharAfterOf !== 61 && nextCharAfterOf !== 58 && nextCharAfterOf !== 59) {
  15110. return false;
  15111. }
  15112. }
  15113. if (this.chStartsBindingIdentifier(nextCh, next) || this.isUnparsedContextual(next, "void")) {
  15114. return true;
  15115. }
  15116. return false;
  15117. }
  15118. isAwaitUsing() {
  15119. if (!this.isContextual(96)) {
  15120. return false;
  15121. }
  15122. let next = this.nextTokenInLineStart();
  15123. if (this.isUnparsedContextual(next, "using")) {
  15124. next = this.nextTokenInLineStartSince(next + 5);
  15125. const nextCh = this.codePointAtPos(next);
  15126. if (this.chStartsBindingIdentifier(nextCh, next)) {
  15127. return true;
  15128. }
  15129. }
  15130. return false;
  15131. }
  15132. chStartsBindingIdentifier(ch, pos) {
  15133. if (isIdentifierStart(ch)) {
  15134. keywordRelationalOperator.lastIndex = pos;
  15135. if (keywordRelationalOperator.test(this.input)) {
  15136. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  15137. if (!isIdentifierChar(endCh) && endCh !== 92) {
  15138. return false;
  15139. }
  15140. }
  15141. return true;
  15142. } else if (ch === 92) {
  15143. return true;
  15144. } else {
  15145. return false;
  15146. }
  15147. }
  15148. chStartsBindingPattern(ch) {
  15149. return ch === 91 || ch === 123;
  15150. }
  15151. hasFollowingBindingAtom() {
  15152. const next = this.nextTokenStart();
  15153. const nextCh = this.codePointAtPos(next);
  15154. return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
  15155. }
  15156. hasInLineFollowingBindingIdentifierOrBrace() {
  15157. const next = this.nextTokenInLineStart();
  15158. const nextCh = this.codePointAtPos(next);
  15159. return nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next);
  15160. }
  15161. allowsUsing() {
  15162. return (this.scope.inModule || !this.scope.inTopLevel) && !this.scope.inBareCaseStatement;
  15163. }
  15164. parseModuleItem() {
  15165. return this.parseStatementLike(1 | 2 | 4 | 8);
  15166. }
  15167. parseStatementListItem() {
  15168. return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8));
  15169. }
  15170. parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) {
  15171. let flags = 0;
  15172. if (this.options.annexB && !this.state.strict) {
  15173. flags |= 4;
  15174. if (allowLabeledFunction) {
  15175. flags |= 8;
  15176. }
  15177. }
  15178. return this.parseStatementLike(flags);
  15179. }
  15180. parseStatement() {
  15181. return this.parseStatementLike(0);
  15182. }
  15183. parseStatementLike(flags) {
  15184. let decorators = null;
  15185. if (this.match(26)) {
  15186. decorators = this.parseDecorators(true);
  15187. }
  15188. return this.parseStatementContent(flags, decorators);
  15189. }
  15190. parseStatementContent(flags, decorators) {
  15191. const startType = this.state.type;
  15192. const node = this.startNode();
  15193. const allowDeclaration = !!(flags & 2);
  15194. const allowFunctionDeclaration = !!(flags & 4);
  15195. const topLevel = flags & 1;
  15196. switch (startType) {
  15197. case 60:
  15198. return this.parseBreakContinueStatement(node, true);
  15199. case 63:
  15200. return this.parseBreakContinueStatement(node, false);
  15201. case 64:
  15202. return this.parseDebuggerStatement(node);
  15203. case 90:
  15204. return this.parseDoWhileStatement(node);
  15205. case 91:
  15206. return this.parseForStatement(node);
  15207. case 68:
  15208. if (this.lookaheadCharCode() === 46) break;
  15209. if (!allowFunctionDeclaration) {
  15210. this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc);
  15211. }
  15212. return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
  15213. case 80:
  15214. if (!allowDeclaration) this.unexpected();
  15215. return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
  15216. case 69:
  15217. return this.parseIfStatement(node);
  15218. case 70:
  15219. return this.parseReturnStatement(node);
  15220. case 71:
  15221. return this.parseSwitchStatement(node);
  15222. case 72:
  15223. return this.parseThrowStatement(node);
  15224. case 73:
  15225. return this.parseTryStatement(node);
  15226. case 96:
  15227. if (this.isAwaitUsing()) {
  15228. if (!this.allowsUsing()) {
  15229. this.raise(Errors.UnexpectedUsingDeclaration, node);
  15230. } else if (!allowDeclaration) {
  15231. this.raise(Errors.UnexpectedLexicalDeclaration, node);
  15232. } else if (!this.recordAwaitIfAllowed()) {
  15233. this.raise(Errors.AwaitUsingNotInAsyncContext, node);
  15234. }
  15235. this.next();
  15236. return this.parseVarStatement(node, "await using");
  15237. }
  15238. break;
  15239. case 107:
  15240. if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) {
  15241. break;
  15242. }
  15243. if (!this.allowsUsing()) {
  15244. this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
  15245. } else if (!allowDeclaration) {
  15246. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  15247. }
  15248. return this.parseVarStatement(node, "using");
  15249. case 100:
  15250. {
  15251. if (this.state.containsEsc) {
  15252. break;
  15253. }
  15254. const next = this.nextTokenStart();
  15255. const nextCh = this.codePointAtPos(next);
  15256. if (nextCh !== 91) {
  15257. if (!allowDeclaration && this.hasFollowingLineBreak()) break;
  15258. if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
  15259. break;
  15260. }
  15261. }
  15262. }
  15263. case 75:
  15264. {
  15265. if (!allowDeclaration) {
  15266. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  15267. }
  15268. }
  15269. case 74:
  15270. {
  15271. const kind = this.state.value;
  15272. return this.parseVarStatement(node, kind);
  15273. }
  15274. case 92:
  15275. return this.parseWhileStatement(node);
  15276. case 76:
  15277. return this.parseWithStatement(node);
  15278. case 5:
  15279. return this.parseBlock();
  15280. case 13:
  15281. return this.parseEmptyStatement(node);
  15282. case 83:
  15283. {
  15284. const nextTokenCharCode = this.lookaheadCharCode();
  15285. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  15286. break;
  15287. }
  15288. }
  15289. case 82:
  15290. {
  15291. if (!(this.optionFlags & 8) && !topLevel) {
  15292. this.raise(Errors.UnexpectedImportExport, this.state.startLoc);
  15293. }
  15294. this.next();
  15295. let result;
  15296. if (startType === 83) {
  15297. result = this.parseImport(node);
  15298. } else {
  15299. result = this.parseExport(node, decorators);
  15300. }
  15301. this.assertModuleNodeAllowed(result);
  15302. return result;
  15303. }
  15304. default:
  15305. {
  15306. if (this.isAsyncFunction()) {
  15307. if (!allowDeclaration) {
  15308. this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc);
  15309. }
  15310. this.next();
  15311. return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
  15312. }
  15313. }
  15314. }
  15315. const maybeName = this.state.value;
  15316. const expr = this.parseExpression();
  15317. if (tokenIsIdentifier(startType) && expr.type === "Identifier" && this.eat(14)) {
  15318. return this.parseLabeledStatement(node, maybeName, expr, flags);
  15319. } else {
  15320. return this.parseExpressionStatement(node, expr, decorators);
  15321. }
  15322. }
  15323. assertModuleNodeAllowed(node) {
  15324. if (!(this.optionFlags & 8) && !this.inModule) {
  15325. this.raise(Errors.ImportOutsideModule, node);
  15326. }
  15327. }
  15328. decoratorsEnabledBeforeExport() {
  15329. if (this.hasPlugin("decorators-legacy")) return true;
  15330. return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false;
  15331. }
  15332. maybeTakeDecorators(maybeDecorators, classNode, exportNode) {
  15333. if (maybeDecorators) {
  15334. var _classNode$decorators;
  15335. if ((_classNode$decorators = classNode.decorators) != null && _classNode$decorators.length) {
  15336. if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") {
  15337. this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]);
  15338. }
  15339. classNode.decorators.unshift(...maybeDecorators);
  15340. } else {
  15341. classNode.decorators = maybeDecorators;
  15342. }
  15343. this.resetStartLocationFromNode(classNode, maybeDecorators[0]);
  15344. if (exportNode) this.resetStartLocationFromNode(exportNode, classNode);
  15345. }
  15346. return classNode;
  15347. }
  15348. canHaveLeadingDecorator() {
  15349. return this.match(80);
  15350. }
  15351. parseDecorators(allowExport) {
  15352. const decorators = [];
  15353. do {
  15354. decorators.push(this.parseDecorator());
  15355. } while (this.match(26));
  15356. if (this.match(82)) {
  15357. if (!allowExport) {
  15358. this.unexpected();
  15359. }
  15360. if (!this.decoratorsEnabledBeforeExport()) {
  15361. this.raise(Errors.DecoratorExportClass, this.state.startLoc);
  15362. }
  15363. } else if (!this.canHaveLeadingDecorator()) {
  15364. throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc);
  15365. }
  15366. return decorators;
  15367. }
  15368. parseDecorator() {
  15369. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  15370. const node = this.startNode();
  15371. this.next();
  15372. if (this.hasPlugin("decorators")) {
  15373. const startLoc = this.state.startLoc;
  15374. let expr;
  15375. if (this.match(10)) {
  15376. const startLoc = this.state.startLoc;
  15377. this.next();
  15378. expr = this.parseExpression();
  15379. this.expect(11);
  15380. expr = this.wrapParenthesis(startLoc, expr);
  15381. const paramsStartLoc = this.state.startLoc;
  15382. node.expression = this.parseMaybeDecoratorArguments(expr, startLoc);
  15383. if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) {
  15384. this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc);
  15385. }
  15386. } else {
  15387. expr = this.parseIdentifier(false);
  15388. while (this.eat(16)) {
  15389. const node = this.startNodeAt(startLoc);
  15390. node.object = expr;
  15391. if (this.match(139)) {
  15392. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  15393. node.property = this.parsePrivateName();
  15394. } else {
  15395. node.property = this.parseIdentifier(true);
  15396. }
  15397. node.computed = false;
  15398. expr = this.finishNode(node, "MemberExpression");
  15399. }
  15400. node.expression = this.parseMaybeDecoratorArguments(expr, startLoc);
  15401. }
  15402. } else {
  15403. node.expression = this.parseExprSubscripts();
  15404. }
  15405. return this.finishNode(node, "Decorator");
  15406. }
  15407. parseMaybeDecoratorArguments(expr, startLoc) {
  15408. if (this.eat(10)) {
  15409. const node = this.startNodeAt(startLoc);
  15410. node.callee = expr;
  15411. node.arguments = this.parseCallExpressionArguments();
  15412. this.toReferencedList(node.arguments);
  15413. return this.finishNode(node, "CallExpression");
  15414. }
  15415. return expr;
  15416. }
  15417. parseBreakContinueStatement(node, isBreak) {
  15418. this.next();
  15419. if (this.isLineTerminator()) {
  15420. node.label = null;
  15421. } else {
  15422. node.label = this.parseIdentifier();
  15423. this.semicolon();
  15424. }
  15425. this.verifyBreakContinue(node, isBreak);
  15426. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  15427. }
  15428. verifyBreakContinue(node, isBreak) {
  15429. let i;
  15430. for (i = 0; i < this.state.labels.length; ++i) {
  15431. const lab = this.state.labels[i];
  15432. if (node.label == null || lab.name === node.label.name) {
  15433. if (lab.kind != null && (isBreak || lab.kind === 1)) {
  15434. break;
  15435. }
  15436. if (node.label && isBreak) break;
  15437. }
  15438. }
  15439. if (i === this.state.labels.length) {
  15440. const type = isBreak ? "BreakStatement" : "ContinueStatement";
  15441. this.raise(Errors.IllegalBreakContinue, node, {
  15442. type
  15443. });
  15444. }
  15445. }
  15446. parseDebuggerStatement(node) {
  15447. this.next();
  15448. this.semicolon();
  15449. return this.finishNode(node, "DebuggerStatement");
  15450. }
  15451. parseHeaderExpression() {
  15452. this.expect(10);
  15453. const val = this.parseExpression();
  15454. this.expect(11);
  15455. return val;
  15456. }
  15457. parseDoWhileStatement(node) {
  15458. this.next();
  15459. this.state.labels.push(loopLabel);
  15460. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15461. this.state.labels.pop();
  15462. this.expect(92);
  15463. node.test = this.parseHeaderExpression();
  15464. this.eat(13);
  15465. return this.finishNode(node, "DoWhileStatement");
  15466. }
  15467. parseForStatement(node) {
  15468. this.next();
  15469. this.state.labels.push(loopLabel);
  15470. let awaitAt = null;
  15471. if (this.isContextual(96) && this.recordAwaitIfAllowed()) {
  15472. awaitAt = this.state.startLoc;
  15473. this.next();
  15474. }
  15475. this.scope.enter(0);
  15476. this.expect(10);
  15477. if (this.match(13)) {
  15478. if (awaitAt !== null) {
  15479. this.unexpected(awaitAt);
  15480. }
  15481. return this.parseFor(node, null);
  15482. }
  15483. const startsWithLet = this.isContextual(100);
  15484. {
  15485. const startsWithAwaitUsing = this.isAwaitUsing();
  15486. const starsWithUsingDeclaration = startsWithAwaitUsing || this.isForUsing();
  15487. const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
  15488. if (this.match(74) || this.match(75) || isLetOrUsing) {
  15489. const initNode = this.startNode();
  15490. let kind;
  15491. if (startsWithAwaitUsing) {
  15492. kind = "await using";
  15493. if (!this.recordAwaitIfAllowed()) {
  15494. this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc);
  15495. }
  15496. this.next();
  15497. } else {
  15498. kind = this.state.value;
  15499. }
  15500. this.next();
  15501. this.parseVar(initNode, true, kind);
  15502. const init = this.finishNode(initNode, "VariableDeclaration");
  15503. const isForIn = this.match(58);
  15504. if (isForIn && starsWithUsingDeclaration) {
  15505. this.raise(Errors.ForInUsing, init);
  15506. }
  15507. if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) {
  15508. return this.parseForIn(node, init, awaitAt);
  15509. }
  15510. if (awaitAt !== null) {
  15511. this.unexpected(awaitAt);
  15512. }
  15513. return this.parseFor(node, init);
  15514. }
  15515. }
  15516. const startsWithAsync = this.isContextual(95);
  15517. const refExpressionErrors = new ExpressionErrors();
  15518. const init = this.parseExpression(true, refExpressionErrors);
  15519. const isForOf = this.isContextual(102);
  15520. if (isForOf) {
  15521. if (startsWithLet) {
  15522. this.raise(Errors.ForOfLet, init);
  15523. }
  15524. if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
  15525. this.raise(Errors.ForOfAsync, init);
  15526. }
  15527. }
  15528. if (isForOf || this.match(58)) {
  15529. this.checkDestructuringPrivate(refExpressionErrors);
  15530. this.toAssignable(init, true);
  15531. const type = isForOf ? "ForOfStatement" : "ForInStatement";
  15532. this.checkLVal(init, {
  15533. type
  15534. });
  15535. return this.parseForIn(node, init, awaitAt);
  15536. } else {
  15537. this.checkExpressionErrors(refExpressionErrors, true);
  15538. }
  15539. if (awaitAt !== null) {
  15540. this.unexpected(awaitAt);
  15541. }
  15542. return this.parseFor(node, init);
  15543. }
  15544. parseFunctionStatement(node, isAsync, isHangingDeclaration) {
  15545. this.next();
  15546. return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0));
  15547. }
  15548. parseIfStatement(node) {
  15549. this.next();
  15550. node.test = this.parseHeaderExpression();
  15551. node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration();
  15552. node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null;
  15553. return this.finishNode(node, "IfStatement");
  15554. }
  15555. parseReturnStatement(node) {
  15556. if (!this.prodParam.hasReturn) {
  15557. this.raise(Errors.IllegalReturn, this.state.startLoc);
  15558. }
  15559. this.next();
  15560. if (this.isLineTerminator()) {
  15561. node.argument = null;
  15562. } else {
  15563. node.argument = this.parseExpression();
  15564. this.semicolon();
  15565. }
  15566. return this.finishNode(node, "ReturnStatement");
  15567. }
  15568. parseSwitchStatement(node) {
  15569. this.next();
  15570. node.discriminant = this.parseHeaderExpression();
  15571. const cases = node.cases = [];
  15572. this.expect(5);
  15573. this.state.labels.push(switchLabel);
  15574. this.scope.enter(256);
  15575. let cur;
  15576. for (let sawDefault; !this.match(8);) {
  15577. if (this.match(61) || this.match(65)) {
  15578. const isCase = this.match(61);
  15579. if (cur) this.finishNode(cur, "SwitchCase");
  15580. cases.push(cur = this.startNode());
  15581. cur.consequent = [];
  15582. this.next();
  15583. if (isCase) {
  15584. cur.test = this.parseExpression();
  15585. } else {
  15586. if (sawDefault) {
  15587. this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc);
  15588. }
  15589. sawDefault = true;
  15590. cur.test = null;
  15591. }
  15592. this.expect(14);
  15593. } else {
  15594. if (cur) {
  15595. cur.consequent.push(this.parseStatementListItem());
  15596. } else {
  15597. this.unexpected();
  15598. }
  15599. }
  15600. }
  15601. this.scope.exit();
  15602. if (cur) this.finishNode(cur, "SwitchCase");
  15603. this.next();
  15604. this.state.labels.pop();
  15605. return this.finishNode(node, "SwitchStatement");
  15606. }
  15607. parseThrowStatement(node) {
  15608. this.next();
  15609. if (this.hasPrecedingLineBreak()) {
  15610. this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc);
  15611. }
  15612. node.argument = this.parseExpression();
  15613. this.semicolon();
  15614. return this.finishNode(node, "ThrowStatement");
  15615. }
  15616. parseCatchClauseParam() {
  15617. const param = this.parseBindingAtom();
  15618. this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0);
  15619. this.checkLVal(param, {
  15620. type: "CatchClause"
  15621. }, 9);
  15622. return param;
  15623. }
  15624. parseTryStatement(node) {
  15625. this.next();
  15626. node.block = this.parseBlock();
  15627. node.handler = null;
  15628. if (this.match(62)) {
  15629. const clause = this.startNode();
  15630. this.next();
  15631. if (this.match(10)) {
  15632. this.expect(10);
  15633. clause.param = this.parseCatchClauseParam();
  15634. this.expect(11);
  15635. } else {
  15636. clause.param = null;
  15637. this.scope.enter(0);
  15638. }
  15639. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  15640. this.scope.exit();
  15641. node.handler = this.finishNode(clause, "CatchClause");
  15642. }
  15643. node.finalizer = this.eat(67) ? this.parseBlock() : null;
  15644. if (!node.handler && !node.finalizer) {
  15645. this.raise(Errors.NoCatchOrFinally, node);
  15646. }
  15647. return this.finishNode(node, "TryStatement");
  15648. }
  15649. parseVarStatement(node, kind, allowMissingInitializer = false) {
  15650. this.next();
  15651. this.parseVar(node, false, kind, allowMissingInitializer);
  15652. this.semicolon();
  15653. return this.finishNode(node, "VariableDeclaration");
  15654. }
  15655. parseWhileStatement(node) {
  15656. this.next();
  15657. node.test = this.parseHeaderExpression();
  15658. this.state.labels.push(loopLabel);
  15659. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15660. this.state.labels.pop();
  15661. return this.finishNode(node, "WhileStatement");
  15662. }
  15663. parseWithStatement(node) {
  15664. if (this.state.strict) {
  15665. this.raise(Errors.StrictWith, this.state.startLoc);
  15666. }
  15667. this.next();
  15668. node.object = this.parseHeaderExpression();
  15669. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15670. return this.finishNode(node, "WithStatement");
  15671. }
  15672. parseEmptyStatement(node) {
  15673. this.next();
  15674. return this.finishNode(node, "EmptyStatement");
  15675. }
  15676. parseLabeledStatement(node, maybeName, expr, flags) {
  15677. for (const label of this.state.labels) {
  15678. if (label.name === maybeName) {
  15679. this.raise(Errors.LabelRedeclaration, expr, {
  15680. labelName: maybeName
  15681. });
  15682. }
  15683. }
  15684. const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
  15685. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  15686. const label = this.state.labels[i];
  15687. if (label.statementStart === node.start) {
  15688. label.statementStart = this.sourceToOffsetPos(this.state.start);
  15689. label.kind = kind;
  15690. } else {
  15691. break;
  15692. }
  15693. }
  15694. this.state.labels.push({
  15695. name: maybeName,
  15696. kind: kind,
  15697. statementStart: this.sourceToOffsetPos(this.state.start)
  15698. });
  15699. node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement();
  15700. this.state.labels.pop();
  15701. node.label = expr;
  15702. return this.finishNode(node, "LabeledStatement");
  15703. }
  15704. parseExpressionStatement(node, expr, decorators) {
  15705. node.expression = expr;
  15706. this.semicolon();
  15707. return this.finishNode(node, "ExpressionStatement");
  15708. }
  15709. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  15710. const node = this.startNode();
  15711. if (allowDirectives) {
  15712. this.state.strictErrors.clear();
  15713. }
  15714. this.expect(5);
  15715. if (createNewLexicalScope) {
  15716. this.scope.enter(0);
  15717. }
  15718. this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse);
  15719. if (createNewLexicalScope) {
  15720. this.scope.exit();
  15721. }
  15722. return this.finishNode(node, "BlockStatement");
  15723. }
  15724. isValidDirective(stmt) {
  15725. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  15726. }
  15727. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  15728. const body = node.body = [];
  15729. const directives = node.directives = [];
  15730. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  15731. }
  15732. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  15733. const oldStrict = this.state.strict;
  15734. let hasStrictModeDirective = false;
  15735. let parsedNonDirective = false;
  15736. while (!this.match(end)) {
  15737. const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
  15738. if (directives && !parsedNonDirective) {
  15739. if (this.isValidDirective(stmt)) {
  15740. const directive = this.stmtToDirective(stmt);
  15741. directives.push(directive);
  15742. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  15743. hasStrictModeDirective = true;
  15744. this.setStrict(true);
  15745. }
  15746. continue;
  15747. }
  15748. parsedNonDirective = true;
  15749. this.state.strictErrors.clear();
  15750. }
  15751. body.push(stmt);
  15752. }
  15753. afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
  15754. if (!oldStrict) {
  15755. this.setStrict(false);
  15756. }
  15757. this.next();
  15758. }
  15759. parseFor(node, init) {
  15760. node.init = init;
  15761. this.semicolon(false);
  15762. node.test = this.match(13) ? null : this.parseExpression();
  15763. this.semicolon(false);
  15764. node.update = this.match(11) ? null : this.parseExpression();
  15765. this.expect(11);
  15766. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15767. this.scope.exit();
  15768. this.state.labels.pop();
  15769. return this.finishNode(node, "ForStatement");
  15770. }
  15771. parseForIn(node, init, awaitAt) {
  15772. const isForIn = this.match(58);
  15773. this.next();
  15774. if (isForIn) {
  15775. if (awaitAt !== null) this.unexpected(awaitAt);
  15776. } else {
  15777. node.await = awaitAt !== null;
  15778. }
  15779. if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || !this.options.annexB || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
  15780. this.raise(Errors.ForInOfLoopInitializer, init, {
  15781. type: isForIn ? "ForInStatement" : "ForOfStatement"
  15782. });
  15783. }
  15784. if (init.type === "AssignmentPattern") {
  15785. this.raise(Errors.InvalidLhs, init, {
  15786. ancestor: {
  15787. type: "ForStatement"
  15788. }
  15789. });
  15790. }
  15791. node.left = init;
  15792. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  15793. this.expect(11);
  15794. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15795. this.scope.exit();
  15796. this.state.labels.pop();
  15797. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  15798. }
  15799. parseVar(node, isFor, kind, allowMissingInitializer = false) {
  15800. const declarations = node.declarations = [];
  15801. node.kind = kind;
  15802. for (;;) {
  15803. const decl = this.startNode();
  15804. this.parseVarId(decl, kind);
  15805. decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  15806. if (decl.init === null && !allowMissingInitializer) {
  15807. if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) {
  15808. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15809. kind: "destructuring"
  15810. });
  15811. } else if ((kind === "const" || kind === "using" || kind === "await using") && !(this.match(58) || this.isContextual(102))) {
  15812. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15813. kind
  15814. });
  15815. }
  15816. }
  15817. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  15818. if (!this.eat(12)) break;
  15819. }
  15820. return node;
  15821. }
  15822. parseVarId(decl, kind) {
  15823. const id = this.parseBindingAtom();
  15824. if (kind === "using" || kind === "await using") {
  15825. if (id.type === "ArrayPattern" || id.type === "ObjectPattern") {
  15826. this.raise(Errors.UsingDeclarationHasBindingPattern, id.loc.start);
  15827. }
  15828. } else {
  15829. if (id.type === "VoidPattern") {
  15830. this.raise(Errors.UnexpectedVoidPattern, id.loc.start);
  15831. }
  15832. }
  15833. this.checkLVal(id, {
  15834. type: "VariableDeclarator"
  15835. }, kind === "var" ? 5 : 8201);
  15836. decl.id = id;
  15837. }
  15838. parseAsyncFunctionExpression(node) {
  15839. return this.parseFunction(node, 8);
  15840. }
  15841. parseFunction(node, flags = 0) {
  15842. const hangingDeclaration = flags & 2;
  15843. const isDeclaration = !!(flags & 1);
  15844. const requireId = isDeclaration && !(flags & 4);
  15845. const isAsync = !!(flags & 8);
  15846. this.initFunction(node, isAsync);
  15847. if (this.match(55)) {
  15848. if (hangingDeclaration) {
  15849. this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc);
  15850. }
  15851. this.next();
  15852. node.generator = true;
  15853. }
  15854. if (isDeclaration) {
  15855. node.id = this.parseFunctionId(requireId);
  15856. }
  15857. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  15858. this.state.maybeInArrowParameters = false;
  15859. this.scope.enter(514);
  15860. this.prodParam.enter(functionFlags(isAsync, node.generator));
  15861. if (!isDeclaration) {
  15862. node.id = this.parseFunctionId();
  15863. }
  15864. this.parseFunctionParams(node, false);
  15865. this.withSmartMixTopicForbiddingContext(() => {
  15866. this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
  15867. });
  15868. this.prodParam.exit();
  15869. this.scope.exit();
  15870. if (isDeclaration && !hangingDeclaration) {
  15871. this.registerFunctionStatementId(node);
  15872. }
  15873. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  15874. return node;
  15875. }
  15876. parseFunctionId(requireId) {
  15877. return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null;
  15878. }
  15879. parseFunctionParams(node, isConstructor) {
  15880. this.expect(10);
  15881. this.expressionScope.enter(newParameterDeclarationScope());
  15882. node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0));
  15883. this.expressionScope.exit();
  15884. }
  15885. registerFunctionStatementId(node) {
  15886. if (!node.id) return;
  15887. this.scope.declareName(node.id.name, !this.options.annexB || this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? 5 : 8201 : 17, node.id.loc.start);
  15888. }
  15889. parseClass(node, isStatement, optionalId) {
  15890. this.next();
  15891. const oldStrict = this.state.strict;
  15892. this.state.strict = true;
  15893. this.parseClassId(node, isStatement, optionalId);
  15894. this.parseClassSuper(node);
  15895. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  15896. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  15897. }
  15898. isClassProperty() {
  15899. return this.match(29) || this.match(13) || this.match(8);
  15900. }
  15901. isClassMethod() {
  15902. return this.match(10);
  15903. }
  15904. nameIsConstructor(key) {
  15905. return key.type === "Identifier" && key.name === "constructor" || key.type === "StringLiteral" && key.value === "constructor";
  15906. }
  15907. isNonstaticConstructor(method) {
  15908. return !method.computed && !method.static && this.nameIsConstructor(method.key);
  15909. }
  15910. parseClassBody(hadSuperClass, oldStrict) {
  15911. this.classScope.enter();
  15912. const state = {
  15913. hadConstructor: false,
  15914. hadSuperClass
  15915. };
  15916. let decorators = [];
  15917. const classBody = this.startNode();
  15918. classBody.body = [];
  15919. this.expect(5);
  15920. this.withSmartMixTopicForbiddingContext(() => {
  15921. while (!this.match(8)) {
  15922. if (this.eat(13)) {
  15923. if (decorators.length > 0) {
  15924. throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc);
  15925. }
  15926. continue;
  15927. }
  15928. if (this.match(26)) {
  15929. decorators.push(this.parseDecorator());
  15930. continue;
  15931. }
  15932. const member = this.startNode();
  15933. if (decorators.length) {
  15934. member.decorators = decorators;
  15935. this.resetStartLocationFromNode(member, decorators[0]);
  15936. decorators = [];
  15937. }
  15938. this.parseClassMember(classBody, member, state);
  15939. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  15940. this.raise(Errors.DecoratorConstructor, member);
  15941. }
  15942. }
  15943. });
  15944. this.state.strict = oldStrict;
  15945. this.next();
  15946. if (decorators.length) {
  15947. throw this.raise(Errors.TrailingDecorator, this.state.startLoc);
  15948. }
  15949. this.classScope.exit();
  15950. return this.finishNode(classBody, "ClassBody");
  15951. }
  15952. parseClassMemberFromModifier(classBody, member) {
  15953. const key = this.parseIdentifier(true);
  15954. if (this.isClassMethod()) {
  15955. const method = member;
  15956. method.kind = "method";
  15957. method.computed = false;
  15958. method.key = key;
  15959. method.static = false;
  15960. this.pushClassMethod(classBody, method, false, false, false, false);
  15961. return true;
  15962. } else if (this.isClassProperty()) {
  15963. const prop = member;
  15964. prop.computed = false;
  15965. prop.key = key;
  15966. prop.static = false;
  15967. classBody.body.push(this.parseClassProperty(prop));
  15968. return true;
  15969. }
  15970. this.resetPreviousNodeTrailingComments(key);
  15971. return false;
  15972. }
  15973. parseClassMember(classBody, member, state) {
  15974. const isStatic = this.isContextual(106);
  15975. if (isStatic) {
  15976. if (this.parseClassMemberFromModifier(classBody, member)) {
  15977. return;
  15978. }
  15979. if (this.eat(5)) {
  15980. this.parseClassStaticBlock(classBody, member);
  15981. return;
  15982. }
  15983. }
  15984. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  15985. }
  15986. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  15987. const publicMethod = member;
  15988. const privateMethod = member;
  15989. const publicProp = member;
  15990. const privateProp = member;
  15991. const accessorProp = member;
  15992. const method = publicMethod;
  15993. const publicMember = publicMethod;
  15994. member.static = isStatic;
  15995. this.parsePropertyNamePrefixOperator(member);
  15996. if (this.eat(55)) {
  15997. method.kind = "method";
  15998. const isPrivateName = this.match(139);
  15999. this.parseClassElementName(method);
  16000. this.parsePostMemberNameModifiers(method);
  16001. if (isPrivateName) {
  16002. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  16003. return;
  16004. }
  16005. if (this.isNonstaticConstructor(publicMethod)) {
  16006. this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
  16007. }
  16008. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  16009. return;
  16010. }
  16011. const isContextual = !this.state.containsEsc && tokenIsIdentifier(this.state.type);
  16012. const key = this.parseClassElementName(member);
  16013. const maybeContextualKw = isContextual ? key.name : null;
  16014. const isPrivate = this.isPrivateName(key);
  16015. const maybeQuestionTokenStartLoc = this.state.startLoc;
  16016. this.parsePostMemberNameModifiers(publicMember);
  16017. if (this.isClassMethod()) {
  16018. method.kind = "method";
  16019. if (isPrivate) {
  16020. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  16021. return;
  16022. }
  16023. const isConstructor = this.isNonstaticConstructor(publicMethod);
  16024. let allowsDirectSuper = false;
  16025. if (isConstructor) {
  16026. publicMethod.kind = "constructor";
  16027. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  16028. this.raise(Errors.DuplicateConstructor, key);
  16029. }
  16030. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  16031. this.raise(Errors.OverrideOnConstructor, key);
  16032. }
  16033. state.hadConstructor = true;
  16034. allowsDirectSuper = state.hadSuperClass;
  16035. }
  16036. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  16037. } else if (this.isClassProperty()) {
  16038. if (isPrivate) {
  16039. this.pushClassPrivateProperty(classBody, privateProp);
  16040. } else {
  16041. this.pushClassProperty(classBody, publicProp);
  16042. }
  16043. } else if (maybeContextualKw === "async" && !this.isLineTerminator()) {
  16044. this.resetPreviousNodeTrailingComments(key);
  16045. const isGenerator = this.eat(55);
  16046. if (publicMember.optional) {
  16047. this.unexpected(maybeQuestionTokenStartLoc);
  16048. }
  16049. method.kind = "method";
  16050. const isPrivate = this.match(139);
  16051. this.parseClassElementName(method);
  16052. this.parsePostMemberNameModifiers(publicMember);
  16053. if (isPrivate) {
  16054. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  16055. } else {
  16056. if (this.isNonstaticConstructor(publicMethod)) {
  16057. this.raise(Errors.ConstructorIsAsync, publicMethod.key);
  16058. }
  16059. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  16060. }
  16061. } else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(55) && this.isLineTerminator())) {
  16062. this.resetPreviousNodeTrailingComments(key);
  16063. method.kind = maybeContextualKw;
  16064. const isPrivate = this.match(139);
  16065. this.parseClassElementName(publicMethod);
  16066. if (isPrivate) {
  16067. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  16068. } else {
  16069. if (this.isNonstaticConstructor(publicMethod)) {
  16070. this.raise(Errors.ConstructorIsAccessor, publicMethod.key);
  16071. }
  16072. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  16073. }
  16074. this.checkGetterSetterParams(publicMethod);
  16075. } else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
  16076. this.expectPlugin("decoratorAutoAccessors");
  16077. this.resetPreviousNodeTrailingComments(key);
  16078. const isPrivate = this.match(139);
  16079. this.parseClassElementName(publicProp);
  16080. this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
  16081. } else if (this.isLineTerminator()) {
  16082. if (isPrivate) {
  16083. this.pushClassPrivateProperty(classBody, privateProp);
  16084. } else {
  16085. this.pushClassProperty(classBody, publicProp);
  16086. }
  16087. } else {
  16088. this.unexpected();
  16089. }
  16090. }
  16091. parseClassElementName(member) {
  16092. const {
  16093. type,
  16094. value
  16095. } = this.state;
  16096. if ((type === 132 || type === 134) && member.static && value === "prototype") {
  16097. this.raise(Errors.StaticPrototype, this.state.startLoc);
  16098. }
  16099. if (type === 139) {
  16100. if (value === "constructor") {
  16101. this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
  16102. }
  16103. const key = this.parsePrivateName();
  16104. member.key = key;
  16105. return key;
  16106. }
  16107. this.parsePropertyName(member);
  16108. return member.key;
  16109. }
  16110. parseClassStaticBlock(classBody, member) {
  16111. var _member$decorators;
  16112. this.scope.enter(576 | 128 | 16);
  16113. const oldLabels = this.state.labels;
  16114. this.state.labels = [];
  16115. this.prodParam.enter(0);
  16116. const body = member.body = [];
  16117. this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
  16118. this.prodParam.exit();
  16119. this.scope.exit();
  16120. this.state.labels = oldLabels;
  16121. classBody.body.push(this.finishNode(member, "StaticBlock"));
  16122. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  16123. this.raise(Errors.DecoratorStaticBlock, member);
  16124. }
  16125. }
  16126. pushClassProperty(classBody, prop) {
  16127. if (!prop.computed && this.nameIsConstructor(prop.key)) {
  16128. this.raise(Errors.ConstructorClassField, prop.key);
  16129. }
  16130. classBody.body.push(this.parseClassProperty(prop));
  16131. }
  16132. pushClassPrivateProperty(classBody, prop) {
  16133. const node = this.parseClassPrivateProperty(prop);
  16134. classBody.body.push(node);
  16135. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  16136. }
  16137. pushClassAccessorProperty(classBody, prop, isPrivate) {
  16138. if (!isPrivate && !prop.computed && this.nameIsConstructor(prop.key)) {
  16139. this.raise(Errors.ConstructorClassField, prop.key);
  16140. }
  16141. const node = this.parseClassAccessorProperty(prop);
  16142. classBody.body.push(node);
  16143. if (isPrivate) {
  16144. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  16145. }
  16146. }
  16147. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  16148. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  16149. }
  16150. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  16151. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  16152. classBody.body.push(node);
  16153. const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0;
  16154. this.declareClassPrivateMethodInScope(node, kind);
  16155. }
  16156. declareClassPrivateMethodInScope(node, kind) {
  16157. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
  16158. }
  16159. parsePostMemberNameModifiers(methodOrProp) {}
  16160. parseClassPrivateProperty(node) {
  16161. this.parseInitializer(node);
  16162. this.semicolon();
  16163. return this.finishNode(node, "ClassPrivateProperty");
  16164. }
  16165. parseClassProperty(node) {
  16166. this.parseInitializer(node);
  16167. this.semicolon();
  16168. return this.finishNode(node, "ClassProperty");
  16169. }
  16170. parseClassAccessorProperty(node) {
  16171. this.parseInitializer(node);
  16172. this.semicolon();
  16173. return this.finishNode(node, "ClassAccessorProperty");
  16174. }
  16175. parseInitializer(node) {
  16176. this.scope.enter(576 | 16);
  16177. this.expressionScope.enter(newExpressionScope());
  16178. this.prodParam.enter(0);
  16179. node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
  16180. this.expressionScope.exit();
  16181. this.prodParam.exit();
  16182. this.scope.exit();
  16183. }
  16184. parseClassId(node, isStatement, optionalId, bindingType = 8331) {
  16185. if (tokenIsIdentifier(this.state.type)) {
  16186. node.id = this.parseIdentifier();
  16187. if (isStatement) {
  16188. this.declareNameFromIdentifier(node.id, bindingType);
  16189. }
  16190. } else {
  16191. if (optionalId || !isStatement) {
  16192. node.id = null;
  16193. } else {
  16194. throw this.raise(Errors.MissingClassName, this.state.startLoc);
  16195. }
  16196. }
  16197. }
  16198. parseClassSuper(node) {
  16199. node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
  16200. }
  16201. parseExport(node, decorators) {
  16202. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
  16203. const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  16204. const parseAfterDefault = !hasDefault || this.eat(12);
  16205. const hasStar = parseAfterDefault && this.eatExportStar(node);
  16206. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  16207. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12));
  16208. const isFromRequired = hasDefault || hasStar;
  16209. if (hasStar && !hasNamespace) {
  16210. if (hasDefault) this.unexpected();
  16211. if (decorators) {
  16212. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  16213. }
  16214. this.parseExportFrom(node, true);
  16215. this.sawUnambiguousESM = true;
  16216. return this.finishNode(node, "ExportAllDeclaration");
  16217. }
  16218. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  16219. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
  16220. this.unexpected(null, 5);
  16221. }
  16222. if (hasNamespace && parseAfterNamespace) {
  16223. this.unexpected(null, 98);
  16224. }
  16225. let hasDeclaration;
  16226. if (isFromRequired || hasSpecifiers) {
  16227. hasDeclaration = false;
  16228. if (decorators) {
  16229. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  16230. }
  16231. this.parseExportFrom(node, isFromRequired);
  16232. } else {
  16233. hasDeclaration = this.maybeParseExportDeclaration(node);
  16234. }
  16235. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  16236. var _node2$declaration;
  16237. const node2 = node;
  16238. this.checkExport(node2, true, false, !!node2.source);
  16239. if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") {
  16240. this.maybeTakeDecorators(decorators, node2.declaration, node2);
  16241. } else if (decorators) {
  16242. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  16243. }
  16244. this.sawUnambiguousESM = true;
  16245. return this.finishNode(node2, "ExportNamedDeclaration");
  16246. }
  16247. if (this.eat(65)) {
  16248. const node2 = node;
  16249. const decl = this.parseExportDefaultExpression();
  16250. node2.declaration = decl;
  16251. if (decl.type === "ClassDeclaration") {
  16252. this.maybeTakeDecorators(decorators, decl, node2);
  16253. } else if (decorators) {
  16254. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  16255. }
  16256. this.checkExport(node2, true, true);
  16257. this.sawUnambiguousESM = true;
  16258. return this.finishNode(node2, "ExportDefaultDeclaration");
  16259. }
  16260. this.unexpected(null, 5);
  16261. }
  16262. eatExportStar(node) {
  16263. return this.eat(55);
  16264. }
  16265. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  16266. if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) {
  16267. this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start);
  16268. const id = maybeDefaultIdentifier || this.parseIdentifier(true);
  16269. const specifier = this.startNodeAtNode(id);
  16270. specifier.exported = id;
  16271. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  16272. return true;
  16273. }
  16274. return false;
  16275. }
  16276. maybeParseExportNamespaceSpecifier(node) {
  16277. if (this.isContextual(93)) {
  16278. var _ref, _ref$specifiers;
  16279. (_ref$specifiers = (_ref = node).specifiers) != null ? _ref$specifiers : _ref.specifiers = [];
  16280. const specifier = this.startNodeAt(this.state.lastTokStartLoc);
  16281. this.next();
  16282. specifier.exported = this.parseModuleExportName();
  16283. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  16284. return true;
  16285. }
  16286. return false;
  16287. }
  16288. maybeParseExportNamedSpecifiers(node) {
  16289. if (this.match(5)) {
  16290. const node2 = node;
  16291. if (!node2.specifiers) node2.specifiers = [];
  16292. const isTypeExport = node2.exportKind === "type";
  16293. node2.specifiers.push(...this.parseExportSpecifiers(isTypeExport));
  16294. node2.source = null;
  16295. if (this.hasPlugin("importAssertions")) {
  16296. node2.assertions = [];
  16297. } else {
  16298. node2.attributes = [];
  16299. }
  16300. node2.declaration = null;
  16301. return true;
  16302. }
  16303. return false;
  16304. }
  16305. maybeParseExportDeclaration(node) {
  16306. if (this.shouldParseExportDeclaration()) {
  16307. node.specifiers = [];
  16308. node.source = null;
  16309. if (this.hasPlugin("importAssertions")) {
  16310. node.assertions = [];
  16311. } else {
  16312. node.attributes = [];
  16313. }
  16314. node.declaration = this.parseExportDeclaration(node);
  16315. return true;
  16316. }
  16317. return false;
  16318. }
  16319. isAsyncFunction() {
  16320. if (!this.isContextual(95)) return false;
  16321. const next = this.nextTokenInLineStart();
  16322. return this.isUnparsedContextual(next, "function");
  16323. }
  16324. parseExportDefaultExpression() {
  16325. const expr = this.startNode();
  16326. if (this.match(68)) {
  16327. this.next();
  16328. return this.parseFunction(expr, 1 | 4);
  16329. } else if (this.isAsyncFunction()) {
  16330. this.next();
  16331. this.next();
  16332. return this.parseFunction(expr, 1 | 4 | 8);
  16333. }
  16334. if (this.match(80)) {
  16335. return this.parseClass(expr, true, true);
  16336. }
  16337. if (this.match(26)) {
  16338. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  16339. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  16340. }
  16341. return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
  16342. }
  16343. if (this.match(75) || this.match(74) || this.isLet() || this.isUsing() || this.isAwaitUsing()) {
  16344. throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
  16345. }
  16346. const res = this.parseMaybeAssignAllowIn();
  16347. this.semicolon();
  16348. return res;
  16349. }
  16350. parseExportDeclaration(node) {
  16351. if (this.match(80)) {
  16352. const node = this.parseClass(this.startNode(), true, false);
  16353. return node;
  16354. }
  16355. return this.parseStatementListItem();
  16356. }
  16357. isExportDefaultSpecifier() {
  16358. const {
  16359. type
  16360. } = this.state;
  16361. if (tokenIsIdentifier(type)) {
  16362. if (type === 95 && !this.state.containsEsc || type === 100) {
  16363. return false;
  16364. }
  16365. if ((type === 130 || type === 129) && !this.state.containsEsc) {
  16366. const next = this.nextTokenStart();
  16367. const nextChar = this.input.charCodeAt(next);
  16368. if (nextChar === 123 || this.chStartsBindingIdentifier(nextChar, next) && !this.input.startsWith("from", next)) {
  16369. this.expectOnePlugin(["flow", "typescript"]);
  16370. return false;
  16371. }
  16372. }
  16373. } else if (!this.match(65)) {
  16374. return false;
  16375. }
  16376. const next = this.nextTokenStart();
  16377. const hasFrom = this.isUnparsedContextual(next, "from");
  16378. if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) {
  16379. return true;
  16380. }
  16381. if (this.match(65) && hasFrom) {
  16382. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  16383. return nextAfterFrom === 34 || nextAfterFrom === 39;
  16384. }
  16385. return false;
  16386. }
  16387. parseExportFrom(node, expect) {
  16388. if (this.eatContextual(98)) {
  16389. node.source = this.parseImportSource();
  16390. this.checkExport(node);
  16391. this.maybeParseImportAttributes(node);
  16392. this.checkJSONModuleImport(node);
  16393. } else if (expect) {
  16394. this.unexpected();
  16395. }
  16396. this.semicolon();
  16397. }
  16398. shouldParseExportDeclaration() {
  16399. const {
  16400. type
  16401. } = this.state;
  16402. if (type === 26) {
  16403. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  16404. if (this.hasPlugin("decorators")) {
  16405. if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  16406. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  16407. }
  16408. return true;
  16409. }
  16410. }
  16411. if (this.isUsing()) {
  16412. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  16413. return true;
  16414. }
  16415. if (this.isAwaitUsing()) {
  16416. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  16417. return true;
  16418. }
  16419. return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction();
  16420. }
  16421. checkExport(node, checkNames, isDefault, isFrom) {
  16422. if (checkNames) {
  16423. var _node$specifiers;
  16424. if (isDefault) {
  16425. this.checkDuplicateExports(node, "default");
  16426. if (this.hasPlugin("exportDefaultFrom")) {
  16427. var _declaration$extra;
  16428. const declaration = node.declaration;
  16429. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  16430. this.raise(Errors.ExportDefaultFromAsIdentifier, declaration);
  16431. }
  16432. }
  16433. } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) {
  16434. for (const specifier of node.specifiers) {
  16435. const {
  16436. exported
  16437. } = specifier;
  16438. const exportName = exported.type === "Identifier" ? exported.name : exported.value;
  16439. this.checkDuplicateExports(specifier, exportName);
  16440. if (!isFrom && specifier.local) {
  16441. const {
  16442. local
  16443. } = specifier;
  16444. if (local.type !== "Identifier") {
  16445. this.raise(Errors.ExportBindingIsString, specifier, {
  16446. localName: local.value,
  16447. exportName
  16448. });
  16449. } else {
  16450. this.checkReservedWord(local.name, local.loc.start, true, false);
  16451. this.scope.checkLocalExport(local);
  16452. }
  16453. }
  16454. }
  16455. } else if (node.declaration) {
  16456. const decl = node.declaration;
  16457. if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") {
  16458. const {
  16459. id
  16460. } = decl;
  16461. if (!id) throw new Error("Assertion failure");
  16462. this.checkDuplicateExports(node, id.name);
  16463. } else if (decl.type === "VariableDeclaration") {
  16464. for (const declaration of decl.declarations) {
  16465. this.checkDeclaration(declaration.id);
  16466. }
  16467. }
  16468. }
  16469. }
  16470. }
  16471. checkDeclaration(node) {
  16472. if (node.type === "Identifier") {
  16473. this.checkDuplicateExports(node, node.name);
  16474. } else if (node.type === "ObjectPattern") {
  16475. for (const prop of node.properties) {
  16476. this.checkDeclaration(prop);
  16477. }
  16478. } else if (node.type === "ArrayPattern") {
  16479. for (const elem of node.elements) {
  16480. if (elem) {
  16481. this.checkDeclaration(elem);
  16482. }
  16483. }
  16484. } else if (node.type === "ObjectProperty") {
  16485. this.checkDeclaration(node.value);
  16486. } else if (node.type === "RestElement") {
  16487. this.checkDeclaration(node.argument);
  16488. } else if (node.type === "AssignmentPattern") {
  16489. this.checkDeclaration(node.left);
  16490. }
  16491. }
  16492. checkDuplicateExports(node, exportName) {
  16493. if (this.exportedIdentifiers.has(exportName)) {
  16494. if (exportName === "default") {
  16495. this.raise(Errors.DuplicateDefaultExport, node);
  16496. } else {
  16497. this.raise(Errors.DuplicateExport, node, {
  16498. exportName
  16499. });
  16500. }
  16501. }
  16502. this.exportedIdentifiers.add(exportName);
  16503. }
  16504. parseExportSpecifiers(isInTypeExport) {
  16505. const nodes = [];
  16506. let first = true;
  16507. this.expect(5);
  16508. while (!this.eat(8)) {
  16509. if (first) {
  16510. first = false;
  16511. } else {
  16512. this.expect(12);
  16513. if (this.eat(8)) break;
  16514. }
  16515. const isMaybeTypeOnly = this.isContextual(130);
  16516. const isString = this.match(134);
  16517. const node = this.startNode();
  16518. node.local = this.parseModuleExportName();
  16519. nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
  16520. }
  16521. return nodes;
  16522. }
  16523. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  16524. if (this.eatContextual(93)) {
  16525. node.exported = this.parseModuleExportName();
  16526. } else if (isString) {
  16527. node.exported = this.cloneStringLiteral(node.local);
  16528. } else if (!node.exported) {
  16529. node.exported = this.cloneIdentifier(node.local);
  16530. }
  16531. return this.finishNode(node, "ExportSpecifier");
  16532. }
  16533. parseModuleExportName() {
  16534. if (this.match(134)) {
  16535. const result = this.parseStringLiteral(this.state.value);
  16536. const surrogate = loneSurrogate.exec(result.value);
  16537. if (surrogate) {
  16538. this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
  16539. surrogateCharCode: surrogate[0].charCodeAt(0)
  16540. });
  16541. }
  16542. return result;
  16543. }
  16544. return this.parseIdentifier(true);
  16545. }
  16546. isJSONModuleImport(node) {
  16547. if (node.assertions != null) {
  16548. return node.assertions.some(({
  16549. key,
  16550. value
  16551. }) => {
  16552. return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
  16553. });
  16554. }
  16555. return false;
  16556. }
  16557. checkImportReflection(node) {
  16558. const {
  16559. specifiers
  16560. } = node;
  16561. const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
  16562. if (node.phase === "source") {
  16563. if (singleBindingType !== "ImportDefaultSpecifier") {
  16564. this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start);
  16565. }
  16566. } else if (node.phase === "defer") {
  16567. if (singleBindingType !== "ImportNamespaceSpecifier") {
  16568. this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start);
  16569. }
  16570. } else if (node.module) {
  16571. var _node$assertions;
  16572. if (singleBindingType !== "ImportDefaultSpecifier") {
  16573. this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start);
  16574. }
  16575. if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) {
  16576. this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start);
  16577. }
  16578. }
  16579. }
  16580. checkJSONModuleImport(node) {
  16581. if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
  16582. const {
  16583. specifiers
  16584. } = node;
  16585. if (specifiers != null) {
  16586. const nonDefaultNamedSpecifier = specifiers.find(specifier => {
  16587. let imported;
  16588. if (specifier.type === "ExportSpecifier") {
  16589. imported = specifier.local;
  16590. } else if (specifier.type === "ImportSpecifier") {
  16591. imported = specifier.imported;
  16592. }
  16593. if (imported !== undefined) {
  16594. return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
  16595. }
  16596. });
  16597. if (nonDefaultNamedSpecifier !== undefined) {
  16598. this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start);
  16599. }
  16600. }
  16601. }
  16602. }
  16603. isPotentialImportPhase(isExport) {
  16604. if (isExport) return false;
  16605. return this.isContextual(105) || this.isContextual(97) || this.isContextual(127);
  16606. }
  16607. applyImportPhase(node, isExport, phase, loc) {
  16608. if (isExport) {
  16609. return;
  16610. }
  16611. if (phase === "module") {
  16612. this.expectPlugin("importReflection", loc);
  16613. node.module = true;
  16614. } else if (this.hasPlugin("importReflection")) {
  16615. node.module = false;
  16616. }
  16617. if (phase === "source") {
  16618. this.expectPlugin("sourcePhaseImports", loc);
  16619. node.phase = "source";
  16620. } else if (phase === "defer") {
  16621. this.expectPlugin("deferredImportEvaluation", loc);
  16622. node.phase = "defer";
  16623. } else if (this.hasPlugin("sourcePhaseImports")) {
  16624. node.phase = null;
  16625. }
  16626. }
  16627. parseMaybeImportPhase(node, isExport) {
  16628. if (!this.isPotentialImportPhase(isExport)) {
  16629. this.applyImportPhase(node, isExport, null);
  16630. return null;
  16631. }
  16632. const phaseIdentifier = this.startNode();
  16633. const phaseIdentifierName = this.parseIdentifierName(true);
  16634. const {
  16635. type
  16636. } = this.state;
  16637. const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16638. if (isImportPhase) {
  16639. this.applyImportPhase(node, isExport, phaseIdentifierName, phaseIdentifier.loc.start);
  16640. return null;
  16641. } else {
  16642. this.applyImportPhase(node, isExport, null);
  16643. return this.createIdentifier(phaseIdentifier, phaseIdentifierName);
  16644. }
  16645. }
  16646. isPrecedingIdImportPhase(phase) {
  16647. const {
  16648. type
  16649. } = this.state;
  16650. return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16651. }
  16652. parseImport(node) {
  16653. if (this.match(134)) {
  16654. return this.parseImportSourceAndAttributes(node);
  16655. }
  16656. return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
  16657. }
  16658. parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
  16659. node.specifiers = [];
  16660. const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
  16661. const parseNext = !hasDefault || this.eat(12);
  16662. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  16663. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  16664. this.expectContextual(98);
  16665. return this.parseImportSourceAndAttributes(node);
  16666. }
  16667. parseImportSourceAndAttributes(node) {
  16668. var _node$specifiers2;
  16669. (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = [];
  16670. node.source = this.parseImportSource();
  16671. this.maybeParseImportAttributes(node);
  16672. this.checkImportReflection(node);
  16673. this.checkJSONModuleImport(node);
  16674. this.semicolon();
  16675. this.sawUnambiguousESM = true;
  16676. return this.finishNode(node, "ImportDeclaration");
  16677. }
  16678. parseImportSource() {
  16679. if (!this.match(134)) this.unexpected();
  16680. return this.parseExprAtom();
  16681. }
  16682. parseImportSpecifierLocal(node, specifier, type) {
  16683. specifier.local = this.parseIdentifier();
  16684. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  16685. }
  16686. finishImportSpecifier(specifier, type, bindingType = 8201) {
  16687. this.checkLVal(specifier.local, {
  16688. type
  16689. }, bindingType);
  16690. return this.finishNode(specifier, type);
  16691. }
  16692. parseImportAttributes() {
  16693. this.expect(5);
  16694. const attrs = [];
  16695. const attrNames = new Set();
  16696. do {
  16697. if (this.match(8)) {
  16698. break;
  16699. }
  16700. const node = this.startNode();
  16701. const keyName = this.state.value;
  16702. if (attrNames.has(keyName)) {
  16703. this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, {
  16704. key: keyName
  16705. });
  16706. }
  16707. attrNames.add(keyName);
  16708. if (this.match(134)) {
  16709. node.key = this.parseStringLiteral(keyName);
  16710. } else {
  16711. node.key = this.parseIdentifier(true);
  16712. }
  16713. this.expect(14);
  16714. if (!this.match(134)) {
  16715. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16716. }
  16717. node.value = this.parseStringLiteral(this.state.value);
  16718. attrs.push(this.finishNode(node, "ImportAttribute"));
  16719. } while (this.eat(12));
  16720. this.expect(8);
  16721. return attrs;
  16722. }
  16723. parseModuleAttributes() {
  16724. const attrs = [];
  16725. const attributes = new Set();
  16726. do {
  16727. const node = this.startNode();
  16728. node.key = this.parseIdentifier(true);
  16729. if (node.key.name !== "type") {
  16730. this.raise(Errors.ModuleAttributeDifferentFromType, node.key);
  16731. }
  16732. if (attributes.has(node.key.name)) {
  16733. this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, {
  16734. key: node.key.name
  16735. });
  16736. }
  16737. attributes.add(node.key.name);
  16738. this.expect(14);
  16739. if (!this.match(134)) {
  16740. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16741. }
  16742. node.value = this.parseStringLiteral(this.state.value);
  16743. attrs.push(this.finishNode(node, "ImportAttribute"));
  16744. } while (this.eat(12));
  16745. return attrs;
  16746. }
  16747. maybeParseImportAttributes(node) {
  16748. let attributes;
  16749. {
  16750. var useWith = false;
  16751. }
  16752. if (this.match(76)) {
  16753. if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) {
  16754. return;
  16755. }
  16756. this.next();
  16757. if (this.hasPlugin("moduleAttributes")) {
  16758. attributes = this.parseModuleAttributes();
  16759. this.addExtra(node, "deprecatedWithLegacySyntax", true);
  16760. } else {
  16761. attributes = this.parseImportAttributes();
  16762. }
  16763. {
  16764. useWith = true;
  16765. }
  16766. } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) {
  16767. if (!this.hasPlugin("deprecatedImportAssert") && !this.hasPlugin("importAssertions")) {
  16768. this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc);
  16769. }
  16770. if (!this.hasPlugin("importAssertions")) {
  16771. this.addExtra(node, "deprecatedAssertSyntax", true);
  16772. }
  16773. this.next();
  16774. attributes = this.parseImportAttributes();
  16775. } else {
  16776. attributes = [];
  16777. }
  16778. if (!useWith && this.hasPlugin("importAssertions")) {
  16779. node.assertions = attributes;
  16780. } else {
  16781. node.attributes = attributes;
  16782. }
  16783. }
  16784. maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) {
  16785. if (maybeDefaultIdentifier) {
  16786. const specifier = this.startNodeAtNode(maybeDefaultIdentifier);
  16787. specifier.local = maybeDefaultIdentifier;
  16788. node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier"));
  16789. return true;
  16790. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  16791. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier");
  16792. return true;
  16793. }
  16794. return false;
  16795. }
  16796. maybeParseStarImportSpecifier(node) {
  16797. if (this.match(55)) {
  16798. const specifier = this.startNode();
  16799. this.next();
  16800. this.expectContextual(93);
  16801. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
  16802. return true;
  16803. }
  16804. return false;
  16805. }
  16806. parseNamedImportSpecifiers(node) {
  16807. let first = true;
  16808. this.expect(5);
  16809. while (!this.eat(8)) {
  16810. if (first) {
  16811. first = false;
  16812. } else {
  16813. if (this.eat(14)) {
  16814. throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
  16815. }
  16816. this.expect(12);
  16817. if (this.eat(8)) break;
  16818. }
  16819. const specifier = this.startNode();
  16820. const importedIsString = this.match(134);
  16821. const isMaybeTypeOnly = this.isContextual(130);
  16822. specifier.imported = this.parseModuleExportName();
  16823. const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
  16824. node.specifiers.push(importSpecifier);
  16825. }
  16826. }
  16827. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  16828. if (this.eatContextual(93)) {
  16829. specifier.local = this.parseIdentifier();
  16830. } else {
  16831. const {
  16832. imported
  16833. } = specifier;
  16834. if (importedIsString) {
  16835. throw this.raise(Errors.ImportBindingIsString, specifier, {
  16836. importName: imported.value
  16837. });
  16838. }
  16839. this.checkReservedWord(imported.name, specifier.loc.start, true, true);
  16840. if (!specifier.local) {
  16841. specifier.local = this.cloneIdentifier(imported);
  16842. }
  16843. }
  16844. return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType);
  16845. }
  16846. isThisParam(param) {
  16847. return param.type === "Identifier" && param.name === "this";
  16848. }
  16849. }
  16850. class Parser extends StatementParser {
  16851. constructor(options, input, pluginsMap) {
  16852. options = getOptions(options);
  16853. super(options, input);
  16854. this.options = options;
  16855. this.initializeScopes();
  16856. this.plugins = pluginsMap;
  16857. this.filename = options.sourceFilename;
  16858. this.startIndex = options.startIndex;
  16859. let optionFlags = 0;
  16860. if (options.allowAwaitOutsideFunction) {
  16861. optionFlags |= 1;
  16862. }
  16863. if (options.allowReturnOutsideFunction) {
  16864. optionFlags |= 2;
  16865. }
  16866. if (options.allowImportExportEverywhere) {
  16867. optionFlags |= 8;
  16868. }
  16869. if (options.allowSuperOutsideMethod) {
  16870. optionFlags |= 16;
  16871. }
  16872. if (options.allowUndeclaredExports) {
  16873. optionFlags |= 64;
  16874. }
  16875. if (options.allowNewTargetOutsideFunction) {
  16876. optionFlags |= 4;
  16877. }
  16878. if (options.allowYieldOutsideFunction) {
  16879. optionFlags |= 32;
  16880. }
  16881. if (options.ranges) {
  16882. optionFlags |= 128;
  16883. }
  16884. if (options.tokens) {
  16885. optionFlags |= 256;
  16886. }
  16887. if (options.createImportExpressions) {
  16888. optionFlags |= 512;
  16889. }
  16890. if (options.createParenthesizedExpressions) {
  16891. optionFlags |= 1024;
  16892. }
  16893. if (options.errorRecovery) {
  16894. optionFlags |= 2048;
  16895. }
  16896. if (options.attachComment) {
  16897. optionFlags |= 4096;
  16898. }
  16899. if (options.annexB) {
  16900. optionFlags |= 8192;
  16901. }
  16902. this.optionFlags = optionFlags;
  16903. }
  16904. getScopeHandler() {
  16905. return ScopeHandler;
  16906. }
  16907. parse() {
  16908. this.enterInitialScopes();
  16909. const file = this.startNode();
  16910. const program = this.startNode();
  16911. this.nextToken();
  16912. file.errors = null;
  16913. this.parseTopLevel(file, program);
  16914. file.errors = this.state.errors;
  16915. file.comments.length = this.state.commentsLen;
  16916. return file;
  16917. }
  16918. }
  16919. function parse(input, options) {
  16920. var _options;
  16921. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  16922. options = Object.assign({}, options);
  16923. try {
  16924. options.sourceType = "module";
  16925. const parser = getParser(options, input);
  16926. const ast = parser.parse();
  16927. if (parser.sawUnambiguousESM) {
  16928. return ast;
  16929. }
  16930. if (parser.ambiguousScriptDifferentAst) {
  16931. try {
  16932. options.sourceType = "script";
  16933. return getParser(options, input).parse();
  16934. } catch (_unused) {}
  16935. } else {
  16936. ast.program.sourceType = "script";
  16937. }
  16938. return ast;
  16939. } catch (moduleError) {
  16940. try {
  16941. options.sourceType = "script";
  16942. return getParser(options, input).parse();
  16943. } catch (_unused2) {}
  16944. throw moduleError;
  16945. }
  16946. } else {
  16947. return getParser(options, input).parse();
  16948. }
  16949. }
  16950. function parseExpression(input, options) {
  16951. const parser = getParser(options, input);
  16952. if (parser.options.strictMode) {
  16953. parser.state.strict = true;
  16954. }
  16955. return parser.getExpression();
  16956. }
  16957. function generateExportedTokenTypes(internalTokenTypes) {
  16958. const tokenTypes = {};
  16959. for (const typeName of Object.keys(internalTokenTypes)) {
  16960. tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
  16961. }
  16962. return tokenTypes;
  16963. }
  16964. const tokTypes = generateExportedTokenTypes(tt);
  16965. function getParser(options, input) {
  16966. let cls = Parser;
  16967. const pluginsMap = new Map();
  16968. if (options != null && options.plugins) {
  16969. for (const plugin of options.plugins) {
  16970. let name, opts;
  16971. if (typeof plugin === "string") {
  16972. name = plugin;
  16973. } else {
  16974. [name, opts] = plugin;
  16975. }
  16976. if (!pluginsMap.has(name)) {
  16977. pluginsMap.set(name, opts || {});
  16978. }
  16979. }
  16980. validatePlugins(pluginsMap);
  16981. cls = getParserClass(pluginsMap);
  16982. }
  16983. return new cls(options, input, pluginsMap);
  16984. }
  16985. const parserClassCache = new Map();
  16986. function getParserClass(pluginsMap) {
  16987. const pluginList = [];
  16988. for (const name of mixinPluginNames) {
  16989. if (pluginsMap.has(name)) {
  16990. pluginList.push(name);
  16991. }
  16992. }
  16993. const key = pluginList.join("|");
  16994. let cls = parserClassCache.get(key);
  16995. if (!cls) {
  16996. cls = Parser;
  16997. for (const plugin of pluginList) {
  16998. cls = mixinPlugins[plugin](cls);
  16999. }
  17000. parserClassCache.set(key, cls);
  17001. }
  17002. return cls;
  17003. }
  17004. lib.parse = parse;
  17005. lib.parseExpression = parseExpression;
  17006. lib.tokTypes = tokTypes;
  17007. return lib;
  17008. }
  17009. var libExports = /*@__PURE__*/ requireLib();
  17010. // @ts-check
  17011. /** @typedef { import('estree').BaseNode} BaseNode */
  17012. /** @typedef {{
  17013. skip: () => void;
  17014. remove: () => void;
  17015. replace: (node: BaseNode) => void;
  17016. }} WalkerContext */
  17017. class WalkerBase {
  17018. constructor() {
  17019. /** @type {boolean} */
  17020. this.should_skip = false;
  17021. /** @type {boolean} */
  17022. this.should_remove = false;
  17023. /** @type {BaseNode | null} */
  17024. this.replacement = null;
  17025. /** @type {WalkerContext} */
  17026. this.context = {
  17027. skip: () => (this.should_skip = true),
  17028. remove: () => (this.should_remove = true),
  17029. replace: (node) => (this.replacement = node)
  17030. };
  17031. }
  17032. /**
  17033. *
  17034. * @param {any} parent
  17035. * @param {string} prop
  17036. * @param {number} index
  17037. * @param {BaseNode} node
  17038. */
  17039. replace(parent, prop, index, node) {
  17040. if (parent) {
  17041. if (index !== null) {
  17042. parent[prop][index] = node;
  17043. } else {
  17044. parent[prop] = node;
  17045. }
  17046. }
  17047. }
  17048. /**
  17049. *
  17050. * @param {any} parent
  17051. * @param {string} prop
  17052. * @param {number} index
  17053. */
  17054. remove(parent, prop, index) {
  17055. if (parent) {
  17056. if (index !== null) {
  17057. parent[prop].splice(index, 1);
  17058. } else {
  17059. delete parent[prop];
  17060. }
  17061. }
  17062. }
  17063. }
  17064. // @ts-check
  17065. /** @typedef { import('estree').BaseNode} BaseNode */
  17066. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  17067. /** @typedef {(
  17068. * this: WalkerContext,
  17069. * node: BaseNode,
  17070. * parent: BaseNode,
  17071. * key: string,
  17072. * index: number
  17073. * ) => void} SyncHandler */
  17074. class SyncWalker extends WalkerBase {
  17075. /**
  17076. *
  17077. * @param {SyncHandler} enter
  17078. * @param {SyncHandler} leave
  17079. */
  17080. constructor(enter, leave) {
  17081. super();
  17082. /** @type {SyncHandler} */
  17083. this.enter = enter;
  17084. /** @type {SyncHandler} */
  17085. this.leave = leave;
  17086. }
  17087. /**
  17088. *
  17089. * @param {BaseNode} node
  17090. * @param {BaseNode} parent
  17091. * @param {string} [prop]
  17092. * @param {number} [index]
  17093. * @returns {BaseNode}
  17094. */
  17095. visit(node, parent, prop, index) {
  17096. if (node) {
  17097. if (this.enter) {
  17098. const _should_skip = this.should_skip;
  17099. const _should_remove = this.should_remove;
  17100. const _replacement = this.replacement;
  17101. this.should_skip = false;
  17102. this.should_remove = false;
  17103. this.replacement = null;
  17104. this.enter.call(this.context, node, parent, prop, index);
  17105. if (this.replacement) {
  17106. node = this.replacement;
  17107. this.replace(parent, prop, index, node);
  17108. }
  17109. if (this.should_remove) {
  17110. this.remove(parent, prop, index);
  17111. }
  17112. const skipped = this.should_skip;
  17113. const removed = this.should_remove;
  17114. this.should_skip = _should_skip;
  17115. this.should_remove = _should_remove;
  17116. this.replacement = _replacement;
  17117. if (skipped) return node;
  17118. if (removed) return null;
  17119. }
  17120. for (const key in node) {
  17121. const value = node[key];
  17122. if (typeof value !== "object") {
  17123. continue;
  17124. } else if (Array.isArray(value)) {
  17125. for (let i = 0; i < value.length; i += 1) {
  17126. if (value[i] !== null && typeof value[i].type === 'string') {
  17127. if (!this.visit(value[i], node, key, i)) {
  17128. // removed
  17129. i--;
  17130. }
  17131. }
  17132. }
  17133. } else if (value !== null && typeof value.type === "string") {
  17134. this.visit(value, node, key, null);
  17135. }
  17136. }
  17137. if (this.leave) {
  17138. const _replacement = this.replacement;
  17139. const _should_remove = this.should_remove;
  17140. this.replacement = null;
  17141. this.should_remove = false;
  17142. this.leave.call(this.context, node, parent, prop, index);
  17143. if (this.replacement) {
  17144. node = this.replacement;
  17145. this.replace(parent, prop, index, node);
  17146. }
  17147. if (this.should_remove) {
  17148. this.remove(parent, prop, index);
  17149. }
  17150. const removed = this.should_remove;
  17151. this.replacement = _replacement;
  17152. this.should_remove = _should_remove;
  17153. if (removed) return null;
  17154. }
  17155. }
  17156. return node;
  17157. }
  17158. }
  17159. // @ts-check
  17160. /** @typedef { import('estree').BaseNode} BaseNode */
  17161. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  17162. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  17163. /**
  17164. *
  17165. * @param {BaseNode} ast
  17166. * @param {{
  17167. * enter?: SyncHandler
  17168. * leave?: SyncHandler
  17169. * }} walker
  17170. * @returns {BaseNode}
  17171. */
  17172. function walk$2(ast, { enter, leave }) {
  17173. const instance = new SyncWalker(enter, leave);
  17174. return instance.visit(ast, null);
  17175. }
  17176. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  17177. const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
  17178. walk$2(root, {
  17179. enter(node, parent) {
  17180. parent && parentStack.push(parent);
  17181. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  17182. return this.skip();
  17183. }
  17184. if (node.type === "Identifier") {
  17185. const isLocal = !!knownIds[node.name];
  17186. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  17187. if (includeAll || isRefed && !isLocal) {
  17188. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  17189. }
  17190. } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
  17191. (parent == null ? void 0 : parent.type) === "ObjectPattern") {
  17192. node.inPattern = true;
  17193. } else if (isFunctionType(node)) {
  17194. if (node.scopeIds) {
  17195. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  17196. } else {
  17197. walkFunctionParams(
  17198. node,
  17199. (id) => markScopeIdentifier(node, id, knownIds)
  17200. );
  17201. }
  17202. } else if (node.type === "BlockStatement") {
  17203. if (node.scopeIds) {
  17204. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  17205. } else {
  17206. walkBlockDeclarations(
  17207. node,
  17208. (id) => markScopeIdentifier(node, id, knownIds)
  17209. );
  17210. }
  17211. } else if (node.type === "SwitchStatement") {
  17212. if (node.scopeIds) {
  17213. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  17214. } else {
  17215. walkSwitchStatement(
  17216. node,
  17217. false,
  17218. (id) => markScopeIdentifier(node, id, knownIds)
  17219. );
  17220. }
  17221. } else if (node.type === "CatchClause" && node.param) {
  17222. if (node.scopeIds) {
  17223. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  17224. } else {
  17225. for (const id of extractIdentifiers$1(node.param)) {
  17226. markScopeIdentifier(node, id, knownIds);
  17227. }
  17228. }
  17229. } else if (isForStatement(node)) {
  17230. if (node.scopeIds) {
  17231. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  17232. } else {
  17233. walkForStatement(
  17234. node,
  17235. false,
  17236. (id) => markScopeIdentifier(node, id, knownIds)
  17237. );
  17238. }
  17239. }
  17240. },
  17241. leave(node, parent) {
  17242. parent && parentStack.pop();
  17243. if (node !== rootExp && node.scopeIds) {
  17244. for (const id of node.scopeIds) {
  17245. knownIds[id]--;
  17246. if (knownIds[id] === 0) {
  17247. delete knownIds[id];
  17248. }
  17249. }
  17250. }
  17251. }
  17252. });
  17253. }
  17254. function isReferencedIdentifier(id, parent, parentStack) {
  17255. if (!parent) {
  17256. return true;
  17257. }
  17258. if (id.name === "arguments") {
  17259. return false;
  17260. }
  17261. if (isReferenced(id, parent, parentStack[parentStack.length - 2])) {
  17262. return true;
  17263. }
  17264. switch (parent.type) {
  17265. case "AssignmentExpression":
  17266. case "AssignmentPattern":
  17267. return true;
  17268. case "ObjectProperty":
  17269. return parent.key !== id && isInDestructureAssignment(parent, parentStack);
  17270. case "ArrayPattern":
  17271. return isInDestructureAssignment(parent, parentStack);
  17272. }
  17273. return false;
  17274. }
  17275. function isInDestructureAssignment(parent, parentStack) {
  17276. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  17277. let i = parentStack.length;
  17278. while (i--) {
  17279. const p = parentStack[i];
  17280. if (p.type === "AssignmentExpression") {
  17281. return true;
  17282. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  17283. break;
  17284. }
  17285. }
  17286. }
  17287. return false;
  17288. }
  17289. function isInNewExpression(parentStack) {
  17290. let i = parentStack.length;
  17291. while (i--) {
  17292. const p = parentStack[i];
  17293. if (p.type === "NewExpression") {
  17294. return true;
  17295. } else if (p.type !== "MemberExpression") {
  17296. break;
  17297. }
  17298. }
  17299. return false;
  17300. }
  17301. function walkFunctionParams(node, onIdent) {
  17302. for (const p of node.params) {
  17303. for (const id of extractIdentifiers$1(p)) {
  17304. onIdent(id);
  17305. }
  17306. }
  17307. }
  17308. function walkBlockDeclarations(block, onIdent) {
  17309. const body = block.type === "SwitchCase" ? block.consequent : block.body;
  17310. for (const stmt of body) {
  17311. if (stmt.type === "VariableDeclaration") {
  17312. if (stmt.declare) continue;
  17313. for (const decl of stmt.declarations) {
  17314. for (const id of extractIdentifiers$1(decl.id)) {
  17315. onIdent(id);
  17316. }
  17317. }
  17318. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  17319. if (stmt.declare || !stmt.id) continue;
  17320. onIdent(stmt.id);
  17321. } else if (isForStatement(stmt)) {
  17322. walkForStatement(stmt, true, onIdent);
  17323. } else if (stmt.type === "SwitchStatement") {
  17324. walkSwitchStatement(stmt, true, onIdent);
  17325. }
  17326. }
  17327. }
  17328. function isForStatement(stmt) {
  17329. return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
  17330. }
  17331. function walkForStatement(stmt, isVar, onIdent) {
  17332. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  17333. if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) {
  17334. for (const decl of variable.declarations) {
  17335. for (const id of extractIdentifiers$1(decl.id)) {
  17336. onIdent(id);
  17337. }
  17338. }
  17339. }
  17340. }
  17341. function walkSwitchStatement(stmt, isVar, onIdent) {
  17342. for (const cs of stmt.cases) {
  17343. for (const stmt2 of cs.consequent) {
  17344. if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
  17345. for (const decl of stmt2.declarations) {
  17346. for (const id of extractIdentifiers$1(decl.id)) {
  17347. onIdent(id);
  17348. }
  17349. }
  17350. }
  17351. }
  17352. walkBlockDeclarations(cs, onIdent);
  17353. }
  17354. }
  17355. function extractIdentifiers$1(param, nodes = []) {
  17356. switch (param.type) {
  17357. case "Identifier":
  17358. nodes.push(param);
  17359. break;
  17360. case "MemberExpression":
  17361. let object = param;
  17362. while (object.type === "MemberExpression") {
  17363. object = object.object;
  17364. }
  17365. nodes.push(object);
  17366. break;
  17367. case "ObjectPattern":
  17368. for (const prop of param.properties) {
  17369. if (prop.type === "RestElement") {
  17370. extractIdentifiers$1(prop.argument, nodes);
  17371. } else {
  17372. extractIdentifiers$1(prop.value, nodes);
  17373. }
  17374. }
  17375. break;
  17376. case "ArrayPattern":
  17377. param.elements.forEach((element) => {
  17378. if (element) extractIdentifiers$1(element, nodes);
  17379. });
  17380. break;
  17381. case "RestElement":
  17382. extractIdentifiers$1(param.argument, nodes);
  17383. break;
  17384. case "AssignmentPattern":
  17385. extractIdentifiers$1(param.left, nodes);
  17386. break;
  17387. }
  17388. return nodes;
  17389. }
  17390. function markKnownIds(name, knownIds) {
  17391. if (name in knownIds) {
  17392. knownIds[name]++;
  17393. } else {
  17394. knownIds[name] = 1;
  17395. }
  17396. }
  17397. function markScopeIdentifier(node, child, knownIds) {
  17398. const { name } = child;
  17399. if (node.scopeIds && node.scopeIds.has(name)) {
  17400. return;
  17401. }
  17402. markKnownIds(name, knownIds);
  17403. (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
  17404. }
  17405. const isFunctionType = (node) => {
  17406. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  17407. };
  17408. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  17409. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  17410. function isReferenced(node, parent, grandparent) {
  17411. switch (parent.type) {
  17412. // yes: PARENT[NODE]
  17413. // yes: NODE.child
  17414. // no: parent.NODE
  17415. case "MemberExpression":
  17416. case "OptionalMemberExpression":
  17417. if (parent.property === node) {
  17418. return !!parent.computed;
  17419. }
  17420. return parent.object === node;
  17421. case "JSXMemberExpression":
  17422. return parent.object === node;
  17423. // no: let NODE = init;
  17424. // yes: let id = NODE;
  17425. case "VariableDeclarator":
  17426. return parent.init === node;
  17427. // yes: () => NODE
  17428. // no: (NODE) => {}
  17429. case "ArrowFunctionExpression":
  17430. return parent.body === node;
  17431. // no: class { #NODE; }
  17432. // no: class { get #NODE() {} }
  17433. // no: class { #NODE() {} }
  17434. // no: class { fn() { return this.#NODE; } }
  17435. case "PrivateName":
  17436. return false;
  17437. // no: class { NODE() {} }
  17438. // yes: class { [NODE]() {} }
  17439. // no: class { foo(NODE) {} }
  17440. case "ClassMethod":
  17441. case "ClassPrivateMethod":
  17442. case "ObjectMethod":
  17443. if (parent.key === node) {
  17444. return !!parent.computed;
  17445. }
  17446. return false;
  17447. // yes: { [NODE]: "" }
  17448. // no: { NODE: "" }
  17449. // depends: { NODE }
  17450. // depends: { key: NODE }
  17451. case "ObjectProperty":
  17452. if (parent.key === node) {
  17453. return !!parent.computed;
  17454. }
  17455. return !grandparent || grandparent.type !== "ObjectPattern";
  17456. // no: class { NODE = value; }
  17457. // yes: class { [NODE] = value; }
  17458. // yes: class { key = NODE; }
  17459. case "ClassProperty":
  17460. if (parent.key === node) {
  17461. return !!parent.computed;
  17462. }
  17463. return true;
  17464. case "ClassPrivateProperty":
  17465. return parent.key !== node;
  17466. // no: class NODE {}
  17467. // yes: class Foo extends NODE {}
  17468. case "ClassDeclaration":
  17469. case "ClassExpression":
  17470. return parent.superClass === node;
  17471. // yes: left = NODE;
  17472. // no: NODE = right;
  17473. case "AssignmentExpression":
  17474. return parent.right === node;
  17475. // no: [NODE = foo] = [];
  17476. // yes: [foo = NODE] = [];
  17477. case "AssignmentPattern":
  17478. return parent.right === node;
  17479. // no: NODE: for (;;) {}
  17480. case "LabeledStatement":
  17481. return false;
  17482. // no: try {} catch (NODE) {}
  17483. case "CatchClause":
  17484. return false;
  17485. // no: function foo(...NODE) {}
  17486. case "RestElement":
  17487. return false;
  17488. case "BreakStatement":
  17489. case "ContinueStatement":
  17490. return false;
  17491. // no: function NODE() {}
  17492. // no: function foo(NODE) {}
  17493. case "FunctionDeclaration":
  17494. case "FunctionExpression":
  17495. return false;
  17496. // no: export NODE from "foo";
  17497. // no: export * as NODE from "foo";
  17498. case "ExportNamespaceSpecifier":
  17499. case "ExportDefaultSpecifier":
  17500. return false;
  17501. // no: export { foo as NODE };
  17502. // yes: export { NODE as foo };
  17503. // no: export { NODE as foo } from "foo";
  17504. case "ExportSpecifier":
  17505. if (grandparent == null ? void 0 : grandparent.source) {
  17506. return false;
  17507. }
  17508. return parent.local === node;
  17509. // no: import NODE from "foo";
  17510. // no: import * as NODE from "foo";
  17511. // no: import { NODE as foo } from "foo";
  17512. // no: import { foo as NODE } from "foo";
  17513. // no: import NODE from "bar";
  17514. case "ImportDefaultSpecifier":
  17515. case "ImportNamespaceSpecifier":
  17516. case "ImportSpecifier":
  17517. return false;
  17518. // no: import "foo" assert { NODE: "json" }
  17519. case "ImportAttribute":
  17520. return false;
  17521. // no: <div NODE="foo" />
  17522. case "JSXAttribute":
  17523. return false;
  17524. // no: [NODE] = [];
  17525. // no: ({ NODE }) = [];
  17526. case "ObjectPattern":
  17527. case "ArrayPattern":
  17528. return false;
  17529. // no: new.NODE
  17530. // no: NODE.target
  17531. case "MetaProperty":
  17532. return false;
  17533. // yes: type X = { someProperty: NODE }
  17534. // no: type X = { NODE: OtherType }
  17535. case "ObjectTypeProperty":
  17536. return parent.key !== node;
  17537. // yes: enum X { Foo = NODE }
  17538. // no: enum X { NODE }
  17539. case "TSEnumMember":
  17540. return parent.id !== node;
  17541. // yes: { [NODE]: value }
  17542. // no: { NODE: value }
  17543. case "TSPropertySignature":
  17544. if (parent.key === node) {
  17545. return !!parent.computed;
  17546. }
  17547. return true;
  17548. }
  17549. return true;
  17550. }
  17551. const TS_NODE_TYPES = [
  17552. "TSAsExpression",
  17553. // foo as number
  17554. "TSTypeAssertion",
  17555. // (<number>foo)
  17556. "TSNonNullExpression",
  17557. // foo!
  17558. "TSInstantiationExpression",
  17559. // foo<string>
  17560. "TSSatisfiesExpression"
  17561. // foo satisfies T
  17562. ];
  17563. function unwrapTSNode(node) {
  17564. if (TS_NODE_TYPES.includes(node.type)) {
  17565. return unwrapTSNode(node.expression);
  17566. } else {
  17567. return node;
  17568. }
  17569. }
  17570. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  17571. function isCoreComponent(tag) {
  17572. switch (tag) {
  17573. case "Teleport":
  17574. case "teleport":
  17575. return TELEPORT;
  17576. case "Suspense":
  17577. case "suspense":
  17578. return SUSPENSE;
  17579. case "KeepAlive":
  17580. case "keep-alive":
  17581. return KEEP_ALIVE;
  17582. case "BaseTransition":
  17583. case "base-transition":
  17584. return BASE_TRANSITION;
  17585. }
  17586. }
  17587. const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
  17588. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  17589. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  17590. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  17591. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  17592. const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
  17593. const isMemberExpressionBrowser = (exp) => {
  17594. const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
  17595. let state = 0 /* inMemberExp */;
  17596. let stateStack = [];
  17597. let currentOpenBracketCount = 0;
  17598. let currentOpenParensCount = 0;
  17599. let currentStringType = null;
  17600. for (let i = 0; i < path.length; i++) {
  17601. const char = path.charAt(i);
  17602. switch (state) {
  17603. case 0 /* inMemberExp */:
  17604. if (char === "[") {
  17605. stateStack.push(state);
  17606. state = 1 /* inBrackets */;
  17607. currentOpenBracketCount++;
  17608. } else if (char === "(") {
  17609. stateStack.push(state);
  17610. state = 2 /* inParens */;
  17611. currentOpenParensCount++;
  17612. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  17613. return false;
  17614. }
  17615. break;
  17616. case 1 /* inBrackets */:
  17617. if (char === `'` || char === `"` || char === "`") {
  17618. stateStack.push(state);
  17619. state = 3 /* inString */;
  17620. currentStringType = char;
  17621. } else if (char === `[`) {
  17622. currentOpenBracketCount++;
  17623. } else if (char === `]`) {
  17624. if (!--currentOpenBracketCount) {
  17625. state = stateStack.pop();
  17626. }
  17627. }
  17628. break;
  17629. case 2 /* inParens */:
  17630. if (char === `'` || char === `"` || char === "`") {
  17631. stateStack.push(state);
  17632. state = 3 /* inString */;
  17633. currentStringType = char;
  17634. } else if (char === `(`) {
  17635. currentOpenParensCount++;
  17636. } else if (char === `)`) {
  17637. if (i === path.length - 1) {
  17638. return false;
  17639. }
  17640. if (!--currentOpenParensCount) {
  17641. state = stateStack.pop();
  17642. }
  17643. }
  17644. break;
  17645. case 3 /* inString */:
  17646. if (char === currentStringType) {
  17647. state = stateStack.pop();
  17648. currentStringType = null;
  17649. }
  17650. break;
  17651. }
  17652. }
  17653. return !currentOpenBracketCount && !currentOpenParensCount;
  17654. };
  17655. const isMemberExpressionNode = (exp, context) => {
  17656. try {
  17657. let ret = exp.ast || libExports.parseExpression(getExpSource(exp), {
  17658. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  17659. });
  17660. ret = unwrapTSNode(ret);
  17661. return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
  17662. } catch (e) {
  17663. return false;
  17664. }
  17665. };
  17666. const isMemberExpression = isMemberExpressionNode;
  17667. const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  17668. const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
  17669. const isFnExpressionNode = (exp, context) => {
  17670. try {
  17671. let ret = exp.ast || libExports.parseExpression(getExpSource(exp), {
  17672. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  17673. });
  17674. if (ret.type === "Program") {
  17675. ret = ret.body[0];
  17676. if (ret.type === "ExpressionStatement") {
  17677. ret = ret.expression;
  17678. }
  17679. }
  17680. ret = unwrapTSNode(ret);
  17681. return ret.type === "FunctionExpression" || ret.type === "ArrowFunctionExpression";
  17682. } catch (e) {
  17683. return false;
  17684. }
  17685. };
  17686. const isFnExpression = isFnExpressionNode;
  17687. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  17688. return advancePositionWithMutation(
  17689. {
  17690. offset: pos.offset,
  17691. line: pos.line,
  17692. column: pos.column
  17693. },
  17694. source,
  17695. numberOfCharacters
  17696. );
  17697. }
  17698. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  17699. let linesCount = 0;
  17700. let lastNewLinePos = -1;
  17701. for (let i = 0; i < numberOfCharacters; i++) {
  17702. if (source.charCodeAt(i) === 10) {
  17703. linesCount++;
  17704. lastNewLinePos = i;
  17705. }
  17706. }
  17707. pos.offset += numberOfCharacters;
  17708. pos.line += linesCount;
  17709. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  17710. return pos;
  17711. }
  17712. function assert(condition, msg) {
  17713. if (!condition) {
  17714. throw new Error(msg || `unexpected compiler condition`);
  17715. }
  17716. }
  17717. function findDir(node, name, allowEmpty = false) {
  17718. for (let i = 0; i < node.props.length; i++) {
  17719. const p = node.props[i];
  17720. if (p.type === 7 && (allowEmpty || p.exp) && (isString$1(name) ? p.name === name : name.test(p.name))) {
  17721. return p;
  17722. }
  17723. }
  17724. }
  17725. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  17726. for (let i = 0; i < node.props.length; i++) {
  17727. const p = node.props[i];
  17728. if (p.type === 6) {
  17729. if (dynamicOnly) continue;
  17730. if (p.name === name && (p.value || allowEmpty)) {
  17731. return p;
  17732. }
  17733. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  17734. return p;
  17735. }
  17736. }
  17737. }
  17738. function isStaticArgOf(arg, name) {
  17739. return !!(arg && isStaticExp(arg) && arg.content === name);
  17740. }
  17741. function hasDynamicKeyVBind(node) {
  17742. return node.props.some(
  17743. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  17744. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  17745. !p.arg.isStatic)
  17746. // v-bind:[foo]
  17747. );
  17748. }
  17749. function isText$1(node) {
  17750. return node.type === 5 || node.type === 2;
  17751. }
  17752. function isVPre(p) {
  17753. return p.type === 7 && p.name === "pre";
  17754. }
  17755. function isVSlot(p) {
  17756. return p.type === 7 && p.name === "slot";
  17757. }
  17758. function isTemplateNode(node) {
  17759. return node.type === 1 && node.tagType === 3;
  17760. }
  17761. function isSlotOutlet(node) {
  17762. return node.type === 1 && node.tagType === 2;
  17763. }
  17764. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  17765. function getUnnormalizedProps(props, callPath = []) {
  17766. if (props && !isString$1(props) && props.type === 14) {
  17767. const callee = props.callee;
  17768. if (!isString$1(callee) && propsHelperSet.has(callee)) {
  17769. return getUnnormalizedProps(
  17770. props.arguments[0],
  17771. callPath.concat(props)
  17772. );
  17773. }
  17774. }
  17775. return [props, callPath];
  17776. }
  17777. function injectProp(node, prop, context) {
  17778. let propsWithInjection;
  17779. let props = node.type === 13 ? node.props : node.arguments[2];
  17780. let callPath = [];
  17781. let parentCall;
  17782. if (props && !isString$1(props) && props.type === 14) {
  17783. const ret = getUnnormalizedProps(props);
  17784. props = ret[0];
  17785. callPath = ret[1];
  17786. parentCall = callPath[callPath.length - 1];
  17787. }
  17788. if (props == null || isString$1(props)) {
  17789. propsWithInjection = createObjectExpression([prop]);
  17790. } else if (props.type === 14) {
  17791. const first = props.arguments[0];
  17792. if (!isString$1(first) && first.type === 15) {
  17793. if (!hasProp(prop, first)) {
  17794. first.properties.unshift(prop);
  17795. }
  17796. } else {
  17797. if (props.callee === TO_HANDLERS) {
  17798. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17799. createObjectExpression([prop]),
  17800. props
  17801. ]);
  17802. } else {
  17803. props.arguments.unshift(createObjectExpression([prop]));
  17804. }
  17805. }
  17806. !propsWithInjection && (propsWithInjection = props);
  17807. } else if (props.type === 15) {
  17808. if (!hasProp(prop, props)) {
  17809. props.properties.unshift(prop);
  17810. }
  17811. propsWithInjection = props;
  17812. } else {
  17813. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17814. createObjectExpression([prop]),
  17815. props
  17816. ]);
  17817. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  17818. parentCall = callPath[callPath.length - 2];
  17819. }
  17820. }
  17821. if (node.type === 13) {
  17822. if (parentCall) {
  17823. parentCall.arguments[0] = propsWithInjection;
  17824. } else {
  17825. node.props = propsWithInjection;
  17826. }
  17827. } else {
  17828. if (parentCall) {
  17829. parentCall.arguments[0] = propsWithInjection;
  17830. } else {
  17831. node.arguments[2] = propsWithInjection;
  17832. }
  17833. }
  17834. }
  17835. function hasProp(prop, props) {
  17836. let result = false;
  17837. if (prop.key.type === 4) {
  17838. const propKeyName = prop.key.content;
  17839. result = props.properties.some(
  17840. (p) => p.key.type === 4 && p.key.content === propKeyName
  17841. );
  17842. }
  17843. return result;
  17844. }
  17845. function toValidAssetId(name, type) {
  17846. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  17847. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  17848. })}`;
  17849. }
  17850. function hasScopeRef(node, ids) {
  17851. if (!node || Object.keys(ids).length === 0) {
  17852. return false;
  17853. }
  17854. switch (node.type) {
  17855. case 1:
  17856. for (let i = 0; i < node.props.length; i++) {
  17857. const p = node.props[i];
  17858. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  17859. return true;
  17860. }
  17861. }
  17862. return node.children.some((c) => hasScopeRef(c, ids));
  17863. case 11:
  17864. if (hasScopeRef(node.source, ids)) {
  17865. return true;
  17866. }
  17867. return node.children.some((c) => hasScopeRef(c, ids));
  17868. case 9:
  17869. return node.branches.some((b) => hasScopeRef(b, ids));
  17870. case 10:
  17871. if (hasScopeRef(node.condition, ids)) {
  17872. return true;
  17873. }
  17874. return node.children.some((c) => hasScopeRef(c, ids));
  17875. case 4:
  17876. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  17877. case 8:
  17878. return node.children.some((c) => isObject$2(c) && hasScopeRef(c, ids));
  17879. case 5:
  17880. case 12:
  17881. return hasScopeRef(node.content, ids);
  17882. case 2:
  17883. case 3:
  17884. case 20:
  17885. return false;
  17886. default:
  17887. return false;
  17888. }
  17889. }
  17890. function getMemoedVNodeCall(node) {
  17891. if (node.type === 14 && node.callee === WITH_MEMO) {
  17892. return node.arguments[1].returns;
  17893. } else {
  17894. return node;
  17895. }
  17896. }
  17897. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
  17898. const defaultParserOptions = {
  17899. parseMode: "base",
  17900. ns: 0,
  17901. delimiters: [`{{`, `}}`],
  17902. getNamespace: () => 0,
  17903. isVoidTag: NO,
  17904. isPreTag: NO,
  17905. isIgnoreNewlineTag: NO,
  17906. isCustomElement: NO,
  17907. onError: defaultOnError,
  17908. onWarn: defaultOnWarn,
  17909. comments: true,
  17910. prefixIdentifiers: false
  17911. };
  17912. let currentOptions = defaultParserOptions;
  17913. let currentRoot = null;
  17914. let currentInput = "";
  17915. let currentOpenTag = null;
  17916. let currentProp = null;
  17917. let currentAttrValue = "";
  17918. let currentAttrStartIndex = -1;
  17919. let currentAttrEndIndex = -1;
  17920. let inPre = 0;
  17921. let inVPre = false;
  17922. let currentVPreBoundary = null;
  17923. const stack = [];
  17924. const tokenizer = new Tokenizer(stack, {
  17925. onerr: emitError,
  17926. ontext(start, end) {
  17927. onText(getSlice(start, end), start, end);
  17928. },
  17929. ontextentity(char, start, end) {
  17930. onText(char, start, end);
  17931. },
  17932. oninterpolation(start, end) {
  17933. if (inVPre) {
  17934. return onText(getSlice(start, end), start, end);
  17935. }
  17936. let innerStart = start + tokenizer.delimiterOpen.length;
  17937. let innerEnd = end - tokenizer.delimiterClose.length;
  17938. while (isWhitespace(currentInput.charCodeAt(innerStart))) {
  17939. innerStart++;
  17940. }
  17941. while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
  17942. innerEnd--;
  17943. }
  17944. let exp = getSlice(innerStart, innerEnd);
  17945. if (exp.includes("&")) {
  17946. {
  17947. exp = decodeHTML(exp);
  17948. }
  17949. }
  17950. addNode({
  17951. type: 5,
  17952. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  17953. loc: getLoc(start, end)
  17954. });
  17955. },
  17956. onopentagname(start, end) {
  17957. const name = getSlice(start, end);
  17958. currentOpenTag = {
  17959. type: 1,
  17960. tag: name,
  17961. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  17962. tagType: 0,
  17963. // will be refined on tag close
  17964. props: [],
  17965. children: [],
  17966. loc: getLoc(start - 1, end),
  17967. codegenNode: void 0
  17968. };
  17969. },
  17970. onopentagend(end) {
  17971. endOpenTag(end);
  17972. },
  17973. onclosetag(start, end) {
  17974. const name = getSlice(start, end);
  17975. if (!currentOptions.isVoidTag(name)) {
  17976. let found = false;
  17977. for (let i = 0; i < stack.length; i++) {
  17978. const e = stack[i];
  17979. if (e.tag.toLowerCase() === name.toLowerCase()) {
  17980. found = true;
  17981. if (i > 0) {
  17982. emitError(24, stack[0].loc.start.offset);
  17983. }
  17984. for (let j = 0; j <= i; j++) {
  17985. const el = stack.shift();
  17986. onCloseTag(el, end, j < i);
  17987. }
  17988. break;
  17989. }
  17990. }
  17991. if (!found) {
  17992. emitError(23, backTrack(start, 60));
  17993. }
  17994. }
  17995. },
  17996. onselfclosingtag(end) {
  17997. const name = currentOpenTag.tag;
  17998. currentOpenTag.isSelfClosing = true;
  17999. endOpenTag(end);
  18000. if (stack[0] && stack[0].tag === name) {
  18001. onCloseTag(stack.shift(), end);
  18002. }
  18003. },
  18004. onattribname(start, end) {
  18005. currentProp = {
  18006. type: 6,
  18007. name: getSlice(start, end),
  18008. nameLoc: getLoc(start, end),
  18009. value: void 0,
  18010. loc: getLoc(start)
  18011. };
  18012. },
  18013. ondirname(start, end) {
  18014. const raw = getSlice(start, end);
  18015. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  18016. if (!inVPre && name === "") {
  18017. emitError(26, start);
  18018. }
  18019. if (inVPre || name === "") {
  18020. currentProp = {
  18021. type: 6,
  18022. name: raw,
  18023. nameLoc: getLoc(start, end),
  18024. value: void 0,
  18025. loc: getLoc(start)
  18026. };
  18027. } else {
  18028. currentProp = {
  18029. type: 7,
  18030. name,
  18031. rawName: raw,
  18032. exp: void 0,
  18033. arg: void 0,
  18034. modifiers: raw === "." ? [createSimpleExpression("prop")] : [],
  18035. loc: getLoc(start)
  18036. };
  18037. if (name === "pre") {
  18038. inVPre = tokenizer.inVPre = true;
  18039. currentVPreBoundary = currentOpenTag;
  18040. const props = currentOpenTag.props;
  18041. for (let i = 0; i < props.length; i++) {
  18042. if (props[i].type === 7) {
  18043. props[i] = dirToAttr(props[i]);
  18044. }
  18045. }
  18046. }
  18047. }
  18048. },
  18049. ondirarg(start, end) {
  18050. if (start === end) return;
  18051. const arg = getSlice(start, end);
  18052. if (inVPre && !isVPre(currentProp)) {
  18053. currentProp.name += arg;
  18054. setLocEnd(currentProp.nameLoc, end);
  18055. } else {
  18056. const isStatic = arg[0] !== `[`;
  18057. currentProp.arg = createExp(
  18058. isStatic ? arg : arg.slice(1, -1),
  18059. isStatic,
  18060. getLoc(start, end),
  18061. isStatic ? 3 : 0
  18062. );
  18063. }
  18064. },
  18065. ondirmodifier(start, end) {
  18066. const mod = getSlice(start, end);
  18067. if (inVPre && !isVPre(currentProp)) {
  18068. currentProp.name += "." + mod;
  18069. setLocEnd(currentProp.nameLoc, end);
  18070. } else if (currentProp.name === "slot") {
  18071. const arg = currentProp.arg;
  18072. if (arg) {
  18073. arg.content += "." + mod;
  18074. setLocEnd(arg.loc, end);
  18075. }
  18076. } else {
  18077. const exp = createSimpleExpression(mod, true, getLoc(start, end));
  18078. currentProp.modifiers.push(exp);
  18079. }
  18080. },
  18081. onattribdata(start, end) {
  18082. currentAttrValue += getSlice(start, end);
  18083. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  18084. currentAttrEndIndex = end;
  18085. },
  18086. onattribentity(char, start, end) {
  18087. currentAttrValue += char;
  18088. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  18089. currentAttrEndIndex = end;
  18090. },
  18091. onattribnameend(end) {
  18092. const start = currentProp.loc.start.offset;
  18093. const name = getSlice(start, end);
  18094. if (currentProp.type === 7) {
  18095. currentProp.rawName = name;
  18096. }
  18097. if (currentOpenTag.props.some(
  18098. (p) => (p.type === 7 ? p.rawName : p.name) === name
  18099. )) {
  18100. emitError(2, start);
  18101. }
  18102. },
  18103. onattribend(quote, end) {
  18104. if (currentOpenTag && currentProp) {
  18105. setLocEnd(currentProp.loc, end);
  18106. if (quote !== 0) {
  18107. if (currentProp.type === 6) {
  18108. if (currentProp.name === "class") {
  18109. currentAttrValue = condense(currentAttrValue).trim();
  18110. }
  18111. if (quote === 1 && !currentAttrValue) {
  18112. emitError(13, end);
  18113. }
  18114. currentProp.value = {
  18115. type: 2,
  18116. content: currentAttrValue,
  18117. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  18118. };
  18119. if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  18120. tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
  18121. }
  18122. } else {
  18123. let expParseMode = 0 /* Normal */;
  18124. {
  18125. if (currentProp.name === "for") {
  18126. expParseMode = 3 /* Skip */;
  18127. } else if (currentProp.name === "slot") {
  18128. expParseMode = 1 /* Params */;
  18129. } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
  18130. expParseMode = 2 /* Statements */;
  18131. }
  18132. }
  18133. currentProp.exp = createExp(
  18134. currentAttrValue,
  18135. false,
  18136. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  18137. 0,
  18138. expParseMode
  18139. );
  18140. if (currentProp.name === "for") {
  18141. currentProp.forParseResult = parseForExpression(currentProp.exp);
  18142. }
  18143. }
  18144. }
  18145. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  18146. currentOpenTag.props.push(currentProp);
  18147. }
  18148. }
  18149. currentAttrValue = "";
  18150. currentAttrStartIndex = currentAttrEndIndex = -1;
  18151. },
  18152. oncomment(start, end) {
  18153. if (currentOptions.comments) {
  18154. addNode({
  18155. type: 3,
  18156. content: getSlice(start, end),
  18157. loc: getLoc(start - 4, end + 3)
  18158. });
  18159. }
  18160. },
  18161. onend() {
  18162. const end = currentInput.length;
  18163. if (tokenizer.state !== 1) {
  18164. switch (tokenizer.state) {
  18165. case 5:
  18166. case 8:
  18167. emitError(5, end);
  18168. break;
  18169. case 3:
  18170. case 4:
  18171. emitError(
  18172. 25,
  18173. tokenizer.sectionStart
  18174. );
  18175. break;
  18176. case 28:
  18177. if (tokenizer.currentSequence === Sequences.CdataEnd) {
  18178. emitError(6, end);
  18179. } else {
  18180. emitError(7, end);
  18181. }
  18182. break;
  18183. case 6:
  18184. case 7:
  18185. case 9:
  18186. case 11:
  18187. case 12:
  18188. case 13:
  18189. case 14:
  18190. case 15:
  18191. case 16:
  18192. case 17:
  18193. case 18:
  18194. case 19:
  18195. // "
  18196. case 20:
  18197. // '
  18198. case 21:
  18199. emitError(9, end);
  18200. break;
  18201. }
  18202. }
  18203. for (let index = 0; index < stack.length; index++) {
  18204. onCloseTag(stack[index], end - 1);
  18205. emitError(24, stack[index].loc.start.offset);
  18206. }
  18207. },
  18208. oncdata(start, end) {
  18209. if (stack[0].ns !== 0) {
  18210. onText(getSlice(start, end), start, end);
  18211. } else {
  18212. emitError(1, start - 9);
  18213. }
  18214. },
  18215. onprocessinginstruction(start) {
  18216. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  18217. emitError(
  18218. 21,
  18219. start - 1
  18220. );
  18221. }
  18222. }
  18223. });
  18224. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  18225. const stripParensRE = /^\(|\)$/g;
  18226. function parseForExpression(input) {
  18227. const loc = input.loc;
  18228. const exp = input.content;
  18229. const inMatch = exp.match(forAliasRE);
  18230. if (!inMatch) return;
  18231. const [, LHS, RHS] = inMatch;
  18232. const createAliasExpression = (content, offset, asParam = false) => {
  18233. const start = loc.start.offset + offset;
  18234. const end = start + content.length;
  18235. return createExp(
  18236. content,
  18237. false,
  18238. getLoc(start, end),
  18239. 0,
  18240. asParam ? 1 /* Params */ : 0 /* Normal */
  18241. );
  18242. };
  18243. const result = {
  18244. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  18245. value: void 0,
  18246. key: void 0,
  18247. index: void 0,
  18248. finalized: false
  18249. };
  18250. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  18251. const trimmedOffset = LHS.indexOf(valueContent);
  18252. const iteratorMatch = valueContent.match(forIteratorRE);
  18253. if (iteratorMatch) {
  18254. valueContent = valueContent.replace(forIteratorRE, "").trim();
  18255. const keyContent = iteratorMatch[1].trim();
  18256. let keyOffset;
  18257. if (keyContent) {
  18258. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  18259. result.key = createAliasExpression(keyContent, keyOffset, true);
  18260. }
  18261. if (iteratorMatch[2]) {
  18262. const indexContent = iteratorMatch[2].trim();
  18263. if (indexContent) {
  18264. result.index = createAliasExpression(
  18265. indexContent,
  18266. exp.indexOf(
  18267. indexContent,
  18268. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  18269. ),
  18270. true
  18271. );
  18272. }
  18273. }
  18274. }
  18275. if (valueContent) {
  18276. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  18277. }
  18278. return result;
  18279. }
  18280. function getSlice(start, end) {
  18281. return currentInput.slice(start, end);
  18282. }
  18283. function endOpenTag(end) {
  18284. if (tokenizer.inSFCRoot) {
  18285. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  18286. }
  18287. addNode(currentOpenTag);
  18288. const { tag, ns } = currentOpenTag;
  18289. if (ns === 0 && currentOptions.isPreTag(tag)) {
  18290. inPre++;
  18291. }
  18292. if (currentOptions.isVoidTag(tag)) {
  18293. onCloseTag(currentOpenTag, end);
  18294. } else {
  18295. stack.unshift(currentOpenTag);
  18296. if (ns === 1 || ns === 2) {
  18297. tokenizer.inXML = true;
  18298. }
  18299. }
  18300. currentOpenTag = null;
  18301. }
  18302. function onText(content, start, end) {
  18303. const parent = stack[0] || currentRoot;
  18304. const lastNode = parent.children[parent.children.length - 1];
  18305. if (lastNode && lastNode.type === 2) {
  18306. lastNode.content += content;
  18307. setLocEnd(lastNode.loc, end);
  18308. } else {
  18309. parent.children.push({
  18310. type: 2,
  18311. content,
  18312. loc: getLoc(start, end)
  18313. });
  18314. }
  18315. }
  18316. function onCloseTag(el, end, isImplied = false) {
  18317. if (isImplied) {
  18318. setLocEnd(el.loc, backTrack(end, 60));
  18319. } else {
  18320. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  18321. }
  18322. if (tokenizer.inSFCRoot) {
  18323. if (el.children.length) {
  18324. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  18325. } else {
  18326. el.innerLoc.end = extend({}, el.innerLoc.start);
  18327. }
  18328. el.innerLoc.source = getSlice(
  18329. el.innerLoc.start.offset,
  18330. el.innerLoc.end.offset
  18331. );
  18332. }
  18333. const { tag, ns, children } = el;
  18334. if (!inVPre) {
  18335. if (tag === "slot") {
  18336. el.tagType = 2;
  18337. } else if (isFragmentTemplate(el)) {
  18338. el.tagType = 3;
  18339. } else if (isComponent(el)) {
  18340. el.tagType = 1;
  18341. }
  18342. }
  18343. if (!tokenizer.inRCDATA) {
  18344. el.children = condenseWhitespace(children);
  18345. }
  18346. if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
  18347. const first = children[0];
  18348. if (first && first.type === 2) {
  18349. first.content = first.content.replace(/^\r?\n/, "");
  18350. }
  18351. }
  18352. if (ns === 0 && currentOptions.isPreTag(tag)) {
  18353. inPre--;
  18354. }
  18355. if (currentVPreBoundary === el) {
  18356. inVPre = tokenizer.inVPre = false;
  18357. currentVPreBoundary = null;
  18358. }
  18359. if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  18360. tokenizer.inXML = false;
  18361. }
  18362. }
  18363. function lookAhead(index, c) {
  18364. let i = index;
  18365. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
  18366. return i;
  18367. }
  18368. function backTrack(index, c) {
  18369. let i = index;
  18370. while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
  18371. return i;
  18372. }
  18373. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  18374. function isFragmentTemplate({ tag, props }) {
  18375. if (tag === "template") {
  18376. for (let i = 0; i < props.length; i++) {
  18377. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  18378. return true;
  18379. }
  18380. }
  18381. }
  18382. return false;
  18383. }
  18384. function isComponent({ tag, props }) {
  18385. if (currentOptions.isCustomElement(tag)) {
  18386. return false;
  18387. }
  18388. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  18389. return true;
  18390. }
  18391. for (let i = 0; i < props.length; i++) {
  18392. const p = props[i];
  18393. if (p.type === 6) {
  18394. if (p.name === "is" && p.value) {
  18395. if (p.value.content.startsWith("vue:")) {
  18396. return true;
  18397. }
  18398. }
  18399. }
  18400. }
  18401. return false;
  18402. }
  18403. function isUpperCase(c) {
  18404. return c > 64 && c < 91;
  18405. }
  18406. const windowsNewlineRE = /\r\n/g;
  18407. function condenseWhitespace(nodes) {
  18408. const shouldCondense = currentOptions.whitespace !== "preserve";
  18409. let removedWhitespace = false;
  18410. for (let i = 0; i < nodes.length; i++) {
  18411. const node = nodes[i];
  18412. if (node.type === 2) {
  18413. if (!inPre) {
  18414. if (isAllWhitespace(node.content)) {
  18415. const prev = nodes[i - 1] && nodes[i - 1].type;
  18416. const next = nodes[i + 1] && nodes[i + 1].type;
  18417. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  18418. removedWhitespace = true;
  18419. nodes[i] = null;
  18420. } else {
  18421. node.content = " ";
  18422. }
  18423. } else if (shouldCondense) {
  18424. node.content = condense(node.content);
  18425. }
  18426. } else {
  18427. node.content = node.content.replace(windowsNewlineRE, "\n");
  18428. }
  18429. }
  18430. }
  18431. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  18432. }
  18433. function isAllWhitespace(str) {
  18434. for (let i = 0; i < str.length; i++) {
  18435. if (!isWhitespace(str.charCodeAt(i))) {
  18436. return false;
  18437. }
  18438. }
  18439. return true;
  18440. }
  18441. function hasNewlineChar(str) {
  18442. for (let i = 0; i < str.length; i++) {
  18443. const c = str.charCodeAt(i);
  18444. if (c === 10 || c === 13) {
  18445. return true;
  18446. }
  18447. }
  18448. return false;
  18449. }
  18450. function condense(str) {
  18451. let ret = "";
  18452. let prevCharIsWhitespace = false;
  18453. for (let i = 0; i < str.length; i++) {
  18454. if (isWhitespace(str.charCodeAt(i))) {
  18455. if (!prevCharIsWhitespace) {
  18456. ret += " ";
  18457. prevCharIsWhitespace = true;
  18458. }
  18459. } else {
  18460. ret += str[i];
  18461. prevCharIsWhitespace = false;
  18462. }
  18463. }
  18464. return ret;
  18465. }
  18466. function addNode(node) {
  18467. (stack[0] || currentRoot).children.push(node);
  18468. }
  18469. function getLoc(start, end) {
  18470. return {
  18471. start: tokenizer.getPos(start),
  18472. // @ts-expect-error allow late attachment
  18473. end: end == null ? end : tokenizer.getPos(end),
  18474. // @ts-expect-error allow late attachment
  18475. source: end == null ? end : getSlice(start, end)
  18476. };
  18477. }
  18478. function cloneLoc(loc) {
  18479. return getLoc(loc.start.offset, loc.end.offset);
  18480. }
  18481. function setLocEnd(loc, end) {
  18482. loc.end = tokenizer.getPos(end);
  18483. loc.source = getSlice(loc.start.offset, end);
  18484. }
  18485. function dirToAttr(dir) {
  18486. const attr = {
  18487. type: 6,
  18488. name: dir.rawName,
  18489. nameLoc: getLoc(
  18490. dir.loc.start.offset,
  18491. dir.loc.start.offset + dir.rawName.length
  18492. ),
  18493. value: void 0,
  18494. loc: dir.loc
  18495. };
  18496. if (dir.exp) {
  18497. const loc = dir.exp.loc;
  18498. if (loc.end.offset < dir.loc.end.offset) {
  18499. loc.start.offset--;
  18500. loc.start.column--;
  18501. loc.end.offset++;
  18502. loc.end.column++;
  18503. }
  18504. attr.value = {
  18505. type: 2,
  18506. content: dir.exp.content,
  18507. loc
  18508. };
  18509. }
  18510. return attr;
  18511. }
  18512. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  18513. const exp = createSimpleExpression(content, isStatic, loc, constType);
  18514. if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
  18515. if (isSimpleIdentifier(content)) {
  18516. exp.ast = null;
  18517. return exp;
  18518. }
  18519. try {
  18520. const plugins = currentOptions.expressionPlugins;
  18521. const options = {
  18522. plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
  18523. };
  18524. if (parseMode === 2 /* Statements */) {
  18525. exp.ast = libExports.parse(` ${content} `, options).program;
  18526. } else if (parseMode === 1 /* Params */) {
  18527. exp.ast = libExports.parseExpression(`(${content})=>{}`, options);
  18528. } else {
  18529. exp.ast = libExports.parseExpression(`(${content})`, options);
  18530. }
  18531. } catch (e) {
  18532. exp.ast = false;
  18533. emitError(45, loc.start.offset, e.message);
  18534. }
  18535. }
  18536. return exp;
  18537. }
  18538. function emitError(code, index, message) {
  18539. currentOptions.onError(
  18540. createCompilerError(code, getLoc(index, index), void 0, message)
  18541. );
  18542. }
  18543. function reset() {
  18544. tokenizer.reset();
  18545. currentOpenTag = null;
  18546. currentProp = null;
  18547. currentAttrValue = "";
  18548. currentAttrStartIndex = -1;
  18549. currentAttrEndIndex = -1;
  18550. stack.length = 0;
  18551. }
  18552. function baseParse(input, options) {
  18553. reset();
  18554. currentInput = input;
  18555. currentOptions = extend({}, defaultParserOptions);
  18556. if (options) {
  18557. let key;
  18558. for (key in options) {
  18559. if (options[key] != null) {
  18560. currentOptions[key] = options[key];
  18561. }
  18562. }
  18563. }
  18564. {
  18565. if (currentOptions.decodeEntities) {
  18566. console.warn(
  18567. `[@vue/compiler-core] decodeEntities option is passed but will be ignored in non-browser builds.`
  18568. );
  18569. }
  18570. }
  18571. tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  18572. tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  18573. const delimiters = options && options.delimiters;
  18574. if (delimiters) {
  18575. tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
  18576. tokenizer.delimiterClose = toCharCodes(delimiters[1]);
  18577. }
  18578. const root = currentRoot = createRoot([], input);
  18579. tokenizer.parse(currentInput);
  18580. root.loc = getLoc(0, input.length);
  18581. root.children = condenseWhitespace(root.children);
  18582. currentRoot = null;
  18583. return root;
  18584. }
  18585. function cacheStatic(root, context) {
  18586. walk$1(
  18587. root,
  18588. void 0,
  18589. context,
  18590. // Root node is unfortunately non-hoistable due to potential parent
  18591. // fallthrough attributes.
  18592. !!getSingleElementRoot(root)
  18593. );
  18594. }
  18595. function getSingleElementRoot(root) {
  18596. const children = root.children.filter((x) => x.type !== 3);
  18597. return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
  18598. }
  18599. function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
  18600. const { children } = node;
  18601. const toCache = [];
  18602. for (let i = 0; i < children.length; i++) {
  18603. const child = children[i];
  18604. if (child.type === 1 && child.tagType === 0) {
  18605. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  18606. if (constantType > 0) {
  18607. if (constantType >= 2) {
  18608. child.codegenNode.patchFlag = -1;
  18609. toCache.push(child);
  18610. continue;
  18611. }
  18612. } else {
  18613. const codegenNode = child.codegenNode;
  18614. if (codegenNode.type === 13) {
  18615. const flag = codegenNode.patchFlag;
  18616. if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  18617. const props = getNodeProps(child);
  18618. if (props) {
  18619. codegenNode.props = context.hoist(props);
  18620. }
  18621. }
  18622. if (codegenNode.dynamicProps) {
  18623. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  18624. }
  18625. }
  18626. }
  18627. } else if (child.type === 12) {
  18628. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  18629. if (constantType >= 2) {
  18630. if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
  18631. child.codegenNode.arguments.push(
  18632. -1 + (` /* ${PatchFlagNames[-1]} */` )
  18633. );
  18634. }
  18635. toCache.push(child);
  18636. continue;
  18637. }
  18638. }
  18639. if (child.type === 1) {
  18640. const isComponent = child.tagType === 1;
  18641. if (isComponent) {
  18642. context.scopes.vSlot++;
  18643. }
  18644. walk$1(child, node, context, false, inFor);
  18645. if (isComponent) {
  18646. context.scopes.vSlot--;
  18647. }
  18648. } else if (child.type === 11) {
  18649. walk$1(child, node, context, child.children.length === 1, true);
  18650. } else if (child.type === 9) {
  18651. for (let i2 = 0; i2 < child.branches.length; i2++) {
  18652. walk$1(
  18653. child.branches[i2],
  18654. node,
  18655. context,
  18656. child.branches[i2].children.length === 1,
  18657. inFor
  18658. );
  18659. }
  18660. }
  18661. }
  18662. let cachedAsArray = false;
  18663. if (toCache.length === children.length && node.type === 1) {
  18664. if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
  18665. node.codegenNode.children = getCacheExpression(
  18666. createArrayExpression(node.codegenNode.children)
  18667. );
  18668. cachedAsArray = true;
  18669. } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray$3(node.codegenNode.children) && node.codegenNode.children.type === 15) {
  18670. const slot = getSlotNode(node.codegenNode, "default");
  18671. if (slot) {
  18672. slot.returns = getCacheExpression(
  18673. createArrayExpression(slot.returns)
  18674. );
  18675. cachedAsArray = true;
  18676. }
  18677. } else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray$3(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
  18678. const slotName = findDir(node, "slot", true);
  18679. const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
  18680. if (slot) {
  18681. slot.returns = getCacheExpression(
  18682. createArrayExpression(slot.returns)
  18683. );
  18684. cachedAsArray = true;
  18685. }
  18686. }
  18687. }
  18688. if (!cachedAsArray) {
  18689. for (const child of toCache) {
  18690. child.codegenNode = context.cache(child.codegenNode);
  18691. }
  18692. }
  18693. function getCacheExpression(value) {
  18694. const exp = context.cache(value);
  18695. exp.needArraySpread = true;
  18696. return exp;
  18697. }
  18698. function getSlotNode(node2, name) {
  18699. if (node2.children && !isArray$3(node2.children) && node2.children.type === 15) {
  18700. const slot = node2.children.properties.find(
  18701. (p) => p.key === name || p.key.content === name
  18702. );
  18703. return slot && slot.value;
  18704. }
  18705. }
  18706. if (toCache.length && context.transformHoist) {
  18707. context.transformHoist(children, context, node);
  18708. }
  18709. }
  18710. function getConstantType(node, context) {
  18711. const { constantCache } = context;
  18712. switch (node.type) {
  18713. case 1:
  18714. if (node.tagType !== 0) {
  18715. return 0;
  18716. }
  18717. const cached = constantCache.get(node);
  18718. if (cached !== void 0) {
  18719. return cached;
  18720. }
  18721. const codegenNode = node.codegenNode;
  18722. if (codegenNode.type !== 13) {
  18723. return 0;
  18724. }
  18725. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
  18726. return 0;
  18727. }
  18728. if (codegenNode.patchFlag === void 0) {
  18729. let returnType2 = 3;
  18730. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  18731. if (generatedPropsType === 0) {
  18732. constantCache.set(node, 0);
  18733. return 0;
  18734. }
  18735. if (generatedPropsType < returnType2) {
  18736. returnType2 = generatedPropsType;
  18737. }
  18738. for (let i = 0; i < node.children.length; i++) {
  18739. const childType = getConstantType(node.children[i], context);
  18740. if (childType === 0) {
  18741. constantCache.set(node, 0);
  18742. return 0;
  18743. }
  18744. if (childType < returnType2) {
  18745. returnType2 = childType;
  18746. }
  18747. }
  18748. if (returnType2 > 1) {
  18749. for (let i = 0; i < node.props.length; i++) {
  18750. const p = node.props[i];
  18751. if (p.type === 7 && p.name === "bind" && p.exp) {
  18752. const expType = getConstantType(p.exp, context);
  18753. if (expType === 0) {
  18754. constantCache.set(node, 0);
  18755. return 0;
  18756. }
  18757. if (expType < returnType2) {
  18758. returnType2 = expType;
  18759. }
  18760. }
  18761. }
  18762. }
  18763. if (codegenNode.isBlock) {
  18764. for (let i = 0; i < node.props.length; i++) {
  18765. const p = node.props[i];
  18766. if (p.type === 7) {
  18767. constantCache.set(node, 0);
  18768. return 0;
  18769. }
  18770. }
  18771. context.removeHelper(OPEN_BLOCK);
  18772. context.removeHelper(
  18773. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  18774. );
  18775. codegenNode.isBlock = false;
  18776. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  18777. }
  18778. constantCache.set(node, returnType2);
  18779. return returnType2;
  18780. } else {
  18781. constantCache.set(node, 0);
  18782. return 0;
  18783. }
  18784. case 2:
  18785. case 3:
  18786. return 3;
  18787. case 9:
  18788. case 11:
  18789. case 10:
  18790. return 0;
  18791. case 5:
  18792. case 12:
  18793. return getConstantType(node.content, context);
  18794. case 4:
  18795. return node.constType;
  18796. case 8:
  18797. let returnType = 3;
  18798. for (let i = 0; i < node.children.length; i++) {
  18799. const child = node.children[i];
  18800. if (isString$1(child) || isSymbol$1(child)) {
  18801. continue;
  18802. }
  18803. const childType = getConstantType(child, context);
  18804. if (childType === 0) {
  18805. return 0;
  18806. } else if (childType < returnType) {
  18807. returnType = childType;
  18808. }
  18809. }
  18810. return returnType;
  18811. case 20:
  18812. return 2;
  18813. default:
  18814. return 0;
  18815. }
  18816. }
  18817. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  18818. NORMALIZE_CLASS,
  18819. NORMALIZE_STYLE,
  18820. NORMALIZE_PROPS,
  18821. GUARD_REACTIVE_PROPS
  18822. ]);
  18823. function getConstantTypeOfHelperCall(value, context) {
  18824. if (value.type === 14 && !isString$1(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  18825. const arg = value.arguments[0];
  18826. if (arg.type === 4) {
  18827. return getConstantType(arg, context);
  18828. } else if (arg.type === 14) {
  18829. return getConstantTypeOfHelperCall(arg, context);
  18830. }
  18831. }
  18832. return 0;
  18833. }
  18834. function getGeneratedPropsConstantType(node, context) {
  18835. let returnType = 3;
  18836. const props = getNodeProps(node);
  18837. if (props && props.type === 15) {
  18838. const { properties } = props;
  18839. for (let i = 0; i < properties.length; i++) {
  18840. const { key, value } = properties[i];
  18841. const keyType = getConstantType(key, context);
  18842. if (keyType === 0) {
  18843. return keyType;
  18844. }
  18845. if (keyType < returnType) {
  18846. returnType = keyType;
  18847. }
  18848. let valueType;
  18849. if (value.type === 4) {
  18850. valueType = getConstantType(value, context);
  18851. } else if (value.type === 14) {
  18852. valueType = getConstantTypeOfHelperCall(value, context);
  18853. } else {
  18854. valueType = 0;
  18855. }
  18856. if (valueType === 0) {
  18857. return valueType;
  18858. }
  18859. if (valueType < returnType) {
  18860. returnType = valueType;
  18861. }
  18862. }
  18863. }
  18864. return returnType;
  18865. }
  18866. function getNodeProps(node) {
  18867. const codegenNode = node.codegenNode;
  18868. if (codegenNode.type === 13) {
  18869. return codegenNode.props;
  18870. }
  18871. }
  18872. function createTransformContext(root, {
  18873. filename = "",
  18874. prefixIdentifiers = false,
  18875. hoistStatic = false,
  18876. hmr = false,
  18877. cacheHandlers = false,
  18878. nodeTransforms = [],
  18879. directiveTransforms = {},
  18880. transformHoist = null,
  18881. isBuiltInComponent = NOOP,
  18882. isCustomElement = NOOP,
  18883. expressionPlugins = [],
  18884. scopeId = null,
  18885. slotted = true,
  18886. ssr = false,
  18887. inSSR = false,
  18888. ssrCssVars = ``,
  18889. bindingMetadata = EMPTY_OBJ,
  18890. inline = false,
  18891. isTS = false,
  18892. onError = defaultOnError,
  18893. onWarn = defaultOnWarn,
  18894. compatConfig
  18895. }) {
  18896. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  18897. const context = {
  18898. // options
  18899. filename,
  18900. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  18901. prefixIdentifiers,
  18902. hoistStatic,
  18903. hmr,
  18904. cacheHandlers,
  18905. nodeTransforms,
  18906. directiveTransforms,
  18907. transformHoist,
  18908. isBuiltInComponent,
  18909. isCustomElement,
  18910. expressionPlugins,
  18911. scopeId,
  18912. slotted,
  18913. ssr,
  18914. inSSR,
  18915. ssrCssVars,
  18916. bindingMetadata,
  18917. inline,
  18918. isTS,
  18919. onError,
  18920. onWarn,
  18921. compatConfig,
  18922. // state
  18923. root,
  18924. helpers: /* @__PURE__ */ new Map(),
  18925. components: /* @__PURE__ */ new Set(),
  18926. directives: /* @__PURE__ */ new Set(),
  18927. hoists: [],
  18928. imports: [],
  18929. cached: [],
  18930. constantCache: /* @__PURE__ */ new WeakMap(),
  18931. temps: 0,
  18932. identifiers: /* @__PURE__ */ Object.create(null),
  18933. scopes: {
  18934. vFor: 0,
  18935. vSlot: 0,
  18936. vPre: 0,
  18937. vOnce: 0
  18938. },
  18939. parent: null,
  18940. grandParent: null,
  18941. currentNode: root,
  18942. childIndex: 0,
  18943. inVOnce: false,
  18944. // methods
  18945. helper(name) {
  18946. const count = context.helpers.get(name) || 0;
  18947. context.helpers.set(name, count + 1);
  18948. return name;
  18949. },
  18950. removeHelper(name) {
  18951. const count = context.helpers.get(name);
  18952. if (count) {
  18953. const currentCount = count - 1;
  18954. if (!currentCount) {
  18955. context.helpers.delete(name);
  18956. } else {
  18957. context.helpers.set(name, currentCount);
  18958. }
  18959. }
  18960. },
  18961. helperString(name) {
  18962. return `_${helperNameMap[context.helper(name)]}`;
  18963. },
  18964. replaceNode(node) {
  18965. {
  18966. if (!context.currentNode) {
  18967. throw new Error(`Node being replaced is already removed.`);
  18968. }
  18969. if (!context.parent) {
  18970. throw new Error(`Cannot replace root node.`);
  18971. }
  18972. }
  18973. context.parent.children[context.childIndex] = context.currentNode = node;
  18974. },
  18975. removeNode(node) {
  18976. if (!context.parent) {
  18977. throw new Error(`Cannot remove root node.`);
  18978. }
  18979. const list = context.parent.children;
  18980. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  18981. if (removalIndex < 0) {
  18982. throw new Error(`node being removed is not a child of current parent`);
  18983. }
  18984. if (!node || node === context.currentNode) {
  18985. context.currentNode = null;
  18986. context.onNodeRemoved();
  18987. } else {
  18988. if (context.childIndex > removalIndex) {
  18989. context.childIndex--;
  18990. context.onNodeRemoved();
  18991. }
  18992. }
  18993. context.parent.children.splice(removalIndex, 1);
  18994. },
  18995. onNodeRemoved: NOOP,
  18996. addIdentifiers(exp) {
  18997. {
  18998. if (isString$1(exp)) {
  18999. addId(exp);
  19000. } else if (exp.identifiers) {
  19001. exp.identifiers.forEach(addId);
  19002. } else if (exp.type === 4) {
  19003. addId(exp.content);
  19004. }
  19005. }
  19006. },
  19007. removeIdentifiers(exp) {
  19008. {
  19009. if (isString$1(exp)) {
  19010. removeId(exp);
  19011. } else if (exp.identifiers) {
  19012. exp.identifiers.forEach(removeId);
  19013. } else if (exp.type === 4) {
  19014. removeId(exp.content);
  19015. }
  19016. }
  19017. },
  19018. hoist(exp) {
  19019. if (isString$1(exp)) exp = createSimpleExpression(exp);
  19020. context.hoists.push(exp);
  19021. const identifier = createSimpleExpression(
  19022. `_hoisted_${context.hoists.length}`,
  19023. false,
  19024. exp.loc,
  19025. 2
  19026. );
  19027. identifier.hoisted = exp;
  19028. return identifier;
  19029. },
  19030. cache(exp, isVNode = false, inVOnce = false) {
  19031. const cacheExp = createCacheExpression(
  19032. context.cached.length,
  19033. exp,
  19034. isVNode,
  19035. inVOnce
  19036. );
  19037. context.cached.push(cacheExp);
  19038. return cacheExp;
  19039. }
  19040. };
  19041. function addId(id) {
  19042. const { identifiers } = context;
  19043. if (identifiers[id] === void 0) {
  19044. identifiers[id] = 0;
  19045. }
  19046. identifiers[id]++;
  19047. }
  19048. function removeId(id) {
  19049. context.identifiers[id]--;
  19050. }
  19051. return context;
  19052. }
  19053. function transform(root, options) {
  19054. const context = createTransformContext(root, options);
  19055. traverseNode(root, context);
  19056. if (options.hoistStatic) {
  19057. cacheStatic(root, context);
  19058. }
  19059. if (!options.ssr) {
  19060. createRootCodegen(root, context);
  19061. }
  19062. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  19063. root.components = [...context.components];
  19064. root.directives = [...context.directives];
  19065. root.imports = context.imports;
  19066. root.hoists = context.hoists;
  19067. root.temps = context.temps;
  19068. root.cached = context.cached;
  19069. root.transformed = true;
  19070. }
  19071. function createRootCodegen(root, context) {
  19072. const { helper } = context;
  19073. const { children } = root;
  19074. if (children.length === 1) {
  19075. const singleElementRootChild = getSingleElementRoot(root);
  19076. if (singleElementRootChild && singleElementRootChild.codegenNode) {
  19077. const codegenNode = singleElementRootChild.codegenNode;
  19078. if (codegenNode.type === 13) {
  19079. convertToBlock(codegenNode, context);
  19080. }
  19081. root.codegenNode = codegenNode;
  19082. } else {
  19083. root.codegenNode = children[0];
  19084. }
  19085. } else if (children.length > 1) {
  19086. let patchFlag = 64;
  19087. if (children.filter((c) => c.type !== 3).length === 1) {
  19088. patchFlag |= 2048;
  19089. }
  19090. root.codegenNode = createVNodeCall(
  19091. context,
  19092. helper(FRAGMENT),
  19093. void 0,
  19094. root.children,
  19095. patchFlag,
  19096. void 0,
  19097. void 0,
  19098. true,
  19099. void 0,
  19100. false
  19101. );
  19102. } else ;
  19103. }
  19104. function traverseChildren(parent, context) {
  19105. let i = 0;
  19106. const nodeRemoved = () => {
  19107. i--;
  19108. };
  19109. for (; i < parent.children.length; i++) {
  19110. const child = parent.children[i];
  19111. if (isString$1(child)) continue;
  19112. context.grandParent = context.parent;
  19113. context.parent = parent;
  19114. context.childIndex = i;
  19115. context.onNodeRemoved = nodeRemoved;
  19116. traverseNode(child, context);
  19117. }
  19118. }
  19119. function traverseNode(node, context) {
  19120. context.currentNode = node;
  19121. const { nodeTransforms } = context;
  19122. const exitFns = [];
  19123. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  19124. const onExit = nodeTransforms[i2](node, context);
  19125. if (onExit) {
  19126. if (isArray$3(onExit)) {
  19127. exitFns.push(...onExit);
  19128. } else {
  19129. exitFns.push(onExit);
  19130. }
  19131. }
  19132. if (!context.currentNode) {
  19133. return;
  19134. } else {
  19135. node = context.currentNode;
  19136. }
  19137. }
  19138. switch (node.type) {
  19139. case 3:
  19140. if (!context.ssr) {
  19141. context.helper(CREATE_COMMENT);
  19142. }
  19143. break;
  19144. case 5:
  19145. if (!context.ssr) {
  19146. context.helper(TO_DISPLAY_STRING);
  19147. }
  19148. break;
  19149. // for container types, further traverse downwards
  19150. case 9:
  19151. for (let i2 = 0; i2 < node.branches.length; i2++) {
  19152. traverseNode(node.branches[i2], context);
  19153. }
  19154. break;
  19155. case 10:
  19156. case 11:
  19157. case 1:
  19158. case 0:
  19159. traverseChildren(node, context);
  19160. break;
  19161. }
  19162. context.currentNode = node;
  19163. let i = exitFns.length;
  19164. while (i--) {
  19165. exitFns[i]();
  19166. }
  19167. }
  19168. function createStructuralDirectiveTransform(name, fn) {
  19169. const matches = isString$1(name) ? (n) => n === name : (n) => name.test(n);
  19170. return (node, context) => {
  19171. if (node.type === 1) {
  19172. const { props } = node;
  19173. if (node.tagType === 3 && props.some(isVSlot)) {
  19174. return;
  19175. }
  19176. const exitFns = [];
  19177. for (let i = 0; i < props.length; i++) {
  19178. const prop = props[i];
  19179. if (prop.type === 7 && matches(prop.name)) {
  19180. props.splice(i, 1);
  19181. i--;
  19182. const onExit = fn(node, prop, context);
  19183. if (onExit) exitFns.push(onExit);
  19184. }
  19185. }
  19186. return exitFns;
  19187. }
  19188. };
  19189. }
  19190. var sourceMap$1 = {};
  19191. var sourceMapGenerator$1 = {};
  19192. var base64Vlq$1 = {};
  19193. var base64$1 = {};
  19194. /* -*- Mode: js; js-indent-level: 2; -*- */
  19195. var hasRequiredBase64$1;
  19196. function requireBase64$1 () {
  19197. if (hasRequiredBase64$1) return base64$1;
  19198. hasRequiredBase64$1 = 1;
  19199. /*
  19200. * Copyright 2011 Mozilla Foundation and contributors
  19201. * Licensed under the New BSD license. See LICENSE or:
  19202. * http://opensource.org/licenses/BSD-3-Clause
  19203. */
  19204. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  19205. /**
  19206. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  19207. */
  19208. base64$1.encode = function (number) {
  19209. if (0 <= number && number < intToCharMap.length) {
  19210. return intToCharMap[number];
  19211. }
  19212. throw new TypeError("Must be between 0 and 63: " + number);
  19213. };
  19214. /**
  19215. * Decode a single base 64 character code digit to an integer. Returns -1 on
  19216. * failure.
  19217. */
  19218. base64$1.decode = function (charCode) {
  19219. var bigA = 65; // 'A'
  19220. var bigZ = 90; // 'Z'
  19221. var littleA = 97; // 'a'
  19222. var littleZ = 122; // 'z'
  19223. var zero = 48; // '0'
  19224. var nine = 57; // '9'
  19225. var plus = 43; // '+'
  19226. var slash = 47; // '/'
  19227. var littleOffset = 26;
  19228. var numberOffset = 52;
  19229. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  19230. if (bigA <= charCode && charCode <= bigZ) {
  19231. return (charCode - bigA);
  19232. }
  19233. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  19234. if (littleA <= charCode && charCode <= littleZ) {
  19235. return (charCode - littleA + littleOffset);
  19236. }
  19237. // 52 - 61: 0123456789
  19238. if (zero <= charCode && charCode <= nine) {
  19239. return (charCode - zero + numberOffset);
  19240. }
  19241. // 62: +
  19242. if (charCode == plus) {
  19243. return 62;
  19244. }
  19245. // 63: /
  19246. if (charCode == slash) {
  19247. return 63;
  19248. }
  19249. // Invalid base64 digit.
  19250. return -1;
  19251. };
  19252. return base64$1;
  19253. }
  19254. /* -*- Mode: js; js-indent-level: 2; -*- */
  19255. var hasRequiredBase64Vlq$1;
  19256. function requireBase64Vlq$1 () {
  19257. if (hasRequiredBase64Vlq$1) return base64Vlq$1;
  19258. hasRequiredBase64Vlq$1 = 1;
  19259. /*
  19260. * Copyright 2011 Mozilla Foundation and contributors
  19261. * Licensed under the New BSD license. See LICENSE or:
  19262. * http://opensource.org/licenses/BSD-3-Clause
  19263. *
  19264. * Based on the Base 64 VLQ implementation in Closure Compiler:
  19265. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  19266. *
  19267. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  19268. * Redistribution and use in source and binary forms, with or without
  19269. * modification, are permitted provided that the following conditions are
  19270. * met:
  19271. *
  19272. * * Redistributions of source code must retain the above copyright
  19273. * notice, this list of conditions and the following disclaimer.
  19274. * * Redistributions in binary form must reproduce the above
  19275. * copyright notice, this list of conditions and the following
  19276. * disclaimer in the documentation and/or other materials provided
  19277. * with the distribution.
  19278. * * Neither the name of Google Inc. nor the names of its
  19279. * contributors may be used to endorse or promote products derived
  19280. * from this software without specific prior written permission.
  19281. *
  19282. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19283. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19284. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19285. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  19286. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19287. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19288. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  19289. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19290. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19291. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  19292. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19293. */
  19294. var base64 = /*@__PURE__*/ requireBase64$1();
  19295. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  19296. // length quantities we use in the source map spec, the first bit is the sign,
  19297. // the next four bits are the actual value, and the 6th bit is the
  19298. // continuation bit. The continuation bit tells us whether there are more
  19299. // digits in this value following this digit.
  19300. //
  19301. // Continuation
  19302. // | Sign
  19303. // | |
  19304. // V V
  19305. // 101011
  19306. var VLQ_BASE_SHIFT = 5;
  19307. // binary: 100000
  19308. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  19309. // binary: 011111
  19310. var VLQ_BASE_MASK = VLQ_BASE - 1;
  19311. // binary: 100000
  19312. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  19313. /**
  19314. * Converts from a two-complement value to a value where the sign bit is
  19315. * placed in the least significant bit. For example, as decimals:
  19316. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  19317. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  19318. */
  19319. function toVLQSigned(aValue) {
  19320. return aValue < 0
  19321. ? ((-aValue) << 1) + 1
  19322. : (aValue << 1) + 0;
  19323. }
  19324. /**
  19325. * Converts to a two-complement value from a value where the sign bit is
  19326. * placed in the least significant bit. For example, as decimals:
  19327. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  19328. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  19329. */
  19330. function fromVLQSigned(aValue) {
  19331. var isNegative = (aValue & 1) === 1;
  19332. var shifted = aValue >> 1;
  19333. return isNegative
  19334. ? -shifted
  19335. : shifted;
  19336. }
  19337. /**
  19338. * Returns the base 64 VLQ encoded value.
  19339. */
  19340. base64Vlq$1.encode = function base64VLQ_encode(aValue) {
  19341. var encoded = "";
  19342. var digit;
  19343. var vlq = toVLQSigned(aValue);
  19344. do {
  19345. digit = vlq & VLQ_BASE_MASK;
  19346. vlq >>>= VLQ_BASE_SHIFT;
  19347. if (vlq > 0) {
  19348. // There are still more digits in this value, so we must make sure the
  19349. // continuation bit is marked.
  19350. digit |= VLQ_CONTINUATION_BIT;
  19351. }
  19352. encoded += base64.encode(digit);
  19353. } while (vlq > 0);
  19354. return encoded;
  19355. };
  19356. /**
  19357. * Decodes the next base 64 VLQ value from the given string and returns the
  19358. * value and the rest of the string via the out parameter.
  19359. */
  19360. base64Vlq$1.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  19361. var strLen = aStr.length;
  19362. var result = 0;
  19363. var shift = 0;
  19364. var continuation, digit;
  19365. do {
  19366. if (aIndex >= strLen) {
  19367. throw new Error("Expected more digits in base 64 VLQ value.");
  19368. }
  19369. digit = base64.decode(aStr.charCodeAt(aIndex++));
  19370. if (digit === -1) {
  19371. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  19372. }
  19373. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  19374. digit &= VLQ_BASE_MASK;
  19375. result = result + (digit << shift);
  19376. shift += VLQ_BASE_SHIFT;
  19377. } while (continuation);
  19378. aOutParam.value = fromVLQSigned(result);
  19379. aOutParam.rest = aIndex;
  19380. };
  19381. return base64Vlq$1;
  19382. }
  19383. var util$2 = {};
  19384. /* -*- Mode: js; js-indent-level: 2; -*- */
  19385. var hasRequiredUtil$2;
  19386. function requireUtil$2 () {
  19387. if (hasRequiredUtil$2) return util$2;
  19388. hasRequiredUtil$2 = 1;
  19389. (function (exports) {
  19390. /*
  19391. * Copyright 2011 Mozilla Foundation and contributors
  19392. * Licensed under the New BSD license. See LICENSE or:
  19393. * http://opensource.org/licenses/BSD-3-Clause
  19394. */
  19395. /**
  19396. * This is a helper function for getting values from parameter/options
  19397. * objects.
  19398. *
  19399. * @param args The object we are extracting values from
  19400. * @param name The name of the property we are getting.
  19401. * @param defaultValue An optional value to return if the property is missing
  19402. * from the object. If this is not specified and the property is missing, an
  19403. * error will be thrown.
  19404. */
  19405. function getArg(aArgs, aName, aDefaultValue) {
  19406. if (aName in aArgs) {
  19407. return aArgs[aName];
  19408. } else if (arguments.length === 3) {
  19409. return aDefaultValue;
  19410. } else {
  19411. throw new Error('"' + aName + '" is a required argument.');
  19412. }
  19413. }
  19414. exports.getArg = getArg;
  19415. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  19416. var dataUrlRegexp = /^data:.+\,.+$/;
  19417. function urlParse(aUrl) {
  19418. var match = aUrl.match(urlRegexp);
  19419. if (!match) {
  19420. return null;
  19421. }
  19422. return {
  19423. scheme: match[1],
  19424. auth: match[2],
  19425. host: match[3],
  19426. port: match[4],
  19427. path: match[5]
  19428. };
  19429. }
  19430. exports.urlParse = urlParse;
  19431. function urlGenerate(aParsedUrl) {
  19432. var url = '';
  19433. if (aParsedUrl.scheme) {
  19434. url += aParsedUrl.scheme + ':';
  19435. }
  19436. url += '//';
  19437. if (aParsedUrl.auth) {
  19438. url += aParsedUrl.auth + '@';
  19439. }
  19440. if (aParsedUrl.host) {
  19441. url += aParsedUrl.host;
  19442. }
  19443. if (aParsedUrl.port) {
  19444. url += ":" + aParsedUrl.port;
  19445. }
  19446. if (aParsedUrl.path) {
  19447. url += aParsedUrl.path;
  19448. }
  19449. return url;
  19450. }
  19451. exports.urlGenerate = urlGenerate;
  19452. var MAX_CACHED_INPUTS = 32;
  19453. /**
  19454. * Takes some function `f(input) -> result` and returns a memoized version of
  19455. * `f`.
  19456. *
  19457. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  19458. * memoization is a dumb-simple, linear least-recently-used cache.
  19459. */
  19460. function lruMemoize(f) {
  19461. var cache = [];
  19462. return function(input) {
  19463. for (var i = 0; i < cache.length; i++) {
  19464. if (cache[i].input === input) {
  19465. var temp = cache[0];
  19466. cache[0] = cache[i];
  19467. cache[i] = temp;
  19468. return cache[0].result;
  19469. }
  19470. }
  19471. var result = f(input);
  19472. cache.unshift({
  19473. input,
  19474. result,
  19475. });
  19476. if (cache.length > MAX_CACHED_INPUTS) {
  19477. cache.pop();
  19478. }
  19479. return result;
  19480. };
  19481. }
  19482. /**
  19483. * Normalizes a path, or the path portion of a URL:
  19484. *
  19485. * - Replaces consecutive slashes with one slash.
  19486. * - Removes unnecessary '.' parts.
  19487. * - Removes unnecessary '<dir>/..' parts.
  19488. *
  19489. * Based on code in the Node.js 'path' core module.
  19490. *
  19491. * @param aPath The path or url to normalize.
  19492. */
  19493. var normalize = lruMemoize(function normalize(aPath) {
  19494. var path = aPath;
  19495. var url = urlParse(aPath);
  19496. if (url) {
  19497. if (!url.path) {
  19498. return aPath;
  19499. }
  19500. path = url.path;
  19501. }
  19502. var isAbsolute = exports.isAbsolute(path);
  19503. // Split the path into parts between `/` characters. This is much faster than
  19504. // using `.split(/\/+/g)`.
  19505. var parts = [];
  19506. var start = 0;
  19507. var i = 0;
  19508. while (true) {
  19509. start = i;
  19510. i = path.indexOf("/", start);
  19511. if (i === -1) {
  19512. parts.push(path.slice(start));
  19513. break;
  19514. } else {
  19515. parts.push(path.slice(start, i));
  19516. while (i < path.length && path[i] === "/") {
  19517. i++;
  19518. }
  19519. }
  19520. }
  19521. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  19522. part = parts[i];
  19523. if (part === '.') {
  19524. parts.splice(i, 1);
  19525. } else if (part === '..') {
  19526. up++;
  19527. } else if (up > 0) {
  19528. if (part === '') {
  19529. // The first part is blank if the path is absolute. Trying to go
  19530. // above the root is a no-op. Therefore we can remove all '..' parts
  19531. // directly after the root.
  19532. parts.splice(i + 1, up);
  19533. up = 0;
  19534. } else {
  19535. parts.splice(i, 2);
  19536. up--;
  19537. }
  19538. }
  19539. }
  19540. path = parts.join('/');
  19541. if (path === '') {
  19542. path = isAbsolute ? '/' : '.';
  19543. }
  19544. if (url) {
  19545. url.path = path;
  19546. return urlGenerate(url);
  19547. }
  19548. return path;
  19549. });
  19550. exports.normalize = normalize;
  19551. /**
  19552. * Joins two paths/URLs.
  19553. *
  19554. * @param aRoot The root path or URL.
  19555. * @param aPath The path or URL to be joined with the root.
  19556. *
  19557. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  19558. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  19559. * first.
  19560. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  19561. * is updated with the result and aRoot is returned. Otherwise the result
  19562. * is returned.
  19563. * - If aPath is absolute, the result is aPath.
  19564. * - Otherwise the two paths are joined with a slash.
  19565. * - Joining for example 'http://' and 'www.example.com' is also supported.
  19566. */
  19567. function join(aRoot, aPath) {
  19568. if (aRoot === "") {
  19569. aRoot = ".";
  19570. }
  19571. if (aPath === "") {
  19572. aPath = ".";
  19573. }
  19574. var aPathUrl = urlParse(aPath);
  19575. var aRootUrl = urlParse(aRoot);
  19576. if (aRootUrl) {
  19577. aRoot = aRootUrl.path || '/';
  19578. }
  19579. // `join(foo, '//www.example.org')`
  19580. if (aPathUrl && !aPathUrl.scheme) {
  19581. if (aRootUrl) {
  19582. aPathUrl.scheme = aRootUrl.scheme;
  19583. }
  19584. return urlGenerate(aPathUrl);
  19585. }
  19586. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  19587. return aPath;
  19588. }
  19589. // `join('http://', 'www.example.com')`
  19590. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  19591. aRootUrl.host = aPath;
  19592. return urlGenerate(aRootUrl);
  19593. }
  19594. var joined = aPath.charAt(0) === '/'
  19595. ? aPath
  19596. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  19597. if (aRootUrl) {
  19598. aRootUrl.path = joined;
  19599. return urlGenerate(aRootUrl);
  19600. }
  19601. return joined;
  19602. }
  19603. exports.join = join;
  19604. exports.isAbsolute = function (aPath) {
  19605. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  19606. };
  19607. /**
  19608. * Make a path relative to a URL or another path.
  19609. *
  19610. * @param aRoot The root path or URL.
  19611. * @param aPath The path or URL to be made relative to aRoot.
  19612. */
  19613. function relative(aRoot, aPath) {
  19614. if (aRoot === "") {
  19615. aRoot = ".";
  19616. }
  19617. aRoot = aRoot.replace(/\/$/, '');
  19618. // It is possible for the path to be above the root. In this case, simply
  19619. // checking whether the root is a prefix of the path won't work. Instead, we
  19620. // need to remove components from the root one by one, until either we find
  19621. // a prefix that fits, or we run out of components to remove.
  19622. var level = 0;
  19623. while (aPath.indexOf(aRoot + '/') !== 0) {
  19624. var index = aRoot.lastIndexOf("/");
  19625. if (index < 0) {
  19626. return aPath;
  19627. }
  19628. // If the only part of the root that is left is the scheme (i.e. http://,
  19629. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  19630. // have exhausted all components, so the path is not relative to the root.
  19631. aRoot = aRoot.slice(0, index);
  19632. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  19633. return aPath;
  19634. }
  19635. ++level;
  19636. }
  19637. // Make sure we add a "../" for each component we removed from the root.
  19638. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  19639. }
  19640. exports.relative = relative;
  19641. var supportsNullProto = (function () {
  19642. var obj = Object.create(null);
  19643. return !('__proto__' in obj);
  19644. }());
  19645. function identity (s) {
  19646. return s;
  19647. }
  19648. /**
  19649. * Because behavior goes wacky when you set `__proto__` on objects, we
  19650. * have to prefix all the strings in our set with an arbitrary character.
  19651. *
  19652. * See https://github.com/mozilla/source-map/pull/31 and
  19653. * https://github.com/mozilla/source-map/issues/30
  19654. *
  19655. * @param String aStr
  19656. */
  19657. function toSetString(aStr) {
  19658. if (isProtoString(aStr)) {
  19659. return '$' + aStr;
  19660. }
  19661. return aStr;
  19662. }
  19663. exports.toSetString = supportsNullProto ? identity : toSetString;
  19664. function fromSetString(aStr) {
  19665. if (isProtoString(aStr)) {
  19666. return aStr.slice(1);
  19667. }
  19668. return aStr;
  19669. }
  19670. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  19671. function isProtoString(s) {
  19672. if (!s) {
  19673. return false;
  19674. }
  19675. var length = s.length;
  19676. if (length < 9 /* "__proto__".length */) {
  19677. return false;
  19678. }
  19679. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  19680. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  19681. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  19682. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  19683. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  19684. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  19685. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  19686. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  19687. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  19688. return false;
  19689. }
  19690. for (var i = length - 10; i >= 0; i--) {
  19691. if (s.charCodeAt(i) !== 36 /* '$' */) {
  19692. return false;
  19693. }
  19694. }
  19695. return true;
  19696. }
  19697. /**
  19698. * Comparator between two mappings where the original positions are compared.
  19699. *
  19700. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  19701. * mappings with the same original source/line/column, but different generated
  19702. * line and column the same. Useful when searching for a mapping with a
  19703. * stubbed out mapping.
  19704. */
  19705. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  19706. var cmp = strcmp(mappingA.source, mappingB.source);
  19707. if (cmp !== 0) {
  19708. return cmp;
  19709. }
  19710. cmp = mappingA.originalLine - mappingB.originalLine;
  19711. if (cmp !== 0) {
  19712. return cmp;
  19713. }
  19714. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19715. if (cmp !== 0 || onlyCompareOriginal) {
  19716. return cmp;
  19717. }
  19718. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19719. if (cmp !== 0) {
  19720. return cmp;
  19721. }
  19722. cmp = mappingA.generatedLine - mappingB.generatedLine;
  19723. if (cmp !== 0) {
  19724. return cmp;
  19725. }
  19726. return strcmp(mappingA.name, mappingB.name);
  19727. }
  19728. exports.compareByOriginalPositions = compareByOriginalPositions;
  19729. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  19730. var cmp;
  19731. cmp = mappingA.originalLine - mappingB.originalLine;
  19732. if (cmp !== 0) {
  19733. return cmp;
  19734. }
  19735. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19736. if (cmp !== 0 || onlyCompareOriginal) {
  19737. return cmp;
  19738. }
  19739. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19740. if (cmp !== 0) {
  19741. return cmp;
  19742. }
  19743. cmp = mappingA.generatedLine - mappingB.generatedLine;
  19744. if (cmp !== 0) {
  19745. return cmp;
  19746. }
  19747. return strcmp(mappingA.name, mappingB.name);
  19748. }
  19749. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  19750. /**
  19751. * Comparator between two mappings with deflated source and name indices where
  19752. * the generated positions are compared.
  19753. *
  19754. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  19755. * mappings with the same generated line and column, but different
  19756. * source/name/original line and column the same. Useful when searching for a
  19757. * mapping with a stubbed out mapping.
  19758. */
  19759. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  19760. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  19761. if (cmp !== 0) {
  19762. return cmp;
  19763. }
  19764. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19765. if (cmp !== 0 || onlyCompareGenerated) {
  19766. return cmp;
  19767. }
  19768. cmp = strcmp(mappingA.source, mappingB.source);
  19769. if (cmp !== 0) {
  19770. return cmp;
  19771. }
  19772. cmp = mappingA.originalLine - mappingB.originalLine;
  19773. if (cmp !== 0) {
  19774. return cmp;
  19775. }
  19776. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19777. if (cmp !== 0) {
  19778. return cmp;
  19779. }
  19780. return strcmp(mappingA.name, mappingB.name);
  19781. }
  19782. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  19783. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  19784. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19785. if (cmp !== 0 || onlyCompareGenerated) {
  19786. return cmp;
  19787. }
  19788. cmp = strcmp(mappingA.source, mappingB.source);
  19789. if (cmp !== 0) {
  19790. return cmp;
  19791. }
  19792. cmp = mappingA.originalLine - mappingB.originalLine;
  19793. if (cmp !== 0) {
  19794. return cmp;
  19795. }
  19796. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19797. if (cmp !== 0) {
  19798. return cmp;
  19799. }
  19800. return strcmp(mappingA.name, mappingB.name);
  19801. }
  19802. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  19803. function strcmp(aStr1, aStr2) {
  19804. if (aStr1 === aStr2) {
  19805. return 0;
  19806. }
  19807. if (aStr1 === null) {
  19808. return 1; // aStr2 !== null
  19809. }
  19810. if (aStr2 === null) {
  19811. return -1; // aStr1 !== null
  19812. }
  19813. if (aStr1 > aStr2) {
  19814. return 1;
  19815. }
  19816. return -1;
  19817. }
  19818. /**
  19819. * Comparator between two mappings with inflated source and name strings where
  19820. * the generated positions are compared.
  19821. */
  19822. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  19823. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  19824. if (cmp !== 0) {
  19825. return cmp;
  19826. }
  19827. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19828. if (cmp !== 0) {
  19829. return cmp;
  19830. }
  19831. cmp = strcmp(mappingA.source, mappingB.source);
  19832. if (cmp !== 0) {
  19833. return cmp;
  19834. }
  19835. cmp = mappingA.originalLine - mappingB.originalLine;
  19836. if (cmp !== 0) {
  19837. return cmp;
  19838. }
  19839. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19840. if (cmp !== 0) {
  19841. return cmp;
  19842. }
  19843. return strcmp(mappingA.name, mappingB.name);
  19844. }
  19845. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  19846. /**
  19847. * Strip any JSON XSSI avoidance prefix from the string (as documented
  19848. * in the source maps specification), and then parse the string as
  19849. * JSON.
  19850. */
  19851. function parseSourceMapInput(str) {
  19852. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  19853. }
  19854. exports.parseSourceMapInput = parseSourceMapInput;
  19855. /**
  19856. * Compute the URL of a source given the the source root, the source's
  19857. * URL, and the source map's URL.
  19858. */
  19859. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  19860. sourceURL = sourceURL || '';
  19861. if (sourceRoot) {
  19862. // This follows what Chrome does.
  19863. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  19864. sourceRoot += '/';
  19865. }
  19866. // The spec says:
  19867. // Line 4: An optional source root, useful for relocating source
  19868. // files on a server or removing repeated values in the
  19869. // “sources” entry. This value is prepended to the individual
  19870. // entries in the “source” field.
  19871. sourceURL = sourceRoot + sourceURL;
  19872. }
  19873. // Historically, SourceMapConsumer did not take the sourceMapURL as
  19874. // a parameter. This mode is still somewhat supported, which is why
  19875. // this code block is conditional. However, it's preferable to pass
  19876. // the source map URL to SourceMapConsumer, so that this function
  19877. // can implement the source URL resolution algorithm as outlined in
  19878. // the spec. This block is basically the equivalent of:
  19879. // new URL(sourceURL, sourceMapURL).toString()
  19880. // ... except it avoids using URL, which wasn't available in the
  19881. // older releases of node still supported by this library.
  19882. //
  19883. // The spec says:
  19884. // If the sources are not absolute URLs after prepending of the
  19885. // “sourceRoot”, the sources are resolved relative to the
  19886. // SourceMap (like resolving script src in a html document).
  19887. if (sourceMapURL) {
  19888. var parsed = urlParse(sourceMapURL);
  19889. if (!parsed) {
  19890. throw new Error("sourceMapURL could not be parsed");
  19891. }
  19892. if (parsed.path) {
  19893. // Strip the last path component, but keep the "/".
  19894. var index = parsed.path.lastIndexOf('/');
  19895. if (index >= 0) {
  19896. parsed.path = parsed.path.substring(0, index + 1);
  19897. }
  19898. }
  19899. sourceURL = join(urlGenerate(parsed), sourceURL);
  19900. }
  19901. return normalize(sourceURL);
  19902. }
  19903. exports.computeSourceURL = computeSourceURL;
  19904. } (util$2));
  19905. return util$2;
  19906. }
  19907. var arraySet$1 = {};
  19908. /* -*- Mode: js; js-indent-level: 2; -*- */
  19909. var hasRequiredArraySet$1;
  19910. function requireArraySet$1 () {
  19911. if (hasRequiredArraySet$1) return arraySet$1;
  19912. hasRequiredArraySet$1 = 1;
  19913. /*
  19914. * Copyright 2011 Mozilla Foundation and contributors
  19915. * Licensed under the New BSD license. See LICENSE or:
  19916. * http://opensource.org/licenses/BSD-3-Clause
  19917. */
  19918. var util = /*@__PURE__*/ requireUtil$2();
  19919. var has = Object.prototype.hasOwnProperty;
  19920. var hasNativeMap = typeof Map !== "undefined";
  19921. /**
  19922. * A data structure which is a combination of an array and a set. Adding a new
  19923. * member is O(1), testing for membership is O(1), and finding the index of an
  19924. * element is O(1). Removing elements from the set is not supported. Only
  19925. * strings are supported for membership.
  19926. */
  19927. function ArraySet() {
  19928. this._array = [];
  19929. this._set = hasNativeMap ? new Map() : Object.create(null);
  19930. }
  19931. /**
  19932. * Static method for creating ArraySet instances from an existing array.
  19933. */
  19934. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  19935. var set = new ArraySet();
  19936. for (var i = 0, len = aArray.length; i < len; i++) {
  19937. set.add(aArray[i], aAllowDuplicates);
  19938. }
  19939. return set;
  19940. };
  19941. /**
  19942. * Return how many unique items are in this ArraySet. If duplicates have been
  19943. * added, than those do not count towards the size.
  19944. *
  19945. * @returns Number
  19946. */
  19947. ArraySet.prototype.size = function ArraySet_size() {
  19948. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  19949. };
  19950. /**
  19951. * Add the given string to this set.
  19952. *
  19953. * @param String aStr
  19954. */
  19955. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  19956. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  19957. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  19958. var idx = this._array.length;
  19959. if (!isDuplicate || aAllowDuplicates) {
  19960. this._array.push(aStr);
  19961. }
  19962. if (!isDuplicate) {
  19963. if (hasNativeMap) {
  19964. this._set.set(aStr, idx);
  19965. } else {
  19966. this._set[sStr] = idx;
  19967. }
  19968. }
  19969. };
  19970. /**
  19971. * Is the given string a member of this set?
  19972. *
  19973. * @param String aStr
  19974. */
  19975. ArraySet.prototype.has = function ArraySet_has(aStr) {
  19976. if (hasNativeMap) {
  19977. return this._set.has(aStr);
  19978. } else {
  19979. var sStr = util.toSetString(aStr);
  19980. return has.call(this._set, sStr);
  19981. }
  19982. };
  19983. /**
  19984. * What is the index of the given string in the array?
  19985. *
  19986. * @param String aStr
  19987. */
  19988. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  19989. if (hasNativeMap) {
  19990. var idx = this._set.get(aStr);
  19991. if (idx >= 0) {
  19992. return idx;
  19993. }
  19994. } else {
  19995. var sStr = util.toSetString(aStr);
  19996. if (has.call(this._set, sStr)) {
  19997. return this._set[sStr];
  19998. }
  19999. }
  20000. throw new Error('"' + aStr + '" is not in the set.');
  20001. };
  20002. /**
  20003. * What is the element at the given index?
  20004. *
  20005. * @param Number aIdx
  20006. */
  20007. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  20008. if (aIdx >= 0 && aIdx < this._array.length) {
  20009. return this._array[aIdx];
  20010. }
  20011. throw new Error('No element indexed by ' + aIdx);
  20012. };
  20013. /**
  20014. * Returns the array representation of this set (which has the proper indices
  20015. * indicated by indexOf). Note that this is a copy of the internal array used
  20016. * for storing the members so that no one can mess with internal state.
  20017. */
  20018. ArraySet.prototype.toArray = function ArraySet_toArray() {
  20019. return this._array.slice();
  20020. };
  20021. arraySet$1.ArraySet = ArraySet;
  20022. return arraySet$1;
  20023. }
  20024. var mappingList$1 = {};
  20025. /* -*- Mode: js; js-indent-level: 2; -*- */
  20026. var hasRequiredMappingList$1;
  20027. function requireMappingList$1 () {
  20028. if (hasRequiredMappingList$1) return mappingList$1;
  20029. hasRequiredMappingList$1 = 1;
  20030. /*
  20031. * Copyright 2014 Mozilla Foundation and contributors
  20032. * Licensed under the New BSD license. See LICENSE or:
  20033. * http://opensource.org/licenses/BSD-3-Clause
  20034. */
  20035. var util = /*@__PURE__*/ requireUtil$2();
  20036. /**
  20037. * Determine whether mappingB is after mappingA with respect to generated
  20038. * position.
  20039. */
  20040. function generatedPositionAfter(mappingA, mappingB) {
  20041. // Optimized for most common case
  20042. var lineA = mappingA.generatedLine;
  20043. var lineB = mappingB.generatedLine;
  20044. var columnA = mappingA.generatedColumn;
  20045. var columnB = mappingB.generatedColumn;
  20046. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  20047. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  20048. }
  20049. /**
  20050. * A data structure to provide a sorted view of accumulated mappings in a
  20051. * performance conscious manner. It trades a neglibable overhead in general
  20052. * case for a large speedup in case of mappings being added in order.
  20053. */
  20054. function MappingList() {
  20055. this._array = [];
  20056. this._sorted = true;
  20057. // Serves as infimum
  20058. this._last = {generatedLine: -1, generatedColumn: 0};
  20059. }
  20060. /**
  20061. * Iterate through internal items. This method takes the same arguments that
  20062. * `Array.prototype.forEach` takes.
  20063. *
  20064. * NOTE: The order of the mappings is NOT guaranteed.
  20065. */
  20066. MappingList.prototype.unsortedForEach =
  20067. function MappingList_forEach(aCallback, aThisArg) {
  20068. this._array.forEach(aCallback, aThisArg);
  20069. };
  20070. /**
  20071. * Add the given source mapping.
  20072. *
  20073. * @param Object aMapping
  20074. */
  20075. MappingList.prototype.add = function MappingList_add(aMapping) {
  20076. if (generatedPositionAfter(this._last, aMapping)) {
  20077. this._last = aMapping;
  20078. this._array.push(aMapping);
  20079. } else {
  20080. this._sorted = false;
  20081. this._array.push(aMapping);
  20082. }
  20083. };
  20084. /**
  20085. * Returns the flat, sorted array of mappings. The mappings are sorted by
  20086. * generated position.
  20087. *
  20088. * WARNING: This method returns internal data without copying, for
  20089. * performance. The return value must NOT be mutated, and should be treated as
  20090. * an immutable borrow. If you want to take ownership, you must make your own
  20091. * copy.
  20092. */
  20093. MappingList.prototype.toArray = function MappingList_toArray() {
  20094. if (!this._sorted) {
  20095. this._array.sort(util.compareByGeneratedPositionsInflated);
  20096. this._sorted = true;
  20097. }
  20098. return this._array;
  20099. };
  20100. mappingList$1.MappingList = MappingList;
  20101. return mappingList$1;
  20102. }
  20103. /* -*- Mode: js; js-indent-level: 2; -*- */
  20104. var hasRequiredSourceMapGenerator$1;
  20105. function requireSourceMapGenerator$1 () {
  20106. if (hasRequiredSourceMapGenerator$1) return sourceMapGenerator$1;
  20107. hasRequiredSourceMapGenerator$1 = 1;
  20108. /*
  20109. * Copyright 2011 Mozilla Foundation and contributors
  20110. * Licensed under the New BSD license. See LICENSE or:
  20111. * http://opensource.org/licenses/BSD-3-Clause
  20112. */
  20113. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$1();
  20114. var util = /*@__PURE__*/ requireUtil$2();
  20115. var ArraySet = /*@__PURE__*/ requireArraySet$1().ArraySet;
  20116. var MappingList = /*@__PURE__*/ requireMappingList$1().MappingList;
  20117. /**
  20118. * An instance of the SourceMapGenerator represents a source map which is
  20119. * being built incrementally. You may pass an object with the following
  20120. * properties:
  20121. *
  20122. * - file: The filename of the generated source.
  20123. * - sourceRoot: A root for all relative URLs in this source map.
  20124. */
  20125. function SourceMapGenerator(aArgs) {
  20126. if (!aArgs) {
  20127. aArgs = {};
  20128. }
  20129. this._file = util.getArg(aArgs, 'file', null);
  20130. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  20131. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  20132. this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
  20133. this._sources = new ArraySet();
  20134. this._names = new ArraySet();
  20135. this._mappings = new MappingList();
  20136. this._sourcesContents = null;
  20137. }
  20138. SourceMapGenerator.prototype._version = 3;
  20139. /**
  20140. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  20141. *
  20142. * @param aSourceMapConsumer The SourceMap.
  20143. */
  20144. SourceMapGenerator.fromSourceMap =
  20145. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  20146. var sourceRoot = aSourceMapConsumer.sourceRoot;
  20147. var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
  20148. file: aSourceMapConsumer.file,
  20149. sourceRoot: sourceRoot
  20150. }));
  20151. aSourceMapConsumer.eachMapping(function (mapping) {
  20152. var newMapping = {
  20153. generated: {
  20154. line: mapping.generatedLine,
  20155. column: mapping.generatedColumn
  20156. }
  20157. };
  20158. if (mapping.source != null) {
  20159. newMapping.source = mapping.source;
  20160. if (sourceRoot != null) {
  20161. newMapping.source = util.relative(sourceRoot, newMapping.source);
  20162. }
  20163. newMapping.original = {
  20164. line: mapping.originalLine,
  20165. column: mapping.originalColumn
  20166. };
  20167. if (mapping.name != null) {
  20168. newMapping.name = mapping.name;
  20169. }
  20170. }
  20171. generator.addMapping(newMapping);
  20172. });
  20173. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  20174. var sourceRelative = sourceFile;
  20175. if (sourceRoot !== null) {
  20176. sourceRelative = util.relative(sourceRoot, sourceFile);
  20177. }
  20178. if (!generator._sources.has(sourceRelative)) {
  20179. generator._sources.add(sourceRelative);
  20180. }
  20181. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  20182. if (content != null) {
  20183. generator.setSourceContent(sourceFile, content);
  20184. }
  20185. });
  20186. return generator;
  20187. };
  20188. /**
  20189. * Add a single mapping from original source line and column to the generated
  20190. * source's line and column for this source map being created. The mapping
  20191. * object should have the following properties:
  20192. *
  20193. * - generated: An object with the generated line and column positions.
  20194. * - original: An object with the original line and column positions.
  20195. * - source: The original source file (relative to the sourceRoot).
  20196. * - name: An optional original token name for this mapping.
  20197. */
  20198. SourceMapGenerator.prototype.addMapping =
  20199. function SourceMapGenerator_addMapping(aArgs) {
  20200. var generated = util.getArg(aArgs, 'generated');
  20201. var original = util.getArg(aArgs, 'original', null);
  20202. var source = util.getArg(aArgs, 'source', null);
  20203. var name = util.getArg(aArgs, 'name', null);
  20204. if (!this._skipValidation) {
  20205. if (this._validateMapping(generated, original, source, name) === false) {
  20206. return;
  20207. }
  20208. }
  20209. if (source != null) {
  20210. source = String(source);
  20211. if (!this._sources.has(source)) {
  20212. this._sources.add(source);
  20213. }
  20214. }
  20215. if (name != null) {
  20216. name = String(name);
  20217. if (!this._names.has(name)) {
  20218. this._names.add(name);
  20219. }
  20220. }
  20221. this._mappings.add({
  20222. generatedLine: generated.line,
  20223. generatedColumn: generated.column,
  20224. originalLine: original != null && original.line,
  20225. originalColumn: original != null && original.column,
  20226. source: source,
  20227. name: name
  20228. });
  20229. };
  20230. /**
  20231. * Set the source content for a source file.
  20232. */
  20233. SourceMapGenerator.prototype.setSourceContent =
  20234. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  20235. var source = aSourceFile;
  20236. if (this._sourceRoot != null) {
  20237. source = util.relative(this._sourceRoot, source);
  20238. }
  20239. if (aSourceContent != null) {
  20240. // Add the source content to the _sourcesContents map.
  20241. // Create a new _sourcesContents map if the property is null.
  20242. if (!this._sourcesContents) {
  20243. this._sourcesContents = Object.create(null);
  20244. }
  20245. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  20246. } else if (this._sourcesContents) {
  20247. // Remove the source file from the _sourcesContents map.
  20248. // If the _sourcesContents map is empty, set the property to null.
  20249. delete this._sourcesContents[util.toSetString(source)];
  20250. if (Object.keys(this._sourcesContents).length === 0) {
  20251. this._sourcesContents = null;
  20252. }
  20253. }
  20254. };
  20255. /**
  20256. * Applies the mappings of a sub-source-map for a specific source file to the
  20257. * source map being generated. Each mapping to the supplied source file is
  20258. * rewritten using the supplied source map. Note: The resolution for the
  20259. * resulting mappings is the minimium of this map and the supplied map.
  20260. *
  20261. * @param aSourceMapConsumer The source map to be applied.
  20262. * @param aSourceFile Optional. The filename of the source file.
  20263. * If omitted, SourceMapConsumer's file property will be used.
  20264. * @param aSourceMapPath Optional. The dirname of the path to the source map
  20265. * to be applied. If relative, it is relative to the SourceMapConsumer.
  20266. * This parameter is needed when the two source maps aren't in the same
  20267. * directory, and the source map to be applied contains relative source
  20268. * paths. If so, those relative source paths need to be rewritten
  20269. * relative to the SourceMapGenerator.
  20270. */
  20271. SourceMapGenerator.prototype.applySourceMap =
  20272. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  20273. var sourceFile = aSourceFile;
  20274. // If aSourceFile is omitted, we will use the file property of the SourceMap
  20275. if (aSourceFile == null) {
  20276. if (aSourceMapConsumer.file == null) {
  20277. throw new Error(
  20278. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  20279. 'or the source map\'s "file" property. Both were omitted.'
  20280. );
  20281. }
  20282. sourceFile = aSourceMapConsumer.file;
  20283. }
  20284. var sourceRoot = this._sourceRoot;
  20285. // Make "sourceFile" relative if an absolute Url is passed.
  20286. if (sourceRoot != null) {
  20287. sourceFile = util.relative(sourceRoot, sourceFile);
  20288. }
  20289. // Applying the SourceMap can add and remove items from the sources and
  20290. // the names array.
  20291. var newSources = new ArraySet();
  20292. var newNames = new ArraySet();
  20293. // Find mappings for the "sourceFile"
  20294. this._mappings.unsortedForEach(function (mapping) {
  20295. if (mapping.source === sourceFile && mapping.originalLine != null) {
  20296. // Check if it can be mapped by the source map, then update the mapping.
  20297. var original = aSourceMapConsumer.originalPositionFor({
  20298. line: mapping.originalLine,
  20299. column: mapping.originalColumn
  20300. });
  20301. if (original.source != null) {
  20302. // Copy mapping
  20303. mapping.source = original.source;
  20304. if (aSourceMapPath != null) {
  20305. mapping.source = util.join(aSourceMapPath, mapping.source);
  20306. }
  20307. if (sourceRoot != null) {
  20308. mapping.source = util.relative(sourceRoot, mapping.source);
  20309. }
  20310. mapping.originalLine = original.line;
  20311. mapping.originalColumn = original.column;
  20312. if (original.name != null) {
  20313. mapping.name = original.name;
  20314. }
  20315. }
  20316. }
  20317. var source = mapping.source;
  20318. if (source != null && !newSources.has(source)) {
  20319. newSources.add(source);
  20320. }
  20321. var name = mapping.name;
  20322. if (name != null && !newNames.has(name)) {
  20323. newNames.add(name);
  20324. }
  20325. }, this);
  20326. this._sources = newSources;
  20327. this._names = newNames;
  20328. // Copy sourcesContents of applied map.
  20329. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  20330. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  20331. if (content != null) {
  20332. if (aSourceMapPath != null) {
  20333. sourceFile = util.join(aSourceMapPath, sourceFile);
  20334. }
  20335. if (sourceRoot != null) {
  20336. sourceFile = util.relative(sourceRoot, sourceFile);
  20337. }
  20338. this.setSourceContent(sourceFile, content);
  20339. }
  20340. }, this);
  20341. };
  20342. /**
  20343. * A mapping can have one of the three levels of data:
  20344. *
  20345. * 1. Just the generated position.
  20346. * 2. The Generated position, original position, and original source.
  20347. * 3. Generated and original position, original source, as well as a name
  20348. * token.
  20349. *
  20350. * To maintain consistency, we validate that any new mapping being added falls
  20351. * in to one of these categories.
  20352. */
  20353. SourceMapGenerator.prototype._validateMapping =
  20354. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  20355. aName) {
  20356. // When aOriginal is truthy but has empty values for .line and .column,
  20357. // it is most likely a programmer error. In this case we throw a very
  20358. // specific error message to try to guide them the right way.
  20359. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  20360. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  20361. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  20362. 'the original mapping entirely and only map the generated position. If so, pass ' +
  20363. 'null for the original mapping instead of an object with empty or null values.';
  20364. if (this._ignoreInvalidMapping) {
  20365. if (typeof console !== 'undefined' && console.warn) {
  20366. console.warn(message);
  20367. }
  20368. return false;
  20369. } else {
  20370. throw new Error(message);
  20371. }
  20372. }
  20373. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  20374. && aGenerated.line > 0 && aGenerated.column >= 0
  20375. && !aOriginal && !aSource && !aName) {
  20376. // Case 1.
  20377. return;
  20378. }
  20379. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  20380. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  20381. && aGenerated.line > 0 && aGenerated.column >= 0
  20382. && aOriginal.line > 0 && aOriginal.column >= 0
  20383. && aSource) {
  20384. // Cases 2 and 3.
  20385. return;
  20386. }
  20387. else {
  20388. var message = 'Invalid mapping: ' + JSON.stringify({
  20389. generated: aGenerated,
  20390. source: aSource,
  20391. original: aOriginal,
  20392. name: aName
  20393. });
  20394. if (this._ignoreInvalidMapping) {
  20395. if (typeof console !== 'undefined' && console.warn) {
  20396. console.warn(message);
  20397. }
  20398. return false;
  20399. } else {
  20400. throw new Error(message)
  20401. }
  20402. }
  20403. };
  20404. /**
  20405. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  20406. * specified by the source map format.
  20407. */
  20408. SourceMapGenerator.prototype._serializeMappings =
  20409. function SourceMapGenerator_serializeMappings() {
  20410. var previousGeneratedColumn = 0;
  20411. var previousGeneratedLine = 1;
  20412. var previousOriginalColumn = 0;
  20413. var previousOriginalLine = 0;
  20414. var previousName = 0;
  20415. var previousSource = 0;
  20416. var result = '';
  20417. var next;
  20418. var mapping;
  20419. var nameIdx;
  20420. var sourceIdx;
  20421. var mappings = this._mappings.toArray();
  20422. for (var i = 0, len = mappings.length; i < len; i++) {
  20423. mapping = mappings[i];
  20424. next = '';
  20425. if (mapping.generatedLine !== previousGeneratedLine) {
  20426. previousGeneratedColumn = 0;
  20427. while (mapping.generatedLine !== previousGeneratedLine) {
  20428. next += ';';
  20429. previousGeneratedLine++;
  20430. }
  20431. }
  20432. else {
  20433. if (i > 0) {
  20434. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  20435. continue;
  20436. }
  20437. next += ',';
  20438. }
  20439. }
  20440. next += base64VLQ.encode(mapping.generatedColumn
  20441. - previousGeneratedColumn);
  20442. previousGeneratedColumn = mapping.generatedColumn;
  20443. if (mapping.source != null) {
  20444. sourceIdx = this._sources.indexOf(mapping.source);
  20445. next += base64VLQ.encode(sourceIdx - previousSource);
  20446. previousSource = sourceIdx;
  20447. // lines are stored 0-based in SourceMap spec version 3
  20448. next += base64VLQ.encode(mapping.originalLine - 1
  20449. - previousOriginalLine);
  20450. previousOriginalLine = mapping.originalLine - 1;
  20451. next += base64VLQ.encode(mapping.originalColumn
  20452. - previousOriginalColumn);
  20453. previousOriginalColumn = mapping.originalColumn;
  20454. if (mapping.name != null) {
  20455. nameIdx = this._names.indexOf(mapping.name);
  20456. next += base64VLQ.encode(nameIdx - previousName);
  20457. previousName = nameIdx;
  20458. }
  20459. }
  20460. result += next;
  20461. }
  20462. return result;
  20463. };
  20464. SourceMapGenerator.prototype._generateSourcesContent =
  20465. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  20466. return aSources.map(function (source) {
  20467. if (!this._sourcesContents) {
  20468. return null;
  20469. }
  20470. if (aSourceRoot != null) {
  20471. source = util.relative(aSourceRoot, source);
  20472. }
  20473. var key = util.toSetString(source);
  20474. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  20475. ? this._sourcesContents[key]
  20476. : null;
  20477. }, this);
  20478. };
  20479. /**
  20480. * Externalize the source map.
  20481. */
  20482. SourceMapGenerator.prototype.toJSON =
  20483. function SourceMapGenerator_toJSON() {
  20484. var map = {
  20485. version: this._version,
  20486. sources: this._sources.toArray(),
  20487. names: this._names.toArray(),
  20488. mappings: this._serializeMappings()
  20489. };
  20490. if (this._file != null) {
  20491. map.file = this._file;
  20492. }
  20493. if (this._sourceRoot != null) {
  20494. map.sourceRoot = this._sourceRoot;
  20495. }
  20496. if (this._sourcesContents) {
  20497. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  20498. }
  20499. return map;
  20500. };
  20501. /**
  20502. * Render the source map being generated to a string.
  20503. */
  20504. SourceMapGenerator.prototype.toString =
  20505. function SourceMapGenerator_toString() {
  20506. return JSON.stringify(this.toJSON());
  20507. };
  20508. sourceMapGenerator$1.SourceMapGenerator = SourceMapGenerator;
  20509. return sourceMapGenerator$1;
  20510. }
  20511. var sourceMapConsumer$1 = {};
  20512. var binarySearch$1 = {};
  20513. /* -*- Mode: js; js-indent-level: 2; -*- */
  20514. var hasRequiredBinarySearch$1;
  20515. function requireBinarySearch$1 () {
  20516. if (hasRequiredBinarySearch$1) return binarySearch$1;
  20517. hasRequiredBinarySearch$1 = 1;
  20518. (function (exports) {
  20519. /*
  20520. * Copyright 2011 Mozilla Foundation and contributors
  20521. * Licensed under the New BSD license. See LICENSE or:
  20522. * http://opensource.org/licenses/BSD-3-Clause
  20523. */
  20524. exports.GREATEST_LOWER_BOUND = 1;
  20525. exports.LEAST_UPPER_BOUND = 2;
  20526. /**
  20527. * Recursive implementation of binary search.
  20528. *
  20529. * @param aLow Indices here and lower do not contain the needle.
  20530. * @param aHigh Indices here and higher do not contain the needle.
  20531. * @param aNeedle The element being searched for.
  20532. * @param aHaystack The non-empty array being searched.
  20533. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  20534. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  20535. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  20536. * closest element that is smaller than or greater than the one we are
  20537. * searching for, respectively, if the exact element cannot be found.
  20538. */
  20539. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  20540. // This function terminates when one of the following is true:
  20541. //
  20542. // 1. We find the exact element we are looking for.
  20543. //
  20544. // 2. We did not find the exact element, but we can return the index of
  20545. // the next-closest element.
  20546. //
  20547. // 3. We did not find the exact element, and there is no next-closest
  20548. // element than the one we are searching for, so we return -1.
  20549. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  20550. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  20551. if (cmp === 0) {
  20552. // Found the element we are looking for.
  20553. return mid;
  20554. }
  20555. else if (cmp > 0) {
  20556. // Our needle is greater than aHaystack[mid].
  20557. if (aHigh - mid > 1) {
  20558. // The element is in the upper half.
  20559. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  20560. }
  20561. // The exact needle element was not found in this haystack. Determine if
  20562. // we are in termination case (3) or (2) and return the appropriate thing.
  20563. if (aBias == exports.LEAST_UPPER_BOUND) {
  20564. return aHigh < aHaystack.length ? aHigh : -1;
  20565. } else {
  20566. return mid;
  20567. }
  20568. }
  20569. else {
  20570. // Our needle is less than aHaystack[mid].
  20571. if (mid - aLow > 1) {
  20572. // The element is in the lower half.
  20573. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  20574. }
  20575. // we are in termination case (3) or (2) and return the appropriate thing.
  20576. if (aBias == exports.LEAST_UPPER_BOUND) {
  20577. return mid;
  20578. } else {
  20579. return aLow < 0 ? -1 : aLow;
  20580. }
  20581. }
  20582. }
  20583. /**
  20584. * This is an implementation of binary search which will always try and return
  20585. * the index of the closest element if there is no exact hit. This is because
  20586. * mappings between original and generated line/col pairs are single points,
  20587. * and there is an implicit region between each of them, so a miss just means
  20588. * that you aren't on the very start of a region.
  20589. *
  20590. * @param aNeedle The element you are looking for.
  20591. * @param aHaystack The array that is being searched.
  20592. * @param aCompare A function which takes the needle and an element in the
  20593. * array and returns -1, 0, or 1 depending on whether the needle is less
  20594. * than, equal to, or greater than the element, respectively.
  20595. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  20596. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  20597. * closest element that is smaller than or greater than the one we are
  20598. * searching for, respectively, if the exact element cannot be found.
  20599. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  20600. */
  20601. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  20602. if (aHaystack.length === 0) {
  20603. return -1;
  20604. }
  20605. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  20606. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  20607. if (index < 0) {
  20608. return -1;
  20609. }
  20610. // We have found either the exact element, or the next-closest element than
  20611. // the one we are searching for. However, there may be more than one such
  20612. // element. Make sure we always return the smallest of these.
  20613. while (index - 1 >= 0) {
  20614. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  20615. break;
  20616. }
  20617. --index;
  20618. }
  20619. return index;
  20620. };
  20621. } (binarySearch$1));
  20622. return binarySearch$1;
  20623. }
  20624. var quickSort$1 = {};
  20625. /* -*- Mode: js; js-indent-level: 2; -*- */
  20626. var hasRequiredQuickSort$1;
  20627. function requireQuickSort$1 () {
  20628. if (hasRequiredQuickSort$1) return quickSort$1;
  20629. hasRequiredQuickSort$1 = 1;
  20630. /*
  20631. * Copyright 2011 Mozilla Foundation and contributors
  20632. * Licensed under the New BSD license. See LICENSE or:
  20633. * http://opensource.org/licenses/BSD-3-Clause
  20634. */
  20635. // It turns out that some (most?) JavaScript engines don't self-host
  20636. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  20637. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  20638. // custom comparator function, calling back and forth between the VM's C++ and
  20639. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  20640. // worse generated code for the comparator function than would be optimal. In
  20641. // fact, when sorting with a comparator, these costs outweigh the benefits of
  20642. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  20643. // a ~3500ms mean speed-up in `bench/bench.html`.
  20644. function SortTemplate(comparator) {
  20645. /**
  20646. * Swap the elements indexed by `x` and `y` in the array `ary`.
  20647. *
  20648. * @param {Array} ary
  20649. * The array.
  20650. * @param {Number} x
  20651. * The index of the first item.
  20652. * @param {Number} y
  20653. * The index of the second item.
  20654. */
  20655. function swap(ary, x, y) {
  20656. var temp = ary[x];
  20657. ary[x] = ary[y];
  20658. ary[y] = temp;
  20659. }
  20660. /**
  20661. * Returns a random integer within the range `low .. high` inclusive.
  20662. *
  20663. * @param {Number} low
  20664. * The lower bound on the range.
  20665. * @param {Number} high
  20666. * The upper bound on the range.
  20667. */
  20668. function randomIntInRange(low, high) {
  20669. return Math.round(low + (Math.random() * (high - low)));
  20670. }
  20671. /**
  20672. * The Quick Sort algorithm.
  20673. *
  20674. * @param {Array} ary
  20675. * An array to sort.
  20676. * @param {function} comparator
  20677. * Function to use to compare two items.
  20678. * @param {Number} p
  20679. * Start index of the array
  20680. * @param {Number} r
  20681. * End index of the array
  20682. */
  20683. function doQuickSort(ary, comparator, p, r) {
  20684. // If our lower bound is less than our upper bound, we (1) partition the
  20685. // array into two pieces and (2) recurse on each half. If it is not, this is
  20686. // the empty array and our base case.
  20687. if (p < r) {
  20688. // (1) Partitioning.
  20689. //
  20690. // The partitioning chooses a pivot between `p` and `r` and moves all
  20691. // elements that are less than or equal to the pivot to the before it, and
  20692. // all the elements that are greater than it after it. The effect is that
  20693. // once partition is done, the pivot is in the exact place it will be when
  20694. // the array is put in sorted order, and it will not need to be moved
  20695. // again. This runs in O(n) time.
  20696. // Always choose a random pivot so that an input array which is reverse
  20697. // sorted does not cause O(n^2) running time.
  20698. var pivotIndex = randomIntInRange(p, r);
  20699. var i = p - 1;
  20700. swap(ary, pivotIndex, r);
  20701. var pivot = ary[r];
  20702. // Immediately after `j` is incremented in this loop, the following hold
  20703. // true:
  20704. //
  20705. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  20706. //
  20707. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  20708. for (var j = p; j < r; j++) {
  20709. if (comparator(ary[j], pivot, false) <= 0) {
  20710. i += 1;
  20711. swap(ary, i, j);
  20712. }
  20713. }
  20714. swap(ary, i + 1, j);
  20715. var q = i + 1;
  20716. // (2) Recurse on each half.
  20717. doQuickSort(ary, comparator, p, q - 1);
  20718. doQuickSort(ary, comparator, q + 1, r);
  20719. }
  20720. }
  20721. return doQuickSort;
  20722. }
  20723. function cloneSort(comparator) {
  20724. let template = SortTemplate.toString();
  20725. let templateFn = new Function(`return ${template}`)();
  20726. return templateFn(comparator);
  20727. }
  20728. /**
  20729. * Sort the given array in-place with the given comparator function.
  20730. *
  20731. * @param {Array} ary
  20732. * An array to sort.
  20733. * @param {function} comparator
  20734. * Function to use to compare two items.
  20735. */
  20736. let sortCache = new WeakMap();
  20737. quickSort$1.quickSort = function (ary, comparator, start = 0) {
  20738. let doQuickSort = sortCache.get(comparator);
  20739. if (doQuickSort === void 0) {
  20740. doQuickSort = cloneSort(comparator);
  20741. sortCache.set(comparator, doQuickSort);
  20742. }
  20743. doQuickSort(ary, comparator, start, ary.length - 1);
  20744. };
  20745. return quickSort$1;
  20746. }
  20747. /* -*- Mode: js; js-indent-level: 2; -*- */
  20748. var hasRequiredSourceMapConsumer$1;
  20749. function requireSourceMapConsumer$1 () {
  20750. if (hasRequiredSourceMapConsumer$1) return sourceMapConsumer$1;
  20751. hasRequiredSourceMapConsumer$1 = 1;
  20752. /*
  20753. * Copyright 2011 Mozilla Foundation and contributors
  20754. * Licensed under the New BSD license. See LICENSE or:
  20755. * http://opensource.org/licenses/BSD-3-Clause
  20756. */
  20757. var util = /*@__PURE__*/ requireUtil$2();
  20758. var binarySearch = /*@__PURE__*/ requireBinarySearch$1();
  20759. var ArraySet = /*@__PURE__*/ requireArraySet$1().ArraySet;
  20760. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$1();
  20761. var quickSort = /*@__PURE__*/ requireQuickSort$1().quickSort;
  20762. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  20763. var sourceMap = aSourceMap;
  20764. if (typeof aSourceMap === 'string') {
  20765. sourceMap = util.parseSourceMapInput(aSourceMap);
  20766. }
  20767. return sourceMap.sections != null
  20768. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  20769. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  20770. }
  20771. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  20772. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  20773. };
  20774. /**
  20775. * The version of the source mapping spec that we are consuming.
  20776. */
  20777. SourceMapConsumer.prototype._version = 3;
  20778. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  20779. // parsed mapping coordinates from the source map's "mappings" attribute. They
  20780. // are lazily instantiated, accessed via the `_generatedMappings` and
  20781. // `_originalMappings` getters respectively, and we only parse the mappings
  20782. // and create these arrays once queried for a source location. We jump through
  20783. // these hoops because there can be many thousands of mappings, and parsing
  20784. // them is expensive, so we only want to do it if we must.
  20785. //
  20786. // Each object in the arrays is of the form:
  20787. //
  20788. // {
  20789. // generatedLine: The line number in the generated code,
  20790. // generatedColumn: The column number in the generated code,
  20791. // source: The path to the original source file that generated this
  20792. // chunk of code,
  20793. // originalLine: The line number in the original source that
  20794. // corresponds to this chunk of generated code,
  20795. // originalColumn: The column number in the original source that
  20796. // corresponds to this chunk of generated code,
  20797. // name: The name of the original symbol which generated this chunk of
  20798. // code.
  20799. // }
  20800. //
  20801. // All properties except for `generatedLine` and `generatedColumn` can be
  20802. // `null`.
  20803. //
  20804. // `_generatedMappings` is ordered by the generated positions.
  20805. //
  20806. // `_originalMappings` is ordered by the original positions.
  20807. SourceMapConsumer.prototype.__generatedMappings = null;
  20808. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  20809. configurable: true,
  20810. enumerable: true,
  20811. get: function () {
  20812. if (!this.__generatedMappings) {
  20813. this._parseMappings(this._mappings, this.sourceRoot);
  20814. }
  20815. return this.__generatedMappings;
  20816. }
  20817. });
  20818. SourceMapConsumer.prototype.__originalMappings = null;
  20819. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  20820. configurable: true,
  20821. enumerable: true,
  20822. get: function () {
  20823. if (!this.__originalMappings) {
  20824. this._parseMappings(this._mappings, this.sourceRoot);
  20825. }
  20826. return this.__originalMappings;
  20827. }
  20828. });
  20829. SourceMapConsumer.prototype._charIsMappingSeparator =
  20830. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  20831. var c = aStr.charAt(index);
  20832. return c === ";" || c === ",";
  20833. };
  20834. /**
  20835. * Parse the mappings in a string in to a data structure which we can easily
  20836. * query (the ordered arrays in the `this.__generatedMappings` and
  20837. * `this.__originalMappings` properties).
  20838. */
  20839. SourceMapConsumer.prototype._parseMappings =
  20840. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20841. throw new Error("Subclasses must implement _parseMappings");
  20842. };
  20843. SourceMapConsumer.GENERATED_ORDER = 1;
  20844. SourceMapConsumer.ORIGINAL_ORDER = 2;
  20845. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  20846. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  20847. /**
  20848. * Iterate over each mapping between an original source/line/column and a
  20849. * generated line/column in this source map.
  20850. *
  20851. * @param Function aCallback
  20852. * The function that is called with each mapping.
  20853. * @param Object aContext
  20854. * Optional. If specified, this object will be the value of `this` every
  20855. * time that `aCallback` is called.
  20856. * @param aOrder
  20857. * Either `SourceMapConsumer.GENERATED_ORDER` or
  20858. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  20859. * iterate over the mappings sorted by the generated file's line/column
  20860. * order or the original's source/line/column order, respectively. Defaults to
  20861. * `SourceMapConsumer.GENERATED_ORDER`.
  20862. */
  20863. SourceMapConsumer.prototype.eachMapping =
  20864. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  20865. var context = aContext || null;
  20866. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  20867. var mappings;
  20868. switch (order) {
  20869. case SourceMapConsumer.GENERATED_ORDER:
  20870. mappings = this._generatedMappings;
  20871. break;
  20872. case SourceMapConsumer.ORIGINAL_ORDER:
  20873. mappings = this._originalMappings;
  20874. break;
  20875. default:
  20876. throw new Error("Unknown order of iteration.");
  20877. }
  20878. var sourceRoot = this.sourceRoot;
  20879. var boundCallback = aCallback.bind(context);
  20880. var names = this._names;
  20881. var sources = this._sources;
  20882. var sourceMapURL = this._sourceMapURL;
  20883. for (var i = 0, n = mappings.length; i < n; i++) {
  20884. var mapping = mappings[i];
  20885. var source = mapping.source === null ? null : sources.at(mapping.source);
  20886. if(source !== null) {
  20887. source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
  20888. }
  20889. boundCallback({
  20890. source: source,
  20891. generatedLine: mapping.generatedLine,
  20892. generatedColumn: mapping.generatedColumn,
  20893. originalLine: mapping.originalLine,
  20894. originalColumn: mapping.originalColumn,
  20895. name: mapping.name === null ? null : names.at(mapping.name)
  20896. });
  20897. }
  20898. };
  20899. /**
  20900. * Returns all generated line and column information for the original source,
  20901. * line, and column provided. If no column is provided, returns all mappings
  20902. * corresponding to a either the line we are searching for or the next
  20903. * closest line that has any mappings. Otherwise, returns all mappings
  20904. * corresponding to the given line and either the column we are searching for
  20905. * or the next closest column that has any offsets.
  20906. *
  20907. * The only argument is an object with the following properties:
  20908. *
  20909. * - source: The filename of the original source.
  20910. * - line: The line number in the original source. The line number is 1-based.
  20911. * - column: Optional. the column number in the original source.
  20912. * The column number is 0-based.
  20913. *
  20914. * and an array of objects is returned, each with the following properties:
  20915. *
  20916. * - line: The line number in the generated source, or null. The
  20917. * line number is 1-based.
  20918. * - column: The column number in the generated source, or null.
  20919. * The column number is 0-based.
  20920. */
  20921. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  20922. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  20923. var line = util.getArg(aArgs, 'line');
  20924. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  20925. // returns the index of the closest mapping less than the needle. By
  20926. // setting needle.originalColumn to 0, we thus find the last mapping for
  20927. // the given line, provided such a mapping exists.
  20928. var needle = {
  20929. source: util.getArg(aArgs, 'source'),
  20930. originalLine: line,
  20931. originalColumn: util.getArg(aArgs, 'column', 0)
  20932. };
  20933. needle.source = this._findSourceIndex(needle.source);
  20934. if (needle.source < 0) {
  20935. return [];
  20936. }
  20937. var mappings = [];
  20938. var index = this._findMapping(needle,
  20939. this._originalMappings,
  20940. "originalLine",
  20941. "originalColumn",
  20942. util.compareByOriginalPositions,
  20943. binarySearch.LEAST_UPPER_BOUND);
  20944. if (index >= 0) {
  20945. var mapping = this._originalMappings[index];
  20946. if (aArgs.column === undefined) {
  20947. var originalLine = mapping.originalLine;
  20948. // Iterate until either we run out of mappings, or we run into
  20949. // a mapping for a different line than the one we found. Since
  20950. // mappings are sorted, this is guaranteed to find all mappings for
  20951. // the line we found.
  20952. while (mapping && mapping.originalLine === originalLine) {
  20953. mappings.push({
  20954. line: util.getArg(mapping, 'generatedLine', null),
  20955. column: util.getArg(mapping, 'generatedColumn', null),
  20956. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20957. });
  20958. mapping = this._originalMappings[++index];
  20959. }
  20960. } else {
  20961. var originalColumn = mapping.originalColumn;
  20962. // Iterate until either we run out of mappings, or we run into
  20963. // a mapping for a different line than the one we were searching for.
  20964. // Since mappings are sorted, this is guaranteed to find all mappings for
  20965. // the line we are searching for.
  20966. while (mapping &&
  20967. mapping.originalLine === line &&
  20968. mapping.originalColumn == originalColumn) {
  20969. mappings.push({
  20970. line: util.getArg(mapping, 'generatedLine', null),
  20971. column: util.getArg(mapping, 'generatedColumn', null),
  20972. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20973. });
  20974. mapping = this._originalMappings[++index];
  20975. }
  20976. }
  20977. }
  20978. return mappings;
  20979. };
  20980. sourceMapConsumer$1.SourceMapConsumer = SourceMapConsumer;
  20981. /**
  20982. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  20983. * query for information about the original file positions by giving it a file
  20984. * position in the generated source.
  20985. *
  20986. * The first parameter is the raw source map (either as a JSON string, or
  20987. * already parsed to an object). According to the spec, source maps have the
  20988. * following attributes:
  20989. *
  20990. * - version: Which version of the source map spec this map is following.
  20991. * - sources: An array of URLs to the original source files.
  20992. * - names: An array of identifiers which can be referrenced by individual mappings.
  20993. * - sourceRoot: Optional. The URL root from which all sources are relative.
  20994. * - sourcesContent: Optional. An array of contents of the original source files.
  20995. * - mappings: A string of base64 VLQs which contain the actual mappings.
  20996. * - file: Optional. The generated file this source map is associated with.
  20997. *
  20998. * Here is an example source map, taken from the source map spec[0]:
  20999. *
  21000. * {
  21001. * version : 3,
  21002. * file: "out.js",
  21003. * sourceRoot : "",
  21004. * sources: ["foo.js", "bar.js"],
  21005. * names: ["src", "maps", "are", "fun"],
  21006. * mappings: "AA,AB;;ABCDE;"
  21007. * }
  21008. *
  21009. * The second parameter, if given, is a string whose value is the URL
  21010. * at which the source map was found. This URL is used to compute the
  21011. * sources array.
  21012. *
  21013. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  21014. */
  21015. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  21016. var sourceMap = aSourceMap;
  21017. if (typeof aSourceMap === 'string') {
  21018. sourceMap = util.parseSourceMapInput(aSourceMap);
  21019. }
  21020. var version = util.getArg(sourceMap, 'version');
  21021. var sources = util.getArg(sourceMap, 'sources');
  21022. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  21023. // requires the array) to play nice here.
  21024. var names = util.getArg(sourceMap, 'names', []);
  21025. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  21026. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  21027. var mappings = util.getArg(sourceMap, 'mappings');
  21028. var file = util.getArg(sourceMap, 'file', null);
  21029. // Once again, Sass deviates from the spec and supplies the version as a
  21030. // string rather than a number, so we use loose equality checking here.
  21031. if (version != this._version) {
  21032. throw new Error('Unsupported version: ' + version);
  21033. }
  21034. if (sourceRoot) {
  21035. sourceRoot = util.normalize(sourceRoot);
  21036. }
  21037. sources = sources
  21038. .map(String)
  21039. // Some source maps produce relative source paths like "./foo.js" instead of
  21040. // "foo.js". Normalize these first so that future comparisons will succeed.
  21041. // See bugzil.la/1090768.
  21042. .map(util.normalize)
  21043. // Always ensure that absolute sources are internally stored relative to
  21044. // the source root, if the source root is absolute. Not doing this would
  21045. // be particularly problematic when the source root is a prefix of the
  21046. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  21047. .map(function (source) {
  21048. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  21049. ? util.relative(sourceRoot, source)
  21050. : source;
  21051. });
  21052. // Pass `true` below to allow duplicate names and sources. While source maps
  21053. // are intended to be compressed and deduplicated, the TypeScript compiler
  21054. // sometimes generates source maps with duplicates in them. See Github issue
  21055. // #72 and bugzil.la/889492.
  21056. this._names = ArraySet.fromArray(names.map(String), true);
  21057. this._sources = ArraySet.fromArray(sources, true);
  21058. this._absoluteSources = this._sources.toArray().map(function (s) {
  21059. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  21060. });
  21061. this.sourceRoot = sourceRoot;
  21062. this.sourcesContent = sourcesContent;
  21063. this._mappings = mappings;
  21064. this._sourceMapURL = aSourceMapURL;
  21065. this.file = file;
  21066. }
  21067. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  21068. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  21069. /**
  21070. * Utility function to find the index of a source. Returns -1 if not
  21071. * found.
  21072. */
  21073. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  21074. var relativeSource = aSource;
  21075. if (this.sourceRoot != null) {
  21076. relativeSource = util.relative(this.sourceRoot, relativeSource);
  21077. }
  21078. if (this._sources.has(relativeSource)) {
  21079. return this._sources.indexOf(relativeSource);
  21080. }
  21081. // Maybe aSource is an absolute URL as returned by |sources|. In
  21082. // this case we can't simply undo the transform.
  21083. var i;
  21084. for (i = 0; i < this._absoluteSources.length; ++i) {
  21085. if (this._absoluteSources[i] == aSource) {
  21086. return i;
  21087. }
  21088. }
  21089. return -1;
  21090. };
  21091. /**
  21092. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  21093. *
  21094. * @param SourceMapGenerator aSourceMap
  21095. * The source map that will be consumed.
  21096. * @param String aSourceMapURL
  21097. * The URL at which the source map can be found (optional)
  21098. * @returns BasicSourceMapConsumer
  21099. */
  21100. BasicSourceMapConsumer.fromSourceMap =
  21101. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  21102. var smc = Object.create(BasicSourceMapConsumer.prototype);
  21103. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  21104. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  21105. smc.sourceRoot = aSourceMap._sourceRoot;
  21106. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  21107. smc.sourceRoot);
  21108. smc.file = aSourceMap._file;
  21109. smc._sourceMapURL = aSourceMapURL;
  21110. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  21111. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  21112. });
  21113. // Because we are modifying the entries (by converting string sources and
  21114. // names to indices into the sources and names ArraySets), we have to make
  21115. // a copy of the entry or else bad things happen. Shared mutable state
  21116. // strikes again! See github issue #191.
  21117. var generatedMappings = aSourceMap._mappings.toArray().slice();
  21118. var destGeneratedMappings = smc.__generatedMappings = [];
  21119. var destOriginalMappings = smc.__originalMappings = [];
  21120. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  21121. var srcMapping = generatedMappings[i];
  21122. var destMapping = new Mapping;
  21123. destMapping.generatedLine = srcMapping.generatedLine;
  21124. destMapping.generatedColumn = srcMapping.generatedColumn;
  21125. if (srcMapping.source) {
  21126. destMapping.source = sources.indexOf(srcMapping.source);
  21127. destMapping.originalLine = srcMapping.originalLine;
  21128. destMapping.originalColumn = srcMapping.originalColumn;
  21129. if (srcMapping.name) {
  21130. destMapping.name = names.indexOf(srcMapping.name);
  21131. }
  21132. destOriginalMappings.push(destMapping);
  21133. }
  21134. destGeneratedMappings.push(destMapping);
  21135. }
  21136. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  21137. return smc;
  21138. };
  21139. /**
  21140. * The version of the source mapping spec that we are consuming.
  21141. */
  21142. BasicSourceMapConsumer.prototype._version = 3;
  21143. /**
  21144. * The list of original sources.
  21145. */
  21146. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  21147. get: function () {
  21148. return this._absoluteSources.slice();
  21149. }
  21150. });
  21151. /**
  21152. * Provide the JIT with a nice shape / hidden class.
  21153. */
  21154. function Mapping() {
  21155. this.generatedLine = 0;
  21156. this.generatedColumn = 0;
  21157. this.source = null;
  21158. this.originalLine = null;
  21159. this.originalColumn = null;
  21160. this.name = null;
  21161. }
  21162. /**
  21163. * Parse the mappings in a string in to a data structure which we can easily
  21164. * query (the ordered arrays in the `this.__generatedMappings` and
  21165. * `this.__originalMappings` properties).
  21166. */
  21167. const compareGenerated = util.compareByGeneratedPositionsDeflatedNoLine;
  21168. function sortGenerated(array, start) {
  21169. let l = array.length;
  21170. let n = array.length - start;
  21171. if (n <= 1) {
  21172. return;
  21173. } else if (n == 2) {
  21174. let a = array[start];
  21175. let b = array[start + 1];
  21176. if (compareGenerated(a, b) > 0) {
  21177. array[start] = b;
  21178. array[start + 1] = a;
  21179. }
  21180. } else if (n < 20) {
  21181. for (let i = start; i < l; i++) {
  21182. for (let j = i; j > start; j--) {
  21183. let a = array[j - 1];
  21184. let b = array[j];
  21185. if (compareGenerated(a, b) <= 0) {
  21186. break;
  21187. }
  21188. array[j - 1] = b;
  21189. array[j] = a;
  21190. }
  21191. }
  21192. } else {
  21193. quickSort(array, compareGenerated, start);
  21194. }
  21195. }
  21196. BasicSourceMapConsumer.prototype._parseMappings =
  21197. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  21198. var generatedLine = 1;
  21199. var previousGeneratedColumn = 0;
  21200. var previousOriginalLine = 0;
  21201. var previousOriginalColumn = 0;
  21202. var previousSource = 0;
  21203. var previousName = 0;
  21204. var length = aStr.length;
  21205. var index = 0;
  21206. var temp = {};
  21207. var originalMappings = [];
  21208. var generatedMappings = [];
  21209. var mapping, segment, end, value;
  21210. let subarrayStart = 0;
  21211. while (index < length) {
  21212. if (aStr.charAt(index) === ';') {
  21213. generatedLine++;
  21214. index++;
  21215. previousGeneratedColumn = 0;
  21216. sortGenerated(generatedMappings, subarrayStart);
  21217. subarrayStart = generatedMappings.length;
  21218. }
  21219. else if (aStr.charAt(index) === ',') {
  21220. index++;
  21221. }
  21222. else {
  21223. mapping = new Mapping();
  21224. mapping.generatedLine = generatedLine;
  21225. for (end = index; end < length; end++) {
  21226. if (this._charIsMappingSeparator(aStr, end)) {
  21227. break;
  21228. }
  21229. }
  21230. aStr.slice(index, end);
  21231. segment = [];
  21232. while (index < end) {
  21233. base64VLQ.decode(aStr, index, temp);
  21234. value = temp.value;
  21235. index = temp.rest;
  21236. segment.push(value);
  21237. }
  21238. if (segment.length === 2) {
  21239. throw new Error('Found a source, but no line and column');
  21240. }
  21241. if (segment.length === 3) {
  21242. throw new Error('Found a source and line, but no column');
  21243. }
  21244. // Generated column.
  21245. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  21246. previousGeneratedColumn = mapping.generatedColumn;
  21247. if (segment.length > 1) {
  21248. // Original source.
  21249. mapping.source = previousSource + segment[1];
  21250. previousSource += segment[1];
  21251. // Original line.
  21252. mapping.originalLine = previousOriginalLine + segment[2];
  21253. previousOriginalLine = mapping.originalLine;
  21254. // Lines are stored 0-based
  21255. mapping.originalLine += 1;
  21256. // Original column.
  21257. mapping.originalColumn = previousOriginalColumn + segment[3];
  21258. previousOriginalColumn = mapping.originalColumn;
  21259. if (segment.length > 4) {
  21260. // Original name.
  21261. mapping.name = previousName + segment[4];
  21262. previousName += segment[4];
  21263. }
  21264. }
  21265. generatedMappings.push(mapping);
  21266. if (typeof mapping.originalLine === 'number') {
  21267. let currentSource = mapping.source;
  21268. while (originalMappings.length <= currentSource) {
  21269. originalMappings.push(null);
  21270. }
  21271. if (originalMappings[currentSource] === null) {
  21272. originalMappings[currentSource] = [];
  21273. }
  21274. originalMappings[currentSource].push(mapping);
  21275. }
  21276. }
  21277. }
  21278. sortGenerated(generatedMappings, subarrayStart);
  21279. this.__generatedMappings = generatedMappings;
  21280. for (var i = 0; i < originalMappings.length; i++) {
  21281. if (originalMappings[i] != null) {
  21282. quickSort(originalMappings[i], util.compareByOriginalPositionsNoSource);
  21283. }
  21284. }
  21285. this.__originalMappings = [].concat(...originalMappings);
  21286. };
  21287. /**
  21288. * Find the mapping that best matches the hypothetical "needle" mapping that
  21289. * we are searching for in the given "haystack" of mappings.
  21290. */
  21291. BasicSourceMapConsumer.prototype._findMapping =
  21292. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  21293. aColumnName, aComparator, aBias) {
  21294. // To return the position we are searching for, we must first find the
  21295. // mapping for the given position and then return the opposite position it
  21296. // points to. Because the mappings are sorted, we can use binary search to
  21297. // find the best mapping.
  21298. if (aNeedle[aLineName] <= 0) {
  21299. throw new TypeError('Line must be greater than or equal to 1, got '
  21300. + aNeedle[aLineName]);
  21301. }
  21302. if (aNeedle[aColumnName] < 0) {
  21303. throw new TypeError('Column must be greater than or equal to 0, got '
  21304. + aNeedle[aColumnName]);
  21305. }
  21306. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  21307. };
  21308. /**
  21309. * Compute the last column for each generated mapping. The last column is
  21310. * inclusive.
  21311. */
  21312. BasicSourceMapConsumer.prototype.computeColumnSpans =
  21313. function SourceMapConsumer_computeColumnSpans() {
  21314. for (var index = 0; index < this._generatedMappings.length; ++index) {
  21315. var mapping = this._generatedMappings[index];
  21316. // Mappings do not contain a field for the last generated columnt. We
  21317. // can come up with an optimistic estimate, however, by assuming that
  21318. // mappings are contiguous (i.e. given two consecutive mappings, the
  21319. // first mapping ends where the second one starts).
  21320. if (index + 1 < this._generatedMappings.length) {
  21321. var nextMapping = this._generatedMappings[index + 1];
  21322. if (mapping.generatedLine === nextMapping.generatedLine) {
  21323. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  21324. continue;
  21325. }
  21326. }
  21327. // The last mapping for each line spans the entire line.
  21328. mapping.lastGeneratedColumn = Infinity;
  21329. }
  21330. };
  21331. /**
  21332. * Returns the original source, line, and column information for the generated
  21333. * source's line and column positions provided. The only argument is an object
  21334. * with the following properties:
  21335. *
  21336. * - line: The line number in the generated source. The line number
  21337. * is 1-based.
  21338. * - column: The column number in the generated source. The column
  21339. * number is 0-based.
  21340. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  21341. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  21342. * closest element that is smaller than or greater than the one we are
  21343. * searching for, respectively, if the exact element cannot be found.
  21344. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  21345. *
  21346. * and an object is returned with the following properties:
  21347. *
  21348. * - source: The original source file, or null.
  21349. * - line: The line number in the original source, or null. The
  21350. * line number is 1-based.
  21351. * - column: The column number in the original source, or null. The
  21352. * column number is 0-based.
  21353. * - name: The original identifier, or null.
  21354. */
  21355. BasicSourceMapConsumer.prototype.originalPositionFor =
  21356. function SourceMapConsumer_originalPositionFor(aArgs) {
  21357. var needle = {
  21358. generatedLine: util.getArg(aArgs, 'line'),
  21359. generatedColumn: util.getArg(aArgs, 'column')
  21360. };
  21361. var index = this._findMapping(
  21362. needle,
  21363. this._generatedMappings,
  21364. "generatedLine",
  21365. "generatedColumn",
  21366. util.compareByGeneratedPositionsDeflated,
  21367. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  21368. );
  21369. if (index >= 0) {
  21370. var mapping = this._generatedMappings[index];
  21371. if (mapping.generatedLine === needle.generatedLine) {
  21372. var source = util.getArg(mapping, 'source', null);
  21373. if (source !== null) {
  21374. source = this._sources.at(source);
  21375. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  21376. }
  21377. var name = util.getArg(mapping, 'name', null);
  21378. if (name !== null) {
  21379. name = this._names.at(name);
  21380. }
  21381. return {
  21382. source: source,
  21383. line: util.getArg(mapping, 'originalLine', null),
  21384. column: util.getArg(mapping, 'originalColumn', null),
  21385. name: name
  21386. };
  21387. }
  21388. }
  21389. return {
  21390. source: null,
  21391. line: null,
  21392. column: null,
  21393. name: null
  21394. };
  21395. };
  21396. /**
  21397. * Return true if we have the source content for every source in the source
  21398. * map, false otherwise.
  21399. */
  21400. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  21401. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  21402. if (!this.sourcesContent) {
  21403. return false;
  21404. }
  21405. return this.sourcesContent.length >= this._sources.size() &&
  21406. !this.sourcesContent.some(function (sc) { return sc == null; });
  21407. };
  21408. /**
  21409. * Returns the original source content. The only argument is the url of the
  21410. * original source file. Returns null if no original source content is
  21411. * available.
  21412. */
  21413. BasicSourceMapConsumer.prototype.sourceContentFor =
  21414. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  21415. if (!this.sourcesContent) {
  21416. return null;
  21417. }
  21418. var index = this._findSourceIndex(aSource);
  21419. if (index >= 0) {
  21420. return this.sourcesContent[index];
  21421. }
  21422. var relativeSource = aSource;
  21423. if (this.sourceRoot != null) {
  21424. relativeSource = util.relative(this.sourceRoot, relativeSource);
  21425. }
  21426. var url;
  21427. if (this.sourceRoot != null
  21428. && (url = util.urlParse(this.sourceRoot))) {
  21429. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  21430. // many users. We can help them out when they expect file:// URIs to
  21431. // behave like it would if they were running a local HTTP server. See
  21432. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  21433. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  21434. if (url.scheme == "file"
  21435. && this._sources.has(fileUriAbsPath)) {
  21436. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  21437. }
  21438. if ((!url.path || url.path == "/")
  21439. && this._sources.has("/" + relativeSource)) {
  21440. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  21441. }
  21442. }
  21443. // This function is used recursively from
  21444. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  21445. // don't want to throw if we can't find the source - we just want to
  21446. // return null, so we provide a flag to exit gracefully.
  21447. if (nullOnMissing) {
  21448. return null;
  21449. }
  21450. else {
  21451. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  21452. }
  21453. };
  21454. /**
  21455. * Returns the generated line and column information for the original source,
  21456. * line, and column positions provided. The only argument is an object with
  21457. * the following properties:
  21458. *
  21459. * - source: The filename of the original source.
  21460. * - line: The line number in the original source. The line number
  21461. * is 1-based.
  21462. * - column: The column number in the original source. The column
  21463. * number is 0-based.
  21464. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  21465. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  21466. * closest element that is smaller than or greater than the one we are
  21467. * searching for, respectively, if the exact element cannot be found.
  21468. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  21469. *
  21470. * and an object is returned with the following properties:
  21471. *
  21472. * - line: The line number in the generated source, or null. The
  21473. * line number is 1-based.
  21474. * - column: The column number in the generated source, or null.
  21475. * The column number is 0-based.
  21476. */
  21477. BasicSourceMapConsumer.prototype.generatedPositionFor =
  21478. function SourceMapConsumer_generatedPositionFor(aArgs) {
  21479. var source = util.getArg(aArgs, 'source');
  21480. source = this._findSourceIndex(source);
  21481. if (source < 0) {
  21482. return {
  21483. line: null,
  21484. column: null,
  21485. lastColumn: null
  21486. };
  21487. }
  21488. var needle = {
  21489. source: source,
  21490. originalLine: util.getArg(aArgs, 'line'),
  21491. originalColumn: util.getArg(aArgs, 'column')
  21492. };
  21493. var index = this._findMapping(
  21494. needle,
  21495. this._originalMappings,
  21496. "originalLine",
  21497. "originalColumn",
  21498. util.compareByOriginalPositions,
  21499. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  21500. );
  21501. if (index >= 0) {
  21502. var mapping = this._originalMappings[index];
  21503. if (mapping.source === needle.source) {
  21504. return {
  21505. line: util.getArg(mapping, 'generatedLine', null),
  21506. column: util.getArg(mapping, 'generatedColumn', null),
  21507. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  21508. };
  21509. }
  21510. }
  21511. return {
  21512. line: null,
  21513. column: null,
  21514. lastColumn: null
  21515. };
  21516. };
  21517. sourceMapConsumer$1.BasicSourceMapConsumer = BasicSourceMapConsumer;
  21518. /**
  21519. * An IndexedSourceMapConsumer instance represents a parsed source map which
  21520. * we can query for information. It differs from BasicSourceMapConsumer in
  21521. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  21522. * input.
  21523. *
  21524. * The first parameter is a raw source map (either as a JSON string, or already
  21525. * parsed to an object). According to the spec for indexed source maps, they
  21526. * have the following attributes:
  21527. *
  21528. * - version: Which version of the source map spec this map is following.
  21529. * - file: Optional. The generated file this source map is associated with.
  21530. * - sections: A list of section definitions.
  21531. *
  21532. * Each value under the "sections" field has two fields:
  21533. * - offset: The offset into the original specified at which this section
  21534. * begins to apply, defined as an object with a "line" and "column"
  21535. * field.
  21536. * - map: A source map definition. This source map could also be indexed,
  21537. * but doesn't have to be.
  21538. *
  21539. * Instead of the "map" field, it's also possible to have a "url" field
  21540. * specifying a URL to retrieve a source map from, but that's currently
  21541. * unsupported.
  21542. *
  21543. * Here's an example source map, taken from the source map spec[0], but
  21544. * modified to omit a section which uses the "url" field.
  21545. *
  21546. * {
  21547. * version : 3,
  21548. * file: "app.js",
  21549. * sections: [{
  21550. * offset: {line:100, column:10},
  21551. * map: {
  21552. * version : 3,
  21553. * file: "section.js",
  21554. * sources: ["foo.js", "bar.js"],
  21555. * names: ["src", "maps", "are", "fun"],
  21556. * mappings: "AAAA,E;;ABCDE;"
  21557. * }
  21558. * }],
  21559. * }
  21560. *
  21561. * The second parameter, if given, is a string whose value is the URL
  21562. * at which the source map was found. This URL is used to compute the
  21563. * sources array.
  21564. *
  21565. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  21566. */
  21567. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  21568. var sourceMap = aSourceMap;
  21569. if (typeof aSourceMap === 'string') {
  21570. sourceMap = util.parseSourceMapInput(aSourceMap);
  21571. }
  21572. var version = util.getArg(sourceMap, 'version');
  21573. var sections = util.getArg(sourceMap, 'sections');
  21574. if (version != this._version) {
  21575. throw new Error('Unsupported version: ' + version);
  21576. }
  21577. this._sources = new ArraySet();
  21578. this._names = new ArraySet();
  21579. var lastOffset = {
  21580. line: -1,
  21581. column: 0
  21582. };
  21583. this._sections = sections.map(function (s) {
  21584. if (s.url) {
  21585. // The url field will require support for asynchronicity.
  21586. // See https://github.com/mozilla/source-map/issues/16
  21587. throw new Error('Support for url field in sections not implemented.');
  21588. }
  21589. var offset = util.getArg(s, 'offset');
  21590. var offsetLine = util.getArg(offset, 'line');
  21591. var offsetColumn = util.getArg(offset, 'column');
  21592. if (offsetLine < lastOffset.line ||
  21593. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  21594. throw new Error('Section offsets must be ordered and non-overlapping.');
  21595. }
  21596. lastOffset = offset;
  21597. return {
  21598. generatedOffset: {
  21599. // The offset fields are 0-based, but we use 1-based indices when
  21600. // encoding/decoding from VLQ.
  21601. generatedLine: offsetLine + 1,
  21602. generatedColumn: offsetColumn + 1
  21603. },
  21604. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  21605. }
  21606. });
  21607. }
  21608. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  21609. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  21610. /**
  21611. * The version of the source mapping spec that we are consuming.
  21612. */
  21613. IndexedSourceMapConsumer.prototype._version = 3;
  21614. /**
  21615. * The list of original sources.
  21616. */
  21617. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  21618. get: function () {
  21619. var sources = [];
  21620. for (var i = 0; i < this._sections.length; i++) {
  21621. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  21622. sources.push(this._sections[i].consumer.sources[j]);
  21623. }
  21624. }
  21625. return sources;
  21626. }
  21627. });
  21628. /**
  21629. * Returns the original source, line, and column information for the generated
  21630. * source's line and column positions provided. The only argument is an object
  21631. * with the following properties:
  21632. *
  21633. * - line: The line number in the generated source. The line number
  21634. * is 1-based.
  21635. * - column: The column number in the generated source. The column
  21636. * number is 0-based.
  21637. *
  21638. * and an object is returned with the following properties:
  21639. *
  21640. * - source: The original source file, or null.
  21641. * - line: The line number in the original source, or null. The
  21642. * line number is 1-based.
  21643. * - column: The column number in the original source, or null. The
  21644. * column number is 0-based.
  21645. * - name: The original identifier, or null.
  21646. */
  21647. IndexedSourceMapConsumer.prototype.originalPositionFor =
  21648. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  21649. var needle = {
  21650. generatedLine: util.getArg(aArgs, 'line'),
  21651. generatedColumn: util.getArg(aArgs, 'column')
  21652. };
  21653. // Find the section containing the generated position we're trying to map
  21654. // to an original position.
  21655. var sectionIndex = binarySearch.search(needle, this._sections,
  21656. function(needle, section) {
  21657. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  21658. if (cmp) {
  21659. return cmp;
  21660. }
  21661. return (needle.generatedColumn -
  21662. section.generatedOffset.generatedColumn);
  21663. });
  21664. var section = this._sections[sectionIndex];
  21665. if (!section) {
  21666. return {
  21667. source: null,
  21668. line: null,
  21669. column: null,
  21670. name: null
  21671. };
  21672. }
  21673. return section.consumer.originalPositionFor({
  21674. line: needle.generatedLine -
  21675. (section.generatedOffset.generatedLine - 1),
  21676. column: needle.generatedColumn -
  21677. (section.generatedOffset.generatedLine === needle.generatedLine
  21678. ? section.generatedOffset.generatedColumn - 1
  21679. : 0),
  21680. bias: aArgs.bias
  21681. });
  21682. };
  21683. /**
  21684. * Return true if we have the source content for every source in the source
  21685. * map, false otherwise.
  21686. */
  21687. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  21688. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  21689. return this._sections.every(function (s) {
  21690. return s.consumer.hasContentsOfAllSources();
  21691. });
  21692. };
  21693. /**
  21694. * Returns the original source content. The only argument is the url of the
  21695. * original source file. Returns null if no original source content is
  21696. * available.
  21697. */
  21698. IndexedSourceMapConsumer.prototype.sourceContentFor =
  21699. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  21700. for (var i = 0; i < this._sections.length; i++) {
  21701. var section = this._sections[i];
  21702. var content = section.consumer.sourceContentFor(aSource, true);
  21703. if (content || content === '') {
  21704. return content;
  21705. }
  21706. }
  21707. if (nullOnMissing) {
  21708. return null;
  21709. }
  21710. else {
  21711. throw new Error('"' + aSource + '" is not in the SourceMap.');
  21712. }
  21713. };
  21714. /**
  21715. * Returns the generated line and column information for the original source,
  21716. * line, and column positions provided. The only argument is an object with
  21717. * the following properties:
  21718. *
  21719. * - source: The filename of the original source.
  21720. * - line: The line number in the original source. The line number
  21721. * is 1-based.
  21722. * - column: The column number in the original source. The column
  21723. * number is 0-based.
  21724. *
  21725. * and an object is returned with the following properties:
  21726. *
  21727. * - line: The line number in the generated source, or null. The
  21728. * line number is 1-based.
  21729. * - column: The column number in the generated source, or null.
  21730. * The column number is 0-based.
  21731. */
  21732. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  21733. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  21734. for (var i = 0; i < this._sections.length; i++) {
  21735. var section = this._sections[i];
  21736. // Only consider this section if the requested source is in the list of
  21737. // sources of the consumer.
  21738. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  21739. continue;
  21740. }
  21741. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  21742. if (generatedPosition) {
  21743. var ret = {
  21744. line: generatedPosition.line +
  21745. (section.generatedOffset.generatedLine - 1),
  21746. column: generatedPosition.column +
  21747. (section.generatedOffset.generatedLine === generatedPosition.line
  21748. ? section.generatedOffset.generatedColumn - 1
  21749. : 0)
  21750. };
  21751. return ret;
  21752. }
  21753. }
  21754. return {
  21755. line: null,
  21756. column: null
  21757. };
  21758. };
  21759. /**
  21760. * Parse the mappings in a string in to a data structure which we can easily
  21761. * query (the ordered arrays in the `this.__generatedMappings` and
  21762. * `this.__originalMappings` properties).
  21763. */
  21764. IndexedSourceMapConsumer.prototype._parseMappings =
  21765. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  21766. this.__generatedMappings = [];
  21767. this.__originalMappings = [];
  21768. for (var i = 0; i < this._sections.length; i++) {
  21769. var section = this._sections[i];
  21770. var sectionMappings = section.consumer._generatedMappings;
  21771. for (var j = 0; j < sectionMappings.length; j++) {
  21772. var mapping = sectionMappings[j];
  21773. var source = section.consumer._sources.at(mapping.source);
  21774. if(source !== null) {
  21775. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  21776. }
  21777. this._sources.add(source);
  21778. source = this._sources.indexOf(source);
  21779. var name = null;
  21780. if (mapping.name) {
  21781. name = section.consumer._names.at(mapping.name);
  21782. this._names.add(name);
  21783. name = this._names.indexOf(name);
  21784. }
  21785. // The mappings coming from the consumer for the section have
  21786. // generated positions relative to the start of the section, so we
  21787. // need to offset them to be relative to the start of the concatenated
  21788. // generated file.
  21789. var adjustedMapping = {
  21790. source: source,
  21791. generatedLine: mapping.generatedLine +
  21792. (section.generatedOffset.generatedLine - 1),
  21793. generatedColumn: mapping.generatedColumn +
  21794. (section.generatedOffset.generatedLine === mapping.generatedLine
  21795. ? section.generatedOffset.generatedColumn - 1
  21796. : 0),
  21797. originalLine: mapping.originalLine,
  21798. originalColumn: mapping.originalColumn,
  21799. name: name
  21800. };
  21801. this.__generatedMappings.push(adjustedMapping);
  21802. if (typeof adjustedMapping.originalLine === 'number') {
  21803. this.__originalMappings.push(adjustedMapping);
  21804. }
  21805. }
  21806. }
  21807. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  21808. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  21809. };
  21810. sourceMapConsumer$1.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  21811. return sourceMapConsumer$1;
  21812. }
  21813. var sourceNode$1 = {};
  21814. /* -*- Mode: js; js-indent-level: 2; -*- */
  21815. var hasRequiredSourceNode$1;
  21816. function requireSourceNode$1 () {
  21817. if (hasRequiredSourceNode$1) return sourceNode$1;
  21818. hasRequiredSourceNode$1 = 1;
  21819. /*
  21820. * Copyright 2011 Mozilla Foundation and contributors
  21821. * Licensed under the New BSD license. See LICENSE or:
  21822. * http://opensource.org/licenses/BSD-3-Clause
  21823. */
  21824. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$1().SourceMapGenerator;
  21825. var util = /*@__PURE__*/ requireUtil$2();
  21826. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  21827. // operating systems these days (capturing the result).
  21828. var REGEX_NEWLINE = /(\r?\n)/;
  21829. // Newline character code for charCodeAt() comparisons
  21830. var NEWLINE_CODE = 10;
  21831. // Private symbol for identifying `SourceNode`s when multiple versions of
  21832. // the source-map library are loaded. This MUST NOT CHANGE across
  21833. // versions!
  21834. var isSourceNode = "$$$isSourceNode$$$";
  21835. /**
  21836. * SourceNodes provide a way to abstract over interpolating/concatenating
  21837. * snippets of generated JavaScript source code while maintaining the line and
  21838. * column information associated with the original source code.
  21839. *
  21840. * @param aLine The original line number.
  21841. * @param aColumn The original column number.
  21842. * @param aSource The original source's filename.
  21843. * @param aChunks Optional. An array of strings which are snippets of
  21844. * generated JS, or other SourceNodes.
  21845. * @param aName The original identifier.
  21846. */
  21847. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  21848. this.children = [];
  21849. this.sourceContents = {};
  21850. this.line = aLine == null ? null : aLine;
  21851. this.column = aColumn == null ? null : aColumn;
  21852. this.source = aSource == null ? null : aSource;
  21853. this.name = aName == null ? null : aName;
  21854. this[isSourceNode] = true;
  21855. if (aChunks != null) this.add(aChunks);
  21856. }
  21857. /**
  21858. * Creates a SourceNode from generated code and a SourceMapConsumer.
  21859. *
  21860. * @param aGeneratedCode The generated code
  21861. * @param aSourceMapConsumer The SourceMap for the generated code
  21862. * @param aRelativePath Optional. The path that relative sources in the
  21863. * SourceMapConsumer should be relative to.
  21864. */
  21865. SourceNode.fromStringWithSourceMap =
  21866. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  21867. // The SourceNode we want to fill with the generated code
  21868. // and the SourceMap
  21869. var node = new SourceNode();
  21870. // All even indices of this array are one line of the generated code,
  21871. // while all odd indices are the newlines between two adjacent lines
  21872. // (since `REGEX_NEWLINE` captures its match).
  21873. // Processed fragments are accessed by calling `shiftNextLine`.
  21874. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  21875. var remainingLinesIndex = 0;
  21876. var shiftNextLine = function() {
  21877. var lineContents = getNextLine();
  21878. // The last line of a file might not have a newline.
  21879. var newLine = getNextLine() || "";
  21880. return lineContents + newLine;
  21881. function getNextLine() {
  21882. return remainingLinesIndex < remainingLines.length ?
  21883. remainingLines[remainingLinesIndex++] : undefined;
  21884. }
  21885. };
  21886. // We need to remember the position of "remainingLines"
  21887. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  21888. // The generate SourceNodes we need a code range.
  21889. // To extract it current and last mapping is used.
  21890. // Here we store the last mapping.
  21891. var lastMapping = null;
  21892. aSourceMapConsumer.eachMapping(function (mapping) {
  21893. if (lastMapping !== null) {
  21894. // We add the code from "lastMapping" to "mapping":
  21895. // First check if there is a new line in between.
  21896. if (lastGeneratedLine < mapping.generatedLine) {
  21897. // Associate first line with "lastMapping"
  21898. addMappingWithCode(lastMapping, shiftNextLine());
  21899. lastGeneratedLine++;
  21900. lastGeneratedColumn = 0;
  21901. // The remaining code is added without mapping
  21902. } else {
  21903. // There is no new line in between.
  21904. // Associate the code between "lastGeneratedColumn" and
  21905. // "mapping.generatedColumn" with "lastMapping"
  21906. var nextLine = remainingLines[remainingLinesIndex] || '';
  21907. var code = nextLine.substr(0, mapping.generatedColumn -
  21908. lastGeneratedColumn);
  21909. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  21910. lastGeneratedColumn);
  21911. lastGeneratedColumn = mapping.generatedColumn;
  21912. addMappingWithCode(lastMapping, code);
  21913. // No more remaining code, continue
  21914. lastMapping = mapping;
  21915. return;
  21916. }
  21917. }
  21918. // We add the generated code until the first mapping
  21919. // to the SourceNode without any mapping.
  21920. // Each line is added as separate string.
  21921. while (lastGeneratedLine < mapping.generatedLine) {
  21922. node.add(shiftNextLine());
  21923. lastGeneratedLine++;
  21924. }
  21925. if (lastGeneratedColumn < mapping.generatedColumn) {
  21926. var nextLine = remainingLines[remainingLinesIndex] || '';
  21927. node.add(nextLine.substr(0, mapping.generatedColumn));
  21928. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  21929. lastGeneratedColumn = mapping.generatedColumn;
  21930. }
  21931. lastMapping = mapping;
  21932. }, this);
  21933. // We have processed all mappings.
  21934. if (remainingLinesIndex < remainingLines.length) {
  21935. if (lastMapping) {
  21936. // Associate the remaining code in the current line with "lastMapping"
  21937. addMappingWithCode(lastMapping, shiftNextLine());
  21938. }
  21939. // and add the remaining lines without any mapping
  21940. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  21941. }
  21942. // Copy sourcesContent into SourceNode
  21943. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  21944. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  21945. if (content != null) {
  21946. if (aRelativePath != null) {
  21947. sourceFile = util.join(aRelativePath, sourceFile);
  21948. }
  21949. node.setSourceContent(sourceFile, content);
  21950. }
  21951. });
  21952. return node;
  21953. function addMappingWithCode(mapping, code) {
  21954. if (mapping === null || mapping.source === undefined) {
  21955. node.add(code);
  21956. } else {
  21957. var source = aRelativePath
  21958. ? util.join(aRelativePath, mapping.source)
  21959. : mapping.source;
  21960. node.add(new SourceNode(mapping.originalLine,
  21961. mapping.originalColumn,
  21962. source,
  21963. code,
  21964. mapping.name));
  21965. }
  21966. }
  21967. };
  21968. /**
  21969. * Add a chunk of generated JS to this source node.
  21970. *
  21971. * @param aChunk A string snippet of generated JS code, another instance of
  21972. * SourceNode, or an array where each member is one of those things.
  21973. */
  21974. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  21975. if (Array.isArray(aChunk)) {
  21976. aChunk.forEach(function (chunk) {
  21977. this.add(chunk);
  21978. }, this);
  21979. }
  21980. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  21981. if (aChunk) {
  21982. this.children.push(aChunk);
  21983. }
  21984. }
  21985. else {
  21986. throw new TypeError(
  21987. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21988. );
  21989. }
  21990. return this;
  21991. };
  21992. /**
  21993. * Add a chunk of generated JS to the beginning of this source node.
  21994. *
  21995. * @param aChunk A string snippet of generated JS code, another instance of
  21996. * SourceNode, or an array where each member is one of those things.
  21997. */
  21998. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  21999. if (Array.isArray(aChunk)) {
  22000. for (var i = aChunk.length-1; i >= 0; i--) {
  22001. this.prepend(aChunk[i]);
  22002. }
  22003. }
  22004. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  22005. this.children.unshift(aChunk);
  22006. }
  22007. else {
  22008. throw new TypeError(
  22009. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  22010. );
  22011. }
  22012. return this;
  22013. };
  22014. /**
  22015. * Walk over the tree of JS snippets in this node and its children. The
  22016. * walking function is called once for each snippet of JS and is passed that
  22017. * snippet and the its original associated source's line/column location.
  22018. *
  22019. * @param aFn The traversal function.
  22020. */
  22021. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  22022. var chunk;
  22023. for (var i = 0, len = this.children.length; i < len; i++) {
  22024. chunk = this.children[i];
  22025. if (chunk[isSourceNode]) {
  22026. chunk.walk(aFn);
  22027. }
  22028. else {
  22029. if (chunk !== '') {
  22030. aFn(chunk, { source: this.source,
  22031. line: this.line,
  22032. column: this.column,
  22033. name: this.name });
  22034. }
  22035. }
  22036. }
  22037. };
  22038. /**
  22039. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  22040. * each of `this.children`.
  22041. *
  22042. * @param aSep The separator.
  22043. */
  22044. SourceNode.prototype.join = function SourceNode_join(aSep) {
  22045. var newChildren;
  22046. var i;
  22047. var len = this.children.length;
  22048. if (len > 0) {
  22049. newChildren = [];
  22050. for (i = 0; i < len-1; i++) {
  22051. newChildren.push(this.children[i]);
  22052. newChildren.push(aSep);
  22053. }
  22054. newChildren.push(this.children[i]);
  22055. this.children = newChildren;
  22056. }
  22057. return this;
  22058. };
  22059. /**
  22060. * Call String.prototype.replace on the very right-most source snippet. Useful
  22061. * for trimming whitespace from the end of a source node, etc.
  22062. *
  22063. * @param aPattern The pattern to replace.
  22064. * @param aReplacement The thing to replace the pattern with.
  22065. */
  22066. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  22067. var lastChild = this.children[this.children.length - 1];
  22068. if (lastChild[isSourceNode]) {
  22069. lastChild.replaceRight(aPattern, aReplacement);
  22070. }
  22071. else if (typeof lastChild === 'string') {
  22072. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  22073. }
  22074. else {
  22075. this.children.push(''.replace(aPattern, aReplacement));
  22076. }
  22077. return this;
  22078. };
  22079. /**
  22080. * Set the source content for a source file. This will be added to the SourceMapGenerator
  22081. * in the sourcesContent field.
  22082. *
  22083. * @param aSourceFile The filename of the source file
  22084. * @param aSourceContent The content of the source file
  22085. */
  22086. SourceNode.prototype.setSourceContent =
  22087. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  22088. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  22089. };
  22090. /**
  22091. * Walk over the tree of SourceNodes. The walking function is called for each
  22092. * source file content and is passed the filename and source content.
  22093. *
  22094. * @param aFn The traversal function.
  22095. */
  22096. SourceNode.prototype.walkSourceContents =
  22097. function SourceNode_walkSourceContents(aFn) {
  22098. for (var i = 0, len = this.children.length; i < len; i++) {
  22099. if (this.children[i][isSourceNode]) {
  22100. this.children[i].walkSourceContents(aFn);
  22101. }
  22102. }
  22103. var sources = Object.keys(this.sourceContents);
  22104. for (var i = 0, len = sources.length; i < len; i++) {
  22105. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  22106. }
  22107. };
  22108. /**
  22109. * Return the string representation of this source node. Walks over the tree
  22110. * and concatenates all the various snippets together to one string.
  22111. */
  22112. SourceNode.prototype.toString = function SourceNode_toString() {
  22113. var str = "";
  22114. this.walk(function (chunk) {
  22115. str += chunk;
  22116. });
  22117. return str;
  22118. };
  22119. /**
  22120. * Returns the string representation of this source node along with a source
  22121. * map.
  22122. */
  22123. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  22124. var generated = {
  22125. code: "",
  22126. line: 1,
  22127. column: 0
  22128. };
  22129. var map = new SourceMapGenerator(aArgs);
  22130. var sourceMappingActive = false;
  22131. var lastOriginalSource = null;
  22132. var lastOriginalLine = null;
  22133. var lastOriginalColumn = null;
  22134. var lastOriginalName = null;
  22135. this.walk(function (chunk, original) {
  22136. generated.code += chunk;
  22137. if (original.source !== null
  22138. && original.line !== null
  22139. && original.column !== null) {
  22140. if(lastOriginalSource !== original.source
  22141. || lastOriginalLine !== original.line
  22142. || lastOriginalColumn !== original.column
  22143. || lastOriginalName !== original.name) {
  22144. map.addMapping({
  22145. source: original.source,
  22146. original: {
  22147. line: original.line,
  22148. column: original.column
  22149. },
  22150. generated: {
  22151. line: generated.line,
  22152. column: generated.column
  22153. },
  22154. name: original.name
  22155. });
  22156. }
  22157. lastOriginalSource = original.source;
  22158. lastOriginalLine = original.line;
  22159. lastOriginalColumn = original.column;
  22160. lastOriginalName = original.name;
  22161. sourceMappingActive = true;
  22162. } else if (sourceMappingActive) {
  22163. map.addMapping({
  22164. generated: {
  22165. line: generated.line,
  22166. column: generated.column
  22167. }
  22168. });
  22169. lastOriginalSource = null;
  22170. sourceMappingActive = false;
  22171. }
  22172. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  22173. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  22174. generated.line++;
  22175. generated.column = 0;
  22176. // Mappings end at eol
  22177. if (idx + 1 === length) {
  22178. lastOriginalSource = null;
  22179. sourceMappingActive = false;
  22180. } else if (sourceMappingActive) {
  22181. map.addMapping({
  22182. source: original.source,
  22183. original: {
  22184. line: original.line,
  22185. column: original.column
  22186. },
  22187. generated: {
  22188. line: generated.line,
  22189. column: generated.column
  22190. },
  22191. name: original.name
  22192. });
  22193. }
  22194. } else {
  22195. generated.column++;
  22196. }
  22197. }
  22198. });
  22199. this.walkSourceContents(function (sourceFile, sourceContent) {
  22200. map.setSourceContent(sourceFile, sourceContent);
  22201. });
  22202. return { code: generated.code, map: map };
  22203. };
  22204. sourceNode$1.SourceNode = SourceNode;
  22205. return sourceNode$1;
  22206. }
  22207. /*
  22208. * Copyright 2009-2011 Mozilla Foundation and contributors
  22209. * Licensed under the New BSD license. See LICENSE.txt or:
  22210. * http://opensource.org/licenses/BSD-3-Clause
  22211. */
  22212. var hasRequiredSourceMap$1;
  22213. function requireSourceMap$1 () {
  22214. if (hasRequiredSourceMap$1) return sourceMap$1;
  22215. hasRequiredSourceMap$1 = 1;
  22216. sourceMap$1.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$1().SourceMapGenerator;
  22217. sourceMap$1.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer$1().SourceMapConsumer;
  22218. sourceMap$1.SourceNode = /*@__PURE__*/ requireSourceNode$1().SourceNode;
  22219. return sourceMap$1;
  22220. }
  22221. var sourceMapExports = /*@__PURE__*/ requireSourceMap$1();
  22222. const PURE_ANNOTATION = `/*@__PURE__*/`;
  22223. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  22224. function createCodegenContext(ast, {
  22225. mode = "function",
  22226. prefixIdentifiers = mode === "module",
  22227. sourceMap = false,
  22228. filename = `template.vue.html`,
  22229. scopeId = null,
  22230. optimizeImports = false,
  22231. runtimeGlobalName = `Vue`,
  22232. runtimeModuleName = `vue`,
  22233. ssrRuntimeModuleName = "vue/server-renderer",
  22234. ssr = false,
  22235. isTS = false,
  22236. inSSR = false
  22237. }) {
  22238. const context = {
  22239. mode,
  22240. prefixIdentifiers,
  22241. sourceMap,
  22242. filename,
  22243. scopeId,
  22244. optimizeImports,
  22245. runtimeGlobalName,
  22246. runtimeModuleName,
  22247. ssrRuntimeModuleName,
  22248. ssr,
  22249. isTS,
  22250. inSSR,
  22251. source: ast.source,
  22252. code: ``,
  22253. column: 1,
  22254. line: 1,
  22255. offset: 0,
  22256. indentLevel: 0,
  22257. pure: false,
  22258. map: void 0,
  22259. helper(key) {
  22260. return `_${helperNameMap[key]}`;
  22261. },
  22262. push(code, newlineIndex = -2 /* None */, node) {
  22263. context.code += code;
  22264. if (context.map) {
  22265. if (node) {
  22266. let name;
  22267. if (node.type === 4 && !node.isStatic) {
  22268. const content = node.content.replace(/^_ctx\./, "");
  22269. if (content !== node.content && isSimpleIdentifier(content)) {
  22270. name = content;
  22271. }
  22272. }
  22273. if (node.loc.source) {
  22274. addMapping(node.loc.start, name);
  22275. }
  22276. }
  22277. if (newlineIndex === -3 /* Unknown */) {
  22278. advancePositionWithMutation(context, code);
  22279. } else {
  22280. context.offset += code.length;
  22281. if (newlineIndex === -2 /* None */) {
  22282. context.column += code.length;
  22283. } else {
  22284. if (newlineIndex === -1 /* End */) {
  22285. newlineIndex = code.length - 1;
  22286. }
  22287. context.line++;
  22288. context.column = code.length - newlineIndex;
  22289. }
  22290. }
  22291. if (node && node.loc !== locStub && node.loc.source) {
  22292. addMapping(node.loc.end);
  22293. }
  22294. }
  22295. },
  22296. indent() {
  22297. newline(++context.indentLevel);
  22298. },
  22299. deindent(withoutNewLine = false) {
  22300. if (withoutNewLine) {
  22301. --context.indentLevel;
  22302. } else {
  22303. newline(--context.indentLevel);
  22304. }
  22305. },
  22306. newline() {
  22307. newline(context.indentLevel);
  22308. }
  22309. };
  22310. function newline(n) {
  22311. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  22312. }
  22313. function addMapping(loc, name = null) {
  22314. const { _names, _mappings } = context.map;
  22315. if (name !== null && !_names.has(name)) _names.add(name);
  22316. _mappings.add({
  22317. originalLine: loc.line,
  22318. originalColumn: loc.column - 1,
  22319. // source-map column is 0 based
  22320. generatedLine: context.line,
  22321. generatedColumn: context.column - 1,
  22322. source: filename,
  22323. name
  22324. });
  22325. }
  22326. if (sourceMap) {
  22327. context.map = new sourceMapExports.SourceMapGenerator();
  22328. context.map.setSourceContent(filename, context.source);
  22329. context.map._sources.add(filename);
  22330. }
  22331. return context;
  22332. }
  22333. function generate(ast, options = {}) {
  22334. const context = createCodegenContext(ast, options);
  22335. if (options.onContextCreated) options.onContextCreated(context);
  22336. const {
  22337. mode,
  22338. push,
  22339. prefixIdentifiers,
  22340. indent,
  22341. deindent,
  22342. newline,
  22343. scopeId,
  22344. ssr
  22345. } = context;
  22346. const helpers = Array.from(ast.helpers);
  22347. const hasHelpers = helpers.length > 0;
  22348. const useWithBlock = !prefixIdentifiers && mode !== "module";
  22349. const genScopeId = scopeId != null && mode === "module";
  22350. const isSetupInlined = !!options.inline;
  22351. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  22352. if (mode === "module") {
  22353. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  22354. } else {
  22355. genFunctionPreamble(ast, preambleContext);
  22356. }
  22357. const functionName = ssr ? `ssrRender` : `render`;
  22358. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  22359. if (options.bindingMetadata && !options.inline) {
  22360. args.push("$props", "$setup", "$data", "$options");
  22361. }
  22362. const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
  22363. if (isSetupInlined) {
  22364. push(`(${signature}) => {`);
  22365. } else {
  22366. push(`function ${functionName}(${signature}) {`);
  22367. }
  22368. indent();
  22369. if (useWithBlock) {
  22370. push(`with (_ctx) {`);
  22371. indent();
  22372. if (hasHelpers) {
  22373. push(
  22374. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  22375. `,
  22376. -1 /* End */
  22377. );
  22378. newline();
  22379. }
  22380. }
  22381. if (ast.components.length) {
  22382. genAssets(ast.components, "component", context);
  22383. if (ast.directives.length || ast.temps > 0) {
  22384. newline();
  22385. }
  22386. }
  22387. if (ast.directives.length) {
  22388. genAssets(ast.directives, "directive", context);
  22389. if (ast.temps > 0) {
  22390. newline();
  22391. }
  22392. }
  22393. if (ast.temps > 0) {
  22394. push(`let `);
  22395. for (let i = 0; i < ast.temps; i++) {
  22396. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  22397. }
  22398. }
  22399. if (ast.components.length || ast.directives.length || ast.temps) {
  22400. push(`
  22401. `, 0 /* Start */);
  22402. newline();
  22403. }
  22404. if (!ssr) {
  22405. push(`return `);
  22406. }
  22407. if (ast.codegenNode) {
  22408. genNode(ast.codegenNode, context);
  22409. } else {
  22410. push(`null`);
  22411. }
  22412. if (useWithBlock) {
  22413. deindent();
  22414. push(`}`);
  22415. }
  22416. deindent();
  22417. push(`}`);
  22418. return {
  22419. ast,
  22420. code: context.code,
  22421. preamble: isSetupInlined ? preambleContext.code : ``,
  22422. map: context.map ? context.map.toJSON() : void 0
  22423. };
  22424. }
  22425. function genFunctionPreamble(ast, context) {
  22426. const {
  22427. ssr,
  22428. prefixIdentifiers,
  22429. push,
  22430. newline,
  22431. runtimeModuleName,
  22432. runtimeGlobalName,
  22433. ssrRuntimeModuleName
  22434. } = context;
  22435. const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
  22436. const helpers = Array.from(ast.helpers);
  22437. if (helpers.length > 0) {
  22438. if (prefixIdentifiers) {
  22439. push(
  22440. `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
  22441. `,
  22442. -1 /* End */
  22443. );
  22444. } else {
  22445. push(`const _Vue = ${VueBinding}
  22446. `, -1 /* End */);
  22447. if (ast.hoists.length) {
  22448. const staticHelpers = [
  22449. CREATE_VNODE,
  22450. CREATE_ELEMENT_VNODE,
  22451. CREATE_COMMENT,
  22452. CREATE_TEXT,
  22453. CREATE_STATIC
  22454. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  22455. push(`const { ${staticHelpers} } = _Vue
  22456. `, -1 /* End */);
  22457. }
  22458. }
  22459. }
  22460. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  22461. push(
  22462. `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
  22463. `,
  22464. -1 /* End */
  22465. );
  22466. }
  22467. genHoists(ast.hoists, context);
  22468. newline();
  22469. push(`return `);
  22470. }
  22471. function genModulePreamble(ast, context, genScopeId, inline) {
  22472. const {
  22473. push,
  22474. newline,
  22475. optimizeImports,
  22476. runtimeModuleName,
  22477. ssrRuntimeModuleName
  22478. } = context;
  22479. if (ast.helpers.size) {
  22480. const helpers = Array.from(ast.helpers);
  22481. if (optimizeImports) {
  22482. push(
  22483. `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  22484. `,
  22485. -1 /* End */
  22486. );
  22487. push(
  22488. `
  22489. // Binding optimization for webpack code-split
  22490. const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
  22491. `,
  22492. -1 /* End */
  22493. );
  22494. } else {
  22495. push(
  22496. `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  22497. `,
  22498. -1 /* End */
  22499. );
  22500. }
  22501. }
  22502. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  22503. push(
  22504. `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
  22505. `,
  22506. -1 /* End */
  22507. );
  22508. }
  22509. if (ast.imports.length) {
  22510. genImports(ast.imports, context);
  22511. newline();
  22512. }
  22513. genHoists(ast.hoists, context);
  22514. newline();
  22515. if (!inline) {
  22516. push(`export `);
  22517. }
  22518. }
  22519. function genAssets(assets, type, { helper, push, newline, isTS }) {
  22520. const resolver = helper(
  22521. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  22522. );
  22523. for (let i = 0; i < assets.length; i++) {
  22524. let id = assets[i];
  22525. const maybeSelfReference = id.endsWith("__self");
  22526. if (maybeSelfReference) {
  22527. id = id.slice(0, -6);
  22528. }
  22529. push(
  22530. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  22531. );
  22532. if (i < assets.length - 1) {
  22533. newline();
  22534. }
  22535. }
  22536. }
  22537. function genHoists(hoists, context) {
  22538. if (!hoists.length) {
  22539. return;
  22540. }
  22541. context.pure = true;
  22542. const { push, newline } = context;
  22543. newline();
  22544. for (let i = 0; i < hoists.length; i++) {
  22545. const exp = hoists[i];
  22546. if (exp) {
  22547. push(`const _hoisted_${i + 1} = `);
  22548. genNode(exp, context);
  22549. newline();
  22550. }
  22551. }
  22552. context.pure = false;
  22553. }
  22554. function genImports(importsOptions, context) {
  22555. if (!importsOptions.length) {
  22556. return;
  22557. }
  22558. importsOptions.forEach((imports) => {
  22559. context.push(`import `);
  22560. genNode(imports.exp, context);
  22561. context.push(` from '${imports.path}'`);
  22562. context.newline();
  22563. });
  22564. }
  22565. function isText(n) {
  22566. return isString$1(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  22567. }
  22568. function genNodeListAsArray(nodes, context) {
  22569. const multilines = nodes.length > 3 || nodes.some((n) => isArray$3(n) || !isText(n));
  22570. context.push(`[`);
  22571. multilines && context.indent();
  22572. genNodeList(nodes, context, multilines);
  22573. multilines && context.deindent();
  22574. context.push(`]`);
  22575. }
  22576. function genNodeList(nodes, context, multilines = false, comma = true) {
  22577. const { push, newline } = context;
  22578. for (let i = 0; i < nodes.length; i++) {
  22579. const node = nodes[i];
  22580. if (isString$1(node)) {
  22581. push(node, -3 /* Unknown */);
  22582. } else if (isArray$3(node)) {
  22583. genNodeListAsArray(node, context);
  22584. } else {
  22585. genNode(node, context);
  22586. }
  22587. if (i < nodes.length - 1) {
  22588. if (multilines) {
  22589. comma && push(",");
  22590. newline();
  22591. } else {
  22592. comma && push(", ");
  22593. }
  22594. }
  22595. }
  22596. }
  22597. function genNode(node, context) {
  22598. if (isString$1(node)) {
  22599. context.push(node, -3 /* Unknown */);
  22600. return;
  22601. }
  22602. if (isSymbol$1(node)) {
  22603. context.push(context.helper(node));
  22604. return;
  22605. }
  22606. switch (node.type) {
  22607. case 1:
  22608. case 9:
  22609. case 11:
  22610. assert(
  22611. node.codegenNode != null,
  22612. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  22613. );
  22614. genNode(node.codegenNode, context);
  22615. break;
  22616. case 2:
  22617. genText(node, context);
  22618. break;
  22619. case 4:
  22620. genExpression(node, context);
  22621. break;
  22622. case 5:
  22623. genInterpolation(node, context);
  22624. break;
  22625. case 12:
  22626. genNode(node.codegenNode, context);
  22627. break;
  22628. case 8:
  22629. genCompoundExpression(node, context);
  22630. break;
  22631. case 3:
  22632. genComment(node, context);
  22633. break;
  22634. case 13:
  22635. genVNodeCall(node, context);
  22636. break;
  22637. case 14:
  22638. genCallExpression(node, context);
  22639. break;
  22640. case 15:
  22641. genObjectExpression(node, context);
  22642. break;
  22643. case 17:
  22644. genArrayExpression(node, context);
  22645. break;
  22646. case 18:
  22647. genFunctionExpression(node, context);
  22648. break;
  22649. case 19:
  22650. genConditionalExpression(node, context);
  22651. break;
  22652. case 20:
  22653. genCacheExpression(node, context);
  22654. break;
  22655. case 21:
  22656. genNodeList(node.body, context, true, false);
  22657. break;
  22658. // SSR only types
  22659. case 22:
  22660. genTemplateLiteral(node, context);
  22661. break;
  22662. case 23:
  22663. genIfStatement(node, context);
  22664. break;
  22665. case 24:
  22666. genAssignmentExpression(node, context);
  22667. break;
  22668. case 25:
  22669. genSequenceExpression(node, context);
  22670. break;
  22671. case 26:
  22672. genReturnStatement(node, context);
  22673. break;
  22674. /* v8 ignore start */
  22675. case 10:
  22676. break;
  22677. default:
  22678. {
  22679. assert(false, `unhandled codegen node type: ${node.type}`);
  22680. const exhaustiveCheck = node;
  22681. return exhaustiveCheck;
  22682. }
  22683. }
  22684. }
  22685. function genText(node, context) {
  22686. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  22687. }
  22688. function genExpression(node, context) {
  22689. const { content, isStatic } = node;
  22690. context.push(
  22691. isStatic ? JSON.stringify(content) : content,
  22692. -3 /* Unknown */,
  22693. node
  22694. );
  22695. }
  22696. function genInterpolation(node, context) {
  22697. const { push, helper, pure } = context;
  22698. if (pure) push(PURE_ANNOTATION);
  22699. push(`${helper(TO_DISPLAY_STRING)}(`);
  22700. genNode(node.content, context);
  22701. push(`)`);
  22702. }
  22703. function genCompoundExpression(node, context) {
  22704. for (let i = 0; i < node.children.length; i++) {
  22705. const child = node.children[i];
  22706. if (isString$1(child)) {
  22707. context.push(child, -3 /* Unknown */);
  22708. } else {
  22709. genNode(child, context);
  22710. }
  22711. }
  22712. }
  22713. function genExpressionAsPropertyKey(node, context) {
  22714. const { push } = context;
  22715. if (node.type === 8) {
  22716. push(`[`);
  22717. genCompoundExpression(node, context);
  22718. push(`]`);
  22719. } else if (node.isStatic) {
  22720. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  22721. push(text, -2 /* None */, node);
  22722. } else {
  22723. push(`[${node.content}]`, -3 /* Unknown */, node);
  22724. }
  22725. }
  22726. function genComment(node, context) {
  22727. const { push, helper, pure } = context;
  22728. if (pure) {
  22729. push(PURE_ANNOTATION);
  22730. }
  22731. push(
  22732. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  22733. -3 /* Unknown */,
  22734. node
  22735. );
  22736. }
  22737. function genVNodeCall(node, context) {
  22738. const { push, helper, pure } = context;
  22739. const {
  22740. tag,
  22741. props,
  22742. children,
  22743. patchFlag,
  22744. dynamicProps,
  22745. directives,
  22746. isBlock,
  22747. disableTracking,
  22748. isComponent
  22749. } = node;
  22750. let patchFlagString;
  22751. if (patchFlag) {
  22752. {
  22753. if (patchFlag < 0) {
  22754. patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  22755. } else {
  22756. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  22757. patchFlagString = patchFlag + ` /* ${flagNames} */`;
  22758. }
  22759. }
  22760. }
  22761. if (directives) {
  22762. push(helper(WITH_DIRECTIVES) + `(`);
  22763. }
  22764. if (isBlock) {
  22765. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  22766. }
  22767. if (pure) {
  22768. push(PURE_ANNOTATION);
  22769. }
  22770. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  22771. push(helper(callHelper) + `(`, -2 /* None */, node);
  22772. genNodeList(
  22773. genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
  22774. context
  22775. );
  22776. push(`)`);
  22777. if (isBlock) {
  22778. push(`)`);
  22779. }
  22780. if (directives) {
  22781. push(`, `);
  22782. genNode(directives, context);
  22783. push(`)`);
  22784. }
  22785. }
  22786. function genNullableArgs(args) {
  22787. let i = args.length;
  22788. while (i--) {
  22789. if (args[i] != null) break;
  22790. }
  22791. return args.slice(0, i + 1).map((arg) => arg || `null`);
  22792. }
  22793. function genCallExpression(node, context) {
  22794. const { push, helper, pure } = context;
  22795. const callee = isString$1(node.callee) ? node.callee : helper(node.callee);
  22796. if (pure) {
  22797. push(PURE_ANNOTATION);
  22798. }
  22799. push(callee + `(`, -2 /* None */, node);
  22800. genNodeList(node.arguments, context);
  22801. push(`)`);
  22802. }
  22803. function genObjectExpression(node, context) {
  22804. const { push, indent, deindent, newline } = context;
  22805. const { properties } = node;
  22806. if (!properties.length) {
  22807. push(`{}`, -2 /* None */, node);
  22808. return;
  22809. }
  22810. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  22811. push(multilines ? `{` : `{ `);
  22812. multilines && indent();
  22813. for (let i = 0; i < properties.length; i++) {
  22814. const { key, value } = properties[i];
  22815. genExpressionAsPropertyKey(key, context);
  22816. push(`: `);
  22817. genNode(value, context);
  22818. if (i < properties.length - 1) {
  22819. push(`,`);
  22820. newline();
  22821. }
  22822. }
  22823. multilines && deindent();
  22824. push(multilines ? `}` : ` }`);
  22825. }
  22826. function genArrayExpression(node, context) {
  22827. genNodeListAsArray(node.elements, context);
  22828. }
  22829. function genFunctionExpression(node, context) {
  22830. const { push, indent, deindent } = context;
  22831. const { params, returns, body, newline, isSlot } = node;
  22832. if (isSlot) {
  22833. push(`_${helperNameMap[WITH_CTX]}(`);
  22834. }
  22835. push(`(`, -2 /* None */, node);
  22836. if (isArray$3(params)) {
  22837. genNodeList(params, context);
  22838. } else if (params) {
  22839. genNode(params, context);
  22840. }
  22841. push(`) => `);
  22842. if (newline || body) {
  22843. push(`{`);
  22844. indent();
  22845. }
  22846. if (returns) {
  22847. if (newline) {
  22848. push(`return `);
  22849. }
  22850. if (isArray$3(returns)) {
  22851. genNodeListAsArray(returns, context);
  22852. } else {
  22853. genNode(returns, context);
  22854. }
  22855. } else if (body) {
  22856. genNode(body, context);
  22857. }
  22858. if (newline || body) {
  22859. deindent();
  22860. push(`}`);
  22861. }
  22862. if (isSlot) {
  22863. push(`)`);
  22864. }
  22865. }
  22866. function genConditionalExpression(node, context) {
  22867. const { test, consequent, alternate, newline: needNewline } = node;
  22868. const { push, indent, deindent, newline } = context;
  22869. if (test.type === 4) {
  22870. const needsParens = !isSimpleIdentifier(test.content);
  22871. needsParens && push(`(`);
  22872. genExpression(test, context);
  22873. needsParens && push(`)`);
  22874. } else {
  22875. push(`(`);
  22876. genNode(test, context);
  22877. push(`)`);
  22878. }
  22879. needNewline && indent();
  22880. context.indentLevel++;
  22881. needNewline || push(` `);
  22882. push(`? `);
  22883. genNode(consequent, context);
  22884. context.indentLevel--;
  22885. needNewline && newline();
  22886. needNewline || push(` `);
  22887. push(`: `);
  22888. const isNested = alternate.type === 19;
  22889. if (!isNested) {
  22890. context.indentLevel++;
  22891. }
  22892. genNode(alternate, context);
  22893. if (!isNested) {
  22894. context.indentLevel--;
  22895. }
  22896. needNewline && deindent(
  22897. true
  22898. /* without newline */
  22899. );
  22900. }
  22901. function genCacheExpression(node, context) {
  22902. const { push, helper, indent, deindent, newline } = context;
  22903. const { needPauseTracking, needArraySpread } = node;
  22904. if (needArraySpread) {
  22905. push(`[...(`);
  22906. }
  22907. push(`_cache[${node.index}] || (`);
  22908. if (needPauseTracking) {
  22909. indent();
  22910. push(`${helper(SET_BLOCK_TRACKING)}(-1`);
  22911. if (node.inVOnce) push(`, true`);
  22912. push(`),`);
  22913. newline();
  22914. push(`(`);
  22915. }
  22916. push(`_cache[${node.index}] = `);
  22917. genNode(node.value, context);
  22918. if (needPauseTracking) {
  22919. push(`).cacheIndex = ${node.index},`);
  22920. newline();
  22921. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  22922. newline();
  22923. push(`_cache[${node.index}]`);
  22924. deindent();
  22925. }
  22926. push(`)`);
  22927. if (needArraySpread) {
  22928. push(`)]`);
  22929. }
  22930. }
  22931. function genTemplateLiteral(node, context) {
  22932. const { push, indent, deindent } = context;
  22933. push("`");
  22934. const l = node.elements.length;
  22935. const multilines = l > 3;
  22936. for (let i = 0; i < l; i++) {
  22937. const e = node.elements[i];
  22938. if (isString$1(e)) {
  22939. push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
  22940. } else {
  22941. push("${");
  22942. if (multilines) indent();
  22943. genNode(e, context);
  22944. if (multilines) deindent();
  22945. push("}");
  22946. }
  22947. }
  22948. push("`");
  22949. }
  22950. function genIfStatement(node, context) {
  22951. const { push, indent, deindent } = context;
  22952. const { test, consequent, alternate } = node;
  22953. push(`if (`);
  22954. genNode(test, context);
  22955. push(`) {`);
  22956. indent();
  22957. genNode(consequent, context);
  22958. deindent();
  22959. push(`}`);
  22960. if (alternate) {
  22961. push(` else `);
  22962. if (alternate.type === 23) {
  22963. genIfStatement(alternate, context);
  22964. } else {
  22965. push(`{`);
  22966. indent();
  22967. genNode(alternate, context);
  22968. deindent();
  22969. push(`}`);
  22970. }
  22971. }
  22972. }
  22973. function genAssignmentExpression(node, context) {
  22974. genNode(node.left, context);
  22975. context.push(` = `);
  22976. genNode(node.right, context);
  22977. }
  22978. function genSequenceExpression(node, context) {
  22979. context.push(`(`);
  22980. genNodeList(node.expressions, context);
  22981. context.push(`)`);
  22982. }
  22983. function genReturnStatement({ returns }, context) {
  22984. context.push(`return `);
  22985. if (isArray$3(returns)) {
  22986. genNodeListAsArray(returns, context);
  22987. } else {
  22988. genNode(returns, context);
  22989. }
  22990. }
  22991. const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
  22992. const transformExpression = (node, context) => {
  22993. if (node.type === 5) {
  22994. node.content = processExpression(
  22995. node.content,
  22996. context
  22997. );
  22998. } else if (node.type === 1) {
  22999. const memo = findDir(node, "memo");
  23000. for (let i = 0; i < node.props.length; i++) {
  23001. const dir = node.props[i];
  23002. if (dir.type === 7 && dir.name !== "for") {
  23003. const exp = dir.exp;
  23004. const arg = dir.arg;
  23005. if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
  23006. !(memo && arg && arg.type === 4 && arg.content === "key")) {
  23007. dir.exp = processExpression(
  23008. exp,
  23009. context,
  23010. // slot args must be processed as function params
  23011. dir.name === "slot"
  23012. );
  23013. }
  23014. if (arg && arg.type === 4 && !arg.isStatic) {
  23015. dir.arg = processExpression(arg, context);
  23016. }
  23017. }
  23018. }
  23019. }
  23020. };
  23021. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  23022. if (!context.prefixIdentifiers || !node.content.trim()) {
  23023. return node;
  23024. }
  23025. const { inline, bindingMetadata } = context;
  23026. const rewriteIdentifier = (raw, parent, id) => {
  23027. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  23028. if (inline) {
  23029. const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
  23030. const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
  23031. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  23032. const isNewExpression = parent && isInNewExpression(parentStack);
  23033. const wrapWithUnref = (raw2) => {
  23034. const wrapped = `${context.helperString(UNREF)}(${raw2})`;
  23035. return isNewExpression ? `(${wrapped})` : wrapped;
  23036. };
  23037. if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
  23038. return raw;
  23039. } else if (type === "setup-ref") {
  23040. return `${raw}.value`;
  23041. } else if (type === "setup-maybe-ref") {
  23042. return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
  23043. } else if (type === "setup-let") {
  23044. if (isAssignmentLVal) {
  23045. const { right: rVal, operator } = parent;
  23046. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  23047. const rExpString = stringifyExpression(
  23048. processExpression(
  23049. createSimpleExpression(rExp, false),
  23050. context,
  23051. false,
  23052. false,
  23053. knownIds
  23054. )
  23055. );
  23056. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  23057. ` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  23058. } else if (isUpdateArg) {
  23059. id.start = parent.start;
  23060. id.end = parent.end;
  23061. const { prefix: isPrefix, operator } = parent;
  23062. const prefix = isPrefix ? operator : ``;
  23063. const postfix = isPrefix ? `` : operator;
  23064. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  23065. ` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  23066. } else if (isDestructureAssignment) {
  23067. return raw;
  23068. } else {
  23069. return wrapWithUnref(raw);
  23070. }
  23071. } else if (type === "props") {
  23072. return genPropsAccessExp(raw);
  23073. } else if (type === "props-aliased") {
  23074. return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
  23075. }
  23076. } else {
  23077. if (type && type.startsWith("setup") || type === "literal-const") {
  23078. return `$setup.${raw}`;
  23079. } else if (type === "props-aliased") {
  23080. return `$props['${bindingMetadata.__propsAliases[raw]}']`;
  23081. } else if (type) {
  23082. return `$${type}.${raw}`;
  23083. }
  23084. }
  23085. return `_ctx.${raw}`;
  23086. };
  23087. const rawExp = node.content;
  23088. let ast = node.ast;
  23089. if (ast === false) {
  23090. return node;
  23091. }
  23092. if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
  23093. const isScopeVarReference = context.identifiers[rawExp];
  23094. const isAllowedGlobal = isGloballyAllowed(rawExp);
  23095. const isLiteral = isLiteralWhitelisted(rawExp);
  23096. if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
  23097. if (isConst(bindingMetadata[rawExp])) {
  23098. node.constType = 1;
  23099. }
  23100. node.content = rewriteIdentifier(rawExp);
  23101. } else if (!isScopeVarReference) {
  23102. if (isLiteral) {
  23103. node.constType = 3;
  23104. } else {
  23105. node.constType = 2;
  23106. }
  23107. }
  23108. return node;
  23109. }
  23110. if (!ast) {
  23111. const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
  23112. try {
  23113. ast = libExports.parseExpression(source, {
  23114. sourceType: "module",
  23115. plugins: context.expressionPlugins
  23116. });
  23117. } catch (e) {
  23118. context.onError(
  23119. createCompilerError(
  23120. 45,
  23121. node.loc,
  23122. void 0,
  23123. e.message
  23124. )
  23125. );
  23126. return node;
  23127. }
  23128. }
  23129. const ids = [];
  23130. const parentStack = [];
  23131. const knownIds = Object.create(context.identifiers);
  23132. walkIdentifiers(
  23133. ast,
  23134. (node2, parent, _, isReferenced, isLocal) => {
  23135. if (isStaticPropertyKey(node2, parent)) {
  23136. return;
  23137. }
  23138. const needPrefix = isReferenced && canPrefix(node2);
  23139. if (needPrefix && !isLocal) {
  23140. if (isStaticProperty(parent) && parent.shorthand) {
  23141. node2.prefix = `${node2.name}: `;
  23142. }
  23143. node2.name = rewriteIdentifier(node2.name, parent, node2);
  23144. ids.push(node2);
  23145. } else {
  23146. if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) {
  23147. node2.isConstant = true;
  23148. }
  23149. ids.push(node2);
  23150. }
  23151. },
  23152. true,
  23153. // invoke on ALL identifiers
  23154. parentStack,
  23155. knownIds
  23156. );
  23157. const children = [];
  23158. ids.sort((a, b) => a.start - b.start);
  23159. ids.forEach((id, i) => {
  23160. const start = id.start - 1;
  23161. const end = id.end - 1;
  23162. const last = ids[i - 1];
  23163. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  23164. if (leadingText.length || id.prefix) {
  23165. children.push(leadingText + (id.prefix || ``));
  23166. }
  23167. const source = rawExp.slice(start, end);
  23168. children.push(
  23169. createSimpleExpression(
  23170. id.name,
  23171. false,
  23172. {
  23173. start: advancePositionWithClone(node.loc.start, source, start),
  23174. end: advancePositionWithClone(node.loc.start, source, end),
  23175. source
  23176. },
  23177. id.isConstant ? 3 : 0
  23178. )
  23179. );
  23180. if (i === ids.length - 1 && end < rawExp.length) {
  23181. children.push(rawExp.slice(end));
  23182. }
  23183. });
  23184. let ret;
  23185. if (children.length) {
  23186. ret = createCompoundExpression(children, node.loc);
  23187. ret.ast = ast;
  23188. } else {
  23189. ret = node;
  23190. ret.constType = 3;
  23191. }
  23192. ret.identifiers = Object.keys(knownIds);
  23193. return ret;
  23194. }
  23195. function canPrefix(id) {
  23196. if (isGloballyAllowed(id.name)) {
  23197. return false;
  23198. }
  23199. if (id.name === "require") {
  23200. return false;
  23201. }
  23202. return true;
  23203. }
  23204. function stringifyExpression(exp) {
  23205. if (isString$1(exp)) {
  23206. return exp;
  23207. } else if (exp.type === 4) {
  23208. return exp.content;
  23209. } else {
  23210. return exp.children.map(stringifyExpression).join("");
  23211. }
  23212. }
  23213. function isConst(type) {
  23214. return type === "setup-const" || type === "literal-const";
  23215. }
  23216. const transformIf = createStructuralDirectiveTransform(
  23217. /^(?:if|else|else-if)$/,
  23218. (node, dir, context) => {
  23219. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  23220. const siblings = context.parent.children;
  23221. let i = siblings.indexOf(ifNode);
  23222. let key = 0;
  23223. while (i-- >= 0) {
  23224. const sibling = siblings[i];
  23225. if (sibling && sibling.type === 9) {
  23226. key += sibling.branches.length;
  23227. }
  23228. }
  23229. return () => {
  23230. if (isRoot) {
  23231. ifNode.codegenNode = createCodegenNodeForBranch(
  23232. branch,
  23233. key,
  23234. context
  23235. );
  23236. } else {
  23237. const parentCondition = getParentCondition(ifNode.codegenNode);
  23238. parentCondition.alternate = createCodegenNodeForBranch(
  23239. branch,
  23240. key + ifNode.branches.length - 1,
  23241. context
  23242. );
  23243. }
  23244. };
  23245. });
  23246. }
  23247. );
  23248. function processIf(node, dir, context, processCodegen) {
  23249. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  23250. const loc = dir.exp ? dir.exp.loc : node.loc;
  23251. context.onError(
  23252. createCompilerError(28, dir.loc)
  23253. );
  23254. dir.exp = createSimpleExpression(`true`, false, loc);
  23255. }
  23256. if (context.prefixIdentifiers && dir.exp) {
  23257. dir.exp = processExpression(dir.exp, context);
  23258. }
  23259. if (dir.name === "if") {
  23260. const branch = createIfBranch(node, dir);
  23261. const ifNode = {
  23262. type: 9,
  23263. loc: cloneLoc(node.loc),
  23264. branches: [branch]
  23265. };
  23266. context.replaceNode(ifNode);
  23267. if (processCodegen) {
  23268. return processCodegen(ifNode, branch, true);
  23269. }
  23270. } else {
  23271. const siblings = context.parent.children;
  23272. const comments = [];
  23273. let i = siblings.indexOf(node);
  23274. while (i-- >= -1) {
  23275. const sibling = siblings[i];
  23276. if (sibling && sibling.type === 3) {
  23277. context.removeNode(sibling);
  23278. comments.unshift(sibling);
  23279. continue;
  23280. }
  23281. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  23282. context.removeNode(sibling);
  23283. continue;
  23284. }
  23285. if (sibling && sibling.type === 9) {
  23286. if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  23287. context.onError(
  23288. createCompilerError(30, node.loc)
  23289. );
  23290. }
  23291. context.removeNode();
  23292. const branch = createIfBranch(node, dir);
  23293. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  23294. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  23295. branch.children = [...comments, ...branch.children];
  23296. }
  23297. {
  23298. const key = branch.userKey;
  23299. if (key) {
  23300. sibling.branches.forEach(({ userKey }) => {
  23301. if (isSameKey(userKey, key)) {
  23302. context.onError(
  23303. createCompilerError(
  23304. 29,
  23305. branch.userKey.loc
  23306. )
  23307. );
  23308. }
  23309. });
  23310. }
  23311. }
  23312. sibling.branches.push(branch);
  23313. const onExit = processCodegen && processCodegen(sibling, branch, false);
  23314. traverseNode(branch, context);
  23315. if (onExit) onExit();
  23316. context.currentNode = null;
  23317. } else {
  23318. context.onError(
  23319. createCompilerError(30, node.loc)
  23320. );
  23321. }
  23322. break;
  23323. }
  23324. }
  23325. }
  23326. function createIfBranch(node, dir) {
  23327. const isTemplateIf = node.tagType === 3;
  23328. return {
  23329. type: 10,
  23330. loc: node.loc,
  23331. condition: dir.name === "else" ? void 0 : dir.exp,
  23332. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  23333. userKey: findProp(node, `key`),
  23334. isTemplateIf
  23335. };
  23336. }
  23337. function createCodegenNodeForBranch(branch, keyIndex, context) {
  23338. if (branch.condition) {
  23339. return createConditionalExpression(
  23340. branch.condition,
  23341. createChildrenCodegenNode(branch, keyIndex, context),
  23342. // make sure to pass in asBlock: true so that the comment node call
  23343. // closes the current block.
  23344. createCallExpression(context.helper(CREATE_COMMENT), [
  23345. '"v-if"' ,
  23346. "true"
  23347. ])
  23348. );
  23349. } else {
  23350. return createChildrenCodegenNode(branch, keyIndex, context);
  23351. }
  23352. }
  23353. function createChildrenCodegenNode(branch, keyIndex, context) {
  23354. const { helper } = context;
  23355. const keyProperty = createObjectProperty(
  23356. `key`,
  23357. createSimpleExpression(
  23358. `${keyIndex}`,
  23359. false,
  23360. locStub,
  23361. 2
  23362. )
  23363. );
  23364. const { children } = branch;
  23365. const firstChild = children[0];
  23366. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  23367. if (needFragmentWrapper) {
  23368. if (children.length === 1 && firstChild.type === 11) {
  23369. const vnodeCall = firstChild.codegenNode;
  23370. injectProp(vnodeCall, keyProperty, context);
  23371. return vnodeCall;
  23372. } else {
  23373. let patchFlag = 64;
  23374. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  23375. patchFlag |= 2048;
  23376. }
  23377. return createVNodeCall(
  23378. context,
  23379. helper(FRAGMENT),
  23380. createObjectExpression([keyProperty]),
  23381. children,
  23382. patchFlag,
  23383. void 0,
  23384. void 0,
  23385. true,
  23386. false,
  23387. false,
  23388. branch.loc
  23389. );
  23390. }
  23391. } else {
  23392. const ret = firstChild.codegenNode;
  23393. const vnodeCall = getMemoedVNodeCall(ret);
  23394. if (vnodeCall.type === 13) {
  23395. convertToBlock(vnodeCall, context);
  23396. }
  23397. injectProp(vnodeCall, keyProperty, context);
  23398. return ret;
  23399. }
  23400. }
  23401. function isSameKey(a, b) {
  23402. if (!a || a.type !== b.type) {
  23403. return false;
  23404. }
  23405. if (a.type === 6) {
  23406. if (a.value.content !== b.value.content) {
  23407. return false;
  23408. }
  23409. } else {
  23410. const exp = a.exp;
  23411. const branchExp = b.exp;
  23412. if (exp.type !== branchExp.type) {
  23413. return false;
  23414. }
  23415. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  23416. return false;
  23417. }
  23418. }
  23419. return true;
  23420. }
  23421. function getParentCondition(node) {
  23422. while (true) {
  23423. if (node.type === 19) {
  23424. if (node.alternate.type === 19) {
  23425. node = node.alternate;
  23426. } else {
  23427. return node;
  23428. }
  23429. } else if (node.type === 20) {
  23430. node = node.value;
  23431. }
  23432. }
  23433. }
  23434. const transformFor = createStructuralDirectiveTransform(
  23435. "for",
  23436. (node, dir, context) => {
  23437. const { helper, removeHelper } = context;
  23438. return processFor(node, dir, context, (forNode) => {
  23439. const renderExp = createCallExpression(helper(RENDER_LIST), [
  23440. forNode.source
  23441. ]);
  23442. const isTemplate = isTemplateNode(node);
  23443. const memo = findDir(node, "memo");
  23444. const keyProp = findProp(node, `key`, false, true);
  23445. const isDirKey = keyProp && keyProp.type === 7;
  23446. let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
  23447. if (memo && keyExp && isDirKey) {
  23448. {
  23449. keyProp.exp = keyExp = processExpression(
  23450. keyExp,
  23451. context
  23452. );
  23453. }
  23454. }
  23455. const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
  23456. if (isTemplate) {
  23457. if (memo) {
  23458. memo.exp = processExpression(
  23459. memo.exp,
  23460. context
  23461. );
  23462. }
  23463. if (keyProperty && keyProp.type !== 6) {
  23464. keyProperty.value = processExpression(
  23465. keyProperty.value,
  23466. context
  23467. );
  23468. }
  23469. }
  23470. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  23471. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  23472. forNode.codegenNode = createVNodeCall(
  23473. context,
  23474. helper(FRAGMENT),
  23475. void 0,
  23476. renderExp,
  23477. fragmentFlag,
  23478. void 0,
  23479. void 0,
  23480. true,
  23481. !isStableFragment,
  23482. false,
  23483. node.loc
  23484. );
  23485. return () => {
  23486. let childBlock;
  23487. const { children } = forNode;
  23488. if (isTemplate) {
  23489. node.children.some((c) => {
  23490. if (c.type === 1) {
  23491. const key = findProp(c, "key");
  23492. if (key) {
  23493. context.onError(
  23494. createCompilerError(
  23495. 33,
  23496. key.loc
  23497. )
  23498. );
  23499. return true;
  23500. }
  23501. }
  23502. });
  23503. }
  23504. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  23505. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  23506. if (slotOutlet) {
  23507. childBlock = slotOutlet.codegenNode;
  23508. if (isTemplate && keyProperty) {
  23509. injectProp(childBlock, keyProperty, context);
  23510. }
  23511. } else if (needFragmentWrapper) {
  23512. childBlock = createVNodeCall(
  23513. context,
  23514. helper(FRAGMENT),
  23515. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  23516. node.children,
  23517. 64,
  23518. void 0,
  23519. void 0,
  23520. true,
  23521. void 0,
  23522. false
  23523. );
  23524. } else {
  23525. childBlock = children[0].codegenNode;
  23526. if (isTemplate && keyProperty) {
  23527. injectProp(childBlock, keyProperty, context);
  23528. }
  23529. if (childBlock.isBlock !== !isStableFragment) {
  23530. if (childBlock.isBlock) {
  23531. removeHelper(OPEN_BLOCK);
  23532. removeHelper(
  23533. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  23534. );
  23535. } else {
  23536. removeHelper(
  23537. getVNodeHelper(context.inSSR, childBlock.isComponent)
  23538. );
  23539. }
  23540. }
  23541. childBlock.isBlock = !isStableFragment;
  23542. if (childBlock.isBlock) {
  23543. helper(OPEN_BLOCK);
  23544. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  23545. } else {
  23546. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  23547. }
  23548. }
  23549. if (memo) {
  23550. const loop = createFunctionExpression(
  23551. createForLoopParams(forNode.parseResult, [
  23552. createSimpleExpression(`_cached`)
  23553. ])
  23554. );
  23555. loop.body = createBlockStatement([
  23556. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  23557. createCompoundExpression([
  23558. `if (_cached`,
  23559. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  23560. ` && ${context.helperString(
  23561. IS_MEMO_SAME
  23562. )}(_cached, _memo)) return _cached`
  23563. ]),
  23564. createCompoundExpression([`const _item = `, childBlock]),
  23565. createSimpleExpression(`_item.memo = _memo`),
  23566. createSimpleExpression(`return _item`)
  23567. ]);
  23568. renderExp.arguments.push(
  23569. loop,
  23570. createSimpleExpression(`_cache`),
  23571. createSimpleExpression(String(context.cached.length))
  23572. );
  23573. context.cached.push(null);
  23574. } else {
  23575. renderExp.arguments.push(
  23576. createFunctionExpression(
  23577. createForLoopParams(forNode.parseResult),
  23578. childBlock,
  23579. true
  23580. )
  23581. );
  23582. }
  23583. };
  23584. });
  23585. }
  23586. );
  23587. function processFor(node, dir, context, processCodegen) {
  23588. if (!dir.exp) {
  23589. context.onError(
  23590. createCompilerError(31, dir.loc)
  23591. );
  23592. return;
  23593. }
  23594. const parseResult = dir.forParseResult;
  23595. if (!parseResult) {
  23596. context.onError(
  23597. createCompilerError(32, dir.loc)
  23598. );
  23599. return;
  23600. }
  23601. finalizeForParseResult(parseResult, context);
  23602. const { addIdentifiers, removeIdentifiers, scopes } = context;
  23603. const { source, value, key, index } = parseResult;
  23604. const forNode = {
  23605. type: 11,
  23606. loc: dir.loc,
  23607. source,
  23608. valueAlias: value,
  23609. keyAlias: key,
  23610. objectIndexAlias: index,
  23611. parseResult,
  23612. children: isTemplateNode(node) ? node.children : [node]
  23613. };
  23614. context.replaceNode(forNode);
  23615. scopes.vFor++;
  23616. if (context.prefixIdentifiers) {
  23617. value && addIdentifiers(value);
  23618. key && addIdentifiers(key);
  23619. index && addIdentifiers(index);
  23620. }
  23621. const onExit = processCodegen && processCodegen(forNode);
  23622. return () => {
  23623. scopes.vFor--;
  23624. if (context.prefixIdentifiers) {
  23625. value && removeIdentifiers(value);
  23626. key && removeIdentifiers(key);
  23627. index && removeIdentifiers(index);
  23628. }
  23629. if (onExit) onExit();
  23630. };
  23631. }
  23632. function finalizeForParseResult(result, context) {
  23633. if (result.finalized) return;
  23634. if (context.prefixIdentifiers) {
  23635. result.source = processExpression(
  23636. result.source,
  23637. context
  23638. );
  23639. if (result.key) {
  23640. result.key = processExpression(
  23641. result.key,
  23642. context,
  23643. true
  23644. );
  23645. }
  23646. if (result.index) {
  23647. result.index = processExpression(
  23648. result.index,
  23649. context,
  23650. true
  23651. );
  23652. }
  23653. if (result.value) {
  23654. result.value = processExpression(
  23655. result.value,
  23656. context,
  23657. true
  23658. );
  23659. }
  23660. }
  23661. result.finalized = true;
  23662. }
  23663. function createForLoopParams({ value, key, index }, memoArgs = []) {
  23664. return createParamsList([value, key, index, ...memoArgs]);
  23665. }
  23666. function createParamsList(args) {
  23667. let i = args.length;
  23668. while (i--) {
  23669. if (args[i]) break;
  23670. }
  23671. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  23672. }
  23673. const defaultFallback = createSimpleExpression(`undefined`, false);
  23674. const trackSlotScopes = (node, context) => {
  23675. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  23676. const vSlot = findDir(node, "slot");
  23677. if (vSlot) {
  23678. const slotProps = vSlot.exp;
  23679. if (context.prefixIdentifiers) {
  23680. slotProps && context.addIdentifiers(slotProps);
  23681. }
  23682. context.scopes.vSlot++;
  23683. return () => {
  23684. if (context.prefixIdentifiers) {
  23685. slotProps && context.removeIdentifiers(slotProps);
  23686. }
  23687. context.scopes.vSlot--;
  23688. };
  23689. }
  23690. }
  23691. };
  23692. const trackVForSlotScopes = (node, context) => {
  23693. let vFor;
  23694. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  23695. const result = vFor.forParseResult;
  23696. if (result) {
  23697. finalizeForParseResult(result, context);
  23698. const { value, key, index } = result;
  23699. const { addIdentifiers, removeIdentifiers } = context;
  23700. value && addIdentifiers(value);
  23701. key && addIdentifiers(key);
  23702. index && addIdentifiers(index);
  23703. return () => {
  23704. value && removeIdentifiers(value);
  23705. key && removeIdentifiers(key);
  23706. index && removeIdentifiers(index);
  23707. };
  23708. }
  23709. }
  23710. };
  23711. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  23712. props,
  23713. children,
  23714. false,
  23715. true,
  23716. children.length ? children[0].loc : loc
  23717. );
  23718. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  23719. context.helper(WITH_CTX);
  23720. const { children, loc } = node;
  23721. const slotsProperties = [];
  23722. const dynamicSlots = [];
  23723. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  23724. if (!context.ssr && context.prefixIdentifiers) {
  23725. hasDynamicSlots = node.props.some(
  23726. (prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
  23727. ) || children.some((child) => hasScopeRef(child, context.identifiers));
  23728. }
  23729. const onComponentSlot = findDir(node, "slot", true);
  23730. if (onComponentSlot) {
  23731. const { arg, exp } = onComponentSlot;
  23732. if (arg && !isStaticExp(arg)) {
  23733. hasDynamicSlots = true;
  23734. }
  23735. slotsProperties.push(
  23736. createObjectProperty(
  23737. arg || createSimpleExpression("default", true),
  23738. buildSlotFn(exp, void 0, children, loc)
  23739. )
  23740. );
  23741. }
  23742. let hasTemplateSlots = false;
  23743. let hasNamedDefaultSlot = false;
  23744. const implicitDefaultChildren = [];
  23745. const seenSlotNames = /* @__PURE__ */ new Set();
  23746. let conditionalBranchIndex = 0;
  23747. for (let i = 0; i < children.length; i++) {
  23748. const slotElement = children[i];
  23749. let slotDir;
  23750. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  23751. if (slotElement.type !== 3) {
  23752. implicitDefaultChildren.push(slotElement);
  23753. }
  23754. continue;
  23755. }
  23756. if (onComponentSlot) {
  23757. context.onError(
  23758. createCompilerError(37, slotDir.loc)
  23759. );
  23760. break;
  23761. }
  23762. hasTemplateSlots = true;
  23763. const { children: slotChildren, loc: slotLoc } = slotElement;
  23764. const {
  23765. arg: slotName = createSimpleExpression(`default`, true),
  23766. exp: slotProps,
  23767. loc: dirLoc
  23768. } = slotDir;
  23769. let staticSlotName;
  23770. if (isStaticExp(slotName)) {
  23771. staticSlotName = slotName ? slotName.content : `default`;
  23772. } else {
  23773. hasDynamicSlots = true;
  23774. }
  23775. const vFor = findDir(slotElement, "for");
  23776. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  23777. let vIf;
  23778. let vElse;
  23779. if (vIf = findDir(slotElement, "if")) {
  23780. hasDynamicSlots = true;
  23781. dynamicSlots.push(
  23782. createConditionalExpression(
  23783. vIf.exp,
  23784. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  23785. defaultFallback
  23786. )
  23787. );
  23788. } else if (vElse = findDir(
  23789. slotElement,
  23790. /^else(?:-if)?$/,
  23791. true
  23792. /* allowEmpty */
  23793. )) {
  23794. let j = i;
  23795. let prev;
  23796. while (j--) {
  23797. prev = children[j];
  23798. if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
  23799. break;
  23800. }
  23801. }
  23802. if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
  23803. let conditional = dynamicSlots[dynamicSlots.length - 1];
  23804. while (conditional.alternate.type === 19) {
  23805. conditional = conditional.alternate;
  23806. }
  23807. conditional.alternate = vElse.exp ? createConditionalExpression(
  23808. vElse.exp,
  23809. buildDynamicSlot(
  23810. slotName,
  23811. slotFunction,
  23812. conditionalBranchIndex++
  23813. ),
  23814. defaultFallback
  23815. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  23816. } else {
  23817. context.onError(
  23818. createCompilerError(30, vElse.loc)
  23819. );
  23820. }
  23821. } else if (vFor) {
  23822. hasDynamicSlots = true;
  23823. const parseResult = vFor.forParseResult;
  23824. if (parseResult) {
  23825. finalizeForParseResult(parseResult, context);
  23826. dynamicSlots.push(
  23827. createCallExpression(context.helper(RENDER_LIST), [
  23828. parseResult.source,
  23829. createFunctionExpression(
  23830. createForLoopParams(parseResult),
  23831. buildDynamicSlot(slotName, slotFunction),
  23832. true
  23833. )
  23834. ])
  23835. );
  23836. } else {
  23837. context.onError(
  23838. createCompilerError(
  23839. 32,
  23840. vFor.loc
  23841. )
  23842. );
  23843. }
  23844. } else {
  23845. if (staticSlotName) {
  23846. if (seenSlotNames.has(staticSlotName)) {
  23847. context.onError(
  23848. createCompilerError(
  23849. 38,
  23850. dirLoc
  23851. )
  23852. );
  23853. continue;
  23854. }
  23855. seenSlotNames.add(staticSlotName);
  23856. if (staticSlotName === "default") {
  23857. hasNamedDefaultSlot = true;
  23858. }
  23859. }
  23860. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  23861. }
  23862. }
  23863. if (!onComponentSlot) {
  23864. const buildDefaultSlotProperty = (props, children2) => {
  23865. const fn = buildSlotFn(props, void 0, children2, loc);
  23866. return createObjectProperty(`default`, fn);
  23867. };
  23868. if (!hasTemplateSlots) {
  23869. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  23870. } else if (implicitDefaultChildren.length && // #3766
  23871. // with whitespace: 'preserve', whitespaces between slots will end up in
  23872. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  23873. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  23874. if (hasNamedDefaultSlot) {
  23875. context.onError(
  23876. createCompilerError(
  23877. 39,
  23878. implicitDefaultChildren[0].loc
  23879. )
  23880. );
  23881. } else {
  23882. slotsProperties.push(
  23883. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  23884. );
  23885. }
  23886. }
  23887. }
  23888. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  23889. let slots = createObjectExpression(
  23890. slotsProperties.concat(
  23891. createObjectProperty(
  23892. `_`,
  23893. // 2 = compiled but dynamic = can skip normalization, but must run diff
  23894. // 1 = compiled and static = can skip normalization AND diff as optimized
  23895. createSimpleExpression(
  23896. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  23897. false
  23898. )
  23899. )
  23900. ),
  23901. loc
  23902. );
  23903. if (dynamicSlots.length) {
  23904. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  23905. slots,
  23906. createArrayExpression(dynamicSlots)
  23907. ]);
  23908. }
  23909. return {
  23910. slots,
  23911. hasDynamicSlots
  23912. };
  23913. }
  23914. function buildDynamicSlot(name, fn, index) {
  23915. const props = [
  23916. createObjectProperty(`name`, name),
  23917. createObjectProperty(`fn`, fn)
  23918. ];
  23919. if (index != null) {
  23920. props.push(
  23921. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  23922. );
  23923. }
  23924. return createObjectExpression(props);
  23925. }
  23926. function hasForwardedSlots(children) {
  23927. for (let i = 0; i < children.length; i++) {
  23928. const child = children[i];
  23929. switch (child.type) {
  23930. case 1:
  23931. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  23932. return true;
  23933. }
  23934. break;
  23935. case 9:
  23936. if (hasForwardedSlots(child.branches)) return true;
  23937. break;
  23938. case 10:
  23939. case 11:
  23940. if (hasForwardedSlots(child.children)) return true;
  23941. break;
  23942. }
  23943. }
  23944. return false;
  23945. }
  23946. function isNonWhitespaceContent(node) {
  23947. if (node.type !== 2 && node.type !== 12)
  23948. return true;
  23949. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  23950. }
  23951. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  23952. const transformElement = (node, context) => {
  23953. return function postTransformElement() {
  23954. node = context.currentNode;
  23955. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  23956. return;
  23957. }
  23958. const { tag, props } = node;
  23959. const isComponent = node.tagType === 1;
  23960. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  23961. const isDynamicComponent = isObject$2(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  23962. let vnodeProps;
  23963. let vnodeChildren;
  23964. let patchFlag = 0;
  23965. let vnodeDynamicProps;
  23966. let dynamicPropNames;
  23967. let vnodeDirectives;
  23968. let shouldUseBlock = (
  23969. // dynamic component may resolve to plain elements
  23970. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  23971. // updates inside get proper isSVG flag at runtime. (#639, #643)
  23972. // This is technically web-specific, but splitting the logic out of core
  23973. // leads to too much unnecessary complexity.
  23974. (tag === "svg" || tag === "foreignObject" || tag === "math")
  23975. );
  23976. if (props.length > 0) {
  23977. const propsBuildResult = buildProps(
  23978. node,
  23979. context,
  23980. void 0,
  23981. isComponent,
  23982. isDynamicComponent
  23983. );
  23984. vnodeProps = propsBuildResult.props;
  23985. patchFlag = propsBuildResult.patchFlag;
  23986. dynamicPropNames = propsBuildResult.dynamicPropNames;
  23987. const directives = propsBuildResult.directives;
  23988. vnodeDirectives = directives && directives.length ? createArrayExpression(
  23989. directives.map((dir) => buildDirectiveArgs(dir, context))
  23990. ) : void 0;
  23991. if (propsBuildResult.shouldUseBlock) {
  23992. shouldUseBlock = true;
  23993. }
  23994. }
  23995. if (node.children.length > 0) {
  23996. if (vnodeTag === KEEP_ALIVE) {
  23997. shouldUseBlock = true;
  23998. patchFlag |= 1024;
  23999. if (node.children.length > 1) {
  24000. context.onError(
  24001. createCompilerError(46, {
  24002. start: node.children[0].loc.start,
  24003. end: node.children[node.children.length - 1].loc.end,
  24004. source: ""
  24005. })
  24006. );
  24007. }
  24008. }
  24009. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  24010. vnodeTag !== TELEPORT && // explained above.
  24011. vnodeTag !== KEEP_ALIVE;
  24012. if (shouldBuildAsSlots) {
  24013. const { slots, hasDynamicSlots } = buildSlots(node, context);
  24014. vnodeChildren = slots;
  24015. if (hasDynamicSlots) {
  24016. patchFlag |= 1024;
  24017. }
  24018. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  24019. const child = node.children[0];
  24020. const type = child.type;
  24021. const hasDynamicTextChild = type === 5 || type === 8;
  24022. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  24023. patchFlag |= 1;
  24024. }
  24025. if (hasDynamicTextChild || type === 2) {
  24026. vnodeChildren = child;
  24027. } else {
  24028. vnodeChildren = node.children;
  24029. }
  24030. } else {
  24031. vnodeChildren = node.children;
  24032. }
  24033. }
  24034. if (dynamicPropNames && dynamicPropNames.length) {
  24035. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  24036. }
  24037. node.codegenNode = createVNodeCall(
  24038. context,
  24039. vnodeTag,
  24040. vnodeProps,
  24041. vnodeChildren,
  24042. patchFlag === 0 ? void 0 : patchFlag,
  24043. vnodeDynamicProps,
  24044. vnodeDirectives,
  24045. !!shouldUseBlock,
  24046. false,
  24047. isComponent,
  24048. node.loc
  24049. );
  24050. };
  24051. };
  24052. function resolveComponentType(node, context, ssr = false) {
  24053. let { tag } = node;
  24054. const isExplicitDynamic = isComponentTag(tag);
  24055. const isProp = findProp(
  24056. node,
  24057. "is",
  24058. false,
  24059. true
  24060. /* allow empty */
  24061. );
  24062. if (isProp) {
  24063. if (isExplicitDynamic || false) {
  24064. let exp;
  24065. if (isProp.type === 6) {
  24066. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  24067. } else {
  24068. exp = isProp.exp;
  24069. if (!exp) {
  24070. exp = createSimpleExpression(`is`, false, isProp.arg.loc);
  24071. {
  24072. exp = isProp.exp = processExpression(exp, context);
  24073. }
  24074. }
  24075. }
  24076. if (exp) {
  24077. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  24078. exp
  24079. ]);
  24080. }
  24081. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  24082. tag = isProp.value.content.slice(4);
  24083. }
  24084. }
  24085. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  24086. if (builtIn) {
  24087. if (!ssr) context.helper(builtIn);
  24088. return builtIn;
  24089. }
  24090. {
  24091. const fromSetup = resolveSetupReference(tag, context);
  24092. if (fromSetup) {
  24093. return fromSetup;
  24094. }
  24095. const dotIndex = tag.indexOf(".");
  24096. if (dotIndex > 0) {
  24097. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  24098. if (ns) {
  24099. return ns + tag.slice(dotIndex);
  24100. }
  24101. }
  24102. }
  24103. if (context.selfName && capitalize(camelize(tag)) === context.selfName) {
  24104. context.helper(RESOLVE_COMPONENT);
  24105. context.components.add(tag + `__self`);
  24106. return toValidAssetId(tag, `component`);
  24107. }
  24108. context.helper(RESOLVE_COMPONENT);
  24109. context.components.add(tag);
  24110. return toValidAssetId(tag, `component`);
  24111. }
  24112. function resolveSetupReference(name, context) {
  24113. const bindings = context.bindingMetadata;
  24114. if (!bindings || bindings.__isScriptSetup === false) {
  24115. return;
  24116. }
  24117. const camelName = camelize(name);
  24118. const PascalName = capitalize(camelName);
  24119. const checkType = (type) => {
  24120. if (bindings[name] === type) {
  24121. return name;
  24122. }
  24123. if (bindings[camelName] === type) {
  24124. return camelName;
  24125. }
  24126. if (bindings[PascalName] === type) {
  24127. return PascalName;
  24128. }
  24129. };
  24130. const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
  24131. if (fromConst) {
  24132. return context.inline ? (
  24133. // in inline mode, const setup bindings (e.g. imports) can be used as-is
  24134. fromConst
  24135. ) : `$setup[${JSON.stringify(fromConst)}]`;
  24136. }
  24137. const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
  24138. if (fromMaybeRef) {
  24139. return context.inline ? (
  24140. // setup scope bindings that may be refs need to be unrefed
  24141. `${context.helperString(UNREF)}(${fromMaybeRef})`
  24142. ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  24143. }
  24144. const fromProps = checkType("props");
  24145. if (fromProps) {
  24146. return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
  24147. }
  24148. }
  24149. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  24150. const { tag, loc: elementLoc, children } = node;
  24151. let properties = [];
  24152. const mergeArgs = [];
  24153. const runtimeDirectives = [];
  24154. const hasChildren = children.length > 0;
  24155. let shouldUseBlock = false;
  24156. let patchFlag = 0;
  24157. let hasRef = false;
  24158. let hasClassBinding = false;
  24159. let hasStyleBinding = false;
  24160. let hasHydrationEventBinding = false;
  24161. let hasDynamicKeys = false;
  24162. let hasVnodeHook = false;
  24163. const dynamicPropNames = [];
  24164. const pushMergeArg = (arg) => {
  24165. if (properties.length) {
  24166. mergeArgs.push(
  24167. createObjectExpression(dedupeProperties(properties), elementLoc)
  24168. );
  24169. properties = [];
  24170. }
  24171. if (arg) mergeArgs.push(arg);
  24172. };
  24173. const pushRefVForMarker = () => {
  24174. if (context.scopes.vFor > 0) {
  24175. properties.push(
  24176. createObjectProperty(
  24177. createSimpleExpression("ref_for", true),
  24178. createSimpleExpression("true")
  24179. )
  24180. );
  24181. }
  24182. };
  24183. const analyzePatchFlag = ({ key, value }) => {
  24184. if (isStaticExp(key)) {
  24185. const name = key.content;
  24186. const isEventHandler = isOn(name);
  24187. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  24188. // dedicated fast path.
  24189. name.toLowerCase() !== "onclick" && // omit v-model handlers
  24190. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  24191. !isReservedProp(name)) {
  24192. hasHydrationEventBinding = true;
  24193. }
  24194. if (isEventHandler && isReservedProp(name)) {
  24195. hasVnodeHook = true;
  24196. }
  24197. if (isEventHandler && value.type === 14) {
  24198. value = value.arguments[0];
  24199. }
  24200. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  24201. return;
  24202. }
  24203. if (name === "ref") {
  24204. hasRef = true;
  24205. } else if (name === "class") {
  24206. hasClassBinding = true;
  24207. } else if (name === "style") {
  24208. hasStyleBinding = true;
  24209. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  24210. dynamicPropNames.push(name);
  24211. }
  24212. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  24213. dynamicPropNames.push(name);
  24214. }
  24215. } else {
  24216. hasDynamicKeys = true;
  24217. }
  24218. };
  24219. for (let i = 0; i < props.length; i++) {
  24220. const prop = props[i];
  24221. if (prop.type === 6) {
  24222. const { loc, name, nameLoc, value } = prop;
  24223. let isStatic = true;
  24224. if (name === "ref") {
  24225. hasRef = true;
  24226. pushRefVForMarker();
  24227. if (value && context.inline) {
  24228. const binding = context.bindingMetadata[value.content];
  24229. if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
  24230. isStatic = false;
  24231. properties.push(
  24232. createObjectProperty(
  24233. createSimpleExpression("ref_key", true),
  24234. createSimpleExpression(value.content, true, value.loc)
  24235. )
  24236. );
  24237. }
  24238. }
  24239. }
  24240. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  24241. continue;
  24242. }
  24243. properties.push(
  24244. createObjectProperty(
  24245. createSimpleExpression(name, true, nameLoc),
  24246. createSimpleExpression(
  24247. value ? value.content : "",
  24248. isStatic,
  24249. value ? value.loc : loc
  24250. )
  24251. )
  24252. );
  24253. } else {
  24254. const { name, arg, exp, loc, modifiers } = prop;
  24255. const isVBind = name === "bind";
  24256. const isVOn = name === "on";
  24257. if (name === "slot") {
  24258. if (!isComponent) {
  24259. context.onError(
  24260. createCompilerError(40, loc)
  24261. );
  24262. }
  24263. continue;
  24264. }
  24265. if (name === "once" || name === "memo") {
  24266. continue;
  24267. }
  24268. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  24269. continue;
  24270. }
  24271. if (isVOn && ssr) {
  24272. continue;
  24273. }
  24274. if (
  24275. // #938: elements with dynamic keys should be forced into blocks
  24276. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  24277. // before children
  24278. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  24279. ) {
  24280. shouldUseBlock = true;
  24281. }
  24282. if (isVBind && isStaticArgOf(arg, "ref")) {
  24283. pushRefVForMarker();
  24284. }
  24285. if (!arg && (isVBind || isVOn)) {
  24286. hasDynamicKeys = true;
  24287. if (exp) {
  24288. if (isVBind) {
  24289. pushRefVForMarker();
  24290. pushMergeArg();
  24291. mergeArgs.push(exp);
  24292. } else {
  24293. pushMergeArg({
  24294. type: 14,
  24295. loc,
  24296. callee: context.helper(TO_HANDLERS),
  24297. arguments: isComponent ? [exp] : [exp, `true`]
  24298. });
  24299. }
  24300. } else {
  24301. context.onError(
  24302. createCompilerError(
  24303. isVBind ? 34 : 35,
  24304. loc
  24305. )
  24306. );
  24307. }
  24308. continue;
  24309. }
  24310. if (isVBind && modifiers.some((mod) => mod.content === "prop")) {
  24311. patchFlag |= 32;
  24312. }
  24313. const directiveTransform = context.directiveTransforms[name];
  24314. if (directiveTransform) {
  24315. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  24316. !ssr && props2.forEach(analyzePatchFlag);
  24317. if (isVOn && arg && !isStaticExp(arg)) {
  24318. pushMergeArg(createObjectExpression(props2, elementLoc));
  24319. } else {
  24320. properties.push(...props2);
  24321. }
  24322. if (needRuntime) {
  24323. runtimeDirectives.push(prop);
  24324. if (isSymbol$1(needRuntime)) {
  24325. directiveImportMap.set(prop, needRuntime);
  24326. }
  24327. }
  24328. } else if (!isBuiltInDirective(name)) {
  24329. runtimeDirectives.push(prop);
  24330. if (hasChildren) {
  24331. shouldUseBlock = true;
  24332. }
  24333. }
  24334. }
  24335. }
  24336. let propsExpression = void 0;
  24337. if (mergeArgs.length) {
  24338. pushMergeArg();
  24339. if (mergeArgs.length > 1) {
  24340. propsExpression = createCallExpression(
  24341. context.helper(MERGE_PROPS),
  24342. mergeArgs,
  24343. elementLoc
  24344. );
  24345. } else {
  24346. propsExpression = mergeArgs[0];
  24347. }
  24348. } else if (properties.length) {
  24349. propsExpression = createObjectExpression(
  24350. dedupeProperties(properties),
  24351. elementLoc
  24352. );
  24353. }
  24354. if (hasDynamicKeys) {
  24355. patchFlag |= 16;
  24356. } else {
  24357. if (hasClassBinding && !isComponent) {
  24358. patchFlag |= 2;
  24359. }
  24360. if (hasStyleBinding && !isComponent) {
  24361. patchFlag |= 4;
  24362. }
  24363. if (dynamicPropNames.length) {
  24364. patchFlag |= 8;
  24365. }
  24366. if (hasHydrationEventBinding) {
  24367. patchFlag |= 32;
  24368. }
  24369. }
  24370. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  24371. patchFlag |= 512;
  24372. }
  24373. if (!context.inSSR && propsExpression) {
  24374. switch (propsExpression.type) {
  24375. case 15:
  24376. let classKeyIndex = -1;
  24377. let styleKeyIndex = -1;
  24378. let hasDynamicKey = false;
  24379. for (let i = 0; i < propsExpression.properties.length; i++) {
  24380. const key = propsExpression.properties[i].key;
  24381. if (isStaticExp(key)) {
  24382. if (key.content === "class") {
  24383. classKeyIndex = i;
  24384. } else if (key.content === "style") {
  24385. styleKeyIndex = i;
  24386. }
  24387. } else if (!key.isHandlerKey) {
  24388. hasDynamicKey = true;
  24389. }
  24390. }
  24391. const classProp = propsExpression.properties[classKeyIndex];
  24392. const styleProp = propsExpression.properties[styleKeyIndex];
  24393. if (!hasDynamicKey) {
  24394. if (classProp && !isStaticExp(classProp.value)) {
  24395. classProp.value = createCallExpression(
  24396. context.helper(NORMALIZE_CLASS),
  24397. [classProp.value]
  24398. );
  24399. }
  24400. if (styleProp && // the static style is compiled into an object,
  24401. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  24402. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  24403. // v-bind:style with static literal object
  24404. styleProp.value.type === 17)) {
  24405. styleProp.value = createCallExpression(
  24406. context.helper(NORMALIZE_STYLE),
  24407. [styleProp.value]
  24408. );
  24409. }
  24410. } else {
  24411. propsExpression = createCallExpression(
  24412. context.helper(NORMALIZE_PROPS),
  24413. [propsExpression]
  24414. );
  24415. }
  24416. break;
  24417. case 14:
  24418. break;
  24419. default:
  24420. propsExpression = createCallExpression(
  24421. context.helper(NORMALIZE_PROPS),
  24422. [
  24423. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  24424. propsExpression
  24425. ])
  24426. ]
  24427. );
  24428. break;
  24429. }
  24430. }
  24431. return {
  24432. props: propsExpression,
  24433. directives: runtimeDirectives,
  24434. patchFlag,
  24435. dynamicPropNames,
  24436. shouldUseBlock
  24437. };
  24438. }
  24439. function dedupeProperties(properties) {
  24440. const knownProps = /* @__PURE__ */ new Map();
  24441. const deduped = [];
  24442. for (let i = 0; i < properties.length; i++) {
  24443. const prop = properties[i];
  24444. if (prop.key.type === 8 || !prop.key.isStatic) {
  24445. deduped.push(prop);
  24446. continue;
  24447. }
  24448. const name = prop.key.content;
  24449. const existing = knownProps.get(name);
  24450. if (existing) {
  24451. if (name === "style" || name === "class" || isOn(name)) {
  24452. mergeAsArray(existing, prop);
  24453. }
  24454. } else {
  24455. knownProps.set(name, prop);
  24456. deduped.push(prop);
  24457. }
  24458. }
  24459. return deduped;
  24460. }
  24461. function mergeAsArray(existing, incoming) {
  24462. if (existing.value.type === 17) {
  24463. existing.value.elements.push(incoming.value);
  24464. } else {
  24465. existing.value = createArrayExpression(
  24466. [existing.value, incoming.value],
  24467. existing.loc
  24468. );
  24469. }
  24470. }
  24471. function buildDirectiveArgs(dir, context) {
  24472. const dirArgs = [];
  24473. const runtime = directiveImportMap.get(dir);
  24474. if (runtime) {
  24475. dirArgs.push(context.helperString(runtime));
  24476. } else {
  24477. const fromSetup = resolveSetupReference("v-" + dir.name, context);
  24478. if (fromSetup) {
  24479. dirArgs.push(fromSetup);
  24480. } else {
  24481. context.helper(RESOLVE_DIRECTIVE);
  24482. context.directives.add(dir.name);
  24483. dirArgs.push(toValidAssetId(dir.name, `directive`));
  24484. }
  24485. }
  24486. const { loc } = dir;
  24487. if (dir.exp) dirArgs.push(dir.exp);
  24488. if (dir.arg) {
  24489. if (!dir.exp) {
  24490. dirArgs.push(`void 0`);
  24491. }
  24492. dirArgs.push(dir.arg);
  24493. }
  24494. if (Object.keys(dir.modifiers).length) {
  24495. if (!dir.arg) {
  24496. if (!dir.exp) {
  24497. dirArgs.push(`void 0`);
  24498. }
  24499. dirArgs.push(`void 0`);
  24500. }
  24501. const trueExpression = createSimpleExpression(`true`, false, loc);
  24502. dirArgs.push(
  24503. createObjectExpression(
  24504. dir.modifiers.map(
  24505. (modifier) => createObjectProperty(modifier, trueExpression)
  24506. ),
  24507. loc
  24508. )
  24509. );
  24510. }
  24511. return createArrayExpression(dirArgs, dir.loc);
  24512. }
  24513. function stringifyDynamicPropNames(props) {
  24514. let propsNamesString = `[`;
  24515. for (let i = 0, l = props.length; i < l; i++) {
  24516. propsNamesString += JSON.stringify(props[i]);
  24517. if (i < l - 1) propsNamesString += ", ";
  24518. }
  24519. return propsNamesString + `]`;
  24520. }
  24521. function isComponentTag(tag) {
  24522. return tag === "component" || tag === "Component";
  24523. }
  24524. const transformSlotOutlet = (node, context) => {
  24525. if (isSlotOutlet(node)) {
  24526. const { children, loc } = node;
  24527. const { slotName, slotProps } = processSlotOutlet(node, context);
  24528. const slotArgs = [
  24529. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  24530. slotName,
  24531. "{}",
  24532. "undefined",
  24533. "true"
  24534. ];
  24535. let expectedLen = 2;
  24536. if (slotProps) {
  24537. slotArgs[2] = slotProps;
  24538. expectedLen = 3;
  24539. }
  24540. if (children.length) {
  24541. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  24542. expectedLen = 4;
  24543. }
  24544. if (context.scopeId && !context.slotted) {
  24545. expectedLen = 5;
  24546. }
  24547. slotArgs.splice(expectedLen);
  24548. node.codegenNode = createCallExpression(
  24549. context.helper(RENDER_SLOT),
  24550. slotArgs,
  24551. loc
  24552. );
  24553. }
  24554. };
  24555. function processSlotOutlet(node, context) {
  24556. let slotName = `"default"`;
  24557. let slotProps = void 0;
  24558. const nonNameProps = [];
  24559. for (let i = 0; i < node.props.length; i++) {
  24560. const p = node.props[i];
  24561. if (p.type === 6) {
  24562. if (p.value) {
  24563. if (p.name === "name") {
  24564. slotName = JSON.stringify(p.value.content);
  24565. } else {
  24566. p.name = camelize(p.name);
  24567. nonNameProps.push(p);
  24568. }
  24569. }
  24570. } else {
  24571. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  24572. if (p.exp) {
  24573. slotName = p.exp;
  24574. } else if (p.arg && p.arg.type === 4) {
  24575. const name = camelize(p.arg.content);
  24576. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  24577. {
  24578. slotName = p.exp = processExpression(p.exp, context);
  24579. }
  24580. }
  24581. } else {
  24582. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  24583. p.arg.content = camelize(p.arg.content);
  24584. }
  24585. nonNameProps.push(p);
  24586. }
  24587. }
  24588. }
  24589. if (nonNameProps.length > 0) {
  24590. const { props, directives } = buildProps(
  24591. node,
  24592. context,
  24593. nonNameProps,
  24594. false,
  24595. false
  24596. );
  24597. slotProps = props;
  24598. if (directives.length) {
  24599. context.onError(
  24600. createCompilerError(
  24601. 36,
  24602. directives[0].loc
  24603. )
  24604. );
  24605. }
  24606. }
  24607. return {
  24608. slotName,
  24609. slotProps
  24610. };
  24611. }
  24612. const transformOn$1 = (dir, node, context, augmentor) => {
  24613. const { loc, modifiers, arg } = dir;
  24614. if (!dir.exp && !modifiers.length) {
  24615. context.onError(createCompilerError(35, loc));
  24616. }
  24617. let eventName;
  24618. if (arg.type === 4) {
  24619. if (arg.isStatic) {
  24620. let rawName = arg.content;
  24621. if (rawName.startsWith("vnode")) {
  24622. context.onError(createCompilerError(51, arg.loc));
  24623. }
  24624. if (rawName.startsWith("vue:")) {
  24625. rawName = `vnode-${rawName.slice(4)}`;
  24626. }
  24627. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  24628. // for non-element and vnode lifecycle event listeners, auto convert
  24629. // it to camelCase. See issue #2249
  24630. toHandlerKey(camelize(rawName))
  24631. ) : (
  24632. // preserve case for plain element listeners that have uppercase
  24633. // letters, as these may be custom elements' custom events
  24634. `on:${rawName}`
  24635. );
  24636. eventName = createSimpleExpression(eventString, true, arg.loc);
  24637. } else {
  24638. eventName = createCompoundExpression([
  24639. `${context.helperString(TO_HANDLER_KEY)}(`,
  24640. arg,
  24641. `)`
  24642. ]);
  24643. }
  24644. } else {
  24645. eventName = arg;
  24646. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  24647. eventName.children.push(`)`);
  24648. }
  24649. let exp = dir.exp;
  24650. if (exp && !exp.content.trim()) {
  24651. exp = void 0;
  24652. }
  24653. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  24654. if (exp) {
  24655. const isMemberExp = isMemberExpression(exp, context);
  24656. const isInlineStatement = !(isMemberExp || isFnExpression(exp, context));
  24657. const hasMultipleStatements = exp.content.includes(`;`);
  24658. if (context.prefixIdentifiers) {
  24659. isInlineStatement && context.addIdentifiers(`$event`);
  24660. exp = dir.exp = processExpression(
  24661. exp,
  24662. context,
  24663. false,
  24664. hasMultipleStatements
  24665. );
  24666. isInlineStatement && context.removeIdentifiers(`$event`);
  24667. shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
  24668. !context.inVOnce && // runtime constants don't need to be cached
  24669. // (this is analyzed by compileScript in SFC <script setup>)
  24670. !(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
  24671. // we need to use the original function to preserve arity,
  24672. // e.g. <transition> relies on checking cb.length to determine
  24673. // transition end handling. Inline function is ok since its arity
  24674. // is preserved even when cached.
  24675. !(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
  24676. // it must be passed fresh to avoid stale values.
  24677. !hasScopeRef(exp, context.identifiers);
  24678. if (shouldCache && isMemberExp) {
  24679. if (exp.type === 4) {
  24680. exp.content = `${exp.content} && ${exp.content}(...args)`;
  24681. } else {
  24682. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  24683. }
  24684. }
  24685. }
  24686. if (isInlineStatement || shouldCache && isMemberExp) {
  24687. exp = createCompoundExpression([
  24688. `${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
  24689. //@ts-ignore
  24690. ` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  24691. exp,
  24692. hasMultipleStatements ? `}` : `)`
  24693. ]);
  24694. }
  24695. }
  24696. let ret = {
  24697. props: [
  24698. createObjectProperty(
  24699. eventName,
  24700. exp || createSimpleExpression(`() => {}`, false, loc)
  24701. )
  24702. ]
  24703. };
  24704. if (augmentor) {
  24705. ret = augmentor(ret);
  24706. }
  24707. if (shouldCache) {
  24708. ret.props[0].value = context.cache(ret.props[0].value);
  24709. }
  24710. ret.props.forEach((p) => p.key.isHandlerKey = true);
  24711. return ret;
  24712. };
  24713. const transformBind = (dir, _node, context) => {
  24714. const { modifiers, loc } = dir;
  24715. const arg = dir.arg;
  24716. let { exp } = dir;
  24717. if (exp && exp.type === 4 && !exp.content.trim()) {
  24718. {
  24719. context.onError(
  24720. createCompilerError(34, loc)
  24721. );
  24722. return {
  24723. props: [
  24724. createObjectProperty(arg, createSimpleExpression("", true, loc))
  24725. ]
  24726. };
  24727. }
  24728. }
  24729. if (arg.type !== 4) {
  24730. arg.children.unshift(`(`);
  24731. arg.children.push(`) || ""`);
  24732. } else if (!arg.isStatic) {
  24733. arg.content = arg.content ? `${arg.content} || ""` : `""`;
  24734. }
  24735. if (modifiers.some((mod) => mod.content === "camel")) {
  24736. if (arg.type === 4) {
  24737. if (arg.isStatic) {
  24738. arg.content = camelize(arg.content);
  24739. } else {
  24740. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  24741. }
  24742. } else {
  24743. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  24744. arg.children.push(`)`);
  24745. }
  24746. }
  24747. if (!context.inSSR) {
  24748. if (modifiers.some((mod) => mod.content === "prop")) {
  24749. injectPrefix(arg, ".");
  24750. }
  24751. if (modifiers.some((mod) => mod.content === "attr")) {
  24752. injectPrefix(arg, "^");
  24753. }
  24754. }
  24755. return {
  24756. props: [createObjectProperty(arg, exp)]
  24757. };
  24758. };
  24759. const injectPrefix = (arg, prefix) => {
  24760. if (arg.type === 4) {
  24761. if (arg.isStatic) {
  24762. arg.content = prefix + arg.content;
  24763. } else {
  24764. arg.content = `\`${prefix}\${${arg.content}}\``;
  24765. }
  24766. } else {
  24767. arg.children.unshift(`'${prefix}' + (`);
  24768. arg.children.push(`)`);
  24769. }
  24770. };
  24771. const transformText = (node, context) => {
  24772. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  24773. return () => {
  24774. const children = node.children;
  24775. let currentContainer = void 0;
  24776. let hasText = false;
  24777. for (let i = 0; i < children.length; i++) {
  24778. const child = children[i];
  24779. if (isText$1(child)) {
  24780. hasText = true;
  24781. for (let j = i + 1; j < children.length; j++) {
  24782. const next = children[j];
  24783. if (isText$1(next)) {
  24784. if (!currentContainer) {
  24785. currentContainer = children[i] = createCompoundExpression(
  24786. [child],
  24787. child.loc
  24788. );
  24789. }
  24790. currentContainer.children.push(` + `, next);
  24791. children.splice(j, 1);
  24792. j--;
  24793. } else {
  24794. currentContainer = void 0;
  24795. break;
  24796. }
  24797. }
  24798. }
  24799. }
  24800. if (!hasText || // if this is a plain element with a single text child, leave it
  24801. // as-is since the runtime has dedicated fast path for this by directly
  24802. // setting textContent of the element.
  24803. // for component root it's always normalized anyway.
  24804. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  24805. // custom directives can potentially add DOM elements arbitrarily,
  24806. // we need to avoid setting textContent of the element at runtime
  24807. // to avoid accidentally overwriting the DOM elements added
  24808. // by the user through custom directives.
  24809. !node.props.find(
  24810. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  24811. ) && // in compat mode, <template> tags with no special directives
  24812. // will be rendered as a fragment so its children must be
  24813. // converted into vnodes.
  24814. true)) {
  24815. return;
  24816. }
  24817. for (let i = 0; i < children.length; i++) {
  24818. const child = children[i];
  24819. if (isText$1(child) || child.type === 8) {
  24820. const callArgs = [];
  24821. if (child.type !== 2 || child.content !== " ") {
  24822. callArgs.push(child);
  24823. }
  24824. if (!context.ssr && getConstantType(child, context) === 0) {
  24825. callArgs.push(
  24826. 1 + (` /* ${PatchFlagNames[1]} */` )
  24827. );
  24828. }
  24829. children[i] = {
  24830. type: 12,
  24831. content: child,
  24832. loc: child.loc,
  24833. codegenNode: createCallExpression(
  24834. context.helper(CREATE_TEXT),
  24835. callArgs
  24836. )
  24837. };
  24838. }
  24839. }
  24840. };
  24841. }
  24842. };
  24843. const seen$1 = /* @__PURE__ */ new WeakSet();
  24844. const transformOnce = (node, context) => {
  24845. if (node.type === 1 && findDir(node, "once", true)) {
  24846. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  24847. return;
  24848. }
  24849. seen$1.add(node);
  24850. context.inVOnce = true;
  24851. context.helper(SET_BLOCK_TRACKING);
  24852. return () => {
  24853. context.inVOnce = false;
  24854. const cur = context.currentNode;
  24855. if (cur.codegenNode) {
  24856. cur.codegenNode = context.cache(
  24857. cur.codegenNode,
  24858. true,
  24859. true
  24860. );
  24861. }
  24862. };
  24863. }
  24864. };
  24865. const transformModel$1 = (dir, node, context) => {
  24866. const { exp, arg } = dir;
  24867. if (!exp) {
  24868. context.onError(
  24869. createCompilerError(41, dir.loc)
  24870. );
  24871. return createTransformProps();
  24872. }
  24873. const rawExp = exp.loc.source.trim();
  24874. const expString = exp.type === 4 ? exp.content : rawExp;
  24875. const bindingType = context.bindingMetadata[rawExp];
  24876. if (bindingType === "props" || bindingType === "props-aliased") {
  24877. context.onError(createCompilerError(44, exp.loc));
  24878. return createTransformProps();
  24879. }
  24880. const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
  24881. if (!expString.trim() || !isMemberExpression(exp, context) && !maybeRef) {
  24882. context.onError(
  24883. createCompilerError(42, exp.loc)
  24884. );
  24885. return createTransformProps();
  24886. }
  24887. if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
  24888. context.onError(
  24889. createCompilerError(43, exp.loc)
  24890. );
  24891. return createTransformProps();
  24892. }
  24893. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  24894. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  24895. let assignmentExp;
  24896. const eventArg = context.isTS ? `($event: any)` : `$event`;
  24897. if (maybeRef) {
  24898. if (bindingType === "setup-ref") {
  24899. assignmentExp = createCompoundExpression([
  24900. `${eventArg} => ((`,
  24901. createSimpleExpression(rawExp, false, exp.loc),
  24902. `).value = $event)`
  24903. ]);
  24904. } else {
  24905. const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
  24906. assignmentExp = createCompoundExpression([
  24907. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
  24908. createSimpleExpression(rawExp, false, exp.loc),
  24909. `).value = $event : ${altAssignment})`
  24910. ]);
  24911. }
  24912. } else {
  24913. assignmentExp = createCompoundExpression([
  24914. `${eventArg} => ((`,
  24915. exp,
  24916. `) = $event)`
  24917. ]);
  24918. }
  24919. const props = [
  24920. // modelValue: foo
  24921. createObjectProperty(propName, dir.exp),
  24922. // "onUpdate:modelValue": $event => (foo = $event)
  24923. createObjectProperty(eventName, assignmentExp)
  24924. ];
  24925. if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
  24926. props[1].value = context.cache(props[1].value);
  24927. }
  24928. if (dir.modifiers.length && node.tagType === 1) {
  24929. const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  24930. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  24931. props.push(
  24932. createObjectProperty(
  24933. modifiersKey,
  24934. createSimpleExpression(
  24935. `{ ${modifiers} }`,
  24936. false,
  24937. dir.loc,
  24938. 2
  24939. )
  24940. )
  24941. );
  24942. }
  24943. return createTransformProps(props);
  24944. };
  24945. function createTransformProps(props = []) {
  24946. return { props };
  24947. }
  24948. const seen = /* @__PURE__ */ new WeakSet();
  24949. const transformMemo = (node, context) => {
  24950. if (node.type === 1) {
  24951. const dir = findDir(node, "memo");
  24952. if (!dir || seen.has(node) || context.inSSR) {
  24953. return;
  24954. }
  24955. seen.add(node);
  24956. return () => {
  24957. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  24958. if (codegenNode && codegenNode.type === 13) {
  24959. if (node.tagType !== 1) {
  24960. convertToBlock(codegenNode, context);
  24961. }
  24962. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  24963. dir.exp,
  24964. createFunctionExpression(void 0, codegenNode),
  24965. `_cache`,
  24966. String(context.cached.length)
  24967. ]);
  24968. context.cached.push(null);
  24969. }
  24970. };
  24971. }
  24972. };
  24973. const transformVBindShorthand = (node, context) => {
  24974. if (node.type === 1) {
  24975. for (const prop of node.props) {
  24976. if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
  24977. const arg = prop.arg;
  24978. if (arg.type !== 4 || !arg.isStatic) {
  24979. context.onError(
  24980. createCompilerError(
  24981. 52,
  24982. arg.loc
  24983. )
  24984. );
  24985. prop.exp = createSimpleExpression("", true, arg.loc);
  24986. } else {
  24987. const propName = camelize(arg.content);
  24988. if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
  24989. propName[0] === "-") {
  24990. prop.exp = createSimpleExpression(propName, false, arg.loc);
  24991. }
  24992. }
  24993. }
  24994. }
  24995. }
  24996. };
  24997. function getBaseTransformPreset(prefixIdentifiers) {
  24998. return [
  24999. [
  25000. transformVBindShorthand,
  25001. transformOnce,
  25002. transformIf,
  25003. transformMemo,
  25004. transformFor,
  25005. ...[],
  25006. ...prefixIdentifiers ? [
  25007. // order is important
  25008. trackVForSlotScopes,
  25009. transformExpression
  25010. ] : [],
  25011. transformSlotOutlet,
  25012. transformElement,
  25013. trackSlotScopes,
  25014. transformText
  25015. ],
  25016. {
  25017. on: transformOn$1,
  25018. bind: transformBind,
  25019. model: transformModel$1
  25020. }
  25021. ];
  25022. }
  25023. function baseCompile(source, options = {}) {
  25024. const onError = options.onError || defaultOnError;
  25025. const isModuleMode = options.mode === "module";
  25026. const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
  25027. if (!prefixIdentifiers && options.cacheHandlers) {
  25028. onError(createCompilerError(49));
  25029. }
  25030. if (options.scopeId && !isModuleMode) {
  25031. onError(createCompilerError(50));
  25032. }
  25033. const resolvedOptions = extend({}, options, {
  25034. prefixIdentifiers
  25035. });
  25036. const ast = isString$1(source) ? baseParse(source, resolvedOptions) : source;
  25037. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  25038. if (options.isTS) {
  25039. const { expressionPlugins } = options;
  25040. if (!expressionPlugins || !expressionPlugins.includes("typescript")) {
  25041. options.expressionPlugins = [...expressionPlugins || [], "typescript"];
  25042. }
  25043. }
  25044. transform(
  25045. ast,
  25046. extend({}, resolvedOptions, {
  25047. nodeTransforms: [
  25048. ...nodeTransforms,
  25049. ...options.nodeTransforms || []
  25050. // user transforms
  25051. ],
  25052. directiveTransforms: extend(
  25053. {},
  25054. directiveTransforms,
  25055. options.directiveTransforms || {}
  25056. // user transforms
  25057. )
  25058. })
  25059. );
  25060. return generate(ast, resolvedOptions);
  25061. }
  25062. const BindingTypes = {
  25063. "DATA": "data",
  25064. "PROPS": "props",
  25065. "PROPS_ALIASED": "props-aliased",
  25066. "SETUP_LET": "setup-let",
  25067. "SETUP_CONST": "setup-const",
  25068. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  25069. "SETUP_MAYBE_REF": "setup-maybe-ref",
  25070. "SETUP_REF": "setup-ref",
  25071. "OPTIONS": "options",
  25072. "LITERAL_CONST": "literal-const"
  25073. };
  25074. const noopDirectiveTransform = () => ({ props: [] });
  25075. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  25076. const V_MODEL_CHECKBOX = Symbol(
  25077. `vModelCheckbox`
  25078. );
  25079. const V_MODEL_TEXT = Symbol(`vModelText` );
  25080. const V_MODEL_SELECT = Symbol(
  25081. `vModelSelect`
  25082. );
  25083. const V_MODEL_DYNAMIC = Symbol(
  25084. `vModelDynamic`
  25085. );
  25086. const V_ON_WITH_MODIFIERS = Symbol(
  25087. `vOnModifiersGuard`
  25088. );
  25089. const V_ON_WITH_KEYS = Symbol(
  25090. `vOnKeysGuard`
  25091. );
  25092. const V_SHOW = Symbol(`vShow` );
  25093. const TRANSITION = Symbol(`Transition` );
  25094. const TRANSITION_GROUP = Symbol(
  25095. `TransitionGroup`
  25096. );
  25097. registerRuntimeHelpers({
  25098. [V_MODEL_RADIO]: `vModelRadio`,
  25099. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  25100. [V_MODEL_TEXT]: `vModelText`,
  25101. [V_MODEL_SELECT]: `vModelSelect`,
  25102. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  25103. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  25104. [V_ON_WITH_KEYS]: `withKeys`,
  25105. [V_SHOW]: `vShow`,
  25106. [TRANSITION]: `Transition`,
  25107. [TRANSITION_GROUP]: `TransitionGroup`
  25108. });
  25109. const parserOptions = {
  25110. parseMode: "html",
  25111. isVoidTag,
  25112. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  25113. isPreTag: (tag) => tag === "pre",
  25114. isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
  25115. decodeEntities: void 0,
  25116. isBuiltInComponent: (tag) => {
  25117. if (tag === "Transition" || tag === "transition") {
  25118. return TRANSITION;
  25119. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  25120. return TRANSITION_GROUP;
  25121. }
  25122. },
  25123. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  25124. getNamespace(tag, parent, rootNamespace) {
  25125. let ns = parent ? parent.ns : rootNamespace;
  25126. if (parent && ns === 2) {
  25127. if (parent.tag === "annotation-xml") {
  25128. if (tag === "svg") {
  25129. return 1;
  25130. }
  25131. if (parent.props.some(
  25132. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  25133. )) {
  25134. ns = 0;
  25135. }
  25136. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  25137. ns = 0;
  25138. }
  25139. } else if (parent && ns === 1) {
  25140. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  25141. ns = 0;
  25142. }
  25143. }
  25144. if (ns === 0) {
  25145. if (tag === "svg") {
  25146. return 1;
  25147. }
  25148. if (tag === "math") {
  25149. return 2;
  25150. }
  25151. }
  25152. return ns;
  25153. }
  25154. };
  25155. const transformStyle = (node) => {
  25156. if (node.type === 1) {
  25157. node.props.forEach((p, i) => {
  25158. if (p.type === 6 && p.name === "style" && p.value) {
  25159. node.props[i] = {
  25160. type: 7,
  25161. name: `bind`,
  25162. arg: createSimpleExpression(`style`, true, p.loc),
  25163. exp: parseInlineCSS(p.value.content, p.loc),
  25164. modifiers: [],
  25165. loc: p.loc
  25166. };
  25167. }
  25168. });
  25169. }
  25170. };
  25171. const parseInlineCSS = (cssText, loc) => {
  25172. const normalized = parseStringStyle(cssText);
  25173. return createSimpleExpression(
  25174. JSON.stringify(normalized),
  25175. false,
  25176. loc,
  25177. 3
  25178. );
  25179. };
  25180. function createDOMCompilerError(code, loc) {
  25181. return createCompilerError(
  25182. code,
  25183. loc,
  25184. DOMErrorMessages
  25185. );
  25186. }
  25187. const DOMErrorCodes = {
  25188. "X_V_HTML_NO_EXPRESSION": 53,
  25189. "53": "X_V_HTML_NO_EXPRESSION",
  25190. "X_V_HTML_WITH_CHILDREN": 54,
  25191. "54": "X_V_HTML_WITH_CHILDREN",
  25192. "X_V_TEXT_NO_EXPRESSION": 55,
  25193. "55": "X_V_TEXT_NO_EXPRESSION",
  25194. "X_V_TEXT_WITH_CHILDREN": 56,
  25195. "56": "X_V_TEXT_WITH_CHILDREN",
  25196. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  25197. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  25198. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  25199. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  25200. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  25201. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  25202. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  25203. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  25204. "X_V_SHOW_NO_EXPRESSION": 61,
  25205. "61": "X_V_SHOW_NO_EXPRESSION",
  25206. "X_TRANSITION_INVALID_CHILDREN": 62,
  25207. "62": "X_TRANSITION_INVALID_CHILDREN",
  25208. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  25209. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  25210. "__EXTEND_POINT__": 64,
  25211. "64": "__EXTEND_POINT__"
  25212. };
  25213. const DOMErrorMessages = {
  25214. [53]: `v-html is missing expression.`,
  25215. [54]: `v-html will override element children.`,
  25216. [55]: `v-text is missing expression.`,
  25217. [56]: `v-text will override element children.`,
  25218. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  25219. [58]: `v-model argument is not supported on plain elements.`,
  25220. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  25221. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  25222. [61]: `v-show is missing expression.`,
  25223. [62]: `<Transition> expects exactly one child element or component.`,
  25224. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  25225. };
  25226. const transformVHtml = (dir, node, context) => {
  25227. const { exp, loc } = dir;
  25228. if (!exp) {
  25229. context.onError(
  25230. createDOMCompilerError(53, loc)
  25231. );
  25232. }
  25233. if (node.children.length) {
  25234. context.onError(
  25235. createDOMCompilerError(54, loc)
  25236. );
  25237. node.children.length = 0;
  25238. }
  25239. return {
  25240. props: [
  25241. createObjectProperty(
  25242. createSimpleExpression(`innerHTML`, true, loc),
  25243. exp || createSimpleExpression("", true)
  25244. )
  25245. ]
  25246. };
  25247. };
  25248. const transformVText = (dir, node, context) => {
  25249. const { exp, loc } = dir;
  25250. if (!exp) {
  25251. context.onError(
  25252. createDOMCompilerError(55, loc)
  25253. );
  25254. }
  25255. if (node.children.length) {
  25256. context.onError(
  25257. createDOMCompilerError(56, loc)
  25258. );
  25259. node.children.length = 0;
  25260. }
  25261. return {
  25262. props: [
  25263. createObjectProperty(
  25264. createSimpleExpression(`textContent`, true),
  25265. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  25266. context.helperString(TO_DISPLAY_STRING),
  25267. [exp],
  25268. loc
  25269. ) : createSimpleExpression("", true)
  25270. )
  25271. ]
  25272. };
  25273. };
  25274. const transformModel = (dir, node, context) => {
  25275. const baseResult = transformModel$1(dir, node, context);
  25276. if (!baseResult.props.length || node.tagType === 1) {
  25277. return baseResult;
  25278. }
  25279. if (dir.arg) {
  25280. context.onError(
  25281. createDOMCompilerError(
  25282. 58,
  25283. dir.arg.loc
  25284. )
  25285. );
  25286. }
  25287. function checkDuplicatedValue() {
  25288. const value = findDir(node, "bind");
  25289. if (value && isStaticArgOf(value.arg, "value")) {
  25290. context.onError(
  25291. createDOMCompilerError(
  25292. 60,
  25293. value.loc
  25294. )
  25295. );
  25296. }
  25297. }
  25298. const { tag } = node;
  25299. const isCustomElement = context.isCustomElement(tag);
  25300. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  25301. let directiveToUse = V_MODEL_TEXT;
  25302. let isInvalidType = false;
  25303. if (tag === "input" || isCustomElement) {
  25304. const type = findProp(node, `type`);
  25305. if (type) {
  25306. if (type.type === 7) {
  25307. directiveToUse = V_MODEL_DYNAMIC;
  25308. } else if (type.value) {
  25309. switch (type.value.content) {
  25310. case "radio":
  25311. directiveToUse = V_MODEL_RADIO;
  25312. break;
  25313. case "checkbox":
  25314. directiveToUse = V_MODEL_CHECKBOX;
  25315. break;
  25316. case "file":
  25317. isInvalidType = true;
  25318. context.onError(
  25319. createDOMCompilerError(
  25320. 59,
  25321. dir.loc
  25322. )
  25323. );
  25324. break;
  25325. default:
  25326. checkDuplicatedValue();
  25327. break;
  25328. }
  25329. }
  25330. } else if (hasDynamicKeyVBind(node)) {
  25331. directiveToUse = V_MODEL_DYNAMIC;
  25332. } else {
  25333. checkDuplicatedValue();
  25334. }
  25335. } else if (tag === "select") {
  25336. directiveToUse = V_MODEL_SELECT;
  25337. } else {
  25338. checkDuplicatedValue();
  25339. }
  25340. if (!isInvalidType) {
  25341. baseResult.needRuntime = context.helper(directiveToUse);
  25342. }
  25343. } else {
  25344. context.onError(
  25345. createDOMCompilerError(
  25346. 57,
  25347. dir.loc
  25348. )
  25349. );
  25350. }
  25351. baseResult.props = baseResult.props.filter(
  25352. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  25353. );
  25354. return baseResult;
  25355. };
  25356. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  25357. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  25358. // event propagation management
  25359. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  25360. );
  25361. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  25362. const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
  25363. const resolveModifiers = (key, modifiers, context, loc) => {
  25364. const keyModifiers = [];
  25365. const nonKeyModifiers = [];
  25366. const eventOptionModifiers = [];
  25367. for (let i = 0; i < modifiers.length; i++) {
  25368. const modifier = modifiers[i].content;
  25369. if (isEventOptionModifier(modifier)) {
  25370. eventOptionModifiers.push(modifier);
  25371. } else {
  25372. if (maybeKeyModifier(modifier)) {
  25373. if (isStaticExp(key)) {
  25374. if (isKeyboardEvent(key.content.toLowerCase())) {
  25375. keyModifiers.push(modifier);
  25376. } else {
  25377. nonKeyModifiers.push(modifier);
  25378. }
  25379. } else {
  25380. keyModifiers.push(modifier);
  25381. nonKeyModifiers.push(modifier);
  25382. }
  25383. } else {
  25384. if (isNonKeyModifier(modifier)) {
  25385. nonKeyModifiers.push(modifier);
  25386. } else {
  25387. keyModifiers.push(modifier);
  25388. }
  25389. }
  25390. }
  25391. }
  25392. return {
  25393. keyModifiers,
  25394. nonKeyModifiers,
  25395. eventOptionModifiers
  25396. };
  25397. };
  25398. const transformClick = (key, event) => {
  25399. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  25400. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  25401. `(`,
  25402. key,
  25403. `) === "onClick" ? "${event}" : (`,
  25404. key,
  25405. `)`
  25406. ]) : key;
  25407. };
  25408. const transformOn = (dir, node, context) => {
  25409. return transformOn$1(dir, node, context, (baseResult) => {
  25410. const { modifiers } = dir;
  25411. if (!modifiers.length) return baseResult;
  25412. let { key, value: handlerExp } = baseResult.props[0];
  25413. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  25414. if (nonKeyModifiers.includes("right")) {
  25415. key = transformClick(key, `onContextmenu`);
  25416. }
  25417. if (nonKeyModifiers.includes("middle")) {
  25418. key = transformClick(key, `onMouseup`);
  25419. }
  25420. if (nonKeyModifiers.length) {
  25421. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  25422. handlerExp,
  25423. JSON.stringify(nonKeyModifiers)
  25424. ]);
  25425. }
  25426. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  25427. (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
  25428. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  25429. handlerExp,
  25430. JSON.stringify(keyModifiers)
  25431. ]);
  25432. }
  25433. if (eventOptionModifiers.length) {
  25434. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  25435. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  25436. }
  25437. return {
  25438. props: [createObjectProperty(key, handlerExp)]
  25439. };
  25440. });
  25441. };
  25442. const transformShow = (dir, node, context) => {
  25443. const { exp, loc } = dir;
  25444. if (!exp) {
  25445. context.onError(
  25446. createDOMCompilerError(61, loc)
  25447. );
  25448. }
  25449. return {
  25450. props: [],
  25451. needRuntime: context.helper(V_SHOW)
  25452. };
  25453. };
  25454. const transformTransition = (node, context) => {
  25455. if (node.type === 1 && node.tagType === 1) {
  25456. const component = context.isBuiltInComponent(node.tag);
  25457. if (component === TRANSITION) {
  25458. return () => {
  25459. if (!node.children.length) {
  25460. return;
  25461. }
  25462. if (hasMultipleChildren(node)) {
  25463. context.onError(
  25464. createDOMCompilerError(
  25465. 62,
  25466. {
  25467. start: node.children[0].loc.start,
  25468. end: node.children[node.children.length - 1].loc.end,
  25469. source: ""
  25470. }
  25471. )
  25472. );
  25473. }
  25474. const child = node.children[0];
  25475. if (child.type === 1) {
  25476. for (const p of child.props) {
  25477. if (p.type === 7 && p.name === "show") {
  25478. node.props.push({
  25479. type: 6,
  25480. name: "persisted",
  25481. nameLoc: node.loc,
  25482. value: void 0,
  25483. loc: node.loc
  25484. });
  25485. }
  25486. }
  25487. }
  25488. };
  25489. }
  25490. }
  25491. };
  25492. function hasMultipleChildren(node) {
  25493. const children = node.children = node.children.filter(
  25494. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  25495. );
  25496. const child = children[0];
  25497. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  25498. }
  25499. const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
  25500. const stringifyStatic = (children, context, parent) => {
  25501. if (context.scopes.vSlot > 0) {
  25502. return;
  25503. }
  25504. const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray$3(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
  25505. let nc = 0;
  25506. let ec = 0;
  25507. const currentChunk = [];
  25508. const stringifyCurrentChunk = (currentIndex) => {
  25509. if (nc >= 20 || ec >= 5) {
  25510. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  25511. JSON.stringify(
  25512. currentChunk.map((node) => stringifyNode(node, context)).join("")
  25513. ).replace(expReplaceRE, `" + $1 + "`),
  25514. // the 2nd argument indicates the number of DOM nodes this static vnode
  25515. // will insert / hydrate
  25516. String(currentChunk.length)
  25517. ]);
  25518. const deleteCount = currentChunk.length - 1;
  25519. if (isParentCached) {
  25520. children.splice(
  25521. currentIndex - currentChunk.length,
  25522. currentChunk.length,
  25523. // @ts-expect-error
  25524. staticCall
  25525. );
  25526. } else {
  25527. currentChunk[0].codegenNode.value = staticCall;
  25528. if (currentChunk.length > 1) {
  25529. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  25530. const cacheIndex = context.cached.indexOf(
  25531. currentChunk[currentChunk.length - 1].codegenNode
  25532. );
  25533. if (cacheIndex > -1) {
  25534. for (let i2 = cacheIndex; i2 < context.cached.length; i2++) {
  25535. const c = context.cached[i2];
  25536. if (c) c.index -= deleteCount;
  25537. }
  25538. context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
  25539. }
  25540. }
  25541. }
  25542. return deleteCount;
  25543. }
  25544. return 0;
  25545. };
  25546. let i = 0;
  25547. for (; i < children.length; i++) {
  25548. const child = children[i];
  25549. const isCached = isParentCached || getCachedNode(child);
  25550. if (isCached) {
  25551. const result = analyzeNode(child);
  25552. if (result) {
  25553. nc += result[0];
  25554. ec += result[1];
  25555. currentChunk.push(child);
  25556. continue;
  25557. }
  25558. }
  25559. i -= stringifyCurrentChunk(i);
  25560. nc = 0;
  25561. ec = 0;
  25562. currentChunk.length = 0;
  25563. }
  25564. stringifyCurrentChunk(i);
  25565. };
  25566. const getCachedNode = (node) => {
  25567. if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) {
  25568. return node.codegenNode;
  25569. }
  25570. };
  25571. const dataAriaRE = /^(?:data|aria)-/;
  25572. const isStringifiableAttr = (name, ns) => {
  25573. return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : ns === 2 ? isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
  25574. };
  25575. const isNonStringifiable = /* @__PURE__ */ makeMap(
  25576. `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
  25577. );
  25578. function analyzeNode(node) {
  25579. if (node.type === 1 && isNonStringifiable(node.tag)) {
  25580. return false;
  25581. }
  25582. if (node.type === 1 && findDir(node, "once", true)) {
  25583. return false;
  25584. }
  25585. if (node.type === 12) {
  25586. return [1, 0];
  25587. }
  25588. let nc = 1;
  25589. let ec = node.props.length > 0 ? 1 : 0;
  25590. let bailed = false;
  25591. const bail = () => {
  25592. bailed = true;
  25593. return false;
  25594. };
  25595. function walk(node2) {
  25596. const isOptionTag = node2.tag === "option" && node2.ns === 0;
  25597. for (let i = 0; i < node2.props.length; i++) {
  25598. const p = node2.props[i];
  25599. if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
  25600. return bail();
  25601. }
  25602. if (p.type === 7 && p.name === "bind") {
  25603. if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
  25604. return bail();
  25605. }
  25606. if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
  25607. return bail();
  25608. }
  25609. if (isOptionTag && isStaticArgOf(p.arg, "value") && p.exp && !p.exp.isStatic) {
  25610. return bail();
  25611. }
  25612. }
  25613. }
  25614. for (let i = 0; i < node2.children.length; i++) {
  25615. nc++;
  25616. const child = node2.children[i];
  25617. if (child.type === 1) {
  25618. if (child.props.length > 0) {
  25619. ec++;
  25620. }
  25621. walk(child);
  25622. if (bailed) {
  25623. return false;
  25624. }
  25625. }
  25626. }
  25627. return true;
  25628. }
  25629. return walk(node) ? [nc, ec] : false;
  25630. }
  25631. function stringifyNode(node, context) {
  25632. if (isString$1(node)) {
  25633. return node;
  25634. }
  25635. if (isSymbol$1(node)) {
  25636. return ``;
  25637. }
  25638. switch (node.type) {
  25639. case 1:
  25640. return stringifyElement(node, context);
  25641. case 2:
  25642. return escapeHtml(node.content);
  25643. case 3:
  25644. return `<!--${escapeHtml(node.content)}-->`;
  25645. case 5:
  25646. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  25647. case 8:
  25648. return escapeHtml(evaluateConstant(node));
  25649. case 12:
  25650. return stringifyNode(node.content, context);
  25651. default:
  25652. return "";
  25653. }
  25654. }
  25655. function stringifyElement(node, context) {
  25656. let res = `<${node.tag}`;
  25657. let innerHTML = "";
  25658. for (let i = 0; i < node.props.length; i++) {
  25659. const p = node.props[i];
  25660. if (p.type === 6) {
  25661. res += ` ${p.name}`;
  25662. if (p.value) {
  25663. res += `="${escapeHtml(p.value.content)}"`;
  25664. }
  25665. } else if (p.type === 7) {
  25666. if (p.name === "bind") {
  25667. const exp = p.exp;
  25668. if (exp.content[0] === "_") {
  25669. res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
  25670. continue;
  25671. }
  25672. if (isBooleanAttr(p.arg.content) && exp.content === "false") {
  25673. continue;
  25674. }
  25675. let evaluated = evaluateConstant(exp);
  25676. if (evaluated != null) {
  25677. const arg = p.arg && p.arg.content;
  25678. if (arg === "class") {
  25679. evaluated = normalizeClass(evaluated);
  25680. } else if (arg === "style") {
  25681. evaluated = stringifyStyle(normalizeStyle(evaluated));
  25682. }
  25683. res += ` ${p.arg.content}="${escapeHtml(
  25684. evaluated
  25685. )}"`;
  25686. }
  25687. } else if (p.name === "html") {
  25688. innerHTML = evaluateConstant(p.exp);
  25689. } else if (p.name === "text") {
  25690. innerHTML = escapeHtml(
  25691. toDisplayString(evaluateConstant(p.exp))
  25692. );
  25693. }
  25694. }
  25695. }
  25696. if (context.scopeId) {
  25697. res += ` ${context.scopeId}`;
  25698. }
  25699. res += `>`;
  25700. if (innerHTML) {
  25701. res += innerHTML;
  25702. } else {
  25703. for (let i = 0; i < node.children.length; i++) {
  25704. res += stringifyNode(node.children[i], context);
  25705. }
  25706. }
  25707. if (!isVoidTag(node.tag)) {
  25708. res += `</${node.tag}>`;
  25709. }
  25710. return res;
  25711. }
  25712. function evaluateConstant(exp) {
  25713. if (exp.type === 4) {
  25714. return new Function(`return (${exp.content})`)();
  25715. } else {
  25716. let res = ``;
  25717. exp.children.forEach((c) => {
  25718. if (isString$1(c) || isSymbol$1(c)) {
  25719. return;
  25720. }
  25721. if (c.type === 2) {
  25722. res += c.content;
  25723. } else if (c.type === 5) {
  25724. res += toDisplayString(evaluateConstant(c.content));
  25725. } else {
  25726. res += evaluateConstant(c);
  25727. }
  25728. });
  25729. return res;
  25730. }
  25731. }
  25732. const ignoreSideEffectTags = (node, context) => {
  25733. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  25734. context.onError(
  25735. createDOMCompilerError(
  25736. 63,
  25737. node.loc
  25738. )
  25739. );
  25740. context.removeNode();
  25741. }
  25742. };
  25743. function isValidHTMLNesting(parent, child) {
  25744. if (parent === "template") {
  25745. return true;
  25746. }
  25747. if (parent in onlyValidChildren) {
  25748. return onlyValidChildren[parent].has(child);
  25749. }
  25750. if (child in onlyValidParents) {
  25751. return onlyValidParents[child].has(parent);
  25752. }
  25753. if (parent in knownInvalidChildren) {
  25754. if (knownInvalidChildren[parent].has(child)) return false;
  25755. }
  25756. if (child in knownInvalidParents) {
  25757. if (knownInvalidParents[child].has(parent)) return false;
  25758. }
  25759. return true;
  25760. }
  25761. const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
  25762. const emptySet = /* @__PURE__ */ new Set([]);
  25763. const onlyValidChildren = {
  25764. head: /* @__PURE__ */ new Set([
  25765. "base",
  25766. "basefront",
  25767. "bgsound",
  25768. "link",
  25769. "meta",
  25770. "title",
  25771. "noscript",
  25772. "noframes",
  25773. "style",
  25774. "script",
  25775. "template"
  25776. ]),
  25777. optgroup: /* @__PURE__ */ new Set(["option"]),
  25778. select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
  25779. // table
  25780. table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
  25781. tr: /* @__PURE__ */ new Set(["td", "th"]),
  25782. colgroup: /* @__PURE__ */ new Set(["col"]),
  25783. tbody: /* @__PURE__ */ new Set(["tr"]),
  25784. thead: /* @__PURE__ */ new Set(["tr"]),
  25785. tfoot: /* @__PURE__ */ new Set(["tr"]),
  25786. // these elements can not have any children elements
  25787. script: emptySet,
  25788. iframe: emptySet,
  25789. option: emptySet,
  25790. textarea: emptySet,
  25791. style: emptySet,
  25792. title: emptySet
  25793. };
  25794. const onlyValidParents = {
  25795. // sections
  25796. html: emptySet,
  25797. body: /* @__PURE__ */ new Set(["html"]),
  25798. head: /* @__PURE__ */ new Set(["html"]),
  25799. // table
  25800. td: /* @__PURE__ */ new Set(["tr"]),
  25801. colgroup: /* @__PURE__ */ new Set(["table"]),
  25802. caption: /* @__PURE__ */ new Set(["table"]),
  25803. tbody: /* @__PURE__ */ new Set(["table"]),
  25804. tfoot: /* @__PURE__ */ new Set(["table"]),
  25805. col: /* @__PURE__ */ new Set(["colgroup"]),
  25806. th: /* @__PURE__ */ new Set(["tr"]),
  25807. thead: /* @__PURE__ */ new Set(["table"]),
  25808. tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
  25809. // data list
  25810. dd: /* @__PURE__ */ new Set(["dl", "div"]),
  25811. dt: /* @__PURE__ */ new Set(["dl", "div"]),
  25812. // other
  25813. figcaption: /* @__PURE__ */ new Set(["figure"]),
  25814. // li: new Set(["ul", "ol"]),
  25815. summary: /* @__PURE__ */ new Set(["details"]),
  25816. area: /* @__PURE__ */ new Set(["map"])
  25817. };
  25818. const knownInvalidChildren = {
  25819. p: /* @__PURE__ */ new Set([
  25820. "address",
  25821. "article",
  25822. "aside",
  25823. "blockquote",
  25824. "center",
  25825. "details",
  25826. "dialog",
  25827. "dir",
  25828. "div",
  25829. "dl",
  25830. "fieldset",
  25831. "figure",
  25832. "footer",
  25833. "form",
  25834. "h1",
  25835. "h2",
  25836. "h3",
  25837. "h4",
  25838. "h5",
  25839. "h6",
  25840. "header",
  25841. "hgroup",
  25842. "hr",
  25843. "li",
  25844. "main",
  25845. "nav",
  25846. "menu",
  25847. "ol",
  25848. "p",
  25849. "pre",
  25850. "section",
  25851. "table",
  25852. "ul"
  25853. ]),
  25854. svg: /* @__PURE__ */ new Set([
  25855. "b",
  25856. "blockquote",
  25857. "br",
  25858. "code",
  25859. "dd",
  25860. "div",
  25861. "dl",
  25862. "dt",
  25863. "em",
  25864. "embed",
  25865. "h1",
  25866. "h2",
  25867. "h3",
  25868. "h4",
  25869. "h5",
  25870. "h6",
  25871. "hr",
  25872. "i",
  25873. "img",
  25874. "li",
  25875. "menu",
  25876. "meta",
  25877. "ol",
  25878. "p",
  25879. "pre",
  25880. "ruby",
  25881. "s",
  25882. "small",
  25883. "span",
  25884. "strong",
  25885. "sub",
  25886. "sup",
  25887. "table",
  25888. "u",
  25889. "ul",
  25890. "var"
  25891. ])
  25892. };
  25893. const knownInvalidParents = {
  25894. a: /* @__PURE__ */ new Set(["a"]),
  25895. button: /* @__PURE__ */ new Set(["button"]),
  25896. dd: /* @__PURE__ */ new Set(["dd", "dt"]),
  25897. dt: /* @__PURE__ */ new Set(["dd", "dt"]),
  25898. form: /* @__PURE__ */ new Set(["form"]),
  25899. li: /* @__PURE__ */ new Set(["li"]),
  25900. h1: headings,
  25901. h2: headings,
  25902. h3: headings,
  25903. h4: headings,
  25904. h5: headings,
  25905. h6: headings
  25906. };
  25907. const validateHtmlNesting = (node, context) => {
  25908. if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
  25909. const error = new SyntaxError(
  25910. `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
  25911. );
  25912. error.loc = node.loc;
  25913. context.onWarn(error);
  25914. }
  25915. };
  25916. const DOMNodeTransforms = [
  25917. transformStyle,
  25918. ...[transformTransition, validateHtmlNesting]
  25919. ];
  25920. const DOMDirectiveTransforms = {
  25921. cloak: noopDirectiveTransform,
  25922. html: transformVHtml,
  25923. text: transformVText,
  25924. model: transformModel,
  25925. // override compiler-core
  25926. on: transformOn,
  25927. // override compiler-core
  25928. show: transformShow
  25929. };
  25930. function compile$1(src, options = {}) {
  25931. return baseCompile(
  25932. src,
  25933. extend({}, parserOptions, options, {
  25934. nodeTransforms: [
  25935. // ignore <script> and <tag>
  25936. // this is not put inside DOMNodeTransforms because that list is used
  25937. // by compiler-ssr to generate vnode fallback branches
  25938. ignoreSideEffectTags,
  25939. ...DOMNodeTransforms,
  25940. ...options.nodeTransforms || []
  25941. ],
  25942. directiveTransforms: extend(
  25943. {},
  25944. DOMDirectiveTransforms,
  25945. options.directiveTransforms || {}
  25946. ),
  25947. transformHoist: stringifyStatic
  25948. })
  25949. );
  25950. }
  25951. function parse$3(template, options = {}) {
  25952. return baseParse(template, extend({}, parserOptions, options));
  25953. }
  25954. var CompilerDOM = /*#__PURE__*/Object.freeze({
  25955. __proto__: null,
  25956. BASE_TRANSITION: BASE_TRANSITION,
  25957. BindingTypes: BindingTypes,
  25958. CAMELIZE: CAMELIZE,
  25959. CAPITALIZE: CAPITALIZE,
  25960. CREATE_BLOCK: CREATE_BLOCK,
  25961. CREATE_COMMENT: CREATE_COMMENT,
  25962. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  25963. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  25964. CREATE_SLOTS: CREATE_SLOTS,
  25965. CREATE_STATIC: CREATE_STATIC,
  25966. CREATE_TEXT: CREATE_TEXT,
  25967. CREATE_VNODE: CREATE_VNODE,
  25968. CompilerDeprecationTypes: CompilerDeprecationTypes,
  25969. ConstantTypes: ConstantTypes,
  25970. DOMDirectiveTransforms: DOMDirectiveTransforms,
  25971. DOMErrorCodes: DOMErrorCodes,
  25972. DOMErrorMessages: DOMErrorMessages,
  25973. DOMNodeTransforms: DOMNodeTransforms,
  25974. ElementTypes: ElementTypes,
  25975. ErrorCodes: ErrorCodes,
  25976. FRAGMENT: FRAGMENT,
  25977. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  25978. IS_MEMO_SAME: IS_MEMO_SAME,
  25979. IS_REF: IS_REF,
  25980. KEEP_ALIVE: KEEP_ALIVE,
  25981. MERGE_PROPS: MERGE_PROPS,
  25982. NORMALIZE_CLASS: NORMALIZE_CLASS,
  25983. NORMALIZE_PROPS: NORMALIZE_PROPS,
  25984. NORMALIZE_STYLE: NORMALIZE_STYLE,
  25985. Namespaces: Namespaces,
  25986. NodeTypes: NodeTypes,
  25987. OPEN_BLOCK: OPEN_BLOCK,
  25988. POP_SCOPE_ID: POP_SCOPE_ID,
  25989. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  25990. RENDER_LIST: RENDER_LIST,
  25991. RENDER_SLOT: RENDER_SLOT,
  25992. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  25993. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  25994. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  25995. RESOLVE_FILTER: RESOLVE_FILTER,
  25996. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  25997. SUSPENSE: SUSPENSE,
  25998. TELEPORT: TELEPORT,
  25999. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  26000. TO_HANDLERS: TO_HANDLERS,
  26001. TO_HANDLER_KEY: TO_HANDLER_KEY,
  26002. TRANSITION: TRANSITION,
  26003. TRANSITION_GROUP: TRANSITION_GROUP,
  26004. TS_NODE_TYPES: TS_NODE_TYPES,
  26005. UNREF: UNREF,
  26006. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  26007. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  26008. V_MODEL_RADIO: V_MODEL_RADIO,
  26009. V_MODEL_SELECT: V_MODEL_SELECT,
  26010. V_MODEL_TEXT: V_MODEL_TEXT,
  26011. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  26012. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  26013. V_SHOW: V_SHOW,
  26014. WITH_CTX: WITH_CTX,
  26015. WITH_DIRECTIVES: WITH_DIRECTIVES,
  26016. WITH_MEMO: WITH_MEMO,
  26017. advancePositionWithClone: advancePositionWithClone,
  26018. advancePositionWithMutation: advancePositionWithMutation,
  26019. assert: assert,
  26020. baseCompile: baseCompile,
  26021. baseParse: baseParse,
  26022. buildDirectiveArgs: buildDirectiveArgs,
  26023. buildProps: buildProps,
  26024. buildSlots: buildSlots,
  26025. checkCompatEnabled: checkCompatEnabled,
  26026. compile: compile$1,
  26027. convertToBlock: convertToBlock,
  26028. createArrayExpression: createArrayExpression,
  26029. createAssignmentExpression: createAssignmentExpression,
  26030. createBlockStatement: createBlockStatement,
  26031. createCacheExpression: createCacheExpression,
  26032. createCallExpression: createCallExpression,
  26033. createCompilerError: createCompilerError,
  26034. createCompoundExpression: createCompoundExpression,
  26035. createConditionalExpression: createConditionalExpression,
  26036. createDOMCompilerError: createDOMCompilerError,
  26037. createForLoopParams: createForLoopParams,
  26038. createFunctionExpression: createFunctionExpression,
  26039. createIfStatement: createIfStatement,
  26040. createInterpolation: createInterpolation,
  26041. createObjectExpression: createObjectExpression,
  26042. createObjectProperty: createObjectProperty,
  26043. createReturnStatement: createReturnStatement,
  26044. createRoot: createRoot,
  26045. createSequenceExpression: createSequenceExpression,
  26046. createSimpleExpression: createSimpleExpression,
  26047. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  26048. createTemplateLiteral: createTemplateLiteral,
  26049. createTransformContext: createTransformContext,
  26050. createVNodeCall: createVNodeCall,
  26051. errorMessages: errorMessages$1,
  26052. extractIdentifiers: extractIdentifiers$1,
  26053. findDir: findDir,
  26054. findProp: findProp,
  26055. forAliasRE: forAliasRE,
  26056. generate: generate,
  26057. generateCodeFrame: generateCodeFrame,
  26058. getBaseTransformPreset: getBaseTransformPreset,
  26059. getConstantType: getConstantType,
  26060. getMemoedVNodeCall: getMemoedVNodeCall,
  26061. getVNodeBlockHelper: getVNodeBlockHelper,
  26062. getVNodeHelper: getVNodeHelper,
  26063. hasDynamicKeyVBind: hasDynamicKeyVBind,
  26064. hasScopeRef: hasScopeRef,
  26065. helperNameMap: helperNameMap,
  26066. injectProp: injectProp,
  26067. isCoreComponent: isCoreComponent,
  26068. isFnExpression: isFnExpression,
  26069. isFnExpressionBrowser: isFnExpressionBrowser,
  26070. isFnExpressionNode: isFnExpressionNode,
  26071. isFunctionType: isFunctionType,
  26072. isInDestructureAssignment: isInDestructureAssignment,
  26073. isInNewExpression: isInNewExpression,
  26074. isMemberExpression: isMemberExpression,
  26075. isMemberExpressionBrowser: isMemberExpressionBrowser,
  26076. isMemberExpressionNode: isMemberExpressionNode,
  26077. isReferencedIdentifier: isReferencedIdentifier,
  26078. isSimpleIdentifier: isSimpleIdentifier,
  26079. isSlotOutlet: isSlotOutlet,
  26080. isStaticArgOf: isStaticArgOf,
  26081. isStaticExp: isStaticExp,
  26082. isStaticProperty: isStaticProperty,
  26083. isStaticPropertyKey: isStaticPropertyKey,
  26084. isTemplateNode: isTemplateNode,
  26085. isText: isText$1,
  26086. isVPre: isVPre,
  26087. isVSlot: isVSlot,
  26088. locStub: locStub,
  26089. noopDirectiveTransform: noopDirectiveTransform,
  26090. parse: parse$3,
  26091. parserOptions: parserOptions,
  26092. processExpression: processExpression,
  26093. processFor: processFor,
  26094. processIf: processIf,
  26095. processSlotOutlet: processSlotOutlet,
  26096. registerRuntimeHelpers: registerRuntimeHelpers,
  26097. resolveComponentType: resolveComponentType,
  26098. stringifyExpression: stringifyExpression,
  26099. toValidAssetId: toValidAssetId,
  26100. trackSlotScopes: trackSlotScopes,
  26101. trackVForSlotScopes: trackVForSlotScopes,
  26102. transform: transform,
  26103. transformBind: transformBind,
  26104. transformElement: transformElement,
  26105. transformExpression: transformExpression,
  26106. transformModel: transformModel$1,
  26107. transformOn: transformOn$1,
  26108. transformStyle: transformStyle,
  26109. transformVBindShorthand: transformVBindShorthand,
  26110. traverseNode: traverseNode,
  26111. unwrapTSNode: unwrapTSNode,
  26112. validFirstIdentCharRE: validFirstIdentCharRE,
  26113. walkBlockDeclarations: walkBlockDeclarations,
  26114. walkFunctionParams: walkFunctionParams,
  26115. walkIdentifiers: walkIdentifiers,
  26116. warnDeprecation: warnDeprecation
  26117. });
  26118. var hashSum;
  26119. var hasRequiredHashSum;
  26120. function requireHashSum () {
  26121. if (hasRequiredHashSum) return hashSum;
  26122. hasRequiredHashSum = 1;
  26123. function pad (hash, len) {
  26124. while (hash.length < len) {
  26125. hash = '0' + hash;
  26126. }
  26127. return hash;
  26128. }
  26129. function fold (hash, text) {
  26130. var i;
  26131. var chr;
  26132. var len;
  26133. if (text.length === 0) {
  26134. return hash;
  26135. }
  26136. for (i = 0, len = text.length; i < len; i++) {
  26137. chr = text.charCodeAt(i);
  26138. hash = ((hash << 5) - hash) + chr;
  26139. hash |= 0;
  26140. }
  26141. return hash < 0 ? hash * -2 : hash;
  26142. }
  26143. function foldObject (hash, o, seen) {
  26144. return Object.keys(o).sort().reduce(foldKey, hash);
  26145. function foldKey (hash, key) {
  26146. return foldValue(hash, o[key], key, seen);
  26147. }
  26148. }
  26149. function foldValue (input, value, key, seen) {
  26150. var hash = fold(fold(fold(input, key), toString(value)), typeof value);
  26151. if (value === null) {
  26152. return fold(hash, 'null');
  26153. }
  26154. if (value === undefined) {
  26155. return fold(hash, 'undefined');
  26156. }
  26157. if (typeof value === 'object' || typeof value === 'function') {
  26158. if (seen.indexOf(value) !== -1) {
  26159. return fold(hash, '[Circular]' + key);
  26160. }
  26161. seen.push(value);
  26162. var objHash = foldObject(hash, value, seen);
  26163. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  26164. return objHash;
  26165. }
  26166. try {
  26167. return fold(objHash, String(value.valueOf()))
  26168. } catch (err) {
  26169. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  26170. }
  26171. }
  26172. return fold(hash, value.toString());
  26173. }
  26174. function toString (o) {
  26175. return Object.prototype.toString.call(o);
  26176. }
  26177. function sum (o) {
  26178. return pad(foldValue(0, o, '', []).toString(16), 8);
  26179. }
  26180. hashSum = sum;
  26181. return hashSum;
  26182. }
  26183. var hashSumExports = /*@__PURE__*/ requireHashSum();
  26184. var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSumExports);
  26185. const CSS_VARS_HELPER = `useCssVars`;
  26186. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  26187. return `{
  26188. ${vars.map(
  26189. (key) => (
  26190. // The `:` prefix here is used in `ssrRenderStyle` to distinguish whether
  26191. // a custom property comes from `ssrCssVars`. If it does, we need to reset
  26192. // its value to `initial` on the component instance to avoid unintentionally
  26193. // inheriting the same property value from a different instance of the same
  26194. // component in the outer scope.
  26195. `"${isSSR ? `:--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
  26196. )
  26197. ).join(",\n ")}
  26198. }`;
  26199. }
  26200. function genVarName(id, raw, isProd, isSSR = false) {
  26201. if (isProd) {
  26202. return hash(id + raw).replace(/^\d/, (r) => `v${r}`);
  26203. } else {
  26204. return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
  26205. }
  26206. }
  26207. function normalizeExpression(exp) {
  26208. exp = exp.trim();
  26209. if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) {
  26210. return exp.slice(1, -1);
  26211. }
  26212. return exp;
  26213. }
  26214. const vBindRE = /v-bind\s*\(/g;
  26215. function parseCssVars(sfc) {
  26216. const vars = [];
  26217. sfc.styles.forEach((style) => {
  26218. let match;
  26219. const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, "");
  26220. while (match = vBindRE.exec(content)) {
  26221. const start = match.index + match[0].length;
  26222. const end = lexBinding(content, start);
  26223. if (end !== null) {
  26224. const variable = normalizeExpression(content.slice(start, end));
  26225. if (!vars.includes(variable)) {
  26226. vars.push(variable);
  26227. }
  26228. }
  26229. }
  26230. });
  26231. return vars;
  26232. }
  26233. function lexBinding(content, start) {
  26234. let state = 0 /* inParens */;
  26235. let parenDepth = 0;
  26236. for (let i = start; i < content.length; i++) {
  26237. const char = content.charAt(i);
  26238. switch (state) {
  26239. case 0 /* inParens */:
  26240. if (char === `'`) {
  26241. state = 1 /* inSingleQuoteString */;
  26242. } else if (char === `"`) {
  26243. state = 2 /* inDoubleQuoteString */;
  26244. } else if (char === `(`) {
  26245. parenDepth++;
  26246. } else if (char === `)`) {
  26247. if (parenDepth > 0) {
  26248. parenDepth--;
  26249. } else {
  26250. return i;
  26251. }
  26252. }
  26253. break;
  26254. case 1 /* inSingleQuoteString */:
  26255. if (char === `'`) {
  26256. state = 0 /* inParens */;
  26257. }
  26258. break;
  26259. case 2 /* inDoubleQuoteString */:
  26260. if (char === `"`) {
  26261. state = 0 /* inParens */;
  26262. }
  26263. break;
  26264. }
  26265. }
  26266. return null;
  26267. }
  26268. const cssVarsPlugin = (opts) => {
  26269. const { id, isProd } = opts;
  26270. return {
  26271. postcssPlugin: "vue-sfc-vars",
  26272. Declaration(decl) {
  26273. const value = decl.value;
  26274. if (vBindRE.test(value)) {
  26275. vBindRE.lastIndex = 0;
  26276. let transformed = "";
  26277. let lastIndex = 0;
  26278. let match;
  26279. while (match = vBindRE.exec(value)) {
  26280. const start = match.index + match[0].length;
  26281. const end = lexBinding(value, start);
  26282. if (end !== null) {
  26283. const variable = normalizeExpression(value.slice(start, end));
  26284. transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`;
  26285. lastIndex = end + 1;
  26286. }
  26287. }
  26288. decl.value = transformed + value.slice(lastIndex);
  26289. }
  26290. }
  26291. };
  26292. };
  26293. cssVarsPlugin.postcss = true;
  26294. function genCssVarsCode(vars, bindings, id, isProd) {
  26295. const varsExp = genCssVarsFromList(vars, id, isProd);
  26296. const exp = createSimpleExpression(varsExp, false);
  26297. const context = createTransformContext(createRoot([]), {
  26298. prefixIdentifiers: true,
  26299. inline: true,
  26300. bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings
  26301. });
  26302. const transformed = processExpression(exp, context);
  26303. const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
  26304. return typeof c === "string" ? c : c.content;
  26305. }).join("");
  26306. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  26307. }
  26308. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
  26309. return `
  26310. import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
  26311. const __injectCSSVars__ = () => {
  26312. ${genCssVarsCode(
  26313. cssVars,
  26314. bindings,
  26315. id,
  26316. isProd
  26317. )}}
  26318. const __setup__ = ${defaultVar}.setup
  26319. ${defaultVar}.setup = __setup__
  26320. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  26321. : __injectCSSVars__
  26322. `;
  26323. }
  26324. var global$1 = (typeof global !== "undefined" ? global :
  26325. typeof self !== "undefined" ? self :
  26326. typeof window !== "undefined" ? window : {});
  26327. // shim for using process in browser
  26328. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  26329. function defaultSetTimout() {
  26330. throw new Error('setTimeout has not been defined');
  26331. }
  26332. function defaultClearTimeout () {
  26333. throw new Error('clearTimeout has not been defined');
  26334. }
  26335. var cachedSetTimeout = defaultSetTimout;
  26336. var cachedClearTimeout = defaultClearTimeout;
  26337. if (typeof global$1.setTimeout === 'function') {
  26338. cachedSetTimeout = setTimeout;
  26339. }
  26340. if (typeof global$1.clearTimeout === 'function') {
  26341. cachedClearTimeout = clearTimeout;
  26342. }
  26343. function runTimeout(fun) {
  26344. if (cachedSetTimeout === setTimeout) {
  26345. //normal enviroments in sane situations
  26346. return setTimeout(fun, 0);
  26347. }
  26348. // if setTimeout wasn't available but was latter defined
  26349. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  26350. cachedSetTimeout = setTimeout;
  26351. return setTimeout(fun, 0);
  26352. }
  26353. try {
  26354. // when when somebody has screwed with setTimeout but no I.E. maddness
  26355. return cachedSetTimeout(fun, 0);
  26356. } catch(e){
  26357. try {
  26358. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  26359. return cachedSetTimeout.call(null, fun, 0);
  26360. } catch(e){
  26361. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  26362. return cachedSetTimeout.call(this, fun, 0);
  26363. }
  26364. }
  26365. }
  26366. function runClearTimeout(marker) {
  26367. if (cachedClearTimeout === clearTimeout) {
  26368. //normal enviroments in sane situations
  26369. return clearTimeout(marker);
  26370. }
  26371. // if clearTimeout wasn't available but was latter defined
  26372. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  26373. cachedClearTimeout = clearTimeout;
  26374. return clearTimeout(marker);
  26375. }
  26376. try {
  26377. // when when somebody has screwed with setTimeout but no I.E. maddness
  26378. return cachedClearTimeout(marker);
  26379. } catch (e){
  26380. try {
  26381. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  26382. return cachedClearTimeout.call(null, marker);
  26383. } catch (e){
  26384. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  26385. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  26386. return cachedClearTimeout.call(this, marker);
  26387. }
  26388. }
  26389. }
  26390. var queue = [];
  26391. var draining = false;
  26392. var currentQueue;
  26393. var queueIndex = -1;
  26394. function cleanUpNextTick() {
  26395. if (!draining || !currentQueue) {
  26396. return;
  26397. }
  26398. draining = false;
  26399. if (currentQueue.length) {
  26400. queue = currentQueue.concat(queue);
  26401. } else {
  26402. queueIndex = -1;
  26403. }
  26404. if (queue.length) {
  26405. drainQueue();
  26406. }
  26407. }
  26408. function drainQueue() {
  26409. if (draining) {
  26410. return;
  26411. }
  26412. var timeout = runTimeout(cleanUpNextTick);
  26413. draining = true;
  26414. var len = queue.length;
  26415. while(len) {
  26416. currentQueue = queue;
  26417. queue = [];
  26418. while (++queueIndex < len) {
  26419. if (currentQueue) {
  26420. currentQueue[queueIndex].run();
  26421. }
  26422. }
  26423. queueIndex = -1;
  26424. len = queue.length;
  26425. }
  26426. currentQueue = null;
  26427. draining = false;
  26428. runClearTimeout(timeout);
  26429. }
  26430. function nextTick(fun) {
  26431. var args = new Array(arguments.length - 1);
  26432. if (arguments.length > 1) {
  26433. for (var i = 1; i < arguments.length; i++) {
  26434. args[i - 1] = arguments[i];
  26435. }
  26436. }
  26437. queue.push(new Item(fun, args));
  26438. if (queue.length === 1 && !draining) {
  26439. runTimeout(drainQueue);
  26440. }
  26441. }
  26442. // v8 likes predictible objects
  26443. function Item(fun, array) {
  26444. this.fun = fun;
  26445. this.array = array;
  26446. }
  26447. Item.prototype.run = function () {
  26448. this.fun.apply(null, this.array);
  26449. };
  26450. var title = 'browser';
  26451. var platform = 'browser';
  26452. var browser = true;
  26453. var env = {};
  26454. var argv = [];
  26455. var version$1 = ''; // empty string to avoid regexp issues
  26456. var versions = {};
  26457. var release = {};
  26458. var config = {};
  26459. function noop() {}
  26460. var on = noop;
  26461. var addListener = noop;
  26462. var once = noop;
  26463. var off = noop;
  26464. var removeListener = noop;
  26465. var removeAllListeners = noop;
  26466. var emit = noop;
  26467. function binding(name) {
  26468. throw new Error('process.binding is not supported');
  26469. }
  26470. function cwd () { return '/' }
  26471. function chdir (dir) {
  26472. throw new Error('process.chdir is not supported');
  26473. }function umask() { return 0; }
  26474. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  26475. var performance = global$1.performance || {};
  26476. var performanceNow =
  26477. performance.now ||
  26478. performance.mozNow ||
  26479. performance.msNow ||
  26480. performance.oNow ||
  26481. performance.webkitNow ||
  26482. function(){ return (new Date()).getTime() };
  26483. // generate timestamp or delta
  26484. // see http://nodejs.org/api/process.html#process_process_hrtime
  26485. function hrtime(previousTimestamp){
  26486. var clocktime = performanceNow.call(performance)*1e-3;
  26487. var seconds = Math.floor(clocktime);
  26488. var nanoseconds = Math.floor((clocktime%1)*1e9);
  26489. if (previousTimestamp) {
  26490. seconds = seconds - previousTimestamp[0];
  26491. nanoseconds = nanoseconds - previousTimestamp[1];
  26492. if (nanoseconds<0) {
  26493. seconds--;
  26494. nanoseconds += 1e9;
  26495. }
  26496. }
  26497. return [seconds,nanoseconds]
  26498. }
  26499. var startTime = new Date();
  26500. function uptime() {
  26501. var currentTime = new Date();
  26502. var dif = currentTime - startTime;
  26503. return dif / 1000;
  26504. }
  26505. var browser$1 = {
  26506. nextTick: nextTick,
  26507. title: title,
  26508. browser: browser,
  26509. env: env,
  26510. argv: argv,
  26511. version: version$1,
  26512. versions: versions,
  26513. on: on,
  26514. addListener: addListener,
  26515. once: once,
  26516. off: off,
  26517. removeListener: removeListener,
  26518. removeAllListeners: removeAllListeners,
  26519. emit: emit,
  26520. binding: binding,
  26521. cwd: cwd,
  26522. chdir: chdir,
  26523. umask: umask,
  26524. hrtime: hrtime,
  26525. platform: platform,
  26526. release: release,
  26527. config: config,
  26528. uptime: uptime
  26529. };
  26530. function createCache(max = 500) {
  26531. {
  26532. return /* @__PURE__ */ new Map();
  26533. }
  26534. }
  26535. function isImportUsed(local, sfc) {
  26536. return resolveTemplateUsedIdentifiers(sfc).has(local);
  26537. }
  26538. const templateUsageCheckCache = createCache();
  26539. function resolveTemplateUsedIdentifiers(sfc) {
  26540. const { content, ast } = sfc.template;
  26541. const cached = templateUsageCheckCache.get(content);
  26542. if (cached) {
  26543. return cached;
  26544. }
  26545. const ids = /* @__PURE__ */ new Set();
  26546. ast.children.forEach(walk);
  26547. function walk(node) {
  26548. var _a;
  26549. switch (node.type) {
  26550. case 1:
  26551. let tag = node.tag;
  26552. if (tag.includes(".")) tag = tag.split(".")[0].trim();
  26553. if (!parserOptions.isNativeTag(tag) && !parserOptions.isBuiltInComponent(tag)) {
  26554. ids.add(camelize(tag));
  26555. ids.add(capitalize(camelize(tag)));
  26556. }
  26557. for (let i = 0; i < node.props.length; i++) {
  26558. const prop = node.props[i];
  26559. if (prop.type === 7) {
  26560. if (!isBuiltInDirective(prop.name)) {
  26561. ids.add(`v${capitalize(camelize(prop.name))}`);
  26562. }
  26563. if (prop.arg && !prop.arg.isStatic) {
  26564. extractIdentifiers(ids, prop.arg);
  26565. }
  26566. if (prop.name === "for") {
  26567. extractIdentifiers(ids, prop.forParseResult.source);
  26568. } else if (prop.exp) {
  26569. extractIdentifiers(ids, prop.exp);
  26570. } else if (prop.name === "bind" && !prop.exp) {
  26571. ids.add(camelize(prop.arg.content));
  26572. }
  26573. }
  26574. if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
  26575. ids.add(prop.value.content);
  26576. }
  26577. }
  26578. node.children.forEach(walk);
  26579. break;
  26580. case 5:
  26581. extractIdentifiers(ids, node.content);
  26582. break;
  26583. }
  26584. }
  26585. templateUsageCheckCache.set(content, ids);
  26586. return ids;
  26587. }
  26588. function extractIdentifiers(ids, node) {
  26589. if (node.ast) {
  26590. walkIdentifiers(node.ast, (n) => ids.add(n.name));
  26591. } else if (node.ast === null) {
  26592. ids.add(node.content);
  26593. }
  26594. }
  26595. var __defProp$a = Object.defineProperty;
  26596. var __defProps$9 = Object.defineProperties;
  26597. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  26598. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  26599. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  26600. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  26601. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  26602. var __spreadValues$a = (a, b) => {
  26603. for (var prop in b || (b = {}))
  26604. if (__hasOwnProp$a.call(b, prop))
  26605. __defNormalProp$a(a, prop, b[prop]);
  26606. if (__getOwnPropSymbols$a)
  26607. for (var prop of __getOwnPropSymbols$a(b)) {
  26608. if (__propIsEnum$a.call(b, prop))
  26609. __defNormalProp$a(a, prop, b[prop]);
  26610. }
  26611. return a;
  26612. };
  26613. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  26614. const DEFAULT_FILENAME = "anonymous.vue";
  26615. const parseCache$1 = createCache();
  26616. function parse$2(source, options = {}) {
  26617. var _a;
  26618. const sourceKey = genCacheKey(source, __spreadProps$9(__spreadValues$a({}, options), {
  26619. compiler: { parse: (_a = options.compiler) == null ? void 0 : _a.parse }
  26620. }));
  26621. const cache = parseCache$1.get(sourceKey);
  26622. if (cache) {
  26623. return cache;
  26624. }
  26625. const {
  26626. sourceMap = true,
  26627. filename = DEFAULT_FILENAME,
  26628. sourceRoot = "",
  26629. pad = false,
  26630. ignoreEmpty = true,
  26631. compiler = CompilerDOM,
  26632. templateParseOptions = {}
  26633. } = options;
  26634. const descriptor = {
  26635. filename,
  26636. source,
  26637. template: null,
  26638. script: null,
  26639. scriptSetup: null,
  26640. styles: [],
  26641. customBlocks: [],
  26642. cssVars: [],
  26643. slotted: false,
  26644. shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor)
  26645. };
  26646. const errors = [];
  26647. const ast = compiler.parse(source, __spreadProps$9(__spreadValues$a({
  26648. parseMode: "sfc",
  26649. prefixIdentifiers: true
  26650. }, templateParseOptions), {
  26651. onError: (e) => {
  26652. errors.push(e);
  26653. }
  26654. }));
  26655. ast.children.forEach((node) => {
  26656. if (node.type !== 1) {
  26657. return;
  26658. }
  26659. if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasSrc(node)) {
  26660. return;
  26661. }
  26662. switch (node.tag) {
  26663. case "template":
  26664. if (!descriptor.template) {
  26665. const templateBlock = descriptor.template = createBlock(
  26666. node,
  26667. source,
  26668. false
  26669. );
  26670. if (!templateBlock.attrs.src) {
  26671. templateBlock.ast = createRoot(node.children, source);
  26672. }
  26673. if (templateBlock.attrs.functional) {
  26674. const err = new SyntaxError(
  26675. `<template functional> is no longer supported in Vue 3, since functional components no longer have significant performance difference from stateful ones. Just use a normal <template> instead.`
  26676. );
  26677. err.loc = node.props.find(
  26678. (p) => p.type === 6 && p.name === "functional"
  26679. ).loc;
  26680. errors.push(err);
  26681. }
  26682. } else {
  26683. errors.push(createDuplicateBlockError(node));
  26684. }
  26685. break;
  26686. case "script":
  26687. const scriptBlock = createBlock(node, source, pad);
  26688. const isSetup = !!scriptBlock.attrs.setup;
  26689. if (isSetup && !descriptor.scriptSetup) {
  26690. descriptor.scriptSetup = scriptBlock;
  26691. break;
  26692. }
  26693. if (!isSetup && !descriptor.script) {
  26694. descriptor.script = scriptBlock;
  26695. break;
  26696. }
  26697. errors.push(createDuplicateBlockError(node, isSetup));
  26698. break;
  26699. case "style":
  26700. const styleBlock = createBlock(node, source, pad);
  26701. if (styleBlock.attrs.vars) {
  26702. errors.push(
  26703. new SyntaxError(
  26704. `<style vars> has been replaced by a new proposal: https://github.com/vuejs/rfcs/pull/231`
  26705. )
  26706. );
  26707. }
  26708. descriptor.styles.push(styleBlock);
  26709. break;
  26710. default:
  26711. descriptor.customBlocks.push(createBlock(node, source, pad));
  26712. break;
  26713. }
  26714. });
  26715. if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
  26716. errors.push(
  26717. new SyntaxError(
  26718. `At least one <template> or <script> is required in a single file component. ${descriptor.filename}`
  26719. )
  26720. );
  26721. }
  26722. if (descriptor.scriptSetup) {
  26723. if (descriptor.scriptSetup.src) {
  26724. errors.push(
  26725. new SyntaxError(
  26726. `<script setup> cannot use the "src" attribute because its syntax will be ambiguous outside of the component.`
  26727. )
  26728. );
  26729. descriptor.scriptSetup = null;
  26730. }
  26731. if (descriptor.script && descriptor.script.src) {
  26732. errors.push(
  26733. new SyntaxError(
  26734. `<script> cannot use the "src" attribute when <script setup> is also present because they must be processed together.`
  26735. )
  26736. );
  26737. descriptor.script = null;
  26738. }
  26739. }
  26740. let templateColumnOffset = 0;
  26741. if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
  26742. [descriptor.template.content, templateColumnOffset] = dedent(
  26743. descriptor.template.content
  26744. );
  26745. }
  26746. if (sourceMap) {
  26747. const genMap = (block, columnOffset = 0) => {
  26748. if (block && !block.src) {
  26749. block.map = generateSourceMap(
  26750. filename,
  26751. source,
  26752. block.content,
  26753. sourceRoot,
  26754. !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
  26755. columnOffset
  26756. );
  26757. }
  26758. };
  26759. genMap(descriptor.template, templateColumnOffset);
  26760. genMap(descriptor.script);
  26761. descriptor.styles.forEach((s) => genMap(s));
  26762. descriptor.customBlocks.forEach((s) => genMap(s));
  26763. }
  26764. descriptor.cssVars = parseCssVars(descriptor);
  26765. const slottedRE = /(?:::v-|:)slotted\(/;
  26766. descriptor.slotted = descriptor.styles.some(
  26767. (s) => s.scoped && slottedRE.test(s.content)
  26768. );
  26769. const result = {
  26770. descriptor,
  26771. errors
  26772. };
  26773. parseCache$1.set(sourceKey, result);
  26774. return result;
  26775. }
  26776. function createDuplicateBlockError(node, isScriptSetup = false) {
  26777. const err = new SyntaxError(
  26778. `Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`
  26779. );
  26780. err.loc = node.loc;
  26781. return err;
  26782. }
  26783. function createBlock(node, source, pad) {
  26784. const type = node.tag;
  26785. const loc = node.innerLoc;
  26786. const attrs = {};
  26787. const block = {
  26788. type,
  26789. content: source.slice(loc.start.offset, loc.end.offset),
  26790. loc,
  26791. attrs
  26792. };
  26793. if (pad) {
  26794. block.content = padContent(source, block, pad) + block.content;
  26795. }
  26796. node.props.forEach((p) => {
  26797. if (p.type === 6) {
  26798. const name = p.name;
  26799. attrs[name] = p.value ? p.value.content || true : true;
  26800. if (name === "lang") {
  26801. block.lang = p.value && p.value.content;
  26802. } else if (name === "src") {
  26803. block.src = p.value && p.value.content;
  26804. } else if (type === "style") {
  26805. if (name === "scoped") {
  26806. block.scoped = true;
  26807. } else if (name === "module") {
  26808. block.module = attrs[name];
  26809. }
  26810. } else if (type === "script" && name === "setup") {
  26811. block.setup = attrs.setup;
  26812. }
  26813. }
  26814. });
  26815. return block;
  26816. }
  26817. const splitRE = /\r?\n/g;
  26818. const emptyRE = /^(?:\/\/)?\s*$/;
  26819. const replaceRE = /./g;
  26820. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
  26821. const map = new sourceMapExports.SourceMapGenerator({
  26822. file: filename.replace(/\\/g, "/"),
  26823. sourceRoot: sourceRoot.replace(/\\/g, "/")
  26824. });
  26825. map.setSourceContent(filename, source);
  26826. map._sources.add(filename);
  26827. generated.split(splitRE).forEach((line, index) => {
  26828. if (!emptyRE.test(line)) {
  26829. const originalLine = index + 1 + lineOffset;
  26830. const generatedLine = index + 1;
  26831. for (let i = 0; i < line.length; i++) {
  26832. if (!/\s/.test(line[i])) {
  26833. map._mappings.add({
  26834. originalLine,
  26835. originalColumn: i + columnOffset,
  26836. generatedLine,
  26837. generatedColumn: i,
  26838. source: filename,
  26839. name: null
  26840. });
  26841. }
  26842. }
  26843. }
  26844. });
  26845. return map.toJSON();
  26846. }
  26847. function padContent(content, block, pad) {
  26848. content = content.slice(0, block.loc.start.offset);
  26849. if (pad === "space") {
  26850. return content.replace(replaceRE, " ");
  26851. } else {
  26852. const offset = content.split(splitRE).length;
  26853. const padChar = block.type === "script" && !block.lang ? "//\n" : "\n";
  26854. return Array(offset).join(padChar);
  26855. }
  26856. }
  26857. function hasSrc(node) {
  26858. return node.props.some((p) => {
  26859. if (p.type !== 6) {
  26860. return false;
  26861. }
  26862. return p.name === "src";
  26863. });
  26864. }
  26865. function isEmpty(node) {
  26866. for (let i = 0; i < node.children.length; i++) {
  26867. const child = node.children[i];
  26868. if (child.type !== 2 || child.content.trim() !== "") {
  26869. return false;
  26870. }
  26871. }
  26872. return true;
  26873. }
  26874. function hmrShouldReload(prevImports, next) {
  26875. if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
  26876. return false;
  26877. }
  26878. for (const key in prevImports) {
  26879. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) {
  26880. return true;
  26881. }
  26882. }
  26883. return false;
  26884. }
  26885. function dedent(s) {
  26886. const lines = s.split("\n");
  26887. const minIndent = lines.reduce(function(minIndent2, line) {
  26888. var _a, _b;
  26889. if (line.trim() === "") {
  26890. return minIndent2;
  26891. }
  26892. const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
  26893. return Math.min(indent, minIndent2);
  26894. }, Infinity);
  26895. if (minIndent === 0) {
  26896. return [s, minIndent];
  26897. }
  26898. return [
  26899. lines.map(function(line) {
  26900. return line.slice(minIndent);
  26901. }).join("\n"),
  26902. minIndent
  26903. ];
  26904. }
  26905. // Copyright Joyent, Inc. and other Node contributors.
  26906. //
  26907. // Permission is hereby granted, free of charge, to any person obtaining a
  26908. // copy of this software and associated documentation files (the
  26909. // "Software"), to deal in the Software without restriction, including
  26910. // without limitation the rights to use, copy, modify, merge, publish,
  26911. // distribute, sublicense, and/or sell copies of the Software, and to permit
  26912. // persons to whom the Software is furnished to do so, subject to the
  26913. // following conditions:
  26914. //
  26915. // The above copyright notice and this permission notice shall be included
  26916. // in all copies or substantial portions of the Software.
  26917. //
  26918. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  26919. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26920. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26921. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  26922. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  26923. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  26924. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  26925. // resolves . and .. elements in a path array with directory names there
  26926. // must be no slashes, empty elements, or device names (c:\) in the array
  26927. // (so also no leading and trailing slashes - it does not distinguish
  26928. // relative and absolute paths)
  26929. function normalizeArray(parts, allowAboveRoot) {
  26930. // if the path tries to go above the root, `up` ends up > 0
  26931. var up = 0;
  26932. for (var i = parts.length - 1; i >= 0; i--) {
  26933. var last = parts[i];
  26934. if (last === '.') {
  26935. parts.splice(i, 1);
  26936. } else if (last === '..') {
  26937. parts.splice(i, 1);
  26938. up++;
  26939. } else if (up) {
  26940. parts.splice(i, 1);
  26941. up--;
  26942. }
  26943. }
  26944. // if the path is allowed to go above the root, restore leading ..s
  26945. if (allowAboveRoot) {
  26946. for (; up--; up) {
  26947. parts.unshift('..');
  26948. }
  26949. }
  26950. return parts;
  26951. }
  26952. // Split a filename into [root, dir, basename, ext], unix version
  26953. // 'root' is just a slash, or nothing.
  26954. var splitPathRe =
  26955. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  26956. var splitPath = function(filename) {
  26957. return splitPathRe.exec(filename).slice(1);
  26958. };
  26959. // path.resolve([from ...], to)
  26960. // posix version
  26961. function resolve() {
  26962. var resolvedPath = '',
  26963. resolvedAbsolute = false;
  26964. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  26965. var path = (i >= 0) ? arguments[i] : '/';
  26966. // Skip empty and invalid entries
  26967. if (typeof path !== 'string') {
  26968. throw new TypeError('Arguments to path.resolve must be strings');
  26969. } else if (!path) {
  26970. continue;
  26971. }
  26972. resolvedPath = path + '/' + resolvedPath;
  26973. resolvedAbsolute = path.charAt(0) === '/';
  26974. }
  26975. // At this point the path should be resolved to a full absolute path, but
  26976. // handle relative paths to be safe (might happen when process.cwd() fails)
  26977. // Normalize the path
  26978. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  26979. return !!p;
  26980. }), !resolvedAbsolute).join('/');
  26981. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  26982. }
  26983. // path.normalize(path)
  26984. // posix version
  26985. function normalize$1(path) {
  26986. var isPathAbsolute = isAbsolute(path),
  26987. trailingSlash = substr(path, -1) === '/';
  26988. // Normalize the path
  26989. path = normalizeArray(filter(path.split('/'), function(p) {
  26990. return !!p;
  26991. }), !isPathAbsolute).join('/');
  26992. if (!path && !isPathAbsolute) {
  26993. path = '.';
  26994. }
  26995. if (path && trailingSlash) {
  26996. path += '/';
  26997. }
  26998. return (isPathAbsolute ? '/' : '') + path;
  26999. }
  27000. // posix version
  27001. function isAbsolute(path) {
  27002. return path.charAt(0) === '/';
  27003. }
  27004. // posix version
  27005. function join() {
  27006. var paths = Array.prototype.slice.call(arguments, 0);
  27007. return normalize$1(filter(paths, function(p, index) {
  27008. if (typeof p !== 'string') {
  27009. throw new TypeError('Arguments to path.join must be strings');
  27010. }
  27011. return p;
  27012. }).join('/'));
  27013. }
  27014. // path.relative(from, to)
  27015. // posix version
  27016. function relative(from, to) {
  27017. from = resolve(from).substr(1);
  27018. to = resolve(to).substr(1);
  27019. function trim(arr) {
  27020. var start = 0;
  27021. for (; start < arr.length; start++) {
  27022. if (arr[start] !== '') break;
  27023. }
  27024. var end = arr.length - 1;
  27025. for (; end >= 0; end--) {
  27026. if (arr[end] !== '') break;
  27027. }
  27028. if (start > end) return [];
  27029. return arr.slice(start, end - start + 1);
  27030. }
  27031. var fromParts = trim(from.split('/'));
  27032. var toParts = trim(to.split('/'));
  27033. var length = Math.min(fromParts.length, toParts.length);
  27034. var samePartsLength = length;
  27035. for (var i = 0; i < length; i++) {
  27036. if (fromParts[i] !== toParts[i]) {
  27037. samePartsLength = i;
  27038. break;
  27039. }
  27040. }
  27041. var outputParts = [];
  27042. for (var i = samePartsLength; i < fromParts.length; i++) {
  27043. outputParts.push('..');
  27044. }
  27045. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  27046. return outputParts.join('/');
  27047. }
  27048. var sep = '/';
  27049. var delimiter$1 = ':';
  27050. function dirname(path) {
  27051. var result = splitPath(path),
  27052. root = result[0],
  27053. dir = result[1];
  27054. if (!root && !dir) {
  27055. // No dirname whatsoever
  27056. return '.';
  27057. }
  27058. if (dir) {
  27059. // It has a dirname, strip trailing slash
  27060. dir = dir.substr(0, dir.length - 1);
  27061. }
  27062. return root + dir;
  27063. }
  27064. function basename(path, ext) {
  27065. var f = splitPath(path)[2];
  27066. // TODO: make this comparison case-insensitive on windows?
  27067. if (ext && f.substr(-1 * ext.length) === ext) {
  27068. f = f.substr(0, f.length - ext.length);
  27069. }
  27070. return f;
  27071. }
  27072. function extname(path) {
  27073. return splitPath(path)[3];
  27074. }
  27075. var path = {
  27076. extname: extname,
  27077. basename: basename,
  27078. dirname: dirname,
  27079. sep: sep,
  27080. delimiter: delimiter$1,
  27081. relative: relative,
  27082. join: join,
  27083. isAbsolute: isAbsolute,
  27084. normalize: normalize$1,
  27085. resolve: resolve
  27086. };
  27087. function filter (xs, f) {
  27088. if (xs.filter) return xs.filter(f);
  27089. var res = [];
  27090. for (var i = 0; i < xs.length; i++) {
  27091. if (f(xs[i], i, xs)) res.push(xs[i]);
  27092. }
  27093. return res;
  27094. }
  27095. // String.prototype.substr - negative index don't work in IE8
  27096. var substr = 'ab'.substr(-1) === 'b' ?
  27097. function (str, start, len) { return str.substr(start, len) } :
  27098. function (str, start, len) {
  27099. if (start < 0) start = str.length + start;
  27100. return str.substr(start, len);
  27101. }
  27102. ;
  27103. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  27104. __proto__: null,
  27105. basename: basename,
  27106. default: path,
  27107. delimiter: delimiter$1,
  27108. dirname: dirname,
  27109. extname: extname,
  27110. isAbsolute: isAbsolute,
  27111. join: join,
  27112. normalize: normalize$1,
  27113. relative: relative,
  27114. resolve: resolve,
  27115. sep: sep
  27116. });
  27117. /*! https://mths.be/punycode v1.4.1 by @mathias */
  27118. /** Highest positive signed 32-bit float value */
  27119. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  27120. /** Bootstring parameters */
  27121. var base = 36;
  27122. var tMin = 1;
  27123. var tMax = 26;
  27124. var skew = 38;
  27125. var damp = 700;
  27126. var initialBias = 72;
  27127. var initialN = 128; // 0x80
  27128. var delimiter = '-'; // '\x2D'
  27129. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  27130. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  27131. /** Error messages */
  27132. var errors = {
  27133. 'overflow': 'Overflow: input needs wider integers to process',
  27134. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  27135. 'invalid-input': 'Invalid input'
  27136. };
  27137. /** Convenience shortcuts */
  27138. var baseMinusTMin = base - tMin;
  27139. var floor = Math.floor;
  27140. var stringFromCharCode = String.fromCharCode;
  27141. /*--------------------------------------------------------------------------*/
  27142. /**
  27143. * A generic error utility function.
  27144. * @private
  27145. * @param {String} type The error type.
  27146. * @returns {Error} Throws a `RangeError` with the applicable error message.
  27147. */
  27148. function error(type) {
  27149. throw new RangeError(errors[type]);
  27150. }
  27151. /**
  27152. * A generic `Array#map` utility function.
  27153. * @private
  27154. * @param {Array} array The array to iterate over.
  27155. * @param {Function} callback The function that gets called for every array
  27156. * item.
  27157. * @returns {Array} A new array of values returned by the callback function.
  27158. */
  27159. function map$1(array, fn) {
  27160. var length = array.length;
  27161. var result = [];
  27162. while (length--) {
  27163. result[length] = fn(array[length]);
  27164. }
  27165. return result;
  27166. }
  27167. /**
  27168. * A simple `Array#map`-like wrapper to work with domain name strings or email
  27169. * addresses.
  27170. * @private
  27171. * @param {String} domain The domain name or email address.
  27172. * @param {Function} callback The function that gets called for every
  27173. * character.
  27174. * @returns {Array} A new string of characters returned by the callback
  27175. * function.
  27176. */
  27177. function mapDomain(string, fn) {
  27178. var parts = string.split('@');
  27179. var result = '';
  27180. if (parts.length > 1) {
  27181. // In email addresses, only the domain name should be punycoded. Leave
  27182. // the local part (i.e. everything up to `@`) intact.
  27183. result = parts[0] + '@';
  27184. string = parts[1];
  27185. }
  27186. // Avoid `split(regex)` for IE8 compatibility. See #17.
  27187. string = string.replace(regexSeparators, '\x2E');
  27188. var labels = string.split('.');
  27189. var encoded = map$1(labels, fn).join('.');
  27190. return result + encoded;
  27191. }
  27192. /**
  27193. * Creates an array containing the numeric code points of each Unicode
  27194. * character in the string. While JavaScript uses UCS-2 internally,
  27195. * this function will convert a pair of surrogate halves (each of which
  27196. * UCS-2 exposes as separate characters) into a single code point,
  27197. * matching UTF-16.
  27198. * @see `punycode.ucs2.encode`
  27199. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  27200. * @memberOf punycode.ucs2
  27201. * @name decode
  27202. * @param {String} string The Unicode input string (UCS-2).
  27203. * @returns {Array} The new array of code points.
  27204. */
  27205. function ucs2decode(string) {
  27206. var output = [],
  27207. counter = 0,
  27208. length = string.length,
  27209. value,
  27210. extra;
  27211. while (counter < length) {
  27212. value = string.charCodeAt(counter++);
  27213. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  27214. // high surrogate, and there is a next character
  27215. extra = string.charCodeAt(counter++);
  27216. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  27217. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  27218. } else {
  27219. // unmatched surrogate; only append this code unit, in case the next
  27220. // code unit is the high surrogate of a surrogate pair
  27221. output.push(value);
  27222. counter--;
  27223. }
  27224. } else {
  27225. output.push(value);
  27226. }
  27227. }
  27228. return output;
  27229. }
  27230. /**
  27231. * Converts a digit/integer into a basic code point.
  27232. * @see `basicToDigit()`
  27233. * @private
  27234. * @param {Number} digit The numeric value of a basic code point.
  27235. * @returns {Number} The basic code point whose value (when used for
  27236. * representing integers) is `digit`, which needs to be in the range
  27237. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  27238. * used; else, the lowercase form is used. The behavior is undefined
  27239. * if `flag` is non-zero and `digit` has no uppercase form.
  27240. */
  27241. function digitToBasic(digit, flag) {
  27242. // 0..25 map to ASCII a..z or A..Z
  27243. // 26..35 map to ASCII 0..9
  27244. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  27245. }
  27246. /**
  27247. * Bias adaptation function as per section 3.4 of RFC 3492.
  27248. * https://tools.ietf.org/html/rfc3492#section-3.4
  27249. * @private
  27250. */
  27251. function adapt(delta, numPoints, firstTime) {
  27252. var k = 0;
  27253. delta = firstTime ? floor(delta / damp) : delta >> 1;
  27254. delta += floor(delta / numPoints);
  27255. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  27256. delta = floor(delta / baseMinusTMin);
  27257. }
  27258. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  27259. }
  27260. /**
  27261. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  27262. * Punycode string of ASCII-only symbols.
  27263. * @memberOf punycode
  27264. * @param {String} input The string of Unicode symbols.
  27265. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  27266. */
  27267. function encode$1(input) {
  27268. var n,
  27269. delta,
  27270. handledCPCount,
  27271. basicLength,
  27272. bias,
  27273. j,
  27274. m,
  27275. q,
  27276. k,
  27277. t,
  27278. currentValue,
  27279. output = [],
  27280. /** `inputLength` will hold the number of code points in `input`. */
  27281. inputLength,
  27282. /** Cached calculation results */
  27283. handledCPCountPlusOne,
  27284. baseMinusT,
  27285. qMinusT;
  27286. // Convert the input in UCS-2 to Unicode
  27287. input = ucs2decode(input);
  27288. // Cache the length
  27289. inputLength = input.length;
  27290. // Initialize the state
  27291. n = initialN;
  27292. delta = 0;
  27293. bias = initialBias;
  27294. // Handle the basic code points
  27295. for (j = 0; j < inputLength; ++j) {
  27296. currentValue = input[j];
  27297. if (currentValue < 0x80) {
  27298. output.push(stringFromCharCode(currentValue));
  27299. }
  27300. }
  27301. handledCPCount = basicLength = output.length;
  27302. // `handledCPCount` is the number of code points that have been handled;
  27303. // `basicLength` is the number of basic code points.
  27304. // Finish the basic string - if it is not empty - with a delimiter
  27305. if (basicLength) {
  27306. output.push(delimiter);
  27307. }
  27308. // Main encoding loop:
  27309. while (handledCPCount < inputLength) {
  27310. // All non-basic code points < n have been handled already. Find the next
  27311. // larger one:
  27312. for (m = maxInt, j = 0; j < inputLength; ++j) {
  27313. currentValue = input[j];
  27314. if (currentValue >= n && currentValue < m) {
  27315. m = currentValue;
  27316. }
  27317. }
  27318. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  27319. // but guard against overflow
  27320. handledCPCountPlusOne = handledCPCount + 1;
  27321. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  27322. error('overflow');
  27323. }
  27324. delta += (m - n) * handledCPCountPlusOne;
  27325. n = m;
  27326. for (j = 0; j < inputLength; ++j) {
  27327. currentValue = input[j];
  27328. if (currentValue < n && ++delta > maxInt) {
  27329. error('overflow');
  27330. }
  27331. if (currentValue == n) {
  27332. // Represent delta as a generalized variable-length integer
  27333. for (q = delta, k = base; /* no condition */ ; k += base) {
  27334. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  27335. if (q < t) {
  27336. break;
  27337. }
  27338. qMinusT = q - t;
  27339. baseMinusT = base - t;
  27340. output.push(
  27341. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  27342. );
  27343. q = floor(qMinusT / baseMinusT);
  27344. }
  27345. output.push(stringFromCharCode(digitToBasic(q, 0)));
  27346. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  27347. delta = 0;
  27348. ++handledCPCount;
  27349. }
  27350. }
  27351. ++delta;
  27352. ++n;
  27353. }
  27354. return output.join('');
  27355. }
  27356. /**
  27357. * Converts a Unicode string representing a domain name or an email address to
  27358. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  27359. * i.e. it doesn't matter if you call it with a domain that's already in
  27360. * ASCII.
  27361. * @memberOf punycode
  27362. * @param {String} input The domain name or email address to convert, as a
  27363. * Unicode string.
  27364. * @returns {String} The Punycode representation of the given domain name or
  27365. * email address.
  27366. */
  27367. function toASCII(input) {
  27368. return mapDomain(input, function(string) {
  27369. return regexNonASCII.test(string) ?
  27370. 'xn--' + encode$1(string) :
  27371. string;
  27372. });
  27373. }
  27374. var lookup = [];
  27375. var revLookup = [];
  27376. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  27377. var inited = false;
  27378. function init () {
  27379. inited = true;
  27380. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  27381. for (var i = 0, len = code.length; i < len; ++i) {
  27382. lookup[i] = code[i];
  27383. revLookup[code.charCodeAt(i)] = i;
  27384. }
  27385. revLookup['-'.charCodeAt(0)] = 62;
  27386. revLookup['_'.charCodeAt(0)] = 63;
  27387. }
  27388. function toByteArray (b64) {
  27389. if (!inited) {
  27390. init();
  27391. }
  27392. var i, j, l, tmp, placeHolders, arr;
  27393. var len = b64.length;
  27394. if (len % 4 > 0) {
  27395. throw new Error('Invalid string. Length must be a multiple of 4')
  27396. }
  27397. // the number of equal signs (place holders)
  27398. // if there are two placeholders, than the two characters before it
  27399. // represent one byte
  27400. // if there is only one, then the three characters before it represent 2 bytes
  27401. // this is just a cheap hack to not do indexOf twice
  27402. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  27403. // base64 is 4/3 + up to two characters of the original data
  27404. arr = new Arr(len * 3 / 4 - placeHolders);
  27405. // if there are placeholders, only get up to the last complete 4 chars
  27406. l = placeHolders > 0 ? len - 4 : len;
  27407. var L = 0;
  27408. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  27409. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  27410. arr[L++] = (tmp >> 16) & 0xFF;
  27411. arr[L++] = (tmp >> 8) & 0xFF;
  27412. arr[L++] = tmp & 0xFF;
  27413. }
  27414. if (placeHolders === 2) {
  27415. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  27416. arr[L++] = tmp & 0xFF;
  27417. } else if (placeHolders === 1) {
  27418. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  27419. arr[L++] = (tmp >> 8) & 0xFF;
  27420. arr[L++] = tmp & 0xFF;
  27421. }
  27422. return arr
  27423. }
  27424. function tripletToBase64 (num) {
  27425. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  27426. }
  27427. function encodeChunk (uint8, start, end) {
  27428. var tmp;
  27429. var output = [];
  27430. for (var i = start; i < end; i += 3) {
  27431. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  27432. output.push(tripletToBase64(tmp));
  27433. }
  27434. return output.join('')
  27435. }
  27436. function fromByteArray (uint8) {
  27437. if (!inited) {
  27438. init();
  27439. }
  27440. var tmp;
  27441. var len = uint8.length;
  27442. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  27443. var output = '';
  27444. var parts = [];
  27445. var maxChunkLength = 16383; // must be multiple of 3
  27446. // go through the array every three bytes, we'll deal with trailing stuff later
  27447. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  27448. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  27449. }
  27450. // pad the end with zeros, but make sure to not forget the extra bytes
  27451. if (extraBytes === 1) {
  27452. tmp = uint8[len - 1];
  27453. output += lookup[tmp >> 2];
  27454. output += lookup[(tmp << 4) & 0x3F];
  27455. output += '==';
  27456. } else if (extraBytes === 2) {
  27457. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  27458. output += lookup[tmp >> 10];
  27459. output += lookup[(tmp >> 4) & 0x3F];
  27460. output += lookup[(tmp << 2) & 0x3F];
  27461. output += '=';
  27462. }
  27463. parts.push(output);
  27464. return parts.join('')
  27465. }
  27466. function read (buffer, offset, isLE, mLen, nBytes) {
  27467. var e, m;
  27468. var eLen = nBytes * 8 - mLen - 1;
  27469. var eMax = (1 << eLen) - 1;
  27470. var eBias = eMax >> 1;
  27471. var nBits = -7;
  27472. var i = isLE ? (nBytes - 1) : 0;
  27473. var d = isLE ? -1 : 1;
  27474. var s = buffer[offset + i];
  27475. i += d;
  27476. e = s & ((1 << (-nBits)) - 1);
  27477. s >>= (-nBits);
  27478. nBits += eLen;
  27479. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  27480. m = e & ((1 << (-nBits)) - 1);
  27481. e >>= (-nBits);
  27482. nBits += mLen;
  27483. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  27484. if (e === 0) {
  27485. e = 1 - eBias;
  27486. } else if (e === eMax) {
  27487. return m ? NaN : ((s ? -1 : 1) * Infinity)
  27488. } else {
  27489. m = m + Math.pow(2, mLen);
  27490. e = e - eBias;
  27491. }
  27492. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  27493. }
  27494. function write (buffer, value, offset, isLE, mLen, nBytes) {
  27495. var e, m, c;
  27496. var eLen = nBytes * 8 - mLen - 1;
  27497. var eMax = (1 << eLen) - 1;
  27498. var eBias = eMax >> 1;
  27499. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  27500. var i = isLE ? 0 : (nBytes - 1);
  27501. var d = isLE ? 1 : -1;
  27502. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  27503. value = Math.abs(value);
  27504. if (isNaN(value) || value === Infinity) {
  27505. m = isNaN(value) ? 1 : 0;
  27506. e = eMax;
  27507. } else {
  27508. e = Math.floor(Math.log(value) / Math.LN2);
  27509. if (value * (c = Math.pow(2, -e)) < 1) {
  27510. e--;
  27511. c *= 2;
  27512. }
  27513. if (e + eBias >= 1) {
  27514. value += rt / c;
  27515. } else {
  27516. value += rt * Math.pow(2, 1 - eBias);
  27517. }
  27518. if (value * c >= 2) {
  27519. e++;
  27520. c /= 2;
  27521. }
  27522. if (e + eBias >= eMax) {
  27523. m = 0;
  27524. e = eMax;
  27525. } else if (e + eBias >= 1) {
  27526. m = (value * c - 1) * Math.pow(2, mLen);
  27527. e = e + eBias;
  27528. } else {
  27529. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  27530. e = 0;
  27531. }
  27532. }
  27533. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  27534. e = (e << mLen) | m;
  27535. eLen += mLen;
  27536. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  27537. buffer[offset + i - d] |= s * 128;
  27538. }
  27539. var toString$1 = {}.toString;
  27540. var isArray$2 = Array.isArray || function (arr) {
  27541. return toString$1.call(arr) == '[object Array]';
  27542. };
  27543. /*!
  27544. * The buffer module from node.js, for the browser.
  27545. *
  27546. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  27547. * @license MIT
  27548. */
  27549. /* eslint-disable no-proto */
  27550. var INSPECT_MAX_BYTES = 50;
  27551. /**
  27552. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  27553. * === true Use Uint8Array implementation (fastest)
  27554. * === false Use Object implementation (most compatible, even IE6)
  27555. *
  27556. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  27557. * Opera 11.6+, iOS 4.2+.
  27558. *
  27559. * Due to various browser bugs, sometimes the Object implementation will be used even
  27560. * when the browser supports typed arrays.
  27561. *
  27562. * Note:
  27563. *
  27564. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  27565. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  27566. *
  27567. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  27568. *
  27569. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  27570. * incorrect length in some situations.
  27571. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  27572. * get the Object implementation, which is slower but behaves correctly.
  27573. */
  27574. Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
  27575. ? global$1.TYPED_ARRAY_SUPPORT
  27576. : true;
  27577. /*
  27578. * Export kMaxLength after typed array support is determined.
  27579. */
  27580. kMaxLength();
  27581. function kMaxLength () {
  27582. return Buffer$1.TYPED_ARRAY_SUPPORT
  27583. ? 0x7fffffff
  27584. : 0x3fffffff
  27585. }
  27586. function createBuffer (that, length) {
  27587. if (kMaxLength() < length) {
  27588. throw new RangeError('Invalid typed array length')
  27589. }
  27590. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27591. // Return an augmented `Uint8Array` instance, for best performance
  27592. that = new Uint8Array(length);
  27593. that.__proto__ = Buffer$1.prototype;
  27594. } else {
  27595. // Fallback: Return an object instance of the Buffer class
  27596. if (that === null) {
  27597. that = new Buffer$1(length);
  27598. }
  27599. that.length = length;
  27600. }
  27601. return that
  27602. }
  27603. /**
  27604. * The Buffer constructor returns instances of `Uint8Array` that have their
  27605. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  27606. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  27607. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  27608. * returns a single octet.
  27609. *
  27610. * The `Uint8Array` prototype remains unmodified.
  27611. */
  27612. function Buffer$1 (arg, encodingOrOffset, length) {
  27613. if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
  27614. return new Buffer$1(arg, encodingOrOffset, length)
  27615. }
  27616. // Common case.
  27617. if (typeof arg === 'number') {
  27618. if (typeof encodingOrOffset === 'string') {
  27619. throw new Error(
  27620. 'If encoding is specified then the first argument must be a string'
  27621. )
  27622. }
  27623. return allocUnsafe(this, arg)
  27624. }
  27625. return from(this, arg, encodingOrOffset, length)
  27626. }
  27627. Buffer$1.poolSize = 8192; // not used by this implementation
  27628. // TODO: Legacy, not needed anymore. Remove in next major version.
  27629. Buffer$1._augment = function (arr) {
  27630. arr.__proto__ = Buffer$1.prototype;
  27631. return arr
  27632. };
  27633. function from (that, value, encodingOrOffset, length) {
  27634. if (typeof value === 'number') {
  27635. throw new TypeError('"value" argument must not be a number')
  27636. }
  27637. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  27638. return fromArrayBuffer(that, value, encodingOrOffset, length)
  27639. }
  27640. if (typeof value === 'string') {
  27641. return fromString(that, value, encodingOrOffset)
  27642. }
  27643. return fromObject(that, value)
  27644. }
  27645. /**
  27646. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  27647. * if value is a number.
  27648. * Buffer.from(str[, encoding])
  27649. * Buffer.from(array)
  27650. * Buffer.from(buffer)
  27651. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  27652. **/
  27653. Buffer$1.from = function (value, encodingOrOffset, length) {
  27654. return from(null, value, encodingOrOffset, length)
  27655. };
  27656. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27657. Buffer$1.prototype.__proto__ = Uint8Array.prototype;
  27658. Buffer$1.__proto__ = Uint8Array;
  27659. if (typeof Symbol !== 'undefined' && Symbol.species &&
  27660. Buffer$1[Symbol.species] === Buffer$1) ;
  27661. }
  27662. function assertSize (size) {
  27663. if (typeof size !== 'number') {
  27664. throw new TypeError('"size" argument must be a number')
  27665. } else if (size < 0) {
  27666. throw new RangeError('"size" argument must not be negative')
  27667. }
  27668. }
  27669. function alloc (that, size, fill, encoding) {
  27670. assertSize(size);
  27671. if (size <= 0) {
  27672. return createBuffer(that, size)
  27673. }
  27674. if (fill !== undefined) {
  27675. // Only pay attention to encoding if it's a string. This
  27676. // prevents accidentally sending in a number that would
  27677. // be interpretted as a start offset.
  27678. return typeof encoding === 'string'
  27679. ? createBuffer(that, size).fill(fill, encoding)
  27680. : createBuffer(that, size).fill(fill)
  27681. }
  27682. return createBuffer(that, size)
  27683. }
  27684. /**
  27685. * Creates a new filled Buffer instance.
  27686. * alloc(size[, fill[, encoding]])
  27687. **/
  27688. Buffer$1.alloc = function (size, fill, encoding) {
  27689. return alloc(null, size, fill, encoding)
  27690. };
  27691. function allocUnsafe (that, size) {
  27692. assertSize(size);
  27693. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  27694. if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
  27695. for (var i = 0; i < size; ++i) {
  27696. that[i] = 0;
  27697. }
  27698. }
  27699. return that
  27700. }
  27701. /**
  27702. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  27703. * */
  27704. Buffer$1.allocUnsafe = function (size) {
  27705. return allocUnsafe(null, size)
  27706. };
  27707. /**
  27708. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  27709. */
  27710. Buffer$1.allocUnsafeSlow = function (size) {
  27711. return allocUnsafe(null, size)
  27712. };
  27713. function fromString (that, string, encoding) {
  27714. if (typeof encoding !== 'string' || encoding === '') {
  27715. encoding = 'utf8';
  27716. }
  27717. if (!Buffer$1.isEncoding(encoding)) {
  27718. throw new TypeError('"encoding" must be a valid string encoding')
  27719. }
  27720. var length = byteLength(string, encoding) | 0;
  27721. that = createBuffer(that, length);
  27722. var actual = that.write(string, encoding);
  27723. if (actual !== length) {
  27724. // Writing a hex string, for example, that contains invalid characters will
  27725. // cause everything after the first invalid character to be ignored. (e.g.
  27726. // 'abxxcd' will be treated as 'ab')
  27727. that = that.slice(0, actual);
  27728. }
  27729. return that
  27730. }
  27731. function fromArrayLike (that, array) {
  27732. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  27733. that = createBuffer(that, length);
  27734. for (var i = 0; i < length; i += 1) {
  27735. that[i] = array[i] & 255;
  27736. }
  27737. return that
  27738. }
  27739. function fromArrayBuffer (that, array, byteOffset, length) {
  27740. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  27741. if (byteOffset < 0 || array.byteLength < byteOffset) {
  27742. throw new RangeError('\'offset\' is out of bounds')
  27743. }
  27744. if (array.byteLength < byteOffset + (length || 0)) {
  27745. throw new RangeError('\'length\' is out of bounds')
  27746. }
  27747. if (byteOffset === undefined && length === undefined) {
  27748. array = new Uint8Array(array);
  27749. } else if (length === undefined) {
  27750. array = new Uint8Array(array, byteOffset);
  27751. } else {
  27752. array = new Uint8Array(array, byteOffset, length);
  27753. }
  27754. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27755. // Return an augmented `Uint8Array` instance, for best performance
  27756. that = array;
  27757. that.__proto__ = Buffer$1.prototype;
  27758. } else {
  27759. // Fallback: Return an object instance of the Buffer class
  27760. that = fromArrayLike(that, array);
  27761. }
  27762. return that
  27763. }
  27764. function fromObject (that, obj) {
  27765. if (internalIsBuffer(obj)) {
  27766. var len = checked(obj.length) | 0;
  27767. that = createBuffer(that, len);
  27768. if (that.length === 0) {
  27769. return that
  27770. }
  27771. obj.copy(that, 0, 0, len);
  27772. return that
  27773. }
  27774. if (obj) {
  27775. if ((typeof ArrayBuffer !== 'undefined' &&
  27776. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  27777. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  27778. return createBuffer(that, 0)
  27779. }
  27780. return fromArrayLike(that, obj)
  27781. }
  27782. if (obj.type === 'Buffer' && isArray$2(obj.data)) {
  27783. return fromArrayLike(that, obj.data)
  27784. }
  27785. }
  27786. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  27787. }
  27788. function checked (length) {
  27789. // Note: cannot use `length < kMaxLength()` here because that fails when
  27790. // length is NaN (which is otherwise coerced to zero.)
  27791. if (length >= kMaxLength()) {
  27792. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  27793. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  27794. }
  27795. return length | 0
  27796. }
  27797. Buffer$1.isBuffer = isBuffer$1;
  27798. function internalIsBuffer (b) {
  27799. return !!(b != null && b._isBuffer)
  27800. }
  27801. Buffer$1.compare = function compare (a, b) {
  27802. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  27803. throw new TypeError('Arguments must be Buffers')
  27804. }
  27805. if (a === b) return 0
  27806. var x = a.length;
  27807. var y = b.length;
  27808. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  27809. if (a[i] !== b[i]) {
  27810. x = a[i];
  27811. y = b[i];
  27812. break
  27813. }
  27814. }
  27815. if (x < y) return -1
  27816. if (y < x) return 1
  27817. return 0
  27818. };
  27819. Buffer$1.isEncoding = function isEncoding (encoding) {
  27820. switch (String(encoding).toLowerCase()) {
  27821. case 'hex':
  27822. case 'utf8':
  27823. case 'utf-8':
  27824. case 'ascii':
  27825. case 'latin1':
  27826. case 'binary':
  27827. case 'base64':
  27828. case 'ucs2':
  27829. case 'ucs-2':
  27830. case 'utf16le':
  27831. case 'utf-16le':
  27832. return true
  27833. default:
  27834. return false
  27835. }
  27836. };
  27837. Buffer$1.concat = function concat (list, length) {
  27838. if (!isArray$2(list)) {
  27839. throw new TypeError('"list" argument must be an Array of Buffers')
  27840. }
  27841. if (list.length === 0) {
  27842. return Buffer$1.alloc(0)
  27843. }
  27844. var i;
  27845. if (length === undefined) {
  27846. length = 0;
  27847. for (i = 0; i < list.length; ++i) {
  27848. length += list[i].length;
  27849. }
  27850. }
  27851. var buffer = Buffer$1.allocUnsafe(length);
  27852. var pos = 0;
  27853. for (i = 0; i < list.length; ++i) {
  27854. var buf = list[i];
  27855. if (!internalIsBuffer(buf)) {
  27856. throw new TypeError('"list" argument must be an Array of Buffers')
  27857. }
  27858. buf.copy(buffer, pos);
  27859. pos += buf.length;
  27860. }
  27861. return buffer
  27862. };
  27863. function byteLength (string, encoding) {
  27864. if (internalIsBuffer(string)) {
  27865. return string.length
  27866. }
  27867. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  27868. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  27869. return string.byteLength
  27870. }
  27871. if (typeof string !== 'string') {
  27872. string = '' + string;
  27873. }
  27874. var len = string.length;
  27875. if (len === 0) return 0
  27876. // Use a for loop to avoid recursion
  27877. var loweredCase = false;
  27878. for (;;) {
  27879. switch (encoding) {
  27880. case 'ascii':
  27881. case 'latin1':
  27882. case 'binary':
  27883. return len
  27884. case 'utf8':
  27885. case 'utf-8':
  27886. case undefined:
  27887. return utf8ToBytes(string).length
  27888. case 'ucs2':
  27889. case 'ucs-2':
  27890. case 'utf16le':
  27891. case 'utf-16le':
  27892. return len * 2
  27893. case 'hex':
  27894. return len >>> 1
  27895. case 'base64':
  27896. return base64ToBytes(string).length
  27897. default:
  27898. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  27899. encoding = ('' + encoding).toLowerCase();
  27900. loweredCase = true;
  27901. }
  27902. }
  27903. }
  27904. Buffer$1.byteLength = byteLength;
  27905. function slowToString (encoding, start, end) {
  27906. var loweredCase = false;
  27907. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  27908. // property of a typed array.
  27909. // This behaves neither like String nor Uint8Array in that we set start/end
  27910. // to their upper/lower bounds if the value passed is out of range.
  27911. // undefined is handled specially as per ECMA-262 6th Edition,
  27912. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  27913. if (start === undefined || start < 0) {
  27914. start = 0;
  27915. }
  27916. // Return early if start > this.length. Done here to prevent potential uint32
  27917. // coercion fail below.
  27918. if (start > this.length) {
  27919. return ''
  27920. }
  27921. if (end === undefined || end > this.length) {
  27922. end = this.length;
  27923. }
  27924. if (end <= 0) {
  27925. return ''
  27926. }
  27927. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  27928. end >>>= 0;
  27929. start >>>= 0;
  27930. if (end <= start) {
  27931. return ''
  27932. }
  27933. if (!encoding) encoding = 'utf8';
  27934. while (true) {
  27935. switch (encoding) {
  27936. case 'hex':
  27937. return hexSlice(this, start, end)
  27938. case 'utf8':
  27939. case 'utf-8':
  27940. return utf8Slice(this, start, end)
  27941. case 'ascii':
  27942. return asciiSlice(this, start, end)
  27943. case 'latin1':
  27944. case 'binary':
  27945. return latin1Slice(this, start, end)
  27946. case 'base64':
  27947. return base64Slice(this, start, end)
  27948. case 'ucs2':
  27949. case 'ucs-2':
  27950. case 'utf16le':
  27951. case 'utf-16le':
  27952. return utf16leSlice(this, start, end)
  27953. default:
  27954. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27955. encoding = (encoding + '').toLowerCase();
  27956. loweredCase = true;
  27957. }
  27958. }
  27959. }
  27960. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  27961. // Buffer instances.
  27962. Buffer$1.prototype._isBuffer = true;
  27963. function swap (b, n, m) {
  27964. var i = b[n];
  27965. b[n] = b[m];
  27966. b[m] = i;
  27967. }
  27968. Buffer$1.prototype.swap16 = function swap16 () {
  27969. var len = this.length;
  27970. if (len % 2 !== 0) {
  27971. throw new RangeError('Buffer size must be a multiple of 16-bits')
  27972. }
  27973. for (var i = 0; i < len; i += 2) {
  27974. swap(this, i, i + 1);
  27975. }
  27976. return this
  27977. };
  27978. Buffer$1.prototype.swap32 = function swap32 () {
  27979. var len = this.length;
  27980. if (len % 4 !== 0) {
  27981. throw new RangeError('Buffer size must be a multiple of 32-bits')
  27982. }
  27983. for (var i = 0; i < len; i += 4) {
  27984. swap(this, i, i + 3);
  27985. swap(this, i + 1, i + 2);
  27986. }
  27987. return this
  27988. };
  27989. Buffer$1.prototype.swap64 = function swap64 () {
  27990. var len = this.length;
  27991. if (len % 8 !== 0) {
  27992. throw new RangeError('Buffer size must be a multiple of 64-bits')
  27993. }
  27994. for (var i = 0; i < len; i += 8) {
  27995. swap(this, i, i + 7);
  27996. swap(this, i + 1, i + 6);
  27997. swap(this, i + 2, i + 5);
  27998. swap(this, i + 3, i + 4);
  27999. }
  28000. return this
  28001. };
  28002. Buffer$1.prototype.toString = function toString () {
  28003. var length = this.length | 0;
  28004. if (length === 0) return ''
  28005. if (arguments.length === 0) return utf8Slice(this, 0, length)
  28006. return slowToString.apply(this, arguments)
  28007. };
  28008. Buffer$1.prototype.equals = function equals (b) {
  28009. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  28010. if (this === b) return true
  28011. return Buffer$1.compare(this, b) === 0
  28012. };
  28013. Buffer$1.prototype.inspect = function inspect () {
  28014. var str = '';
  28015. var max = INSPECT_MAX_BYTES;
  28016. if (this.length > 0) {
  28017. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  28018. if (this.length > max) str += ' ... ';
  28019. }
  28020. return '<Buffer ' + str + '>'
  28021. };
  28022. Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  28023. if (!internalIsBuffer(target)) {
  28024. throw new TypeError('Argument must be a Buffer')
  28025. }
  28026. if (start === undefined) {
  28027. start = 0;
  28028. }
  28029. if (end === undefined) {
  28030. end = target ? target.length : 0;
  28031. }
  28032. if (thisStart === undefined) {
  28033. thisStart = 0;
  28034. }
  28035. if (thisEnd === undefined) {
  28036. thisEnd = this.length;
  28037. }
  28038. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  28039. throw new RangeError('out of range index')
  28040. }
  28041. if (thisStart >= thisEnd && start >= end) {
  28042. return 0
  28043. }
  28044. if (thisStart >= thisEnd) {
  28045. return -1
  28046. }
  28047. if (start >= end) {
  28048. return 1
  28049. }
  28050. start >>>= 0;
  28051. end >>>= 0;
  28052. thisStart >>>= 0;
  28053. thisEnd >>>= 0;
  28054. if (this === target) return 0
  28055. var x = thisEnd - thisStart;
  28056. var y = end - start;
  28057. var len = Math.min(x, y);
  28058. var thisCopy = this.slice(thisStart, thisEnd);
  28059. var targetCopy = target.slice(start, end);
  28060. for (var i = 0; i < len; ++i) {
  28061. if (thisCopy[i] !== targetCopy[i]) {
  28062. x = thisCopy[i];
  28063. y = targetCopy[i];
  28064. break
  28065. }
  28066. }
  28067. if (x < y) return -1
  28068. if (y < x) return 1
  28069. return 0
  28070. };
  28071. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  28072. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  28073. //
  28074. // Arguments:
  28075. // - buffer - a Buffer to search
  28076. // - val - a string, Buffer, or number
  28077. // - byteOffset - an index into `buffer`; will be clamped to an int32
  28078. // - encoding - an optional encoding, relevant is val is a string
  28079. // - dir - true for indexOf, false for lastIndexOf
  28080. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  28081. // Empty buffer means no match
  28082. if (buffer.length === 0) return -1
  28083. // Normalize byteOffset
  28084. if (typeof byteOffset === 'string') {
  28085. encoding = byteOffset;
  28086. byteOffset = 0;
  28087. } else if (byteOffset > 0x7fffffff) {
  28088. byteOffset = 0x7fffffff;
  28089. } else if (byteOffset < -2147483648) {
  28090. byteOffset = -2147483648;
  28091. }
  28092. byteOffset = +byteOffset; // Coerce to Number.
  28093. if (isNaN(byteOffset)) {
  28094. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  28095. byteOffset = dir ? 0 : (buffer.length - 1);
  28096. }
  28097. // Normalize byteOffset: negative offsets start from the end of the buffer
  28098. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  28099. if (byteOffset >= buffer.length) {
  28100. if (dir) return -1
  28101. else byteOffset = buffer.length - 1;
  28102. } else if (byteOffset < 0) {
  28103. if (dir) byteOffset = 0;
  28104. else return -1
  28105. }
  28106. // Normalize val
  28107. if (typeof val === 'string') {
  28108. val = Buffer$1.from(val, encoding);
  28109. }
  28110. // Finally, search either indexOf (if dir is true) or lastIndexOf
  28111. if (internalIsBuffer(val)) {
  28112. // Special case: looking for empty string/buffer always fails
  28113. if (val.length === 0) {
  28114. return -1
  28115. }
  28116. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  28117. } else if (typeof val === 'number') {
  28118. val = val & 0xFF; // Search for a byte value [0-255]
  28119. if (Buffer$1.TYPED_ARRAY_SUPPORT &&
  28120. typeof Uint8Array.prototype.indexOf === 'function') {
  28121. if (dir) {
  28122. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  28123. } else {
  28124. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  28125. }
  28126. }
  28127. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  28128. }
  28129. throw new TypeError('val must be string, number or Buffer')
  28130. }
  28131. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  28132. var indexSize = 1;
  28133. var arrLength = arr.length;
  28134. var valLength = val.length;
  28135. if (encoding !== undefined) {
  28136. encoding = String(encoding).toLowerCase();
  28137. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  28138. encoding === 'utf16le' || encoding === 'utf-16le') {
  28139. if (arr.length < 2 || val.length < 2) {
  28140. return -1
  28141. }
  28142. indexSize = 2;
  28143. arrLength /= 2;
  28144. valLength /= 2;
  28145. byteOffset /= 2;
  28146. }
  28147. }
  28148. function read (buf, i) {
  28149. if (indexSize === 1) {
  28150. return buf[i]
  28151. } else {
  28152. return buf.readUInt16BE(i * indexSize)
  28153. }
  28154. }
  28155. var i;
  28156. if (dir) {
  28157. var foundIndex = -1;
  28158. for (i = byteOffset; i < arrLength; i++) {
  28159. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  28160. if (foundIndex === -1) foundIndex = i;
  28161. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  28162. } else {
  28163. if (foundIndex !== -1) i -= i - foundIndex;
  28164. foundIndex = -1;
  28165. }
  28166. }
  28167. } else {
  28168. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  28169. for (i = byteOffset; i >= 0; i--) {
  28170. var found = true;
  28171. for (var j = 0; j < valLength; j++) {
  28172. if (read(arr, i + j) !== read(val, j)) {
  28173. found = false;
  28174. break
  28175. }
  28176. }
  28177. if (found) return i
  28178. }
  28179. }
  28180. return -1
  28181. }
  28182. Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
  28183. return this.indexOf(val, byteOffset, encoding) !== -1
  28184. };
  28185. Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  28186. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  28187. };
  28188. Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  28189. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  28190. };
  28191. function hexWrite (buf, string, offset, length) {
  28192. offset = Number(offset) || 0;
  28193. var remaining = buf.length - offset;
  28194. if (!length) {
  28195. length = remaining;
  28196. } else {
  28197. length = Number(length);
  28198. if (length > remaining) {
  28199. length = remaining;
  28200. }
  28201. }
  28202. // must be an even number of digits
  28203. var strLen = string.length;
  28204. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  28205. if (length > strLen / 2) {
  28206. length = strLen / 2;
  28207. }
  28208. for (var i = 0; i < length; ++i) {
  28209. var parsed = parseInt(string.substr(i * 2, 2), 16);
  28210. if (isNaN(parsed)) return i
  28211. buf[offset + i] = parsed;
  28212. }
  28213. return i
  28214. }
  28215. function utf8Write (buf, string, offset, length) {
  28216. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  28217. }
  28218. function asciiWrite (buf, string, offset, length) {
  28219. return blitBuffer(asciiToBytes(string), buf, offset, length)
  28220. }
  28221. function latin1Write (buf, string, offset, length) {
  28222. return asciiWrite(buf, string, offset, length)
  28223. }
  28224. function base64Write (buf, string, offset, length) {
  28225. return blitBuffer(base64ToBytes(string), buf, offset, length)
  28226. }
  28227. function ucs2Write (buf, string, offset, length) {
  28228. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  28229. }
  28230. Buffer$1.prototype.write = function write (string, offset, length, encoding) {
  28231. // Buffer#write(string)
  28232. if (offset === undefined) {
  28233. encoding = 'utf8';
  28234. length = this.length;
  28235. offset = 0;
  28236. // Buffer#write(string, encoding)
  28237. } else if (length === undefined && typeof offset === 'string') {
  28238. encoding = offset;
  28239. length = this.length;
  28240. offset = 0;
  28241. // Buffer#write(string, offset[, length][, encoding])
  28242. } else if (isFinite(offset)) {
  28243. offset = offset | 0;
  28244. if (isFinite(length)) {
  28245. length = length | 0;
  28246. if (encoding === undefined) encoding = 'utf8';
  28247. } else {
  28248. encoding = length;
  28249. length = undefined;
  28250. }
  28251. // legacy write(string, encoding, offset, length) - remove in v0.13
  28252. } else {
  28253. throw new Error(
  28254. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  28255. )
  28256. }
  28257. var remaining = this.length - offset;
  28258. if (length === undefined || length > remaining) length = remaining;
  28259. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  28260. throw new RangeError('Attempt to write outside buffer bounds')
  28261. }
  28262. if (!encoding) encoding = 'utf8';
  28263. var loweredCase = false;
  28264. for (;;) {
  28265. switch (encoding) {
  28266. case 'hex':
  28267. return hexWrite(this, string, offset, length)
  28268. case 'utf8':
  28269. case 'utf-8':
  28270. return utf8Write(this, string, offset, length)
  28271. case 'ascii':
  28272. return asciiWrite(this, string, offset, length)
  28273. case 'latin1':
  28274. case 'binary':
  28275. return latin1Write(this, string, offset, length)
  28276. case 'base64':
  28277. // Warning: maxLength not taken into account in base64Write
  28278. return base64Write(this, string, offset, length)
  28279. case 'ucs2':
  28280. case 'ucs-2':
  28281. case 'utf16le':
  28282. case 'utf-16le':
  28283. return ucs2Write(this, string, offset, length)
  28284. default:
  28285. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  28286. encoding = ('' + encoding).toLowerCase();
  28287. loweredCase = true;
  28288. }
  28289. }
  28290. };
  28291. Buffer$1.prototype.toJSON = function toJSON () {
  28292. return {
  28293. type: 'Buffer',
  28294. data: Array.prototype.slice.call(this._arr || this, 0)
  28295. }
  28296. };
  28297. function base64Slice (buf, start, end) {
  28298. if (start === 0 && end === buf.length) {
  28299. return fromByteArray(buf)
  28300. } else {
  28301. return fromByteArray(buf.slice(start, end))
  28302. }
  28303. }
  28304. function utf8Slice (buf, start, end) {
  28305. end = Math.min(buf.length, end);
  28306. var res = [];
  28307. var i = start;
  28308. while (i < end) {
  28309. var firstByte = buf[i];
  28310. var codePoint = null;
  28311. var bytesPerSequence = (firstByte > 0xEF) ? 4
  28312. : (firstByte > 0xDF) ? 3
  28313. : (firstByte > 0xBF) ? 2
  28314. : 1;
  28315. if (i + bytesPerSequence <= end) {
  28316. var secondByte, thirdByte, fourthByte, tempCodePoint;
  28317. switch (bytesPerSequence) {
  28318. case 1:
  28319. if (firstByte < 0x80) {
  28320. codePoint = firstByte;
  28321. }
  28322. break
  28323. case 2:
  28324. secondByte = buf[i + 1];
  28325. if ((secondByte & 0xC0) === 0x80) {
  28326. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  28327. if (tempCodePoint > 0x7F) {
  28328. codePoint = tempCodePoint;
  28329. }
  28330. }
  28331. break
  28332. case 3:
  28333. secondByte = buf[i + 1];
  28334. thirdByte = buf[i + 2];
  28335. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  28336. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  28337. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  28338. codePoint = tempCodePoint;
  28339. }
  28340. }
  28341. break
  28342. case 4:
  28343. secondByte = buf[i + 1];
  28344. thirdByte = buf[i + 2];
  28345. fourthByte = buf[i + 3];
  28346. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  28347. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  28348. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  28349. codePoint = tempCodePoint;
  28350. }
  28351. }
  28352. }
  28353. }
  28354. if (codePoint === null) {
  28355. // we did not generate a valid codePoint so insert a
  28356. // replacement char (U+FFFD) and advance only 1 byte
  28357. codePoint = 0xFFFD;
  28358. bytesPerSequence = 1;
  28359. } else if (codePoint > 0xFFFF) {
  28360. // encode to utf16 (surrogate pair dance)
  28361. codePoint -= 0x10000;
  28362. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  28363. codePoint = 0xDC00 | codePoint & 0x3FF;
  28364. }
  28365. res.push(codePoint);
  28366. i += bytesPerSequence;
  28367. }
  28368. return decodeCodePointsArray(res)
  28369. }
  28370. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  28371. // the lowest limit is Chrome, with 0x10000 args.
  28372. // We go 1 magnitude less, for safety
  28373. var MAX_ARGUMENTS_LENGTH = 0x1000;
  28374. function decodeCodePointsArray (codePoints) {
  28375. var len = codePoints.length;
  28376. if (len <= MAX_ARGUMENTS_LENGTH) {
  28377. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  28378. }
  28379. // Decode in chunks to avoid "call stack size exceeded".
  28380. var res = '';
  28381. var i = 0;
  28382. while (i < len) {
  28383. res += String.fromCharCode.apply(
  28384. String,
  28385. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  28386. );
  28387. }
  28388. return res
  28389. }
  28390. function asciiSlice (buf, start, end) {
  28391. var ret = '';
  28392. end = Math.min(buf.length, end);
  28393. for (var i = start; i < end; ++i) {
  28394. ret += String.fromCharCode(buf[i] & 0x7F);
  28395. }
  28396. return ret
  28397. }
  28398. function latin1Slice (buf, start, end) {
  28399. var ret = '';
  28400. end = Math.min(buf.length, end);
  28401. for (var i = start; i < end; ++i) {
  28402. ret += String.fromCharCode(buf[i]);
  28403. }
  28404. return ret
  28405. }
  28406. function hexSlice (buf, start, end) {
  28407. var len = buf.length;
  28408. if (!start || start < 0) start = 0;
  28409. if (!end || end < 0 || end > len) end = len;
  28410. var out = '';
  28411. for (var i = start; i < end; ++i) {
  28412. out += toHex(buf[i]);
  28413. }
  28414. return out
  28415. }
  28416. function utf16leSlice (buf, start, end) {
  28417. var bytes = buf.slice(start, end);
  28418. var res = '';
  28419. for (var i = 0; i < bytes.length; i += 2) {
  28420. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  28421. }
  28422. return res
  28423. }
  28424. Buffer$1.prototype.slice = function slice (start, end) {
  28425. var len = this.length;
  28426. start = ~~start;
  28427. end = end === undefined ? len : ~~end;
  28428. if (start < 0) {
  28429. start += len;
  28430. if (start < 0) start = 0;
  28431. } else if (start > len) {
  28432. start = len;
  28433. }
  28434. if (end < 0) {
  28435. end += len;
  28436. if (end < 0) end = 0;
  28437. } else if (end > len) {
  28438. end = len;
  28439. }
  28440. if (end < start) end = start;
  28441. var newBuf;
  28442. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28443. newBuf = this.subarray(start, end);
  28444. newBuf.__proto__ = Buffer$1.prototype;
  28445. } else {
  28446. var sliceLen = end - start;
  28447. newBuf = new Buffer$1(sliceLen, undefined);
  28448. for (var i = 0; i < sliceLen; ++i) {
  28449. newBuf[i] = this[i + start];
  28450. }
  28451. }
  28452. return newBuf
  28453. };
  28454. /*
  28455. * Need to make sure that buffer isn't trying to write out of bounds.
  28456. */
  28457. function checkOffset (offset, ext, length) {
  28458. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  28459. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  28460. }
  28461. Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  28462. offset = offset | 0;
  28463. byteLength = byteLength | 0;
  28464. if (!noAssert) checkOffset(offset, byteLength, this.length);
  28465. var val = this[offset];
  28466. var mul = 1;
  28467. var i = 0;
  28468. while (++i < byteLength && (mul *= 0x100)) {
  28469. val += this[offset + i] * mul;
  28470. }
  28471. return val
  28472. };
  28473. Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  28474. offset = offset | 0;
  28475. byteLength = byteLength | 0;
  28476. if (!noAssert) {
  28477. checkOffset(offset, byteLength, this.length);
  28478. }
  28479. var val = this[offset + --byteLength];
  28480. var mul = 1;
  28481. while (byteLength > 0 && (mul *= 0x100)) {
  28482. val += this[offset + --byteLength] * mul;
  28483. }
  28484. return val
  28485. };
  28486. Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  28487. if (!noAssert) checkOffset(offset, 1, this.length);
  28488. return this[offset]
  28489. };
  28490. Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  28491. if (!noAssert) checkOffset(offset, 2, this.length);
  28492. return this[offset] | (this[offset + 1] << 8)
  28493. };
  28494. Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  28495. if (!noAssert) checkOffset(offset, 2, this.length);
  28496. return (this[offset] << 8) | this[offset + 1]
  28497. };
  28498. Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  28499. if (!noAssert) checkOffset(offset, 4, this.length);
  28500. return ((this[offset]) |
  28501. (this[offset + 1] << 8) |
  28502. (this[offset + 2] << 16)) +
  28503. (this[offset + 3] * 0x1000000)
  28504. };
  28505. Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  28506. if (!noAssert) checkOffset(offset, 4, this.length);
  28507. return (this[offset] * 0x1000000) +
  28508. ((this[offset + 1] << 16) |
  28509. (this[offset + 2] << 8) |
  28510. this[offset + 3])
  28511. };
  28512. Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  28513. offset = offset | 0;
  28514. byteLength = byteLength | 0;
  28515. if (!noAssert) checkOffset(offset, byteLength, this.length);
  28516. var val = this[offset];
  28517. var mul = 1;
  28518. var i = 0;
  28519. while (++i < byteLength && (mul *= 0x100)) {
  28520. val += this[offset + i] * mul;
  28521. }
  28522. mul *= 0x80;
  28523. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  28524. return val
  28525. };
  28526. Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  28527. offset = offset | 0;
  28528. byteLength = byteLength | 0;
  28529. if (!noAssert) checkOffset(offset, byteLength, this.length);
  28530. var i = byteLength;
  28531. var mul = 1;
  28532. var val = this[offset + --i];
  28533. while (i > 0 && (mul *= 0x100)) {
  28534. val += this[offset + --i] * mul;
  28535. }
  28536. mul *= 0x80;
  28537. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  28538. return val
  28539. };
  28540. Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
  28541. if (!noAssert) checkOffset(offset, 1, this.length);
  28542. if (!(this[offset] & 0x80)) return (this[offset])
  28543. return ((0xff - this[offset] + 1) * -1)
  28544. };
  28545. Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  28546. if (!noAssert) checkOffset(offset, 2, this.length);
  28547. var val = this[offset] | (this[offset + 1] << 8);
  28548. return (val & 0x8000) ? val | 0xFFFF0000 : val
  28549. };
  28550. Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  28551. if (!noAssert) checkOffset(offset, 2, this.length);
  28552. var val = this[offset + 1] | (this[offset] << 8);
  28553. return (val & 0x8000) ? val | 0xFFFF0000 : val
  28554. };
  28555. Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  28556. if (!noAssert) checkOffset(offset, 4, this.length);
  28557. return (this[offset]) |
  28558. (this[offset + 1] << 8) |
  28559. (this[offset + 2] << 16) |
  28560. (this[offset + 3] << 24)
  28561. };
  28562. Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  28563. if (!noAssert) checkOffset(offset, 4, this.length);
  28564. return (this[offset] << 24) |
  28565. (this[offset + 1] << 16) |
  28566. (this[offset + 2] << 8) |
  28567. (this[offset + 3])
  28568. };
  28569. Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  28570. if (!noAssert) checkOffset(offset, 4, this.length);
  28571. return read(this, offset, true, 23, 4)
  28572. };
  28573. Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  28574. if (!noAssert) checkOffset(offset, 4, this.length);
  28575. return read(this, offset, false, 23, 4)
  28576. };
  28577. Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  28578. if (!noAssert) checkOffset(offset, 8, this.length);
  28579. return read(this, offset, true, 52, 8)
  28580. };
  28581. Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  28582. if (!noAssert) checkOffset(offset, 8, this.length);
  28583. return read(this, offset, false, 52, 8)
  28584. };
  28585. function checkInt (buf, value, offset, ext, max, min) {
  28586. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  28587. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  28588. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  28589. }
  28590. Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  28591. value = +value;
  28592. offset = offset | 0;
  28593. byteLength = byteLength | 0;
  28594. if (!noAssert) {
  28595. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  28596. checkInt(this, value, offset, byteLength, maxBytes, 0);
  28597. }
  28598. var mul = 1;
  28599. var i = 0;
  28600. this[offset] = value & 0xFF;
  28601. while (++i < byteLength && (mul *= 0x100)) {
  28602. this[offset + i] = (value / mul) & 0xFF;
  28603. }
  28604. return offset + byteLength
  28605. };
  28606. Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  28607. value = +value;
  28608. offset = offset | 0;
  28609. byteLength = byteLength | 0;
  28610. if (!noAssert) {
  28611. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  28612. checkInt(this, value, offset, byteLength, maxBytes, 0);
  28613. }
  28614. var i = byteLength - 1;
  28615. var mul = 1;
  28616. this[offset + i] = value & 0xFF;
  28617. while (--i >= 0 && (mul *= 0x100)) {
  28618. this[offset + i] = (value / mul) & 0xFF;
  28619. }
  28620. return offset + byteLength
  28621. };
  28622. Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  28623. value = +value;
  28624. offset = offset | 0;
  28625. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  28626. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  28627. this[offset] = (value & 0xff);
  28628. return offset + 1
  28629. };
  28630. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  28631. if (value < 0) value = 0xffff + value + 1;
  28632. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  28633. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  28634. (littleEndian ? i : 1 - i) * 8;
  28635. }
  28636. }
  28637. Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  28638. value = +value;
  28639. offset = offset | 0;
  28640. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  28641. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28642. this[offset] = (value & 0xff);
  28643. this[offset + 1] = (value >>> 8);
  28644. } else {
  28645. objectWriteUInt16(this, value, offset, true);
  28646. }
  28647. return offset + 2
  28648. };
  28649. Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  28650. value = +value;
  28651. offset = offset | 0;
  28652. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  28653. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28654. this[offset] = (value >>> 8);
  28655. this[offset + 1] = (value & 0xff);
  28656. } else {
  28657. objectWriteUInt16(this, value, offset, false);
  28658. }
  28659. return offset + 2
  28660. };
  28661. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  28662. if (value < 0) value = 0xffffffff + value + 1;
  28663. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  28664. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  28665. }
  28666. }
  28667. Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  28668. value = +value;
  28669. offset = offset | 0;
  28670. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  28671. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28672. this[offset + 3] = (value >>> 24);
  28673. this[offset + 2] = (value >>> 16);
  28674. this[offset + 1] = (value >>> 8);
  28675. this[offset] = (value & 0xff);
  28676. } else {
  28677. objectWriteUInt32(this, value, offset, true);
  28678. }
  28679. return offset + 4
  28680. };
  28681. Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  28682. value = +value;
  28683. offset = offset | 0;
  28684. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  28685. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28686. this[offset] = (value >>> 24);
  28687. this[offset + 1] = (value >>> 16);
  28688. this[offset + 2] = (value >>> 8);
  28689. this[offset + 3] = (value & 0xff);
  28690. } else {
  28691. objectWriteUInt32(this, value, offset, false);
  28692. }
  28693. return offset + 4
  28694. };
  28695. Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  28696. value = +value;
  28697. offset = offset | 0;
  28698. if (!noAssert) {
  28699. var limit = Math.pow(2, 8 * byteLength - 1);
  28700. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  28701. }
  28702. var i = 0;
  28703. var mul = 1;
  28704. var sub = 0;
  28705. this[offset] = value & 0xFF;
  28706. while (++i < byteLength && (mul *= 0x100)) {
  28707. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  28708. sub = 1;
  28709. }
  28710. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  28711. }
  28712. return offset + byteLength
  28713. };
  28714. Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  28715. value = +value;
  28716. offset = offset | 0;
  28717. if (!noAssert) {
  28718. var limit = Math.pow(2, 8 * byteLength - 1);
  28719. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  28720. }
  28721. var i = byteLength - 1;
  28722. var mul = 1;
  28723. var sub = 0;
  28724. this[offset + i] = value & 0xFF;
  28725. while (--i >= 0 && (mul *= 0x100)) {
  28726. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  28727. sub = 1;
  28728. }
  28729. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  28730. }
  28731. return offset + byteLength
  28732. };
  28733. Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  28734. value = +value;
  28735. offset = offset | 0;
  28736. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
  28737. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  28738. if (value < 0) value = 0xff + value + 1;
  28739. this[offset] = (value & 0xff);
  28740. return offset + 1
  28741. };
  28742. Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  28743. value = +value;
  28744. offset = offset | 0;
  28745. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
  28746. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28747. this[offset] = (value & 0xff);
  28748. this[offset + 1] = (value >>> 8);
  28749. } else {
  28750. objectWriteUInt16(this, value, offset, true);
  28751. }
  28752. return offset + 2
  28753. };
  28754. Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  28755. value = +value;
  28756. offset = offset | 0;
  28757. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
  28758. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28759. this[offset] = (value >>> 8);
  28760. this[offset + 1] = (value & 0xff);
  28761. } else {
  28762. objectWriteUInt16(this, value, offset, false);
  28763. }
  28764. return offset + 2
  28765. };
  28766. Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  28767. value = +value;
  28768. offset = offset | 0;
  28769. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
  28770. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28771. this[offset] = (value & 0xff);
  28772. this[offset + 1] = (value >>> 8);
  28773. this[offset + 2] = (value >>> 16);
  28774. this[offset + 3] = (value >>> 24);
  28775. } else {
  28776. objectWriteUInt32(this, value, offset, true);
  28777. }
  28778. return offset + 4
  28779. };
  28780. Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  28781. value = +value;
  28782. offset = offset | 0;
  28783. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
  28784. if (value < 0) value = 0xffffffff + value + 1;
  28785. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28786. this[offset] = (value >>> 24);
  28787. this[offset + 1] = (value >>> 16);
  28788. this[offset + 2] = (value >>> 8);
  28789. this[offset + 3] = (value & 0xff);
  28790. } else {
  28791. objectWriteUInt32(this, value, offset, false);
  28792. }
  28793. return offset + 4
  28794. };
  28795. function checkIEEE754 (buf, value, offset, ext, max, min) {
  28796. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  28797. if (offset < 0) throw new RangeError('Index out of range')
  28798. }
  28799. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  28800. if (!noAssert) {
  28801. checkIEEE754(buf, value, offset, 4);
  28802. }
  28803. write(buf, value, offset, littleEndian, 23, 4);
  28804. return offset + 4
  28805. }
  28806. Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  28807. return writeFloat(this, value, offset, true, noAssert)
  28808. };
  28809. Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  28810. return writeFloat(this, value, offset, false, noAssert)
  28811. };
  28812. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  28813. if (!noAssert) {
  28814. checkIEEE754(buf, value, offset, 8);
  28815. }
  28816. write(buf, value, offset, littleEndian, 52, 8);
  28817. return offset + 8
  28818. }
  28819. Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  28820. return writeDouble(this, value, offset, true, noAssert)
  28821. };
  28822. Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  28823. return writeDouble(this, value, offset, false, noAssert)
  28824. };
  28825. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  28826. Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
  28827. if (!start) start = 0;
  28828. if (!end && end !== 0) end = this.length;
  28829. if (targetStart >= target.length) targetStart = target.length;
  28830. if (!targetStart) targetStart = 0;
  28831. if (end > 0 && end < start) end = start;
  28832. // Copy 0 bytes; we're done
  28833. if (end === start) return 0
  28834. if (target.length === 0 || this.length === 0) return 0
  28835. // Fatal error conditions
  28836. if (targetStart < 0) {
  28837. throw new RangeError('targetStart out of bounds')
  28838. }
  28839. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  28840. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  28841. // Are we oob?
  28842. if (end > this.length) end = this.length;
  28843. if (target.length - targetStart < end - start) {
  28844. end = target.length - targetStart + start;
  28845. }
  28846. var len = end - start;
  28847. var i;
  28848. if (this === target && start < targetStart && targetStart < end) {
  28849. // descending copy from end
  28850. for (i = len - 1; i >= 0; --i) {
  28851. target[i + targetStart] = this[i + start];
  28852. }
  28853. } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
  28854. // ascending copy from start
  28855. for (i = 0; i < len; ++i) {
  28856. target[i + targetStart] = this[i + start];
  28857. }
  28858. } else {
  28859. Uint8Array.prototype.set.call(
  28860. target,
  28861. this.subarray(start, start + len),
  28862. targetStart
  28863. );
  28864. }
  28865. return len
  28866. };
  28867. // Usage:
  28868. // buffer.fill(number[, offset[, end]])
  28869. // buffer.fill(buffer[, offset[, end]])
  28870. // buffer.fill(string[, offset[, end]][, encoding])
  28871. Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
  28872. // Handle string cases:
  28873. if (typeof val === 'string') {
  28874. if (typeof start === 'string') {
  28875. encoding = start;
  28876. start = 0;
  28877. end = this.length;
  28878. } else if (typeof end === 'string') {
  28879. encoding = end;
  28880. end = this.length;
  28881. }
  28882. if (val.length === 1) {
  28883. var code = val.charCodeAt(0);
  28884. if (code < 256) {
  28885. val = code;
  28886. }
  28887. }
  28888. if (encoding !== undefined && typeof encoding !== 'string') {
  28889. throw new TypeError('encoding must be a string')
  28890. }
  28891. if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
  28892. throw new TypeError('Unknown encoding: ' + encoding)
  28893. }
  28894. } else if (typeof val === 'number') {
  28895. val = val & 255;
  28896. }
  28897. // Invalid ranges are not set to a default, so can range check early.
  28898. if (start < 0 || this.length < start || this.length < end) {
  28899. throw new RangeError('Out of range index')
  28900. }
  28901. if (end <= start) {
  28902. return this
  28903. }
  28904. start = start >>> 0;
  28905. end = end === undefined ? this.length : end >>> 0;
  28906. if (!val) val = 0;
  28907. var i;
  28908. if (typeof val === 'number') {
  28909. for (i = start; i < end; ++i) {
  28910. this[i] = val;
  28911. }
  28912. } else {
  28913. var bytes = internalIsBuffer(val)
  28914. ? val
  28915. : utf8ToBytes(new Buffer$1(val, encoding).toString());
  28916. var len = bytes.length;
  28917. for (i = 0; i < end - start; ++i) {
  28918. this[i + start] = bytes[i % len];
  28919. }
  28920. }
  28921. return this
  28922. };
  28923. // HELPER FUNCTIONS
  28924. // ================
  28925. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  28926. function base64clean (str) {
  28927. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  28928. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  28929. // Node converts strings with length < 2 to ''
  28930. if (str.length < 2) return ''
  28931. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  28932. while (str.length % 4 !== 0) {
  28933. str = str + '=';
  28934. }
  28935. return str
  28936. }
  28937. function stringtrim (str) {
  28938. if (str.trim) return str.trim()
  28939. return str.replace(/^\s+|\s+$/g, '')
  28940. }
  28941. function toHex (n) {
  28942. if (n < 16) return '0' + n.toString(16)
  28943. return n.toString(16)
  28944. }
  28945. function utf8ToBytes (string, units) {
  28946. units = units || Infinity;
  28947. var codePoint;
  28948. var length = string.length;
  28949. var leadSurrogate = null;
  28950. var bytes = [];
  28951. for (var i = 0; i < length; ++i) {
  28952. codePoint = string.charCodeAt(i);
  28953. // is surrogate component
  28954. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  28955. // last char was a lead
  28956. if (!leadSurrogate) {
  28957. // no lead yet
  28958. if (codePoint > 0xDBFF) {
  28959. // unexpected trail
  28960. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28961. continue
  28962. } else if (i + 1 === length) {
  28963. // unpaired lead
  28964. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28965. continue
  28966. }
  28967. // valid lead
  28968. leadSurrogate = codePoint;
  28969. continue
  28970. }
  28971. // 2 leads in a row
  28972. if (codePoint < 0xDC00) {
  28973. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28974. leadSurrogate = codePoint;
  28975. continue
  28976. }
  28977. // valid surrogate pair
  28978. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  28979. } else if (leadSurrogate) {
  28980. // valid bmp char, but last char was a lead
  28981. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28982. }
  28983. leadSurrogate = null;
  28984. // encode utf8
  28985. if (codePoint < 0x80) {
  28986. if ((units -= 1) < 0) break
  28987. bytes.push(codePoint);
  28988. } else if (codePoint < 0x800) {
  28989. if ((units -= 2) < 0) break
  28990. bytes.push(
  28991. codePoint >> 0x6 | 0xC0,
  28992. codePoint & 0x3F | 0x80
  28993. );
  28994. } else if (codePoint < 0x10000) {
  28995. if ((units -= 3) < 0) break
  28996. bytes.push(
  28997. codePoint >> 0xC | 0xE0,
  28998. codePoint >> 0x6 & 0x3F | 0x80,
  28999. codePoint & 0x3F | 0x80
  29000. );
  29001. } else if (codePoint < 0x110000) {
  29002. if ((units -= 4) < 0) break
  29003. bytes.push(
  29004. codePoint >> 0x12 | 0xF0,
  29005. codePoint >> 0xC & 0x3F | 0x80,
  29006. codePoint >> 0x6 & 0x3F | 0x80,
  29007. codePoint & 0x3F | 0x80
  29008. );
  29009. } else {
  29010. throw new Error('Invalid code point')
  29011. }
  29012. }
  29013. return bytes
  29014. }
  29015. function asciiToBytes (str) {
  29016. var byteArray = [];
  29017. for (var i = 0; i < str.length; ++i) {
  29018. // Node's code seems to be doing this and not & 0x7F..
  29019. byteArray.push(str.charCodeAt(i) & 0xFF);
  29020. }
  29021. return byteArray
  29022. }
  29023. function utf16leToBytes (str, units) {
  29024. var c, hi, lo;
  29025. var byteArray = [];
  29026. for (var i = 0; i < str.length; ++i) {
  29027. if ((units -= 2) < 0) break
  29028. c = str.charCodeAt(i);
  29029. hi = c >> 8;
  29030. lo = c % 256;
  29031. byteArray.push(lo);
  29032. byteArray.push(hi);
  29033. }
  29034. return byteArray
  29035. }
  29036. function base64ToBytes (str) {
  29037. return toByteArray(base64clean(str))
  29038. }
  29039. function blitBuffer (src, dst, offset, length) {
  29040. for (var i = 0; i < length; ++i) {
  29041. if ((i + offset >= dst.length) || (i >= src.length)) break
  29042. dst[i + offset] = src[i];
  29043. }
  29044. return i
  29045. }
  29046. function isnan (val) {
  29047. return val !== val // eslint-disable-line no-self-compare
  29048. }
  29049. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  29050. // The _isBuffer check is for Safari 5-7 support, because it's missing
  29051. // Object.prototype.constructor. Remove this eventually
  29052. function isBuffer$1(obj) {
  29053. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  29054. }
  29055. function isFastBuffer (obj) {
  29056. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  29057. }
  29058. // For Node v0.10 support. Remove this eventually.
  29059. function isSlowBuffer (obj) {
  29060. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  29061. }
  29062. var inherits;
  29063. if (typeof Object.create === 'function'){
  29064. inherits = function inherits(ctor, superCtor) {
  29065. // implementation from standard node.js 'util' module
  29066. ctor.super_ = superCtor;
  29067. ctor.prototype = Object.create(superCtor.prototype, {
  29068. constructor: {
  29069. value: ctor,
  29070. enumerable: false,
  29071. writable: true,
  29072. configurable: true
  29073. }
  29074. });
  29075. };
  29076. } else {
  29077. inherits = function inherits(ctor, superCtor) {
  29078. ctor.super_ = superCtor;
  29079. var TempCtor = function () {};
  29080. TempCtor.prototype = superCtor.prototype;
  29081. ctor.prototype = new TempCtor();
  29082. ctor.prototype.constructor = ctor;
  29083. };
  29084. }
  29085. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  29086. function getOwnPropertyDescriptors(obj) {
  29087. var keys = Object.keys(obj);
  29088. var descriptors = {};
  29089. for (var i = 0; i < keys.length; i++) {
  29090. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  29091. }
  29092. return descriptors;
  29093. };
  29094. var formatRegExp = /%[sdj%]/g;
  29095. function format$1(f) {
  29096. if (!isString(f)) {
  29097. var objects = [];
  29098. for (var i = 0; i < arguments.length; i++) {
  29099. objects.push(inspect(arguments[i]));
  29100. }
  29101. return objects.join(' ');
  29102. }
  29103. var i = 1;
  29104. var args = arguments;
  29105. var len = args.length;
  29106. var str = String(f).replace(formatRegExp, function(x) {
  29107. if (x === '%%') return '%';
  29108. if (i >= len) return x;
  29109. switch (x) {
  29110. case '%s': return String(args[i++]);
  29111. case '%d': return Number(args[i++]);
  29112. case '%j':
  29113. try {
  29114. return JSON.stringify(args[i++]);
  29115. } catch (_) {
  29116. return '[Circular]';
  29117. }
  29118. default:
  29119. return x;
  29120. }
  29121. });
  29122. for (var x = args[i]; i < len; x = args[++i]) {
  29123. if (isNull(x) || !isObject$1(x)) {
  29124. str += ' ' + x;
  29125. } else {
  29126. str += ' ' + inspect(x);
  29127. }
  29128. }
  29129. return str;
  29130. }
  29131. // Mark that a method should not be used.
  29132. // Returns a modified function which warns once by default.
  29133. // If --no-deprecation is set, then it is a no-op.
  29134. function deprecate(fn, msg) {
  29135. // Allow for deprecating things in the process of starting up.
  29136. if (isUndefined(global$1.process)) {
  29137. return function() {
  29138. return deprecate(fn, msg).apply(this, arguments);
  29139. };
  29140. }
  29141. if (browser$1.noDeprecation === true) {
  29142. return fn;
  29143. }
  29144. var warned = false;
  29145. function deprecated() {
  29146. if (!warned) {
  29147. if (browser$1.throwDeprecation) {
  29148. throw new Error(msg);
  29149. } else if (browser$1.traceDeprecation) {
  29150. console.trace(msg);
  29151. } else {
  29152. console.error(msg);
  29153. }
  29154. warned = true;
  29155. }
  29156. return fn.apply(this, arguments);
  29157. }
  29158. return deprecated;
  29159. }
  29160. var debugs = {};
  29161. var debugEnviron;
  29162. function debuglog(set) {
  29163. if (isUndefined(debugEnviron))
  29164. debugEnviron = browser$1.env.NODE_DEBUG || '';
  29165. set = set.toUpperCase();
  29166. if (!debugs[set]) {
  29167. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  29168. var pid = 0;
  29169. debugs[set] = function() {
  29170. var msg = format$1.apply(null, arguments);
  29171. console.error('%s %d: %s', set, pid, msg);
  29172. };
  29173. } else {
  29174. debugs[set] = function() {};
  29175. }
  29176. }
  29177. return debugs[set];
  29178. }
  29179. /**
  29180. * Echos the value of a value. Trys to print the value out
  29181. * in the best way possible given the different types.
  29182. *
  29183. * @param {Object} obj The object to print out.
  29184. * @param {Object} opts Optional options object that alters the output.
  29185. */
  29186. /* legacy: obj, showHidden, depth, colors*/
  29187. function inspect(obj, opts) {
  29188. // default options
  29189. var ctx = {
  29190. seen: [],
  29191. stylize: stylizeNoColor
  29192. };
  29193. // legacy...
  29194. if (arguments.length >= 3) ctx.depth = arguments[2];
  29195. if (arguments.length >= 4) ctx.colors = arguments[3];
  29196. if (isBoolean(opts)) {
  29197. // legacy...
  29198. ctx.showHidden = opts;
  29199. } else if (opts) {
  29200. // got an "options" object
  29201. _extend(ctx, opts);
  29202. }
  29203. // set default options
  29204. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  29205. if (isUndefined(ctx.depth)) ctx.depth = 2;
  29206. if (isUndefined(ctx.colors)) ctx.colors = false;
  29207. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  29208. if (ctx.colors) ctx.stylize = stylizeWithColor;
  29209. return formatValue(ctx, obj, ctx.depth);
  29210. }
  29211. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  29212. inspect.colors = {
  29213. 'bold' : [1, 22],
  29214. 'italic' : [3, 23],
  29215. 'underline' : [4, 24],
  29216. 'inverse' : [7, 27],
  29217. 'white' : [37, 39],
  29218. 'grey' : [90, 39],
  29219. 'black' : [30, 39],
  29220. 'blue' : [34, 39],
  29221. 'cyan' : [36, 39],
  29222. 'green' : [32, 39],
  29223. 'magenta' : [35, 39],
  29224. 'red' : [31, 39],
  29225. 'yellow' : [33, 39]
  29226. };
  29227. // Don't use 'blue' not visible on cmd.exe
  29228. inspect.styles = {
  29229. 'special': 'cyan',
  29230. 'number': 'yellow',
  29231. 'boolean': 'yellow',
  29232. 'undefined': 'grey',
  29233. 'null': 'bold',
  29234. 'string': 'green',
  29235. 'date': 'magenta',
  29236. // "name": intentionally not styling
  29237. 'regexp': 'red'
  29238. };
  29239. function stylizeWithColor(str, styleType) {
  29240. var style = inspect.styles[styleType];
  29241. if (style) {
  29242. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  29243. '\u001b[' + inspect.colors[style][1] + 'm';
  29244. } else {
  29245. return str;
  29246. }
  29247. }
  29248. function stylizeNoColor(str, styleType) {
  29249. return str;
  29250. }
  29251. function arrayToHash(array) {
  29252. var hash = {};
  29253. array.forEach(function(val, idx) {
  29254. hash[val] = true;
  29255. });
  29256. return hash;
  29257. }
  29258. function formatValue(ctx, value, recurseTimes) {
  29259. // Provide a hook for user-specified inspect functions.
  29260. // Check that value is an object with an inspect function on it
  29261. if (ctx.customInspect &&
  29262. value &&
  29263. isFunction(value.inspect) &&
  29264. // Filter out the util module, it's inspect function is special
  29265. value.inspect !== inspect &&
  29266. // Also filter out any prototype objects using the circular check.
  29267. !(value.constructor && value.constructor.prototype === value)) {
  29268. var ret = value.inspect(recurseTimes, ctx);
  29269. if (!isString(ret)) {
  29270. ret = formatValue(ctx, ret, recurseTimes);
  29271. }
  29272. return ret;
  29273. }
  29274. // Primitive types cannot have properties
  29275. var primitive = formatPrimitive(ctx, value);
  29276. if (primitive) {
  29277. return primitive;
  29278. }
  29279. // Look up the keys of the object.
  29280. var keys = Object.keys(value);
  29281. var visibleKeys = arrayToHash(keys);
  29282. if (ctx.showHidden) {
  29283. keys = Object.getOwnPropertyNames(value);
  29284. }
  29285. // IE doesn't make error fields non-enumerable
  29286. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  29287. if (isError(value)
  29288. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  29289. return formatError(value);
  29290. }
  29291. // Some type of object without properties can be shortcutted.
  29292. if (keys.length === 0) {
  29293. if (isFunction(value)) {
  29294. var name = value.name ? ': ' + value.name : '';
  29295. return ctx.stylize('[Function' + name + ']', 'special');
  29296. }
  29297. if (isRegExp(value)) {
  29298. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  29299. }
  29300. if (isDate(value)) {
  29301. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  29302. }
  29303. if (isError(value)) {
  29304. return formatError(value);
  29305. }
  29306. }
  29307. var base = '', array = false, braces = ['{', '}'];
  29308. // Make Array say that they are Array
  29309. if (isArray$1(value)) {
  29310. array = true;
  29311. braces = ['[', ']'];
  29312. }
  29313. // Make functions say that they are functions
  29314. if (isFunction(value)) {
  29315. var n = value.name ? ': ' + value.name : '';
  29316. base = ' [Function' + n + ']';
  29317. }
  29318. // Make RegExps say that they are RegExps
  29319. if (isRegExp(value)) {
  29320. base = ' ' + RegExp.prototype.toString.call(value);
  29321. }
  29322. // Make dates with properties first say the date
  29323. if (isDate(value)) {
  29324. base = ' ' + Date.prototype.toUTCString.call(value);
  29325. }
  29326. // Make error with message first say the error
  29327. if (isError(value)) {
  29328. base = ' ' + formatError(value);
  29329. }
  29330. if (keys.length === 0 && (!array || value.length == 0)) {
  29331. return braces[0] + base + braces[1];
  29332. }
  29333. if (recurseTimes < 0) {
  29334. if (isRegExp(value)) {
  29335. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  29336. } else {
  29337. return ctx.stylize('[Object]', 'special');
  29338. }
  29339. }
  29340. ctx.seen.push(value);
  29341. var output;
  29342. if (array) {
  29343. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  29344. } else {
  29345. output = keys.map(function(key) {
  29346. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  29347. });
  29348. }
  29349. ctx.seen.pop();
  29350. return reduceToSingleString(output, base, braces);
  29351. }
  29352. function formatPrimitive(ctx, value) {
  29353. if (isUndefined(value))
  29354. return ctx.stylize('undefined', 'undefined');
  29355. if (isString(value)) {
  29356. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  29357. .replace(/'/g, "\\'")
  29358. .replace(/\\"/g, '"') + '\'';
  29359. return ctx.stylize(simple, 'string');
  29360. }
  29361. if (isNumber(value))
  29362. return ctx.stylize('' + value, 'number');
  29363. if (isBoolean(value))
  29364. return ctx.stylize('' + value, 'boolean');
  29365. // For some reason typeof null is "object", so special case here.
  29366. if (isNull(value))
  29367. return ctx.stylize('null', 'null');
  29368. }
  29369. function formatError(value) {
  29370. return '[' + Error.prototype.toString.call(value) + ']';
  29371. }
  29372. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  29373. var output = [];
  29374. for (var i = 0, l = value.length; i < l; ++i) {
  29375. if (hasOwnProperty$2(value, String(i))) {
  29376. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  29377. String(i), true));
  29378. } else {
  29379. output.push('');
  29380. }
  29381. }
  29382. keys.forEach(function(key) {
  29383. if (!key.match(/^\d+$/)) {
  29384. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  29385. key, true));
  29386. }
  29387. });
  29388. return output;
  29389. }
  29390. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  29391. var name, str, desc;
  29392. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  29393. if (desc.get) {
  29394. if (desc.set) {
  29395. str = ctx.stylize('[Getter/Setter]', 'special');
  29396. } else {
  29397. str = ctx.stylize('[Getter]', 'special');
  29398. }
  29399. } else {
  29400. if (desc.set) {
  29401. str = ctx.stylize('[Setter]', 'special');
  29402. }
  29403. }
  29404. if (!hasOwnProperty$2(visibleKeys, key)) {
  29405. name = '[' + key + ']';
  29406. }
  29407. if (!str) {
  29408. if (ctx.seen.indexOf(desc.value) < 0) {
  29409. if (isNull(recurseTimes)) {
  29410. str = formatValue(ctx, desc.value, null);
  29411. } else {
  29412. str = formatValue(ctx, desc.value, recurseTimes - 1);
  29413. }
  29414. if (str.indexOf('\n') > -1) {
  29415. if (array) {
  29416. str = str.split('\n').map(function(line) {
  29417. return ' ' + line;
  29418. }).join('\n').substr(2);
  29419. } else {
  29420. str = '\n' + str.split('\n').map(function(line) {
  29421. return ' ' + line;
  29422. }).join('\n');
  29423. }
  29424. }
  29425. } else {
  29426. str = ctx.stylize('[Circular]', 'special');
  29427. }
  29428. }
  29429. if (isUndefined(name)) {
  29430. if (array && key.match(/^\d+$/)) {
  29431. return str;
  29432. }
  29433. name = JSON.stringify('' + key);
  29434. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  29435. name = name.substr(1, name.length - 2);
  29436. name = ctx.stylize(name, 'name');
  29437. } else {
  29438. name = name.replace(/'/g, "\\'")
  29439. .replace(/\\"/g, '"')
  29440. .replace(/(^"|"$)/g, "'");
  29441. name = ctx.stylize(name, 'string');
  29442. }
  29443. }
  29444. return name + ': ' + str;
  29445. }
  29446. function reduceToSingleString(output, base, braces) {
  29447. var length = output.reduce(function(prev, cur) {
  29448. if (cur.indexOf('\n') >= 0) ;
  29449. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  29450. }, 0);
  29451. if (length > 60) {
  29452. return braces[0] +
  29453. (base === '' ? '' : base + '\n ') +
  29454. ' ' +
  29455. output.join(',\n ') +
  29456. ' ' +
  29457. braces[1];
  29458. }
  29459. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  29460. }
  29461. // NOTE: These type checking functions intentionally don't use `instanceof`
  29462. // because it is fragile and can be easily faked with `Object.create()`.
  29463. function isArray$1(ar) {
  29464. return Array.isArray(ar);
  29465. }
  29466. function isBoolean(arg) {
  29467. return typeof arg === 'boolean';
  29468. }
  29469. function isNull(arg) {
  29470. return arg === null;
  29471. }
  29472. function isNullOrUndefined(arg) {
  29473. return arg == null;
  29474. }
  29475. function isNumber(arg) {
  29476. return typeof arg === 'number';
  29477. }
  29478. function isString(arg) {
  29479. return typeof arg === 'string';
  29480. }
  29481. function isSymbol(arg) {
  29482. return typeof arg === 'symbol';
  29483. }
  29484. function isUndefined(arg) {
  29485. return arg === void 0;
  29486. }
  29487. function isRegExp(re) {
  29488. return isObject$1(re) && objectToString(re) === '[object RegExp]';
  29489. }
  29490. function isObject$1(arg) {
  29491. return typeof arg === 'object' && arg !== null;
  29492. }
  29493. function isDate(d) {
  29494. return isObject$1(d) && objectToString(d) === '[object Date]';
  29495. }
  29496. function isError(e) {
  29497. return isObject$1(e) &&
  29498. (objectToString(e) === '[object Error]' || e instanceof Error);
  29499. }
  29500. function isFunction(arg) {
  29501. return typeof arg === 'function';
  29502. }
  29503. function isPrimitive(arg) {
  29504. return arg === null ||
  29505. typeof arg === 'boolean' ||
  29506. typeof arg === 'number' ||
  29507. typeof arg === 'string' ||
  29508. typeof arg === 'symbol' || // ES6 symbol
  29509. typeof arg === 'undefined';
  29510. }
  29511. function isBuffer(maybeBuf) {
  29512. return Buffer$1.isBuffer(maybeBuf);
  29513. }
  29514. function objectToString(o) {
  29515. return Object.prototype.toString.call(o);
  29516. }
  29517. function pad(n) {
  29518. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  29519. }
  29520. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  29521. 'Oct', 'Nov', 'Dec'];
  29522. // 26 Feb 16:19:34
  29523. function timestamp() {
  29524. var d = new Date();
  29525. var time = [pad(d.getHours()),
  29526. pad(d.getMinutes()),
  29527. pad(d.getSeconds())].join(':');
  29528. return [d.getDate(), months[d.getMonth()], time].join(' ');
  29529. }
  29530. // log is just a thin wrapper to console.log that prepends a timestamp
  29531. function log() {
  29532. console.log('%s - %s', timestamp(), format$1.apply(null, arguments));
  29533. }
  29534. function _extend(origin, add) {
  29535. // Don't do anything if add isn't an object
  29536. if (!add || !isObject$1(add)) return origin;
  29537. var keys = Object.keys(add);
  29538. var i = keys.length;
  29539. while (i--) {
  29540. origin[keys[i]] = add[keys[i]];
  29541. }
  29542. return origin;
  29543. }
  29544. function hasOwnProperty$2(obj, prop) {
  29545. return Object.prototype.hasOwnProperty.call(obj, prop);
  29546. }
  29547. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  29548. function promisify(original) {
  29549. if (typeof original !== 'function')
  29550. throw new TypeError('The "original" argument must be of type Function');
  29551. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  29552. var fn = original[kCustomPromisifiedSymbol];
  29553. if (typeof fn !== 'function') {
  29554. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  29555. }
  29556. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  29557. value: fn, enumerable: false, writable: false, configurable: true
  29558. });
  29559. return fn;
  29560. }
  29561. function fn() {
  29562. var promiseResolve, promiseReject;
  29563. var promise = new Promise(function (resolve, reject) {
  29564. promiseResolve = resolve;
  29565. promiseReject = reject;
  29566. });
  29567. var args = [];
  29568. for (var i = 0; i < arguments.length; i++) {
  29569. args.push(arguments[i]);
  29570. }
  29571. args.push(function (err, value) {
  29572. if (err) {
  29573. promiseReject(err);
  29574. } else {
  29575. promiseResolve(value);
  29576. }
  29577. });
  29578. try {
  29579. original.apply(this, args);
  29580. } catch (err) {
  29581. promiseReject(err);
  29582. }
  29583. return promise;
  29584. }
  29585. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  29586. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  29587. value: fn, enumerable: false, writable: false, configurable: true
  29588. });
  29589. return Object.defineProperties(
  29590. fn,
  29591. getOwnPropertyDescriptors(original)
  29592. );
  29593. }
  29594. promisify.custom = kCustomPromisifiedSymbol;
  29595. function callbackifyOnRejected(reason, cb) {
  29596. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  29597. // Because `null` is a special error value in callbacks which means "no error
  29598. // occurred", we error-wrap so the callback consumer can distinguish between
  29599. // "the promise rejected with null" or "the promise fulfilled with undefined".
  29600. if (!reason) {
  29601. var newReason = new Error('Promise was rejected with a falsy value');
  29602. newReason.reason = reason;
  29603. reason = newReason;
  29604. }
  29605. return cb(reason);
  29606. }
  29607. function callbackify(original) {
  29608. if (typeof original !== 'function') {
  29609. throw new TypeError('The "original" argument must be of type Function');
  29610. }
  29611. // We DO NOT return the promise as it gives the user a false sense that
  29612. // the promise is actually somehow related to the callback's execution
  29613. // and that the callback throwing will reject the promise.
  29614. function callbackified() {
  29615. var args = [];
  29616. for (var i = 0; i < arguments.length; i++) {
  29617. args.push(arguments[i]);
  29618. }
  29619. var maybeCb = args.pop();
  29620. if (typeof maybeCb !== 'function') {
  29621. throw new TypeError('The last argument must be of type Function');
  29622. }
  29623. var self = this;
  29624. var cb = function() {
  29625. return maybeCb.apply(self, arguments);
  29626. };
  29627. // In true node style we process the callback on `nextTick` with all the
  29628. // implications (stack, `uncaughtException`, `async_hooks`)
  29629. original.apply(this, args)
  29630. .then(function(ret) { browser$1.nextTick(cb.bind(null, null, ret)); },
  29631. function(rej) { browser$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
  29632. }
  29633. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  29634. Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
  29635. return callbackified;
  29636. }
  29637. var _polyfillNode_util = {
  29638. inherits: inherits,
  29639. _extend: _extend,
  29640. log: log,
  29641. isBuffer: isBuffer,
  29642. isPrimitive: isPrimitive,
  29643. isFunction: isFunction,
  29644. isError: isError,
  29645. isDate: isDate,
  29646. isObject: isObject$1,
  29647. isRegExp: isRegExp,
  29648. isUndefined: isUndefined,
  29649. isSymbol: isSymbol,
  29650. isString: isString,
  29651. isNumber: isNumber,
  29652. isNullOrUndefined: isNullOrUndefined,
  29653. isNull: isNull,
  29654. isBoolean: isBoolean,
  29655. isArray: isArray$1,
  29656. inspect: inspect,
  29657. deprecate: deprecate,
  29658. format: format$1,
  29659. debuglog: debuglog,
  29660. promisify: promisify,
  29661. callbackify: callbackify,
  29662. };
  29663. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  29664. __proto__: null,
  29665. _extend: _extend,
  29666. callbackify: callbackify,
  29667. debuglog: debuglog,
  29668. default: _polyfillNode_util,
  29669. deprecate: deprecate,
  29670. format: format$1,
  29671. inherits: inherits,
  29672. inspect: inspect,
  29673. isArray: isArray$1,
  29674. isBoolean: isBoolean,
  29675. isBuffer: isBuffer,
  29676. isDate: isDate,
  29677. isError: isError,
  29678. isFunction: isFunction,
  29679. isNull: isNull,
  29680. isNullOrUndefined: isNullOrUndefined,
  29681. isNumber: isNumber,
  29682. isObject: isObject$1,
  29683. isPrimitive: isPrimitive,
  29684. isRegExp: isRegExp,
  29685. isString: isString,
  29686. isSymbol: isSymbol,
  29687. isUndefined: isUndefined,
  29688. log: log,
  29689. promisify: promisify
  29690. });
  29691. // Copyright Joyent, Inc. and other Node contributors.
  29692. //
  29693. // Permission is hereby granted, free of charge, to any person obtaining a
  29694. // copy of this software and associated documentation files (the
  29695. // "Software"), to deal in the Software without restriction, including
  29696. // without limitation the rights to use, copy, modify, merge, publish,
  29697. // distribute, sublicense, and/or sell copies of the Software, and to permit
  29698. // persons to whom the Software is furnished to do so, subject to the
  29699. // following conditions:
  29700. //
  29701. // The above copyright notice and this permission notice shall be included
  29702. // in all copies or substantial portions of the Software.
  29703. //
  29704. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  29705. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29706. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  29707. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  29708. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  29709. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  29710. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  29711. // If obj.hasOwnProperty has been overridden, then calling
  29712. // obj.hasOwnProperty(prop) will break.
  29713. // See: https://github.com/joyent/node/issues/1707
  29714. function hasOwnProperty$1(obj, prop) {
  29715. return Object.prototype.hasOwnProperty.call(obj, prop);
  29716. }
  29717. var isArray = Array.isArray || function (xs) {
  29718. return Object.prototype.toString.call(xs) === '[object Array]';
  29719. };
  29720. function stringifyPrimitive(v) {
  29721. switch (typeof v) {
  29722. case 'string':
  29723. return v;
  29724. case 'boolean':
  29725. return v ? 'true' : 'false';
  29726. case 'number':
  29727. return isFinite(v) ? v : '';
  29728. default:
  29729. return '';
  29730. }
  29731. }
  29732. function stringify (obj, sep, eq, name) {
  29733. sep = sep || '&';
  29734. eq = eq || '=';
  29735. if (obj === null) {
  29736. obj = undefined;
  29737. }
  29738. if (typeof obj === 'object') {
  29739. return map(objectKeys(obj), function(k) {
  29740. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  29741. if (isArray(obj[k])) {
  29742. return map(obj[k], function(v) {
  29743. return ks + encodeURIComponent(stringifyPrimitive(v));
  29744. }).join(sep);
  29745. } else {
  29746. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  29747. }
  29748. }).join(sep);
  29749. }
  29750. if (!name) return '';
  29751. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  29752. encodeURIComponent(stringifyPrimitive(obj));
  29753. }
  29754. function map (xs, f) {
  29755. if (xs.map) return xs.map(f);
  29756. var res = [];
  29757. for (var i = 0; i < xs.length; i++) {
  29758. res.push(f(xs[i], i));
  29759. }
  29760. return res;
  29761. }
  29762. var objectKeys = Object.keys || function (obj) {
  29763. var res = [];
  29764. for (var key in obj) {
  29765. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  29766. }
  29767. return res;
  29768. };
  29769. function parse$1(qs, sep, eq, options) {
  29770. sep = sep || '&';
  29771. eq = eq || '=';
  29772. var obj = {};
  29773. if (typeof qs !== 'string' || qs.length === 0) {
  29774. return obj;
  29775. }
  29776. var regexp = /\+/g;
  29777. qs = qs.split(sep);
  29778. var maxKeys = 1000;
  29779. if (options && typeof options.maxKeys === 'number') {
  29780. maxKeys = options.maxKeys;
  29781. }
  29782. var len = qs.length;
  29783. // maxKeys <= 0 means that we should not limit keys count
  29784. if (maxKeys > 0 && len > maxKeys) {
  29785. len = maxKeys;
  29786. }
  29787. for (var i = 0; i < len; ++i) {
  29788. var x = qs[i].replace(regexp, '%20'),
  29789. idx = x.indexOf(eq),
  29790. kstr, vstr, k, v;
  29791. if (idx >= 0) {
  29792. kstr = x.substr(0, idx);
  29793. vstr = x.substr(idx + 1);
  29794. } else {
  29795. kstr = x;
  29796. vstr = '';
  29797. }
  29798. k = decodeURIComponent(kstr);
  29799. v = decodeURIComponent(vstr);
  29800. if (!hasOwnProperty$1(obj, k)) {
  29801. obj[k] = v;
  29802. } else if (isArray(obj[k])) {
  29803. obj[k].push(v);
  29804. } else {
  29805. obj[k] = [obj[k], v];
  29806. }
  29807. }
  29808. return obj;
  29809. }
  29810. // WHATWG API
  29811. const URL$1 = global$1.URL;
  29812. const URLSearchParams = global$1.URLSearchParams;
  29813. var _polyfillNode_url = {
  29814. parse: urlParse,
  29815. resolve: urlResolve,
  29816. resolveObject: urlResolveObject,
  29817. fileURLToPath: urlFileURLToPath,
  29818. format: urlFormat,
  29819. Url: Url,
  29820. // WHATWG API
  29821. URL: URL$1,
  29822. URLSearchParams,
  29823. };
  29824. function Url() {
  29825. this.protocol = null;
  29826. this.slashes = null;
  29827. this.auth = null;
  29828. this.host = null;
  29829. this.port = null;
  29830. this.hostname = null;
  29831. this.hash = null;
  29832. this.search = null;
  29833. this.query = null;
  29834. this.pathname = null;
  29835. this.path = null;
  29836. this.href = null;
  29837. }
  29838. // Reference: RFC 3986, RFC 1808, RFC 2396
  29839. // define these here so at least they only have to be
  29840. // compiled once on the first module load.
  29841. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  29842. portPattern = /:[0-9]*$/,
  29843. // Special case for a simple path URL
  29844. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  29845. // RFC 2396: characters reserved for delimiting URLs.
  29846. // We actually just auto-escape these.
  29847. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  29848. // RFC 2396: characters not allowed for various reasons.
  29849. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  29850. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  29851. autoEscape = ['\''].concat(unwise),
  29852. // Characters that are never ever allowed in a hostname.
  29853. // Note that any invalid chars are also handled, but these
  29854. // are the ones that are *expected* to be seen, so we fast-path
  29855. // them.
  29856. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  29857. hostEndingChars = ['/', '?', '#'],
  29858. hostnameMaxLen = 255,
  29859. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  29860. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  29861. // protocols that can allow "unsafe" and "unwise" chars.
  29862. unsafeProtocol = {
  29863. 'javascript': true,
  29864. 'javascript:': true
  29865. },
  29866. // protocols that never have a hostname.
  29867. hostlessProtocol = {
  29868. 'javascript': true,
  29869. 'javascript:': true
  29870. },
  29871. // protocols that always contain a // bit.
  29872. slashedProtocol = {
  29873. 'http': true,
  29874. 'https': true,
  29875. 'ftp': true,
  29876. 'gopher': true,
  29877. 'file': true,
  29878. 'http:': true,
  29879. 'https:': true,
  29880. 'ftp:': true,
  29881. 'gopher:': true,
  29882. 'file:': true
  29883. };
  29884. function urlParse(url, parseQueryString, slashesDenoteHost) {
  29885. if (url && isObject$1(url) && url instanceof Url) return url;
  29886. var u = new Url;
  29887. u.parse(url, parseQueryString, slashesDenoteHost);
  29888. return u;
  29889. }
  29890. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  29891. return parse(this, url, parseQueryString, slashesDenoteHost);
  29892. };
  29893. function parse(self, url, parseQueryString, slashesDenoteHost) {
  29894. if (!isString(url)) {
  29895. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  29896. }
  29897. // Copy chrome, IE, opera backslash-handling behavior.
  29898. // Back slashes before the query string get converted to forward slashes
  29899. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  29900. var queryIndex = url.indexOf('?'),
  29901. splitter =
  29902. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  29903. uSplit = url.split(splitter),
  29904. slashRegex = /\\/g;
  29905. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  29906. url = uSplit.join(splitter);
  29907. var rest = url;
  29908. // trim before proceeding.
  29909. // This is to support parse stuff like " http://foo.com \n"
  29910. rest = rest.trim();
  29911. if (!slashesDenoteHost && url.split('#').length === 1) {
  29912. // Try fast path regexp
  29913. var simplePath = simplePathPattern.exec(rest);
  29914. if (simplePath) {
  29915. self.path = rest;
  29916. self.href = rest;
  29917. self.pathname = simplePath[1];
  29918. if (simplePath[2]) {
  29919. self.search = simplePath[2];
  29920. if (parseQueryString) {
  29921. self.query = parse$1(self.search.substr(1));
  29922. } else {
  29923. self.query = self.search.substr(1);
  29924. }
  29925. } else if (parseQueryString) {
  29926. self.search = '';
  29927. self.query = {};
  29928. }
  29929. return self;
  29930. }
  29931. }
  29932. var proto = protocolPattern.exec(rest);
  29933. if (proto) {
  29934. proto = proto[0];
  29935. var lowerProto = proto.toLowerCase();
  29936. self.protocol = lowerProto;
  29937. rest = rest.substr(proto.length);
  29938. }
  29939. // figure out if it's got a host
  29940. // user@server is *always* interpreted as a hostname, and url
  29941. // resolution will treat //foo/bar as host=foo,path=bar because that's
  29942. // how the browser resolves relative URLs.
  29943. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  29944. var slashes = rest.substr(0, 2) === '//';
  29945. if (slashes && !(proto && hostlessProtocol[proto])) {
  29946. rest = rest.substr(2);
  29947. self.slashes = true;
  29948. }
  29949. }
  29950. var i, hec, l, p;
  29951. if (!hostlessProtocol[proto] &&
  29952. (slashes || (proto && !slashedProtocol[proto]))) {
  29953. // there's a hostname.
  29954. // the first instance of /, ?, ;, or # ends the host.
  29955. //
  29956. // If there is an @ in the hostname, then non-host chars *are* allowed
  29957. // to the left of the last @ sign, unless some host-ending character
  29958. // comes *before* the @-sign.
  29959. // URLs are obnoxious.
  29960. //
  29961. // ex:
  29962. // http://a@b@c/ => user:a@b host:c
  29963. // http://a@b?@c => user:a host:c path:/?@c
  29964. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  29965. // Review our test case against browsers more comprehensively.
  29966. // find the first instance of any hostEndingChars
  29967. var hostEnd = -1;
  29968. for (i = 0; i < hostEndingChars.length; i++) {
  29969. hec = rest.indexOf(hostEndingChars[i]);
  29970. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  29971. hostEnd = hec;
  29972. }
  29973. // at this point, either we have an explicit point where the
  29974. // auth portion cannot go past, or the last @ char is the decider.
  29975. var auth, atSign;
  29976. if (hostEnd === -1) {
  29977. // atSign can be anywhere.
  29978. atSign = rest.lastIndexOf('@');
  29979. } else {
  29980. // atSign must be in auth portion.
  29981. // http://a@b/c@d => host:b auth:a path:/c@d
  29982. atSign = rest.lastIndexOf('@', hostEnd);
  29983. }
  29984. // Now we have a portion which is definitely the auth.
  29985. // Pull that off.
  29986. if (atSign !== -1) {
  29987. auth = rest.slice(0, atSign);
  29988. rest = rest.slice(atSign + 1);
  29989. self.auth = decodeURIComponent(auth);
  29990. }
  29991. // the host is the remaining to the left of the first non-host char
  29992. hostEnd = -1;
  29993. for (i = 0; i < nonHostChars.length; i++) {
  29994. hec = rest.indexOf(nonHostChars[i]);
  29995. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  29996. hostEnd = hec;
  29997. }
  29998. // if we still have not hit it, then the entire thing is a host.
  29999. if (hostEnd === -1)
  30000. hostEnd = rest.length;
  30001. self.host = rest.slice(0, hostEnd);
  30002. rest = rest.slice(hostEnd);
  30003. // pull out port.
  30004. parseHost(self);
  30005. // we've indicated that there is a hostname,
  30006. // so even if it's empty, it has to be present.
  30007. self.hostname = self.hostname || '';
  30008. // if hostname begins with [ and ends with ]
  30009. // assume that it's an IPv6 address.
  30010. var ipv6Hostname = self.hostname[0] === '[' &&
  30011. self.hostname[self.hostname.length - 1] === ']';
  30012. // validate a little.
  30013. if (!ipv6Hostname) {
  30014. var hostparts = self.hostname.split(/\./);
  30015. for (i = 0, l = hostparts.length; i < l; i++) {
  30016. var part = hostparts[i];
  30017. if (!part) continue;
  30018. if (!part.match(hostnamePartPattern)) {
  30019. var newpart = '';
  30020. for (var j = 0, k = part.length; j < k; j++) {
  30021. if (part.charCodeAt(j) > 127) {
  30022. // we replace non-ASCII char with a temporary placeholder
  30023. // we need this to make sure size of hostname is not
  30024. // broken by replacing non-ASCII by nothing
  30025. newpart += 'x';
  30026. } else {
  30027. newpart += part[j];
  30028. }
  30029. }
  30030. // we test again with ASCII char only
  30031. if (!newpart.match(hostnamePartPattern)) {
  30032. var validParts = hostparts.slice(0, i);
  30033. var notHost = hostparts.slice(i + 1);
  30034. var bit = part.match(hostnamePartStart);
  30035. if (bit) {
  30036. validParts.push(bit[1]);
  30037. notHost.unshift(bit[2]);
  30038. }
  30039. if (notHost.length) {
  30040. rest = '/' + notHost.join('.') + rest;
  30041. }
  30042. self.hostname = validParts.join('.');
  30043. break;
  30044. }
  30045. }
  30046. }
  30047. }
  30048. if (self.hostname.length > hostnameMaxLen) {
  30049. self.hostname = '';
  30050. } else {
  30051. // hostnames are always lower case.
  30052. self.hostname = self.hostname.toLowerCase();
  30053. }
  30054. if (!ipv6Hostname) {
  30055. // IDNA Support: Returns a punycoded representation of "domain".
  30056. // It only converts parts of the domain name that
  30057. // have non-ASCII characters, i.e. it doesn't matter if
  30058. // you call it with a domain that already is ASCII-only.
  30059. self.hostname = toASCII(self.hostname);
  30060. }
  30061. p = self.port ? ':' + self.port : '';
  30062. var h = self.hostname || '';
  30063. self.host = h + p;
  30064. self.href += self.host;
  30065. // strip [ and ] from the hostname
  30066. // the host field still retains them, though
  30067. if (ipv6Hostname) {
  30068. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  30069. if (rest[0] !== '/') {
  30070. rest = '/' + rest;
  30071. }
  30072. }
  30073. }
  30074. // now rest is set to the post-host stuff.
  30075. // chop off any delim chars.
  30076. if (!unsafeProtocol[lowerProto]) {
  30077. // First, make 100% sure that any "autoEscape" chars get
  30078. // escaped, even if encodeURIComponent doesn't think they
  30079. // need to be.
  30080. for (i = 0, l = autoEscape.length; i < l; i++) {
  30081. var ae = autoEscape[i];
  30082. if (rest.indexOf(ae) === -1)
  30083. continue;
  30084. var esc = encodeURIComponent(ae);
  30085. if (esc === ae) {
  30086. esc = escape(ae);
  30087. }
  30088. rest = rest.split(ae).join(esc);
  30089. }
  30090. }
  30091. // chop off from the tail first.
  30092. var hash = rest.indexOf('#');
  30093. if (hash !== -1) {
  30094. // got a fragment string.
  30095. self.hash = rest.substr(hash);
  30096. rest = rest.slice(0, hash);
  30097. }
  30098. var qm = rest.indexOf('?');
  30099. if (qm !== -1) {
  30100. self.search = rest.substr(qm);
  30101. self.query = rest.substr(qm + 1);
  30102. if (parseQueryString) {
  30103. self.query = parse$1(self.query);
  30104. }
  30105. rest = rest.slice(0, qm);
  30106. } else if (parseQueryString) {
  30107. // no query string, but parseQueryString still requested
  30108. self.search = '';
  30109. self.query = {};
  30110. }
  30111. if (rest) self.pathname = rest;
  30112. if (slashedProtocol[lowerProto] &&
  30113. self.hostname && !self.pathname) {
  30114. self.pathname = '/';
  30115. }
  30116. //to support http.request
  30117. if (self.pathname || self.search) {
  30118. p = self.pathname || '';
  30119. var s = self.search || '';
  30120. self.path = p + s;
  30121. }
  30122. // finally, reconstruct the href based on what has been validated.
  30123. self.href = format(self);
  30124. return self;
  30125. }
  30126. function urlFileURLToPath(path) {
  30127. if (typeof path === 'string')
  30128. path = new Url().parse(path);
  30129. else if (!(path instanceof Url))
  30130. throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type ' + (typeof path) + String(path));
  30131. if (path.protocol !== 'file:')
  30132. throw new TypeError('The URL must be of scheme file');
  30133. return getPathFromURLPosix(path);
  30134. }
  30135. function getPathFromURLPosix(url) {
  30136. const pathname = url.pathname;
  30137. for (let n = 0; n < pathname.length; n++) {
  30138. if (pathname[n] === '%') {
  30139. const third = pathname.codePointAt(n + 2) | 0x20;
  30140. if (pathname[n + 1] === '2' && third === 102) {
  30141. throw new TypeError(
  30142. 'must not include encoded / characters'
  30143. );
  30144. }
  30145. }
  30146. }
  30147. return decodeURIComponent(pathname);
  30148. }
  30149. // format a parsed object into a url string
  30150. function urlFormat(obj) {
  30151. // ensure it's an object, and not a string url.
  30152. // If it's an obj, this is a no-op.
  30153. // this way, you can call url_format() on strings
  30154. // to clean up potentially wonky urls.
  30155. if (isString(obj)) obj = parse({}, obj);
  30156. return format(obj);
  30157. }
  30158. function format(self) {
  30159. var auth = self.auth || '';
  30160. if (auth) {
  30161. auth = encodeURIComponent(auth);
  30162. auth = auth.replace(/%3A/i, ':');
  30163. auth += '@';
  30164. }
  30165. var protocol = self.protocol || '',
  30166. pathname = self.pathname || '',
  30167. hash = self.hash || '',
  30168. host = false,
  30169. query = '';
  30170. if (self.host) {
  30171. host = auth + self.host;
  30172. } else if (self.hostname) {
  30173. host = auth + (self.hostname.indexOf(':') === -1 ?
  30174. self.hostname :
  30175. '[' + this.hostname + ']');
  30176. if (self.port) {
  30177. host += ':' + self.port;
  30178. }
  30179. }
  30180. if (self.query &&
  30181. isObject$1(self.query) &&
  30182. Object.keys(self.query).length) {
  30183. query = stringify(self.query);
  30184. }
  30185. var search = self.search || (query && ('?' + query)) || '';
  30186. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  30187. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  30188. // unless they had them to begin with.
  30189. if (self.slashes ||
  30190. (!protocol || slashedProtocol[protocol]) && host !== false) {
  30191. host = '//' + (host || '');
  30192. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  30193. } else if (!host) {
  30194. host = '';
  30195. }
  30196. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  30197. if (search && search.charAt(0) !== '?') search = '?' + search;
  30198. pathname = pathname.replace(/[?#]/g, function(match) {
  30199. return encodeURIComponent(match);
  30200. });
  30201. search = search.replace('#', '%23');
  30202. return protocol + host + pathname + search + hash;
  30203. }
  30204. Url.prototype.format = function() {
  30205. return format(this);
  30206. };
  30207. function urlResolve(source, relative) {
  30208. return urlParse(source, false, true).resolve(relative);
  30209. }
  30210. Url.prototype.resolve = function(relative) {
  30211. return this.resolveObject(urlParse(relative, false, true)).format();
  30212. };
  30213. function urlResolveObject(source, relative) {
  30214. if (!source) return relative;
  30215. return urlParse(source, false, true).resolveObject(relative);
  30216. }
  30217. Url.prototype.resolveObject = function(relative) {
  30218. if (isString(relative)) {
  30219. var rel = new Url();
  30220. rel.parse(relative, false, true);
  30221. relative = rel;
  30222. }
  30223. var result = new Url();
  30224. var tkeys = Object.keys(this);
  30225. for (var tk = 0; tk < tkeys.length; tk++) {
  30226. var tkey = tkeys[tk];
  30227. result[tkey] = this[tkey];
  30228. }
  30229. // hash is always overridden, no matter what.
  30230. // even href="" will remove it.
  30231. result.hash = relative.hash;
  30232. // if the relative url is empty, then there's nothing left to do here.
  30233. if (relative.href === '') {
  30234. result.href = result.format();
  30235. return result;
  30236. }
  30237. // hrefs like //foo/bar always cut to the protocol.
  30238. if (relative.slashes && !relative.protocol) {
  30239. // take everything except the protocol from relative
  30240. var rkeys = Object.keys(relative);
  30241. for (var rk = 0; rk < rkeys.length; rk++) {
  30242. var rkey = rkeys[rk];
  30243. if (rkey !== 'protocol')
  30244. result[rkey] = relative[rkey];
  30245. }
  30246. //urlParse appends trailing / to urls like http://www.example.com
  30247. if (slashedProtocol[result.protocol] &&
  30248. result.hostname && !result.pathname) {
  30249. result.path = result.pathname = '/';
  30250. }
  30251. result.href = result.format();
  30252. return result;
  30253. }
  30254. var relPath;
  30255. if (relative.protocol && relative.protocol !== result.protocol) {
  30256. // if it's a known url protocol, then changing
  30257. // the protocol does weird things
  30258. // first, if it's not file:, then we MUST have a host,
  30259. // and if there was a path
  30260. // to begin with, then we MUST have a path.
  30261. // if it is file:, then the host is dropped,
  30262. // because that's known to be hostless.
  30263. // anything else is assumed to be absolute.
  30264. if (!slashedProtocol[relative.protocol]) {
  30265. var keys = Object.keys(relative);
  30266. for (var v = 0; v < keys.length; v++) {
  30267. var k = keys[v];
  30268. result[k] = relative[k];
  30269. }
  30270. result.href = result.format();
  30271. return result;
  30272. }
  30273. result.protocol = relative.protocol;
  30274. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  30275. relPath = (relative.pathname || '').split('/');
  30276. while (relPath.length && !(relative.host = relPath.shift()));
  30277. if (!relative.host) relative.host = '';
  30278. if (!relative.hostname) relative.hostname = '';
  30279. if (relPath[0] !== '') relPath.unshift('');
  30280. if (relPath.length < 2) relPath.unshift('');
  30281. result.pathname = relPath.join('/');
  30282. } else {
  30283. result.pathname = relative.pathname;
  30284. }
  30285. result.search = relative.search;
  30286. result.query = relative.query;
  30287. result.host = relative.host || '';
  30288. result.auth = relative.auth;
  30289. result.hostname = relative.hostname || relative.host;
  30290. result.port = relative.port;
  30291. // to support http.request
  30292. if (result.pathname || result.search) {
  30293. var p = result.pathname || '';
  30294. var s = result.search || '';
  30295. result.path = p + s;
  30296. }
  30297. result.slashes = result.slashes || relative.slashes;
  30298. result.href = result.format();
  30299. return result;
  30300. }
  30301. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  30302. isRelAbs = (
  30303. relative.host ||
  30304. relative.pathname && relative.pathname.charAt(0) === '/'
  30305. ),
  30306. mustEndAbs = (isRelAbs || isSourceAbs ||
  30307. (result.host && relative.pathname)),
  30308. removeAllDots = mustEndAbs,
  30309. srcPath = result.pathname && result.pathname.split('/') || [],
  30310. psychotic = result.protocol && !slashedProtocol[result.protocol];
  30311. relPath = relative.pathname && relative.pathname.split('/') || [];
  30312. // if the url is a non-slashed url, then relative
  30313. // links like ../.. should be able
  30314. // to crawl up to the hostname, as well. This is strange.
  30315. // result.protocol has already been set by now.
  30316. // Later on, put the first path part into the host field.
  30317. if (psychotic) {
  30318. result.hostname = '';
  30319. result.port = null;
  30320. if (result.host) {
  30321. if (srcPath[0] === '') srcPath[0] = result.host;
  30322. else srcPath.unshift(result.host);
  30323. }
  30324. result.host = '';
  30325. if (relative.protocol) {
  30326. relative.hostname = null;
  30327. relative.port = null;
  30328. if (relative.host) {
  30329. if (relPath[0] === '') relPath[0] = relative.host;
  30330. else relPath.unshift(relative.host);
  30331. }
  30332. relative.host = null;
  30333. }
  30334. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  30335. }
  30336. var authInHost;
  30337. if (isRelAbs) {
  30338. // it's absolute.
  30339. result.host = (relative.host || relative.host === '') ?
  30340. relative.host : result.host;
  30341. result.hostname = (relative.hostname || relative.hostname === '') ?
  30342. relative.hostname : result.hostname;
  30343. result.search = relative.search;
  30344. result.query = relative.query;
  30345. srcPath = relPath;
  30346. // fall through to the dot-handling below.
  30347. } else if (relPath.length) {
  30348. // it's relative
  30349. // throw away the existing file, and take the new path instead.
  30350. if (!srcPath) srcPath = [];
  30351. srcPath.pop();
  30352. srcPath = srcPath.concat(relPath);
  30353. result.search = relative.search;
  30354. result.query = relative.query;
  30355. } else if (!isNullOrUndefined(relative.search)) {
  30356. // just pull out the search.
  30357. // like href='?foo'.
  30358. // Put this after the other two cases because it simplifies the booleans
  30359. if (psychotic) {
  30360. result.hostname = result.host = srcPath.shift();
  30361. //occationaly the auth can get stuck only in host
  30362. //this especially happens in cases like
  30363. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  30364. authInHost = result.host && result.host.indexOf('@') > 0 ?
  30365. result.host.split('@') : false;
  30366. if (authInHost) {
  30367. result.auth = authInHost.shift();
  30368. result.host = result.hostname = authInHost.shift();
  30369. }
  30370. }
  30371. result.search = relative.search;
  30372. result.query = relative.query;
  30373. //to support http.request
  30374. if (!isNull(result.pathname) || !isNull(result.search)) {
  30375. result.path = (result.pathname ? result.pathname : '') +
  30376. (result.search ? result.search : '');
  30377. }
  30378. result.href = result.format();
  30379. return result;
  30380. }
  30381. if (!srcPath.length) {
  30382. // no path at all. easy.
  30383. // we've already handled the other stuff above.
  30384. result.pathname = null;
  30385. //to support http.request
  30386. if (result.search) {
  30387. result.path = '/' + result.search;
  30388. } else {
  30389. result.path = null;
  30390. }
  30391. result.href = result.format();
  30392. return result;
  30393. }
  30394. // if a url ENDs in . or .., then it must get a trailing slash.
  30395. // however, if it ends in anything else non-slashy,
  30396. // then it must NOT get a trailing slash.
  30397. var last = srcPath.slice(-1)[0];
  30398. var hasTrailingSlash = (
  30399. (result.host || relative.host || srcPath.length > 1) &&
  30400. (last === '.' || last === '..') || last === '');
  30401. // strip single dots, resolve double dots to parent dir
  30402. // if the path tries to go above the root, `up` ends up > 0
  30403. var up = 0;
  30404. for (var i = srcPath.length; i >= 0; i--) {
  30405. last = srcPath[i];
  30406. if (last === '.') {
  30407. srcPath.splice(i, 1);
  30408. } else if (last === '..') {
  30409. srcPath.splice(i, 1);
  30410. up++;
  30411. } else if (up) {
  30412. srcPath.splice(i, 1);
  30413. up--;
  30414. }
  30415. }
  30416. // if the path is allowed to go above the root, restore leading ..s
  30417. if (!mustEndAbs && !removeAllDots) {
  30418. for (; up--; up) {
  30419. srcPath.unshift('..');
  30420. }
  30421. }
  30422. if (mustEndAbs && srcPath[0] !== '' &&
  30423. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  30424. srcPath.unshift('');
  30425. }
  30426. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  30427. srcPath.push('');
  30428. }
  30429. var isAbsolute = srcPath[0] === '' ||
  30430. (srcPath[0] && srcPath[0].charAt(0) === '/');
  30431. // put the host back
  30432. if (psychotic) {
  30433. result.hostname = result.host = isAbsolute ? '' :
  30434. srcPath.length ? srcPath.shift() : '';
  30435. //occationaly the auth can get stuck only in host
  30436. //this especially happens in cases like
  30437. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  30438. authInHost = result.host && result.host.indexOf('@') > 0 ?
  30439. result.host.split('@') : false;
  30440. if (authInHost) {
  30441. result.auth = authInHost.shift();
  30442. result.host = result.hostname = authInHost.shift();
  30443. }
  30444. }
  30445. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  30446. if (mustEndAbs && !isAbsolute) {
  30447. srcPath.unshift('');
  30448. }
  30449. if (!srcPath.length) {
  30450. result.pathname = null;
  30451. result.path = null;
  30452. } else {
  30453. result.pathname = srcPath.join('/');
  30454. }
  30455. //to support request.http
  30456. if (!isNull(result.pathname) || !isNull(result.search)) {
  30457. result.path = (result.pathname ? result.pathname : '') +
  30458. (result.search ? result.search : '');
  30459. }
  30460. result.auth = relative.auth || result.auth;
  30461. result.slashes = result.slashes || relative.slashes;
  30462. result.href = result.format();
  30463. return result;
  30464. };
  30465. Url.prototype.parseHost = function() {
  30466. return parseHost(this);
  30467. };
  30468. function parseHost(self) {
  30469. var host = self.host;
  30470. var port = portPattern.exec(host);
  30471. if (port) {
  30472. port = port[0];
  30473. if (port !== ':') {
  30474. self.port = port.substr(1);
  30475. }
  30476. host = host.substr(0, host.length - port.length);
  30477. }
  30478. if (host) self.hostname = host;
  30479. }
  30480. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  30481. __proto__: null,
  30482. URL: URL$1,
  30483. URLSearchParams: URLSearchParams,
  30484. Url: Url,
  30485. default: _polyfillNode_url,
  30486. fileURLToPath: urlFileURLToPath,
  30487. format: urlFormat,
  30488. parse: urlParse,
  30489. resolve: urlResolve,
  30490. resolveObject: urlResolveObject
  30491. });
  30492. function isRelativeUrl(url) {
  30493. const firstChar = url.charAt(0);
  30494. return firstChar === "." || firstChar === "~" || firstChar === "@";
  30495. }
  30496. const externalRE = /^(?:https?:)?\/\//;
  30497. function isExternalUrl(url) {
  30498. return externalRE.test(url);
  30499. }
  30500. const dataUrlRE = /^\s*data:/i;
  30501. function isDataUrl(url) {
  30502. return dataUrlRE.test(url);
  30503. }
  30504. function parseUrl(url) {
  30505. const firstChar = url.charAt(0);
  30506. if (firstChar === "~") {
  30507. const secondChar = url.charAt(1);
  30508. url = url.slice(secondChar === "/" ? 2 : 1);
  30509. }
  30510. return parseUriParts(url);
  30511. }
  30512. function parseUriParts(urlString) {
  30513. return urlParse(isString$1(urlString) ? urlString : "", false, true);
  30514. }
  30515. var __defProp$9 = Object.defineProperty;
  30516. var __defProps$8 = Object.defineProperties;
  30517. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  30518. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  30519. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  30520. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  30521. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30522. var __spreadValues$9 = (a, b) => {
  30523. for (var prop in b || (b = {}))
  30524. if (__hasOwnProp$9.call(b, prop))
  30525. __defNormalProp$9(a, prop, b[prop]);
  30526. if (__getOwnPropSymbols$9)
  30527. for (var prop of __getOwnPropSymbols$9(b)) {
  30528. if (__propIsEnum$9.call(b, prop))
  30529. __defNormalProp$9(a, prop, b[prop]);
  30530. }
  30531. return a;
  30532. };
  30533. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  30534. const defaultAssetUrlOptions = {
  30535. base: null,
  30536. includeAbsolute: false,
  30537. tags: {
  30538. video: ["src", "poster"],
  30539. source: ["src"],
  30540. img: ["src"],
  30541. image: ["xlink:href", "href"],
  30542. use: ["xlink:href", "href"]
  30543. }
  30544. };
  30545. const normalizeOptions = (options) => {
  30546. if (Object.keys(options).some((key) => isArray$3(options[key]))) {
  30547. return __spreadProps$8(__spreadValues$9({}, defaultAssetUrlOptions), {
  30548. tags: options
  30549. });
  30550. }
  30551. return __spreadValues$9(__spreadValues$9({}, defaultAssetUrlOptions), options);
  30552. };
  30553. const createAssetUrlTransformWithOptions = (options) => {
  30554. return (node, context) => transformAssetUrl(node, context, options);
  30555. };
  30556. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  30557. if (node.type === 1) {
  30558. if (!node.props.length) {
  30559. return;
  30560. }
  30561. const tags = options.tags || defaultAssetUrlOptions.tags;
  30562. const attrs = tags[node.tag];
  30563. const wildCardAttrs = tags["*"];
  30564. if (!attrs && !wildCardAttrs) {
  30565. return;
  30566. }
  30567. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  30568. node.props.forEach((attr, index) => {
  30569. if (attr.type !== 6 || !assetAttrs.includes(attr.name) || !attr.value || isExternalUrl(attr.value.content) || isDataUrl(attr.value.content) || attr.value.content[0] === "#" || !options.includeAbsolute && !isRelativeUrl(attr.value.content)) {
  30570. return;
  30571. }
  30572. const url = parseUrl(attr.value.content);
  30573. if (options.base && attr.value.content[0] === ".") {
  30574. const base = parseUrl(options.base);
  30575. const protocol = base.protocol || "";
  30576. const host = base.host ? protocol + "//" + base.host : "";
  30577. const basePath = base.path || "/";
  30578. attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
  30579. return;
  30580. }
  30581. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  30582. node.props[index] = {
  30583. type: 7,
  30584. name: "bind",
  30585. arg: createSimpleExpression(attr.name, true, attr.loc),
  30586. exp,
  30587. modifiers: [],
  30588. loc: attr.loc
  30589. };
  30590. });
  30591. }
  30592. };
  30593. function getImportsExpressionExp(path2, hash, loc, context) {
  30594. if (path2) {
  30595. let name;
  30596. let exp;
  30597. const existingIndex = context.imports.findIndex((i) => i.path === path2);
  30598. if (existingIndex > -1) {
  30599. name = `_imports_${existingIndex}`;
  30600. exp = context.imports[existingIndex].exp;
  30601. } else {
  30602. name = `_imports_${context.imports.length}`;
  30603. exp = createSimpleExpression(
  30604. name,
  30605. false,
  30606. loc,
  30607. 3
  30608. );
  30609. context.imports.push({
  30610. exp,
  30611. path: decodeURIComponent(path2)
  30612. });
  30613. }
  30614. if (!hash) {
  30615. return exp;
  30616. }
  30617. const hashExp = `${name} + '${hash}'`;
  30618. const finalExp = createSimpleExpression(
  30619. hashExp,
  30620. false,
  30621. loc,
  30622. 3
  30623. );
  30624. if (!context.hoistStatic) {
  30625. return finalExp;
  30626. }
  30627. const existingHoistIndex = context.hoists.findIndex((h) => {
  30628. return h && h.type === 4 && !h.isStatic && h.content === hashExp;
  30629. });
  30630. if (existingHoistIndex > -1) {
  30631. return createSimpleExpression(
  30632. `_hoisted_${existingHoistIndex + 1}`,
  30633. false,
  30634. loc,
  30635. 3
  30636. );
  30637. }
  30638. return context.hoist(finalExp);
  30639. } else {
  30640. return createSimpleExpression(`''`, false, loc, 3);
  30641. }
  30642. }
  30643. const srcsetTags = ["img", "source"];
  30644. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  30645. const createSrcsetTransformWithOptions = (options) => {
  30646. return (node, context) => transformSrcset(node, context, options);
  30647. };
  30648. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  30649. if (node.type === 1) {
  30650. if (srcsetTags.includes(node.tag) && node.props.length) {
  30651. node.props.forEach((attr, index) => {
  30652. if (attr.name === "srcset" && attr.type === 6) {
  30653. if (!attr.value) return;
  30654. const value = attr.value.content;
  30655. if (!value) return;
  30656. const imageCandidates = value.split(",").map((s) => {
  30657. const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
  30658. return { url, descriptor };
  30659. });
  30660. for (let i = 0; i < imageCandidates.length; i++) {
  30661. const { url } = imageCandidates[i];
  30662. if (isDataUrl(url)) {
  30663. imageCandidates[i + 1].url = url + "," + imageCandidates[i + 1].url;
  30664. imageCandidates.splice(i, 1);
  30665. }
  30666. }
  30667. const shouldProcessUrl = (url) => {
  30668. return url && !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
  30669. };
  30670. if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
  30671. return;
  30672. }
  30673. if (options.base) {
  30674. const base = options.base;
  30675. const set = [];
  30676. let needImportTransform = false;
  30677. imageCandidates.forEach((candidate) => {
  30678. let { url, descriptor } = candidate;
  30679. descriptor = descriptor ? ` ${descriptor}` : ``;
  30680. if (url[0] === ".") {
  30681. candidate.url = (path.posix || path).join(base, url);
  30682. set.push(candidate.url + descriptor);
  30683. } else if (shouldProcessUrl(url)) {
  30684. needImportTransform = true;
  30685. } else {
  30686. set.push(url + descriptor);
  30687. }
  30688. });
  30689. if (!needImportTransform) {
  30690. attr.value.content = set.join(", ");
  30691. return;
  30692. }
  30693. }
  30694. const compoundExpression = createCompoundExpression([], attr.loc);
  30695. imageCandidates.forEach(({ url, descriptor }, index2) => {
  30696. if (shouldProcessUrl(url)) {
  30697. const { path: path2 } = parseUrl(url);
  30698. let exp2;
  30699. if (path2) {
  30700. const existingImportsIndex = context.imports.findIndex(
  30701. (i) => i.path === path2
  30702. );
  30703. if (existingImportsIndex > -1) {
  30704. exp2 = createSimpleExpression(
  30705. `_imports_${existingImportsIndex}`,
  30706. false,
  30707. attr.loc,
  30708. 3
  30709. );
  30710. } else {
  30711. exp2 = createSimpleExpression(
  30712. `_imports_${context.imports.length}`,
  30713. false,
  30714. attr.loc,
  30715. 3
  30716. );
  30717. context.imports.push({ exp: exp2, path: path2 });
  30718. }
  30719. compoundExpression.children.push(exp2);
  30720. }
  30721. } else {
  30722. const exp2 = createSimpleExpression(
  30723. `"${url}"`,
  30724. false,
  30725. attr.loc,
  30726. 3
  30727. );
  30728. compoundExpression.children.push(exp2);
  30729. }
  30730. const isNotLast = imageCandidates.length - 1 > index2;
  30731. if (descriptor && isNotLast) {
  30732. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  30733. } else if (descriptor) {
  30734. compoundExpression.children.push(` + ' ${descriptor}'`);
  30735. } else if (isNotLast) {
  30736. compoundExpression.children.push(` + ', ' + `);
  30737. }
  30738. });
  30739. let exp = compoundExpression;
  30740. if (context.hoistStatic) {
  30741. exp = context.hoist(compoundExpression);
  30742. exp.constType = 3;
  30743. }
  30744. node.props[index] = {
  30745. type: 7,
  30746. name: "bind",
  30747. arg: createSimpleExpression("srcset", true, attr.loc),
  30748. exp,
  30749. modifiers: [],
  30750. loc: attr.loc
  30751. };
  30752. }
  30753. });
  30754. }
  30755. }
  30756. };
  30757. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  30758. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  30759. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  30760. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  30761. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  30762. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  30763. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  30764. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  30765. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  30766. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  30767. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  30768. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(
  30769. `ssrIncludeBooleanAttr`
  30770. );
  30771. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  30772. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  30773. const SSR_RENDER_DYNAMIC_MODEL = Symbol(
  30774. `ssrRenderDynamicModel`
  30775. );
  30776. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(
  30777. `ssrGetDynamicModelProps`
  30778. );
  30779. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  30780. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  30781. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  30782. const ssrHelpers = {
  30783. [SSR_INTERPOLATE]: `ssrInterpolate`,
  30784. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  30785. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  30786. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  30787. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  30788. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  30789. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  30790. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  30791. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  30792. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  30793. [SSR_RENDER_LIST]: `ssrRenderList`,
  30794. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  30795. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  30796. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  30797. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  30798. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  30799. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  30800. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  30801. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  30802. };
  30803. registerRuntimeHelpers(ssrHelpers);
  30804. const ssrTransformIf = createStructuralDirectiveTransform(
  30805. /^(?:if|else|else-if)$/,
  30806. processIf
  30807. );
  30808. function ssrProcessIf(node, context, disableNestedFragments = false, disableComment = false) {
  30809. const [rootBranch] = node.branches;
  30810. const ifStatement = createIfStatement(
  30811. rootBranch.condition,
  30812. processIfBranch(rootBranch, context, disableNestedFragments)
  30813. );
  30814. context.pushStatement(ifStatement);
  30815. let currentIf = ifStatement;
  30816. for (let i = 1; i < node.branches.length; i++) {
  30817. const branch = node.branches[i];
  30818. const branchBlockStatement = processIfBranch(
  30819. branch,
  30820. context,
  30821. disableNestedFragments
  30822. );
  30823. if (branch.condition) {
  30824. currentIf = currentIf.alternate = createIfStatement(
  30825. branch.condition,
  30826. branchBlockStatement
  30827. );
  30828. } else {
  30829. currentIf.alternate = branchBlockStatement;
  30830. }
  30831. }
  30832. if (!currentIf.alternate && !disableComment) {
  30833. currentIf.alternate = createBlockStatement([
  30834. createCallExpression(`_push`, ["`<!---->`"])
  30835. ]);
  30836. }
  30837. }
  30838. function processIfBranch(branch, context, disableNestedFragments = false) {
  30839. const { children } = branch;
  30840. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  30841. !(children.length === 1 && children[0].type === 11);
  30842. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  30843. }
  30844. const ssrTransformFor = createStructuralDirectiveTransform("for", processFor);
  30845. function ssrProcessFor(node, context, disableNestedFragments = false) {
  30846. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  30847. const renderLoop = createFunctionExpression(
  30848. createForLoopParams(node.parseResult)
  30849. );
  30850. renderLoop.body = processChildrenAsStatement(
  30851. node,
  30852. context,
  30853. needFragmentWrapper
  30854. );
  30855. if (!disableNestedFragments) {
  30856. context.pushStringPart(`<!--[-->`);
  30857. }
  30858. context.pushStatement(
  30859. createCallExpression(context.helper(SSR_RENDER_LIST), [
  30860. node.source,
  30861. renderLoop
  30862. ])
  30863. );
  30864. if (!disableNestedFragments) {
  30865. context.pushStringPart(`<!--]-->`);
  30866. }
  30867. }
  30868. const ssrTransformSlotOutlet = (node, context) => {
  30869. if (isSlotOutlet(node)) {
  30870. const { slotName, slotProps } = processSlotOutlet(node, context);
  30871. const args = [
  30872. `_ctx.$slots`,
  30873. slotName,
  30874. slotProps || `{}`,
  30875. // fallback content placeholder. will be replaced in the process phase
  30876. `null`,
  30877. `_push`,
  30878. `_parent`
  30879. ];
  30880. if (context.scopeId && context.slotted !== false) {
  30881. args.push(`"${context.scopeId}-s"`);
  30882. }
  30883. let method = SSR_RENDER_SLOT;
  30884. let parent = context.parent;
  30885. if (parent) {
  30886. const children = parent.children;
  30887. if (parent.type === 10) {
  30888. parent = context.grandParent;
  30889. }
  30890. let componentType;
  30891. if (parent.type === 1 && parent.tagType === 1 && ((componentType = resolveComponentType(parent, context, true)) === TRANSITION || componentType === TRANSITION_GROUP) && children.filter((c) => c.type === 1).length === 1) {
  30892. method = SSR_RENDER_SLOT_INNER;
  30893. if (!(context.scopeId && context.slotted !== false)) {
  30894. args.push("null");
  30895. }
  30896. args.push("true");
  30897. }
  30898. }
  30899. node.ssrCodegenNode = createCallExpression(context.helper(method), args);
  30900. }
  30901. };
  30902. function ssrProcessSlotOutlet(node, context) {
  30903. const renderCall = node.ssrCodegenNode;
  30904. if (node.children.length) {
  30905. const fallbackRenderFn = createFunctionExpression([]);
  30906. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  30907. renderCall.arguments[3] = fallbackRenderFn;
  30908. }
  30909. if (context.withSlotScopeId) {
  30910. const slotScopeId = renderCall.arguments[6];
  30911. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  30912. }
  30913. context.pushStatement(node.ssrCodegenNode);
  30914. }
  30915. function createSSRCompilerError(code, loc) {
  30916. return createCompilerError(code, loc, SSRErrorMessages);
  30917. }
  30918. const SSRErrorMessages = {
  30919. [65]: `Unsafe attribute name for SSR.`,
  30920. [66]: `Missing the 'to' prop on teleport element.`,
  30921. [67]: `Invalid AST node during SSR transform.`
  30922. };
  30923. function ssrProcessTeleport(node, context) {
  30924. const targetProp = findProp(node, "to");
  30925. if (!targetProp) {
  30926. context.onError(
  30927. createSSRCompilerError(66, node.loc)
  30928. );
  30929. return;
  30930. }
  30931. let target;
  30932. if (targetProp.type === 6) {
  30933. target = targetProp.value && createSimpleExpression(targetProp.value.content, true);
  30934. } else {
  30935. target = targetProp.exp;
  30936. }
  30937. if (!target) {
  30938. context.onError(
  30939. createSSRCompilerError(
  30940. 66,
  30941. targetProp.loc
  30942. )
  30943. );
  30944. return;
  30945. }
  30946. const disabledProp = findProp(
  30947. node,
  30948. "disabled",
  30949. false,
  30950. true
  30951. /* allow empty */
  30952. );
  30953. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  30954. const contentRenderFn = createFunctionExpression(
  30955. [`_push`],
  30956. void 0,
  30957. // Body is added later
  30958. true,
  30959. // newline
  30960. false,
  30961. // isSlot
  30962. node.loc
  30963. );
  30964. contentRenderFn.body = processChildrenAsStatement(node, context);
  30965. context.pushStatement(
  30966. createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  30967. `_push`,
  30968. contentRenderFn,
  30969. target,
  30970. disabled,
  30971. `_parent`
  30972. ])
  30973. );
  30974. }
  30975. const wipMap$3 = /* @__PURE__ */ new WeakMap();
  30976. function ssrTransformSuspense(node, context) {
  30977. return () => {
  30978. if (node.children.length) {
  30979. const wipEntry = {
  30980. slotsExp: null,
  30981. // to be immediately set
  30982. wipSlots: []
  30983. };
  30984. wipMap$3.set(node, wipEntry);
  30985. wipEntry.slotsExp = buildSlots(
  30986. node,
  30987. context,
  30988. (_props, _vForExp, children, loc) => {
  30989. const fn = createFunctionExpression(
  30990. [],
  30991. void 0,
  30992. // no return, assign body later
  30993. true,
  30994. // newline
  30995. false,
  30996. // suspense slots are not treated as normal slots
  30997. loc
  30998. );
  30999. wipEntry.wipSlots.push({
  31000. fn,
  31001. children
  31002. });
  31003. return fn;
  31004. }
  31005. ).slots;
  31006. }
  31007. };
  31008. }
  31009. function ssrProcessSuspense(node, context) {
  31010. const wipEntry = wipMap$3.get(node);
  31011. if (!wipEntry) {
  31012. return;
  31013. }
  31014. const { slotsExp, wipSlots } = wipEntry;
  31015. for (let i = 0; i < wipSlots.length; i++) {
  31016. const slot = wipSlots[i];
  31017. slot.fn.body = processChildrenAsStatement(slot, context);
  31018. }
  31019. context.pushStatement(
  31020. createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  31021. `_push`,
  31022. slotsExp
  31023. ])
  31024. );
  31025. }
  31026. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  31027. const ssrTransformElement = (node, context) => {
  31028. if (node.type !== 1 || node.tagType !== 0) {
  31029. return;
  31030. }
  31031. return function ssrPostTransformElement() {
  31032. const openTag = [`<${node.tag}`];
  31033. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  31034. const hasDynamicVBind = hasDynamicKeyVBind(node);
  31035. const hasCustomDir = node.props.some(
  31036. (p) => p.type === 7 && !isBuiltInDirective(p.name)
  31037. );
  31038. const vShowPropIndex = node.props.findIndex(
  31039. (i) => i.type === 7 && i.name === "show"
  31040. );
  31041. if (vShowPropIndex !== -1) {
  31042. const vShowProp = node.props[vShowPropIndex];
  31043. node.props.splice(vShowPropIndex, 1);
  31044. node.props.push(vShowProp);
  31045. }
  31046. const needMergeProps = hasDynamicVBind || hasCustomDir;
  31047. if (needMergeProps) {
  31048. const { props, directives } = buildProps(
  31049. node,
  31050. context,
  31051. node.props,
  31052. false,
  31053. false,
  31054. true
  31055. );
  31056. if (props || directives.length) {
  31057. const mergedProps = buildSSRProps(props, directives, context);
  31058. const propsExp = createCallExpression(
  31059. context.helper(SSR_RENDER_ATTRS),
  31060. [mergedProps]
  31061. );
  31062. if (node.tag === "textarea") {
  31063. const existingText = node.children[0];
  31064. if (!existingText || existingText.type !== 5) {
  31065. const tempId = `_temp${context.temps++}`;
  31066. propsExp.arguments = [
  31067. createAssignmentExpression(
  31068. createSimpleExpression(tempId, false),
  31069. mergedProps
  31070. )
  31071. ];
  31072. rawChildrenMap.set(
  31073. node,
  31074. createCallExpression(context.helper(SSR_INTERPOLATE), [
  31075. createConditionalExpression(
  31076. createSimpleExpression(`"value" in ${tempId}`, false),
  31077. createSimpleExpression(`${tempId}.value`, false),
  31078. createSimpleExpression(
  31079. existingText ? existingText.content : ``,
  31080. true
  31081. ),
  31082. false
  31083. )
  31084. ])
  31085. );
  31086. }
  31087. } else if (node.tag === "input") {
  31088. const vModel = findVModel(node);
  31089. if (vModel) {
  31090. const tempId = `_temp${context.temps++}`;
  31091. const tempExp = createSimpleExpression(tempId, false);
  31092. propsExp.arguments = [
  31093. createSequenceExpression([
  31094. createAssignmentExpression(tempExp, mergedProps),
  31095. createCallExpression(context.helper(MERGE_PROPS), [
  31096. tempExp,
  31097. createCallExpression(
  31098. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  31099. [
  31100. tempExp,
  31101. // existing props
  31102. vModel.exp
  31103. // model
  31104. ]
  31105. )
  31106. ])
  31107. ])
  31108. ];
  31109. }
  31110. } else if (directives.length && !node.children.length) {
  31111. const vText = findDir(node, "text");
  31112. if (!vText) {
  31113. const tempId = `_temp${context.temps++}`;
  31114. propsExp.arguments = [
  31115. createAssignmentExpression(
  31116. createSimpleExpression(tempId, false),
  31117. mergedProps
  31118. )
  31119. ];
  31120. rawChildrenMap.set(
  31121. node,
  31122. createConditionalExpression(
  31123. createSimpleExpression(`"textContent" in ${tempId}`, false),
  31124. createCallExpression(context.helper(SSR_INTERPOLATE), [
  31125. createSimpleExpression(`${tempId}.textContent`, false)
  31126. ]),
  31127. createSimpleExpression(`${tempId}.innerHTML ?? ''`, false),
  31128. false
  31129. )
  31130. );
  31131. }
  31132. }
  31133. if (needTagForRuntime) {
  31134. propsExp.arguments.push(`"${node.tag}"`);
  31135. }
  31136. openTag.push(propsExp);
  31137. }
  31138. }
  31139. let dynamicClassBinding = void 0;
  31140. let staticClassBinding = void 0;
  31141. let dynamicStyleBinding = void 0;
  31142. for (let i = 0; i < node.props.length; i++) {
  31143. const prop = node.props[i];
  31144. if (node.tag === "input" && isTrueFalseValue(prop)) {
  31145. continue;
  31146. }
  31147. if (prop.type === 7) {
  31148. if (prop.name === "html" && prop.exp) {
  31149. rawChildrenMap.set(
  31150. node,
  31151. createCompoundExpression([`(`, prop.exp, `) ?? ''`])
  31152. );
  31153. } else if (prop.name === "text" && prop.exp) {
  31154. node.children = [createInterpolation(prop.exp, prop.loc)];
  31155. } else if (prop.name === "slot") {
  31156. context.onError(
  31157. createCompilerError(40, prop.loc)
  31158. );
  31159. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  31160. if (!needMergeProps) {
  31161. node.children = [createInterpolation(prop.exp, prop.loc)];
  31162. }
  31163. } else if (!needMergeProps && prop.name !== "on") {
  31164. const directiveTransform = context.directiveTransforms[prop.name];
  31165. if (directiveTransform) {
  31166. const { props, ssrTagParts } = directiveTransform(
  31167. prop,
  31168. node,
  31169. context
  31170. );
  31171. if (ssrTagParts) {
  31172. openTag.push(...ssrTagParts);
  31173. }
  31174. for (let j = 0; j < props.length; j++) {
  31175. const { key, value } = props[j];
  31176. if (isStaticExp(key)) {
  31177. let attrName = key.content;
  31178. if (attrName === "key" || attrName === "ref") {
  31179. continue;
  31180. }
  31181. if (attrName === "class") {
  31182. openTag.push(
  31183. ` class="`,
  31184. dynamicClassBinding = createCallExpression(
  31185. context.helper(SSR_RENDER_CLASS),
  31186. [value]
  31187. ),
  31188. `"`
  31189. );
  31190. } else if (attrName === "style") {
  31191. if (dynamicStyleBinding) {
  31192. mergeCall(dynamicStyleBinding, value);
  31193. } else {
  31194. openTag.push(
  31195. ` style="`,
  31196. dynamicStyleBinding = createCallExpression(
  31197. context.helper(SSR_RENDER_STYLE),
  31198. [value]
  31199. ),
  31200. `"`
  31201. );
  31202. }
  31203. } else {
  31204. attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
  31205. if (isBooleanAttr(attrName)) {
  31206. openTag.push(
  31207. createConditionalExpression(
  31208. createCallExpression(
  31209. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  31210. [value]
  31211. ),
  31212. createSimpleExpression(" " + attrName, true),
  31213. createSimpleExpression("", true),
  31214. false
  31215. )
  31216. );
  31217. } else if (isSSRSafeAttrName(attrName)) {
  31218. openTag.push(
  31219. createCallExpression(context.helper(SSR_RENDER_ATTR), [
  31220. key,
  31221. value
  31222. ])
  31223. );
  31224. } else {
  31225. context.onError(
  31226. createSSRCompilerError(
  31227. 65,
  31228. key.loc
  31229. )
  31230. );
  31231. }
  31232. }
  31233. } else {
  31234. const args = [key, value];
  31235. if (needTagForRuntime) {
  31236. args.push(`"${node.tag}"`);
  31237. }
  31238. openTag.push(
  31239. createCallExpression(
  31240. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  31241. args
  31242. )
  31243. );
  31244. }
  31245. }
  31246. }
  31247. }
  31248. } else {
  31249. const name = prop.name;
  31250. if (node.tag === "textarea" && name === "value" && prop.value) {
  31251. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  31252. } else if (!needMergeProps) {
  31253. if (name === "key" || name === "ref") {
  31254. continue;
  31255. }
  31256. if (name === "class" && prop.value) {
  31257. staticClassBinding = JSON.stringify(prop.value.content);
  31258. }
  31259. openTag.push(
  31260. ` ${prop.name}` + (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
  31261. );
  31262. }
  31263. }
  31264. }
  31265. if (dynamicClassBinding && staticClassBinding) {
  31266. mergeCall(dynamicClassBinding, staticClassBinding);
  31267. removeStaticBinding(openTag, "class");
  31268. }
  31269. if (context.scopeId) {
  31270. openTag.push(` ${context.scopeId}`);
  31271. }
  31272. node.ssrCodegenNode = createTemplateLiteral(openTag);
  31273. };
  31274. };
  31275. function buildSSRProps(props, directives, context) {
  31276. let mergePropsArgs = [];
  31277. if (props) {
  31278. if (props.type === 14) {
  31279. mergePropsArgs = props.arguments;
  31280. } else {
  31281. mergePropsArgs.push(props);
  31282. }
  31283. }
  31284. if (directives.length) {
  31285. for (const dir of directives) {
  31286. mergePropsArgs.push(
  31287. createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  31288. `_ctx`,
  31289. ...buildDirectiveArgs(dir, context).elements
  31290. ])
  31291. );
  31292. }
  31293. }
  31294. return mergePropsArgs.length > 1 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  31295. }
  31296. function isTrueFalseValue(prop) {
  31297. if (prop.type === 7) {
  31298. return prop.name === "bind" && prop.arg && isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  31299. } else {
  31300. return prop.name === "true-value" || prop.name === "false-value";
  31301. }
  31302. }
  31303. function isTextareaWithValue(node, prop) {
  31304. return !!(node.tag === "textarea" && prop.name === "bind" && isStaticArgOf(prop.arg, "value"));
  31305. }
  31306. function mergeCall(call, arg) {
  31307. const existing = call.arguments[0];
  31308. if (existing.type === 17) {
  31309. existing.elements.push(arg);
  31310. } else {
  31311. call.arguments[0] = createArrayExpression([existing, arg]);
  31312. }
  31313. }
  31314. function removeStaticBinding(tag, binding) {
  31315. const regExp = new RegExp(`^ ${binding}=".+"$`);
  31316. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  31317. if (i > -1) {
  31318. tag.splice(i, 1);
  31319. }
  31320. }
  31321. function findVModel(node) {
  31322. return node.props.find(
  31323. (p) => p.type === 7 && p.name === "model" && p.exp
  31324. );
  31325. }
  31326. function ssrProcessElement(node, context) {
  31327. const isVoidTag = context.options.isVoidTag || NO;
  31328. const elementsToAdd = node.ssrCodegenNode.elements;
  31329. for (let j = 0; j < elementsToAdd.length; j++) {
  31330. context.pushStringPart(elementsToAdd[j]);
  31331. }
  31332. if (context.withSlotScopeId) {
  31333. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  31334. }
  31335. context.pushStringPart(`>`);
  31336. const rawChildren = rawChildrenMap.get(node);
  31337. if (rawChildren) {
  31338. context.pushStringPart(rawChildren);
  31339. } else if (node.children.length) {
  31340. processChildren(node, context);
  31341. }
  31342. if (!isVoidTag(node.tag)) {
  31343. context.pushStringPart(`</${node.tag}>`);
  31344. }
  31345. }
  31346. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  31347. function ssrTransformTransitionGroup(node, context) {
  31348. return () => {
  31349. const tag = findProp(node, "tag");
  31350. if (tag) {
  31351. const otherProps = node.props.filter((p) => p !== tag);
  31352. const { props, directives } = buildProps(
  31353. node,
  31354. context,
  31355. otherProps,
  31356. true,
  31357. false,
  31358. true
  31359. );
  31360. let propsExp = null;
  31361. if (props || directives.length) {
  31362. propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  31363. buildSSRProps(props, directives, context)
  31364. ]);
  31365. }
  31366. wipMap$2.set(node, {
  31367. tag,
  31368. propsExp,
  31369. scopeId: context.scopeId || null
  31370. });
  31371. }
  31372. };
  31373. }
  31374. function ssrProcessTransitionGroup(node, context) {
  31375. const entry = wipMap$2.get(node);
  31376. if (entry) {
  31377. const { tag, propsExp, scopeId } = entry;
  31378. if (tag.type === 7) {
  31379. context.pushStringPart(`<`);
  31380. context.pushStringPart(tag.exp);
  31381. if (propsExp) {
  31382. context.pushStringPart(propsExp);
  31383. }
  31384. if (scopeId) {
  31385. context.pushStringPart(` ${scopeId}`);
  31386. }
  31387. context.pushStringPart(`>`);
  31388. processChildren(
  31389. node,
  31390. context,
  31391. false,
  31392. /**
  31393. * TransitionGroup has the special runtime behavior of flattening and
  31394. * concatenating all children into a single fragment (in order for them to
  31395. * be patched using the same key map) so we need to account for that here
  31396. * by disabling nested fragment wrappers from being generated.
  31397. */
  31398. true,
  31399. /**
  31400. * TransitionGroup filters out comment children at runtime and thus
  31401. * doesn't expect comments to be present during hydration. We need to
  31402. * account for that by disabling the empty comment that is otherwise
  31403. * rendered for a falsy v-if that has no v-else specified. (#6715)
  31404. */
  31405. true
  31406. );
  31407. context.pushStringPart(`</`);
  31408. context.pushStringPart(tag.exp);
  31409. context.pushStringPart(`>`);
  31410. } else {
  31411. context.pushStringPart(`<${tag.value.content}`);
  31412. if (propsExp) {
  31413. context.pushStringPart(propsExp);
  31414. }
  31415. if (scopeId) {
  31416. context.pushStringPart(` ${scopeId}`);
  31417. }
  31418. context.pushStringPart(`>`);
  31419. processChildren(node, context, false, true, true);
  31420. context.pushStringPart(`</${tag.value.content}>`);
  31421. }
  31422. } else {
  31423. processChildren(node, context, true, true, true);
  31424. }
  31425. }
  31426. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  31427. function ssrTransformTransition(node, context) {
  31428. return () => {
  31429. const appear = findProp(node, "appear", false, true);
  31430. wipMap$1.set(node, !!appear);
  31431. };
  31432. }
  31433. function ssrProcessTransition(node, context) {
  31434. node.children = node.children.filter((c) => c.type !== 3);
  31435. const appear = wipMap$1.get(node);
  31436. if (appear) {
  31437. context.pushStringPart(`<template>`);
  31438. processChildren(node, context, false, true);
  31439. context.pushStringPart(`</template>`);
  31440. } else {
  31441. processChildren(node, context, false, true);
  31442. }
  31443. }
  31444. var __defProp$8 = Object.defineProperty;
  31445. var __defProps$7 = Object.defineProperties;
  31446. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  31447. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  31448. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  31449. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  31450. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31451. var __spreadValues$8 = (a, b) => {
  31452. for (var prop in b || (b = {}))
  31453. if (__hasOwnProp$8.call(b, prop))
  31454. __defNormalProp$8(a, prop, b[prop]);
  31455. if (__getOwnPropSymbols$8)
  31456. for (var prop of __getOwnPropSymbols$8(b)) {
  31457. if (__propIsEnum$8.call(b, prop))
  31458. __defNormalProp$8(a, prop, b[prop]);
  31459. }
  31460. return a;
  31461. };
  31462. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  31463. const wipMap = /* @__PURE__ */ new WeakMap();
  31464. const WIP_SLOT = Symbol();
  31465. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  31466. const ssrTransformComponent = (node, context) => {
  31467. if (node.type !== 1 || node.tagType !== 1) {
  31468. return;
  31469. }
  31470. const component = resolveComponentType(
  31471. node,
  31472. context,
  31473. true
  31474. /* ssr */
  31475. );
  31476. const isDynamicComponent = isObject$2(component) && component.callee === RESOLVE_DYNAMIC_COMPONENT;
  31477. componentTypeMap.set(node, component);
  31478. if (isSymbol$1(component)) {
  31479. if (component === SUSPENSE) {
  31480. return ssrTransformSuspense(node, context);
  31481. } else if (component === TRANSITION_GROUP) {
  31482. return ssrTransformTransitionGroup(node, context);
  31483. } else if (component === TRANSITION) {
  31484. return ssrTransformTransition(node);
  31485. }
  31486. return;
  31487. }
  31488. const vnodeBranches = [];
  31489. const clonedNode = clone(node);
  31490. return function ssrPostTransformComponent() {
  31491. if (clonedNode.children.length) {
  31492. buildSlots(clonedNode, context, (props, vFor, children) => {
  31493. vnodeBranches.push(
  31494. createVNodeSlotBranch(props, vFor, children, context)
  31495. );
  31496. return createFunctionExpression(void 0);
  31497. });
  31498. }
  31499. let propsExp = `null`;
  31500. if (node.props.length) {
  31501. const { props, directives } = buildProps(
  31502. node,
  31503. context,
  31504. void 0,
  31505. true,
  31506. isDynamicComponent
  31507. );
  31508. if (props || directives.length) {
  31509. propsExp = buildSSRProps(props, directives, context);
  31510. }
  31511. }
  31512. const wipEntries = [];
  31513. wipMap.set(node, wipEntries);
  31514. const buildSSRSlotFn = (props, _vForExp, children, loc) => {
  31515. const param0 = props && stringifyExpression(props) || `_`;
  31516. const fn = createFunctionExpression(
  31517. [param0, `_push`, `_parent`, `_scopeId`],
  31518. void 0,
  31519. // no return, assign body later
  31520. true,
  31521. // newline
  31522. true,
  31523. // isSlot
  31524. loc
  31525. );
  31526. wipEntries.push({
  31527. type: WIP_SLOT,
  31528. fn,
  31529. children,
  31530. // also collect the corresponding vnode branch built earlier
  31531. vnodeBranch: vnodeBranches[wipEntries.length]
  31532. });
  31533. return fn;
  31534. };
  31535. const slots = node.children.length ? buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  31536. if (typeof component !== "string") {
  31537. node.ssrCodegenNode = createCallExpression(
  31538. context.helper(SSR_RENDER_VNODE),
  31539. [
  31540. `_push`,
  31541. createCallExpression(context.helper(CREATE_VNODE), [
  31542. component,
  31543. propsExp,
  31544. slots
  31545. ]),
  31546. `_parent`
  31547. ]
  31548. );
  31549. } else {
  31550. node.ssrCodegenNode = createCallExpression(
  31551. context.helper(SSR_RENDER_COMPONENT),
  31552. [component, propsExp, slots, `_parent`]
  31553. );
  31554. }
  31555. };
  31556. };
  31557. function ssrProcessComponent(node, context, parent) {
  31558. const component = componentTypeMap.get(node);
  31559. if (!node.ssrCodegenNode) {
  31560. if (component === TELEPORT) {
  31561. return ssrProcessTeleport(node, context);
  31562. } else if (component === SUSPENSE) {
  31563. return ssrProcessSuspense(node, context);
  31564. } else if (component === TRANSITION_GROUP) {
  31565. return ssrProcessTransitionGroup(node, context);
  31566. } else {
  31567. if (parent.type === WIP_SLOT) {
  31568. context.pushStringPart(``);
  31569. }
  31570. if (component === TRANSITION) {
  31571. return ssrProcessTransition(node, context);
  31572. }
  31573. processChildren(node, context);
  31574. }
  31575. } else {
  31576. const wipEntries = wipMap.get(node) || [];
  31577. for (let i = 0; i < wipEntries.length; i++) {
  31578. const { fn, vnodeBranch } = wipEntries[i];
  31579. fn.body = createIfStatement(
  31580. createSimpleExpression(`_push`, false),
  31581. processChildrenAsStatement(
  31582. wipEntries[i],
  31583. context,
  31584. false,
  31585. true
  31586. ),
  31587. vnodeBranch
  31588. );
  31589. }
  31590. if (context.withSlotScopeId) {
  31591. node.ssrCodegenNode.arguments.push(`_scopeId`);
  31592. }
  31593. if (typeof component === "string") {
  31594. context.pushStatement(
  31595. createCallExpression(`_push`, [node.ssrCodegenNode])
  31596. );
  31597. } else {
  31598. context.pushStatement(node.ssrCodegenNode);
  31599. }
  31600. }
  31601. }
  31602. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  31603. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  31604. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  31605. const vnodeDirectiveTransforms = __spreadValues$8(__spreadValues$8({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  31606. function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
  31607. const rawOptions = rawOptionsMap.get(parentContext.root);
  31608. const subOptions = __spreadProps$7(__spreadValues$8({}, rawOptions), {
  31609. // overwrite with vnode-based transforms
  31610. nodeTransforms: [
  31611. ...vnodeNodeTransforms,
  31612. ...rawOptions.nodeTransforms || []
  31613. ],
  31614. directiveTransforms: __spreadValues$8(__spreadValues$8({}, vnodeDirectiveTransforms), rawOptions.directiveTransforms || {})
  31615. });
  31616. const wrapperProps = [];
  31617. if (slotProps) {
  31618. wrapperProps.push({
  31619. type: 7,
  31620. name: "slot",
  31621. exp: slotProps,
  31622. arg: void 0,
  31623. modifiers: [],
  31624. loc: locStub
  31625. });
  31626. }
  31627. if (vFor) {
  31628. wrapperProps.push(extend({}, vFor));
  31629. }
  31630. const wrapperNode = {
  31631. type: 1,
  31632. ns: 0,
  31633. tag: "template",
  31634. tagType: 3,
  31635. props: wrapperProps,
  31636. children,
  31637. loc: locStub,
  31638. codegenNode: void 0
  31639. };
  31640. subTransform(wrapperNode, subOptions, parentContext);
  31641. return createReturnStatement(children);
  31642. }
  31643. function subTransform(node, options, parentContext) {
  31644. const childRoot = createRoot([node]);
  31645. const childContext = createTransformContext(childRoot, options);
  31646. childContext.ssr = false;
  31647. childContext.scopes = __spreadValues$8({}, parentContext.scopes);
  31648. childContext.identifiers = __spreadValues$8({}, parentContext.identifiers);
  31649. childContext.imports = parentContext.imports;
  31650. traverseNode(childRoot, childContext);
  31651. ["helpers", "components", "directives"].forEach((key) => {
  31652. childContext[key].forEach((value, helperKey) => {
  31653. if (key === "helpers") {
  31654. const parentCount = parentContext.helpers.get(helperKey);
  31655. if (parentCount === void 0) {
  31656. parentContext.helpers.set(helperKey, value);
  31657. } else {
  31658. parentContext.helpers.set(helperKey, value + parentCount);
  31659. }
  31660. } else {
  31661. parentContext[key].add(value);
  31662. }
  31663. });
  31664. });
  31665. }
  31666. function clone(v) {
  31667. if (isArray$3(v)) {
  31668. return v.map(clone);
  31669. } else if (isPlainObject(v)) {
  31670. const res = {};
  31671. for (const key in v) {
  31672. res[key] = clone(v[key]);
  31673. }
  31674. return res;
  31675. } else {
  31676. return v;
  31677. }
  31678. }
  31679. function ssrCodegenTransform(ast, options) {
  31680. const context = createSSRTransformContext(ast, options);
  31681. if (options.ssrCssVars) {
  31682. const cssContext = createTransformContext(createRoot([]), options);
  31683. const varsExp = processExpression(
  31684. createSimpleExpression(options.ssrCssVars, false),
  31685. cssContext
  31686. );
  31687. context.body.push(
  31688. createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  31689. );
  31690. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  31691. ast.helpers.add(helper);
  31692. });
  31693. }
  31694. const isFragment = ast.children.length > 1 && ast.children.some((c) => !isText$1(c));
  31695. processChildren(ast, context, isFragment);
  31696. ast.codegenNode = createBlockStatement(context.body);
  31697. ast.ssrHelpers = Array.from(
  31698. /* @__PURE__ */ new Set([
  31699. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  31700. ...context.helpers
  31701. ])
  31702. );
  31703. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  31704. }
  31705. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  31706. const body = [];
  31707. let currentString = null;
  31708. return {
  31709. root,
  31710. options,
  31711. body,
  31712. helpers,
  31713. withSlotScopeId,
  31714. onError: options.onError || ((e) => {
  31715. throw e;
  31716. }),
  31717. helper(name) {
  31718. helpers.add(name);
  31719. return name;
  31720. },
  31721. pushStringPart(part) {
  31722. if (!currentString) {
  31723. const currentCall = createCallExpression(`_push`);
  31724. body.push(currentCall);
  31725. currentString = createTemplateLiteral([]);
  31726. currentCall.arguments.push(currentString);
  31727. }
  31728. const bufferedElements = currentString.elements;
  31729. const lastItem = bufferedElements[bufferedElements.length - 1];
  31730. if (isString$1(part) && isString$1(lastItem)) {
  31731. bufferedElements[bufferedElements.length - 1] += part;
  31732. } else {
  31733. bufferedElements.push(part);
  31734. }
  31735. },
  31736. pushStatement(statement) {
  31737. currentString = null;
  31738. body.push(statement);
  31739. }
  31740. };
  31741. }
  31742. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  31743. return createSSRTransformContext(
  31744. parent.root,
  31745. parent.options,
  31746. parent.helpers,
  31747. withSlotScopeId
  31748. );
  31749. }
  31750. function processChildren(parent, context, asFragment = false, disableNestedFragments = false, disableComment = false) {
  31751. if (asFragment) {
  31752. context.pushStringPart(`<!--[-->`);
  31753. }
  31754. const { children } = parent;
  31755. for (let i = 0; i < children.length; i++) {
  31756. const child = children[i];
  31757. switch (child.type) {
  31758. case 1:
  31759. switch (child.tagType) {
  31760. case 0:
  31761. ssrProcessElement(child, context);
  31762. break;
  31763. case 1:
  31764. ssrProcessComponent(child, context, parent);
  31765. break;
  31766. case 2:
  31767. ssrProcessSlotOutlet(child, context);
  31768. break;
  31769. case 3:
  31770. break;
  31771. default:
  31772. context.onError(
  31773. createSSRCompilerError(
  31774. 67,
  31775. child.loc
  31776. )
  31777. );
  31778. const exhaustiveCheck2 = child;
  31779. return exhaustiveCheck2;
  31780. }
  31781. break;
  31782. case 2:
  31783. context.pushStringPart(escapeHtml(child.content));
  31784. break;
  31785. case 3:
  31786. if (!disableComment) {
  31787. context.pushStringPart(`<!--${child.content}-->`);
  31788. }
  31789. break;
  31790. case 5:
  31791. context.pushStringPart(
  31792. createCallExpression(context.helper(SSR_INTERPOLATE), [
  31793. child.content
  31794. ])
  31795. );
  31796. break;
  31797. case 9:
  31798. ssrProcessIf(child, context, disableNestedFragments, disableComment);
  31799. break;
  31800. case 11:
  31801. ssrProcessFor(child, context, disableNestedFragments);
  31802. break;
  31803. case 10:
  31804. break;
  31805. case 12:
  31806. case 8:
  31807. break;
  31808. default:
  31809. context.onError(
  31810. createSSRCompilerError(
  31811. 67,
  31812. child.loc
  31813. )
  31814. );
  31815. const exhaustiveCheck = child;
  31816. return exhaustiveCheck;
  31817. }
  31818. }
  31819. if (asFragment) {
  31820. context.pushStringPart(`<!--]-->`);
  31821. }
  31822. }
  31823. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  31824. const childContext = createChildContext(parentContext, withSlotScopeId);
  31825. processChildren(parent, childContext, asFragment);
  31826. return createBlockStatement(childContext.body);
  31827. }
  31828. const ssrTransformModel = (dir, node, context) => {
  31829. const model = dir.exp;
  31830. function checkDuplicatedValue() {
  31831. const value = findProp(node, "value");
  31832. if (value) {
  31833. context.onError(
  31834. createDOMCompilerError(
  31835. 60,
  31836. value.loc
  31837. )
  31838. );
  31839. }
  31840. }
  31841. const processSelectChildren = (children) => {
  31842. children.forEach((child) => {
  31843. if (child.type === 1) {
  31844. processOption(child);
  31845. } else if (child.type === 11) {
  31846. processSelectChildren(child.children);
  31847. } else if (child.type === 9) {
  31848. child.branches.forEach((b) => processSelectChildren(b.children));
  31849. }
  31850. });
  31851. };
  31852. function processOption(plainNode) {
  31853. if (plainNode.tag === "option") {
  31854. if (plainNode.props.findIndex((p) => p.name === "selected") === -1) {
  31855. const value = findValueBinding(plainNode);
  31856. plainNode.ssrCodegenNode.elements.push(
  31857. createConditionalExpression(
  31858. createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [
  31859. createConditionalExpression(
  31860. createCallExpression(`Array.isArray`, [model]),
  31861. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  31862. model,
  31863. value
  31864. ]),
  31865. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31866. model,
  31867. value
  31868. ])
  31869. )
  31870. ]),
  31871. createSimpleExpression(" selected", true),
  31872. createSimpleExpression("", true),
  31873. false
  31874. )
  31875. );
  31876. }
  31877. } else if (plainNode.tag === "optgroup") {
  31878. processSelectChildren(plainNode.children);
  31879. }
  31880. }
  31881. if (node.tagType === 0) {
  31882. const res = { props: [] };
  31883. const defaultProps = [
  31884. // default value binding for text type inputs
  31885. createObjectProperty(`value`, model)
  31886. ];
  31887. if (node.tag === "input") {
  31888. const type = findProp(node, "type");
  31889. if (type) {
  31890. const value = findValueBinding(node);
  31891. if (type.type === 7) {
  31892. res.ssrTagParts = [
  31893. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  31894. type.exp,
  31895. model,
  31896. value
  31897. ])
  31898. ];
  31899. } else if (type.value) {
  31900. switch (type.value.content) {
  31901. case "radio":
  31902. res.props = [
  31903. createObjectProperty(
  31904. `checked`,
  31905. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31906. model,
  31907. value
  31908. ])
  31909. )
  31910. ];
  31911. break;
  31912. case "checkbox":
  31913. const trueValueBinding = findProp(node, "true-value");
  31914. if (trueValueBinding) {
  31915. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  31916. res.props = [
  31917. createObjectProperty(
  31918. `checked`,
  31919. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31920. model,
  31921. trueValue
  31922. ])
  31923. )
  31924. ];
  31925. } else {
  31926. res.props = [
  31927. createObjectProperty(
  31928. `checked`,
  31929. createConditionalExpression(
  31930. createCallExpression(`Array.isArray`, [model]),
  31931. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  31932. model,
  31933. value
  31934. ]),
  31935. model
  31936. )
  31937. )
  31938. ];
  31939. }
  31940. break;
  31941. case "file":
  31942. context.onError(
  31943. createDOMCompilerError(
  31944. 59,
  31945. dir.loc
  31946. )
  31947. );
  31948. break;
  31949. default:
  31950. checkDuplicatedValue();
  31951. res.props = defaultProps;
  31952. break;
  31953. }
  31954. }
  31955. } else if (hasDynamicKeyVBind(node)) ; else {
  31956. checkDuplicatedValue();
  31957. res.props = defaultProps;
  31958. }
  31959. } else if (node.tag === "textarea") {
  31960. checkDuplicatedValue();
  31961. node.children = [createInterpolation(model, model.loc)];
  31962. } else if (node.tag === "select") {
  31963. processSelectChildren(node.children);
  31964. } else {
  31965. context.onError(
  31966. createDOMCompilerError(
  31967. 57,
  31968. dir.loc
  31969. )
  31970. );
  31971. }
  31972. return res;
  31973. } else {
  31974. return transformModel$1(dir, node, context);
  31975. }
  31976. };
  31977. function findValueBinding(node) {
  31978. const valueBinding = findProp(node, "value");
  31979. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : createSimpleExpression(valueBinding.value.content, true) : createSimpleExpression(`null`, false);
  31980. }
  31981. const ssrTransformShow = (dir, node, context) => {
  31982. if (!dir.exp) {
  31983. context.onError(
  31984. createDOMCompilerError(61)
  31985. );
  31986. }
  31987. return {
  31988. props: [
  31989. createObjectProperty(
  31990. `style`,
  31991. createConditionalExpression(
  31992. dir.exp,
  31993. createSimpleExpression(`null`, false),
  31994. createObjectExpression([
  31995. createObjectProperty(
  31996. `display`,
  31997. createSimpleExpression(`none`, true)
  31998. )
  31999. ]),
  32000. false
  32001. )
  32002. )
  32003. ]
  32004. };
  32005. };
  32006. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  32007. const hasSingleChild = (node) => filterChild(node).length === 1;
  32008. const ssrInjectFallthroughAttrs = (node, context) => {
  32009. if (node.type === 0) {
  32010. context.identifiers._attrs = 1;
  32011. }
  32012. if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
  32013. const rootChildren = filterChild(context.root);
  32014. if (rootChildren.length === 1 && rootChildren[0] === node) {
  32015. if (hasSingleChild(node)) {
  32016. injectFallthroughAttrs(node.children[0]);
  32017. }
  32018. return;
  32019. }
  32020. }
  32021. const parent = context.parent;
  32022. if (!parent || parent.type !== 0) {
  32023. return;
  32024. }
  32025. if (node.type === 10 && hasSingleChild(node)) {
  32026. let hasEncounteredIf = false;
  32027. for (const c of filterChild(parent)) {
  32028. if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
  32029. if (hasEncounteredIf) return;
  32030. hasEncounteredIf = true;
  32031. } else if (
  32032. // node before v-if
  32033. !hasEncounteredIf || // non else nodes
  32034. !(c.type === 1 && findDir(c, /else/, true))
  32035. ) {
  32036. return;
  32037. }
  32038. }
  32039. injectFallthroughAttrs(node.children[0]);
  32040. } else if (hasSingleChild(parent)) {
  32041. injectFallthroughAttrs(node);
  32042. }
  32043. };
  32044. function injectFallthroughAttrs(node) {
  32045. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  32046. node.props.push({
  32047. type: 7,
  32048. name: "bind",
  32049. arg: void 0,
  32050. exp: createSimpleExpression(`_attrs`, false),
  32051. modifiers: [],
  32052. loc: locStub
  32053. });
  32054. }
  32055. }
  32056. const ssrInjectCssVars = (node, context) => {
  32057. if (!context.ssrCssVars) {
  32058. return;
  32059. }
  32060. if (node.type === 0) {
  32061. context.identifiers._cssVars = 1;
  32062. }
  32063. const parent = context.parent;
  32064. if (!parent || parent.type !== 0) {
  32065. return;
  32066. }
  32067. if (node.type === 10) {
  32068. for (const child of node.children) {
  32069. injectCssVars(child);
  32070. }
  32071. } else {
  32072. injectCssVars(node);
  32073. }
  32074. };
  32075. function injectCssVars(node) {
  32076. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  32077. if (node.tag === "suspense" || node.tag === "Suspense") {
  32078. for (const child of node.children) {
  32079. if (child.type === 1 && child.tagType === 3) {
  32080. child.children.forEach(injectCssVars);
  32081. } else {
  32082. injectCssVars(child);
  32083. }
  32084. }
  32085. } else {
  32086. node.props.push({
  32087. type: 7,
  32088. name: "bind",
  32089. arg: void 0,
  32090. exp: createSimpleExpression(`_cssVars`, false),
  32091. modifiers: [],
  32092. loc: locStub
  32093. });
  32094. }
  32095. }
  32096. }
  32097. var __defProp$7 = Object.defineProperty;
  32098. var __defProps$6 = Object.defineProperties;
  32099. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  32100. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  32101. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  32102. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  32103. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  32104. var __spreadValues$7 = (a, b) => {
  32105. for (var prop in b || (b = {}))
  32106. if (__hasOwnProp$7.call(b, prop))
  32107. __defNormalProp$7(a, prop, b[prop]);
  32108. if (__getOwnPropSymbols$7)
  32109. for (var prop of __getOwnPropSymbols$7(b)) {
  32110. if (__propIsEnum$7.call(b, prop))
  32111. __defNormalProp$7(a, prop, b[prop]);
  32112. }
  32113. return a;
  32114. };
  32115. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  32116. function compile(source, options = {}) {
  32117. options = __spreadProps$6(__spreadValues$7(__spreadValues$7({}, options), parserOptions), {
  32118. ssr: true,
  32119. inSSR: true,
  32120. scopeId: options.mode === "function" ? null : options.scopeId,
  32121. // always prefix since compiler-ssr doesn't have size concern
  32122. prefixIdentifiers: true,
  32123. // disable optimizations that are unnecessary for ssr
  32124. cacheHandlers: false,
  32125. hoistStatic: false
  32126. });
  32127. const ast = typeof source === "string" ? baseParse(source, options) : source;
  32128. rawOptionsMap.set(ast, options);
  32129. transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
  32130. hoistStatic: false,
  32131. nodeTransforms: [
  32132. transformVBindShorthand,
  32133. ssrTransformIf,
  32134. ssrTransformFor,
  32135. trackVForSlotScopes,
  32136. transformExpression,
  32137. ssrTransformSlotOutlet,
  32138. ssrInjectFallthroughAttrs,
  32139. ssrInjectCssVars,
  32140. ssrTransformElement,
  32141. ssrTransformComponent,
  32142. trackSlotScopes,
  32143. transformStyle,
  32144. ...options.nodeTransforms || []
  32145. // user transforms
  32146. ],
  32147. directiveTransforms: __spreadValues$7({
  32148. // reusing core v-bind
  32149. bind: transformBind,
  32150. on: transformOn$1,
  32151. // model and show have dedicated SSR handling
  32152. model: ssrTransformModel,
  32153. show: ssrTransformShow,
  32154. // the following are ignored during SSR
  32155. // on: noopDirectiveTransform,
  32156. cloak: noopDirectiveTransform,
  32157. once: noopDirectiveTransform,
  32158. memo: noopDirectiveTransform
  32159. }, options.directiveTransforms || {})
  32160. }));
  32161. ssrCodegenTransform(ast, options);
  32162. return generate(ast, options);
  32163. }
  32164. var CompilerSSR = /*#__PURE__*/Object.freeze({
  32165. __proto__: null,
  32166. compile: compile
  32167. });
  32168. var _polyfillNode_fs = {};
  32169. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  32170. __proto__: null,
  32171. default: _polyfillNode_fs
  32172. });
  32173. var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  32174. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  32175. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  32176. const hasWarned = {};
  32177. function warnOnce$1(msg) {
  32178. const isNodeProd = typeof process !== "undefined" && process.env.NODE_ENV === "production";
  32179. if (!isNodeProd && true && !hasWarned[msg]) {
  32180. hasWarned[msg] = true;
  32181. warn(msg);
  32182. }
  32183. }
  32184. function warn(msg) {
  32185. console.warn(
  32186. `\x1B[1m\x1B[33m[@vue/compiler-sfc]\x1B[0m\x1B[33m ${msg}\x1B[0m
  32187. `
  32188. );
  32189. }
  32190. var __defProp$6 = Object.defineProperty;
  32191. var __defProps$5 = Object.defineProperties;
  32192. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  32193. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  32194. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  32195. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  32196. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  32197. var __spreadValues$6 = (a, b) => {
  32198. for (var prop in b || (b = {}))
  32199. if (__hasOwnProp$6.call(b, prop))
  32200. __defNormalProp$6(a, prop, b[prop]);
  32201. if (__getOwnPropSymbols$6)
  32202. for (var prop of __getOwnPropSymbols$6(b)) {
  32203. if (__propIsEnum$6.call(b, prop))
  32204. __defNormalProp$6(a, prop, b[prop]);
  32205. }
  32206. return a;
  32207. };
  32208. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  32209. function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
  32210. let res = "";
  32211. let err = null;
  32212. preprocessor.render(
  32213. source,
  32214. __spreadValues$6({ filename }, preprocessOptions),
  32215. (_err, _res) => {
  32216. if (_err) err = _err;
  32217. res = _res;
  32218. }
  32219. );
  32220. if (err) throw err;
  32221. return res;
  32222. }
  32223. function compileTemplate(options) {
  32224. const { preprocessLang, preprocessCustomRequire } = options;
  32225. if (preprocessLang && !preprocessCustomRequire) {
  32226. throw new Error(
  32227. `[@vue/compiler-sfc] Template preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor in the shape of { render(): string }.`
  32228. );
  32229. }
  32230. const preprocessor = preprocessLang ? preprocessCustomRequire ? preprocessCustomRequire(preprocessLang) : void 0 : false;
  32231. if (preprocessor) {
  32232. try {
  32233. return doCompileTemplate(__spreadProps$5(__spreadValues$6({}, options), {
  32234. source: preprocess$1(options, preprocessor),
  32235. ast: void 0
  32236. // invalidate AST if template goes through preprocessor
  32237. }));
  32238. } catch (e) {
  32239. return {
  32240. code: `export default function render() {}`,
  32241. source: options.source,
  32242. tips: [],
  32243. errors: [e]
  32244. };
  32245. }
  32246. } else if (preprocessLang) {
  32247. return {
  32248. code: `export default function render() {}`,
  32249. source: options.source,
  32250. tips: [
  32251. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  32252. ],
  32253. errors: [
  32254. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  32255. ]
  32256. };
  32257. } else {
  32258. return doCompileTemplate(options);
  32259. }
  32260. }
  32261. function doCompileTemplate({
  32262. filename,
  32263. id,
  32264. scoped,
  32265. slotted,
  32266. inMap,
  32267. source,
  32268. ast: inAST,
  32269. ssr = false,
  32270. ssrCssVars,
  32271. isProd = false,
  32272. compiler,
  32273. compilerOptions = {},
  32274. transformAssetUrls
  32275. }) {
  32276. const errors = [];
  32277. const warnings = [];
  32278. let nodeTransforms = [];
  32279. if (isObject$2(transformAssetUrls)) {
  32280. const assetOptions = normalizeOptions(transformAssetUrls);
  32281. nodeTransforms = [
  32282. createAssetUrlTransformWithOptions(assetOptions),
  32283. createSrcsetTransformWithOptions(assetOptions)
  32284. ];
  32285. } else if (transformAssetUrls !== false) {
  32286. nodeTransforms = [transformAssetUrl, transformSrcset];
  32287. }
  32288. if (ssr && !ssrCssVars) {
  32289. warnOnce$1(
  32290. `compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.`
  32291. );
  32292. }
  32293. if (!id) {
  32294. warnOnce$1(`compileTemplate now requires the \`id\` option.`);
  32295. id = "";
  32296. }
  32297. const shortId = id.replace(/^data-v-/, "");
  32298. const longId = `data-v-${shortId}`;
  32299. const defaultCompiler = ssr ? CompilerSSR : CompilerDOM;
  32300. compiler = compiler || defaultCompiler;
  32301. if (compiler !== defaultCompiler) {
  32302. inAST = void 0;
  32303. }
  32304. if (inAST == null ? void 0 : inAST.transformed) {
  32305. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
  32306. prefixIdentifiers: true
  32307. }, compilerOptions), {
  32308. parseMode: "sfc",
  32309. onError: (e) => errors.push(e)
  32310. }));
  32311. const template = newAST.children.find(
  32312. (node) => node.type === 1 && node.tag === "template"
  32313. );
  32314. inAST = createRoot(template.children, inAST.source);
  32315. }
  32316. let { code, ast, preamble, map } = compiler.compile(inAST || source, __spreadProps$5(__spreadValues$6({
  32317. mode: "module",
  32318. prefixIdentifiers: true,
  32319. hoistStatic: true,
  32320. cacheHandlers: true,
  32321. ssrCssVars: ssr && ssrCssVars && ssrCssVars.length ? genCssVarsFromList(ssrCssVars, shortId, isProd, true) : "",
  32322. scopeId: scoped ? longId : void 0,
  32323. slotted,
  32324. sourceMap: true
  32325. }, compilerOptions), {
  32326. hmr: !isProd,
  32327. nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
  32328. filename,
  32329. onError: (e) => errors.push(e),
  32330. onWarn: (w) => warnings.push(w)
  32331. }));
  32332. if (inMap && !inAST) {
  32333. if (map) {
  32334. map = mapLines(inMap, map);
  32335. }
  32336. if (errors.length) {
  32337. patchErrors(errors, source, inMap);
  32338. }
  32339. }
  32340. const tips = warnings.map((w) => {
  32341. let msg = w.message;
  32342. if (w.loc) {
  32343. msg += `
  32344. ${generateCodeFrame(
  32345. (inAST == null ? void 0 : inAST.source) || source,
  32346. w.loc.start.offset,
  32347. w.loc.end.offset
  32348. )}`;
  32349. }
  32350. return msg;
  32351. });
  32352. return { code, ast, preamble, source, errors, tips, map };
  32353. }
  32354. function mapLines(oldMap, newMap) {
  32355. if (!oldMap) return newMap;
  32356. if (!newMap) return oldMap;
  32357. const oldMapConsumer = new sourceMapExports.SourceMapConsumer(oldMap);
  32358. const newMapConsumer = new sourceMapExports.SourceMapConsumer(newMap);
  32359. const mergedMapGenerator = new sourceMapExports.SourceMapGenerator();
  32360. newMapConsumer.eachMapping((m) => {
  32361. if (m.originalLine == null) {
  32362. return;
  32363. }
  32364. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  32365. line: m.originalLine,
  32366. column: m.originalColumn
  32367. });
  32368. if (origPosInOldMap.source == null) {
  32369. return;
  32370. }
  32371. mergedMapGenerator.addMapping({
  32372. generated: {
  32373. line: m.generatedLine,
  32374. column: m.generatedColumn
  32375. },
  32376. original: {
  32377. line: origPosInOldMap.line,
  32378. // map line
  32379. // use current column, since the oldMap produced by @vue/compiler-sfc
  32380. // does not
  32381. column: m.originalColumn
  32382. },
  32383. source: origPosInOldMap.source,
  32384. name: origPosInOldMap.name
  32385. });
  32386. });
  32387. const generator = mergedMapGenerator;
  32388. oldMapConsumer.sources.forEach((sourceFile) => {
  32389. generator._sources.add(sourceFile);
  32390. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  32391. if (sourceContent != null) {
  32392. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  32393. }
  32394. });
  32395. generator._sourceRoot = oldMap.sourceRoot;
  32396. generator._file = oldMap.file;
  32397. return generator.toJSON();
  32398. }
  32399. function patchErrors(errors, source, inMap) {
  32400. const originalSource = inMap.sourcesContent[0];
  32401. const offset = originalSource.indexOf(source);
  32402. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  32403. errors.forEach((err) => {
  32404. if (err.loc) {
  32405. err.loc.start.line += lineOffset;
  32406. err.loc.start.offset += offset;
  32407. if (err.loc.end !== err.loc.start) {
  32408. err.loc.end.line += lineOffset;
  32409. err.loc.end.offset += offset;
  32410. }
  32411. }
  32412. });
  32413. }
  32414. var picocolors = {exports: {}};
  32415. var hasRequiredPicocolors;
  32416. function requirePicocolors () {
  32417. if (hasRequiredPicocolors) return picocolors.exports;
  32418. hasRequiredPicocolors = 1;
  32419. let p = browser$1 || {}, argv = p.argv || [], env = p.env || {};
  32420. let isColorSupported =
  32421. !(!!env.NO_COLOR || argv.includes("--no-color")) &&
  32422. (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
  32423. let formatter = (open, close, replace = open) =>
  32424. input => {
  32425. let string = "" + input, index = string.indexOf(close, open.length);
  32426. return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
  32427. };
  32428. let replaceClose = (string, close, replace, index) => {
  32429. let result = "", cursor = 0;
  32430. do {
  32431. result += string.substring(cursor, index) + replace;
  32432. cursor = index + close.length;
  32433. index = string.indexOf(close, cursor);
  32434. } while (~index)
  32435. return result + string.substring(cursor)
  32436. };
  32437. let createColors = (enabled = isColorSupported) => {
  32438. let f = enabled ? formatter : () => String;
  32439. return {
  32440. isColorSupported: enabled,
  32441. reset: f("\x1b[0m", "\x1b[0m"),
  32442. bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
  32443. dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
  32444. italic: f("\x1b[3m", "\x1b[23m"),
  32445. underline: f("\x1b[4m", "\x1b[24m"),
  32446. inverse: f("\x1b[7m", "\x1b[27m"),
  32447. hidden: f("\x1b[8m", "\x1b[28m"),
  32448. strikethrough: f("\x1b[9m", "\x1b[29m"),
  32449. black: f("\x1b[30m", "\x1b[39m"),
  32450. red: f("\x1b[31m", "\x1b[39m"),
  32451. green: f("\x1b[32m", "\x1b[39m"),
  32452. yellow: f("\x1b[33m", "\x1b[39m"),
  32453. blue: f("\x1b[34m", "\x1b[39m"),
  32454. magenta: f("\x1b[35m", "\x1b[39m"),
  32455. cyan: f("\x1b[36m", "\x1b[39m"),
  32456. white: f("\x1b[37m", "\x1b[39m"),
  32457. gray: f("\x1b[90m", "\x1b[39m"),
  32458. bgBlack: f("\x1b[40m", "\x1b[49m"),
  32459. bgRed: f("\x1b[41m", "\x1b[49m"),
  32460. bgGreen: f("\x1b[42m", "\x1b[49m"),
  32461. bgYellow: f("\x1b[43m", "\x1b[49m"),
  32462. bgBlue: f("\x1b[44m", "\x1b[49m"),
  32463. bgMagenta: f("\x1b[45m", "\x1b[49m"),
  32464. bgCyan: f("\x1b[46m", "\x1b[49m"),
  32465. bgWhite: f("\x1b[47m", "\x1b[49m"),
  32466. blackBright: f("\x1b[90m", "\x1b[39m"),
  32467. redBright: f("\x1b[91m", "\x1b[39m"),
  32468. greenBright: f("\x1b[92m", "\x1b[39m"),
  32469. yellowBright: f("\x1b[93m", "\x1b[39m"),
  32470. blueBright: f("\x1b[94m", "\x1b[39m"),
  32471. magentaBright: f("\x1b[95m", "\x1b[39m"),
  32472. cyanBright: f("\x1b[96m", "\x1b[39m"),
  32473. whiteBright: f("\x1b[97m", "\x1b[39m"),
  32474. bgBlackBright: f("\x1b[100m", "\x1b[49m"),
  32475. bgRedBright: f("\x1b[101m", "\x1b[49m"),
  32476. bgGreenBright: f("\x1b[102m", "\x1b[49m"),
  32477. bgYellowBright: f("\x1b[103m", "\x1b[49m"),
  32478. bgBlueBright: f("\x1b[104m", "\x1b[49m"),
  32479. bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
  32480. bgCyanBright: f("\x1b[106m", "\x1b[49m"),
  32481. bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
  32482. }
  32483. };
  32484. picocolors.exports = createColors();
  32485. picocolors.exports.createColors = createColors;
  32486. return picocolors.exports;
  32487. }
  32488. var tokenize$1;
  32489. var hasRequiredTokenize$1;
  32490. function requireTokenize$1 () {
  32491. if (hasRequiredTokenize$1) return tokenize$1;
  32492. hasRequiredTokenize$1 = 1;
  32493. const SINGLE_QUOTE = "'".charCodeAt(0);
  32494. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  32495. const BACKSLASH = '\\'.charCodeAt(0);
  32496. const SLASH = '/'.charCodeAt(0);
  32497. const NEWLINE = '\n'.charCodeAt(0);
  32498. const SPACE = ' '.charCodeAt(0);
  32499. const FEED = '\f'.charCodeAt(0);
  32500. const TAB = '\t'.charCodeAt(0);
  32501. const CR = '\r'.charCodeAt(0);
  32502. const OPEN_SQUARE = '['.charCodeAt(0);
  32503. const CLOSE_SQUARE = ']'.charCodeAt(0);
  32504. const OPEN_PARENTHESES = '('.charCodeAt(0);
  32505. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  32506. const OPEN_CURLY = '{'.charCodeAt(0);
  32507. const CLOSE_CURLY = '}'.charCodeAt(0);
  32508. const SEMICOLON = ';'.charCodeAt(0);
  32509. const ASTERISK = '*'.charCodeAt(0);
  32510. const COLON = ':'.charCodeAt(0);
  32511. const AT = '@'.charCodeAt(0);
  32512. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  32513. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  32514. const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
  32515. const RE_HEX_ESCAPE = /[\da-f]/i;
  32516. tokenize$1 = function tokenizer(input, options = {}) {
  32517. let css = input.css.valueOf();
  32518. let ignore = options.ignoreErrors;
  32519. let code, content, escape, next, quote;
  32520. let currentToken, escaped, escapePos, n, prev;
  32521. let length = css.length;
  32522. let pos = 0;
  32523. let buffer = [];
  32524. let returned = [];
  32525. function position() {
  32526. return pos
  32527. }
  32528. function unclosed(what) {
  32529. throw input.error('Unclosed ' + what, pos)
  32530. }
  32531. function endOfFile() {
  32532. return returned.length === 0 && pos >= length
  32533. }
  32534. function nextToken(opts) {
  32535. if (returned.length) return returned.pop()
  32536. if (pos >= length) return
  32537. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  32538. code = css.charCodeAt(pos);
  32539. switch (code) {
  32540. case NEWLINE:
  32541. case SPACE:
  32542. case TAB:
  32543. case CR:
  32544. case FEED: {
  32545. next = pos;
  32546. do {
  32547. next += 1;
  32548. code = css.charCodeAt(next);
  32549. } while (
  32550. code === SPACE ||
  32551. code === NEWLINE ||
  32552. code === TAB ||
  32553. code === CR ||
  32554. code === FEED
  32555. )
  32556. currentToken = ['space', css.slice(pos, next)];
  32557. pos = next - 1;
  32558. break
  32559. }
  32560. case OPEN_SQUARE:
  32561. case CLOSE_SQUARE:
  32562. case OPEN_CURLY:
  32563. case CLOSE_CURLY:
  32564. case COLON:
  32565. case SEMICOLON:
  32566. case CLOSE_PARENTHESES: {
  32567. let controlChar = String.fromCharCode(code);
  32568. currentToken = [controlChar, controlChar, pos];
  32569. break
  32570. }
  32571. case OPEN_PARENTHESES: {
  32572. prev = buffer.length ? buffer.pop()[1] : '';
  32573. n = css.charCodeAt(pos + 1);
  32574. if (
  32575. prev === 'url' &&
  32576. n !== SINGLE_QUOTE &&
  32577. n !== DOUBLE_QUOTE &&
  32578. n !== SPACE &&
  32579. n !== NEWLINE &&
  32580. n !== TAB &&
  32581. n !== FEED &&
  32582. n !== CR
  32583. ) {
  32584. next = pos;
  32585. do {
  32586. escaped = false;
  32587. next = css.indexOf(')', next + 1);
  32588. if (next === -1) {
  32589. if (ignore || ignoreUnclosed) {
  32590. next = pos;
  32591. break
  32592. } else {
  32593. unclosed('bracket');
  32594. }
  32595. }
  32596. escapePos = next;
  32597. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  32598. escapePos -= 1;
  32599. escaped = !escaped;
  32600. }
  32601. } while (escaped)
  32602. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  32603. pos = next;
  32604. } else {
  32605. next = css.indexOf(')', pos + 1);
  32606. content = css.slice(pos, next + 1);
  32607. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  32608. currentToken = ['(', '(', pos];
  32609. } else {
  32610. currentToken = ['brackets', content, pos, next];
  32611. pos = next;
  32612. }
  32613. }
  32614. break
  32615. }
  32616. case SINGLE_QUOTE:
  32617. case DOUBLE_QUOTE: {
  32618. quote = code === SINGLE_QUOTE ? "'" : '"';
  32619. next = pos;
  32620. do {
  32621. escaped = false;
  32622. next = css.indexOf(quote, next + 1);
  32623. if (next === -1) {
  32624. if (ignore || ignoreUnclosed) {
  32625. next = pos + 1;
  32626. break
  32627. } else {
  32628. unclosed('string');
  32629. }
  32630. }
  32631. escapePos = next;
  32632. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  32633. escapePos -= 1;
  32634. escaped = !escaped;
  32635. }
  32636. } while (escaped)
  32637. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  32638. pos = next;
  32639. break
  32640. }
  32641. case AT: {
  32642. RE_AT_END.lastIndex = pos + 1;
  32643. RE_AT_END.test(css);
  32644. if (RE_AT_END.lastIndex === 0) {
  32645. next = css.length - 1;
  32646. } else {
  32647. next = RE_AT_END.lastIndex - 2;
  32648. }
  32649. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  32650. pos = next;
  32651. break
  32652. }
  32653. case BACKSLASH: {
  32654. next = pos;
  32655. escape = true;
  32656. while (css.charCodeAt(next + 1) === BACKSLASH) {
  32657. next += 1;
  32658. escape = !escape;
  32659. }
  32660. code = css.charCodeAt(next + 1);
  32661. if (
  32662. escape &&
  32663. code !== SLASH &&
  32664. code !== SPACE &&
  32665. code !== NEWLINE &&
  32666. code !== TAB &&
  32667. code !== CR &&
  32668. code !== FEED
  32669. ) {
  32670. next += 1;
  32671. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  32672. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  32673. next += 1;
  32674. }
  32675. if (css.charCodeAt(next + 1) === SPACE) {
  32676. next += 1;
  32677. }
  32678. }
  32679. }
  32680. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  32681. pos = next;
  32682. break
  32683. }
  32684. default: {
  32685. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  32686. next = css.indexOf('*/', pos + 2) + 1;
  32687. if (next === 0) {
  32688. if (ignore || ignoreUnclosed) {
  32689. next = css.length;
  32690. } else {
  32691. unclosed('comment');
  32692. }
  32693. }
  32694. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  32695. pos = next;
  32696. } else {
  32697. RE_WORD_END.lastIndex = pos + 1;
  32698. RE_WORD_END.test(css);
  32699. if (RE_WORD_END.lastIndex === 0) {
  32700. next = css.length - 1;
  32701. } else {
  32702. next = RE_WORD_END.lastIndex - 2;
  32703. }
  32704. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  32705. buffer.push(currentToken);
  32706. pos = next;
  32707. }
  32708. break
  32709. }
  32710. }
  32711. pos++;
  32712. return currentToken
  32713. }
  32714. function back(token) {
  32715. returned.push(token);
  32716. }
  32717. return {
  32718. back,
  32719. endOfFile,
  32720. nextToken,
  32721. position
  32722. }
  32723. };
  32724. return tokenize$1;
  32725. }
  32726. var terminalHighlight_1;
  32727. var hasRequiredTerminalHighlight;
  32728. function requireTerminalHighlight () {
  32729. if (hasRequiredTerminalHighlight) return terminalHighlight_1;
  32730. hasRequiredTerminalHighlight = 1;
  32731. let pico = /*@__PURE__*/ requirePicocolors();
  32732. let tokenizer = /*@__PURE__*/ requireTokenize$1();
  32733. let Input;
  32734. function registerInput(dependant) {
  32735. Input = dependant;
  32736. }
  32737. const HIGHLIGHT_THEME = {
  32738. ';': pico.yellow,
  32739. ':': pico.yellow,
  32740. '(': pico.cyan,
  32741. ')': pico.cyan,
  32742. '[': pico.yellow,
  32743. ']': pico.yellow,
  32744. '{': pico.yellow,
  32745. '}': pico.yellow,
  32746. 'at-word': pico.cyan,
  32747. 'brackets': pico.cyan,
  32748. 'call': pico.cyan,
  32749. 'class': pico.yellow,
  32750. 'comment': pico.gray,
  32751. 'hash': pico.magenta,
  32752. 'string': pico.green
  32753. };
  32754. function getTokenType([type, value], processor) {
  32755. if (type === 'word') {
  32756. if (value[0] === '.') {
  32757. return 'class'
  32758. }
  32759. if (value[0] === '#') {
  32760. return 'hash'
  32761. }
  32762. }
  32763. if (!processor.endOfFile()) {
  32764. let next = processor.nextToken();
  32765. processor.back(next);
  32766. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  32767. }
  32768. return type
  32769. }
  32770. function terminalHighlight(css) {
  32771. let processor = tokenizer(new Input(css), { ignoreErrors: true });
  32772. let result = '';
  32773. while (!processor.endOfFile()) {
  32774. let token = processor.nextToken();
  32775. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  32776. if (color) {
  32777. result += token[1]
  32778. .split(/\r?\n/)
  32779. .map(i => color(i))
  32780. .join('\n');
  32781. } else {
  32782. result += token[1];
  32783. }
  32784. }
  32785. return result
  32786. }
  32787. terminalHighlight.registerInput = registerInput;
  32788. terminalHighlight_1 = terminalHighlight;
  32789. return terminalHighlight_1;
  32790. }
  32791. var cssSyntaxError;
  32792. var hasRequiredCssSyntaxError;
  32793. function requireCssSyntaxError () {
  32794. if (hasRequiredCssSyntaxError) return cssSyntaxError;
  32795. hasRequiredCssSyntaxError = 1;
  32796. let pico = /*@__PURE__*/ requirePicocolors();
  32797. let terminalHighlight = /*@__PURE__*/ requireTerminalHighlight();
  32798. class CssSyntaxError extends Error {
  32799. constructor(message, line, column, source, file, plugin) {
  32800. super(message);
  32801. this.name = 'CssSyntaxError';
  32802. this.reason = message;
  32803. if (file) {
  32804. this.file = file;
  32805. }
  32806. if (source) {
  32807. this.source = source;
  32808. }
  32809. if (plugin) {
  32810. this.plugin = plugin;
  32811. }
  32812. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  32813. if (typeof line === 'number') {
  32814. this.line = line;
  32815. this.column = column;
  32816. } else {
  32817. this.line = line.line;
  32818. this.column = line.column;
  32819. this.endLine = column.line;
  32820. this.endColumn = column.column;
  32821. }
  32822. }
  32823. this.setMessage();
  32824. if (Error.captureStackTrace) {
  32825. Error.captureStackTrace(this, CssSyntaxError);
  32826. }
  32827. }
  32828. setMessage() {
  32829. this.message = this.plugin ? this.plugin + ': ' : '';
  32830. this.message += this.file ? this.file : '<css input>';
  32831. if (typeof this.line !== 'undefined') {
  32832. this.message += ':' + this.line + ':' + this.column;
  32833. }
  32834. this.message += ': ' + this.reason;
  32835. }
  32836. showSourceCode(color) {
  32837. if (!this.source) return ''
  32838. let css = this.source;
  32839. if (color == null) color = pico.isColorSupported;
  32840. let aside = text => text;
  32841. let mark = text => text;
  32842. let highlight = text => text;
  32843. if (color) {
  32844. let { bold, gray, red } = pico.createColors(true);
  32845. mark = text => bold(red(text));
  32846. aside = text => gray(text);
  32847. if (terminalHighlight) {
  32848. highlight = text => terminalHighlight(text);
  32849. }
  32850. }
  32851. let lines = css.split(/\r?\n/);
  32852. let start = Math.max(this.line - 3, 0);
  32853. let end = Math.min(this.line + 2, lines.length);
  32854. let maxWidth = String(end).length;
  32855. return lines
  32856. .slice(start, end)
  32857. .map((line, index) => {
  32858. let number = start + 1 + index;
  32859. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  32860. if (number === this.line) {
  32861. if (line.length > 160) {
  32862. let padding = 20;
  32863. let subLineStart = Math.max(0, this.column - padding);
  32864. let subLineEnd = Math.max(
  32865. this.column + padding,
  32866. this.endColumn + padding
  32867. );
  32868. let subLine = line.slice(subLineStart, subLineEnd);
  32869. let spacing =
  32870. aside(gutter.replace(/\d/g, ' ')) +
  32871. line
  32872. .slice(0, Math.min(this.column - 1, padding - 1))
  32873. .replace(/[^\t]/g, ' ');
  32874. return (
  32875. mark('>') +
  32876. aside(gutter) +
  32877. highlight(subLine) +
  32878. '\n ' +
  32879. spacing +
  32880. mark('^')
  32881. )
  32882. }
  32883. let spacing =
  32884. aside(gutter.replace(/\d/g, ' ')) +
  32885. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  32886. return (
  32887. mark('>') +
  32888. aside(gutter) +
  32889. highlight(line) +
  32890. '\n ' +
  32891. spacing +
  32892. mark('^')
  32893. )
  32894. }
  32895. return ' ' + aside(gutter) + highlight(line)
  32896. })
  32897. .join('\n')
  32898. }
  32899. toString() {
  32900. let code = this.showSourceCode();
  32901. if (code) {
  32902. code = '\n\n' + code + '\n';
  32903. }
  32904. return this.name + ': ' + this.message + code
  32905. }
  32906. }
  32907. cssSyntaxError = CssSyntaxError;
  32908. CssSyntaxError.default = CssSyntaxError;
  32909. return cssSyntaxError;
  32910. }
  32911. var stringifier;
  32912. var hasRequiredStringifier;
  32913. function requireStringifier () {
  32914. if (hasRequiredStringifier) return stringifier;
  32915. hasRequiredStringifier = 1;
  32916. const DEFAULT_RAW = {
  32917. after: '\n',
  32918. beforeClose: '\n',
  32919. beforeComment: '\n',
  32920. beforeDecl: '\n',
  32921. beforeOpen: ' ',
  32922. beforeRule: '\n',
  32923. colon: ': ',
  32924. commentLeft: ' ',
  32925. commentRight: ' ',
  32926. emptyBody: '',
  32927. indent: ' ',
  32928. semicolon: false
  32929. };
  32930. function capitalize(str) {
  32931. return str[0].toUpperCase() + str.slice(1)
  32932. }
  32933. class Stringifier {
  32934. constructor(builder) {
  32935. this.builder = builder;
  32936. }
  32937. atrule(node, semicolon) {
  32938. let name = '@' + node.name;
  32939. let params = node.params ? this.rawValue(node, 'params') : '';
  32940. if (typeof node.raws.afterName !== 'undefined') {
  32941. name += node.raws.afterName;
  32942. } else if (params) {
  32943. name += ' ';
  32944. }
  32945. if (node.nodes) {
  32946. this.block(node, name + params);
  32947. } else {
  32948. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  32949. this.builder(name + params + end, node);
  32950. }
  32951. }
  32952. beforeAfter(node, detect) {
  32953. let value;
  32954. if (node.type === 'decl') {
  32955. value = this.raw(node, null, 'beforeDecl');
  32956. } else if (node.type === 'comment') {
  32957. value = this.raw(node, null, 'beforeComment');
  32958. } else if (detect === 'before') {
  32959. value = this.raw(node, null, 'beforeRule');
  32960. } else {
  32961. value = this.raw(node, null, 'beforeClose');
  32962. }
  32963. let buf = node.parent;
  32964. let depth = 0;
  32965. while (buf && buf.type !== 'root') {
  32966. depth += 1;
  32967. buf = buf.parent;
  32968. }
  32969. if (value.includes('\n')) {
  32970. let indent = this.raw(node, null, 'indent');
  32971. if (indent.length) {
  32972. for (let step = 0; step < depth; step++) value += indent;
  32973. }
  32974. }
  32975. return value
  32976. }
  32977. block(node, start) {
  32978. let between = this.raw(node, 'between', 'beforeOpen');
  32979. this.builder(start + between + '{', node, 'start');
  32980. let after;
  32981. if (node.nodes && node.nodes.length) {
  32982. this.body(node);
  32983. after = this.raw(node, 'after');
  32984. } else {
  32985. after = this.raw(node, 'after', 'emptyBody');
  32986. }
  32987. if (after) this.builder(after);
  32988. this.builder('}', node, 'end');
  32989. }
  32990. body(node) {
  32991. let last = node.nodes.length - 1;
  32992. while (last > 0) {
  32993. if (node.nodes[last].type !== 'comment') break
  32994. last -= 1;
  32995. }
  32996. let semicolon = this.raw(node, 'semicolon');
  32997. for (let i = 0; i < node.nodes.length; i++) {
  32998. let child = node.nodes[i];
  32999. let before = this.raw(child, 'before');
  33000. if (before) this.builder(before);
  33001. this.stringify(child, last !== i || semicolon);
  33002. }
  33003. }
  33004. comment(node) {
  33005. let left = this.raw(node, 'left', 'commentLeft');
  33006. let right = this.raw(node, 'right', 'commentRight');
  33007. this.builder('/*' + left + node.text + right + '*/', node);
  33008. }
  33009. decl(node, semicolon) {
  33010. let between = this.raw(node, 'between', 'colon');
  33011. let string = node.prop + between + this.rawValue(node, 'value');
  33012. if (node.important) {
  33013. string += node.raws.important || ' !important';
  33014. }
  33015. if (semicolon) string += ';';
  33016. this.builder(string, node);
  33017. }
  33018. document(node) {
  33019. this.body(node);
  33020. }
  33021. raw(node, own, detect) {
  33022. let value;
  33023. if (!detect) detect = own;
  33024. // Already had
  33025. if (own) {
  33026. value = node.raws[own];
  33027. if (typeof value !== 'undefined') return value
  33028. }
  33029. let parent = node.parent;
  33030. if (detect === 'before') {
  33031. // Hack for first rule in CSS
  33032. if (!parent || (parent.type === 'root' && parent.first === node)) {
  33033. return ''
  33034. }
  33035. // `root` nodes in `document` should use only their own raws
  33036. if (parent && parent.type === 'document') {
  33037. return ''
  33038. }
  33039. }
  33040. // Floating child without parent
  33041. if (!parent) return DEFAULT_RAW[detect]
  33042. // Detect style by other nodes
  33043. let root = node.root();
  33044. if (!root.rawCache) root.rawCache = {};
  33045. if (typeof root.rawCache[detect] !== 'undefined') {
  33046. return root.rawCache[detect]
  33047. }
  33048. if (detect === 'before' || detect === 'after') {
  33049. return this.beforeAfter(node, detect)
  33050. } else {
  33051. let method = 'raw' + capitalize(detect);
  33052. if (this[method]) {
  33053. value = this[method](root, node);
  33054. } else {
  33055. root.walk(i => {
  33056. value = i.raws[own];
  33057. if (typeof value !== 'undefined') return false
  33058. });
  33059. }
  33060. }
  33061. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  33062. root.rawCache[detect] = value;
  33063. return value
  33064. }
  33065. rawBeforeClose(root) {
  33066. let value;
  33067. root.walk(i => {
  33068. if (i.nodes && i.nodes.length > 0) {
  33069. if (typeof i.raws.after !== 'undefined') {
  33070. value = i.raws.after;
  33071. if (value.includes('\n')) {
  33072. value = value.replace(/[^\n]+$/, '');
  33073. }
  33074. return false
  33075. }
  33076. }
  33077. });
  33078. if (value) value = value.replace(/\S/g, '');
  33079. return value
  33080. }
  33081. rawBeforeComment(root, node) {
  33082. let value;
  33083. root.walkComments(i => {
  33084. if (typeof i.raws.before !== 'undefined') {
  33085. value = i.raws.before;
  33086. if (value.includes('\n')) {
  33087. value = value.replace(/[^\n]+$/, '');
  33088. }
  33089. return false
  33090. }
  33091. });
  33092. if (typeof value === 'undefined') {
  33093. value = this.raw(node, null, 'beforeDecl');
  33094. } else if (value) {
  33095. value = value.replace(/\S/g, '');
  33096. }
  33097. return value
  33098. }
  33099. rawBeforeDecl(root, node) {
  33100. let value;
  33101. root.walkDecls(i => {
  33102. if (typeof i.raws.before !== 'undefined') {
  33103. value = i.raws.before;
  33104. if (value.includes('\n')) {
  33105. value = value.replace(/[^\n]+$/, '');
  33106. }
  33107. return false
  33108. }
  33109. });
  33110. if (typeof value === 'undefined') {
  33111. value = this.raw(node, null, 'beforeRule');
  33112. } else if (value) {
  33113. value = value.replace(/\S/g, '');
  33114. }
  33115. return value
  33116. }
  33117. rawBeforeOpen(root) {
  33118. let value;
  33119. root.walk(i => {
  33120. if (i.type !== 'decl') {
  33121. value = i.raws.between;
  33122. if (typeof value !== 'undefined') return false
  33123. }
  33124. });
  33125. return value
  33126. }
  33127. rawBeforeRule(root) {
  33128. let value;
  33129. root.walk(i => {
  33130. if (i.nodes && (i.parent !== root || root.first !== i)) {
  33131. if (typeof i.raws.before !== 'undefined') {
  33132. value = i.raws.before;
  33133. if (value.includes('\n')) {
  33134. value = value.replace(/[^\n]+$/, '');
  33135. }
  33136. return false
  33137. }
  33138. }
  33139. });
  33140. if (value) value = value.replace(/\S/g, '');
  33141. return value
  33142. }
  33143. rawColon(root) {
  33144. let value;
  33145. root.walkDecls(i => {
  33146. if (typeof i.raws.between !== 'undefined') {
  33147. value = i.raws.between.replace(/[^\s:]/g, '');
  33148. return false
  33149. }
  33150. });
  33151. return value
  33152. }
  33153. rawEmptyBody(root) {
  33154. let value;
  33155. root.walk(i => {
  33156. if (i.nodes && i.nodes.length === 0) {
  33157. value = i.raws.after;
  33158. if (typeof value !== 'undefined') return false
  33159. }
  33160. });
  33161. return value
  33162. }
  33163. rawIndent(root) {
  33164. if (root.raws.indent) return root.raws.indent
  33165. let value;
  33166. root.walk(i => {
  33167. let p = i.parent;
  33168. if (p && p !== root && p.parent && p.parent === root) {
  33169. if (typeof i.raws.before !== 'undefined') {
  33170. let parts = i.raws.before.split('\n');
  33171. value = parts[parts.length - 1];
  33172. value = value.replace(/\S/g, '');
  33173. return false
  33174. }
  33175. }
  33176. });
  33177. return value
  33178. }
  33179. rawSemicolon(root) {
  33180. let value;
  33181. root.walk(i => {
  33182. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  33183. value = i.raws.semicolon;
  33184. if (typeof value !== 'undefined') return false
  33185. }
  33186. });
  33187. return value
  33188. }
  33189. rawValue(node, prop) {
  33190. let value = node[prop];
  33191. let raw = node.raws[prop];
  33192. if (raw && raw.value === value) {
  33193. return raw.raw
  33194. }
  33195. return value
  33196. }
  33197. root(node) {
  33198. this.body(node);
  33199. if (node.raws.after) this.builder(node.raws.after);
  33200. }
  33201. rule(node) {
  33202. this.block(node, this.rawValue(node, 'selector'));
  33203. if (node.raws.ownSemicolon) {
  33204. this.builder(node.raws.ownSemicolon, node, 'end');
  33205. }
  33206. }
  33207. stringify(node, semicolon) {
  33208. /* c8 ignore start */
  33209. if (!this[node.type]) {
  33210. throw new Error(
  33211. 'Unknown AST node type ' +
  33212. node.type +
  33213. '. ' +
  33214. 'Maybe you need to change PostCSS stringifier.'
  33215. )
  33216. }
  33217. /* c8 ignore stop */
  33218. this[node.type](node, semicolon);
  33219. }
  33220. }
  33221. stringifier = Stringifier;
  33222. Stringifier.default = Stringifier;
  33223. return stringifier;
  33224. }
  33225. var stringify_1;
  33226. var hasRequiredStringify;
  33227. function requireStringify () {
  33228. if (hasRequiredStringify) return stringify_1;
  33229. hasRequiredStringify = 1;
  33230. let Stringifier = /*@__PURE__*/ requireStringifier();
  33231. function stringify(node, builder) {
  33232. let str = new Stringifier(builder);
  33233. str.stringify(node);
  33234. }
  33235. stringify_1 = stringify;
  33236. stringify.default = stringify;
  33237. return stringify_1;
  33238. }
  33239. var symbols = {};
  33240. var hasRequiredSymbols;
  33241. function requireSymbols () {
  33242. if (hasRequiredSymbols) return symbols;
  33243. hasRequiredSymbols = 1;
  33244. symbols.isClean = Symbol('isClean');
  33245. symbols.my = Symbol('my');
  33246. return symbols;
  33247. }
  33248. var node$2;
  33249. var hasRequiredNode$2;
  33250. function requireNode$2 () {
  33251. if (hasRequiredNode$2) return node$2;
  33252. hasRequiredNode$2 = 1;
  33253. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  33254. let Stringifier = /*@__PURE__*/ requireStringifier();
  33255. let stringify = /*@__PURE__*/ requireStringify();
  33256. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  33257. function cloneNode(obj, parent) {
  33258. let cloned = new obj.constructor();
  33259. for (let i in obj) {
  33260. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  33261. /* c8 ignore next 2 */
  33262. continue
  33263. }
  33264. if (i === 'proxyCache') continue
  33265. let value = obj[i];
  33266. let type = typeof value;
  33267. if (i === 'parent' && type === 'object') {
  33268. if (parent) cloned[i] = parent;
  33269. } else if (i === 'source') {
  33270. cloned[i] = value;
  33271. } else if (Array.isArray(value)) {
  33272. cloned[i] = value.map(j => cloneNode(j, cloned));
  33273. } else {
  33274. if (type === 'object' && value !== null) value = cloneNode(value);
  33275. cloned[i] = value;
  33276. }
  33277. }
  33278. return cloned
  33279. }
  33280. function sourceOffset(inputCSS, position) {
  33281. // Not all custom syntaxes support `offset` in `source.start` and `source.end`
  33282. if (position && typeof position.offset !== 'undefined') {
  33283. return position.offset
  33284. }
  33285. let column = 1;
  33286. let line = 1;
  33287. let offset = 0;
  33288. for (let i = 0; i < inputCSS.length; i++) {
  33289. if (line === position.line && column === position.column) {
  33290. offset = i;
  33291. break
  33292. }
  33293. if (inputCSS[i] === '\n') {
  33294. column = 1;
  33295. line += 1;
  33296. } else {
  33297. column += 1;
  33298. }
  33299. }
  33300. return offset
  33301. }
  33302. class Node {
  33303. get proxyOf() {
  33304. return this
  33305. }
  33306. constructor(defaults = {}) {
  33307. this.raws = {};
  33308. this[isClean] = false;
  33309. this[my] = true;
  33310. for (let name in defaults) {
  33311. if (name === 'nodes') {
  33312. this.nodes = [];
  33313. for (let node of defaults[name]) {
  33314. if (typeof node.clone === 'function') {
  33315. this.append(node.clone());
  33316. } else {
  33317. this.append(node);
  33318. }
  33319. }
  33320. } else {
  33321. this[name] = defaults[name];
  33322. }
  33323. }
  33324. }
  33325. addToError(error) {
  33326. error.postcssNode = this;
  33327. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  33328. let s = this.source;
  33329. error.stack = error.stack.replace(
  33330. /\n\s{4}at /,
  33331. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  33332. );
  33333. }
  33334. return error
  33335. }
  33336. after(add) {
  33337. this.parent.insertAfter(this, add);
  33338. return this
  33339. }
  33340. assign(overrides = {}) {
  33341. for (let name in overrides) {
  33342. this[name] = overrides[name];
  33343. }
  33344. return this
  33345. }
  33346. before(add) {
  33347. this.parent.insertBefore(this, add);
  33348. return this
  33349. }
  33350. cleanRaws(keepBetween) {
  33351. delete this.raws.before;
  33352. delete this.raws.after;
  33353. if (!keepBetween) delete this.raws.between;
  33354. }
  33355. clone(overrides = {}) {
  33356. let cloned = cloneNode(this);
  33357. for (let name in overrides) {
  33358. cloned[name] = overrides[name];
  33359. }
  33360. return cloned
  33361. }
  33362. cloneAfter(overrides = {}) {
  33363. let cloned = this.clone(overrides);
  33364. this.parent.insertAfter(this, cloned);
  33365. return cloned
  33366. }
  33367. cloneBefore(overrides = {}) {
  33368. let cloned = this.clone(overrides);
  33369. this.parent.insertBefore(this, cloned);
  33370. return cloned
  33371. }
  33372. error(message, opts = {}) {
  33373. if (this.source) {
  33374. let { end, start } = this.rangeBy(opts);
  33375. return this.source.input.error(
  33376. message,
  33377. { column: start.column, line: start.line },
  33378. { column: end.column, line: end.line },
  33379. opts
  33380. )
  33381. }
  33382. return new CssSyntaxError(message)
  33383. }
  33384. getProxyProcessor() {
  33385. return {
  33386. get(node, prop) {
  33387. if (prop === 'proxyOf') {
  33388. return node
  33389. } else if (prop === 'root') {
  33390. return () => node.root().toProxy()
  33391. } else {
  33392. return node[prop]
  33393. }
  33394. },
  33395. set(node, prop, value) {
  33396. if (node[prop] === value) return true
  33397. node[prop] = value;
  33398. if (
  33399. prop === 'prop' ||
  33400. prop === 'value' ||
  33401. prop === 'name' ||
  33402. prop === 'params' ||
  33403. prop === 'important' ||
  33404. /* c8 ignore next */
  33405. prop === 'text'
  33406. ) {
  33407. node.markDirty();
  33408. }
  33409. return true
  33410. }
  33411. }
  33412. }
  33413. /* c8 ignore next 3 */
  33414. markClean() {
  33415. this[isClean] = true;
  33416. }
  33417. markDirty() {
  33418. if (this[isClean]) {
  33419. this[isClean] = false;
  33420. let next = this;
  33421. while ((next = next.parent)) {
  33422. next[isClean] = false;
  33423. }
  33424. }
  33425. }
  33426. next() {
  33427. if (!this.parent) return undefined
  33428. let index = this.parent.index(this);
  33429. return this.parent.nodes[index + 1]
  33430. }
  33431. positionBy(opts = {}) {
  33432. let pos = this.source.start;
  33433. if (opts.index) {
  33434. pos = this.positionInside(opts.index);
  33435. } else if (opts.word) {
  33436. let inputString =
  33437. 'document' in this.source.input
  33438. ? this.source.input.document
  33439. : this.source.input.css;
  33440. let stringRepresentation = inputString.slice(
  33441. sourceOffset(inputString, this.source.start),
  33442. sourceOffset(inputString, this.source.end)
  33443. );
  33444. let index = stringRepresentation.indexOf(opts.word);
  33445. if (index !== -1) pos = this.positionInside(index);
  33446. }
  33447. return pos
  33448. }
  33449. positionInside(index) {
  33450. let column = this.source.start.column;
  33451. let line = this.source.start.line;
  33452. let inputString =
  33453. 'document' in this.source.input
  33454. ? this.source.input.document
  33455. : this.source.input.css;
  33456. let offset = sourceOffset(inputString, this.source.start);
  33457. let end = offset + index;
  33458. for (let i = offset; i < end; i++) {
  33459. if (inputString[i] === '\n') {
  33460. column = 1;
  33461. line += 1;
  33462. } else {
  33463. column += 1;
  33464. }
  33465. }
  33466. return { column, line, offset: end }
  33467. }
  33468. prev() {
  33469. if (!this.parent) return undefined
  33470. let index = this.parent.index(this);
  33471. return this.parent.nodes[index - 1]
  33472. }
  33473. rangeBy(opts = {}) {
  33474. let inputString =
  33475. 'document' in this.source.input
  33476. ? this.source.input.document
  33477. : this.source.input.css;
  33478. let start = {
  33479. column: this.source.start.column,
  33480. line: this.source.start.line,
  33481. offset: sourceOffset(inputString, this.source.start)
  33482. };
  33483. let end = this.source.end
  33484. ? {
  33485. column: this.source.end.column + 1,
  33486. line: this.source.end.line,
  33487. offset:
  33488. typeof this.source.end.offset === 'number'
  33489. ? // `source.end.offset` is exclusive, so we don't need to add 1
  33490. this.source.end.offset
  33491. : // Since line/column in this.source.end is inclusive,
  33492. // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
  33493. // So, we add 1 to convert it to exclusive.
  33494. sourceOffset(inputString, this.source.end) + 1
  33495. }
  33496. : {
  33497. column: start.column + 1,
  33498. line: start.line,
  33499. offset: start.offset + 1
  33500. };
  33501. if (opts.word) {
  33502. let stringRepresentation = inputString.slice(
  33503. sourceOffset(inputString, this.source.start),
  33504. sourceOffset(inputString, this.source.end)
  33505. );
  33506. let index = stringRepresentation.indexOf(opts.word);
  33507. if (index !== -1) {
  33508. start = this.positionInside(index);
  33509. end = this.positionInside(index + opts.word.length);
  33510. }
  33511. } else {
  33512. if (opts.start) {
  33513. start = {
  33514. column: opts.start.column,
  33515. line: opts.start.line,
  33516. offset: sourceOffset(inputString, opts.start)
  33517. };
  33518. } else if (opts.index) {
  33519. start = this.positionInside(opts.index);
  33520. }
  33521. if (opts.end) {
  33522. end = {
  33523. column: opts.end.column,
  33524. line: opts.end.line,
  33525. offset: sourceOffset(inputString, opts.end)
  33526. };
  33527. } else if (typeof opts.endIndex === 'number') {
  33528. end = this.positionInside(opts.endIndex);
  33529. } else if (opts.index) {
  33530. end = this.positionInside(opts.index + 1);
  33531. }
  33532. }
  33533. if (
  33534. end.line < start.line ||
  33535. (end.line === start.line && end.column <= start.column)
  33536. ) {
  33537. end = {
  33538. column: start.column + 1,
  33539. line: start.line,
  33540. offset: start.offset + 1
  33541. };
  33542. }
  33543. return { end, start }
  33544. }
  33545. raw(prop, defaultType) {
  33546. let str = new Stringifier();
  33547. return str.raw(this, prop, defaultType)
  33548. }
  33549. remove() {
  33550. if (this.parent) {
  33551. this.parent.removeChild(this);
  33552. }
  33553. this.parent = undefined;
  33554. return this
  33555. }
  33556. replaceWith(...nodes) {
  33557. if (this.parent) {
  33558. let bookmark = this;
  33559. let foundSelf = false;
  33560. for (let node of nodes) {
  33561. if (node === this) {
  33562. foundSelf = true;
  33563. } else if (foundSelf) {
  33564. this.parent.insertAfter(bookmark, node);
  33565. bookmark = node;
  33566. } else {
  33567. this.parent.insertBefore(bookmark, node);
  33568. }
  33569. }
  33570. if (!foundSelf) {
  33571. this.remove();
  33572. }
  33573. }
  33574. return this
  33575. }
  33576. root() {
  33577. let result = this;
  33578. while (result.parent && result.parent.type !== 'document') {
  33579. result = result.parent;
  33580. }
  33581. return result
  33582. }
  33583. toJSON(_, inputs) {
  33584. let fixed = {};
  33585. let emitInputs = inputs == null;
  33586. inputs = inputs || new Map();
  33587. let inputsNextIndex = 0;
  33588. for (let name in this) {
  33589. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  33590. /* c8 ignore next 2 */
  33591. continue
  33592. }
  33593. if (name === 'parent' || name === 'proxyCache') continue
  33594. let value = this[name];
  33595. if (Array.isArray(value)) {
  33596. fixed[name] = value.map(i => {
  33597. if (typeof i === 'object' && i.toJSON) {
  33598. return i.toJSON(null, inputs)
  33599. } else {
  33600. return i
  33601. }
  33602. });
  33603. } else if (typeof value === 'object' && value.toJSON) {
  33604. fixed[name] = value.toJSON(null, inputs);
  33605. } else if (name === 'source') {
  33606. if (value == null) continue
  33607. let inputId = inputs.get(value.input);
  33608. if (inputId == null) {
  33609. inputId = inputsNextIndex;
  33610. inputs.set(value.input, inputsNextIndex);
  33611. inputsNextIndex++;
  33612. }
  33613. fixed[name] = {
  33614. end: value.end,
  33615. inputId,
  33616. start: value.start
  33617. };
  33618. } else {
  33619. fixed[name] = value;
  33620. }
  33621. }
  33622. if (emitInputs) {
  33623. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  33624. }
  33625. return fixed
  33626. }
  33627. toProxy() {
  33628. if (!this.proxyCache) {
  33629. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  33630. }
  33631. return this.proxyCache
  33632. }
  33633. toString(stringifier = stringify) {
  33634. if (stringifier.stringify) stringifier = stringifier.stringify;
  33635. let result = '';
  33636. stringifier(this, i => {
  33637. result += i;
  33638. });
  33639. return result
  33640. }
  33641. warn(result, text, opts = {}) {
  33642. let data = { node: this };
  33643. for (let i in opts) data[i] = opts[i];
  33644. return result.warn(text, data)
  33645. }
  33646. }
  33647. node$2 = Node;
  33648. Node.default = Node;
  33649. return node$2;
  33650. }
  33651. var comment$1;
  33652. var hasRequiredComment$1;
  33653. function requireComment$1 () {
  33654. if (hasRequiredComment$1) return comment$1;
  33655. hasRequiredComment$1 = 1;
  33656. let Node = /*@__PURE__*/ requireNode$2();
  33657. class Comment extends Node {
  33658. constructor(defaults) {
  33659. super(defaults);
  33660. this.type = 'comment';
  33661. }
  33662. }
  33663. comment$1 = Comment;
  33664. Comment.default = Comment;
  33665. return comment$1;
  33666. }
  33667. var declaration;
  33668. var hasRequiredDeclaration;
  33669. function requireDeclaration () {
  33670. if (hasRequiredDeclaration) return declaration;
  33671. hasRequiredDeclaration = 1;
  33672. let Node = /*@__PURE__*/ requireNode$2();
  33673. class Declaration extends Node {
  33674. get variable() {
  33675. return this.prop.startsWith('--') || this.prop[0] === '$'
  33676. }
  33677. constructor(defaults) {
  33678. if (
  33679. defaults &&
  33680. typeof defaults.value !== 'undefined' &&
  33681. typeof defaults.value !== 'string'
  33682. ) {
  33683. defaults = { ...defaults, value: String(defaults.value) };
  33684. }
  33685. super(defaults);
  33686. this.type = 'decl';
  33687. }
  33688. }
  33689. declaration = Declaration;
  33690. Declaration.default = Declaration;
  33691. return declaration;
  33692. }
  33693. var container$1;
  33694. var hasRequiredContainer$1;
  33695. function requireContainer$1 () {
  33696. if (hasRequiredContainer$1) return container$1;
  33697. hasRequiredContainer$1 = 1;
  33698. let Comment = /*@__PURE__*/ requireComment$1();
  33699. let Declaration = /*@__PURE__*/ requireDeclaration();
  33700. let Node = /*@__PURE__*/ requireNode$2();
  33701. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  33702. let AtRule, parse, Root, Rule;
  33703. function cleanSource(nodes) {
  33704. return nodes.map(i => {
  33705. if (i.nodes) i.nodes = cleanSource(i.nodes);
  33706. delete i.source;
  33707. return i
  33708. })
  33709. }
  33710. function markTreeDirty(node) {
  33711. node[isClean] = false;
  33712. if (node.proxyOf.nodes) {
  33713. for (let i of node.proxyOf.nodes) {
  33714. markTreeDirty(i);
  33715. }
  33716. }
  33717. }
  33718. class Container extends Node {
  33719. get first() {
  33720. if (!this.proxyOf.nodes) return undefined
  33721. return this.proxyOf.nodes[0]
  33722. }
  33723. get last() {
  33724. if (!this.proxyOf.nodes) return undefined
  33725. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  33726. }
  33727. append(...children) {
  33728. for (let child of children) {
  33729. let nodes = this.normalize(child, this.last);
  33730. for (let node of nodes) this.proxyOf.nodes.push(node);
  33731. }
  33732. this.markDirty();
  33733. return this
  33734. }
  33735. cleanRaws(keepBetween) {
  33736. super.cleanRaws(keepBetween);
  33737. if (this.nodes) {
  33738. for (let node of this.nodes) node.cleanRaws(keepBetween);
  33739. }
  33740. }
  33741. each(callback) {
  33742. if (!this.proxyOf.nodes) return undefined
  33743. let iterator = this.getIterator();
  33744. let index, result;
  33745. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  33746. index = this.indexes[iterator];
  33747. result = callback(this.proxyOf.nodes[index], index);
  33748. if (result === false) break
  33749. this.indexes[iterator] += 1;
  33750. }
  33751. delete this.indexes[iterator];
  33752. return result
  33753. }
  33754. every(condition) {
  33755. return this.nodes.every(condition)
  33756. }
  33757. getIterator() {
  33758. if (!this.lastEach) this.lastEach = 0;
  33759. if (!this.indexes) this.indexes = {};
  33760. this.lastEach += 1;
  33761. let iterator = this.lastEach;
  33762. this.indexes[iterator] = 0;
  33763. return iterator
  33764. }
  33765. getProxyProcessor() {
  33766. return {
  33767. get(node, prop) {
  33768. if (prop === 'proxyOf') {
  33769. return node
  33770. } else if (!node[prop]) {
  33771. return node[prop]
  33772. } else if (
  33773. prop === 'each' ||
  33774. (typeof prop === 'string' && prop.startsWith('walk'))
  33775. ) {
  33776. return (...args) => {
  33777. return node[prop](
  33778. ...args.map(i => {
  33779. if (typeof i === 'function') {
  33780. return (child, index) => i(child.toProxy(), index)
  33781. } else {
  33782. return i
  33783. }
  33784. })
  33785. )
  33786. }
  33787. } else if (prop === 'every' || prop === 'some') {
  33788. return cb => {
  33789. return node[prop]((child, ...other) =>
  33790. cb(child.toProxy(), ...other)
  33791. )
  33792. }
  33793. } else if (prop === 'root') {
  33794. return () => node.root().toProxy()
  33795. } else if (prop === 'nodes') {
  33796. return node.nodes.map(i => i.toProxy())
  33797. } else if (prop === 'first' || prop === 'last') {
  33798. return node[prop].toProxy()
  33799. } else {
  33800. return node[prop]
  33801. }
  33802. },
  33803. set(node, prop, value) {
  33804. if (node[prop] === value) return true
  33805. node[prop] = value;
  33806. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  33807. node.markDirty();
  33808. }
  33809. return true
  33810. }
  33811. }
  33812. }
  33813. index(child) {
  33814. if (typeof child === 'number') return child
  33815. if (child.proxyOf) child = child.proxyOf;
  33816. return this.proxyOf.nodes.indexOf(child)
  33817. }
  33818. insertAfter(exist, add) {
  33819. let existIndex = this.index(exist);
  33820. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
  33821. existIndex = this.index(exist);
  33822. for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
  33823. let index;
  33824. for (let id in this.indexes) {
  33825. index = this.indexes[id];
  33826. if (existIndex < index) {
  33827. this.indexes[id] = index + nodes.length;
  33828. }
  33829. }
  33830. this.markDirty();
  33831. return this
  33832. }
  33833. insertBefore(exist, add) {
  33834. let existIndex = this.index(exist);
  33835. let type = existIndex === 0 ? 'prepend' : false;
  33836. let nodes = this.normalize(
  33837. add,
  33838. this.proxyOf.nodes[existIndex],
  33839. type
  33840. ).reverse();
  33841. existIndex = this.index(exist);
  33842. for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
  33843. let index;
  33844. for (let id in this.indexes) {
  33845. index = this.indexes[id];
  33846. if (existIndex <= index) {
  33847. this.indexes[id] = index + nodes.length;
  33848. }
  33849. }
  33850. this.markDirty();
  33851. return this
  33852. }
  33853. normalize(nodes, sample) {
  33854. if (typeof nodes === 'string') {
  33855. nodes = cleanSource(parse(nodes).nodes);
  33856. } else if (typeof nodes === 'undefined') {
  33857. nodes = [];
  33858. } else if (Array.isArray(nodes)) {
  33859. nodes = nodes.slice(0);
  33860. for (let i of nodes) {
  33861. if (i.parent) i.parent.removeChild(i, 'ignore');
  33862. }
  33863. } else if (nodes.type === 'root' && this.type !== 'document') {
  33864. nodes = nodes.nodes.slice(0);
  33865. for (let i of nodes) {
  33866. if (i.parent) i.parent.removeChild(i, 'ignore');
  33867. }
  33868. } else if (nodes.type) {
  33869. nodes = [nodes];
  33870. } else if (nodes.prop) {
  33871. if (typeof nodes.value === 'undefined') {
  33872. throw new Error('Value field is missed in node creation')
  33873. } else if (typeof nodes.value !== 'string') {
  33874. nodes.value = String(nodes.value);
  33875. }
  33876. nodes = [new Declaration(nodes)];
  33877. } else if (nodes.selector || nodes.selectors) {
  33878. nodes = [new Rule(nodes)];
  33879. } else if (nodes.name) {
  33880. nodes = [new AtRule(nodes)];
  33881. } else if (nodes.text) {
  33882. nodes = [new Comment(nodes)];
  33883. } else {
  33884. throw new Error('Unknown node type in node creation')
  33885. }
  33886. let processed = nodes.map(i => {
  33887. /* c8 ignore next */
  33888. if (!i[my]) Container.rebuild(i);
  33889. i = i.proxyOf;
  33890. if (i.parent) i.parent.removeChild(i);
  33891. if (i[isClean]) markTreeDirty(i);
  33892. if (!i.raws) i.raws = {};
  33893. if (typeof i.raws.before === 'undefined') {
  33894. if (sample && typeof sample.raws.before !== 'undefined') {
  33895. i.raws.before = sample.raws.before.replace(/\S/g, '');
  33896. }
  33897. }
  33898. i.parent = this.proxyOf;
  33899. return i
  33900. });
  33901. return processed
  33902. }
  33903. prepend(...children) {
  33904. children = children.reverse();
  33905. for (let child of children) {
  33906. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  33907. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  33908. for (let id in this.indexes) {
  33909. this.indexes[id] = this.indexes[id] + nodes.length;
  33910. }
  33911. }
  33912. this.markDirty();
  33913. return this
  33914. }
  33915. push(child) {
  33916. child.parent = this;
  33917. this.proxyOf.nodes.push(child);
  33918. return this
  33919. }
  33920. removeAll() {
  33921. for (let node of this.proxyOf.nodes) node.parent = undefined;
  33922. this.proxyOf.nodes = [];
  33923. this.markDirty();
  33924. return this
  33925. }
  33926. removeChild(child) {
  33927. child = this.index(child);
  33928. this.proxyOf.nodes[child].parent = undefined;
  33929. this.proxyOf.nodes.splice(child, 1);
  33930. let index;
  33931. for (let id in this.indexes) {
  33932. index = this.indexes[id];
  33933. if (index >= child) {
  33934. this.indexes[id] = index - 1;
  33935. }
  33936. }
  33937. this.markDirty();
  33938. return this
  33939. }
  33940. replaceValues(pattern, opts, callback) {
  33941. if (!callback) {
  33942. callback = opts;
  33943. opts = {};
  33944. }
  33945. this.walkDecls(decl => {
  33946. if (opts.props && !opts.props.includes(decl.prop)) return
  33947. if (opts.fast && !decl.value.includes(opts.fast)) return
  33948. decl.value = decl.value.replace(pattern, callback);
  33949. });
  33950. this.markDirty();
  33951. return this
  33952. }
  33953. some(condition) {
  33954. return this.nodes.some(condition)
  33955. }
  33956. walk(callback) {
  33957. return this.each((child, i) => {
  33958. let result;
  33959. try {
  33960. result = callback(child, i);
  33961. } catch (e) {
  33962. throw child.addToError(e)
  33963. }
  33964. if (result !== false && child.walk) {
  33965. result = child.walk(callback);
  33966. }
  33967. return result
  33968. })
  33969. }
  33970. walkAtRules(name, callback) {
  33971. if (!callback) {
  33972. callback = name;
  33973. return this.walk((child, i) => {
  33974. if (child.type === 'atrule') {
  33975. return callback(child, i)
  33976. }
  33977. })
  33978. }
  33979. if (name instanceof RegExp) {
  33980. return this.walk((child, i) => {
  33981. if (child.type === 'atrule' && name.test(child.name)) {
  33982. return callback(child, i)
  33983. }
  33984. })
  33985. }
  33986. return this.walk((child, i) => {
  33987. if (child.type === 'atrule' && child.name === name) {
  33988. return callback(child, i)
  33989. }
  33990. })
  33991. }
  33992. walkComments(callback) {
  33993. return this.walk((child, i) => {
  33994. if (child.type === 'comment') {
  33995. return callback(child, i)
  33996. }
  33997. })
  33998. }
  33999. walkDecls(prop, callback) {
  34000. if (!callback) {
  34001. callback = prop;
  34002. return this.walk((child, i) => {
  34003. if (child.type === 'decl') {
  34004. return callback(child, i)
  34005. }
  34006. })
  34007. }
  34008. if (prop instanceof RegExp) {
  34009. return this.walk((child, i) => {
  34010. if (child.type === 'decl' && prop.test(child.prop)) {
  34011. return callback(child, i)
  34012. }
  34013. })
  34014. }
  34015. return this.walk((child, i) => {
  34016. if (child.type === 'decl' && child.prop === prop) {
  34017. return callback(child, i)
  34018. }
  34019. })
  34020. }
  34021. walkRules(selector, callback) {
  34022. if (!callback) {
  34023. callback = selector;
  34024. return this.walk((child, i) => {
  34025. if (child.type === 'rule') {
  34026. return callback(child, i)
  34027. }
  34028. })
  34029. }
  34030. if (selector instanceof RegExp) {
  34031. return this.walk((child, i) => {
  34032. if (child.type === 'rule' && selector.test(child.selector)) {
  34033. return callback(child, i)
  34034. }
  34035. })
  34036. }
  34037. return this.walk((child, i) => {
  34038. if (child.type === 'rule' && child.selector === selector) {
  34039. return callback(child, i)
  34040. }
  34041. })
  34042. }
  34043. }
  34044. Container.registerParse = dependant => {
  34045. parse = dependant;
  34046. };
  34047. Container.registerRule = dependant => {
  34048. Rule = dependant;
  34049. };
  34050. Container.registerAtRule = dependant => {
  34051. AtRule = dependant;
  34052. };
  34053. Container.registerRoot = dependant => {
  34054. Root = dependant;
  34055. };
  34056. container$1 = Container;
  34057. Container.default = Container;
  34058. /* c8 ignore start */
  34059. Container.rebuild = node => {
  34060. if (node.type === 'atrule') {
  34061. Object.setPrototypeOf(node, AtRule.prototype);
  34062. } else if (node.type === 'rule') {
  34063. Object.setPrototypeOf(node, Rule.prototype);
  34064. } else if (node.type === 'decl') {
  34065. Object.setPrototypeOf(node, Declaration.prototype);
  34066. } else if (node.type === 'comment') {
  34067. Object.setPrototypeOf(node, Comment.prototype);
  34068. } else if (node.type === 'root') {
  34069. Object.setPrototypeOf(node, Root.prototype);
  34070. }
  34071. node[my] = true;
  34072. if (node.nodes) {
  34073. node.nodes.forEach(child => {
  34074. Container.rebuild(child);
  34075. });
  34076. }
  34077. };
  34078. /* c8 ignore stop */
  34079. return container$1;
  34080. }
  34081. var atRule;
  34082. var hasRequiredAtRule;
  34083. function requireAtRule () {
  34084. if (hasRequiredAtRule) return atRule;
  34085. hasRequiredAtRule = 1;
  34086. let Container = /*@__PURE__*/ requireContainer$1();
  34087. class AtRule extends Container {
  34088. constructor(defaults) {
  34089. super(defaults);
  34090. this.type = 'atrule';
  34091. }
  34092. append(...children) {
  34093. if (!this.proxyOf.nodes) this.nodes = [];
  34094. return super.append(...children)
  34095. }
  34096. prepend(...children) {
  34097. if (!this.proxyOf.nodes) this.nodes = [];
  34098. return super.prepend(...children)
  34099. }
  34100. }
  34101. atRule = AtRule;
  34102. AtRule.default = AtRule;
  34103. Container.registerAtRule(AtRule);
  34104. return atRule;
  34105. }
  34106. var document;
  34107. var hasRequiredDocument;
  34108. function requireDocument () {
  34109. if (hasRequiredDocument) return document;
  34110. hasRequiredDocument = 1;
  34111. let Container = /*@__PURE__*/ requireContainer$1();
  34112. let LazyResult, Processor;
  34113. class Document extends Container {
  34114. constructor(defaults) {
  34115. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  34116. super({ type: 'document', ...defaults });
  34117. if (!this.nodes) {
  34118. this.nodes = [];
  34119. }
  34120. }
  34121. toResult(opts = {}) {
  34122. let lazy = new LazyResult(new Processor(), this, opts);
  34123. return lazy.stringify()
  34124. }
  34125. }
  34126. Document.registerLazyResult = dependant => {
  34127. LazyResult = dependant;
  34128. };
  34129. Document.registerProcessor = dependant => {
  34130. Processor = dependant;
  34131. };
  34132. document = Document;
  34133. Document.default = Document;
  34134. return document;
  34135. }
  34136. var nonSecure;
  34137. var hasRequiredNonSecure;
  34138. function requireNonSecure () {
  34139. if (hasRequiredNonSecure) return nonSecure;
  34140. hasRequiredNonSecure = 1;
  34141. // This alphabet uses `A-Za-z0-9_-` symbols.
  34142. // The order of characters is optimized for better gzip and brotli compression.
  34143. // References to the same file (works both for gzip and brotli):
  34144. // `'use`, `andom`, and `rict'`
  34145. // References to the brotli default dictionary:
  34146. // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
  34147. let urlAlphabet =
  34148. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
  34149. let customAlphabet = (alphabet, defaultSize = 21) => {
  34150. return (size = defaultSize) => {
  34151. let id = '';
  34152. // A compact alternative for `for (var i = 0; i < step; i++)`.
  34153. let i = size | 0;
  34154. while (i--) {
  34155. // `| 0` is more compact and faster than `Math.floor()`.
  34156. id += alphabet[(Math.random() * alphabet.length) | 0];
  34157. }
  34158. return id
  34159. }
  34160. };
  34161. let nanoid = (size = 21) => {
  34162. let id = '';
  34163. // A compact alternative for `for (var i = 0; i < step; i++)`.
  34164. let i = size | 0;
  34165. while (i--) {
  34166. // `| 0` is more compact and faster than `Math.floor()`.
  34167. id += urlAlphabet[(Math.random() * 64) | 0];
  34168. }
  34169. return id
  34170. };
  34171. nonSecure = { nanoid, customAlphabet };
  34172. return nonSecure;
  34173. }
  34174. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  34175. var previousMap;
  34176. var hasRequiredPreviousMap;
  34177. function requirePreviousMap () {
  34178. if (hasRequiredPreviousMap) return previousMap;
  34179. hasRequiredPreviousMap = 1;
  34180. let { existsSync, readFileSync } = require$$0$1;
  34181. let { dirname, join } = require$$1;
  34182. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  34183. function fromBase64(str) {
  34184. if (Buffer$1) {
  34185. return Buffer$1.from(str, 'base64').toString()
  34186. } else {
  34187. /* c8 ignore next 2 */
  34188. return window.atob(str)
  34189. }
  34190. }
  34191. class PreviousMap {
  34192. constructor(css, opts) {
  34193. if (opts.map === false) return
  34194. this.loadAnnotation(css);
  34195. this.inline = this.startWith(this.annotation, 'data:');
  34196. let prev = opts.map ? opts.map.prev : undefined;
  34197. let text = this.loadMap(opts.from, prev);
  34198. if (!this.mapFile && opts.from) {
  34199. this.mapFile = opts.from;
  34200. }
  34201. if (this.mapFile) this.root = dirname(this.mapFile);
  34202. if (text) this.text = text;
  34203. }
  34204. consumer() {
  34205. if (!this.consumerCache) {
  34206. this.consumerCache = new SourceMapConsumer(this.text);
  34207. }
  34208. return this.consumerCache
  34209. }
  34210. decodeInline(text) {
  34211. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  34212. let baseUri = /^data:application\/json;base64,/;
  34213. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  34214. let uri = /^data:application\/json,/;
  34215. let uriMatch = text.match(charsetUri) || text.match(uri);
  34216. if (uriMatch) {
  34217. return decodeURIComponent(text.substr(uriMatch[0].length))
  34218. }
  34219. let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
  34220. if (baseUriMatch) {
  34221. return fromBase64(text.substr(baseUriMatch[0].length))
  34222. }
  34223. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  34224. throw new Error('Unsupported source map encoding ' + encoding)
  34225. }
  34226. getAnnotationURL(sourceMapString) {
  34227. return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
  34228. }
  34229. isMap(map) {
  34230. if (typeof map !== 'object') return false
  34231. return (
  34232. typeof map.mappings === 'string' ||
  34233. typeof map._mappings === 'string' ||
  34234. Array.isArray(map.sections)
  34235. )
  34236. }
  34237. loadAnnotation(css) {
  34238. let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
  34239. if (!comments) return
  34240. // sourceMappingURLs from comments, strings, etc.
  34241. let start = css.lastIndexOf(comments.pop());
  34242. let end = css.indexOf('*/', start);
  34243. if (start > -1 && end > -1) {
  34244. // Locate the last sourceMappingURL to avoid pickin
  34245. this.annotation = this.getAnnotationURL(css.substring(start, end));
  34246. }
  34247. }
  34248. loadFile(path) {
  34249. this.root = dirname(path);
  34250. if (existsSync(path)) {
  34251. this.mapFile = path;
  34252. return readFileSync(path, 'utf-8').toString().trim()
  34253. }
  34254. }
  34255. loadMap(file, prev) {
  34256. if (prev === false) return false
  34257. if (prev) {
  34258. if (typeof prev === 'string') {
  34259. return prev
  34260. } else if (typeof prev === 'function') {
  34261. let prevPath = prev(file);
  34262. if (prevPath) {
  34263. let map = this.loadFile(prevPath);
  34264. if (!map) {
  34265. throw new Error(
  34266. 'Unable to load previous source map: ' + prevPath.toString()
  34267. )
  34268. }
  34269. return map
  34270. }
  34271. } else if (prev instanceof SourceMapConsumer) {
  34272. return SourceMapGenerator.fromSourceMap(prev).toString()
  34273. } else if (prev instanceof SourceMapGenerator) {
  34274. return prev.toString()
  34275. } else if (this.isMap(prev)) {
  34276. return JSON.stringify(prev)
  34277. } else {
  34278. throw new Error(
  34279. 'Unsupported previous source map format: ' + prev.toString()
  34280. )
  34281. }
  34282. } else if (this.inline) {
  34283. return this.decodeInline(this.annotation)
  34284. } else if (this.annotation) {
  34285. let map = this.annotation;
  34286. if (file) map = join(dirname(file), map);
  34287. return this.loadFile(map)
  34288. }
  34289. }
  34290. startWith(string, start) {
  34291. if (!string) return false
  34292. return string.substr(0, start.length) === start
  34293. }
  34294. withContent() {
  34295. return !!(
  34296. this.consumer().sourcesContent &&
  34297. this.consumer().sourcesContent.length > 0
  34298. )
  34299. }
  34300. }
  34301. previousMap = PreviousMap;
  34302. PreviousMap.default = PreviousMap;
  34303. return previousMap;
  34304. }
  34305. var input;
  34306. var hasRequiredInput;
  34307. function requireInput () {
  34308. if (hasRequiredInput) return input;
  34309. hasRequiredInput = 1;
  34310. let { nanoid } = /*@__PURE__*/ requireNonSecure();
  34311. let { isAbsolute, resolve } = require$$1;
  34312. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  34313. let { fileURLToPath, pathToFileURL } = require$$2;
  34314. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  34315. let PreviousMap = /*@__PURE__*/ requirePreviousMap();
  34316. let terminalHighlight = /*@__PURE__*/ requireTerminalHighlight();
  34317. let lineToIndexCache = Symbol('lineToIndexCache');
  34318. let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
  34319. let pathAvailable = Boolean(resolve && isAbsolute);
  34320. function getLineToIndex(input) {
  34321. if (input[lineToIndexCache]) return input[lineToIndexCache]
  34322. let lines = input.css.split('\n');
  34323. let lineToIndex = new Array(lines.length);
  34324. let prevIndex = 0;
  34325. for (let i = 0, l = lines.length; i < l; i++) {
  34326. lineToIndex[i] = prevIndex;
  34327. prevIndex += lines[i].length + 1;
  34328. }
  34329. input[lineToIndexCache] = lineToIndex;
  34330. return lineToIndex
  34331. }
  34332. class Input {
  34333. get from() {
  34334. return this.file || this.id
  34335. }
  34336. constructor(css, opts = {}) {
  34337. if (
  34338. css === null ||
  34339. typeof css === 'undefined' ||
  34340. (typeof css === 'object' && !css.toString)
  34341. ) {
  34342. throw new Error(`PostCSS received ${css} instead of CSS string`)
  34343. }
  34344. this.css = css.toString();
  34345. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  34346. this.hasBOM = true;
  34347. this.css = this.css.slice(1);
  34348. } else {
  34349. this.hasBOM = false;
  34350. }
  34351. this.document = this.css;
  34352. if (opts.document) this.document = opts.document.toString();
  34353. if (opts.from) {
  34354. if (
  34355. !pathAvailable ||
  34356. /^\w+:\/\//.test(opts.from) ||
  34357. isAbsolute(opts.from)
  34358. ) {
  34359. this.file = opts.from;
  34360. } else {
  34361. this.file = resolve(opts.from);
  34362. }
  34363. }
  34364. if (pathAvailable && sourceMapAvailable) {
  34365. let map = new PreviousMap(this.css, opts);
  34366. if (map.text) {
  34367. this.map = map;
  34368. let file = map.consumer().file;
  34369. if (!this.file && file) this.file = this.mapResolve(file);
  34370. }
  34371. }
  34372. if (!this.file) {
  34373. this.id = '<input css ' + nanoid(6) + '>';
  34374. }
  34375. if (this.map) this.map.file = this.from;
  34376. }
  34377. error(message, line, column, opts = {}) {
  34378. let endColumn, endLine, endOffset, offset, result;
  34379. if (line && typeof line === 'object') {
  34380. let start = line;
  34381. let end = column;
  34382. if (typeof start.offset === 'number') {
  34383. offset = start.offset;
  34384. let pos = this.fromOffset(offset);
  34385. line = pos.line;
  34386. column = pos.col;
  34387. } else {
  34388. line = start.line;
  34389. column = start.column;
  34390. offset = this.fromLineAndColumn(line, column);
  34391. }
  34392. if (typeof end.offset === 'number') {
  34393. endOffset = end.offset;
  34394. let pos = this.fromOffset(endOffset);
  34395. endLine = pos.line;
  34396. endColumn = pos.col;
  34397. } else {
  34398. endLine = end.line;
  34399. endColumn = end.column;
  34400. endOffset = this.fromLineAndColumn(end.line, end.column);
  34401. }
  34402. } else if (!column) {
  34403. offset = line;
  34404. let pos = this.fromOffset(offset);
  34405. line = pos.line;
  34406. column = pos.col;
  34407. } else {
  34408. offset = this.fromLineAndColumn(line, column);
  34409. }
  34410. let origin = this.origin(line, column, endLine, endColumn);
  34411. if (origin) {
  34412. result = new CssSyntaxError(
  34413. message,
  34414. origin.endLine === undefined
  34415. ? origin.line
  34416. : { column: origin.column, line: origin.line },
  34417. origin.endLine === undefined
  34418. ? origin.column
  34419. : { column: origin.endColumn, line: origin.endLine },
  34420. origin.source,
  34421. origin.file,
  34422. opts.plugin
  34423. );
  34424. } else {
  34425. result = new CssSyntaxError(
  34426. message,
  34427. endLine === undefined ? line : { column, line },
  34428. endLine === undefined ? column : { column: endColumn, line: endLine },
  34429. this.css,
  34430. this.file,
  34431. opts.plugin
  34432. );
  34433. }
  34434. result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
  34435. if (this.file) {
  34436. if (pathToFileURL) {
  34437. result.input.url = pathToFileURL(this.file).toString();
  34438. }
  34439. result.input.file = this.file;
  34440. }
  34441. return result
  34442. }
  34443. fromLineAndColumn(line, column) {
  34444. let lineToIndex = getLineToIndex(this);
  34445. let index = lineToIndex[line - 1];
  34446. return index + column - 1
  34447. }
  34448. fromOffset(offset) {
  34449. let lineToIndex = getLineToIndex(this);
  34450. let lastLine = lineToIndex[lineToIndex.length - 1];
  34451. let min = 0;
  34452. if (offset >= lastLine) {
  34453. min = lineToIndex.length - 1;
  34454. } else {
  34455. let max = lineToIndex.length - 2;
  34456. let mid;
  34457. while (min < max) {
  34458. mid = min + ((max - min) >> 1);
  34459. if (offset < lineToIndex[mid]) {
  34460. max = mid - 1;
  34461. } else if (offset >= lineToIndex[mid + 1]) {
  34462. min = mid + 1;
  34463. } else {
  34464. min = mid;
  34465. break
  34466. }
  34467. }
  34468. }
  34469. return {
  34470. col: offset - lineToIndex[min] + 1,
  34471. line: min + 1
  34472. }
  34473. }
  34474. mapResolve(file) {
  34475. if (/^\w+:\/\//.test(file)) {
  34476. return file
  34477. }
  34478. return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
  34479. }
  34480. origin(line, column, endLine, endColumn) {
  34481. if (!this.map) return false
  34482. let consumer = this.map.consumer();
  34483. let from = consumer.originalPositionFor({ column, line });
  34484. if (!from.source) return false
  34485. let to;
  34486. if (typeof endLine === 'number') {
  34487. to = consumer.originalPositionFor({ column: endColumn, line: endLine });
  34488. }
  34489. let fromUrl;
  34490. if (isAbsolute(from.source)) {
  34491. fromUrl = pathToFileURL(from.source);
  34492. } else {
  34493. fromUrl = new URL(
  34494. from.source,
  34495. this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
  34496. );
  34497. }
  34498. let result = {
  34499. column: from.column,
  34500. endColumn: to && to.column,
  34501. endLine: to && to.line,
  34502. line: from.line,
  34503. url: fromUrl.toString()
  34504. };
  34505. if (fromUrl.protocol === 'file:') {
  34506. if (fileURLToPath) {
  34507. result.file = fileURLToPath(fromUrl);
  34508. } else {
  34509. /* c8 ignore next 2 */
  34510. throw new Error(`file: protocol is not available in this PostCSS build`)
  34511. }
  34512. }
  34513. let source = consumer.sourceContentFor(from.source);
  34514. if (source) result.source = source;
  34515. return result
  34516. }
  34517. toJSON() {
  34518. let json = {};
  34519. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  34520. if (this[name] != null) {
  34521. json[name] = this[name];
  34522. }
  34523. }
  34524. if (this.map) {
  34525. json.map = { ...this.map };
  34526. if (json.map.consumerCache) {
  34527. json.map.consumerCache = undefined;
  34528. }
  34529. }
  34530. return json
  34531. }
  34532. }
  34533. input = Input;
  34534. Input.default = Input;
  34535. if (terminalHighlight && terminalHighlight.registerInput) {
  34536. terminalHighlight.registerInput(Input);
  34537. }
  34538. return input;
  34539. }
  34540. var root$1;
  34541. var hasRequiredRoot$1;
  34542. function requireRoot$1 () {
  34543. if (hasRequiredRoot$1) return root$1;
  34544. hasRequiredRoot$1 = 1;
  34545. let Container = /*@__PURE__*/ requireContainer$1();
  34546. let LazyResult, Processor;
  34547. class Root extends Container {
  34548. constructor(defaults) {
  34549. super(defaults);
  34550. this.type = 'root';
  34551. if (!this.nodes) this.nodes = [];
  34552. }
  34553. normalize(child, sample, type) {
  34554. let nodes = super.normalize(child);
  34555. if (sample) {
  34556. if (type === 'prepend') {
  34557. if (this.nodes.length > 1) {
  34558. sample.raws.before = this.nodes[1].raws.before;
  34559. } else {
  34560. delete sample.raws.before;
  34561. }
  34562. } else if (this.first !== sample) {
  34563. for (let node of nodes) {
  34564. node.raws.before = sample.raws.before;
  34565. }
  34566. }
  34567. }
  34568. return nodes
  34569. }
  34570. removeChild(child, ignore) {
  34571. let index = this.index(child);
  34572. if (!ignore && index === 0 && this.nodes.length > 1) {
  34573. this.nodes[1].raws.before = this.nodes[index].raws.before;
  34574. }
  34575. return super.removeChild(child)
  34576. }
  34577. toResult(opts = {}) {
  34578. let lazy = new LazyResult(new Processor(), this, opts);
  34579. return lazy.stringify()
  34580. }
  34581. }
  34582. Root.registerLazyResult = dependant => {
  34583. LazyResult = dependant;
  34584. };
  34585. Root.registerProcessor = dependant => {
  34586. Processor = dependant;
  34587. };
  34588. root$1 = Root;
  34589. Root.default = Root;
  34590. Container.registerRoot(Root);
  34591. return root$1;
  34592. }
  34593. var list_1;
  34594. var hasRequiredList;
  34595. function requireList () {
  34596. if (hasRequiredList) return list_1;
  34597. hasRequiredList = 1;
  34598. let list = {
  34599. comma(string) {
  34600. return list.split(string, [','], true)
  34601. },
  34602. space(string) {
  34603. let spaces = [' ', '\n', '\t'];
  34604. return list.split(string, spaces)
  34605. },
  34606. split(string, separators, last) {
  34607. let array = [];
  34608. let current = '';
  34609. let split = false;
  34610. let func = 0;
  34611. let inQuote = false;
  34612. let prevQuote = '';
  34613. let escape = false;
  34614. for (let letter of string) {
  34615. if (escape) {
  34616. escape = false;
  34617. } else if (letter === '\\') {
  34618. escape = true;
  34619. } else if (inQuote) {
  34620. if (letter === prevQuote) {
  34621. inQuote = false;
  34622. }
  34623. } else if (letter === '"' || letter === "'") {
  34624. inQuote = true;
  34625. prevQuote = letter;
  34626. } else if (letter === '(') {
  34627. func += 1;
  34628. } else if (letter === ')') {
  34629. if (func > 0) func -= 1;
  34630. } else if (func === 0) {
  34631. if (separators.includes(letter)) split = true;
  34632. }
  34633. if (split) {
  34634. if (current !== '') array.push(current.trim());
  34635. current = '';
  34636. split = false;
  34637. } else {
  34638. current += letter;
  34639. }
  34640. }
  34641. if (last || current !== '') array.push(current.trim());
  34642. return array
  34643. }
  34644. };
  34645. list_1 = list;
  34646. list.default = list;
  34647. return list_1;
  34648. }
  34649. var rule;
  34650. var hasRequiredRule;
  34651. function requireRule () {
  34652. if (hasRequiredRule) return rule;
  34653. hasRequiredRule = 1;
  34654. let Container = /*@__PURE__*/ requireContainer$1();
  34655. let list = /*@__PURE__*/ requireList();
  34656. class Rule extends Container {
  34657. get selectors() {
  34658. return list.comma(this.selector)
  34659. }
  34660. set selectors(values) {
  34661. let match = this.selector ? this.selector.match(/,\s*/) : null;
  34662. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  34663. this.selector = values.join(sep);
  34664. }
  34665. constructor(defaults) {
  34666. super(defaults);
  34667. this.type = 'rule';
  34668. if (!this.nodes) this.nodes = [];
  34669. }
  34670. }
  34671. rule = Rule;
  34672. Rule.default = Rule;
  34673. Container.registerRule(Rule);
  34674. return rule;
  34675. }
  34676. var fromJSON_1;
  34677. var hasRequiredFromJSON;
  34678. function requireFromJSON () {
  34679. if (hasRequiredFromJSON) return fromJSON_1;
  34680. hasRequiredFromJSON = 1;
  34681. let AtRule = /*@__PURE__*/ requireAtRule();
  34682. let Comment = /*@__PURE__*/ requireComment$1();
  34683. let Declaration = /*@__PURE__*/ requireDeclaration();
  34684. let Input = /*@__PURE__*/ requireInput();
  34685. let PreviousMap = /*@__PURE__*/ requirePreviousMap();
  34686. let Root = /*@__PURE__*/ requireRoot$1();
  34687. let Rule = /*@__PURE__*/ requireRule();
  34688. function fromJSON(json, inputs) {
  34689. if (Array.isArray(json)) return json.map(n => fromJSON(n))
  34690. let { inputs: ownInputs, ...defaults } = json;
  34691. if (ownInputs) {
  34692. inputs = [];
  34693. for (let input of ownInputs) {
  34694. let inputHydrated = { ...input, __proto__: Input.prototype };
  34695. if (inputHydrated.map) {
  34696. inputHydrated.map = {
  34697. ...inputHydrated.map,
  34698. __proto__: PreviousMap.prototype
  34699. };
  34700. }
  34701. inputs.push(inputHydrated);
  34702. }
  34703. }
  34704. if (defaults.nodes) {
  34705. defaults.nodes = json.nodes.map(n => fromJSON(n, inputs));
  34706. }
  34707. if (defaults.source) {
  34708. let { inputId, ...source } = defaults.source;
  34709. defaults.source = source;
  34710. if (inputId != null) {
  34711. defaults.source.input = inputs[inputId];
  34712. }
  34713. }
  34714. if (defaults.type === 'root') {
  34715. return new Root(defaults)
  34716. } else if (defaults.type === 'decl') {
  34717. return new Declaration(defaults)
  34718. } else if (defaults.type === 'rule') {
  34719. return new Rule(defaults)
  34720. } else if (defaults.type === 'comment') {
  34721. return new Comment(defaults)
  34722. } else if (defaults.type === 'atrule') {
  34723. return new AtRule(defaults)
  34724. } else {
  34725. throw new Error('Unknown node type: ' + json.type)
  34726. }
  34727. }
  34728. fromJSON_1 = fromJSON;
  34729. fromJSON.default = fromJSON;
  34730. return fromJSON_1;
  34731. }
  34732. var mapGenerator;
  34733. var hasRequiredMapGenerator;
  34734. function requireMapGenerator () {
  34735. if (hasRequiredMapGenerator) return mapGenerator;
  34736. hasRequiredMapGenerator = 1;
  34737. let { dirname, relative, resolve, sep } = require$$1;
  34738. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  34739. let { pathToFileURL } = require$$2;
  34740. let Input = /*@__PURE__*/ requireInput();
  34741. let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
  34742. let pathAvailable = Boolean(dirname && resolve && relative && sep);
  34743. class MapGenerator {
  34744. constructor(stringify, root, opts, cssString) {
  34745. this.stringify = stringify;
  34746. this.mapOpts = opts.map || {};
  34747. this.root = root;
  34748. this.opts = opts;
  34749. this.css = cssString;
  34750. this.originalCSS = cssString;
  34751. this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
  34752. this.memoizedFileURLs = new Map();
  34753. this.memoizedPaths = new Map();
  34754. this.memoizedURLs = new Map();
  34755. }
  34756. addAnnotation() {
  34757. let content;
  34758. if (this.isInline()) {
  34759. content =
  34760. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  34761. } else if (typeof this.mapOpts.annotation === 'string') {
  34762. content = this.mapOpts.annotation;
  34763. } else if (typeof this.mapOpts.annotation === 'function') {
  34764. content = this.mapOpts.annotation(this.opts.to, this.root);
  34765. } else {
  34766. content = this.outputFile() + '.map';
  34767. }
  34768. let eol = '\n';
  34769. if (this.css.includes('\r\n')) eol = '\r\n';
  34770. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  34771. }
  34772. applyPrevMaps() {
  34773. for (let prev of this.previous()) {
  34774. let from = this.toUrl(this.path(prev.file));
  34775. let root = prev.root || dirname(prev.file);
  34776. let map;
  34777. if (this.mapOpts.sourcesContent === false) {
  34778. map = new SourceMapConsumer(prev.text);
  34779. if (map.sourcesContent) {
  34780. map.sourcesContent = null;
  34781. }
  34782. } else {
  34783. map = prev.consumer();
  34784. }
  34785. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  34786. }
  34787. }
  34788. clearAnnotation() {
  34789. if (this.mapOpts.annotation === false) return
  34790. if (this.root) {
  34791. let node;
  34792. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  34793. node = this.root.nodes[i];
  34794. if (node.type !== 'comment') continue
  34795. if (node.text.startsWith('# sourceMappingURL=')) {
  34796. this.root.removeChild(i);
  34797. }
  34798. }
  34799. } else if (this.css) {
  34800. this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
  34801. }
  34802. }
  34803. generate() {
  34804. this.clearAnnotation();
  34805. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  34806. return this.generateMap()
  34807. } else {
  34808. let result = '';
  34809. this.stringify(this.root, i => {
  34810. result += i;
  34811. });
  34812. return [result]
  34813. }
  34814. }
  34815. generateMap() {
  34816. if (this.root) {
  34817. this.generateString();
  34818. } else if (this.previous().length === 1) {
  34819. let prev = this.previous()[0].consumer();
  34820. prev.file = this.outputFile();
  34821. this.map = SourceMapGenerator.fromSourceMap(prev, {
  34822. ignoreInvalidMapping: true
  34823. });
  34824. } else {
  34825. this.map = new SourceMapGenerator({
  34826. file: this.outputFile(),
  34827. ignoreInvalidMapping: true
  34828. });
  34829. this.map.addMapping({
  34830. generated: { column: 0, line: 1 },
  34831. original: { column: 0, line: 1 },
  34832. source: this.opts.from
  34833. ? this.toUrl(this.path(this.opts.from))
  34834. : '<no source>'
  34835. });
  34836. }
  34837. if (this.isSourcesContent()) this.setSourcesContent();
  34838. if (this.root && this.previous().length > 0) this.applyPrevMaps();
  34839. if (this.isAnnotation()) this.addAnnotation();
  34840. if (this.isInline()) {
  34841. return [this.css]
  34842. } else {
  34843. return [this.css, this.map]
  34844. }
  34845. }
  34846. generateString() {
  34847. this.css = '';
  34848. this.map = new SourceMapGenerator({
  34849. file: this.outputFile(),
  34850. ignoreInvalidMapping: true
  34851. });
  34852. let line = 1;
  34853. let column = 1;
  34854. let noSource = '<no source>';
  34855. let mapping = {
  34856. generated: { column: 0, line: 0 },
  34857. original: { column: 0, line: 0 },
  34858. source: ''
  34859. };
  34860. let last, lines;
  34861. this.stringify(this.root, (str, node, type) => {
  34862. this.css += str;
  34863. if (node && type !== 'end') {
  34864. mapping.generated.line = line;
  34865. mapping.generated.column = column - 1;
  34866. if (node.source && node.source.start) {
  34867. mapping.source = this.sourcePath(node);
  34868. mapping.original.line = node.source.start.line;
  34869. mapping.original.column = node.source.start.column - 1;
  34870. this.map.addMapping(mapping);
  34871. } else {
  34872. mapping.source = noSource;
  34873. mapping.original.line = 1;
  34874. mapping.original.column = 0;
  34875. this.map.addMapping(mapping);
  34876. }
  34877. }
  34878. lines = str.match(/\n/g);
  34879. if (lines) {
  34880. line += lines.length;
  34881. last = str.lastIndexOf('\n');
  34882. column = str.length - last;
  34883. } else {
  34884. column += str.length;
  34885. }
  34886. if (node && type !== 'start') {
  34887. let p = node.parent || { raws: {} };
  34888. let childless =
  34889. node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
  34890. if (!childless || node !== p.last || p.raws.semicolon) {
  34891. if (node.source && node.source.end) {
  34892. mapping.source = this.sourcePath(node);
  34893. mapping.original.line = node.source.end.line;
  34894. mapping.original.column = node.source.end.column - 1;
  34895. mapping.generated.line = line;
  34896. mapping.generated.column = column - 2;
  34897. this.map.addMapping(mapping);
  34898. } else {
  34899. mapping.source = noSource;
  34900. mapping.original.line = 1;
  34901. mapping.original.column = 0;
  34902. mapping.generated.line = line;
  34903. mapping.generated.column = column - 1;
  34904. this.map.addMapping(mapping);
  34905. }
  34906. }
  34907. }
  34908. });
  34909. }
  34910. isAnnotation() {
  34911. if (this.isInline()) {
  34912. return true
  34913. }
  34914. if (typeof this.mapOpts.annotation !== 'undefined') {
  34915. return this.mapOpts.annotation
  34916. }
  34917. if (this.previous().length) {
  34918. return this.previous().some(i => i.annotation)
  34919. }
  34920. return true
  34921. }
  34922. isInline() {
  34923. if (typeof this.mapOpts.inline !== 'undefined') {
  34924. return this.mapOpts.inline
  34925. }
  34926. let annotation = this.mapOpts.annotation;
  34927. if (typeof annotation !== 'undefined' && annotation !== true) {
  34928. return false
  34929. }
  34930. if (this.previous().length) {
  34931. return this.previous().some(i => i.inline)
  34932. }
  34933. return true
  34934. }
  34935. isMap() {
  34936. if (typeof this.opts.map !== 'undefined') {
  34937. return !!this.opts.map
  34938. }
  34939. return this.previous().length > 0
  34940. }
  34941. isSourcesContent() {
  34942. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  34943. return this.mapOpts.sourcesContent
  34944. }
  34945. if (this.previous().length) {
  34946. return this.previous().some(i => i.withContent())
  34947. }
  34948. return true
  34949. }
  34950. outputFile() {
  34951. if (this.opts.to) {
  34952. return this.path(this.opts.to)
  34953. } else if (this.opts.from) {
  34954. return this.path(this.opts.from)
  34955. } else {
  34956. return 'to.css'
  34957. }
  34958. }
  34959. path(file) {
  34960. if (this.mapOpts.absolute) return file
  34961. if (file.charCodeAt(0) === 60 /* `<` */) return file
  34962. if (/^\w+:\/\//.test(file)) return file
  34963. let cached = this.memoizedPaths.get(file);
  34964. if (cached) return cached
  34965. let from = this.opts.to ? dirname(this.opts.to) : '.';
  34966. if (typeof this.mapOpts.annotation === 'string') {
  34967. from = dirname(resolve(from, this.mapOpts.annotation));
  34968. }
  34969. let path = relative(from, file);
  34970. this.memoizedPaths.set(file, path);
  34971. return path
  34972. }
  34973. previous() {
  34974. if (!this.previousMaps) {
  34975. this.previousMaps = [];
  34976. if (this.root) {
  34977. this.root.walk(node => {
  34978. if (node.source && node.source.input.map) {
  34979. let map = node.source.input.map;
  34980. if (!this.previousMaps.includes(map)) {
  34981. this.previousMaps.push(map);
  34982. }
  34983. }
  34984. });
  34985. } else {
  34986. let input = new Input(this.originalCSS, this.opts);
  34987. if (input.map) this.previousMaps.push(input.map);
  34988. }
  34989. }
  34990. return this.previousMaps
  34991. }
  34992. setSourcesContent() {
  34993. let already = {};
  34994. if (this.root) {
  34995. this.root.walk(node => {
  34996. if (node.source) {
  34997. let from = node.source.input.from;
  34998. if (from && !already[from]) {
  34999. already[from] = true;
  35000. let fromUrl = this.usesFileUrls
  35001. ? this.toFileUrl(from)
  35002. : this.toUrl(this.path(from));
  35003. this.map.setSourceContent(fromUrl, node.source.input.css);
  35004. }
  35005. }
  35006. });
  35007. } else if (this.css) {
  35008. let from = this.opts.from
  35009. ? this.toUrl(this.path(this.opts.from))
  35010. : '<no source>';
  35011. this.map.setSourceContent(from, this.css);
  35012. }
  35013. }
  35014. sourcePath(node) {
  35015. if (this.mapOpts.from) {
  35016. return this.toUrl(this.mapOpts.from)
  35017. } else if (this.usesFileUrls) {
  35018. return this.toFileUrl(node.source.input.from)
  35019. } else {
  35020. return this.toUrl(this.path(node.source.input.from))
  35021. }
  35022. }
  35023. toBase64(str) {
  35024. if (Buffer$1) {
  35025. return Buffer$1.from(str).toString('base64')
  35026. } else {
  35027. return window.btoa(unescape(encodeURIComponent(str)))
  35028. }
  35029. }
  35030. toFileUrl(path) {
  35031. let cached = this.memoizedFileURLs.get(path);
  35032. if (cached) return cached
  35033. if (pathToFileURL) {
  35034. let fileURL = pathToFileURL(path).toString();
  35035. this.memoizedFileURLs.set(path, fileURL);
  35036. return fileURL
  35037. } else {
  35038. throw new Error(
  35039. '`map.absolute` option is not available in this PostCSS build'
  35040. )
  35041. }
  35042. }
  35043. toUrl(path) {
  35044. let cached = this.memoizedURLs.get(path);
  35045. if (cached) return cached
  35046. if (sep === '\\') {
  35047. path = path.replace(/\\/g, '/');
  35048. }
  35049. let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
  35050. this.memoizedURLs.set(path, url);
  35051. return url
  35052. }
  35053. }
  35054. mapGenerator = MapGenerator;
  35055. return mapGenerator;
  35056. }
  35057. var parser$1;
  35058. var hasRequiredParser$1;
  35059. function requireParser$1 () {
  35060. if (hasRequiredParser$1) return parser$1;
  35061. hasRequiredParser$1 = 1;
  35062. let AtRule = /*@__PURE__*/ requireAtRule();
  35063. let Comment = /*@__PURE__*/ requireComment$1();
  35064. let Declaration = /*@__PURE__*/ requireDeclaration();
  35065. let Root = /*@__PURE__*/ requireRoot$1();
  35066. let Rule = /*@__PURE__*/ requireRule();
  35067. let tokenizer = /*@__PURE__*/ requireTokenize$1();
  35068. const SAFE_COMMENT_NEIGHBOR = {
  35069. empty: true,
  35070. space: true
  35071. };
  35072. function findLastWithPosition(tokens) {
  35073. for (let i = tokens.length - 1; i >= 0; i--) {
  35074. let token = tokens[i];
  35075. let pos = token[3] || token[2];
  35076. if (pos) return pos
  35077. }
  35078. }
  35079. class Parser {
  35080. constructor(input) {
  35081. this.input = input;
  35082. this.root = new Root();
  35083. this.current = this.root;
  35084. this.spaces = '';
  35085. this.semicolon = false;
  35086. this.createTokenizer();
  35087. this.root.source = { input, start: { column: 1, line: 1, offset: 0 } };
  35088. }
  35089. atrule(token) {
  35090. let node = new AtRule();
  35091. node.name = token[1].slice(1);
  35092. if (node.name === '') {
  35093. this.unnamedAtrule(node, token);
  35094. }
  35095. this.init(node, token[2]);
  35096. let type;
  35097. let prev;
  35098. let shift;
  35099. let last = false;
  35100. let open = false;
  35101. let params = [];
  35102. let brackets = [];
  35103. while (!this.tokenizer.endOfFile()) {
  35104. token = this.tokenizer.nextToken();
  35105. type = token[0];
  35106. if (type === '(' || type === '[') {
  35107. brackets.push(type === '(' ? ')' : ']');
  35108. } else if (type === '{' && brackets.length > 0) {
  35109. brackets.push('}');
  35110. } else if (type === brackets[brackets.length - 1]) {
  35111. brackets.pop();
  35112. }
  35113. if (brackets.length === 0) {
  35114. if (type === ';') {
  35115. node.source.end = this.getPosition(token[2]);
  35116. node.source.end.offset++;
  35117. this.semicolon = true;
  35118. break
  35119. } else if (type === '{') {
  35120. open = true;
  35121. break
  35122. } else if (type === '}') {
  35123. if (params.length > 0) {
  35124. shift = params.length - 1;
  35125. prev = params[shift];
  35126. while (prev && prev[0] === 'space') {
  35127. prev = params[--shift];
  35128. }
  35129. if (prev) {
  35130. node.source.end = this.getPosition(prev[3] || prev[2]);
  35131. node.source.end.offset++;
  35132. }
  35133. }
  35134. this.end(token);
  35135. break
  35136. } else {
  35137. params.push(token);
  35138. }
  35139. } else {
  35140. params.push(token);
  35141. }
  35142. if (this.tokenizer.endOfFile()) {
  35143. last = true;
  35144. break
  35145. }
  35146. }
  35147. node.raws.between = this.spacesAndCommentsFromEnd(params);
  35148. if (params.length) {
  35149. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  35150. this.raw(node, 'params', params);
  35151. if (last) {
  35152. token = params[params.length - 1];
  35153. node.source.end = this.getPosition(token[3] || token[2]);
  35154. node.source.end.offset++;
  35155. this.spaces = node.raws.between;
  35156. node.raws.between = '';
  35157. }
  35158. } else {
  35159. node.raws.afterName = '';
  35160. node.params = '';
  35161. }
  35162. if (open) {
  35163. node.nodes = [];
  35164. this.current = node;
  35165. }
  35166. }
  35167. checkMissedSemicolon(tokens) {
  35168. let colon = this.colon(tokens);
  35169. if (colon === false) return
  35170. let founded = 0;
  35171. let token;
  35172. for (let j = colon - 1; j >= 0; j--) {
  35173. token = tokens[j];
  35174. if (token[0] !== 'space') {
  35175. founded += 1;
  35176. if (founded === 2) break
  35177. }
  35178. }
  35179. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  35180. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  35181. // And because we need it after that one we do +1 to get the next one.
  35182. throw this.input.error(
  35183. 'Missed semicolon',
  35184. token[0] === 'word' ? token[3] + 1 : token[2]
  35185. )
  35186. }
  35187. colon(tokens) {
  35188. let brackets = 0;
  35189. let prev, token, type;
  35190. for (let [i, element] of tokens.entries()) {
  35191. token = element;
  35192. type = token[0];
  35193. if (type === '(') {
  35194. brackets += 1;
  35195. }
  35196. if (type === ')') {
  35197. brackets -= 1;
  35198. }
  35199. if (brackets === 0 && type === ':') {
  35200. if (!prev) {
  35201. this.doubleColon(token);
  35202. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  35203. continue
  35204. } else {
  35205. return i
  35206. }
  35207. }
  35208. prev = token;
  35209. }
  35210. return false
  35211. }
  35212. comment(token) {
  35213. let node = new Comment();
  35214. this.init(node, token[2]);
  35215. node.source.end = this.getPosition(token[3] || token[2]);
  35216. node.source.end.offset++;
  35217. let text = token[1].slice(2, -2);
  35218. if (/^\s*$/.test(text)) {
  35219. node.text = '';
  35220. node.raws.left = text;
  35221. node.raws.right = '';
  35222. } else {
  35223. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  35224. node.text = match[2];
  35225. node.raws.left = match[1];
  35226. node.raws.right = match[3];
  35227. }
  35228. }
  35229. createTokenizer() {
  35230. this.tokenizer = tokenizer(this.input);
  35231. }
  35232. decl(tokens, customProperty) {
  35233. let node = new Declaration();
  35234. this.init(node, tokens[0][2]);
  35235. let last = tokens[tokens.length - 1];
  35236. if (last[0] === ';') {
  35237. this.semicolon = true;
  35238. tokens.pop();
  35239. }
  35240. node.source.end = this.getPosition(
  35241. last[3] || last[2] || findLastWithPosition(tokens)
  35242. );
  35243. node.source.end.offset++;
  35244. while (tokens[0][0] !== 'word') {
  35245. if (tokens.length === 1) this.unknownWord(tokens);
  35246. node.raws.before += tokens.shift()[1];
  35247. }
  35248. node.source.start = this.getPosition(tokens[0][2]);
  35249. node.prop = '';
  35250. while (tokens.length) {
  35251. let type = tokens[0][0];
  35252. if (type === ':' || type === 'space' || type === 'comment') {
  35253. break
  35254. }
  35255. node.prop += tokens.shift()[1];
  35256. }
  35257. node.raws.between = '';
  35258. let token;
  35259. while (tokens.length) {
  35260. token = tokens.shift();
  35261. if (token[0] === ':') {
  35262. node.raws.between += token[1];
  35263. break
  35264. } else {
  35265. if (token[0] === 'word' && /\w/.test(token[1])) {
  35266. this.unknownWord([token]);
  35267. }
  35268. node.raws.between += token[1];
  35269. }
  35270. }
  35271. if (node.prop[0] === '_' || node.prop[0] === '*') {
  35272. node.raws.before += node.prop[0];
  35273. node.prop = node.prop.slice(1);
  35274. }
  35275. let firstSpaces = [];
  35276. let next;
  35277. while (tokens.length) {
  35278. next = tokens[0][0];
  35279. if (next !== 'space' && next !== 'comment') break
  35280. firstSpaces.push(tokens.shift());
  35281. }
  35282. this.precheckMissedSemicolon(tokens);
  35283. for (let i = tokens.length - 1; i >= 0; i--) {
  35284. token = tokens[i];
  35285. if (token[1].toLowerCase() === '!important') {
  35286. node.important = true;
  35287. let string = this.stringFrom(tokens, i);
  35288. string = this.spacesFromEnd(tokens) + string;
  35289. if (string !== ' !important') node.raws.important = string;
  35290. break
  35291. } else if (token[1].toLowerCase() === 'important') {
  35292. let cache = tokens.slice(0);
  35293. let str = '';
  35294. for (let j = i; j > 0; j--) {
  35295. let type = cache[j][0];
  35296. if (str.trim().startsWith('!') && type !== 'space') {
  35297. break
  35298. }
  35299. str = cache.pop()[1] + str;
  35300. }
  35301. if (str.trim().startsWith('!')) {
  35302. node.important = true;
  35303. node.raws.important = str;
  35304. tokens = cache;
  35305. }
  35306. }
  35307. if (token[0] !== 'space' && token[0] !== 'comment') {
  35308. break
  35309. }
  35310. }
  35311. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  35312. if (hasWord) {
  35313. node.raws.between += firstSpaces.map(i => i[1]).join('');
  35314. firstSpaces = [];
  35315. }
  35316. this.raw(node, 'value', firstSpaces.concat(tokens), customProperty);
  35317. if (node.value.includes(':') && !customProperty) {
  35318. this.checkMissedSemicolon(tokens);
  35319. }
  35320. }
  35321. doubleColon(token) {
  35322. throw this.input.error(
  35323. 'Double colon',
  35324. { offset: token[2] },
  35325. { offset: token[2] + token[1].length }
  35326. )
  35327. }
  35328. emptyRule(token) {
  35329. let node = new Rule();
  35330. this.init(node, token[2]);
  35331. node.selector = '';
  35332. node.raws.between = '';
  35333. this.current = node;
  35334. }
  35335. end(token) {
  35336. if (this.current.nodes && this.current.nodes.length) {
  35337. this.current.raws.semicolon = this.semicolon;
  35338. }
  35339. this.semicolon = false;
  35340. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  35341. this.spaces = '';
  35342. if (this.current.parent) {
  35343. this.current.source.end = this.getPosition(token[2]);
  35344. this.current.source.end.offset++;
  35345. this.current = this.current.parent;
  35346. } else {
  35347. this.unexpectedClose(token);
  35348. }
  35349. }
  35350. endFile() {
  35351. if (this.current.parent) this.unclosedBlock();
  35352. if (this.current.nodes && this.current.nodes.length) {
  35353. this.current.raws.semicolon = this.semicolon;
  35354. }
  35355. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  35356. this.root.source.end = this.getPosition(this.tokenizer.position());
  35357. }
  35358. freeSemicolon(token) {
  35359. this.spaces += token[1];
  35360. if (this.current.nodes) {
  35361. let prev = this.current.nodes[this.current.nodes.length - 1];
  35362. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  35363. prev.raws.ownSemicolon = this.spaces;
  35364. this.spaces = '';
  35365. prev.source.end = this.getPosition(token[2]);
  35366. prev.source.end.offset += prev.raws.ownSemicolon.length;
  35367. }
  35368. }
  35369. }
  35370. // Helpers
  35371. getPosition(offset) {
  35372. let pos = this.input.fromOffset(offset);
  35373. return {
  35374. column: pos.col,
  35375. line: pos.line,
  35376. offset
  35377. }
  35378. }
  35379. init(node, offset) {
  35380. this.current.push(node);
  35381. node.source = {
  35382. input: this.input,
  35383. start: this.getPosition(offset)
  35384. };
  35385. node.raws.before = this.spaces;
  35386. this.spaces = '';
  35387. if (node.type !== 'comment') this.semicolon = false;
  35388. }
  35389. other(start) {
  35390. let end = false;
  35391. let type = null;
  35392. let colon = false;
  35393. let bracket = null;
  35394. let brackets = [];
  35395. let customProperty = start[1].startsWith('--');
  35396. let tokens = [];
  35397. let token = start;
  35398. while (token) {
  35399. type = token[0];
  35400. tokens.push(token);
  35401. if (type === '(' || type === '[') {
  35402. if (!bracket) bracket = token;
  35403. brackets.push(type === '(' ? ')' : ']');
  35404. } else if (customProperty && colon && type === '{') {
  35405. if (!bracket) bracket = token;
  35406. brackets.push('}');
  35407. } else if (brackets.length === 0) {
  35408. if (type === ';') {
  35409. if (colon) {
  35410. this.decl(tokens, customProperty);
  35411. return
  35412. } else {
  35413. break
  35414. }
  35415. } else if (type === '{') {
  35416. this.rule(tokens);
  35417. return
  35418. } else if (type === '}') {
  35419. this.tokenizer.back(tokens.pop());
  35420. end = true;
  35421. break
  35422. } else if (type === ':') {
  35423. colon = true;
  35424. }
  35425. } else if (type === brackets[brackets.length - 1]) {
  35426. brackets.pop();
  35427. if (brackets.length === 0) bracket = null;
  35428. }
  35429. token = this.tokenizer.nextToken();
  35430. }
  35431. if (this.tokenizer.endOfFile()) end = true;
  35432. if (brackets.length > 0) this.unclosedBracket(bracket);
  35433. if (end && colon) {
  35434. if (!customProperty) {
  35435. while (tokens.length) {
  35436. token = tokens[tokens.length - 1][0];
  35437. if (token !== 'space' && token !== 'comment') break
  35438. this.tokenizer.back(tokens.pop());
  35439. }
  35440. }
  35441. this.decl(tokens, customProperty);
  35442. } else {
  35443. this.unknownWord(tokens);
  35444. }
  35445. }
  35446. parse() {
  35447. let token;
  35448. while (!this.tokenizer.endOfFile()) {
  35449. token = this.tokenizer.nextToken();
  35450. switch (token[0]) {
  35451. case 'space':
  35452. this.spaces += token[1];
  35453. break
  35454. case ';':
  35455. this.freeSemicolon(token);
  35456. break
  35457. case '}':
  35458. this.end(token);
  35459. break
  35460. case 'comment':
  35461. this.comment(token);
  35462. break
  35463. case 'at-word':
  35464. this.atrule(token);
  35465. break
  35466. case '{':
  35467. this.emptyRule(token);
  35468. break
  35469. default:
  35470. this.other(token);
  35471. break
  35472. }
  35473. }
  35474. this.endFile();
  35475. }
  35476. precheckMissedSemicolon(/* tokens */) {
  35477. // Hook for Safe Parser
  35478. }
  35479. raw(node, prop, tokens, customProperty) {
  35480. let token, type;
  35481. let length = tokens.length;
  35482. let value = '';
  35483. let clean = true;
  35484. let next, prev;
  35485. for (let i = 0; i < length; i += 1) {
  35486. token = tokens[i];
  35487. type = token[0];
  35488. if (type === 'space' && i === length - 1 && !customProperty) {
  35489. clean = false;
  35490. } else if (type === 'comment') {
  35491. prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty';
  35492. next = tokens[i + 1] ? tokens[i + 1][0] : 'empty';
  35493. if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
  35494. if (value.slice(-1) === ',') {
  35495. clean = false;
  35496. } else {
  35497. value += token[1];
  35498. }
  35499. } else {
  35500. clean = false;
  35501. }
  35502. } else {
  35503. value += token[1];
  35504. }
  35505. }
  35506. if (!clean) {
  35507. let raw = tokens.reduce((all, i) => all + i[1], '');
  35508. node.raws[prop] = { raw, value };
  35509. }
  35510. node[prop] = value;
  35511. }
  35512. rule(tokens) {
  35513. tokens.pop();
  35514. let node = new Rule();
  35515. this.init(node, tokens[0][2]);
  35516. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  35517. this.raw(node, 'selector', tokens);
  35518. this.current = node;
  35519. }
  35520. spacesAndCommentsFromEnd(tokens) {
  35521. let lastTokenType;
  35522. let spaces = '';
  35523. while (tokens.length) {
  35524. lastTokenType = tokens[tokens.length - 1][0];
  35525. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  35526. spaces = tokens.pop()[1] + spaces;
  35527. }
  35528. return spaces
  35529. }
  35530. // Errors
  35531. spacesAndCommentsFromStart(tokens) {
  35532. let next;
  35533. let spaces = '';
  35534. while (tokens.length) {
  35535. next = tokens[0][0];
  35536. if (next !== 'space' && next !== 'comment') break
  35537. spaces += tokens.shift()[1];
  35538. }
  35539. return spaces
  35540. }
  35541. spacesFromEnd(tokens) {
  35542. let lastTokenType;
  35543. let spaces = '';
  35544. while (tokens.length) {
  35545. lastTokenType = tokens[tokens.length - 1][0];
  35546. if (lastTokenType !== 'space') break
  35547. spaces = tokens.pop()[1] + spaces;
  35548. }
  35549. return spaces
  35550. }
  35551. stringFrom(tokens, from) {
  35552. let result = '';
  35553. for (let i = from; i < tokens.length; i++) {
  35554. result += tokens[i][1];
  35555. }
  35556. tokens.splice(from, tokens.length - from);
  35557. return result
  35558. }
  35559. unclosedBlock() {
  35560. let pos = this.current.source.start;
  35561. throw this.input.error('Unclosed block', pos.line, pos.column)
  35562. }
  35563. unclosedBracket(bracket) {
  35564. throw this.input.error(
  35565. 'Unclosed bracket',
  35566. { offset: bracket[2] },
  35567. { offset: bracket[2] + 1 }
  35568. )
  35569. }
  35570. unexpectedClose(token) {
  35571. throw this.input.error(
  35572. 'Unexpected }',
  35573. { offset: token[2] },
  35574. { offset: token[2] + 1 }
  35575. )
  35576. }
  35577. unknownWord(tokens) {
  35578. throw this.input.error(
  35579. 'Unknown word ' + tokens[0][1],
  35580. { offset: tokens[0][2] },
  35581. { offset: tokens[0][2] + tokens[0][1].length }
  35582. )
  35583. }
  35584. unnamedAtrule(node, token) {
  35585. throw this.input.error(
  35586. 'At-rule without name',
  35587. { offset: token[2] },
  35588. { offset: token[2] + token[1].length }
  35589. )
  35590. }
  35591. }
  35592. parser$1 = Parser;
  35593. return parser$1;
  35594. }
  35595. var parse_1;
  35596. var hasRequiredParse;
  35597. function requireParse () {
  35598. if (hasRequiredParse) return parse_1;
  35599. hasRequiredParse = 1;
  35600. let Container = /*@__PURE__*/ requireContainer$1();
  35601. let Input = /*@__PURE__*/ requireInput();
  35602. let Parser = /*@__PURE__*/ requireParser$1();
  35603. function parse(css, opts) {
  35604. let input = new Input(css, opts);
  35605. let parser = new Parser(input);
  35606. try {
  35607. parser.parse();
  35608. } catch (e) {
  35609. if (browser$1.env.NODE_ENV !== 'production') {
  35610. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  35611. if (/\.scss$/i.test(opts.from)) {
  35612. e.message +=
  35613. '\nYou tried to parse SCSS with ' +
  35614. 'the standard CSS parser; ' +
  35615. 'try again with the postcss-scss parser';
  35616. } else if (/\.sass/i.test(opts.from)) {
  35617. e.message +=
  35618. '\nYou tried to parse Sass with ' +
  35619. 'the standard CSS parser; ' +
  35620. 'try again with the postcss-sass parser';
  35621. } else if (/\.less$/i.test(opts.from)) {
  35622. e.message +=
  35623. '\nYou tried to parse Less with ' +
  35624. 'the standard CSS parser; ' +
  35625. 'try again with the postcss-less parser';
  35626. }
  35627. }
  35628. }
  35629. throw e
  35630. }
  35631. return parser.root
  35632. }
  35633. parse_1 = parse;
  35634. parse.default = parse;
  35635. Container.registerParse(parse);
  35636. return parse_1;
  35637. }
  35638. var warning;
  35639. var hasRequiredWarning;
  35640. function requireWarning () {
  35641. if (hasRequiredWarning) return warning;
  35642. hasRequiredWarning = 1;
  35643. class Warning {
  35644. constructor(text, opts = {}) {
  35645. this.type = 'warning';
  35646. this.text = text;
  35647. if (opts.node && opts.node.source) {
  35648. let range = opts.node.rangeBy(opts);
  35649. this.line = range.start.line;
  35650. this.column = range.start.column;
  35651. this.endLine = range.end.line;
  35652. this.endColumn = range.end.column;
  35653. }
  35654. for (let opt in opts) this[opt] = opts[opt];
  35655. }
  35656. toString() {
  35657. if (this.node) {
  35658. return this.node.error(this.text, {
  35659. index: this.index,
  35660. plugin: this.plugin,
  35661. word: this.word
  35662. }).message
  35663. }
  35664. if (this.plugin) {
  35665. return this.plugin + ': ' + this.text
  35666. }
  35667. return this.text
  35668. }
  35669. }
  35670. warning = Warning;
  35671. Warning.default = Warning;
  35672. return warning;
  35673. }
  35674. var result;
  35675. var hasRequiredResult;
  35676. function requireResult () {
  35677. if (hasRequiredResult) return result;
  35678. hasRequiredResult = 1;
  35679. let Warning = /*@__PURE__*/ requireWarning();
  35680. class Result {
  35681. get content() {
  35682. return this.css
  35683. }
  35684. constructor(processor, root, opts) {
  35685. this.processor = processor;
  35686. this.messages = [];
  35687. this.root = root;
  35688. this.opts = opts;
  35689. this.css = '';
  35690. this.map = undefined;
  35691. }
  35692. toString() {
  35693. return this.css
  35694. }
  35695. warn(text, opts = {}) {
  35696. if (!opts.plugin) {
  35697. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  35698. opts.plugin = this.lastPlugin.postcssPlugin;
  35699. }
  35700. }
  35701. let warning = new Warning(text, opts);
  35702. this.messages.push(warning);
  35703. return warning
  35704. }
  35705. warnings() {
  35706. return this.messages.filter(i => i.type === 'warning')
  35707. }
  35708. }
  35709. result = Result;
  35710. Result.default = Result;
  35711. return result;
  35712. }
  35713. /* eslint-disable no-console */
  35714. var warnOnce;
  35715. var hasRequiredWarnOnce;
  35716. function requireWarnOnce () {
  35717. if (hasRequiredWarnOnce) return warnOnce;
  35718. hasRequiredWarnOnce = 1;
  35719. let printed = {};
  35720. warnOnce = function warnOnce(message) {
  35721. if (printed[message]) return
  35722. printed[message] = true;
  35723. if (typeof console !== 'undefined' && console.warn) {
  35724. console.warn(message);
  35725. }
  35726. };
  35727. return warnOnce;
  35728. }
  35729. var lazyResult;
  35730. var hasRequiredLazyResult;
  35731. function requireLazyResult () {
  35732. if (hasRequiredLazyResult) return lazyResult;
  35733. hasRequiredLazyResult = 1;
  35734. let Container = /*@__PURE__*/ requireContainer$1();
  35735. let Document = /*@__PURE__*/ requireDocument();
  35736. let MapGenerator = /*@__PURE__*/ requireMapGenerator();
  35737. let parse = /*@__PURE__*/ requireParse();
  35738. let Result = /*@__PURE__*/ requireResult();
  35739. let Root = /*@__PURE__*/ requireRoot$1();
  35740. let stringify = /*@__PURE__*/ requireStringify();
  35741. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  35742. let warnOnce = /*@__PURE__*/ requireWarnOnce();
  35743. const TYPE_TO_CLASS_NAME = {
  35744. atrule: 'AtRule',
  35745. comment: 'Comment',
  35746. decl: 'Declaration',
  35747. document: 'Document',
  35748. root: 'Root',
  35749. rule: 'Rule'
  35750. };
  35751. const PLUGIN_PROPS = {
  35752. AtRule: true,
  35753. AtRuleExit: true,
  35754. Comment: true,
  35755. CommentExit: true,
  35756. Declaration: true,
  35757. DeclarationExit: true,
  35758. Document: true,
  35759. DocumentExit: true,
  35760. Once: true,
  35761. OnceExit: true,
  35762. postcssPlugin: true,
  35763. prepare: true,
  35764. Root: true,
  35765. RootExit: true,
  35766. Rule: true,
  35767. RuleExit: true
  35768. };
  35769. const NOT_VISITORS = {
  35770. Once: true,
  35771. postcssPlugin: true,
  35772. prepare: true
  35773. };
  35774. const CHILDREN = 0;
  35775. function isPromise(obj) {
  35776. return typeof obj === 'object' && typeof obj.then === 'function'
  35777. }
  35778. function getEvents(node) {
  35779. let key = false;
  35780. let type = TYPE_TO_CLASS_NAME[node.type];
  35781. if (node.type === 'decl') {
  35782. key = node.prop.toLowerCase();
  35783. } else if (node.type === 'atrule') {
  35784. key = node.name.toLowerCase();
  35785. }
  35786. if (key && node.append) {
  35787. return [
  35788. type,
  35789. type + '-' + key,
  35790. CHILDREN,
  35791. type + 'Exit',
  35792. type + 'Exit-' + key
  35793. ]
  35794. } else if (key) {
  35795. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  35796. } else if (node.append) {
  35797. return [type, CHILDREN, type + 'Exit']
  35798. } else {
  35799. return [type, type + 'Exit']
  35800. }
  35801. }
  35802. function toStack(node) {
  35803. let events;
  35804. if (node.type === 'document') {
  35805. events = ['Document', CHILDREN, 'DocumentExit'];
  35806. } else if (node.type === 'root') {
  35807. events = ['Root', CHILDREN, 'RootExit'];
  35808. } else {
  35809. events = getEvents(node);
  35810. }
  35811. return {
  35812. eventIndex: 0,
  35813. events,
  35814. iterator: 0,
  35815. node,
  35816. visitorIndex: 0,
  35817. visitors: []
  35818. }
  35819. }
  35820. function cleanMarks(node) {
  35821. node[isClean] = false;
  35822. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  35823. return node
  35824. }
  35825. let postcss = {};
  35826. class LazyResult {
  35827. get content() {
  35828. return this.stringify().content
  35829. }
  35830. get css() {
  35831. return this.stringify().css
  35832. }
  35833. get map() {
  35834. return this.stringify().map
  35835. }
  35836. get messages() {
  35837. return this.sync().messages
  35838. }
  35839. get opts() {
  35840. return this.result.opts
  35841. }
  35842. get processor() {
  35843. return this.result.processor
  35844. }
  35845. get root() {
  35846. return this.sync().root
  35847. }
  35848. get [Symbol.toStringTag]() {
  35849. return 'LazyResult'
  35850. }
  35851. constructor(processor, css, opts) {
  35852. this.stringified = false;
  35853. this.processed = false;
  35854. let root;
  35855. if (
  35856. typeof css === 'object' &&
  35857. css !== null &&
  35858. (css.type === 'root' || css.type === 'document')
  35859. ) {
  35860. root = cleanMarks(css);
  35861. } else if (css instanceof LazyResult || css instanceof Result) {
  35862. root = cleanMarks(css.root);
  35863. if (css.map) {
  35864. if (typeof opts.map === 'undefined') opts.map = {};
  35865. if (!opts.map.inline) opts.map.inline = false;
  35866. opts.map.prev = css.map;
  35867. }
  35868. } else {
  35869. let parser = parse;
  35870. if (opts.syntax) parser = opts.syntax.parse;
  35871. if (opts.parser) parser = opts.parser;
  35872. if (parser.parse) parser = parser.parse;
  35873. try {
  35874. root = parser(css, opts);
  35875. } catch (error) {
  35876. this.processed = true;
  35877. this.error = error;
  35878. }
  35879. if (root && !root[my]) {
  35880. /* c8 ignore next 2 */
  35881. Container.rebuild(root);
  35882. }
  35883. }
  35884. this.result = new Result(processor, root, opts);
  35885. this.helpers = { ...postcss, postcss, result: this.result };
  35886. this.plugins = this.processor.plugins.map(plugin => {
  35887. if (typeof plugin === 'object' && plugin.prepare) {
  35888. return { ...plugin, ...plugin.prepare(this.result) }
  35889. } else {
  35890. return plugin
  35891. }
  35892. });
  35893. }
  35894. async() {
  35895. if (this.error) return Promise.reject(this.error)
  35896. if (this.processed) return Promise.resolve(this.result)
  35897. if (!this.processing) {
  35898. this.processing = this.runAsync();
  35899. }
  35900. return this.processing
  35901. }
  35902. catch(onRejected) {
  35903. return this.async().catch(onRejected)
  35904. }
  35905. finally(onFinally) {
  35906. return this.async().then(onFinally, onFinally)
  35907. }
  35908. getAsyncError() {
  35909. throw new Error('Use process(css).then(cb) to work with async plugins')
  35910. }
  35911. handleError(error, node) {
  35912. let plugin = this.result.lastPlugin;
  35913. try {
  35914. if (node) node.addToError(error);
  35915. this.error = error;
  35916. if (error.name === 'CssSyntaxError' && !error.plugin) {
  35917. error.plugin = plugin.postcssPlugin;
  35918. error.setMessage();
  35919. } else if (plugin.postcssVersion) {
  35920. if (browser$1.env.NODE_ENV !== 'production') {
  35921. let pluginName = plugin.postcssPlugin;
  35922. let pluginVer = plugin.postcssVersion;
  35923. let runtimeVer = this.result.processor.version;
  35924. let a = pluginVer.split('.');
  35925. let b = runtimeVer.split('.');
  35926. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  35927. // eslint-disable-next-line no-console
  35928. console.error(
  35929. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  35930. 'version is ' +
  35931. runtimeVer +
  35932. ', but ' +
  35933. pluginName +
  35934. ' uses ' +
  35935. pluginVer +
  35936. '. Perhaps this is the source of the error below.'
  35937. );
  35938. }
  35939. }
  35940. }
  35941. } catch (err) {
  35942. /* c8 ignore next 3 */
  35943. // eslint-disable-next-line no-console
  35944. if (console && console.error) console.error(err);
  35945. }
  35946. return error
  35947. }
  35948. prepareVisitors() {
  35949. this.listeners = {};
  35950. let add = (plugin, type, cb) => {
  35951. if (!this.listeners[type]) this.listeners[type] = [];
  35952. this.listeners[type].push([plugin, cb]);
  35953. };
  35954. for (let plugin of this.plugins) {
  35955. if (typeof plugin === 'object') {
  35956. for (let event in plugin) {
  35957. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  35958. throw new Error(
  35959. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  35960. `Try to update PostCSS (${this.processor.version} now).`
  35961. )
  35962. }
  35963. if (!NOT_VISITORS[event]) {
  35964. if (typeof plugin[event] === 'object') {
  35965. for (let filter in plugin[event]) {
  35966. if (filter === '*') {
  35967. add(plugin, event, plugin[event][filter]);
  35968. } else {
  35969. add(
  35970. plugin,
  35971. event + '-' + filter.toLowerCase(),
  35972. plugin[event][filter]
  35973. );
  35974. }
  35975. }
  35976. } else if (typeof plugin[event] === 'function') {
  35977. add(plugin, event, plugin[event]);
  35978. }
  35979. }
  35980. }
  35981. }
  35982. }
  35983. this.hasListener = Object.keys(this.listeners).length > 0;
  35984. }
  35985. async runAsync() {
  35986. this.plugin = 0;
  35987. for (let i = 0; i < this.plugins.length; i++) {
  35988. let plugin = this.plugins[i];
  35989. let promise = this.runOnRoot(plugin);
  35990. if (isPromise(promise)) {
  35991. try {
  35992. await promise;
  35993. } catch (error) {
  35994. throw this.handleError(error)
  35995. }
  35996. }
  35997. }
  35998. this.prepareVisitors();
  35999. if (this.hasListener) {
  36000. let root = this.result.root;
  36001. while (!root[isClean]) {
  36002. root[isClean] = true;
  36003. let stack = [toStack(root)];
  36004. while (stack.length > 0) {
  36005. let promise = this.visitTick(stack);
  36006. if (isPromise(promise)) {
  36007. try {
  36008. await promise;
  36009. } catch (e) {
  36010. let node = stack[stack.length - 1].node;
  36011. throw this.handleError(e, node)
  36012. }
  36013. }
  36014. }
  36015. }
  36016. if (this.listeners.OnceExit) {
  36017. for (let [plugin, visitor] of this.listeners.OnceExit) {
  36018. this.result.lastPlugin = plugin;
  36019. try {
  36020. if (root.type === 'document') {
  36021. let roots = root.nodes.map(subRoot =>
  36022. visitor(subRoot, this.helpers)
  36023. );
  36024. await Promise.all(roots);
  36025. } else {
  36026. await visitor(root, this.helpers);
  36027. }
  36028. } catch (e) {
  36029. throw this.handleError(e)
  36030. }
  36031. }
  36032. }
  36033. }
  36034. this.processed = true;
  36035. return this.stringify()
  36036. }
  36037. runOnRoot(plugin) {
  36038. this.result.lastPlugin = plugin;
  36039. try {
  36040. if (typeof plugin === 'object' && plugin.Once) {
  36041. if (this.result.root.type === 'document') {
  36042. let roots = this.result.root.nodes.map(root =>
  36043. plugin.Once(root, this.helpers)
  36044. );
  36045. if (isPromise(roots[0])) {
  36046. return Promise.all(roots)
  36047. }
  36048. return roots
  36049. }
  36050. return plugin.Once(this.result.root, this.helpers)
  36051. } else if (typeof plugin === 'function') {
  36052. return plugin(this.result.root, this.result)
  36053. }
  36054. } catch (error) {
  36055. throw this.handleError(error)
  36056. }
  36057. }
  36058. stringify() {
  36059. if (this.error) throw this.error
  36060. if (this.stringified) return this.result
  36061. this.stringified = true;
  36062. this.sync();
  36063. let opts = this.result.opts;
  36064. let str = stringify;
  36065. if (opts.syntax) str = opts.syntax.stringify;
  36066. if (opts.stringifier) str = opts.stringifier;
  36067. if (str.stringify) str = str.stringify;
  36068. let map = new MapGenerator(str, this.result.root, this.result.opts);
  36069. let data = map.generate();
  36070. this.result.css = data[0];
  36071. this.result.map = data[1];
  36072. return this.result
  36073. }
  36074. sync() {
  36075. if (this.error) throw this.error
  36076. if (this.processed) return this.result
  36077. this.processed = true;
  36078. if (this.processing) {
  36079. throw this.getAsyncError()
  36080. }
  36081. for (let plugin of this.plugins) {
  36082. let promise = this.runOnRoot(plugin);
  36083. if (isPromise(promise)) {
  36084. throw this.getAsyncError()
  36085. }
  36086. }
  36087. this.prepareVisitors();
  36088. if (this.hasListener) {
  36089. let root = this.result.root;
  36090. while (!root[isClean]) {
  36091. root[isClean] = true;
  36092. this.walkSync(root);
  36093. }
  36094. if (this.listeners.OnceExit) {
  36095. if (root.type === 'document') {
  36096. for (let subRoot of root.nodes) {
  36097. this.visitSync(this.listeners.OnceExit, subRoot);
  36098. }
  36099. } else {
  36100. this.visitSync(this.listeners.OnceExit, root);
  36101. }
  36102. }
  36103. }
  36104. return this.result
  36105. }
  36106. then(onFulfilled, onRejected) {
  36107. if (browser$1.env.NODE_ENV !== 'production') {
  36108. if (!('from' in this.opts)) {
  36109. warnOnce(
  36110. 'Without `from` option PostCSS could generate wrong source map ' +
  36111. 'and will not find Browserslist config. Set it to CSS file path ' +
  36112. 'or to `undefined` to prevent this warning.'
  36113. );
  36114. }
  36115. }
  36116. return this.async().then(onFulfilled, onRejected)
  36117. }
  36118. toString() {
  36119. return this.css
  36120. }
  36121. visitSync(visitors, node) {
  36122. for (let [plugin, visitor] of visitors) {
  36123. this.result.lastPlugin = plugin;
  36124. let promise;
  36125. try {
  36126. promise = visitor(node, this.helpers);
  36127. } catch (e) {
  36128. throw this.handleError(e, node.proxyOf)
  36129. }
  36130. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  36131. return true
  36132. }
  36133. if (isPromise(promise)) {
  36134. throw this.getAsyncError()
  36135. }
  36136. }
  36137. }
  36138. visitTick(stack) {
  36139. let visit = stack[stack.length - 1];
  36140. let { node, visitors } = visit;
  36141. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  36142. stack.pop();
  36143. return
  36144. }
  36145. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  36146. let [plugin, visitor] = visitors[visit.visitorIndex];
  36147. visit.visitorIndex += 1;
  36148. if (visit.visitorIndex === visitors.length) {
  36149. visit.visitors = [];
  36150. visit.visitorIndex = 0;
  36151. }
  36152. this.result.lastPlugin = plugin;
  36153. try {
  36154. return visitor(node.toProxy(), this.helpers)
  36155. } catch (e) {
  36156. throw this.handleError(e, node)
  36157. }
  36158. }
  36159. if (visit.iterator !== 0) {
  36160. let iterator = visit.iterator;
  36161. let child;
  36162. while ((child = node.nodes[node.indexes[iterator]])) {
  36163. node.indexes[iterator] += 1;
  36164. if (!child[isClean]) {
  36165. child[isClean] = true;
  36166. stack.push(toStack(child));
  36167. return
  36168. }
  36169. }
  36170. visit.iterator = 0;
  36171. delete node.indexes[iterator];
  36172. }
  36173. let events = visit.events;
  36174. while (visit.eventIndex < events.length) {
  36175. let event = events[visit.eventIndex];
  36176. visit.eventIndex += 1;
  36177. if (event === CHILDREN) {
  36178. if (node.nodes && node.nodes.length) {
  36179. node[isClean] = true;
  36180. visit.iterator = node.getIterator();
  36181. }
  36182. return
  36183. } else if (this.listeners[event]) {
  36184. visit.visitors = this.listeners[event];
  36185. return
  36186. }
  36187. }
  36188. stack.pop();
  36189. }
  36190. walkSync(node) {
  36191. node[isClean] = true;
  36192. let events = getEvents(node);
  36193. for (let event of events) {
  36194. if (event === CHILDREN) {
  36195. if (node.nodes) {
  36196. node.each(child => {
  36197. if (!child[isClean]) this.walkSync(child);
  36198. });
  36199. }
  36200. } else {
  36201. let visitors = this.listeners[event];
  36202. if (visitors) {
  36203. if (this.visitSync(visitors, node.toProxy())) return
  36204. }
  36205. }
  36206. }
  36207. }
  36208. warnings() {
  36209. return this.sync().warnings()
  36210. }
  36211. }
  36212. LazyResult.registerPostcss = dependant => {
  36213. postcss = dependant;
  36214. };
  36215. lazyResult = LazyResult;
  36216. LazyResult.default = LazyResult;
  36217. Root.registerLazyResult(LazyResult);
  36218. Document.registerLazyResult(LazyResult);
  36219. return lazyResult;
  36220. }
  36221. var noWorkResult;
  36222. var hasRequiredNoWorkResult;
  36223. function requireNoWorkResult () {
  36224. if (hasRequiredNoWorkResult) return noWorkResult;
  36225. hasRequiredNoWorkResult = 1;
  36226. let MapGenerator = /*@__PURE__*/ requireMapGenerator();
  36227. let parse = /*@__PURE__*/ requireParse();
  36228. const Result = /*@__PURE__*/ requireResult();
  36229. let stringify = /*@__PURE__*/ requireStringify();
  36230. let warnOnce = /*@__PURE__*/ requireWarnOnce();
  36231. class NoWorkResult {
  36232. get content() {
  36233. return this.result.css
  36234. }
  36235. get css() {
  36236. return this.result.css
  36237. }
  36238. get map() {
  36239. return this.result.map
  36240. }
  36241. get messages() {
  36242. return []
  36243. }
  36244. get opts() {
  36245. return this.result.opts
  36246. }
  36247. get processor() {
  36248. return this.result.processor
  36249. }
  36250. get root() {
  36251. if (this._root) {
  36252. return this._root
  36253. }
  36254. let root;
  36255. let parser = parse;
  36256. try {
  36257. root = parser(this._css, this._opts);
  36258. } catch (error) {
  36259. this.error = error;
  36260. }
  36261. if (this.error) {
  36262. throw this.error
  36263. } else {
  36264. this._root = root;
  36265. return root
  36266. }
  36267. }
  36268. get [Symbol.toStringTag]() {
  36269. return 'NoWorkResult'
  36270. }
  36271. constructor(processor, css, opts) {
  36272. css = css.toString();
  36273. this.stringified = false;
  36274. this._processor = processor;
  36275. this._css = css;
  36276. this._opts = opts;
  36277. this._map = undefined;
  36278. let root;
  36279. let str = stringify;
  36280. this.result = new Result(this._processor, root, this._opts);
  36281. this.result.css = css;
  36282. let self = this;
  36283. Object.defineProperty(this.result, 'root', {
  36284. get() {
  36285. return self.root
  36286. }
  36287. });
  36288. let map = new MapGenerator(str, root, this._opts, css);
  36289. if (map.isMap()) {
  36290. let [generatedCSS, generatedMap] = map.generate();
  36291. if (generatedCSS) {
  36292. this.result.css = generatedCSS;
  36293. }
  36294. if (generatedMap) {
  36295. this.result.map = generatedMap;
  36296. }
  36297. } else {
  36298. map.clearAnnotation();
  36299. this.result.css = map.css;
  36300. }
  36301. }
  36302. async() {
  36303. if (this.error) return Promise.reject(this.error)
  36304. return Promise.resolve(this.result)
  36305. }
  36306. catch(onRejected) {
  36307. return this.async().catch(onRejected)
  36308. }
  36309. finally(onFinally) {
  36310. return this.async().then(onFinally, onFinally)
  36311. }
  36312. sync() {
  36313. if (this.error) throw this.error
  36314. return this.result
  36315. }
  36316. then(onFulfilled, onRejected) {
  36317. if (browser$1.env.NODE_ENV !== 'production') {
  36318. if (!('from' in this._opts)) {
  36319. warnOnce(
  36320. 'Without `from` option PostCSS could generate wrong source map ' +
  36321. 'and will not find Browserslist config. Set it to CSS file path ' +
  36322. 'or to `undefined` to prevent this warning.'
  36323. );
  36324. }
  36325. }
  36326. return this.async().then(onFulfilled, onRejected)
  36327. }
  36328. toString() {
  36329. return this._css
  36330. }
  36331. warnings() {
  36332. return []
  36333. }
  36334. }
  36335. noWorkResult = NoWorkResult;
  36336. NoWorkResult.default = NoWorkResult;
  36337. return noWorkResult;
  36338. }
  36339. var processor$1;
  36340. var hasRequiredProcessor$1;
  36341. function requireProcessor$1 () {
  36342. if (hasRequiredProcessor$1) return processor$1;
  36343. hasRequiredProcessor$1 = 1;
  36344. let Document = /*@__PURE__*/ requireDocument();
  36345. let LazyResult = /*@__PURE__*/ requireLazyResult();
  36346. let NoWorkResult = /*@__PURE__*/ requireNoWorkResult();
  36347. let Root = /*@__PURE__*/ requireRoot$1();
  36348. class Processor {
  36349. constructor(plugins = []) {
  36350. this.version = '8.5.6';
  36351. this.plugins = this.normalize(plugins);
  36352. }
  36353. normalize(plugins) {
  36354. let normalized = [];
  36355. for (let i of plugins) {
  36356. if (i.postcss === true) {
  36357. i = i();
  36358. } else if (i.postcss) {
  36359. i = i.postcss;
  36360. }
  36361. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  36362. normalized = normalized.concat(i.plugins);
  36363. } else if (typeof i === 'object' && i.postcssPlugin) {
  36364. normalized.push(i);
  36365. } else if (typeof i === 'function') {
  36366. normalized.push(i);
  36367. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  36368. if (browser$1.env.NODE_ENV !== 'production') {
  36369. throw new Error(
  36370. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  36371. 'one of the syntax/parser/stringifier options as outlined ' +
  36372. 'in your PostCSS runner documentation.'
  36373. )
  36374. }
  36375. } else {
  36376. throw new Error(i + ' is not a PostCSS plugin')
  36377. }
  36378. }
  36379. return normalized
  36380. }
  36381. process(css, opts = {}) {
  36382. if (
  36383. !this.plugins.length &&
  36384. !opts.parser &&
  36385. !opts.stringifier &&
  36386. !opts.syntax
  36387. ) {
  36388. return new NoWorkResult(this, css, opts)
  36389. } else {
  36390. return new LazyResult(this, css, opts)
  36391. }
  36392. }
  36393. use(plugin) {
  36394. this.plugins = this.plugins.concat(this.normalize([plugin]));
  36395. return this
  36396. }
  36397. }
  36398. processor$1 = Processor;
  36399. Processor.default = Processor;
  36400. Root.registerProcessor(Processor);
  36401. Document.registerProcessor(Processor);
  36402. return processor$1;
  36403. }
  36404. var postcss_1;
  36405. var hasRequiredPostcss;
  36406. function requirePostcss () {
  36407. if (hasRequiredPostcss) return postcss_1;
  36408. hasRequiredPostcss = 1;
  36409. let AtRule = /*@__PURE__*/ requireAtRule();
  36410. let Comment = /*@__PURE__*/ requireComment$1();
  36411. let Container = /*@__PURE__*/ requireContainer$1();
  36412. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  36413. let Declaration = /*@__PURE__*/ requireDeclaration();
  36414. let Document = /*@__PURE__*/ requireDocument();
  36415. let fromJSON = /*@__PURE__*/ requireFromJSON();
  36416. let Input = /*@__PURE__*/ requireInput();
  36417. let LazyResult = /*@__PURE__*/ requireLazyResult();
  36418. let list = /*@__PURE__*/ requireList();
  36419. let Node = /*@__PURE__*/ requireNode$2();
  36420. let parse = /*@__PURE__*/ requireParse();
  36421. let Processor = /*@__PURE__*/ requireProcessor$1();
  36422. let Result = /*@__PURE__*/ requireResult();
  36423. let Root = /*@__PURE__*/ requireRoot$1();
  36424. let Rule = /*@__PURE__*/ requireRule();
  36425. let stringify = /*@__PURE__*/ requireStringify();
  36426. let Warning = /*@__PURE__*/ requireWarning();
  36427. function postcss(...plugins) {
  36428. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  36429. plugins = plugins[0];
  36430. }
  36431. return new Processor(plugins)
  36432. }
  36433. postcss.plugin = function plugin(name, initializer) {
  36434. let warningPrinted = false;
  36435. function creator(...args) {
  36436. // eslint-disable-next-line no-console
  36437. if (console && console.warn && !warningPrinted) {
  36438. warningPrinted = true;
  36439. // eslint-disable-next-line no-console
  36440. console.warn(
  36441. name +
  36442. ': postcss.plugin was deprecated. Migration guide:\n' +
  36443. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  36444. );
  36445. if (browser$1.env.LANG && browser$1.env.LANG.startsWith('cn')) {
  36446. /* c8 ignore next 7 */
  36447. // eslint-disable-next-line no-console
  36448. console.warn(
  36449. name +
  36450. ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
  36451. 'https://www.w3ctech.com/topic/2226'
  36452. );
  36453. }
  36454. }
  36455. let transformer = initializer(...args);
  36456. transformer.postcssPlugin = name;
  36457. transformer.postcssVersion = new Processor().version;
  36458. return transformer
  36459. }
  36460. let cache;
  36461. Object.defineProperty(creator, 'postcss', {
  36462. get() {
  36463. if (!cache) cache = creator();
  36464. return cache
  36465. }
  36466. });
  36467. creator.process = function (css, processOpts, pluginOpts) {
  36468. return postcss([creator(pluginOpts)]).process(css, processOpts)
  36469. };
  36470. return creator
  36471. };
  36472. postcss.stringify = stringify;
  36473. postcss.parse = parse;
  36474. postcss.fromJSON = fromJSON;
  36475. postcss.list = list;
  36476. postcss.comment = defaults => new Comment(defaults);
  36477. postcss.atRule = defaults => new AtRule(defaults);
  36478. postcss.decl = defaults => new Declaration(defaults);
  36479. postcss.rule = defaults => new Rule(defaults);
  36480. postcss.root = defaults => new Root(defaults);
  36481. postcss.document = defaults => new Document(defaults);
  36482. postcss.CssSyntaxError = CssSyntaxError;
  36483. postcss.Declaration = Declaration;
  36484. postcss.Container = Container;
  36485. postcss.Processor = Processor;
  36486. postcss.Document = Document;
  36487. postcss.Comment = Comment;
  36488. postcss.Warning = Warning;
  36489. postcss.AtRule = AtRule;
  36490. postcss.Result = Result;
  36491. postcss.Input = Input;
  36492. postcss.Rule = Rule;
  36493. postcss.Root = Root;
  36494. postcss.Node = Node;
  36495. LazyResult.registerPostcss(postcss);
  36496. postcss_1 = postcss;
  36497. postcss.default = postcss;
  36498. return postcss_1;
  36499. }
  36500. var postcssExports = /*@__PURE__*/ requirePostcss();
  36501. var postcss = /*@__PURE__*/getDefaultExportFromCjs(postcssExports);
  36502. postcss.stringify;
  36503. postcss.fromJSON;
  36504. postcss.plugin;
  36505. postcss.parse;
  36506. postcss.list;
  36507. postcss.document;
  36508. postcss.comment;
  36509. postcss.atRule;
  36510. postcss.rule;
  36511. postcss.decl;
  36512. postcss.root;
  36513. postcss.CssSyntaxError;
  36514. postcss.Declaration;
  36515. postcss.Container;
  36516. postcss.Processor;
  36517. postcss.Document;
  36518. postcss.Comment;
  36519. postcss.Warning;
  36520. postcss.AtRule;
  36521. postcss.Result;
  36522. postcss.Input;
  36523. const Rule = postcss.Rule;
  36524. postcss.Root;
  36525. postcss.Node;
  36526. const trimPlugin = () => {
  36527. return {
  36528. postcssPlugin: "vue-sfc-trim",
  36529. Once(root) {
  36530. root.walk(({ type, raws }) => {
  36531. if (type === "rule" || type === "atrule") {
  36532. if (raws.before) raws.before = "\n";
  36533. if ("after" in raws && raws.after) raws.after = "\n";
  36534. }
  36535. });
  36536. }
  36537. };
  36538. };
  36539. trimPlugin.postcss = true;
  36540. var dist = {exports: {}};
  36541. var processor = {exports: {}};
  36542. var parser = {exports: {}};
  36543. var root = {exports: {}};
  36544. var container = {exports: {}};
  36545. var node$1 = {exports: {}};
  36546. var util$1 = {};
  36547. var unesc = {exports: {}};
  36548. var hasRequiredUnesc;
  36549. function requireUnesc () {
  36550. if (hasRequiredUnesc) return unesc.exports;
  36551. hasRequiredUnesc = 1;
  36552. (function (module, exports) {
  36553. exports.__esModule = true;
  36554. exports["default"] = unesc;
  36555. // Many thanks for this post which made this migration much easier.
  36556. // https://mathiasbynens.be/notes/css-escapes
  36557. /**
  36558. *
  36559. * @param {string} str
  36560. * @returns {[string, number]|undefined}
  36561. */
  36562. function gobbleHex(str) {
  36563. var lower = str.toLowerCase();
  36564. var hex = '';
  36565. var spaceTerminated = false;
  36566. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  36567. var code = lower.charCodeAt(i);
  36568. // check to see if we are dealing with a valid hex char [a-f|0-9]
  36569. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  36570. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  36571. spaceTerminated = code === 32;
  36572. if (!valid) {
  36573. break;
  36574. }
  36575. hex += lower[i];
  36576. }
  36577. if (hex.length === 0) {
  36578. return undefined;
  36579. }
  36580. var codePoint = parseInt(hex, 16);
  36581. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  36582. // Add special case for
  36583. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  36584. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  36585. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  36586. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  36587. }
  36588. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  36589. }
  36590. var CONTAINS_ESCAPE = /\\/;
  36591. function unesc(str) {
  36592. var needToProcess = CONTAINS_ESCAPE.test(str);
  36593. if (!needToProcess) {
  36594. return str;
  36595. }
  36596. var ret = "";
  36597. for (var i = 0; i < str.length; i++) {
  36598. if (str[i] === "\\") {
  36599. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  36600. if (gobbled !== undefined) {
  36601. ret += gobbled[0];
  36602. i += gobbled[1];
  36603. continue;
  36604. }
  36605. // Retain a pair of \\ if double escaped `\\\\`
  36606. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  36607. if (str[i + 1] === "\\") {
  36608. ret += "\\";
  36609. i++;
  36610. continue;
  36611. }
  36612. // if \\ is at the end of the string retain it
  36613. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  36614. if (str.length === i + 1) {
  36615. ret += str[i];
  36616. }
  36617. continue;
  36618. }
  36619. ret += str[i];
  36620. }
  36621. return ret;
  36622. }
  36623. module.exports = exports.default;
  36624. } (unesc, unesc.exports));
  36625. return unesc.exports;
  36626. }
  36627. var getProp = {exports: {}};
  36628. var hasRequiredGetProp;
  36629. function requireGetProp () {
  36630. if (hasRequiredGetProp) return getProp.exports;
  36631. hasRequiredGetProp = 1;
  36632. (function (module, exports) {
  36633. exports.__esModule = true;
  36634. exports["default"] = getProp;
  36635. function getProp(obj) {
  36636. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  36637. props[_key - 1] = arguments[_key];
  36638. }
  36639. while (props.length > 0) {
  36640. var prop = props.shift();
  36641. if (!obj[prop]) {
  36642. return undefined;
  36643. }
  36644. obj = obj[prop];
  36645. }
  36646. return obj;
  36647. }
  36648. module.exports = exports.default;
  36649. } (getProp, getProp.exports));
  36650. return getProp.exports;
  36651. }
  36652. var ensureObject = {exports: {}};
  36653. var hasRequiredEnsureObject;
  36654. function requireEnsureObject () {
  36655. if (hasRequiredEnsureObject) return ensureObject.exports;
  36656. hasRequiredEnsureObject = 1;
  36657. (function (module, exports) {
  36658. exports.__esModule = true;
  36659. exports["default"] = ensureObject;
  36660. function ensureObject(obj) {
  36661. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  36662. props[_key - 1] = arguments[_key];
  36663. }
  36664. while (props.length > 0) {
  36665. var prop = props.shift();
  36666. if (!obj[prop]) {
  36667. obj[prop] = {};
  36668. }
  36669. obj = obj[prop];
  36670. }
  36671. }
  36672. module.exports = exports.default;
  36673. } (ensureObject, ensureObject.exports));
  36674. return ensureObject.exports;
  36675. }
  36676. var stripComments = {exports: {}};
  36677. var hasRequiredStripComments;
  36678. function requireStripComments () {
  36679. if (hasRequiredStripComments) return stripComments.exports;
  36680. hasRequiredStripComments = 1;
  36681. (function (module, exports) {
  36682. exports.__esModule = true;
  36683. exports["default"] = stripComments;
  36684. function stripComments(str) {
  36685. var s = "";
  36686. var commentStart = str.indexOf("/*");
  36687. var lastEnd = 0;
  36688. while (commentStart >= 0) {
  36689. s = s + str.slice(lastEnd, commentStart);
  36690. var commentEnd = str.indexOf("*/", commentStart + 2);
  36691. if (commentEnd < 0) {
  36692. return s;
  36693. }
  36694. lastEnd = commentEnd + 2;
  36695. commentStart = str.indexOf("/*", lastEnd);
  36696. }
  36697. s = s + str.slice(lastEnd);
  36698. return s;
  36699. }
  36700. module.exports = exports.default;
  36701. } (stripComments, stripComments.exports));
  36702. return stripComments.exports;
  36703. }
  36704. var hasRequiredUtil$1;
  36705. function requireUtil$1 () {
  36706. if (hasRequiredUtil$1) return util$1;
  36707. hasRequiredUtil$1 = 1;
  36708. util$1.__esModule = true;
  36709. util$1.unesc = util$1.stripComments = util$1.getProp = util$1.ensureObject = void 0;
  36710. var _unesc = _interopRequireDefault(/*@__PURE__*/ requireUnesc());
  36711. util$1.unesc = _unesc["default"];
  36712. var _getProp = _interopRequireDefault(/*@__PURE__*/ requireGetProp());
  36713. util$1.getProp = _getProp["default"];
  36714. var _ensureObject = _interopRequireDefault(/*@__PURE__*/ requireEnsureObject());
  36715. util$1.ensureObject = _ensureObject["default"];
  36716. var _stripComments = _interopRequireDefault(/*@__PURE__*/ requireStripComments());
  36717. util$1.stripComments = _stripComments["default"];
  36718. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36719. return util$1;
  36720. }
  36721. var hasRequiredNode$1;
  36722. function requireNode$1 () {
  36723. if (hasRequiredNode$1) return node$1.exports;
  36724. hasRequiredNode$1 = 1;
  36725. (function (module, exports) {
  36726. exports.__esModule = true;
  36727. exports["default"] = void 0;
  36728. var _util = /*@__PURE__*/ requireUtil$1();
  36729. 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); } }
  36730. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36731. var cloneNode = function cloneNode(obj, parent) {
  36732. if (typeof obj !== 'object' || obj === null) {
  36733. return obj;
  36734. }
  36735. var cloned = new obj.constructor();
  36736. for (var i in obj) {
  36737. if (!obj.hasOwnProperty(i)) {
  36738. continue;
  36739. }
  36740. var value = obj[i];
  36741. var type = typeof value;
  36742. if (i === 'parent' && type === 'object') {
  36743. if (parent) {
  36744. cloned[i] = parent;
  36745. }
  36746. } else if (value instanceof Array) {
  36747. cloned[i] = value.map(function (j) {
  36748. return cloneNode(j, cloned);
  36749. });
  36750. } else {
  36751. cloned[i] = cloneNode(value, cloned);
  36752. }
  36753. }
  36754. return cloned;
  36755. };
  36756. var Node = /*#__PURE__*/function () {
  36757. function Node(opts) {
  36758. if (opts === void 0) {
  36759. opts = {};
  36760. }
  36761. Object.assign(this, opts);
  36762. this.spaces = this.spaces || {};
  36763. this.spaces.before = this.spaces.before || '';
  36764. this.spaces.after = this.spaces.after || '';
  36765. }
  36766. var _proto = Node.prototype;
  36767. _proto.remove = function remove() {
  36768. if (this.parent) {
  36769. this.parent.removeChild(this);
  36770. }
  36771. this.parent = undefined;
  36772. return this;
  36773. };
  36774. _proto.replaceWith = function replaceWith() {
  36775. if (this.parent) {
  36776. for (var index in arguments) {
  36777. this.parent.insertBefore(this, arguments[index]);
  36778. }
  36779. this.remove();
  36780. }
  36781. return this;
  36782. };
  36783. _proto.next = function next() {
  36784. return this.parent.at(this.parent.index(this) + 1);
  36785. };
  36786. _proto.prev = function prev() {
  36787. return this.parent.at(this.parent.index(this) - 1);
  36788. };
  36789. _proto.clone = function clone(overrides) {
  36790. if (overrides === void 0) {
  36791. overrides = {};
  36792. }
  36793. var cloned = cloneNode(this);
  36794. for (var name in overrides) {
  36795. cloned[name] = overrides[name];
  36796. }
  36797. return cloned;
  36798. }
  36799. /**
  36800. * Some non-standard syntax doesn't follow normal escaping rules for css.
  36801. * This allows non standard syntax to be appended to an existing property
  36802. * by specifying the escaped value. By specifying the escaped value,
  36803. * illegal characters are allowed to be directly inserted into css output.
  36804. * @param {string} name the property to set
  36805. * @param {any} value the unescaped value of the property
  36806. * @param {string} valueEscaped optional. the escaped value of the property.
  36807. */;
  36808. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  36809. if (!this.raws) {
  36810. this.raws = {};
  36811. }
  36812. var originalValue = this[name];
  36813. var originalEscaped = this.raws[name];
  36814. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  36815. if (originalEscaped || valueEscaped !== value) {
  36816. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  36817. } else {
  36818. delete this.raws[name]; // delete any escaped value that was created by the setter.
  36819. }
  36820. }
  36821. /**
  36822. * Some non-standard syntax doesn't follow normal escaping rules for css.
  36823. * This allows the escaped value to be specified directly, allowing illegal
  36824. * characters to be directly inserted into css output.
  36825. * @param {string} name the property to set
  36826. * @param {any} value the unescaped value of the property
  36827. * @param {string} valueEscaped the escaped value of the property.
  36828. */;
  36829. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  36830. if (!this.raws) {
  36831. this.raws = {};
  36832. }
  36833. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  36834. this.raws[name] = valueEscaped;
  36835. }
  36836. /**
  36837. * When you want a value to passed through to CSS directly. This method
  36838. * deletes the corresponding raw value causing the stringifier to fallback
  36839. * to the unescaped value.
  36840. * @param {string} name the property to set.
  36841. * @param {any} value The value that is both escaped and unescaped.
  36842. */;
  36843. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  36844. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  36845. if (this.raws) {
  36846. delete this.raws[name];
  36847. }
  36848. }
  36849. /**
  36850. *
  36851. * @param {number} line The number (starting with 1)
  36852. * @param {number} column The column number (starting with 1)
  36853. */;
  36854. _proto.isAtPosition = function isAtPosition(line, column) {
  36855. if (this.source && this.source.start && this.source.end) {
  36856. if (this.source.start.line > line) {
  36857. return false;
  36858. }
  36859. if (this.source.end.line < line) {
  36860. return false;
  36861. }
  36862. if (this.source.start.line === line && this.source.start.column > column) {
  36863. return false;
  36864. }
  36865. if (this.source.end.line === line && this.source.end.column < column) {
  36866. return false;
  36867. }
  36868. return true;
  36869. }
  36870. return undefined;
  36871. };
  36872. _proto.stringifyProperty = function stringifyProperty(name) {
  36873. return this.raws && this.raws[name] || this[name];
  36874. };
  36875. _proto.valueToString = function valueToString() {
  36876. return String(this.stringifyProperty("value"));
  36877. };
  36878. _proto.toString = function toString() {
  36879. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  36880. };
  36881. _createClass(Node, [{
  36882. key: "rawSpaceBefore",
  36883. get: function get() {
  36884. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  36885. if (rawSpace === undefined) {
  36886. rawSpace = this.spaces && this.spaces.before;
  36887. }
  36888. return rawSpace || "";
  36889. },
  36890. set: function set(raw) {
  36891. (0, _util.ensureObject)(this, "raws", "spaces");
  36892. this.raws.spaces.before = raw;
  36893. }
  36894. }, {
  36895. key: "rawSpaceAfter",
  36896. get: function get() {
  36897. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  36898. if (rawSpace === undefined) {
  36899. rawSpace = this.spaces.after;
  36900. }
  36901. return rawSpace || "";
  36902. },
  36903. set: function set(raw) {
  36904. (0, _util.ensureObject)(this, "raws", "spaces");
  36905. this.raws.spaces.after = raw;
  36906. }
  36907. }]);
  36908. return Node;
  36909. }();
  36910. exports["default"] = Node;
  36911. module.exports = exports.default;
  36912. } (node$1, node$1.exports));
  36913. return node$1.exports;
  36914. }
  36915. var types = {};
  36916. var hasRequiredTypes;
  36917. function requireTypes () {
  36918. if (hasRequiredTypes) return types;
  36919. hasRequiredTypes = 1;
  36920. types.__esModule = true;
  36921. types.UNIVERSAL = types.TAG = types.STRING = types.SELECTOR = types.ROOT = types.PSEUDO = types.NESTING = types.ID = types.COMMENT = types.COMBINATOR = types.CLASS = types.ATTRIBUTE = void 0;
  36922. var TAG = 'tag';
  36923. types.TAG = TAG;
  36924. var STRING = 'string';
  36925. types.STRING = STRING;
  36926. var SELECTOR = 'selector';
  36927. types.SELECTOR = SELECTOR;
  36928. var ROOT = 'root';
  36929. types.ROOT = ROOT;
  36930. var PSEUDO = 'pseudo';
  36931. types.PSEUDO = PSEUDO;
  36932. var NESTING = 'nesting';
  36933. types.NESTING = NESTING;
  36934. var ID = 'id';
  36935. types.ID = ID;
  36936. var COMMENT = 'comment';
  36937. types.COMMENT = COMMENT;
  36938. var COMBINATOR = 'combinator';
  36939. types.COMBINATOR = COMBINATOR;
  36940. var CLASS = 'class';
  36941. types.CLASS = CLASS;
  36942. var ATTRIBUTE = 'attribute';
  36943. types.ATTRIBUTE = ATTRIBUTE;
  36944. var UNIVERSAL = 'universal';
  36945. types.UNIVERSAL = UNIVERSAL;
  36946. return types;
  36947. }
  36948. var hasRequiredContainer;
  36949. function requireContainer () {
  36950. if (hasRequiredContainer) return container.exports;
  36951. hasRequiredContainer = 1;
  36952. (function (module, exports) {
  36953. exports.__esModule = true;
  36954. exports["default"] = void 0;
  36955. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  36956. var types = _interopRequireWildcard(/*@__PURE__*/ requireTypes());
  36957. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  36958. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  36959. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36960. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { 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."); }
  36961. 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); }
  36962. 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; }
  36963. 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); } }
  36964. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36965. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36966. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36967. var Container = /*#__PURE__*/function (_Node) {
  36968. _inheritsLoose(Container, _Node);
  36969. function Container(opts) {
  36970. var _this;
  36971. _this = _Node.call(this, opts) || this;
  36972. if (!_this.nodes) {
  36973. _this.nodes = [];
  36974. }
  36975. return _this;
  36976. }
  36977. var _proto = Container.prototype;
  36978. _proto.append = function append(selector) {
  36979. selector.parent = this;
  36980. this.nodes.push(selector);
  36981. return this;
  36982. };
  36983. _proto.prepend = function prepend(selector) {
  36984. selector.parent = this;
  36985. this.nodes.unshift(selector);
  36986. for (var id in this.indexes) {
  36987. this.indexes[id]++;
  36988. }
  36989. return this;
  36990. };
  36991. _proto.at = function at(index) {
  36992. return this.nodes[index];
  36993. };
  36994. _proto.index = function index(child) {
  36995. if (typeof child === 'number') {
  36996. return child;
  36997. }
  36998. return this.nodes.indexOf(child);
  36999. };
  37000. _proto.removeChild = function removeChild(child) {
  37001. child = this.index(child);
  37002. this.at(child).parent = undefined;
  37003. this.nodes.splice(child, 1);
  37004. var index;
  37005. for (var id in this.indexes) {
  37006. index = this.indexes[id];
  37007. if (index >= child) {
  37008. this.indexes[id] = index - 1;
  37009. }
  37010. }
  37011. return this;
  37012. };
  37013. _proto.removeAll = function removeAll() {
  37014. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  37015. var node = _step.value;
  37016. node.parent = undefined;
  37017. }
  37018. this.nodes = [];
  37019. return this;
  37020. };
  37021. _proto.empty = function empty() {
  37022. return this.removeAll();
  37023. };
  37024. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  37025. var _this$nodes;
  37026. newNode.parent = this;
  37027. var oldIndex = this.index(oldNode);
  37028. var resetNode = [];
  37029. for (var i = 2; i < arguments.length; i++) {
  37030. resetNode.push(arguments[i]);
  37031. }
  37032. (_this$nodes = this.nodes).splice.apply(_this$nodes, [oldIndex + 1, 0, newNode].concat(resetNode));
  37033. newNode.parent = this;
  37034. var index;
  37035. for (var id in this.indexes) {
  37036. index = this.indexes[id];
  37037. if (oldIndex < index) {
  37038. this.indexes[id] = index + arguments.length - 1;
  37039. }
  37040. }
  37041. return this;
  37042. };
  37043. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  37044. var _this$nodes2;
  37045. newNode.parent = this;
  37046. var oldIndex = this.index(oldNode);
  37047. var resetNode = [];
  37048. for (var i = 2; i < arguments.length; i++) {
  37049. resetNode.push(arguments[i]);
  37050. }
  37051. (_this$nodes2 = this.nodes).splice.apply(_this$nodes2, [oldIndex, 0, newNode].concat(resetNode));
  37052. newNode.parent = this;
  37053. var index;
  37054. for (var id in this.indexes) {
  37055. index = this.indexes[id];
  37056. if (index >= oldIndex) {
  37057. this.indexes[id] = index + arguments.length - 1;
  37058. }
  37059. }
  37060. return this;
  37061. };
  37062. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  37063. var found = undefined;
  37064. this.each(function (node) {
  37065. if (node.atPosition) {
  37066. var foundChild = node.atPosition(line, col);
  37067. if (foundChild) {
  37068. found = foundChild;
  37069. return false;
  37070. }
  37071. } else if (node.isAtPosition(line, col)) {
  37072. found = node;
  37073. return false;
  37074. }
  37075. });
  37076. return found;
  37077. }
  37078. /**
  37079. * Return the most specific node at the line and column number given.
  37080. * The source location is based on the original parsed location, locations aren't
  37081. * updated as selector nodes are mutated.
  37082. *
  37083. * Note that this location is relative to the location of the first character
  37084. * of the selector, and not the location of the selector in the overall document
  37085. * when used in conjunction with postcss.
  37086. *
  37087. * If not found, returns undefined.
  37088. * @param {number} line The line number of the node to find. (1-based index)
  37089. * @param {number} col The column number of the node to find. (1-based index)
  37090. */;
  37091. _proto.atPosition = function atPosition(line, col) {
  37092. if (this.isAtPosition(line, col)) {
  37093. return this._findChildAtPosition(line, col) || this;
  37094. } else {
  37095. return undefined;
  37096. }
  37097. };
  37098. _proto._inferEndPosition = function _inferEndPosition() {
  37099. if (this.last && this.last.source && this.last.source.end) {
  37100. this.source = this.source || {};
  37101. this.source.end = this.source.end || {};
  37102. Object.assign(this.source.end, this.last.source.end);
  37103. }
  37104. };
  37105. _proto.each = function each(callback) {
  37106. if (!this.lastEach) {
  37107. this.lastEach = 0;
  37108. }
  37109. if (!this.indexes) {
  37110. this.indexes = {};
  37111. }
  37112. this.lastEach++;
  37113. var id = this.lastEach;
  37114. this.indexes[id] = 0;
  37115. if (!this.length) {
  37116. return undefined;
  37117. }
  37118. var index, result;
  37119. while (this.indexes[id] < this.length) {
  37120. index = this.indexes[id];
  37121. result = callback(this.at(index), index);
  37122. if (result === false) {
  37123. break;
  37124. }
  37125. this.indexes[id] += 1;
  37126. }
  37127. delete this.indexes[id];
  37128. if (result === false) {
  37129. return false;
  37130. }
  37131. };
  37132. _proto.walk = function walk(callback) {
  37133. return this.each(function (node, i) {
  37134. var result = callback(node, i);
  37135. if (result !== false && node.length) {
  37136. result = node.walk(callback);
  37137. }
  37138. if (result === false) {
  37139. return false;
  37140. }
  37141. });
  37142. };
  37143. _proto.walkAttributes = function walkAttributes(callback) {
  37144. var _this2 = this;
  37145. return this.walk(function (selector) {
  37146. if (selector.type === types.ATTRIBUTE) {
  37147. return callback.call(_this2, selector);
  37148. }
  37149. });
  37150. };
  37151. _proto.walkClasses = function walkClasses(callback) {
  37152. var _this3 = this;
  37153. return this.walk(function (selector) {
  37154. if (selector.type === types.CLASS) {
  37155. return callback.call(_this3, selector);
  37156. }
  37157. });
  37158. };
  37159. _proto.walkCombinators = function walkCombinators(callback) {
  37160. var _this4 = this;
  37161. return this.walk(function (selector) {
  37162. if (selector.type === types.COMBINATOR) {
  37163. return callback.call(_this4, selector);
  37164. }
  37165. });
  37166. };
  37167. _proto.walkComments = function walkComments(callback) {
  37168. var _this5 = this;
  37169. return this.walk(function (selector) {
  37170. if (selector.type === types.COMMENT) {
  37171. return callback.call(_this5, selector);
  37172. }
  37173. });
  37174. };
  37175. _proto.walkIds = function walkIds(callback) {
  37176. var _this6 = this;
  37177. return this.walk(function (selector) {
  37178. if (selector.type === types.ID) {
  37179. return callback.call(_this6, selector);
  37180. }
  37181. });
  37182. };
  37183. _proto.walkNesting = function walkNesting(callback) {
  37184. var _this7 = this;
  37185. return this.walk(function (selector) {
  37186. if (selector.type === types.NESTING) {
  37187. return callback.call(_this7, selector);
  37188. }
  37189. });
  37190. };
  37191. _proto.walkPseudos = function walkPseudos(callback) {
  37192. var _this8 = this;
  37193. return this.walk(function (selector) {
  37194. if (selector.type === types.PSEUDO) {
  37195. return callback.call(_this8, selector);
  37196. }
  37197. });
  37198. };
  37199. _proto.walkTags = function walkTags(callback) {
  37200. var _this9 = this;
  37201. return this.walk(function (selector) {
  37202. if (selector.type === types.TAG) {
  37203. return callback.call(_this9, selector);
  37204. }
  37205. });
  37206. };
  37207. _proto.walkUniversals = function walkUniversals(callback) {
  37208. var _this10 = this;
  37209. return this.walk(function (selector) {
  37210. if (selector.type === types.UNIVERSAL) {
  37211. return callback.call(_this10, selector);
  37212. }
  37213. });
  37214. };
  37215. _proto.split = function split(callback) {
  37216. var _this11 = this;
  37217. var current = [];
  37218. return this.reduce(function (memo, node, index) {
  37219. var split = callback.call(_this11, node);
  37220. current.push(node);
  37221. if (split) {
  37222. memo.push(current);
  37223. current = [];
  37224. } else if (index === _this11.length - 1) {
  37225. memo.push(current);
  37226. }
  37227. return memo;
  37228. }, []);
  37229. };
  37230. _proto.map = function map(callback) {
  37231. return this.nodes.map(callback);
  37232. };
  37233. _proto.reduce = function reduce(callback, memo) {
  37234. return this.nodes.reduce(callback, memo);
  37235. };
  37236. _proto.every = function every(callback) {
  37237. return this.nodes.every(callback);
  37238. };
  37239. _proto.some = function some(callback) {
  37240. return this.nodes.some(callback);
  37241. };
  37242. _proto.filter = function filter(callback) {
  37243. return this.nodes.filter(callback);
  37244. };
  37245. _proto.sort = function sort(callback) {
  37246. return this.nodes.sort(callback);
  37247. };
  37248. _proto.toString = function toString() {
  37249. return this.map(String).join('');
  37250. };
  37251. _createClass(Container, [{
  37252. key: "first",
  37253. get: function get() {
  37254. return this.at(0);
  37255. }
  37256. }, {
  37257. key: "last",
  37258. get: function get() {
  37259. return this.at(this.length - 1);
  37260. }
  37261. }, {
  37262. key: "length",
  37263. get: function get() {
  37264. return this.nodes.length;
  37265. }
  37266. }]);
  37267. return Container;
  37268. }(_node["default"]);
  37269. exports["default"] = Container;
  37270. module.exports = exports.default;
  37271. } (container, container.exports));
  37272. return container.exports;
  37273. }
  37274. var hasRequiredRoot;
  37275. function requireRoot () {
  37276. if (hasRequiredRoot) return root.exports;
  37277. hasRequiredRoot = 1;
  37278. (function (module, exports) {
  37279. exports.__esModule = true;
  37280. exports["default"] = void 0;
  37281. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  37282. var _types = /*@__PURE__*/ requireTypes();
  37283. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37284. 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); } }
  37285. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  37286. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37287. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37288. var Root = /*#__PURE__*/function (_Container) {
  37289. _inheritsLoose(Root, _Container);
  37290. function Root(opts) {
  37291. var _this;
  37292. _this = _Container.call(this, opts) || this;
  37293. _this.type = _types.ROOT;
  37294. return _this;
  37295. }
  37296. var _proto = Root.prototype;
  37297. _proto.toString = function toString() {
  37298. var str = this.reduce(function (memo, selector) {
  37299. memo.push(String(selector));
  37300. return memo;
  37301. }, []).join(',');
  37302. return this.trailingComma ? str + ',' : str;
  37303. };
  37304. _proto.error = function error(message, options) {
  37305. if (this._error) {
  37306. return this._error(message, options);
  37307. } else {
  37308. return new Error(message);
  37309. }
  37310. };
  37311. _createClass(Root, [{
  37312. key: "errorGenerator",
  37313. set: function set(handler) {
  37314. this._error = handler;
  37315. }
  37316. }]);
  37317. return Root;
  37318. }(_container["default"]);
  37319. exports["default"] = Root;
  37320. module.exports = exports.default;
  37321. } (root, root.exports));
  37322. return root.exports;
  37323. }
  37324. var selector = {exports: {}};
  37325. var hasRequiredSelector;
  37326. function requireSelector () {
  37327. if (hasRequiredSelector) return selector.exports;
  37328. hasRequiredSelector = 1;
  37329. (function (module, exports) {
  37330. exports.__esModule = true;
  37331. exports["default"] = void 0;
  37332. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  37333. var _types = /*@__PURE__*/ requireTypes();
  37334. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37335. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37336. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37337. var Selector = /*#__PURE__*/function (_Container) {
  37338. _inheritsLoose(Selector, _Container);
  37339. function Selector(opts) {
  37340. var _this;
  37341. _this = _Container.call(this, opts) || this;
  37342. _this.type = _types.SELECTOR;
  37343. return _this;
  37344. }
  37345. return Selector;
  37346. }(_container["default"]);
  37347. exports["default"] = Selector;
  37348. module.exports = exports.default;
  37349. } (selector, selector.exports));
  37350. return selector.exports;
  37351. }
  37352. var className = {exports: {}};
  37353. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  37354. var cssesc_1;
  37355. var hasRequiredCssesc;
  37356. function requireCssesc () {
  37357. if (hasRequiredCssesc) return cssesc_1;
  37358. hasRequiredCssesc = 1;
  37359. var object = {};
  37360. var hasOwnProperty = object.hasOwnProperty;
  37361. var merge = function merge(options, defaults) {
  37362. if (!options) {
  37363. return defaults;
  37364. }
  37365. var result = {};
  37366. for (var key in defaults) {
  37367. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  37368. // only recognized option names are used.
  37369. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  37370. }
  37371. return result;
  37372. };
  37373. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  37374. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  37375. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  37376. // https://mathiasbynens.be/notes/css-escapes#css
  37377. var cssesc = function cssesc(string, options) {
  37378. options = merge(options, cssesc.options);
  37379. if (options.quotes != 'single' && options.quotes != 'double') {
  37380. options.quotes = 'single';
  37381. }
  37382. var quote = options.quotes == 'double' ? '"' : '\'';
  37383. var isIdentifier = options.isIdentifier;
  37384. var firstChar = string.charAt(0);
  37385. var output = '';
  37386. var counter = 0;
  37387. var length = string.length;
  37388. while (counter < length) {
  37389. var character = string.charAt(counter++);
  37390. var codePoint = character.charCodeAt();
  37391. var value = void 0;
  37392. // If it’s not a printable ASCII character…
  37393. if (codePoint < 0x20 || codePoint > 0x7E) {
  37394. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  37395. // It’s a high surrogate, and there is a next character.
  37396. var extra = string.charCodeAt(counter++);
  37397. if ((extra & 0xFC00) == 0xDC00) {
  37398. // next character is low surrogate
  37399. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  37400. } else {
  37401. // It’s an unmatched surrogate; only append this code unit, in case
  37402. // the next code unit is the high surrogate of a surrogate pair.
  37403. counter--;
  37404. }
  37405. }
  37406. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  37407. } else {
  37408. if (options.escapeEverything) {
  37409. if (regexAnySingleEscape.test(character)) {
  37410. value = '\\' + character;
  37411. } else {
  37412. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  37413. }
  37414. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  37415. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  37416. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  37417. value = '\\' + character;
  37418. } else {
  37419. value = character;
  37420. }
  37421. }
  37422. output += value;
  37423. }
  37424. if (isIdentifier) {
  37425. if (/^-[-\d]/.test(output)) {
  37426. output = '\\-' + output.slice(1);
  37427. } else if (/\d/.test(firstChar)) {
  37428. output = '\\3' + firstChar + ' ' + output.slice(1);
  37429. }
  37430. }
  37431. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  37432. // since they’re redundant. Note that this is only possible if the escape
  37433. // sequence isn’t preceded by an odd number of backslashes.
  37434. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  37435. if ($1 && $1.length % 2) {
  37436. // It’s not safe to remove the space, so don’t.
  37437. return $0;
  37438. }
  37439. // Strip the space.
  37440. return ($1 || '') + $2;
  37441. });
  37442. if (!isIdentifier && options.wrap) {
  37443. return quote + output + quote;
  37444. }
  37445. return output;
  37446. };
  37447. // Expose default options (so they can be overridden globally).
  37448. cssesc.options = {
  37449. 'escapeEverything': false,
  37450. 'isIdentifier': false,
  37451. 'quotes': 'single',
  37452. 'wrap': false
  37453. };
  37454. cssesc.version = '3.0.0';
  37455. cssesc_1 = cssesc;
  37456. return cssesc_1;
  37457. }
  37458. var hasRequiredClassName;
  37459. function requireClassName () {
  37460. if (hasRequiredClassName) return className.exports;
  37461. hasRequiredClassName = 1;
  37462. (function (module, exports) {
  37463. exports.__esModule = true;
  37464. exports["default"] = void 0;
  37465. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  37466. var _util = /*@__PURE__*/ requireUtil$1();
  37467. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  37468. var _types = /*@__PURE__*/ requireTypes();
  37469. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37470. 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); } }
  37471. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  37472. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37473. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37474. var ClassName = /*#__PURE__*/function (_Node) {
  37475. _inheritsLoose(ClassName, _Node);
  37476. function ClassName(opts) {
  37477. var _this;
  37478. _this = _Node.call(this, opts) || this;
  37479. _this.type = _types.CLASS;
  37480. _this._constructed = true;
  37481. return _this;
  37482. }
  37483. var _proto = ClassName.prototype;
  37484. _proto.valueToString = function valueToString() {
  37485. return '.' + _Node.prototype.valueToString.call(this);
  37486. };
  37487. _createClass(ClassName, [{
  37488. key: "value",
  37489. get: function get() {
  37490. return this._value;
  37491. },
  37492. set: function set(v) {
  37493. if (this._constructed) {
  37494. var escaped = (0, _cssesc["default"])(v, {
  37495. isIdentifier: true
  37496. });
  37497. if (escaped !== v) {
  37498. (0, _util.ensureObject)(this, "raws");
  37499. this.raws.value = escaped;
  37500. } else if (this.raws) {
  37501. delete this.raws.value;
  37502. }
  37503. }
  37504. this._value = v;
  37505. }
  37506. }]);
  37507. return ClassName;
  37508. }(_node["default"]);
  37509. exports["default"] = ClassName;
  37510. module.exports = exports.default;
  37511. } (className, className.exports));
  37512. return className.exports;
  37513. }
  37514. var comment = {exports: {}};
  37515. var hasRequiredComment;
  37516. function requireComment () {
  37517. if (hasRequiredComment) return comment.exports;
  37518. hasRequiredComment = 1;
  37519. (function (module, exports) {
  37520. exports.__esModule = true;
  37521. exports["default"] = void 0;
  37522. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  37523. var _types = /*@__PURE__*/ requireTypes();
  37524. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37525. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37526. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37527. var Comment = /*#__PURE__*/function (_Node) {
  37528. _inheritsLoose(Comment, _Node);
  37529. function Comment(opts) {
  37530. var _this;
  37531. _this = _Node.call(this, opts) || this;
  37532. _this.type = _types.COMMENT;
  37533. return _this;
  37534. }
  37535. return Comment;
  37536. }(_node["default"]);
  37537. exports["default"] = Comment;
  37538. module.exports = exports.default;
  37539. } (comment, comment.exports));
  37540. return comment.exports;
  37541. }
  37542. var id = {exports: {}};
  37543. var hasRequiredId;
  37544. function requireId () {
  37545. if (hasRequiredId) return id.exports;
  37546. hasRequiredId = 1;
  37547. (function (module, exports) {
  37548. exports.__esModule = true;
  37549. exports["default"] = void 0;
  37550. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  37551. var _types = /*@__PURE__*/ requireTypes();
  37552. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37553. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37554. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37555. var ID = /*#__PURE__*/function (_Node) {
  37556. _inheritsLoose(ID, _Node);
  37557. function ID(opts) {
  37558. var _this;
  37559. _this = _Node.call(this, opts) || this;
  37560. _this.type = _types.ID;
  37561. return _this;
  37562. }
  37563. var _proto = ID.prototype;
  37564. _proto.valueToString = function valueToString() {
  37565. return '#' + _Node.prototype.valueToString.call(this);
  37566. };
  37567. return ID;
  37568. }(_node["default"]);
  37569. exports["default"] = ID;
  37570. module.exports = exports.default;
  37571. } (id, id.exports));
  37572. return id.exports;
  37573. }
  37574. var tag = {exports: {}};
  37575. var namespace = {exports: {}};
  37576. var hasRequiredNamespace;
  37577. function requireNamespace () {
  37578. if (hasRequiredNamespace) return namespace.exports;
  37579. hasRequiredNamespace = 1;
  37580. (function (module, exports) {
  37581. exports.__esModule = true;
  37582. exports["default"] = void 0;
  37583. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  37584. var _util = /*@__PURE__*/ requireUtil$1();
  37585. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  37586. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37587. 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); } }
  37588. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  37589. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37590. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37591. var Namespace = /*#__PURE__*/function (_Node) {
  37592. _inheritsLoose(Namespace, _Node);
  37593. function Namespace() {
  37594. return _Node.apply(this, arguments) || this;
  37595. }
  37596. var _proto = Namespace.prototype;
  37597. _proto.qualifiedName = function qualifiedName(value) {
  37598. if (this.namespace) {
  37599. return this.namespaceString + "|" + value;
  37600. } else {
  37601. return value;
  37602. }
  37603. };
  37604. _proto.valueToString = function valueToString() {
  37605. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  37606. };
  37607. _createClass(Namespace, [{
  37608. key: "namespace",
  37609. get: function get() {
  37610. return this._namespace;
  37611. },
  37612. set: function set(namespace) {
  37613. if (namespace === true || namespace === "*" || namespace === "&") {
  37614. this._namespace = namespace;
  37615. if (this.raws) {
  37616. delete this.raws.namespace;
  37617. }
  37618. return;
  37619. }
  37620. var escaped = (0, _cssesc["default"])(namespace, {
  37621. isIdentifier: true
  37622. });
  37623. this._namespace = namespace;
  37624. if (escaped !== namespace) {
  37625. (0, _util.ensureObject)(this, "raws");
  37626. this.raws.namespace = escaped;
  37627. } else if (this.raws) {
  37628. delete this.raws.namespace;
  37629. }
  37630. }
  37631. }, {
  37632. key: "ns",
  37633. get: function get() {
  37634. return this._namespace;
  37635. },
  37636. set: function set(namespace) {
  37637. this.namespace = namespace;
  37638. }
  37639. }, {
  37640. key: "namespaceString",
  37641. get: function get() {
  37642. if (this.namespace) {
  37643. var ns = this.stringifyProperty("namespace");
  37644. if (ns === true) {
  37645. return '';
  37646. } else {
  37647. return ns;
  37648. }
  37649. } else {
  37650. return '';
  37651. }
  37652. }
  37653. }]);
  37654. return Namespace;
  37655. }(_node["default"]);
  37656. exports["default"] = Namespace;
  37657. module.exports = exports.default;
  37658. } (namespace, namespace.exports));
  37659. return namespace.exports;
  37660. }
  37661. var hasRequiredTag;
  37662. function requireTag () {
  37663. if (hasRequiredTag) return tag.exports;
  37664. hasRequiredTag = 1;
  37665. (function (module, exports) {
  37666. exports.__esModule = true;
  37667. exports["default"] = void 0;
  37668. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  37669. var _types = /*@__PURE__*/ requireTypes();
  37670. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37671. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37672. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37673. var Tag = /*#__PURE__*/function (_Namespace) {
  37674. _inheritsLoose(Tag, _Namespace);
  37675. function Tag(opts) {
  37676. var _this;
  37677. _this = _Namespace.call(this, opts) || this;
  37678. _this.type = _types.TAG;
  37679. return _this;
  37680. }
  37681. return Tag;
  37682. }(_namespace["default"]);
  37683. exports["default"] = Tag;
  37684. module.exports = exports.default;
  37685. } (tag, tag.exports));
  37686. return tag.exports;
  37687. }
  37688. var string = {exports: {}};
  37689. var hasRequiredString;
  37690. function requireString () {
  37691. if (hasRequiredString) return string.exports;
  37692. hasRequiredString = 1;
  37693. (function (module, exports) {
  37694. exports.__esModule = true;
  37695. exports["default"] = void 0;
  37696. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  37697. var _types = /*@__PURE__*/ requireTypes();
  37698. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37699. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37700. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37701. var String = /*#__PURE__*/function (_Node) {
  37702. _inheritsLoose(String, _Node);
  37703. function String(opts) {
  37704. var _this;
  37705. _this = _Node.call(this, opts) || this;
  37706. _this.type = _types.STRING;
  37707. return _this;
  37708. }
  37709. return String;
  37710. }(_node["default"]);
  37711. exports["default"] = String;
  37712. module.exports = exports.default;
  37713. } (string, string.exports));
  37714. return string.exports;
  37715. }
  37716. var pseudo = {exports: {}};
  37717. var hasRequiredPseudo;
  37718. function requirePseudo () {
  37719. if (hasRequiredPseudo) return pseudo.exports;
  37720. hasRequiredPseudo = 1;
  37721. (function (module, exports) {
  37722. exports.__esModule = true;
  37723. exports["default"] = void 0;
  37724. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  37725. var _types = /*@__PURE__*/ requireTypes();
  37726. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37727. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37728. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37729. var Pseudo = /*#__PURE__*/function (_Container) {
  37730. _inheritsLoose(Pseudo, _Container);
  37731. function Pseudo(opts) {
  37732. var _this;
  37733. _this = _Container.call(this, opts) || this;
  37734. _this.type = _types.PSEUDO;
  37735. return _this;
  37736. }
  37737. var _proto = Pseudo.prototype;
  37738. _proto.toString = function toString() {
  37739. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  37740. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  37741. };
  37742. return Pseudo;
  37743. }(_container["default"]);
  37744. exports["default"] = Pseudo;
  37745. module.exports = exports.default;
  37746. } (pseudo, pseudo.exports));
  37747. return pseudo.exports;
  37748. }
  37749. var attribute = {};
  37750. var node;
  37751. var hasRequiredNode;
  37752. function requireNode () {
  37753. if (hasRequiredNode) return node;
  37754. hasRequiredNode = 1;
  37755. /**
  37756. * For Node.js, simply re-export the core `util.deprecate` function.
  37757. */
  37758. node = require$$0.deprecate;
  37759. return node;
  37760. }
  37761. var hasRequiredAttribute;
  37762. function requireAttribute () {
  37763. if (hasRequiredAttribute) return attribute;
  37764. hasRequiredAttribute = 1;
  37765. (function (exports) {
  37766. exports.__esModule = true;
  37767. exports["default"] = void 0;
  37768. exports.unescapeValue = unescapeValue;
  37769. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  37770. var _unesc = _interopRequireDefault(/*@__PURE__*/ requireUnesc());
  37771. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  37772. var _types = /*@__PURE__*/ requireTypes();
  37773. var _CSSESC_QUOTE_OPTIONS;
  37774. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37775. 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); } }
  37776. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  37777. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  37778. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37779. var deprecate = /*@__PURE__*/ requireNode();
  37780. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  37781. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  37782. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  37783. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  37784. function unescapeValue(value) {
  37785. var deprecatedUsage = false;
  37786. var quoteMark = null;
  37787. var unescaped = value;
  37788. var m = unescaped.match(WRAPPED_IN_QUOTES);
  37789. if (m) {
  37790. quoteMark = m[1];
  37791. unescaped = m[2];
  37792. }
  37793. unescaped = (0, _unesc["default"])(unescaped);
  37794. if (unescaped !== value) {
  37795. deprecatedUsage = true;
  37796. }
  37797. return {
  37798. deprecatedUsage: deprecatedUsage,
  37799. unescaped: unescaped,
  37800. quoteMark: quoteMark
  37801. };
  37802. }
  37803. function handleDeprecatedContructorOpts(opts) {
  37804. if (opts.quoteMark !== undefined) {
  37805. return opts;
  37806. }
  37807. if (opts.value === undefined) {
  37808. return opts;
  37809. }
  37810. warnOfDeprecatedConstructor();
  37811. var _unescapeValue = unescapeValue(opts.value),
  37812. quoteMark = _unescapeValue.quoteMark,
  37813. unescaped = _unescapeValue.unescaped;
  37814. if (!opts.raws) {
  37815. opts.raws = {};
  37816. }
  37817. if (opts.raws.value === undefined) {
  37818. opts.raws.value = opts.value;
  37819. }
  37820. opts.value = unescaped;
  37821. opts.quoteMark = quoteMark;
  37822. return opts;
  37823. }
  37824. var Attribute = /*#__PURE__*/function (_Namespace) {
  37825. _inheritsLoose(Attribute, _Namespace);
  37826. function Attribute(opts) {
  37827. var _this;
  37828. if (opts === void 0) {
  37829. opts = {};
  37830. }
  37831. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  37832. _this.type = _types.ATTRIBUTE;
  37833. _this.raws = _this.raws || {};
  37834. Object.defineProperty(_this.raws, 'unquoted', {
  37835. get: deprecate(function () {
  37836. return _this.value;
  37837. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  37838. set: deprecate(function () {
  37839. return _this.value;
  37840. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  37841. });
  37842. _this._constructed = true;
  37843. return _this;
  37844. }
  37845. /**
  37846. * Returns the Attribute's value quoted such that it would be legal to use
  37847. * in the value of a css file. The original value's quotation setting
  37848. * used for stringification is left unchanged. See `setValue(value, options)`
  37849. * if you want to control the quote settings of a new value for the attribute.
  37850. *
  37851. * You can also change the quotation used for the current value by setting quoteMark.
  37852. *
  37853. * Options:
  37854. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  37855. * option is not set, the original value for quoteMark will be used. If
  37856. * indeterminate, a double quote is used. The legal values are:
  37857. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  37858. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  37859. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  37860. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  37861. * over the quoteMark option value.
  37862. * * smart {boolean} - if true, will select a quote mark based on the value
  37863. * and the other options specified here. See the `smartQuoteMark()`
  37864. * method.
  37865. **/
  37866. var _proto = Attribute.prototype;
  37867. _proto.getQuotedValue = function getQuotedValue(options) {
  37868. if (options === void 0) {
  37869. options = {};
  37870. }
  37871. var quoteMark = this._determineQuoteMark(options);
  37872. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  37873. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  37874. return escaped;
  37875. };
  37876. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  37877. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  37878. }
  37879. /**
  37880. * Set the unescaped value with the specified quotation options. The value
  37881. * provided must not include any wrapping quote marks -- those quotes will
  37882. * be interpreted as part of the value and escaped accordingly.
  37883. */;
  37884. _proto.setValue = function setValue(value, options) {
  37885. if (options === void 0) {
  37886. options = {};
  37887. }
  37888. this._value = value;
  37889. this._quoteMark = this._determineQuoteMark(options);
  37890. this._syncRawValue();
  37891. }
  37892. /**
  37893. * Intelligently select a quoteMark value based on the value's contents. If
  37894. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  37895. * mark will be picked that minimizes the number of escapes.
  37896. *
  37897. * If there's no clear winner, the quote mark from these options is used,
  37898. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  37899. * true). If the quoteMark is unspecified, a double quote is used.
  37900. *
  37901. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  37902. * from the quoteValue method.
  37903. */;
  37904. _proto.smartQuoteMark = function smartQuoteMark(options) {
  37905. var v = this.value;
  37906. var numSingleQuotes = v.replace(/[^']/g, '').length;
  37907. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  37908. if (numSingleQuotes + numDoubleQuotes === 0) {
  37909. var escaped = (0, _cssesc["default"])(v, {
  37910. isIdentifier: true
  37911. });
  37912. if (escaped === v) {
  37913. return Attribute.NO_QUOTE;
  37914. } else {
  37915. var pref = this.preferredQuoteMark(options);
  37916. if (pref === Attribute.NO_QUOTE) {
  37917. // pick a quote mark that isn't none and see if it's smaller
  37918. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  37919. var opts = CSSESC_QUOTE_OPTIONS[quote];
  37920. var quoteValue = (0, _cssesc["default"])(v, opts);
  37921. if (quoteValue.length < escaped.length) {
  37922. return quote;
  37923. }
  37924. }
  37925. return pref;
  37926. }
  37927. } else if (numDoubleQuotes === numSingleQuotes) {
  37928. return this.preferredQuoteMark(options);
  37929. } else if (numDoubleQuotes < numSingleQuotes) {
  37930. return Attribute.DOUBLE_QUOTE;
  37931. } else {
  37932. return Attribute.SINGLE_QUOTE;
  37933. }
  37934. }
  37935. /**
  37936. * Selects the preferred quote mark based on the options and the current quote mark value.
  37937. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  37938. * instead.
  37939. */;
  37940. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  37941. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  37942. if (quoteMark === undefined) {
  37943. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  37944. }
  37945. if (quoteMark === undefined) {
  37946. quoteMark = Attribute.DOUBLE_QUOTE;
  37947. }
  37948. return quoteMark;
  37949. };
  37950. _proto._syncRawValue = function _syncRawValue() {
  37951. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  37952. if (rawValue === this._value) {
  37953. if (this.raws) {
  37954. delete this.raws.value;
  37955. }
  37956. } else {
  37957. this.raws.value = rawValue;
  37958. }
  37959. };
  37960. _proto._handleEscapes = function _handleEscapes(prop, value) {
  37961. if (this._constructed) {
  37962. var escaped = (0, _cssesc["default"])(value, {
  37963. isIdentifier: true
  37964. });
  37965. if (escaped !== value) {
  37966. this.raws[prop] = escaped;
  37967. } else {
  37968. delete this.raws[prop];
  37969. }
  37970. }
  37971. };
  37972. _proto._spacesFor = function _spacesFor(name) {
  37973. var attrSpaces = {
  37974. before: '',
  37975. after: ''
  37976. };
  37977. var spaces = this.spaces[name] || {};
  37978. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  37979. return Object.assign(attrSpaces, spaces, rawSpaces);
  37980. };
  37981. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  37982. if (spaceName === void 0) {
  37983. spaceName = name;
  37984. }
  37985. if (concat === void 0) {
  37986. concat = defaultAttrConcat;
  37987. }
  37988. var attrSpaces = this._spacesFor(spaceName);
  37989. return concat(this.stringifyProperty(name), attrSpaces);
  37990. }
  37991. /**
  37992. * returns the offset of the attribute part specified relative to the
  37993. * start of the node of the output string.
  37994. *
  37995. * * "ns" - alias for "namespace"
  37996. * * "namespace" - the namespace if it exists.
  37997. * * "attribute" - the attribute name
  37998. * * "attributeNS" - the start of the attribute or its namespace
  37999. * * "operator" - the match operator of the attribute
  38000. * * "value" - The value (string or identifier)
  38001. * * "insensitive" - the case insensitivity flag;
  38002. * @param part One of the possible values inside an attribute.
  38003. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  38004. */;
  38005. _proto.offsetOf = function offsetOf(name) {
  38006. var count = 1;
  38007. var attributeSpaces = this._spacesFor("attribute");
  38008. count += attributeSpaces.before.length;
  38009. if (name === "namespace" || name === "ns") {
  38010. return this.namespace ? count : -1;
  38011. }
  38012. if (name === "attributeNS") {
  38013. return count;
  38014. }
  38015. count += this.namespaceString.length;
  38016. if (this.namespace) {
  38017. count += 1;
  38018. }
  38019. if (name === "attribute") {
  38020. return count;
  38021. }
  38022. count += this.stringifyProperty("attribute").length;
  38023. count += attributeSpaces.after.length;
  38024. var operatorSpaces = this._spacesFor("operator");
  38025. count += operatorSpaces.before.length;
  38026. var operator = this.stringifyProperty("operator");
  38027. if (name === "operator") {
  38028. return operator ? count : -1;
  38029. }
  38030. count += operator.length;
  38031. count += operatorSpaces.after.length;
  38032. var valueSpaces = this._spacesFor("value");
  38033. count += valueSpaces.before.length;
  38034. var value = this.stringifyProperty("value");
  38035. if (name === "value") {
  38036. return value ? count : -1;
  38037. }
  38038. count += value.length;
  38039. count += valueSpaces.after.length;
  38040. var insensitiveSpaces = this._spacesFor("insensitive");
  38041. count += insensitiveSpaces.before.length;
  38042. if (name === "insensitive") {
  38043. return this.insensitive ? count : -1;
  38044. }
  38045. return -1;
  38046. };
  38047. _proto.toString = function toString() {
  38048. var _this2 = this;
  38049. var selector = [this.rawSpaceBefore, '['];
  38050. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  38051. if (this.operator && (this.value || this.value === '')) {
  38052. selector.push(this._stringFor('operator'));
  38053. selector.push(this._stringFor('value'));
  38054. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  38055. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  38056. attrSpaces.before = " ";
  38057. }
  38058. return defaultAttrConcat(attrValue, attrSpaces);
  38059. }));
  38060. }
  38061. selector.push(']');
  38062. selector.push(this.rawSpaceAfter);
  38063. return selector.join('');
  38064. };
  38065. _createClass(Attribute, [{
  38066. key: "quoted",
  38067. get: function get() {
  38068. var qm = this.quoteMark;
  38069. return qm === "'" || qm === '"';
  38070. },
  38071. set: function set(value) {
  38072. warnOfDeprecatedQuotedAssignment();
  38073. }
  38074. /**
  38075. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  38076. * returns `null` if the value is not quoted.
  38077. * returns `undefined` if the quotation state is unknown (this can happen when
  38078. * the attribute is constructed without specifying a quote mark.)
  38079. */
  38080. }, {
  38081. key: "quoteMark",
  38082. get: function get() {
  38083. return this._quoteMark;
  38084. }
  38085. /**
  38086. * Set the quote mark to be used by this attribute's value.
  38087. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  38088. * value is updated accordingly.
  38089. *
  38090. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  38091. */,
  38092. set: function set(quoteMark) {
  38093. if (!this._constructed) {
  38094. this._quoteMark = quoteMark;
  38095. return;
  38096. }
  38097. if (this._quoteMark !== quoteMark) {
  38098. this._quoteMark = quoteMark;
  38099. this._syncRawValue();
  38100. }
  38101. }
  38102. }, {
  38103. key: "qualifiedAttribute",
  38104. get: function get() {
  38105. return this.qualifiedName(this.raws.attribute || this.attribute);
  38106. }
  38107. }, {
  38108. key: "insensitiveFlag",
  38109. get: function get() {
  38110. return this.insensitive ? 'i' : '';
  38111. }
  38112. }, {
  38113. key: "value",
  38114. get: function get() {
  38115. return this._value;
  38116. },
  38117. set:
  38118. /**
  38119. * Before 3.0, the value had to be set to an escaped value including any wrapped
  38120. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  38121. * is unescaped during parsing and any quote marks are removed.
  38122. *
  38123. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  38124. * a deprecation warning is raised when the new value contains any characters that would
  38125. * require escaping (including if it contains wrapped quotes).
  38126. *
  38127. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  38128. * how the new value is quoted.
  38129. */
  38130. function set(v) {
  38131. if (this._constructed) {
  38132. var _unescapeValue2 = unescapeValue(v),
  38133. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  38134. unescaped = _unescapeValue2.unescaped,
  38135. quoteMark = _unescapeValue2.quoteMark;
  38136. if (deprecatedUsage) {
  38137. warnOfDeprecatedValueAssignment();
  38138. }
  38139. if (unescaped === this._value && quoteMark === this._quoteMark) {
  38140. return;
  38141. }
  38142. this._value = unescaped;
  38143. this._quoteMark = quoteMark;
  38144. this._syncRawValue();
  38145. } else {
  38146. this._value = v;
  38147. }
  38148. }
  38149. }, {
  38150. key: "insensitive",
  38151. get: function get() {
  38152. return this._insensitive;
  38153. }
  38154. /**
  38155. * Set the case insensitive flag.
  38156. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  38157. * of the attribute is updated accordingly.
  38158. *
  38159. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  38160. */,
  38161. set: function set(insensitive) {
  38162. if (!insensitive) {
  38163. this._insensitive = false;
  38164. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  38165. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  38166. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  38167. this.raws.insensitiveFlag = undefined;
  38168. }
  38169. }
  38170. this._insensitive = insensitive;
  38171. }
  38172. }, {
  38173. key: "attribute",
  38174. get: function get() {
  38175. return this._attribute;
  38176. },
  38177. set: function set(name) {
  38178. this._handleEscapes("attribute", name);
  38179. this._attribute = name;
  38180. }
  38181. }]);
  38182. return Attribute;
  38183. }(_namespace["default"]);
  38184. exports["default"] = Attribute;
  38185. Attribute.NO_QUOTE = null;
  38186. Attribute.SINGLE_QUOTE = "'";
  38187. Attribute.DOUBLE_QUOTE = '"';
  38188. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  38189. "'": {
  38190. quotes: 'single',
  38191. wrap: true
  38192. },
  38193. '"': {
  38194. quotes: 'double',
  38195. wrap: true
  38196. }
  38197. }, _CSSESC_QUOTE_OPTIONS[null] = {
  38198. isIdentifier: true
  38199. }, _CSSESC_QUOTE_OPTIONS);
  38200. function defaultAttrConcat(attrValue, attrSpaces) {
  38201. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  38202. }
  38203. } (attribute));
  38204. return attribute;
  38205. }
  38206. var universal = {exports: {}};
  38207. var hasRequiredUniversal;
  38208. function requireUniversal () {
  38209. if (hasRequiredUniversal) return universal.exports;
  38210. hasRequiredUniversal = 1;
  38211. (function (module, exports) {
  38212. exports.__esModule = true;
  38213. exports["default"] = void 0;
  38214. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  38215. var _types = /*@__PURE__*/ requireTypes();
  38216. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38217. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  38218. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38219. var Universal = /*#__PURE__*/function (_Namespace) {
  38220. _inheritsLoose(Universal, _Namespace);
  38221. function Universal(opts) {
  38222. var _this;
  38223. _this = _Namespace.call(this, opts) || this;
  38224. _this.type = _types.UNIVERSAL;
  38225. _this.value = '*';
  38226. return _this;
  38227. }
  38228. return Universal;
  38229. }(_namespace["default"]);
  38230. exports["default"] = Universal;
  38231. module.exports = exports.default;
  38232. } (universal, universal.exports));
  38233. return universal.exports;
  38234. }
  38235. var combinator = {exports: {}};
  38236. var hasRequiredCombinator;
  38237. function requireCombinator () {
  38238. if (hasRequiredCombinator) return combinator.exports;
  38239. hasRequiredCombinator = 1;
  38240. (function (module, exports) {
  38241. exports.__esModule = true;
  38242. exports["default"] = void 0;
  38243. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  38244. var _types = /*@__PURE__*/ requireTypes();
  38245. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38246. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  38247. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38248. var Combinator = /*#__PURE__*/function (_Node) {
  38249. _inheritsLoose(Combinator, _Node);
  38250. function Combinator(opts) {
  38251. var _this;
  38252. _this = _Node.call(this, opts) || this;
  38253. _this.type = _types.COMBINATOR;
  38254. return _this;
  38255. }
  38256. return Combinator;
  38257. }(_node["default"]);
  38258. exports["default"] = Combinator;
  38259. module.exports = exports.default;
  38260. } (combinator, combinator.exports));
  38261. return combinator.exports;
  38262. }
  38263. var nesting = {exports: {}};
  38264. var hasRequiredNesting;
  38265. function requireNesting () {
  38266. if (hasRequiredNesting) return nesting.exports;
  38267. hasRequiredNesting = 1;
  38268. (function (module, exports) {
  38269. exports.__esModule = true;
  38270. exports["default"] = void 0;
  38271. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  38272. var _types = /*@__PURE__*/ requireTypes();
  38273. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38274. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  38275. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38276. var Nesting = /*#__PURE__*/function (_Node) {
  38277. _inheritsLoose(Nesting, _Node);
  38278. function Nesting(opts) {
  38279. var _this;
  38280. _this = _Node.call(this, opts) || this;
  38281. _this.type = _types.NESTING;
  38282. _this.value = '&';
  38283. return _this;
  38284. }
  38285. return Nesting;
  38286. }(_node["default"]);
  38287. exports["default"] = Nesting;
  38288. module.exports = exports.default;
  38289. } (nesting, nesting.exports));
  38290. return nesting.exports;
  38291. }
  38292. var sortAscending = {exports: {}};
  38293. var hasRequiredSortAscending;
  38294. function requireSortAscending () {
  38295. if (hasRequiredSortAscending) return sortAscending.exports;
  38296. hasRequiredSortAscending = 1;
  38297. (function (module, exports) {
  38298. exports.__esModule = true;
  38299. exports["default"] = sortAscending;
  38300. function sortAscending(list) {
  38301. return list.sort(function (a, b) {
  38302. return a - b;
  38303. });
  38304. }
  38305. module.exports = exports.default;
  38306. } (sortAscending, sortAscending.exports));
  38307. return sortAscending.exports;
  38308. }
  38309. var tokenize = {};
  38310. var tokenTypes = {};
  38311. var hasRequiredTokenTypes;
  38312. function requireTokenTypes () {
  38313. if (hasRequiredTokenTypes) return tokenTypes;
  38314. hasRequiredTokenTypes = 1;
  38315. tokenTypes.__esModule = true;
  38316. tokenTypes.word = tokenTypes.tilde = tokenTypes.tab = tokenTypes.str = tokenTypes.space = tokenTypes.slash = tokenTypes.singleQuote = tokenTypes.semicolon = tokenTypes.plus = tokenTypes.pipe = tokenTypes.openSquare = tokenTypes.openParenthesis = tokenTypes.newline = tokenTypes.greaterThan = tokenTypes.feed = tokenTypes.equals = tokenTypes.doubleQuote = tokenTypes.dollar = tokenTypes.cr = tokenTypes.comment = tokenTypes.comma = tokenTypes.combinator = tokenTypes.colon = tokenTypes.closeSquare = tokenTypes.closeParenthesis = tokenTypes.caret = tokenTypes.bang = tokenTypes.backslash = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  38317. var ampersand = 38; // `&`.charCodeAt(0);
  38318. tokenTypes.ampersand = ampersand;
  38319. var asterisk = 42; // `*`.charCodeAt(0);
  38320. tokenTypes.asterisk = asterisk;
  38321. var at = 64; // `@`.charCodeAt(0);
  38322. tokenTypes.at = at;
  38323. var comma = 44; // `,`.charCodeAt(0);
  38324. tokenTypes.comma = comma;
  38325. var colon = 58; // `:`.charCodeAt(0);
  38326. tokenTypes.colon = colon;
  38327. var semicolon = 59; // `;`.charCodeAt(0);
  38328. tokenTypes.semicolon = semicolon;
  38329. var openParenthesis = 40; // `(`.charCodeAt(0);
  38330. tokenTypes.openParenthesis = openParenthesis;
  38331. var closeParenthesis = 41; // `)`.charCodeAt(0);
  38332. tokenTypes.closeParenthesis = closeParenthesis;
  38333. var openSquare = 91; // `[`.charCodeAt(0);
  38334. tokenTypes.openSquare = openSquare;
  38335. var closeSquare = 93; // `]`.charCodeAt(0);
  38336. tokenTypes.closeSquare = closeSquare;
  38337. var dollar = 36; // `$`.charCodeAt(0);
  38338. tokenTypes.dollar = dollar;
  38339. var tilde = 126; // `~`.charCodeAt(0);
  38340. tokenTypes.tilde = tilde;
  38341. var caret = 94; // `^`.charCodeAt(0);
  38342. tokenTypes.caret = caret;
  38343. var plus = 43; // `+`.charCodeAt(0);
  38344. tokenTypes.plus = plus;
  38345. var equals = 61; // `=`.charCodeAt(0);
  38346. tokenTypes.equals = equals;
  38347. var pipe = 124; // `|`.charCodeAt(0);
  38348. tokenTypes.pipe = pipe;
  38349. var greaterThan = 62; // `>`.charCodeAt(0);
  38350. tokenTypes.greaterThan = greaterThan;
  38351. var space = 32; // ` `.charCodeAt(0);
  38352. tokenTypes.space = space;
  38353. var singleQuote = 39; // `'`.charCodeAt(0);
  38354. tokenTypes.singleQuote = singleQuote;
  38355. var doubleQuote = 34; // `"`.charCodeAt(0);
  38356. tokenTypes.doubleQuote = doubleQuote;
  38357. var slash = 47; // `/`.charCodeAt(0);
  38358. tokenTypes.slash = slash;
  38359. var bang = 33; // `!`.charCodeAt(0);
  38360. tokenTypes.bang = bang;
  38361. var backslash = 92; // '\\'.charCodeAt(0);
  38362. tokenTypes.backslash = backslash;
  38363. var cr = 13; // '\r'.charCodeAt(0);
  38364. tokenTypes.cr = cr;
  38365. var feed = 12; // '\f'.charCodeAt(0);
  38366. tokenTypes.feed = feed;
  38367. var newline = 10; // '\n'.charCodeAt(0);
  38368. tokenTypes.newline = newline;
  38369. var tab = 9; // '\t'.charCodeAt(0);
  38370. // Expose aliases primarily for readability.
  38371. tokenTypes.tab = tab;
  38372. var str = singleQuote;
  38373. // No good single character representation!
  38374. tokenTypes.str = str;
  38375. var comment = -1;
  38376. tokenTypes.comment = comment;
  38377. var word = -2;
  38378. tokenTypes.word = word;
  38379. var combinator = -3;
  38380. tokenTypes.combinator = combinator;
  38381. return tokenTypes;
  38382. }
  38383. var hasRequiredTokenize;
  38384. function requireTokenize () {
  38385. if (hasRequiredTokenize) return tokenize;
  38386. hasRequiredTokenize = 1;
  38387. (function (exports) {
  38388. exports.__esModule = true;
  38389. exports.FIELDS = void 0;
  38390. exports["default"] = tokenize;
  38391. var t = _interopRequireWildcard(/*@__PURE__*/ requireTokenTypes());
  38392. var _unescapable, _wordDelimiters;
  38393. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  38394. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  38395. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  38396. 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);
  38397. var hex = {};
  38398. var hexChars = "0123456789abcdefABCDEF";
  38399. for (var i = 0; i < hexChars.length; i++) {
  38400. hex[hexChars.charCodeAt(i)] = true;
  38401. }
  38402. /**
  38403. * Returns the last index of the bar css word
  38404. * @param {string} css The string in which the word begins
  38405. * @param {number} start The index into the string where word's first letter occurs
  38406. */
  38407. function consumeWord(css, start) {
  38408. var next = start;
  38409. var code;
  38410. do {
  38411. code = css.charCodeAt(next);
  38412. if (wordDelimiters[code]) {
  38413. return next - 1;
  38414. } else if (code === t.backslash) {
  38415. next = consumeEscape(css, next) + 1;
  38416. } else {
  38417. // All other characters are part of the word
  38418. next++;
  38419. }
  38420. } while (next < css.length);
  38421. return next - 1;
  38422. }
  38423. /**
  38424. * Returns the last index of the escape sequence
  38425. * @param {string} css The string in which the sequence begins
  38426. * @param {number} start The index into the string where escape character (`\`) occurs.
  38427. */
  38428. function consumeEscape(css, start) {
  38429. var next = start;
  38430. var code = css.charCodeAt(next + 1);
  38431. if (unescapable[code]) ; else if (hex[code]) {
  38432. var hexDigits = 0;
  38433. // consume up to 6 hex chars
  38434. do {
  38435. next++;
  38436. hexDigits++;
  38437. code = css.charCodeAt(next + 1);
  38438. } while (hex[code] && hexDigits < 6);
  38439. // if fewer than 6 hex chars, a trailing space ends the escape
  38440. if (hexDigits < 6 && code === t.space) {
  38441. next++;
  38442. }
  38443. } else {
  38444. // the next char is part of the current word
  38445. next++;
  38446. }
  38447. return next;
  38448. }
  38449. var FIELDS = {
  38450. TYPE: 0,
  38451. START_LINE: 1,
  38452. START_COL: 2,
  38453. END_LINE: 3,
  38454. END_COL: 4,
  38455. START_POS: 5,
  38456. END_POS: 6
  38457. };
  38458. exports.FIELDS = FIELDS;
  38459. function tokenize(input) {
  38460. var tokens = [];
  38461. var css = input.css.valueOf();
  38462. var _css = css,
  38463. length = _css.length;
  38464. var offset = -1;
  38465. var line = 1;
  38466. var start = 0;
  38467. var end = 0;
  38468. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  38469. function unclosed(what, fix) {
  38470. if (input.safe) {
  38471. // fyi: this is never set to true.
  38472. css += fix;
  38473. next = css.length - 1;
  38474. } else {
  38475. throw input.error('Unclosed ' + what, line, start - offset, start);
  38476. }
  38477. }
  38478. while (start < length) {
  38479. code = css.charCodeAt(start);
  38480. if (code === t.newline) {
  38481. offset = start;
  38482. line += 1;
  38483. }
  38484. switch (code) {
  38485. case t.space:
  38486. case t.tab:
  38487. case t.newline:
  38488. case t.cr:
  38489. case t.feed:
  38490. next = start;
  38491. do {
  38492. next += 1;
  38493. code = css.charCodeAt(next);
  38494. if (code === t.newline) {
  38495. offset = next;
  38496. line += 1;
  38497. }
  38498. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  38499. tokenType = t.space;
  38500. endLine = line;
  38501. endColumn = next - offset - 1;
  38502. end = next;
  38503. break;
  38504. case t.plus:
  38505. case t.greaterThan:
  38506. case t.tilde:
  38507. case t.pipe:
  38508. next = start;
  38509. do {
  38510. next += 1;
  38511. code = css.charCodeAt(next);
  38512. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  38513. tokenType = t.combinator;
  38514. endLine = line;
  38515. endColumn = start - offset;
  38516. end = next;
  38517. break;
  38518. // Consume these characters as single tokens.
  38519. case t.asterisk:
  38520. case t.ampersand:
  38521. case t.bang:
  38522. case t.comma:
  38523. case t.equals:
  38524. case t.dollar:
  38525. case t.caret:
  38526. case t.openSquare:
  38527. case t.closeSquare:
  38528. case t.colon:
  38529. case t.semicolon:
  38530. case t.openParenthesis:
  38531. case t.closeParenthesis:
  38532. next = start;
  38533. tokenType = code;
  38534. endLine = line;
  38535. endColumn = start - offset;
  38536. end = next + 1;
  38537. break;
  38538. case t.singleQuote:
  38539. case t.doubleQuote:
  38540. quote = code === t.singleQuote ? "'" : '"';
  38541. next = start;
  38542. do {
  38543. escaped = false;
  38544. next = css.indexOf(quote, next + 1);
  38545. if (next === -1) {
  38546. unclosed('quote', quote);
  38547. }
  38548. escapePos = next;
  38549. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  38550. escapePos -= 1;
  38551. escaped = !escaped;
  38552. }
  38553. } while (escaped);
  38554. tokenType = t.str;
  38555. endLine = line;
  38556. endColumn = start - offset;
  38557. end = next + 1;
  38558. break;
  38559. default:
  38560. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  38561. next = css.indexOf('*/', start + 2) + 1;
  38562. if (next === 0) {
  38563. unclosed('comment', '*/');
  38564. }
  38565. content = css.slice(start, next + 1);
  38566. lines = content.split('\n');
  38567. last = lines.length - 1;
  38568. if (last > 0) {
  38569. nextLine = line + last;
  38570. nextOffset = next - lines[last].length;
  38571. } else {
  38572. nextLine = line;
  38573. nextOffset = offset;
  38574. }
  38575. tokenType = t.comment;
  38576. line = nextLine;
  38577. endLine = nextLine;
  38578. endColumn = next - nextOffset;
  38579. } else if (code === t.slash) {
  38580. next = start;
  38581. tokenType = code;
  38582. endLine = line;
  38583. endColumn = start - offset;
  38584. end = next + 1;
  38585. } else {
  38586. next = consumeWord(css, start);
  38587. tokenType = t.word;
  38588. endLine = line;
  38589. endColumn = next - offset;
  38590. }
  38591. end = next + 1;
  38592. break;
  38593. }
  38594. // Ensure that the token structure remains consistent
  38595. tokens.push([tokenType,
  38596. // [0] Token type
  38597. line,
  38598. // [1] Starting line
  38599. start - offset,
  38600. // [2] Starting column
  38601. endLine,
  38602. // [3] Ending line
  38603. endColumn,
  38604. // [4] Ending column
  38605. start,
  38606. // [5] Start position / Source index
  38607. end // [6] End position
  38608. ]);
  38609. // Reset offset for the next token
  38610. if (nextOffset) {
  38611. offset = nextOffset;
  38612. nextOffset = null;
  38613. }
  38614. start = end;
  38615. }
  38616. return tokens;
  38617. }
  38618. } (tokenize));
  38619. return tokenize;
  38620. }
  38621. var hasRequiredParser;
  38622. function requireParser () {
  38623. if (hasRequiredParser) return parser.exports;
  38624. hasRequiredParser = 1;
  38625. (function (module, exports) {
  38626. exports.__esModule = true;
  38627. exports["default"] = void 0;
  38628. var _root = _interopRequireDefault(/*@__PURE__*/ requireRoot());
  38629. var _selector = _interopRequireDefault(/*@__PURE__*/ requireSelector());
  38630. var _className = _interopRequireDefault(/*@__PURE__*/ requireClassName());
  38631. var _comment = _interopRequireDefault(/*@__PURE__*/ requireComment());
  38632. var _id = _interopRequireDefault(/*@__PURE__*/ requireId());
  38633. var _tag = _interopRequireDefault(/*@__PURE__*/ requireTag());
  38634. var _string = _interopRequireDefault(/*@__PURE__*/ requireString());
  38635. var _pseudo = _interopRequireDefault(/*@__PURE__*/ requirePseudo());
  38636. var _attribute = _interopRequireWildcard(/*@__PURE__*/ requireAttribute());
  38637. var _universal = _interopRequireDefault(/*@__PURE__*/ requireUniversal());
  38638. var _combinator = _interopRequireDefault(/*@__PURE__*/ requireCombinator());
  38639. var _nesting = _interopRequireDefault(/*@__PURE__*/ requireNesting());
  38640. var _sortAscending = _interopRequireDefault(/*@__PURE__*/ requireSortAscending());
  38641. var _tokenize = _interopRequireWildcard(/*@__PURE__*/ requireTokenize());
  38642. var tokens = _interopRequireWildcard(/*@__PURE__*/ requireTokenTypes());
  38643. var types = _interopRequireWildcard(/*@__PURE__*/ requireTypes());
  38644. var _util = /*@__PURE__*/ requireUtil$1();
  38645. var _WHITESPACE_TOKENS, _Object$assign;
  38646. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  38647. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  38648. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38649. 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); } }
  38650. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  38651. 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);
  38652. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  38653. function tokenStart(token) {
  38654. return {
  38655. line: token[_tokenize.FIELDS.START_LINE],
  38656. column: token[_tokenize.FIELDS.START_COL]
  38657. };
  38658. }
  38659. function tokenEnd(token) {
  38660. return {
  38661. line: token[_tokenize.FIELDS.END_LINE],
  38662. column: token[_tokenize.FIELDS.END_COL]
  38663. };
  38664. }
  38665. function getSource(startLine, startColumn, endLine, endColumn) {
  38666. return {
  38667. start: {
  38668. line: startLine,
  38669. column: startColumn
  38670. },
  38671. end: {
  38672. line: endLine,
  38673. column: endColumn
  38674. }
  38675. };
  38676. }
  38677. function getTokenSource(token) {
  38678. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  38679. }
  38680. function getTokenSourceSpan(startToken, endToken) {
  38681. if (!startToken) {
  38682. return undefined;
  38683. }
  38684. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  38685. }
  38686. function unescapeProp(node, prop) {
  38687. var value = node[prop];
  38688. if (typeof value !== "string") {
  38689. return;
  38690. }
  38691. if (value.indexOf("\\") !== -1) {
  38692. (0, _util.ensureObject)(node, 'raws');
  38693. node[prop] = (0, _util.unesc)(value);
  38694. if (node.raws[prop] === undefined) {
  38695. node.raws[prop] = value;
  38696. }
  38697. }
  38698. return node;
  38699. }
  38700. function indexesOf(array, item) {
  38701. var i = -1;
  38702. var indexes = [];
  38703. while ((i = array.indexOf(item, i + 1)) !== -1) {
  38704. indexes.push(i);
  38705. }
  38706. return indexes;
  38707. }
  38708. function uniqs() {
  38709. var list = Array.prototype.concat.apply([], arguments);
  38710. return list.filter(function (item, i) {
  38711. return i === list.indexOf(item);
  38712. });
  38713. }
  38714. var Parser = /*#__PURE__*/function () {
  38715. function Parser(rule, options) {
  38716. if (options === void 0) {
  38717. options = {};
  38718. }
  38719. this.rule = rule;
  38720. this.options = Object.assign({
  38721. lossy: false,
  38722. safe: false
  38723. }, options);
  38724. this.position = 0;
  38725. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  38726. this.tokens = (0, _tokenize["default"])({
  38727. css: this.css,
  38728. error: this._errorGenerator(),
  38729. safe: this.options.safe
  38730. });
  38731. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  38732. this.root = new _root["default"]({
  38733. source: rootSource
  38734. });
  38735. this.root.errorGenerator = this._errorGenerator();
  38736. var selector = new _selector["default"]({
  38737. source: {
  38738. start: {
  38739. line: 1,
  38740. column: 1
  38741. }
  38742. },
  38743. sourceIndex: 0
  38744. });
  38745. this.root.append(selector);
  38746. this.current = selector;
  38747. this.loop();
  38748. }
  38749. var _proto = Parser.prototype;
  38750. _proto._errorGenerator = function _errorGenerator() {
  38751. var _this = this;
  38752. return function (message, errorOptions) {
  38753. if (typeof _this.rule === 'string') {
  38754. return new Error(message);
  38755. }
  38756. return _this.rule.error(message, errorOptions);
  38757. };
  38758. };
  38759. _proto.attribute = function attribute() {
  38760. var attr = [];
  38761. var startingToken = this.currToken;
  38762. this.position++;
  38763. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  38764. attr.push(this.currToken);
  38765. this.position++;
  38766. }
  38767. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  38768. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  38769. }
  38770. var len = attr.length;
  38771. var node = {
  38772. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  38773. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  38774. };
  38775. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  38776. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  38777. }
  38778. var pos = 0;
  38779. var spaceBefore = '';
  38780. var commentBefore = '';
  38781. var lastAdded = null;
  38782. var spaceAfterMeaningfulToken = false;
  38783. while (pos < len) {
  38784. var token = attr[pos];
  38785. var content = this.content(token);
  38786. var next = attr[pos + 1];
  38787. switch (token[_tokenize.FIELDS.TYPE]) {
  38788. case tokens.space:
  38789. // if (
  38790. // len === 1 ||
  38791. // pos === 0 && this.content(next) === '|'
  38792. // ) {
  38793. // return this.expected('attribute', token[TOKEN.START_POS], content);
  38794. // }
  38795. spaceAfterMeaningfulToken = true;
  38796. if (this.options.lossy) {
  38797. break;
  38798. }
  38799. if (lastAdded) {
  38800. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  38801. var prevContent = node.spaces[lastAdded].after || '';
  38802. node.spaces[lastAdded].after = prevContent + content;
  38803. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  38804. if (existingComment) {
  38805. node.raws.spaces[lastAdded].after = existingComment + content;
  38806. }
  38807. } else {
  38808. spaceBefore = spaceBefore + content;
  38809. commentBefore = commentBefore + content;
  38810. }
  38811. break;
  38812. case tokens.asterisk:
  38813. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  38814. node.operator = content;
  38815. lastAdded = 'operator';
  38816. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  38817. if (spaceBefore) {
  38818. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  38819. node.spaces.attribute.before = spaceBefore;
  38820. spaceBefore = '';
  38821. }
  38822. if (commentBefore) {
  38823. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  38824. node.raws.spaces.attribute.before = spaceBefore;
  38825. commentBefore = '';
  38826. }
  38827. node.namespace = (node.namespace || "") + content;
  38828. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  38829. if (rawValue) {
  38830. node.raws.namespace += content;
  38831. }
  38832. lastAdded = 'namespace';
  38833. }
  38834. spaceAfterMeaningfulToken = false;
  38835. break;
  38836. case tokens.dollar:
  38837. if (lastAdded === "value") {
  38838. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  38839. node.value += "$";
  38840. if (oldRawValue) {
  38841. node.raws.value = oldRawValue + "$";
  38842. }
  38843. break;
  38844. }
  38845. // Falls through
  38846. case tokens.caret:
  38847. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  38848. node.operator = content;
  38849. lastAdded = 'operator';
  38850. }
  38851. spaceAfterMeaningfulToken = false;
  38852. break;
  38853. case tokens.combinator:
  38854. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  38855. node.operator = content;
  38856. lastAdded = 'operator';
  38857. }
  38858. if (content !== '|') {
  38859. spaceAfterMeaningfulToken = false;
  38860. break;
  38861. }
  38862. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  38863. node.operator = content;
  38864. lastAdded = 'operator';
  38865. } else if (!node.namespace && !node.attribute) {
  38866. node.namespace = true;
  38867. }
  38868. spaceAfterMeaningfulToken = false;
  38869. break;
  38870. case tokens.word:
  38871. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  38872. // this look-ahead probably fails with comment nodes involved.
  38873. !node.operator && !node.namespace) {
  38874. node.namespace = content;
  38875. lastAdded = 'namespace';
  38876. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  38877. if (spaceBefore) {
  38878. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  38879. node.spaces.attribute.before = spaceBefore;
  38880. spaceBefore = '';
  38881. }
  38882. if (commentBefore) {
  38883. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  38884. node.raws.spaces.attribute.before = commentBefore;
  38885. commentBefore = '';
  38886. }
  38887. node.attribute = (node.attribute || "") + content;
  38888. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  38889. if (_rawValue) {
  38890. node.raws.attribute += content;
  38891. }
  38892. lastAdded = 'attribute';
  38893. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  38894. var _unescaped = (0, _util.unesc)(content);
  38895. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  38896. var oldValue = node.value || '';
  38897. node.value = oldValue + _unescaped;
  38898. node.quoteMark = null;
  38899. if (_unescaped !== content || _oldRawValue) {
  38900. (0, _util.ensureObject)(node, 'raws');
  38901. node.raws.value = (_oldRawValue || oldValue) + content;
  38902. }
  38903. lastAdded = 'value';
  38904. } else {
  38905. var insensitive = content === 'i' || content === "I";
  38906. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  38907. node.insensitive = insensitive;
  38908. if (!insensitive || content === "I") {
  38909. (0, _util.ensureObject)(node, 'raws');
  38910. node.raws.insensitiveFlag = content;
  38911. }
  38912. lastAdded = 'insensitive';
  38913. if (spaceBefore) {
  38914. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  38915. node.spaces.insensitive.before = spaceBefore;
  38916. spaceBefore = '';
  38917. }
  38918. if (commentBefore) {
  38919. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  38920. node.raws.spaces.insensitive.before = commentBefore;
  38921. commentBefore = '';
  38922. }
  38923. } else if (node.value || node.value === '') {
  38924. lastAdded = 'value';
  38925. node.value += content;
  38926. if (node.raws.value) {
  38927. node.raws.value += content;
  38928. }
  38929. }
  38930. }
  38931. spaceAfterMeaningfulToken = false;
  38932. break;
  38933. case tokens.str:
  38934. if (!node.attribute || !node.operator) {
  38935. return this.error("Expected an attribute followed by an operator preceding the string.", {
  38936. index: token[_tokenize.FIELDS.START_POS]
  38937. });
  38938. }
  38939. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  38940. unescaped = _unescapeValue.unescaped,
  38941. quoteMark = _unescapeValue.quoteMark;
  38942. node.value = unescaped;
  38943. node.quoteMark = quoteMark;
  38944. lastAdded = 'value';
  38945. (0, _util.ensureObject)(node, 'raws');
  38946. node.raws.value = content;
  38947. spaceAfterMeaningfulToken = false;
  38948. break;
  38949. case tokens.equals:
  38950. if (!node.attribute) {
  38951. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  38952. }
  38953. if (node.value) {
  38954. return this.error('Unexpected "=" found; an operator was already defined.', {
  38955. index: token[_tokenize.FIELDS.START_POS]
  38956. });
  38957. }
  38958. node.operator = node.operator ? node.operator + content : content;
  38959. lastAdded = 'operator';
  38960. spaceAfterMeaningfulToken = false;
  38961. break;
  38962. case tokens.comment:
  38963. if (lastAdded) {
  38964. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  38965. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  38966. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  38967. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  38968. node.raws.spaces[lastAdded].after = rawLastComment + content;
  38969. } else {
  38970. var lastValue = node[lastAdded] || '';
  38971. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  38972. (0, _util.ensureObject)(node, 'raws');
  38973. node.raws[lastAdded] = rawLastValue + content;
  38974. }
  38975. } else {
  38976. commentBefore = commentBefore + content;
  38977. }
  38978. break;
  38979. default:
  38980. return this.error("Unexpected \"" + content + "\" found.", {
  38981. index: token[_tokenize.FIELDS.START_POS]
  38982. });
  38983. }
  38984. pos++;
  38985. }
  38986. unescapeProp(node, "attribute");
  38987. unescapeProp(node, "namespace");
  38988. this.newNode(new _attribute["default"](node));
  38989. this.position++;
  38990. }
  38991. /**
  38992. * return a node containing meaningless garbage up to (but not including) the specified token position.
  38993. * if the token position is negative, all remaining tokens are consumed.
  38994. *
  38995. * This returns an array containing a single string node if all whitespace,
  38996. * otherwise an array of comment nodes with space before and after.
  38997. *
  38998. * These tokens are not added to the current selector, the caller can add them or use them to amend
  38999. * a previous node's space metadata.
  39000. *
  39001. * In lossy mode, this returns only comments.
  39002. */;
  39003. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  39004. if (stopPosition < 0) {
  39005. stopPosition = this.tokens.length;
  39006. }
  39007. var startPosition = this.position;
  39008. var nodes = [];
  39009. var space = "";
  39010. var lastComment = undefined;
  39011. do {
  39012. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  39013. if (!this.options.lossy) {
  39014. space += this.content();
  39015. }
  39016. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  39017. var spaces = {};
  39018. if (space) {
  39019. spaces.before = space;
  39020. space = "";
  39021. }
  39022. lastComment = new _comment["default"]({
  39023. value: this.content(),
  39024. source: getTokenSource(this.currToken),
  39025. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  39026. spaces: spaces
  39027. });
  39028. nodes.push(lastComment);
  39029. }
  39030. } while (++this.position < stopPosition);
  39031. if (space) {
  39032. if (lastComment) {
  39033. lastComment.spaces.after = space;
  39034. } else if (!this.options.lossy) {
  39035. var firstToken = this.tokens[startPosition];
  39036. var lastToken = this.tokens[this.position - 1];
  39037. nodes.push(new _string["default"]({
  39038. value: '',
  39039. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  39040. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  39041. spaces: {
  39042. before: space,
  39043. after: ''
  39044. }
  39045. }));
  39046. }
  39047. }
  39048. return nodes;
  39049. }
  39050. /**
  39051. *
  39052. * @param {*} nodes
  39053. */;
  39054. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  39055. var _this2 = this;
  39056. if (requiredSpace === void 0) {
  39057. requiredSpace = false;
  39058. }
  39059. var space = "";
  39060. var rawSpace = "";
  39061. nodes.forEach(function (n) {
  39062. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  39063. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  39064. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  39065. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  39066. });
  39067. if (rawSpace === space) {
  39068. rawSpace = undefined;
  39069. }
  39070. var result = {
  39071. space: space,
  39072. rawSpace: rawSpace
  39073. };
  39074. return result;
  39075. };
  39076. _proto.isNamedCombinator = function isNamedCombinator(position) {
  39077. if (position === void 0) {
  39078. position = this.position;
  39079. }
  39080. 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;
  39081. };
  39082. _proto.namedCombinator = function namedCombinator() {
  39083. if (this.isNamedCombinator()) {
  39084. var nameRaw = this.content(this.tokens[this.position + 1]);
  39085. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  39086. var raws = {};
  39087. if (name !== nameRaw) {
  39088. raws.value = "/" + nameRaw + "/";
  39089. }
  39090. var node = new _combinator["default"]({
  39091. value: "/" + name + "/",
  39092. 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]),
  39093. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  39094. raws: raws
  39095. });
  39096. this.position = this.position + 3;
  39097. return node;
  39098. } else {
  39099. this.unexpected();
  39100. }
  39101. };
  39102. _proto.combinator = function combinator() {
  39103. var _this3 = this;
  39104. if (this.content() === '|') {
  39105. return this.namespace();
  39106. }
  39107. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  39108. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  39109. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  39110. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  39111. if (nodes.length > 0) {
  39112. var last = this.current.last;
  39113. if (last) {
  39114. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  39115. space = _this$convertWhitespa.space,
  39116. rawSpace = _this$convertWhitespa.rawSpace;
  39117. if (rawSpace !== undefined) {
  39118. last.rawSpaceAfter += rawSpace;
  39119. }
  39120. last.spaces.after += space;
  39121. } else {
  39122. nodes.forEach(function (n) {
  39123. return _this3.newNode(n);
  39124. });
  39125. }
  39126. }
  39127. return;
  39128. }
  39129. var firstToken = this.currToken;
  39130. var spaceOrDescendantSelectorNodes = undefined;
  39131. if (nextSigTokenPos > this.position) {
  39132. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  39133. }
  39134. var node;
  39135. if (this.isNamedCombinator()) {
  39136. node = this.namedCombinator();
  39137. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  39138. node = new _combinator["default"]({
  39139. value: this.content(),
  39140. source: getTokenSource(this.currToken),
  39141. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  39142. });
  39143. this.position++;
  39144. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  39145. this.unexpected();
  39146. }
  39147. if (node) {
  39148. if (spaceOrDescendantSelectorNodes) {
  39149. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  39150. _space = _this$convertWhitespa2.space,
  39151. _rawSpace = _this$convertWhitespa2.rawSpace;
  39152. node.spaces.before = _space;
  39153. node.rawSpaceBefore = _rawSpace;
  39154. }
  39155. } else {
  39156. // descendant combinator
  39157. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  39158. _space2 = _this$convertWhitespa3.space,
  39159. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  39160. if (!_rawSpace2) {
  39161. _rawSpace2 = _space2;
  39162. }
  39163. var spaces = {};
  39164. var raws = {
  39165. spaces: {}
  39166. };
  39167. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  39168. spaces.before = _space2.slice(0, _space2.length - 1);
  39169. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  39170. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  39171. spaces.after = _space2.slice(1);
  39172. raws.spaces.after = _rawSpace2.slice(1);
  39173. } else {
  39174. raws.value = _rawSpace2;
  39175. }
  39176. node = new _combinator["default"]({
  39177. value: ' ',
  39178. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  39179. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  39180. spaces: spaces,
  39181. raws: raws
  39182. });
  39183. }
  39184. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  39185. node.spaces.after = this.optionalSpace(this.content());
  39186. this.position++;
  39187. }
  39188. return this.newNode(node);
  39189. };
  39190. _proto.comma = function comma() {
  39191. if (this.position === this.tokens.length - 1) {
  39192. this.root.trailingComma = true;
  39193. this.position++;
  39194. return;
  39195. }
  39196. this.current._inferEndPosition();
  39197. var selector = new _selector["default"]({
  39198. source: {
  39199. start: tokenStart(this.tokens[this.position + 1])
  39200. },
  39201. sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS]
  39202. });
  39203. this.current.parent.append(selector);
  39204. this.current = selector;
  39205. this.position++;
  39206. };
  39207. _proto.comment = function comment() {
  39208. var current = this.currToken;
  39209. this.newNode(new _comment["default"]({
  39210. value: this.content(),
  39211. source: getTokenSource(current),
  39212. sourceIndex: current[_tokenize.FIELDS.START_POS]
  39213. }));
  39214. this.position++;
  39215. };
  39216. _proto.error = function error(message, opts) {
  39217. throw this.root.error(message, opts);
  39218. };
  39219. _proto.missingBackslash = function missingBackslash() {
  39220. return this.error('Expected a backslash preceding the semicolon.', {
  39221. index: this.currToken[_tokenize.FIELDS.START_POS]
  39222. });
  39223. };
  39224. _proto.missingParenthesis = function missingParenthesis() {
  39225. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  39226. };
  39227. _proto.missingSquareBracket = function missingSquareBracket() {
  39228. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  39229. };
  39230. _proto.unexpected = function unexpected() {
  39231. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  39232. };
  39233. _proto.unexpectedPipe = function unexpectedPipe() {
  39234. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  39235. };
  39236. _proto.namespace = function namespace() {
  39237. var before = this.prevToken && this.content(this.prevToken) || true;
  39238. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  39239. this.position++;
  39240. return this.word(before);
  39241. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  39242. this.position++;
  39243. return this.universal(before);
  39244. }
  39245. this.unexpectedPipe();
  39246. };
  39247. _proto.nesting = function nesting() {
  39248. if (this.nextToken) {
  39249. var nextContent = this.content(this.nextToken);
  39250. if (nextContent === "|") {
  39251. this.position++;
  39252. return;
  39253. }
  39254. }
  39255. var current = this.currToken;
  39256. this.newNode(new _nesting["default"]({
  39257. value: this.content(),
  39258. source: getTokenSource(current),
  39259. sourceIndex: current[_tokenize.FIELDS.START_POS]
  39260. }));
  39261. this.position++;
  39262. };
  39263. _proto.parentheses = function parentheses() {
  39264. var last = this.current.last;
  39265. var unbalanced = 1;
  39266. this.position++;
  39267. if (last && last.type === types.PSEUDO) {
  39268. var selector = new _selector["default"]({
  39269. source: {
  39270. start: tokenStart(this.tokens[this.position])
  39271. },
  39272. sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS]
  39273. });
  39274. var cache = this.current;
  39275. last.append(selector);
  39276. this.current = selector;
  39277. while (this.position < this.tokens.length && unbalanced) {
  39278. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  39279. unbalanced++;
  39280. }
  39281. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  39282. unbalanced--;
  39283. }
  39284. if (unbalanced) {
  39285. this.parse();
  39286. } else {
  39287. this.current.source.end = tokenEnd(this.currToken);
  39288. this.current.parent.source.end = tokenEnd(this.currToken);
  39289. this.position++;
  39290. }
  39291. }
  39292. this.current = cache;
  39293. } else {
  39294. // I think this case should be an error. It's used to implement a basic parse of media queries
  39295. // but I don't think it's a good idea.
  39296. var parenStart = this.currToken;
  39297. var parenValue = "(";
  39298. var parenEnd;
  39299. while (this.position < this.tokens.length && unbalanced) {
  39300. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  39301. unbalanced++;
  39302. }
  39303. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  39304. unbalanced--;
  39305. }
  39306. parenEnd = this.currToken;
  39307. parenValue += this.parseParenthesisToken(this.currToken);
  39308. this.position++;
  39309. }
  39310. if (last) {
  39311. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  39312. } else {
  39313. this.newNode(new _string["default"]({
  39314. value: parenValue,
  39315. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  39316. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  39317. }));
  39318. }
  39319. }
  39320. if (unbalanced) {
  39321. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  39322. }
  39323. };
  39324. _proto.pseudo = function pseudo() {
  39325. var _this4 = this;
  39326. var pseudoStr = '';
  39327. var startingToken = this.currToken;
  39328. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  39329. pseudoStr += this.content();
  39330. this.position++;
  39331. }
  39332. if (!this.currToken) {
  39333. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  39334. }
  39335. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  39336. this.splitWord(false, function (first, length) {
  39337. pseudoStr += first;
  39338. _this4.newNode(new _pseudo["default"]({
  39339. value: pseudoStr,
  39340. source: getTokenSourceSpan(startingToken, _this4.currToken),
  39341. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  39342. }));
  39343. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  39344. _this4.error('Misplaced parenthesis.', {
  39345. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  39346. });
  39347. }
  39348. });
  39349. } else {
  39350. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  39351. }
  39352. };
  39353. _proto.space = function space() {
  39354. var content = this.content();
  39355. // Handle space before and after the selector
  39356. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  39357. return node.type === 'comment';
  39358. })) {
  39359. this.spaces = this.optionalSpace(content);
  39360. this.position++;
  39361. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  39362. this.current.last.spaces.after = this.optionalSpace(content);
  39363. this.position++;
  39364. } else {
  39365. this.combinator();
  39366. }
  39367. };
  39368. _proto.string = function string() {
  39369. var current = this.currToken;
  39370. this.newNode(new _string["default"]({
  39371. value: this.content(),
  39372. source: getTokenSource(current),
  39373. sourceIndex: current[_tokenize.FIELDS.START_POS]
  39374. }));
  39375. this.position++;
  39376. };
  39377. _proto.universal = function universal(namespace) {
  39378. var nextToken = this.nextToken;
  39379. if (nextToken && this.content(nextToken) === '|') {
  39380. this.position++;
  39381. return this.namespace();
  39382. }
  39383. var current = this.currToken;
  39384. this.newNode(new _universal["default"]({
  39385. value: this.content(),
  39386. source: getTokenSource(current),
  39387. sourceIndex: current[_tokenize.FIELDS.START_POS]
  39388. }), namespace);
  39389. this.position++;
  39390. };
  39391. _proto.splitWord = function splitWord(namespace, firstCallback) {
  39392. var _this5 = this;
  39393. var nextToken = this.nextToken;
  39394. var word = this.content();
  39395. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  39396. this.position++;
  39397. var current = this.content();
  39398. word += current;
  39399. if (current.lastIndexOf('\\') === current.length - 1) {
  39400. var next = this.nextToken;
  39401. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  39402. word += this.requiredSpace(this.content(next));
  39403. this.position++;
  39404. }
  39405. }
  39406. nextToken = this.nextToken;
  39407. }
  39408. var hasClass = indexesOf(word, '.').filter(function (i) {
  39409. // Allow escaped dot within class name
  39410. var escapedDot = word[i - 1] === '\\';
  39411. // Allow decimal numbers percent in @keyframes
  39412. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  39413. return !escapedDot && !isKeyframesPercent;
  39414. });
  39415. var hasId = indexesOf(word, '#').filter(function (i) {
  39416. return word[i - 1] !== '\\';
  39417. });
  39418. // Eliminate Sass interpolations from the list of id indexes
  39419. var interpolations = indexesOf(word, '#{');
  39420. if (interpolations.length) {
  39421. hasId = hasId.filter(function (hashIndex) {
  39422. return !~interpolations.indexOf(hashIndex);
  39423. });
  39424. }
  39425. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  39426. indices.forEach(function (ind, i) {
  39427. var index = indices[i + 1] || word.length;
  39428. var value = word.slice(ind, index);
  39429. if (i === 0 && firstCallback) {
  39430. return firstCallback.call(_this5, value, indices.length);
  39431. }
  39432. var node;
  39433. var current = _this5.currToken;
  39434. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  39435. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  39436. if (~hasClass.indexOf(ind)) {
  39437. var classNameOpts = {
  39438. value: value.slice(1),
  39439. source: source,
  39440. sourceIndex: sourceIndex
  39441. };
  39442. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  39443. } else if (~hasId.indexOf(ind)) {
  39444. var idOpts = {
  39445. value: value.slice(1),
  39446. source: source,
  39447. sourceIndex: sourceIndex
  39448. };
  39449. node = new _id["default"](unescapeProp(idOpts, "value"));
  39450. } else {
  39451. var tagOpts = {
  39452. value: value,
  39453. source: source,
  39454. sourceIndex: sourceIndex
  39455. };
  39456. unescapeProp(tagOpts, "value");
  39457. node = new _tag["default"](tagOpts);
  39458. }
  39459. _this5.newNode(node, namespace);
  39460. // Ensure that the namespace is used only once
  39461. namespace = null;
  39462. });
  39463. this.position++;
  39464. };
  39465. _proto.word = function word(namespace) {
  39466. var nextToken = this.nextToken;
  39467. if (nextToken && this.content(nextToken) === '|') {
  39468. this.position++;
  39469. return this.namespace();
  39470. }
  39471. return this.splitWord(namespace);
  39472. };
  39473. _proto.loop = function loop() {
  39474. while (this.position < this.tokens.length) {
  39475. this.parse(true);
  39476. }
  39477. this.current._inferEndPosition();
  39478. return this.root;
  39479. };
  39480. _proto.parse = function parse(throwOnParenthesis) {
  39481. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  39482. case tokens.space:
  39483. this.space();
  39484. break;
  39485. case tokens.comment:
  39486. this.comment();
  39487. break;
  39488. case tokens.openParenthesis:
  39489. this.parentheses();
  39490. break;
  39491. case tokens.closeParenthesis:
  39492. if (throwOnParenthesis) {
  39493. this.missingParenthesis();
  39494. }
  39495. break;
  39496. case tokens.openSquare:
  39497. this.attribute();
  39498. break;
  39499. case tokens.dollar:
  39500. case tokens.caret:
  39501. case tokens.equals:
  39502. case tokens.word:
  39503. this.word();
  39504. break;
  39505. case tokens.colon:
  39506. this.pseudo();
  39507. break;
  39508. case tokens.comma:
  39509. this.comma();
  39510. break;
  39511. case tokens.asterisk:
  39512. this.universal();
  39513. break;
  39514. case tokens.ampersand:
  39515. this.nesting();
  39516. break;
  39517. case tokens.slash:
  39518. case tokens.combinator:
  39519. this.combinator();
  39520. break;
  39521. case tokens.str:
  39522. this.string();
  39523. break;
  39524. // These cases throw; no break needed.
  39525. case tokens.closeSquare:
  39526. this.missingSquareBracket();
  39527. case tokens.semicolon:
  39528. this.missingBackslash();
  39529. default:
  39530. this.unexpected();
  39531. }
  39532. }
  39533. /**
  39534. * Helpers
  39535. */;
  39536. _proto.expected = function expected(description, index, found) {
  39537. if (Array.isArray(description)) {
  39538. var last = description.pop();
  39539. description = description.join(', ') + " or " + last;
  39540. }
  39541. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  39542. if (!found) {
  39543. return this.error("Expected " + an + " " + description + ".", {
  39544. index: index
  39545. });
  39546. }
  39547. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  39548. index: index
  39549. });
  39550. };
  39551. _proto.requiredSpace = function requiredSpace(space) {
  39552. return this.options.lossy ? ' ' : space;
  39553. };
  39554. _proto.optionalSpace = function optionalSpace(space) {
  39555. return this.options.lossy ? '' : space;
  39556. };
  39557. _proto.lossySpace = function lossySpace(space, required) {
  39558. if (this.options.lossy) {
  39559. return required ? ' ' : '';
  39560. } else {
  39561. return space;
  39562. }
  39563. };
  39564. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  39565. var content = this.content(token);
  39566. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  39567. return this.requiredSpace(content);
  39568. } else {
  39569. return content;
  39570. }
  39571. };
  39572. _proto.newNode = function newNode(node, namespace) {
  39573. if (namespace) {
  39574. if (/^ +$/.test(namespace)) {
  39575. if (!this.options.lossy) {
  39576. this.spaces = (this.spaces || '') + namespace;
  39577. }
  39578. namespace = true;
  39579. }
  39580. node.namespace = namespace;
  39581. unescapeProp(node, "namespace");
  39582. }
  39583. if (this.spaces) {
  39584. node.spaces.before = this.spaces;
  39585. this.spaces = '';
  39586. }
  39587. return this.current.append(node);
  39588. };
  39589. _proto.content = function content(token) {
  39590. if (token === void 0) {
  39591. token = this.currToken;
  39592. }
  39593. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  39594. };
  39595. /**
  39596. * returns the index of the next non-whitespace, non-comment token.
  39597. * returns -1 if no meaningful token is found.
  39598. */
  39599. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  39600. if (startPosition === void 0) {
  39601. startPosition = this.position + 1;
  39602. }
  39603. var searchPosition = startPosition;
  39604. while (searchPosition < this.tokens.length) {
  39605. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  39606. searchPosition++;
  39607. continue;
  39608. } else {
  39609. return searchPosition;
  39610. }
  39611. }
  39612. return -1;
  39613. };
  39614. _createClass(Parser, [{
  39615. key: "currToken",
  39616. get: function get() {
  39617. return this.tokens[this.position];
  39618. }
  39619. }, {
  39620. key: "nextToken",
  39621. get: function get() {
  39622. return this.tokens[this.position + 1];
  39623. }
  39624. }, {
  39625. key: "prevToken",
  39626. get: function get() {
  39627. return this.tokens[this.position - 1];
  39628. }
  39629. }]);
  39630. return Parser;
  39631. }();
  39632. exports["default"] = Parser;
  39633. module.exports = exports.default;
  39634. } (parser, parser.exports));
  39635. return parser.exports;
  39636. }
  39637. var hasRequiredProcessor;
  39638. function requireProcessor () {
  39639. if (hasRequiredProcessor) return processor.exports;
  39640. hasRequiredProcessor = 1;
  39641. (function (module, exports) {
  39642. exports.__esModule = true;
  39643. exports["default"] = void 0;
  39644. var _parser = _interopRequireDefault(/*@__PURE__*/ requireParser());
  39645. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39646. var Processor = /*#__PURE__*/function () {
  39647. function Processor(func, options) {
  39648. this.func = func || function noop() {};
  39649. this.funcRes = null;
  39650. this.options = options;
  39651. }
  39652. var _proto = Processor.prototype;
  39653. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  39654. if (options === void 0) {
  39655. options = {};
  39656. }
  39657. var merged = Object.assign({}, this.options, options);
  39658. if (merged.updateSelector === false) {
  39659. return false;
  39660. } else {
  39661. return typeof rule !== "string";
  39662. }
  39663. };
  39664. _proto._isLossy = function _isLossy(options) {
  39665. if (options === void 0) {
  39666. options = {};
  39667. }
  39668. var merged = Object.assign({}, this.options, options);
  39669. if (merged.lossless === false) {
  39670. return true;
  39671. } else {
  39672. return false;
  39673. }
  39674. };
  39675. _proto._root = function _root(rule, options) {
  39676. if (options === void 0) {
  39677. options = {};
  39678. }
  39679. var parser = new _parser["default"](rule, this._parseOptions(options));
  39680. return parser.root;
  39681. };
  39682. _proto._parseOptions = function _parseOptions(options) {
  39683. return {
  39684. lossy: this._isLossy(options)
  39685. };
  39686. };
  39687. _proto._run = function _run(rule, options) {
  39688. var _this = this;
  39689. if (options === void 0) {
  39690. options = {};
  39691. }
  39692. return new Promise(function (resolve, reject) {
  39693. try {
  39694. var root = _this._root(rule, options);
  39695. Promise.resolve(_this.func(root)).then(function (transform) {
  39696. var string = undefined;
  39697. if (_this._shouldUpdateSelector(rule, options)) {
  39698. string = root.toString();
  39699. rule.selector = string;
  39700. }
  39701. return {
  39702. transform: transform,
  39703. root: root,
  39704. string: string
  39705. };
  39706. }).then(resolve, reject);
  39707. } catch (e) {
  39708. reject(e);
  39709. return;
  39710. }
  39711. });
  39712. };
  39713. _proto._runSync = function _runSync(rule, options) {
  39714. if (options === void 0) {
  39715. options = {};
  39716. }
  39717. var root = this._root(rule, options);
  39718. var transform = this.func(root);
  39719. if (transform && typeof transform.then === "function") {
  39720. throw new Error("Selector processor returned a promise to a synchronous call.");
  39721. }
  39722. var string = undefined;
  39723. if (options.updateSelector && typeof rule !== "string") {
  39724. string = root.toString();
  39725. rule.selector = string;
  39726. }
  39727. return {
  39728. transform: transform,
  39729. root: root,
  39730. string: string
  39731. };
  39732. }
  39733. /**
  39734. * Process rule into a selector AST.
  39735. *
  39736. * @param rule {postcss.Rule | string} The css selector to be processed
  39737. * @param options The options for processing
  39738. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  39739. */;
  39740. _proto.ast = function ast(rule, options) {
  39741. return this._run(rule, options).then(function (result) {
  39742. return result.root;
  39743. });
  39744. }
  39745. /**
  39746. * Process rule into a selector AST synchronously.
  39747. *
  39748. * @param rule {postcss.Rule | string} The css selector to be processed
  39749. * @param options The options for processing
  39750. * @returns {parser.Root} The AST of the selector after processing it.
  39751. */;
  39752. _proto.astSync = function astSync(rule, options) {
  39753. return this._runSync(rule, options).root;
  39754. }
  39755. /**
  39756. * Process a selector into a transformed value asynchronously
  39757. *
  39758. * @param rule {postcss.Rule | string} The css selector to be processed
  39759. * @param options The options for processing
  39760. * @returns {Promise<any>} The value returned by the processor.
  39761. */;
  39762. _proto.transform = function transform(rule, options) {
  39763. return this._run(rule, options).then(function (result) {
  39764. return result.transform;
  39765. });
  39766. }
  39767. /**
  39768. * Process a selector into a transformed value synchronously.
  39769. *
  39770. * @param rule {postcss.Rule | string} The css selector to be processed
  39771. * @param options The options for processing
  39772. * @returns {any} The value returned by the processor.
  39773. */;
  39774. _proto.transformSync = function transformSync(rule, options) {
  39775. return this._runSync(rule, options).transform;
  39776. }
  39777. /**
  39778. * Process a selector into a new selector string asynchronously.
  39779. *
  39780. * @param rule {postcss.Rule | string} The css selector to be processed
  39781. * @param options The options for processing
  39782. * @returns {string} the selector after processing.
  39783. */;
  39784. _proto.process = function process(rule, options) {
  39785. return this._run(rule, options).then(function (result) {
  39786. return result.string || result.root.toString();
  39787. });
  39788. }
  39789. /**
  39790. * Process a selector into a new selector string synchronously.
  39791. *
  39792. * @param rule {postcss.Rule | string} The css selector to be processed
  39793. * @param options The options for processing
  39794. * @returns {string} the selector after processing.
  39795. */;
  39796. _proto.processSync = function processSync(rule, options) {
  39797. var result = this._runSync(rule, options);
  39798. return result.string || result.root.toString();
  39799. };
  39800. return Processor;
  39801. }();
  39802. exports["default"] = Processor;
  39803. module.exports = exports.default;
  39804. } (processor, processor.exports));
  39805. return processor.exports;
  39806. }
  39807. var selectors = {};
  39808. var constructors = {};
  39809. var hasRequiredConstructors;
  39810. function requireConstructors () {
  39811. if (hasRequiredConstructors) return constructors;
  39812. hasRequiredConstructors = 1;
  39813. constructors.__esModule = true;
  39814. 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;
  39815. var _attribute = _interopRequireDefault(/*@__PURE__*/ requireAttribute());
  39816. var _className = _interopRequireDefault(/*@__PURE__*/ requireClassName());
  39817. var _combinator = _interopRequireDefault(/*@__PURE__*/ requireCombinator());
  39818. var _comment = _interopRequireDefault(/*@__PURE__*/ requireComment());
  39819. var _id = _interopRequireDefault(/*@__PURE__*/ requireId());
  39820. var _nesting = _interopRequireDefault(/*@__PURE__*/ requireNesting());
  39821. var _pseudo = _interopRequireDefault(/*@__PURE__*/ requirePseudo());
  39822. var _root = _interopRequireDefault(/*@__PURE__*/ requireRoot());
  39823. var _selector = _interopRequireDefault(/*@__PURE__*/ requireSelector());
  39824. var _string = _interopRequireDefault(/*@__PURE__*/ requireString());
  39825. var _tag = _interopRequireDefault(/*@__PURE__*/ requireTag());
  39826. var _universal = _interopRequireDefault(/*@__PURE__*/ requireUniversal());
  39827. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39828. var attribute = function attribute(opts) {
  39829. return new _attribute["default"](opts);
  39830. };
  39831. constructors.attribute = attribute;
  39832. var className = function className(opts) {
  39833. return new _className["default"](opts);
  39834. };
  39835. constructors.className = className;
  39836. var combinator = function combinator(opts) {
  39837. return new _combinator["default"](opts);
  39838. };
  39839. constructors.combinator = combinator;
  39840. var comment = function comment(opts) {
  39841. return new _comment["default"](opts);
  39842. };
  39843. constructors.comment = comment;
  39844. var id = function id(opts) {
  39845. return new _id["default"](opts);
  39846. };
  39847. constructors.id = id;
  39848. var nesting = function nesting(opts) {
  39849. return new _nesting["default"](opts);
  39850. };
  39851. constructors.nesting = nesting;
  39852. var pseudo = function pseudo(opts) {
  39853. return new _pseudo["default"](opts);
  39854. };
  39855. constructors.pseudo = pseudo;
  39856. var root = function root(opts) {
  39857. return new _root["default"](opts);
  39858. };
  39859. constructors.root = root;
  39860. var selector = function selector(opts) {
  39861. return new _selector["default"](opts);
  39862. };
  39863. constructors.selector = selector;
  39864. var string = function string(opts) {
  39865. return new _string["default"](opts);
  39866. };
  39867. constructors.string = string;
  39868. var tag = function tag(opts) {
  39869. return new _tag["default"](opts);
  39870. };
  39871. constructors.tag = tag;
  39872. var universal = function universal(opts) {
  39873. return new _universal["default"](opts);
  39874. };
  39875. constructors.universal = universal;
  39876. return constructors;
  39877. }
  39878. var guards = {};
  39879. var hasRequiredGuards;
  39880. function requireGuards () {
  39881. if (hasRequiredGuards) return guards;
  39882. hasRequiredGuards = 1;
  39883. guards.__esModule = true;
  39884. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  39885. guards.isContainer = isContainer;
  39886. guards.isIdentifier = void 0;
  39887. guards.isNamespace = isNamespace;
  39888. guards.isNesting = void 0;
  39889. guards.isNode = isNode;
  39890. guards.isPseudo = void 0;
  39891. guards.isPseudoClass = isPseudoClass;
  39892. guards.isPseudoElement = isPseudoElement;
  39893. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  39894. var _types = /*@__PURE__*/ requireTypes();
  39895. var _IS_TYPE;
  39896. 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);
  39897. function isNode(node) {
  39898. return typeof node === "object" && IS_TYPE[node.type];
  39899. }
  39900. function isNodeType(type, node) {
  39901. return isNode(node) && node.type === type;
  39902. }
  39903. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  39904. guards.isAttribute = isAttribute;
  39905. var isClassName = isNodeType.bind(null, _types.CLASS);
  39906. guards.isClassName = isClassName;
  39907. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  39908. guards.isCombinator = isCombinator;
  39909. var isComment = isNodeType.bind(null, _types.COMMENT);
  39910. guards.isComment = isComment;
  39911. var isIdentifier = isNodeType.bind(null, _types.ID);
  39912. guards.isIdentifier = isIdentifier;
  39913. var isNesting = isNodeType.bind(null, _types.NESTING);
  39914. guards.isNesting = isNesting;
  39915. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  39916. guards.isPseudo = isPseudo;
  39917. var isRoot = isNodeType.bind(null, _types.ROOT);
  39918. guards.isRoot = isRoot;
  39919. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  39920. guards.isSelector = isSelector;
  39921. var isString = isNodeType.bind(null, _types.STRING);
  39922. guards.isString = isString;
  39923. var isTag = isNodeType.bind(null, _types.TAG);
  39924. guards.isTag = isTag;
  39925. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  39926. guards.isUniversal = isUniversal;
  39927. function isPseudoElement(node) {
  39928. 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");
  39929. }
  39930. function isPseudoClass(node) {
  39931. return isPseudo(node) && !isPseudoElement(node);
  39932. }
  39933. function isContainer(node) {
  39934. return !!(isNode(node) && node.walk);
  39935. }
  39936. function isNamespace(node) {
  39937. return isAttribute(node) || isTag(node);
  39938. }
  39939. return guards;
  39940. }
  39941. var hasRequiredSelectors;
  39942. function requireSelectors () {
  39943. if (hasRequiredSelectors) return selectors;
  39944. hasRequiredSelectors = 1;
  39945. (function (exports) {
  39946. exports.__esModule = true;
  39947. var _types = /*@__PURE__*/ requireTypes();
  39948. Object.keys(_types).forEach(function (key) {
  39949. if (key === "default" || key === "__esModule") return;
  39950. if (key in exports && exports[key] === _types[key]) return;
  39951. exports[key] = _types[key];
  39952. });
  39953. var _constructors = /*@__PURE__*/ requireConstructors();
  39954. Object.keys(_constructors).forEach(function (key) {
  39955. if (key === "default" || key === "__esModule") return;
  39956. if (key in exports && exports[key] === _constructors[key]) return;
  39957. exports[key] = _constructors[key];
  39958. });
  39959. var _guards = /*@__PURE__*/ requireGuards();
  39960. Object.keys(_guards).forEach(function (key) {
  39961. if (key === "default" || key === "__esModule") return;
  39962. if (key in exports && exports[key] === _guards[key]) return;
  39963. exports[key] = _guards[key];
  39964. });
  39965. } (selectors));
  39966. return selectors;
  39967. }
  39968. var hasRequiredDist;
  39969. function requireDist () {
  39970. if (hasRequiredDist) return dist.exports;
  39971. hasRequiredDist = 1;
  39972. (function (module, exports) {
  39973. exports.__esModule = true;
  39974. exports["default"] = void 0;
  39975. var _processor = _interopRequireDefault(/*@__PURE__*/ requireProcessor());
  39976. var selectors = _interopRequireWildcard(/*@__PURE__*/ requireSelectors());
  39977. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  39978. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  39979. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39980. var parser = function parser(processor) {
  39981. return new _processor["default"](processor);
  39982. };
  39983. Object.assign(parser, selectors);
  39984. delete parser.__esModule;
  39985. var _default = parser;
  39986. exports["default"] = _default;
  39987. module.exports = exports.default;
  39988. } (dist, dist.exports));
  39989. return dist.exports;
  39990. }
  39991. var distExports = /*@__PURE__*/ requireDist();
  39992. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
  39993. const animationNameRE = /^(?:-\w+-)?animation-name$/;
  39994. const animationRE = /^(?:-\w+-)?animation$/;
  39995. const keyframesRE = /^(?:-\w+-)?keyframes$/;
  39996. const scopedPlugin = (id = "") => {
  39997. const keyframes = /* @__PURE__ */ Object.create(null);
  39998. const shortId = id.replace(/^data-v-/, "");
  39999. return {
  40000. postcssPlugin: "vue-sfc-scoped",
  40001. Rule(rule) {
  40002. processRule(id, rule);
  40003. },
  40004. AtRule(node) {
  40005. if (keyframesRE.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
  40006. keyframes[node.params] = node.params = node.params + "-" + shortId;
  40007. }
  40008. },
  40009. OnceExit(root) {
  40010. if (Object.keys(keyframes).length) {
  40011. root.walkDecls((decl) => {
  40012. if (animationNameRE.test(decl.prop)) {
  40013. decl.value = decl.value.split(",").map((v) => keyframes[v.trim()] || v.trim()).join(",");
  40014. }
  40015. if (animationRE.test(decl.prop)) {
  40016. decl.value = decl.value.split(",").map((v) => {
  40017. const vals = v.trim().split(/\s+/);
  40018. const i = vals.findIndex((val) => keyframes[val]);
  40019. if (i !== -1) {
  40020. vals.splice(i, 1, keyframes[vals[i]]);
  40021. return vals.join(" ");
  40022. } else {
  40023. return v;
  40024. }
  40025. }).join(",");
  40026. }
  40027. });
  40028. }
  40029. }
  40030. };
  40031. };
  40032. const processedRules = /* @__PURE__ */ new WeakSet();
  40033. function processRule(id, rule) {
  40034. if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && keyframesRE.test(rule.parent.name)) {
  40035. return;
  40036. }
  40037. processedRules.add(rule);
  40038. let deep = false;
  40039. let parent = rule.parent;
  40040. while (parent && parent.type !== "root") {
  40041. if (parent.__deep) {
  40042. deep = true;
  40043. break;
  40044. }
  40045. parent = parent.parent;
  40046. }
  40047. rule.selector = selectorParser((selectorRoot) => {
  40048. selectorRoot.each((selector) => {
  40049. rewriteSelector(id, rule, selector, selectorRoot, deep);
  40050. });
  40051. }).processSync(rule.selector);
  40052. }
  40053. function rewriteSelector(id, rule, selector, selectorRoot, deep, slotted = false) {
  40054. let node = null;
  40055. let shouldInject = !deep;
  40056. selector.each((n) => {
  40057. if (n.type === "combinator" && (n.value === ">>>" || n.value === "/deep/")) {
  40058. n.value = " ";
  40059. n.spaces.before = n.spaces.after = "";
  40060. warn(
  40061. `the >>> and /deep/ combinators have been deprecated. Use :deep() instead.`
  40062. );
  40063. return false;
  40064. }
  40065. if (n.type === "pseudo") {
  40066. const { value } = n;
  40067. if (value === ":deep" || value === "::v-deep") {
  40068. rule.__deep = true;
  40069. if (n.nodes.length) {
  40070. let last = n;
  40071. n.nodes[0].each((ss) => {
  40072. selector.insertAfter(last, ss);
  40073. last = ss;
  40074. });
  40075. const prev = selector.at(selector.index(n) - 1);
  40076. if (!prev || !isSpaceCombinator(prev)) {
  40077. selector.insertAfter(
  40078. n,
  40079. selectorParser.combinator({
  40080. value: " "
  40081. })
  40082. );
  40083. }
  40084. selector.removeChild(n);
  40085. } else {
  40086. warn(
  40087. `${value} usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
  40088. );
  40089. const prev = selector.at(selector.index(n) - 1);
  40090. if (prev && isSpaceCombinator(prev)) {
  40091. selector.removeChild(prev);
  40092. }
  40093. selector.removeChild(n);
  40094. }
  40095. return false;
  40096. }
  40097. if (value === ":slotted" || value === "::v-slotted") {
  40098. rewriteSelector(
  40099. id,
  40100. rule,
  40101. n.nodes[0],
  40102. selectorRoot,
  40103. deep,
  40104. true
  40105. );
  40106. let last = n;
  40107. n.nodes[0].each((ss) => {
  40108. selector.insertAfter(last, ss);
  40109. last = ss;
  40110. });
  40111. selector.removeChild(n);
  40112. shouldInject = false;
  40113. return false;
  40114. }
  40115. if (value === ":global" || value === "::v-global") {
  40116. selector.replaceWith(n.nodes[0]);
  40117. return false;
  40118. }
  40119. }
  40120. if (n.type === "universal") {
  40121. const prev = selector.at(selector.index(n) - 1);
  40122. const next = selector.at(selector.index(n) + 1);
  40123. if (!prev) {
  40124. if (next) {
  40125. if (next.type === "combinator" && next.value === " ") {
  40126. selector.removeChild(next);
  40127. }
  40128. selector.removeChild(n);
  40129. return;
  40130. } else {
  40131. node = selectorParser.combinator({
  40132. value: ""
  40133. });
  40134. selector.insertBefore(n, node);
  40135. selector.removeChild(n);
  40136. return false;
  40137. }
  40138. }
  40139. if (node) return;
  40140. }
  40141. if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where") && !node) {
  40142. node = n;
  40143. }
  40144. });
  40145. if (rule.nodes.some((node2) => node2.type === "rule")) {
  40146. const deep2 = rule.__deep;
  40147. if (!deep2) {
  40148. extractAndWrapNodes(rule);
  40149. const atruleNodes = rule.nodes.filter((node2) => node2.type === "atrule");
  40150. for (const atnode of atruleNodes) {
  40151. extractAndWrapNodes(atnode);
  40152. }
  40153. }
  40154. shouldInject = deep2;
  40155. }
  40156. if (node) {
  40157. const { type, value } = node;
  40158. if (type === "pseudo" && (value === ":is" || value === ":where")) {
  40159. node.nodes.forEach(
  40160. (value2) => rewriteSelector(id, rule, value2, selectorRoot, deep, slotted)
  40161. );
  40162. shouldInject = false;
  40163. }
  40164. }
  40165. if (node) {
  40166. node.spaces.after = "";
  40167. } else {
  40168. selector.first.spaces.before = "";
  40169. }
  40170. if (shouldInject) {
  40171. const idToAdd = slotted ? id + "-s" : id;
  40172. selector.insertAfter(
  40173. // If node is null it means we need to inject [id] at the start
  40174. // insertAfter can handle `null` here
  40175. node,
  40176. selectorParser.attribute({
  40177. attribute: idToAdd,
  40178. value: idToAdd,
  40179. raws: {},
  40180. quoteMark: `"`
  40181. })
  40182. );
  40183. }
  40184. }
  40185. function isSpaceCombinator(node) {
  40186. return node.type === "combinator" && /^\s+$/.test(node.value);
  40187. }
  40188. function extractAndWrapNodes(parentNode) {
  40189. if (!parentNode.nodes) return;
  40190. const nodes = parentNode.nodes.filter(
  40191. (node) => node.type === "decl" || node.type === "comment"
  40192. );
  40193. if (nodes.length) {
  40194. for (const node of nodes) {
  40195. parentNode.removeChild(node);
  40196. }
  40197. const wrappedRule = new Rule({
  40198. nodes,
  40199. selector: "&"
  40200. });
  40201. parentNode.prepend(wrappedRule);
  40202. }
  40203. }
  40204. scopedPlugin.postcss = true;
  40205. var sourceMap = {};
  40206. var sourceMapGenerator = {};
  40207. var base64Vlq = {};
  40208. var base64 = {};
  40209. /* -*- Mode: js; js-indent-level: 2; -*- */
  40210. var hasRequiredBase64;
  40211. function requireBase64 () {
  40212. if (hasRequiredBase64) return base64;
  40213. hasRequiredBase64 = 1;
  40214. /*
  40215. * Copyright 2011 Mozilla Foundation and contributors
  40216. * Licensed under the New BSD license. See LICENSE or:
  40217. * http://opensource.org/licenses/BSD-3-Clause
  40218. */
  40219. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  40220. /**
  40221. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  40222. */
  40223. base64.encode = function (number) {
  40224. if (0 <= number && number < intToCharMap.length) {
  40225. return intToCharMap[number];
  40226. }
  40227. throw new TypeError("Must be between 0 and 63: " + number);
  40228. };
  40229. /**
  40230. * Decode a single base 64 character code digit to an integer. Returns -1 on
  40231. * failure.
  40232. */
  40233. base64.decode = function (charCode) {
  40234. var bigA = 65; // 'A'
  40235. var bigZ = 90; // 'Z'
  40236. var littleA = 97; // 'a'
  40237. var littleZ = 122; // 'z'
  40238. var zero = 48; // '0'
  40239. var nine = 57; // '9'
  40240. var plus = 43; // '+'
  40241. var slash = 47; // '/'
  40242. var littleOffset = 26;
  40243. var numberOffset = 52;
  40244. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  40245. if (bigA <= charCode && charCode <= bigZ) {
  40246. return (charCode - bigA);
  40247. }
  40248. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  40249. if (littleA <= charCode && charCode <= littleZ) {
  40250. return (charCode - littleA + littleOffset);
  40251. }
  40252. // 52 - 61: 0123456789
  40253. if (zero <= charCode && charCode <= nine) {
  40254. return (charCode - zero + numberOffset);
  40255. }
  40256. // 62: +
  40257. if (charCode == plus) {
  40258. return 62;
  40259. }
  40260. // 63: /
  40261. if (charCode == slash) {
  40262. return 63;
  40263. }
  40264. // Invalid base64 digit.
  40265. return -1;
  40266. };
  40267. return base64;
  40268. }
  40269. /* -*- Mode: js; js-indent-level: 2; -*- */
  40270. var hasRequiredBase64Vlq;
  40271. function requireBase64Vlq () {
  40272. if (hasRequiredBase64Vlq) return base64Vlq;
  40273. hasRequiredBase64Vlq = 1;
  40274. /*
  40275. * Copyright 2011 Mozilla Foundation and contributors
  40276. * Licensed under the New BSD license. See LICENSE or:
  40277. * http://opensource.org/licenses/BSD-3-Clause
  40278. *
  40279. * Based on the Base 64 VLQ implementation in Closure Compiler:
  40280. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  40281. *
  40282. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  40283. * Redistribution and use in source and binary forms, with or without
  40284. * modification, are permitted provided that the following conditions are
  40285. * met:
  40286. *
  40287. * * Redistributions of source code must retain the above copyright
  40288. * notice, this list of conditions and the following disclaimer.
  40289. * * Redistributions in binary form must reproduce the above
  40290. * copyright notice, this list of conditions and the following
  40291. * disclaimer in the documentation and/or other materials provided
  40292. * with the distribution.
  40293. * * Neither the name of Google Inc. nor the names of its
  40294. * contributors may be used to endorse or promote products derived
  40295. * from this software without specific prior written permission.
  40296. *
  40297. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  40298. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  40299. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  40300. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  40301. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40302. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  40303. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  40304. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  40305. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  40306. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  40307. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40308. */
  40309. var base64 = /*@__PURE__*/ requireBase64();
  40310. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  40311. // length quantities we use in the source map spec, the first bit is the sign,
  40312. // the next four bits are the actual value, and the 6th bit is the
  40313. // continuation bit. The continuation bit tells us whether there are more
  40314. // digits in this value following this digit.
  40315. //
  40316. // Continuation
  40317. // | Sign
  40318. // | |
  40319. // V V
  40320. // 101011
  40321. var VLQ_BASE_SHIFT = 5;
  40322. // binary: 100000
  40323. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  40324. // binary: 011111
  40325. var VLQ_BASE_MASK = VLQ_BASE - 1;
  40326. // binary: 100000
  40327. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  40328. /**
  40329. * Converts from a two-complement value to a value where the sign bit is
  40330. * placed in the least significant bit. For example, as decimals:
  40331. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  40332. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  40333. */
  40334. function toVLQSigned(aValue) {
  40335. return aValue < 0
  40336. ? ((-aValue) << 1) + 1
  40337. : (aValue << 1) + 0;
  40338. }
  40339. /**
  40340. * Converts to a two-complement value from a value where the sign bit is
  40341. * placed in the least significant bit. For example, as decimals:
  40342. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  40343. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  40344. */
  40345. function fromVLQSigned(aValue) {
  40346. var isNegative = (aValue & 1) === 1;
  40347. var shifted = aValue >> 1;
  40348. return isNegative
  40349. ? -shifted
  40350. : shifted;
  40351. }
  40352. /**
  40353. * Returns the base 64 VLQ encoded value.
  40354. */
  40355. base64Vlq.encode = function base64VLQ_encode(aValue) {
  40356. var encoded = "";
  40357. var digit;
  40358. var vlq = toVLQSigned(aValue);
  40359. do {
  40360. digit = vlq & VLQ_BASE_MASK;
  40361. vlq >>>= VLQ_BASE_SHIFT;
  40362. if (vlq > 0) {
  40363. // There are still more digits in this value, so we must make sure the
  40364. // continuation bit is marked.
  40365. digit |= VLQ_CONTINUATION_BIT;
  40366. }
  40367. encoded += base64.encode(digit);
  40368. } while (vlq > 0);
  40369. return encoded;
  40370. };
  40371. /**
  40372. * Decodes the next base 64 VLQ value from the given string and returns the
  40373. * value and the rest of the string via the out parameter.
  40374. */
  40375. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  40376. var strLen = aStr.length;
  40377. var result = 0;
  40378. var shift = 0;
  40379. var continuation, digit;
  40380. do {
  40381. if (aIndex >= strLen) {
  40382. throw new Error("Expected more digits in base 64 VLQ value.");
  40383. }
  40384. digit = base64.decode(aStr.charCodeAt(aIndex++));
  40385. if (digit === -1) {
  40386. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  40387. }
  40388. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  40389. digit &= VLQ_BASE_MASK;
  40390. result = result + (digit << shift);
  40391. shift += VLQ_BASE_SHIFT;
  40392. } while (continuation);
  40393. aOutParam.value = fromVLQSigned(result);
  40394. aOutParam.rest = aIndex;
  40395. };
  40396. return base64Vlq;
  40397. }
  40398. var util = {};
  40399. /* -*- Mode: js; js-indent-level: 2; -*- */
  40400. var hasRequiredUtil;
  40401. function requireUtil () {
  40402. if (hasRequiredUtil) return util;
  40403. hasRequiredUtil = 1;
  40404. (function (exports) {
  40405. /*
  40406. * Copyright 2011 Mozilla Foundation and contributors
  40407. * Licensed under the New BSD license. See LICENSE or:
  40408. * http://opensource.org/licenses/BSD-3-Clause
  40409. */
  40410. /**
  40411. * This is a helper function for getting values from parameter/options
  40412. * objects.
  40413. *
  40414. * @param args The object we are extracting values from
  40415. * @param name The name of the property we are getting.
  40416. * @param defaultValue An optional value to return if the property is missing
  40417. * from the object. If this is not specified and the property is missing, an
  40418. * error will be thrown.
  40419. */
  40420. function getArg(aArgs, aName, aDefaultValue) {
  40421. if (aName in aArgs) {
  40422. return aArgs[aName];
  40423. } else if (arguments.length === 3) {
  40424. return aDefaultValue;
  40425. } else {
  40426. throw new Error('"' + aName + '" is a required argument.');
  40427. }
  40428. }
  40429. exports.getArg = getArg;
  40430. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  40431. var dataUrlRegexp = /^data:.+\,.+$/;
  40432. function urlParse(aUrl) {
  40433. var match = aUrl.match(urlRegexp);
  40434. if (!match) {
  40435. return null;
  40436. }
  40437. return {
  40438. scheme: match[1],
  40439. auth: match[2],
  40440. host: match[3],
  40441. port: match[4],
  40442. path: match[5]
  40443. };
  40444. }
  40445. exports.urlParse = urlParse;
  40446. function urlGenerate(aParsedUrl) {
  40447. var url = '';
  40448. if (aParsedUrl.scheme) {
  40449. url += aParsedUrl.scheme + ':';
  40450. }
  40451. url += '//';
  40452. if (aParsedUrl.auth) {
  40453. url += aParsedUrl.auth + '@';
  40454. }
  40455. if (aParsedUrl.host) {
  40456. url += aParsedUrl.host;
  40457. }
  40458. if (aParsedUrl.port) {
  40459. url += ":" + aParsedUrl.port;
  40460. }
  40461. if (aParsedUrl.path) {
  40462. url += aParsedUrl.path;
  40463. }
  40464. return url;
  40465. }
  40466. exports.urlGenerate = urlGenerate;
  40467. /**
  40468. * Normalizes a path, or the path portion of a URL:
  40469. *
  40470. * - Replaces consecutive slashes with one slash.
  40471. * - Removes unnecessary '.' parts.
  40472. * - Removes unnecessary '<dir>/..' parts.
  40473. *
  40474. * Based on code in the Node.js 'path' core module.
  40475. *
  40476. * @param aPath The path or url to normalize.
  40477. */
  40478. function normalize(aPath) {
  40479. var path = aPath;
  40480. var url = urlParse(aPath);
  40481. if (url) {
  40482. if (!url.path) {
  40483. return aPath;
  40484. }
  40485. path = url.path;
  40486. }
  40487. var isAbsolute = exports.isAbsolute(path);
  40488. var parts = path.split(/\/+/);
  40489. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  40490. part = parts[i];
  40491. if (part === '.') {
  40492. parts.splice(i, 1);
  40493. } else if (part === '..') {
  40494. up++;
  40495. } else if (up > 0) {
  40496. if (part === '') {
  40497. // The first part is blank if the path is absolute. Trying to go
  40498. // above the root is a no-op. Therefore we can remove all '..' parts
  40499. // directly after the root.
  40500. parts.splice(i + 1, up);
  40501. up = 0;
  40502. } else {
  40503. parts.splice(i, 2);
  40504. up--;
  40505. }
  40506. }
  40507. }
  40508. path = parts.join('/');
  40509. if (path === '') {
  40510. path = isAbsolute ? '/' : '.';
  40511. }
  40512. if (url) {
  40513. url.path = path;
  40514. return urlGenerate(url);
  40515. }
  40516. return path;
  40517. }
  40518. exports.normalize = normalize;
  40519. /**
  40520. * Joins two paths/URLs.
  40521. *
  40522. * @param aRoot The root path or URL.
  40523. * @param aPath The path or URL to be joined with the root.
  40524. *
  40525. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  40526. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  40527. * first.
  40528. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  40529. * is updated with the result and aRoot is returned. Otherwise the result
  40530. * is returned.
  40531. * - If aPath is absolute, the result is aPath.
  40532. * - Otherwise the two paths are joined with a slash.
  40533. * - Joining for example 'http://' and 'www.example.com' is also supported.
  40534. */
  40535. function join(aRoot, aPath) {
  40536. if (aRoot === "") {
  40537. aRoot = ".";
  40538. }
  40539. if (aPath === "") {
  40540. aPath = ".";
  40541. }
  40542. var aPathUrl = urlParse(aPath);
  40543. var aRootUrl = urlParse(aRoot);
  40544. if (aRootUrl) {
  40545. aRoot = aRootUrl.path || '/';
  40546. }
  40547. // `join(foo, '//www.example.org')`
  40548. if (aPathUrl && !aPathUrl.scheme) {
  40549. if (aRootUrl) {
  40550. aPathUrl.scheme = aRootUrl.scheme;
  40551. }
  40552. return urlGenerate(aPathUrl);
  40553. }
  40554. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  40555. return aPath;
  40556. }
  40557. // `join('http://', 'www.example.com')`
  40558. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  40559. aRootUrl.host = aPath;
  40560. return urlGenerate(aRootUrl);
  40561. }
  40562. var joined = aPath.charAt(0) === '/'
  40563. ? aPath
  40564. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  40565. if (aRootUrl) {
  40566. aRootUrl.path = joined;
  40567. return urlGenerate(aRootUrl);
  40568. }
  40569. return joined;
  40570. }
  40571. exports.join = join;
  40572. exports.isAbsolute = function (aPath) {
  40573. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  40574. };
  40575. /**
  40576. * Make a path relative to a URL or another path.
  40577. *
  40578. * @param aRoot The root path or URL.
  40579. * @param aPath The path or URL to be made relative to aRoot.
  40580. */
  40581. function relative(aRoot, aPath) {
  40582. if (aRoot === "") {
  40583. aRoot = ".";
  40584. }
  40585. aRoot = aRoot.replace(/\/$/, '');
  40586. // It is possible for the path to be above the root. In this case, simply
  40587. // checking whether the root is a prefix of the path won't work. Instead, we
  40588. // need to remove components from the root one by one, until either we find
  40589. // a prefix that fits, or we run out of components to remove.
  40590. var level = 0;
  40591. while (aPath.indexOf(aRoot + '/') !== 0) {
  40592. var index = aRoot.lastIndexOf("/");
  40593. if (index < 0) {
  40594. return aPath;
  40595. }
  40596. // If the only part of the root that is left is the scheme (i.e. http://,
  40597. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  40598. // have exhausted all components, so the path is not relative to the root.
  40599. aRoot = aRoot.slice(0, index);
  40600. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  40601. return aPath;
  40602. }
  40603. ++level;
  40604. }
  40605. // Make sure we add a "../" for each component we removed from the root.
  40606. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  40607. }
  40608. exports.relative = relative;
  40609. var supportsNullProto = (function () {
  40610. var obj = Object.create(null);
  40611. return !('__proto__' in obj);
  40612. }());
  40613. function identity (s) {
  40614. return s;
  40615. }
  40616. /**
  40617. * Because behavior goes wacky when you set `__proto__` on objects, we
  40618. * have to prefix all the strings in our set with an arbitrary character.
  40619. *
  40620. * See https://github.com/mozilla/source-map/pull/31 and
  40621. * https://github.com/mozilla/source-map/issues/30
  40622. *
  40623. * @param String aStr
  40624. */
  40625. function toSetString(aStr) {
  40626. if (isProtoString(aStr)) {
  40627. return '$' + aStr;
  40628. }
  40629. return aStr;
  40630. }
  40631. exports.toSetString = supportsNullProto ? identity : toSetString;
  40632. function fromSetString(aStr) {
  40633. if (isProtoString(aStr)) {
  40634. return aStr.slice(1);
  40635. }
  40636. return aStr;
  40637. }
  40638. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  40639. function isProtoString(s) {
  40640. if (!s) {
  40641. return false;
  40642. }
  40643. var length = s.length;
  40644. if (length < 9 /* "__proto__".length */) {
  40645. return false;
  40646. }
  40647. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  40648. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  40649. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  40650. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  40651. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  40652. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  40653. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  40654. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  40655. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  40656. return false;
  40657. }
  40658. for (var i = length - 10; i >= 0; i--) {
  40659. if (s.charCodeAt(i) !== 36 /* '$' */) {
  40660. return false;
  40661. }
  40662. }
  40663. return true;
  40664. }
  40665. /**
  40666. * Comparator between two mappings where the original positions are compared.
  40667. *
  40668. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  40669. * mappings with the same original source/line/column, but different generated
  40670. * line and column the same. Useful when searching for a mapping with a
  40671. * stubbed out mapping.
  40672. */
  40673. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  40674. var cmp = strcmp(mappingA.source, mappingB.source);
  40675. if (cmp !== 0) {
  40676. return cmp;
  40677. }
  40678. cmp = mappingA.originalLine - mappingB.originalLine;
  40679. if (cmp !== 0) {
  40680. return cmp;
  40681. }
  40682. cmp = mappingA.originalColumn - mappingB.originalColumn;
  40683. if (cmp !== 0 || onlyCompareOriginal) {
  40684. return cmp;
  40685. }
  40686. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  40687. if (cmp !== 0) {
  40688. return cmp;
  40689. }
  40690. cmp = mappingA.generatedLine - mappingB.generatedLine;
  40691. if (cmp !== 0) {
  40692. return cmp;
  40693. }
  40694. return strcmp(mappingA.name, mappingB.name);
  40695. }
  40696. exports.compareByOriginalPositions = compareByOriginalPositions;
  40697. /**
  40698. * Comparator between two mappings with deflated source and name indices where
  40699. * the generated positions are compared.
  40700. *
  40701. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  40702. * mappings with the same generated line and column, but different
  40703. * source/name/original line and column the same. Useful when searching for a
  40704. * mapping with a stubbed out mapping.
  40705. */
  40706. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  40707. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  40708. if (cmp !== 0) {
  40709. return cmp;
  40710. }
  40711. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  40712. if (cmp !== 0 || onlyCompareGenerated) {
  40713. return cmp;
  40714. }
  40715. cmp = strcmp(mappingA.source, mappingB.source);
  40716. if (cmp !== 0) {
  40717. return cmp;
  40718. }
  40719. cmp = mappingA.originalLine - mappingB.originalLine;
  40720. if (cmp !== 0) {
  40721. return cmp;
  40722. }
  40723. cmp = mappingA.originalColumn - mappingB.originalColumn;
  40724. if (cmp !== 0) {
  40725. return cmp;
  40726. }
  40727. return strcmp(mappingA.name, mappingB.name);
  40728. }
  40729. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  40730. function strcmp(aStr1, aStr2) {
  40731. if (aStr1 === aStr2) {
  40732. return 0;
  40733. }
  40734. if (aStr1 === null) {
  40735. return 1; // aStr2 !== null
  40736. }
  40737. if (aStr2 === null) {
  40738. return -1; // aStr1 !== null
  40739. }
  40740. if (aStr1 > aStr2) {
  40741. return 1;
  40742. }
  40743. return -1;
  40744. }
  40745. /**
  40746. * Comparator between two mappings with inflated source and name strings where
  40747. * the generated positions are compared.
  40748. */
  40749. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  40750. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  40751. if (cmp !== 0) {
  40752. return cmp;
  40753. }
  40754. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  40755. if (cmp !== 0) {
  40756. return cmp;
  40757. }
  40758. cmp = strcmp(mappingA.source, mappingB.source);
  40759. if (cmp !== 0) {
  40760. return cmp;
  40761. }
  40762. cmp = mappingA.originalLine - mappingB.originalLine;
  40763. if (cmp !== 0) {
  40764. return cmp;
  40765. }
  40766. cmp = mappingA.originalColumn - mappingB.originalColumn;
  40767. if (cmp !== 0) {
  40768. return cmp;
  40769. }
  40770. return strcmp(mappingA.name, mappingB.name);
  40771. }
  40772. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  40773. /**
  40774. * Strip any JSON XSSI avoidance prefix from the string (as documented
  40775. * in the source maps specification), and then parse the string as
  40776. * JSON.
  40777. */
  40778. function parseSourceMapInput(str) {
  40779. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  40780. }
  40781. exports.parseSourceMapInput = parseSourceMapInput;
  40782. /**
  40783. * Compute the URL of a source given the the source root, the source's
  40784. * URL, and the source map's URL.
  40785. */
  40786. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  40787. sourceURL = sourceURL || '';
  40788. if (sourceRoot) {
  40789. // This follows what Chrome does.
  40790. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  40791. sourceRoot += '/';
  40792. }
  40793. // The spec says:
  40794. // Line 4: An optional source root, useful for relocating source
  40795. // files on a server or removing repeated values in the
  40796. // “sources” entry. This value is prepended to the individual
  40797. // entries in the “source” field.
  40798. sourceURL = sourceRoot + sourceURL;
  40799. }
  40800. // Historically, SourceMapConsumer did not take the sourceMapURL as
  40801. // a parameter. This mode is still somewhat supported, which is why
  40802. // this code block is conditional. However, it's preferable to pass
  40803. // the source map URL to SourceMapConsumer, so that this function
  40804. // can implement the source URL resolution algorithm as outlined in
  40805. // the spec. This block is basically the equivalent of:
  40806. // new URL(sourceURL, sourceMapURL).toString()
  40807. // ... except it avoids using URL, which wasn't available in the
  40808. // older releases of node still supported by this library.
  40809. //
  40810. // The spec says:
  40811. // If the sources are not absolute URLs after prepending of the
  40812. // “sourceRoot”, the sources are resolved relative to the
  40813. // SourceMap (like resolving script src in a html document).
  40814. if (sourceMapURL) {
  40815. var parsed = urlParse(sourceMapURL);
  40816. if (!parsed) {
  40817. throw new Error("sourceMapURL could not be parsed");
  40818. }
  40819. if (parsed.path) {
  40820. // Strip the last path component, but keep the "/".
  40821. var index = parsed.path.lastIndexOf('/');
  40822. if (index >= 0) {
  40823. parsed.path = parsed.path.substring(0, index + 1);
  40824. }
  40825. }
  40826. sourceURL = join(urlGenerate(parsed), sourceURL);
  40827. }
  40828. return normalize(sourceURL);
  40829. }
  40830. exports.computeSourceURL = computeSourceURL;
  40831. } (util));
  40832. return util;
  40833. }
  40834. var arraySet = {};
  40835. /* -*- Mode: js; js-indent-level: 2; -*- */
  40836. var hasRequiredArraySet;
  40837. function requireArraySet () {
  40838. if (hasRequiredArraySet) return arraySet;
  40839. hasRequiredArraySet = 1;
  40840. /*
  40841. * Copyright 2011 Mozilla Foundation and contributors
  40842. * Licensed under the New BSD license. See LICENSE or:
  40843. * http://opensource.org/licenses/BSD-3-Clause
  40844. */
  40845. var util = /*@__PURE__*/ requireUtil();
  40846. var has = Object.prototype.hasOwnProperty;
  40847. var hasNativeMap = typeof Map !== "undefined";
  40848. /**
  40849. * A data structure which is a combination of an array and a set. Adding a new
  40850. * member is O(1), testing for membership is O(1), and finding the index of an
  40851. * element is O(1). Removing elements from the set is not supported. Only
  40852. * strings are supported for membership.
  40853. */
  40854. function ArraySet() {
  40855. this._array = [];
  40856. this._set = hasNativeMap ? new Map() : Object.create(null);
  40857. }
  40858. /**
  40859. * Static method for creating ArraySet instances from an existing array.
  40860. */
  40861. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  40862. var set = new ArraySet();
  40863. for (var i = 0, len = aArray.length; i < len; i++) {
  40864. set.add(aArray[i], aAllowDuplicates);
  40865. }
  40866. return set;
  40867. };
  40868. /**
  40869. * Return how many unique items are in this ArraySet. If duplicates have been
  40870. * added, than those do not count towards the size.
  40871. *
  40872. * @returns Number
  40873. */
  40874. ArraySet.prototype.size = function ArraySet_size() {
  40875. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  40876. };
  40877. /**
  40878. * Add the given string to this set.
  40879. *
  40880. * @param String aStr
  40881. */
  40882. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  40883. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  40884. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  40885. var idx = this._array.length;
  40886. if (!isDuplicate || aAllowDuplicates) {
  40887. this._array.push(aStr);
  40888. }
  40889. if (!isDuplicate) {
  40890. if (hasNativeMap) {
  40891. this._set.set(aStr, idx);
  40892. } else {
  40893. this._set[sStr] = idx;
  40894. }
  40895. }
  40896. };
  40897. /**
  40898. * Is the given string a member of this set?
  40899. *
  40900. * @param String aStr
  40901. */
  40902. ArraySet.prototype.has = function ArraySet_has(aStr) {
  40903. if (hasNativeMap) {
  40904. return this._set.has(aStr);
  40905. } else {
  40906. var sStr = util.toSetString(aStr);
  40907. return has.call(this._set, sStr);
  40908. }
  40909. };
  40910. /**
  40911. * What is the index of the given string in the array?
  40912. *
  40913. * @param String aStr
  40914. */
  40915. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  40916. if (hasNativeMap) {
  40917. var idx = this._set.get(aStr);
  40918. if (idx >= 0) {
  40919. return idx;
  40920. }
  40921. } else {
  40922. var sStr = util.toSetString(aStr);
  40923. if (has.call(this._set, sStr)) {
  40924. return this._set[sStr];
  40925. }
  40926. }
  40927. throw new Error('"' + aStr + '" is not in the set.');
  40928. };
  40929. /**
  40930. * What is the element at the given index?
  40931. *
  40932. * @param Number aIdx
  40933. */
  40934. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  40935. if (aIdx >= 0 && aIdx < this._array.length) {
  40936. return this._array[aIdx];
  40937. }
  40938. throw new Error('No element indexed by ' + aIdx);
  40939. };
  40940. /**
  40941. * Returns the array representation of this set (which has the proper indices
  40942. * indicated by indexOf). Note that this is a copy of the internal array used
  40943. * for storing the members so that no one can mess with internal state.
  40944. */
  40945. ArraySet.prototype.toArray = function ArraySet_toArray() {
  40946. return this._array.slice();
  40947. };
  40948. arraySet.ArraySet = ArraySet;
  40949. return arraySet;
  40950. }
  40951. var mappingList = {};
  40952. /* -*- Mode: js; js-indent-level: 2; -*- */
  40953. var hasRequiredMappingList;
  40954. function requireMappingList () {
  40955. if (hasRequiredMappingList) return mappingList;
  40956. hasRequiredMappingList = 1;
  40957. /*
  40958. * Copyright 2014 Mozilla Foundation and contributors
  40959. * Licensed under the New BSD license. See LICENSE or:
  40960. * http://opensource.org/licenses/BSD-3-Clause
  40961. */
  40962. var util = /*@__PURE__*/ requireUtil();
  40963. /**
  40964. * Determine whether mappingB is after mappingA with respect to generated
  40965. * position.
  40966. */
  40967. function generatedPositionAfter(mappingA, mappingB) {
  40968. // Optimized for most common case
  40969. var lineA = mappingA.generatedLine;
  40970. var lineB = mappingB.generatedLine;
  40971. var columnA = mappingA.generatedColumn;
  40972. var columnB = mappingB.generatedColumn;
  40973. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  40974. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  40975. }
  40976. /**
  40977. * A data structure to provide a sorted view of accumulated mappings in a
  40978. * performance conscious manner. It trades a neglibable overhead in general
  40979. * case for a large speedup in case of mappings being added in order.
  40980. */
  40981. function MappingList() {
  40982. this._array = [];
  40983. this._sorted = true;
  40984. // Serves as infimum
  40985. this._last = {generatedLine: -1, generatedColumn: 0};
  40986. }
  40987. /**
  40988. * Iterate through internal items. This method takes the same arguments that
  40989. * `Array.prototype.forEach` takes.
  40990. *
  40991. * NOTE: The order of the mappings is NOT guaranteed.
  40992. */
  40993. MappingList.prototype.unsortedForEach =
  40994. function MappingList_forEach(aCallback, aThisArg) {
  40995. this._array.forEach(aCallback, aThisArg);
  40996. };
  40997. /**
  40998. * Add the given source mapping.
  40999. *
  41000. * @param Object aMapping
  41001. */
  41002. MappingList.prototype.add = function MappingList_add(aMapping) {
  41003. if (generatedPositionAfter(this._last, aMapping)) {
  41004. this._last = aMapping;
  41005. this._array.push(aMapping);
  41006. } else {
  41007. this._sorted = false;
  41008. this._array.push(aMapping);
  41009. }
  41010. };
  41011. /**
  41012. * Returns the flat, sorted array of mappings. The mappings are sorted by
  41013. * generated position.
  41014. *
  41015. * WARNING: This method returns internal data without copying, for
  41016. * performance. The return value must NOT be mutated, and should be treated as
  41017. * an immutable borrow. If you want to take ownership, you must make your own
  41018. * copy.
  41019. */
  41020. MappingList.prototype.toArray = function MappingList_toArray() {
  41021. if (!this._sorted) {
  41022. this._array.sort(util.compareByGeneratedPositionsInflated);
  41023. this._sorted = true;
  41024. }
  41025. return this._array;
  41026. };
  41027. mappingList.MappingList = MappingList;
  41028. return mappingList;
  41029. }
  41030. /* -*- Mode: js; js-indent-level: 2; -*- */
  41031. var hasRequiredSourceMapGenerator;
  41032. function requireSourceMapGenerator () {
  41033. if (hasRequiredSourceMapGenerator) return sourceMapGenerator;
  41034. hasRequiredSourceMapGenerator = 1;
  41035. /*
  41036. * Copyright 2011 Mozilla Foundation and contributors
  41037. * Licensed under the New BSD license. See LICENSE or:
  41038. * http://opensource.org/licenses/BSD-3-Clause
  41039. */
  41040. var base64VLQ = /*@__PURE__*/ requireBase64Vlq();
  41041. var util = /*@__PURE__*/ requireUtil();
  41042. var ArraySet = /*@__PURE__*/ requireArraySet().ArraySet;
  41043. var MappingList = /*@__PURE__*/ requireMappingList().MappingList;
  41044. /**
  41045. * An instance of the SourceMapGenerator represents a source map which is
  41046. * being built incrementally. You may pass an object with the following
  41047. * properties:
  41048. *
  41049. * - file: The filename of the generated source.
  41050. * - sourceRoot: A root for all relative URLs in this source map.
  41051. */
  41052. function SourceMapGenerator(aArgs) {
  41053. if (!aArgs) {
  41054. aArgs = {};
  41055. }
  41056. this._file = util.getArg(aArgs, 'file', null);
  41057. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  41058. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  41059. this._sources = new ArraySet();
  41060. this._names = new ArraySet();
  41061. this._mappings = new MappingList();
  41062. this._sourcesContents = null;
  41063. }
  41064. SourceMapGenerator.prototype._version = 3;
  41065. /**
  41066. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  41067. *
  41068. * @param aSourceMapConsumer The SourceMap.
  41069. */
  41070. SourceMapGenerator.fromSourceMap =
  41071. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  41072. var sourceRoot = aSourceMapConsumer.sourceRoot;
  41073. var generator = new SourceMapGenerator({
  41074. file: aSourceMapConsumer.file,
  41075. sourceRoot: sourceRoot
  41076. });
  41077. aSourceMapConsumer.eachMapping(function (mapping) {
  41078. var newMapping = {
  41079. generated: {
  41080. line: mapping.generatedLine,
  41081. column: mapping.generatedColumn
  41082. }
  41083. };
  41084. if (mapping.source != null) {
  41085. newMapping.source = mapping.source;
  41086. if (sourceRoot != null) {
  41087. newMapping.source = util.relative(sourceRoot, newMapping.source);
  41088. }
  41089. newMapping.original = {
  41090. line: mapping.originalLine,
  41091. column: mapping.originalColumn
  41092. };
  41093. if (mapping.name != null) {
  41094. newMapping.name = mapping.name;
  41095. }
  41096. }
  41097. generator.addMapping(newMapping);
  41098. });
  41099. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  41100. var sourceRelative = sourceFile;
  41101. if (sourceRoot !== null) {
  41102. sourceRelative = util.relative(sourceRoot, sourceFile);
  41103. }
  41104. if (!generator._sources.has(sourceRelative)) {
  41105. generator._sources.add(sourceRelative);
  41106. }
  41107. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  41108. if (content != null) {
  41109. generator.setSourceContent(sourceFile, content);
  41110. }
  41111. });
  41112. return generator;
  41113. };
  41114. /**
  41115. * Add a single mapping from original source line and column to the generated
  41116. * source's line and column for this source map being created. The mapping
  41117. * object should have the following properties:
  41118. *
  41119. * - generated: An object with the generated line and column positions.
  41120. * - original: An object with the original line and column positions.
  41121. * - source: The original source file (relative to the sourceRoot).
  41122. * - name: An optional original token name for this mapping.
  41123. */
  41124. SourceMapGenerator.prototype.addMapping =
  41125. function SourceMapGenerator_addMapping(aArgs) {
  41126. var generated = util.getArg(aArgs, 'generated');
  41127. var original = util.getArg(aArgs, 'original', null);
  41128. var source = util.getArg(aArgs, 'source', null);
  41129. var name = util.getArg(aArgs, 'name', null);
  41130. if (!this._skipValidation) {
  41131. this._validateMapping(generated, original, source, name);
  41132. }
  41133. if (source != null) {
  41134. source = String(source);
  41135. if (!this._sources.has(source)) {
  41136. this._sources.add(source);
  41137. }
  41138. }
  41139. if (name != null) {
  41140. name = String(name);
  41141. if (!this._names.has(name)) {
  41142. this._names.add(name);
  41143. }
  41144. }
  41145. this._mappings.add({
  41146. generatedLine: generated.line,
  41147. generatedColumn: generated.column,
  41148. originalLine: original != null && original.line,
  41149. originalColumn: original != null && original.column,
  41150. source: source,
  41151. name: name
  41152. });
  41153. };
  41154. /**
  41155. * Set the source content for a source file.
  41156. */
  41157. SourceMapGenerator.prototype.setSourceContent =
  41158. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  41159. var source = aSourceFile;
  41160. if (this._sourceRoot != null) {
  41161. source = util.relative(this._sourceRoot, source);
  41162. }
  41163. if (aSourceContent != null) {
  41164. // Add the source content to the _sourcesContents map.
  41165. // Create a new _sourcesContents map if the property is null.
  41166. if (!this._sourcesContents) {
  41167. this._sourcesContents = Object.create(null);
  41168. }
  41169. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  41170. } else if (this._sourcesContents) {
  41171. // Remove the source file from the _sourcesContents map.
  41172. // If the _sourcesContents map is empty, set the property to null.
  41173. delete this._sourcesContents[util.toSetString(source)];
  41174. if (Object.keys(this._sourcesContents).length === 0) {
  41175. this._sourcesContents = null;
  41176. }
  41177. }
  41178. };
  41179. /**
  41180. * Applies the mappings of a sub-source-map for a specific source file to the
  41181. * source map being generated. Each mapping to the supplied source file is
  41182. * rewritten using the supplied source map. Note: The resolution for the
  41183. * resulting mappings is the minimium of this map and the supplied map.
  41184. *
  41185. * @param aSourceMapConsumer The source map to be applied.
  41186. * @param aSourceFile Optional. The filename of the source file.
  41187. * If omitted, SourceMapConsumer's file property will be used.
  41188. * @param aSourceMapPath Optional. The dirname of the path to the source map
  41189. * to be applied. If relative, it is relative to the SourceMapConsumer.
  41190. * This parameter is needed when the two source maps aren't in the same
  41191. * directory, and the source map to be applied contains relative source
  41192. * paths. If so, those relative source paths need to be rewritten
  41193. * relative to the SourceMapGenerator.
  41194. */
  41195. SourceMapGenerator.prototype.applySourceMap =
  41196. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  41197. var sourceFile = aSourceFile;
  41198. // If aSourceFile is omitted, we will use the file property of the SourceMap
  41199. if (aSourceFile == null) {
  41200. if (aSourceMapConsumer.file == null) {
  41201. throw new Error(
  41202. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  41203. 'or the source map\'s "file" property. Both were omitted.'
  41204. );
  41205. }
  41206. sourceFile = aSourceMapConsumer.file;
  41207. }
  41208. var sourceRoot = this._sourceRoot;
  41209. // Make "sourceFile" relative if an absolute Url is passed.
  41210. if (sourceRoot != null) {
  41211. sourceFile = util.relative(sourceRoot, sourceFile);
  41212. }
  41213. // Applying the SourceMap can add and remove items from the sources and
  41214. // the names array.
  41215. var newSources = new ArraySet();
  41216. var newNames = new ArraySet();
  41217. // Find mappings for the "sourceFile"
  41218. this._mappings.unsortedForEach(function (mapping) {
  41219. if (mapping.source === sourceFile && mapping.originalLine != null) {
  41220. // Check if it can be mapped by the source map, then update the mapping.
  41221. var original = aSourceMapConsumer.originalPositionFor({
  41222. line: mapping.originalLine,
  41223. column: mapping.originalColumn
  41224. });
  41225. if (original.source != null) {
  41226. // Copy mapping
  41227. mapping.source = original.source;
  41228. if (aSourceMapPath != null) {
  41229. mapping.source = util.join(aSourceMapPath, mapping.source);
  41230. }
  41231. if (sourceRoot != null) {
  41232. mapping.source = util.relative(sourceRoot, mapping.source);
  41233. }
  41234. mapping.originalLine = original.line;
  41235. mapping.originalColumn = original.column;
  41236. if (original.name != null) {
  41237. mapping.name = original.name;
  41238. }
  41239. }
  41240. }
  41241. var source = mapping.source;
  41242. if (source != null && !newSources.has(source)) {
  41243. newSources.add(source);
  41244. }
  41245. var name = mapping.name;
  41246. if (name != null && !newNames.has(name)) {
  41247. newNames.add(name);
  41248. }
  41249. }, this);
  41250. this._sources = newSources;
  41251. this._names = newNames;
  41252. // Copy sourcesContents of applied map.
  41253. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  41254. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  41255. if (content != null) {
  41256. if (aSourceMapPath != null) {
  41257. sourceFile = util.join(aSourceMapPath, sourceFile);
  41258. }
  41259. if (sourceRoot != null) {
  41260. sourceFile = util.relative(sourceRoot, sourceFile);
  41261. }
  41262. this.setSourceContent(sourceFile, content);
  41263. }
  41264. }, this);
  41265. };
  41266. /**
  41267. * A mapping can have one of the three levels of data:
  41268. *
  41269. * 1. Just the generated position.
  41270. * 2. The Generated position, original position, and original source.
  41271. * 3. Generated and original position, original source, as well as a name
  41272. * token.
  41273. *
  41274. * To maintain consistency, we validate that any new mapping being added falls
  41275. * in to one of these categories.
  41276. */
  41277. SourceMapGenerator.prototype._validateMapping =
  41278. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  41279. aName) {
  41280. // When aOriginal is truthy but has empty values for .line and .column,
  41281. // it is most likely a programmer error. In this case we throw a very
  41282. // specific error message to try to guide them the right way.
  41283. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  41284. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  41285. throw new Error(
  41286. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  41287. 'the original mapping entirely and only map the generated position. If so, pass ' +
  41288. 'null for the original mapping instead of an object with empty or null values.'
  41289. );
  41290. }
  41291. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  41292. && aGenerated.line > 0 && aGenerated.column >= 0
  41293. && !aOriginal && !aSource && !aName) {
  41294. // Case 1.
  41295. return;
  41296. }
  41297. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  41298. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  41299. && aGenerated.line > 0 && aGenerated.column >= 0
  41300. && aOriginal.line > 0 && aOriginal.column >= 0
  41301. && aSource) {
  41302. // Cases 2 and 3.
  41303. return;
  41304. }
  41305. else {
  41306. throw new Error('Invalid mapping: ' + JSON.stringify({
  41307. generated: aGenerated,
  41308. source: aSource,
  41309. original: aOriginal,
  41310. name: aName
  41311. }));
  41312. }
  41313. };
  41314. /**
  41315. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  41316. * specified by the source map format.
  41317. */
  41318. SourceMapGenerator.prototype._serializeMappings =
  41319. function SourceMapGenerator_serializeMappings() {
  41320. var previousGeneratedColumn = 0;
  41321. var previousGeneratedLine = 1;
  41322. var previousOriginalColumn = 0;
  41323. var previousOriginalLine = 0;
  41324. var previousName = 0;
  41325. var previousSource = 0;
  41326. var result = '';
  41327. var next;
  41328. var mapping;
  41329. var nameIdx;
  41330. var sourceIdx;
  41331. var mappings = this._mappings.toArray();
  41332. for (var i = 0, len = mappings.length; i < len; i++) {
  41333. mapping = mappings[i];
  41334. next = '';
  41335. if (mapping.generatedLine !== previousGeneratedLine) {
  41336. previousGeneratedColumn = 0;
  41337. while (mapping.generatedLine !== previousGeneratedLine) {
  41338. next += ';';
  41339. previousGeneratedLine++;
  41340. }
  41341. }
  41342. else {
  41343. if (i > 0) {
  41344. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  41345. continue;
  41346. }
  41347. next += ',';
  41348. }
  41349. }
  41350. next += base64VLQ.encode(mapping.generatedColumn
  41351. - previousGeneratedColumn);
  41352. previousGeneratedColumn = mapping.generatedColumn;
  41353. if (mapping.source != null) {
  41354. sourceIdx = this._sources.indexOf(mapping.source);
  41355. next += base64VLQ.encode(sourceIdx - previousSource);
  41356. previousSource = sourceIdx;
  41357. // lines are stored 0-based in SourceMap spec version 3
  41358. next += base64VLQ.encode(mapping.originalLine - 1
  41359. - previousOriginalLine);
  41360. previousOriginalLine = mapping.originalLine - 1;
  41361. next += base64VLQ.encode(mapping.originalColumn
  41362. - previousOriginalColumn);
  41363. previousOriginalColumn = mapping.originalColumn;
  41364. if (mapping.name != null) {
  41365. nameIdx = this._names.indexOf(mapping.name);
  41366. next += base64VLQ.encode(nameIdx - previousName);
  41367. previousName = nameIdx;
  41368. }
  41369. }
  41370. result += next;
  41371. }
  41372. return result;
  41373. };
  41374. SourceMapGenerator.prototype._generateSourcesContent =
  41375. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  41376. return aSources.map(function (source) {
  41377. if (!this._sourcesContents) {
  41378. return null;
  41379. }
  41380. if (aSourceRoot != null) {
  41381. source = util.relative(aSourceRoot, source);
  41382. }
  41383. var key = util.toSetString(source);
  41384. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  41385. ? this._sourcesContents[key]
  41386. : null;
  41387. }, this);
  41388. };
  41389. /**
  41390. * Externalize the source map.
  41391. */
  41392. SourceMapGenerator.prototype.toJSON =
  41393. function SourceMapGenerator_toJSON() {
  41394. var map = {
  41395. version: this._version,
  41396. sources: this._sources.toArray(),
  41397. names: this._names.toArray(),
  41398. mappings: this._serializeMappings()
  41399. };
  41400. if (this._file != null) {
  41401. map.file = this._file;
  41402. }
  41403. if (this._sourceRoot != null) {
  41404. map.sourceRoot = this._sourceRoot;
  41405. }
  41406. if (this._sourcesContents) {
  41407. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  41408. }
  41409. return map;
  41410. };
  41411. /**
  41412. * Render the source map being generated to a string.
  41413. */
  41414. SourceMapGenerator.prototype.toString =
  41415. function SourceMapGenerator_toString() {
  41416. return JSON.stringify(this.toJSON());
  41417. };
  41418. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator;
  41419. return sourceMapGenerator;
  41420. }
  41421. var sourceMapConsumer = {};
  41422. var binarySearch = {};
  41423. /* -*- Mode: js; js-indent-level: 2; -*- */
  41424. var hasRequiredBinarySearch;
  41425. function requireBinarySearch () {
  41426. if (hasRequiredBinarySearch) return binarySearch;
  41427. hasRequiredBinarySearch = 1;
  41428. (function (exports) {
  41429. /*
  41430. * Copyright 2011 Mozilla Foundation and contributors
  41431. * Licensed under the New BSD license. See LICENSE or:
  41432. * http://opensource.org/licenses/BSD-3-Clause
  41433. */
  41434. exports.GREATEST_LOWER_BOUND = 1;
  41435. exports.LEAST_UPPER_BOUND = 2;
  41436. /**
  41437. * Recursive implementation of binary search.
  41438. *
  41439. * @param aLow Indices here and lower do not contain the needle.
  41440. * @param aHigh Indices here and higher do not contain the needle.
  41441. * @param aNeedle The element being searched for.
  41442. * @param aHaystack The non-empty array being searched.
  41443. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  41444. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  41445. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  41446. * closest element that is smaller than or greater than the one we are
  41447. * searching for, respectively, if the exact element cannot be found.
  41448. */
  41449. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  41450. // This function terminates when one of the following is true:
  41451. //
  41452. // 1. We find the exact element we are looking for.
  41453. //
  41454. // 2. We did not find the exact element, but we can return the index of
  41455. // the next-closest element.
  41456. //
  41457. // 3. We did not find the exact element, and there is no next-closest
  41458. // element than the one we are searching for, so we return -1.
  41459. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  41460. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  41461. if (cmp === 0) {
  41462. // Found the element we are looking for.
  41463. return mid;
  41464. }
  41465. else if (cmp > 0) {
  41466. // Our needle is greater than aHaystack[mid].
  41467. if (aHigh - mid > 1) {
  41468. // The element is in the upper half.
  41469. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  41470. }
  41471. // The exact needle element was not found in this haystack. Determine if
  41472. // we are in termination case (3) or (2) and return the appropriate thing.
  41473. if (aBias == exports.LEAST_UPPER_BOUND) {
  41474. return aHigh < aHaystack.length ? aHigh : -1;
  41475. } else {
  41476. return mid;
  41477. }
  41478. }
  41479. else {
  41480. // Our needle is less than aHaystack[mid].
  41481. if (mid - aLow > 1) {
  41482. // The element is in the lower half.
  41483. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  41484. }
  41485. // we are in termination case (3) or (2) and return the appropriate thing.
  41486. if (aBias == exports.LEAST_UPPER_BOUND) {
  41487. return mid;
  41488. } else {
  41489. return aLow < 0 ? -1 : aLow;
  41490. }
  41491. }
  41492. }
  41493. /**
  41494. * This is an implementation of binary search which will always try and return
  41495. * the index of the closest element if there is no exact hit. This is because
  41496. * mappings between original and generated line/col pairs are single points,
  41497. * and there is an implicit region between each of them, so a miss just means
  41498. * that you aren't on the very start of a region.
  41499. *
  41500. * @param aNeedle The element you are looking for.
  41501. * @param aHaystack The array that is being searched.
  41502. * @param aCompare A function which takes the needle and an element in the
  41503. * array and returns -1, 0, or 1 depending on whether the needle is less
  41504. * than, equal to, or greater than the element, respectively.
  41505. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  41506. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  41507. * closest element that is smaller than or greater than the one we are
  41508. * searching for, respectively, if the exact element cannot be found.
  41509. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  41510. */
  41511. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  41512. if (aHaystack.length === 0) {
  41513. return -1;
  41514. }
  41515. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  41516. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  41517. if (index < 0) {
  41518. return -1;
  41519. }
  41520. // We have found either the exact element, or the next-closest element than
  41521. // the one we are searching for. However, there may be more than one such
  41522. // element. Make sure we always return the smallest of these.
  41523. while (index - 1 >= 0) {
  41524. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  41525. break;
  41526. }
  41527. --index;
  41528. }
  41529. return index;
  41530. };
  41531. } (binarySearch));
  41532. return binarySearch;
  41533. }
  41534. var quickSort = {};
  41535. /* -*- Mode: js; js-indent-level: 2; -*- */
  41536. var hasRequiredQuickSort;
  41537. function requireQuickSort () {
  41538. if (hasRequiredQuickSort) return quickSort;
  41539. hasRequiredQuickSort = 1;
  41540. /*
  41541. * Copyright 2011 Mozilla Foundation and contributors
  41542. * Licensed under the New BSD license. See LICENSE or:
  41543. * http://opensource.org/licenses/BSD-3-Clause
  41544. */
  41545. // It turns out that some (most?) JavaScript engines don't self-host
  41546. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  41547. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  41548. // custom comparator function, calling back and forth between the VM's C++ and
  41549. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  41550. // worse generated code for the comparator function than would be optimal. In
  41551. // fact, when sorting with a comparator, these costs outweigh the benefits of
  41552. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  41553. // a ~3500ms mean speed-up in `bench/bench.html`.
  41554. /**
  41555. * Swap the elements indexed by `x` and `y` in the array `ary`.
  41556. *
  41557. * @param {Array} ary
  41558. * The array.
  41559. * @param {Number} x
  41560. * The index of the first item.
  41561. * @param {Number} y
  41562. * The index of the second item.
  41563. */
  41564. function swap(ary, x, y) {
  41565. var temp = ary[x];
  41566. ary[x] = ary[y];
  41567. ary[y] = temp;
  41568. }
  41569. /**
  41570. * Returns a random integer within the range `low .. high` inclusive.
  41571. *
  41572. * @param {Number} low
  41573. * The lower bound on the range.
  41574. * @param {Number} high
  41575. * The upper bound on the range.
  41576. */
  41577. function randomIntInRange(low, high) {
  41578. return Math.round(low + (Math.random() * (high - low)));
  41579. }
  41580. /**
  41581. * The Quick Sort algorithm.
  41582. *
  41583. * @param {Array} ary
  41584. * An array to sort.
  41585. * @param {function} comparator
  41586. * Function to use to compare two items.
  41587. * @param {Number} p
  41588. * Start index of the array
  41589. * @param {Number} r
  41590. * End index of the array
  41591. */
  41592. function doQuickSort(ary, comparator, p, r) {
  41593. // If our lower bound is less than our upper bound, we (1) partition the
  41594. // array into two pieces and (2) recurse on each half. If it is not, this is
  41595. // the empty array and our base case.
  41596. if (p < r) {
  41597. // (1) Partitioning.
  41598. //
  41599. // The partitioning chooses a pivot between `p` and `r` and moves all
  41600. // elements that are less than or equal to the pivot to the before it, and
  41601. // all the elements that are greater than it after it. The effect is that
  41602. // once partition is done, the pivot is in the exact place it will be when
  41603. // the array is put in sorted order, and it will not need to be moved
  41604. // again. This runs in O(n) time.
  41605. // Always choose a random pivot so that an input array which is reverse
  41606. // sorted does not cause O(n^2) running time.
  41607. var pivotIndex = randomIntInRange(p, r);
  41608. var i = p - 1;
  41609. swap(ary, pivotIndex, r);
  41610. var pivot = ary[r];
  41611. // Immediately after `j` is incremented in this loop, the following hold
  41612. // true:
  41613. //
  41614. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  41615. //
  41616. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  41617. for (var j = p; j < r; j++) {
  41618. if (comparator(ary[j], pivot) <= 0) {
  41619. i += 1;
  41620. swap(ary, i, j);
  41621. }
  41622. }
  41623. swap(ary, i + 1, j);
  41624. var q = i + 1;
  41625. // (2) Recurse on each half.
  41626. doQuickSort(ary, comparator, p, q - 1);
  41627. doQuickSort(ary, comparator, q + 1, r);
  41628. }
  41629. }
  41630. /**
  41631. * Sort the given array in-place with the given comparator function.
  41632. *
  41633. * @param {Array} ary
  41634. * An array to sort.
  41635. * @param {function} comparator
  41636. * Function to use to compare two items.
  41637. */
  41638. quickSort.quickSort = function (ary, comparator) {
  41639. doQuickSort(ary, comparator, 0, ary.length - 1);
  41640. };
  41641. return quickSort;
  41642. }
  41643. /* -*- Mode: js; js-indent-level: 2; -*- */
  41644. var hasRequiredSourceMapConsumer;
  41645. function requireSourceMapConsumer () {
  41646. if (hasRequiredSourceMapConsumer) return sourceMapConsumer;
  41647. hasRequiredSourceMapConsumer = 1;
  41648. /*
  41649. * Copyright 2011 Mozilla Foundation and contributors
  41650. * Licensed under the New BSD license. See LICENSE or:
  41651. * http://opensource.org/licenses/BSD-3-Clause
  41652. */
  41653. var util = /*@__PURE__*/ requireUtil();
  41654. var binarySearch = /*@__PURE__*/ requireBinarySearch();
  41655. var ArraySet = /*@__PURE__*/ requireArraySet().ArraySet;
  41656. var base64VLQ = /*@__PURE__*/ requireBase64Vlq();
  41657. var quickSort = /*@__PURE__*/ requireQuickSort().quickSort;
  41658. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  41659. var sourceMap = aSourceMap;
  41660. if (typeof aSourceMap === 'string') {
  41661. sourceMap = util.parseSourceMapInput(aSourceMap);
  41662. }
  41663. return sourceMap.sections != null
  41664. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  41665. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  41666. }
  41667. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  41668. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  41669. };
  41670. /**
  41671. * The version of the source mapping spec that we are consuming.
  41672. */
  41673. SourceMapConsumer.prototype._version = 3;
  41674. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  41675. // parsed mapping coordinates from the source map's "mappings" attribute. They
  41676. // are lazily instantiated, accessed via the `_generatedMappings` and
  41677. // `_originalMappings` getters respectively, and we only parse the mappings
  41678. // and create these arrays once queried for a source location. We jump through
  41679. // these hoops because there can be many thousands of mappings, and parsing
  41680. // them is expensive, so we only want to do it if we must.
  41681. //
  41682. // Each object in the arrays is of the form:
  41683. //
  41684. // {
  41685. // generatedLine: The line number in the generated code,
  41686. // generatedColumn: The column number in the generated code,
  41687. // source: The path to the original source file that generated this
  41688. // chunk of code,
  41689. // originalLine: The line number in the original source that
  41690. // corresponds to this chunk of generated code,
  41691. // originalColumn: The column number in the original source that
  41692. // corresponds to this chunk of generated code,
  41693. // name: The name of the original symbol which generated this chunk of
  41694. // code.
  41695. // }
  41696. //
  41697. // All properties except for `generatedLine` and `generatedColumn` can be
  41698. // `null`.
  41699. //
  41700. // `_generatedMappings` is ordered by the generated positions.
  41701. //
  41702. // `_originalMappings` is ordered by the original positions.
  41703. SourceMapConsumer.prototype.__generatedMappings = null;
  41704. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  41705. configurable: true,
  41706. enumerable: true,
  41707. get: function () {
  41708. if (!this.__generatedMappings) {
  41709. this._parseMappings(this._mappings, this.sourceRoot);
  41710. }
  41711. return this.__generatedMappings;
  41712. }
  41713. });
  41714. SourceMapConsumer.prototype.__originalMappings = null;
  41715. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  41716. configurable: true,
  41717. enumerable: true,
  41718. get: function () {
  41719. if (!this.__originalMappings) {
  41720. this._parseMappings(this._mappings, this.sourceRoot);
  41721. }
  41722. return this.__originalMappings;
  41723. }
  41724. });
  41725. SourceMapConsumer.prototype._charIsMappingSeparator =
  41726. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  41727. var c = aStr.charAt(index);
  41728. return c === ";" || c === ",";
  41729. };
  41730. /**
  41731. * Parse the mappings in a string in to a data structure which we can easily
  41732. * query (the ordered arrays in the `this.__generatedMappings` and
  41733. * `this.__originalMappings` properties).
  41734. */
  41735. SourceMapConsumer.prototype._parseMappings =
  41736. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  41737. throw new Error("Subclasses must implement _parseMappings");
  41738. };
  41739. SourceMapConsumer.GENERATED_ORDER = 1;
  41740. SourceMapConsumer.ORIGINAL_ORDER = 2;
  41741. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  41742. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  41743. /**
  41744. * Iterate over each mapping between an original source/line/column and a
  41745. * generated line/column in this source map.
  41746. *
  41747. * @param Function aCallback
  41748. * The function that is called with each mapping.
  41749. * @param Object aContext
  41750. * Optional. If specified, this object will be the value of `this` every
  41751. * time that `aCallback` is called.
  41752. * @param aOrder
  41753. * Either `SourceMapConsumer.GENERATED_ORDER` or
  41754. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  41755. * iterate over the mappings sorted by the generated file's line/column
  41756. * order or the original's source/line/column order, respectively. Defaults to
  41757. * `SourceMapConsumer.GENERATED_ORDER`.
  41758. */
  41759. SourceMapConsumer.prototype.eachMapping =
  41760. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  41761. var context = aContext || null;
  41762. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  41763. var mappings;
  41764. switch (order) {
  41765. case SourceMapConsumer.GENERATED_ORDER:
  41766. mappings = this._generatedMappings;
  41767. break;
  41768. case SourceMapConsumer.ORIGINAL_ORDER:
  41769. mappings = this._originalMappings;
  41770. break;
  41771. default:
  41772. throw new Error("Unknown order of iteration.");
  41773. }
  41774. var sourceRoot = this.sourceRoot;
  41775. mappings.map(function (mapping) {
  41776. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  41777. source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  41778. return {
  41779. source: source,
  41780. generatedLine: mapping.generatedLine,
  41781. generatedColumn: mapping.generatedColumn,
  41782. originalLine: mapping.originalLine,
  41783. originalColumn: mapping.originalColumn,
  41784. name: mapping.name === null ? null : this._names.at(mapping.name)
  41785. };
  41786. }, this).forEach(aCallback, context);
  41787. };
  41788. /**
  41789. * Returns all generated line and column information for the original source,
  41790. * line, and column provided. If no column is provided, returns all mappings
  41791. * corresponding to a either the line we are searching for or the next
  41792. * closest line that has any mappings. Otherwise, returns all mappings
  41793. * corresponding to the given line and either the column we are searching for
  41794. * or the next closest column that has any offsets.
  41795. *
  41796. * The only argument is an object with the following properties:
  41797. *
  41798. * - source: The filename of the original source.
  41799. * - line: The line number in the original source. The line number is 1-based.
  41800. * - column: Optional. the column number in the original source.
  41801. * The column number is 0-based.
  41802. *
  41803. * and an array of objects is returned, each with the following properties:
  41804. *
  41805. * - line: The line number in the generated source, or null. The
  41806. * line number is 1-based.
  41807. * - column: The column number in the generated source, or null.
  41808. * The column number is 0-based.
  41809. */
  41810. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  41811. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  41812. var line = util.getArg(aArgs, 'line');
  41813. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  41814. // returns the index of the closest mapping less than the needle. By
  41815. // setting needle.originalColumn to 0, we thus find the last mapping for
  41816. // the given line, provided such a mapping exists.
  41817. var needle = {
  41818. source: util.getArg(aArgs, 'source'),
  41819. originalLine: line,
  41820. originalColumn: util.getArg(aArgs, 'column', 0)
  41821. };
  41822. needle.source = this._findSourceIndex(needle.source);
  41823. if (needle.source < 0) {
  41824. return [];
  41825. }
  41826. var mappings = [];
  41827. var index = this._findMapping(needle,
  41828. this._originalMappings,
  41829. "originalLine",
  41830. "originalColumn",
  41831. util.compareByOriginalPositions,
  41832. binarySearch.LEAST_UPPER_BOUND);
  41833. if (index >= 0) {
  41834. var mapping = this._originalMappings[index];
  41835. if (aArgs.column === undefined) {
  41836. var originalLine = mapping.originalLine;
  41837. // Iterate until either we run out of mappings, or we run into
  41838. // a mapping for a different line than the one we found. Since
  41839. // mappings are sorted, this is guaranteed to find all mappings for
  41840. // the line we found.
  41841. while (mapping && mapping.originalLine === originalLine) {
  41842. mappings.push({
  41843. line: util.getArg(mapping, 'generatedLine', null),
  41844. column: util.getArg(mapping, 'generatedColumn', null),
  41845. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  41846. });
  41847. mapping = this._originalMappings[++index];
  41848. }
  41849. } else {
  41850. var originalColumn = mapping.originalColumn;
  41851. // Iterate until either we run out of mappings, or we run into
  41852. // a mapping for a different line than the one we were searching for.
  41853. // Since mappings are sorted, this is guaranteed to find all mappings for
  41854. // the line we are searching for.
  41855. while (mapping &&
  41856. mapping.originalLine === line &&
  41857. mapping.originalColumn == originalColumn) {
  41858. mappings.push({
  41859. line: util.getArg(mapping, 'generatedLine', null),
  41860. column: util.getArg(mapping, 'generatedColumn', null),
  41861. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  41862. });
  41863. mapping = this._originalMappings[++index];
  41864. }
  41865. }
  41866. }
  41867. return mappings;
  41868. };
  41869. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer;
  41870. /**
  41871. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  41872. * query for information about the original file positions by giving it a file
  41873. * position in the generated source.
  41874. *
  41875. * The first parameter is the raw source map (either as a JSON string, or
  41876. * already parsed to an object). According to the spec, source maps have the
  41877. * following attributes:
  41878. *
  41879. * - version: Which version of the source map spec this map is following.
  41880. * - sources: An array of URLs to the original source files.
  41881. * - names: An array of identifiers which can be referrenced by individual mappings.
  41882. * - sourceRoot: Optional. The URL root from which all sources are relative.
  41883. * - sourcesContent: Optional. An array of contents of the original source files.
  41884. * - mappings: A string of base64 VLQs which contain the actual mappings.
  41885. * - file: Optional. The generated file this source map is associated with.
  41886. *
  41887. * Here is an example source map, taken from the source map spec[0]:
  41888. *
  41889. * {
  41890. * version : 3,
  41891. * file: "out.js",
  41892. * sourceRoot : "",
  41893. * sources: ["foo.js", "bar.js"],
  41894. * names: ["src", "maps", "are", "fun"],
  41895. * mappings: "AA,AB;;ABCDE;"
  41896. * }
  41897. *
  41898. * The second parameter, if given, is a string whose value is the URL
  41899. * at which the source map was found. This URL is used to compute the
  41900. * sources array.
  41901. *
  41902. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  41903. */
  41904. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  41905. var sourceMap = aSourceMap;
  41906. if (typeof aSourceMap === 'string') {
  41907. sourceMap = util.parseSourceMapInput(aSourceMap);
  41908. }
  41909. var version = util.getArg(sourceMap, 'version');
  41910. var sources = util.getArg(sourceMap, 'sources');
  41911. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  41912. // requires the array) to play nice here.
  41913. var names = util.getArg(sourceMap, 'names', []);
  41914. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  41915. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  41916. var mappings = util.getArg(sourceMap, 'mappings');
  41917. var file = util.getArg(sourceMap, 'file', null);
  41918. // Once again, Sass deviates from the spec and supplies the version as a
  41919. // string rather than a number, so we use loose equality checking here.
  41920. if (version != this._version) {
  41921. throw new Error('Unsupported version: ' + version);
  41922. }
  41923. if (sourceRoot) {
  41924. sourceRoot = util.normalize(sourceRoot);
  41925. }
  41926. sources = sources
  41927. .map(String)
  41928. // Some source maps produce relative source paths like "./foo.js" instead of
  41929. // "foo.js". Normalize these first so that future comparisons will succeed.
  41930. // See bugzil.la/1090768.
  41931. .map(util.normalize)
  41932. // Always ensure that absolute sources are internally stored relative to
  41933. // the source root, if the source root is absolute. Not doing this would
  41934. // be particularly problematic when the source root is a prefix of the
  41935. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  41936. .map(function (source) {
  41937. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  41938. ? util.relative(sourceRoot, source)
  41939. : source;
  41940. });
  41941. // Pass `true` below to allow duplicate names and sources. While source maps
  41942. // are intended to be compressed and deduplicated, the TypeScript compiler
  41943. // sometimes generates source maps with duplicates in them. See Github issue
  41944. // #72 and bugzil.la/889492.
  41945. this._names = ArraySet.fromArray(names.map(String), true);
  41946. this._sources = ArraySet.fromArray(sources, true);
  41947. this._absoluteSources = this._sources.toArray().map(function (s) {
  41948. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  41949. });
  41950. this.sourceRoot = sourceRoot;
  41951. this.sourcesContent = sourcesContent;
  41952. this._mappings = mappings;
  41953. this._sourceMapURL = aSourceMapURL;
  41954. this.file = file;
  41955. }
  41956. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  41957. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  41958. /**
  41959. * Utility function to find the index of a source. Returns -1 if not
  41960. * found.
  41961. */
  41962. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  41963. var relativeSource = aSource;
  41964. if (this.sourceRoot != null) {
  41965. relativeSource = util.relative(this.sourceRoot, relativeSource);
  41966. }
  41967. if (this._sources.has(relativeSource)) {
  41968. return this._sources.indexOf(relativeSource);
  41969. }
  41970. // Maybe aSource is an absolute URL as returned by |sources|. In
  41971. // this case we can't simply undo the transform.
  41972. var i;
  41973. for (i = 0; i < this._absoluteSources.length; ++i) {
  41974. if (this._absoluteSources[i] == aSource) {
  41975. return i;
  41976. }
  41977. }
  41978. return -1;
  41979. };
  41980. /**
  41981. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  41982. *
  41983. * @param SourceMapGenerator aSourceMap
  41984. * The source map that will be consumed.
  41985. * @param String aSourceMapURL
  41986. * The URL at which the source map can be found (optional)
  41987. * @returns BasicSourceMapConsumer
  41988. */
  41989. BasicSourceMapConsumer.fromSourceMap =
  41990. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  41991. var smc = Object.create(BasicSourceMapConsumer.prototype);
  41992. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  41993. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  41994. smc.sourceRoot = aSourceMap._sourceRoot;
  41995. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  41996. smc.sourceRoot);
  41997. smc.file = aSourceMap._file;
  41998. smc._sourceMapURL = aSourceMapURL;
  41999. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  42000. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  42001. });
  42002. // Because we are modifying the entries (by converting string sources and
  42003. // names to indices into the sources and names ArraySets), we have to make
  42004. // a copy of the entry or else bad things happen. Shared mutable state
  42005. // strikes again! See github issue #191.
  42006. var generatedMappings = aSourceMap._mappings.toArray().slice();
  42007. var destGeneratedMappings = smc.__generatedMappings = [];
  42008. var destOriginalMappings = smc.__originalMappings = [];
  42009. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  42010. var srcMapping = generatedMappings[i];
  42011. var destMapping = new Mapping;
  42012. destMapping.generatedLine = srcMapping.generatedLine;
  42013. destMapping.generatedColumn = srcMapping.generatedColumn;
  42014. if (srcMapping.source) {
  42015. destMapping.source = sources.indexOf(srcMapping.source);
  42016. destMapping.originalLine = srcMapping.originalLine;
  42017. destMapping.originalColumn = srcMapping.originalColumn;
  42018. if (srcMapping.name) {
  42019. destMapping.name = names.indexOf(srcMapping.name);
  42020. }
  42021. destOriginalMappings.push(destMapping);
  42022. }
  42023. destGeneratedMappings.push(destMapping);
  42024. }
  42025. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  42026. return smc;
  42027. };
  42028. /**
  42029. * The version of the source mapping spec that we are consuming.
  42030. */
  42031. BasicSourceMapConsumer.prototype._version = 3;
  42032. /**
  42033. * The list of original sources.
  42034. */
  42035. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  42036. get: function () {
  42037. return this._absoluteSources.slice();
  42038. }
  42039. });
  42040. /**
  42041. * Provide the JIT with a nice shape / hidden class.
  42042. */
  42043. function Mapping() {
  42044. this.generatedLine = 0;
  42045. this.generatedColumn = 0;
  42046. this.source = null;
  42047. this.originalLine = null;
  42048. this.originalColumn = null;
  42049. this.name = null;
  42050. }
  42051. /**
  42052. * Parse the mappings in a string in to a data structure which we can easily
  42053. * query (the ordered arrays in the `this.__generatedMappings` and
  42054. * `this.__originalMappings` properties).
  42055. */
  42056. BasicSourceMapConsumer.prototype._parseMappings =
  42057. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  42058. var generatedLine = 1;
  42059. var previousGeneratedColumn = 0;
  42060. var previousOriginalLine = 0;
  42061. var previousOriginalColumn = 0;
  42062. var previousSource = 0;
  42063. var previousName = 0;
  42064. var length = aStr.length;
  42065. var index = 0;
  42066. var cachedSegments = {};
  42067. var temp = {};
  42068. var originalMappings = [];
  42069. var generatedMappings = [];
  42070. var mapping, str, segment, end, value;
  42071. while (index < length) {
  42072. if (aStr.charAt(index) === ';') {
  42073. generatedLine++;
  42074. index++;
  42075. previousGeneratedColumn = 0;
  42076. }
  42077. else if (aStr.charAt(index) === ',') {
  42078. index++;
  42079. }
  42080. else {
  42081. mapping = new Mapping();
  42082. mapping.generatedLine = generatedLine;
  42083. // Because each offset is encoded relative to the previous one,
  42084. // many segments often have the same encoding. We can exploit this
  42085. // fact by caching the parsed variable length fields of each segment,
  42086. // allowing us to avoid a second parse if we encounter the same
  42087. // segment again.
  42088. for (end = index; end < length; end++) {
  42089. if (this._charIsMappingSeparator(aStr, end)) {
  42090. break;
  42091. }
  42092. }
  42093. str = aStr.slice(index, end);
  42094. segment = cachedSegments[str];
  42095. if (segment) {
  42096. index += str.length;
  42097. } else {
  42098. segment = [];
  42099. while (index < end) {
  42100. base64VLQ.decode(aStr, index, temp);
  42101. value = temp.value;
  42102. index = temp.rest;
  42103. segment.push(value);
  42104. }
  42105. if (segment.length === 2) {
  42106. throw new Error('Found a source, but no line and column');
  42107. }
  42108. if (segment.length === 3) {
  42109. throw new Error('Found a source and line, but no column');
  42110. }
  42111. cachedSegments[str] = segment;
  42112. }
  42113. // Generated column.
  42114. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  42115. previousGeneratedColumn = mapping.generatedColumn;
  42116. if (segment.length > 1) {
  42117. // Original source.
  42118. mapping.source = previousSource + segment[1];
  42119. previousSource += segment[1];
  42120. // Original line.
  42121. mapping.originalLine = previousOriginalLine + segment[2];
  42122. previousOriginalLine = mapping.originalLine;
  42123. // Lines are stored 0-based
  42124. mapping.originalLine += 1;
  42125. // Original column.
  42126. mapping.originalColumn = previousOriginalColumn + segment[3];
  42127. previousOriginalColumn = mapping.originalColumn;
  42128. if (segment.length > 4) {
  42129. // Original name.
  42130. mapping.name = previousName + segment[4];
  42131. previousName += segment[4];
  42132. }
  42133. }
  42134. generatedMappings.push(mapping);
  42135. if (typeof mapping.originalLine === 'number') {
  42136. originalMappings.push(mapping);
  42137. }
  42138. }
  42139. }
  42140. quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
  42141. this.__generatedMappings = generatedMappings;
  42142. quickSort(originalMappings, util.compareByOriginalPositions);
  42143. this.__originalMappings = originalMappings;
  42144. };
  42145. /**
  42146. * Find the mapping that best matches the hypothetical "needle" mapping that
  42147. * we are searching for in the given "haystack" of mappings.
  42148. */
  42149. BasicSourceMapConsumer.prototype._findMapping =
  42150. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  42151. aColumnName, aComparator, aBias) {
  42152. // To return the position we are searching for, we must first find the
  42153. // mapping for the given position and then return the opposite position it
  42154. // points to. Because the mappings are sorted, we can use binary search to
  42155. // find the best mapping.
  42156. if (aNeedle[aLineName] <= 0) {
  42157. throw new TypeError('Line must be greater than or equal to 1, got '
  42158. + aNeedle[aLineName]);
  42159. }
  42160. if (aNeedle[aColumnName] < 0) {
  42161. throw new TypeError('Column must be greater than or equal to 0, got '
  42162. + aNeedle[aColumnName]);
  42163. }
  42164. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  42165. };
  42166. /**
  42167. * Compute the last column for each generated mapping. The last column is
  42168. * inclusive.
  42169. */
  42170. BasicSourceMapConsumer.prototype.computeColumnSpans =
  42171. function SourceMapConsumer_computeColumnSpans() {
  42172. for (var index = 0; index < this._generatedMappings.length; ++index) {
  42173. var mapping = this._generatedMappings[index];
  42174. // Mappings do not contain a field for the last generated columnt. We
  42175. // can come up with an optimistic estimate, however, by assuming that
  42176. // mappings are contiguous (i.e. given two consecutive mappings, the
  42177. // first mapping ends where the second one starts).
  42178. if (index + 1 < this._generatedMappings.length) {
  42179. var nextMapping = this._generatedMappings[index + 1];
  42180. if (mapping.generatedLine === nextMapping.generatedLine) {
  42181. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  42182. continue;
  42183. }
  42184. }
  42185. // The last mapping for each line spans the entire line.
  42186. mapping.lastGeneratedColumn = Infinity;
  42187. }
  42188. };
  42189. /**
  42190. * Returns the original source, line, and column information for the generated
  42191. * source's line and column positions provided. The only argument is an object
  42192. * with the following properties:
  42193. *
  42194. * - line: The line number in the generated source. The line number
  42195. * is 1-based.
  42196. * - column: The column number in the generated source. The column
  42197. * number is 0-based.
  42198. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  42199. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  42200. * closest element that is smaller than or greater than the one we are
  42201. * searching for, respectively, if the exact element cannot be found.
  42202. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  42203. *
  42204. * and an object is returned with the following properties:
  42205. *
  42206. * - source: The original source file, or null.
  42207. * - line: The line number in the original source, or null. The
  42208. * line number is 1-based.
  42209. * - column: The column number in the original source, or null. The
  42210. * column number is 0-based.
  42211. * - name: The original identifier, or null.
  42212. */
  42213. BasicSourceMapConsumer.prototype.originalPositionFor =
  42214. function SourceMapConsumer_originalPositionFor(aArgs) {
  42215. var needle = {
  42216. generatedLine: util.getArg(aArgs, 'line'),
  42217. generatedColumn: util.getArg(aArgs, 'column')
  42218. };
  42219. var index = this._findMapping(
  42220. needle,
  42221. this._generatedMappings,
  42222. "generatedLine",
  42223. "generatedColumn",
  42224. util.compareByGeneratedPositionsDeflated,
  42225. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  42226. );
  42227. if (index >= 0) {
  42228. var mapping = this._generatedMappings[index];
  42229. if (mapping.generatedLine === needle.generatedLine) {
  42230. var source = util.getArg(mapping, 'source', null);
  42231. if (source !== null) {
  42232. source = this._sources.at(source);
  42233. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  42234. }
  42235. var name = util.getArg(mapping, 'name', null);
  42236. if (name !== null) {
  42237. name = this._names.at(name);
  42238. }
  42239. return {
  42240. source: source,
  42241. line: util.getArg(mapping, 'originalLine', null),
  42242. column: util.getArg(mapping, 'originalColumn', null),
  42243. name: name
  42244. };
  42245. }
  42246. }
  42247. return {
  42248. source: null,
  42249. line: null,
  42250. column: null,
  42251. name: null
  42252. };
  42253. };
  42254. /**
  42255. * Return true if we have the source content for every source in the source
  42256. * map, false otherwise.
  42257. */
  42258. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  42259. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  42260. if (!this.sourcesContent) {
  42261. return false;
  42262. }
  42263. return this.sourcesContent.length >= this._sources.size() &&
  42264. !this.sourcesContent.some(function (sc) { return sc == null; });
  42265. };
  42266. /**
  42267. * Returns the original source content. The only argument is the url of the
  42268. * original source file. Returns null if no original source content is
  42269. * available.
  42270. */
  42271. BasicSourceMapConsumer.prototype.sourceContentFor =
  42272. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  42273. if (!this.sourcesContent) {
  42274. return null;
  42275. }
  42276. var index = this._findSourceIndex(aSource);
  42277. if (index >= 0) {
  42278. return this.sourcesContent[index];
  42279. }
  42280. var relativeSource = aSource;
  42281. if (this.sourceRoot != null) {
  42282. relativeSource = util.relative(this.sourceRoot, relativeSource);
  42283. }
  42284. var url;
  42285. if (this.sourceRoot != null
  42286. && (url = util.urlParse(this.sourceRoot))) {
  42287. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  42288. // many users. We can help them out when they expect file:// URIs to
  42289. // behave like it would if they were running a local HTTP server. See
  42290. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  42291. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  42292. if (url.scheme == "file"
  42293. && this._sources.has(fileUriAbsPath)) {
  42294. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  42295. }
  42296. if ((!url.path || url.path == "/")
  42297. && this._sources.has("/" + relativeSource)) {
  42298. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  42299. }
  42300. }
  42301. // This function is used recursively from
  42302. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  42303. // don't want to throw if we can't find the source - we just want to
  42304. // return null, so we provide a flag to exit gracefully.
  42305. if (nullOnMissing) {
  42306. return null;
  42307. }
  42308. else {
  42309. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  42310. }
  42311. };
  42312. /**
  42313. * Returns the generated line and column information for the original source,
  42314. * line, and column positions provided. The only argument is an object with
  42315. * the following properties:
  42316. *
  42317. * - source: The filename of the original source.
  42318. * - line: The line number in the original source. The line number
  42319. * is 1-based.
  42320. * - column: The column number in the original source. The column
  42321. * number is 0-based.
  42322. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  42323. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  42324. * closest element that is smaller than or greater than the one we are
  42325. * searching for, respectively, if the exact element cannot be found.
  42326. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  42327. *
  42328. * and an object is returned with the following properties:
  42329. *
  42330. * - line: The line number in the generated source, or null. The
  42331. * line number is 1-based.
  42332. * - column: The column number in the generated source, or null.
  42333. * The column number is 0-based.
  42334. */
  42335. BasicSourceMapConsumer.prototype.generatedPositionFor =
  42336. function SourceMapConsumer_generatedPositionFor(aArgs) {
  42337. var source = util.getArg(aArgs, 'source');
  42338. source = this._findSourceIndex(source);
  42339. if (source < 0) {
  42340. return {
  42341. line: null,
  42342. column: null,
  42343. lastColumn: null
  42344. };
  42345. }
  42346. var needle = {
  42347. source: source,
  42348. originalLine: util.getArg(aArgs, 'line'),
  42349. originalColumn: util.getArg(aArgs, 'column')
  42350. };
  42351. var index = this._findMapping(
  42352. needle,
  42353. this._originalMappings,
  42354. "originalLine",
  42355. "originalColumn",
  42356. util.compareByOriginalPositions,
  42357. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  42358. );
  42359. if (index >= 0) {
  42360. var mapping = this._originalMappings[index];
  42361. if (mapping.source === needle.source) {
  42362. return {
  42363. line: util.getArg(mapping, 'generatedLine', null),
  42364. column: util.getArg(mapping, 'generatedColumn', null),
  42365. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  42366. };
  42367. }
  42368. }
  42369. return {
  42370. line: null,
  42371. column: null,
  42372. lastColumn: null
  42373. };
  42374. };
  42375. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  42376. /**
  42377. * An IndexedSourceMapConsumer instance represents a parsed source map which
  42378. * we can query for information. It differs from BasicSourceMapConsumer in
  42379. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  42380. * input.
  42381. *
  42382. * The first parameter is a raw source map (either as a JSON string, or already
  42383. * parsed to an object). According to the spec for indexed source maps, they
  42384. * have the following attributes:
  42385. *
  42386. * - version: Which version of the source map spec this map is following.
  42387. * - file: Optional. The generated file this source map is associated with.
  42388. * - sections: A list of section definitions.
  42389. *
  42390. * Each value under the "sections" field has two fields:
  42391. * - offset: The offset into the original specified at which this section
  42392. * begins to apply, defined as an object with a "line" and "column"
  42393. * field.
  42394. * - map: A source map definition. This source map could also be indexed,
  42395. * but doesn't have to be.
  42396. *
  42397. * Instead of the "map" field, it's also possible to have a "url" field
  42398. * specifying a URL to retrieve a source map from, but that's currently
  42399. * unsupported.
  42400. *
  42401. * Here's an example source map, taken from the source map spec[0], but
  42402. * modified to omit a section which uses the "url" field.
  42403. *
  42404. * {
  42405. * version : 3,
  42406. * file: "app.js",
  42407. * sections: [{
  42408. * offset: {line:100, column:10},
  42409. * map: {
  42410. * version : 3,
  42411. * file: "section.js",
  42412. * sources: ["foo.js", "bar.js"],
  42413. * names: ["src", "maps", "are", "fun"],
  42414. * mappings: "AAAA,E;;ABCDE;"
  42415. * }
  42416. * }],
  42417. * }
  42418. *
  42419. * The second parameter, if given, is a string whose value is the URL
  42420. * at which the source map was found. This URL is used to compute the
  42421. * sources array.
  42422. *
  42423. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  42424. */
  42425. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  42426. var sourceMap = aSourceMap;
  42427. if (typeof aSourceMap === 'string') {
  42428. sourceMap = util.parseSourceMapInput(aSourceMap);
  42429. }
  42430. var version = util.getArg(sourceMap, 'version');
  42431. var sections = util.getArg(sourceMap, 'sections');
  42432. if (version != this._version) {
  42433. throw new Error('Unsupported version: ' + version);
  42434. }
  42435. this._sources = new ArraySet();
  42436. this._names = new ArraySet();
  42437. var lastOffset = {
  42438. line: -1,
  42439. column: 0
  42440. };
  42441. this._sections = sections.map(function (s) {
  42442. if (s.url) {
  42443. // The url field will require support for asynchronicity.
  42444. // See https://github.com/mozilla/source-map/issues/16
  42445. throw new Error('Support for url field in sections not implemented.');
  42446. }
  42447. var offset = util.getArg(s, 'offset');
  42448. var offsetLine = util.getArg(offset, 'line');
  42449. var offsetColumn = util.getArg(offset, 'column');
  42450. if (offsetLine < lastOffset.line ||
  42451. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  42452. throw new Error('Section offsets must be ordered and non-overlapping.');
  42453. }
  42454. lastOffset = offset;
  42455. return {
  42456. generatedOffset: {
  42457. // The offset fields are 0-based, but we use 1-based indices when
  42458. // encoding/decoding from VLQ.
  42459. generatedLine: offsetLine + 1,
  42460. generatedColumn: offsetColumn + 1
  42461. },
  42462. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  42463. }
  42464. });
  42465. }
  42466. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  42467. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  42468. /**
  42469. * The version of the source mapping spec that we are consuming.
  42470. */
  42471. IndexedSourceMapConsumer.prototype._version = 3;
  42472. /**
  42473. * The list of original sources.
  42474. */
  42475. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  42476. get: function () {
  42477. var sources = [];
  42478. for (var i = 0; i < this._sections.length; i++) {
  42479. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  42480. sources.push(this._sections[i].consumer.sources[j]);
  42481. }
  42482. }
  42483. return sources;
  42484. }
  42485. });
  42486. /**
  42487. * Returns the original source, line, and column information for the generated
  42488. * source's line and column positions provided. The only argument is an object
  42489. * with the following properties:
  42490. *
  42491. * - line: The line number in the generated source. The line number
  42492. * is 1-based.
  42493. * - column: The column number in the generated source. The column
  42494. * number is 0-based.
  42495. *
  42496. * and an object is returned with the following properties:
  42497. *
  42498. * - source: The original source file, or null.
  42499. * - line: The line number in the original source, or null. The
  42500. * line number is 1-based.
  42501. * - column: The column number in the original source, or null. The
  42502. * column number is 0-based.
  42503. * - name: The original identifier, or null.
  42504. */
  42505. IndexedSourceMapConsumer.prototype.originalPositionFor =
  42506. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  42507. var needle = {
  42508. generatedLine: util.getArg(aArgs, 'line'),
  42509. generatedColumn: util.getArg(aArgs, 'column')
  42510. };
  42511. // Find the section containing the generated position we're trying to map
  42512. // to an original position.
  42513. var sectionIndex = binarySearch.search(needle, this._sections,
  42514. function(needle, section) {
  42515. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  42516. if (cmp) {
  42517. return cmp;
  42518. }
  42519. return (needle.generatedColumn -
  42520. section.generatedOffset.generatedColumn);
  42521. });
  42522. var section = this._sections[sectionIndex];
  42523. if (!section) {
  42524. return {
  42525. source: null,
  42526. line: null,
  42527. column: null,
  42528. name: null
  42529. };
  42530. }
  42531. return section.consumer.originalPositionFor({
  42532. line: needle.generatedLine -
  42533. (section.generatedOffset.generatedLine - 1),
  42534. column: needle.generatedColumn -
  42535. (section.generatedOffset.generatedLine === needle.generatedLine
  42536. ? section.generatedOffset.generatedColumn - 1
  42537. : 0),
  42538. bias: aArgs.bias
  42539. });
  42540. };
  42541. /**
  42542. * Return true if we have the source content for every source in the source
  42543. * map, false otherwise.
  42544. */
  42545. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  42546. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  42547. return this._sections.every(function (s) {
  42548. return s.consumer.hasContentsOfAllSources();
  42549. });
  42550. };
  42551. /**
  42552. * Returns the original source content. The only argument is the url of the
  42553. * original source file. Returns null if no original source content is
  42554. * available.
  42555. */
  42556. IndexedSourceMapConsumer.prototype.sourceContentFor =
  42557. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  42558. for (var i = 0; i < this._sections.length; i++) {
  42559. var section = this._sections[i];
  42560. var content = section.consumer.sourceContentFor(aSource, true);
  42561. if (content) {
  42562. return content;
  42563. }
  42564. }
  42565. if (nullOnMissing) {
  42566. return null;
  42567. }
  42568. else {
  42569. throw new Error('"' + aSource + '" is not in the SourceMap.');
  42570. }
  42571. };
  42572. /**
  42573. * Returns the generated line and column information for the original source,
  42574. * line, and column positions provided. The only argument is an object with
  42575. * the following properties:
  42576. *
  42577. * - source: The filename of the original source.
  42578. * - line: The line number in the original source. The line number
  42579. * is 1-based.
  42580. * - column: The column number in the original source. The column
  42581. * number is 0-based.
  42582. *
  42583. * and an object is returned with the following properties:
  42584. *
  42585. * - line: The line number in the generated source, or null. The
  42586. * line number is 1-based.
  42587. * - column: The column number in the generated source, or null.
  42588. * The column number is 0-based.
  42589. */
  42590. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  42591. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  42592. for (var i = 0; i < this._sections.length; i++) {
  42593. var section = this._sections[i];
  42594. // Only consider this section if the requested source is in the list of
  42595. // sources of the consumer.
  42596. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  42597. continue;
  42598. }
  42599. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  42600. if (generatedPosition) {
  42601. var ret = {
  42602. line: generatedPosition.line +
  42603. (section.generatedOffset.generatedLine - 1),
  42604. column: generatedPosition.column +
  42605. (section.generatedOffset.generatedLine === generatedPosition.line
  42606. ? section.generatedOffset.generatedColumn - 1
  42607. : 0)
  42608. };
  42609. return ret;
  42610. }
  42611. }
  42612. return {
  42613. line: null,
  42614. column: null
  42615. };
  42616. };
  42617. /**
  42618. * Parse the mappings in a string in to a data structure which we can easily
  42619. * query (the ordered arrays in the `this.__generatedMappings` and
  42620. * `this.__originalMappings` properties).
  42621. */
  42622. IndexedSourceMapConsumer.prototype._parseMappings =
  42623. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  42624. this.__generatedMappings = [];
  42625. this.__originalMappings = [];
  42626. for (var i = 0; i < this._sections.length; i++) {
  42627. var section = this._sections[i];
  42628. var sectionMappings = section.consumer._generatedMappings;
  42629. for (var j = 0; j < sectionMappings.length; j++) {
  42630. var mapping = sectionMappings[j];
  42631. var source = section.consumer._sources.at(mapping.source);
  42632. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  42633. this._sources.add(source);
  42634. source = this._sources.indexOf(source);
  42635. var name = null;
  42636. if (mapping.name) {
  42637. name = section.consumer._names.at(mapping.name);
  42638. this._names.add(name);
  42639. name = this._names.indexOf(name);
  42640. }
  42641. // The mappings coming from the consumer for the section have
  42642. // generated positions relative to the start of the section, so we
  42643. // need to offset them to be relative to the start of the concatenated
  42644. // generated file.
  42645. var adjustedMapping = {
  42646. source: source,
  42647. generatedLine: mapping.generatedLine +
  42648. (section.generatedOffset.generatedLine - 1),
  42649. generatedColumn: mapping.generatedColumn +
  42650. (section.generatedOffset.generatedLine === mapping.generatedLine
  42651. ? section.generatedOffset.generatedColumn - 1
  42652. : 0),
  42653. originalLine: mapping.originalLine,
  42654. originalColumn: mapping.originalColumn,
  42655. name: name
  42656. };
  42657. this.__generatedMappings.push(adjustedMapping);
  42658. if (typeof adjustedMapping.originalLine === 'number') {
  42659. this.__originalMappings.push(adjustedMapping);
  42660. }
  42661. }
  42662. }
  42663. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  42664. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  42665. };
  42666. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  42667. return sourceMapConsumer;
  42668. }
  42669. var sourceNode = {};
  42670. /* -*- Mode: js; js-indent-level: 2; -*- */
  42671. var hasRequiredSourceNode;
  42672. function requireSourceNode () {
  42673. if (hasRequiredSourceNode) return sourceNode;
  42674. hasRequiredSourceNode = 1;
  42675. /*
  42676. * Copyright 2011 Mozilla Foundation and contributors
  42677. * Licensed under the New BSD license. See LICENSE or:
  42678. * http://opensource.org/licenses/BSD-3-Clause
  42679. */
  42680. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator().SourceMapGenerator;
  42681. var util = /*@__PURE__*/ requireUtil();
  42682. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  42683. // operating systems these days (capturing the result).
  42684. var REGEX_NEWLINE = /(\r?\n)/;
  42685. // Newline character code for charCodeAt() comparisons
  42686. var NEWLINE_CODE = 10;
  42687. // Private symbol for identifying `SourceNode`s when multiple versions of
  42688. // the source-map library are loaded. This MUST NOT CHANGE across
  42689. // versions!
  42690. var isSourceNode = "$$$isSourceNode$$$";
  42691. /**
  42692. * SourceNodes provide a way to abstract over interpolating/concatenating
  42693. * snippets of generated JavaScript source code while maintaining the line and
  42694. * column information associated with the original source code.
  42695. *
  42696. * @param aLine The original line number.
  42697. * @param aColumn The original column number.
  42698. * @param aSource The original source's filename.
  42699. * @param aChunks Optional. An array of strings which are snippets of
  42700. * generated JS, or other SourceNodes.
  42701. * @param aName The original identifier.
  42702. */
  42703. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  42704. this.children = [];
  42705. this.sourceContents = {};
  42706. this.line = aLine == null ? null : aLine;
  42707. this.column = aColumn == null ? null : aColumn;
  42708. this.source = aSource == null ? null : aSource;
  42709. this.name = aName == null ? null : aName;
  42710. this[isSourceNode] = true;
  42711. if (aChunks != null) this.add(aChunks);
  42712. }
  42713. /**
  42714. * Creates a SourceNode from generated code and a SourceMapConsumer.
  42715. *
  42716. * @param aGeneratedCode The generated code
  42717. * @param aSourceMapConsumer The SourceMap for the generated code
  42718. * @param aRelativePath Optional. The path that relative sources in the
  42719. * SourceMapConsumer should be relative to.
  42720. */
  42721. SourceNode.fromStringWithSourceMap =
  42722. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  42723. // The SourceNode we want to fill with the generated code
  42724. // and the SourceMap
  42725. var node = new SourceNode();
  42726. // All even indices of this array are one line of the generated code,
  42727. // while all odd indices are the newlines between two adjacent lines
  42728. // (since `REGEX_NEWLINE` captures its match).
  42729. // Processed fragments are accessed by calling `shiftNextLine`.
  42730. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  42731. var remainingLinesIndex = 0;
  42732. var shiftNextLine = function() {
  42733. var lineContents = getNextLine();
  42734. // The last line of a file might not have a newline.
  42735. var newLine = getNextLine() || "";
  42736. return lineContents + newLine;
  42737. function getNextLine() {
  42738. return remainingLinesIndex < remainingLines.length ?
  42739. remainingLines[remainingLinesIndex++] : undefined;
  42740. }
  42741. };
  42742. // We need to remember the position of "remainingLines"
  42743. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  42744. // The generate SourceNodes we need a code range.
  42745. // To extract it current and last mapping is used.
  42746. // Here we store the last mapping.
  42747. var lastMapping = null;
  42748. aSourceMapConsumer.eachMapping(function (mapping) {
  42749. if (lastMapping !== null) {
  42750. // We add the code from "lastMapping" to "mapping":
  42751. // First check if there is a new line in between.
  42752. if (lastGeneratedLine < mapping.generatedLine) {
  42753. // Associate first line with "lastMapping"
  42754. addMappingWithCode(lastMapping, shiftNextLine());
  42755. lastGeneratedLine++;
  42756. lastGeneratedColumn = 0;
  42757. // The remaining code is added without mapping
  42758. } else {
  42759. // There is no new line in between.
  42760. // Associate the code between "lastGeneratedColumn" and
  42761. // "mapping.generatedColumn" with "lastMapping"
  42762. var nextLine = remainingLines[remainingLinesIndex] || '';
  42763. var code = nextLine.substr(0, mapping.generatedColumn -
  42764. lastGeneratedColumn);
  42765. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  42766. lastGeneratedColumn);
  42767. lastGeneratedColumn = mapping.generatedColumn;
  42768. addMappingWithCode(lastMapping, code);
  42769. // No more remaining code, continue
  42770. lastMapping = mapping;
  42771. return;
  42772. }
  42773. }
  42774. // We add the generated code until the first mapping
  42775. // to the SourceNode without any mapping.
  42776. // Each line is added as separate string.
  42777. while (lastGeneratedLine < mapping.generatedLine) {
  42778. node.add(shiftNextLine());
  42779. lastGeneratedLine++;
  42780. }
  42781. if (lastGeneratedColumn < mapping.generatedColumn) {
  42782. var nextLine = remainingLines[remainingLinesIndex] || '';
  42783. node.add(nextLine.substr(0, mapping.generatedColumn));
  42784. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  42785. lastGeneratedColumn = mapping.generatedColumn;
  42786. }
  42787. lastMapping = mapping;
  42788. }, this);
  42789. // We have processed all mappings.
  42790. if (remainingLinesIndex < remainingLines.length) {
  42791. if (lastMapping) {
  42792. // Associate the remaining code in the current line with "lastMapping"
  42793. addMappingWithCode(lastMapping, shiftNextLine());
  42794. }
  42795. // and add the remaining lines without any mapping
  42796. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  42797. }
  42798. // Copy sourcesContent into SourceNode
  42799. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  42800. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  42801. if (content != null) {
  42802. if (aRelativePath != null) {
  42803. sourceFile = util.join(aRelativePath, sourceFile);
  42804. }
  42805. node.setSourceContent(sourceFile, content);
  42806. }
  42807. });
  42808. return node;
  42809. function addMappingWithCode(mapping, code) {
  42810. if (mapping === null || mapping.source === undefined) {
  42811. node.add(code);
  42812. } else {
  42813. var source = aRelativePath
  42814. ? util.join(aRelativePath, mapping.source)
  42815. : mapping.source;
  42816. node.add(new SourceNode(mapping.originalLine,
  42817. mapping.originalColumn,
  42818. source,
  42819. code,
  42820. mapping.name));
  42821. }
  42822. }
  42823. };
  42824. /**
  42825. * Add a chunk of generated JS to this source node.
  42826. *
  42827. * @param aChunk A string snippet of generated JS code, another instance of
  42828. * SourceNode, or an array where each member is one of those things.
  42829. */
  42830. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  42831. if (Array.isArray(aChunk)) {
  42832. aChunk.forEach(function (chunk) {
  42833. this.add(chunk);
  42834. }, this);
  42835. }
  42836. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  42837. if (aChunk) {
  42838. this.children.push(aChunk);
  42839. }
  42840. }
  42841. else {
  42842. throw new TypeError(
  42843. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  42844. );
  42845. }
  42846. return this;
  42847. };
  42848. /**
  42849. * Add a chunk of generated JS to the beginning of this source node.
  42850. *
  42851. * @param aChunk A string snippet of generated JS code, another instance of
  42852. * SourceNode, or an array where each member is one of those things.
  42853. */
  42854. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  42855. if (Array.isArray(aChunk)) {
  42856. for (var i = aChunk.length-1; i >= 0; i--) {
  42857. this.prepend(aChunk[i]);
  42858. }
  42859. }
  42860. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  42861. this.children.unshift(aChunk);
  42862. }
  42863. else {
  42864. throw new TypeError(
  42865. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  42866. );
  42867. }
  42868. return this;
  42869. };
  42870. /**
  42871. * Walk over the tree of JS snippets in this node and its children. The
  42872. * walking function is called once for each snippet of JS and is passed that
  42873. * snippet and the its original associated source's line/column location.
  42874. *
  42875. * @param aFn The traversal function.
  42876. */
  42877. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  42878. var chunk;
  42879. for (var i = 0, len = this.children.length; i < len; i++) {
  42880. chunk = this.children[i];
  42881. if (chunk[isSourceNode]) {
  42882. chunk.walk(aFn);
  42883. }
  42884. else {
  42885. if (chunk !== '') {
  42886. aFn(chunk, { source: this.source,
  42887. line: this.line,
  42888. column: this.column,
  42889. name: this.name });
  42890. }
  42891. }
  42892. }
  42893. };
  42894. /**
  42895. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  42896. * each of `this.children`.
  42897. *
  42898. * @param aSep The separator.
  42899. */
  42900. SourceNode.prototype.join = function SourceNode_join(aSep) {
  42901. var newChildren;
  42902. var i;
  42903. var len = this.children.length;
  42904. if (len > 0) {
  42905. newChildren = [];
  42906. for (i = 0; i < len-1; i++) {
  42907. newChildren.push(this.children[i]);
  42908. newChildren.push(aSep);
  42909. }
  42910. newChildren.push(this.children[i]);
  42911. this.children = newChildren;
  42912. }
  42913. return this;
  42914. };
  42915. /**
  42916. * Call String.prototype.replace on the very right-most source snippet. Useful
  42917. * for trimming whitespace from the end of a source node, etc.
  42918. *
  42919. * @param aPattern The pattern to replace.
  42920. * @param aReplacement The thing to replace the pattern with.
  42921. */
  42922. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  42923. var lastChild = this.children[this.children.length - 1];
  42924. if (lastChild[isSourceNode]) {
  42925. lastChild.replaceRight(aPattern, aReplacement);
  42926. }
  42927. else if (typeof lastChild === 'string') {
  42928. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  42929. }
  42930. else {
  42931. this.children.push(''.replace(aPattern, aReplacement));
  42932. }
  42933. return this;
  42934. };
  42935. /**
  42936. * Set the source content for a source file. This will be added to the SourceMapGenerator
  42937. * in the sourcesContent field.
  42938. *
  42939. * @param aSourceFile The filename of the source file
  42940. * @param aSourceContent The content of the source file
  42941. */
  42942. SourceNode.prototype.setSourceContent =
  42943. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  42944. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  42945. };
  42946. /**
  42947. * Walk over the tree of SourceNodes. The walking function is called for each
  42948. * source file content and is passed the filename and source content.
  42949. *
  42950. * @param aFn The traversal function.
  42951. */
  42952. SourceNode.prototype.walkSourceContents =
  42953. function SourceNode_walkSourceContents(aFn) {
  42954. for (var i = 0, len = this.children.length; i < len; i++) {
  42955. if (this.children[i][isSourceNode]) {
  42956. this.children[i].walkSourceContents(aFn);
  42957. }
  42958. }
  42959. var sources = Object.keys(this.sourceContents);
  42960. for (var i = 0, len = sources.length; i < len; i++) {
  42961. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  42962. }
  42963. };
  42964. /**
  42965. * Return the string representation of this source node. Walks over the tree
  42966. * and concatenates all the various snippets together to one string.
  42967. */
  42968. SourceNode.prototype.toString = function SourceNode_toString() {
  42969. var str = "";
  42970. this.walk(function (chunk) {
  42971. str += chunk;
  42972. });
  42973. return str;
  42974. };
  42975. /**
  42976. * Returns the string representation of this source node along with a source
  42977. * map.
  42978. */
  42979. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  42980. var generated = {
  42981. code: "",
  42982. line: 1,
  42983. column: 0
  42984. };
  42985. var map = new SourceMapGenerator(aArgs);
  42986. var sourceMappingActive = false;
  42987. var lastOriginalSource = null;
  42988. var lastOriginalLine = null;
  42989. var lastOriginalColumn = null;
  42990. var lastOriginalName = null;
  42991. this.walk(function (chunk, original) {
  42992. generated.code += chunk;
  42993. if (original.source !== null
  42994. && original.line !== null
  42995. && original.column !== null) {
  42996. if(lastOriginalSource !== original.source
  42997. || lastOriginalLine !== original.line
  42998. || lastOriginalColumn !== original.column
  42999. || lastOriginalName !== original.name) {
  43000. map.addMapping({
  43001. source: original.source,
  43002. original: {
  43003. line: original.line,
  43004. column: original.column
  43005. },
  43006. generated: {
  43007. line: generated.line,
  43008. column: generated.column
  43009. },
  43010. name: original.name
  43011. });
  43012. }
  43013. lastOriginalSource = original.source;
  43014. lastOriginalLine = original.line;
  43015. lastOriginalColumn = original.column;
  43016. lastOriginalName = original.name;
  43017. sourceMappingActive = true;
  43018. } else if (sourceMappingActive) {
  43019. map.addMapping({
  43020. generated: {
  43021. line: generated.line,
  43022. column: generated.column
  43023. }
  43024. });
  43025. lastOriginalSource = null;
  43026. sourceMappingActive = false;
  43027. }
  43028. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  43029. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  43030. generated.line++;
  43031. generated.column = 0;
  43032. // Mappings end at eol
  43033. if (idx + 1 === length) {
  43034. lastOriginalSource = null;
  43035. sourceMappingActive = false;
  43036. } else if (sourceMappingActive) {
  43037. map.addMapping({
  43038. source: original.source,
  43039. original: {
  43040. line: original.line,
  43041. column: original.column
  43042. },
  43043. generated: {
  43044. line: generated.line,
  43045. column: generated.column
  43046. },
  43047. name: original.name
  43048. });
  43049. }
  43050. } else {
  43051. generated.column++;
  43052. }
  43053. }
  43054. });
  43055. this.walkSourceContents(function (sourceFile, sourceContent) {
  43056. map.setSourceContent(sourceFile, sourceContent);
  43057. });
  43058. return { code: generated.code, map: map };
  43059. };
  43060. sourceNode.SourceNode = SourceNode;
  43061. return sourceNode;
  43062. }
  43063. /*
  43064. * Copyright 2009-2011 Mozilla Foundation and contributors
  43065. * Licensed under the New BSD license. See LICENSE.txt or:
  43066. * http://opensource.org/licenses/BSD-3-Clause
  43067. */
  43068. var hasRequiredSourceMap;
  43069. function requireSourceMap () {
  43070. if (hasRequiredSourceMap) return sourceMap;
  43071. hasRequiredSourceMap = 1;
  43072. sourceMap.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator().SourceMapGenerator;
  43073. sourceMap.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer().SourceMapConsumer;
  43074. sourceMap.SourceNode = /*@__PURE__*/ requireSourceNode().SourceNode;
  43075. return sourceMap;
  43076. }
  43077. var mergeSourceMap;
  43078. var hasRequiredMergeSourceMap;
  43079. function requireMergeSourceMap () {
  43080. if (hasRequiredMergeSourceMap) return mergeSourceMap;
  43081. hasRequiredMergeSourceMap = 1;
  43082. var sourceMap = /*@__PURE__*/ requireSourceMap();
  43083. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  43084. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  43085. mergeSourceMap = merge;
  43086. /**
  43087. * Merge old source map and new source map and return merged.
  43088. * If old or new source map value is falsy, return another one as it is.
  43089. *
  43090. * @param {object|string} [oldMap] old source map object
  43091. * @param {object|string} [newmap] new source map object
  43092. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  43093. */
  43094. function merge(oldMap, newMap) {
  43095. if (!oldMap) return newMap
  43096. if (!newMap) return oldMap
  43097. var oldMapConsumer = new SourceMapConsumer(oldMap);
  43098. var newMapConsumer = new SourceMapConsumer(newMap);
  43099. var mergedMapGenerator = new SourceMapGenerator();
  43100. // iterate on new map and overwrite original position of new map with one of old map
  43101. newMapConsumer.eachMapping(function(m) {
  43102. // pass when `originalLine` is null.
  43103. // It occurs in case that the node does not have origin in original code.
  43104. if (m.originalLine == null) return
  43105. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  43106. line: m.originalLine,
  43107. column: m.originalColumn
  43108. });
  43109. if (origPosInOldMap.source == null) return
  43110. mergedMapGenerator.addMapping({
  43111. original: {
  43112. line: origPosInOldMap.line,
  43113. column: origPosInOldMap.column
  43114. },
  43115. generated: {
  43116. line: m.generatedLine,
  43117. column: m.generatedColumn
  43118. },
  43119. source: origPosInOldMap.source,
  43120. name: origPosInOldMap.name
  43121. });
  43122. });
  43123. var consumers = [oldMapConsumer, newMapConsumer];
  43124. consumers.forEach(function(consumer) {
  43125. consumer.sources.forEach(function(sourceFile) {
  43126. mergedMapGenerator._sources.add(sourceFile);
  43127. var sourceContent = consumer.sourceContentFor(sourceFile);
  43128. if (sourceContent != null) {
  43129. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  43130. }
  43131. });
  43132. });
  43133. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  43134. mergedMapGenerator._file = oldMap.file;
  43135. return JSON.parse(mergedMapGenerator.toString())
  43136. }
  43137. return mergeSourceMap;
  43138. }
  43139. var mergeSourceMapExports = /*@__PURE__*/ requireMergeSourceMap();
  43140. var merge = /*@__PURE__*/getDefaultExportFromCjs(mergeSourceMapExports);
  43141. var __defProp$5 = Object.defineProperty;
  43142. var __defProps$4 = Object.defineProperties;
  43143. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  43144. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  43145. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  43146. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  43147. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  43148. var __spreadValues$5 = (a, b) => {
  43149. for (var prop in b || (b = {}))
  43150. if (__hasOwnProp$5.call(b, prop))
  43151. __defNormalProp$5(a, prop, b[prop]);
  43152. if (__getOwnPropSymbols$5)
  43153. for (var prop of __getOwnPropSymbols$5(b)) {
  43154. if (__propIsEnum$5.call(b, prop))
  43155. __defNormalProp$5(a, prop, b[prop]);
  43156. }
  43157. return a;
  43158. };
  43159. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  43160. const scss = (source, map, options, load = require) => {
  43161. const nodeSass = load("sass");
  43162. const { compileString, renderSync } = nodeSass;
  43163. const data = getSource(source, options.filename, options.additionalData);
  43164. let css;
  43165. let dependencies;
  43166. let sourceMap;
  43167. try {
  43168. if (compileString) {
  43169. const { pathToFileURL, fileURLToPath } = load("url");
  43170. const result = compileString(data, __spreadProps$4(__spreadValues$5({}, options), {
  43171. url: pathToFileURL(options.filename),
  43172. sourceMap: !!map
  43173. }));
  43174. css = result.css;
  43175. dependencies = result.loadedUrls.map((url) => fileURLToPath(url));
  43176. sourceMap = map ? result.sourceMap : void 0;
  43177. } else {
  43178. const result = renderSync(__spreadProps$4(__spreadValues$5({}, options), {
  43179. data,
  43180. file: options.filename,
  43181. outFile: options.filename,
  43182. sourceMap: !!map
  43183. }));
  43184. css = result.css.toString();
  43185. dependencies = result.stats.includedFiles;
  43186. sourceMap = map ? JSON.parse(result.map.toString()) : void 0;
  43187. }
  43188. if (map) {
  43189. return {
  43190. code: css,
  43191. errors: [],
  43192. dependencies,
  43193. map: merge(map, sourceMap)
  43194. };
  43195. }
  43196. return { code: css, errors: [], dependencies };
  43197. } catch (e) {
  43198. return { code: "", errors: [e], dependencies: [] };
  43199. }
  43200. };
  43201. const sass = (source, map, options, load) => scss(
  43202. source,
  43203. map,
  43204. __spreadProps$4(__spreadValues$5({}, options), {
  43205. indentedSyntax: true
  43206. }),
  43207. load
  43208. );
  43209. const less = (source, map, options, load = require) => {
  43210. const nodeLess = load("less");
  43211. let result;
  43212. let error = null;
  43213. nodeLess.render(
  43214. getSource(source, options.filename, options.additionalData),
  43215. __spreadProps$4(__spreadValues$5({}, options), { syncImport: true }),
  43216. (err, output) => {
  43217. error = err;
  43218. result = output;
  43219. }
  43220. );
  43221. if (error) return { code: "", errors: [error], dependencies: [] };
  43222. const dependencies = result.imports;
  43223. if (map) {
  43224. return {
  43225. code: result.css.toString(),
  43226. map: merge(map, result.map),
  43227. errors: [],
  43228. dependencies
  43229. };
  43230. }
  43231. return {
  43232. code: result.css.toString(),
  43233. errors: [],
  43234. dependencies
  43235. };
  43236. };
  43237. const styl = (source, map, options, load = require) => {
  43238. const nodeStylus = load("stylus");
  43239. try {
  43240. const ref = nodeStylus(source, options);
  43241. if (map) ref.set("sourcemap", { inline: false, comment: false });
  43242. const result = ref.render();
  43243. const dependencies = ref.deps();
  43244. if (map) {
  43245. return {
  43246. code: result,
  43247. map: merge(map, ref.sourcemap),
  43248. errors: [],
  43249. dependencies
  43250. };
  43251. }
  43252. return { code: result, errors: [], dependencies };
  43253. } catch (e) {
  43254. return { code: "", errors: [e], dependencies: [] };
  43255. }
  43256. };
  43257. function getSource(source, filename, additionalData) {
  43258. if (!additionalData) return source;
  43259. if (isFunction$1(additionalData)) {
  43260. return additionalData(source, filename);
  43261. }
  43262. return additionalData + source;
  43263. }
  43264. const processors = {
  43265. less,
  43266. sass,
  43267. scss,
  43268. styl,
  43269. stylus: styl
  43270. };
  43271. var __defProp$4 = Object.defineProperty;
  43272. var __defProps$3 = Object.defineProperties;
  43273. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  43274. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  43275. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  43276. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  43277. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  43278. var __spreadValues$4 = (a, b) => {
  43279. for (var prop in b || (b = {}))
  43280. if (__hasOwnProp$4.call(b, prop))
  43281. __defNormalProp$4(a, prop, b[prop]);
  43282. if (__getOwnPropSymbols$4)
  43283. for (var prop of __getOwnPropSymbols$4(b)) {
  43284. if (__propIsEnum$4.call(b, prop))
  43285. __defNormalProp$4(a, prop, b[prop]);
  43286. }
  43287. return a;
  43288. };
  43289. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  43290. function compileStyle(options) {
  43291. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  43292. isAsync: false
  43293. }));
  43294. }
  43295. function compileStyleAsync(options) {
  43296. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  43297. isAsync: true
  43298. }));
  43299. }
  43300. function doCompileStyle(options) {
  43301. const {
  43302. filename,
  43303. id,
  43304. scoped = false,
  43305. trim = true,
  43306. isProd = false,
  43307. modules = false,
  43308. modulesOptions = {},
  43309. preprocessLang,
  43310. postcssOptions,
  43311. postcssPlugins
  43312. } = options;
  43313. const preprocessor = preprocessLang && processors[preprocessLang];
  43314. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  43315. const map = preProcessedSource ? preProcessedSource.map : options.inMap || options.map;
  43316. const source = preProcessedSource ? preProcessedSource.code : options.source;
  43317. const shortId = id.replace(/^data-v-/, "");
  43318. const longId = `data-v-${shortId}`;
  43319. const plugins = (postcssPlugins || []).slice();
  43320. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  43321. if (trim) {
  43322. plugins.push(trimPlugin());
  43323. }
  43324. if (scoped) {
  43325. plugins.push(scopedPlugin(longId));
  43326. }
  43327. let cssModules;
  43328. if (modules) {
  43329. {
  43330. throw new Error(
  43331. "[@vue/compiler-sfc] `modules` option is not supported in the browser build."
  43332. );
  43333. }
  43334. }
  43335. const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
  43336. to: filename,
  43337. from: filename
  43338. });
  43339. if (map) {
  43340. postCSSOptions.map = {
  43341. inline: false,
  43342. annotation: false,
  43343. prev: map
  43344. };
  43345. }
  43346. let result;
  43347. let code;
  43348. let outMap;
  43349. const dependencies = new Set(
  43350. preProcessedSource ? preProcessedSource.dependencies : []
  43351. );
  43352. dependencies.delete(filename);
  43353. const errors = [];
  43354. if (preProcessedSource && preProcessedSource.errors.length) {
  43355. errors.push(...preProcessedSource.errors);
  43356. }
  43357. const recordPlainCssDependencies = (messages) => {
  43358. messages.forEach((msg) => {
  43359. if (msg.type === "dependency") {
  43360. dependencies.add(msg.file);
  43361. }
  43362. });
  43363. return dependencies;
  43364. };
  43365. try {
  43366. result = postcss(plugins).process(source, postCSSOptions);
  43367. if (options.isAsync) {
  43368. return result.then((result2) => ({
  43369. code: result2.css || "",
  43370. map: result2.map && result2.map.toJSON(),
  43371. errors,
  43372. modules: cssModules,
  43373. rawResult: result2,
  43374. dependencies: recordPlainCssDependencies(result2.messages)
  43375. })).catch((error) => ({
  43376. code: "",
  43377. map: void 0,
  43378. errors: [...errors, error],
  43379. rawResult: void 0,
  43380. dependencies
  43381. }));
  43382. }
  43383. recordPlainCssDependencies(result.messages);
  43384. code = result.css;
  43385. outMap = result.map;
  43386. } catch (e) {
  43387. errors.push(e);
  43388. }
  43389. return {
  43390. code: code || ``,
  43391. map: outMap && outMap.toJSON(),
  43392. errors,
  43393. rawResult: result,
  43394. dependencies
  43395. };
  43396. }
  43397. function preprocess(options, preprocessor) {
  43398. if (!options.preprocessCustomRequire) {
  43399. throw new Error(
  43400. `[@vue/compiler-sfc] Style preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor.`
  43401. );
  43402. }
  43403. return preprocessor(
  43404. options.source,
  43405. options.inMap || options.map,
  43406. __spreadValues$4({
  43407. filename: options.filename
  43408. }, options.preprocessOptions),
  43409. options.preprocessCustomRequire
  43410. );
  43411. }
  43412. const UNKNOWN_TYPE = "Unknown";
  43413. function resolveObjectKey(node, computed) {
  43414. switch (node.type) {
  43415. case "StringLiteral":
  43416. case "NumericLiteral":
  43417. return String(node.value);
  43418. case "Identifier":
  43419. if (!computed) return node.name;
  43420. }
  43421. return void 0;
  43422. }
  43423. function concatStrings(strs) {
  43424. return strs.filter((s) => !!s).join(", ");
  43425. }
  43426. function isLiteralNode(node) {
  43427. return node.type.endsWith("Literal");
  43428. }
  43429. function isCallOf(node, test) {
  43430. return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
  43431. }
  43432. function toRuntimeTypeString(types) {
  43433. return types.length > 1 ? `[${types.join(", ")}]` : types[0];
  43434. }
  43435. function getImportedName(specifier) {
  43436. if (specifier.type === "ImportSpecifier")
  43437. return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
  43438. else if (specifier.type === "ImportNamespaceSpecifier") return "*";
  43439. return "default";
  43440. }
  43441. function getId(node) {
  43442. return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
  43443. }
  43444. const normalize = (path.posix || path).normalize;
  43445. const windowsSlashRE = /\\/g;
  43446. function normalizePath(p) {
  43447. return normalize(p.replace(windowsSlashRE, "/"));
  43448. }
  43449. const joinPaths = (path.posix || path).join;
  43450. const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
  43451. function getEscapedPropName(key) {
  43452. return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
  43453. }
  43454. const isJS = (...langs) => langs.some((lang) => lang === "js" || lang === "jsx");
  43455. const isTS = (...langs) => langs.some((lang) => lang === "ts" || lang === "tsx");
  43456. function analyzeScriptBindings(ast) {
  43457. for (const node of ast) {
  43458. if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
  43459. return analyzeBindingsFromOptions(node.declaration);
  43460. }
  43461. }
  43462. return {};
  43463. }
  43464. function analyzeBindingsFromOptions(node) {
  43465. const bindings = {};
  43466. Object.defineProperty(bindings, "__isScriptSetup", {
  43467. enumerable: false,
  43468. value: false
  43469. });
  43470. for (const property of node.properties) {
  43471. if (property.type === "ObjectProperty" && !property.computed && property.key.type === "Identifier") {
  43472. if (property.key.name === "props") {
  43473. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  43474. bindings[key] = "props";
  43475. }
  43476. } else if (property.key.name === "inject") {
  43477. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  43478. bindings[key] = "options";
  43479. }
  43480. } else if (property.value.type === "ObjectExpression" && (property.key.name === "computed" || property.key.name === "methods")) {
  43481. for (const key of getObjectExpressionKeys(property.value)) {
  43482. bindings[key] = "options";
  43483. }
  43484. }
  43485. } else if (property.type === "ObjectMethod" && property.key.type === "Identifier" && (property.key.name === "setup" || property.key.name === "data")) {
  43486. for (const bodyItem of property.body.body) {
  43487. if (bodyItem.type === "ReturnStatement" && bodyItem.argument && bodyItem.argument.type === "ObjectExpression") {
  43488. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  43489. bindings[key] = property.key.name === "setup" ? "setup-maybe-ref" : "data";
  43490. }
  43491. }
  43492. }
  43493. }
  43494. }
  43495. return bindings;
  43496. }
  43497. function getObjectExpressionKeys(node) {
  43498. const keys = [];
  43499. for (const prop of node.properties) {
  43500. if (prop.type === "SpreadElement") continue;
  43501. const key = resolveObjectKey(prop.key, prop.computed);
  43502. if (key) keys.push(String(key));
  43503. }
  43504. return keys;
  43505. }
  43506. function getArrayExpressionKeys(node) {
  43507. const keys = [];
  43508. for (const element of node.elements) {
  43509. if (element && element.type === "StringLiteral") {
  43510. keys.push(element.value);
  43511. }
  43512. }
  43513. return keys;
  43514. }
  43515. function getObjectOrArrayExpressionKeys(value) {
  43516. if (value.type === "ArrayExpression") {
  43517. return getArrayExpressionKeys(value);
  43518. }
  43519. if (value.type === "ObjectExpression") {
  43520. return getObjectExpressionKeys(value);
  43521. }
  43522. return [];
  43523. }
  43524. // src/vlq.ts
  43525. var comma = ",".charCodeAt(0);
  43526. var semicolon = ";".charCodeAt(0);
  43527. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  43528. var intToChar = new Uint8Array(64);
  43529. var charToInt = new Uint8Array(128);
  43530. for (let i = 0; i < chars.length; i++) {
  43531. const c = chars.charCodeAt(i);
  43532. intToChar[i] = c;
  43533. charToInt[c] = i;
  43534. }
  43535. function encodeInteger(builder, num, relative) {
  43536. let delta = num - relative;
  43537. delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
  43538. do {
  43539. let clamped = delta & 31;
  43540. delta >>>= 5;
  43541. if (delta > 0) clamped |= 32;
  43542. builder.write(intToChar[clamped]);
  43543. } while (delta > 0);
  43544. return num;
  43545. }
  43546. // src/strings.ts
  43547. var bufLength = 1024 * 16;
  43548. var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
  43549. decode(buf) {
  43550. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  43551. return out.toString();
  43552. }
  43553. } : {
  43554. decode(buf) {
  43555. let out = "";
  43556. for (let i = 0; i < buf.length; i++) {
  43557. out += String.fromCharCode(buf[i]);
  43558. }
  43559. return out;
  43560. }
  43561. };
  43562. var StringWriter = class {
  43563. constructor() {
  43564. this.pos = 0;
  43565. this.out = "";
  43566. this.buffer = new Uint8Array(bufLength);
  43567. }
  43568. write(v) {
  43569. const { buffer } = this;
  43570. buffer[this.pos++] = v;
  43571. if (this.pos === bufLength) {
  43572. this.out += td.decode(buffer);
  43573. this.pos = 0;
  43574. }
  43575. }
  43576. flush() {
  43577. const { buffer, out, pos } = this;
  43578. return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
  43579. }
  43580. };
  43581. function encode(decoded) {
  43582. const writer = new StringWriter();
  43583. let sourcesIndex = 0;
  43584. let sourceLine = 0;
  43585. let sourceColumn = 0;
  43586. let namesIndex = 0;
  43587. for (let i = 0; i < decoded.length; i++) {
  43588. const line = decoded[i];
  43589. if (i > 0) writer.write(semicolon);
  43590. if (line.length === 0) continue;
  43591. let genColumn = 0;
  43592. for (let j = 0; j < line.length; j++) {
  43593. const segment = line[j];
  43594. if (j > 0) writer.write(comma);
  43595. genColumn = encodeInteger(writer, segment[0], genColumn);
  43596. if (segment.length === 1) continue;
  43597. sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
  43598. sourceLine = encodeInteger(writer, segment[2], sourceLine);
  43599. sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
  43600. if (segment.length === 4) continue;
  43601. namesIndex = encodeInteger(writer, segment[4], namesIndex);
  43602. }
  43603. }
  43604. return writer.flush();
  43605. }
  43606. class BitSet {
  43607. constructor(arg) {
  43608. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  43609. }
  43610. add(n) {
  43611. this.bits[n >> 5] |= 1 << (n & 31);
  43612. }
  43613. has(n) {
  43614. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  43615. }
  43616. }
  43617. class Chunk {
  43618. constructor(start, end, content) {
  43619. this.start = start;
  43620. this.end = end;
  43621. this.original = content;
  43622. this.intro = '';
  43623. this.outro = '';
  43624. this.content = content;
  43625. this.storeName = false;
  43626. this.edited = false;
  43627. {
  43628. this.previous = null;
  43629. this.next = null;
  43630. }
  43631. }
  43632. appendLeft(content) {
  43633. this.outro += content;
  43634. }
  43635. appendRight(content) {
  43636. this.intro = this.intro + content;
  43637. }
  43638. clone() {
  43639. const chunk = new Chunk(this.start, this.end, this.original);
  43640. chunk.intro = this.intro;
  43641. chunk.outro = this.outro;
  43642. chunk.content = this.content;
  43643. chunk.storeName = this.storeName;
  43644. chunk.edited = this.edited;
  43645. return chunk;
  43646. }
  43647. contains(index) {
  43648. return this.start < index && index < this.end;
  43649. }
  43650. eachNext(fn) {
  43651. let chunk = this;
  43652. while (chunk) {
  43653. fn(chunk);
  43654. chunk = chunk.next;
  43655. }
  43656. }
  43657. eachPrevious(fn) {
  43658. let chunk = this;
  43659. while (chunk) {
  43660. fn(chunk);
  43661. chunk = chunk.previous;
  43662. }
  43663. }
  43664. edit(content, storeName, contentOnly) {
  43665. this.content = content;
  43666. if (!contentOnly) {
  43667. this.intro = '';
  43668. this.outro = '';
  43669. }
  43670. this.storeName = storeName;
  43671. this.edited = true;
  43672. return this;
  43673. }
  43674. prependLeft(content) {
  43675. this.outro = content + this.outro;
  43676. }
  43677. prependRight(content) {
  43678. this.intro = content + this.intro;
  43679. }
  43680. reset() {
  43681. this.intro = '';
  43682. this.outro = '';
  43683. if (this.edited) {
  43684. this.content = this.original;
  43685. this.storeName = false;
  43686. this.edited = false;
  43687. }
  43688. }
  43689. split(index) {
  43690. const sliceIndex = index - this.start;
  43691. const originalBefore = this.original.slice(0, sliceIndex);
  43692. const originalAfter = this.original.slice(sliceIndex);
  43693. this.original = originalBefore;
  43694. const newChunk = new Chunk(index, this.end, originalAfter);
  43695. newChunk.outro = this.outro;
  43696. this.outro = '';
  43697. this.end = index;
  43698. if (this.edited) {
  43699. // after split we should save the edit content record into the correct chunk
  43700. // to make sure sourcemap correct
  43701. // For example:
  43702. // ' test'.trim()
  43703. // split -> ' ' + 'test'
  43704. // ✔️ edit -> '' + 'test'
  43705. // ✖️ edit -> 'test' + ''
  43706. // TODO is this block necessary?...
  43707. newChunk.edit('', false);
  43708. this.content = '';
  43709. } else {
  43710. this.content = originalBefore;
  43711. }
  43712. newChunk.next = this.next;
  43713. if (newChunk.next) newChunk.next.previous = newChunk;
  43714. newChunk.previous = this;
  43715. this.next = newChunk;
  43716. return newChunk;
  43717. }
  43718. toString() {
  43719. return this.intro + this.content + this.outro;
  43720. }
  43721. trimEnd(rx) {
  43722. this.outro = this.outro.replace(rx, '');
  43723. if (this.outro.length) return true;
  43724. const trimmed = this.content.replace(rx, '');
  43725. if (trimmed.length) {
  43726. if (trimmed !== this.content) {
  43727. this.split(this.start + trimmed.length).edit('', undefined, true);
  43728. if (this.edited) {
  43729. // save the change, if it has been edited
  43730. this.edit(trimmed, this.storeName, true);
  43731. }
  43732. }
  43733. return true;
  43734. } else {
  43735. this.edit('', undefined, true);
  43736. this.intro = this.intro.replace(rx, '');
  43737. if (this.intro.length) return true;
  43738. }
  43739. }
  43740. trimStart(rx) {
  43741. this.intro = this.intro.replace(rx, '');
  43742. if (this.intro.length) return true;
  43743. const trimmed = this.content.replace(rx, '');
  43744. if (trimmed.length) {
  43745. if (trimmed !== this.content) {
  43746. const newChunk = this.split(this.end - trimmed.length);
  43747. if (this.edited) {
  43748. // save the change, if it has been edited
  43749. newChunk.edit(trimmed, this.storeName, true);
  43750. }
  43751. this.edit('', undefined, true);
  43752. }
  43753. return true;
  43754. } else {
  43755. this.edit('', undefined, true);
  43756. this.outro = this.outro.replace(rx, '');
  43757. if (this.outro.length) return true;
  43758. }
  43759. }
  43760. }
  43761. function getBtoa() {
  43762. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  43763. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  43764. } else if (typeof Buffer === 'function') {
  43765. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  43766. } else {
  43767. return () => {
  43768. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  43769. };
  43770. }
  43771. }
  43772. const btoa = /*#__PURE__*/ getBtoa();
  43773. class SourceMap {
  43774. constructor(properties) {
  43775. this.version = 3;
  43776. this.file = properties.file;
  43777. this.sources = properties.sources;
  43778. this.sourcesContent = properties.sourcesContent;
  43779. this.names = properties.names;
  43780. this.mappings = encode(properties.mappings);
  43781. if (typeof properties.x_google_ignoreList !== 'undefined') {
  43782. this.x_google_ignoreList = properties.x_google_ignoreList;
  43783. }
  43784. if (typeof properties.debugId !== 'undefined') {
  43785. this.debugId = properties.debugId;
  43786. }
  43787. }
  43788. toString() {
  43789. return JSON.stringify(this);
  43790. }
  43791. toUrl() {
  43792. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  43793. }
  43794. }
  43795. function guessIndent(code) {
  43796. const lines = code.split('\n');
  43797. const tabbed = lines.filter((line) => /^\t+/.test(line));
  43798. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  43799. if (tabbed.length === 0 && spaced.length === 0) {
  43800. return null;
  43801. }
  43802. // More lines tabbed than spaced? Assume tabs, and
  43803. // default to tabs in the case of a tie (or nothing
  43804. // to go on)
  43805. if (tabbed.length >= spaced.length) {
  43806. return '\t';
  43807. }
  43808. // Otherwise, we need to guess the multiple
  43809. const min = spaced.reduce((previous, current) => {
  43810. const numSpaces = /^ +/.exec(current)[0].length;
  43811. return Math.min(numSpaces, previous);
  43812. }, Infinity);
  43813. return new Array(min + 1).join(' ');
  43814. }
  43815. function getRelativePath(from, to) {
  43816. const fromParts = from.split(/[/\\]/);
  43817. const toParts = to.split(/[/\\]/);
  43818. fromParts.pop(); // get dirname
  43819. while (fromParts[0] === toParts[0]) {
  43820. fromParts.shift();
  43821. toParts.shift();
  43822. }
  43823. if (fromParts.length) {
  43824. let i = fromParts.length;
  43825. while (i--) fromParts[i] = '..';
  43826. }
  43827. return fromParts.concat(toParts).join('/');
  43828. }
  43829. const toString = Object.prototype.toString;
  43830. function isObject(thing) {
  43831. return toString.call(thing) === '[object Object]';
  43832. }
  43833. function getLocator(source) {
  43834. const originalLines = source.split('\n');
  43835. const lineOffsets = [];
  43836. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  43837. lineOffsets.push(pos);
  43838. pos += originalLines[i].length + 1;
  43839. }
  43840. return function locate(index) {
  43841. let i = 0;
  43842. let j = lineOffsets.length;
  43843. while (i < j) {
  43844. const m = (i + j) >> 1;
  43845. if (index < lineOffsets[m]) {
  43846. j = m;
  43847. } else {
  43848. i = m + 1;
  43849. }
  43850. }
  43851. const line = i - 1;
  43852. const column = index - lineOffsets[line];
  43853. return { line, column };
  43854. };
  43855. }
  43856. const wordRegex = /\w/;
  43857. class Mappings {
  43858. constructor(hires) {
  43859. this.hires = hires;
  43860. this.generatedCodeLine = 0;
  43861. this.generatedCodeColumn = 0;
  43862. this.raw = [];
  43863. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  43864. this.pending = null;
  43865. }
  43866. addEdit(sourceIndex, content, loc, nameIndex) {
  43867. if (content.length) {
  43868. const contentLengthMinusOne = content.length - 1;
  43869. let contentLineEnd = content.indexOf('\n', 0);
  43870. let previousContentLineEnd = -1;
  43871. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  43872. // else code afterwards would fill one line too many
  43873. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  43874. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  43875. if (nameIndex >= 0) {
  43876. segment.push(nameIndex);
  43877. }
  43878. this.rawSegments.push(segment);
  43879. this.generatedCodeLine += 1;
  43880. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  43881. this.generatedCodeColumn = 0;
  43882. previousContentLineEnd = contentLineEnd;
  43883. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  43884. }
  43885. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  43886. if (nameIndex >= 0) {
  43887. segment.push(nameIndex);
  43888. }
  43889. this.rawSegments.push(segment);
  43890. this.advance(content.slice(previousContentLineEnd + 1));
  43891. } else if (this.pending) {
  43892. this.rawSegments.push(this.pending);
  43893. this.advance(content);
  43894. }
  43895. this.pending = null;
  43896. }
  43897. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  43898. let originalCharIndex = chunk.start;
  43899. let first = true;
  43900. // when iterating each char, check if it's in a word boundary
  43901. let charInHiresBoundary = false;
  43902. while (originalCharIndex < chunk.end) {
  43903. if (original[originalCharIndex] === '\n') {
  43904. loc.line += 1;
  43905. loc.column = 0;
  43906. this.generatedCodeLine += 1;
  43907. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  43908. this.generatedCodeColumn = 0;
  43909. first = true;
  43910. charInHiresBoundary = false;
  43911. } else {
  43912. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  43913. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  43914. if (this.hires === 'boundary') {
  43915. // in hires "boundary", group segments per word boundary than per char
  43916. if (wordRegex.test(original[originalCharIndex])) {
  43917. // for first char in the boundary found, start the boundary by pushing a segment
  43918. if (!charInHiresBoundary) {
  43919. this.rawSegments.push(segment);
  43920. charInHiresBoundary = true;
  43921. }
  43922. } else {
  43923. // for non-word char, end the boundary by pushing a segment
  43924. this.rawSegments.push(segment);
  43925. charInHiresBoundary = false;
  43926. }
  43927. } else {
  43928. this.rawSegments.push(segment);
  43929. }
  43930. }
  43931. loc.column += 1;
  43932. this.generatedCodeColumn += 1;
  43933. first = false;
  43934. }
  43935. originalCharIndex += 1;
  43936. }
  43937. this.pending = null;
  43938. }
  43939. advance(str) {
  43940. if (!str) return;
  43941. const lines = str.split('\n');
  43942. if (lines.length > 1) {
  43943. for (let i = 0; i < lines.length - 1; i++) {
  43944. this.generatedCodeLine++;
  43945. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  43946. }
  43947. this.generatedCodeColumn = 0;
  43948. }
  43949. this.generatedCodeColumn += lines[lines.length - 1].length;
  43950. }
  43951. }
  43952. const n = '\n';
  43953. const warned = {
  43954. insertLeft: false,
  43955. insertRight: false,
  43956. storeName: false,
  43957. };
  43958. class MagicString {
  43959. constructor(string, options = {}) {
  43960. const chunk = new Chunk(0, string.length, string);
  43961. Object.defineProperties(this, {
  43962. original: { writable: true, value: string },
  43963. outro: { writable: true, value: '' },
  43964. intro: { writable: true, value: '' },
  43965. firstChunk: { writable: true, value: chunk },
  43966. lastChunk: { writable: true, value: chunk },
  43967. lastSearchedChunk: { writable: true, value: chunk },
  43968. byStart: { writable: true, value: {} },
  43969. byEnd: { writable: true, value: {} },
  43970. filename: { writable: true, value: options.filename },
  43971. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  43972. sourcemapLocations: { writable: true, value: new BitSet() },
  43973. storedNames: { writable: true, value: {} },
  43974. indentStr: { writable: true, value: undefined },
  43975. ignoreList: { writable: true, value: options.ignoreList },
  43976. offset: { writable: true, value: options.offset || 0 },
  43977. });
  43978. this.byStart[0] = chunk;
  43979. this.byEnd[string.length] = chunk;
  43980. }
  43981. addSourcemapLocation(char) {
  43982. this.sourcemapLocations.add(char);
  43983. }
  43984. append(content) {
  43985. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  43986. this.outro += content;
  43987. return this;
  43988. }
  43989. appendLeft(index, content) {
  43990. index = index + this.offset;
  43991. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  43992. this._split(index);
  43993. const chunk = this.byEnd[index];
  43994. if (chunk) {
  43995. chunk.appendLeft(content);
  43996. } else {
  43997. this.intro += content;
  43998. }
  43999. return this;
  44000. }
  44001. appendRight(index, content) {
  44002. index = index + this.offset;
  44003. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  44004. this._split(index);
  44005. const chunk = this.byStart[index];
  44006. if (chunk) {
  44007. chunk.appendRight(content);
  44008. } else {
  44009. this.outro += content;
  44010. }
  44011. return this;
  44012. }
  44013. clone() {
  44014. const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
  44015. let originalChunk = this.firstChunk;
  44016. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  44017. while (originalChunk) {
  44018. cloned.byStart[clonedChunk.start] = clonedChunk;
  44019. cloned.byEnd[clonedChunk.end] = clonedChunk;
  44020. const nextOriginalChunk = originalChunk.next;
  44021. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  44022. if (nextClonedChunk) {
  44023. clonedChunk.next = nextClonedChunk;
  44024. nextClonedChunk.previous = clonedChunk;
  44025. clonedChunk = nextClonedChunk;
  44026. }
  44027. originalChunk = nextOriginalChunk;
  44028. }
  44029. cloned.lastChunk = clonedChunk;
  44030. if (this.indentExclusionRanges) {
  44031. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  44032. }
  44033. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  44034. cloned.intro = this.intro;
  44035. cloned.outro = this.outro;
  44036. return cloned;
  44037. }
  44038. generateDecodedMap(options) {
  44039. options = options || {};
  44040. const sourceIndex = 0;
  44041. const names = Object.keys(this.storedNames);
  44042. const mappings = new Mappings(options.hires);
  44043. const locate = getLocator(this.original);
  44044. if (this.intro) {
  44045. mappings.advance(this.intro);
  44046. }
  44047. this.firstChunk.eachNext((chunk) => {
  44048. const loc = locate(chunk.start);
  44049. if (chunk.intro.length) mappings.advance(chunk.intro);
  44050. if (chunk.edited) {
  44051. mappings.addEdit(
  44052. sourceIndex,
  44053. chunk.content,
  44054. loc,
  44055. chunk.storeName ? names.indexOf(chunk.original) : -1,
  44056. );
  44057. } else {
  44058. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  44059. }
  44060. if (chunk.outro.length) mappings.advance(chunk.outro);
  44061. });
  44062. if (this.outro) {
  44063. mappings.advance(this.outro);
  44064. }
  44065. return {
  44066. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  44067. sources: [
  44068. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  44069. ],
  44070. sourcesContent: options.includeContent ? [this.original] : undefined,
  44071. names,
  44072. mappings: mappings.raw,
  44073. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  44074. };
  44075. }
  44076. generateMap(options) {
  44077. return new SourceMap(this.generateDecodedMap(options));
  44078. }
  44079. _ensureindentStr() {
  44080. if (this.indentStr === undefined) {
  44081. this.indentStr = guessIndent(this.original);
  44082. }
  44083. }
  44084. _getRawIndentString() {
  44085. this._ensureindentStr();
  44086. return this.indentStr;
  44087. }
  44088. getIndentString() {
  44089. this._ensureindentStr();
  44090. return this.indentStr === null ? '\t' : this.indentStr;
  44091. }
  44092. indent(indentStr, options) {
  44093. const pattern = /^[^\r\n]/gm;
  44094. if (isObject(indentStr)) {
  44095. options = indentStr;
  44096. indentStr = undefined;
  44097. }
  44098. if (indentStr === undefined) {
  44099. this._ensureindentStr();
  44100. indentStr = this.indentStr || '\t';
  44101. }
  44102. if (indentStr === '') return this; // noop
  44103. options = options || {};
  44104. // Process exclusion ranges
  44105. const isExcluded = {};
  44106. if (options.exclude) {
  44107. const exclusions =
  44108. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  44109. exclusions.forEach((exclusion) => {
  44110. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  44111. isExcluded[i] = true;
  44112. }
  44113. });
  44114. }
  44115. let shouldIndentNextCharacter = options.indentStart !== false;
  44116. const replacer = (match) => {
  44117. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  44118. shouldIndentNextCharacter = true;
  44119. return match;
  44120. };
  44121. this.intro = this.intro.replace(pattern, replacer);
  44122. let charIndex = 0;
  44123. let chunk = this.firstChunk;
  44124. while (chunk) {
  44125. const end = chunk.end;
  44126. if (chunk.edited) {
  44127. if (!isExcluded[charIndex]) {
  44128. chunk.content = chunk.content.replace(pattern, replacer);
  44129. if (chunk.content.length) {
  44130. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  44131. }
  44132. }
  44133. } else {
  44134. charIndex = chunk.start;
  44135. while (charIndex < end) {
  44136. if (!isExcluded[charIndex]) {
  44137. const char = this.original[charIndex];
  44138. if (char === '\n') {
  44139. shouldIndentNextCharacter = true;
  44140. } else if (char !== '\r' && shouldIndentNextCharacter) {
  44141. shouldIndentNextCharacter = false;
  44142. if (charIndex === chunk.start) {
  44143. chunk.prependRight(indentStr);
  44144. } else {
  44145. this._splitChunk(chunk, charIndex);
  44146. chunk = chunk.next;
  44147. chunk.prependRight(indentStr);
  44148. }
  44149. }
  44150. }
  44151. charIndex += 1;
  44152. }
  44153. }
  44154. charIndex = chunk.end;
  44155. chunk = chunk.next;
  44156. }
  44157. this.outro = this.outro.replace(pattern, replacer);
  44158. return this;
  44159. }
  44160. insert() {
  44161. throw new Error(
  44162. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  44163. );
  44164. }
  44165. insertLeft(index, content) {
  44166. if (!warned.insertLeft) {
  44167. console.warn(
  44168. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  44169. );
  44170. warned.insertLeft = true;
  44171. }
  44172. return this.appendLeft(index, content);
  44173. }
  44174. insertRight(index, content) {
  44175. if (!warned.insertRight) {
  44176. console.warn(
  44177. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  44178. );
  44179. warned.insertRight = true;
  44180. }
  44181. return this.prependRight(index, content);
  44182. }
  44183. move(start, end, index) {
  44184. start = start + this.offset;
  44185. end = end + this.offset;
  44186. index = index + this.offset;
  44187. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  44188. this._split(start);
  44189. this._split(end);
  44190. this._split(index);
  44191. const first = this.byStart[start];
  44192. const last = this.byEnd[end];
  44193. const oldLeft = first.previous;
  44194. const oldRight = last.next;
  44195. const newRight = this.byStart[index];
  44196. if (!newRight && last === this.lastChunk) return this;
  44197. const newLeft = newRight ? newRight.previous : this.lastChunk;
  44198. if (oldLeft) oldLeft.next = oldRight;
  44199. if (oldRight) oldRight.previous = oldLeft;
  44200. if (newLeft) newLeft.next = first;
  44201. if (newRight) newRight.previous = last;
  44202. if (!first.previous) this.firstChunk = last.next;
  44203. if (!last.next) {
  44204. this.lastChunk = first.previous;
  44205. this.lastChunk.next = null;
  44206. }
  44207. first.previous = newLeft;
  44208. last.next = newRight || null;
  44209. if (!newLeft) this.firstChunk = first;
  44210. if (!newRight) this.lastChunk = last;
  44211. return this;
  44212. }
  44213. overwrite(start, end, content, options) {
  44214. options = options || {};
  44215. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  44216. }
  44217. update(start, end, content, options) {
  44218. start = start + this.offset;
  44219. end = end + this.offset;
  44220. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  44221. if (this.original.length !== 0) {
  44222. while (start < 0) start += this.original.length;
  44223. while (end < 0) end += this.original.length;
  44224. }
  44225. if (end > this.original.length) throw new Error('end is out of bounds');
  44226. if (start === end)
  44227. throw new Error(
  44228. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  44229. );
  44230. this._split(start);
  44231. this._split(end);
  44232. if (options === true) {
  44233. if (!warned.storeName) {
  44234. console.warn(
  44235. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  44236. );
  44237. warned.storeName = true;
  44238. }
  44239. options = { storeName: true };
  44240. }
  44241. const storeName = options !== undefined ? options.storeName : false;
  44242. const overwrite = options !== undefined ? options.overwrite : false;
  44243. if (storeName) {
  44244. const original = this.original.slice(start, end);
  44245. Object.defineProperty(this.storedNames, original, {
  44246. writable: true,
  44247. value: true,
  44248. enumerable: true,
  44249. });
  44250. }
  44251. const first = this.byStart[start];
  44252. const last = this.byEnd[end];
  44253. if (first) {
  44254. let chunk = first;
  44255. while (chunk !== last) {
  44256. if (chunk.next !== this.byStart[chunk.end]) {
  44257. throw new Error('Cannot overwrite across a split point');
  44258. }
  44259. chunk = chunk.next;
  44260. chunk.edit('', false);
  44261. }
  44262. first.edit(content, storeName, !overwrite);
  44263. } else {
  44264. // must be inserting at the end
  44265. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  44266. // TODO last chunk in the array may not be the last chunk, if it's moved...
  44267. last.next = newChunk;
  44268. newChunk.previous = last;
  44269. }
  44270. return this;
  44271. }
  44272. prepend(content) {
  44273. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  44274. this.intro = content + this.intro;
  44275. return this;
  44276. }
  44277. prependLeft(index, content) {
  44278. index = index + this.offset;
  44279. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  44280. this._split(index);
  44281. const chunk = this.byEnd[index];
  44282. if (chunk) {
  44283. chunk.prependLeft(content);
  44284. } else {
  44285. this.intro = content + this.intro;
  44286. }
  44287. return this;
  44288. }
  44289. prependRight(index, content) {
  44290. index = index + this.offset;
  44291. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  44292. this._split(index);
  44293. const chunk = this.byStart[index];
  44294. if (chunk) {
  44295. chunk.prependRight(content);
  44296. } else {
  44297. this.outro = content + this.outro;
  44298. }
  44299. return this;
  44300. }
  44301. remove(start, end) {
  44302. start = start + this.offset;
  44303. end = end + this.offset;
  44304. if (this.original.length !== 0) {
  44305. while (start < 0) start += this.original.length;
  44306. while (end < 0) end += this.original.length;
  44307. }
  44308. if (start === end) return this;
  44309. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  44310. if (start > end) throw new Error('end must be greater than start');
  44311. this._split(start);
  44312. this._split(end);
  44313. let chunk = this.byStart[start];
  44314. while (chunk) {
  44315. chunk.intro = '';
  44316. chunk.outro = '';
  44317. chunk.edit('');
  44318. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  44319. }
  44320. return this;
  44321. }
  44322. reset(start, end) {
  44323. start = start + this.offset;
  44324. end = end + this.offset;
  44325. if (this.original.length !== 0) {
  44326. while (start < 0) start += this.original.length;
  44327. while (end < 0) end += this.original.length;
  44328. }
  44329. if (start === end) return this;
  44330. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  44331. if (start > end) throw new Error('end must be greater than start');
  44332. this._split(start);
  44333. this._split(end);
  44334. let chunk = this.byStart[start];
  44335. while (chunk) {
  44336. chunk.reset();
  44337. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  44338. }
  44339. return this;
  44340. }
  44341. lastChar() {
  44342. if (this.outro.length) return this.outro[this.outro.length - 1];
  44343. let chunk = this.lastChunk;
  44344. do {
  44345. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  44346. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  44347. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  44348. } while ((chunk = chunk.previous));
  44349. if (this.intro.length) return this.intro[this.intro.length - 1];
  44350. return '';
  44351. }
  44352. lastLine() {
  44353. let lineIndex = this.outro.lastIndexOf(n);
  44354. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  44355. let lineStr = this.outro;
  44356. let chunk = this.lastChunk;
  44357. do {
  44358. if (chunk.outro.length > 0) {
  44359. lineIndex = chunk.outro.lastIndexOf(n);
  44360. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  44361. lineStr = chunk.outro + lineStr;
  44362. }
  44363. if (chunk.content.length > 0) {
  44364. lineIndex = chunk.content.lastIndexOf(n);
  44365. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  44366. lineStr = chunk.content + lineStr;
  44367. }
  44368. if (chunk.intro.length > 0) {
  44369. lineIndex = chunk.intro.lastIndexOf(n);
  44370. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  44371. lineStr = chunk.intro + lineStr;
  44372. }
  44373. } while ((chunk = chunk.previous));
  44374. lineIndex = this.intro.lastIndexOf(n);
  44375. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  44376. return this.intro + lineStr;
  44377. }
  44378. slice(start = 0, end = this.original.length - this.offset) {
  44379. start = start + this.offset;
  44380. end = end + this.offset;
  44381. if (this.original.length !== 0) {
  44382. while (start < 0) start += this.original.length;
  44383. while (end < 0) end += this.original.length;
  44384. }
  44385. let result = '';
  44386. // find start chunk
  44387. let chunk = this.firstChunk;
  44388. while (chunk && (chunk.start > start || chunk.end <= start)) {
  44389. // found end chunk before start
  44390. if (chunk.start < end && chunk.end >= end) {
  44391. return result;
  44392. }
  44393. chunk = chunk.next;
  44394. }
  44395. if (chunk && chunk.edited && chunk.start !== start)
  44396. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  44397. const startChunk = chunk;
  44398. while (chunk) {
  44399. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  44400. result += chunk.intro;
  44401. }
  44402. const containsEnd = chunk.start < end && chunk.end >= end;
  44403. if (containsEnd && chunk.edited && chunk.end !== end)
  44404. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  44405. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  44406. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  44407. result += chunk.content.slice(sliceStart, sliceEnd);
  44408. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  44409. result += chunk.outro;
  44410. }
  44411. if (containsEnd) {
  44412. break;
  44413. }
  44414. chunk = chunk.next;
  44415. }
  44416. return result;
  44417. }
  44418. // TODO deprecate this? not really very useful
  44419. snip(start, end) {
  44420. const clone = this.clone();
  44421. clone.remove(0, start);
  44422. clone.remove(end, clone.original.length);
  44423. return clone;
  44424. }
  44425. _split(index) {
  44426. if (this.byStart[index] || this.byEnd[index]) return;
  44427. let chunk = this.lastSearchedChunk;
  44428. let previousChunk = chunk;
  44429. const searchForward = index > chunk.end;
  44430. while (chunk) {
  44431. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  44432. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  44433. // Prevent infinite loop (e.g. via empty chunks, where start === end)
  44434. if (chunk === previousChunk) return;
  44435. previousChunk = chunk;
  44436. }
  44437. }
  44438. _splitChunk(chunk, index) {
  44439. if (chunk.edited && chunk.content.length) {
  44440. // zero-length edited chunks are a special case (overlapping replacements)
  44441. const loc = getLocator(this.original)(index);
  44442. throw new Error(
  44443. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  44444. );
  44445. }
  44446. const newChunk = chunk.split(index);
  44447. this.byEnd[index] = chunk;
  44448. this.byStart[index] = newChunk;
  44449. this.byEnd[newChunk.end] = newChunk;
  44450. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  44451. this.lastSearchedChunk = chunk;
  44452. return true;
  44453. }
  44454. toString() {
  44455. let str = this.intro;
  44456. let chunk = this.firstChunk;
  44457. while (chunk) {
  44458. str += chunk.toString();
  44459. chunk = chunk.next;
  44460. }
  44461. return str + this.outro;
  44462. }
  44463. isEmpty() {
  44464. let chunk = this.firstChunk;
  44465. do {
  44466. if (
  44467. (chunk.intro.length && chunk.intro.trim()) ||
  44468. (chunk.content.length && chunk.content.trim()) ||
  44469. (chunk.outro.length && chunk.outro.trim())
  44470. )
  44471. return false;
  44472. } while ((chunk = chunk.next));
  44473. return true;
  44474. }
  44475. length() {
  44476. let chunk = this.firstChunk;
  44477. let length = 0;
  44478. do {
  44479. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  44480. } while ((chunk = chunk.next));
  44481. return length;
  44482. }
  44483. trimLines() {
  44484. return this.trim('[\\r\\n]');
  44485. }
  44486. trim(charType) {
  44487. return this.trimStart(charType).trimEnd(charType);
  44488. }
  44489. trimEndAborted(charType) {
  44490. const rx = new RegExp((charType || '\\s') + '+$');
  44491. this.outro = this.outro.replace(rx, '');
  44492. if (this.outro.length) return true;
  44493. let chunk = this.lastChunk;
  44494. do {
  44495. const end = chunk.end;
  44496. const aborted = chunk.trimEnd(rx);
  44497. // if chunk was trimmed, we have a new lastChunk
  44498. if (chunk.end !== end) {
  44499. if (this.lastChunk === chunk) {
  44500. this.lastChunk = chunk.next;
  44501. }
  44502. this.byEnd[chunk.end] = chunk;
  44503. this.byStart[chunk.next.start] = chunk.next;
  44504. this.byEnd[chunk.next.end] = chunk.next;
  44505. }
  44506. if (aborted) return true;
  44507. chunk = chunk.previous;
  44508. } while (chunk);
  44509. return false;
  44510. }
  44511. trimEnd(charType) {
  44512. this.trimEndAborted(charType);
  44513. return this;
  44514. }
  44515. trimStartAborted(charType) {
  44516. const rx = new RegExp('^' + (charType || '\\s') + '+');
  44517. this.intro = this.intro.replace(rx, '');
  44518. if (this.intro.length) return true;
  44519. let chunk = this.firstChunk;
  44520. do {
  44521. const end = chunk.end;
  44522. const aborted = chunk.trimStart(rx);
  44523. if (chunk.end !== end) {
  44524. // special case...
  44525. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  44526. this.byEnd[chunk.end] = chunk;
  44527. this.byStart[chunk.next.start] = chunk.next;
  44528. this.byEnd[chunk.next.end] = chunk.next;
  44529. }
  44530. if (aborted) return true;
  44531. chunk = chunk.next;
  44532. } while (chunk);
  44533. return false;
  44534. }
  44535. trimStart(charType) {
  44536. this.trimStartAborted(charType);
  44537. return this;
  44538. }
  44539. hasChanged() {
  44540. return this.original !== this.toString();
  44541. }
  44542. _replaceRegexp(searchValue, replacement) {
  44543. function getReplacement(match, str) {
  44544. if (typeof replacement === 'string') {
  44545. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  44546. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  44547. if (i === '$') return '$';
  44548. if (i === '&') return match[0];
  44549. const num = +i;
  44550. if (num < match.length) return match[+i];
  44551. return `$${i}`;
  44552. });
  44553. } else {
  44554. return replacement(...match, match.index, str, match.groups);
  44555. }
  44556. }
  44557. function matchAll(re, str) {
  44558. let match;
  44559. const matches = [];
  44560. while ((match = re.exec(str))) {
  44561. matches.push(match);
  44562. }
  44563. return matches;
  44564. }
  44565. if (searchValue.global) {
  44566. const matches = matchAll(searchValue, this.original);
  44567. matches.forEach((match) => {
  44568. if (match.index != null) {
  44569. const replacement = getReplacement(match, this.original);
  44570. if (replacement !== match[0]) {
  44571. this.overwrite(match.index, match.index + match[0].length, replacement);
  44572. }
  44573. }
  44574. });
  44575. } else {
  44576. const match = this.original.match(searchValue);
  44577. if (match && match.index != null) {
  44578. const replacement = getReplacement(match, this.original);
  44579. if (replacement !== match[0]) {
  44580. this.overwrite(match.index, match.index + match[0].length, replacement);
  44581. }
  44582. }
  44583. }
  44584. return this;
  44585. }
  44586. _replaceString(string, replacement) {
  44587. const { original } = this;
  44588. const index = original.indexOf(string);
  44589. if (index !== -1) {
  44590. if (typeof replacement === 'function') {
  44591. replacement = replacement(string, index, original);
  44592. }
  44593. if (string !== replacement) {
  44594. this.overwrite(index, index + string.length, replacement);
  44595. }
  44596. }
  44597. return this;
  44598. }
  44599. replace(searchValue, replacement) {
  44600. if (typeof searchValue === 'string') {
  44601. return this._replaceString(searchValue, replacement);
  44602. }
  44603. return this._replaceRegexp(searchValue, replacement);
  44604. }
  44605. _replaceAllString(string, replacement) {
  44606. const { original } = this;
  44607. const stringLength = string.length;
  44608. for (
  44609. let index = original.indexOf(string);
  44610. index !== -1;
  44611. index = original.indexOf(string, index + stringLength)
  44612. ) {
  44613. const previous = original.slice(index, index + stringLength);
  44614. let _replacement = replacement;
  44615. if (typeof replacement === 'function') {
  44616. _replacement = replacement(previous, index, original);
  44617. }
  44618. if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
  44619. }
  44620. return this;
  44621. }
  44622. replaceAll(searchValue, replacement) {
  44623. if (typeof searchValue === 'string') {
  44624. return this._replaceAllString(searchValue, replacement);
  44625. }
  44626. if (!searchValue.global) {
  44627. throw new TypeError(
  44628. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  44629. );
  44630. }
  44631. return this._replaceRegexp(searchValue, replacement);
  44632. }
  44633. }
  44634. var _a, _b;
  44635. class ScriptCompileContext {
  44636. constructor(descriptor, options) {
  44637. this.descriptor = descriptor;
  44638. this.options = options;
  44639. this.isCE = false;
  44640. this.source = this.descriptor.source;
  44641. this.filename = this.descriptor.filename;
  44642. this.s = new MagicString(this.source);
  44643. this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
  44644. this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
  44645. this.userImports = /* @__PURE__ */ Object.create(null);
  44646. // macros presence check
  44647. this.hasDefinePropsCall = false;
  44648. this.hasDefineEmitCall = false;
  44649. this.hasDefineExposeCall = false;
  44650. this.hasDefaultExportName = false;
  44651. this.hasDefaultExportRender = false;
  44652. this.hasDefineOptionsCall = false;
  44653. this.hasDefineSlotsCall = false;
  44654. this.hasDefineModelCall = false;
  44655. this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
  44656. // defineModel
  44657. this.modelDecls = /* @__PURE__ */ Object.create(null);
  44658. // codegen
  44659. this.bindingMetadata = {};
  44660. this.helperImports = /* @__PURE__ */ new Set();
  44661. const { script, scriptSetup } = descriptor;
  44662. const scriptLang = script && script.lang;
  44663. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  44664. this.isJS = isJS(scriptLang, scriptSetupLang);
  44665. this.isTS = isTS(scriptLang, scriptSetupLang);
  44666. const customElement = options.customElement;
  44667. const filename = this.descriptor.filename;
  44668. if (customElement) {
  44669. this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
  44670. }
  44671. const plugins = resolveParserPlugins(
  44672. scriptLang || scriptSetupLang,
  44673. options.babelParserPlugins
  44674. );
  44675. function parse(input, offset) {
  44676. try {
  44677. return libExports.parse(input, {
  44678. plugins,
  44679. sourceType: "module"
  44680. }).program;
  44681. } catch (e) {
  44682. e.message = `[vue/compiler-sfc] ${e.message}
  44683. ${descriptor.filename}
  44684. ${generateCodeFrame(
  44685. descriptor.source,
  44686. e.pos + offset,
  44687. e.pos + offset + 1
  44688. )}`;
  44689. throw e;
  44690. }
  44691. }
  44692. this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
  44693. this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
  44694. }
  44695. helper(key) {
  44696. this.helperImports.add(key);
  44697. return `_${key}`;
  44698. }
  44699. getString(node, scriptSetup = true) {
  44700. const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
  44701. return block.content.slice(node.start, node.end);
  44702. }
  44703. warn(msg, node, scope) {
  44704. warn(generateError(msg, node, this, scope));
  44705. }
  44706. error(msg, node, scope) {
  44707. throw new Error(
  44708. `[@vue/compiler-sfc] ${generateError(msg, node, this, scope)}`
  44709. );
  44710. }
  44711. }
  44712. function generateError(msg, node, ctx, scope) {
  44713. const offset = scope ? scope.offset : ctx.startOffset;
  44714. return `${msg}
  44715. ${(scope || ctx.descriptor).filename}
  44716. ${generateCodeFrame(
  44717. (scope || ctx.descriptor).source,
  44718. node.start + offset,
  44719. node.end + offset
  44720. )}`;
  44721. }
  44722. function resolveParserPlugins(lang, userPlugins, dts = false) {
  44723. const plugins = [];
  44724. if (!userPlugins || !userPlugins.some(
  44725. (p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
  44726. )) {
  44727. plugins.push("importAttributes");
  44728. }
  44729. if (lang === "jsx" || lang === "tsx" || lang === "mtsx") {
  44730. plugins.push("jsx");
  44731. } else if (userPlugins) {
  44732. userPlugins = userPlugins.filter((p) => p !== "jsx");
  44733. }
  44734. if (lang === "ts" || lang === "mts" || lang === "tsx" || lang === "mtsx") {
  44735. plugins.push(["typescript", { dts }], "explicitResourceManagement");
  44736. if (!userPlugins || !userPlugins.includes("decorators")) {
  44737. plugins.push("decorators-legacy");
  44738. }
  44739. }
  44740. if (userPlugins) {
  44741. plugins.push(...userPlugins);
  44742. }
  44743. return plugins;
  44744. }
  44745. function rewriteDefault(input, as, parserPlugins) {
  44746. const ast = libExports.parse(input, {
  44747. sourceType: "module",
  44748. plugins: resolveParserPlugins("js", parserPlugins)
  44749. }).program.body;
  44750. const s = new MagicString(input);
  44751. rewriteDefaultAST(ast, s, as);
  44752. return s.toString();
  44753. }
  44754. function rewriteDefaultAST(ast, s, as) {
  44755. if (!hasDefaultExport(ast)) {
  44756. s.append(`
  44757. const ${as} = {}`);
  44758. return;
  44759. }
  44760. ast.forEach((node) => {
  44761. if (node.type === "ExportDefaultDeclaration") {
  44762. if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
  44763. const start = node.declaration.decorators && node.declaration.decorators.length > 0 ? node.declaration.decorators[node.declaration.decorators.length - 1].end : node.start;
  44764. s.overwrite(start, node.declaration.id.start, ` class `);
  44765. s.append(`
  44766. const ${as} = ${node.declaration.id.name}`);
  44767. } else {
  44768. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  44769. }
  44770. } else if (node.type === "ExportNamedDeclaration") {
  44771. for (const specifier of node.specifiers) {
  44772. if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.exported.name === "default") {
  44773. if (node.source) {
  44774. if (specifier.local.name === "default") {
  44775. s.prepend(
  44776. `import { default as __VUE_DEFAULT__ } from '${node.source.value}'
  44777. `
  44778. );
  44779. const end2 = specifierEnd(s, specifier.local.end, node.end);
  44780. s.remove(specifier.start, end2);
  44781. s.append(`
  44782. const ${as} = __VUE_DEFAULT__`);
  44783. continue;
  44784. } else {
  44785. s.prepend(
  44786. `import { ${s.slice(
  44787. specifier.local.start,
  44788. specifier.local.end
  44789. )} as __VUE_DEFAULT__ } from '${node.source.value}'
  44790. `
  44791. );
  44792. const end2 = specifierEnd(s, specifier.exported.end, node.end);
  44793. s.remove(specifier.start, end2);
  44794. s.append(`
  44795. const ${as} = __VUE_DEFAULT__`);
  44796. continue;
  44797. }
  44798. }
  44799. const end = specifierEnd(s, specifier.end, node.end);
  44800. s.remove(specifier.start, end);
  44801. s.append(`
  44802. const ${as} = ${specifier.local.name}`);
  44803. }
  44804. }
  44805. }
  44806. });
  44807. }
  44808. function hasDefaultExport(ast) {
  44809. for (const stmt of ast) {
  44810. if (stmt.type === "ExportDefaultDeclaration") {
  44811. return true;
  44812. } else if (stmt.type === "ExportNamedDeclaration" && stmt.specifiers.some(
  44813. (spec) => spec.exported.name === "default"
  44814. )) {
  44815. return true;
  44816. }
  44817. }
  44818. return false;
  44819. }
  44820. function specifierEnd(s, end, nodeEnd) {
  44821. let hasCommas = false;
  44822. let oldEnd = end;
  44823. while (end < nodeEnd) {
  44824. if (/\s/.test(s.slice(end, end + 1))) {
  44825. end++;
  44826. } else if (s.slice(end, end + 1) === ",") {
  44827. end++;
  44828. hasCommas = true;
  44829. break;
  44830. } else if (s.slice(end, end + 1) === "}") {
  44831. break;
  44832. }
  44833. }
  44834. return hasCommas ? end : oldEnd;
  44835. }
  44836. var __defProp$3 = Object.defineProperty;
  44837. var __defProps$2 = Object.defineProperties;
  44838. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  44839. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  44840. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  44841. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  44842. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  44843. var __spreadValues$3 = (a, b) => {
  44844. for (var prop in b || (b = {}))
  44845. if (__hasOwnProp$3.call(b, prop))
  44846. __defNormalProp$3(a, prop, b[prop]);
  44847. if (__getOwnPropSymbols$3)
  44848. for (var prop of __getOwnPropSymbols$3(b)) {
  44849. if (__propIsEnum$3.call(b, prop))
  44850. __defNormalProp$3(a, prop, b[prop]);
  44851. }
  44852. return a;
  44853. };
  44854. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  44855. const normalScriptDefaultVar = `__default__`;
  44856. function processNormalScript(ctx, scopeId) {
  44857. var _a;
  44858. const script = ctx.descriptor.script;
  44859. try {
  44860. let content = script.content;
  44861. let map = script.map;
  44862. const scriptAst = ctx.scriptAst;
  44863. const bindings = analyzeScriptBindings(scriptAst.body);
  44864. const { cssVars } = ctx.descriptor;
  44865. const { genDefaultAs, isProd } = ctx.options;
  44866. if (cssVars.length || genDefaultAs) {
  44867. const defaultVar = genDefaultAs || normalScriptDefaultVar;
  44868. const s = new MagicString(content);
  44869. rewriteDefaultAST(scriptAst.body, s, defaultVar);
  44870. content = s.toString();
  44871. if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
  44872. content += genNormalScriptCssVarsCode(
  44873. cssVars,
  44874. bindings,
  44875. scopeId,
  44876. !!isProd,
  44877. defaultVar
  44878. );
  44879. }
  44880. if (!genDefaultAs) {
  44881. content += `
  44882. export default ${defaultVar}`;
  44883. }
  44884. }
  44885. return __spreadProps$2(__spreadValues$3({}, script), {
  44886. content,
  44887. map,
  44888. bindings,
  44889. scriptAst: scriptAst.body
  44890. });
  44891. } catch (e) {
  44892. return script;
  44893. }
  44894. }
  44895. var __defProp$2 = Object.defineProperty;
  44896. var __defProps$1 = Object.defineProperties;
  44897. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  44898. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  44899. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  44900. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  44901. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  44902. var __spreadValues$2 = (a, b) => {
  44903. for (var prop in b || (b = {}))
  44904. if (__hasOwnProp$2.call(b, prop))
  44905. __defNormalProp$2(a, prop, b[prop]);
  44906. if (__getOwnPropSymbols$2)
  44907. for (var prop of __getOwnPropSymbols$2(b)) {
  44908. if (__propIsEnum$2.call(b, prop))
  44909. __defNormalProp$2(a, prop, b[prop]);
  44910. }
  44911. return a;
  44912. };
  44913. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  44914. class TypeScope {
  44915. constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
  44916. this.filename = filename;
  44917. this.source = source;
  44918. this.offset = offset;
  44919. this.imports = imports;
  44920. this.types = types;
  44921. this.declares = declares;
  44922. this.isGenericScope = false;
  44923. this.resolvedImportSources = /* @__PURE__ */ Object.create(null);
  44924. this.exportedTypes = /* @__PURE__ */ Object.create(null);
  44925. this.exportedDeclares = /* @__PURE__ */ Object.create(null);
  44926. }
  44927. }
  44928. function resolveTypeElements(ctx, node, scope, typeParameters) {
  44929. const canCache = !typeParameters;
  44930. if (canCache && node._resolvedElements) {
  44931. return node._resolvedElements;
  44932. }
  44933. const resolved = innerResolveTypeElements(
  44934. ctx,
  44935. node,
  44936. node._ownerScope || scope || ctxToScope(ctx),
  44937. typeParameters
  44938. );
  44939. return canCache ? node._resolvedElements = resolved : resolved;
  44940. }
  44941. function innerResolveTypeElements(ctx, node, scope, typeParameters) {
  44942. var _a, _b;
  44943. if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  44944. return { props: {} };
  44945. }
  44946. switch (node.type) {
  44947. case "TSTypeLiteral":
  44948. return typeElementsToMap(ctx, node.members, scope, typeParameters);
  44949. case "TSInterfaceDeclaration":
  44950. return resolveInterfaceMembers(ctx, node, scope, typeParameters);
  44951. case "TSTypeAliasDeclaration":
  44952. case "TSTypeAnnotation":
  44953. case "TSParenthesizedType":
  44954. return resolveTypeElements(
  44955. ctx,
  44956. node.typeAnnotation,
  44957. scope,
  44958. typeParameters
  44959. );
  44960. case "TSFunctionType": {
  44961. return { props: {}, calls: [node] };
  44962. }
  44963. case "TSUnionType":
  44964. case "TSIntersectionType":
  44965. return mergeElements(
  44966. node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
  44967. node.type
  44968. );
  44969. case "TSMappedType":
  44970. return resolveMappedType(ctx, node, scope, typeParameters);
  44971. case "TSIndexedAccessType": {
  44972. const types = resolveIndexType(ctx, node, scope);
  44973. return mergeElements(
  44974. types.map((t) => resolveTypeElements(ctx, t, t._ownerScope)),
  44975. "TSUnionType"
  44976. );
  44977. }
  44978. case "TSExpressionWithTypeArguments":
  44979. // referenced by interface extends
  44980. case "TSTypeReference": {
  44981. const typeName = getReferenceName(node);
  44982. if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
  44983. return resolveExtractPropTypes(
  44984. resolveTypeElements(
  44985. ctx,
  44986. node.typeParameters.params[0],
  44987. scope,
  44988. typeParameters
  44989. ),
  44990. scope
  44991. );
  44992. }
  44993. const resolved = resolveTypeReference(ctx, node, scope);
  44994. if (resolved) {
  44995. let typeParams;
  44996. if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
  44997. typeParams = /* @__PURE__ */ Object.create(null);
  44998. resolved.typeParameters.params.forEach((p, i) => {
  44999. let param = typeParameters && typeParameters[p.name];
  45000. if (!param) param = node.typeParameters.params[i];
  45001. typeParams[p.name] = param;
  45002. });
  45003. }
  45004. return resolveTypeElements(
  45005. ctx,
  45006. resolved,
  45007. resolved._ownerScope,
  45008. typeParams
  45009. );
  45010. } else {
  45011. if (typeof typeName === "string") {
  45012. if (typeParameters && typeParameters[typeName]) {
  45013. return resolveTypeElements(
  45014. ctx,
  45015. typeParameters[typeName],
  45016. scope,
  45017. typeParameters
  45018. );
  45019. }
  45020. if (
  45021. // @ts-expect-error
  45022. SupportedBuiltinsSet.has(typeName)
  45023. ) {
  45024. return resolveBuiltin(
  45025. ctx,
  45026. node,
  45027. typeName,
  45028. scope,
  45029. typeParameters
  45030. );
  45031. } else if (typeName === "ReturnType" && node.typeParameters) {
  45032. const ret = resolveReturnType(
  45033. ctx,
  45034. node.typeParameters.params[0],
  45035. scope
  45036. );
  45037. if (ret) {
  45038. return resolveTypeElements(ctx, ret, scope);
  45039. }
  45040. }
  45041. }
  45042. return ctx.error(
  45043. `Unresolvable type reference or unsupported built-in utility type`,
  45044. node,
  45045. scope
  45046. );
  45047. }
  45048. }
  45049. case "TSImportType": {
  45050. if (getId(node.argument) === "vue" && ((_b = node.qualifier) == null ? void 0 : _b.type) === "Identifier" && node.qualifier.name === "ExtractPropTypes" && node.typeParameters) {
  45051. return resolveExtractPropTypes(
  45052. resolveTypeElements(ctx, node.typeParameters.params[0], scope),
  45053. scope
  45054. );
  45055. }
  45056. const sourceScope = importSourceToScope(
  45057. ctx,
  45058. node.argument,
  45059. scope,
  45060. node.argument.value
  45061. );
  45062. const resolved = resolveTypeReference(ctx, node, sourceScope);
  45063. if (resolved) {
  45064. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  45065. }
  45066. break;
  45067. }
  45068. case "TSTypeQuery":
  45069. {
  45070. const resolved = resolveTypeReference(ctx, node, scope);
  45071. if (resolved) {
  45072. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  45073. }
  45074. }
  45075. break;
  45076. }
  45077. return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
  45078. }
  45079. function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
  45080. const res = { props: {} };
  45081. for (const e of elements) {
  45082. if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
  45083. if (typeParameters) {
  45084. scope = createChildScope(scope);
  45085. scope.isGenericScope = true;
  45086. Object.assign(scope.types, typeParameters);
  45087. }
  45088. e._ownerScope = scope;
  45089. const name = getId(e.key);
  45090. if (name && !e.computed) {
  45091. res.props[name] = e;
  45092. } else if (e.key.type === "TemplateLiteral") {
  45093. for (const key of resolveTemplateKeys(ctx, e.key, scope)) {
  45094. res.props[key] = e;
  45095. }
  45096. } else {
  45097. ctx.error(
  45098. `Unsupported computed key in type referenced by a macro`,
  45099. e.key,
  45100. scope
  45101. );
  45102. }
  45103. } else if (e.type === "TSCallSignatureDeclaration") {
  45104. (res.calls || (res.calls = [])).push(e);
  45105. }
  45106. }
  45107. return res;
  45108. }
  45109. function mergeElements(maps, type) {
  45110. if (maps.length === 1) return maps[0];
  45111. const res = { props: {} };
  45112. const { props: baseProps } = res;
  45113. for (const { props, calls } of maps) {
  45114. for (const key in props) {
  45115. if (!hasOwn(baseProps, key)) {
  45116. baseProps[key] = props[key];
  45117. } else {
  45118. baseProps[key] = createProperty(
  45119. baseProps[key].key,
  45120. {
  45121. type,
  45122. // @ts-expect-error
  45123. types: [baseProps[key], props[key]]
  45124. },
  45125. baseProps[key]._ownerScope,
  45126. baseProps[key].optional || props[key].optional
  45127. );
  45128. }
  45129. }
  45130. if (calls) {
  45131. (res.calls || (res.calls = [])).push(...calls);
  45132. }
  45133. }
  45134. return res;
  45135. }
  45136. function createProperty(key, typeAnnotation, scope, optional) {
  45137. return {
  45138. type: "TSPropertySignature",
  45139. key,
  45140. kind: "get",
  45141. optional,
  45142. typeAnnotation: {
  45143. type: "TSTypeAnnotation",
  45144. typeAnnotation
  45145. },
  45146. _ownerScope: scope
  45147. };
  45148. }
  45149. function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
  45150. const base = typeElementsToMap(
  45151. ctx,
  45152. node.body.body,
  45153. node._ownerScope,
  45154. typeParameters
  45155. );
  45156. if (node.extends) {
  45157. for (const ext of node.extends) {
  45158. try {
  45159. const { props, calls } = resolveTypeElements(ctx, ext, scope);
  45160. for (const key in props) {
  45161. if (!hasOwn(base.props, key)) {
  45162. base.props[key] = props[key];
  45163. }
  45164. }
  45165. if (calls) {
  45166. ;
  45167. (base.calls || (base.calls = [])).push(...calls);
  45168. }
  45169. } catch (e) {
  45170. ctx.error(
  45171. `Failed to resolve extends base type.
  45172. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
  45173. interface Props extends /* @vue-ignore */ Base {}
  45174. Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
  45175. ext,
  45176. scope
  45177. );
  45178. }
  45179. }
  45180. }
  45181. return base;
  45182. }
  45183. function resolveMappedType(ctx, node, scope, typeParameters) {
  45184. const res = { props: {} };
  45185. let keys;
  45186. if (node.nameType) {
  45187. const { name, constraint } = node.typeParameter;
  45188. scope = createChildScope(scope);
  45189. Object.assign(scope.types, __spreadProps$1(__spreadValues$2({}, typeParameters), { [name]: constraint }));
  45190. keys = resolveStringType(ctx, node.nameType, scope);
  45191. } else {
  45192. keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
  45193. }
  45194. for (const key of keys) {
  45195. res.props[key] = createProperty(
  45196. {
  45197. type: "Identifier",
  45198. name: key
  45199. },
  45200. node.typeAnnotation,
  45201. scope,
  45202. !!node.optional
  45203. );
  45204. }
  45205. return res;
  45206. }
  45207. function resolveIndexType(ctx, node, scope) {
  45208. var _a, _b;
  45209. if (node.indexType.type === "TSNumberKeyword") {
  45210. return resolveArrayElementType(ctx, node.objectType, scope);
  45211. }
  45212. const { indexType, objectType } = node;
  45213. const types = [];
  45214. let keys;
  45215. let resolved;
  45216. if (indexType.type === "TSStringKeyword") {
  45217. resolved = resolveTypeElements(ctx, objectType, scope);
  45218. keys = Object.keys(resolved.props);
  45219. } else {
  45220. keys = resolveStringType(ctx, indexType, scope);
  45221. resolved = resolveTypeElements(ctx, objectType, scope);
  45222. }
  45223. for (const key of keys) {
  45224. const targetType = (_b = (_a = resolved.props[key]) == null ? void 0 : _a.typeAnnotation) == null ? void 0 : _b.typeAnnotation;
  45225. if (targetType) {
  45226. targetType._ownerScope = resolved.props[key]._ownerScope;
  45227. types.push(targetType);
  45228. }
  45229. }
  45230. return types;
  45231. }
  45232. function resolveArrayElementType(ctx, node, scope) {
  45233. if (node.type === "TSArrayType") {
  45234. return [node.elementType];
  45235. }
  45236. if (node.type === "TSTupleType") {
  45237. return node.elementTypes.map(
  45238. (t) => t.type === "TSNamedTupleMember" ? t.elementType : t
  45239. );
  45240. }
  45241. if (node.type === "TSTypeReference") {
  45242. if (getReferenceName(node) === "Array" && node.typeParameters) {
  45243. return node.typeParameters.params;
  45244. } else {
  45245. const resolved = resolveTypeReference(ctx, node, scope);
  45246. if (resolved) {
  45247. return resolveArrayElementType(ctx, resolved, scope);
  45248. }
  45249. }
  45250. }
  45251. return ctx.error(
  45252. "Failed to resolve element type from target type",
  45253. node,
  45254. scope
  45255. );
  45256. }
  45257. function resolveStringType(ctx, node, scope, typeParameters) {
  45258. switch (node.type) {
  45259. case "StringLiteral":
  45260. return [node.value];
  45261. case "TSLiteralType":
  45262. return resolveStringType(ctx, node.literal, scope, typeParameters);
  45263. case "TSUnionType":
  45264. return node.types.map((t) => resolveStringType(ctx, t, scope, typeParameters)).flat();
  45265. case "TemplateLiteral": {
  45266. return resolveTemplateKeys(ctx, node, scope);
  45267. }
  45268. case "TSTypeReference": {
  45269. const resolved = resolveTypeReference(ctx, node, scope);
  45270. if (resolved) {
  45271. return resolveStringType(ctx, resolved, scope, typeParameters);
  45272. }
  45273. if (node.typeName.type === "Identifier") {
  45274. const name = node.typeName.name;
  45275. if (typeParameters && typeParameters[name]) {
  45276. return resolveStringType(
  45277. ctx,
  45278. typeParameters[name],
  45279. scope,
  45280. typeParameters
  45281. );
  45282. }
  45283. const getParam = (index = 0) => resolveStringType(
  45284. ctx,
  45285. node.typeParameters.params[index],
  45286. scope,
  45287. typeParameters
  45288. );
  45289. switch (name) {
  45290. case "Extract":
  45291. return getParam(1);
  45292. case "Exclude": {
  45293. const excluded = getParam(1);
  45294. return getParam().filter((s) => !excluded.includes(s));
  45295. }
  45296. case "Uppercase":
  45297. return getParam().map((s) => s.toUpperCase());
  45298. case "Lowercase":
  45299. return getParam().map((s) => s.toLowerCase());
  45300. case "Capitalize":
  45301. return getParam().map(capitalize);
  45302. case "Uncapitalize":
  45303. return getParam().map((s) => s[0].toLowerCase() + s.slice(1));
  45304. default:
  45305. ctx.error(
  45306. "Unsupported type when resolving index type",
  45307. node.typeName,
  45308. scope
  45309. );
  45310. }
  45311. }
  45312. }
  45313. }
  45314. return ctx.error("Failed to resolve index type into finite keys", node, scope);
  45315. }
  45316. function resolveTemplateKeys(ctx, node, scope) {
  45317. if (!node.expressions.length) {
  45318. return [node.quasis[0].value.raw];
  45319. }
  45320. const res = [];
  45321. const e = node.expressions[0];
  45322. const q = node.quasis[0];
  45323. const leading = q ? q.value.raw : ``;
  45324. const resolved = resolveStringType(ctx, e, scope);
  45325. const restResolved = resolveTemplateKeys(
  45326. ctx,
  45327. __spreadProps$1(__spreadValues$2({}, node), {
  45328. expressions: node.expressions.slice(1),
  45329. quasis: q ? node.quasis.slice(1) : node.quasis
  45330. }),
  45331. scope
  45332. );
  45333. for (const r of resolved) {
  45334. for (const rr of restResolved) {
  45335. res.push(leading + r + rr);
  45336. }
  45337. }
  45338. return res;
  45339. }
  45340. const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
  45341. "Partial",
  45342. "Required",
  45343. "Readonly",
  45344. "Pick",
  45345. "Omit"
  45346. ]);
  45347. function resolveBuiltin(ctx, node, name, scope, typeParameters) {
  45348. const t = resolveTypeElements(
  45349. ctx,
  45350. node.typeParameters.params[0],
  45351. scope,
  45352. typeParameters
  45353. );
  45354. switch (name) {
  45355. case "Partial": {
  45356. const res2 = { props: {}, calls: t.calls };
  45357. Object.keys(t.props).forEach((key) => {
  45358. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: true });
  45359. });
  45360. return res2;
  45361. }
  45362. case "Required": {
  45363. const res2 = { props: {}, calls: t.calls };
  45364. Object.keys(t.props).forEach((key) => {
  45365. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: false });
  45366. });
  45367. return res2;
  45368. }
  45369. case "Readonly":
  45370. return t;
  45371. case "Pick": {
  45372. const picked = resolveStringType(
  45373. ctx,
  45374. node.typeParameters.params[1],
  45375. scope,
  45376. typeParameters
  45377. );
  45378. const res2 = { props: {}, calls: t.calls };
  45379. for (const key of picked) {
  45380. res2.props[key] = t.props[key];
  45381. }
  45382. return res2;
  45383. }
  45384. case "Omit":
  45385. const omitted = resolveStringType(
  45386. ctx,
  45387. node.typeParameters.params[1],
  45388. scope,
  45389. typeParameters
  45390. );
  45391. const res = { props: {}, calls: t.calls };
  45392. for (const key in t.props) {
  45393. if (!omitted.includes(key)) {
  45394. res.props[key] = t.props[key];
  45395. }
  45396. }
  45397. return res;
  45398. }
  45399. }
  45400. function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
  45401. const canCache = !(scope == null ? void 0 : scope.isGenericScope);
  45402. if (canCache && node._resolvedReference) {
  45403. return node._resolvedReference;
  45404. }
  45405. const resolved = innerResolveTypeReference(
  45406. ctx,
  45407. scope || ctxToScope(ctx),
  45408. name || getReferenceName(node),
  45409. node,
  45410. onlyExported
  45411. );
  45412. return canCache ? node._resolvedReference = resolved : resolved;
  45413. }
  45414. function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
  45415. if (typeof name === "string") {
  45416. if (scope.imports[name]) {
  45417. return resolveTypeFromImport(ctx, node, name, scope);
  45418. } else {
  45419. const lookupSource = node.type === "TSTypeQuery" ? onlyExported ? scope.exportedDeclares : scope.declares : onlyExported ? scope.exportedTypes : scope.types;
  45420. if (lookupSource[name]) {
  45421. return lookupSource[name];
  45422. } else {
  45423. const globalScopes = resolveGlobalScope(ctx);
  45424. if (globalScopes) {
  45425. for (const s of globalScopes) {
  45426. const src = node.type === "TSTypeQuery" ? s.declares : s.types;
  45427. if (src[name]) {
  45428. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(s.filename);
  45429. return src[name];
  45430. }
  45431. }
  45432. }
  45433. }
  45434. }
  45435. } else {
  45436. let ns = innerResolveTypeReference(ctx, scope, name[0], node, onlyExported);
  45437. if (ns) {
  45438. if (ns.type !== "TSModuleDeclaration") {
  45439. ns = ns._ns;
  45440. }
  45441. if (ns) {
  45442. const childScope = moduleDeclToScope(ctx, ns, ns._ownerScope || scope);
  45443. return innerResolveTypeReference(
  45444. ctx,
  45445. childScope,
  45446. name.length > 2 ? name.slice(1) : name[name.length - 1],
  45447. node,
  45448. !ns.declare
  45449. );
  45450. }
  45451. }
  45452. }
  45453. }
  45454. function getReferenceName(node) {
  45455. const ref = node.type === "TSTypeReference" ? node.typeName : node.type === "TSExpressionWithTypeArguments" ? node.expression : node.type === "TSImportType" ? node.qualifier : node.exprName;
  45456. if ((ref == null ? void 0 : ref.type) === "Identifier") {
  45457. return ref.name;
  45458. } else if ((ref == null ? void 0 : ref.type) === "TSQualifiedName") {
  45459. return qualifiedNameToPath(ref);
  45460. } else {
  45461. return "default";
  45462. }
  45463. }
  45464. function qualifiedNameToPath(node) {
  45465. if (node.type === "Identifier") {
  45466. return [node.name];
  45467. } else {
  45468. return [...qualifiedNameToPath(node.left), node.right.name];
  45469. }
  45470. }
  45471. function resolveGlobalScope(ctx) {
  45472. if (ctx.options.globalTypeFiles) {
  45473. const fs = resolveFS(ctx);
  45474. if (!fs) {
  45475. throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
  45476. }
  45477. return ctx.options.globalTypeFiles.map(
  45478. (file) => fileToScope(ctx, normalizePath(file), true)
  45479. );
  45480. }
  45481. }
  45482. let ts;
  45483. let loadTS;
  45484. function registerTS(_loadTS) {
  45485. loadTS = () => {
  45486. try {
  45487. return _loadTS();
  45488. } catch (err) {
  45489. if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
  45490. throw new Error(
  45491. 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
  45492. );
  45493. } else {
  45494. throw new Error(
  45495. "Failed to load TypeScript for resolving imported types."
  45496. );
  45497. }
  45498. }
  45499. };
  45500. }
  45501. function resolveFS(ctx) {
  45502. if (ctx.fs) {
  45503. return ctx.fs;
  45504. }
  45505. if (!ts && loadTS) {
  45506. ts = loadTS();
  45507. }
  45508. const fs = ctx.options.fs || (ts == null ? void 0 : ts.sys);
  45509. if (!fs) {
  45510. return;
  45511. }
  45512. return ctx.fs = {
  45513. fileExists(file) {
  45514. if (file.endsWith(".vue.ts") && !file.endsWith(".d.vue.ts")) {
  45515. file = file.replace(/\.ts$/, "");
  45516. }
  45517. return fs.fileExists(file);
  45518. },
  45519. readFile(file) {
  45520. if (file.endsWith(".vue.ts") && !file.endsWith(".d.vue.ts")) {
  45521. file = file.replace(/\.ts$/, "");
  45522. }
  45523. return fs.readFile(file);
  45524. },
  45525. realpath: fs.realpath
  45526. };
  45527. }
  45528. function resolveTypeFromImport(ctx, node, name, scope) {
  45529. const { source, imported } = scope.imports[name];
  45530. const sourceScope = importSourceToScope(ctx, node, scope, source);
  45531. return resolveTypeReference(ctx, node, sourceScope, imported, true);
  45532. }
  45533. function importSourceToScope(ctx, node, scope, source) {
  45534. let fs;
  45535. try {
  45536. fs = resolveFS(ctx);
  45537. } catch (err) {
  45538. return ctx.error(err.message, node, scope);
  45539. }
  45540. if (!fs) {
  45541. return ctx.error(
  45542. `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
  45543. node,
  45544. scope
  45545. );
  45546. }
  45547. let resolved = scope.resolvedImportSources[source];
  45548. if (!resolved) {
  45549. if (source.startsWith("..")) {
  45550. const osSpecificJoinFn = joinPaths;
  45551. const filename = osSpecificJoinFn(dirname(scope.filename), source);
  45552. resolved = resolveExt(filename, fs);
  45553. } else if (source[0] === ".") {
  45554. const filename = joinPaths(dirname(scope.filename), source);
  45555. resolved = resolveExt(filename, fs);
  45556. } else {
  45557. {
  45558. return ctx.error(
  45559. `Type import from non-relative sources is not supported in the browser build.`,
  45560. node,
  45561. scope
  45562. );
  45563. }
  45564. }
  45565. if (resolved) {
  45566. resolved = scope.resolvedImportSources[source] = normalizePath(resolved);
  45567. }
  45568. }
  45569. if (resolved) {
  45570. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(resolved);
  45571. return fileToScope(ctx, resolved);
  45572. } else {
  45573. return ctx.error(
  45574. `Failed to resolve import source ${JSON.stringify(source)}.`,
  45575. node,
  45576. scope
  45577. );
  45578. }
  45579. }
  45580. function resolveExt(filename, fs) {
  45581. filename = filename.replace(/\.js$/, "");
  45582. const tryResolve = (filename2) => {
  45583. if (fs.fileExists(filename2)) return filename2;
  45584. };
  45585. return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.tsx`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.tsx`)) || tryResolve(joinPaths(filename, `index.d.ts`));
  45586. }
  45587. const tsConfigCache = createCache();
  45588. const tsConfigRefMap = /* @__PURE__ */ new Map();
  45589. const fileToScopeCache = createCache();
  45590. function invalidateTypeCache(filename) {
  45591. filename = normalizePath(filename);
  45592. fileToScopeCache.delete(filename);
  45593. tsConfigCache.delete(filename);
  45594. const affectedConfig = tsConfigRefMap.get(filename);
  45595. if (affectedConfig) tsConfigCache.delete(affectedConfig);
  45596. }
  45597. function fileToScope(ctx, filename, asGlobal = false) {
  45598. const cached = fileToScopeCache.get(filename);
  45599. if (cached) {
  45600. return cached;
  45601. }
  45602. const fs = resolveFS(ctx);
  45603. const source = fs.readFile(filename) || "";
  45604. const body = parseFile(filename, source, fs, ctx.options.babelParserPlugins);
  45605. const scope = new TypeScope(filename, source, 0, recordImports(body));
  45606. recordTypes(ctx, body, scope, asGlobal);
  45607. fileToScopeCache.set(filename, scope);
  45608. return scope;
  45609. }
  45610. function parseFile(filename, content, fs, parserPlugins) {
  45611. const ext = extname(filename);
  45612. if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
  45613. return libExports.parse(content, {
  45614. plugins: resolveParserPlugins(
  45615. ext.slice(1),
  45616. parserPlugins,
  45617. /\.d\.m?ts$/.test(filename)
  45618. ),
  45619. sourceType: "module"
  45620. }).program.body;
  45621. }
  45622. const isUnknownTypeSource = !/\.[cm]?[tj]sx?$/.test(filename);
  45623. const arbitraryTypeSource = `${filename.slice(0, -ext.length)}.d${ext}.ts`;
  45624. const hasArbitraryTypeDeclaration = isUnknownTypeSource && fs.fileExists(arbitraryTypeSource);
  45625. if (hasArbitraryTypeDeclaration) {
  45626. return libExports.parse(fs.readFile(arbitraryTypeSource), {
  45627. plugins: resolveParserPlugins("ts", parserPlugins, true),
  45628. sourceType: "module"
  45629. }).program.body;
  45630. }
  45631. if (ext === ".vue") {
  45632. const {
  45633. descriptor: { script, scriptSetup }
  45634. } = parse$2(content);
  45635. if (!script && !scriptSetup) {
  45636. return [];
  45637. }
  45638. const scriptOffset = script ? script.loc.start.offset : Infinity;
  45639. const scriptSetupOffset = scriptSetup ? scriptSetup.loc.start.offset : Infinity;
  45640. const firstBlock = scriptOffset < scriptSetupOffset ? script : scriptSetup;
  45641. const secondBlock = scriptOffset < scriptSetupOffset ? scriptSetup : script;
  45642. let scriptContent = " ".repeat(Math.min(scriptOffset, scriptSetupOffset)) + firstBlock.content;
  45643. if (secondBlock) {
  45644. scriptContent += " ".repeat(secondBlock.loc.start.offset - script.loc.end.offset) + secondBlock.content;
  45645. }
  45646. const lang = (script == null ? void 0 : script.lang) || (scriptSetup == null ? void 0 : scriptSetup.lang);
  45647. return libExports.parse(scriptContent, {
  45648. plugins: resolveParserPlugins(lang, parserPlugins),
  45649. sourceType: "module"
  45650. }).program.body;
  45651. }
  45652. return [];
  45653. }
  45654. function ctxToScope(ctx) {
  45655. if (ctx.scope) {
  45656. return ctx.scope;
  45657. }
  45658. const body = "ast" in ctx ? ctx.ast : ctx.scriptAst ? [...ctx.scriptAst.body, ...ctx.scriptSetupAst.body] : ctx.scriptSetupAst.body;
  45659. const scope = new TypeScope(
  45660. ctx.filename,
  45661. ctx.source,
  45662. "startOffset" in ctx ? ctx.startOffset : 0,
  45663. "userImports" in ctx ? Object.create(ctx.userImports) : recordImports(body)
  45664. );
  45665. recordTypes(ctx, body, scope);
  45666. return ctx.scope = scope;
  45667. }
  45668. function moduleDeclToScope(ctx, node, parentScope) {
  45669. if (node._resolvedChildScope) {
  45670. return node._resolvedChildScope;
  45671. }
  45672. const scope = createChildScope(parentScope);
  45673. if (node.body.type === "TSModuleDeclaration") {
  45674. const decl = node.body;
  45675. decl._ownerScope = scope;
  45676. const id = getId(decl.id);
  45677. scope.types[id] = scope.exportedTypes[id] = decl;
  45678. } else {
  45679. recordTypes(ctx, node.body.body, scope);
  45680. }
  45681. return node._resolvedChildScope = scope;
  45682. }
  45683. function createChildScope(parentScope) {
  45684. return new TypeScope(
  45685. parentScope.filename,
  45686. parentScope.source,
  45687. parentScope.offset,
  45688. Object.create(parentScope.imports),
  45689. Object.create(parentScope.types),
  45690. Object.create(parentScope.declares)
  45691. );
  45692. }
  45693. const importExportRE = /^Import|^Export/;
  45694. function recordTypes(ctx, body, scope, asGlobal = false) {
  45695. const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
  45696. const isAmbient = asGlobal ? !body.some((s) => importExportRE.test(s.type)) : false;
  45697. for (const stmt of body) {
  45698. if (asGlobal) {
  45699. if (isAmbient) {
  45700. if (stmt.declare) {
  45701. recordType(stmt, types, declares);
  45702. }
  45703. } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
  45704. for (const s of stmt.body.body) {
  45705. if (s.type === "ExportNamedDeclaration" && s.declaration) {
  45706. recordType(s.declaration, types, declares);
  45707. } else {
  45708. recordType(s, types, declares);
  45709. }
  45710. }
  45711. }
  45712. } else {
  45713. recordType(stmt, types, declares);
  45714. }
  45715. }
  45716. if (!asGlobal) {
  45717. for (const stmt of body) {
  45718. if (stmt.type === "ExportNamedDeclaration") {
  45719. if (stmt.declaration) {
  45720. recordType(stmt.declaration, types, declares);
  45721. recordType(stmt.declaration, exportedTypes, exportedDeclares);
  45722. } else {
  45723. for (const spec of stmt.specifiers) {
  45724. if (spec.type === "ExportSpecifier") {
  45725. const local = spec.local.name;
  45726. const exported = getId(spec.exported);
  45727. if (stmt.source) {
  45728. imports[exported] = {
  45729. source: stmt.source.value,
  45730. imported: local
  45731. };
  45732. exportedTypes[exported] = {
  45733. type: "TSTypeReference",
  45734. typeName: {
  45735. type: "Identifier",
  45736. name: local
  45737. },
  45738. _ownerScope: scope
  45739. };
  45740. } else if (types[local]) {
  45741. exportedTypes[exported] = types[local];
  45742. }
  45743. }
  45744. }
  45745. }
  45746. } else if (stmt.type === "ExportAllDeclaration") {
  45747. const sourceScope = importSourceToScope(
  45748. ctx,
  45749. stmt.source,
  45750. scope,
  45751. stmt.source.value
  45752. );
  45753. Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
  45754. } else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
  45755. if (stmt.declaration.type !== "Identifier") {
  45756. recordType(stmt.declaration, types, declares, "default");
  45757. recordType(
  45758. stmt.declaration,
  45759. exportedTypes,
  45760. exportedDeclares,
  45761. "default"
  45762. );
  45763. } else if (types[stmt.declaration.name]) {
  45764. exportedTypes["default"] = types[stmt.declaration.name];
  45765. }
  45766. }
  45767. }
  45768. }
  45769. for (const key of Object.keys(types)) {
  45770. const node = types[key];
  45771. node._ownerScope = scope;
  45772. if (node._ns) node._ns._ownerScope = scope;
  45773. }
  45774. for (const key of Object.keys(declares)) {
  45775. declares[key]._ownerScope = scope;
  45776. }
  45777. }
  45778. function recordType(node, types, declares, overwriteId) {
  45779. switch (node.type) {
  45780. case "TSInterfaceDeclaration":
  45781. case "TSEnumDeclaration":
  45782. case "TSModuleDeclaration": {
  45783. const id = overwriteId || getId(node.id);
  45784. let existing = types[id];
  45785. if (existing) {
  45786. if (node.type === "TSModuleDeclaration") {
  45787. if (existing.type === "TSModuleDeclaration") {
  45788. mergeNamespaces(existing, node);
  45789. } else {
  45790. attachNamespace(existing, node);
  45791. }
  45792. break;
  45793. }
  45794. if (existing.type === "TSModuleDeclaration") {
  45795. types[id] = node;
  45796. attachNamespace(node, existing);
  45797. break;
  45798. }
  45799. if (existing.type !== node.type) {
  45800. break;
  45801. }
  45802. if (node.type === "TSInterfaceDeclaration") {
  45803. existing.body.body.push(...node.body.body);
  45804. } else {
  45805. existing.members.push(...node.members);
  45806. }
  45807. } else {
  45808. types[id] = node;
  45809. }
  45810. break;
  45811. }
  45812. case "ClassDeclaration":
  45813. if (overwriteId || node.id) types[overwriteId || getId(node.id)] = node;
  45814. break;
  45815. case "TSTypeAliasDeclaration":
  45816. types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
  45817. break;
  45818. case "TSDeclareFunction":
  45819. if (node.id) declares[node.id.name] = node;
  45820. break;
  45821. case "VariableDeclaration": {
  45822. if (node.declare) {
  45823. for (const decl of node.declarations) {
  45824. if (decl.id.type === "Identifier" && decl.id.typeAnnotation) {
  45825. declares[decl.id.name] = decl.id.typeAnnotation.typeAnnotation;
  45826. }
  45827. }
  45828. }
  45829. break;
  45830. }
  45831. }
  45832. }
  45833. function mergeNamespaces(to, from) {
  45834. const toBody = to.body;
  45835. const fromBody = from.body;
  45836. if (toBody.type === "TSModuleDeclaration") {
  45837. if (fromBody.type === "TSModuleDeclaration") {
  45838. mergeNamespaces(toBody, fromBody);
  45839. } else {
  45840. fromBody.body.push({
  45841. type: "ExportNamedDeclaration",
  45842. declaration: toBody,
  45843. exportKind: "type",
  45844. specifiers: []
  45845. });
  45846. }
  45847. } else if (fromBody.type === "TSModuleDeclaration") {
  45848. toBody.body.push({
  45849. type: "ExportNamedDeclaration",
  45850. declaration: fromBody,
  45851. exportKind: "type",
  45852. specifiers: []
  45853. });
  45854. } else {
  45855. toBody.body.push(...fromBody.body);
  45856. }
  45857. }
  45858. function attachNamespace(to, ns) {
  45859. if (!to._ns) {
  45860. to._ns = ns;
  45861. } else {
  45862. mergeNamespaces(to._ns, ns);
  45863. }
  45864. }
  45865. function recordImports(body) {
  45866. const imports = /* @__PURE__ */ Object.create(null);
  45867. for (const s of body) {
  45868. recordImport(s, imports);
  45869. }
  45870. return imports;
  45871. }
  45872. function recordImport(node, imports) {
  45873. if (node.type !== "ImportDeclaration") {
  45874. return;
  45875. }
  45876. for (const s of node.specifiers) {
  45877. imports[s.local.name] = {
  45878. imported: getImportedName(s),
  45879. source: node.source.value
  45880. };
  45881. }
  45882. }
  45883. function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false, typeParameters) {
  45884. if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  45885. return [UNKNOWN_TYPE];
  45886. }
  45887. try {
  45888. switch (node.type) {
  45889. case "TSStringKeyword":
  45890. return ["String"];
  45891. case "TSNumberKeyword":
  45892. return ["Number"];
  45893. case "TSBooleanKeyword":
  45894. return ["Boolean"];
  45895. case "TSObjectKeyword":
  45896. return ["Object"];
  45897. case "TSNullKeyword":
  45898. return ["null"];
  45899. case "TSTypeLiteral":
  45900. case "TSInterfaceDeclaration": {
  45901. const types = /* @__PURE__ */ new Set();
  45902. const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
  45903. for (const m of members) {
  45904. if (isKeyOf) {
  45905. if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
  45906. types.add("Number");
  45907. } else if (m.type === "TSIndexSignature") {
  45908. const annotation = m.parameters[0].typeAnnotation;
  45909. if (annotation && annotation.type !== "Noop") {
  45910. const type = inferRuntimeType(
  45911. ctx,
  45912. annotation.typeAnnotation,
  45913. scope
  45914. )[0];
  45915. if (type === UNKNOWN_TYPE) return [UNKNOWN_TYPE];
  45916. types.add(type);
  45917. }
  45918. } else {
  45919. types.add("String");
  45920. }
  45921. } else if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
  45922. types.add("Function");
  45923. } else {
  45924. types.add("Object");
  45925. }
  45926. }
  45927. return types.size ? Array.from(types) : [isKeyOf ? UNKNOWN_TYPE : "Object"];
  45928. }
  45929. case "TSPropertySignature":
  45930. if (node.typeAnnotation) {
  45931. return inferRuntimeType(
  45932. ctx,
  45933. node.typeAnnotation.typeAnnotation,
  45934. scope
  45935. );
  45936. }
  45937. break;
  45938. case "TSMethodSignature":
  45939. case "TSFunctionType":
  45940. return ["Function"];
  45941. case "TSArrayType":
  45942. case "TSTupleType":
  45943. return ["Array"];
  45944. case "TSLiteralType":
  45945. switch (node.literal.type) {
  45946. case "StringLiteral":
  45947. return ["String"];
  45948. case "BooleanLiteral":
  45949. return ["Boolean"];
  45950. case "NumericLiteral":
  45951. case "BigIntLiteral":
  45952. return ["Number"];
  45953. default:
  45954. return [UNKNOWN_TYPE];
  45955. }
  45956. case "TSTypeReference": {
  45957. const resolved = resolveTypeReference(ctx, node, scope);
  45958. if (resolved) {
  45959. if (resolved.type === "TSTypeAliasDeclaration") {
  45960. if (resolved.typeAnnotation.type === "TSFunctionType") {
  45961. return ["Function"];
  45962. }
  45963. if (node.typeParameters) {
  45964. const typeParams = /* @__PURE__ */ Object.create(null);
  45965. if (resolved.typeParameters) {
  45966. resolved.typeParameters.params.forEach((p, i) => {
  45967. typeParams[p.name] = node.typeParameters.params[i];
  45968. });
  45969. }
  45970. return inferRuntimeType(
  45971. ctx,
  45972. resolved.typeAnnotation,
  45973. resolved._ownerScope,
  45974. isKeyOf,
  45975. typeParams
  45976. );
  45977. }
  45978. }
  45979. return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
  45980. }
  45981. if (node.typeName.type === "Identifier") {
  45982. if (typeParameters && typeParameters[node.typeName.name]) {
  45983. return inferRuntimeType(
  45984. ctx,
  45985. typeParameters[node.typeName.name],
  45986. scope,
  45987. isKeyOf,
  45988. typeParameters
  45989. );
  45990. }
  45991. if (isKeyOf) {
  45992. switch (node.typeName.name) {
  45993. case "String":
  45994. case "Array":
  45995. case "ArrayLike":
  45996. case "Parameters":
  45997. case "ConstructorParameters":
  45998. case "ReadonlyArray":
  45999. return ["String", "Number"];
  46000. // TS built-in utility types
  46001. case "Record":
  46002. case "Partial":
  46003. case "Required":
  46004. case "Readonly":
  46005. if (node.typeParameters && node.typeParameters.params[0]) {
  46006. return inferRuntimeType(
  46007. ctx,
  46008. node.typeParameters.params[0],
  46009. scope,
  46010. true
  46011. );
  46012. }
  46013. break;
  46014. case "Pick":
  46015. case "Extract":
  46016. if (node.typeParameters && node.typeParameters.params[1]) {
  46017. return inferRuntimeType(
  46018. ctx,
  46019. node.typeParameters.params[1],
  46020. scope
  46021. );
  46022. }
  46023. break;
  46024. case "Function":
  46025. case "Object":
  46026. case "Set":
  46027. case "Map":
  46028. case "WeakSet":
  46029. case "WeakMap":
  46030. case "Date":
  46031. case "Promise":
  46032. case "Error":
  46033. case "Uppercase":
  46034. case "Lowercase":
  46035. case "Capitalize":
  46036. case "Uncapitalize":
  46037. case "ReadonlyMap":
  46038. case "ReadonlySet":
  46039. return ["String"];
  46040. }
  46041. } else {
  46042. switch (node.typeName.name) {
  46043. case "Array":
  46044. case "Function":
  46045. case "Object":
  46046. case "Set":
  46047. case "Map":
  46048. case "WeakSet":
  46049. case "WeakMap":
  46050. case "Date":
  46051. case "Promise":
  46052. case "Error":
  46053. return [node.typeName.name];
  46054. // TS built-in utility types
  46055. // https://www.typescriptlang.org/docs/handbook/utility-types.html
  46056. case "Partial":
  46057. case "Required":
  46058. case "Readonly":
  46059. case "Record":
  46060. case "Pick":
  46061. case "Omit":
  46062. case "InstanceType":
  46063. return ["Object"];
  46064. case "Uppercase":
  46065. case "Lowercase":
  46066. case "Capitalize":
  46067. case "Uncapitalize":
  46068. return ["String"];
  46069. case "Parameters":
  46070. case "ConstructorParameters":
  46071. case "ReadonlyArray":
  46072. return ["Array"];
  46073. case "ReadonlyMap":
  46074. return ["Map"];
  46075. case "ReadonlySet":
  46076. return ["Set"];
  46077. case "NonNullable":
  46078. if (node.typeParameters && node.typeParameters.params[0]) {
  46079. return inferRuntimeType(
  46080. ctx,
  46081. node.typeParameters.params[0],
  46082. scope
  46083. ).filter((t) => t !== "null");
  46084. }
  46085. break;
  46086. case "Extract":
  46087. if (node.typeParameters && node.typeParameters.params[1]) {
  46088. return inferRuntimeType(
  46089. ctx,
  46090. node.typeParameters.params[1],
  46091. scope
  46092. );
  46093. }
  46094. break;
  46095. case "Exclude":
  46096. case "OmitThisParameter":
  46097. if (node.typeParameters && node.typeParameters.params[0]) {
  46098. return inferRuntimeType(
  46099. ctx,
  46100. node.typeParameters.params[0],
  46101. scope
  46102. );
  46103. }
  46104. break;
  46105. }
  46106. }
  46107. }
  46108. break;
  46109. }
  46110. case "TSParenthesizedType":
  46111. return inferRuntimeType(ctx, node.typeAnnotation, scope);
  46112. case "TSUnionType":
  46113. return flattenTypes(ctx, node.types, scope, isKeyOf, typeParameters);
  46114. case "TSIntersectionType": {
  46115. return flattenTypes(
  46116. ctx,
  46117. node.types,
  46118. scope,
  46119. isKeyOf,
  46120. typeParameters
  46121. ).filter((t) => t !== UNKNOWN_TYPE);
  46122. }
  46123. case "TSMappedType": {
  46124. const { typeAnnotation, typeParameter } = node;
  46125. if (typeAnnotation && typeAnnotation.type === "TSIndexedAccessType" && typeParameter && typeParameter.constraint && typeParameters) {
  46126. const constraint = typeParameter.constraint;
  46127. if (constraint.type === "TSTypeOperator" && constraint.operator === "keyof" && constraint.typeAnnotation && constraint.typeAnnotation.type === "TSTypeReference" && constraint.typeAnnotation.typeName.type === "Identifier") {
  46128. const typeName = constraint.typeAnnotation.typeName.name;
  46129. const index = typeAnnotation.indexType;
  46130. const obj = typeAnnotation.objectType;
  46131. if (obj && obj.type === "TSTypeReference" && obj.typeName.type === "Identifier" && obj.typeName.name === typeName && index && index.type === "TSTypeReference" && index.typeName.type === "Identifier" && index.typeName.name === typeParameter.name) {
  46132. const targetType = typeParameters[typeName];
  46133. if (targetType) {
  46134. return inferRuntimeType(ctx, targetType, scope);
  46135. }
  46136. }
  46137. }
  46138. }
  46139. return [UNKNOWN_TYPE];
  46140. }
  46141. case "TSEnumDeclaration":
  46142. return inferEnumType(node);
  46143. case "TSSymbolKeyword":
  46144. return ["Symbol"];
  46145. case "TSIndexedAccessType": {
  46146. const types = resolveIndexType(ctx, node, scope);
  46147. return flattenTypes(ctx, types, scope, isKeyOf);
  46148. }
  46149. case "ClassDeclaration":
  46150. return ["Object"];
  46151. case "TSImportType": {
  46152. const sourceScope = importSourceToScope(
  46153. ctx,
  46154. node.argument,
  46155. scope,
  46156. node.argument.value
  46157. );
  46158. const resolved = resolveTypeReference(ctx, node, sourceScope);
  46159. if (resolved) {
  46160. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  46161. }
  46162. break;
  46163. }
  46164. case "TSTypeQuery": {
  46165. const id = node.exprName;
  46166. if (id.type === "Identifier") {
  46167. const matched = scope.declares[id.name];
  46168. if (matched) {
  46169. return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf);
  46170. }
  46171. }
  46172. break;
  46173. }
  46174. // e.g. readonly
  46175. case "TSTypeOperator": {
  46176. return inferRuntimeType(
  46177. ctx,
  46178. node.typeAnnotation,
  46179. scope,
  46180. node.operator === "keyof"
  46181. );
  46182. }
  46183. case "TSAnyKeyword": {
  46184. if (isKeyOf) {
  46185. return ["String", "Number", "Symbol"];
  46186. }
  46187. break;
  46188. }
  46189. }
  46190. } catch (e) {
  46191. }
  46192. return [UNKNOWN_TYPE];
  46193. }
  46194. function flattenTypes(ctx, types, scope, isKeyOf = false, typeParameters = void 0) {
  46195. if (types.length === 1) {
  46196. return inferRuntimeType(ctx, types[0], scope, isKeyOf, typeParameters);
  46197. }
  46198. return [
  46199. ...new Set(
  46200. [].concat(
  46201. ...types.map(
  46202. (t) => inferRuntimeType(ctx, t, scope, isKeyOf, typeParameters)
  46203. )
  46204. )
  46205. )
  46206. ];
  46207. }
  46208. function inferEnumType(node) {
  46209. const types = /* @__PURE__ */ new Set();
  46210. for (const m of node.members) {
  46211. if (m.initializer) {
  46212. switch (m.initializer.type) {
  46213. case "StringLiteral":
  46214. types.add("String");
  46215. break;
  46216. case "NumericLiteral":
  46217. types.add("Number");
  46218. break;
  46219. }
  46220. }
  46221. }
  46222. return types.size ? [...types] : ["Number"];
  46223. }
  46224. function resolveExtractPropTypes({ props }, scope) {
  46225. const res = { props: {} };
  46226. for (const key in props) {
  46227. const raw = props[key];
  46228. res.props[key] = reverseInferType(
  46229. raw.key,
  46230. raw.typeAnnotation.typeAnnotation,
  46231. scope
  46232. );
  46233. }
  46234. return res;
  46235. }
  46236. function reverseInferType(key, node, scope, optional = true, checkObjectSyntax = true) {
  46237. if (checkObjectSyntax && node.type === "TSTypeLiteral") {
  46238. const typeType = findStaticPropertyType(node, "type");
  46239. if (typeType) {
  46240. const requiredType = findStaticPropertyType(node, "required");
  46241. const optional2 = requiredType && requiredType.type === "TSLiteralType" && requiredType.literal.type === "BooleanLiteral" ? !requiredType.literal.value : true;
  46242. return reverseInferType(key, typeType, scope, optional2, false);
  46243. }
  46244. } else if (node.type === "TSTypeReference" && node.typeName.type === "Identifier") {
  46245. if (node.typeName.name.endsWith("Constructor")) {
  46246. return createProperty(
  46247. key,
  46248. ctorToType(node.typeName.name),
  46249. scope,
  46250. optional
  46251. );
  46252. } else if (node.typeName.name === "PropType" && node.typeParameters) {
  46253. return createProperty(key, node.typeParameters.params[0], scope, optional);
  46254. }
  46255. }
  46256. if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
  46257. for (const t of node.typeParameters.params) {
  46258. const inferred = reverseInferType(key, t, scope, optional);
  46259. if (inferred) return inferred;
  46260. }
  46261. }
  46262. return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
  46263. }
  46264. function ctorToType(ctorType) {
  46265. const ctor = ctorType.slice(0, -11);
  46266. switch (ctor) {
  46267. case "String":
  46268. case "Number":
  46269. case "Boolean":
  46270. return { type: `TS${ctor}Keyword` };
  46271. case "Array":
  46272. case "Function":
  46273. case "Object":
  46274. case "Set":
  46275. case "Map":
  46276. case "WeakSet":
  46277. case "WeakMap":
  46278. case "Date":
  46279. case "Promise":
  46280. return {
  46281. type: "TSTypeReference",
  46282. typeName: { type: "Identifier", name: ctor }
  46283. };
  46284. }
  46285. return { type: `TSNullKeyword` };
  46286. }
  46287. function findStaticPropertyType(node, key) {
  46288. const prop = node.members.find(
  46289. (m) => m.type === "TSPropertySignature" && !m.computed && getId(m.key) === key && m.typeAnnotation
  46290. );
  46291. return prop && prop.typeAnnotation.typeAnnotation;
  46292. }
  46293. function resolveReturnType(ctx, arg, scope) {
  46294. var _a;
  46295. let resolved = arg;
  46296. if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
  46297. resolved = resolveTypeReference(ctx, arg, scope);
  46298. }
  46299. if (!resolved) return;
  46300. if (resolved.type === "TSFunctionType") {
  46301. return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
  46302. }
  46303. if (resolved.type === "TSDeclareFunction") {
  46304. return resolved.returnType;
  46305. }
  46306. }
  46307. function resolveUnionType(ctx, node, scope) {
  46308. if (node.type === "TSTypeReference") {
  46309. const resolved = resolveTypeReference(ctx, node, scope);
  46310. if (resolved) node = resolved;
  46311. }
  46312. let types;
  46313. if (node.type === "TSUnionType") {
  46314. types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
  46315. } else {
  46316. types = [node];
  46317. }
  46318. return types;
  46319. }
  46320. const DEFINE_MODEL = "defineModel";
  46321. function processDefineModel(ctx, node, declId) {
  46322. if (!isCallOf(node, DEFINE_MODEL)) {
  46323. return false;
  46324. }
  46325. ctx.hasDefineModelCall = true;
  46326. const type = node.typeParameters && node.typeParameters.params[0] || void 0;
  46327. let modelName;
  46328. let options;
  46329. const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
  46330. const hasName = arg0 && arg0.type === "StringLiteral";
  46331. if (hasName) {
  46332. modelName = arg0.value;
  46333. options = node.arguments[1];
  46334. } else {
  46335. modelName = "modelValue";
  46336. options = arg0;
  46337. }
  46338. if (ctx.modelDecls[modelName]) {
  46339. ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
  46340. }
  46341. let optionsString = options && ctx.getString(options);
  46342. let optionsRemoved = !options;
  46343. const runtimeOptionNodes = [];
  46344. if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
  46345. let removed = 0;
  46346. for (let i = options.properties.length - 1; i >= 0; i--) {
  46347. const p = options.properties[i];
  46348. const next = options.properties[i + 1];
  46349. const start = p.start;
  46350. const end = next ? next.start : options.end - 1;
  46351. if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
  46352. optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
  46353. } else {
  46354. removed++;
  46355. ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
  46356. runtimeOptionNodes.push(p);
  46357. }
  46358. }
  46359. if (removed === options.properties.length) {
  46360. optionsRemoved = true;
  46361. ctx.s.remove(
  46362. ctx.startOffset + (hasName ? arg0.end : options.start),
  46363. ctx.startOffset + options.end
  46364. );
  46365. }
  46366. }
  46367. ctx.modelDecls[modelName] = {
  46368. type,
  46369. options: optionsString,
  46370. runtimeOptionNodes,
  46371. identifier: declId && declId.type === "Identifier" ? declId.name : void 0
  46372. };
  46373. ctx.bindingMetadata[modelName] = "props";
  46374. ctx.s.overwrite(
  46375. ctx.startOffset + node.callee.start,
  46376. ctx.startOffset + node.callee.end,
  46377. ctx.helper("useModel")
  46378. );
  46379. ctx.s.appendLeft(
  46380. ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
  46381. `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
  46382. );
  46383. return true;
  46384. }
  46385. function genModelProps(ctx) {
  46386. if (!ctx.hasDefineModelCall) return;
  46387. const isProd = !!ctx.options.isProd;
  46388. let modelPropsDecl = "";
  46389. for (const [name, { type, options: runtimeOptions }] of Object.entries(
  46390. ctx.modelDecls
  46391. )) {
  46392. let skipCheck = false;
  46393. let codegenOptions = ``;
  46394. let runtimeTypes = type && inferRuntimeType(ctx, type);
  46395. if (runtimeTypes) {
  46396. const hasBoolean = runtimeTypes.includes("Boolean");
  46397. const hasFunction = runtimeTypes.includes("Function");
  46398. const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
  46399. if (hasUnknownType) {
  46400. if (hasBoolean || hasFunction) {
  46401. runtimeTypes = runtimeTypes.filter((t) => t !== UNKNOWN_TYPE);
  46402. skipCheck = true;
  46403. } else {
  46404. runtimeTypes = ["null"];
  46405. }
  46406. }
  46407. if (!isProd) {
  46408. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}` + (skipCheck ? ", skipCheck: true" : "");
  46409. } else if (hasBoolean || runtimeOptions && hasFunction) {
  46410. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`;
  46411. } else ;
  46412. }
  46413. let decl;
  46414. if (codegenOptions && runtimeOptions) {
  46415. decl = ctx.isTS ? `{ ${codegenOptions}, ...${runtimeOptions} }` : `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`;
  46416. } else if (codegenOptions) {
  46417. decl = `{ ${codegenOptions} }`;
  46418. } else if (runtimeOptions) {
  46419. decl = runtimeOptions;
  46420. } else {
  46421. decl = `{}`;
  46422. }
  46423. modelPropsDecl += `
  46424. ${JSON.stringify(name)}: ${decl},`;
  46425. const modifierPropName = JSON.stringify(
  46426. name === "modelValue" ? `modelModifiers` : `${name}Modifiers`
  46427. );
  46428. modelPropsDecl += `
  46429. ${modifierPropName}: {},`;
  46430. }
  46431. return `{${modelPropsDecl}
  46432. }`;
  46433. }
  46434. const DEFINE_PROPS = "defineProps";
  46435. const WITH_DEFAULTS = "withDefaults";
  46436. function processDefineProps(ctx, node, declId, isWithDefaults = false) {
  46437. if (!isCallOf(node, DEFINE_PROPS)) {
  46438. return processWithDefaults(ctx, node, declId);
  46439. }
  46440. if (ctx.hasDefinePropsCall) {
  46441. ctx.error(`duplicate ${DEFINE_PROPS}() call`, node);
  46442. }
  46443. ctx.hasDefinePropsCall = true;
  46444. ctx.propsRuntimeDecl = node.arguments[0];
  46445. if (ctx.propsRuntimeDecl) {
  46446. for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
  46447. if (!(key in ctx.bindingMetadata)) {
  46448. ctx.bindingMetadata[key] = "props";
  46449. }
  46450. }
  46451. }
  46452. if (node.typeParameters) {
  46453. if (ctx.propsRuntimeDecl) {
  46454. ctx.error(
  46455. `${DEFINE_PROPS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  46456. node
  46457. );
  46458. }
  46459. ctx.propsTypeDecl = node.typeParameters.params[0];
  46460. }
  46461. if (!isWithDefaults && declId && declId.type === "ObjectPattern") {
  46462. processPropsDestructure(ctx, declId);
  46463. }
  46464. ctx.propsCall = node;
  46465. ctx.propsDecl = declId;
  46466. return true;
  46467. }
  46468. function processWithDefaults(ctx, node, declId) {
  46469. if (!isCallOf(node, WITH_DEFAULTS)) {
  46470. return false;
  46471. }
  46472. if (!processDefineProps(
  46473. ctx,
  46474. node.arguments[0],
  46475. declId,
  46476. true
  46477. )) {
  46478. ctx.error(
  46479. `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
  46480. node.arguments[0] || node
  46481. );
  46482. }
  46483. if (ctx.propsRuntimeDecl) {
  46484. ctx.error(
  46485. `${WITH_DEFAULTS} can only be used with type-based ${DEFINE_PROPS} declaration.`,
  46486. node
  46487. );
  46488. }
  46489. if (declId && declId.type === "ObjectPattern") {
  46490. ctx.warn(
  46491. `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
  46492. Reactive destructure will be disabled when using withDefaults().
  46493. Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...). `,
  46494. node.callee
  46495. );
  46496. }
  46497. ctx.propsRuntimeDefaults = node.arguments[1];
  46498. if (!ctx.propsRuntimeDefaults) {
  46499. ctx.error(`The 2nd argument of ${WITH_DEFAULTS} is required.`, node);
  46500. }
  46501. ctx.propsCall = node;
  46502. return true;
  46503. }
  46504. function genRuntimeProps(ctx) {
  46505. let propsDecls;
  46506. if (ctx.propsRuntimeDecl) {
  46507. propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim();
  46508. if (ctx.propsDestructureDecl) {
  46509. const defaults = [];
  46510. for (const key in ctx.propsDestructuredBindings) {
  46511. const d = genDestructuredDefaultValue(ctx, key);
  46512. const finalKey = getEscapedPropName(key);
  46513. if (d)
  46514. defaults.push(
  46515. `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
  46516. );
  46517. }
  46518. if (defaults.length) {
  46519. propsDecls = `/*@__PURE__*/${ctx.helper(
  46520. `mergeDefaults`
  46521. )}(${propsDecls}, {
  46522. ${defaults.join(",\n ")}
  46523. })`;
  46524. }
  46525. }
  46526. } else if (ctx.propsTypeDecl) {
  46527. propsDecls = extractRuntimeProps(ctx);
  46528. }
  46529. const modelsDecls = genModelProps(ctx);
  46530. if (propsDecls && modelsDecls) {
  46531. return `/*@__PURE__*/${ctx.helper(
  46532. "mergeModels"
  46533. )}(${propsDecls}, ${modelsDecls})`;
  46534. } else {
  46535. return modelsDecls || propsDecls;
  46536. }
  46537. }
  46538. function extractRuntimeProps(ctx) {
  46539. const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
  46540. if (!props.length) {
  46541. return;
  46542. }
  46543. const propStrings = [];
  46544. const hasStaticDefaults = hasStaticWithDefaults(ctx);
  46545. for (const prop of props) {
  46546. propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
  46547. if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
  46548. ctx.bindingMetadata[prop.key] = "props";
  46549. }
  46550. }
  46551. let propsDecls = `{
  46552. ${propStrings.join(",\n ")}
  46553. }`;
  46554. if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
  46555. propsDecls = `/*@__PURE__*/${ctx.helper(
  46556. "mergeDefaults"
  46557. )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
  46558. }
  46559. return propsDecls;
  46560. }
  46561. function resolveRuntimePropsFromType(ctx, node) {
  46562. const props = [];
  46563. const elements = resolveTypeElements(ctx, node);
  46564. for (const key in elements.props) {
  46565. const e = elements.props[key];
  46566. let type = inferRuntimeType(ctx, e);
  46567. let skipCheck = false;
  46568. if (type.includes(UNKNOWN_TYPE)) {
  46569. if (type.includes("Boolean") || type.includes("Function")) {
  46570. type = type.filter((t) => t !== UNKNOWN_TYPE);
  46571. skipCheck = true;
  46572. } else {
  46573. type = ["null"];
  46574. }
  46575. }
  46576. props.push({
  46577. key,
  46578. required: !e.optional,
  46579. type: type || [`null`],
  46580. skipCheck
  46581. });
  46582. }
  46583. return props;
  46584. }
  46585. function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStaticDefaults) {
  46586. let defaultString;
  46587. const destructured = genDestructuredDefaultValue(ctx, key, type);
  46588. if (destructured) {
  46589. defaultString = `default: ${destructured.valueString}${destructured.needSkipFactory ? `, skipFactory: true` : ``}`;
  46590. } else if (hasStaticDefaults) {
  46591. const prop = ctx.propsRuntimeDefaults.properties.find(
  46592. (node) => {
  46593. if (node.type === "SpreadElement") return false;
  46594. return resolveObjectKey(node.key, node.computed) === key;
  46595. }
  46596. );
  46597. if (prop) {
  46598. if (prop.type === "ObjectProperty") {
  46599. defaultString = `default: ${ctx.getString(prop.value)}`;
  46600. } else {
  46601. defaultString = `${prop.async ? "async " : ""}${prop.kind !== "method" ? `${prop.kind} ` : ""}default() ${ctx.getString(prop.body)}`;
  46602. }
  46603. }
  46604. }
  46605. const finalKey = getEscapedPropName(key);
  46606. if (!ctx.options.isProd) {
  46607. return `${finalKey}: { ${concatStrings([
  46608. `type: ${toRuntimeTypeString(type)}`,
  46609. `required: ${required}`,
  46610. skipCheck && "skipCheck: true",
  46611. defaultString
  46612. ])} }`;
  46613. } else if (type.some(
  46614. (el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
  46615. )) {
  46616. return `${finalKey}: { ${concatStrings([
  46617. `type: ${toRuntimeTypeString(type)}`,
  46618. defaultString
  46619. ])} }`;
  46620. } else {
  46621. if (ctx.isCE) {
  46622. if (defaultString) {
  46623. return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
  46624. type
  46625. )} }`}`;
  46626. } else {
  46627. return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
  46628. }
  46629. }
  46630. return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
  46631. }
  46632. }
  46633. function hasStaticWithDefaults(ctx) {
  46634. return !!(ctx.propsRuntimeDefaults && ctx.propsRuntimeDefaults.type === "ObjectExpression" && ctx.propsRuntimeDefaults.properties.every(
  46635. (node) => node.type !== "SpreadElement" && (!node.computed || node.key.type.endsWith("Literal"))
  46636. ));
  46637. }
  46638. function genDestructuredDefaultValue(ctx, key, inferredType) {
  46639. const destructured = ctx.propsDestructuredBindings[key];
  46640. const defaultVal = destructured && destructured.default;
  46641. if (defaultVal) {
  46642. const value = ctx.getString(defaultVal);
  46643. const unwrapped = unwrapTSNode(defaultVal);
  46644. if (inferredType && inferredType.length && !inferredType.includes("null")) {
  46645. const valueType = inferValueType(unwrapped);
  46646. if (valueType && !inferredType.includes(valueType)) {
  46647. ctx.error(
  46648. `Default value of prop "${key}" does not match declared type.`,
  46649. unwrapped
  46650. );
  46651. }
  46652. }
  46653. const needSkipFactory = !inferredType && (isFunctionType(unwrapped) || unwrapped.type === "Identifier");
  46654. const needFactoryWrap = !needSkipFactory && !isLiteralNode(unwrapped) && !(inferredType == null ? void 0 : inferredType.includes("Function"));
  46655. return {
  46656. valueString: needFactoryWrap ? `() => (${value})` : value,
  46657. needSkipFactory
  46658. };
  46659. }
  46660. }
  46661. function inferValueType(node) {
  46662. switch (node.type) {
  46663. case "StringLiteral":
  46664. return "String";
  46665. case "NumericLiteral":
  46666. return "Number";
  46667. case "BooleanLiteral":
  46668. return "Boolean";
  46669. case "ObjectExpression":
  46670. return "Object";
  46671. case "ArrayExpression":
  46672. return "Array";
  46673. case "FunctionExpression":
  46674. case "ArrowFunctionExpression":
  46675. return "Function";
  46676. }
  46677. }
  46678. function processPropsDestructure(ctx, declId) {
  46679. if (ctx.options.propsDestructure === "error") {
  46680. ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
  46681. } else if (ctx.options.propsDestructure === false) {
  46682. return;
  46683. }
  46684. ctx.propsDestructureDecl = declId;
  46685. const registerBinding = (key, local, defaultValue) => {
  46686. ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
  46687. if (local !== key) {
  46688. ctx.bindingMetadata[local] = "props-aliased";
  46689. (ctx.bindingMetadata.__propsAliases || (ctx.bindingMetadata.__propsAliases = {}))[local] = key;
  46690. }
  46691. };
  46692. for (const prop of declId.properties) {
  46693. if (prop.type === "ObjectProperty") {
  46694. const propKey = resolveObjectKey(prop.key, prop.computed);
  46695. if (!propKey) {
  46696. ctx.error(
  46697. `${DEFINE_PROPS}() destructure cannot use computed key.`,
  46698. prop.key
  46699. );
  46700. }
  46701. if (prop.value.type === "AssignmentPattern") {
  46702. const { left, right } = prop.value;
  46703. if (left.type !== "Identifier") {
  46704. ctx.error(
  46705. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  46706. left
  46707. );
  46708. }
  46709. registerBinding(propKey, left.name, right);
  46710. } else if (prop.value.type === "Identifier") {
  46711. registerBinding(propKey, prop.value.name);
  46712. } else {
  46713. ctx.error(
  46714. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  46715. prop.value
  46716. );
  46717. }
  46718. } else {
  46719. ctx.propsDestructureRestId = prop.argument.name;
  46720. ctx.bindingMetadata[ctx.propsDestructureRestId] = "setup-reactive-const";
  46721. }
  46722. }
  46723. }
  46724. function transformDestructuredProps(ctx, vueImportAliases) {
  46725. if (ctx.options.propsDestructure === false) {
  46726. return;
  46727. }
  46728. const rootScope = /* @__PURE__ */ Object.create(null);
  46729. const scopeStack = [rootScope];
  46730. let currentScope = rootScope;
  46731. const excludedIds = /* @__PURE__ */ new WeakSet();
  46732. const parentStack = [];
  46733. const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
  46734. for (const key in ctx.propsDestructuredBindings) {
  46735. const { local } = ctx.propsDestructuredBindings[key];
  46736. rootScope[local] = true;
  46737. propsLocalToPublicMap[local] = key;
  46738. }
  46739. function pushScope() {
  46740. scopeStack.push(currentScope = Object.create(currentScope));
  46741. }
  46742. function popScope() {
  46743. scopeStack.pop();
  46744. currentScope = scopeStack[scopeStack.length - 1] || null;
  46745. }
  46746. function registerLocalBinding(id) {
  46747. excludedIds.add(id);
  46748. if (currentScope) {
  46749. currentScope[id.name] = false;
  46750. } else {
  46751. ctx.error(
  46752. "registerBinding called without active scope, something is wrong.",
  46753. id
  46754. );
  46755. }
  46756. }
  46757. function walkScope(node, isRoot = false) {
  46758. for (const stmt of node.body) {
  46759. if (stmt.type === "VariableDeclaration") {
  46760. walkVariableDeclaration(stmt, isRoot);
  46761. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  46762. if (stmt.declare || !stmt.id) continue;
  46763. registerLocalBinding(stmt.id);
  46764. } else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
  46765. walkVariableDeclaration(stmt.left);
  46766. } else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration && stmt.declaration.type === "VariableDeclaration") {
  46767. walkVariableDeclaration(stmt.declaration, isRoot);
  46768. } else if (stmt.type === "LabeledStatement" && stmt.body.type === "VariableDeclaration") {
  46769. walkVariableDeclaration(stmt.body, isRoot);
  46770. }
  46771. }
  46772. }
  46773. function walkVariableDeclaration(stmt, isRoot = false) {
  46774. if (stmt.declare) {
  46775. return;
  46776. }
  46777. for (const decl of stmt.declarations) {
  46778. const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
  46779. for (const id of extractIdentifiers$1(decl.id)) {
  46780. if (isDefineProps) {
  46781. excludedIds.add(id);
  46782. } else {
  46783. registerLocalBinding(id);
  46784. }
  46785. }
  46786. }
  46787. }
  46788. function rewriteId(id, parent, parentStack2) {
  46789. if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
  46790. ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
  46791. }
  46792. if (isStaticProperty(parent) && parent.shorthand) {
  46793. if (!parent.inPattern || isInDestructureAssignment(parent, parentStack2)) {
  46794. ctx.s.appendLeft(
  46795. id.end + ctx.startOffset,
  46796. `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
  46797. );
  46798. }
  46799. } else {
  46800. ctx.s.overwrite(
  46801. id.start + ctx.startOffset,
  46802. id.end + ctx.startOffset,
  46803. genPropsAccessExp(propsLocalToPublicMap[id.name])
  46804. );
  46805. }
  46806. }
  46807. function checkUsage(node, method, alias = method) {
  46808. if (isCallOf(node, alias)) {
  46809. const arg = unwrapTSNode(node.arguments[0]);
  46810. if (arg.type === "Identifier" && currentScope[arg.name]) {
  46811. ctx.error(
  46812. `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). Pass a getter () => ${arg.name} instead.`,
  46813. arg
  46814. );
  46815. }
  46816. }
  46817. }
  46818. const ast = ctx.scriptSetupAst;
  46819. walkScope(ast, true);
  46820. walk$2(ast, {
  46821. enter(node, parent) {
  46822. parent && parentStack.push(parent);
  46823. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  46824. return this.skip();
  46825. }
  46826. checkUsage(node, "watch", vueImportAliases.watch);
  46827. checkUsage(node, "toRef", vueImportAliases.toRef);
  46828. if (isFunctionType(node)) {
  46829. pushScope();
  46830. walkFunctionParams(node, registerLocalBinding);
  46831. if (node.body.type === "BlockStatement") {
  46832. walkScope(node.body);
  46833. }
  46834. return;
  46835. }
  46836. if (node.type === "CatchClause") {
  46837. pushScope();
  46838. if (node.param && node.param.type === "Identifier") {
  46839. registerLocalBinding(node.param);
  46840. }
  46841. walkScope(node.body);
  46842. return;
  46843. }
  46844. if (node.type === "BlockStatement" && !isFunctionType(parent)) {
  46845. pushScope();
  46846. walkScope(node);
  46847. return;
  46848. }
  46849. if (node.type === "Identifier") {
  46850. if (isReferencedIdentifier(node, parent, parentStack) && !excludedIds.has(node)) {
  46851. if (currentScope[node.name]) {
  46852. rewriteId(node, parent, parentStack);
  46853. }
  46854. }
  46855. }
  46856. },
  46857. leave(node, parent) {
  46858. parent && parentStack.pop();
  46859. if (node.type === "BlockStatement" && !isFunctionType(parent) || isFunctionType(node) || node.type === "CatchClause") {
  46860. popScope();
  46861. }
  46862. }
  46863. });
  46864. }
  46865. const DEFINE_EMITS = "defineEmits";
  46866. function processDefineEmits(ctx, node, declId) {
  46867. if (!isCallOf(node, DEFINE_EMITS)) {
  46868. return false;
  46869. }
  46870. if (ctx.hasDefineEmitCall) {
  46871. ctx.error(`duplicate ${DEFINE_EMITS}() call`, node);
  46872. }
  46873. ctx.hasDefineEmitCall = true;
  46874. ctx.emitsRuntimeDecl = node.arguments[0];
  46875. if (node.typeParameters) {
  46876. if (ctx.emitsRuntimeDecl) {
  46877. ctx.error(
  46878. `${DEFINE_EMITS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  46879. node
  46880. );
  46881. }
  46882. ctx.emitsTypeDecl = node.typeParameters.params[0];
  46883. }
  46884. ctx.emitDecl = declId;
  46885. return true;
  46886. }
  46887. function genRuntimeEmits(ctx) {
  46888. let emitsDecl = "";
  46889. if (ctx.emitsRuntimeDecl) {
  46890. emitsDecl = ctx.getString(ctx.emitsRuntimeDecl).trim();
  46891. } else if (ctx.emitsTypeDecl) {
  46892. const typeDeclaredEmits = extractRuntimeEmits(ctx);
  46893. emitsDecl = typeDeclaredEmits.size ? `[${Array.from(typeDeclaredEmits).map((k) => JSON.stringify(k)).join(", ")}]` : ``;
  46894. }
  46895. if (ctx.hasDefineModelCall) {
  46896. let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
  46897. emitsDecl = emitsDecl ? `/*@__PURE__*/${ctx.helper(
  46898. "mergeModels"
  46899. )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
  46900. }
  46901. return emitsDecl;
  46902. }
  46903. function extractRuntimeEmits(ctx) {
  46904. const emits = /* @__PURE__ */ new Set();
  46905. const node = ctx.emitsTypeDecl;
  46906. if (node.type === "TSFunctionType") {
  46907. extractEventNames(ctx, node.parameters[0], emits);
  46908. return emits;
  46909. }
  46910. const { props, calls } = resolveTypeElements(ctx, node);
  46911. let hasProperty = false;
  46912. for (const key in props) {
  46913. emits.add(key);
  46914. hasProperty = true;
  46915. }
  46916. if (calls) {
  46917. if (hasProperty) {
  46918. ctx.error(
  46919. `defineEmits() type cannot mixed call signature and property syntax.`,
  46920. node
  46921. );
  46922. }
  46923. for (const call of calls) {
  46924. extractEventNames(ctx, call.parameters[0], emits);
  46925. }
  46926. }
  46927. return emits;
  46928. }
  46929. function extractEventNames(ctx, eventName, emits) {
  46930. if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
  46931. const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
  46932. for (const type of types) {
  46933. if (type.type === "TSLiteralType") {
  46934. if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
  46935. emits.add(String(type.literal.value));
  46936. }
  46937. }
  46938. }
  46939. }
  46940. }
  46941. const DEFINE_EXPOSE = "defineExpose";
  46942. function processDefineExpose(ctx, node) {
  46943. if (isCallOf(node, DEFINE_EXPOSE)) {
  46944. if (ctx.hasDefineExposeCall) {
  46945. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  46946. }
  46947. ctx.hasDefineExposeCall = true;
  46948. return true;
  46949. }
  46950. return false;
  46951. }
  46952. const DEFINE_SLOTS = "defineSlots";
  46953. function processDefineSlots(ctx, node, declId) {
  46954. if (!isCallOf(node, DEFINE_SLOTS)) {
  46955. return false;
  46956. }
  46957. if (ctx.hasDefineSlotsCall) {
  46958. ctx.error(`duplicate ${DEFINE_SLOTS}() call`, node);
  46959. }
  46960. ctx.hasDefineSlotsCall = true;
  46961. if (node.arguments.length > 0) {
  46962. ctx.error(`${DEFINE_SLOTS}() cannot accept arguments`, node);
  46963. }
  46964. if (declId) {
  46965. ctx.s.overwrite(
  46966. ctx.startOffset + node.start,
  46967. ctx.startOffset + node.end,
  46968. `${ctx.helper("useSlots")}()`
  46969. );
  46970. }
  46971. return true;
  46972. }
  46973. const DEFINE_OPTIONS = "defineOptions";
  46974. function processDefineOptions(ctx, node) {
  46975. if (!isCallOf(node, DEFINE_OPTIONS)) {
  46976. return false;
  46977. }
  46978. if (ctx.hasDefineOptionsCall) {
  46979. ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
  46980. }
  46981. if (node.typeParameters) {
  46982. ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
  46983. }
  46984. if (!node.arguments[0]) return true;
  46985. ctx.hasDefineOptionsCall = true;
  46986. ctx.optionsRuntimeDecl = unwrapTSNode(node.arguments[0]);
  46987. let propsOption = void 0;
  46988. let emitsOption = void 0;
  46989. let exposeOption = void 0;
  46990. let slotsOption = void 0;
  46991. if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
  46992. for (const prop of ctx.optionsRuntimeDecl.properties) {
  46993. if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
  46994. switch (prop.key.name) {
  46995. case "props":
  46996. propsOption = prop;
  46997. break;
  46998. case "emits":
  46999. emitsOption = prop;
  47000. break;
  47001. case "expose":
  47002. exposeOption = prop;
  47003. break;
  47004. case "slots":
  47005. slotsOption = prop;
  47006. break;
  47007. }
  47008. }
  47009. }
  47010. }
  47011. if (propsOption) {
  47012. ctx.error(
  47013. `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
  47014. propsOption
  47015. );
  47016. }
  47017. if (emitsOption) {
  47018. ctx.error(
  47019. `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
  47020. emitsOption
  47021. );
  47022. }
  47023. if (exposeOption) {
  47024. ctx.error(
  47025. `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
  47026. exposeOption
  47027. );
  47028. }
  47029. if (slotsOption) {
  47030. ctx.error(
  47031. `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
  47032. slotsOption
  47033. );
  47034. }
  47035. return true;
  47036. }
  47037. function processAwait(ctx, node, needSemi, isStatement) {
  47038. const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
  47039. const startOffset = ctx.startOffset;
  47040. const argumentStr = ctx.descriptor.source.slice(
  47041. argumentStart + startOffset,
  47042. node.argument.end + startOffset
  47043. );
  47044. const containsNestedAwait = /\bawait\b/.test(argumentStr);
  47045. ctx.s.overwrite(
  47046. node.start + startOffset,
  47047. argumentStart + startOffset,
  47048. `${needSemi ? `;` : ``}(
  47049. ([__temp,__restore] = ${ctx.helper(
  47050. `withAsyncContext`
  47051. )}(${containsNestedAwait ? `async ` : ``}() => `
  47052. );
  47053. ctx.s.appendLeft(
  47054. node.end + startOffset,
  47055. `)),
  47056. ${isStatement ? `` : `__temp = `}await __temp,
  47057. __restore()${isStatement ? `` : `,
  47058. __temp`}
  47059. )`
  47060. );
  47061. }
  47062. var __defProp$1 = Object.defineProperty;
  47063. var __defProps = Object.defineProperties;
  47064. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  47065. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  47066. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  47067. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  47068. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  47069. var __spreadValues$1 = (a, b) => {
  47070. for (var prop in b || (b = {}))
  47071. if (__hasOwnProp$1.call(b, prop))
  47072. __defNormalProp$1(a, prop, b[prop]);
  47073. if (__getOwnPropSymbols$1)
  47074. for (var prop of __getOwnPropSymbols$1(b)) {
  47075. if (__propIsEnum$1.call(b, prop))
  47076. __defNormalProp$1(a, prop, b[prop]);
  47077. }
  47078. return a;
  47079. };
  47080. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  47081. const MACROS = [
  47082. DEFINE_PROPS,
  47083. DEFINE_EMITS,
  47084. DEFINE_EXPOSE,
  47085. DEFINE_OPTIONS,
  47086. DEFINE_SLOTS,
  47087. DEFINE_MODEL,
  47088. WITH_DEFAULTS
  47089. ];
  47090. function compileScript(sfc, options) {
  47091. var _a, _b, _c;
  47092. if (!options.id) {
  47093. warnOnce$1(
  47094. `compileScript now requires passing the \`id\` option.
  47095. Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
  47096. );
  47097. }
  47098. const { script, scriptSetup, source, filename } = sfc;
  47099. const hoistStatic = options.hoistStatic !== false && !script;
  47100. const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
  47101. const scriptLang = script && script.lang;
  47102. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  47103. const isJSOrTS = isJS(scriptLang, scriptSetupLang) || isTS(scriptLang, scriptSetupLang);
  47104. if (script && scriptSetup && scriptLang !== scriptSetupLang) {
  47105. throw new Error(
  47106. `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
  47107. );
  47108. }
  47109. if (!scriptSetup) {
  47110. if (!script) {
  47111. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  47112. }
  47113. if (script.lang && !isJSOrTS) {
  47114. return script;
  47115. }
  47116. const ctx2 = new ScriptCompileContext(sfc, options);
  47117. return processNormalScript(ctx2, scopeId);
  47118. }
  47119. if (scriptSetupLang && !isJSOrTS) {
  47120. return scriptSetup;
  47121. }
  47122. const ctx = new ScriptCompileContext(sfc, options);
  47123. const scriptBindings = /* @__PURE__ */ Object.create(null);
  47124. const setupBindings = /* @__PURE__ */ Object.create(null);
  47125. let defaultExport;
  47126. let hasAwait = false;
  47127. let hasInlinedSsrRenderFn = false;
  47128. const startOffset = ctx.startOffset;
  47129. const endOffset = ctx.endOffset;
  47130. const scriptStartOffset = script && script.loc.start.offset;
  47131. const scriptEndOffset = script && script.loc.end.offset;
  47132. function hoistNode(node) {
  47133. const start = node.start + startOffset;
  47134. let end = node.end + startOffset;
  47135. if (node.trailingComments && node.trailingComments.length > 0) {
  47136. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  47137. end = lastCommentNode.end + startOffset;
  47138. }
  47139. while (end <= source.length) {
  47140. if (!/\s/.test(source.charAt(end))) {
  47141. break;
  47142. }
  47143. end++;
  47144. }
  47145. ctx.s.move(start, end, 0);
  47146. }
  47147. function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
  47148. let isUsedInTemplate = needTemplateUsageCheck;
  47149. if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  47150. isUsedInTemplate = isImportUsed(local, sfc);
  47151. }
  47152. ctx.userImports[local] = {
  47153. isType,
  47154. imported,
  47155. local,
  47156. source: source2,
  47157. isFromSetup,
  47158. isUsedInTemplate
  47159. };
  47160. }
  47161. function checkInvalidScopeReference(node, method) {
  47162. if (!node) return;
  47163. walkIdentifiers(node, (id) => {
  47164. const binding = setupBindings[id.name];
  47165. if (binding && binding !== "literal-const") {
  47166. ctx.error(
  47167. `\`${method}()\` in <script setup> cannot reference locally declared variables because it will be hoisted outside of the setup() function. If your component options require initialization in the module scope, use a separate normal <script> to export the options instead.`,
  47168. id
  47169. );
  47170. }
  47171. });
  47172. }
  47173. const scriptAst = ctx.scriptAst;
  47174. const scriptSetupAst = ctx.scriptSetupAst;
  47175. if (scriptAst) {
  47176. for (const node of scriptAst.body) {
  47177. if (node.type === "ImportDeclaration") {
  47178. for (const specifier of node.specifiers) {
  47179. const imported = getImportedName(specifier);
  47180. registerUserImport(
  47181. node.source.value,
  47182. specifier.local.name,
  47183. imported,
  47184. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  47185. false,
  47186. !options.inlineTemplate
  47187. );
  47188. }
  47189. }
  47190. }
  47191. }
  47192. for (const node of scriptSetupAst.body) {
  47193. if (node.type === "ImportDeclaration") {
  47194. hoistNode(node);
  47195. let removed = 0;
  47196. const removeSpecifier = (i) => {
  47197. const removeLeft = i > removed;
  47198. removed++;
  47199. const current = node.specifiers[i];
  47200. const next = node.specifiers[i + 1];
  47201. ctx.s.remove(
  47202. removeLeft ? node.specifiers[i - 1].end + startOffset : current.start + startOffset,
  47203. next && !removeLeft ? next.start + startOffset : current.end + startOffset
  47204. );
  47205. };
  47206. for (let i = 0; i < node.specifiers.length; i++) {
  47207. const specifier = node.specifiers[i];
  47208. const local = specifier.local.name;
  47209. const imported = getImportedName(specifier);
  47210. const source2 = node.source.value;
  47211. const existing = ctx.userImports[local];
  47212. if (source2 === "vue" && MACROS.includes(imported)) {
  47213. if (local === imported) {
  47214. warnOnce$1(
  47215. `\`${imported}\` is a compiler macro and no longer needs to be imported.`
  47216. );
  47217. } else {
  47218. ctx.error(
  47219. `\`${imported}\` is a compiler macro and cannot be aliased to a different name.`,
  47220. specifier
  47221. );
  47222. }
  47223. removeSpecifier(i);
  47224. } else if (existing) {
  47225. if (existing.source === source2 && existing.imported === imported) {
  47226. removeSpecifier(i);
  47227. } else {
  47228. ctx.error(
  47229. `different imports aliased to same local name.`,
  47230. specifier
  47231. );
  47232. }
  47233. } else {
  47234. registerUserImport(
  47235. source2,
  47236. local,
  47237. imported,
  47238. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  47239. true,
  47240. !options.inlineTemplate
  47241. );
  47242. }
  47243. }
  47244. if (node.specifiers.length && removed === node.specifiers.length) {
  47245. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  47246. }
  47247. }
  47248. }
  47249. const vueImportAliases = {};
  47250. for (const key in ctx.userImports) {
  47251. const { source: source2, imported, local } = ctx.userImports[key];
  47252. if (source2 === "vue") vueImportAliases[imported] = local;
  47253. }
  47254. if (script && scriptAst) {
  47255. for (const node of scriptAst.body) {
  47256. if (node.type === "ExportDefaultDeclaration") {
  47257. defaultExport = node;
  47258. let optionProperties;
  47259. if (defaultExport.declaration.type === "ObjectExpression") {
  47260. optionProperties = defaultExport.declaration.properties;
  47261. } else if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
  47262. optionProperties = defaultExport.declaration.arguments[0].properties;
  47263. }
  47264. if (optionProperties) {
  47265. for (const p of optionProperties) {
  47266. if (p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name") {
  47267. ctx.hasDefaultExportName = true;
  47268. }
  47269. if ((p.type === "ObjectMethod" || p.type === "ObjectProperty") && p.key.type === "Identifier" && p.key.name === "render") {
  47270. ctx.hasDefaultExportRender = true;
  47271. }
  47272. }
  47273. }
  47274. const start = node.start + scriptStartOffset;
  47275. const end = node.declaration.start + scriptStartOffset;
  47276. ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `);
  47277. } else if (node.type === "ExportNamedDeclaration") {
  47278. const defaultSpecifier = node.specifiers.find(
  47279. (s) => s.exported.type === "Identifier" && s.exported.name === "default"
  47280. );
  47281. if (defaultSpecifier) {
  47282. defaultExport = node;
  47283. if (node.specifiers.length > 1) {
  47284. ctx.s.remove(
  47285. defaultSpecifier.start + scriptStartOffset,
  47286. defaultSpecifier.end + scriptStartOffset
  47287. );
  47288. } else {
  47289. ctx.s.remove(
  47290. node.start + scriptStartOffset,
  47291. node.end + scriptStartOffset
  47292. );
  47293. }
  47294. if (node.source) {
  47295. ctx.s.prepend(
  47296. `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'
  47297. `
  47298. );
  47299. } else {
  47300. ctx.s.appendLeft(
  47301. scriptEndOffset,
  47302. `
  47303. const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
  47304. `
  47305. );
  47306. }
  47307. }
  47308. if (node.declaration) {
  47309. walkDeclaration(
  47310. "script",
  47311. node.declaration,
  47312. scriptBindings,
  47313. vueImportAliases,
  47314. hoistStatic
  47315. );
  47316. }
  47317. } else if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  47318. walkDeclaration(
  47319. "script",
  47320. node,
  47321. scriptBindings,
  47322. vueImportAliases,
  47323. hoistStatic
  47324. );
  47325. }
  47326. }
  47327. if (scriptStartOffset > startOffset) {
  47328. if (!/\n$/.test(script.content.trim())) {
  47329. ctx.s.appendLeft(scriptEndOffset, `
  47330. `);
  47331. }
  47332. ctx.s.move(scriptStartOffset, scriptEndOffset, 0);
  47333. }
  47334. }
  47335. for (const node of scriptSetupAst.body) {
  47336. if (node.type === "ExpressionStatement") {
  47337. const expr = unwrapTSNode(node.expression);
  47338. if (processDefineProps(ctx, expr) || processDefineEmits(ctx, expr) || processDefineOptions(ctx, expr) || processDefineSlots(ctx, expr)) {
  47339. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  47340. } else if (processDefineExpose(ctx, expr)) {
  47341. const callee = expr.callee;
  47342. ctx.s.overwrite(
  47343. callee.start + startOffset,
  47344. callee.end + startOffset,
  47345. "__expose"
  47346. );
  47347. } else {
  47348. processDefineModel(ctx, expr);
  47349. }
  47350. }
  47351. if (node.type === "VariableDeclaration" && !node.declare) {
  47352. const total = node.declarations.length;
  47353. let left = total;
  47354. let lastNonRemoved;
  47355. for (let i = 0; i < total; i++) {
  47356. const decl = node.declarations[i];
  47357. const init = decl.init && unwrapTSNode(decl.init);
  47358. if (init) {
  47359. if (processDefineOptions(ctx, init)) {
  47360. ctx.error(
  47361. `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
  47362. node
  47363. );
  47364. }
  47365. const isDefineProps = processDefineProps(ctx, init, decl.id);
  47366. if (ctx.propsDestructureRestId) {
  47367. setupBindings[ctx.propsDestructureRestId] = "setup-reactive-const";
  47368. }
  47369. const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
  47370. !isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
  47371. if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
  47372. if (left === 1) {
  47373. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  47374. } else {
  47375. let start = decl.start + startOffset;
  47376. let end = decl.end + startOffset;
  47377. if (i === total - 1) {
  47378. start = node.declarations[lastNonRemoved].end + startOffset;
  47379. } else {
  47380. end = node.declarations[i + 1].start + startOffset;
  47381. }
  47382. ctx.s.remove(start, end);
  47383. left--;
  47384. }
  47385. } else if (isDefineEmits) {
  47386. ctx.s.overwrite(
  47387. startOffset + init.start,
  47388. startOffset + init.end,
  47389. "__emit"
  47390. );
  47391. } else {
  47392. lastNonRemoved = i;
  47393. }
  47394. }
  47395. }
  47396. }
  47397. let isAllLiteral = false;
  47398. if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  47399. isAllLiteral = walkDeclaration(
  47400. "scriptSetup",
  47401. node,
  47402. setupBindings,
  47403. vueImportAliases,
  47404. hoistStatic,
  47405. !!ctx.propsDestructureDecl
  47406. );
  47407. }
  47408. if (hoistStatic && isAllLiteral) {
  47409. hoistNode(node);
  47410. }
  47411. if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
  47412. const scope = [scriptSetupAst.body];
  47413. walk$2(node, {
  47414. enter(child, parent) {
  47415. if (isFunctionType(child)) {
  47416. this.skip();
  47417. }
  47418. if (child.type === "BlockStatement") {
  47419. scope.push(child.body);
  47420. }
  47421. if (child.type === "AwaitExpression") {
  47422. hasAwait = true;
  47423. const currentScope = scope[scope.length - 1];
  47424. const needsSemi = currentScope.some((n, i) => {
  47425. return (scope.length === 1 || i > 0) && n.type === "ExpressionStatement" && n.start === child.start;
  47426. });
  47427. processAwait(
  47428. ctx,
  47429. child,
  47430. needsSemi,
  47431. parent.type === "ExpressionStatement"
  47432. );
  47433. }
  47434. },
  47435. exit(node2) {
  47436. if (node2.type === "BlockStatement") scope.pop();
  47437. }
  47438. });
  47439. }
  47440. if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration") {
  47441. ctx.error(
  47442. `<script setup> cannot contain ES module exports. If you are using a previous version of <script setup>, please consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`,
  47443. node
  47444. );
  47445. }
  47446. if (ctx.isTS) {
  47447. if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
  47448. if (node.type !== "TSEnumDeclaration") {
  47449. hoistNode(node);
  47450. }
  47451. }
  47452. }
  47453. }
  47454. if (ctx.propsDestructureDecl) {
  47455. transformDestructuredProps(ctx, vueImportAliases);
  47456. }
  47457. checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
  47458. checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
  47459. checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
  47460. checkInvalidScopeReference(ctx.emitsRuntimeDecl, DEFINE_EMITS);
  47461. checkInvalidScopeReference(ctx.optionsRuntimeDecl, DEFINE_OPTIONS);
  47462. for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
  47463. for (const node of runtimeOptionNodes) {
  47464. checkInvalidScopeReference(node, DEFINE_MODEL);
  47465. }
  47466. }
  47467. if (script) {
  47468. if (startOffset < scriptStartOffset) {
  47469. ctx.s.remove(0, startOffset);
  47470. ctx.s.remove(endOffset, scriptStartOffset);
  47471. ctx.s.remove(scriptEndOffset, source.length);
  47472. } else {
  47473. ctx.s.remove(0, scriptStartOffset);
  47474. ctx.s.remove(scriptEndOffset, startOffset);
  47475. ctx.s.remove(endOffset, source.length);
  47476. }
  47477. } else {
  47478. ctx.s.remove(0, startOffset);
  47479. ctx.s.remove(endOffset, source.length);
  47480. }
  47481. if (scriptAst) {
  47482. Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body));
  47483. }
  47484. for (const [key, { isType, imported, source: source2 }] of Object.entries(
  47485. ctx.userImports
  47486. )) {
  47487. if (isType) continue;
  47488. ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
  47489. }
  47490. for (const key in scriptBindings) {
  47491. ctx.bindingMetadata[key] = scriptBindings[key];
  47492. }
  47493. for (const key in setupBindings) {
  47494. ctx.bindingMetadata[key] = setupBindings[key];
  47495. }
  47496. if (sfc.cssVars.length && // no need to do this when targeting SSR
  47497. !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
  47498. ctx.helperImports.add(CSS_VARS_HELPER);
  47499. ctx.helperImports.add("unref");
  47500. ctx.s.prependLeft(
  47501. startOffset,
  47502. `
  47503. ${genCssVarsCode(
  47504. sfc.cssVars,
  47505. ctx.bindingMetadata,
  47506. scopeId,
  47507. !!options.isProd
  47508. )}
  47509. `
  47510. );
  47511. }
  47512. let args = `__props`;
  47513. if (ctx.propsTypeDecl) {
  47514. args += `: any`;
  47515. }
  47516. if (ctx.propsDecl) {
  47517. if (ctx.propsDestructureRestId) {
  47518. ctx.s.overwrite(
  47519. startOffset + ctx.propsCall.start,
  47520. startOffset + ctx.propsCall.end,
  47521. `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
  47522. Object.keys(ctx.propsDestructuredBindings)
  47523. )})`
  47524. );
  47525. ctx.s.overwrite(
  47526. startOffset + ctx.propsDestructureDecl.start,
  47527. startOffset + ctx.propsDestructureDecl.end,
  47528. ctx.propsDestructureRestId
  47529. );
  47530. } else if (!ctx.propsDestructureDecl) {
  47531. ctx.s.overwrite(
  47532. startOffset + ctx.propsCall.start,
  47533. startOffset + ctx.propsCall.end,
  47534. "__props"
  47535. );
  47536. }
  47537. }
  47538. if (hasAwait) {
  47539. const any = ctx.isTS ? `: any` : ``;
  47540. ctx.s.prependLeft(startOffset, `
  47541. let __temp${any}, __restore${any}
  47542. `);
  47543. }
  47544. const destructureElements = ctx.hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [];
  47545. if (ctx.emitDecl) {
  47546. destructureElements.push(`emit: __emit`);
  47547. }
  47548. if (destructureElements.length) {
  47549. args += `, { ${destructureElements.join(", ")} }`;
  47550. }
  47551. let templateMap;
  47552. let returned;
  47553. const propsDecl = genRuntimeProps(ctx);
  47554. if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
  47555. const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
  47556. for (const key in ctx.userImports) {
  47557. if (!ctx.userImports[key].isType && ctx.userImports[key].isUsedInTemplate) {
  47558. allBindings[key] = true;
  47559. }
  47560. }
  47561. returned = `{ `;
  47562. for (const key in allBindings) {
  47563. if (allBindings[key] === true && ctx.userImports[key].source !== "vue" && !ctx.userImports[key].source.endsWith(".vue")) {
  47564. returned += `get ${key}() { return ${key} }, `;
  47565. } else if (ctx.bindingMetadata[key] === "setup-let") {
  47566. const setArg = key === "v" ? `_v` : `v`;
  47567. returned += `get ${key}() { return ${key} }, set ${key}(${setArg}) { ${key} = ${setArg} }, `;
  47568. } else {
  47569. returned += `${key}, `;
  47570. }
  47571. }
  47572. returned = returned.replace(/, $/, "") + ` }`;
  47573. } else {
  47574. if (sfc.template && !sfc.template.src) {
  47575. if (options.templateOptions && options.templateOptions.ssr) {
  47576. hasInlinedSsrRenderFn = true;
  47577. }
  47578. const { code, ast, preamble, tips, errors, map: map2 } = compileTemplate(__spreadProps(__spreadValues$1({
  47579. filename,
  47580. ast: sfc.template.ast,
  47581. source: sfc.template.content,
  47582. inMap: sfc.template.map
  47583. }, options.templateOptions), {
  47584. id: scopeId,
  47585. scoped: sfc.styles.some((s) => s.scoped),
  47586. isProd: options.isProd,
  47587. ssrCssVars: sfc.cssVars,
  47588. compilerOptions: __spreadProps(__spreadValues$1({}, options.templateOptions && options.templateOptions.compilerOptions), {
  47589. inline: true,
  47590. isTS: ctx.isTS,
  47591. bindingMetadata: ctx.bindingMetadata
  47592. })
  47593. }));
  47594. templateMap = map2;
  47595. if (tips.length) {
  47596. tips.forEach(warnOnce$1);
  47597. }
  47598. const err = errors[0];
  47599. if (typeof err === "string") {
  47600. throw new Error(err);
  47601. } else if (err) {
  47602. if (err.loc) {
  47603. err.message += `
  47604. ` + sfc.filename + "\n" + generateCodeFrame(
  47605. source,
  47606. err.loc.start.offset,
  47607. err.loc.end.offset
  47608. ) + `
  47609. `;
  47610. }
  47611. throw err;
  47612. }
  47613. if (preamble) {
  47614. ctx.s.prepend(preamble);
  47615. }
  47616. if (ast && ast.helpers.has(UNREF)) {
  47617. ctx.helperImports.delete("unref");
  47618. }
  47619. returned = code;
  47620. } else {
  47621. returned = `() => {}`;
  47622. }
  47623. }
  47624. if (!options.inlineTemplate && true) {
  47625. ctx.s.appendRight(
  47626. endOffset,
  47627. `
  47628. const __returned__ = ${returned}
  47629. Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
  47630. return __returned__
  47631. }
  47632. `
  47633. );
  47634. } else {
  47635. ctx.s.appendRight(endOffset, `
  47636. return ${returned}
  47637. }
  47638. `);
  47639. }
  47640. const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
  47641. let runtimeOptions = ``;
  47642. if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  47643. const match = filename.match(/([^/\\]+)\.\w+$/);
  47644. if (match) {
  47645. runtimeOptions += `
  47646. __name: '${match[1]}',`;
  47647. }
  47648. }
  47649. if (hasInlinedSsrRenderFn) {
  47650. runtimeOptions += `
  47651. __ssrInlineRender: true,`;
  47652. }
  47653. if (propsDecl) runtimeOptions += `
  47654. props: ${propsDecl},`;
  47655. const emitsDecl = genRuntimeEmits(ctx);
  47656. if (emitsDecl) runtimeOptions += `
  47657. emits: ${emitsDecl},`;
  47658. let definedOptions = "";
  47659. if (ctx.optionsRuntimeDecl) {
  47660. definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
  47661. }
  47662. const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
  47663. `;
  47664. if (ctx.isTS) {
  47665. const def = (defaultExport ? `
  47666. ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
  47667. ...${definedOptions},` : "");
  47668. ctx.s.prependLeft(
  47669. startOffset,
  47670. `
  47671. ${genDefaultAs} /*@__PURE__*/${ctx.helper(
  47672. `defineComponent`
  47673. )}({${def}${runtimeOptions}
  47674. ${hasAwait ? `async ` : ``}setup(${args}) {
  47675. ${exposeCall}`
  47676. );
  47677. ctx.s.appendRight(endOffset, `})`);
  47678. } else {
  47679. if (defaultExport || definedOptions) {
  47680. ctx.s.prependLeft(
  47681. startOffset,
  47682. `
  47683. ${genDefaultAs} /*@__PURE__*/Object.assign(${defaultExport ? `${normalScriptDefaultVar}, ` : ""}${definedOptions ? `${definedOptions}, ` : ""}{${runtimeOptions}
  47684. ${hasAwait ? `async ` : ``}setup(${args}) {
  47685. ${exposeCall}`
  47686. );
  47687. ctx.s.appendRight(endOffset, `})`);
  47688. } else {
  47689. ctx.s.prependLeft(
  47690. startOffset,
  47691. `
  47692. ${genDefaultAs} {${runtimeOptions}
  47693. ${hasAwait ? `async ` : ``}setup(${args}) {
  47694. ${exposeCall}`
  47695. );
  47696. ctx.s.appendRight(endOffset, `}`);
  47697. }
  47698. }
  47699. if (ctx.helperImports.size > 0) {
  47700. const runtimeModuleName = (_c = (_b = options.templateOptions) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.runtimeModuleName;
  47701. const importSrc = runtimeModuleName ? JSON.stringify(runtimeModuleName) : `'vue'`;
  47702. ctx.s.prepend(
  47703. `import { ${[...ctx.helperImports].map((h) => `${h} as _${h}`).join(", ")} } from ${importSrc}
  47704. `
  47705. );
  47706. }
  47707. const content = ctx.s.toString();
  47708. let map = options.sourceMap !== false ? ctx.s.generateMap({
  47709. source: filename,
  47710. hires: true,
  47711. includeContent: true
  47712. }) : void 0;
  47713. if (templateMap && map) {
  47714. const offset = content.indexOf(returned);
  47715. const templateLineOffset = content.slice(0, offset).split(/\r?\n/).length - 1;
  47716. map = mergeSourceMaps(map, templateMap, templateLineOffset);
  47717. }
  47718. return __spreadProps(__spreadValues$1({}, scriptSetup), {
  47719. bindings: ctx.bindingMetadata,
  47720. imports: ctx.userImports,
  47721. content,
  47722. map,
  47723. scriptAst: scriptAst == null ? void 0 : scriptAst.body,
  47724. scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
  47725. deps: ctx.deps ? [...ctx.deps] : void 0
  47726. });
  47727. }
  47728. function registerBinding(bindings, node, type) {
  47729. bindings[node.name] = type;
  47730. }
  47731. function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic, isPropsDestructureEnabled = false) {
  47732. let isAllLiteral = false;
  47733. if (node.type === "VariableDeclaration") {
  47734. const isConst = node.kind === "const";
  47735. isAllLiteral = isConst && node.declarations.every(
  47736. (decl) => decl.id.type === "Identifier" && isStaticNode(decl.init)
  47737. );
  47738. for (const { id, init: _init } of node.declarations) {
  47739. const init = _init && unwrapTSNode(_init);
  47740. const isConstMacroCall = isConst && isCallOf(
  47741. init,
  47742. (c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS || c === DEFINE_SLOTS
  47743. );
  47744. if (id.type === "Identifier") {
  47745. let bindingType;
  47746. const userReactiveBinding = userImportAliases["reactive"];
  47747. if ((hoistStatic || from === "script") && (isAllLiteral || isConst && isStaticNode(init))) {
  47748. bindingType = "literal-const";
  47749. } else if (isCallOf(init, userReactiveBinding)) {
  47750. bindingType = isConst ? "setup-reactive-const" : "setup-let";
  47751. } else if (
  47752. // if a declaration is a const literal, we can mark it so that
  47753. // the generated render fn code doesn't need to unref() it
  47754. isConstMacroCall || isConst && canNeverBeRef(init, userReactiveBinding)
  47755. ) {
  47756. bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
  47757. } else if (isConst) {
  47758. if (isCallOf(
  47759. init,
  47760. (m) => m === userImportAliases["ref"] || m === userImportAliases["computed"] || m === userImportAliases["shallowRef"] || m === userImportAliases["customRef"] || m === userImportAliases["toRef"] || m === userImportAliases["useTemplateRef"] || m === DEFINE_MODEL
  47761. )) {
  47762. bindingType = "setup-ref";
  47763. } else {
  47764. bindingType = "setup-maybe-ref";
  47765. }
  47766. } else {
  47767. bindingType = "setup-let";
  47768. }
  47769. registerBinding(bindings, id, bindingType);
  47770. } else {
  47771. if (isCallOf(init, DEFINE_PROPS) && isPropsDestructureEnabled) {
  47772. continue;
  47773. }
  47774. if (id.type === "ObjectPattern") {
  47775. walkObjectPattern(id, bindings, isConst, isConstMacroCall);
  47776. } else if (id.type === "ArrayPattern") {
  47777. walkArrayPattern(id, bindings, isConst, isConstMacroCall);
  47778. }
  47779. }
  47780. }
  47781. } else if (node.type === "TSEnumDeclaration") {
  47782. isAllLiteral = node.members.every(
  47783. (member) => !member.initializer || isStaticNode(member.initializer)
  47784. );
  47785. bindings[node.id.name] = isAllLiteral ? "literal-const" : "setup-const";
  47786. } else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
  47787. bindings[node.id.name] = "setup-const";
  47788. }
  47789. return isAllLiteral;
  47790. }
  47791. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  47792. for (const p of node.properties) {
  47793. if (p.type === "ObjectProperty") {
  47794. if (p.key.type === "Identifier" && p.key === p.value) {
  47795. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  47796. registerBinding(bindings, p.key, type);
  47797. } else {
  47798. walkPattern(p.value, bindings, isConst, isDefineCall);
  47799. }
  47800. } else {
  47801. const type = isConst ? "setup-const" : "setup-let";
  47802. registerBinding(bindings, p.argument, type);
  47803. }
  47804. }
  47805. }
  47806. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  47807. for (const e of node.elements) {
  47808. e && walkPattern(e, bindings, isConst, isDefineCall);
  47809. }
  47810. }
  47811. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  47812. if (node.type === "Identifier") {
  47813. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  47814. registerBinding(bindings, node, type);
  47815. } else if (node.type === "RestElement") {
  47816. const type = isConst ? "setup-const" : "setup-let";
  47817. registerBinding(bindings, node.argument, type);
  47818. } else if (node.type === "ObjectPattern") {
  47819. walkObjectPattern(node, bindings, isConst);
  47820. } else if (node.type === "ArrayPattern") {
  47821. walkArrayPattern(node, bindings, isConst);
  47822. } else if (node.type === "AssignmentPattern") {
  47823. if (node.left.type === "Identifier") {
  47824. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  47825. registerBinding(bindings, node.left, type);
  47826. } else {
  47827. walkPattern(node.left, bindings, isConst);
  47828. }
  47829. }
  47830. }
  47831. function canNeverBeRef(node, userReactiveImport) {
  47832. if (isCallOf(node, userReactiveImport)) {
  47833. return true;
  47834. }
  47835. switch (node.type) {
  47836. case "UnaryExpression":
  47837. case "BinaryExpression":
  47838. case "ArrayExpression":
  47839. case "ObjectExpression":
  47840. case "FunctionExpression":
  47841. case "ArrowFunctionExpression":
  47842. case "UpdateExpression":
  47843. case "ClassExpression":
  47844. case "TaggedTemplateExpression":
  47845. return true;
  47846. case "SequenceExpression":
  47847. return canNeverBeRef(
  47848. node.expressions[node.expressions.length - 1],
  47849. userReactiveImport
  47850. );
  47851. default:
  47852. if (isLiteralNode(node)) {
  47853. return true;
  47854. }
  47855. return false;
  47856. }
  47857. }
  47858. function isStaticNode(node) {
  47859. node = unwrapTSNode(node);
  47860. switch (node.type) {
  47861. case "UnaryExpression":
  47862. return isStaticNode(node.argument);
  47863. case "LogicalExpression":
  47864. // 1 > 2
  47865. case "BinaryExpression":
  47866. return isStaticNode(node.left) && isStaticNode(node.right);
  47867. case "ConditionalExpression": {
  47868. return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
  47869. }
  47870. case "SequenceExpression":
  47871. // (1, 2)
  47872. case "TemplateLiteral":
  47873. return node.expressions.every((expr) => isStaticNode(expr));
  47874. case "ParenthesizedExpression":
  47875. return isStaticNode(node.expression);
  47876. case "StringLiteral":
  47877. case "NumericLiteral":
  47878. case "BooleanLiteral":
  47879. case "NullLiteral":
  47880. case "BigIntLiteral":
  47881. return true;
  47882. }
  47883. return false;
  47884. }
  47885. function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
  47886. const generator = new sourceMapExports.SourceMapGenerator();
  47887. const addMapping = (map, lineOffset = 0) => {
  47888. const consumer = new sourceMapExports.SourceMapConsumer(map);
  47889. consumer.sources.forEach((sourceFile) => {
  47890. generator._sources.add(sourceFile);
  47891. const sourceContent = consumer.sourceContentFor(sourceFile);
  47892. if (sourceContent != null) {
  47893. generator.setSourceContent(sourceFile, sourceContent);
  47894. }
  47895. });
  47896. consumer.eachMapping((m) => {
  47897. if (m.originalLine == null) return;
  47898. generator.addMapping({
  47899. generated: {
  47900. line: m.generatedLine + lineOffset,
  47901. column: m.generatedColumn
  47902. },
  47903. original: {
  47904. line: m.originalLine,
  47905. column: m.originalColumn
  47906. },
  47907. source: m.source,
  47908. name: m.name
  47909. });
  47910. });
  47911. };
  47912. addMapping(scriptMap);
  47913. addMapping(templateMap, templateLineOffset);
  47914. generator._sourceRoot = scriptMap.sourceRoot;
  47915. generator._file = scriptMap.file;
  47916. return generator.toJSON();
  47917. }
  47918. var __defProp = Object.defineProperty;
  47919. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  47920. var __hasOwnProp = Object.prototype.hasOwnProperty;
  47921. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  47922. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  47923. var __spreadValues = (a, b) => {
  47924. for (var prop in b || (b = {}))
  47925. if (__hasOwnProp.call(b, prop))
  47926. __defNormalProp(a, prop, b[prop]);
  47927. if (__getOwnPropSymbols)
  47928. for (var prop of __getOwnPropSymbols(b)) {
  47929. if (__propIsEnum.call(b, prop))
  47930. __defNormalProp(a, prop, b[prop]);
  47931. }
  47932. return a;
  47933. };
  47934. const version = "3.5.22";
  47935. const parseCache = parseCache$1;
  47936. const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
  47937. const walk = walk$2;
  47938. const shouldTransformRef = () => false;
  47939. var parse$4 = libExports.parse;
  47940. export { MagicString, parse$4 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, errorMessages, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$2 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };