compiler-sfc.esm-browser.js 1.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569
  1. /**
  2. * Make a map and return a function for checking if a key
  3. * is in that map.
  4. * IMPORTANT: all calls of this function must be prefixed with
  5. * \/\*#\_\_PURE\_\_\*\/
  6. * So that rollup can tree-shake them if necessary.
  7. */
  8. function makeMap(str, expectsLowerCase) {
  9. const map = Object.create(null);
  10. const list = str.split(',');
  11. for (let i = 0; i < list.length; i++) {
  12. map[list[i]] = true;
  13. }
  14. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  15. }
  16. /**
  17. * dev only flag -> name mapping
  18. */
  19. const PatchFlagNames = {
  20. [1 /* TEXT */]: `TEXT`,
  21. [2 /* CLASS */]: `CLASS`,
  22. [4 /* STYLE */]: `STYLE`,
  23. [8 /* PROPS */]: `PROPS`,
  24. [16 /* FULL_PROPS */]: `FULL_PROPS`,
  25. [32 /* HYDRATE_EVENTS */]: `HYDRATE_EVENTS`,
  26. [64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
  27. [128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
  28. [256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
  29. [512 /* NEED_PATCH */]: `NEED_PATCH`,
  30. [1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
  31. [2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
  32. [-1 /* HOISTED */]: `HOISTED`,
  33. [-2 /* BAIL */]: `BAIL`
  34. };
  35. /**
  36. * Dev only
  37. */
  38. const slotFlagsText = {
  39. [1 /* STABLE */]: 'STABLE',
  40. [2 /* DYNAMIC */]: 'DYNAMIC',
  41. [3 /* FORWARDED */]: 'FORWARDED'
  42. };
  43. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  44. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  45. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  46. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  47. const range = 2;
  48. function generateCodeFrame(source, start = 0, end = source.length) {
  49. // Split the content into individual lines but capture the newline sequence
  50. // that separated each line. This is important because the actual sequence is
  51. // needed to properly take into account the full line length for offset
  52. // comparison
  53. let lines = source.split(/(\r?\n)/);
  54. // Separate the lines and newline sequences into separate arrays for easier referencing
  55. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  56. lines = lines.filter((_, idx) => idx % 2 === 0);
  57. let count = 0;
  58. const res = [];
  59. for (let i = 0; i < lines.length; i++) {
  60. count +=
  61. lines[i].length +
  62. ((newlineSequences[i] && newlineSequences[i].length) || 0);
  63. if (count >= start) {
  64. for (let j = i - range; j <= i + range || end > count; j++) {
  65. if (j < 0 || j >= lines.length)
  66. continue;
  67. const line = j + 1;
  68. res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
  69. const lineLength = lines[j].length;
  70. const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
  71. if (j === i) {
  72. // push underline
  73. const pad = start - (count - (lineLength + newLineSeqLength));
  74. const length = Math.max(1, end > count ? lineLength - pad : end - start);
  75. res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
  76. }
  77. else if (j > i) {
  78. if (end > count) {
  79. const length = Math.max(Math.min(end - count, lineLength), 1);
  80. res.push(` | ` + '^'.repeat(length));
  81. }
  82. count += lineLength + newLineSeqLength;
  83. }
  84. }
  85. break;
  86. }
  87. }
  88. return res.join('\n');
  89. }
  90. /**
  91. * On the client we only need to offer special cases for boolean attributes that
  92. * have different names from their corresponding dom properties:
  93. * - itemscope -> N/A
  94. * - allowfullscreen -> allowFullscreen
  95. * - formnovalidate -> formNoValidate
  96. * - ismap -> isMap
  97. * - nomodule -> noModule
  98. * - novalidate -> noValidate
  99. * - readonly -> readOnly
  100. */
  101. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  102. /**
  103. * The full list is needed during SSR to produce the correct initial markup.
  104. */
  105. const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
  106. `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
  107. `loop,open,required,reversed,scoped,seamless,` +
  108. `checked,muted,multiple,selected`);
  109. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  110. const attrValidationCache = {};
  111. function isSSRSafeAttrName(name) {
  112. if (attrValidationCache.hasOwnProperty(name)) {
  113. return attrValidationCache[name];
  114. }
  115. const isUnsafe = unsafeAttrCharRE.test(name);
  116. if (isUnsafe) {
  117. console.error(`unsafe attribute name: ${name}`);
  118. }
  119. return (attrValidationCache[name] = !isUnsafe);
  120. }
  121. const propsToAttrMap = {
  122. acceptCharset: 'accept-charset',
  123. className: 'class',
  124. htmlFor: 'for',
  125. httpEquiv: 'http-equiv'
  126. };
  127. /**
  128. * CSS properties that accept plain numbers
  129. */
  130. const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` +
  131. `border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` +
  132. `columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` +
  133. `grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` +
  134. `grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` +
  135. `line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` +
  136. // SVG
  137. `fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` +
  138. `stroke-miterlimit,stroke-opacity,stroke-width`);
  139. /**
  140. * Known attributes, this is used for stringification of runtime static nodes
  141. * so that we don't stringify bindings that cannot be set from HTML.
  142. * Don't also forget to allow `data-*` and `aria-*`!
  143. * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
  144. */
  145. const isKnownHtmlAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` +
  146. `autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` +
  147. `border,buffered,capture,challenge,charset,checked,cite,class,code,` +
  148. `codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` +
  149. `coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` +
  150. `disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` +
  151. `formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` +
  152. `height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` +
  153. `ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` +
  154. `manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` +
  155. `open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` +
  156. `referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
  157. `selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
  158. `start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
  159. `value,width,wrap`);
  160. /**
  161. * Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
  162. */
  163. const isKnownSvgAttr = /*#__PURE__*/ makeMap(`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,` +
  164. `arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,` +
  165. `baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,` +
  166. `clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,` +
  167. `color-interpolation-filters,color-profile,color-rendering,` +
  168. `contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,` +
  169. `descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,` +
  170. `dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,` +
  171. `fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,` +
  172. `font-family,font-size,font-size-adjust,font-stretch,font-style,` +
  173. `font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,` +
  174. `glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,` +
  175. `gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,` +
  176. `horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,` +
  177. `k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,` +
  178. `lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,` +
  179. `marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,` +
  180. `mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,` +
  181. `name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,` +
  182. `overflow,overline-position,overline-thickness,panose-1,paint-order,path,` +
  183. `pathLength,patternContentUnits,patternTransform,patternUnits,ping,` +
  184. `pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,` +
  185. `preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,` +
  186. `rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,` +
  187. `restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,` +
  188. `specularConstant,specularExponent,speed,spreadMethod,startOffset,` +
  189. `stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,` +
  190. `strikethrough-position,strikethrough-thickness,string,stroke,` +
  191. `stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,` +
  192. `stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,` +
  193. `systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,` +
  194. `text-decoration,text-rendering,textLength,to,transform,transform-origin,` +
  195. `type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,` +
  196. `unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,` +
  197. `v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,` +
  198. `vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
  199. `writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
  200. `xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,` +
  201. `xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`);
  202. function normalizeStyle(value) {
  203. if (isArray(value)) {
  204. const res = {};
  205. for (let i = 0; i < value.length; i++) {
  206. const item = value[i];
  207. const normalized = isString(item)
  208. ? parseStringStyle(item)
  209. : normalizeStyle(item);
  210. if (normalized) {
  211. for (const key in normalized) {
  212. res[key] = normalized[key];
  213. }
  214. }
  215. }
  216. return res;
  217. }
  218. else if (isString(value)) {
  219. return value;
  220. }
  221. else if (isObject(value)) {
  222. return value;
  223. }
  224. }
  225. const listDelimiterRE = /;(?![^(]*\))/g;
  226. const propertyDelimiterRE = /:(.+)/;
  227. function parseStringStyle(cssText) {
  228. const ret = {};
  229. cssText.split(listDelimiterRE).forEach(item => {
  230. if (item) {
  231. const tmp = item.split(propertyDelimiterRE);
  232. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  233. }
  234. });
  235. return ret;
  236. }
  237. function stringifyStyle(styles) {
  238. let ret = '';
  239. if (!styles || isString(styles)) {
  240. return ret;
  241. }
  242. for (const key in styles) {
  243. const value = styles[key];
  244. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  245. if (isString(value) ||
  246. (typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))) {
  247. // only render valid values
  248. ret += `${normalizedKey}:${value};`;
  249. }
  250. }
  251. return ret;
  252. }
  253. function normalizeClass(value) {
  254. let res = '';
  255. if (isString(value)) {
  256. res = value;
  257. }
  258. else if (isArray(value)) {
  259. for (let i = 0; i < value.length; i++) {
  260. const normalized = normalizeClass(value[i]);
  261. if (normalized) {
  262. res += normalized + ' ';
  263. }
  264. }
  265. }
  266. else if (isObject(value)) {
  267. for (const name in value) {
  268. if (value[name]) {
  269. res += name + ' ';
  270. }
  271. }
  272. }
  273. return res.trim();
  274. }
  275. // These tag configs are shared between compiler-dom and runtime-dom, so they
  276. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  277. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  278. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  279. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  280. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  281. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  282. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  283. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  284. 'option,output,progress,select,textarea,details,dialog,menu,' +
  285. 'summary,template,blockquote,iframe,tfoot';
  286. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  287. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  288. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  289. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  290. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  291. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  292. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  293. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  294. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  295. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  296. 'text,textPath,title,tspan,unknown,use,view';
  297. const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
  298. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  299. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  300. const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
  301. const escapeRE = /["'&<>]/;
  302. function escapeHtml(string) {
  303. const str = '' + string;
  304. const match = escapeRE.exec(str);
  305. if (!match) {
  306. return str;
  307. }
  308. let html = '';
  309. let escaped;
  310. let index;
  311. let lastIndex = 0;
  312. for (index = match.index; index < str.length; index++) {
  313. switch (str.charCodeAt(index)) {
  314. case 34: // "
  315. escaped = '&quot;';
  316. break;
  317. case 38: // &
  318. escaped = '&amp;';
  319. break;
  320. case 39: // '
  321. escaped = '&#39;';
  322. break;
  323. case 60: // <
  324. escaped = '&lt;';
  325. break;
  326. case 62: // >
  327. escaped = '&gt;';
  328. break;
  329. default:
  330. continue;
  331. }
  332. if (lastIndex !== index) {
  333. html += str.substring(lastIndex, index);
  334. }
  335. lastIndex = index + 1;
  336. html += escaped;
  337. }
  338. return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
  339. }
  340. /**
  341. * For converting {{ interpolation }} values to displayed strings.
  342. * @private
  343. */
  344. const toDisplayString = (val) => {
  345. return val == null
  346. ? ''
  347. : isArray(val) ||
  348. (isObject(val) &&
  349. (val.toString === objectToString || !isFunction(val.toString)))
  350. ? JSON.stringify(val, replacer, 2)
  351. : String(val);
  352. };
  353. const replacer = (_key, val) => {
  354. // can't use isRef here since @vue/shared has no deps
  355. if (val && val.__v_isRef) {
  356. return replacer(_key, val.value);
  357. }
  358. else if (isMap(val)) {
  359. return {
  360. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  361. entries[`${key} =>`] = val;
  362. return entries;
  363. }, {})
  364. };
  365. }
  366. else if (isSet(val)) {
  367. return {
  368. [`Set(${val.size})`]: [...val.values()]
  369. };
  370. }
  371. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  372. return String(val);
  373. }
  374. return val;
  375. };
  376. /**
  377. * List of @babel/parser plugins that are used for template expression
  378. * transforms and SFC script transforms. By default we enable proposals slated
  379. * for ES2020. This will need to be updated as the spec moves forward.
  380. * Full list at https://babeljs.io/docs/en/next/babel-parser#plugins
  381. */
  382. const babelParserDefaultPlugins = [
  383. 'bigInt',
  384. 'optionalChaining',
  385. 'nullishCoalescingOperator'
  386. ];
  387. const EMPTY_OBJ = Object.freeze({})
  388. ;
  389. Object.freeze([]) ;
  390. const NOOP = () => { };
  391. /**
  392. * Always return false.
  393. */
  394. const NO = () => false;
  395. const onRE = /^on[^a-z]/;
  396. const isOn = (key) => onRE.test(key);
  397. const extend = Object.assign;
  398. const hasOwnProperty = Object.prototype.hasOwnProperty;
  399. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  400. const isArray = Array.isArray;
  401. const isMap = (val) => toTypeString(val) === '[object Map]';
  402. const isSet = (val) => toTypeString(val) === '[object Set]';
  403. const isFunction = (val) => typeof val === 'function';
  404. const isString = (val) => typeof val === 'string';
  405. const isSymbol = (val) => typeof val === 'symbol';
  406. const isObject = (val) => val !== null && typeof val === 'object';
  407. const objectToString = Object.prototype.toString;
  408. const toTypeString = (value) => objectToString.call(value);
  409. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  410. const isReservedProp = /*#__PURE__*/ makeMap(
  411. // the leading comma is intentional so empty string "" is also included
  412. ',key,ref,' +
  413. 'onVnodeBeforeMount,onVnodeMounted,' +
  414. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  415. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  416. const cacheStringFunction = (fn) => {
  417. const cache = Object.create(null);
  418. return ((str) => {
  419. const hit = cache[str];
  420. return hit || (cache[str] = fn(str));
  421. });
  422. };
  423. const camelizeRE = /-(\w)/g;
  424. /**
  425. * @private
  426. */
  427. const camelize = cacheStringFunction((str) => {
  428. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  429. });
  430. const hyphenateRE = /\B([A-Z])/g;
  431. /**
  432. * @private
  433. */
  434. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  435. /**
  436. * @private
  437. */
  438. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  439. /**
  440. * @private
  441. */
  442. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  443. function defaultOnError(error) {
  444. throw error;
  445. }
  446. function defaultOnWarn(msg) {
  447. console.warn(`[Vue warn] ${msg.message}`);
  448. }
  449. function createCompilerError(code, loc, messages, additionalMessage) {
  450. const msg = (messages || errorMessages)[code] + (additionalMessage || ``)
  451. ;
  452. const error = new SyntaxError(String(msg));
  453. error.code = code;
  454. error.loc = loc;
  455. return error;
  456. }
  457. const errorMessages = {
  458. // parse errors
  459. [0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
  460. [1 /* CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
  461. [2 /* DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
  462. [3 /* END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
  463. [4 /* END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
  464. [5 /* EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
  465. [6 /* EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
  466. [7 /* EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
  467. [8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
  468. [9 /* EOF_IN_TAG */]: 'Unexpected EOF in tag.',
  469. [10 /* INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
  470. [11 /* INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
  471. [12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '&lt;' to print '<'.",
  472. [13 /* MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
  473. [14 /* MISSING_END_TAG_NAME */]: 'End tag name was expected.',
  474. [15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
  475. [16 /* NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
  476. [17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
  477. [18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
  478. [19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
  479. [21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
  480. [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
  481. [22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
  482. // Vue-specific parse errors
  483. [23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
  484. [24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
  485. [25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
  486. [27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
  487. 'Note that dynamic directive argument cannot contain spaces.',
  488. [26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
  489. // transform errors
  490. [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
  491. [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
  492. [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
  493. [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
  494. [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
  495. [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
  496. [34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
  497. [35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
  498. [36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
  499. [37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
  500. `When there are multiple named slots, all slots should use <template> ` +
  501. `syntax to avoid scope ambiguity.`,
  502. [38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
  503. [39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
  504. `default slot. These children will be ignored.`,
  505. [40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
  506. [41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
  507. [42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
  508. [43 /* X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  509. [44 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
  510. [45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
  511. // generic errors
  512. [46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  513. [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
  514. [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  515. [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
  516. // just to fullfill types
  517. [50 /* __EXTEND_POINT__ */]: ``
  518. };
  519. const FRAGMENT = Symbol(`Fragment` );
  520. const TELEPORT = Symbol(`Teleport` );
  521. const SUSPENSE = Symbol(`Suspense` );
  522. const KEEP_ALIVE = Symbol(`KeepAlive` );
  523. const BASE_TRANSITION = Symbol(`BaseTransition` );
  524. const OPEN_BLOCK = Symbol(`openBlock` );
  525. const CREATE_BLOCK = Symbol(`createBlock` );
  526. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  527. const CREATE_VNODE = Symbol(`createVNode` );
  528. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  529. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  530. const CREATE_TEXT = Symbol(`createTextVNode` );
  531. const CREATE_STATIC = Symbol(`createStaticVNode` );
  532. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  533. const RESOLVE_DYNAMIC_COMPONENT = Symbol(`resolveDynamicComponent` );
  534. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  535. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  536. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  537. const RENDER_LIST = Symbol(`renderList` );
  538. const RENDER_SLOT = Symbol(`renderSlot` );
  539. const CREATE_SLOTS = Symbol(`createSlots` );
  540. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  541. const MERGE_PROPS = Symbol(`mergeProps` );
  542. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  543. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  544. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  545. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  546. const TO_HANDLERS = Symbol(`toHandlers` );
  547. const CAMELIZE = Symbol(`camelize` );
  548. const CAPITALIZE = Symbol(`capitalize` );
  549. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  550. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  551. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  552. const POP_SCOPE_ID = Symbol(`popScopeId` );
  553. const WITH_CTX = Symbol(`withCtx` );
  554. const UNREF = Symbol(`unref` );
  555. const IS_REF = Symbol(`isRef` );
  556. const WITH_MEMO = Symbol(`withMemo` );
  557. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  558. // Name mapping for runtime helpers that need to be imported from 'vue' in
  559. // generated code. Make sure these are correctly exported in the runtime!
  560. // Using `any` here because TS doesn't allow symbols as index type.
  561. const helperNameMap = {
  562. [FRAGMENT]: `Fragment`,
  563. [TELEPORT]: `Teleport`,
  564. [SUSPENSE]: `Suspense`,
  565. [KEEP_ALIVE]: `KeepAlive`,
  566. [BASE_TRANSITION]: `BaseTransition`,
  567. [OPEN_BLOCK]: `openBlock`,
  568. [CREATE_BLOCK]: `createBlock`,
  569. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  570. [CREATE_VNODE]: `createVNode`,
  571. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  572. [CREATE_COMMENT]: `createCommentVNode`,
  573. [CREATE_TEXT]: `createTextVNode`,
  574. [CREATE_STATIC]: `createStaticVNode`,
  575. [RESOLVE_COMPONENT]: `resolveComponent`,
  576. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  577. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  578. [RESOLVE_FILTER]: `resolveFilter`,
  579. [WITH_DIRECTIVES]: `withDirectives`,
  580. [RENDER_LIST]: `renderList`,
  581. [RENDER_SLOT]: `renderSlot`,
  582. [CREATE_SLOTS]: `createSlots`,
  583. [TO_DISPLAY_STRING]: `toDisplayString`,
  584. [MERGE_PROPS]: `mergeProps`,
  585. [NORMALIZE_CLASS]: `normalizeClass`,
  586. [NORMALIZE_STYLE]: `normalizeStyle`,
  587. [NORMALIZE_PROPS]: `normalizeProps`,
  588. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  589. [TO_HANDLERS]: `toHandlers`,
  590. [CAMELIZE]: `camelize`,
  591. [CAPITALIZE]: `capitalize`,
  592. [TO_HANDLER_KEY]: `toHandlerKey`,
  593. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  594. [PUSH_SCOPE_ID]: `pushScopeId`,
  595. [POP_SCOPE_ID]: `popScopeId`,
  596. [WITH_CTX]: `withCtx`,
  597. [UNREF]: `unref`,
  598. [IS_REF]: `isRef`,
  599. [WITH_MEMO]: `withMemo`,
  600. [IS_MEMO_SAME]: `isMemoSame`
  601. };
  602. function registerRuntimeHelpers(helpers) {
  603. Object.getOwnPropertySymbols(helpers).forEach(s => {
  604. helperNameMap[s] = helpers[s];
  605. });
  606. }
  607. // AST Utilities ---------------------------------------------------------------
  608. // Some expressions, e.g. sequence and conditional expressions, are never
  609. // associated with template nodes, so their source locations are just a stub.
  610. // Container types like CompoundExpression also don't need a real location.
  611. const locStub = {
  612. source: '',
  613. start: { line: 1, column: 1, offset: 0 },
  614. end: { line: 1, column: 1, offset: 0 }
  615. };
  616. function createRoot(children, loc = locStub) {
  617. return {
  618. type: 0 /* ROOT */,
  619. children,
  620. helpers: [],
  621. components: [],
  622. directives: [],
  623. hoists: [],
  624. imports: [],
  625. cached: 0,
  626. temps: 0,
  627. codegenNode: undefined,
  628. loc
  629. };
  630. }
  631. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  632. if (context) {
  633. if (isBlock) {
  634. context.helper(OPEN_BLOCK);
  635. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  636. }
  637. else {
  638. context.helper(getVNodeHelper(context.inSSR, isComponent));
  639. }
  640. if (directives) {
  641. context.helper(WITH_DIRECTIVES);
  642. }
  643. }
  644. return {
  645. type: 13 /* VNODE_CALL */,
  646. tag,
  647. props,
  648. children,
  649. patchFlag,
  650. dynamicProps,
  651. directives,
  652. isBlock,
  653. disableTracking,
  654. isComponent,
  655. loc
  656. };
  657. }
  658. function createArrayExpression(elements, loc = locStub) {
  659. return {
  660. type: 17 /* JS_ARRAY_EXPRESSION */,
  661. loc,
  662. elements
  663. };
  664. }
  665. function createObjectExpression(properties, loc = locStub) {
  666. return {
  667. type: 15 /* JS_OBJECT_EXPRESSION */,
  668. loc,
  669. properties
  670. };
  671. }
  672. function createObjectProperty(key, value) {
  673. return {
  674. type: 16 /* JS_PROPERTY */,
  675. loc: locStub,
  676. key: isString(key) ? createSimpleExpression(key, true) : key,
  677. value
  678. };
  679. }
  680. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
  681. return {
  682. type: 4 /* SIMPLE_EXPRESSION */,
  683. loc,
  684. content,
  685. isStatic,
  686. constType: isStatic ? 3 /* CAN_STRINGIFY */ : constType
  687. };
  688. }
  689. function createInterpolation(content, loc) {
  690. return {
  691. type: 5 /* INTERPOLATION */,
  692. loc,
  693. content: isString(content)
  694. ? createSimpleExpression(content, false, loc)
  695. : content
  696. };
  697. }
  698. function createCompoundExpression(children, loc = locStub) {
  699. return {
  700. type: 8 /* COMPOUND_EXPRESSION */,
  701. loc,
  702. children
  703. };
  704. }
  705. function createCallExpression(callee, args = [], loc = locStub) {
  706. return {
  707. type: 14 /* JS_CALL_EXPRESSION */,
  708. loc,
  709. callee,
  710. arguments: args
  711. };
  712. }
  713. function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
  714. return {
  715. type: 18 /* JS_FUNCTION_EXPRESSION */,
  716. params,
  717. returns,
  718. newline,
  719. isSlot,
  720. loc
  721. };
  722. }
  723. function createConditionalExpression(test, consequent, alternate, newline = true) {
  724. return {
  725. type: 19 /* JS_CONDITIONAL_EXPRESSION */,
  726. test,
  727. consequent,
  728. alternate,
  729. newline,
  730. loc: locStub
  731. };
  732. }
  733. function createCacheExpression(index, value, isVNode = false) {
  734. return {
  735. type: 20 /* JS_CACHE_EXPRESSION */,
  736. index,
  737. value,
  738. isVNode,
  739. loc: locStub
  740. };
  741. }
  742. function createBlockStatement(body) {
  743. return {
  744. type: 21 /* JS_BLOCK_STATEMENT */,
  745. body,
  746. loc: locStub
  747. };
  748. }
  749. function createTemplateLiteral(elements) {
  750. return {
  751. type: 22 /* JS_TEMPLATE_LITERAL */,
  752. elements,
  753. loc: locStub
  754. };
  755. }
  756. function createIfStatement(test, consequent, alternate) {
  757. return {
  758. type: 23 /* JS_IF_STATEMENT */,
  759. test,
  760. consequent,
  761. alternate,
  762. loc: locStub
  763. };
  764. }
  765. function createAssignmentExpression(left, right) {
  766. return {
  767. type: 24 /* JS_ASSIGNMENT_EXPRESSION */,
  768. left,
  769. right,
  770. loc: locStub
  771. };
  772. }
  773. function createSequenceExpression(expressions) {
  774. return {
  775. type: 25 /* JS_SEQUENCE_EXPRESSION */,
  776. expressions,
  777. loc: locStub
  778. };
  779. }
  780. function createReturnStatement(returns) {
  781. return {
  782. type: 26 /* JS_RETURN_STATEMENT */,
  783. returns,
  784. loc: locStub
  785. };
  786. }
  787. const isStaticExp = (p) => p.type === 4 /* SIMPLE_EXPRESSION */ && p.isStatic;
  788. const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
  789. function isCoreComponent(tag) {
  790. if (isBuiltInType(tag, 'Teleport')) {
  791. return TELEPORT;
  792. }
  793. else if (isBuiltInType(tag, 'Suspense')) {
  794. return SUSPENSE;
  795. }
  796. else if (isBuiltInType(tag, 'KeepAlive')) {
  797. return KEEP_ALIVE;
  798. }
  799. else if (isBuiltInType(tag, 'BaseTransition')) {
  800. return BASE_TRANSITION;
  801. }
  802. }
  803. const nonIdentifierRE = /^\d|[^\$\w]/;
  804. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  805. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  806. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  807. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  808. /**
  809. * Simple lexer to check if an expression is a member expression. This is
  810. * lax and only checks validity at the root level (i.e. does not validate exps
  811. * inside square brackets), but it's ok since these are only used on template
  812. * expressions and false positives are invalid expressions in the first place.
  813. */
  814. const isMemberExpression = (path) => {
  815. // remove whitespaces around . or [ first
  816. path = path.trim().replace(whitespaceRE, s => s.trim());
  817. let state = 0 /* inMemberExp */;
  818. let stateStack = [];
  819. let currentOpenBracketCount = 0;
  820. let currentOpenParensCount = 0;
  821. let currentStringType = null;
  822. for (let i = 0; i < path.length; i++) {
  823. const char = path.charAt(i);
  824. switch (state) {
  825. case 0 /* inMemberExp */:
  826. if (char === '[') {
  827. stateStack.push(state);
  828. state = 1 /* inBrackets */;
  829. currentOpenBracketCount++;
  830. }
  831. else if (char === '(') {
  832. stateStack.push(state);
  833. state = 2 /* inParens */;
  834. currentOpenParensCount++;
  835. }
  836. else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  837. return false;
  838. }
  839. break;
  840. case 1 /* inBrackets */:
  841. if (char === `'` || char === `"` || char === '`') {
  842. stateStack.push(state);
  843. state = 3 /* inString */;
  844. currentStringType = char;
  845. }
  846. else if (char === `[`) {
  847. currentOpenBracketCount++;
  848. }
  849. else if (char === `]`) {
  850. if (!--currentOpenBracketCount) {
  851. state = stateStack.pop();
  852. }
  853. }
  854. break;
  855. case 2 /* inParens */:
  856. if (char === `'` || char === `"` || char === '`') {
  857. stateStack.push(state);
  858. state = 3 /* inString */;
  859. currentStringType = char;
  860. }
  861. else if (char === `(`) {
  862. currentOpenParensCount++;
  863. }
  864. else if (char === `)`) {
  865. // if the exp ends as a call then it should not be considered valid
  866. if (i === path.length - 1) {
  867. return false;
  868. }
  869. if (!--currentOpenParensCount) {
  870. state = stateStack.pop();
  871. }
  872. }
  873. break;
  874. case 3 /* inString */:
  875. if (char === currentStringType) {
  876. state = stateStack.pop();
  877. currentStringType = null;
  878. }
  879. break;
  880. }
  881. }
  882. return !currentOpenBracketCount && !currentOpenParensCount;
  883. };
  884. function getInnerRange(loc, offset, length) {
  885. const source = loc.source.substr(offset, length);
  886. const newLoc = {
  887. source,
  888. start: advancePositionWithClone(loc.start, loc.source, offset),
  889. end: loc.end
  890. };
  891. if (length != null) {
  892. newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
  893. }
  894. return newLoc;
  895. }
  896. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  897. return advancePositionWithMutation(extend({}, pos), source, numberOfCharacters);
  898. }
  899. // advance by mutation without cloning (for performance reasons), since this
  900. // gets called a lot in the parser
  901. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  902. let linesCount = 0;
  903. let lastNewLinePos = -1;
  904. for (let i = 0; i < numberOfCharacters; i++) {
  905. if (source.charCodeAt(i) === 10 /* newline char code */) {
  906. linesCount++;
  907. lastNewLinePos = i;
  908. }
  909. }
  910. pos.offset += numberOfCharacters;
  911. pos.line += linesCount;
  912. pos.column =
  913. lastNewLinePos === -1
  914. ? pos.column + numberOfCharacters
  915. : numberOfCharacters - lastNewLinePos;
  916. return pos;
  917. }
  918. function assert(condition, msg) {
  919. /* istanbul ignore if */
  920. if (!condition) {
  921. throw new Error(msg || `unexpected compiler condition`);
  922. }
  923. }
  924. function findDir(node, name, allowEmpty = false) {
  925. for (let i = 0; i < node.props.length; i++) {
  926. const p = node.props[i];
  927. if (p.type === 7 /* DIRECTIVE */ &&
  928. (allowEmpty || p.exp) &&
  929. (isString(name) ? p.name === name : name.test(p.name))) {
  930. return p;
  931. }
  932. }
  933. }
  934. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  935. for (let i = 0; i < node.props.length; i++) {
  936. const p = node.props[i];
  937. if (p.type === 6 /* ATTRIBUTE */) {
  938. if (dynamicOnly)
  939. continue;
  940. if (p.name === name && (p.value || allowEmpty)) {
  941. return p;
  942. }
  943. }
  944. else if (p.name === 'bind' &&
  945. (p.exp || allowEmpty) &&
  946. isBindKey(p.arg, name)) {
  947. return p;
  948. }
  949. }
  950. }
  951. function isBindKey(arg, name) {
  952. return !!(arg && isStaticExp(arg) && arg.content === name);
  953. }
  954. function hasDynamicKeyVBind(node) {
  955. return node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
  956. p.name === 'bind' &&
  957. (!p.arg || // v-bind="obj"
  958. p.arg.type !== 4 /* SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
  959. !p.arg.isStatic) // v-bind:[foo]
  960. );
  961. }
  962. function isText(node) {
  963. return node.type === 5 /* INTERPOLATION */ || node.type === 2 /* TEXT */;
  964. }
  965. function isVSlot(p) {
  966. return p.type === 7 /* DIRECTIVE */ && p.name === 'slot';
  967. }
  968. function isTemplateNode(node) {
  969. return (node.type === 1 /* ELEMENT */ && node.tagType === 3 /* TEMPLATE */);
  970. }
  971. function isSlotOutlet(node) {
  972. return node.type === 1 /* ELEMENT */ && node.tagType === 2 /* SLOT */;
  973. }
  974. function getVNodeHelper(ssr, isComponent) {
  975. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  976. }
  977. function getVNodeBlockHelper(ssr, isComponent) {
  978. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  979. }
  980. const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  981. function getUnnormalizedProps(props, callPath = []) {
  982. if (props &&
  983. !isString(props) &&
  984. props.type === 14 /* JS_CALL_EXPRESSION */) {
  985. const callee = props.callee;
  986. if (!isString(callee) && propsHelperSet.has(callee)) {
  987. return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
  988. }
  989. }
  990. return [props, callPath];
  991. }
  992. function injectProp(node, prop, context) {
  993. let propsWithInjection;
  994. const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
  995. /**
  996. * 1. mergeProps(...)
  997. * 2. toHandlers(...)
  998. * 3. normalizeProps(...)
  999. * 4. normalizeProps(guardReactiveProps(...))
  1000. *
  1001. * we need to get the real props before normalization
  1002. */
  1003. let props = originalProps;
  1004. let callPath = [];
  1005. let parentCall;
  1006. if (props &&
  1007. !isString(props) &&
  1008. props.type === 14 /* JS_CALL_EXPRESSION */) {
  1009. const ret = getUnnormalizedProps(props);
  1010. props = ret[0];
  1011. callPath = ret[1];
  1012. parentCall = callPath[callPath.length - 1];
  1013. }
  1014. if (props == null || isString(props)) {
  1015. propsWithInjection = createObjectExpression([prop]);
  1016. }
  1017. else if (props.type === 14 /* JS_CALL_EXPRESSION */) {
  1018. // merged props... add ours
  1019. // only inject key to object literal if it's the first argument so that
  1020. // if doesn't override user provided keys
  1021. const first = props.arguments[0];
  1022. if (!isString(first) && first.type === 15 /* JS_OBJECT_EXPRESSION */) {
  1023. first.properties.unshift(prop);
  1024. }
  1025. else {
  1026. if (props.callee === TO_HANDLERS) {
  1027. // #2366
  1028. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  1029. createObjectExpression([prop]),
  1030. props
  1031. ]);
  1032. }
  1033. else {
  1034. props.arguments.unshift(createObjectExpression([prop]));
  1035. }
  1036. }
  1037. !propsWithInjection && (propsWithInjection = props);
  1038. }
  1039. else if (props.type === 15 /* JS_OBJECT_EXPRESSION */) {
  1040. let alreadyExists = false;
  1041. // check existing key to avoid overriding user provided keys
  1042. if (prop.key.type === 4 /* SIMPLE_EXPRESSION */) {
  1043. const propKeyName = prop.key.content;
  1044. alreadyExists = props.properties.some(p => p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
  1045. p.key.content === propKeyName);
  1046. }
  1047. if (!alreadyExists) {
  1048. props.properties.unshift(prop);
  1049. }
  1050. propsWithInjection = props;
  1051. }
  1052. else {
  1053. // single v-bind with expression, return a merged replacement
  1054. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  1055. createObjectExpression([prop]),
  1056. props
  1057. ]);
  1058. // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(props))`,
  1059. // it will be rewritten as `normalizeProps(mergeProps({ key: 0 }, props))`,
  1060. // the `guardReactiveProps` will no longer be needed
  1061. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  1062. parentCall = callPath[callPath.length - 2];
  1063. }
  1064. }
  1065. if (node.type === 13 /* VNODE_CALL */) {
  1066. if (parentCall) {
  1067. parentCall.arguments[0] = propsWithInjection;
  1068. }
  1069. else {
  1070. node.props = propsWithInjection;
  1071. }
  1072. }
  1073. else {
  1074. if (parentCall) {
  1075. parentCall.arguments[0] = propsWithInjection;
  1076. }
  1077. else {
  1078. node.arguments[2] = propsWithInjection;
  1079. }
  1080. }
  1081. }
  1082. function toValidAssetId(name, type) {
  1083. // see issue#4422, we need adding identifier on validAssetId if variable `name` has specific character
  1084. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  1085. return searchValue === '-' ? '_' : name.charCodeAt(replaceValue).toString();
  1086. })}`;
  1087. }
  1088. // Check if a node contains expressions that reference current context scope ids
  1089. function hasScopeRef(node, ids) {
  1090. if (!node || Object.keys(ids).length === 0) {
  1091. return false;
  1092. }
  1093. switch (node.type) {
  1094. case 1 /* ELEMENT */:
  1095. for (let i = 0; i < node.props.length; i++) {
  1096. const p = node.props[i];
  1097. if (p.type === 7 /* DIRECTIVE */ &&
  1098. (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  1099. return true;
  1100. }
  1101. }
  1102. return node.children.some(c => hasScopeRef(c, ids));
  1103. case 11 /* FOR */:
  1104. if (hasScopeRef(node.source, ids)) {
  1105. return true;
  1106. }
  1107. return node.children.some(c => hasScopeRef(c, ids));
  1108. case 9 /* IF */:
  1109. return node.branches.some(b => hasScopeRef(b, ids));
  1110. case 10 /* IF_BRANCH */:
  1111. if (hasScopeRef(node.condition, ids)) {
  1112. return true;
  1113. }
  1114. return node.children.some(c => hasScopeRef(c, ids));
  1115. case 4 /* SIMPLE_EXPRESSION */:
  1116. return (!node.isStatic &&
  1117. isSimpleIdentifier(node.content) &&
  1118. !!ids[node.content]);
  1119. case 8 /* COMPOUND_EXPRESSION */:
  1120. return node.children.some(c => isObject(c) && hasScopeRef(c, ids));
  1121. case 5 /* INTERPOLATION */:
  1122. case 12 /* TEXT_CALL */:
  1123. return hasScopeRef(node.content, ids);
  1124. case 2 /* TEXT */:
  1125. case 3 /* COMMENT */:
  1126. return false;
  1127. default:
  1128. return false;
  1129. }
  1130. }
  1131. function getMemoedVNodeCall(node) {
  1132. if (node.type === 14 /* JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
  1133. return node.arguments[1].returns;
  1134. }
  1135. else {
  1136. return node;
  1137. }
  1138. }
  1139. function makeBlock(node, { helper, removeHelper, inSSR }) {
  1140. if (!node.isBlock) {
  1141. node.isBlock = true;
  1142. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  1143. helper(OPEN_BLOCK);
  1144. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  1145. }
  1146. }
  1147. const deprecationData = {
  1148. ["COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */]: {
  1149. message: `Platform-native elements with "is" prop will no longer be ` +
  1150. `treated as components in Vue 3 unless the "is" value is explicitly ` +
  1151. `prefixed with "vue:".`,
  1152. link: `https://v3.vuejs.org/guide/migration/custom-elements-interop.html`
  1153. },
  1154. ["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
  1155. message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
  1156. `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
  1157. `\`v-model:${key}\`.`,
  1158. link: `https://v3.vuejs.org/guide/migration/v-model.html`
  1159. },
  1160. ["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
  1161. message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
  1162. `Vue 3 will automatically set a binding as DOM property when appropriate.`
  1163. },
  1164. ["COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */]: {
  1165. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
  1166. `object spread: it will now overwrite an existing non-mergeable attribute ` +
  1167. `that appears before v-bind in the case of conflict. ` +
  1168. `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
  1169. `You can also suppress this warning if the usage is intended.`,
  1170. link: `https://v3.vuejs.org/guide/migration/v-bind.html`
  1171. },
  1172. ["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
  1173. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  1174. link: `https://v3.vuejs.org/guide/migration/v-on-native-modifier-removed.html`
  1175. },
  1176. ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
  1177. message: `v-if / v-for precedence when used on the same element has changed ` +
  1178. `in Vue 3: v-if now takes higher precedence and will no longer have ` +
  1179. `access to v-for scope variables. It is best to avoid the ambiguity ` +
  1180. `with <template> tags or use a computed property that filters v-for ` +
  1181. `data source.`,
  1182. link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
  1183. },
  1184. ["COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */]: {
  1185. message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
  1186. `Consider using function refs or refactor to avoid ref usage altogether.`,
  1187. link: `https://v3.vuejs.org/guide/migration/array-refs.html`
  1188. },
  1189. ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
  1190. message: `<template> with no special directives will render as a native template ` +
  1191. `element instead of its inner content in Vue 3.`
  1192. },
  1193. ["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
  1194. message: `"inline-template" has been removed in Vue 3.`,
  1195. link: `https://v3.vuejs.org/guide/migration/inline-template-attribute.html`
  1196. },
  1197. ["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
  1198. message: `filters have been removed in Vue 3. ` +
  1199. `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
  1200. `Use method calls or computed properties instead.`,
  1201. link: `https://v3.vuejs.org/guide/migration/filters.html`
  1202. }
  1203. };
  1204. function getCompatValue(key, context) {
  1205. const config = context.options
  1206. ? context.options.compatConfig
  1207. : context.compatConfig;
  1208. const value = config && config[key];
  1209. if (key === 'MODE') {
  1210. return value || 3; // compiler defaults to v3 behavior
  1211. }
  1212. else {
  1213. return value;
  1214. }
  1215. }
  1216. function isCompatEnabled(key, context) {
  1217. const mode = getCompatValue('MODE', context);
  1218. const value = getCompatValue(key, context);
  1219. // in v3 mode, only enable if explicitly set to true
  1220. // otherwise enable for any non-false value
  1221. return mode === 3 ? value === true : value !== false;
  1222. }
  1223. function checkCompatEnabled(key, context, loc, ...args) {
  1224. const enabled = isCompatEnabled(key, context);
  1225. if (enabled) {
  1226. warnDeprecation(key, context, loc, ...args);
  1227. }
  1228. return enabled;
  1229. }
  1230. function warnDeprecation(key, context, loc, ...args) {
  1231. const val = getCompatValue(key, context);
  1232. if (val === 'suppress-warning') {
  1233. return;
  1234. }
  1235. const { message, link } = deprecationData[key];
  1236. const msg = `(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`;
  1237. const err = new SyntaxError(msg);
  1238. err.code = key;
  1239. if (loc)
  1240. err.loc = loc;
  1241. context.onWarn(err);
  1242. }
  1243. // The default decoder only provides escapes for characters reserved as part of
  1244. // the template syntax, and is only used if the custom renderer did not provide
  1245. // a platform-specific decoder.
  1246. const decodeRE = /&(gt|lt|amp|apos|quot);/g;
  1247. const decodeMap = {
  1248. gt: '>',
  1249. lt: '<',
  1250. amp: '&',
  1251. apos: "'",
  1252. quot: '"'
  1253. };
  1254. const defaultParserOptions = {
  1255. delimiters: [`{{`, `}}`],
  1256. getNamespace: () => 0 /* HTML */,
  1257. getTextMode: () => 0 /* DATA */,
  1258. isVoidTag: NO,
  1259. isPreTag: NO,
  1260. isCustomElement: NO,
  1261. decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
  1262. onError: defaultOnError,
  1263. onWarn: defaultOnWarn,
  1264. comments: true
  1265. };
  1266. function baseParse(content, options = {}) {
  1267. const context = createParserContext(content, options);
  1268. const start = getCursor(context);
  1269. return createRoot(parseChildren(context, 0 /* DATA */, []), getSelection(context, start));
  1270. }
  1271. function createParserContext(content, rawOptions) {
  1272. const options = extend({}, defaultParserOptions);
  1273. let key;
  1274. for (key in rawOptions) {
  1275. // @ts-ignore
  1276. options[key] =
  1277. rawOptions[key] === undefined
  1278. ? defaultParserOptions[key]
  1279. : rawOptions[key];
  1280. }
  1281. return {
  1282. options,
  1283. column: 1,
  1284. line: 1,
  1285. offset: 0,
  1286. originalSource: content,
  1287. source: content,
  1288. inPre: false,
  1289. inVPre: false,
  1290. onWarn: options.onWarn
  1291. };
  1292. }
  1293. function parseChildren(context, mode, ancestors) {
  1294. const parent = last(ancestors);
  1295. const ns = parent ? parent.ns : 0 /* HTML */;
  1296. const nodes = [];
  1297. while (!isEnd(context, mode, ancestors)) {
  1298. const s = context.source;
  1299. let node = undefined;
  1300. if (mode === 0 /* DATA */ || mode === 1 /* RCDATA */) {
  1301. if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
  1302. // '{{'
  1303. node = parseInterpolation(context, mode);
  1304. }
  1305. else if (mode === 0 /* DATA */ && s[0] === '<') {
  1306. // https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
  1307. if (s.length === 1) {
  1308. emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 1);
  1309. }
  1310. else if (s[1] === '!') {
  1311. // https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
  1312. if (startsWith(s, '<!--')) {
  1313. node = parseComment(context);
  1314. }
  1315. else if (startsWith(s, '<!DOCTYPE')) {
  1316. // Ignore DOCTYPE by a limitation.
  1317. node = parseBogusComment(context);
  1318. }
  1319. else if (startsWith(s, '<![CDATA[')) {
  1320. if (ns !== 0 /* HTML */) {
  1321. node = parseCDATA(context, ancestors);
  1322. }
  1323. else {
  1324. emitError(context, 1 /* CDATA_IN_HTML_CONTENT */);
  1325. node = parseBogusComment(context);
  1326. }
  1327. }
  1328. else {
  1329. emitError(context, 11 /* INCORRECTLY_OPENED_COMMENT */);
  1330. node = parseBogusComment(context);
  1331. }
  1332. }
  1333. else if (s[1] === '/') {
  1334. // https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
  1335. if (s.length === 2) {
  1336. emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 2);
  1337. }
  1338. else if (s[2] === '>') {
  1339. emitError(context, 14 /* MISSING_END_TAG_NAME */, 2);
  1340. advanceBy(context, 3);
  1341. continue;
  1342. }
  1343. else if (/[a-z]/i.test(s[2])) {
  1344. emitError(context, 23 /* X_INVALID_END_TAG */);
  1345. parseTag(context, 1 /* End */, parent);
  1346. continue;
  1347. }
  1348. else {
  1349. emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
  1350. node = parseBogusComment(context);
  1351. }
  1352. }
  1353. else if (/[a-z]/i.test(s[1])) {
  1354. node = parseElement(context, ancestors);
  1355. }
  1356. else if (s[1] === '?') {
  1357. emitError(context, 21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
  1358. node = parseBogusComment(context);
  1359. }
  1360. else {
  1361. emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
  1362. }
  1363. }
  1364. }
  1365. if (!node) {
  1366. node = parseText(context, mode);
  1367. }
  1368. if (isArray(node)) {
  1369. for (let i = 0; i < node.length; i++) {
  1370. pushNode(nodes, node[i]);
  1371. }
  1372. }
  1373. else {
  1374. pushNode(nodes, node);
  1375. }
  1376. }
  1377. // Whitespace handling strategy like v2
  1378. let removedWhitespace = false;
  1379. if (mode !== 2 /* RAWTEXT */ && mode !== 1 /* RCDATA */) {
  1380. const shouldCondense = context.options.whitespace !== 'preserve';
  1381. for (let i = 0; i < nodes.length; i++) {
  1382. const node = nodes[i];
  1383. if (!context.inPre && node.type === 2 /* TEXT */) {
  1384. if (!/[^\t\r\n\f ]/.test(node.content)) {
  1385. const prev = nodes[i - 1];
  1386. const next = nodes[i + 1];
  1387. // Remove if:
  1388. // - the whitespace is the first or last node, or:
  1389. // - (condense mode) the whitespace is adjacent to a comment, or:
  1390. // - (condense mode) the whitespace is between two elements AND contains newline
  1391. if (!prev ||
  1392. !next ||
  1393. (shouldCondense &&
  1394. (prev.type === 3 /* COMMENT */ ||
  1395. next.type === 3 /* COMMENT */ ||
  1396. (prev.type === 1 /* ELEMENT */ &&
  1397. next.type === 1 /* ELEMENT */ &&
  1398. /[\r\n]/.test(node.content))))) {
  1399. removedWhitespace = true;
  1400. nodes[i] = null;
  1401. }
  1402. else {
  1403. // Otherwise, the whitespace is condensed into a single space
  1404. node.content = ' ';
  1405. }
  1406. }
  1407. else if (shouldCondense) {
  1408. // in condense mode, consecutive whitespaces in text are condensed
  1409. // down to a single space.
  1410. node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
  1411. }
  1412. }
  1413. // Remove comment nodes if desired by configuration.
  1414. else if (node.type === 3 /* COMMENT */ && !context.options.comments) {
  1415. removedWhitespace = true;
  1416. nodes[i] = null;
  1417. }
  1418. }
  1419. if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
  1420. // remove leading newline per html spec
  1421. // https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
  1422. const first = nodes[0];
  1423. if (first && first.type === 2 /* TEXT */) {
  1424. first.content = first.content.replace(/^\r?\n/, '');
  1425. }
  1426. }
  1427. }
  1428. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  1429. }
  1430. function pushNode(nodes, node) {
  1431. if (node.type === 2 /* TEXT */) {
  1432. const prev = last(nodes);
  1433. // Merge if both this and the previous node are text and those are
  1434. // consecutive. This happens for cases like "a < b".
  1435. if (prev &&
  1436. prev.type === 2 /* TEXT */ &&
  1437. prev.loc.end.offset === node.loc.start.offset) {
  1438. prev.content += node.content;
  1439. prev.loc.end = node.loc.end;
  1440. prev.loc.source += node.loc.source;
  1441. return;
  1442. }
  1443. }
  1444. nodes.push(node);
  1445. }
  1446. function parseCDATA(context, ancestors) {
  1447. advanceBy(context, 9);
  1448. const nodes = parseChildren(context, 3 /* CDATA */, ancestors);
  1449. if (context.source.length === 0) {
  1450. emitError(context, 6 /* EOF_IN_CDATA */);
  1451. }
  1452. else {
  1453. advanceBy(context, 3);
  1454. }
  1455. return nodes;
  1456. }
  1457. function parseComment(context) {
  1458. const start = getCursor(context);
  1459. let content;
  1460. // Regular comment.
  1461. const match = /--(\!)?>/.exec(context.source);
  1462. if (!match) {
  1463. content = context.source.slice(4);
  1464. advanceBy(context, context.source.length);
  1465. emitError(context, 7 /* EOF_IN_COMMENT */);
  1466. }
  1467. else {
  1468. if (match.index <= 3) {
  1469. emitError(context, 0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
  1470. }
  1471. if (match[1]) {
  1472. emitError(context, 10 /* INCORRECTLY_CLOSED_COMMENT */);
  1473. }
  1474. content = context.source.slice(4, match.index);
  1475. // Advancing with reporting nested comments.
  1476. const s = context.source.slice(0, match.index);
  1477. let prevIndex = 1, nestedIndex = 0;
  1478. while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
  1479. advanceBy(context, nestedIndex - prevIndex + 1);
  1480. if (nestedIndex + 4 < s.length) {
  1481. emitError(context, 16 /* NESTED_COMMENT */);
  1482. }
  1483. prevIndex = nestedIndex + 1;
  1484. }
  1485. advanceBy(context, match.index + match[0].length - prevIndex + 1);
  1486. }
  1487. return {
  1488. type: 3 /* COMMENT */,
  1489. content,
  1490. loc: getSelection(context, start)
  1491. };
  1492. }
  1493. function parseBogusComment(context) {
  1494. const start = getCursor(context);
  1495. const contentStart = context.source[1] === '?' ? 1 : 2;
  1496. let content;
  1497. const closeIndex = context.source.indexOf('>');
  1498. if (closeIndex === -1) {
  1499. content = context.source.slice(contentStart);
  1500. advanceBy(context, context.source.length);
  1501. }
  1502. else {
  1503. content = context.source.slice(contentStart, closeIndex);
  1504. advanceBy(context, closeIndex + 1);
  1505. }
  1506. return {
  1507. type: 3 /* COMMENT */,
  1508. content,
  1509. loc: getSelection(context, start)
  1510. };
  1511. }
  1512. function parseElement(context, ancestors) {
  1513. // Start tag.
  1514. const wasInPre = context.inPre;
  1515. const wasInVPre = context.inVPre;
  1516. const parent = last(ancestors);
  1517. const element = parseTag(context, 0 /* Start */, parent);
  1518. const isPreBoundary = context.inPre && !wasInPre;
  1519. const isVPreBoundary = context.inVPre && !wasInVPre;
  1520. if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
  1521. // #4030 self-closing <pre> tag
  1522. if (isPreBoundary) {
  1523. context.inPre = false;
  1524. }
  1525. if (isVPreBoundary) {
  1526. context.inVPre = false;
  1527. }
  1528. return element;
  1529. }
  1530. // Children.
  1531. ancestors.push(element);
  1532. const mode = context.options.getTextMode(element, parent);
  1533. const children = parseChildren(context, mode, ancestors);
  1534. ancestors.pop();
  1535. element.children = children;
  1536. // End tag.
  1537. if (startsWithEndTagOpen(context.source, element.tag)) {
  1538. parseTag(context, 1 /* End */, parent);
  1539. }
  1540. else {
  1541. emitError(context, 24 /* X_MISSING_END_TAG */, 0, element.loc.start);
  1542. if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
  1543. const first = children[0];
  1544. if (first && startsWith(first.loc.source, '<!--')) {
  1545. emitError(context, 8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
  1546. }
  1547. }
  1548. }
  1549. element.loc = getSelection(context, element.loc.start);
  1550. if (isPreBoundary) {
  1551. context.inPre = false;
  1552. }
  1553. if (isVPreBoundary) {
  1554. context.inVPre = false;
  1555. }
  1556. return element;
  1557. }
  1558. const isSpecialTemplateDirective = /*#__PURE__*/ makeMap(`if,else,else-if,for,slot`);
  1559. function parseTag(context, type, parent) {
  1560. // Tag open.
  1561. const start = getCursor(context);
  1562. const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
  1563. const tag = match[1];
  1564. const ns = context.options.getNamespace(tag, parent);
  1565. advanceBy(context, match[0].length);
  1566. advanceSpaces(context);
  1567. // save current state in case we need to re-parse attributes with v-pre
  1568. const cursor = getCursor(context);
  1569. const currentSource = context.source;
  1570. // check <pre> tag
  1571. if (context.options.isPreTag(tag)) {
  1572. context.inPre = true;
  1573. }
  1574. // Attributes.
  1575. let props = parseAttributes(context, type);
  1576. // check v-pre
  1577. if (type === 0 /* Start */ &&
  1578. !context.inVPre &&
  1579. props.some(p => p.type === 7 /* DIRECTIVE */ && p.name === 'pre')) {
  1580. context.inVPre = true;
  1581. // reset context
  1582. extend(context, cursor);
  1583. context.source = currentSource;
  1584. // re-parse attrs and filter out v-pre itself
  1585. props = parseAttributes(context, type).filter(p => p.name !== 'v-pre');
  1586. }
  1587. // Tag close.
  1588. let isSelfClosing = false;
  1589. if (context.source.length === 0) {
  1590. emitError(context, 9 /* EOF_IN_TAG */);
  1591. }
  1592. else {
  1593. isSelfClosing = startsWith(context.source, '/>');
  1594. if (type === 1 /* End */ && isSelfClosing) {
  1595. emitError(context, 4 /* END_TAG_WITH_TRAILING_SOLIDUS */);
  1596. }
  1597. advanceBy(context, isSelfClosing ? 2 : 1);
  1598. }
  1599. if (type === 1 /* End */) {
  1600. return;
  1601. }
  1602. let tagType = 0 /* ELEMENT */;
  1603. if (!context.inVPre) {
  1604. if (tag === 'slot') {
  1605. tagType = 2 /* SLOT */;
  1606. }
  1607. else if (tag === 'template') {
  1608. if (props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
  1609. tagType = 3 /* TEMPLATE */;
  1610. }
  1611. }
  1612. else if (isComponent(tag, props, context)) {
  1613. tagType = 1 /* COMPONENT */;
  1614. }
  1615. }
  1616. return {
  1617. type: 1 /* ELEMENT */,
  1618. ns,
  1619. tag,
  1620. tagType,
  1621. props,
  1622. isSelfClosing,
  1623. children: [],
  1624. loc: getSelection(context, start),
  1625. codegenNode: undefined // to be created during transform phase
  1626. };
  1627. }
  1628. function isComponent(tag, props, context) {
  1629. const options = context.options;
  1630. if (options.isCustomElement(tag)) {
  1631. return false;
  1632. }
  1633. if (tag === 'component' ||
  1634. /^[A-Z]/.test(tag) ||
  1635. isCoreComponent(tag) ||
  1636. (options.isBuiltInComponent && options.isBuiltInComponent(tag)) ||
  1637. (options.isNativeTag && !options.isNativeTag(tag))) {
  1638. return true;
  1639. }
  1640. // at this point the tag should be a native tag, but check for potential "is"
  1641. // casting
  1642. for (let i = 0; i < props.length; i++) {
  1643. const p = props[i];
  1644. if (p.type === 6 /* ATTRIBUTE */) {
  1645. if (p.name === 'is' && p.value) {
  1646. if (p.value.content.startsWith('vue:')) {
  1647. return true;
  1648. }
  1649. }
  1650. }
  1651. else {
  1652. // directive
  1653. // v-is (TODO Deprecate)
  1654. if (p.name === 'is') {
  1655. return true;
  1656. }
  1657. else if (
  1658. // :is on plain element - only treat as component in compat mode
  1659. p.name === 'bind' &&
  1660. isBindKey(p.arg, 'is') &&
  1661. false &&
  1662. checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
  1663. return true;
  1664. }
  1665. }
  1666. }
  1667. }
  1668. function parseAttributes(context, type) {
  1669. const props = [];
  1670. const attributeNames = new Set();
  1671. while (context.source.length > 0 &&
  1672. !startsWith(context.source, '>') &&
  1673. !startsWith(context.source, '/>')) {
  1674. if (startsWith(context.source, '/')) {
  1675. emitError(context, 22 /* UNEXPECTED_SOLIDUS_IN_TAG */);
  1676. advanceBy(context, 1);
  1677. advanceSpaces(context);
  1678. continue;
  1679. }
  1680. if (type === 1 /* End */) {
  1681. emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
  1682. }
  1683. const attr = parseAttribute(context, attributeNames);
  1684. if (type === 0 /* Start */) {
  1685. props.push(attr);
  1686. }
  1687. if (/^[^\t\r\n\f />]/.test(context.source)) {
  1688. emitError(context, 15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
  1689. }
  1690. advanceSpaces(context);
  1691. }
  1692. return props;
  1693. }
  1694. function parseAttribute(context, nameSet) {
  1695. // Name.
  1696. const start = getCursor(context);
  1697. const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
  1698. const name = match[0];
  1699. if (nameSet.has(name)) {
  1700. emitError(context, 2 /* DUPLICATE_ATTRIBUTE */);
  1701. }
  1702. nameSet.add(name);
  1703. if (name[0] === '=') {
  1704. emitError(context, 19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
  1705. }
  1706. {
  1707. const pattern = /["'<]/g;
  1708. let m;
  1709. while ((m = pattern.exec(name))) {
  1710. emitError(context, 17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
  1711. }
  1712. }
  1713. advanceBy(context, name.length);
  1714. // Value
  1715. let value = undefined;
  1716. if (/^[\t\r\n\f ]*=/.test(context.source)) {
  1717. advanceSpaces(context);
  1718. advanceBy(context, 1);
  1719. advanceSpaces(context);
  1720. value = parseAttributeValue(context);
  1721. if (!value) {
  1722. emitError(context, 13 /* MISSING_ATTRIBUTE_VALUE */);
  1723. }
  1724. }
  1725. const loc = getSelection(context, start);
  1726. if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
  1727. const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
  1728. let isPropShorthand = startsWith(name, '.');
  1729. let dirName = match[1] ||
  1730. (isPropShorthand || startsWith(name, ':')
  1731. ? 'bind'
  1732. : startsWith(name, '@')
  1733. ? 'on'
  1734. : 'slot');
  1735. let arg;
  1736. if (match[2]) {
  1737. const isSlot = dirName === 'slot';
  1738. const startOffset = name.lastIndexOf(match[2]);
  1739. const loc = getSelection(context, getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset + match[2].length + ((isSlot && match[3]) || '').length));
  1740. let content = match[2];
  1741. let isStatic = true;
  1742. if (content.startsWith('[')) {
  1743. isStatic = false;
  1744. if (!content.endsWith(']')) {
  1745. emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
  1746. }
  1747. content = content.substr(1, content.length - 2);
  1748. }
  1749. else if (isSlot) {
  1750. // #1241 special case for v-slot: vuetify relies extensively on slot
  1751. // names containing dots. v-slot doesn't have any modifiers and Vue 2.x
  1752. // supports such usage so we are keeping it consistent with 2.x.
  1753. content += match[3] || '';
  1754. }
  1755. arg = {
  1756. type: 4 /* SIMPLE_EXPRESSION */,
  1757. content,
  1758. isStatic,
  1759. constType: isStatic
  1760. ? 3 /* CAN_STRINGIFY */
  1761. : 0 /* NOT_CONSTANT */,
  1762. loc
  1763. };
  1764. }
  1765. if (value && value.isQuoted) {
  1766. const valueLoc = value.loc;
  1767. valueLoc.start.offset++;
  1768. valueLoc.start.column++;
  1769. valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
  1770. valueLoc.source = valueLoc.source.slice(1, -1);
  1771. }
  1772. const modifiers = match[3] ? match[3].substr(1).split('.') : [];
  1773. if (isPropShorthand)
  1774. modifiers.push('prop');
  1775. return {
  1776. type: 7 /* DIRECTIVE */,
  1777. name: dirName,
  1778. exp: value && {
  1779. type: 4 /* SIMPLE_EXPRESSION */,
  1780. content: value.content,
  1781. isStatic: false,
  1782. // Treat as non-constant by default. This can be potentially set to
  1783. // other values by `transformExpression` to make it eligible for hoisting.
  1784. constType: 0 /* NOT_CONSTANT */,
  1785. loc: value.loc
  1786. },
  1787. arg,
  1788. modifiers,
  1789. loc
  1790. };
  1791. }
  1792. // missing directive name or illegal directive name
  1793. if (!context.inVPre && startsWith(name, 'v-')) {
  1794. emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
  1795. }
  1796. return {
  1797. type: 6 /* ATTRIBUTE */,
  1798. name,
  1799. value: value && {
  1800. type: 2 /* TEXT */,
  1801. content: value.content,
  1802. loc: value.loc
  1803. },
  1804. loc
  1805. };
  1806. }
  1807. function parseAttributeValue(context) {
  1808. const start = getCursor(context);
  1809. let content;
  1810. const quote = context.source[0];
  1811. const isQuoted = quote === `"` || quote === `'`;
  1812. if (isQuoted) {
  1813. // Quoted value.
  1814. advanceBy(context, 1);
  1815. const endIndex = context.source.indexOf(quote);
  1816. if (endIndex === -1) {
  1817. content = parseTextData(context, context.source.length, 4 /* ATTRIBUTE_VALUE */);
  1818. }
  1819. else {
  1820. content = parseTextData(context, endIndex, 4 /* ATTRIBUTE_VALUE */);
  1821. advanceBy(context, 1);
  1822. }
  1823. }
  1824. else {
  1825. // Unquoted
  1826. const match = /^[^\t\r\n\f >]+/.exec(context.source);
  1827. if (!match) {
  1828. return undefined;
  1829. }
  1830. const unexpectedChars = /["'<=`]/g;
  1831. let m;
  1832. while ((m = unexpectedChars.exec(match[0]))) {
  1833. emitError(context, 18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
  1834. }
  1835. content = parseTextData(context, match[0].length, 4 /* ATTRIBUTE_VALUE */);
  1836. }
  1837. return { content, isQuoted, loc: getSelection(context, start) };
  1838. }
  1839. function parseInterpolation(context, mode) {
  1840. const [open, close] = context.options.delimiters;
  1841. const closeIndex = context.source.indexOf(close, open.length);
  1842. if (closeIndex === -1) {
  1843. emitError(context, 25 /* X_MISSING_INTERPOLATION_END */);
  1844. return undefined;
  1845. }
  1846. const start = getCursor(context);
  1847. advanceBy(context, open.length);
  1848. const innerStart = getCursor(context);
  1849. const innerEnd = getCursor(context);
  1850. const rawContentLength = closeIndex - open.length;
  1851. const rawContent = context.source.slice(0, rawContentLength);
  1852. const preTrimContent = parseTextData(context, rawContentLength, mode);
  1853. const content = preTrimContent.trim();
  1854. const startOffset = preTrimContent.indexOf(content);
  1855. if (startOffset > 0) {
  1856. advancePositionWithMutation(innerStart, rawContent, startOffset);
  1857. }
  1858. const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
  1859. advancePositionWithMutation(innerEnd, rawContent, endOffset);
  1860. advanceBy(context, close.length);
  1861. return {
  1862. type: 5 /* INTERPOLATION */,
  1863. content: {
  1864. type: 4 /* SIMPLE_EXPRESSION */,
  1865. isStatic: false,
  1866. // Set `isConstant` to false by default and will decide in transformExpression
  1867. constType: 0 /* NOT_CONSTANT */,
  1868. content,
  1869. loc: getSelection(context, innerStart, innerEnd)
  1870. },
  1871. loc: getSelection(context, start)
  1872. };
  1873. }
  1874. function parseText(context, mode) {
  1875. const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
  1876. let endIndex = context.source.length;
  1877. for (let i = 0; i < endTokens.length; i++) {
  1878. const index = context.source.indexOf(endTokens[i], 1);
  1879. if (index !== -1 && endIndex > index) {
  1880. endIndex = index;
  1881. }
  1882. }
  1883. const start = getCursor(context);
  1884. const content = parseTextData(context, endIndex, mode);
  1885. return {
  1886. type: 2 /* TEXT */,
  1887. content,
  1888. loc: getSelection(context, start)
  1889. };
  1890. }
  1891. /**
  1892. * Get text data with a given length from the current location.
  1893. * This translates HTML entities in the text data.
  1894. */
  1895. function parseTextData(context, length, mode) {
  1896. const rawText = context.source.slice(0, length);
  1897. advanceBy(context, length);
  1898. if (mode === 2 /* RAWTEXT */ ||
  1899. mode === 3 /* CDATA */ ||
  1900. rawText.indexOf('&') === -1) {
  1901. return rawText;
  1902. }
  1903. else {
  1904. // DATA or RCDATA containing "&"". Entity decoding required.
  1905. return context.options.decodeEntities(rawText, mode === 4 /* ATTRIBUTE_VALUE */);
  1906. }
  1907. }
  1908. function getCursor(context) {
  1909. const { column, line, offset } = context;
  1910. return { column, line, offset };
  1911. }
  1912. function getSelection(context, start, end) {
  1913. end = end || getCursor(context);
  1914. return {
  1915. start,
  1916. end,
  1917. source: context.originalSource.slice(start.offset, end.offset)
  1918. };
  1919. }
  1920. function last(xs) {
  1921. return xs[xs.length - 1];
  1922. }
  1923. function startsWith(source, searchString) {
  1924. return source.startsWith(searchString);
  1925. }
  1926. function advanceBy(context, numberOfCharacters) {
  1927. const { source } = context;
  1928. advancePositionWithMutation(context, source, numberOfCharacters);
  1929. context.source = source.slice(numberOfCharacters);
  1930. }
  1931. function advanceSpaces(context) {
  1932. const match = /^[\t\r\n\f ]+/.exec(context.source);
  1933. if (match) {
  1934. advanceBy(context, match[0].length);
  1935. }
  1936. }
  1937. function getNewPosition(context, start, numberOfCharacters) {
  1938. return advancePositionWithClone(start, context.originalSource.slice(start.offset, numberOfCharacters), numberOfCharacters);
  1939. }
  1940. function emitError(context, code, offset, loc = getCursor(context)) {
  1941. if (offset) {
  1942. loc.offset += offset;
  1943. loc.column += offset;
  1944. }
  1945. context.options.onError(createCompilerError(code, {
  1946. start: loc,
  1947. end: loc,
  1948. source: ''
  1949. }));
  1950. }
  1951. function isEnd(context, mode, ancestors) {
  1952. const s = context.source;
  1953. switch (mode) {
  1954. case 0 /* DATA */:
  1955. if (startsWith(s, '</')) {
  1956. // TODO: probably bad performance
  1957. for (let i = ancestors.length - 1; i >= 0; --i) {
  1958. if (startsWithEndTagOpen(s, ancestors[i].tag)) {
  1959. return true;
  1960. }
  1961. }
  1962. }
  1963. break;
  1964. case 1 /* RCDATA */:
  1965. case 2 /* RAWTEXT */: {
  1966. const parent = last(ancestors);
  1967. if (parent && startsWithEndTagOpen(s, parent.tag)) {
  1968. return true;
  1969. }
  1970. break;
  1971. }
  1972. case 3 /* CDATA */:
  1973. if (startsWith(s, ']]>')) {
  1974. return true;
  1975. }
  1976. break;
  1977. }
  1978. return !s;
  1979. }
  1980. function startsWithEndTagOpen(source, tag) {
  1981. return (startsWith(source, '</') &&
  1982. source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
  1983. /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
  1984. }
  1985. function hoistStatic(root, context) {
  1986. walk(root, context,
  1987. // Root node is unfortunately non-hoistable due to potential parent
  1988. // fallthrough attributes.
  1989. isSingleElementRoot(root, root.children[0]));
  1990. }
  1991. function isSingleElementRoot(root, child) {
  1992. const { children } = root;
  1993. return (children.length === 1 &&
  1994. child.type === 1 /* ELEMENT */ &&
  1995. !isSlotOutlet(child));
  1996. }
  1997. function walk(node, context, doNotHoistNode = false) {
  1998. // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
  1999. // static bindings with expressions. These expressions are guaranteed to be
  2000. // constant so they are still eligible for hoisting, but they are only
  2001. // available at runtime and therefore cannot be evaluated ahead of time.
  2002. // This is only a concern for pre-stringification (via transformHoist by
  2003. // @vue/compiler-dom), but doing it here allows us to perform only one full
  2004. // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
  2005. // stringficiation threshold is met.
  2006. let canStringify = true;
  2007. const { children } = node;
  2008. const originalCount = children.length;
  2009. let hoistedCount = 0;
  2010. for (let i = 0; i < children.length; i++) {
  2011. const child = children[i];
  2012. // only plain elements & text calls are eligible for hoisting.
  2013. if (child.type === 1 /* ELEMENT */ &&
  2014. child.tagType === 0 /* ELEMENT */) {
  2015. const constantType = doNotHoistNode
  2016. ? 0 /* NOT_CONSTANT */
  2017. : getConstantType(child, context);
  2018. if (constantType > 0 /* NOT_CONSTANT */) {
  2019. if (constantType < 3 /* CAN_STRINGIFY */) {
  2020. canStringify = false;
  2021. }
  2022. if (constantType >= 2 /* CAN_HOIST */) {
  2023. child.codegenNode.patchFlag =
  2024. -1 /* HOISTED */ + (` /* HOISTED */` );
  2025. child.codegenNode = context.hoist(child.codegenNode);
  2026. hoistedCount++;
  2027. continue;
  2028. }
  2029. }
  2030. else {
  2031. // node may contain dynamic children, but its props may be eligible for
  2032. // hoisting.
  2033. const codegenNode = child.codegenNode;
  2034. if (codegenNode.type === 13 /* VNODE_CALL */) {
  2035. const flag = getPatchFlag(codegenNode);
  2036. if ((!flag ||
  2037. flag === 512 /* NEED_PATCH */ ||
  2038. flag === 1 /* TEXT */) &&
  2039. getGeneratedPropsConstantType(child, context) >=
  2040. 2 /* CAN_HOIST */) {
  2041. const props = getNodeProps(child);
  2042. if (props) {
  2043. codegenNode.props = context.hoist(props);
  2044. }
  2045. }
  2046. if (codegenNode.dynamicProps) {
  2047. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  2048. }
  2049. }
  2050. }
  2051. }
  2052. else if (child.type === 12 /* TEXT_CALL */) {
  2053. const contentType = getConstantType(child.content, context);
  2054. if (contentType > 0) {
  2055. if (contentType < 3 /* CAN_STRINGIFY */) {
  2056. canStringify = false;
  2057. }
  2058. if (contentType >= 2 /* CAN_HOIST */) {
  2059. child.codegenNode = context.hoist(child.codegenNode);
  2060. hoistedCount++;
  2061. }
  2062. }
  2063. }
  2064. // walk further
  2065. if (child.type === 1 /* ELEMENT */) {
  2066. const isComponent = child.tagType === 1 /* COMPONENT */;
  2067. if (isComponent) {
  2068. context.scopes.vSlot++;
  2069. }
  2070. walk(child, context);
  2071. if (isComponent) {
  2072. context.scopes.vSlot--;
  2073. }
  2074. }
  2075. else if (child.type === 11 /* FOR */) {
  2076. // Do not hoist v-for single child because it has to be a block
  2077. walk(child, context, child.children.length === 1);
  2078. }
  2079. else if (child.type === 9 /* IF */) {
  2080. for (let i = 0; i < child.branches.length; i++) {
  2081. // Do not hoist v-if single child because it has to be a block
  2082. walk(child.branches[i], context, child.branches[i].children.length === 1);
  2083. }
  2084. }
  2085. }
  2086. if (canStringify && hoistedCount && context.transformHoist) {
  2087. context.transformHoist(children, context, node);
  2088. }
  2089. // all children were hoisted - the entire children array is hoistable.
  2090. if (hoistedCount &&
  2091. hoistedCount === originalCount &&
  2092. node.type === 1 /* ELEMENT */ &&
  2093. node.tagType === 0 /* ELEMENT */ &&
  2094. node.codegenNode &&
  2095. node.codegenNode.type === 13 /* VNODE_CALL */ &&
  2096. isArray(node.codegenNode.children)) {
  2097. node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
  2098. }
  2099. }
  2100. function getConstantType(node, context) {
  2101. const { constantCache } = context;
  2102. switch (node.type) {
  2103. case 1 /* ELEMENT */:
  2104. if (node.tagType !== 0 /* ELEMENT */) {
  2105. return 0 /* NOT_CONSTANT */;
  2106. }
  2107. const cached = constantCache.get(node);
  2108. if (cached !== undefined) {
  2109. return cached;
  2110. }
  2111. const codegenNode = node.codegenNode;
  2112. if (codegenNode.type !== 13 /* VNODE_CALL */) {
  2113. return 0 /* NOT_CONSTANT */;
  2114. }
  2115. const flag = getPatchFlag(codegenNode);
  2116. if (!flag) {
  2117. let returnType = 3 /* CAN_STRINGIFY */;
  2118. // Element itself has no patch flag. However we still need to check:
  2119. // 1. Even for a node with no patch flag, it is possible for it to contain
  2120. // non-hoistable expressions that refers to scope variables, e.g. compiler
  2121. // injected keys or cached event handlers. Therefore we need to always
  2122. // check the codegenNode's props to be sure.
  2123. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  2124. if (generatedPropsType === 0 /* NOT_CONSTANT */) {
  2125. constantCache.set(node, 0 /* NOT_CONSTANT */);
  2126. return 0 /* NOT_CONSTANT */;
  2127. }
  2128. if (generatedPropsType < returnType) {
  2129. returnType = generatedPropsType;
  2130. }
  2131. // 2. its children.
  2132. for (let i = 0; i < node.children.length; i++) {
  2133. const childType = getConstantType(node.children[i], context);
  2134. if (childType === 0 /* NOT_CONSTANT */) {
  2135. constantCache.set(node, 0 /* NOT_CONSTANT */);
  2136. return 0 /* NOT_CONSTANT */;
  2137. }
  2138. if (childType < returnType) {
  2139. returnType = childType;
  2140. }
  2141. }
  2142. // 3. if the type is not already CAN_SKIP_PATCH which is the lowest non-0
  2143. // type, check if any of the props can cause the type to be lowered
  2144. // we can skip can_patch because it's guaranteed by the absence of a
  2145. // patchFlag.
  2146. if (returnType > 1 /* CAN_SKIP_PATCH */) {
  2147. for (let i = 0; i < node.props.length; i++) {
  2148. const p = node.props[i];
  2149. if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind' && p.exp) {
  2150. const expType = getConstantType(p.exp, context);
  2151. if (expType === 0 /* NOT_CONSTANT */) {
  2152. constantCache.set(node, 0 /* NOT_CONSTANT */);
  2153. return 0 /* NOT_CONSTANT */;
  2154. }
  2155. if (expType < returnType) {
  2156. returnType = expType;
  2157. }
  2158. }
  2159. }
  2160. }
  2161. // only svg/foreignObject could be block here, however if they are
  2162. // static then they don't need to be blocks since there will be no
  2163. // nested updates.
  2164. if (codegenNode.isBlock) {
  2165. context.removeHelper(OPEN_BLOCK);
  2166. context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
  2167. codegenNode.isBlock = false;
  2168. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  2169. }
  2170. constantCache.set(node, returnType);
  2171. return returnType;
  2172. }
  2173. else {
  2174. constantCache.set(node, 0 /* NOT_CONSTANT */);
  2175. return 0 /* NOT_CONSTANT */;
  2176. }
  2177. case 2 /* TEXT */:
  2178. case 3 /* COMMENT */:
  2179. return 3 /* CAN_STRINGIFY */;
  2180. case 9 /* IF */:
  2181. case 11 /* FOR */:
  2182. case 10 /* IF_BRANCH */:
  2183. return 0 /* NOT_CONSTANT */;
  2184. case 5 /* INTERPOLATION */:
  2185. case 12 /* TEXT_CALL */:
  2186. return getConstantType(node.content, context);
  2187. case 4 /* SIMPLE_EXPRESSION */:
  2188. return node.constType;
  2189. case 8 /* COMPOUND_EXPRESSION */:
  2190. let returnType = 3 /* CAN_STRINGIFY */;
  2191. for (let i = 0; i < node.children.length; i++) {
  2192. const child = node.children[i];
  2193. if (isString(child) || isSymbol(child)) {
  2194. continue;
  2195. }
  2196. const childType = getConstantType(child, context);
  2197. if (childType === 0 /* NOT_CONSTANT */) {
  2198. return 0 /* NOT_CONSTANT */;
  2199. }
  2200. else if (childType < returnType) {
  2201. returnType = childType;
  2202. }
  2203. }
  2204. return returnType;
  2205. default:
  2206. return 0 /* NOT_CONSTANT */;
  2207. }
  2208. }
  2209. const allowHoistedHelperSet = new Set([
  2210. NORMALIZE_CLASS,
  2211. NORMALIZE_STYLE,
  2212. NORMALIZE_PROPS,
  2213. GUARD_REACTIVE_PROPS
  2214. ]);
  2215. function getConstantTypeOfHelperCall(value, context) {
  2216. if (value.type === 14 /* JS_CALL_EXPRESSION */ &&
  2217. !isString(value.callee) &&
  2218. allowHoistedHelperSet.has(value.callee)) {
  2219. const arg = value.arguments[0];
  2220. if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
  2221. return getConstantType(arg, context);
  2222. }
  2223. else if (arg.type === 14 /* JS_CALL_EXPRESSION */) {
  2224. // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
  2225. return getConstantTypeOfHelperCall(arg, context);
  2226. }
  2227. }
  2228. return 0 /* NOT_CONSTANT */;
  2229. }
  2230. function getGeneratedPropsConstantType(node, context) {
  2231. let returnType = 3 /* CAN_STRINGIFY */;
  2232. const props = getNodeProps(node);
  2233. if (props && props.type === 15 /* JS_OBJECT_EXPRESSION */) {
  2234. const { properties } = props;
  2235. for (let i = 0; i < properties.length; i++) {
  2236. const { key, value } = properties[i];
  2237. const keyType = getConstantType(key, context);
  2238. if (keyType === 0 /* NOT_CONSTANT */) {
  2239. return keyType;
  2240. }
  2241. if (keyType < returnType) {
  2242. returnType = keyType;
  2243. }
  2244. let valueType;
  2245. if (value.type === 4 /* SIMPLE_EXPRESSION */) {
  2246. valueType = getConstantType(value, context);
  2247. }
  2248. else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
  2249. // some helper calls can be hoisted,
  2250. // such as the `normalizeProps` generated by the compiler for pre-normalize class,
  2251. // in this case we need to respect the ConstanType of the helper's argments
  2252. valueType = getConstantTypeOfHelperCall(value, context);
  2253. }
  2254. else {
  2255. valueType = 0 /* NOT_CONSTANT */;
  2256. }
  2257. if (valueType === 0 /* NOT_CONSTANT */) {
  2258. return valueType;
  2259. }
  2260. if (valueType < returnType) {
  2261. returnType = valueType;
  2262. }
  2263. }
  2264. }
  2265. return returnType;
  2266. }
  2267. function getNodeProps(node) {
  2268. const codegenNode = node.codegenNode;
  2269. if (codegenNode.type === 13 /* VNODE_CALL */) {
  2270. return codegenNode.props;
  2271. }
  2272. }
  2273. function getPatchFlag(node) {
  2274. const flag = node.patchFlag;
  2275. return flag ? parseInt(flag, 10) : undefined;
  2276. }
  2277. function createTransformContext(root, { filename = '', prefixIdentifiers = false, hoistStatic = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
  2278. const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/);
  2279. const context = {
  2280. // options
  2281. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  2282. prefixIdentifiers,
  2283. hoistStatic,
  2284. cacheHandlers,
  2285. nodeTransforms,
  2286. directiveTransforms,
  2287. transformHoist,
  2288. isBuiltInComponent,
  2289. isCustomElement,
  2290. expressionPlugins,
  2291. scopeId,
  2292. slotted,
  2293. ssr,
  2294. inSSR,
  2295. ssrCssVars,
  2296. bindingMetadata,
  2297. inline,
  2298. isTS,
  2299. onError,
  2300. onWarn,
  2301. compatConfig,
  2302. // state
  2303. root,
  2304. helpers: new Map(),
  2305. components: new Set(),
  2306. directives: new Set(),
  2307. hoists: [],
  2308. imports: [],
  2309. constantCache: new Map(),
  2310. temps: 0,
  2311. cached: 0,
  2312. identifiers: Object.create(null),
  2313. scopes: {
  2314. vFor: 0,
  2315. vSlot: 0,
  2316. vPre: 0,
  2317. vOnce: 0
  2318. },
  2319. parent: null,
  2320. currentNode: root,
  2321. childIndex: 0,
  2322. inVOnce: false,
  2323. // methods
  2324. helper(name) {
  2325. const count = context.helpers.get(name) || 0;
  2326. context.helpers.set(name, count + 1);
  2327. return name;
  2328. },
  2329. removeHelper(name) {
  2330. const count = context.helpers.get(name);
  2331. if (count) {
  2332. const currentCount = count - 1;
  2333. if (!currentCount) {
  2334. context.helpers.delete(name);
  2335. }
  2336. else {
  2337. context.helpers.set(name, currentCount);
  2338. }
  2339. }
  2340. },
  2341. helperString(name) {
  2342. return `_${helperNameMap[context.helper(name)]}`;
  2343. },
  2344. replaceNode(node) {
  2345. /* istanbul ignore if */
  2346. {
  2347. if (!context.currentNode) {
  2348. throw new Error(`Node being replaced is already removed.`);
  2349. }
  2350. if (!context.parent) {
  2351. throw new Error(`Cannot replace root node.`);
  2352. }
  2353. }
  2354. context.parent.children[context.childIndex] = context.currentNode = node;
  2355. },
  2356. removeNode(node) {
  2357. if (!context.parent) {
  2358. throw new Error(`Cannot remove root node.`);
  2359. }
  2360. const list = context.parent.children;
  2361. const removalIndex = node
  2362. ? list.indexOf(node)
  2363. : context.currentNode
  2364. ? context.childIndex
  2365. : -1;
  2366. /* istanbul ignore if */
  2367. if (removalIndex < 0) {
  2368. throw new Error(`node being removed is not a child of current parent`);
  2369. }
  2370. if (!node || node === context.currentNode) {
  2371. // current node removed
  2372. context.currentNode = null;
  2373. context.onNodeRemoved();
  2374. }
  2375. else {
  2376. // sibling node removed
  2377. if (context.childIndex > removalIndex) {
  2378. context.childIndex--;
  2379. context.onNodeRemoved();
  2380. }
  2381. }
  2382. context.parent.children.splice(removalIndex, 1);
  2383. },
  2384. onNodeRemoved: () => { },
  2385. addIdentifiers(exp) {
  2386. // identifier tracking only happens in non-browser builds.
  2387. {
  2388. if (isString(exp)) {
  2389. addId(exp);
  2390. }
  2391. else if (exp.identifiers) {
  2392. exp.identifiers.forEach(addId);
  2393. }
  2394. else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
  2395. addId(exp.content);
  2396. }
  2397. }
  2398. },
  2399. removeIdentifiers(exp) {
  2400. {
  2401. if (isString(exp)) {
  2402. removeId(exp);
  2403. }
  2404. else if (exp.identifiers) {
  2405. exp.identifiers.forEach(removeId);
  2406. }
  2407. else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
  2408. removeId(exp.content);
  2409. }
  2410. }
  2411. },
  2412. hoist(exp) {
  2413. if (isString(exp))
  2414. exp = createSimpleExpression(exp);
  2415. context.hoists.push(exp);
  2416. const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* CAN_HOIST */);
  2417. identifier.hoisted = exp;
  2418. return identifier;
  2419. },
  2420. cache(exp, isVNode = false) {
  2421. return createCacheExpression(context.cached++, exp, isVNode);
  2422. }
  2423. };
  2424. function addId(id) {
  2425. const { identifiers } = context;
  2426. if (identifiers[id] === undefined) {
  2427. identifiers[id] = 0;
  2428. }
  2429. identifiers[id]++;
  2430. }
  2431. function removeId(id) {
  2432. context.identifiers[id]--;
  2433. }
  2434. return context;
  2435. }
  2436. function transform(root, options) {
  2437. const context = createTransformContext(root, options);
  2438. traverseNode(root, context);
  2439. if (options.hoistStatic) {
  2440. hoistStatic(root, context);
  2441. }
  2442. if (!options.ssr) {
  2443. createRootCodegen(root, context);
  2444. }
  2445. // finalize meta information
  2446. root.helpers = [...context.helpers.keys()];
  2447. root.components = [...context.components];
  2448. root.directives = [...context.directives];
  2449. root.imports = context.imports;
  2450. root.hoists = context.hoists;
  2451. root.temps = context.temps;
  2452. root.cached = context.cached;
  2453. }
  2454. function createRootCodegen(root, context) {
  2455. const { helper } = context;
  2456. const { children } = root;
  2457. if (children.length === 1) {
  2458. const child = children[0];
  2459. // if the single child is an element, turn it into a block.
  2460. if (isSingleElementRoot(root, child) && child.codegenNode) {
  2461. // single element root is never hoisted so codegenNode will never be
  2462. // SimpleExpressionNode
  2463. const codegenNode = child.codegenNode;
  2464. if (codegenNode.type === 13 /* VNODE_CALL */) {
  2465. makeBlock(codegenNode, context);
  2466. }
  2467. root.codegenNode = codegenNode;
  2468. }
  2469. else {
  2470. // - single <slot/>, IfNode, ForNode: already blocks.
  2471. // - single text node: always patched.
  2472. // root codegen falls through via genNode()
  2473. root.codegenNode = child;
  2474. }
  2475. }
  2476. else if (children.length > 1) {
  2477. // root has multiple nodes - return a fragment block.
  2478. let patchFlag = 64 /* STABLE_FRAGMENT */;
  2479. let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
  2480. // check if the fragment actually contains a single valid child with
  2481. // the rest being comments
  2482. if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
  2483. patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
  2484. patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
  2485. }
  2486. root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false /* isComponent */);
  2487. }
  2488. else ;
  2489. }
  2490. function traverseChildren(parent, context) {
  2491. let i = 0;
  2492. const nodeRemoved = () => {
  2493. i--;
  2494. };
  2495. for (; i < parent.children.length; i++) {
  2496. const child = parent.children[i];
  2497. if (isString(child))
  2498. continue;
  2499. context.parent = parent;
  2500. context.childIndex = i;
  2501. context.onNodeRemoved = nodeRemoved;
  2502. traverseNode(child, context);
  2503. }
  2504. }
  2505. function traverseNode(node, context) {
  2506. context.currentNode = node;
  2507. // apply transform plugins
  2508. const { nodeTransforms } = context;
  2509. const exitFns = [];
  2510. for (let i = 0; i < nodeTransforms.length; i++) {
  2511. const onExit = nodeTransforms[i](node, context);
  2512. if (onExit) {
  2513. if (isArray(onExit)) {
  2514. exitFns.push(...onExit);
  2515. }
  2516. else {
  2517. exitFns.push(onExit);
  2518. }
  2519. }
  2520. if (!context.currentNode) {
  2521. // node was removed
  2522. return;
  2523. }
  2524. else {
  2525. // node may have been replaced
  2526. node = context.currentNode;
  2527. }
  2528. }
  2529. switch (node.type) {
  2530. case 3 /* COMMENT */:
  2531. if (!context.ssr) {
  2532. // inject import for the Comment symbol, which is needed for creating
  2533. // comment nodes with `createVNode`
  2534. context.helper(CREATE_COMMENT);
  2535. }
  2536. break;
  2537. case 5 /* INTERPOLATION */:
  2538. // no need to traverse, but we need to inject toString helper
  2539. if (!context.ssr) {
  2540. context.helper(TO_DISPLAY_STRING);
  2541. }
  2542. break;
  2543. // for container types, further traverse downwards
  2544. case 9 /* IF */:
  2545. for (let i = 0; i < node.branches.length; i++) {
  2546. traverseNode(node.branches[i], context);
  2547. }
  2548. break;
  2549. case 10 /* IF_BRANCH */:
  2550. case 11 /* FOR */:
  2551. case 1 /* ELEMENT */:
  2552. case 0 /* ROOT */:
  2553. traverseChildren(node, context);
  2554. break;
  2555. }
  2556. // exit transforms
  2557. context.currentNode = node;
  2558. let i = exitFns.length;
  2559. while (i--) {
  2560. exitFns[i]();
  2561. }
  2562. }
  2563. function createStructuralDirectiveTransform(name, fn) {
  2564. const matches = isString(name)
  2565. ? (n) => n === name
  2566. : (n) => name.test(n);
  2567. return (node, context) => {
  2568. if (node.type === 1 /* ELEMENT */) {
  2569. const { props } = node;
  2570. // structural directive transforms are not concerned with slots
  2571. // as they are handled separately in vSlot.ts
  2572. if (node.tagType === 3 /* TEMPLATE */ && props.some(isVSlot)) {
  2573. return;
  2574. }
  2575. const exitFns = [];
  2576. for (let i = 0; i < props.length; i++) {
  2577. const prop = props[i];
  2578. if (prop.type === 7 /* DIRECTIVE */ && matches(prop.name)) {
  2579. // structural directives are removed to avoid infinite recursion
  2580. // also we remove them *before* applying so that it can further
  2581. // traverse itself in case it moves the node around
  2582. props.splice(i, 1);
  2583. i--;
  2584. const onExit = fn(node, prop, context);
  2585. if (onExit)
  2586. exitFns.push(onExit);
  2587. }
  2588. }
  2589. return exitFns;
  2590. }
  2591. };
  2592. }
  2593. /* -*- Mode: js; js-indent-level: 2; -*- */
  2594. /*
  2595. * Copyright 2011 Mozilla Foundation and contributors
  2596. * Licensed under the New BSD license. See LICENSE or:
  2597. * http://opensource.org/licenses/BSD-3-Clause
  2598. */
  2599. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  2600. /**
  2601. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  2602. */
  2603. var encode = function (number) {
  2604. if (0 <= number && number < intToCharMap.length) {
  2605. return intToCharMap[number];
  2606. }
  2607. throw new TypeError("Must be between 0 and 63: " + number);
  2608. };
  2609. /**
  2610. * Decode a single base 64 character code digit to an integer. Returns -1 on
  2611. * failure.
  2612. */
  2613. var decode = function (charCode) {
  2614. var bigA = 65; // 'A'
  2615. var bigZ = 90; // 'Z'
  2616. var littleA = 97; // 'a'
  2617. var littleZ = 122; // 'z'
  2618. var zero = 48; // '0'
  2619. var nine = 57; // '9'
  2620. var plus = 43; // '+'
  2621. var slash = 47; // '/'
  2622. var littleOffset = 26;
  2623. var numberOffset = 52;
  2624. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  2625. if (bigA <= charCode && charCode <= bigZ) {
  2626. return (charCode - bigA);
  2627. }
  2628. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  2629. if (littleA <= charCode && charCode <= littleZ) {
  2630. return (charCode - littleA + littleOffset);
  2631. }
  2632. // 52 - 61: 0123456789
  2633. if (zero <= charCode && charCode <= nine) {
  2634. return (charCode - zero + numberOffset);
  2635. }
  2636. // 62: +
  2637. if (charCode == plus) {
  2638. return 62;
  2639. }
  2640. // 63: /
  2641. if (charCode == slash) {
  2642. return 63;
  2643. }
  2644. // Invalid base64 digit.
  2645. return -1;
  2646. };
  2647. var base64 = {
  2648. encode: encode,
  2649. decode: decode
  2650. };
  2651. /* -*- Mode: js; js-indent-level: 2; -*- */
  2652. /*
  2653. * Copyright 2011 Mozilla Foundation and contributors
  2654. * Licensed under the New BSD license. See LICENSE or:
  2655. * http://opensource.org/licenses/BSD-3-Clause
  2656. *
  2657. * Based on the Base 64 VLQ implementation in Closure Compiler:
  2658. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  2659. *
  2660. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  2661. * Redistribution and use in source and binary forms, with or without
  2662. * modification, are permitted provided that the following conditions are
  2663. * met:
  2664. *
  2665. * * Redistributions of source code must retain the above copyright
  2666. * notice, this list of conditions and the following disclaimer.
  2667. * * Redistributions in binary form must reproduce the above
  2668. * copyright notice, this list of conditions and the following
  2669. * disclaimer in the documentation and/or other materials provided
  2670. * with the distribution.
  2671. * * Neither the name of Google Inc. nor the names of its
  2672. * contributors may be used to endorse or promote products derived
  2673. * from this software without specific prior written permission.
  2674. *
  2675. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2676. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2677. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2678. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2679. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2680. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2681. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2682. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2683. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2684. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  2685. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2686. */
  2687. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  2688. // length quantities we use in the source map spec, the first bit is the sign,
  2689. // the next four bits are the actual value, and the 6th bit is the
  2690. // continuation bit. The continuation bit tells us whether there are more
  2691. // digits in this value following this digit.
  2692. //
  2693. // Continuation
  2694. // | Sign
  2695. // | |
  2696. // V V
  2697. // 101011
  2698. var VLQ_BASE_SHIFT = 5;
  2699. // binary: 100000
  2700. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  2701. // binary: 011111
  2702. var VLQ_BASE_MASK = VLQ_BASE - 1;
  2703. // binary: 100000
  2704. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  2705. /**
  2706. * Converts from a two-complement value to a value where the sign bit is
  2707. * placed in the least significant bit. For example, as decimals:
  2708. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  2709. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  2710. */
  2711. function toVLQSigned(aValue) {
  2712. return aValue < 0
  2713. ? ((-aValue) << 1) + 1
  2714. : (aValue << 1) + 0;
  2715. }
  2716. /**
  2717. * Converts to a two-complement value from a value where the sign bit is
  2718. * placed in the least significant bit. For example, as decimals:
  2719. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  2720. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  2721. */
  2722. function fromVLQSigned(aValue) {
  2723. var isNegative = (aValue & 1) === 1;
  2724. var shifted = aValue >> 1;
  2725. return isNegative
  2726. ? -shifted
  2727. : shifted;
  2728. }
  2729. /**
  2730. * Returns the base 64 VLQ encoded value.
  2731. */
  2732. var encode$1 = function base64VLQ_encode(aValue) {
  2733. var encoded = "";
  2734. var digit;
  2735. var vlq = toVLQSigned(aValue);
  2736. do {
  2737. digit = vlq & VLQ_BASE_MASK;
  2738. vlq >>>= VLQ_BASE_SHIFT;
  2739. if (vlq > 0) {
  2740. // There are still more digits in this value, so we must make sure the
  2741. // continuation bit is marked.
  2742. digit |= VLQ_CONTINUATION_BIT;
  2743. }
  2744. encoded += base64.encode(digit);
  2745. } while (vlq > 0);
  2746. return encoded;
  2747. };
  2748. /**
  2749. * Decodes the next base 64 VLQ value from the given string and returns the
  2750. * value and the rest of the string via the out parameter.
  2751. */
  2752. var decode$1 = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  2753. var strLen = aStr.length;
  2754. var result = 0;
  2755. var shift = 0;
  2756. var continuation, digit;
  2757. do {
  2758. if (aIndex >= strLen) {
  2759. throw new Error("Expected more digits in base 64 VLQ value.");
  2760. }
  2761. digit = base64.decode(aStr.charCodeAt(aIndex++));
  2762. if (digit === -1) {
  2763. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  2764. }
  2765. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  2766. digit &= VLQ_BASE_MASK;
  2767. result = result + (digit << shift);
  2768. shift += VLQ_BASE_SHIFT;
  2769. } while (continuation);
  2770. aOutParam.value = fromVLQSigned(result);
  2771. aOutParam.rest = aIndex;
  2772. };
  2773. var base64Vlq = {
  2774. encode: encode$1,
  2775. decode: decode$1
  2776. };
  2777. function getDefaultExportFromCjs (x) {
  2778. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2779. }
  2780. function getAugmentedNamespace(n) {
  2781. if (n.__esModule) return n;
  2782. var a = Object.defineProperty({}, '__esModule', {value: true});
  2783. Object.keys(n).forEach(function (k) {
  2784. var d = Object.getOwnPropertyDescriptor(n, k);
  2785. Object.defineProperty(a, k, d.get ? d : {
  2786. enumerable: true,
  2787. get: function () {
  2788. return n[k];
  2789. }
  2790. });
  2791. });
  2792. return a;
  2793. }
  2794. function createCommonjsModule(fn) {
  2795. var module = { exports: {} };
  2796. return fn(module, module.exports), module.exports;
  2797. }
  2798. /* -*- Mode: js; js-indent-level: 2; -*- */
  2799. var util = createCommonjsModule(function (module, exports) {
  2800. /*
  2801. * Copyright 2011 Mozilla Foundation and contributors
  2802. * Licensed under the New BSD license. See LICENSE or:
  2803. * http://opensource.org/licenses/BSD-3-Clause
  2804. */
  2805. /**
  2806. * This is a helper function for getting values from parameter/options
  2807. * objects.
  2808. *
  2809. * @param args The object we are extracting values from
  2810. * @param name The name of the property we are getting.
  2811. * @param defaultValue An optional value to return if the property is missing
  2812. * from the object. If this is not specified and the property is missing, an
  2813. * error will be thrown.
  2814. */
  2815. function getArg(aArgs, aName, aDefaultValue) {
  2816. if (aName in aArgs) {
  2817. return aArgs[aName];
  2818. } else if (arguments.length === 3) {
  2819. return aDefaultValue;
  2820. } else {
  2821. throw new Error('"' + aName + '" is a required argument.');
  2822. }
  2823. }
  2824. exports.getArg = getArg;
  2825. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  2826. var dataUrlRegexp = /^data:.+\,.+$/;
  2827. function urlParse(aUrl) {
  2828. var match = aUrl.match(urlRegexp);
  2829. if (!match) {
  2830. return null;
  2831. }
  2832. return {
  2833. scheme: match[1],
  2834. auth: match[2],
  2835. host: match[3],
  2836. port: match[4],
  2837. path: match[5]
  2838. };
  2839. }
  2840. exports.urlParse = urlParse;
  2841. function urlGenerate(aParsedUrl) {
  2842. var url = '';
  2843. if (aParsedUrl.scheme) {
  2844. url += aParsedUrl.scheme + ':';
  2845. }
  2846. url += '//';
  2847. if (aParsedUrl.auth) {
  2848. url += aParsedUrl.auth + '@';
  2849. }
  2850. if (aParsedUrl.host) {
  2851. url += aParsedUrl.host;
  2852. }
  2853. if (aParsedUrl.port) {
  2854. url += ":" + aParsedUrl.port;
  2855. }
  2856. if (aParsedUrl.path) {
  2857. url += aParsedUrl.path;
  2858. }
  2859. return url;
  2860. }
  2861. exports.urlGenerate = urlGenerate;
  2862. /**
  2863. * Normalizes a path, or the path portion of a URL:
  2864. *
  2865. * - Replaces consecutive slashes with one slash.
  2866. * - Removes unnecessary '.' parts.
  2867. * - Removes unnecessary '<dir>/..' parts.
  2868. *
  2869. * Based on code in the Node.js 'path' core module.
  2870. *
  2871. * @param aPath The path or url to normalize.
  2872. */
  2873. function normalize(aPath) {
  2874. var path = aPath;
  2875. var url = urlParse(aPath);
  2876. if (url) {
  2877. if (!url.path) {
  2878. return aPath;
  2879. }
  2880. path = url.path;
  2881. }
  2882. var isAbsolute = exports.isAbsolute(path);
  2883. var parts = path.split(/\/+/);
  2884. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  2885. part = parts[i];
  2886. if (part === '.') {
  2887. parts.splice(i, 1);
  2888. } else if (part === '..') {
  2889. up++;
  2890. } else if (up > 0) {
  2891. if (part === '') {
  2892. // The first part is blank if the path is absolute. Trying to go
  2893. // above the root is a no-op. Therefore we can remove all '..' parts
  2894. // directly after the root.
  2895. parts.splice(i + 1, up);
  2896. up = 0;
  2897. } else {
  2898. parts.splice(i, 2);
  2899. up--;
  2900. }
  2901. }
  2902. }
  2903. path = parts.join('/');
  2904. if (path === '') {
  2905. path = isAbsolute ? '/' : '.';
  2906. }
  2907. if (url) {
  2908. url.path = path;
  2909. return urlGenerate(url);
  2910. }
  2911. return path;
  2912. }
  2913. exports.normalize = normalize;
  2914. /**
  2915. * Joins two paths/URLs.
  2916. *
  2917. * @param aRoot The root path or URL.
  2918. * @param aPath The path or URL to be joined with the root.
  2919. *
  2920. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  2921. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  2922. * first.
  2923. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  2924. * is updated with the result and aRoot is returned. Otherwise the result
  2925. * is returned.
  2926. * - If aPath is absolute, the result is aPath.
  2927. * - Otherwise the two paths are joined with a slash.
  2928. * - Joining for example 'http://' and 'www.example.com' is also supported.
  2929. */
  2930. function join(aRoot, aPath) {
  2931. if (aRoot === "") {
  2932. aRoot = ".";
  2933. }
  2934. if (aPath === "") {
  2935. aPath = ".";
  2936. }
  2937. var aPathUrl = urlParse(aPath);
  2938. var aRootUrl = urlParse(aRoot);
  2939. if (aRootUrl) {
  2940. aRoot = aRootUrl.path || '/';
  2941. }
  2942. // `join(foo, '//www.example.org')`
  2943. if (aPathUrl && !aPathUrl.scheme) {
  2944. if (aRootUrl) {
  2945. aPathUrl.scheme = aRootUrl.scheme;
  2946. }
  2947. return urlGenerate(aPathUrl);
  2948. }
  2949. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  2950. return aPath;
  2951. }
  2952. // `join('http://', 'www.example.com')`
  2953. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  2954. aRootUrl.host = aPath;
  2955. return urlGenerate(aRootUrl);
  2956. }
  2957. var joined = aPath.charAt(0) === '/'
  2958. ? aPath
  2959. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  2960. if (aRootUrl) {
  2961. aRootUrl.path = joined;
  2962. return urlGenerate(aRootUrl);
  2963. }
  2964. return joined;
  2965. }
  2966. exports.join = join;
  2967. exports.isAbsolute = function (aPath) {
  2968. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  2969. };
  2970. /**
  2971. * Make a path relative to a URL or another path.
  2972. *
  2973. * @param aRoot The root path or URL.
  2974. * @param aPath The path or URL to be made relative to aRoot.
  2975. */
  2976. function relative(aRoot, aPath) {
  2977. if (aRoot === "") {
  2978. aRoot = ".";
  2979. }
  2980. aRoot = aRoot.replace(/\/$/, '');
  2981. // It is possible for the path to be above the root. In this case, simply
  2982. // checking whether the root is a prefix of the path won't work. Instead, we
  2983. // need to remove components from the root one by one, until either we find
  2984. // a prefix that fits, or we run out of components to remove.
  2985. var level = 0;
  2986. while (aPath.indexOf(aRoot + '/') !== 0) {
  2987. var index = aRoot.lastIndexOf("/");
  2988. if (index < 0) {
  2989. return aPath;
  2990. }
  2991. // If the only part of the root that is left is the scheme (i.e. http://,
  2992. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  2993. // have exhausted all components, so the path is not relative to the root.
  2994. aRoot = aRoot.slice(0, index);
  2995. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  2996. return aPath;
  2997. }
  2998. ++level;
  2999. }
  3000. // Make sure we add a "../" for each component we removed from the root.
  3001. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  3002. }
  3003. exports.relative = relative;
  3004. var supportsNullProto = (function () {
  3005. var obj = Object.create(null);
  3006. return !('__proto__' in obj);
  3007. }());
  3008. function identity (s) {
  3009. return s;
  3010. }
  3011. /**
  3012. * Because behavior goes wacky when you set `__proto__` on objects, we
  3013. * have to prefix all the strings in our set with an arbitrary character.
  3014. *
  3015. * See https://github.com/mozilla/source-map/pull/31 and
  3016. * https://github.com/mozilla/source-map/issues/30
  3017. *
  3018. * @param String aStr
  3019. */
  3020. function toSetString(aStr) {
  3021. if (isProtoString(aStr)) {
  3022. return '$' + aStr;
  3023. }
  3024. return aStr;
  3025. }
  3026. exports.toSetString = supportsNullProto ? identity : toSetString;
  3027. function fromSetString(aStr) {
  3028. if (isProtoString(aStr)) {
  3029. return aStr.slice(1);
  3030. }
  3031. return aStr;
  3032. }
  3033. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  3034. function isProtoString(s) {
  3035. if (!s) {
  3036. return false;
  3037. }
  3038. var length = s.length;
  3039. if (length < 9 /* "__proto__".length */) {
  3040. return false;
  3041. }
  3042. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  3043. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  3044. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  3045. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  3046. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  3047. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  3048. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  3049. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  3050. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  3051. return false;
  3052. }
  3053. for (var i = length - 10; i >= 0; i--) {
  3054. if (s.charCodeAt(i) !== 36 /* '$' */) {
  3055. return false;
  3056. }
  3057. }
  3058. return true;
  3059. }
  3060. /**
  3061. * Comparator between two mappings where the original positions are compared.
  3062. *
  3063. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  3064. * mappings with the same original source/line/column, but different generated
  3065. * line and column the same. Useful when searching for a mapping with a
  3066. * stubbed out mapping.
  3067. */
  3068. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  3069. var cmp = strcmp(mappingA.source, mappingB.source);
  3070. if (cmp !== 0) {
  3071. return cmp;
  3072. }
  3073. cmp = mappingA.originalLine - mappingB.originalLine;
  3074. if (cmp !== 0) {
  3075. return cmp;
  3076. }
  3077. cmp = mappingA.originalColumn - mappingB.originalColumn;
  3078. if (cmp !== 0 || onlyCompareOriginal) {
  3079. return cmp;
  3080. }
  3081. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  3082. if (cmp !== 0) {
  3083. return cmp;
  3084. }
  3085. cmp = mappingA.generatedLine - mappingB.generatedLine;
  3086. if (cmp !== 0) {
  3087. return cmp;
  3088. }
  3089. return strcmp(mappingA.name, mappingB.name);
  3090. }
  3091. exports.compareByOriginalPositions = compareByOriginalPositions;
  3092. /**
  3093. * Comparator between two mappings with deflated source and name indices where
  3094. * the generated positions are compared.
  3095. *
  3096. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  3097. * mappings with the same generated line and column, but different
  3098. * source/name/original line and column the same. Useful when searching for a
  3099. * mapping with a stubbed out mapping.
  3100. */
  3101. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  3102. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  3103. if (cmp !== 0) {
  3104. return cmp;
  3105. }
  3106. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  3107. if (cmp !== 0 || onlyCompareGenerated) {
  3108. return cmp;
  3109. }
  3110. cmp = strcmp(mappingA.source, mappingB.source);
  3111. if (cmp !== 0) {
  3112. return cmp;
  3113. }
  3114. cmp = mappingA.originalLine - mappingB.originalLine;
  3115. if (cmp !== 0) {
  3116. return cmp;
  3117. }
  3118. cmp = mappingA.originalColumn - mappingB.originalColumn;
  3119. if (cmp !== 0) {
  3120. return cmp;
  3121. }
  3122. return strcmp(mappingA.name, mappingB.name);
  3123. }
  3124. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  3125. function strcmp(aStr1, aStr2) {
  3126. if (aStr1 === aStr2) {
  3127. return 0;
  3128. }
  3129. if (aStr1 === null) {
  3130. return 1; // aStr2 !== null
  3131. }
  3132. if (aStr2 === null) {
  3133. return -1; // aStr1 !== null
  3134. }
  3135. if (aStr1 > aStr2) {
  3136. return 1;
  3137. }
  3138. return -1;
  3139. }
  3140. /**
  3141. * Comparator between two mappings with inflated source and name strings where
  3142. * the generated positions are compared.
  3143. */
  3144. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  3145. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  3146. if (cmp !== 0) {
  3147. return cmp;
  3148. }
  3149. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  3150. if (cmp !== 0) {
  3151. return cmp;
  3152. }
  3153. cmp = strcmp(mappingA.source, mappingB.source);
  3154. if (cmp !== 0) {
  3155. return cmp;
  3156. }
  3157. cmp = mappingA.originalLine - mappingB.originalLine;
  3158. if (cmp !== 0) {
  3159. return cmp;
  3160. }
  3161. cmp = mappingA.originalColumn - mappingB.originalColumn;
  3162. if (cmp !== 0) {
  3163. return cmp;
  3164. }
  3165. return strcmp(mappingA.name, mappingB.name);
  3166. }
  3167. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  3168. /**
  3169. * Strip any JSON XSSI avoidance prefix from the string (as documented
  3170. * in the source maps specification), and then parse the string as
  3171. * JSON.
  3172. */
  3173. function parseSourceMapInput(str) {
  3174. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  3175. }
  3176. exports.parseSourceMapInput = parseSourceMapInput;
  3177. /**
  3178. * Compute the URL of a source given the the source root, the source's
  3179. * URL, and the source map's URL.
  3180. */
  3181. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  3182. sourceURL = sourceURL || '';
  3183. if (sourceRoot) {
  3184. // This follows what Chrome does.
  3185. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  3186. sourceRoot += '/';
  3187. }
  3188. // The spec says:
  3189. // Line 4: An optional source root, useful for relocating source
  3190. // files on a server or removing repeated values in the
  3191. // “sources” entry. This value is prepended to the individual
  3192. // entries in the “source” field.
  3193. sourceURL = sourceRoot + sourceURL;
  3194. }
  3195. // Historically, SourceMapConsumer did not take the sourceMapURL as
  3196. // a parameter. This mode is still somewhat supported, which is why
  3197. // this code block is conditional. However, it's preferable to pass
  3198. // the source map URL to SourceMapConsumer, so that this function
  3199. // can implement the source URL resolution algorithm as outlined in
  3200. // the spec. This block is basically the equivalent of:
  3201. // new URL(sourceURL, sourceMapURL).toString()
  3202. // ... except it avoids using URL, which wasn't available in the
  3203. // older releases of node still supported by this library.
  3204. //
  3205. // The spec says:
  3206. // If the sources are not absolute URLs after prepending of the
  3207. // “sourceRoot”, the sources are resolved relative to the
  3208. // SourceMap (like resolving script src in a html document).
  3209. if (sourceMapURL) {
  3210. var parsed = urlParse(sourceMapURL);
  3211. if (!parsed) {
  3212. throw new Error("sourceMapURL could not be parsed");
  3213. }
  3214. if (parsed.path) {
  3215. // Strip the last path component, but keep the "/".
  3216. var index = parsed.path.lastIndexOf('/');
  3217. if (index >= 0) {
  3218. parsed.path = parsed.path.substring(0, index + 1);
  3219. }
  3220. }
  3221. sourceURL = join(urlGenerate(parsed), sourceURL);
  3222. }
  3223. return normalize(sourceURL);
  3224. }
  3225. exports.computeSourceURL = computeSourceURL;
  3226. });
  3227. /* -*- Mode: js; js-indent-level: 2; -*- */
  3228. /*
  3229. * Copyright 2011 Mozilla Foundation and contributors
  3230. * Licensed under the New BSD license. See LICENSE or:
  3231. * http://opensource.org/licenses/BSD-3-Clause
  3232. */
  3233. var has = Object.prototype.hasOwnProperty;
  3234. var hasNativeMap = typeof Map !== "undefined";
  3235. /**
  3236. * A data structure which is a combination of an array and a set. Adding a new
  3237. * member is O(1), testing for membership is O(1), and finding the index of an
  3238. * element is O(1). Removing elements from the set is not supported. Only
  3239. * strings are supported for membership.
  3240. */
  3241. function ArraySet() {
  3242. this._array = [];
  3243. this._set = hasNativeMap ? new Map() : Object.create(null);
  3244. }
  3245. /**
  3246. * Static method for creating ArraySet instances from an existing array.
  3247. */
  3248. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  3249. var set = new ArraySet();
  3250. for (var i = 0, len = aArray.length; i < len; i++) {
  3251. set.add(aArray[i], aAllowDuplicates);
  3252. }
  3253. return set;
  3254. };
  3255. /**
  3256. * Return how many unique items are in this ArraySet. If duplicates have been
  3257. * added, than those do not count towards the size.
  3258. *
  3259. * @returns Number
  3260. */
  3261. ArraySet.prototype.size = function ArraySet_size() {
  3262. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  3263. };
  3264. /**
  3265. * Add the given string to this set.
  3266. *
  3267. * @param String aStr
  3268. */
  3269. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  3270. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  3271. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  3272. var idx = this._array.length;
  3273. if (!isDuplicate || aAllowDuplicates) {
  3274. this._array.push(aStr);
  3275. }
  3276. if (!isDuplicate) {
  3277. if (hasNativeMap) {
  3278. this._set.set(aStr, idx);
  3279. } else {
  3280. this._set[sStr] = idx;
  3281. }
  3282. }
  3283. };
  3284. /**
  3285. * Is the given string a member of this set?
  3286. *
  3287. * @param String aStr
  3288. */
  3289. ArraySet.prototype.has = function ArraySet_has(aStr) {
  3290. if (hasNativeMap) {
  3291. return this._set.has(aStr);
  3292. } else {
  3293. var sStr = util.toSetString(aStr);
  3294. return has.call(this._set, sStr);
  3295. }
  3296. };
  3297. /**
  3298. * What is the index of the given string in the array?
  3299. *
  3300. * @param String aStr
  3301. */
  3302. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  3303. if (hasNativeMap) {
  3304. var idx = this._set.get(aStr);
  3305. if (idx >= 0) {
  3306. return idx;
  3307. }
  3308. } else {
  3309. var sStr = util.toSetString(aStr);
  3310. if (has.call(this._set, sStr)) {
  3311. return this._set[sStr];
  3312. }
  3313. }
  3314. throw new Error('"' + aStr + '" is not in the set.');
  3315. };
  3316. /**
  3317. * What is the element at the given index?
  3318. *
  3319. * @param Number aIdx
  3320. */
  3321. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  3322. if (aIdx >= 0 && aIdx < this._array.length) {
  3323. return this._array[aIdx];
  3324. }
  3325. throw new Error('No element indexed by ' + aIdx);
  3326. };
  3327. /**
  3328. * Returns the array representation of this set (which has the proper indices
  3329. * indicated by indexOf). Note that this is a copy of the internal array used
  3330. * for storing the members so that no one can mess with internal state.
  3331. */
  3332. ArraySet.prototype.toArray = function ArraySet_toArray() {
  3333. return this._array.slice();
  3334. };
  3335. var ArraySet_1 = ArraySet;
  3336. var arraySet = {
  3337. ArraySet: ArraySet_1
  3338. };
  3339. /* -*- Mode: js; js-indent-level: 2; -*- */
  3340. /*
  3341. * Copyright 2014 Mozilla Foundation and contributors
  3342. * Licensed under the New BSD license. See LICENSE or:
  3343. * http://opensource.org/licenses/BSD-3-Clause
  3344. */
  3345. /**
  3346. * Determine whether mappingB is after mappingA with respect to generated
  3347. * position.
  3348. */
  3349. function generatedPositionAfter(mappingA, mappingB) {
  3350. // Optimized for most common case
  3351. var lineA = mappingA.generatedLine;
  3352. var lineB = mappingB.generatedLine;
  3353. var columnA = mappingA.generatedColumn;
  3354. var columnB = mappingB.generatedColumn;
  3355. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  3356. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  3357. }
  3358. /**
  3359. * A data structure to provide a sorted view of accumulated mappings in a
  3360. * performance conscious manner. It trades a neglibable overhead in general
  3361. * case for a large speedup in case of mappings being added in order.
  3362. */
  3363. function MappingList() {
  3364. this._array = [];
  3365. this._sorted = true;
  3366. // Serves as infimum
  3367. this._last = {generatedLine: -1, generatedColumn: 0};
  3368. }
  3369. /**
  3370. * Iterate through internal items. This method takes the same arguments that
  3371. * `Array.prototype.forEach` takes.
  3372. *
  3373. * NOTE: The order of the mappings is NOT guaranteed.
  3374. */
  3375. MappingList.prototype.unsortedForEach =
  3376. function MappingList_forEach(aCallback, aThisArg) {
  3377. this._array.forEach(aCallback, aThisArg);
  3378. };
  3379. /**
  3380. * Add the given source mapping.
  3381. *
  3382. * @param Object aMapping
  3383. */
  3384. MappingList.prototype.add = function MappingList_add(aMapping) {
  3385. if (generatedPositionAfter(this._last, aMapping)) {
  3386. this._last = aMapping;
  3387. this._array.push(aMapping);
  3388. } else {
  3389. this._sorted = false;
  3390. this._array.push(aMapping);
  3391. }
  3392. };
  3393. /**
  3394. * Returns the flat, sorted array of mappings. The mappings are sorted by
  3395. * generated position.
  3396. *
  3397. * WARNING: This method returns internal data without copying, for
  3398. * performance. The return value must NOT be mutated, and should be treated as
  3399. * an immutable borrow. If you want to take ownership, you must make your own
  3400. * copy.
  3401. */
  3402. MappingList.prototype.toArray = function MappingList_toArray() {
  3403. if (!this._sorted) {
  3404. this._array.sort(util.compareByGeneratedPositionsInflated);
  3405. this._sorted = true;
  3406. }
  3407. return this._array;
  3408. };
  3409. var MappingList_1 = MappingList;
  3410. var mappingList = {
  3411. MappingList: MappingList_1
  3412. };
  3413. /* -*- Mode: js; js-indent-level: 2; -*- */
  3414. /*
  3415. * Copyright 2011 Mozilla Foundation and contributors
  3416. * Licensed under the New BSD license. See LICENSE or:
  3417. * http://opensource.org/licenses/BSD-3-Clause
  3418. */
  3419. var ArraySet$1 = arraySet.ArraySet;
  3420. var MappingList$1 = mappingList.MappingList;
  3421. /**
  3422. * An instance of the SourceMapGenerator represents a source map which is
  3423. * being built incrementally. You may pass an object with the following
  3424. * properties:
  3425. *
  3426. * - file: The filename of the generated source.
  3427. * - sourceRoot: A root for all relative URLs in this source map.
  3428. */
  3429. function SourceMapGenerator(aArgs) {
  3430. if (!aArgs) {
  3431. aArgs = {};
  3432. }
  3433. this._file = util.getArg(aArgs, 'file', null);
  3434. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  3435. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  3436. this._sources = new ArraySet$1();
  3437. this._names = new ArraySet$1();
  3438. this._mappings = new MappingList$1();
  3439. this._sourcesContents = null;
  3440. }
  3441. SourceMapGenerator.prototype._version = 3;
  3442. /**
  3443. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  3444. *
  3445. * @param aSourceMapConsumer The SourceMap.
  3446. */
  3447. SourceMapGenerator.fromSourceMap =
  3448. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  3449. var sourceRoot = aSourceMapConsumer.sourceRoot;
  3450. var generator = new SourceMapGenerator({
  3451. file: aSourceMapConsumer.file,
  3452. sourceRoot: sourceRoot
  3453. });
  3454. aSourceMapConsumer.eachMapping(function (mapping) {
  3455. var newMapping = {
  3456. generated: {
  3457. line: mapping.generatedLine,
  3458. column: mapping.generatedColumn
  3459. }
  3460. };
  3461. if (mapping.source != null) {
  3462. newMapping.source = mapping.source;
  3463. if (sourceRoot != null) {
  3464. newMapping.source = util.relative(sourceRoot, newMapping.source);
  3465. }
  3466. newMapping.original = {
  3467. line: mapping.originalLine,
  3468. column: mapping.originalColumn
  3469. };
  3470. if (mapping.name != null) {
  3471. newMapping.name = mapping.name;
  3472. }
  3473. }
  3474. generator.addMapping(newMapping);
  3475. });
  3476. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  3477. var sourceRelative = sourceFile;
  3478. if (sourceRoot !== null) {
  3479. sourceRelative = util.relative(sourceRoot, sourceFile);
  3480. }
  3481. if (!generator._sources.has(sourceRelative)) {
  3482. generator._sources.add(sourceRelative);
  3483. }
  3484. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  3485. if (content != null) {
  3486. generator.setSourceContent(sourceFile, content);
  3487. }
  3488. });
  3489. return generator;
  3490. };
  3491. /**
  3492. * Add a single mapping from original source line and column to the generated
  3493. * source's line and column for this source map being created. The mapping
  3494. * object should have the following properties:
  3495. *
  3496. * - generated: An object with the generated line and column positions.
  3497. * - original: An object with the original line and column positions.
  3498. * - source: The original source file (relative to the sourceRoot).
  3499. * - name: An optional original token name for this mapping.
  3500. */
  3501. SourceMapGenerator.prototype.addMapping =
  3502. function SourceMapGenerator_addMapping(aArgs) {
  3503. var generated = util.getArg(aArgs, 'generated');
  3504. var original = util.getArg(aArgs, 'original', null);
  3505. var source = util.getArg(aArgs, 'source', null);
  3506. var name = util.getArg(aArgs, 'name', null);
  3507. if (!this._skipValidation) {
  3508. this._validateMapping(generated, original, source, name);
  3509. }
  3510. if (source != null) {
  3511. source = String(source);
  3512. if (!this._sources.has(source)) {
  3513. this._sources.add(source);
  3514. }
  3515. }
  3516. if (name != null) {
  3517. name = String(name);
  3518. if (!this._names.has(name)) {
  3519. this._names.add(name);
  3520. }
  3521. }
  3522. this._mappings.add({
  3523. generatedLine: generated.line,
  3524. generatedColumn: generated.column,
  3525. originalLine: original != null && original.line,
  3526. originalColumn: original != null && original.column,
  3527. source: source,
  3528. name: name
  3529. });
  3530. };
  3531. /**
  3532. * Set the source content for a source file.
  3533. */
  3534. SourceMapGenerator.prototype.setSourceContent =
  3535. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  3536. var source = aSourceFile;
  3537. if (this._sourceRoot != null) {
  3538. source = util.relative(this._sourceRoot, source);
  3539. }
  3540. if (aSourceContent != null) {
  3541. // Add the source content to the _sourcesContents map.
  3542. // Create a new _sourcesContents map if the property is null.
  3543. if (!this._sourcesContents) {
  3544. this._sourcesContents = Object.create(null);
  3545. }
  3546. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  3547. } else if (this._sourcesContents) {
  3548. // Remove the source file from the _sourcesContents map.
  3549. // If the _sourcesContents map is empty, set the property to null.
  3550. delete this._sourcesContents[util.toSetString(source)];
  3551. if (Object.keys(this._sourcesContents).length === 0) {
  3552. this._sourcesContents = null;
  3553. }
  3554. }
  3555. };
  3556. /**
  3557. * Applies the mappings of a sub-source-map for a specific source file to the
  3558. * source map being generated. Each mapping to the supplied source file is
  3559. * rewritten using the supplied source map. Note: The resolution for the
  3560. * resulting mappings is the minimium of this map and the supplied map.
  3561. *
  3562. * @param aSourceMapConsumer The source map to be applied.
  3563. * @param aSourceFile Optional. The filename of the source file.
  3564. * If omitted, SourceMapConsumer's file property will be used.
  3565. * @param aSourceMapPath Optional. The dirname of the path to the source map
  3566. * to be applied. If relative, it is relative to the SourceMapConsumer.
  3567. * This parameter is needed when the two source maps aren't in the same
  3568. * directory, and the source map to be applied contains relative source
  3569. * paths. If so, those relative source paths need to be rewritten
  3570. * relative to the SourceMapGenerator.
  3571. */
  3572. SourceMapGenerator.prototype.applySourceMap =
  3573. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  3574. var sourceFile = aSourceFile;
  3575. // If aSourceFile is omitted, we will use the file property of the SourceMap
  3576. if (aSourceFile == null) {
  3577. if (aSourceMapConsumer.file == null) {
  3578. throw new Error(
  3579. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  3580. 'or the source map\'s "file" property. Both were omitted.'
  3581. );
  3582. }
  3583. sourceFile = aSourceMapConsumer.file;
  3584. }
  3585. var sourceRoot = this._sourceRoot;
  3586. // Make "sourceFile" relative if an absolute Url is passed.
  3587. if (sourceRoot != null) {
  3588. sourceFile = util.relative(sourceRoot, sourceFile);
  3589. }
  3590. // Applying the SourceMap can add and remove items from the sources and
  3591. // the names array.
  3592. var newSources = new ArraySet$1();
  3593. var newNames = new ArraySet$1();
  3594. // Find mappings for the "sourceFile"
  3595. this._mappings.unsortedForEach(function (mapping) {
  3596. if (mapping.source === sourceFile && mapping.originalLine != null) {
  3597. // Check if it can be mapped by the source map, then update the mapping.
  3598. var original = aSourceMapConsumer.originalPositionFor({
  3599. line: mapping.originalLine,
  3600. column: mapping.originalColumn
  3601. });
  3602. if (original.source != null) {
  3603. // Copy mapping
  3604. mapping.source = original.source;
  3605. if (aSourceMapPath != null) {
  3606. mapping.source = util.join(aSourceMapPath, mapping.source);
  3607. }
  3608. if (sourceRoot != null) {
  3609. mapping.source = util.relative(sourceRoot, mapping.source);
  3610. }
  3611. mapping.originalLine = original.line;
  3612. mapping.originalColumn = original.column;
  3613. if (original.name != null) {
  3614. mapping.name = original.name;
  3615. }
  3616. }
  3617. }
  3618. var source = mapping.source;
  3619. if (source != null && !newSources.has(source)) {
  3620. newSources.add(source);
  3621. }
  3622. var name = mapping.name;
  3623. if (name != null && !newNames.has(name)) {
  3624. newNames.add(name);
  3625. }
  3626. }, this);
  3627. this._sources = newSources;
  3628. this._names = newNames;
  3629. // Copy sourcesContents of applied map.
  3630. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  3631. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  3632. if (content != null) {
  3633. if (aSourceMapPath != null) {
  3634. sourceFile = util.join(aSourceMapPath, sourceFile);
  3635. }
  3636. if (sourceRoot != null) {
  3637. sourceFile = util.relative(sourceRoot, sourceFile);
  3638. }
  3639. this.setSourceContent(sourceFile, content);
  3640. }
  3641. }, this);
  3642. };
  3643. /**
  3644. * A mapping can have one of the three levels of data:
  3645. *
  3646. * 1. Just the generated position.
  3647. * 2. The Generated position, original position, and original source.
  3648. * 3. Generated and original position, original source, as well as a name
  3649. * token.
  3650. *
  3651. * To maintain consistency, we validate that any new mapping being added falls
  3652. * in to one of these categories.
  3653. */
  3654. SourceMapGenerator.prototype._validateMapping =
  3655. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  3656. aName) {
  3657. // When aOriginal is truthy but has empty values for .line and .column,
  3658. // it is most likely a programmer error. In this case we throw a very
  3659. // specific error message to try to guide them the right way.
  3660. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  3661. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  3662. throw new Error(
  3663. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  3664. 'the original mapping entirely and only map the generated position. If so, pass ' +
  3665. 'null for the original mapping instead of an object with empty or null values.'
  3666. );
  3667. }
  3668. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  3669. && aGenerated.line > 0 && aGenerated.column >= 0
  3670. && !aOriginal && !aSource && !aName) {
  3671. // Case 1.
  3672. return;
  3673. }
  3674. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  3675. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  3676. && aGenerated.line > 0 && aGenerated.column >= 0
  3677. && aOriginal.line > 0 && aOriginal.column >= 0
  3678. && aSource) {
  3679. // Cases 2 and 3.
  3680. return;
  3681. }
  3682. else {
  3683. throw new Error('Invalid mapping: ' + JSON.stringify({
  3684. generated: aGenerated,
  3685. source: aSource,
  3686. original: aOriginal,
  3687. name: aName
  3688. }));
  3689. }
  3690. };
  3691. /**
  3692. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  3693. * specified by the source map format.
  3694. */
  3695. SourceMapGenerator.prototype._serializeMappings =
  3696. function SourceMapGenerator_serializeMappings() {
  3697. var previousGeneratedColumn = 0;
  3698. var previousGeneratedLine = 1;
  3699. var previousOriginalColumn = 0;
  3700. var previousOriginalLine = 0;
  3701. var previousName = 0;
  3702. var previousSource = 0;
  3703. var result = '';
  3704. var next;
  3705. var mapping;
  3706. var nameIdx;
  3707. var sourceIdx;
  3708. var mappings = this._mappings.toArray();
  3709. for (var i = 0, len = mappings.length; i < len; i++) {
  3710. mapping = mappings[i];
  3711. next = '';
  3712. if (mapping.generatedLine !== previousGeneratedLine) {
  3713. previousGeneratedColumn = 0;
  3714. while (mapping.generatedLine !== previousGeneratedLine) {
  3715. next += ';';
  3716. previousGeneratedLine++;
  3717. }
  3718. }
  3719. else {
  3720. if (i > 0) {
  3721. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  3722. continue;
  3723. }
  3724. next += ',';
  3725. }
  3726. }
  3727. next += base64Vlq.encode(mapping.generatedColumn
  3728. - previousGeneratedColumn);
  3729. previousGeneratedColumn = mapping.generatedColumn;
  3730. if (mapping.source != null) {
  3731. sourceIdx = this._sources.indexOf(mapping.source);
  3732. next += base64Vlq.encode(sourceIdx - previousSource);
  3733. previousSource = sourceIdx;
  3734. // lines are stored 0-based in SourceMap spec version 3
  3735. next += base64Vlq.encode(mapping.originalLine - 1
  3736. - previousOriginalLine);
  3737. previousOriginalLine = mapping.originalLine - 1;
  3738. next += base64Vlq.encode(mapping.originalColumn
  3739. - previousOriginalColumn);
  3740. previousOriginalColumn = mapping.originalColumn;
  3741. if (mapping.name != null) {
  3742. nameIdx = this._names.indexOf(mapping.name);
  3743. next += base64Vlq.encode(nameIdx - previousName);
  3744. previousName = nameIdx;
  3745. }
  3746. }
  3747. result += next;
  3748. }
  3749. return result;
  3750. };
  3751. SourceMapGenerator.prototype._generateSourcesContent =
  3752. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  3753. return aSources.map(function (source) {
  3754. if (!this._sourcesContents) {
  3755. return null;
  3756. }
  3757. if (aSourceRoot != null) {
  3758. source = util.relative(aSourceRoot, source);
  3759. }
  3760. var key = util.toSetString(source);
  3761. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  3762. ? this._sourcesContents[key]
  3763. : null;
  3764. }, this);
  3765. };
  3766. /**
  3767. * Externalize the source map.
  3768. */
  3769. SourceMapGenerator.prototype.toJSON =
  3770. function SourceMapGenerator_toJSON() {
  3771. var map = {
  3772. version: this._version,
  3773. sources: this._sources.toArray(),
  3774. names: this._names.toArray(),
  3775. mappings: this._serializeMappings()
  3776. };
  3777. if (this._file != null) {
  3778. map.file = this._file;
  3779. }
  3780. if (this._sourceRoot != null) {
  3781. map.sourceRoot = this._sourceRoot;
  3782. }
  3783. if (this._sourcesContents) {
  3784. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  3785. }
  3786. return map;
  3787. };
  3788. /**
  3789. * Render the source map being generated to a string.
  3790. */
  3791. SourceMapGenerator.prototype.toString =
  3792. function SourceMapGenerator_toString() {
  3793. return JSON.stringify(this.toJSON());
  3794. };
  3795. var SourceMapGenerator_1 = SourceMapGenerator;
  3796. var sourceMapGenerator = {
  3797. SourceMapGenerator: SourceMapGenerator_1
  3798. };
  3799. /* -*- Mode: js; js-indent-level: 2; -*- */
  3800. var binarySearch = createCommonjsModule(function (module, exports) {
  3801. /*
  3802. * Copyright 2011 Mozilla Foundation and contributors
  3803. * Licensed under the New BSD license. See LICENSE or:
  3804. * http://opensource.org/licenses/BSD-3-Clause
  3805. */
  3806. exports.GREATEST_LOWER_BOUND = 1;
  3807. exports.LEAST_UPPER_BOUND = 2;
  3808. /**
  3809. * Recursive implementation of binary search.
  3810. *
  3811. * @param aLow Indices here and lower do not contain the needle.
  3812. * @param aHigh Indices here and higher do not contain the needle.
  3813. * @param aNeedle The element being searched for.
  3814. * @param aHaystack The non-empty array being searched.
  3815. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  3816. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  3817. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  3818. * closest element that is smaller than or greater than the one we are
  3819. * searching for, respectively, if the exact element cannot be found.
  3820. */
  3821. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  3822. // This function terminates when one of the following is true:
  3823. //
  3824. // 1. We find the exact element we are looking for.
  3825. //
  3826. // 2. We did not find the exact element, but we can return the index of
  3827. // the next-closest element.
  3828. //
  3829. // 3. We did not find the exact element, and there is no next-closest
  3830. // element than the one we are searching for, so we return -1.
  3831. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  3832. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  3833. if (cmp === 0) {
  3834. // Found the element we are looking for.
  3835. return mid;
  3836. }
  3837. else if (cmp > 0) {
  3838. // Our needle is greater than aHaystack[mid].
  3839. if (aHigh - mid > 1) {
  3840. // The element is in the upper half.
  3841. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  3842. }
  3843. // The exact needle element was not found in this haystack. Determine if
  3844. // we are in termination case (3) or (2) and return the appropriate thing.
  3845. if (aBias == exports.LEAST_UPPER_BOUND) {
  3846. return aHigh < aHaystack.length ? aHigh : -1;
  3847. } else {
  3848. return mid;
  3849. }
  3850. }
  3851. else {
  3852. // Our needle is less than aHaystack[mid].
  3853. if (mid - aLow > 1) {
  3854. // The element is in the lower half.
  3855. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  3856. }
  3857. // we are in termination case (3) or (2) and return the appropriate thing.
  3858. if (aBias == exports.LEAST_UPPER_BOUND) {
  3859. return mid;
  3860. } else {
  3861. return aLow < 0 ? -1 : aLow;
  3862. }
  3863. }
  3864. }
  3865. /**
  3866. * This is an implementation of binary search which will always try and return
  3867. * the index of the closest element if there is no exact hit. This is because
  3868. * mappings between original and generated line/col pairs are single points,
  3869. * and there is an implicit region between each of them, so a miss just means
  3870. * that you aren't on the very start of a region.
  3871. *
  3872. * @param aNeedle The element you are looking for.
  3873. * @param aHaystack The array that is being searched.
  3874. * @param aCompare A function which takes the needle and an element in the
  3875. * array and returns -1, 0, or 1 depending on whether the needle is less
  3876. * than, equal to, or greater than the element, respectively.
  3877. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  3878. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  3879. * closest element that is smaller than or greater than the one we are
  3880. * searching for, respectively, if the exact element cannot be found.
  3881. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  3882. */
  3883. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  3884. if (aHaystack.length === 0) {
  3885. return -1;
  3886. }
  3887. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  3888. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  3889. if (index < 0) {
  3890. return -1;
  3891. }
  3892. // We have found either the exact element, or the next-closest element than
  3893. // the one we are searching for. However, there may be more than one such
  3894. // element. Make sure we always return the smallest of these.
  3895. while (index - 1 >= 0) {
  3896. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  3897. break;
  3898. }
  3899. --index;
  3900. }
  3901. return index;
  3902. };
  3903. });
  3904. /* -*- Mode: js; js-indent-level: 2; -*- */
  3905. /*
  3906. * Copyright 2011 Mozilla Foundation and contributors
  3907. * Licensed under the New BSD license. See LICENSE or:
  3908. * http://opensource.org/licenses/BSD-3-Clause
  3909. */
  3910. // It turns out that some (most?) JavaScript engines don't self-host
  3911. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  3912. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  3913. // custom comparator function, calling back and forth between the VM's C++ and
  3914. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  3915. // worse generated code for the comparator function than would be optimal. In
  3916. // fact, when sorting with a comparator, these costs outweigh the benefits of
  3917. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  3918. // a ~3500ms mean speed-up in `bench/bench.html`.
  3919. /**
  3920. * Swap the elements indexed by `x` and `y` in the array `ary`.
  3921. *
  3922. * @param {Array} ary
  3923. * The array.
  3924. * @param {Number} x
  3925. * The index of the first item.
  3926. * @param {Number} y
  3927. * The index of the second item.
  3928. */
  3929. function swap(ary, x, y) {
  3930. var temp = ary[x];
  3931. ary[x] = ary[y];
  3932. ary[y] = temp;
  3933. }
  3934. /**
  3935. * Returns a random integer within the range `low .. high` inclusive.
  3936. *
  3937. * @param {Number} low
  3938. * The lower bound on the range.
  3939. * @param {Number} high
  3940. * The upper bound on the range.
  3941. */
  3942. function randomIntInRange(low, high) {
  3943. return Math.round(low + (Math.random() * (high - low)));
  3944. }
  3945. /**
  3946. * The Quick Sort algorithm.
  3947. *
  3948. * @param {Array} ary
  3949. * An array to sort.
  3950. * @param {function} comparator
  3951. * Function to use to compare two items.
  3952. * @param {Number} p
  3953. * Start index of the array
  3954. * @param {Number} r
  3955. * End index of the array
  3956. */
  3957. function doQuickSort(ary, comparator, p, r) {
  3958. // If our lower bound is less than our upper bound, we (1) partition the
  3959. // array into two pieces and (2) recurse on each half. If it is not, this is
  3960. // the empty array and our base case.
  3961. if (p < r) {
  3962. // (1) Partitioning.
  3963. //
  3964. // The partitioning chooses a pivot between `p` and `r` and moves all
  3965. // elements that are less than or equal to the pivot to the before it, and
  3966. // all the elements that are greater than it after it. The effect is that
  3967. // once partition is done, the pivot is in the exact place it will be when
  3968. // the array is put in sorted order, and it will not need to be moved
  3969. // again. This runs in O(n) time.
  3970. // Always choose a random pivot so that an input array which is reverse
  3971. // sorted does not cause O(n^2) running time.
  3972. var pivotIndex = randomIntInRange(p, r);
  3973. var i = p - 1;
  3974. swap(ary, pivotIndex, r);
  3975. var pivot = ary[r];
  3976. // Immediately after `j` is incremented in this loop, the following hold
  3977. // true:
  3978. //
  3979. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  3980. //
  3981. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  3982. for (var j = p; j < r; j++) {
  3983. if (comparator(ary[j], pivot) <= 0) {
  3984. i += 1;
  3985. swap(ary, i, j);
  3986. }
  3987. }
  3988. swap(ary, i + 1, j);
  3989. var q = i + 1;
  3990. // (2) Recurse on each half.
  3991. doQuickSort(ary, comparator, p, q - 1);
  3992. doQuickSort(ary, comparator, q + 1, r);
  3993. }
  3994. }
  3995. /**
  3996. * Sort the given array in-place with the given comparator function.
  3997. *
  3998. * @param {Array} ary
  3999. * An array to sort.
  4000. * @param {function} comparator
  4001. * Function to use to compare two items.
  4002. */
  4003. var quickSort_1 = function (ary, comparator) {
  4004. doQuickSort(ary, comparator, 0, ary.length - 1);
  4005. };
  4006. var quickSort = {
  4007. quickSort: quickSort_1
  4008. };
  4009. /* -*- Mode: js; js-indent-level: 2; -*- */
  4010. /*
  4011. * Copyright 2011 Mozilla Foundation and contributors
  4012. * Licensed under the New BSD license. See LICENSE or:
  4013. * http://opensource.org/licenses/BSD-3-Clause
  4014. */
  4015. var ArraySet$2 = arraySet.ArraySet;
  4016. var quickSort$1 = quickSort.quickSort;
  4017. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  4018. var sourceMap = aSourceMap;
  4019. if (typeof aSourceMap === 'string') {
  4020. sourceMap = util.parseSourceMapInput(aSourceMap);
  4021. }
  4022. return sourceMap.sections != null
  4023. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  4024. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  4025. }
  4026. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  4027. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  4028. };
  4029. /**
  4030. * The version of the source mapping spec that we are consuming.
  4031. */
  4032. SourceMapConsumer.prototype._version = 3;
  4033. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  4034. // parsed mapping coordinates from the source map's "mappings" attribute. They
  4035. // are lazily instantiated, accessed via the `_generatedMappings` and
  4036. // `_originalMappings` getters respectively, and we only parse the mappings
  4037. // and create these arrays once queried for a source location. We jump through
  4038. // these hoops because there can be many thousands of mappings, and parsing
  4039. // them is expensive, so we only want to do it if we must.
  4040. //
  4041. // Each object in the arrays is of the form:
  4042. //
  4043. // {
  4044. // generatedLine: The line number in the generated code,
  4045. // generatedColumn: The column number in the generated code,
  4046. // source: The path to the original source file that generated this
  4047. // chunk of code,
  4048. // originalLine: The line number in the original source that
  4049. // corresponds to this chunk of generated code,
  4050. // originalColumn: The column number in the original source that
  4051. // corresponds to this chunk of generated code,
  4052. // name: The name of the original symbol which generated this chunk of
  4053. // code.
  4054. // }
  4055. //
  4056. // All properties except for `generatedLine` and `generatedColumn` can be
  4057. // `null`.
  4058. //
  4059. // `_generatedMappings` is ordered by the generated positions.
  4060. //
  4061. // `_originalMappings` is ordered by the original positions.
  4062. SourceMapConsumer.prototype.__generatedMappings = null;
  4063. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  4064. configurable: true,
  4065. enumerable: true,
  4066. get: function () {
  4067. if (!this.__generatedMappings) {
  4068. this._parseMappings(this._mappings, this.sourceRoot);
  4069. }
  4070. return this.__generatedMappings;
  4071. }
  4072. });
  4073. SourceMapConsumer.prototype.__originalMappings = null;
  4074. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  4075. configurable: true,
  4076. enumerable: true,
  4077. get: function () {
  4078. if (!this.__originalMappings) {
  4079. this._parseMappings(this._mappings, this.sourceRoot);
  4080. }
  4081. return this.__originalMappings;
  4082. }
  4083. });
  4084. SourceMapConsumer.prototype._charIsMappingSeparator =
  4085. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  4086. var c = aStr.charAt(index);
  4087. return c === ";" || c === ",";
  4088. };
  4089. /**
  4090. * Parse the mappings in a string in to a data structure which we can easily
  4091. * query (the ordered arrays in the `this.__generatedMappings` and
  4092. * `this.__originalMappings` properties).
  4093. */
  4094. SourceMapConsumer.prototype._parseMappings =
  4095. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  4096. throw new Error("Subclasses must implement _parseMappings");
  4097. };
  4098. SourceMapConsumer.GENERATED_ORDER = 1;
  4099. SourceMapConsumer.ORIGINAL_ORDER = 2;
  4100. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  4101. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  4102. /**
  4103. * Iterate over each mapping between an original source/line/column and a
  4104. * generated line/column in this source map.
  4105. *
  4106. * @param Function aCallback
  4107. * The function that is called with each mapping.
  4108. * @param Object aContext
  4109. * Optional. If specified, this object will be the value of `this` every
  4110. * time that `aCallback` is called.
  4111. * @param aOrder
  4112. * Either `SourceMapConsumer.GENERATED_ORDER` or
  4113. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  4114. * iterate over the mappings sorted by the generated file's line/column
  4115. * order or the original's source/line/column order, respectively. Defaults to
  4116. * `SourceMapConsumer.GENERATED_ORDER`.
  4117. */
  4118. SourceMapConsumer.prototype.eachMapping =
  4119. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  4120. var context = aContext || null;
  4121. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  4122. var mappings;
  4123. switch (order) {
  4124. case SourceMapConsumer.GENERATED_ORDER:
  4125. mappings = this._generatedMappings;
  4126. break;
  4127. case SourceMapConsumer.ORIGINAL_ORDER:
  4128. mappings = this._originalMappings;
  4129. break;
  4130. default:
  4131. throw new Error("Unknown order of iteration.");
  4132. }
  4133. var sourceRoot = this.sourceRoot;
  4134. mappings.map(function (mapping) {
  4135. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  4136. source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  4137. return {
  4138. source: source,
  4139. generatedLine: mapping.generatedLine,
  4140. generatedColumn: mapping.generatedColumn,
  4141. originalLine: mapping.originalLine,
  4142. originalColumn: mapping.originalColumn,
  4143. name: mapping.name === null ? null : this._names.at(mapping.name)
  4144. };
  4145. }, this).forEach(aCallback, context);
  4146. };
  4147. /**
  4148. * Returns all generated line and column information for the original source,
  4149. * line, and column provided. If no column is provided, returns all mappings
  4150. * corresponding to a either the line we are searching for or the next
  4151. * closest line that has any mappings. Otherwise, returns all mappings
  4152. * corresponding to the given line and either the column we are searching for
  4153. * or the next closest column that has any offsets.
  4154. *
  4155. * The only argument is an object with the following properties:
  4156. *
  4157. * - source: The filename of the original source.
  4158. * - line: The line number in the original source. The line number is 1-based.
  4159. * - column: Optional. the column number in the original source.
  4160. * The column number is 0-based.
  4161. *
  4162. * and an array of objects is returned, each with the following properties:
  4163. *
  4164. * - line: The line number in the generated source, or null. The
  4165. * line number is 1-based.
  4166. * - column: The column number in the generated source, or null.
  4167. * The column number is 0-based.
  4168. */
  4169. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  4170. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  4171. var line = util.getArg(aArgs, 'line');
  4172. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  4173. // returns the index of the closest mapping less than the needle. By
  4174. // setting needle.originalColumn to 0, we thus find the last mapping for
  4175. // the given line, provided such a mapping exists.
  4176. var needle = {
  4177. source: util.getArg(aArgs, 'source'),
  4178. originalLine: line,
  4179. originalColumn: util.getArg(aArgs, 'column', 0)
  4180. };
  4181. needle.source = this._findSourceIndex(needle.source);
  4182. if (needle.source < 0) {
  4183. return [];
  4184. }
  4185. var mappings = [];
  4186. var index = this._findMapping(needle,
  4187. this._originalMappings,
  4188. "originalLine",
  4189. "originalColumn",
  4190. util.compareByOriginalPositions,
  4191. binarySearch.LEAST_UPPER_BOUND);
  4192. if (index >= 0) {
  4193. var mapping = this._originalMappings[index];
  4194. if (aArgs.column === undefined) {
  4195. var originalLine = mapping.originalLine;
  4196. // Iterate until either we run out of mappings, or we run into
  4197. // a mapping for a different line than the one we found. Since
  4198. // mappings are sorted, this is guaranteed to find all mappings for
  4199. // the line we found.
  4200. while (mapping && mapping.originalLine === originalLine) {
  4201. mappings.push({
  4202. line: util.getArg(mapping, 'generatedLine', null),
  4203. column: util.getArg(mapping, 'generatedColumn', null),
  4204. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  4205. });
  4206. mapping = this._originalMappings[++index];
  4207. }
  4208. } else {
  4209. var originalColumn = mapping.originalColumn;
  4210. // Iterate until either we run out of mappings, or we run into
  4211. // a mapping for a different line than the one we were searching for.
  4212. // Since mappings are sorted, this is guaranteed to find all mappings for
  4213. // the line we are searching for.
  4214. while (mapping &&
  4215. mapping.originalLine === line &&
  4216. mapping.originalColumn == originalColumn) {
  4217. mappings.push({
  4218. line: util.getArg(mapping, 'generatedLine', null),
  4219. column: util.getArg(mapping, 'generatedColumn', null),
  4220. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  4221. });
  4222. mapping = this._originalMappings[++index];
  4223. }
  4224. }
  4225. }
  4226. return mappings;
  4227. };
  4228. var SourceMapConsumer_1 = SourceMapConsumer;
  4229. /**
  4230. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  4231. * query for information about the original file positions by giving it a file
  4232. * position in the generated source.
  4233. *
  4234. * The first parameter is the raw source map (either as a JSON string, or
  4235. * already parsed to an object). According to the spec, source maps have the
  4236. * following attributes:
  4237. *
  4238. * - version: Which version of the source map spec this map is following.
  4239. * - sources: An array of URLs to the original source files.
  4240. * - names: An array of identifiers which can be referrenced by individual mappings.
  4241. * - sourceRoot: Optional. The URL root from which all sources are relative.
  4242. * - sourcesContent: Optional. An array of contents of the original source files.
  4243. * - mappings: A string of base64 VLQs which contain the actual mappings.
  4244. * - file: Optional. The generated file this source map is associated with.
  4245. *
  4246. * Here is an example source map, taken from the source map spec[0]:
  4247. *
  4248. * {
  4249. * version : 3,
  4250. * file: "out.js",
  4251. * sourceRoot : "",
  4252. * sources: ["foo.js", "bar.js"],
  4253. * names: ["src", "maps", "are", "fun"],
  4254. * mappings: "AA,AB;;ABCDE;"
  4255. * }
  4256. *
  4257. * The second parameter, if given, is a string whose value is the URL
  4258. * at which the source map was found. This URL is used to compute the
  4259. * sources array.
  4260. *
  4261. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  4262. */
  4263. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  4264. var sourceMap = aSourceMap;
  4265. if (typeof aSourceMap === 'string') {
  4266. sourceMap = util.parseSourceMapInput(aSourceMap);
  4267. }
  4268. var version = util.getArg(sourceMap, 'version');
  4269. var sources = util.getArg(sourceMap, 'sources');
  4270. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  4271. // requires the array) to play nice here.
  4272. var names = util.getArg(sourceMap, 'names', []);
  4273. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  4274. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  4275. var mappings = util.getArg(sourceMap, 'mappings');
  4276. var file = util.getArg(sourceMap, 'file', null);
  4277. // Once again, Sass deviates from the spec and supplies the version as a
  4278. // string rather than a number, so we use loose equality checking here.
  4279. if (version != this._version) {
  4280. throw new Error('Unsupported version: ' + version);
  4281. }
  4282. if (sourceRoot) {
  4283. sourceRoot = util.normalize(sourceRoot);
  4284. }
  4285. sources = sources
  4286. .map(String)
  4287. // Some source maps produce relative source paths like "./foo.js" instead of
  4288. // "foo.js". Normalize these first so that future comparisons will succeed.
  4289. // See bugzil.la/1090768.
  4290. .map(util.normalize)
  4291. // Always ensure that absolute sources are internally stored relative to
  4292. // the source root, if the source root is absolute. Not doing this would
  4293. // be particularly problematic when the source root is a prefix of the
  4294. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  4295. .map(function (source) {
  4296. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  4297. ? util.relative(sourceRoot, source)
  4298. : source;
  4299. });
  4300. // Pass `true` below to allow duplicate names and sources. While source maps
  4301. // are intended to be compressed and deduplicated, the TypeScript compiler
  4302. // sometimes generates source maps with duplicates in them. See Github issue
  4303. // #72 and bugzil.la/889492.
  4304. this._names = ArraySet$2.fromArray(names.map(String), true);
  4305. this._sources = ArraySet$2.fromArray(sources, true);
  4306. this._absoluteSources = this._sources.toArray().map(function (s) {
  4307. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  4308. });
  4309. this.sourceRoot = sourceRoot;
  4310. this.sourcesContent = sourcesContent;
  4311. this._mappings = mappings;
  4312. this._sourceMapURL = aSourceMapURL;
  4313. this.file = file;
  4314. }
  4315. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  4316. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  4317. /**
  4318. * Utility function to find the index of a source. Returns -1 if not
  4319. * found.
  4320. */
  4321. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  4322. var relativeSource = aSource;
  4323. if (this.sourceRoot != null) {
  4324. relativeSource = util.relative(this.sourceRoot, relativeSource);
  4325. }
  4326. if (this._sources.has(relativeSource)) {
  4327. return this._sources.indexOf(relativeSource);
  4328. }
  4329. // Maybe aSource is an absolute URL as returned by |sources|. In
  4330. // this case we can't simply undo the transform.
  4331. var i;
  4332. for (i = 0; i < this._absoluteSources.length; ++i) {
  4333. if (this._absoluteSources[i] == aSource) {
  4334. return i;
  4335. }
  4336. }
  4337. return -1;
  4338. };
  4339. /**
  4340. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  4341. *
  4342. * @param SourceMapGenerator aSourceMap
  4343. * The source map that will be consumed.
  4344. * @param String aSourceMapURL
  4345. * The URL at which the source map can be found (optional)
  4346. * @returns BasicSourceMapConsumer
  4347. */
  4348. BasicSourceMapConsumer.fromSourceMap =
  4349. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  4350. var smc = Object.create(BasicSourceMapConsumer.prototype);
  4351. var names = smc._names = ArraySet$2.fromArray(aSourceMap._names.toArray(), true);
  4352. var sources = smc._sources = ArraySet$2.fromArray(aSourceMap._sources.toArray(), true);
  4353. smc.sourceRoot = aSourceMap._sourceRoot;
  4354. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  4355. smc.sourceRoot);
  4356. smc.file = aSourceMap._file;
  4357. smc._sourceMapURL = aSourceMapURL;
  4358. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  4359. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  4360. });
  4361. // Because we are modifying the entries (by converting string sources and
  4362. // names to indices into the sources and names ArraySets), we have to make
  4363. // a copy of the entry or else bad things happen. Shared mutable state
  4364. // strikes again! See github issue #191.
  4365. var generatedMappings = aSourceMap._mappings.toArray().slice();
  4366. var destGeneratedMappings = smc.__generatedMappings = [];
  4367. var destOriginalMappings = smc.__originalMappings = [];
  4368. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  4369. var srcMapping = generatedMappings[i];
  4370. var destMapping = new Mapping;
  4371. destMapping.generatedLine = srcMapping.generatedLine;
  4372. destMapping.generatedColumn = srcMapping.generatedColumn;
  4373. if (srcMapping.source) {
  4374. destMapping.source = sources.indexOf(srcMapping.source);
  4375. destMapping.originalLine = srcMapping.originalLine;
  4376. destMapping.originalColumn = srcMapping.originalColumn;
  4377. if (srcMapping.name) {
  4378. destMapping.name = names.indexOf(srcMapping.name);
  4379. }
  4380. destOriginalMappings.push(destMapping);
  4381. }
  4382. destGeneratedMappings.push(destMapping);
  4383. }
  4384. quickSort$1(smc.__originalMappings, util.compareByOriginalPositions);
  4385. return smc;
  4386. };
  4387. /**
  4388. * The version of the source mapping spec that we are consuming.
  4389. */
  4390. BasicSourceMapConsumer.prototype._version = 3;
  4391. /**
  4392. * The list of original sources.
  4393. */
  4394. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  4395. get: function () {
  4396. return this._absoluteSources.slice();
  4397. }
  4398. });
  4399. /**
  4400. * Provide the JIT with a nice shape / hidden class.
  4401. */
  4402. function Mapping() {
  4403. this.generatedLine = 0;
  4404. this.generatedColumn = 0;
  4405. this.source = null;
  4406. this.originalLine = null;
  4407. this.originalColumn = null;
  4408. this.name = null;
  4409. }
  4410. /**
  4411. * Parse the mappings in a string in to a data structure which we can easily
  4412. * query (the ordered arrays in the `this.__generatedMappings` and
  4413. * `this.__originalMappings` properties).
  4414. */
  4415. BasicSourceMapConsumer.prototype._parseMappings =
  4416. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  4417. var generatedLine = 1;
  4418. var previousGeneratedColumn = 0;
  4419. var previousOriginalLine = 0;
  4420. var previousOriginalColumn = 0;
  4421. var previousSource = 0;
  4422. var previousName = 0;
  4423. var length = aStr.length;
  4424. var index = 0;
  4425. var cachedSegments = {};
  4426. var temp = {};
  4427. var originalMappings = [];
  4428. var generatedMappings = [];
  4429. var mapping, str, segment, end, value;
  4430. while (index < length) {
  4431. if (aStr.charAt(index) === ';') {
  4432. generatedLine++;
  4433. index++;
  4434. previousGeneratedColumn = 0;
  4435. }
  4436. else if (aStr.charAt(index) === ',') {
  4437. index++;
  4438. }
  4439. else {
  4440. mapping = new Mapping();
  4441. mapping.generatedLine = generatedLine;
  4442. // Because each offset is encoded relative to the previous one,
  4443. // many segments often have the same encoding. We can exploit this
  4444. // fact by caching the parsed variable length fields of each segment,
  4445. // allowing us to avoid a second parse if we encounter the same
  4446. // segment again.
  4447. for (end = index; end < length; end++) {
  4448. if (this._charIsMappingSeparator(aStr, end)) {
  4449. break;
  4450. }
  4451. }
  4452. str = aStr.slice(index, end);
  4453. segment = cachedSegments[str];
  4454. if (segment) {
  4455. index += str.length;
  4456. } else {
  4457. segment = [];
  4458. while (index < end) {
  4459. base64Vlq.decode(aStr, index, temp);
  4460. value = temp.value;
  4461. index = temp.rest;
  4462. segment.push(value);
  4463. }
  4464. if (segment.length === 2) {
  4465. throw new Error('Found a source, but no line and column');
  4466. }
  4467. if (segment.length === 3) {
  4468. throw new Error('Found a source and line, but no column');
  4469. }
  4470. cachedSegments[str] = segment;
  4471. }
  4472. // Generated column.
  4473. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  4474. previousGeneratedColumn = mapping.generatedColumn;
  4475. if (segment.length > 1) {
  4476. // Original source.
  4477. mapping.source = previousSource + segment[1];
  4478. previousSource += segment[1];
  4479. // Original line.
  4480. mapping.originalLine = previousOriginalLine + segment[2];
  4481. previousOriginalLine = mapping.originalLine;
  4482. // Lines are stored 0-based
  4483. mapping.originalLine += 1;
  4484. // Original column.
  4485. mapping.originalColumn = previousOriginalColumn + segment[3];
  4486. previousOriginalColumn = mapping.originalColumn;
  4487. if (segment.length > 4) {
  4488. // Original name.
  4489. mapping.name = previousName + segment[4];
  4490. previousName += segment[4];
  4491. }
  4492. }
  4493. generatedMappings.push(mapping);
  4494. if (typeof mapping.originalLine === 'number') {
  4495. originalMappings.push(mapping);
  4496. }
  4497. }
  4498. }
  4499. quickSort$1(generatedMappings, util.compareByGeneratedPositionsDeflated);
  4500. this.__generatedMappings = generatedMappings;
  4501. quickSort$1(originalMappings, util.compareByOriginalPositions);
  4502. this.__originalMappings = originalMappings;
  4503. };
  4504. /**
  4505. * Find the mapping that best matches the hypothetical "needle" mapping that
  4506. * we are searching for in the given "haystack" of mappings.
  4507. */
  4508. BasicSourceMapConsumer.prototype._findMapping =
  4509. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  4510. aColumnName, aComparator, aBias) {
  4511. // To return the position we are searching for, we must first find the
  4512. // mapping for the given position and then return the opposite position it
  4513. // points to. Because the mappings are sorted, we can use binary search to
  4514. // find the best mapping.
  4515. if (aNeedle[aLineName] <= 0) {
  4516. throw new TypeError('Line must be greater than or equal to 1, got '
  4517. + aNeedle[aLineName]);
  4518. }
  4519. if (aNeedle[aColumnName] < 0) {
  4520. throw new TypeError('Column must be greater than or equal to 0, got '
  4521. + aNeedle[aColumnName]);
  4522. }
  4523. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  4524. };
  4525. /**
  4526. * Compute the last column for each generated mapping. The last column is
  4527. * inclusive.
  4528. */
  4529. BasicSourceMapConsumer.prototype.computeColumnSpans =
  4530. function SourceMapConsumer_computeColumnSpans() {
  4531. for (var index = 0; index < this._generatedMappings.length; ++index) {
  4532. var mapping = this._generatedMappings[index];
  4533. // Mappings do not contain a field for the last generated columnt. We
  4534. // can come up with an optimistic estimate, however, by assuming that
  4535. // mappings are contiguous (i.e. given two consecutive mappings, the
  4536. // first mapping ends where the second one starts).
  4537. if (index + 1 < this._generatedMappings.length) {
  4538. var nextMapping = this._generatedMappings[index + 1];
  4539. if (mapping.generatedLine === nextMapping.generatedLine) {
  4540. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  4541. continue;
  4542. }
  4543. }
  4544. // The last mapping for each line spans the entire line.
  4545. mapping.lastGeneratedColumn = Infinity;
  4546. }
  4547. };
  4548. /**
  4549. * Returns the original source, line, and column information for the generated
  4550. * source's line and column positions provided. The only argument is an object
  4551. * with the following properties:
  4552. *
  4553. * - line: The line number in the generated source. The line number
  4554. * is 1-based.
  4555. * - column: The column number in the generated source. The column
  4556. * number is 0-based.
  4557. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  4558. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  4559. * closest element that is smaller than or greater than the one we are
  4560. * searching for, respectively, if the exact element cannot be found.
  4561. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  4562. *
  4563. * and an object is returned with the following properties:
  4564. *
  4565. * - source: The original source file, or null.
  4566. * - line: The line number in the original source, or null. The
  4567. * line number is 1-based.
  4568. * - column: The column number in the original source, or null. The
  4569. * column number is 0-based.
  4570. * - name: The original identifier, or null.
  4571. */
  4572. BasicSourceMapConsumer.prototype.originalPositionFor =
  4573. function SourceMapConsumer_originalPositionFor(aArgs) {
  4574. var needle = {
  4575. generatedLine: util.getArg(aArgs, 'line'),
  4576. generatedColumn: util.getArg(aArgs, 'column')
  4577. };
  4578. var index = this._findMapping(
  4579. needle,
  4580. this._generatedMappings,
  4581. "generatedLine",
  4582. "generatedColumn",
  4583. util.compareByGeneratedPositionsDeflated,
  4584. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  4585. );
  4586. if (index >= 0) {
  4587. var mapping = this._generatedMappings[index];
  4588. if (mapping.generatedLine === needle.generatedLine) {
  4589. var source = util.getArg(mapping, 'source', null);
  4590. if (source !== null) {
  4591. source = this._sources.at(source);
  4592. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  4593. }
  4594. var name = util.getArg(mapping, 'name', null);
  4595. if (name !== null) {
  4596. name = this._names.at(name);
  4597. }
  4598. return {
  4599. source: source,
  4600. line: util.getArg(mapping, 'originalLine', null),
  4601. column: util.getArg(mapping, 'originalColumn', null),
  4602. name: name
  4603. };
  4604. }
  4605. }
  4606. return {
  4607. source: null,
  4608. line: null,
  4609. column: null,
  4610. name: null
  4611. };
  4612. };
  4613. /**
  4614. * Return true if we have the source content for every source in the source
  4615. * map, false otherwise.
  4616. */
  4617. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  4618. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  4619. if (!this.sourcesContent) {
  4620. return false;
  4621. }
  4622. return this.sourcesContent.length >= this._sources.size() &&
  4623. !this.sourcesContent.some(function (sc) { return sc == null; });
  4624. };
  4625. /**
  4626. * Returns the original source content. The only argument is the url of the
  4627. * original source file. Returns null if no original source content is
  4628. * available.
  4629. */
  4630. BasicSourceMapConsumer.prototype.sourceContentFor =
  4631. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  4632. if (!this.sourcesContent) {
  4633. return null;
  4634. }
  4635. var index = this._findSourceIndex(aSource);
  4636. if (index >= 0) {
  4637. return this.sourcesContent[index];
  4638. }
  4639. var relativeSource = aSource;
  4640. if (this.sourceRoot != null) {
  4641. relativeSource = util.relative(this.sourceRoot, relativeSource);
  4642. }
  4643. var url;
  4644. if (this.sourceRoot != null
  4645. && (url = util.urlParse(this.sourceRoot))) {
  4646. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  4647. // many users. We can help them out when they expect file:// URIs to
  4648. // behave like it would if they were running a local HTTP server. See
  4649. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  4650. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  4651. if (url.scheme == "file"
  4652. && this._sources.has(fileUriAbsPath)) {
  4653. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  4654. }
  4655. if ((!url.path || url.path == "/")
  4656. && this._sources.has("/" + relativeSource)) {
  4657. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  4658. }
  4659. }
  4660. // This function is used recursively from
  4661. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  4662. // don't want to throw if we can't find the source - we just want to
  4663. // return null, so we provide a flag to exit gracefully.
  4664. if (nullOnMissing) {
  4665. return null;
  4666. }
  4667. else {
  4668. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  4669. }
  4670. };
  4671. /**
  4672. * Returns the generated line and column information for the original source,
  4673. * line, and column positions provided. The only argument is an object with
  4674. * the following properties:
  4675. *
  4676. * - source: The filename of the original source.
  4677. * - line: The line number in the original source. The line number
  4678. * is 1-based.
  4679. * - column: The column number in the original source. The column
  4680. * number is 0-based.
  4681. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  4682. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  4683. * closest element that is smaller than or greater than the one we are
  4684. * searching for, respectively, if the exact element cannot be found.
  4685. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  4686. *
  4687. * and an object is returned with the following properties:
  4688. *
  4689. * - line: The line number in the generated source, or null. The
  4690. * line number is 1-based.
  4691. * - column: The column number in the generated source, or null.
  4692. * The column number is 0-based.
  4693. */
  4694. BasicSourceMapConsumer.prototype.generatedPositionFor =
  4695. function SourceMapConsumer_generatedPositionFor(aArgs) {
  4696. var source = util.getArg(aArgs, 'source');
  4697. source = this._findSourceIndex(source);
  4698. if (source < 0) {
  4699. return {
  4700. line: null,
  4701. column: null,
  4702. lastColumn: null
  4703. };
  4704. }
  4705. var needle = {
  4706. source: source,
  4707. originalLine: util.getArg(aArgs, 'line'),
  4708. originalColumn: util.getArg(aArgs, 'column')
  4709. };
  4710. var index = this._findMapping(
  4711. needle,
  4712. this._originalMappings,
  4713. "originalLine",
  4714. "originalColumn",
  4715. util.compareByOriginalPositions,
  4716. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  4717. );
  4718. if (index >= 0) {
  4719. var mapping = this._originalMappings[index];
  4720. if (mapping.source === needle.source) {
  4721. return {
  4722. line: util.getArg(mapping, 'generatedLine', null),
  4723. column: util.getArg(mapping, 'generatedColumn', null),
  4724. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  4725. };
  4726. }
  4727. }
  4728. return {
  4729. line: null,
  4730. column: null,
  4731. lastColumn: null
  4732. };
  4733. };
  4734. var BasicSourceMapConsumer_1 = BasicSourceMapConsumer;
  4735. /**
  4736. * An IndexedSourceMapConsumer instance represents a parsed source map which
  4737. * we can query for information. It differs from BasicSourceMapConsumer in
  4738. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  4739. * input.
  4740. *
  4741. * The first parameter is a raw source map (either as a JSON string, or already
  4742. * parsed to an object). According to the spec for indexed source maps, they
  4743. * have the following attributes:
  4744. *
  4745. * - version: Which version of the source map spec this map is following.
  4746. * - file: Optional. The generated file this source map is associated with.
  4747. * - sections: A list of section definitions.
  4748. *
  4749. * Each value under the "sections" field has two fields:
  4750. * - offset: The offset into the original specified at which this section
  4751. * begins to apply, defined as an object with a "line" and "column"
  4752. * field.
  4753. * - map: A source map definition. This source map could also be indexed,
  4754. * but doesn't have to be.
  4755. *
  4756. * Instead of the "map" field, it's also possible to have a "url" field
  4757. * specifying a URL to retrieve a source map from, but that's currently
  4758. * unsupported.
  4759. *
  4760. * Here's an example source map, taken from the source map spec[0], but
  4761. * modified to omit a section which uses the "url" field.
  4762. *
  4763. * {
  4764. * version : 3,
  4765. * file: "app.js",
  4766. * sections: [{
  4767. * offset: {line:100, column:10},
  4768. * map: {
  4769. * version : 3,
  4770. * file: "section.js",
  4771. * sources: ["foo.js", "bar.js"],
  4772. * names: ["src", "maps", "are", "fun"],
  4773. * mappings: "AAAA,E;;ABCDE;"
  4774. * }
  4775. * }],
  4776. * }
  4777. *
  4778. * The second parameter, if given, is a string whose value is the URL
  4779. * at which the source map was found. This URL is used to compute the
  4780. * sources array.
  4781. *
  4782. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  4783. */
  4784. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  4785. var sourceMap = aSourceMap;
  4786. if (typeof aSourceMap === 'string') {
  4787. sourceMap = util.parseSourceMapInput(aSourceMap);
  4788. }
  4789. var version = util.getArg(sourceMap, 'version');
  4790. var sections = util.getArg(sourceMap, 'sections');
  4791. if (version != this._version) {
  4792. throw new Error('Unsupported version: ' + version);
  4793. }
  4794. this._sources = new ArraySet$2();
  4795. this._names = new ArraySet$2();
  4796. var lastOffset = {
  4797. line: -1,
  4798. column: 0
  4799. };
  4800. this._sections = sections.map(function (s) {
  4801. if (s.url) {
  4802. // The url field will require support for asynchronicity.
  4803. // See https://github.com/mozilla/source-map/issues/16
  4804. throw new Error('Support for url field in sections not implemented.');
  4805. }
  4806. var offset = util.getArg(s, 'offset');
  4807. var offsetLine = util.getArg(offset, 'line');
  4808. var offsetColumn = util.getArg(offset, 'column');
  4809. if (offsetLine < lastOffset.line ||
  4810. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  4811. throw new Error('Section offsets must be ordered and non-overlapping.');
  4812. }
  4813. lastOffset = offset;
  4814. return {
  4815. generatedOffset: {
  4816. // The offset fields are 0-based, but we use 1-based indices when
  4817. // encoding/decoding from VLQ.
  4818. generatedLine: offsetLine + 1,
  4819. generatedColumn: offsetColumn + 1
  4820. },
  4821. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  4822. }
  4823. });
  4824. }
  4825. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  4826. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  4827. /**
  4828. * The version of the source mapping spec that we are consuming.
  4829. */
  4830. IndexedSourceMapConsumer.prototype._version = 3;
  4831. /**
  4832. * The list of original sources.
  4833. */
  4834. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  4835. get: function () {
  4836. var sources = [];
  4837. for (var i = 0; i < this._sections.length; i++) {
  4838. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  4839. sources.push(this._sections[i].consumer.sources[j]);
  4840. }
  4841. }
  4842. return sources;
  4843. }
  4844. });
  4845. /**
  4846. * Returns the original source, line, and column information for the generated
  4847. * source's line and column positions provided. The only argument is an object
  4848. * with the following properties:
  4849. *
  4850. * - line: The line number in the generated source. The line number
  4851. * is 1-based.
  4852. * - column: The column number in the generated source. The column
  4853. * number is 0-based.
  4854. *
  4855. * and an object is returned with the following properties:
  4856. *
  4857. * - source: The original source file, or null.
  4858. * - line: The line number in the original source, or null. The
  4859. * line number is 1-based.
  4860. * - column: The column number in the original source, or null. The
  4861. * column number is 0-based.
  4862. * - name: The original identifier, or null.
  4863. */
  4864. IndexedSourceMapConsumer.prototype.originalPositionFor =
  4865. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  4866. var needle = {
  4867. generatedLine: util.getArg(aArgs, 'line'),
  4868. generatedColumn: util.getArg(aArgs, 'column')
  4869. };
  4870. // Find the section containing the generated position we're trying to map
  4871. // to an original position.
  4872. var sectionIndex = binarySearch.search(needle, this._sections,
  4873. function(needle, section) {
  4874. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  4875. if (cmp) {
  4876. return cmp;
  4877. }
  4878. return (needle.generatedColumn -
  4879. section.generatedOffset.generatedColumn);
  4880. });
  4881. var section = this._sections[sectionIndex];
  4882. if (!section) {
  4883. return {
  4884. source: null,
  4885. line: null,
  4886. column: null,
  4887. name: null
  4888. };
  4889. }
  4890. return section.consumer.originalPositionFor({
  4891. line: needle.generatedLine -
  4892. (section.generatedOffset.generatedLine - 1),
  4893. column: needle.generatedColumn -
  4894. (section.generatedOffset.generatedLine === needle.generatedLine
  4895. ? section.generatedOffset.generatedColumn - 1
  4896. : 0),
  4897. bias: aArgs.bias
  4898. });
  4899. };
  4900. /**
  4901. * Return true if we have the source content for every source in the source
  4902. * map, false otherwise.
  4903. */
  4904. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  4905. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  4906. return this._sections.every(function (s) {
  4907. return s.consumer.hasContentsOfAllSources();
  4908. });
  4909. };
  4910. /**
  4911. * Returns the original source content. The only argument is the url of the
  4912. * original source file. Returns null if no original source content is
  4913. * available.
  4914. */
  4915. IndexedSourceMapConsumer.prototype.sourceContentFor =
  4916. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  4917. for (var i = 0; i < this._sections.length; i++) {
  4918. var section = this._sections[i];
  4919. var content = section.consumer.sourceContentFor(aSource, true);
  4920. if (content) {
  4921. return content;
  4922. }
  4923. }
  4924. if (nullOnMissing) {
  4925. return null;
  4926. }
  4927. else {
  4928. throw new Error('"' + aSource + '" is not in the SourceMap.');
  4929. }
  4930. };
  4931. /**
  4932. * Returns the generated line and column information for the original source,
  4933. * line, and column positions provided. The only argument is an object with
  4934. * the following properties:
  4935. *
  4936. * - source: The filename of the original source.
  4937. * - line: The line number in the original source. The line number
  4938. * is 1-based.
  4939. * - column: The column number in the original source. The column
  4940. * number is 0-based.
  4941. *
  4942. * and an object is returned with the following properties:
  4943. *
  4944. * - line: The line number in the generated source, or null. The
  4945. * line number is 1-based.
  4946. * - column: The column number in the generated source, or null.
  4947. * The column number is 0-based.
  4948. */
  4949. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  4950. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  4951. for (var i = 0; i < this._sections.length; i++) {
  4952. var section = this._sections[i];
  4953. // Only consider this section if the requested source is in the list of
  4954. // sources of the consumer.
  4955. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  4956. continue;
  4957. }
  4958. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  4959. if (generatedPosition) {
  4960. var ret = {
  4961. line: generatedPosition.line +
  4962. (section.generatedOffset.generatedLine - 1),
  4963. column: generatedPosition.column +
  4964. (section.generatedOffset.generatedLine === generatedPosition.line
  4965. ? section.generatedOffset.generatedColumn - 1
  4966. : 0)
  4967. };
  4968. return ret;
  4969. }
  4970. }
  4971. return {
  4972. line: null,
  4973. column: null
  4974. };
  4975. };
  4976. /**
  4977. * Parse the mappings in a string in to a data structure which we can easily
  4978. * query (the ordered arrays in the `this.__generatedMappings` and
  4979. * `this.__originalMappings` properties).
  4980. */
  4981. IndexedSourceMapConsumer.prototype._parseMappings =
  4982. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  4983. this.__generatedMappings = [];
  4984. this.__originalMappings = [];
  4985. for (var i = 0; i < this._sections.length; i++) {
  4986. var section = this._sections[i];
  4987. var sectionMappings = section.consumer._generatedMappings;
  4988. for (var j = 0; j < sectionMappings.length; j++) {
  4989. var mapping = sectionMappings[j];
  4990. var source = section.consumer._sources.at(mapping.source);
  4991. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  4992. this._sources.add(source);
  4993. source = this._sources.indexOf(source);
  4994. var name = null;
  4995. if (mapping.name) {
  4996. name = section.consumer._names.at(mapping.name);
  4997. this._names.add(name);
  4998. name = this._names.indexOf(name);
  4999. }
  5000. // The mappings coming from the consumer for the section have
  5001. // generated positions relative to the start of the section, so we
  5002. // need to offset them to be relative to the start of the concatenated
  5003. // generated file.
  5004. var adjustedMapping = {
  5005. source: source,
  5006. generatedLine: mapping.generatedLine +
  5007. (section.generatedOffset.generatedLine - 1),
  5008. generatedColumn: mapping.generatedColumn +
  5009. (section.generatedOffset.generatedLine === mapping.generatedLine
  5010. ? section.generatedOffset.generatedColumn - 1
  5011. : 0),
  5012. originalLine: mapping.originalLine,
  5013. originalColumn: mapping.originalColumn,
  5014. name: name
  5015. };
  5016. this.__generatedMappings.push(adjustedMapping);
  5017. if (typeof adjustedMapping.originalLine === 'number') {
  5018. this.__originalMappings.push(adjustedMapping);
  5019. }
  5020. }
  5021. }
  5022. quickSort$1(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  5023. quickSort$1(this.__originalMappings, util.compareByOriginalPositions);
  5024. };
  5025. var IndexedSourceMapConsumer_1 = IndexedSourceMapConsumer;
  5026. var sourceMapConsumer = {
  5027. SourceMapConsumer: SourceMapConsumer_1,
  5028. BasicSourceMapConsumer: BasicSourceMapConsumer_1,
  5029. IndexedSourceMapConsumer: IndexedSourceMapConsumer_1
  5030. };
  5031. /* -*- Mode: js; js-indent-level: 2; -*- */
  5032. /*
  5033. * Copyright 2011 Mozilla Foundation and contributors
  5034. * Licensed under the New BSD license. See LICENSE or:
  5035. * http://opensource.org/licenses/BSD-3-Clause
  5036. */
  5037. var SourceMapGenerator$1 = sourceMapGenerator.SourceMapGenerator;
  5038. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  5039. // operating systems these days (capturing the result).
  5040. var REGEX_NEWLINE = /(\r?\n)/;
  5041. // Newline character code for charCodeAt() comparisons
  5042. var NEWLINE_CODE = 10;
  5043. // Private symbol for identifying `SourceNode`s when multiple versions of
  5044. // the source-map library are loaded. This MUST NOT CHANGE across
  5045. // versions!
  5046. var isSourceNode = "$$$isSourceNode$$$";
  5047. /**
  5048. * SourceNodes provide a way to abstract over interpolating/concatenating
  5049. * snippets of generated JavaScript source code while maintaining the line and
  5050. * column information associated with the original source code.
  5051. *
  5052. * @param aLine The original line number.
  5053. * @param aColumn The original column number.
  5054. * @param aSource The original source's filename.
  5055. * @param aChunks Optional. An array of strings which are snippets of
  5056. * generated JS, or other SourceNodes.
  5057. * @param aName The original identifier.
  5058. */
  5059. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  5060. this.children = [];
  5061. this.sourceContents = {};
  5062. this.line = aLine == null ? null : aLine;
  5063. this.column = aColumn == null ? null : aColumn;
  5064. this.source = aSource == null ? null : aSource;
  5065. this.name = aName == null ? null : aName;
  5066. this[isSourceNode] = true;
  5067. if (aChunks != null) this.add(aChunks);
  5068. }
  5069. /**
  5070. * Creates a SourceNode from generated code and a SourceMapConsumer.
  5071. *
  5072. * @param aGeneratedCode The generated code
  5073. * @param aSourceMapConsumer The SourceMap for the generated code
  5074. * @param aRelativePath Optional. The path that relative sources in the
  5075. * SourceMapConsumer should be relative to.
  5076. */
  5077. SourceNode.fromStringWithSourceMap =
  5078. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  5079. // The SourceNode we want to fill with the generated code
  5080. // and the SourceMap
  5081. var node = new SourceNode();
  5082. // All even indices of this array are one line of the generated code,
  5083. // while all odd indices are the newlines between two adjacent lines
  5084. // (since `REGEX_NEWLINE` captures its match).
  5085. // Processed fragments are accessed by calling `shiftNextLine`.
  5086. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  5087. var remainingLinesIndex = 0;
  5088. var shiftNextLine = function() {
  5089. var lineContents = getNextLine();
  5090. // The last line of a file might not have a newline.
  5091. var newLine = getNextLine() || "";
  5092. return lineContents + newLine;
  5093. function getNextLine() {
  5094. return remainingLinesIndex < remainingLines.length ?
  5095. remainingLines[remainingLinesIndex++] : undefined;
  5096. }
  5097. };
  5098. // We need to remember the position of "remainingLines"
  5099. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  5100. // The generate SourceNodes we need a code range.
  5101. // To extract it current and last mapping is used.
  5102. // Here we store the last mapping.
  5103. var lastMapping = null;
  5104. aSourceMapConsumer.eachMapping(function (mapping) {
  5105. if (lastMapping !== null) {
  5106. // We add the code from "lastMapping" to "mapping":
  5107. // First check if there is a new line in between.
  5108. if (lastGeneratedLine < mapping.generatedLine) {
  5109. // Associate first line with "lastMapping"
  5110. addMappingWithCode(lastMapping, shiftNextLine());
  5111. lastGeneratedLine++;
  5112. lastGeneratedColumn = 0;
  5113. // The remaining code is added without mapping
  5114. } else {
  5115. // There is no new line in between.
  5116. // Associate the code between "lastGeneratedColumn" and
  5117. // "mapping.generatedColumn" with "lastMapping"
  5118. var nextLine = remainingLines[remainingLinesIndex] || '';
  5119. var code = nextLine.substr(0, mapping.generatedColumn -
  5120. lastGeneratedColumn);
  5121. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  5122. lastGeneratedColumn);
  5123. lastGeneratedColumn = mapping.generatedColumn;
  5124. addMappingWithCode(lastMapping, code);
  5125. // No more remaining code, continue
  5126. lastMapping = mapping;
  5127. return;
  5128. }
  5129. }
  5130. // We add the generated code until the first mapping
  5131. // to the SourceNode without any mapping.
  5132. // Each line is added as separate string.
  5133. while (lastGeneratedLine < mapping.generatedLine) {
  5134. node.add(shiftNextLine());
  5135. lastGeneratedLine++;
  5136. }
  5137. if (lastGeneratedColumn < mapping.generatedColumn) {
  5138. var nextLine = remainingLines[remainingLinesIndex] || '';
  5139. node.add(nextLine.substr(0, mapping.generatedColumn));
  5140. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  5141. lastGeneratedColumn = mapping.generatedColumn;
  5142. }
  5143. lastMapping = mapping;
  5144. }, this);
  5145. // We have processed all mappings.
  5146. if (remainingLinesIndex < remainingLines.length) {
  5147. if (lastMapping) {
  5148. // Associate the remaining code in the current line with "lastMapping"
  5149. addMappingWithCode(lastMapping, shiftNextLine());
  5150. }
  5151. // and add the remaining lines without any mapping
  5152. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  5153. }
  5154. // Copy sourcesContent into SourceNode
  5155. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  5156. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  5157. if (content != null) {
  5158. if (aRelativePath != null) {
  5159. sourceFile = util.join(aRelativePath, sourceFile);
  5160. }
  5161. node.setSourceContent(sourceFile, content);
  5162. }
  5163. });
  5164. return node;
  5165. function addMappingWithCode(mapping, code) {
  5166. if (mapping === null || mapping.source === undefined) {
  5167. node.add(code);
  5168. } else {
  5169. var source = aRelativePath
  5170. ? util.join(aRelativePath, mapping.source)
  5171. : mapping.source;
  5172. node.add(new SourceNode(mapping.originalLine,
  5173. mapping.originalColumn,
  5174. source,
  5175. code,
  5176. mapping.name));
  5177. }
  5178. }
  5179. };
  5180. /**
  5181. * Add a chunk of generated JS to this source node.
  5182. *
  5183. * @param aChunk A string snippet of generated JS code, another instance of
  5184. * SourceNode, or an array where each member is one of those things.
  5185. */
  5186. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  5187. if (Array.isArray(aChunk)) {
  5188. aChunk.forEach(function (chunk) {
  5189. this.add(chunk);
  5190. }, this);
  5191. }
  5192. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  5193. if (aChunk) {
  5194. this.children.push(aChunk);
  5195. }
  5196. }
  5197. else {
  5198. throw new TypeError(
  5199. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  5200. );
  5201. }
  5202. return this;
  5203. };
  5204. /**
  5205. * Add a chunk of generated JS to the beginning of this source node.
  5206. *
  5207. * @param aChunk A string snippet of generated JS code, another instance of
  5208. * SourceNode, or an array where each member is one of those things.
  5209. */
  5210. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  5211. if (Array.isArray(aChunk)) {
  5212. for (var i = aChunk.length-1; i >= 0; i--) {
  5213. this.prepend(aChunk[i]);
  5214. }
  5215. }
  5216. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  5217. this.children.unshift(aChunk);
  5218. }
  5219. else {
  5220. throw new TypeError(
  5221. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  5222. );
  5223. }
  5224. return this;
  5225. };
  5226. /**
  5227. * Walk over the tree of JS snippets in this node and its children. The
  5228. * walking function is called once for each snippet of JS and is passed that
  5229. * snippet and the its original associated source's line/column location.
  5230. *
  5231. * @param aFn The traversal function.
  5232. */
  5233. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  5234. var chunk;
  5235. for (var i = 0, len = this.children.length; i < len; i++) {
  5236. chunk = this.children[i];
  5237. if (chunk[isSourceNode]) {
  5238. chunk.walk(aFn);
  5239. }
  5240. else {
  5241. if (chunk !== '') {
  5242. aFn(chunk, { source: this.source,
  5243. line: this.line,
  5244. column: this.column,
  5245. name: this.name });
  5246. }
  5247. }
  5248. }
  5249. };
  5250. /**
  5251. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  5252. * each of `this.children`.
  5253. *
  5254. * @param aSep The separator.
  5255. */
  5256. SourceNode.prototype.join = function SourceNode_join(aSep) {
  5257. var newChildren;
  5258. var i;
  5259. var len = this.children.length;
  5260. if (len > 0) {
  5261. newChildren = [];
  5262. for (i = 0; i < len-1; i++) {
  5263. newChildren.push(this.children[i]);
  5264. newChildren.push(aSep);
  5265. }
  5266. newChildren.push(this.children[i]);
  5267. this.children = newChildren;
  5268. }
  5269. return this;
  5270. };
  5271. /**
  5272. * Call String.prototype.replace on the very right-most source snippet. Useful
  5273. * for trimming whitespace from the end of a source node, etc.
  5274. *
  5275. * @param aPattern The pattern to replace.
  5276. * @param aReplacement The thing to replace the pattern with.
  5277. */
  5278. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  5279. var lastChild = this.children[this.children.length - 1];
  5280. if (lastChild[isSourceNode]) {
  5281. lastChild.replaceRight(aPattern, aReplacement);
  5282. }
  5283. else if (typeof lastChild === 'string') {
  5284. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  5285. }
  5286. else {
  5287. this.children.push(''.replace(aPattern, aReplacement));
  5288. }
  5289. return this;
  5290. };
  5291. /**
  5292. * Set the source content for a source file. This will be added to the SourceMapGenerator
  5293. * in the sourcesContent field.
  5294. *
  5295. * @param aSourceFile The filename of the source file
  5296. * @param aSourceContent The content of the source file
  5297. */
  5298. SourceNode.prototype.setSourceContent =
  5299. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  5300. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  5301. };
  5302. /**
  5303. * Walk over the tree of SourceNodes. The walking function is called for each
  5304. * source file content and is passed the filename and source content.
  5305. *
  5306. * @param aFn The traversal function.
  5307. */
  5308. SourceNode.prototype.walkSourceContents =
  5309. function SourceNode_walkSourceContents(aFn) {
  5310. for (var i = 0, len = this.children.length; i < len; i++) {
  5311. if (this.children[i][isSourceNode]) {
  5312. this.children[i].walkSourceContents(aFn);
  5313. }
  5314. }
  5315. var sources = Object.keys(this.sourceContents);
  5316. for (var i = 0, len = sources.length; i < len; i++) {
  5317. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  5318. }
  5319. };
  5320. /**
  5321. * Return the string representation of this source node. Walks over the tree
  5322. * and concatenates all the various snippets together to one string.
  5323. */
  5324. SourceNode.prototype.toString = function SourceNode_toString() {
  5325. var str = "";
  5326. this.walk(function (chunk) {
  5327. str += chunk;
  5328. });
  5329. return str;
  5330. };
  5331. /**
  5332. * Returns the string representation of this source node along with a source
  5333. * map.
  5334. */
  5335. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  5336. var generated = {
  5337. code: "",
  5338. line: 1,
  5339. column: 0
  5340. };
  5341. var map = new SourceMapGenerator$1(aArgs);
  5342. var sourceMappingActive = false;
  5343. var lastOriginalSource = null;
  5344. var lastOriginalLine = null;
  5345. var lastOriginalColumn = null;
  5346. var lastOriginalName = null;
  5347. this.walk(function (chunk, original) {
  5348. generated.code += chunk;
  5349. if (original.source !== null
  5350. && original.line !== null
  5351. && original.column !== null) {
  5352. if(lastOriginalSource !== original.source
  5353. || lastOriginalLine !== original.line
  5354. || lastOriginalColumn !== original.column
  5355. || lastOriginalName !== original.name) {
  5356. map.addMapping({
  5357. source: original.source,
  5358. original: {
  5359. line: original.line,
  5360. column: original.column
  5361. },
  5362. generated: {
  5363. line: generated.line,
  5364. column: generated.column
  5365. },
  5366. name: original.name
  5367. });
  5368. }
  5369. lastOriginalSource = original.source;
  5370. lastOriginalLine = original.line;
  5371. lastOriginalColumn = original.column;
  5372. lastOriginalName = original.name;
  5373. sourceMappingActive = true;
  5374. } else if (sourceMappingActive) {
  5375. map.addMapping({
  5376. generated: {
  5377. line: generated.line,
  5378. column: generated.column
  5379. }
  5380. });
  5381. lastOriginalSource = null;
  5382. sourceMappingActive = false;
  5383. }
  5384. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  5385. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  5386. generated.line++;
  5387. generated.column = 0;
  5388. // Mappings end at eol
  5389. if (idx + 1 === length) {
  5390. lastOriginalSource = null;
  5391. sourceMappingActive = false;
  5392. } else if (sourceMappingActive) {
  5393. map.addMapping({
  5394. source: original.source,
  5395. original: {
  5396. line: original.line,
  5397. column: original.column
  5398. },
  5399. generated: {
  5400. line: generated.line,
  5401. column: generated.column
  5402. },
  5403. name: original.name
  5404. });
  5405. }
  5406. } else {
  5407. generated.column++;
  5408. }
  5409. }
  5410. });
  5411. this.walkSourceContents(function (sourceFile, sourceContent) {
  5412. map.setSourceContent(sourceFile, sourceContent);
  5413. });
  5414. return { code: generated.code, map: map };
  5415. };
  5416. var SourceNode_1 = SourceNode;
  5417. var sourceNode = {
  5418. SourceNode: SourceNode_1
  5419. };
  5420. /*
  5421. * Copyright 2009-2011 Mozilla Foundation and contributors
  5422. * Licensed under the New BSD license. See LICENSE.txt or:
  5423. * http://opensource.org/licenses/BSD-3-Clause
  5424. */
  5425. var SourceMapGenerator$2 = sourceMapGenerator.SourceMapGenerator;
  5426. var SourceMapConsumer$1 = sourceMapConsumer.SourceMapConsumer;
  5427. var SourceNode$1 = sourceNode.SourceNode;
  5428. var sourceMap = {
  5429. SourceMapGenerator: SourceMapGenerator$2,
  5430. SourceMapConsumer: SourceMapConsumer$1,
  5431. SourceNode: SourceNode$1
  5432. };
  5433. const PURE_ANNOTATION = `/*#__PURE__*/`;
  5434. function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
  5435. const context = {
  5436. mode,
  5437. prefixIdentifiers,
  5438. sourceMap,
  5439. filename,
  5440. scopeId,
  5441. optimizeImports,
  5442. runtimeGlobalName,
  5443. runtimeModuleName,
  5444. ssr,
  5445. isTS,
  5446. inSSR,
  5447. source: ast.loc.source,
  5448. code: ``,
  5449. column: 1,
  5450. line: 1,
  5451. offset: 0,
  5452. indentLevel: 0,
  5453. pure: false,
  5454. map: undefined,
  5455. helper(key) {
  5456. return `_${helperNameMap[key]}`;
  5457. },
  5458. push(code, node) {
  5459. context.code += code;
  5460. if (context.map) {
  5461. if (node) {
  5462. let name;
  5463. if (node.type === 4 /* SIMPLE_EXPRESSION */ && !node.isStatic) {
  5464. const content = node.content.replace(/^_ctx\./, '');
  5465. if (content !== node.content && isSimpleIdentifier(content)) {
  5466. name = content;
  5467. }
  5468. }
  5469. addMapping(node.loc.start, name);
  5470. }
  5471. advancePositionWithMutation(context, code);
  5472. if (node && node.loc !== locStub) {
  5473. addMapping(node.loc.end);
  5474. }
  5475. }
  5476. },
  5477. indent() {
  5478. newline(++context.indentLevel);
  5479. },
  5480. deindent(withoutNewLine = false) {
  5481. if (withoutNewLine) {
  5482. --context.indentLevel;
  5483. }
  5484. else {
  5485. newline(--context.indentLevel);
  5486. }
  5487. },
  5488. newline() {
  5489. newline(context.indentLevel);
  5490. }
  5491. };
  5492. function newline(n) {
  5493. context.push('\n' + ` `.repeat(n));
  5494. }
  5495. function addMapping(loc, name) {
  5496. context.map.addMapping({
  5497. name,
  5498. source: context.filename,
  5499. original: {
  5500. line: loc.line,
  5501. column: loc.column - 1 // source-map column is 0 based
  5502. },
  5503. generated: {
  5504. line: context.line,
  5505. column: context.column - 1
  5506. }
  5507. });
  5508. }
  5509. if (sourceMap) {
  5510. // lazy require source-map implementation, only in non-browser builds
  5511. context.map = new SourceMapGenerator$2();
  5512. context.map.setSourceContent(filename, context.source);
  5513. }
  5514. return context;
  5515. }
  5516. function generate(ast, options = {}) {
  5517. const context = createCodegenContext(ast, options);
  5518. if (options.onContextCreated)
  5519. options.onContextCreated(context);
  5520. const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
  5521. const hasHelpers = ast.helpers.length > 0;
  5522. const useWithBlock = !prefixIdentifiers && mode !== 'module';
  5523. const genScopeId = scopeId != null && mode === 'module';
  5524. const isSetupInlined = !!options.inline;
  5525. // preambles
  5526. // in setup() inline mode, the preamble is generated in a sub context
  5527. // and returned separately.
  5528. const preambleContext = isSetupInlined
  5529. ? createCodegenContext(ast, options)
  5530. : context;
  5531. if (mode === 'module') {
  5532. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  5533. }
  5534. else {
  5535. genFunctionPreamble(ast, preambleContext);
  5536. }
  5537. // enter render function
  5538. const functionName = ssr ? `ssrRender` : `render`;
  5539. const args = ssr ? ['_ctx', '_push', '_parent', '_attrs'] : ['_ctx', '_cache'];
  5540. if (options.bindingMetadata && !options.inline) {
  5541. // binding optimization args
  5542. args.push('$props', '$setup', '$data', '$options');
  5543. }
  5544. const signature = options.isTS
  5545. ? args.map(arg => `${arg}: any`).join(',')
  5546. : args.join(', ');
  5547. if (isSetupInlined) {
  5548. push(`(${signature}) => {`);
  5549. }
  5550. else {
  5551. push(`function ${functionName}(${signature}) {`);
  5552. }
  5553. indent();
  5554. if (useWithBlock) {
  5555. push(`with (_ctx) {`);
  5556. indent();
  5557. // function mode const declarations should be inside with block
  5558. // also they should be renamed to avoid collision with user properties
  5559. if (hasHelpers) {
  5560. push(`const { ${ast.helpers
  5561. .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
  5562. .join(', ')} } = _Vue`);
  5563. push(`\n`);
  5564. newline();
  5565. }
  5566. }
  5567. // generate asset resolution statements
  5568. if (ast.components.length) {
  5569. genAssets(ast.components, 'component', context);
  5570. if (ast.directives.length || ast.temps > 0) {
  5571. newline();
  5572. }
  5573. }
  5574. if (ast.directives.length) {
  5575. genAssets(ast.directives, 'directive', context);
  5576. if (ast.temps > 0) {
  5577. newline();
  5578. }
  5579. }
  5580. if (ast.temps > 0) {
  5581. push(`let `);
  5582. for (let i = 0; i < ast.temps; i++) {
  5583. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  5584. }
  5585. }
  5586. if (ast.components.length || ast.directives.length || ast.temps) {
  5587. push(`\n`);
  5588. newline();
  5589. }
  5590. // generate the VNode tree expression
  5591. if (!ssr) {
  5592. push(`return `);
  5593. }
  5594. if (ast.codegenNode) {
  5595. genNode(ast.codegenNode, context);
  5596. }
  5597. else {
  5598. push(`null`);
  5599. }
  5600. if (useWithBlock) {
  5601. deindent();
  5602. push(`}`);
  5603. }
  5604. deindent();
  5605. push(`}`);
  5606. return {
  5607. ast,
  5608. code: context.code,
  5609. preamble: isSetupInlined ? preambleContext.code : ``,
  5610. // SourceMapGenerator does have toJSON() method but it's not in the types
  5611. map: context.map ? context.map.toJSON() : undefined
  5612. };
  5613. }
  5614. function genFunctionPreamble(ast, context) {
  5615. const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
  5616. const VueBinding = ssr
  5617. ? `require(${JSON.stringify(runtimeModuleName)})`
  5618. : runtimeGlobalName;
  5619. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  5620. // Generate const declaration for helpers
  5621. // In prefix mode, we place the const declaration at top so it's done
  5622. // only once; But if we not prefixing, we place the declaration inside the
  5623. // with block so it doesn't incur the `in` check cost for every helper access.
  5624. if (ast.helpers.length > 0) {
  5625. if (prefixIdentifiers) {
  5626. push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
  5627. }
  5628. else {
  5629. // "with" mode.
  5630. // save Vue in a separate variable to avoid collision
  5631. push(`const _Vue = ${VueBinding}\n`);
  5632. // in "with" mode, helpers are declared inside the with block to avoid
  5633. // has check cost, but hoists are lifted out of the function - we need
  5634. // to provide the helper here.
  5635. if (ast.hoists.length) {
  5636. const staticHelpers = [
  5637. CREATE_VNODE,
  5638. CREATE_ELEMENT_VNODE,
  5639. CREATE_COMMENT,
  5640. CREATE_TEXT,
  5641. CREATE_STATIC
  5642. ]
  5643. .filter(helper => ast.helpers.includes(helper))
  5644. .map(aliasHelper)
  5645. .join(', ');
  5646. push(`const { ${staticHelpers} } = _Vue\n`);
  5647. }
  5648. }
  5649. }
  5650. // generate variables for ssr helpers
  5651. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  5652. // ssr guarantees prefixIdentifier: true
  5653. push(`const { ${ast.ssrHelpers
  5654. .map(aliasHelper)
  5655. .join(', ')} } = require("@vue/server-renderer")\n`);
  5656. }
  5657. genHoists(ast.hoists, context);
  5658. newline();
  5659. push(`return `);
  5660. }
  5661. function genModulePreamble(ast, context, genScopeId, inline) {
  5662. const { push, newline, optimizeImports, runtimeModuleName } = context;
  5663. if (genScopeId && ast.hoists.length) {
  5664. ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
  5665. }
  5666. // generate import statements for helpers
  5667. if (ast.helpers.length) {
  5668. if (optimizeImports) {
  5669. // when bundled with webpack with code-split, calling an import binding
  5670. // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
  5671. // incurring both payload size increase and potential perf overhead.
  5672. // therefore we assign the imports to variables (which is a constant ~50b
  5673. // cost per-component instead of scaling with template size)
  5674. push(`import { ${ast.helpers
  5675. .map(s => helperNameMap[s])
  5676. .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
  5677. push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
  5678. .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
  5679. .join(', ')}\n`);
  5680. }
  5681. else {
  5682. push(`import { ${ast.helpers
  5683. .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
  5684. .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
  5685. }
  5686. }
  5687. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  5688. push(`import { ${ast.ssrHelpers
  5689. .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
  5690. .join(', ')} } from "@vue/server-renderer"\n`);
  5691. }
  5692. if (ast.imports.length) {
  5693. genImports(ast.imports, context);
  5694. newline();
  5695. }
  5696. genHoists(ast.hoists, context);
  5697. newline();
  5698. if (!inline) {
  5699. push(`export `);
  5700. }
  5701. }
  5702. function genAssets(assets, type, { helper, push, newline, isTS }) {
  5703. const resolver = helper(type === 'component'
  5704. ? RESOLVE_COMPONENT
  5705. : RESOLVE_DIRECTIVE);
  5706. for (let i = 0; i < assets.length; i++) {
  5707. let id = assets[i];
  5708. // potential component implicit self-reference inferred from SFC filename
  5709. const maybeSelfReference = id.endsWith('__self');
  5710. if (maybeSelfReference) {
  5711. id = id.slice(0, -6);
  5712. }
  5713. push(`const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`);
  5714. if (i < assets.length - 1) {
  5715. newline();
  5716. }
  5717. }
  5718. }
  5719. function genHoists(hoists, context) {
  5720. if (!hoists.length) {
  5721. return;
  5722. }
  5723. context.pure = true;
  5724. const { push, newline, helper, scopeId, mode } = context;
  5725. const genScopeId = scopeId != null && mode !== 'function';
  5726. newline();
  5727. // push scope Id before initializing hoisted vnodes so that these vnodes
  5728. // get the proper scopeId as well.
  5729. if (genScopeId) {
  5730. push(`${helper(PUSH_SCOPE_ID)}("${scopeId}")`);
  5731. newline();
  5732. }
  5733. hoists.forEach((exp, i) => {
  5734. if (exp) {
  5735. push(`const _hoisted_${i + 1} = `);
  5736. genNode(exp, context);
  5737. newline();
  5738. }
  5739. });
  5740. if (genScopeId) {
  5741. push(`${helper(POP_SCOPE_ID)}()`);
  5742. newline();
  5743. }
  5744. context.pure = false;
  5745. }
  5746. function genImports(importsOptions, context) {
  5747. if (!importsOptions.length) {
  5748. return;
  5749. }
  5750. importsOptions.forEach(imports => {
  5751. context.push(`import `);
  5752. genNode(imports.exp, context);
  5753. context.push(` from '${imports.path}'`);
  5754. context.newline();
  5755. });
  5756. }
  5757. function isText$1(n) {
  5758. return (isString(n) ||
  5759. n.type === 4 /* SIMPLE_EXPRESSION */ ||
  5760. n.type === 2 /* TEXT */ ||
  5761. n.type === 5 /* INTERPOLATION */ ||
  5762. n.type === 8 /* COMPOUND_EXPRESSION */);
  5763. }
  5764. function genNodeListAsArray(nodes, context) {
  5765. const multilines = nodes.length > 3 ||
  5766. (nodes.some(n => isArray(n) || !isText$1(n)));
  5767. context.push(`[`);
  5768. multilines && context.indent();
  5769. genNodeList(nodes, context, multilines);
  5770. multilines && context.deindent();
  5771. context.push(`]`);
  5772. }
  5773. function genNodeList(nodes, context, multilines = false, comma = true) {
  5774. const { push, newline } = context;
  5775. for (let i = 0; i < nodes.length; i++) {
  5776. const node = nodes[i];
  5777. if (isString(node)) {
  5778. push(node);
  5779. }
  5780. else if (isArray(node)) {
  5781. genNodeListAsArray(node, context);
  5782. }
  5783. else {
  5784. genNode(node, context);
  5785. }
  5786. if (i < nodes.length - 1) {
  5787. if (multilines) {
  5788. comma && push(',');
  5789. newline();
  5790. }
  5791. else {
  5792. comma && push(', ');
  5793. }
  5794. }
  5795. }
  5796. }
  5797. function genNode(node, context) {
  5798. if (isString(node)) {
  5799. context.push(node);
  5800. return;
  5801. }
  5802. if (isSymbol(node)) {
  5803. context.push(context.helper(node));
  5804. return;
  5805. }
  5806. switch (node.type) {
  5807. case 1 /* ELEMENT */:
  5808. case 9 /* IF */:
  5809. case 11 /* FOR */:
  5810. assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
  5811. `Apply appropriate transforms first.`);
  5812. genNode(node.codegenNode, context);
  5813. break;
  5814. case 2 /* TEXT */:
  5815. genText(node, context);
  5816. break;
  5817. case 4 /* SIMPLE_EXPRESSION */:
  5818. genExpression(node, context);
  5819. break;
  5820. case 5 /* INTERPOLATION */:
  5821. genInterpolation(node, context);
  5822. break;
  5823. case 12 /* TEXT_CALL */:
  5824. genNode(node.codegenNode, context);
  5825. break;
  5826. case 8 /* COMPOUND_EXPRESSION */:
  5827. genCompoundExpression(node, context);
  5828. break;
  5829. case 3 /* COMMENT */:
  5830. genComment(node, context);
  5831. break;
  5832. case 13 /* VNODE_CALL */:
  5833. genVNodeCall(node, context);
  5834. break;
  5835. case 14 /* JS_CALL_EXPRESSION */:
  5836. genCallExpression(node, context);
  5837. break;
  5838. case 15 /* JS_OBJECT_EXPRESSION */:
  5839. genObjectExpression(node, context);
  5840. break;
  5841. case 17 /* JS_ARRAY_EXPRESSION */:
  5842. genArrayExpression(node, context);
  5843. break;
  5844. case 18 /* JS_FUNCTION_EXPRESSION */:
  5845. genFunctionExpression(node, context);
  5846. break;
  5847. case 19 /* JS_CONDITIONAL_EXPRESSION */:
  5848. genConditionalExpression(node, context);
  5849. break;
  5850. case 20 /* JS_CACHE_EXPRESSION */:
  5851. genCacheExpression(node, context);
  5852. break;
  5853. case 21 /* JS_BLOCK_STATEMENT */:
  5854. genNodeList(node.body, context, true, false);
  5855. break;
  5856. // SSR only types
  5857. case 22 /* JS_TEMPLATE_LITERAL */:
  5858. genTemplateLiteral(node, context);
  5859. break;
  5860. case 23 /* JS_IF_STATEMENT */:
  5861. genIfStatement(node, context);
  5862. break;
  5863. case 24 /* JS_ASSIGNMENT_EXPRESSION */:
  5864. genAssignmentExpression(node, context);
  5865. break;
  5866. case 25 /* JS_SEQUENCE_EXPRESSION */:
  5867. genSequenceExpression(node, context);
  5868. break;
  5869. case 26 /* JS_RETURN_STATEMENT */:
  5870. genReturnStatement(node, context);
  5871. break;
  5872. /* istanbul ignore next */
  5873. case 10 /* IF_BRANCH */:
  5874. // noop
  5875. break;
  5876. default:
  5877. {
  5878. assert(false, `unhandled codegen node type: ${node.type}`);
  5879. // make sure we exhaust all possible types
  5880. const exhaustiveCheck = node;
  5881. return exhaustiveCheck;
  5882. }
  5883. }
  5884. }
  5885. function genText(node, context) {
  5886. context.push(JSON.stringify(node.content), node);
  5887. }
  5888. function genExpression(node, context) {
  5889. const { content, isStatic } = node;
  5890. context.push(isStatic ? JSON.stringify(content) : content, node);
  5891. }
  5892. function genInterpolation(node, context) {
  5893. const { push, helper, pure } = context;
  5894. if (pure)
  5895. push(PURE_ANNOTATION);
  5896. push(`${helper(TO_DISPLAY_STRING)}(`);
  5897. genNode(node.content, context);
  5898. push(`)`);
  5899. }
  5900. function genCompoundExpression(node, context) {
  5901. for (let i = 0; i < node.children.length; i++) {
  5902. const child = node.children[i];
  5903. if (isString(child)) {
  5904. context.push(child);
  5905. }
  5906. else {
  5907. genNode(child, context);
  5908. }
  5909. }
  5910. }
  5911. function genExpressionAsPropertyKey(node, context) {
  5912. const { push } = context;
  5913. if (node.type === 8 /* COMPOUND_EXPRESSION */) {
  5914. push(`[`);
  5915. genCompoundExpression(node, context);
  5916. push(`]`);
  5917. }
  5918. else if (node.isStatic) {
  5919. // only quote keys if necessary
  5920. const text = isSimpleIdentifier(node.content)
  5921. ? node.content
  5922. : JSON.stringify(node.content);
  5923. push(text, node);
  5924. }
  5925. else {
  5926. push(`[${node.content}]`, node);
  5927. }
  5928. }
  5929. function genComment(node, context) {
  5930. const { push, helper, pure } = context;
  5931. if (pure) {
  5932. push(PURE_ANNOTATION);
  5933. }
  5934. push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
  5935. }
  5936. function genVNodeCall(node, context) {
  5937. const { push, helper, pure } = context;
  5938. const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
  5939. if (directives) {
  5940. push(helper(WITH_DIRECTIVES) + `(`);
  5941. }
  5942. if (isBlock) {
  5943. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  5944. }
  5945. if (pure) {
  5946. push(PURE_ANNOTATION);
  5947. }
  5948. const callHelper = isBlock
  5949. ? getVNodeBlockHelper(context.inSSR, isComponent)
  5950. : getVNodeHelper(context.inSSR, isComponent);
  5951. push(helper(callHelper) + `(`, node);
  5952. genNodeList(genNullableArgs([tag, props, children, patchFlag, dynamicProps]), context);
  5953. push(`)`);
  5954. if (isBlock) {
  5955. push(`)`);
  5956. }
  5957. if (directives) {
  5958. push(`, `);
  5959. genNode(directives, context);
  5960. push(`)`);
  5961. }
  5962. }
  5963. function genNullableArgs(args) {
  5964. let i = args.length;
  5965. while (i--) {
  5966. if (args[i] != null)
  5967. break;
  5968. }
  5969. return args.slice(0, i + 1).map(arg => arg || `null`);
  5970. }
  5971. // JavaScript
  5972. function genCallExpression(node, context) {
  5973. const { push, helper, pure } = context;
  5974. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  5975. if (pure) {
  5976. push(PURE_ANNOTATION);
  5977. }
  5978. push(callee + `(`, node);
  5979. genNodeList(node.arguments, context);
  5980. push(`)`);
  5981. }
  5982. function genObjectExpression(node, context) {
  5983. const { push, indent, deindent, newline } = context;
  5984. const { properties } = node;
  5985. if (!properties.length) {
  5986. push(`{}`, node);
  5987. return;
  5988. }
  5989. const multilines = properties.length > 1 ||
  5990. (properties.some(p => p.value.type !== 4 /* SIMPLE_EXPRESSION */));
  5991. push(multilines ? `{` : `{ `);
  5992. multilines && indent();
  5993. for (let i = 0; i < properties.length; i++) {
  5994. const { key, value } = properties[i];
  5995. // key
  5996. genExpressionAsPropertyKey(key, context);
  5997. push(`: `);
  5998. // value
  5999. genNode(value, context);
  6000. if (i < properties.length - 1) {
  6001. // will only reach this if it's multilines
  6002. push(`,`);
  6003. newline();
  6004. }
  6005. }
  6006. multilines && deindent();
  6007. push(multilines ? `}` : ` }`);
  6008. }
  6009. function genArrayExpression(node, context) {
  6010. genNodeListAsArray(node.elements, context);
  6011. }
  6012. function genFunctionExpression(node, context) {
  6013. const { push, indent, deindent } = context;
  6014. const { params, returns, body, newline, isSlot } = node;
  6015. if (isSlot) {
  6016. // wrap slot functions with owner context
  6017. push(`_${helperNameMap[WITH_CTX]}(`);
  6018. }
  6019. push(`(`, node);
  6020. if (isArray(params)) {
  6021. genNodeList(params, context);
  6022. }
  6023. else if (params) {
  6024. genNode(params, context);
  6025. }
  6026. push(`) => `);
  6027. if (newline || body) {
  6028. push(`{`);
  6029. indent();
  6030. }
  6031. if (returns) {
  6032. if (newline) {
  6033. push(`return `);
  6034. }
  6035. if (isArray(returns)) {
  6036. genNodeListAsArray(returns, context);
  6037. }
  6038. else {
  6039. genNode(returns, context);
  6040. }
  6041. }
  6042. else if (body) {
  6043. genNode(body, context);
  6044. }
  6045. if (newline || body) {
  6046. deindent();
  6047. push(`}`);
  6048. }
  6049. if (isSlot) {
  6050. push(`)`);
  6051. }
  6052. }
  6053. function genConditionalExpression(node, context) {
  6054. const { test, consequent, alternate, newline: needNewline } = node;
  6055. const { push, indent, deindent, newline } = context;
  6056. if (test.type === 4 /* SIMPLE_EXPRESSION */) {
  6057. const needsParens = !isSimpleIdentifier(test.content);
  6058. needsParens && push(`(`);
  6059. genExpression(test, context);
  6060. needsParens && push(`)`);
  6061. }
  6062. else {
  6063. push(`(`);
  6064. genNode(test, context);
  6065. push(`)`);
  6066. }
  6067. needNewline && indent();
  6068. context.indentLevel++;
  6069. needNewline || push(` `);
  6070. push(`? `);
  6071. genNode(consequent, context);
  6072. context.indentLevel--;
  6073. needNewline && newline();
  6074. needNewline || push(` `);
  6075. push(`: `);
  6076. const isNested = alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */;
  6077. if (!isNested) {
  6078. context.indentLevel++;
  6079. }
  6080. genNode(alternate, context);
  6081. if (!isNested) {
  6082. context.indentLevel--;
  6083. }
  6084. needNewline && deindent(true /* without newline */);
  6085. }
  6086. function genCacheExpression(node, context) {
  6087. const { push, helper, indent, deindent, newline } = context;
  6088. push(`_cache[${node.index}] || (`);
  6089. if (node.isVNode) {
  6090. indent();
  6091. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  6092. newline();
  6093. }
  6094. push(`_cache[${node.index}] = `);
  6095. genNode(node.value, context);
  6096. if (node.isVNode) {
  6097. push(`,`);
  6098. newline();
  6099. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  6100. newline();
  6101. push(`_cache[${node.index}]`);
  6102. deindent();
  6103. }
  6104. push(`)`);
  6105. }
  6106. function genTemplateLiteral(node, context) {
  6107. const { push, indent, deindent } = context;
  6108. push('`');
  6109. const l = node.elements.length;
  6110. const multilines = l > 3;
  6111. for (let i = 0; i < l; i++) {
  6112. const e = node.elements[i];
  6113. if (isString(e)) {
  6114. push(e.replace(/(`|\$|\\)/g, '\\$1'));
  6115. }
  6116. else {
  6117. push('${');
  6118. if (multilines)
  6119. indent();
  6120. genNode(e, context);
  6121. if (multilines)
  6122. deindent();
  6123. push('}');
  6124. }
  6125. }
  6126. push('`');
  6127. }
  6128. function genIfStatement(node, context) {
  6129. const { push, indent, deindent } = context;
  6130. const { test, consequent, alternate } = node;
  6131. push(`if (`);
  6132. genNode(test, context);
  6133. push(`) {`);
  6134. indent();
  6135. genNode(consequent, context);
  6136. deindent();
  6137. push(`}`);
  6138. if (alternate) {
  6139. push(` else `);
  6140. if (alternate.type === 23 /* JS_IF_STATEMENT */) {
  6141. genIfStatement(alternate, context);
  6142. }
  6143. else {
  6144. push(`{`);
  6145. indent();
  6146. genNode(alternate, context);
  6147. deindent();
  6148. push(`}`);
  6149. }
  6150. }
  6151. }
  6152. function genAssignmentExpression(node, context) {
  6153. genNode(node.left, context);
  6154. context.push(` = `);
  6155. genNode(node.right, context);
  6156. }
  6157. function genSequenceExpression(node, context) {
  6158. context.push(`(`);
  6159. genNodeList(node.expressions, context);
  6160. context.push(`)`);
  6161. }
  6162. function genReturnStatement({ returns }, context) {
  6163. context.push(`return `);
  6164. if (isArray(returns)) {
  6165. genNodeListAsArray(returns, context);
  6166. }
  6167. else {
  6168. genNode(returns, context);
  6169. }
  6170. }
  6171. var _default = shallowEqual;
  6172. function shallowEqual(actual, expected) {
  6173. const keys = Object.keys(expected);
  6174. for (const key of keys) {
  6175. if (actual[key] !== expected[key]) {
  6176. return false;
  6177. }
  6178. }
  6179. return true;
  6180. }
  6181. var shallowEqual_1 = /*#__PURE__*/Object.defineProperty({
  6182. default: _default
  6183. }, '__esModule', {value: true});
  6184. var isArrayExpression_1 = isArrayExpression;
  6185. var isAssignmentExpression_1 = isAssignmentExpression;
  6186. var isBinaryExpression_1 = isBinaryExpression;
  6187. var isInterpreterDirective_1 = isInterpreterDirective;
  6188. var isDirective_1 = isDirective;
  6189. var isDirectiveLiteral_1 = isDirectiveLiteral;
  6190. var isBlockStatement_1 = isBlockStatement;
  6191. var isBreakStatement_1 = isBreakStatement;
  6192. var isCallExpression_1 = isCallExpression;
  6193. var isCatchClause_1 = isCatchClause;
  6194. var isConditionalExpression_1 = isConditionalExpression;
  6195. var isContinueStatement_1 = isContinueStatement;
  6196. var isDebuggerStatement_1 = isDebuggerStatement;
  6197. var isDoWhileStatement_1 = isDoWhileStatement;
  6198. var isEmptyStatement_1 = isEmptyStatement;
  6199. var isExpressionStatement_1 = isExpressionStatement;
  6200. var isFile_1 = isFile;
  6201. var isForInStatement_1 = isForInStatement;
  6202. var isForStatement_1 = isForStatement;
  6203. var isFunctionDeclaration_1 = isFunctionDeclaration;
  6204. var isFunctionExpression_1 = isFunctionExpression;
  6205. var isIdentifier_1 = isIdentifier;
  6206. var isIfStatement_1 = isIfStatement;
  6207. var isLabeledStatement_1 = isLabeledStatement;
  6208. var isStringLiteral_1 = isStringLiteral;
  6209. var isNumericLiteral_1 = isNumericLiteral;
  6210. var isNullLiteral_1 = isNullLiteral;
  6211. var isBooleanLiteral_1 = isBooleanLiteral;
  6212. var isRegExpLiteral_1 = isRegExpLiteral;
  6213. var isLogicalExpression_1 = isLogicalExpression;
  6214. var isMemberExpression_1 = isMemberExpression$1;
  6215. var isNewExpression_1 = isNewExpression;
  6216. var isProgram_1 = isProgram;
  6217. var isObjectExpression_1 = isObjectExpression;
  6218. var isObjectMethod_1 = isObjectMethod;
  6219. var isObjectProperty_1 = isObjectProperty;
  6220. var isRestElement_1 = isRestElement;
  6221. var isReturnStatement_1 = isReturnStatement;
  6222. var isSequenceExpression_1 = isSequenceExpression;
  6223. var isParenthesizedExpression_1 = isParenthesizedExpression;
  6224. var isSwitchCase_1 = isSwitchCase;
  6225. var isSwitchStatement_1 = isSwitchStatement;
  6226. var isThisExpression_1 = isThisExpression;
  6227. var isThrowStatement_1 = isThrowStatement;
  6228. var isTryStatement_1 = isTryStatement;
  6229. var isUnaryExpression_1 = isUnaryExpression;
  6230. var isUpdateExpression_1 = isUpdateExpression;
  6231. var isVariableDeclaration_1 = isVariableDeclaration;
  6232. var isVariableDeclarator_1 = isVariableDeclarator;
  6233. var isWhileStatement_1 = isWhileStatement;
  6234. var isWithStatement_1 = isWithStatement;
  6235. var isAssignmentPattern_1 = isAssignmentPattern;
  6236. var isArrayPattern_1 = isArrayPattern;
  6237. var isArrowFunctionExpression_1 = isArrowFunctionExpression;
  6238. var isClassBody_1 = isClassBody;
  6239. var isClassExpression_1 = isClassExpression;
  6240. var isClassDeclaration_1 = isClassDeclaration;
  6241. var isExportAllDeclaration_1 = isExportAllDeclaration;
  6242. var isExportDefaultDeclaration_1 = isExportDefaultDeclaration;
  6243. var isExportNamedDeclaration_1 = isExportNamedDeclaration;
  6244. var isExportSpecifier_1 = isExportSpecifier;
  6245. var isForOfStatement_1 = isForOfStatement;
  6246. var isImportDeclaration_1 = isImportDeclaration;
  6247. var isImportDefaultSpecifier_1 = isImportDefaultSpecifier;
  6248. var isImportNamespaceSpecifier_1 = isImportNamespaceSpecifier;
  6249. var isImportSpecifier_1 = isImportSpecifier;
  6250. var isMetaProperty_1 = isMetaProperty;
  6251. var isClassMethod_1 = isClassMethod;
  6252. var isObjectPattern_1 = isObjectPattern;
  6253. var isSpreadElement_1 = isSpreadElement;
  6254. var isSuper_1 = isSuper;
  6255. var isTaggedTemplateExpression_1 = isTaggedTemplateExpression;
  6256. var isTemplateElement_1 = isTemplateElement;
  6257. var isTemplateLiteral_1 = isTemplateLiteral;
  6258. var isYieldExpression_1 = isYieldExpression;
  6259. var isAwaitExpression_1 = isAwaitExpression;
  6260. var isImport_1 = isImport;
  6261. var isBigIntLiteral_1 = isBigIntLiteral;
  6262. var isExportNamespaceSpecifier_1 = isExportNamespaceSpecifier;
  6263. var isOptionalMemberExpression_1 = isOptionalMemberExpression;
  6264. var isOptionalCallExpression_1 = isOptionalCallExpression;
  6265. var isClassProperty_1 = isClassProperty;
  6266. var isClassPrivateProperty_1 = isClassPrivateProperty;
  6267. var isClassPrivateMethod_1 = isClassPrivateMethod;
  6268. var isPrivateName_1 = isPrivateName;
  6269. var isAnyTypeAnnotation_1 = isAnyTypeAnnotation;
  6270. var isArrayTypeAnnotation_1 = isArrayTypeAnnotation;
  6271. var isBooleanTypeAnnotation_1 = isBooleanTypeAnnotation;
  6272. var isBooleanLiteralTypeAnnotation_1 = isBooleanLiteralTypeAnnotation;
  6273. var isNullLiteralTypeAnnotation_1 = isNullLiteralTypeAnnotation;
  6274. var isClassImplements_1 = isClassImplements;
  6275. var isDeclareClass_1 = isDeclareClass;
  6276. var isDeclareFunction_1 = isDeclareFunction;
  6277. var isDeclareInterface_1 = isDeclareInterface;
  6278. var isDeclareModule_1 = isDeclareModule;
  6279. var isDeclareModuleExports_1 = isDeclareModuleExports;
  6280. var isDeclareTypeAlias_1 = isDeclareTypeAlias;
  6281. var isDeclareOpaqueType_1 = isDeclareOpaqueType;
  6282. var isDeclareVariable_1 = isDeclareVariable;
  6283. var isDeclareExportDeclaration_1 = isDeclareExportDeclaration;
  6284. var isDeclareExportAllDeclaration_1 = isDeclareExportAllDeclaration;
  6285. var isDeclaredPredicate_1 = isDeclaredPredicate;
  6286. var isExistsTypeAnnotation_1 = isExistsTypeAnnotation;
  6287. var isFunctionTypeAnnotation_1 = isFunctionTypeAnnotation;
  6288. var isFunctionTypeParam_1 = isFunctionTypeParam;
  6289. var isGenericTypeAnnotation_1 = isGenericTypeAnnotation;
  6290. var isInferredPredicate_1 = isInferredPredicate;
  6291. var isInterfaceExtends_1 = isInterfaceExtends;
  6292. var isInterfaceDeclaration_1 = isInterfaceDeclaration;
  6293. var isInterfaceTypeAnnotation_1 = isInterfaceTypeAnnotation;
  6294. var isIntersectionTypeAnnotation_1 = isIntersectionTypeAnnotation;
  6295. var isMixedTypeAnnotation_1 = isMixedTypeAnnotation;
  6296. var isEmptyTypeAnnotation_1 = isEmptyTypeAnnotation;
  6297. var isNullableTypeAnnotation_1 = isNullableTypeAnnotation;
  6298. var isNumberLiteralTypeAnnotation_1 = isNumberLiteralTypeAnnotation;
  6299. var isNumberTypeAnnotation_1 = isNumberTypeAnnotation;
  6300. var isObjectTypeAnnotation_1 = isObjectTypeAnnotation;
  6301. var isObjectTypeInternalSlot_1 = isObjectTypeInternalSlot;
  6302. var isObjectTypeCallProperty_1 = isObjectTypeCallProperty;
  6303. var isObjectTypeIndexer_1 = isObjectTypeIndexer;
  6304. var isObjectTypeProperty_1 = isObjectTypeProperty;
  6305. var isObjectTypeSpreadProperty_1 = isObjectTypeSpreadProperty;
  6306. var isOpaqueType_1 = isOpaqueType;
  6307. var isQualifiedTypeIdentifier_1 = isQualifiedTypeIdentifier;
  6308. var isStringLiteralTypeAnnotation_1 = isStringLiteralTypeAnnotation;
  6309. var isStringTypeAnnotation_1 = isStringTypeAnnotation;
  6310. var isSymbolTypeAnnotation_1 = isSymbolTypeAnnotation;
  6311. var isThisTypeAnnotation_1 = isThisTypeAnnotation;
  6312. var isTupleTypeAnnotation_1 = isTupleTypeAnnotation;
  6313. var isTypeofTypeAnnotation_1 = isTypeofTypeAnnotation;
  6314. var isTypeAlias_1 = isTypeAlias;
  6315. var isTypeAnnotation_1 = isTypeAnnotation;
  6316. var isTypeCastExpression_1 = isTypeCastExpression;
  6317. var isTypeParameter_1 = isTypeParameter;
  6318. var isTypeParameterDeclaration_1 = isTypeParameterDeclaration;
  6319. var isTypeParameterInstantiation_1 = isTypeParameterInstantiation;
  6320. var isUnionTypeAnnotation_1 = isUnionTypeAnnotation;
  6321. var isVariance_1 = isVariance;
  6322. var isVoidTypeAnnotation_1 = isVoidTypeAnnotation;
  6323. var isEnumDeclaration_1 = isEnumDeclaration;
  6324. var isEnumBooleanBody_1 = isEnumBooleanBody;
  6325. var isEnumNumberBody_1 = isEnumNumberBody;
  6326. var isEnumStringBody_1 = isEnumStringBody;
  6327. var isEnumSymbolBody_1 = isEnumSymbolBody;
  6328. var isEnumBooleanMember_1 = isEnumBooleanMember;
  6329. var isEnumNumberMember_1 = isEnumNumberMember;
  6330. var isEnumStringMember_1 = isEnumStringMember;
  6331. var isEnumDefaultedMember_1 = isEnumDefaultedMember;
  6332. var isIndexedAccessType_1 = isIndexedAccessType;
  6333. var isOptionalIndexedAccessType_1 = isOptionalIndexedAccessType;
  6334. var isJSXAttribute_1 = isJSXAttribute;
  6335. var isJSXClosingElement_1 = isJSXClosingElement;
  6336. var isJSXElement_1 = isJSXElement;
  6337. var isJSXEmptyExpression_1 = isJSXEmptyExpression;
  6338. var isJSXExpressionContainer_1 = isJSXExpressionContainer;
  6339. var isJSXSpreadChild_1 = isJSXSpreadChild;
  6340. var isJSXIdentifier_1 = isJSXIdentifier;
  6341. var isJSXMemberExpression_1 = isJSXMemberExpression;
  6342. var isJSXNamespacedName_1 = isJSXNamespacedName;
  6343. var isJSXOpeningElement_1 = isJSXOpeningElement;
  6344. var isJSXSpreadAttribute_1 = isJSXSpreadAttribute;
  6345. var isJSXText_1 = isJSXText;
  6346. var isJSXFragment_1 = isJSXFragment;
  6347. var isJSXOpeningFragment_1 = isJSXOpeningFragment;
  6348. var isJSXClosingFragment_1 = isJSXClosingFragment;
  6349. var isNoop_1 = isNoop;
  6350. var isPlaceholder_1 = isPlaceholder;
  6351. var isV8IntrinsicIdentifier_1 = isV8IntrinsicIdentifier;
  6352. var isArgumentPlaceholder_1 = isArgumentPlaceholder;
  6353. var isBindExpression_1 = isBindExpression;
  6354. var isImportAttribute_1 = isImportAttribute;
  6355. var isDecorator_1 = isDecorator;
  6356. var isDoExpression_1 = isDoExpression;
  6357. var isExportDefaultSpecifier_1 = isExportDefaultSpecifier;
  6358. var isRecordExpression_1 = isRecordExpression;
  6359. var isTupleExpression_1 = isTupleExpression;
  6360. var isDecimalLiteral_1 = isDecimalLiteral;
  6361. var isStaticBlock_1 = isStaticBlock;
  6362. var isModuleExpression_1 = isModuleExpression;
  6363. var isTopicReference_1 = isTopicReference;
  6364. var isPipelineTopicExpression_1 = isPipelineTopicExpression;
  6365. var isPipelineBareFunction_1 = isPipelineBareFunction;
  6366. var isPipelinePrimaryTopicReference_1 = isPipelinePrimaryTopicReference;
  6367. var isTSParameterProperty_1 = isTSParameterProperty;
  6368. var isTSDeclareFunction_1 = isTSDeclareFunction;
  6369. var isTSDeclareMethod_1 = isTSDeclareMethod;
  6370. var isTSQualifiedName_1 = isTSQualifiedName;
  6371. var isTSCallSignatureDeclaration_1 = isTSCallSignatureDeclaration;
  6372. var isTSConstructSignatureDeclaration_1 = isTSConstructSignatureDeclaration;
  6373. var isTSPropertySignature_1 = isTSPropertySignature;
  6374. var isTSMethodSignature_1 = isTSMethodSignature;
  6375. var isTSIndexSignature_1 = isTSIndexSignature;
  6376. var isTSAnyKeyword_1 = isTSAnyKeyword;
  6377. var isTSBooleanKeyword_1 = isTSBooleanKeyword;
  6378. var isTSBigIntKeyword_1 = isTSBigIntKeyword;
  6379. var isTSIntrinsicKeyword_1 = isTSIntrinsicKeyword;
  6380. var isTSNeverKeyword_1 = isTSNeverKeyword;
  6381. var isTSNullKeyword_1 = isTSNullKeyword;
  6382. var isTSNumberKeyword_1 = isTSNumberKeyword;
  6383. var isTSObjectKeyword_1 = isTSObjectKeyword;
  6384. var isTSStringKeyword_1 = isTSStringKeyword;
  6385. var isTSSymbolKeyword_1 = isTSSymbolKeyword;
  6386. var isTSUndefinedKeyword_1 = isTSUndefinedKeyword;
  6387. var isTSUnknownKeyword_1 = isTSUnknownKeyword;
  6388. var isTSVoidKeyword_1 = isTSVoidKeyword;
  6389. var isTSThisType_1 = isTSThisType;
  6390. var isTSFunctionType_1 = isTSFunctionType;
  6391. var isTSConstructorType_1 = isTSConstructorType;
  6392. var isTSTypeReference_1 = isTSTypeReference;
  6393. var isTSTypePredicate_1 = isTSTypePredicate;
  6394. var isTSTypeQuery_1 = isTSTypeQuery;
  6395. var isTSTypeLiteral_1 = isTSTypeLiteral;
  6396. var isTSArrayType_1 = isTSArrayType;
  6397. var isTSTupleType_1 = isTSTupleType;
  6398. var isTSOptionalType_1 = isTSOptionalType;
  6399. var isTSRestType_1 = isTSRestType;
  6400. var isTSNamedTupleMember_1 = isTSNamedTupleMember;
  6401. var isTSUnionType_1 = isTSUnionType;
  6402. var isTSIntersectionType_1 = isTSIntersectionType;
  6403. var isTSConditionalType_1 = isTSConditionalType;
  6404. var isTSInferType_1 = isTSInferType;
  6405. var isTSParenthesizedType_1 = isTSParenthesizedType;
  6406. var isTSTypeOperator_1 = isTSTypeOperator;
  6407. var isTSIndexedAccessType_1 = isTSIndexedAccessType;
  6408. var isTSMappedType_1 = isTSMappedType;
  6409. var isTSLiteralType_1 = isTSLiteralType;
  6410. var isTSExpressionWithTypeArguments_1 = isTSExpressionWithTypeArguments;
  6411. var isTSInterfaceDeclaration_1 = isTSInterfaceDeclaration;
  6412. var isTSInterfaceBody_1 = isTSInterfaceBody;
  6413. var isTSTypeAliasDeclaration_1 = isTSTypeAliasDeclaration;
  6414. var isTSAsExpression_1 = isTSAsExpression;
  6415. var isTSTypeAssertion_1 = isTSTypeAssertion;
  6416. var isTSEnumDeclaration_1 = isTSEnumDeclaration;
  6417. var isTSEnumMember_1 = isTSEnumMember;
  6418. var isTSModuleDeclaration_1 = isTSModuleDeclaration;
  6419. var isTSModuleBlock_1 = isTSModuleBlock;
  6420. var isTSImportType_1 = isTSImportType;
  6421. var isTSImportEqualsDeclaration_1 = isTSImportEqualsDeclaration;
  6422. var isTSExternalModuleReference_1 = isTSExternalModuleReference;
  6423. var isTSNonNullExpression_1 = isTSNonNullExpression;
  6424. var isTSExportAssignment_1 = isTSExportAssignment;
  6425. var isTSNamespaceExportDeclaration_1 = isTSNamespaceExportDeclaration;
  6426. var isTSTypeAnnotation_1 = isTSTypeAnnotation;
  6427. var isTSTypeParameterInstantiation_1 = isTSTypeParameterInstantiation;
  6428. var isTSTypeParameterDeclaration_1 = isTSTypeParameterDeclaration;
  6429. var isTSTypeParameter_1 = isTSTypeParameter;
  6430. var isExpression_1 = isExpression;
  6431. var isBinary_1 = isBinary;
  6432. var isScopable_1 = isScopable;
  6433. var isBlockParent_1 = isBlockParent;
  6434. var isBlock_1 = isBlock;
  6435. var isStatement_1 = isStatement;
  6436. var isTerminatorless_1 = isTerminatorless;
  6437. var isCompletionStatement_1 = isCompletionStatement;
  6438. var isConditional_1 = isConditional;
  6439. var isLoop_1 = isLoop;
  6440. var isWhile_1 = isWhile;
  6441. var isExpressionWrapper_1 = isExpressionWrapper;
  6442. var isFor_1 = isFor;
  6443. var isForXStatement_1 = isForXStatement;
  6444. var isFunction_1 = isFunction$1;
  6445. var isFunctionParent_1 = isFunctionParent;
  6446. var isPureish_1 = isPureish;
  6447. var isDeclaration_1 = isDeclaration;
  6448. var isPatternLike_1 = isPatternLike;
  6449. var isLVal_1 = isLVal;
  6450. var isTSEntityName_1 = isTSEntityName;
  6451. var isLiteral_1 = isLiteral;
  6452. var isImmutable_1 = isImmutable;
  6453. var isUserWhitespacable_1 = isUserWhitespacable;
  6454. var isMethod_1 = isMethod;
  6455. var isObjectMember_1 = isObjectMember;
  6456. var isProperty_1 = isProperty;
  6457. var isUnaryLike_1 = isUnaryLike;
  6458. var isPattern_1 = isPattern;
  6459. var isClass_1 = isClass;
  6460. var isModuleDeclaration_1 = isModuleDeclaration;
  6461. var isExportDeclaration_1 = isExportDeclaration;
  6462. var isModuleSpecifier_1 = isModuleSpecifier;
  6463. var isPrivate_1 = isPrivate;
  6464. var isFlow_1 = isFlow;
  6465. var isFlowType_1 = isFlowType;
  6466. var isFlowBaseAnnotation_1 = isFlowBaseAnnotation;
  6467. var isFlowDeclaration_1 = isFlowDeclaration;
  6468. var isFlowPredicate_1 = isFlowPredicate;
  6469. var isEnumBody_1 = isEnumBody;
  6470. var isEnumMember_1 = isEnumMember;
  6471. var isJSX_1 = isJSX;
  6472. var isTSTypeElement_1 = isTSTypeElement;
  6473. var isTSType_1 = isTSType;
  6474. var isTSBaseType_1 = isTSBaseType;
  6475. var isNumberLiteral_1 = isNumberLiteral;
  6476. var isRegexLiteral_1 = isRegexLiteral;
  6477. var isRestProperty_1 = isRestProperty;
  6478. var isSpreadProperty_1 = isSpreadProperty;
  6479. function isArrayExpression(node, opts) {
  6480. if (!node) return false;
  6481. const nodeType = node.type;
  6482. if (nodeType === "ArrayExpression") {
  6483. if (typeof opts === "undefined") {
  6484. return true;
  6485. } else {
  6486. return (0, shallowEqual_1.default)(node, opts);
  6487. }
  6488. }
  6489. return false;
  6490. }
  6491. function isAssignmentExpression(node, opts) {
  6492. if (!node) return false;
  6493. const nodeType = node.type;
  6494. if (nodeType === "AssignmentExpression") {
  6495. if (typeof opts === "undefined") {
  6496. return true;
  6497. } else {
  6498. return (0, shallowEqual_1.default)(node, opts);
  6499. }
  6500. }
  6501. return false;
  6502. }
  6503. function isBinaryExpression(node, opts) {
  6504. if (!node) return false;
  6505. const nodeType = node.type;
  6506. if (nodeType === "BinaryExpression") {
  6507. if (typeof opts === "undefined") {
  6508. return true;
  6509. } else {
  6510. return (0, shallowEqual_1.default)(node, opts);
  6511. }
  6512. }
  6513. return false;
  6514. }
  6515. function isInterpreterDirective(node, opts) {
  6516. if (!node) return false;
  6517. const nodeType = node.type;
  6518. if (nodeType === "InterpreterDirective") {
  6519. if (typeof opts === "undefined") {
  6520. return true;
  6521. } else {
  6522. return (0, shallowEqual_1.default)(node, opts);
  6523. }
  6524. }
  6525. return false;
  6526. }
  6527. function isDirective(node, opts) {
  6528. if (!node) return false;
  6529. const nodeType = node.type;
  6530. if (nodeType === "Directive") {
  6531. if (typeof opts === "undefined") {
  6532. return true;
  6533. } else {
  6534. return (0, shallowEqual_1.default)(node, opts);
  6535. }
  6536. }
  6537. return false;
  6538. }
  6539. function isDirectiveLiteral(node, opts) {
  6540. if (!node) return false;
  6541. const nodeType = node.type;
  6542. if (nodeType === "DirectiveLiteral") {
  6543. if (typeof opts === "undefined") {
  6544. return true;
  6545. } else {
  6546. return (0, shallowEqual_1.default)(node, opts);
  6547. }
  6548. }
  6549. return false;
  6550. }
  6551. function isBlockStatement(node, opts) {
  6552. if (!node) return false;
  6553. const nodeType = node.type;
  6554. if (nodeType === "BlockStatement") {
  6555. if (typeof opts === "undefined") {
  6556. return true;
  6557. } else {
  6558. return (0, shallowEqual_1.default)(node, opts);
  6559. }
  6560. }
  6561. return false;
  6562. }
  6563. function isBreakStatement(node, opts) {
  6564. if (!node) return false;
  6565. const nodeType = node.type;
  6566. if (nodeType === "BreakStatement") {
  6567. if (typeof opts === "undefined") {
  6568. return true;
  6569. } else {
  6570. return (0, shallowEqual_1.default)(node, opts);
  6571. }
  6572. }
  6573. return false;
  6574. }
  6575. function isCallExpression(node, opts) {
  6576. if (!node) return false;
  6577. const nodeType = node.type;
  6578. if (nodeType === "CallExpression") {
  6579. if (typeof opts === "undefined") {
  6580. return true;
  6581. } else {
  6582. return (0, shallowEqual_1.default)(node, opts);
  6583. }
  6584. }
  6585. return false;
  6586. }
  6587. function isCatchClause(node, opts) {
  6588. if (!node) return false;
  6589. const nodeType = node.type;
  6590. if (nodeType === "CatchClause") {
  6591. if (typeof opts === "undefined") {
  6592. return true;
  6593. } else {
  6594. return (0, shallowEqual_1.default)(node, opts);
  6595. }
  6596. }
  6597. return false;
  6598. }
  6599. function isConditionalExpression(node, opts) {
  6600. if (!node) return false;
  6601. const nodeType = node.type;
  6602. if (nodeType === "ConditionalExpression") {
  6603. if (typeof opts === "undefined") {
  6604. return true;
  6605. } else {
  6606. return (0, shallowEqual_1.default)(node, opts);
  6607. }
  6608. }
  6609. return false;
  6610. }
  6611. function isContinueStatement(node, opts) {
  6612. if (!node) return false;
  6613. const nodeType = node.type;
  6614. if (nodeType === "ContinueStatement") {
  6615. if (typeof opts === "undefined") {
  6616. return true;
  6617. } else {
  6618. return (0, shallowEqual_1.default)(node, opts);
  6619. }
  6620. }
  6621. return false;
  6622. }
  6623. function isDebuggerStatement(node, opts) {
  6624. if (!node) return false;
  6625. const nodeType = node.type;
  6626. if (nodeType === "DebuggerStatement") {
  6627. if (typeof opts === "undefined") {
  6628. return true;
  6629. } else {
  6630. return (0, shallowEqual_1.default)(node, opts);
  6631. }
  6632. }
  6633. return false;
  6634. }
  6635. function isDoWhileStatement(node, opts) {
  6636. if (!node) return false;
  6637. const nodeType = node.type;
  6638. if (nodeType === "DoWhileStatement") {
  6639. if (typeof opts === "undefined") {
  6640. return true;
  6641. } else {
  6642. return (0, shallowEqual_1.default)(node, opts);
  6643. }
  6644. }
  6645. return false;
  6646. }
  6647. function isEmptyStatement(node, opts) {
  6648. if (!node) return false;
  6649. const nodeType = node.type;
  6650. if (nodeType === "EmptyStatement") {
  6651. if (typeof opts === "undefined") {
  6652. return true;
  6653. } else {
  6654. return (0, shallowEqual_1.default)(node, opts);
  6655. }
  6656. }
  6657. return false;
  6658. }
  6659. function isExpressionStatement(node, opts) {
  6660. if (!node) return false;
  6661. const nodeType = node.type;
  6662. if (nodeType === "ExpressionStatement") {
  6663. if (typeof opts === "undefined") {
  6664. return true;
  6665. } else {
  6666. return (0, shallowEqual_1.default)(node, opts);
  6667. }
  6668. }
  6669. return false;
  6670. }
  6671. function isFile(node, opts) {
  6672. if (!node) return false;
  6673. const nodeType = node.type;
  6674. if (nodeType === "File") {
  6675. if (typeof opts === "undefined") {
  6676. return true;
  6677. } else {
  6678. return (0, shallowEqual_1.default)(node, opts);
  6679. }
  6680. }
  6681. return false;
  6682. }
  6683. function isForInStatement(node, opts) {
  6684. if (!node) return false;
  6685. const nodeType = node.type;
  6686. if (nodeType === "ForInStatement") {
  6687. if (typeof opts === "undefined") {
  6688. return true;
  6689. } else {
  6690. return (0, shallowEqual_1.default)(node, opts);
  6691. }
  6692. }
  6693. return false;
  6694. }
  6695. function isForStatement(node, opts) {
  6696. if (!node) return false;
  6697. const nodeType = node.type;
  6698. if (nodeType === "ForStatement") {
  6699. if (typeof opts === "undefined") {
  6700. return true;
  6701. } else {
  6702. return (0, shallowEqual_1.default)(node, opts);
  6703. }
  6704. }
  6705. return false;
  6706. }
  6707. function isFunctionDeclaration(node, opts) {
  6708. if (!node) return false;
  6709. const nodeType = node.type;
  6710. if (nodeType === "FunctionDeclaration") {
  6711. if (typeof opts === "undefined") {
  6712. return true;
  6713. } else {
  6714. return (0, shallowEqual_1.default)(node, opts);
  6715. }
  6716. }
  6717. return false;
  6718. }
  6719. function isFunctionExpression(node, opts) {
  6720. if (!node) return false;
  6721. const nodeType = node.type;
  6722. if (nodeType === "FunctionExpression") {
  6723. if (typeof opts === "undefined") {
  6724. return true;
  6725. } else {
  6726. return (0, shallowEqual_1.default)(node, opts);
  6727. }
  6728. }
  6729. return false;
  6730. }
  6731. function isIdentifier(node, opts) {
  6732. if (!node) return false;
  6733. const nodeType = node.type;
  6734. if (nodeType === "Identifier") {
  6735. if (typeof opts === "undefined") {
  6736. return true;
  6737. } else {
  6738. return (0, shallowEqual_1.default)(node, opts);
  6739. }
  6740. }
  6741. return false;
  6742. }
  6743. function isIfStatement(node, opts) {
  6744. if (!node) return false;
  6745. const nodeType = node.type;
  6746. if (nodeType === "IfStatement") {
  6747. if (typeof opts === "undefined") {
  6748. return true;
  6749. } else {
  6750. return (0, shallowEqual_1.default)(node, opts);
  6751. }
  6752. }
  6753. return false;
  6754. }
  6755. function isLabeledStatement(node, opts) {
  6756. if (!node) return false;
  6757. const nodeType = node.type;
  6758. if (nodeType === "LabeledStatement") {
  6759. if (typeof opts === "undefined") {
  6760. return true;
  6761. } else {
  6762. return (0, shallowEqual_1.default)(node, opts);
  6763. }
  6764. }
  6765. return false;
  6766. }
  6767. function isStringLiteral(node, opts) {
  6768. if (!node) return false;
  6769. const nodeType = node.type;
  6770. if (nodeType === "StringLiteral") {
  6771. if (typeof opts === "undefined") {
  6772. return true;
  6773. } else {
  6774. return (0, shallowEqual_1.default)(node, opts);
  6775. }
  6776. }
  6777. return false;
  6778. }
  6779. function isNumericLiteral(node, opts) {
  6780. if (!node) return false;
  6781. const nodeType = node.type;
  6782. if (nodeType === "NumericLiteral") {
  6783. if (typeof opts === "undefined") {
  6784. return true;
  6785. } else {
  6786. return (0, shallowEqual_1.default)(node, opts);
  6787. }
  6788. }
  6789. return false;
  6790. }
  6791. function isNullLiteral(node, opts) {
  6792. if (!node) return false;
  6793. const nodeType = node.type;
  6794. if (nodeType === "NullLiteral") {
  6795. if (typeof opts === "undefined") {
  6796. return true;
  6797. } else {
  6798. return (0, shallowEqual_1.default)(node, opts);
  6799. }
  6800. }
  6801. return false;
  6802. }
  6803. function isBooleanLiteral(node, opts) {
  6804. if (!node) return false;
  6805. const nodeType = node.type;
  6806. if (nodeType === "BooleanLiteral") {
  6807. if (typeof opts === "undefined") {
  6808. return true;
  6809. } else {
  6810. return (0, shallowEqual_1.default)(node, opts);
  6811. }
  6812. }
  6813. return false;
  6814. }
  6815. function isRegExpLiteral(node, opts) {
  6816. if (!node) return false;
  6817. const nodeType = node.type;
  6818. if (nodeType === "RegExpLiteral") {
  6819. if (typeof opts === "undefined") {
  6820. return true;
  6821. } else {
  6822. return (0, shallowEqual_1.default)(node, opts);
  6823. }
  6824. }
  6825. return false;
  6826. }
  6827. function isLogicalExpression(node, opts) {
  6828. if (!node) return false;
  6829. const nodeType = node.type;
  6830. if (nodeType === "LogicalExpression") {
  6831. if (typeof opts === "undefined") {
  6832. return true;
  6833. } else {
  6834. return (0, shallowEqual_1.default)(node, opts);
  6835. }
  6836. }
  6837. return false;
  6838. }
  6839. function isMemberExpression$1(node, opts) {
  6840. if (!node) return false;
  6841. const nodeType = node.type;
  6842. if (nodeType === "MemberExpression") {
  6843. if (typeof opts === "undefined") {
  6844. return true;
  6845. } else {
  6846. return (0, shallowEqual_1.default)(node, opts);
  6847. }
  6848. }
  6849. return false;
  6850. }
  6851. function isNewExpression(node, opts) {
  6852. if (!node) return false;
  6853. const nodeType = node.type;
  6854. if (nodeType === "NewExpression") {
  6855. if (typeof opts === "undefined") {
  6856. return true;
  6857. } else {
  6858. return (0, shallowEqual_1.default)(node, opts);
  6859. }
  6860. }
  6861. return false;
  6862. }
  6863. function isProgram(node, opts) {
  6864. if (!node) return false;
  6865. const nodeType = node.type;
  6866. if (nodeType === "Program") {
  6867. if (typeof opts === "undefined") {
  6868. return true;
  6869. } else {
  6870. return (0, shallowEqual_1.default)(node, opts);
  6871. }
  6872. }
  6873. return false;
  6874. }
  6875. function isObjectExpression(node, opts) {
  6876. if (!node) return false;
  6877. const nodeType = node.type;
  6878. if (nodeType === "ObjectExpression") {
  6879. if (typeof opts === "undefined") {
  6880. return true;
  6881. } else {
  6882. return (0, shallowEqual_1.default)(node, opts);
  6883. }
  6884. }
  6885. return false;
  6886. }
  6887. function isObjectMethod(node, opts) {
  6888. if (!node) return false;
  6889. const nodeType = node.type;
  6890. if (nodeType === "ObjectMethod") {
  6891. if (typeof opts === "undefined") {
  6892. return true;
  6893. } else {
  6894. return (0, shallowEqual_1.default)(node, opts);
  6895. }
  6896. }
  6897. return false;
  6898. }
  6899. function isObjectProperty(node, opts) {
  6900. if (!node) return false;
  6901. const nodeType = node.type;
  6902. if (nodeType === "ObjectProperty") {
  6903. if (typeof opts === "undefined") {
  6904. return true;
  6905. } else {
  6906. return (0, shallowEqual_1.default)(node, opts);
  6907. }
  6908. }
  6909. return false;
  6910. }
  6911. function isRestElement(node, opts) {
  6912. if (!node) return false;
  6913. const nodeType = node.type;
  6914. if (nodeType === "RestElement") {
  6915. if (typeof opts === "undefined") {
  6916. return true;
  6917. } else {
  6918. return (0, shallowEqual_1.default)(node, opts);
  6919. }
  6920. }
  6921. return false;
  6922. }
  6923. function isReturnStatement(node, opts) {
  6924. if (!node) return false;
  6925. const nodeType = node.type;
  6926. if (nodeType === "ReturnStatement") {
  6927. if (typeof opts === "undefined") {
  6928. return true;
  6929. } else {
  6930. return (0, shallowEqual_1.default)(node, opts);
  6931. }
  6932. }
  6933. return false;
  6934. }
  6935. function isSequenceExpression(node, opts) {
  6936. if (!node) return false;
  6937. const nodeType = node.type;
  6938. if (nodeType === "SequenceExpression") {
  6939. if (typeof opts === "undefined") {
  6940. return true;
  6941. } else {
  6942. return (0, shallowEqual_1.default)(node, opts);
  6943. }
  6944. }
  6945. return false;
  6946. }
  6947. function isParenthesizedExpression(node, opts) {
  6948. if (!node) return false;
  6949. const nodeType = node.type;
  6950. if (nodeType === "ParenthesizedExpression") {
  6951. if (typeof opts === "undefined") {
  6952. return true;
  6953. } else {
  6954. return (0, shallowEqual_1.default)(node, opts);
  6955. }
  6956. }
  6957. return false;
  6958. }
  6959. function isSwitchCase(node, opts) {
  6960. if (!node) return false;
  6961. const nodeType = node.type;
  6962. if (nodeType === "SwitchCase") {
  6963. if (typeof opts === "undefined") {
  6964. return true;
  6965. } else {
  6966. return (0, shallowEqual_1.default)(node, opts);
  6967. }
  6968. }
  6969. return false;
  6970. }
  6971. function isSwitchStatement(node, opts) {
  6972. if (!node) return false;
  6973. const nodeType = node.type;
  6974. if (nodeType === "SwitchStatement") {
  6975. if (typeof opts === "undefined") {
  6976. return true;
  6977. } else {
  6978. return (0, shallowEqual_1.default)(node, opts);
  6979. }
  6980. }
  6981. return false;
  6982. }
  6983. function isThisExpression(node, opts) {
  6984. if (!node) return false;
  6985. const nodeType = node.type;
  6986. if (nodeType === "ThisExpression") {
  6987. if (typeof opts === "undefined") {
  6988. return true;
  6989. } else {
  6990. return (0, shallowEqual_1.default)(node, opts);
  6991. }
  6992. }
  6993. return false;
  6994. }
  6995. function isThrowStatement(node, opts) {
  6996. if (!node) return false;
  6997. const nodeType = node.type;
  6998. if (nodeType === "ThrowStatement") {
  6999. if (typeof opts === "undefined") {
  7000. return true;
  7001. } else {
  7002. return (0, shallowEqual_1.default)(node, opts);
  7003. }
  7004. }
  7005. return false;
  7006. }
  7007. function isTryStatement(node, opts) {
  7008. if (!node) return false;
  7009. const nodeType = node.type;
  7010. if (nodeType === "TryStatement") {
  7011. if (typeof opts === "undefined") {
  7012. return true;
  7013. } else {
  7014. return (0, shallowEqual_1.default)(node, opts);
  7015. }
  7016. }
  7017. return false;
  7018. }
  7019. function isUnaryExpression(node, opts) {
  7020. if (!node) return false;
  7021. const nodeType = node.type;
  7022. if (nodeType === "UnaryExpression") {
  7023. if (typeof opts === "undefined") {
  7024. return true;
  7025. } else {
  7026. return (0, shallowEqual_1.default)(node, opts);
  7027. }
  7028. }
  7029. return false;
  7030. }
  7031. function isUpdateExpression(node, opts) {
  7032. if (!node) return false;
  7033. const nodeType = node.type;
  7034. if (nodeType === "UpdateExpression") {
  7035. if (typeof opts === "undefined") {
  7036. return true;
  7037. } else {
  7038. return (0, shallowEqual_1.default)(node, opts);
  7039. }
  7040. }
  7041. return false;
  7042. }
  7043. function isVariableDeclaration(node, opts) {
  7044. if (!node) return false;
  7045. const nodeType = node.type;
  7046. if (nodeType === "VariableDeclaration") {
  7047. if (typeof opts === "undefined") {
  7048. return true;
  7049. } else {
  7050. return (0, shallowEqual_1.default)(node, opts);
  7051. }
  7052. }
  7053. return false;
  7054. }
  7055. function isVariableDeclarator(node, opts) {
  7056. if (!node) return false;
  7057. const nodeType = node.type;
  7058. if (nodeType === "VariableDeclarator") {
  7059. if (typeof opts === "undefined") {
  7060. return true;
  7061. } else {
  7062. return (0, shallowEqual_1.default)(node, opts);
  7063. }
  7064. }
  7065. return false;
  7066. }
  7067. function isWhileStatement(node, opts) {
  7068. if (!node) return false;
  7069. const nodeType = node.type;
  7070. if (nodeType === "WhileStatement") {
  7071. if (typeof opts === "undefined") {
  7072. return true;
  7073. } else {
  7074. return (0, shallowEqual_1.default)(node, opts);
  7075. }
  7076. }
  7077. return false;
  7078. }
  7079. function isWithStatement(node, opts) {
  7080. if (!node) return false;
  7081. const nodeType = node.type;
  7082. if (nodeType === "WithStatement") {
  7083. if (typeof opts === "undefined") {
  7084. return true;
  7085. } else {
  7086. return (0, shallowEqual_1.default)(node, opts);
  7087. }
  7088. }
  7089. return false;
  7090. }
  7091. function isAssignmentPattern(node, opts) {
  7092. if (!node) return false;
  7093. const nodeType = node.type;
  7094. if (nodeType === "AssignmentPattern") {
  7095. if (typeof opts === "undefined") {
  7096. return true;
  7097. } else {
  7098. return (0, shallowEqual_1.default)(node, opts);
  7099. }
  7100. }
  7101. return false;
  7102. }
  7103. function isArrayPattern(node, opts) {
  7104. if (!node) return false;
  7105. const nodeType = node.type;
  7106. if (nodeType === "ArrayPattern") {
  7107. if (typeof opts === "undefined") {
  7108. return true;
  7109. } else {
  7110. return (0, shallowEqual_1.default)(node, opts);
  7111. }
  7112. }
  7113. return false;
  7114. }
  7115. function isArrowFunctionExpression(node, opts) {
  7116. if (!node) return false;
  7117. const nodeType = node.type;
  7118. if (nodeType === "ArrowFunctionExpression") {
  7119. if (typeof opts === "undefined") {
  7120. return true;
  7121. } else {
  7122. return (0, shallowEqual_1.default)(node, opts);
  7123. }
  7124. }
  7125. return false;
  7126. }
  7127. function isClassBody(node, opts) {
  7128. if (!node) return false;
  7129. const nodeType = node.type;
  7130. if (nodeType === "ClassBody") {
  7131. if (typeof opts === "undefined") {
  7132. return true;
  7133. } else {
  7134. return (0, shallowEqual_1.default)(node, opts);
  7135. }
  7136. }
  7137. return false;
  7138. }
  7139. function isClassExpression(node, opts) {
  7140. if (!node) return false;
  7141. const nodeType = node.type;
  7142. if (nodeType === "ClassExpression") {
  7143. if (typeof opts === "undefined") {
  7144. return true;
  7145. } else {
  7146. return (0, shallowEqual_1.default)(node, opts);
  7147. }
  7148. }
  7149. return false;
  7150. }
  7151. function isClassDeclaration(node, opts) {
  7152. if (!node) return false;
  7153. const nodeType = node.type;
  7154. if (nodeType === "ClassDeclaration") {
  7155. if (typeof opts === "undefined") {
  7156. return true;
  7157. } else {
  7158. return (0, shallowEqual_1.default)(node, opts);
  7159. }
  7160. }
  7161. return false;
  7162. }
  7163. function isExportAllDeclaration(node, opts) {
  7164. if (!node) return false;
  7165. const nodeType = node.type;
  7166. if (nodeType === "ExportAllDeclaration") {
  7167. if (typeof opts === "undefined") {
  7168. return true;
  7169. } else {
  7170. return (0, shallowEqual_1.default)(node, opts);
  7171. }
  7172. }
  7173. return false;
  7174. }
  7175. function isExportDefaultDeclaration(node, opts) {
  7176. if (!node) return false;
  7177. const nodeType = node.type;
  7178. if (nodeType === "ExportDefaultDeclaration") {
  7179. if (typeof opts === "undefined") {
  7180. return true;
  7181. } else {
  7182. return (0, shallowEqual_1.default)(node, opts);
  7183. }
  7184. }
  7185. return false;
  7186. }
  7187. function isExportNamedDeclaration(node, opts) {
  7188. if (!node) return false;
  7189. const nodeType = node.type;
  7190. if (nodeType === "ExportNamedDeclaration") {
  7191. if (typeof opts === "undefined") {
  7192. return true;
  7193. } else {
  7194. return (0, shallowEqual_1.default)(node, opts);
  7195. }
  7196. }
  7197. return false;
  7198. }
  7199. function isExportSpecifier(node, opts) {
  7200. if (!node) return false;
  7201. const nodeType = node.type;
  7202. if (nodeType === "ExportSpecifier") {
  7203. if (typeof opts === "undefined") {
  7204. return true;
  7205. } else {
  7206. return (0, shallowEqual_1.default)(node, opts);
  7207. }
  7208. }
  7209. return false;
  7210. }
  7211. function isForOfStatement(node, opts) {
  7212. if (!node) return false;
  7213. const nodeType = node.type;
  7214. if (nodeType === "ForOfStatement") {
  7215. if (typeof opts === "undefined") {
  7216. return true;
  7217. } else {
  7218. return (0, shallowEqual_1.default)(node, opts);
  7219. }
  7220. }
  7221. return false;
  7222. }
  7223. function isImportDeclaration(node, opts) {
  7224. if (!node) return false;
  7225. const nodeType = node.type;
  7226. if (nodeType === "ImportDeclaration") {
  7227. if (typeof opts === "undefined") {
  7228. return true;
  7229. } else {
  7230. return (0, shallowEqual_1.default)(node, opts);
  7231. }
  7232. }
  7233. return false;
  7234. }
  7235. function isImportDefaultSpecifier(node, opts) {
  7236. if (!node) return false;
  7237. const nodeType = node.type;
  7238. if (nodeType === "ImportDefaultSpecifier") {
  7239. if (typeof opts === "undefined") {
  7240. return true;
  7241. } else {
  7242. return (0, shallowEqual_1.default)(node, opts);
  7243. }
  7244. }
  7245. return false;
  7246. }
  7247. function isImportNamespaceSpecifier(node, opts) {
  7248. if (!node) return false;
  7249. const nodeType = node.type;
  7250. if (nodeType === "ImportNamespaceSpecifier") {
  7251. if (typeof opts === "undefined") {
  7252. return true;
  7253. } else {
  7254. return (0, shallowEqual_1.default)(node, opts);
  7255. }
  7256. }
  7257. return false;
  7258. }
  7259. function isImportSpecifier(node, opts) {
  7260. if (!node) return false;
  7261. const nodeType = node.type;
  7262. if (nodeType === "ImportSpecifier") {
  7263. if (typeof opts === "undefined") {
  7264. return true;
  7265. } else {
  7266. return (0, shallowEqual_1.default)(node, opts);
  7267. }
  7268. }
  7269. return false;
  7270. }
  7271. function isMetaProperty(node, opts) {
  7272. if (!node) return false;
  7273. const nodeType = node.type;
  7274. if (nodeType === "MetaProperty") {
  7275. if (typeof opts === "undefined") {
  7276. return true;
  7277. } else {
  7278. return (0, shallowEqual_1.default)(node, opts);
  7279. }
  7280. }
  7281. return false;
  7282. }
  7283. function isClassMethod(node, opts) {
  7284. if (!node) return false;
  7285. const nodeType = node.type;
  7286. if (nodeType === "ClassMethod") {
  7287. if (typeof opts === "undefined") {
  7288. return true;
  7289. } else {
  7290. return (0, shallowEqual_1.default)(node, opts);
  7291. }
  7292. }
  7293. return false;
  7294. }
  7295. function isObjectPattern(node, opts) {
  7296. if (!node) return false;
  7297. const nodeType = node.type;
  7298. if (nodeType === "ObjectPattern") {
  7299. if (typeof opts === "undefined") {
  7300. return true;
  7301. } else {
  7302. return (0, shallowEqual_1.default)(node, opts);
  7303. }
  7304. }
  7305. return false;
  7306. }
  7307. function isSpreadElement(node, opts) {
  7308. if (!node) return false;
  7309. const nodeType = node.type;
  7310. if (nodeType === "SpreadElement") {
  7311. if (typeof opts === "undefined") {
  7312. return true;
  7313. } else {
  7314. return (0, shallowEqual_1.default)(node, opts);
  7315. }
  7316. }
  7317. return false;
  7318. }
  7319. function isSuper(node, opts) {
  7320. if (!node) return false;
  7321. const nodeType = node.type;
  7322. if (nodeType === "Super") {
  7323. if (typeof opts === "undefined") {
  7324. return true;
  7325. } else {
  7326. return (0, shallowEqual_1.default)(node, opts);
  7327. }
  7328. }
  7329. return false;
  7330. }
  7331. function isTaggedTemplateExpression(node, opts) {
  7332. if (!node) return false;
  7333. const nodeType = node.type;
  7334. if (nodeType === "TaggedTemplateExpression") {
  7335. if (typeof opts === "undefined") {
  7336. return true;
  7337. } else {
  7338. return (0, shallowEqual_1.default)(node, opts);
  7339. }
  7340. }
  7341. return false;
  7342. }
  7343. function isTemplateElement(node, opts) {
  7344. if (!node) return false;
  7345. const nodeType = node.type;
  7346. if (nodeType === "TemplateElement") {
  7347. if (typeof opts === "undefined") {
  7348. return true;
  7349. } else {
  7350. return (0, shallowEqual_1.default)(node, opts);
  7351. }
  7352. }
  7353. return false;
  7354. }
  7355. function isTemplateLiteral(node, opts) {
  7356. if (!node) return false;
  7357. const nodeType = node.type;
  7358. if (nodeType === "TemplateLiteral") {
  7359. if (typeof opts === "undefined") {
  7360. return true;
  7361. } else {
  7362. return (0, shallowEqual_1.default)(node, opts);
  7363. }
  7364. }
  7365. return false;
  7366. }
  7367. function isYieldExpression(node, opts) {
  7368. if (!node) return false;
  7369. const nodeType = node.type;
  7370. if (nodeType === "YieldExpression") {
  7371. if (typeof opts === "undefined") {
  7372. return true;
  7373. } else {
  7374. return (0, shallowEqual_1.default)(node, opts);
  7375. }
  7376. }
  7377. return false;
  7378. }
  7379. function isAwaitExpression(node, opts) {
  7380. if (!node) return false;
  7381. const nodeType = node.type;
  7382. if (nodeType === "AwaitExpression") {
  7383. if (typeof opts === "undefined") {
  7384. return true;
  7385. } else {
  7386. return (0, shallowEqual_1.default)(node, opts);
  7387. }
  7388. }
  7389. return false;
  7390. }
  7391. function isImport(node, opts) {
  7392. if (!node) return false;
  7393. const nodeType = node.type;
  7394. if (nodeType === "Import") {
  7395. if (typeof opts === "undefined") {
  7396. return true;
  7397. } else {
  7398. return (0, shallowEqual_1.default)(node, opts);
  7399. }
  7400. }
  7401. return false;
  7402. }
  7403. function isBigIntLiteral(node, opts) {
  7404. if (!node) return false;
  7405. const nodeType = node.type;
  7406. if (nodeType === "BigIntLiteral") {
  7407. if (typeof opts === "undefined") {
  7408. return true;
  7409. } else {
  7410. return (0, shallowEqual_1.default)(node, opts);
  7411. }
  7412. }
  7413. return false;
  7414. }
  7415. function isExportNamespaceSpecifier(node, opts) {
  7416. if (!node) return false;
  7417. const nodeType = node.type;
  7418. if (nodeType === "ExportNamespaceSpecifier") {
  7419. if (typeof opts === "undefined") {
  7420. return true;
  7421. } else {
  7422. return (0, shallowEqual_1.default)(node, opts);
  7423. }
  7424. }
  7425. return false;
  7426. }
  7427. function isOptionalMemberExpression(node, opts) {
  7428. if (!node) return false;
  7429. const nodeType = node.type;
  7430. if (nodeType === "OptionalMemberExpression") {
  7431. if (typeof opts === "undefined") {
  7432. return true;
  7433. } else {
  7434. return (0, shallowEqual_1.default)(node, opts);
  7435. }
  7436. }
  7437. return false;
  7438. }
  7439. function isOptionalCallExpression(node, opts) {
  7440. if (!node) return false;
  7441. const nodeType = node.type;
  7442. if (nodeType === "OptionalCallExpression") {
  7443. if (typeof opts === "undefined") {
  7444. return true;
  7445. } else {
  7446. return (0, shallowEqual_1.default)(node, opts);
  7447. }
  7448. }
  7449. return false;
  7450. }
  7451. function isClassProperty(node, opts) {
  7452. if (!node) return false;
  7453. const nodeType = node.type;
  7454. if (nodeType === "ClassProperty") {
  7455. if (typeof opts === "undefined") {
  7456. return true;
  7457. } else {
  7458. return (0, shallowEqual_1.default)(node, opts);
  7459. }
  7460. }
  7461. return false;
  7462. }
  7463. function isClassPrivateProperty(node, opts) {
  7464. if (!node) return false;
  7465. const nodeType = node.type;
  7466. if (nodeType === "ClassPrivateProperty") {
  7467. if (typeof opts === "undefined") {
  7468. return true;
  7469. } else {
  7470. return (0, shallowEqual_1.default)(node, opts);
  7471. }
  7472. }
  7473. return false;
  7474. }
  7475. function isClassPrivateMethod(node, opts) {
  7476. if (!node) return false;
  7477. const nodeType = node.type;
  7478. if (nodeType === "ClassPrivateMethod") {
  7479. if (typeof opts === "undefined") {
  7480. return true;
  7481. } else {
  7482. return (0, shallowEqual_1.default)(node, opts);
  7483. }
  7484. }
  7485. return false;
  7486. }
  7487. function isPrivateName(node, opts) {
  7488. if (!node) return false;
  7489. const nodeType = node.type;
  7490. if (nodeType === "PrivateName") {
  7491. if (typeof opts === "undefined") {
  7492. return true;
  7493. } else {
  7494. return (0, shallowEqual_1.default)(node, opts);
  7495. }
  7496. }
  7497. return false;
  7498. }
  7499. function isAnyTypeAnnotation(node, opts) {
  7500. if (!node) return false;
  7501. const nodeType = node.type;
  7502. if (nodeType === "AnyTypeAnnotation") {
  7503. if (typeof opts === "undefined") {
  7504. return true;
  7505. } else {
  7506. return (0, shallowEqual_1.default)(node, opts);
  7507. }
  7508. }
  7509. return false;
  7510. }
  7511. function isArrayTypeAnnotation(node, opts) {
  7512. if (!node) return false;
  7513. const nodeType = node.type;
  7514. if (nodeType === "ArrayTypeAnnotation") {
  7515. if (typeof opts === "undefined") {
  7516. return true;
  7517. } else {
  7518. return (0, shallowEqual_1.default)(node, opts);
  7519. }
  7520. }
  7521. return false;
  7522. }
  7523. function isBooleanTypeAnnotation(node, opts) {
  7524. if (!node) return false;
  7525. const nodeType = node.type;
  7526. if (nodeType === "BooleanTypeAnnotation") {
  7527. if (typeof opts === "undefined") {
  7528. return true;
  7529. } else {
  7530. return (0, shallowEqual_1.default)(node, opts);
  7531. }
  7532. }
  7533. return false;
  7534. }
  7535. function isBooleanLiteralTypeAnnotation(node, opts) {
  7536. if (!node) return false;
  7537. const nodeType = node.type;
  7538. if (nodeType === "BooleanLiteralTypeAnnotation") {
  7539. if (typeof opts === "undefined") {
  7540. return true;
  7541. } else {
  7542. return (0, shallowEqual_1.default)(node, opts);
  7543. }
  7544. }
  7545. return false;
  7546. }
  7547. function isNullLiteralTypeAnnotation(node, opts) {
  7548. if (!node) return false;
  7549. const nodeType = node.type;
  7550. if (nodeType === "NullLiteralTypeAnnotation") {
  7551. if (typeof opts === "undefined") {
  7552. return true;
  7553. } else {
  7554. return (0, shallowEqual_1.default)(node, opts);
  7555. }
  7556. }
  7557. return false;
  7558. }
  7559. function isClassImplements(node, opts) {
  7560. if (!node) return false;
  7561. const nodeType = node.type;
  7562. if (nodeType === "ClassImplements") {
  7563. if (typeof opts === "undefined") {
  7564. return true;
  7565. } else {
  7566. return (0, shallowEqual_1.default)(node, opts);
  7567. }
  7568. }
  7569. return false;
  7570. }
  7571. function isDeclareClass(node, opts) {
  7572. if (!node) return false;
  7573. const nodeType = node.type;
  7574. if (nodeType === "DeclareClass") {
  7575. if (typeof opts === "undefined") {
  7576. return true;
  7577. } else {
  7578. return (0, shallowEqual_1.default)(node, opts);
  7579. }
  7580. }
  7581. return false;
  7582. }
  7583. function isDeclareFunction(node, opts) {
  7584. if (!node) return false;
  7585. const nodeType = node.type;
  7586. if (nodeType === "DeclareFunction") {
  7587. if (typeof opts === "undefined") {
  7588. return true;
  7589. } else {
  7590. return (0, shallowEqual_1.default)(node, opts);
  7591. }
  7592. }
  7593. return false;
  7594. }
  7595. function isDeclareInterface(node, opts) {
  7596. if (!node) return false;
  7597. const nodeType = node.type;
  7598. if (nodeType === "DeclareInterface") {
  7599. if (typeof opts === "undefined") {
  7600. return true;
  7601. } else {
  7602. return (0, shallowEqual_1.default)(node, opts);
  7603. }
  7604. }
  7605. return false;
  7606. }
  7607. function isDeclareModule(node, opts) {
  7608. if (!node) return false;
  7609. const nodeType = node.type;
  7610. if (nodeType === "DeclareModule") {
  7611. if (typeof opts === "undefined") {
  7612. return true;
  7613. } else {
  7614. return (0, shallowEqual_1.default)(node, opts);
  7615. }
  7616. }
  7617. return false;
  7618. }
  7619. function isDeclareModuleExports(node, opts) {
  7620. if (!node) return false;
  7621. const nodeType = node.type;
  7622. if (nodeType === "DeclareModuleExports") {
  7623. if (typeof opts === "undefined") {
  7624. return true;
  7625. } else {
  7626. return (0, shallowEqual_1.default)(node, opts);
  7627. }
  7628. }
  7629. return false;
  7630. }
  7631. function isDeclareTypeAlias(node, opts) {
  7632. if (!node) return false;
  7633. const nodeType = node.type;
  7634. if (nodeType === "DeclareTypeAlias") {
  7635. if (typeof opts === "undefined") {
  7636. return true;
  7637. } else {
  7638. return (0, shallowEqual_1.default)(node, opts);
  7639. }
  7640. }
  7641. return false;
  7642. }
  7643. function isDeclareOpaqueType(node, opts) {
  7644. if (!node) return false;
  7645. const nodeType = node.type;
  7646. if (nodeType === "DeclareOpaqueType") {
  7647. if (typeof opts === "undefined") {
  7648. return true;
  7649. } else {
  7650. return (0, shallowEqual_1.default)(node, opts);
  7651. }
  7652. }
  7653. return false;
  7654. }
  7655. function isDeclareVariable(node, opts) {
  7656. if (!node) return false;
  7657. const nodeType = node.type;
  7658. if (nodeType === "DeclareVariable") {
  7659. if (typeof opts === "undefined") {
  7660. return true;
  7661. } else {
  7662. return (0, shallowEqual_1.default)(node, opts);
  7663. }
  7664. }
  7665. return false;
  7666. }
  7667. function isDeclareExportDeclaration(node, opts) {
  7668. if (!node) return false;
  7669. const nodeType = node.type;
  7670. if (nodeType === "DeclareExportDeclaration") {
  7671. if (typeof opts === "undefined") {
  7672. return true;
  7673. } else {
  7674. return (0, shallowEqual_1.default)(node, opts);
  7675. }
  7676. }
  7677. return false;
  7678. }
  7679. function isDeclareExportAllDeclaration(node, opts) {
  7680. if (!node) return false;
  7681. const nodeType = node.type;
  7682. if (nodeType === "DeclareExportAllDeclaration") {
  7683. if (typeof opts === "undefined") {
  7684. return true;
  7685. } else {
  7686. return (0, shallowEqual_1.default)(node, opts);
  7687. }
  7688. }
  7689. return false;
  7690. }
  7691. function isDeclaredPredicate(node, opts) {
  7692. if (!node) return false;
  7693. const nodeType = node.type;
  7694. if (nodeType === "DeclaredPredicate") {
  7695. if (typeof opts === "undefined") {
  7696. return true;
  7697. } else {
  7698. return (0, shallowEqual_1.default)(node, opts);
  7699. }
  7700. }
  7701. return false;
  7702. }
  7703. function isExistsTypeAnnotation(node, opts) {
  7704. if (!node) return false;
  7705. const nodeType = node.type;
  7706. if (nodeType === "ExistsTypeAnnotation") {
  7707. if (typeof opts === "undefined") {
  7708. return true;
  7709. } else {
  7710. return (0, shallowEqual_1.default)(node, opts);
  7711. }
  7712. }
  7713. return false;
  7714. }
  7715. function isFunctionTypeAnnotation(node, opts) {
  7716. if (!node) return false;
  7717. const nodeType = node.type;
  7718. if (nodeType === "FunctionTypeAnnotation") {
  7719. if (typeof opts === "undefined") {
  7720. return true;
  7721. } else {
  7722. return (0, shallowEqual_1.default)(node, opts);
  7723. }
  7724. }
  7725. return false;
  7726. }
  7727. function isFunctionTypeParam(node, opts) {
  7728. if (!node) return false;
  7729. const nodeType = node.type;
  7730. if (nodeType === "FunctionTypeParam") {
  7731. if (typeof opts === "undefined") {
  7732. return true;
  7733. } else {
  7734. return (0, shallowEqual_1.default)(node, opts);
  7735. }
  7736. }
  7737. return false;
  7738. }
  7739. function isGenericTypeAnnotation(node, opts) {
  7740. if (!node) return false;
  7741. const nodeType = node.type;
  7742. if (nodeType === "GenericTypeAnnotation") {
  7743. if (typeof opts === "undefined") {
  7744. return true;
  7745. } else {
  7746. return (0, shallowEqual_1.default)(node, opts);
  7747. }
  7748. }
  7749. return false;
  7750. }
  7751. function isInferredPredicate(node, opts) {
  7752. if (!node) return false;
  7753. const nodeType = node.type;
  7754. if (nodeType === "InferredPredicate") {
  7755. if (typeof opts === "undefined") {
  7756. return true;
  7757. } else {
  7758. return (0, shallowEqual_1.default)(node, opts);
  7759. }
  7760. }
  7761. return false;
  7762. }
  7763. function isInterfaceExtends(node, opts) {
  7764. if (!node) return false;
  7765. const nodeType = node.type;
  7766. if (nodeType === "InterfaceExtends") {
  7767. if (typeof opts === "undefined") {
  7768. return true;
  7769. } else {
  7770. return (0, shallowEqual_1.default)(node, opts);
  7771. }
  7772. }
  7773. return false;
  7774. }
  7775. function isInterfaceDeclaration(node, opts) {
  7776. if (!node) return false;
  7777. const nodeType = node.type;
  7778. if (nodeType === "InterfaceDeclaration") {
  7779. if (typeof opts === "undefined") {
  7780. return true;
  7781. } else {
  7782. return (0, shallowEqual_1.default)(node, opts);
  7783. }
  7784. }
  7785. return false;
  7786. }
  7787. function isInterfaceTypeAnnotation(node, opts) {
  7788. if (!node) return false;
  7789. const nodeType = node.type;
  7790. if (nodeType === "InterfaceTypeAnnotation") {
  7791. if (typeof opts === "undefined") {
  7792. return true;
  7793. } else {
  7794. return (0, shallowEqual_1.default)(node, opts);
  7795. }
  7796. }
  7797. return false;
  7798. }
  7799. function isIntersectionTypeAnnotation(node, opts) {
  7800. if (!node) return false;
  7801. const nodeType = node.type;
  7802. if (nodeType === "IntersectionTypeAnnotation") {
  7803. if (typeof opts === "undefined") {
  7804. return true;
  7805. } else {
  7806. return (0, shallowEqual_1.default)(node, opts);
  7807. }
  7808. }
  7809. return false;
  7810. }
  7811. function isMixedTypeAnnotation(node, opts) {
  7812. if (!node) return false;
  7813. const nodeType = node.type;
  7814. if (nodeType === "MixedTypeAnnotation") {
  7815. if (typeof opts === "undefined") {
  7816. return true;
  7817. } else {
  7818. return (0, shallowEqual_1.default)(node, opts);
  7819. }
  7820. }
  7821. return false;
  7822. }
  7823. function isEmptyTypeAnnotation(node, opts) {
  7824. if (!node) return false;
  7825. const nodeType = node.type;
  7826. if (nodeType === "EmptyTypeAnnotation") {
  7827. if (typeof opts === "undefined") {
  7828. return true;
  7829. } else {
  7830. return (0, shallowEqual_1.default)(node, opts);
  7831. }
  7832. }
  7833. return false;
  7834. }
  7835. function isNullableTypeAnnotation(node, opts) {
  7836. if (!node) return false;
  7837. const nodeType = node.type;
  7838. if (nodeType === "NullableTypeAnnotation") {
  7839. if (typeof opts === "undefined") {
  7840. return true;
  7841. } else {
  7842. return (0, shallowEqual_1.default)(node, opts);
  7843. }
  7844. }
  7845. return false;
  7846. }
  7847. function isNumberLiteralTypeAnnotation(node, opts) {
  7848. if (!node) return false;
  7849. const nodeType = node.type;
  7850. if (nodeType === "NumberLiteralTypeAnnotation") {
  7851. if (typeof opts === "undefined") {
  7852. return true;
  7853. } else {
  7854. return (0, shallowEqual_1.default)(node, opts);
  7855. }
  7856. }
  7857. return false;
  7858. }
  7859. function isNumberTypeAnnotation(node, opts) {
  7860. if (!node) return false;
  7861. const nodeType = node.type;
  7862. if (nodeType === "NumberTypeAnnotation") {
  7863. if (typeof opts === "undefined") {
  7864. return true;
  7865. } else {
  7866. return (0, shallowEqual_1.default)(node, opts);
  7867. }
  7868. }
  7869. return false;
  7870. }
  7871. function isObjectTypeAnnotation(node, opts) {
  7872. if (!node) return false;
  7873. const nodeType = node.type;
  7874. if (nodeType === "ObjectTypeAnnotation") {
  7875. if (typeof opts === "undefined") {
  7876. return true;
  7877. } else {
  7878. return (0, shallowEqual_1.default)(node, opts);
  7879. }
  7880. }
  7881. return false;
  7882. }
  7883. function isObjectTypeInternalSlot(node, opts) {
  7884. if (!node) return false;
  7885. const nodeType = node.type;
  7886. if (nodeType === "ObjectTypeInternalSlot") {
  7887. if (typeof opts === "undefined") {
  7888. return true;
  7889. } else {
  7890. return (0, shallowEqual_1.default)(node, opts);
  7891. }
  7892. }
  7893. return false;
  7894. }
  7895. function isObjectTypeCallProperty(node, opts) {
  7896. if (!node) return false;
  7897. const nodeType = node.type;
  7898. if (nodeType === "ObjectTypeCallProperty") {
  7899. if (typeof opts === "undefined") {
  7900. return true;
  7901. } else {
  7902. return (0, shallowEqual_1.default)(node, opts);
  7903. }
  7904. }
  7905. return false;
  7906. }
  7907. function isObjectTypeIndexer(node, opts) {
  7908. if (!node) return false;
  7909. const nodeType = node.type;
  7910. if (nodeType === "ObjectTypeIndexer") {
  7911. if (typeof opts === "undefined") {
  7912. return true;
  7913. } else {
  7914. return (0, shallowEqual_1.default)(node, opts);
  7915. }
  7916. }
  7917. return false;
  7918. }
  7919. function isObjectTypeProperty(node, opts) {
  7920. if (!node) return false;
  7921. const nodeType = node.type;
  7922. if (nodeType === "ObjectTypeProperty") {
  7923. if (typeof opts === "undefined") {
  7924. return true;
  7925. } else {
  7926. return (0, shallowEqual_1.default)(node, opts);
  7927. }
  7928. }
  7929. return false;
  7930. }
  7931. function isObjectTypeSpreadProperty(node, opts) {
  7932. if (!node) return false;
  7933. const nodeType = node.type;
  7934. if (nodeType === "ObjectTypeSpreadProperty") {
  7935. if (typeof opts === "undefined") {
  7936. return true;
  7937. } else {
  7938. return (0, shallowEqual_1.default)(node, opts);
  7939. }
  7940. }
  7941. return false;
  7942. }
  7943. function isOpaqueType(node, opts) {
  7944. if (!node) return false;
  7945. const nodeType = node.type;
  7946. if (nodeType === "OpaqueType") {
  7947. if (typeof opts === "undefined") {
  7948. return true;
  7949. } else {
  7950. return (0, shallowEqual_1.default)(node, opts);
  7951. }
  7952. }
  7953. return false;
  7954. }
  7955. function isQualifiedTypeIdentifier(node, opts) {
  7956. if (!node) return false;
  7957. const nodeType = node.type;
  7958. if (nodeType === "QualifiedTypeIdentifier") {
  7959. if (typeof opts === "undefined") {
  7960. return true;
  7961. } else {
  7962. return (0, shallowEqual_1.default)(node, opts);
  7963. }
  7964. }
  7965. return false;
  7966. }
  7967. function isStringLiteralTypeAnnotation(node, opts) {
  7968. if (!node) return false;
  7969. const nodeType = node.type;
  7970. if (nodeType === "StringLiteralTypeAnnotation") {
  7971. if (typeof opts === "undefined") {
  7972. return true;
  7973. } else {
  7974. return (0, shallowEqual_1.default)(node, opts);
  7975. }
  7976. }
  7977. return false;
  7978. }
  7979. function isStringTypeAnnotation(node, opts) {
  7980. if (!node) return false;
  7981. const nodeType = node.type;
  7982. if (nodeType === "StringTypeAnnotation") {
  7983. if (typeof opts === "undefined") {
  7984. return true;
  7985. } else {
  7986. return (0, shallowEqual_1.default)(node, opts);
  7987. }
  7988. }
  7989. return false;
  7990. }
  7991. function isSymbolTypeAnnotation(node, opts) {
  7992. if (!node) return false;
  7993. const nodeType = node.type;
  7994. if (nodeType === "SymbolTypeAnnotation") {
  7995. if (typeof opts === "undefined") {
  7996. return true;
  7997. } else {
  7998. return (0, shallowEqual_1.default)(node, opts);
  7999. }
  8000. }
  8001. return false;
  8002. }
  8003. function isThisTypeAnnotation(node, opts) {
  8004. if (!node) return false;
  8005. const nodeType = node.type;
  8006. if (nodeType === "ThisTypeAnnotation") {
  8007. if (typeof opts === "undefined") {
  8008. return true;
  8009. } else {
  8010. return (0, shallowEqual_1.default)(node, opts);
  8011. }
  8012. }
  8013. return false;
  8014. }
  8015. function isTupleTypeAnnotation(node, opts) {
  8016. if (!node) return false;
  8017. const nodeType = node.type;
  8018. if (nodeType === "TupleTypeAnnotation") {
  8019. if (typeof opts === "undefined") {
  8020. return true;
  8021. } else {
  8022. return (0, shallowEqual_1.default)(node, opts);
  8023. }
  8024. }
  8025. return false;
  8026. }
  8027. function isTypeofTypeAnnotation(node, opts) {
  8028. if (!node) return false;
  8029. const nodeType = node.type;
  8030. if (nodeType === "TypeofTypeAnnotation") {
  8031. if (typeof opts === "undefined") {
  8032. return true;
  8033. } else {
  8034. return (0, shallowEqual_1.default)(node, opts);
  8035. }
  8036. }
  8037. return false;
  8038. }
  8039. function isTypeAlias(node, opts) {
  8040. if (!node) return false;
  8041. const nodeType = node.type;
  8042. if (nodeType === "TypeAlias") {
  8043. if (typeof opts === "undefined") {
  8044. return true;
  8045. } else {
  8046. return (0, shallowEqual_1.default)(node, opts);
  8047. }
  8048. }
  8049. return false;
  8050. }
  8051. function isTypeAnnotation(node, opts) {
  8052. if (!node) return false;
  8053. const nodeType = node.type;
  8054. if (nodeType === "TypeAnnotation") {
  8055. if (typeof opts === "undefined") {
  8056. return true;
  8057. } else {
  8058. return (0, shallowEqual_1.default)(node, opts);
  8059. }
  8060. }
  8061. return false;
  8062. }
  8063. function isTypeCastExpression(node, opts) {
  8064. if (!node) return false;
  8065. const nodeType = node.type;
  8066. if (nodeType === "TypeCastExpression") {
  8067. if (typeof opts === "undefined") {
  8068. return true;
  8069. } else {
  8070. return (0, shallowEqual_1.default)(node, opts);
  8071. }
  8072. }
  8073. return false;
  8074. }
  8075. function isTypeParameter(node, opts) {
  8076. if (!node) return false;
  8077. const nodeType = node.type;
  8078. if (nodeType === "TypeParameter") {
  8079. if (typeof opts === "undefined") {
  8080. return true;
  8081. } else {
  8082. return (0, shallowEqual_1.default)(node, opts);
  8083. }
  8084. }
  8085. return false;
  8086. }
  8087. function isTypeParameterDeclaration(node, opts) {
  8088. if (!node) return false;
  8089. const nodeType = node.type;
  8090. if (nodeType === "TypeParameterDeclaration") {
  8091. if (typeof opts === "undefined") {
  8092. return true;
  8093. } else {
  8094. return (0, shallowEqual_1.default)(node, opts);
  8095. }
  8096. }
  8097. return false;
  8098. }
  8099. function isTypeParameterInstantiation(node, opts) {
  8100. if (!node) return false;
  8101. const nodeType = node.type;
  8102. if (nodeType === "TypeParameterInstantiation") {
  8103. if (typeof opts === "undefined") {
  8104. return true;
  8105. } else {
  8106. return (0, shallowEqual_1.default)(node, opts);
  8107. }
  8108. }
  8109. return false;
  8110. }
  8111. function isUnionTypeAnnotation(node, opts) {
  8112. if (!node) return false;
  8113. const nodeType = node.type;
  8114. if (nodeType === "UnionTypeAnnotation") {
  8115. if (typeof opts === "undefined") {
  8116. return true;
  8117. } else {
  8118. return (0, shallowEqual_1.default)(node, opts);
  8119. }
  8120. }
  8121. return false;
  8122. }
  8123. function isVariance(node, opts) {
  8124. if (!node) return false;
  8125. const nodeType = node.type;
  8126. if (nodeType === "Variance") {
  8127. if (typeof opts === "undefined") {
  8128. return true;
  8129. } else {
  8130. return (0, shallowEqual_1.default)(node, opts);
  8131. }
  8132. }
  8133. return false;
  8134. }
  8135. function isVoidTypeAnnotation(node, opts) {
  8136. if (!node) return false;
  8137. const nodeType = node.type;
  8138. if (nodeType === "VoidTypeAnnotation") {
  8139. if (typeof opts === "undefined") {
  8140. return true;
  8141. } else {
  8142. return (0, shallowEqual_1.default)(node, opts);
  8143. }
  8144. }
  8145. return false;
  8146. }
  8147. function isEnumDeclaration(node, opts) {
  8148. if (!node) return false;
  8149. const nodeType = node.type;
  8150. if (nodeType === "EnumDeclaration") {
  8151. if (typeof opts === "undefined") {
  8152. return true;
  8153. } else {
  8154. return (0, shallowEqual_1.default)(node, opts);
  8155. }
  8156. }
  8157. return false;
  8158. }
  8159. function isEnumBooleanBody(node, opts) {
  8160. if (!node) return false;
  8161. const nodeType = node.type;
  8162. if (nodeType === "EnumBooleanBody") {
  8163. if (typeof opts === "undefined") {
  8164. return true;
  8165. } else {
  8166. return (0, shallowEqual_1.default)(node, opts);
  8167. }
  8168. }
  8169. return false;
  8170. }
  8171. function isEnumNumberBody(node, opts) {
  8172. if (!node) return false;
  8173. const nodeType = node.type;
  8174. if (nodeType === "EnumNumberBody") {
  8175. if (typeof opts === "undefined") {
  8176. return true;
  8177. } else {
  8178. return (0, shallowEqual_1.default)(node, opts);
  8179. }
  8180. }
  8181. return false;
  8182. }
  8183. function isEnumStringBody(node, opts) {
  8184. if (!node) return false;
  8185. const nodeType = node.type;
  8186. if (nodeType === "EnumStringBody") {
  8187. if (typeof opts === "undefined") {
  8188. return true;
  8189. } else {
  8190. return (0, shallowEqual_1.default)(node, opts);
  8191. }
  8192. }
  8193. return false;
  8194. }
  8195. function isEnumSymbolBody(node, opts) {
  8196. if (!node) return false;
  8197. const nodeType = node.type;
  8198. if (nodeType === "EnumSymbolBody") {
  8199. if (typeof opts === "undefined") {
  8200. return true;
  8201. } else {
  8202. return (0, shallowEqual_1.default)(node, opts);
  8203. }
  8204. }
  8205. return false;
  8206. }
  8207. function isEnumBooleanMember(node, opts) {
  8208. if (!node) return false;
  8209. const nodeType = node.type;
  8210. if (nodeType === "EnumBooleanMember") {
  8211. if (typeof opts === "undefined") {
  8212. return true;
  8213. } else {
  8214. return (0, shallowEqual_1.default)(node, opts);
  8215. }
  8216. }
  8217. return false;
  8218. }
  8219. function isEnumNumberMember(node, opts) {
  8220. if (!node) return false;
  8221. const nodeType = node.type;
  8222. if (nodeType === "EnumNumberMember") {
  8223. if (typeof opts === "undefined") {
  8224. return true;
  8225. } else {
  8226. return (0, shallowEqual_1.default)(node, opts);
  8227. }
  8228. }
  8229. return false;
  8230. }
  8231. function isEnumStringMember(node, opts) {
  8232. if (!node) return false;
  8233. const nodeType = node.type;
  8234. if (nodeType === "EnumStringMember") {
  8235. if (typeof opts === "undefined") {
  8236. return true;
  8237. } else {
  8238. return (0, shallowEqual_1.default)(node, opts);
  8239. }
  8240. }
  8241. return false;
  8242. }
  8243. function isEnumDefaultedMember(node, opts) {
  8244. if (!node) return false;
  8245. const nodeType = node.type;
  8246. if (nodeType === "EnumDefaultedMember") {
  8247. if (typeof opts === "undefined") {
  8248. return true;
  8249. } else {
  8250. return (0, shallowEqual_1.default)(node, opts);
  8251. }
  8252. }
  8253. return false;
  8254. }
  8255. function isIndexedAccessType(node, opts) {
  8256. if (!node) return false;
  8257. const nodeType = node.type;
  8258. if (nodeType === "IndexedAccessType") {
  8259. if (typeof opts === "undefined") {
  8260. return true;
  8261. } else {
  8262. return (0, shallowEqual_1.default)(node, opts);
  8263. }
  8264. }
  8265. return false;
  8266. }
  8267. function isOptionalIndexedAccessType(node, opts) {
  8268. if (!node) return false;
  8269. const nodeType = node.type;
  8270. if (nodeType === "OptionalIndexedAccessType") {
  8271. if (typeof opts === "undefined") {
  8272. return true;
  8273. } else {
  8274. return (0, shallowEqual_1.default)(node, opts);
  8275. }
  8276. }
  8277. return false;
  8278. }
  8279. function isJSXAttribute(node, opts) {
  8280. if (!node) return false;
  8281. const nodeType = node.type;
  8282. if (nodeType === "JSXAttribute") {
  8283. if (typeof opts === "undefined") {
  8284. return true;
  8285. } else {
  8286. return (0, shallowEqual_1.default)(node, opts);
  8287. }
  8288. }
  8289. return false;
  8290. }
  8291. function isJSXClosingElement(node, opts) {
  8292. if (!node) return false;
  8293. const nodeType = node.type;
  8294. if (nodeType === "JSXClosingElement") {
  8295. if (typeof opts === "undefined") {
  8296. return true;
  8297. } else {
  8298. return (0, shallowEqual_1.default)(node, opts);
  8299. }
  8300. }
  8301. return false;
  8302. }
  8303. function isJSXElement(node, opts) {
  8304. if (!node) return false;
  8305. const nodeType = node.type;
  8306. if (nodeType === "JSXElement") {
  8307. if (typeof opts === "undefined") {
  8308. return true;
  8309. } else {
  8310. return (0, shallowEqual_1.default)(node, opts);
  8311. }
  8312. }
  8313. return false;
  8314. }
  8315. function isJSXEmptyExpression(node, opts) {
  8316. if (!node) return false;
  8317. const nodeType = node.type;
  8318. if (nodeType === "JSXEmptyExpression") {
  8319. if (typeof opts === "undefined") {
  8320. return true;
  8321. } else {
  8322. return (0, shallowEqual_1.default)(node, opts);
  8323. }
  8324. }
  8325. return false;
  8326. }
  8327. function isJSXExpressionContainer(node, opts) {
  8328. if (!node) return false;
  8329. const nodeType = node.type;
  8330. if (nodeType === "JSXExpressionContainer") {
  8331. if (typeof opts === "undefined") {
  8332. return true;
  8333. } else {
  8334. return (0, shallowEqual_1.default)(node, opts);
  8335. }
  8336. }
  8337. return false;
  8338. }
  8339. function isJSXSpreadChild(node, opts) {
  8340. if (!node) return false;
  8341. const nodeType = node.type;
  8342. if (nodeType === "JSXSpreadChild") {
  8343. if (typeof opts === "undefined") {
  8344. return true;
  8345. } else {
  8346. return (0, shallowEqual_1.default)(node, opts);
  8347. }
  8348. }
  8349. return false;
  8350. }
  8351. function isJSXIdentifier(node, opts) {
  8352. if (!node) return false;
  8353. const nodeType = node.type;
  8354. if (nodeType === "JSXIdentifier") {
  8355. if (typeof opts === "undefined") {
  8356. return true;
  8357. } else {
  8358. return (0, shallowEqual_1.default)(node, opts);
  8359. }
  8360. }
  8361. return false;
  8362. }
  8363. function isJSXMemberExpression(node, opts) {
  8364. if (!node) return false;
  8365. const nodeType = node.type;
  8366. if (nodeType === "JSXMemberExpression") {
  8367. if (typeof opts === "undefined") {
  8368. return true;
  8369. } else {
  8370. return (0, shallowEqual_1.default)(node, opts);
  8371. }
  8372. }
  8373. return false;
  8374. }
  8375. function isJSXNamespacedName(node, opts) {
  8376. if (!node) return false;
  8377. const nodeType = node.type;
  8378. if (nodeType === "JSXNamespacedName") {
  8379. if (typeof opts === "undefined") {
  8380. return true;
  8381. } else {
  8382. return (0, shallowEqual_1.default)(node, opts);
  8383. }
  8384. }
  8385. return false;
  8386. }
  8387. function isJSXOpeningElement(node, opts) {
  8388. if (!node) return false;
  8389. const nodeType = node.type;
  8390. if (nodeType === "JSXOpeningElement") {
  8391. if (typeof opts === "undefined") {
  8392. return true;
  8393. } else {
  8394. return (0, shallowEqual_1.default)(node, opts);
  8395. }
  8396. }
  8397. return false;
  8398. }
  8399. function isJSXSpreadAttribute(node, opts) {
  8400. if (!node) return false;
  8401. const nodeType = node.type;
  8402. if (nodeType === "JSXSpreadAttribute") {
  8403. if (typeof opts === "undefined") {
  8404. return true;
  8405. } else {
  8406. return (0, shallowEqual_1.default)(node, opts);
  8407. }
  8408. }
  8409. return false;
  8410. }
  8411. function isJSXText(node, opts) {
  8412. if (!node) return false;
  8413. const nodeType = node.type;
  8414. if (nodeType === "JSXText") {
  8415. if (typeof opts === "undefined") {
  8416. return true;
  8417. } else {
  8418. return (0, shallowEqual_1.default)(node, opts);
  8419. }
  8420. }
  8421. return false;
  8422. }
  8423. function isJSXFragment(node, opts) {
  8424. if (!node) return false;
  8425. const nodeType = node.type;
  8426. if (nodeType === "JSXFragment") {
  8427. if (typeof opts === "undefined") {
  8428. return true;
  8429. } else {
  8430. return (0, shallowEqual_1.default)(node, opts);
  8431. }
  8432. }
  8433. return false;
  8434. }
  8435. function isJSXOpeningFragment(node, opts) {
  8436. if (!node) return false;
  8437. const nodeType = node.type;
  8438. if (nodeType === "JSXOpeningFragment") {
  8439. if (typeof opts === "undefined") {
  8440. return true;
  8441. } else {
  8442. return (0, shallowEqual_1.default)(node, opts);
  8443. }
  8444. }
  8445. return false;
  8446. }
  8447. function isJSXClosingFragment(node, opts) {
  8448. if (!node) return false;
  8449. const nodeType = node.type;
  8450. if (nodeType === "JSXClosingFragment") {
  8451. if (typeof opts === "undefined") {
  8452. return true;
  8453. } else {
  8454. return (0, shallowEqual_1.default)(node, opts);
  8455. }
  8456. }
  8457. return false;
  8458. }
  8459. function isNoop(node, opts) {
  8460. if (!node) return false;
  8461. const nodeType = node.type;
  8462. if (nodeType === "Noop") {
  8463. if (typeof opts === "undefined") {
  8464. return true;
  8465. } else {
  8466. return (0, shallowEqual_1.default)(node, opts);
  8467. }
  8468. }
  8469. return false;
  8470. }
  8471. function isPlaceholder(node, opts) {
  8472. if (!node) return false;
  8473. const nodeType = node.type;
  8474. if (nodeType === "Placeholder") {
  8475. if (typeof opts === "undefined") {
  8476. return true;
  8477. } else {
  8478. return (0, shallowEqual_1.default)(node, opts);
  8479. }
  8480. }
  8481. return false;
  8482. }
  8483. function isV8IntrinsicIdentifier(node, opts) {
  8484. if (!node) return false;
  8485. const nodeType = node.type;
  8486. if (nodeType === "V8IntrinsicIdentifier") {
  8487. if (typeof opts === "undefined") {
  8488. return true;
  8489. } else {
  8490. return (0, shallowEqual_1.default)(node, opts);
  8491. }
  8492. }
  8493. return false;
  8494. }
  8495. function isArgumentPlaceholder(node, opts) {
  8496. if (!node) return false;
  8497. const nodeType = node.type;
  8498. if (nodeType === "ArgumentPlaceholder") {
  8499. if (typeof opts === "undefined") {
  8500. return true;
  8501. } else {
  8502. return (0, shallowEqual_1.default)(node, opts);
  8503. }
  8504. }
  8505. return false;
  8506. }
  8507. function isBindExpression(node, opts) {
  8508. if (!node) return false;
  8509. const nodeType = node.type;
  8510. if (nodeType === "BindExpression") {
  8511. if (typeof opts === "undefined") {
  8512. return true;
  8513. } else {
  8514. return (0, shallowEqual_1.default)(node, opts);
  8515. }
  8516. }
  8517. return false;
  8518. }
  8519. function isImportAttribute(node, opts) {
  8520. if (!node) return false;
  8521. const nodeType = node.type;
  8522. if (nodeType === "ImportAttribute") {
  8523. if (typeof opts === "undefined") {
  8524. return true;
  8525. } else {
  8526. return (0, shallowEqual_1.default)(node, opts);
  8527. }
  8528. }
  8529. return false;
  8530. }
  8531. function isDecorator(node, opts) {
  8532. if (!node) return false;
  8533. const nodeType = node.type;
  8534. if (nodeType === "Decorator") {
  8535. if (typeof opts === "undefined") {
  8536. return true;
  8537. } else {
  8538. return (0, shallowEqual_1.default)(node, opts);
  8539. }
  8540. }
  8541. return false;
  8542. }
  8543. function isDoExpression(node, opts) {
  8544. if (!node) return false;
  8545. const nodeType = node.type;
  8546. if (nodeType === "DoExpression") {
  8547. if (typeof opts === "undefined") {
  8548. return true;
  8549. } else {
  8550. return (0, shallowEqual_1.default)(node, opts);
  8551. }
  8552. }
  8553. return false;
  8554. }
  8555. function isExportDefaultSpecifier(node, opts) {
  8556. if (!node) return false;
  8557. const nodeType = node.type;
  8558. if (nodeType === "ExportDefaultSpecifier") {
  8559. if (typeof opts === "undefined") {
  8560. return true;
  8561. } else {
  8562. return (0, shallowEqual_1.default)(node, opts);
  8563. }
  8564. }
  8565. return false;
  8566. }
  8567. function isRecordExpression(node, opts) {
  8568. if (!node) return false;
  8569. const nodeType = node.type;
  8570. if (nodeType === "RecordExpression") {
  8571. if (typeof opts === "undefined") {
  8572. return true;
  8573. } else {
  8574. return (0, shallowEqual_1.default)(node, opts);
  8575. }
  8576. }
  8577. return false;
  8578. }
  8579. function isTupleExpression(node, opts) {
  8580. if (!node) return false;
  8581. const nodeType = node.type;
  8582. if (nodeType === "TupleExpression") {
  8583. if (typeof opts === "undefined") {
  8584. return true;
  8585. } else {
  8586. return (0, shallowEqual_1.default)(node, opts);
  8587. }
  8588. }
  8589. return false;
  8590. }
  8591. function isDecimalLiteral(node, opts) {
  8592. if (!node) return false;
  8593. const nodeType = node.type;
  8594. if (nodeType === "DecimalLiteral") {
  8595. if (typeof opts === "undefined") {
  8596. return true;
  8597. } else {
  8598. return (0, shallowEqual_1.default)(node, opts);
  8599. }
  8600. }
  8601. return false;
  8602. }
  8603. function isStaticBlock(node, opts) {
  8604. if (!node) return false;
  8605. const nodeType = node.type;
  8606. if (nodeType === "StaticBlock") {
  8607. if (typeof opts === "undefined") {
  8608. return true;
  8609. } else {
  8610. return (0, shallowEqual_1.default)(node, opts);
  8611. }
  8612. }
  8613. return false;
  8614. }
  8615. function isModuleExpression(node, opts) {
  8616. if (!node) return false;
  8617. const nodeType = node.type;
  8618. if (nodeType === "ModuleExpression") {
  8619. if (typeof opts === "undefined") {
  8620. return true;
  8621. } else {
  8622. return (0, shallowEqual_1.default)(node, opts);
  8623. }
  8624. }
  8625. return false;
  8626. }
  8627. function isTopicReference(node, opts) {
  8628. if (!node) return false;
  8629. const nodeType = node.type;
  8630. if (nodeType === "TopicReference") {
  8631. if (typeof opts === "undefined") {
  8632. return true;
  8633. } else {
  8634. return (0, shallowEqual_1.default)(node, opts);
  8635. }
  8636. }
  8637. return false;
  8638. }
  8639. function isPipelineTopicExpression(node, opts) {
  8640. if (!node) return false;
  8641. const nodeType = node.type;
  8642. if (nodeType === "PipelineTopicExpression") {
  8643. if (typeof opts === "undefined") {
  8644. return true;
  8645. } else {
  8646. return (0, shallowEqual_1.default)(node, opts);
  8647. }
  8648. }
  8649. return false;
  8650. }
  8651. function isPipelineBareFunction(node, opts) {
  8652. if (!node) return false;
  8653. const nodeType = node.type;
  8654. if (nodeType === "PipelineBareFunction") {
  8655. if (typeof opts === "undefined") {
  8656. return true;
  8657. } else {
  8658. return (0, shallowEqual_1.default)(node, opts);
  8659. }
  8660. }
  8661. return false;
  8662. }
  8663. function isPipelinePrimaryTopicReference(node, opts) {
  8664. if (!node) return false;
  8665. const nodeType = node.type;
  8666. if (nodeType === "PipelinePrimaryTopicReference") {
  8667. if (typeof opts === "undefined") {
  8668. return true;
  8669. } else {
  8670. return (0, shallowEqual_1.default)(node, opts);
  8671. }
  8672. }
  8673. return false;
  8674. }
  8675. function isTSParameterProperty(node, opts) {
  8676. if (!node) return false;
  8677. const nodeType = node.type;
  8678. if (nodeType === "TSParameterProperty") {
  8679. if (typeof opts === "undefined") {
  8680. return true;
  8681. } else {
  8682. return (0, shallowEqual_1.default)(node, opts);
  8683. }
  8684. }
  8685. return false;
  8686. }
  8687. function isTSDeclareFunction(node, opts) {
  8688. if (!node) return false;
  8689. const nodeType = node.type;
  8690. if (nodeType === "TSDeclareFunction") {
  8691. if (typeof opts === "undefined") {
  8692. return true;
  8693. } else {
  8694. return (0, shallowEqual_1.default)(node, opts);
  8695. }
  8696. }
  8697. return false;
  8698. }
  8699. function isTSDeclareMethod(node, opts) {
  8700. if (!node) return false;
  8701. const nodeType = node.type;
  8702. if (nodeType === "TSDeclareMethod") {
  8703. if (typeof opts === "undefined") {
  8704. return true;
  8705. } else {
  8706. return (0, shallowEqual_1.default)(node, opts);
  8707. }
  8708. }
  8709. return false;
  8710. }
  8711. function isTSQualifiedName(node, opts) {
  8712. if (!node) return false;
  8713. const nodeType = node.type;
  8714. if (nodeType === "TSQualifiedName") {
  8715. if (typeof opts === "undefined") {
  8716. return true;
  8717. } else {
  8718. return (0, shallowEqual_1.default)(node, opts);
  8719. }
  8720. }
  8721. return false;
  8722. }
  8723. function isTSCallSignatureDeclaration(node, opts) {
  8724. if (!node) return false;
  8725. const nodeType = node.type;
  8726. if (nodeType === "TSCallSignatureDeclaration") {
  8727. if (typeof opts === "undefined") {
  8728. return true;
  8729. } else {
  8730. return (0, shallowEqual_1.default)(node, opts);
  8731. }
  8732. }
  8733. return false;
  8734. }
  8735. function isTSConstructSignatureDeclaration(node, opts) {
  8736. if (!node) return false;
  8737. const nodeType = node.type;
  8738. if (nodeType === "TSConstructSignatureDeclaration") {
  8739. if (typeof opts === "undefined") {
  8740. return true;
  8741. } else {
  8742. return (0, shallowEqual_1.default)(node, opts);
  8743. }
  8744. }
  8745. return false;
  8746. }
  8747. function isTSPropertySignature(node, opts) {
  8748. if (!node) return false;
  8749. const nodeType = node.type;
  8750. if (nodeType === "TSPropertySignature") {
  8751. if (typeof opts === "undefined") {
  8752. return true;
  8753. } else {
  8754. return (0, shallowEqual_1.default)(node, opts);
  8755. }
  8756. }
  8757. return false;
  8758. }
  8759. function isTSMethodSignature(node, opts) {
  8760. if (!node) return false;
  8761. const nodeType = node.type;
  8762. if (nodeType === "TSMethodSignature") {
  8763. if (typeof opts === "undefined") {
  8764. return true;
  8765. } else {
  8766. return (0, shallowEqual_1.default)(node, opts);
  8767. }
  8768. }
  8769. return false;
  8770. }
  8771. function isTSIndexSignature(node, opts) {
  8772. if (!node) return false;
  8773. const nodeType = node.type;
  8774. if (nodeType === "TSIndexSignature") {
  8775. if (typeof opts === "undefined") {
  8776. return true;
  8777. } else {
  8778. return (0, shallowEqual_1.default)(node, opts);
  8779. }
  8780. }
  8781. return false;
  8782. }
  8783. function isTSAnyKeyword(node, opts) {
  8784. if (!node) return false;
  8785. const nodeType = node.type;
  8786. if (nodeType === "TSAnyKeyword") {
  8787. if (typeof opts === "undefined") {
  8788. return true;
  8789. } else {
  8790. return (0, shallowEqual_1.default)(node, opts);
  8791. }
  8792. }
  8793. return false;
  8794. }
  8795. function isTSBooleanKeyword(node, opts) {
  8796. if (!node) return false;
  8797. const nodeType = node.type;
  8798. if (nodeType === "TSBooleanKeyword") {
  8799. if (typeof opts === "undefined") {
  8800. return true;
  8801. } else {
  8802. return (0, shallowEqual_1.default)(node, opts);
  8803. }
  8804. }
  8805. return false;
  8806. }
  8807. function isTSBigIntKeyword(node, opts) {
  8808. if (!node) return false;
  8809. const nodeType = node.type;
  8810. if (nodeType === "TSBigIntKeyword") {
  8811. if (typeof opts === "undefined") {
  8812. return true;
  8813. } else {
  8814. return (0, shallowEqual_1.default)(node, opts);
  8815. }
  8816. }
  8817. return false;
  8818. }
  8819. function isTSIntrinsicKeyword(node, opts) {
  8820. if (!node) return false;
  8821. const nodeType = node.type;
  8822. if (nodeType === "TSIntrinsicKeyword") {
  8823. if (typeof opts === "undefined") {
  8824. return true;
  8825. } else {
  8826. return (0, shallowEqual_1.default)(node, opts);
  8827. }
  8828. }
  8829. return false;
  8830. }
  8831. function isTSNeverKeyword(node, opts) {
  8832. if (!node) return false;
  8833. const nodeType = node.type;
  8834. if (nodeType === "TSNeverKeyword") {
  8835. if (typeof opts === "undefined") {
  8836. return true;
  8837. } else {
  8838. return (0, shallowEqual_1.default)(node, opts);
  8839. }
  8840. }
  8841. return false;
  8842. }
  8843. function isTSNullKeyword(node, opts) {
  8844. if (!node) return false;
  8845. const nodeType = node.type;
  8846. if (nodeType === "TSNullKeyword") {
  8847. if (typeof opts === "undefined") {
  8848. return true;
  8849. } else {
  8850. return (0, shallowEqual_1.default)(node, opts);
  8851. }
  8852. }
  8853. return false;
  8854. }
  8855. function isTSNumberKeyword(node, opts) {
  8856. if (!node) return false;
  8857. const nodeType = node.type;
  8858. if (nodeType === "TSNumberKeyword") {
  8859. if (typeof opts === "undefined") {
  8860. return true;
  8861. } else {
  8862. return (0, shallowEqual_1.default)(node, opts);
  8863. }
  8864. }
  8865. return false;
  8866. }
  8867. function isTSObjectKeyword(node, opts) {
  8868. if (!node) return false;
  8869. const nodeType = node.type;
  8870. if (nodeType === "TSObjectKeyword") {
  8871. if (typeof opts === "undefined") {
  8872. return true;
  8873. } else {
  8874. return (0, shallowEqual_1.default)(node, opts);
  8875. }
  8876. }
  8877. return false;
  8878. }
  8879. function isTSStringKeyword(node, opts) {
  8880. if (!node) return false;
  8881. const nodeType = node.type;
  8882. if (nodeType === "TSStringKeyword") {
  8883. if (typeof opts === "undefined") {
  8884. return true;
  8885. } else {
  8886. return (0, shallowEqual_1.default)(node, opts);
  8887. }
  8888. }
  8889. return false;
  8890. }
  8891. function isTSSymbolKeyword(node, opts) {
  8892. if (!node) return false;
  8893. const nodeType = node.type;
  8894. if (nodeType === "TSSymbolKeyword") {
  8895. if (typeof opts === "undefined") {
  8896. return true;
  8897. } else {
  8898. return (0, shallowEqual_1.default)(node, opts);
  8899. }
  8900. }
  8901. return false;
  8902. }
  8903. function isTSUndefinedKeyword(node, opts) {
  8904. if (!node) return false;
  8905. const nodeType = node.type;
  8906. if (nodeType === "TSUndefinedKeyword") {
  8907. if (typeof opts === "undefined") {
  8908. return true;
  8909. } else {
  8910. return (0, shallowEqual_1.default)(node, opts);
  8911. }
  8912. }
  8913. return false;
  8914. }
  8915. function isTSUnknownKeyword(node, opts) {
  8916. if (!node) return false;
  8917. const nodeType = node.type;
  8918. if (nodeType === "TSUnknownKeyword") {
  8919. if (typeof opts === "undefined") {
  8920. return true;
  8921. } else {
  8922. return (0, shallowEqual_1.default)(node, opts);
  8923. }
  8924. }
  8925. return false;
  8926. }
  8927. function isTSVoidKeyword(node, opts) {
  8928. if (!node) return false;
  8929. const nodeType = node.type;
  8930. if (nodeType === "TSVoidKeyword") {
  8931. if (typeof opts === "undefined") {
  8932. return true;
  8933. } else {
  8934. return (0, shallowEqual_1.default)(node, opts);
  8935. }
  8936. }
  8937. return false;
  8938. }
  8939. function isTSThisType(node, opts) {
  8940. if (!node) return false;
  8941. const nodeType = node.type;
  8942. if (nodeType === "TSThisType") {
  8943. if (typeof opts === "undefined") {
  8944. return true;
  8945. } else {
  8946. return (0, shallowEqual_1.default)(node, opts);
  8947. }
  8948. }
  8949. return false;
  8950. }
  8951. function isTSFunctionType(node, opts) {
  8952. if (!node) return false;
  8953. const nodeType = node.type;
  8954. if (nodeType === "TSFunctionType") {
  8955. if (typeof opts === "undefined") {
  8956. return true;
  8957. } else {
  8958. return (0, shallowEqual_1.default)(node, opts);
  8959. }
  8960. }
  8961. return false;
  8962. }
  8963. function isTSConstructorType(node, opts) {
  8964. if (!node) return false;
  8965. const nodeType = node.type;
  8966. if (nodeType === "TSConstructorType") {
  8967. if (typeof opts === "undefined") {
  8968. return true;
  8969. } else {
  8970. return (0, shallowEqual_1.default)(node, opts);
  8971. }
  8972. }
  8973. return false;
  8974. }
  8975. function isTSTypeReference(node, opts) {
  8976. if (!node) return false;
  8977. const nodeType = node.type;
  8978. if (nodeType === "TSTypeReference") {
  8979. if (typeof opts === "undefined") {
  8980. return true;
  8981. } else {
  8982. return (0, shallowEqual_1.default)(node, opts);
  8983. }
  8984. }
  8985. return false;
  8986. }
  8987. function isTSTypePredicate(node, opts) {
  8988. if (!node) return false;
  8989. const nodeType = node.type;
  8990. if (nodeType === "TSTypePredicate") {
  8991. if (typeof opts === "undefined") {
  8992. return true;
  8993. } else {
  8994. return (0, shallowEqual_1.default)(node, opts);
  8995. }
  8996. }
  8997. return false;
  8998. }
  8999. function isTSTypeQuery(node, opts) {
  9000. if (!node) return false;
  9001. const nodeType = node.type;
  9002. if (nodeType === "TSTypeQuery") {
  9003. if (typeof opts === "undefined") {
  9004. return true;
  9005. } else {
  9006. return (0, shallowEqual_1.default)(node, opts);
  9007. }
  9008. }
  9009. return false;
  9010. }
  9011. function isTSTypeLiteral(node, opts) {
  9012. if (!node) return false;
  9013. const nodeType = node.type;
  9014. if (nodeType === "TSTypeLiteral") {
  9015. if (typeof opts === "undefined") {
  9016. return true;
  9017. } else {
  9018. return (0, shallowEqual_1.default)(node, opts);
  9019. }
  9020. }
  9021. return false;
  9022. }
  9023. function isTSArrayType(node, opts) {
  9024. if (!node) return false;
  9025. const nodeType = node.type;
  9026. if (nodeType === "TSArrayType") {
  9027. if (typeof opts === "undefined") {
  9028. return true;
  9029. } else {
  9030. return (0, shallowEqual_1.default)(node, opts);
  9031. }
  9032. }
  9033. return false;
  9034. }
  9035. function isTSTupleType(node, opts) {
  9036. if (!node) return false;
  9037. const nodeType = node.type;
  9038. if (nodeType === "TSTupleType") {
  9039. if (typeof opts === "undefined") {
  9040. return true;
  9041. } else {
  9042. return (0, shallowEqual_1.default)(node, opts);
  9043. }
  9044. }
  9045. return false;
  9046. }
  9047. function isTSOptionalType(node, opts) {
  9048. if (!node) return false;
  9049. const nodeType = node.type;
  9050. if (nodeType === "TSOptionalType") {
  9051. if (typeof opts === "undefined") {
  9052. return true;
  9053. } else {
  9054. return (0, shallowEqual_1.default)(node, opts);
  9055. }
  9056. }
  9057. return false;
  9058. }
  9059. function isTSRestType(node, opts) {
  9060. if (!node) return false;
  9061. const nodeType = node.type;
  9062. if (nodeType === "TSRestType") {
  9063. if (typeof opts === "undefined") {
  9064. return true;
  9065. } else {
  9066. return (0, shallowEqual_1.default)(node, opts);
  9067. }
  9068. }
  9069. return false;
  9070. }
  9071. function isTSNamedTupleMember(node, opts) {
  9072. if (!node) return false;
  9073. const nodeType = node.type;
  9074. if (nodeType === "TSNamedTupleMember") {
  9075. if (typeof opts === "undefined") {
  9076. return true;
  9077. } else {
  9078. return (0, shallowEqual_1.default)(node, opts);
  9079. }
  9080. }
  9081. return false;
  9082. }
  9083. function isTSUnionType(node, opts) {
  9084. if (!node) return false;
  9085. const nodeType = node.type;
  9086. if (nodeType === "TSUnionType") {
  9087. if (typeof opts === "undefined") {
  9088. return true;
  9089. } else {
  9090. return (0, shallowEqual_1.default)(node, opts);
  9091. }
  9092. }
  9093. return false;
  9094. }
  9095. function isTSIntersectionType(node, opts) {
  9096. if (!node) return false;
  9097. const nodeType = node.type;
  9098. if (nodeType === "TSIntersectionType") {
  9099. if (typeof opts === "undefined") {
  9100. return true;
  9101. } else {
  9102. return (0, shallowEqual_1.default)(node, opts);
  9103. }
  9104. }
  9105. return false;
  9106. }
  9107. function isTSConditionalType(node, opts) {
  9108. if (!node) return false;
  9109. const nodeType = node.type;
  9110. if (nodeType === "TSConditionalType") {
  9111. if (typeof opts === "undefined") {
  9112. return true;
  9113. } else {
  9114. return (0, shallowEqual_1.default)(node, opts);
  9115. }
  9116. }
  9117. return false;
  9118. }
  9119. function isTSInferType(node, opts) {
  9120. if (!node) return false;
  9121. const nodeType = node.type;
  9122. if (nodeType === "TSInferType") {
  9123. if (typeof opts === "undefined") {
  9124. return true;
  9125. } else {
  9126. return (0, shallowEqual_1.default)(node, opts);
  9127. }
  9128. }
  9129. return false;
  9130. }
  9131. function isTSParenthesizedType(node, opts) {
  9132. if (!node) return false;
  9133. const nodeType = node.type;
  9134. if (nodeType === "TSParenthesizedType") {
  9135. if (typeof opts === "undefined") {
  9136. return true;
  9137. } else {
  9138. return (0, shallowEqual_1.default)(node, opts);
  9139. }
  9140. }
  9141. return false;
  9142. }
  9143. function isTSTypeOperator(node, opts) {
  9144. if (!node) return false;
  9145. const nodeType = node.type;
  9146. if (nodeType === "TSTypeOperator") {
  9147. if (typeof opts === "undefined") {
  9148. return true;
  9149. } else {
  9150. return (0, shallowEqual_1.default)(node, opts);
  9151. }
  9152. }
  9153. return false;
  9154. }
  9155. function isTSIndexedAccessType(node, opts) {
  9156. if (!node) return false;
  9157. const nodeType = node.type;
  9158. if (nodeType === "TSIndexedAccessType") {
  9159. if (typeof opts === "undefined") {
  9160. return true;
  9161. } else {
  9162. return (0, shallowEqual_1.default)(node, opts);
  9163. }
  9164. }
  9165. return false;
  9166. }
  9167. function isTSMappedType(node, opts) {
  9168. if (!node) return false;
  9169. const nodeType = node.type;
  9170. if (nodeType === "TSMappedType") {
  9171. if (typeof opts === "undefined") {
  9172. return true;
  9173. } else {
  9174. return (0, shallowEqual_1.default)(node, opts);
  9175. }
  9176. }
  9177. return false;
  9178. }
  9179. function isTSLiteralType(node, opts) {
  9180. if (!node) return false;
  9181. const nodeType = node.type;
  9182. if (nodeType === "TSLiteralType") {
  9183. if (typeof opts === "undefined") {
  9184. return true;
  9185. } else {
  9186. return (0, shallowEqual_1.default)(node, opts);
  9187. }
  9188. }
  9189. return false;
  9190. }
  9191. function isTSExpressionWithTypeArguments(node, opts) {
  9192. if (!node) return false;
  9193. const nodeType = node.type;
  9194. if (nodeType === "TSExpressionWithTypeArguments") {
  9195. if (typeof opts === "undefined") {
  9196. return true;
  9197. } else {
  9198. return (0, shallowEqual_1.default)(node, opts);
  9199. }
  9200. }
  9201. return false;
  9202. }
  9203. function isTSInterfaceDeclaration(node, opts) {
  9204. if (!node) return false;
  9205. const nodeType = node.type;
  9206. if (nodeType === "TSInterfaceDeclaration") {
  9207. if (typeof opts === "undefined") {
  9208. return true;
  9209. } else {
  9210. return (0, shallowEqual_1.default)(node, opts);
  9211. }
  9212. }
  9213. return false;
  9214. }
  9215. function isTSInterfaceBody(node, opts) {
  9216. if (!node) return false;
  9217. const nodeType = node.type;
  9218. if (nodeType === "TSInterfaceBody") {
  9219. if (typeof opts === "undefined") {
  9220. return true;
  9221. } else {
  9222. return (0, shallowEqual_1.default)(node, opts);
  9223. }
  9224. }
  9225. return false;
  9226. }
  9227. function isTSTypeAliasDeclaration(node, opts) {
  9228. if (!node) return false;
  9229. const nodeType = node.type;
  9230. if (nodeType === "TSTypeAliasDeclaration") {
  9231. if (typeof opts === "undefined") {
  9232. return true;
  9233. } else {
  9234. return (0, shallowEqual_1.default)(node, opts);
  9235. }
  9236. }
  9237. return false;
  9238. }
  9239. function isTSAsExpression(node, opts) {
  9240. if (!node) return false;
  9241. const nodeType = node.type;
  9242. if (nodeType === "TSAsExpression") {
  9243. if (typeof opts === "undefined") {
  9244. return true;
  9245. } else {
  9246. return (0, shallowEqual_1.default)(node, opts);
  9247. }
  9248. }
  9249. return false;
  9250. }
  9251. function isTSTypeAssertion(node, opts) {
  9252. if (!node) return false;
  9253. const nodeType = node.type;
  9254. if (nodeType === "TSTypeAssertion") {
  9255. if (typeof opts === "undefined") {
  9256. return true;
  9257. } else {
  9258. return (0, shallowEqual_1.default)(node, opts);
  9259. }
  9260. }
  9261. return false;
  9262. }
  9263. function isTSEnumDeclaration(node, opts) {
  9264. if (!node) return false;
  9265. const nodeType = node.type;
  9266. if (nodeType === "TSEnumDeclaration") {
  9267. if (typeof opts === "undefined") {
  9268. return true;
  9269. } else {
  9270. return (0, shallowEqual_1.default)(node, opts);
  9271. }
  9272. }
  9273. return false;
  9274. }
  9275. function isTSEnumMember(node, opts) {
  9276. if (!node) return false;
  9277. const nodeType = node.type;
  9278. if (nodeType === "TSEnumMember") {
  9279. if (typeof opts === "undefined") {
  9280. return true;
  9281. } else {
  9282. return (0, shallowEqual_1.default)(node, opts);
  9283. }
  9284. }
  9285. return false;
  9286. }
  9287. function isTSModuleDeclaration(node, opts) {
  9288. if (!node) return false;
  9289. const nodeType = node.type;
  9290. if (nodeType === "TSModuleDeclaration") {
  9291. if (typeof opts === "undefined") {
  9292. return true;
  9293. } else {
  9294. return (0, shallowEqual_1.default)(node, opts);
  9295. }
  9296. }
  9297. return false;
  9298. }
  9299. function isTSModuleBlock(node, opts) {
  9300. if (!node) return false;
  9301. const nodeType = node.type;
  9302. if (nodeType === "TSModuleBlock") {
  9303. if (typeof opts === "undefined") {
  9304. return true;
  9305. } else {
  9306. return (0, shallowEqual_1.default)(node, opts);
  9307. }
  9308. }
  9309. return false;
  9310. }
  9311. function isTSImportType(node, opts) {
  9312. if (!node) return false;
  9313. const nodeType = node.type;
  9314. if (nodeType === "TSImportType") {
  9315. if (typeof opts === "undefined") {
  9316. return true;
  9317. } else {
  9318. return (0, shallowEqual_1.default)(node, opts);
  9319. }
  9320. }
  9321. return false;
  9322. }
  9323. function isTSImportEqualsDeclaration(node, opts) {
  9324. if (!node) return false;
  9325. const nodeType = node.type;
  9326. if (nodeType === "TSImportEqualsDeclaration") {
  9327. if (typeof opts === "undefined") {
  9328. return true;
  9329. } else {
  9330. return (0, shallowEqual_1.default)(node, opts);
  9331. }
  9332. }
  9333. return false;
  9334. }
  9335. function isTSExternalModuleReference(node, opts) {
  9336. if (!node) return false;
  9337. const nodeType = node.type;
  9338. if (nodeType === "TSExternalModuleReference") {
  9339. if (typeof opts === "undefined") {
  9340. return true;
  9341. } else {
  9342. return (0, shallowEqual_1.default)(node, opts);
  9343. }
  9344. }
  9345. return false;
  9346. }
  9347. function isTSNonNullExpression(node, opts) {
  9348. if (!node) return false;
  9349. const nodeType = node.type;
  9350. if (nodeType === "TSNonNullExpression") {
  9351. if (typeof opts === "undefined") {
  9352. return true;
  9353. } else {
  9354. return (0, shallowEqual_1.default)(node, opts);
  9355. }
  9356. }
  9357. return false;
  9358. }
  9359. function isTSExportAssignment(node, opts) {
  9360. if (!node) return false;
  9361. const nodeType = node.type;
  9362. if (nodeType === "TSExportAssignment") {
  9363. if (typeof opts === "undefined") {
  9364. return true;
  9365. } else {
  9366. return (0, shallowEqual_1.default)(node, opts);
  9367. }
  9368. }
  9369. return false;
  9370. }
  9371. function isTSNamespaceExportDeclaration(node, opts) {
  9372. if (!node) return false;
  9373. const nodeType = node.type;
  9374. if (nodeType === "TSNamespaceExportDeclaration") {
  9375. if (typeof opts === "undefined") {
  9376. return true;
  9377. } else {
  9378. return (0, shallowEqual_1.default)(node, opts);
  9379. }
  9380. }
  9381. return false;
  9382. }
  9383. function isTSTypeAnnotation(node, opts) {
  9384. if (!node) return false;
  9385. const nodeType = node.type;
  9386. if (nodeType === "TSTypeAnnotation") {
  9387. if (typeof opts === "undefined") {
  9388. return true;
  9389. } else {
  9390. return (0, shallowEqual_1.default)(node, opts);
  9391. }
  9392. }
  9393. return false;
  9394. }
  9395. function isTSTypeParameterInstantiation(node, opts) {
  9396. if (!node) return false;
  9397. const nodeType = node.type;
  9398. if (nodeType === "TSTypeParameterInstantiation") {
  9399. if (typeof opts === "undefined") {
  9400. return true;
  9401. } else {
  9402. return (0, shallowEqual_1.default)(node, opts);
  9403. }
  9404. }
  9405. return false;
  9406. }
  9407. function isTSTypeParameterDeclaration(node, opts) {
  9408. if (!node) return false;
  9409. const nodeType = node.type;
  9410. if (nodeType === "TSTypeParameterDeclaration") {
  9411. if (typeof opts === "undefined") {
  9412. return true;
  9413. } else {
  9414. return (0, shallowEqual_1.default)(node, opts);
  9415. }
  9416. }
  9417. return false;
  9418. }
  9419. function isTSTypeParameter(node, opts) {
  9420. if (!node) return false;
  9421. const nodeType = node.type;
  9422. if (nodeType === "TSTypeParameter") {
  9423. if (typeof opts === "undefined") {
  9424. return true;
  9425. } else {
  9426. return (0, shallowEqual_1.default)(node, opts);
  9427. }
  9428. }
  9429. return false;
  9430. }
  9431. function isExpression(node, opts) {
  9432. if (!node) return false;
  9433. const nodeType = node.type;
  9434. if ("ArrayExpression" === nodeType || "AssignmentExpression" === nodeType || "BinaryExpression" === nodeType || "CallExpression" === nodeType || "ConditionalExpression" === nodeType || "FunctionExpression" === nodeType || "Identifier" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "LogicalExpression" === nodeType || "MemberExpression" === nodeType || "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "MetaProperty" === nodeType || "Super" === nodeType || "TaggedTemplateExpression" === nodeType || "TemplateLiteral" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType || "Import" === nodeType || "BigIntLiteral" === nodeType || "OptionalMemberExpression" === nodeType || "OptionalCallExpression" === nodeType || "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || "BindExpression" === nodeType || "DoExpression" === nodeType || "RecordExpression" === nodeType || "TupleExpression" === nodeType || "DecimalLiteral" === nodeType || "ModuleExpression" === nodeType || "TopicReference" === nodeType || "PipelineTopicExpression" === nodeType || "PipelineBareFunction" === nodeType || "PipelinePrimaryTopicReference" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType || nodeType === "Placeholder" && ("Expression" === node.expectedNode || "Identifier" === node.expectedNode || "StringLiteral" === node.expectedNode)) {
  9435. if (typeof opts === "undefined") {
  9436. return true;
  9437. } else {
  9438. return (0, shallowEqual_1.default)(node, opts);
  9439. }
  9440. }
  9441. return false;
  9442. }
  9443. function isBinary(node, opts) {
  9444. if (!node) return false;
  9445. const nodeType = node.type;
  9446. if ("BinaryExpression" === nodeType || "LogicalExpression" === nodeType) {
  9447. if (typeof opts === "undefined") {
  9448. return true;
  9449. } else {
  9450. return (0, shallowEqual_1.default)(node, opts);
  9451. }
  9452. }
  9453. return false;
  9454. }
  9455. function isScopable(node, opts) {
  9456. if (!node) return false;
  9457. const nodeType = node.type;
  9458. if ("BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
  9459. if (typeof opts === "undefined") {
  9460. return true;
  9461. } else {
  9462. return (0, shallowEqual_1.default)(node, opts);
  9463. }
  9464. }
  9465. return false;
  9466. }
  9467. function isBlockParent(node, opts) {
  9468. if (!node) return false;
  9469. const nodeType = node.type;
  9470. if ("BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "StaticBlock" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
  9471. if (typeof opts === "undefined") {
  9472. return true;
  9473. } else {
  9474. return (0, shallowEqual_1.default)(node, opts);
  9475. }
  9476. }
  9477. return false;
  9478. }
  9479. function isBlock(node, opts) {
  9480. if (!node) return false;
  9481. const nodeType = node.type;
  9482. if ("BlockStatement" === nodeType || "Program" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) {
  9483. if (typeof opts === "undefined") {
  9484. return true;
  9485. } else {
  9486. return (0, shallowEqual_1.default)(node, opts);
  9487. }
  9488. }
  9489. return false;
  9490. }
  9491. function isStatement(node, opts) {
  9492. if (!node) return false;
  9493. const nodeType = node.type;
  9494. if ("BlockStatement" === nodeType || "BreakStatement" === nodeType || "ContinueStatement" === nodeType || "DebuggerStatement" === nodeType || "DoWhileStatement" === nodeType || "EmptyStatement" === nodeType || "ExpressionStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "IfStatement" === nodeType || "LabeledStatement" === nodeType || "ReturnStatement" === nodeType || "SwitchStatement" === nodeType || "ThrowStatement" === nodeType || "TryStatement" === nodeType || "VariableDeclaration" === nodeType || "WhileStatement" === nodeType || "WithStatement" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ForOfStatement" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || "TSImportEqualsDeclaration" === nodeType || "TSExportAssignment" === nodeType || "TSNamespaceExportDeclaration" === nodeType || nodeType === "Placeholder" && ("Statement" === node.expectedNode || "Declaration" === node.expectedNode || "BlockStatement" === node.expectedNode)) {
  9495. if (typeof opts === "undefined") {
  9496. return true;
  9497. } else {
  9498. return (0, shallowEqual_1.default)(node, opts);
  9499. }
  9500. }
  9501. return false;
  9502. }
  9503. function isTerminatorless(node, opts) {
  9504. if (!node) return false;
  9505. const nodeType = node.type;
  9506. if ("BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType || "YieldExpression" === nodeType || "AwaitExpression" === nodeType) {
  9507. if (typeof opts === "undefined") {
  9508. return true;
  9509. } else {
  9510. return (0, shallowEqual_1.default)(node, opts);
  9511. }
  9512. }
  9513. return false;
  9514. }
  9515. function isCompletionStatement(node, opts) {
  9516. if (!node) return false;
  9517. const nodeType = node.type;
  9518. if ("BreakStatement" === nodeType || "ContinueStatement" === nodeType || "ReturnStatement" === nodeType || "ThrowStatement" === nodeType) {
  9519. if (typeof opts === "undefined") {
  9520. return true;
  9521. } else {
  9522. return (0, shallowEqual_1.default)(node, opts);
  9523. }
  9524. }
  9525. return false;
  9526. }
  9527. function isConditional(node, opts) {
  9528. if (!node) return false;
  9529. const nodeType = node.type;
  9530. if ("ConditionalExpression" === nodeType || "IfStatement" === nodeType) {
  9531. if (typeof opts === "undefined") {
  9532. return true;
  9533. } else {
  9534. return (0, shallowEqual_1.default)(node, opts);
  9535. }
  9536. }
  9537. return false;
  9538. }
  9539. function isLoop(node, opts) {
  9540. if (!node) return false;
  9541. const nodeType = node.type;
  9542. if ("DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "WhileStatement" === nodeType || "ForOfStatement" === nodeType) {
  9543. if (typeof opts === "undefined") {
  9544. return true;
  9545. } else {
  9546. return (0, shallowEqual_1.default)(node, opts);
  9547. }
  9548. }
  9549. return false;
  9550. }
  9551. function isWhile(node, opts) {
  9552. if (!node) return false;
  9553. const nodeType = node.type;
  9554. if ("DoWhileStatement" === nodeType || "WhileStatement" === nodeType) {
  9555. if (typeof opts === "undefined") {
  9556. return true;
  9557. } else {
  9558. return (0, shallowEqual_1.default)(node, opts);
  9559. }
  9560. }
  9561. return false;
  9562. }
  9563. function isExpressionWrapper(node, opts) {
  9564. if (!node) return false;
  9565. const nodeType = node.type;
  9566. if ("ExpressionStatement" === nodeType || "ParenthesizedExpression" === nodeType || "TypeCastExpression" === nodeType) {
  9567. if (typeof opts === "undefined") {
  9568. return true;
  9569. } else {
  9570. return (0, shallowEqual_1.default)(node, opts);
  9571. }
  9572. }
  9573. return false;
  9574. }
  9575. function isFor(node, opts) {
  9576. if (!node) return false;
  9577. const nodeType = node.type;
  9578. if ("ForInStatement" === nodeType || "ForStatement" === nodeType || "ForOfStatement" === nodeType) {
  9579. if (typeof opts === "undefined") {
  9580. return true;
  9581. } else {
  9582. return (0, shallowEqual_1.default)(node, opts);
  9583. }
  9584. }
  9585. return false;
  9586. }
  9587. function isForXStatement(node, opts) {
  9588. if (!node) return false;
  9589. const nodeType = node.type;
  9590. if ("ForInStatement" === nodeType || "ForOfStatement" === nodeType) {
  9591. if (typeof opts === "undefined") {
  9592. return true;
  9593. } else {
  9594. return (0, shallowEqual_1.default)(node, opts);
  9595. }
  9596. }
  9597. return false;
  9598. }
  9599. function isFunction$1(node, opts) {
  9600. if (!node) return false;
  9601. const nodeType = node.type;
  9602. if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
  9603. if (typeof opts === "undefined") {
  9604. return true;
  9605. } else {
  9606. return (0, shallowEqual_1.default)(node, opts);
  9607. }
  9608. }
  9609. return false;
  9610. }
  9611. function isFunctionParent(node, opts) {
  9612. if (!node) return false;
  9613. const nodeType = node.type;
  9614. if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "ObjectMethod" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
  9615. if (typeof opts === "undefined") {
  9616. return true;
  9617. } else {
  9618. return (0, shallowEqual_1.default)(node, opts);
  9619. }
  9620. }
  9621. return false;
  9622. }
  9623. function isPureish(node, opts) {
  9624. if (!node) return false;
  9625. const nodeType = node.type;
  9626. if ("FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "ArrowFunctionExpression" === nodeType || "BigIntLiteral" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
  9627. if (typeof opts === "undefined") {
  9628. return true;
  9629. } else {
  9630. return (0, shallowEqual_1.default)(node, opts);
  9631. }
  9632. }
  9633. return false;
  9634. }
  9635. function isDeclaration(node, opts) {
  9636. if (!node) return false;
  9637. const nodeType = node.type;
  9638. if ("FunctionDeclaration" === nodeType || "VariableDeclaration" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || nodeType === "Placeholder" && "Declaration" === node.expectedNode) {
  9639. if (typeof opts === "undefined") {
  9640. return true;
  9641. } else {
  9642. return (0, shallowEqual_1.default)(node, opts);
  9643. }
  9644. }
  9645. return false;
  9646. }
  9647. function isPatternLike(node, opts) {
  9648. if (!node) return false;
  9649. const nodeType = node.type;
  9650. if ("Identifier" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
  9651. if (typeof opts === "undefined") {
  9652. return true;
  9653. } else {
  9654. return (0, shallowEqual_1.default)(node, opts);
  9655. }
  9656. }
  9657. return false;
  9658. }
  9659. function isLVal(node, opts) {
  9660. if (!node) return false;
  9661. const nodeType = node.type;
  9662. if ("Identifier" === nodeType || "MemberExpression" === nodeType || "RestElement" === nodeType || "AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || "TSParameterProperty" === nodeType || nodeType === "Placeholder" && ("Pattern" === node.expectedNode || "Identifier" === node.expectedNode)) {
  9663. if (typeof opts === "undefined") {
  9664. return true;
  9665. } else {
  9666. return (0, shallowEqual_1.default)(node, opts);
  9667. }
  9668. }
  9669. return false;
  9670. }
  9671. function isTSEntityName(node, opts) {
  9672. if (!node) return false;
  9673. const nodeType = node.type;
  9674. if ("Identifier" === nodeType || "TSQualifiedName" === nodeType || nodeType === "Placeholder" && "Identifier" === node.expectedNode) {
  9675. if (typeof opts === "undefined") {
  9676. return true;
  9677. } else {
  9678. return (0, shallowEqual_1.default)(node, opts);
  9679. }
  9680. }
  9681. return false;
  9682. }
  9683. function isLiteral(node, opts) {
  9684. if (!node) return false;
  9685. const nodeType = node.type;
  9686. if ("StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "RegExpLiteral" === nodeType || "TemplateLiteral" === nodeType || "BigIntLiteral" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
  9687. if (typeof opts === "undefined") {
  9688. return true;
  9689. } else {
  9690. return (0, shallowEqual_1.default)(node, opts);
  9691. }
  9692. }
  9693. return false;
  9694. }
  9695. function isImmutable(node, opts) {
  9696. if (!node) return false;
  9697. const nodeType = node.type;
  9698. if ("StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "BigIntLiteral" === nodeType || "JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXOpeningElement" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType || "DecimalLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) {
  9699. if (typeof opts === "undefined") {
  9700. return true;
  9701. } else {
  9702. return (0, shallowEqual_1.default)(node, opts);
  9703. }
  9704. }
  9705. return false;
  9706. }
  9707. function isUserWhitespacable(node, opts) {
  9708. if (!node) return false;
  9709. const nodeType = node.type;
  9710. if ("ObjectMethod" === nodeType || "ObjectProperty" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType) {
  9711. if (typeof opts === "undefined") {
  9712. return true;
  9713. } else {
  9714. return (0, shallowEqual_1.default)(node, opts);
  9715. }
  9716. }
  9717. return false;
  9718. }
  9719. function isMethod(node, opts) {
  9720. if (!node) return false;
  9721. const nodeType = node.type;
  9722. if ("ObjectMethod" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType) {
  9723. if (typeof opts === "undefined") {
  9724. return true;
  9725. } else {
  9726. return (0, shallowEqual_1.default)(node, opts);
  9727. }
  9728. }
  9729. return false;
  9730. }
  9731. function isObjectMember(node, opts) {
  9732. if (!node) return false;
  9733. const nodeType = node.type;
  9734. if ("ObjectMethod" === nodeType || "ObjectProperty" === nodeType) {
  9735. if (typeof opts === "undefined") {
  9736. return true;
  9737. } else {
  9738. return (0, shallowEqual_1.default)(node, opts);
  9739. }
  9740. }
  9741. return false;
  9742. }
  9743. function isProperty(node, opts) {
  9744. if (!node) return false;
  9745. const nodeType = node.type;
  9746. if ("ObjectProperty" === nodeType || "ClassProperty" === nodeType || "ClassPrivateProperty" === nodeType) {
  9747. if (typeof opts === "undefined") {
  9748. return true;
  9749. } else {
  9750. return (0, shallowEqual_1.default)(node, opts);
  9751. }
  9752. }
  9753. return false;
  9754. }
  9755. function isUnaryLike(node, opts) {
  9756. if (!node) return false;
  9757. const nodeType = node.type;
  9758. if ("UnaryExpression" === nodeType || "SpreadElement" === nodeType) {
  9759. if (typeof opts === "undefined") {
  9760. return true;
  9761. } else {
  9762. return (0, shallowEqual_1.default)(node, opts);
  9763. }
  9764. }
  9765. return false;
  9766. }
  9767. function isPattern(node, opts) {
  9768. if (!node) return false;
  9769. const nodeType = node.type;
  9770. if ("AssignmentPattern" === nodeType || "ArrayPattern" === nodeType || "ObjectPattern" === nodeType || nodeType === "Placeholder" && "Pattern" === node.expectedNode) {
  9771. if (typeof opts === "undefined") {
  9772. return true;
  9773. } else {
  9774. return (0, shallowEqual_1.default)(node, opts);
  9775. }
  9776. }
  9777. return false;
  9778. }
  9779. function isClass(node, opts) {
  9780. if (!node) return false;
  9781. const nodeType = node.type;
  9782. if ("ClassExpression" === nodeType || "ClassDeclaration" === nodeType) {
  9783. if (typeof opts === "undefined") {
  9784. return true;
  9785. } else {
  9786. return (0, shallowEqual_1.default)(node, opts);
  9787. }
  9788. }
  9789. return false;
  9790. }
  9791. function isModuleDeclaration(node, opts) {
  9792. if (!node) return false;
  9793. const nodeType = node.type;
  9794. if ("ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType) {
  9795. if (typeof opts === "undefined") {
  9796. return true;
  9797. } else {
  9798. return (0, shallowEqual_1.default)(node, opts);
  9799. }
  9800. }
  9801. return false;
  9802. }
  9803. function isExportDeclaration(node, opts) {
  9804. if (!node) return false;
  9805. const nodeType = node.type;
  9806. if ("ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType) {
  9807. if (typeof opts === "undefined") {
  9808. return true;
  9809. } else {
  9810. return (0, shallowEqual_1.default)(node, opts);
  9811. }
  9812. }
  9813. return false;
  9814. }
  9815. function isModuleSpecifier(node, opts) {
  9816. if (!node) return false;
  9817. const nodeType = node.type;
  9818. if ("ExportSpecifier" === nodeType || "ImportDefaultSpecifier" === nodeType || "ImportNamespaceSpecifier" === nodeType || "ImportSpecifier" === nodeType || "ExportNamespaceSpecifier" === nodeType || "ExportDefaultSpecifier" === nodeType) {
  9819. if (typeof opts === "undefined") {
  9820. return true;
  9821. } else {
  9822. return (0, shallowEqual_1.default)(node, opts);
  9823. }
  9824. }
  9825. return false;
  9826. }
  9827. function isPrivate(node, opts) {
  9828. if (!node) return false;
  9829. const nodeType = node.type;
  9830. if ("ClassPrivateProperty" === nodeType || "ClassPrivateMethod" === nodeType || "PrivateName" === nodeType) {
  9831. if (typeof opts === "undefined") {
  9832. return true;
  9833. } else {
  9834. return (0, shallowEqual_1.default)(node, opts);
  9835. }
  9836. }
  9837. return false;
  9838. }
  9839. function isFlow(node, opts) {
  9840. if (!node) return false;
  9841. const nodeType = node.type;
  9842. if ("AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ClassImplements" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "DeclaredPredicate" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "FunctionTypeParam" === nodeType || "GenericTypeAnnotation" === nodeType || "InferredPredicate" === nodeType || "InterfaceExtends" === nodeType || "InterfaceDeclaration" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "ObjectTypeInternalSlot" === nodeType || "ObjectTypeCallProperty" === nodeType || "ObjectTypeIndexer" === nodeType || "ObjectTypeProperty" === nodeType || "ObjectTypeSpreadProperty" === nodeType || "OpaqueType" === nodeType || "QualifiedTypeIdentifier" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "TypeAlias" === nodeType || "TypeAnnotation" === nodeType || "TypeCastExpression" === nodeType || "TypeParameter" === nodeType || "TypeParameterDeclaration" === nodeType || "TypeParameterInstantiation" === nodeType || "UnionTypeAnnotation" === nodeType || "Variance" === nodeType || "VoidTypeAnnotation" === nodeType || "IndexedAccessType" === nodeType || "OptionalIndexedAccessType" === nodeType) {
  9843. if (typeof opts === "undefined") {
  9844. return true;
  9845. } else {
  9846. return (0, shallowEqual_1.default)(node, opts);
  9847. }
  9848. }
  9849. return false;
  9850. }
  9851. function isFlowType(node, opts) {
  9852. if (!node) return false;
  9853. const nodeType = node.type;
  9854. if ("AnyTypeAnnotation" === nodeType || "ArrayTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "BooleanLiteralTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "ExistsTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType || "GenericTypeAnnotation" === nodeType || "InterfaceTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NullableTypeAnnotation" === nodeType || "NumberLiteralTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "ObjectTypeAnnotation" === nodeType || "StringLiteralTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "TupleTypeAnnotation" === nodeType || "TypeofTypeAnnotation" === nodeType || "UnionTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType || "IndexedAccessType" === nodeType || "OptionalIndexedAccessType" === nodeType) {
  9855. if (typeof opts === "undefined") {
  9856. return true;
  9857. } else {
  9858. return (0, shallowEqual_1.default)(node, opts);
  9859. }
  9860. }
  9861. return false;
  9862. }
  9863. function isFlowBaseAnnotation(node, opts) {
  9864. if (!node) return false;
  9865. const nodeType = node.type;
  9866. if ("AnyTypeAnnotation" === nodeType || "BooleanTypeAnnotation" === nodeType || "NullLiteralTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType || "NumberTypeAnnotation" === nodeType || "StringTypeAnnotation" === nodeType || "SymbolTypeAnnotation" === nodeType || "ThisTypeAnnotation" === nodeType || "VoidTypeAnnotation" === nodeType) {
  9867. if (typeof opts === "undefined") {
  9868. return true;
  9869. } else {
  9870. return (0, shallowEqual_1.default)(node, opts);
  9871. }
  9872. }
  9873. return false;
  9874. }
  9875. function isFlowDeclaration(node, opts) {
  9876. if (!node) return false;
  9877. const nodeType = node.type;
  9878. if ("DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType) {
  9879. if (typeof opts === "undefined") {
  9880. return true;
  9881. } else {
  9882. return (0, shallowEqual_1.default)(node, opts);
  9883. }
  9884. }
  9885. return false;
  9886. }
  9887. function isFlowPredicate(node, opts) {
  9888. if (!node) return false;
  9889. const nodeType = node.type;
  9890. if ("DeclaredPredicate" === nodeType || "InferredPredicate" === nodeType) {
  9891. if (typeof opts === "undefined") {
  9892. return true;
  9893. } else {
  9894. return (0, shallowEqual_1.default)(node, opts);
  9895. }
  9896. }
  9897. return false;
  9898. }
  9899. function isEnumBody(node, opts) {
  9900. if (!node) return false;
  9901. const nodeType = node.type;
  9902. if ("EnumBooleanBody" === nodeType || "EnumNumberBody" === nodeType || "EnumStringBody" === nodeType || "EnumSymbolBody" === nodeType) {
  9903. if (typeof opts === "undefined") {
  9904. return true;
  9905. } else {
  9906. return (0, shallowEqual_1.default)(node, opts);
  9907. }
  9908. }
  9909. return false;
  9910. }
  9911. function isEnumMember(node, opts) {
  9912. if (!node) return false;
  9913. const nodeType = node.type;
  9914. if ("EnumBooleanMember" === nodeType || "EnumNumberMember" === nodeType || "EnumStringMember" === nodeType || "EnumDefaultedMember" === nodeType) {
  9915. if (typeof opts === "undefined") {
  9916. return true;
  9917. } else {
  9918. return (0, shallowEqual_1.default)(node, opts);
  9919. }
  9920. }
  9921. return false;
  9922. }
  9923. function isJSX(node, opts) {
  9924. if (!node) return false;
  9925. const nodeType = node.type;
  9926. if ("JSXAttribute" === nodeType || "JSXClosingElement" === nodeType || "JSXElement" === nodeType || "JSXEmptyExpression" === nodeType || "JSXExpressionContainer" === nodeType || "JSXSpreadChild" === nodeType || "JSXIdentifier" === nodeType || "JSXMemberExpression" === nodeType || "JSXNamespacedName" === nodeType || "JSXOpeningElement" === nodeType || "JSXSpreadAttribute" === nodeType || "JSXText" === nodeType || "JSXFragment" === nodeType || "JSXOpeningFragment" === nodeType || "JSXClosingFragment" === nodeType) {
  9927. if (typeof opts === "undefined") {
  9928. return true;
  9929. } else {
  9930. return (0, shallowEqual_1.default)(node, opts);
  9931. }
  9932. }
  9933. return false;
  9934. }
  9935. function isTSTypeElement(node, opts) {
  9936. if (!node) return false;
  9937. const nodeType = node.type;
  9938. if ("TSCallSignatureDeclaration" === nodeType || "TSConstructSignatureDeclaration" === nodeType || "TSPropertySignature" === nodeType || "TSMethodSignature" === nodeType || "TSIndexSignature" === nodeType) {
  9939. if (typeof opts === "undefined") {
  9940. return true;
  9941. } else {
  9942. return (0, shallowEqual_1.default)(node, opts);
  9943. }
  9944. }
  9945. return false;
  9946. }
  9947. function isTSType(node, opts) {
  9948. if (!node) return false;
  9949. const nodeType = node.type;
  9950. if ("TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSImportType" === nodeType) {
  9951. if (typeof opts === "undefined") {
  9952. return true;
  9953. } else {
  9954. return (0, shallowEqual_1.default)(node, opts);
  9955. }
  9956. }
  9957. return false;
  9958. }
  9959. function isTSBaseType(node, opts) {
  9960. if (!node) return false;
  9961. const nodeType = node.type;
  9962. if ("TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSIntrinsicKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSLiteralType" === nodeType) {
  9963. if (typeof opts === "undefined") {
  9964. return true;
  9965. } else {
  9966. return (0, shallowEqual_1.default)(node, opts);
  9967. }
  9968. }
  9969. return false;
  9970. }
  9971. function isNumberLiteral(node, opts) {
  9972. console.trace("The node type NumberLiteral has been renamed to NumericLiteral");
  9973. if (!node) return false;
  9974. const nodeType = node.type;
  9975. if (nodeType === "NumberLiteral") {
  9976. if (typeof opts === "undefined") {
  9977. return true;
  9978. } else {
  9979. return (0, shallowEqual_1.default)(node, opts);
  9980. }
  9981. }
  9982. return false;
  9983. }
  9984. function isRegexLiteral(node, opts) {
  9985. console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
  9986. if (!node) return false;
  9987. const nodeType = node.type;
  9988. if (nodeType === "RegexLiteral") {
  9989. if (typeof opts === "undefined") {
  9990. return true;
  9991. } else {
  9992. return (0, shallowEqual_1.default)(node, opts);
  9993. }
  9994. }
  9995. return false;
  9996. }
  9997. function isRestProperty(node, opts) {
  9998. console.trace("The node type RestProperty has been renamed to RestElement");
  9999. if (!node) return false;
  10000. const nodeType = node.type;
  10001. if (nodeType === "RestProperty") {
  10002. if (typeof opts === "undefined") {
  10003. return true;
  10004. } else {
  10005. return (0, shallowEqual_1.default)(node, opts);
  10006. }
  10007. }
  10008. return false;
  10009. }
  10010. function isSpreadProperty(node, opts) {
  10011. console.trace("The node type SpreadProperty has been renamed to SpreadElement");
  10012. if (!node) return false;
  10013. const nodeType = node.type;
  10014. if (nodeType === "SpreadProperty") {
  10015. if (typeof opts === "undefined") {
  10016. return true;
  10017. } else {
  10018. return (0, shallowEqual_1.default)(node, opts);
  10019. }
  10020. }
  10021. return false;
  10022. }
  10023. var generated = /*#__PURE__*/Object.defineProperty({
  10024. isArrayExpression: isArrayExpression_1,
  10025. isAssignmentExpression: isAssignmentExpression_1,
  10026. isBinaryExpression: isBinaryExpression_1,
  10027. isInterpreterDirective: isInterpreterDirective_1,
  10028. isDirective: isDirective_1,
  10029. isDirectiveLiteral: isDirectiveLiteral_1,
  10030. isBlockStatement: isBlockStatement_1,
  10031. isBreakStatement: isBreakStatement_1,
  10032. isCallExpression: isCallExpression_1,
  10033. isCatchClause: isCatchClause_1,
  10034. isConditionalExpression: isConditionalExpression_1,
  10035. isContinueStatement: isContinueStatement_1,
  10036. isDebuggerStatement: isDebuggerStatement_1,
  10037. isDoWhileStatement: isDoWhileStatement_1,
  10038. isEmptyStatement: isEmptyStatement_1,
  10039. isExpressionStatement: isExpressionStatement_1,
  10040. isFile: isFile_1,
  10041. isForInStatement: isForInStatement_1,
  10042. isForStatement: isForStatement_1,
  10043. isFunctionDeclaration: isFunctionDeclaration_1,
  10044. isFunctionExpression: isFunctionExpression_1,
  10045. isIdentifier: isIdentifier_1,
  10046. isIfStatement: isIfStatement_1,
  10047. isLabeledStatement: isLabeledStatement_1,
  10048. isStringLiteral: isStringLiteral_1,
  10049. isNumericLiteral: isNumericLiteral_1,
  10050. isNullLiteral: isNullLiteral_1,
  10051. isBooleanLiteral: isBooleanLiteral_1,
  10052. isRegExpLiteral: isRegExpLiteral_1,
  10053. isLogicalExpression: isLogicalExpression_1,
  10054. isMemberExpression: isMemberExpression_1,
  10055. isNewExpression: isNewExpression_1,
  10056. isProgram: isProgram_1,
  10057. isObjectExpression: isObjectExpression_1,
  10058. isObjectMethod: isObjectMethod_1,
  10059. isObjectProperty: isObjectProperty_1,
  10060. isRestElement: isRestElement_1,
  10061. isReturnStatement: isReturnStatement_1,
  10062. isSequenceExpression: isSequenceExpression_1,
  10063. isParenthesizedExpression: isParenthesizedExpression_1,
  10064. isSwitchCase: isSwitchCase_1,
  10065. isSwitchStatement: isSwitchStatement_1,
  10066. isThisExpression: isThisExpression_1,
  10067. isThrowStatement: isThrowStatement_1,
  10068. isTryStatement: isTryStatement_1,
  10069. isUnaryExpression: isUnaryExpression_1,
  10070. isUpdateExpression: isUpdateExpression_1,
  10071. isVariableDeclaration: isVariableDeclaration_1,
  10072. isVariableDeclarator: isVariableDeclarator_1,
  10073. isWhileStatement: isWhileStatement_1,
  10074. isWithStatement: isWithStatement_1,
  10075. isAssignmentPattern: isAssignmentPattern_1,
  10076. isArrayPattern: isArrayPattern_1,
  10077. isArrowFunctionExpression: isArrowFunctionExpression_1,
  10078. isClassBody: isClassBody_1,
  10079. isClassExpression: isClassExpression_1,
  10080. isClassDeclaration: isClassDeclaration_1,
  10081. isExportAllDeclaration: isExportAllDeclaration_1,
  10082. isExportDefaultDeclaration: isExportDefaultDeclaration_1,
  10083. isExportNamedDeclaration: isExportNamedDeclaration_1,
  10084. isExportSpecifier: isExportSpecifier_1,
  10085. isForOfStatement: isForOfStatement_1,
  10086. isImportDeclaration: isImportDeclaration_1,
  10087. isImportDefaultSpecifier: isImportDefaultSpecifier_1,
  10088. isImportNamespaceSpecifier: isImportNamespaceSpecifier_1,
  10089. isImportSpecifier: isImportSpecifier_1,
  10090. isMetaProperty: isMetaProperty_1,
  10091. isClassMethod: isClassMethod_1,
  10092. isObjectPattern: isObjectPattern_1,
  10093. isSpreadElement: isSpreadElement_1,
  10094. isSuper: isSuper_1,
  10095. isTaggedTemplateExpression: isTaggedTemplateExpression_1,
  10096. isTemplateElement: isTemplateElement_1,
  10097. isTemplateLiteral: isTemplateLiteral_1,
  10098. isYieldExpression: isYieldExpression_1,
  10099. isAwaitExpression: isAwaitExpression_1,
  10100. isImport: isImport_1,
  10101. isBigIntLiteral: isBigIntLiteral_1,
  10102. isExportNamespaceSpecifier: isExportNamespaceSpecifier_1,
  10103. isOptionalMemberExpression: isOptionalMemberExpression_1,
  10104. isOptionalCallExpression: isOptionalCallExpression_1,
  10105. isClassProperty: isClassProperty_1,
  10106. isClassPrivateProperty: isClassPrivateProperty_1,
  10107. isClassPrivateMethod: isClassPrivateMethod_1,
  10108. isPrivateName: isPrivateName_1,
  10109. isAnyTypeAnnotation: isAnyTypeAnnotation_1,
  10110. isArrayTypeAnnotation: isArrayTypeAnnotation_1,
  10111. isBooleanTypeAnnotation: isBooleanTypeAnnotation_1,
  10112. isBooleanLiteralTypeAnnotation: isBooleanLiteralTypeAnnotation_1,
  10113. isNullLiteralTypeAnnotation: isNullLiteralTypeAnnotation_1,
  10114. isClassImplements: isClassImplements_1,
  10115. isDeclareClass: isDeclareClass_1,
  10116. isDeclareFunction: isDeclareFunction_1,
  10117. isDeclareInterface: isDeclareInterface_1,
  10118. isDeclareModule: isDeclareModule_1,
  10119. isDeclareModuleExports: isDeclareModuleExports_1,
  10120. isDeclareTypeAlias: isDeclareTypeAlias_1,
  10121. isDeclareOpaqueType: isDeclareOpaqueType_1,
  10122. isDeclareVariable: isDeclareVariable_1,
  10123. isDeclareExportDeclaration: isDeclareExportDeclaration_1,
  10124. isDeclareExportAllDeclaration: isDeclareExportAllDeclaration_1,
  10125. isDeclaredPredicate: isDeclaredPredicate_1,
  10126. isExistsTypeAnnotation: isExistsTypeAnnotation_1,
  10127. isFunctionTypeAnnotation: isFunctionTypeAnnotation_1,
  10128. isFunctionTypeParam: isFunctionTypeParam_1,
  10129. isGenericTypeAnnotation: isGenericTypeAnnotation_1,
  10130. isInferredPredicate: isInferredPredicate_1,
  10131. isInterfaceExtends: isInterfaceExtends_1,
  10132. isInterfaceDeclaration: isInterfaceDeclaration_1,
  10133. isInterfaceTypeAnnotation: isInterfaceTypeAnnotation_1,
  10134. isIntersectionTypeAnnotation: isIntersectionTypeAnnotation_1,
  10135. isMixedTypeAnnotation: isMixedTypeAnnotation_1,
  10136. isEmptyTypeAnnotation: isEmptyTypeAnnotation_1,
  10137. isNullableTypeAnnotation: isNullableTypeAnnotation_1,
  10138. isNumberLiteralTypeAnnotation: isNumberLiteralTypeAnnotation_1,
  10139. isNumberTypeAnnotation: isNumberTypeAnnotation_1,
  10140. isObjectTypeAnnotation: isObjectTypeAnnotation_1,
  10141. isObjectTypeInternalSlot: isObjectTypeInternalSlot_1,
  10142. isObjectTypeCallProperty: isObjectTypeCallProperty_1,
  10143. isObjectTypeIndexer: isObjectTypeIndexer_1,
  10144. isObjectTypeProperty: isObjectTypeProperty_1,
  10145. isObjectTypeSpreadProperty: isObjectTypeSpreadProperty_1,
  10146. isOpaqueType: isOpaqueType_1,
  10147. isQualifiedTypeIdentifier: isQualifiedTypeIdentifier_1,
  10148. isStringLiteralTypeAnnotation: isStringLiteralTypeAnnotation_1,
  10149. isStringTypeAnnotation: isStringTypeAnnotation_1,
  10150. isSymbolTypeAnnotation: isSymbolTypeAnnotation_1,
  10151. isThisTypeAnnotation: isThisTypeAnnotation_1,
  10152. isTupleTypeAnnotation: isTupleTypeAnnotation_1,
  10153. isTypeofTypeAnnotation: isTypeofTypeAnnotation_1,
  10154. isTypeAlias: isTypeAlias_1,
  10155. isTypeAnnotation: isTypeAnnotation_1,
  10156. isTypeCastExpression: isTypeCastExpression_1,
  10157. isTypeParameter: isTypeParameter_1,
  10158. isTypeParameterDeclaration: isTypeParameterDeclaration_1,
  10159. isTypeParameterInstantiation: isTypeParameterInstantiation_1,
  10160. isUnionTypeAnnotation: isUnionTypeAnnotation_1,
  10161. isVariance: isVariance_1,
  10162. isVoidTypeAnnotation: isVoidTypeAnnotation_1,
  10163. isEnumDeclaration: isEnumDeclaration_1,
  10164. isEnumBooleanBody: isEnumBooleanBody_1,
  10165. isEnumNumberBody: isEnumNumberBody_1,
  10166. isEnumStringBody: isEnumStringBody_1,
  10167. isEnumSymbolBody: isEnumSymbolBody_1,
  10168. isEnumBooleanMember: isEnumBooleanMember_1,
  10169. isEnumNumberMember: isEnumNumberMember_1,
  10170. isEnumStringMember: isEnumStringMember_1,
  10171. isEnumDefaultedMember: isEnumDefaultedMember_1,
  10172. isIndexedAccessType: isIndexedAccessType_1,
  10173. isOptionalIndexedAccessType: isOptionalIndexedAccessType_1,
  10174. isJSXAttribute: isJSXAttribute_1,
  10175. isJSXClosingElement: isJSXClosingElement_1,
  10176. isJSXElement: isJSXElement_1,
  10177. isJSXEmptyExpression: isJSXEmptyExpression_1,
  10178. isJSXExpressionContainer: isJSXExpressionContainer_1,
  10179. isJSXSpreadChild: isJSXSpreadChild_1,
  10180. isJSXIdentifier: isJSXIdentifier_1,
  10181. isJSXMemberExpression: isJSXMemberExpression_1,
  10182. isJSXNamespacedName: isJSXNamespacedName_1,
  10183. isJSXOpeningElement: isJSXOpeningElement_1,
  10184. isJSXSpreadAttribute: isJSXSpreadAttribute_1,
  10185. isJSXText: isJSXText_1,
  10186. isJSXFragment: isJSXFragment_1,
  10187. isJSXOpeningFragment: isJSXOpeningFragment_1,
  10188. isJSXClosingFragment: isJSXClosingFragment_1,
  10189. isNoop: isNoop_1,
  10190. isPlaceholder: isPlaceholder_1,
  10191. isV8IntrinsicIdentifier: isV8IntrinsicIdentifier_1,
  10192. isArgumentPlaceholder: isArgumentPlaceholder_1,
  10193. isBindExpression: isBindExpression_1,
  10194. isImportAttribute: isImportAttribute_1,
  10195. isDecorator: isDecorator_1,
  10196. isDoExpression: isDoExpression_1,
  10197. isExportDefaultSpecifier: isExportDefaultSpecifier_1,
  10198. isRecordExpression: isRecordExpression_1,
  10199. isTupleExpression: isTupleExpression_1,
  10200. isDecimalLiteral: isDecimalLiteral_1,
  10201. isStaticBlock: isStaticBlock_1,
  10202. isModuleExpression: isModuleExpression_1,
  10203. isTopicReference: isTopicReference_1,
  10204. isPipelineTopicExpression: isPipelineTopicExpression_1,
  10205. isPipelineBareFunction: isPipelineBareFunction_1,
  10206. isPipelinePrimaryTopicReference: isPipelinePrimaryTopicReference_1,
  10207. isTSParameterProperty: isTSParameterProperty_1,
  10208. isTSDeclareFunction: isTSDeclareFunction_1,
  10209. isTSDeclareMethod: isTSDeclareMethod_1,
  10210. isTSQualifiedName: isTSQualifiedName_1,
  10211. isTSCallSignatureDeclaration: isTSCallSignatureDeclaration_1,
  10212. isTSConstructSignatureDeclaration: isTSConstructSignatureDeclaration_1,
  10213. isTSPropertySignature: isTSPropertySignature_1,
  10214. isTSMethodSignature: isTSMethodSignature_1,
  10215. isTSIndexSignature: isTSIndexSignature_1,
  10216. isTSAnyKeyword: isTSAnyKeyword_1,
  10217. isTSBooleanKeyword: isTSBooleanKeyword_1,
  10218. isTSBigIntKeyword: isTSBigIntKeyword_1,
  10219. isTSIntrinsicKeyword: isTSIntrinsicKeyword_1,
  10220. isTSNeverKeyword: isTSNeverKeyword_1,
  10221. isTSNullKeyword: isTSNullKeyword_1,
  10222. isTSNumberKeyword: isTSNumberKeyword_1,
  10223. isTSObjectKeyword: isTSObjectKeyword_1,
  10224. isTSStringKeyword: isTSStringKeyword_1,
  10225. isTSSymbolKeyword: isTSSymbolKeyword_1,
  10226. isTSUndefinedKeyword: isTSUndefinedKeyword_1,
  10227. isTSUnknownKeyword: isTSUnknownKeyword_1,
  10228. isTSVoidKeyword: isTSVoidKeyword_1,
  10229. isTSThisType: isTSThisType_1,
  10230. isTSFunctionType: isTSFunctionType_1,
  10231. isTSConstructorType: isTSConstructorType_1,
  10232. isTSTypeReference: isTSTypeReference_1,
  10233. isTSTypePredicate: isTSTypePredicate_1,
  10234. isTSTypeQuery: isTSTypeQuery_1,
  10235. isTSTypeLiteral: isTSTypeLiteral_1,
  10236. isTSArrayType: isTSArrayType_1,
  10237. isTSTupleType: isTSTupleType_1,
  10238. isTSOptionalType: isTSOptionalType_1,
  10239. isTSRestType: isTSRestType_1,
  10240. isTSNamedTupleMember: isTSNamedTupleMember_1,
  10241. isTSUnionType: isTSUnionType_1,
  10242. isTSIntersectionType: isTSIntersectionType_1,
  10243. isTSConditionalType: isTSConditionalType_1,
  10244. isTSInferType: isTSInferType_1,
  10245. isTSParenthesizedType: isTSParenthesizedType_1,
  10246. isTSTypeOperator: isTSTypeOperator_1,
  10247. isTSIndexedAccessType: isTSIndexedAccessType_1,
  10248. isTSMappedType: isTSMappedType_1,
  10249. isTSLiteralType: isTSLiteralType_1,
  10250. isTSExpressionWithTypeArguments: isTSExpressionWithTypeArguments_1,
  10251. isTSInterfaceDeclaration: isTSInterfaceDeclaration_1,
  10252. isTSInterfaceBody: isTSInterfaceBody_1,
  10253. isTSTypeAliasDeclaration: isTSTypeAliasDeclaration_1,
  10254. isTSAsExpression: isTSAsExpression_1,
  10255. isTSTypeAssertion: isTSTypeAssertion_1,
  10256. isTSEnumDeclaration: isTSEnumDeclaration_1,
  10257. isTSEnumMember: isTSEnumMember_1,
  10258. isTSModuleDeclaration: isTSModuleDeclaration_1,
  10259. isTSModuleBlock: isTSModuleBlock_1,
  10260. isTSImportType: isTSImportType_1,
  10261. isTSImportEqualsDeclaration: isTSImportEqualsDeclaration_1,
  10262. isTSExternalModuleReference: isTSExternalModuleReference_1,
  10263. isTSNonNullExpression: isTSNonNullExpression_1,
  10264. isTSExportAssignment: isTSExportAssignment_1,
  10265. isTSNamespaceExportDeclaration: isTSNamespaceExportDeclaration_1,
  10266. isTSTypeAnnotation: isTSTypeAnnotation_1,
  10267. isTSTypeParameterInstantiation: isTSTypeParameterInstantiation_1,
  10268. isTSTypeParameterDeclaration: isTSTypeParameterDeclaration_1,
  10269. isTSTypeParameter: isTSTypeParameter_1,
  10270. isExpression: isExpression_1,
  10271. isBinary: isBinary_1,
  10272. isScopable: isScopable_1,
  10273. isBlockParent: isBlockParent_1,
  10274. isBlock: isBlock_1,
  10275. isStatement: isStatement_1,
  10276. isTerminatorless: isTerminatorless_1,
  10277. isCompletionStatement: isCompletionStatement_1,
  10278. isConditional: isConditional_1,
  10279. isLoop: isLoop_1,
  10280. isWhile: isWhile_1,
  10281. isExpressionWrapper: isExpressionWrapper_1,
  10282. isFor: isFor_1,
  10283. isForXStatement: isForXStatement_1,
  10284. isFunction: isFunction_1,
  10285. isFunctionParent: isFunctionParent_1,
  10286. isPureish: isPureish_1,
  10287. isDeclaration: isDeclaration_1,
  10288. isPatternLike: isPatternLike_1,
  10289. isLVal: isLVal_1,
  10290. isTSEntityName: isTSEntityName_1,
  10291. isLiteral: isLiteral_1,
  10292. isImmutable: isImmutable_1,
  10293. isUserWhitespacable: isUserWhitespacable_1,
  10294. isMethod: isMethod_1,
  10295. isObjectMember: isObjectMember_1,
  10296. isProperty: isProperty_1,
  10297. isUnaryLike: isUnaryLike_1,
  10298. isPattern: isPattern_1,
  10299. isClass: isClass_1,
  10300. isModuleDeclaration: isModuleDeclaration_1,
  10301. isExportDeclaration: isExportDeclaration_1,
  10302. isModuleSpecifier: isModuleSpecifier_1,
  10303. isPrivate: isPrivate_1,
  10304. isFlow: isFlow_1,
  10305. isFlowType: isFlowType_1,
  10306. isFlowBaseAnnotation: isFlowBaseAnnotation_1,
  10307. isFlowDeclaration: isFlowDeclaration_1,
  10308. isFlowPredicate: isFlowPredicate_1,
  10309. isEnumBody: isEnumBody_1,
  10310. isEnumMember: isEnumMember_1,
  10311. isJSX: isJSX_1,
  10312. isTSTypeElement: isTSTypeElement_1,
  10313. isTSType: isTSType_1,
  10314. isTSBaseType: isTSBaseType_1,
  10315. isNumberLiteral: isNumberLiteral_1,
  10316. isRegexLiteral: isRegexLiteral_1,
  10317. isRestProperty: isRestProperty_1,
  10318. isSpreadProperty: isSpreadProperty_1
  10319. }, '__esModule', {value: true});
  10320. var _default$1 = matchesPattern;
  10321. function matchesPattern(member, match, allowPartial) {
  10322. if (!(0, generated.isMemberExpression)(member)) return false;
  10323. const parts = Array.isArray(match) ? match : match.split(".");
  10324. const nodes = [];
  10325. let node;
  10326. for (node = member; (0, generated.isMemberExpression)(node); node = node.object) {
  10327. nodes.push(node.property);
  10328. }
  10329. nodes.push(node);
  10330. if (nodes.length < parts.length) return false;
  10331. if (!allowPartial && nodes.length > parts.length) return false;
  10332. for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) {
  10333. const node = nodes[j];
  10334. let value;
  10335. if ((0, generated.isIdentifier)(node)) {
  10336. value = node.name;
  10337. } else if ((0, generated.isStringLiteral)(node)) {
  10338. value = node.value;
  10339. } else if ((0, generated.isThisExpression)(node)) {
  10340. value = "this";
  10341. } else {
  10342. return false;
  10343. }
  10344. if (parts[i] !== value) return false;
  10345. }
  10346. return true;
  10347. }
  10348. var matchesPattern_1 = /*#__PURE__*/Object.defineProperty({
  10349. default: _default$1
  10350. }, '__esModule', {value: true});
  10351. var _default$2 = buildMatchMemberExpression;
  10352. function buildMatchMemberExpression(match, allowPartial) {
  10353. const parts = match.split(".");
  10354. return member => (0, matchesPattern_1.default)(member, parts, allowPartial);
  10355. }
  10356. var buildMatchMemberExpression_1 = /*#__PURE__*/Object.defineProperty({
  10357. default: _default$2
  10358. }, '__esModule', {value: true});
  10359. var isReactComponent_1 = createCommonjsModule(function (module, exports) {
  10360. Object.defineProperty(exports, "__esModule", {
  10361. value: true
  10362. });
  10363. exports.default = void 0;
  10364. const isReactComponent = (0, buildMatchMemberExpression_1.default)("React.Component");
  10365. var _default = isReactComponent;
  10366. exports.default = _default;
  10367. });
  10368. var _default$3 = isCompatTag;
  10369. function isCompatTag(tagName) {
  10370. return !!tagName && /^[a-z]/.test(tagName);
  10371. }
  10372. var isCompatTag_1 = /*#__PURE__*/Object.defineProperty({
  10373. default: _default$3
  10374. }, '__esModule', {value: true});
  10375. let fastProto = null;
  10376. // Creates an object with permanently fast properties in V8. See Toon Verwaest's
  10377. // post https://medium.com/@tverwaes/setting-up-prototypes-in-v8-ec9c9491dfe2#5f62
  10378. // for more details. Use %HasFastProperties(object) and the Node.js flag
  10379. // --allow-natives-syntax to check whether an object has fast properties.
  10380. function FastObject(o) {
  10381. // A prototype object will have "fast properties" enabled once it is checked
  10382. // against the inline property cache of a function, e.g. fastProto.property:
  10383. // https://github.com/v8/v8/blob/6.0.122/test/mjsunit/fast-prototype.js#L48-L63
  10384. if (fastProto !== null && typeof fastProto.property) {
  10385. const result = fastProto;
  10386. fastProto = FastObject.prototype = null;
  10387. return result;
  10388. }
  10389. fastProto = FastObject.prototype = o == null ? Object.create(null) : o;
  10390. return new FastObject;
  10391. }
  10392. // Initialize the inline property cache of FastObject
  10393. FastObject();
  10394. var toFastProperties = function toFastproperties(o) {
  10395. return FastObject(o);
  10396. };
  10397. var global = (typeof global !== "undefined" ? global :
  10398. typeof self !== "undefined" ? self :
  10399. typeof window !== "undefined" ? window : {});
  10400. // shim for using process in browser
  10401. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  10402. function defaultSetTimout() {
  10403. throw new Error('setTimeout has not been defined');
  10404. }
  10405. function defaultClearTimeout () {
  10406. throw new Error('clearTimeout has not been defined');
  10407. }
  10408. var cachedSetTimeout = defaultSetTimout;
  10409. var cachedClearTimeout = defaultClearTimeout;
  10410. if (typeof global.setTimeout === 'function') {
  10411. cachedSetTimeout = setTimeout;
  10412. }
  10413. if (typeof global.clearTimeout === 'function') {
  10414. cachedClearTimeout = clearTimeout;
  10415. }
  10416. function runTimeout(fun) {
  10417. if (cachedSetTimeout === setTimeout) {
  10418. //normal enviroments in sane situations
  10419. return setTimeout(fun, 0);
  10420. }
  10421. // if setTimeout wasn't available but was latter defined
  10422. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  10423. cachedSetTimeout = setTimeout;
  10424. return setTimeout(fun, 0);
  10425. }
  10426. try {
  10427. // when when somebody has screwed with setTimeout but no I.E. maddness
  10428. return cachedSetTimeout(fun, 0);
  10429. } catch(e){
  10430. try {
  10431. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  10432. return cachedSetTimeout.call(null, fun, 0);
  10433. } catch(e){
  10434. // 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
  10435. return cachedSetTimeout.call(this, fun, 0);
  10436. }
  10437. }
  10438. }
  10439. function runClearTimeout(marker) {
  10440. if (cachedClearTimeout === clearTimeout) {
  10441. //normal enviroments in sane situations
  10442. return clearTimeout(marker);
  10443. }
  10444. // if clearTimeout wasn't available but was latter defined
  10445. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  10446. cachedClearTimeout = clearTimeout;
  10447. return clearTimeout(marker);
  10448. }
  10449. try {
  10450. // when when somebody has screwed with setTimeout but no I.E. maddness
  10451. return cachedClearTimeout(marker);
  10452. } catch (e){
  10453. try {
  10454. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  10455. return cachedClearTimeout.call(null, marker);
  10456. } catch (e){
  10457. // 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.
  10458. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  10459. return cachedClearTimeout.call(this, marker);
  10460. }
  10461. }
  10462. }
  10463. var queue = [];
  10464. var draining = false;
  10465. var currentQueue;
  10466. var queueIndex = -1;
  10467. function cleanUpNextTick() {
  10468. if (!draining || !currentQueue) {
  10469. return;
  10470. }
  10471. draining = false;
  10472. if (currentQueue.length) {
  10473. queue = currentQueue.concat(queue);
  10474. } else {
  10475. queueIndex = -1;
  10476. }
  10477. if (queue.length) {
  10478. drainQueue();
  10479. }
  10480. }
  10481. function drainQueue() {
  10482. if (draining) {
  10483. return;
  10484. }
  10485. var timeout = runTimeout(cleanUpNextTick);
  10486. draining = true;
  10487. var len = queue.length;
  10488. while(len) {
  10489. currentQueue = queue;
  10490. queue = [];
  10491. while (++queueIndex < len) {
  10492. if (currentQueue) {
  10493. currentQueue[queueIndex].run();
  10494. }
  10495. }
  10496. queueIndex = -1;
  10497. len = queue.length;
  10498. }
  10499. currentQueue = null;
  10500. draining = false;
  10501. runClearTimeout(timeout);
  10502. }
  10503. function nextTick(fun) {
  10504. var args = new Array(arguments.length - 1);
  10505. if (arguments.length > 1) {
  10506. for (var i = 1; i < arguments.length; i++) {
  10507. args[i - 1] = arguments[i];
  10508. }
  10509. }
  10510. queue.push(new Item(fun, args));
  10511. if (queue.length === 1 && !draining) {
  10512. runTimeout(drainQueue);
  10513. }
  10514. }
  10515. // v8 likes predictible objects
  10516. function Item(fun, array) {
  10517. this.fun = fun;
  10518. this.array = array;
  10519. }
  10520. Item.prototype.run = function () {
  10521. this.fun.apply(null, this.array);
  10522. };
  10523. var title = 'browser';
  10524. var platform = 'browser';
  10525. var browser = true;
  10526. var env = {};
  10527. var argv = [];
  10528. var version = ''; // empty string to avoid regexp issues
  10529. var versions = {};
  10530. var release = {};
  10531. var config = {};
  10532. function noop() {}
  10533. var on = noop;
  10534. var addListener = noop;
  10535. var once = noop;
  10536. var off = noop;
  10537. var removeListener = noop;
  10538. var removeAllListeners = noop;
  10539. var emit = noop;
  10540. function binding(name) {
  10541. throw new Error('process.binding is not supported');
  10542. }
  10543. function cwd () { return '/' }
  10544. function chdir (dir) {
  10545. throw new Error('process.chdir is not supported');
  10546. }function umask() { return 0; }
  10547. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  10548. var performance = global.performance || {};
  10549. var performanceNow =
  10550. performance.now ||
  10551. performance.mozNow ||
  10552. performance.msNow ||
  10553. performance.oNow ||
  10554. performance.webkitNow ||
  10555. function(){ return (new Date()).getTime() };
  10556. // generate timestamp or delta
  10557. // see http://nodejs.org/api/process.html#process_process_hrtime
  10558. function hrtime(previousTimestamp){
  10559. var clocktime = performanceNow.call(performance)*1e-3;
  10560. var seconds = Math.floor(clocktime);
  10561. var nanoseconds = Math.floor((clocktime%1)*1e9);
  10562. if (previousTimestamp) {
  10563. seconds = seconds - previousTimestamp[0];
  10564. nanoseconds = nanoseconds - previousTimestamp[1];
  10565. if (nanoseconds<0) {
  10566. seconds--;
  10567. nanoseconds += 1e9;
  10568. }
  10569. }
  10570. return [seconds,nanoseconds]
  10571. }
  10572. var startTime = new Date();
  10573. function uptime() {
  10574. var currentTime = new Date();
  10575. var dif = currentTime - startTime;
  10576. return dif / 1000;
  10577. }
  10578. var browser$1 = {
  10579. nextTick: nextTick,
  10580. title: title,
  10581. browser: browser,
  10582. env: env,
  10583. argv: argv,
  10584. version: version,
  10585. versions: versions,
  10586. on: on,
  10587. addListener: addListener,
  10588. once: once,
  10589. off: off,
  10590. removeListener: removeListener,
  10591. removeAllListeners: removeAllListeners,
  10592. emit: emit,
  10593. binding: binding,
  10594. cwd: cwd,
  10595. chdir: chdir,
  10596. umask: umask,
  10597. hrtime: hrtime,
  10598. platform: platform,
  10599. release: release,
  10600. config: config,
  10601. uptime: uptime
  10602. };
  10603. var _default$4 = isType;
  10604. function isType(nodeType, targetType) {
  10605. if (nodeType === targetType) return true;
  10606. if (definitions.ALIAS_KEYS[targetType]) return false;
  10607. const aliases = definitions.FLIPPED_ALIAS_KEYS[targetType];
  10608. if (aliases) {
  10609. if (aliases[0] === nodeType) return true;
  10610. for (const alias of aliases) {
  10611. if (nodeType === alias) return true;
  10612. }
  10613. }
  10614. return false;
  10615. }
  10616. var isType_1 = /*#__PURE__*/Object.defineProperty({
  10617. default: _default$4
  10618. }, '__esModule', {value: true});
  10619. var _default$5 = isPlaceholderType;
  10620. function isPlaceholderType(placeholderType, targetType) {
  10621. if (placeholderType === targetType) return true;
  10622. const aliases = definitions.PLACEHOLDERS_ALIAS[placeholderType];
  10623. if (aliases) {
  10624. for (const alias of aliases) {
  10625. if (targetType === alias) return true;
  10626. }
  10627. }
  10628. return false;
  10629. }
  10630. var isPlaceholderType_1 = /*#__PURE__*/Object.defineProperty({
  10631. default: _default$5
  10632. }, '__esModule', {value: true});
  10633. var _default$6 = is;
  10634. function is(type, node, opts) {
  10635. if (!node) return false;
  10636. const matches = (0, isType_1.default)(node.type, type);
  10637. if (!matches) {
  10638. if (!opts && node.type === "Placeholder" && type in definitions.FLIPPED_ALIAS_KEYS) {
  10639. return (0, isPlaceholderType_1.default)(node.expectedNode, type);
  10640. }
  10641. return false;
  10642. }
  10643. if (typeof opts === "undefined") {
  10644. return true;
  10645. } else {
  10646. return (0, shallowEqual_1.default)(node, opts);
  10647. }
  10648. }
  10649. var is_1 = /*#__PURE__*/Object.defineProperty({
  10650. default: _default$6
  10651. }, '__esModule', {value: true});
  10652. var isIdentifierStart_1 = isIdentifierStart;
  10653. var isIdentifierChar_1 = isIdentifierChar;
  10654. var isIdentifierName_1 = isIdentifierName;
  10655. 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\u08a0-\u08b4\u08b6-\u08c7\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\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\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-\u170c\u170e-\u1711\u1720-\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-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\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-\u2c2e\u2c30-\u2c5e\u2c60-\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-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\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";
  10656. let nonASCIIidentifierChars = "\u200c\u200d\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\u08d3-\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\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\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-\u0ecd\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-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\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-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\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";
  10657. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  10658. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  10659. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  10660. 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, 157, 310, 10, 21, 11, 7, 153, 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, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 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, 85, 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, 159, 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, 230, 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, 35, 56, 264, 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, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 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, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 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, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
  10661. 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, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 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, 406, 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, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 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, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  10662. function isInAstralSet(code, set) {
  10663. let pos = 0x10000;
  10664. for (let i = 0, length = set.length; i < length; i += 2) {
  10665. pos += set[i];
  10666. if (pos > code) return false;
  10667. pos += set[i + 1];
  10668. if (pos >= code) return true;
  10669. }
  10670. return false;
  10671. }
  10672. function isIdentifierStart(code) {
  10673. if (code < 65) return code === 36;
  10674. if (code <= 90) return true;
  10675. if (code < 97) return code === 95;
  10676. if (code <= 122) return true;
  10677. if (code <= 0xffff) {
  10678. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  10679. }
  10680. return isInAstralSet(code, astralIdentifierStartCodes);
  10681. }
  10682. function isIdentifierChar(code) {
  10683. if (code < 48) return code === 36;
  10684. if (code < 58) return true;
  10685. if (code < 65) return false;
  10686. if (code <= 90) return true;
  10687. if (code < 97) return code === 95;
  10688. if (code <= 122) return true;
  10689. if (code <= 0xffff) {
  10690. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  10691. }
  10692. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  10693. }
  10694. function isIdentifierName(name) {
  10695. let isFirst = true;
  10696. for (let i = 0; i < name.length; i++) {
  10697. let cp = name.charCodeAt(i);
  10698. if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) {
  10699. const trail = name.charCodeAt(++i);
  10700. if ((trail & 0xfc00) === 0xdc00) {
  10701. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  10702. }
  10703. }
  10704. if (isFirst) {
  10705. isFirst = false;
  10706. if (!isIdentifierStart(cp)) {
  10707. return false;
  10708. }
  10709. } else if (!isIdentifierChar(cp)) {
  10710. return false;
  10711. }
  10712. }
  10713. return !isFirst;
  10714. }
  10715. var identifier = /*#__PURE__*/Object.defineProperty({
  10716. isIdentifierStart: isIdentifierStart_1,
  10717. isIdentifierChar: isIdentifierChar_1,
  10718. isIdentifierName: isIdentifierName_1
  10719. }, '__esModule', {value: true});
  10720. var isReservedWord_1 = isReservedWord;
  10721. var isStrictReservedWord_1 = isStrictReservedWord;
  10722. var isStrictBindOnlyReservedWord_1 = isStrictBindOnlyReservedWord;
  10723. var isStrictBindReservedWord_1 = isStrictBindReservedWord;
  10724. var isKeyword_1 = isKeyword;
  10725. const reservedWords = {
  10726. 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"],
  10727. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  10728. strictBind: ["eval", "arguments"]
  10729. };
  10730. const keywords = new Set(reservedWords.keyword);
  10731. const reservedWordsStrictSet = new Set(reservedWords.strict);
  10732. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  10733. function isReservedWord(word, inModule) {
  10734. return inModule && word === "await" || word === "enum";
  10735. }
  10736. function isStrictReservedWord(word, inModule) {
  10737. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  10738. }
  10739. function isStrictBindOnlyReservedWord(word) {
  10740. return reservedWordsStrictBindSet.has(word);
  10741. }
  10742. function isStrictBindReservedWord(word, inModule) {
  10743. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  10744. }
  10745. function isKeyword(word) {
  10746. return keywords.has(word);
  10747. }
  10748. var keyword = /*#__PURE__*/Object.defineProperty({
  10749. isReservedWord: isReservedWord_1,
  10750. isStrictReservedWord: isStrictReservedWord_1,
  10751. isStrictBindOnlyReservedWord: isStrictBindOnlyReservedWord_1,
  10752. isStrictBindReservedWord: isStrictBindReservedWord_1,
  10753. isKeyword: isKeyword_1
  10754. }, '__esModule', {value: true});
  10755. var lib = createCommonjsModule(function (module, exports) {
  10756. Object.defineProperty(exports, "__esModule", {
  10757. value: true
  10758. });
  10759. Object.defineProperty(exports, "isIdentifierName", {
  10760. enumerable: true,
  10761. get: function () {
  10762. return identifier.isIdentifierName;
  10763. }
  10764. });
  10765. Object.defineProperty(exports, "isIdentifierChar", {
  10766. enumerable: true,
  10767. get: function () {
  10768. return identifier.isIdentifierChar;
  10769. }
  10770. });
  10771. Object.defineProperty(exports, "isIdentifierStart", {
  10772. enumerable: true,
  10773. get: function () {
  10774. return identifier.isIdentifierStart;
  10775. }
  10776. });
  10777. Object.defineProperty(exports, "isReservedWord", {
  10778. enumerable: true,
  10779. get: function () {
  10780. return keyword.isReservedWord;
  10781. }
  10782. });
  10783. Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
  10784. enumerable: true,
  10785. get: function () {
  10786. return keyword.isStrictBindOnlyReservedWord;
  10787. }
  10788. });
  10789. Object.defineProperty(exports, "isStrictBindReservedWord", {
  10790. enumerable: true,
  10791. get: function () {
  10792. return keyword.isStrictBindReservedWord;
  10793. }
  10794. });
  10795. Object.defineProperty(exports, "isStrictReservedWord", {
  10796. enumerable: true,
  10797. get: function () {
  10798. return keyword.isStrictReservedWord;
  10799. }
  10800. });
  10801. Object.defineProperty(exports, "isKeyword", {
  10802. enumerable: true,
  10803. get: function () {
  10804. return keyword.isKeyword;
  10805. }
  10806. });
  10807. });
  10808. var _default$7 = isValidIdentifier;
  10809. function isValidIdentifier(name, reserved = true) {
  10810. if (typeof name !== "string") return false;
  10811. if (reserved) {
  10812. if ((0, lib.isKeyword)(name) || (0, lib.isStrictReservedWord)(name, true)) {
  10813. return false;
  10814. }
  10815. }
  10816. return (0, lib.isIdentifierName)(name);
  10817. }
  10818. var isValidIdentifier_1 = /*#__PURE__*/Object.defineProperty({
  10819. default: _default$7
  10820. }, '__esModule', {value: true});
  10821. var constants = createCommonjsModule(function (module, exports) {
  10822. Object.defineProperty(exports, "__esModule", {
  10823. value: true
  10824. });
  10825. exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0;
  10826. const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
  10827. exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS;
  10828. const FLATTENABLE_KEYS = ["body", "expressions"];
  10829. exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS;
  10830. const FOR_INIT_KEYS = ["left", "init"];
  10831. exports.FOR_INIT_KEYS = FOR_INIT_KEYS;
  10832. const COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"];
  10833. exports.COMMENT_KEYS = COMMENT_KEYS;
  10834. const LOGICAL_OPERATORS = ["||", "&&", "??"];
  10835. exports.LOGICAL_OPERATORS = LOGICAL_OPERATORS;
  10836. const UPDATE_OPERATORS = ["++", "--"];
  10837. exports.UPDATE_OPERATORS = UPDATE_OPERATORS;
  10838. const BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="];
  10839. exports.BOOLEAN_NUMBER_BINARY_OPERATORS = BOOLEAN_NUMBER_BINARY_OPERATORS;
  10840. const EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="];
  10841. exports.EQUALITY_BINARY_OPERATORS = EQUALITY_BINARY_OPERATORS;
  10842. const COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"];
  10843. exports.COMPARISON_BINARY_OPERATORS = COMPARISON_BINARY_OPERATORS;
  10844. const BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS];
  10845. exports.BOOLEAN_BINARY_OPERATORS = BOOLEAN_BINARY_OPERATORS;
  10846. const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"];
  10847. exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS;
  10848. const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS];
  10849. exports.BINARY_OPERATORS = BINARY_OPERATORS;
  10850. const ASSIGNMENT_OPERATORS = ["=", "+=", ...NUMBER_BINARY_OPERATORS.map(op => op + "="), ...LOGICAL_OPERATORS.map(op => op + "=")];
  10851. exports.ASSIGNMENT_OPERATORS = ASSIGNMENT_OPERATORS;
  10852. const BOOLEAN_UNARY_OPERATORS = ["delete", "!"];
  10853. exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS;
  10854. const NUMBER_UNARY_OPERATORS = ["+", "-", "~"];
  10855. exports.NUMBER_UNARY_OPERATORS = NUMBER_UNARY_OPERATORS;
  10856. const STRING_UNARY_OPERATORS = ["typeof"];
  10857. exports.STRING_UNARY_OPERATORS = STRING_UNARY_OPERATORS;
  10858. const UNARY_OPERATORS = ["void", "throw", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS];
  10859. exports.UNARY_OPERATORS = UNARY_OPERATORS;
  10860. const INHERIT_KEYS = {
  10861. optional: ["typeAnnotation", "typeParameters", "returnType"],
  10862. force: ["start", "loc", "end"]
  10863. };
  10864. exports.INHERIT_KEYS = INHERIT_KEYS;
  10865. const BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
  10866. exports.BLOCK_SCOPED_SYMBOL = BLOCK_SCOPED_SYMBOL;
  10867. const NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding");
  10868. exports.NOT_LOCAL_BINDING = NOT_LOCAL_BINDING;
  10869. });
  10870. var _default$8 = validate;
  10871. var validateField_1 = validateField;
  10872. var validateChild_1 = validateChild;
  10873. function validate(node, key, val) {
  10874. if (!node) return;
  10875. const fields = definitions.NODE_FIELDS[node.type];
  10876. if (!fields) return;
  10877. const field = fields[key];
  10878. validateField(node, key, val, field);
  10879. validateChild(node, key, val);
  10880. }
  10881. function validateField(node, key, val, field) {
  10882. if (!(field != null && field.validate)) return;
  10883. if (field.optional && val == null) return;
  10884. field.validate(node, key, val);
  10885. }
  10886. function validateChild(node, key, val) {
  10887. if (val == null) return;
  10888. const validate = definitions.NODE_PARENT_VALIDATIONS[val.type];
  10889. if (!validate) return;
  10890. validate(node, key, val);
  10891. }
  10892. var validate_1 = /*#__PURE__*/Object.defineProperty({
  10893. default: _default$8,
  10894. validateField: validateField_1,
  10895. validateChild: validateChild_1
  10896. }, '__esModule', {value: true});
  10897. var utils = createCommonjsModule(function (module, exports) {
  10898. Object.defineProperty(exports, "__esModule", {
  10899. value: true
  10900. });
  10901. exports.validate = validate;
  10902. exports.typeIs = typeIs;
  10903. exports.validateType = validateType;
  10904. exports.validateOptional = validateOptional;
  10905. exports.validateOptionalType = validateOptionalType;
  10906. exports.arrayOf = arrayOf;
  10907. exports.arrayOfType = arrayOfType;
  10908. exports.validateArrayOfType = validateArrayOfType;
  10909. exports.assertEach = assertEach;
  10910. exports.assertOneOf = assertOneOf;
  10911. exports.assertNodeType = assertNodeType;
  10912. exports.assertNodeOrValueType = assertNodeOrValueType;
  10913. exports.assertValueType = assertValueType;
  10914. exports.assertShape = assertShape;
  10915. exports.assertOptionalChainStart = assertOptionalChainStart;
  10916. exports.chain = chain;
  10917. exports.default = defineType;
  10918. exports.NODE_PARENT_VALIDATIONS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = void 0;
  10919. const VISITOR_KEYS = {};
  10920. exports.VISITOR_KEYS = VISITOR_KEYS;
  10921. const ALIAS_KEYS = {};
  10922. exports.ALIAS_KEYS = ALIAS_KEYS;
  10923. const FLIPPED_ALIAS_KEYS = {};
  10924. exports.FLIPPED_ALIAS_KEYS = FLIPPED_ALIAS_KEYS;
  10925. const NODE_FIELDS = {};
  10926. exports.NODE_FIELDS = NODE_FIELDS;
  10927. const BUILDER_KEYS = {};
  10928. exports.BUILDER_KEYS = BUILDER_KEYS;
  10929. const DEPRECATED_KEYS = {};
  10930. exports.DEPRECATED_KEYS = DEPRECATED_KEYS;
  10931. const NODE_PARENT_VALIDATIONS = {};
  10932. exports.NODE_PARENT_VALIDATIONS = NODE_PARENT_VALIDATIONS;
  10933. function getType(val) {
  10934. if (Array.isArray(val)) {
  10935. return "array";
  10936. } else if (val === null) {
  10937. return "null";
  10938. } else {
  10939. return typeof val;
  10940. }
  10941. }
  10942. function validate(validate) {
  10943. return {
  10944. validate
  10945. };
  10946. }
  10947. function typeIs(typeName) {
  10948. return typeof typeName === "string" ? assertNodeType(typeName) : assertNodeType(...typeName);
  10949. }
  10950. function validateType(typeName) {
  10951. return validate(typeIs(typeName));
  10952. }
  10953. function validateOptional(validate) {
  10954. return {
  10955. validate,
  10956. optional: true
  10957. };
  10958. }
  10959. function validateOptionalType(typeName) {
  10960. return {
  10961. validate: typeIs(typeName),
  10962. optional: true
  10963. };
  10964. }
  10965. function arrayOf(elementType) {
  10966. return chain(assertValueType("array"), assertEach(elementType));
  10967. }
  10968. function arrayOfType(typeName) {
  10969. return arrayOf(typeIs(typeName));
  10970. }
  10971. function validateArrayOfType(typeName) {
  10972. return validate(arrayOfType(typeName));
  10973. }
  10974. function assertEach(callback) {
  10975. function validator(node, key, val) {
  10976. if (!Array.isArray(val)) return;
  10977. for (let i = 0; i < val.length; i++) {
  10978. const subkey = `${key}[${i}]`;
  10979. const v = val[i];
  10980. callback(node, subkey, v);
  10981. }
  10982. }
  10983. validator.each = callback;
  10984. return validator;
  10985. }
  10986. function assertOneOf(...values) {
  10987. function validate(node, key, val) {
  10988. if (values.indexOf(val) < 0) {
  10989. throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`);
  10990. }
  10991. }
  10992. validate.oneOf = values;
  10993. return validate;
  10994. }
  10995. function assertNodeType(...types) {
  10996. function validate(node, key, val) {
  10997. for (const type of types) {
  10998. if ((0, is_1.default)(type, val)) {
  10999. (0, validate_1.validateChild)(node, key, val);
  11000. return;
  11001. }
  11002. }
  11003. throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`);
  11004. }
  11005. validate.oneOfNodeTypes = types;
  11006. return validate;
  11007. }
  11008. function assertNodeOrValueType(...types) {
  11009. function validate(node, key, val) {
  11010. for (const type of types) {
  11011. if (getType(val) === type || (0, is_1.default)(type, val)) {
  11012. (0, validate_1.validateChild)(node, key, val);
  11013. return;
  11014. }
  11015. }
  11016. throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`);
  11017. }
  11018. validate.oneOfNodeOrValueTypes = types;
  11019. return validate;
  11020. }
  11021. function assertValueType(type) {
  11022. function validate(node, key, val) {
  11023. const valid = getType(val) === type;
  11024. if (!valid) {
  11025. throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`);
  11026. }
  11027. }
  11028. validate.type = type;
  11029. return validate;
  11030. }
  11031. function assertShape(shape) {
  11032. function validate(node, key, val) {
  11033. const errors = [];
  11034. for (const property of Object.keys(shape)) {
  11035. try {
  11036. (0, validate_1.validateField)(node, property, val[property], shape[property]);
  11037. } catch (error) {
  11038. if (error instanceof TypeError) {
  11039. errors.push(error.message);
  11040. continue;
  11041. }
  11042. throw error;
  11043. }
  11044. }
  11045. if (errors.length) {
  11046. throw new TypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`);
  11047. }
  11048. }
  11049. validate.shapeOf = shape;
  11050. return validate;
  11051. }
  11052. function assertOptionalChainStart() {
  11053. function validate(node) {
  11054. var _current;
  11055. let current = node;
  11056. while (node) {
  11057. const {
  11058. type
  11059. } = current;
  11060. if (type === "OptionalCallExpression") {
  11061. if (current.optional) return;
  11062. current = current.callee;
  11063. continue;
  11064. }
  11065. if (type === "OptionalMemberExpression") {
  11066. if (current.optional) return;
  11067. current = current.object;
  11068. continue;
  11069. }
  11070. break;
  11071. }
  11072. throw new TypeError(`Non-optional ${node.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${(_current = current) == null ? void 0 : _current.type}`);
  11073. }
  11074. return validate;
  11075. }
  11076. function chain(...fns) {
  11077. function validate(...args) {
  11078. for (const fn of fns) {
  11079. fn(...args);
  11080. }
  11081. }
  11082. validate.chainOf = fns;
  11083. if (fns.length >= 2 && "type" in fns[0] && fns[0].type === "array" && !("each" in fns[1])) {
  11084. throw new Error(`An assertValueType("array") validator can only be followed by an assertEach(...) validator.`);
  11085. }
  11086. return validate;
  11087. }
  11088. const validTypeOpts = ["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"];
  11089. const validFieldKeys = ["default", "optional", "validate"];
  11090. function defineType(type, opts = {}) {
  11091. const inherits = opts.inherits && store[opts.inherits] || {};
  11092. let fields = opts.fields;
  11093. if (!fields) {
  11094. fields = {};
  11095. if (inherits.fields) {
  11096. const keys = Object.getOwnPropertyNames(inherits.fields);
  11097. for (const key of keys) {
  11098. const field = inherits.fields[key];
  11099. const def = field.default;
  11100. if (Array.isArray(def) ? def.length > 0 : def && typeof def === "object") {
  11101. throw new Error("field defaults can only be primitives or empty arrays currently");
  11102. }
  11103. fields[key] = {
  11104. default: Array.isArray(def) ? [] : def,
  11105. optional: field.optional,
  11106. validate: field.validate
  11107. };
  11108. }
  11109. }
  11110. }
  11111. const visitor = opts.visitor || inherits.visitor || [];
  11112. const aliases = opts.aliases || inherits.aliases || [];
  11113. const builder = opts.builder || inherits.builder || opts.visitor || [];
  11114. for (const k of Object.keys(opts)) {
  11115. if (validTypeOpts.indexOf(k) === -1) {
  11116. throw new Error(`Unknown type option "${k}" on ${type}`);
  11117. }
  11118. }
  11119. if (opts.deprecatedAlias) {
  11120. DEPRECATED_KEYS[opts.deprecatedAlias] = type;
  11121. }
  11122. for (const key of visitor.concat(builder)) {
  11123. fields[key] = fields[key] || {};
  11124. }
  11125. for (const key of Object.keys(fields)) {
  11126. const field = fields[key];
  11127. if (field.default !== undefined && builder.indexOf(key) === -1) {
  11128. field.optional = true;
  11129. }
  11130. if (field.default === undefined) {
  11131. field.default = null;
  11132. } else if (!field.validate && field.default != null) {
  11133. field.validate = assertValueType(getType(field.default));
  11134. }
  11135. for (const k of Object.keys(field)) {
  11136. if (validFieldKeys.indexOf(k) === -1) {
  11137. throw new Error(`Unknown field key "${k}" on ${type}.${key}`);
  11138. }
  11139. }
  11140. }
  11141. VISITOR_KEYS[type] = opts.visitor = visitor;
  11142. BUILDER_KEYS[type] = opts.builder = builder;
  11143. NODE_FIELDS[type] = opts.fields = fields;
  11144. ALIAS_KEYS[type] = opts.aliases = aliases;
  11145. aliases.forEach(alias => {
  11146. FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || [];
  11147. FLIPPED_ALIAS_KEYS[alias].push(type);
  11148. });
  11149. if (opts.validate) {
  11150. NODE_PARENT_VALIDATIONS[type] = opts.validate;
  11151. }
  11152. store[type] = opts;
  11153. }
  11154. const store = {};
  11155. });
  11156. var placeholders = createCommonjsModule(function (module, exports) {
  11157. Object.defineProperty(exports, "__esModule", {
  11158. value: true
  11159. });
  11160. exports.PLACEHOLDERS_FLIPPED_ALIAS = exports.PLACEHOLDERS_ALIAS = exports.PLACEHOLDERS = void 0;
  11161. const PLACEHOLDERS = ["Identifier", "StringLiteral", "Expression", "Statement", "Declaration", "BlockStatement", "ClassBody", "Pattern"];
  11162. exports.PLACEHOLDERS = PLACEHOLDERS;
  11163. const PLACEHOLDERS_ALIAS = {
  11164. Declaration: ["Statement"],
  11165. Pattern: ["PatternLike", "LVal"]
  11166. };
  11167. exports.PLACEHOLDERS_ALIAS = PLACEHOLDERS_ALIAS;
  11168. for (const type of PLACEHOLDERS) {
  11169. const alias = utils.ALIAS_KEYS[type];
  11170. if (alias != null && alias.length) PLACEHOLDERS_ALIAS[type] = alias;
  11171. }
  11172. const PLACEHOLDERS_FLIPPED_ALIAS = {};
  11173. exports.PLACEHOLDERS_FLIPPED_ALIAS = PLACEHOLDERS_FLIPPED_ALIAS;
  11174. Object.keys(PLACEHOLDERS_ALIAS).forEach(type => {
  11175. PLACEHOLDERS_ALIAS[type].forEach(alias => {
  11176. if (!Object.hasOwnProperty.call(PLACEHOLDERS_FLIPPED_ALIAS, alias)) {
  11177. PLACEHOLDERS_FLIPPED_ALIAS[alias] = [];
  11178. }
  11179. PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type);
  11180. });
  11181. });
  11182. });
  11183. var definitions = createCommonjsModule(function (module, exports) {
  11184. Object.defineProperty(exports, "__esModule", {
  11185. value: true
  11186. });
  11187. Object.defineProperty(exports, "VISITOR_KEYS", {
  11188. enumerable: true,
  11189. get: function () {
  11190. return utils.VISITOR_KEYS;
  11191. }
  11192. });
  11193. Object.defineProperty(exports, "ALIAS_KEYS", {
  11194. enumerable: true,
  11195. get: function () {
  11196. return utils.ALIAS_KEYS;
  11197. }
  11198. });
  11199. Object.defineProperty(exports, "FLIPPED_ALIAS_KEYS", {
  11200. enumerable: true,
  11201. get: function () {
  11202. return utils.FLIPPED_ALIAS_KEYS;
  11203. }
  11204. });
  11205. Object.defineProperty(exports, "NODE_FIELDS", {
  11206. enumerable: true,
  11207. get: function () {
  11208. return utils.NODE_FIELDS;
  11209. }
  11210. });
  11211. Object.defineProperty(exports, "BUILDER_KEYS", {
  11212. enumerable: true,
  11213. get: function () {
  11214. return utils.BUILDER_KEYS;
  11215. }
  11216. });
  11217. Object.defineProperty(exports, "DEPRECATED_KEYS", {
  11218. enumerable: true,
  11219. get: function () {
  11220. return utils.DEPRECATED_KEYS;
  11221. }
  11222. });
  11223. Object.defineProperty(exports, "NODE_PARENT_VALIDATIONS", {
  11224. enumerable: true,
  11225. get: function () {
  11226. return utils.NODE_PARENT_VALIDATIONS;
  11227. }
  11228. });
  11229. Object.defineProperty(exports, "PLACEHOLDERS", {
  11230. enumerable: true,
  11231. get: function () {
  11232. return placeholders.PLACEHOLDERS;
  11233. }
  11234. });
  11235. Object.defineProperty(exports, "PLACEHOLDERS_ALIAS", {
  11236. enumerable: true,
  11237. get: function () {
  11238. return placeholders.PLACEHOLDERS_ALIAS;
  11239. }
  11240. });
  11241. Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", {
  11242. enumerable: true,
  11243. get: function () {
  11244. return placeholders.PLACEHOLDERS_FLIPPED_ALIAS;
  11245. }
  11246. });
  11247. exports.TYPES = void 0;
  11248. toFastProperties(utils.VISITOR_KEYS);
  11249. toFastProperties(utils.ALIAS_KEYS);
  11250. toFastProperties(utils.FLIPPED_ALIAS_KEYS);
  11251. toFastProperties(utils.NODE_FIELDS);
  11252. toFastProperties(utils.BUILDER_KEYS);
  11253. toFastProperties(utils.DEPRECATED_KEYS);
  11254. toFastProperties(placeholders.PLACEHOLDERS_ALIAS);
  11255. toFastProperties(placeholders.PLACEHOLDERS_FLIPPED_ALIAS);
  11256. const TYPES = Object.keys(utils.VISITOR_KEYS).concat(Object.keys(utils.FLIPPED_ALIAS_KEYS)).concat(Object.keys(utils.DEPRECATED_KEYS));
  11257. exports.TYPES = TYPES;
  11258. });
  11259. var _default$9 = builder;
  11260. function builder(type, ...args) {
  11261. const keys = definitions.BUILDER_KEYS[type];
  11262. const countArgs = args.length;
  11263. if (countArgs > keys.length) {
  11264. throw new Error(`${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`);
  11265. }
  11266. const node = {
  11267. type
  11268. };
  11269. let i = 0;
  11270. keys.forEach(key => {
  11271. const field = definitions.NODE_FIELDS[type][key];
  11272. let arg;
  11273. if (i < countArgs) arg = args[i];
  11274. if (arg === undefined) {
  11275. arg = Array.isArray(field.default) ? [] : field.default;
  11276. }
  11277. node[key] = arg;
  11278. i++;
  11279. });
  11280. for (const key of Object.keys(node)) {
  11281. (0, validate_1.default)(node, key, node[key]);
  11282. }
  11283. return node;
  11284. }
  11285. var builder_1 = /*#__PURE__*/Object.defineProperty({
  11286. default: _default$9
  11287. }, '__esModule', {value: true});
  11288. var generated$1 = createCommonjsModule(function (module, exports) {
  11289. Object.defineProperty(exports, "__esModule", {
  11290. value: true
  11291. });
  11292. exports.arrayExpression = arrayExpression;
  11293. exports.assignmentExpression = assignmentExpression;
  11294. exports.binaryExpression = binaryExpression;
  11295. exports.interpreterDirective = interpreterDirective;
  11296. exports.directive = directive;
  11297. exports.directiveLiteral = directiveLiteral;
  11298. exports.blockStatement = blockStatement;
  11299. exports.breakStatement = breakStatement;
  11300. exports.callExpression = callExpression;
  11301. exports.catchClause = catchClause;
  11302. exports.conditionalExpression = conditionalExpression;
  11303. exports.continueStatement = continueStatement;
  11304. exports.debuggerStatement = debuggerStatement;
  11305. exports.doWhileStatement = doWhileStatement;
  11306. exports.emptyStatement = emptyStatement;
  11307. exports.expressionStatement = expressionStatement;
  11308. exports.file = file;
  11309. exports.forInStatement = forInStatement;
  11310. exports.forStatement = forStatement;
  11311. exports.functionDeclaration = functionDeclaration;
  11312. exports.functionExpression = functionExpression;
  11313. exports.identifier = identifier;
  11314. exports.ifStatement = ifStatement;
  11315. exports.labeledStatement = labeledStatement;
  11316. exports.stringLiteral = stringLiteral;
  11317. exports.numericLiteral = numericLiteral;
  11318. exports.nullLiteral = nullLiteral;
  11319. exports.booleanLiteral = booleanLiteral;
  11320. exports.regExpLiteral = regExpLiteral;
  11321. exports.logicalExpression = logicalExpression;
  11322. exports.memberExpression = memberExpression;
  11323. exports.newExpression = newExpression;
  11324. exports.program = program;
  11325. exports.objectExpression = objectExpression;
  11326. exports.objectMethod = objectMethod;
  11327. exports.objectProperty = objectProperty;
  11328. exports.restElement = restElement;
  11329. exports.returnStatement = returnStatement;
  11330. exports.sequenceExpression = sequenceExpression;
  11331. exports.parenthesizedExpression = parenthesizedExpression;
  11332. exports.switchCase = switchCase;
  11333. exports.switchStatement = switchStatement;
  11334. exports.thisExpression = thisExpression;
  11335. exports.throwStatement = throwStatement;
  11336. exports.tryStatement = tryStatement;
  11337. exports.unaryExpression = unaryExpression;
  11338. exports.updateExpression = updateExpression;
  11339. exports.variableDeclaration = variableDeclaration;
  11340. exports.variableDeclarator = variableDeclarator;
  11341. exports.whileStatement = whileStatement;
  11342. exports.withStatement = withStatement;
  11343. exports.assignmentPattern = assignmentPattern;
  11344. exports.arrayPattern = arrayPattern;
  11345. exports.arrowFunctionExpression = arrowFunctionExpression;
  11346. exports.classBody = classBody;
  11347. exports.classExpression = classExpression;
  11348. exports.classDeclaration = classDeclaration;
  11349. exports.exportAllDeclaration = exportAllDeclaration;
  11350. exports.exportDefaultDeclaration = exportDefaultDeclaration;
  11351. exports.exportNamedDeclaration = exportNamedDeclaration;
  11352. exports.exportSpecifier = exportSpecifier;
  11353. exports.forOfStatement = forOfStatement;
  11354. exports.importDeclaration = importDeclaration;
  11355. exports.importDefaultSpecifier = importDefaultSpecifier;
  11356. exports.importNamespaceSpecifier = importNamespaceSpecifier;
  11357. exports.importSpecifier = importSpecifier;
  11358. exports.metaProperty = metaProperty;
  11359. exports.classMethod = classMethod;
  11360. exports.objectPattern = objectPattern;
  11361. exports.spreadElement = spreadElement;
  11362. exports.super = _super;
  11363. exports.taggedTemplateExpression = taggedTemplateExpression;
  11364. exports.templateElement = templateElement;
  11365. exports.templateLiteral = templateLiteral;
  11366. exports.yieldExpression = yieldExpression;
  11367. exports.awaitExpression = awaitExpression;
  11368. exports.import = _import;
  11369. exports.bigIntLiteral = bigIntLiteral;
  11370. exports.exportNamespaceSpecifier = exportNamespaceSpecifier;
  11371. exports.optionalMemberExpression = optionalMemberExpression;
  11372. exports.optionalCallExpression = optionalCallExpression;
  11373. exports.classProperty = classProperty;
  11374. exports.classPrivateProperty = classPrivateProperty;
  11375. exports.classPrivateMethod = classPrivateMethod;
  11376. exports.privateName = privateName;
  11377. exports.anyTypeAnnotation = anyTypeAnnotation;
  11378. exports.arrayTypeAnnotation = arrayTypeAnnotation;
  11379. exports.booleanTypeAnnotation = booleanTypeAnnotation;
  11380. exports.booleanLiteralTypeAnnotation = booleanLiteralTypeAnnotation;
  11381. exports.nullLiteralTypeAnnotation = nullLiteralTypeAnnotation;
  11382. exports.classImplements = classImplements;
  11383. exports.declareClass = declareClass;
  11384. exports.declareFunction = declareFunction;
  11385. exports.declareInterface = declareInterface;
  11386. exports.declareModule = declareModule;
  11387. exports.declareModuleExports = declareModuleExports;
  11388. exports.declareTypeAlias = declareTypeAlias;
  11389. exports.declareOpaqueType = declareOpaqueType;
  11390. exports.declareVariable = declareVariable;
  11391. exports.declareExportDeclaration = declareExportDeclaration;
  11392. exports.declareExportAllDeclaration = declareExportAllDeclaration;
  11393. exports.declaredPredicate = declaredPredicate;
  11394. exports.existsTypeAnnotation = existsTypeAnnotation;
  11395. exports.functionTypeAnnotation = functionTypeAnnotation;
  11396. exports.functionTypeParam = functionTypeParam;
  11397. exports.genericTypeAnnotation = genericTypeAnnotation;
  11398. exports.inferredPredicate = inferredPredicate;
  11399. exports.interfaceExtends = interfaceExtends;
  11400. exports.interfaceDeclaration = interfaceDeclaration;
  11401. exports.interfaceTypeAnnotation = interfaceTypeAnnotation;
  11402. exports.intersectionTypeAnnotation = intersectionTypeAnnotation;
  11403. exports.mixedTypeAnnotation = mixedTypeAnnotation;
  11404. exports.emptyTypeAnnotation = emptyTypeAnnotation;
  11405. exports.nullableTypeAnnotation = nullableTypeAnnotation;
  11406. exports.numberLiteralTypeAnnotation = numberLiteralTypeAnnotation;
  11407. exports.numberTypeAnnotation = numberTypeAnnotation;
  11408. exports.objectTypeAnnotation = objectTypeAnnotation;
  11409. exports.objectTypeInternalSlot = objectTypeInternalSlot;
  11410. exports.objectTypeCallProperty = objectTypeCallProperty;
  11411. exports.objectTypeIndexer = objectTypeIndexer;
  11412. exports.objectTypeProperty = objectTypeProperty;
  11413. exports.objectTypeSpreadProperty = objectTypeSpreadProperty;
  11414. exports.opaqueType = opaqueType;
  11415. exports.qualifiedTypeIdentifier = qualifiedTypeIdentifier;
  11416. exports.stringLiteralTypeAnnotation = stringLiteralTypeAnnotation;
  11417. exports.stringTypeAnnotation = stringTypeAnnotation;
  11418. exports.symbolTypeAnnotation = symbolTypeAnnotation;
  11419. exports.thisTypeAnnotation = thisTypeAnnotation;
  11420. exports.tupleTypeAnnotation = tupleTypeAnnotation;
  11421. exports.typeofTypeAnnotation = typeofTypeAnnotation;
  11422. exports.typeAlias = typeAlias;
  11423. exports.typeAnnotation = typeAnnotation;
  11424. exports.typeCastExpression = typeCastExpression;
  11425. exports.typeParameter = typeParameter;
  11426. exports.typeParameterDeclaration = typeParameterDeclaration;
  11427. exports.typeParameterInstantiation = typeParameterInstantiation;
  11428. exports.unionTypeAnnotation = unionTypeAnnotation;
  11429. exports.variance = variance;
  11430. exports.voidTypeAnnotation = voidTypeAnnotation;
  11431. exports.enumDeclaration = enumDeclaration;
  11432. exports.enumBooleanBody = enumBooleanBody;
  11433. exports.enumNumberBody = enumNumberBody;
  11434. exports.enumStringBody = enumStringBody;
  11435. exports.enumSymbolBody = enumSymbolBody;
  11436. exports.enumBooleanMember = enumBooleanMember;
  11437. exports.enumNumberMember = enumNumberMember;
  11438. exports.enumStringMember = enumStringMember;
  11439. exports.enumDefaultedMember = enumDefaultedMember;
  11440. exports.indexedAccessType = indexedAccessType;
  11441. exports.optionalIndexedAccessType = optionalIndexedAccessType;
  11442. exports.jSXAttribute = exports.jsxAttribute = jsxAttribute;
  11443. exports.jSXClosingElement = exports.jsxClosingElement = jsxClosingElement;
  11444. exports.jSXElement = exports.jsxElement = jsxElement;
  11445. exports.jSXEmptyExpression = exports.jsxEmptyExpression = jsxEmptyExpression;
  11446. exports.jSXExpressionContainer = exports.jsxExpressionContainer = jsxExpressionContainer;
  11447. exports.jSXSpreadChild = exports.jsxSpreadChild = jsxSpreadChild;
  11448. exports.jSXIdentifier = exports.jsxIdentifier = jsxIdentifier;
  11449. exports.jSXMemberExpression = exports.jsxMemberExpression = jsxMemberExpression;
  11450. exports.jSXNamespacedName = exports.jsxNamespacedName = jsxNamespacedName;
  11451. exports.jSXOpeningElement = exports.jsxOpeningElement = jsxOpeningElement;
  11452. exports.jSXSpreadAttribute = exports.jsxSpreadAttribute = jsxSpreadAttribute;
  11453. exports.jSXText = exports.jsxText = jsxText;
  11454. exports.jSXFragment = exports.jsxFragment = jsxFragment;
  11455. exports.jSXOpeningFragment = exports.jsxOpeningFragment = jsxOpeningFragment;
  11456. exports.jSXClosingFragment = exports.jsxClosingFragment = jsxClosingFragment;
  11457. exports.noop = noop;
  11458. exports.placeholder = placeholder;
  11459. exports.v8IntrinsicIdentifier = v8IntrinsicIdentifier;
  11460. exports.argumentPlaceholder = argumentPlaceholder;
  11461. exports.bindExpression = bindExpression;
  11462. exports.importAttribute = importAttribute;
  11463. exports.decorator = decorator;
  11464. exports.doExpression = doExpression;
  11465. exports.exportDefaultSpecifier = exportDefaultSpecifier;
  11466. exports.recordExpression = recordExpression;
  11467. exports.tupleExpression = tupleExpression;
  11468. exports.decimalLiteral = decimalLiteral;
  11469. exports.staticBlock = staticBlock;
  11470. exports.moduleExpression = moduleExpression;
  11471. exports.topicReference = topicReference;
  11472. exports.pipelineTopicExpression = pipelineTopicExpression;
  11473. exports.pipelineBareFunction = pipelineBareFunction;
  11474. exports.pipelinePrimaryTopicReference = pipelinePrimaryTopicReference;
  11475. exports.tSParameterProperty = exports.tsParameterProperty = tsParameterProperty;
  11476. exports.tSDeclareFunction = exports.tsDeclareFunction = tsDeclareFunction;
  11477. exports.tSDeclareMethod = exports.tsDeclareMethod = tsDeclareMethod;
  11478. exports.tSQualifiedName = exports.tsQualifiedName = tsQualifiedName;
  11479. exports.tSCallSignatureDeclaration = exports.tsCallSignatureDeclaration = tsCallSignatureDeclaration;
  11480. exports.tSConstructSignatureDeclaration = exports.tsConstructSignatureDeclaration = tsConstructSignatureDeclaration;
  11481. exports.tSPropertySignature = exports.tsPropertySignature = tsPropertySignature;
  11482. exports.tSMethodSignature = exports.tsMethodSignature = tsMethodSignature;
  11483. exports.tSIndexSignature = exports.tsIndexSignature = tsIndexSignature;
  11484. exports.tSAnyKeyword = exports.tsAnyKeyword = tsAnyKeyword;
  11485. exports.tSBooleanKeyword = exports.tsBooleanKeyword = tsBooleanKeyword;
  11486. exports.tSBigIntKeyword = exports.tsBigIntKeyword = tsBigIntKeyword;
  11487. exports.tSIntrinsicKeyword = exports.tsIntrinsicKeyword = tsIntrinsicKeyword;
  11488. exports.tSNeverKeyword = exports.tsNeverKeyword = tsNeverKeyword;
  11489. exports.tSNullKeyword = exports.tsNullKeyword = tsNullKeyword;
  11490. exports.tSNumberKeyword = exports.tsNumberKeyword = tsNumberKeyword;
  11491. exports.tSObjectKeyword = exports.tsObjectKeyword = tsObjectKeyword;
  11492. exports.tSStringKeyword = exports.tsStringKeyword = tsStringKeyword;
  11493. exports.tSSymbolKeyword = exports.tsSymbolKeyword = tsSymbolKeyword;
  11494. exports.tSUndefinedKeyword = exports.tsUndefinedKeyword = tsUndefinedKeyword;
  11495. exports.tSUnknownKeyword = exports.tsUnknownKeyword = tsUnknownKeyword;
  11496. exports.tSVoidKeyword = exports.tsVoidKeyword = tsVoidKeyword;
  11497. exports.tSThisType = exports.tsThisType = tsThisType;
  11498. exports.tSFunctionType = exports.tsFunctionType = tsFunctionType;
  11499. exports.tSConstructorType = exports.tsConstructorType = tsConstructorType;
  11500. exports.tSTypeReference = exports.tsTypeReference = tsTypeReference;
  11501. exports.tSTypePredicate = exports.tsTypePredicate = tsTypePredicate;
  11502. exports.tSTypeQuery = exports.tsTypeQuery = tsTypeQuery;
  11503. exports.tSTypeLiteral = exports.tsTypeLiteral = tsTypeLiteral;
  11504. exports.tSArrayType = exports.tsArrayType = tsArrayType;
  11505. exports.tSTupleType = exports.tsTupleType = tsTupleType;
  11506. exports.tSOptionalType = exports.tsOptionalType = tsOptionalType;
  11507. exports.tSRestType = exports.tsRestType = tsRestType;
  11508. exports.tSNamedTupleMember = exports.tsNamedTupleMember = tsNamedTupleMember;
  11509. exports.tSUnionType = exports.tsUnionType = tsUnionType;
  11510. exports.tSIntersectionType = exports.tsIntersectionType = tsIntersectionType;
  11511. exports.tSConditionalType = exports.tsConditionalType = tsConditionalType;
  11512. exports.tSInferType = exports.tsInferType = tsInferType;
  11513. exports.tSParenthesizedType = exports.tsParenthesizedType = tsParenthesizedType;
  11514. exports.tSTypeOperator = exports.tsTypeOperator = tsTypeOperator;
  11515. exports.tSIndexedAccessType = exports.tsIndexedAccessType = tsIndexedAccessType;
  11516. exports.tSMappedType = exports.tsMappedType = tsMappedType;
  11517. exports.tSLiteralType = exports.tsLiteralType = tsLiteralType;
  11518. exports.tSExpressionWithTypeArguments = exports.tsExpressionWithTypeArguments = tsExpressionWithTypeArguments;
  11519. exports.tSInterfaceDeclaration = exports.tsInterfaceDeclaration = tsInterfaceDeclaration;
  11520. exports.tSInterfaceBody = exports.tsInterfaceBody = tsInterfaceBody;
  11521. exports.tSTypeAliasDeclaration = exports.tsTypeAliasDeclaration = tsTypeAliasDeclaration;
  11522. exports.tSAsExpression = exports.tsAsExpression = tsAsExpression;
  11523. exports.tSTypeAssertion = exports.tsTypeAssertion = tsTypeAssertion;
  11524. exports.tSEnumDeclaration = exports.tsEnumDeclaration = tsEnumDeclaration;
  11525. exports.tSEnumMember = exports.tsEnumMember = tsEnumMember;
  11526. exports.tSModuleDeclaration = exports.tsModuleDeclaration = tsModuleDeclaration;
  11527. exports.tSModuleBlock = exports.tsModuleBlock = tsModuleBlock;
  11528. exports.tSImportType = exports.tsImportType = tsImportType;
  11529. exports.tSImportEqualsDeclaration = exports.tsImportEqualsDeclaration = tsImportEqualsDeclaration;
  11530. exports.tSExternalModuleReference = exports.tsExternalModuleReference = tsExternalModuleReference;
  11531. exports.tSNonNullExpression = exports.tsNonNullExpression = tsNonNullExpression;
  11532. exports.tSExportAssignment = exports.tsExportAssignment = tsExportAssignment;
  11533. exports.tSNamespaceExportDeclaration = exports.tsNamespaceExportDeclaration = tsNamespaceExportDeclaration;
  11534. exports.tSTypeAnnotation = exports.tsTypeAnnotation = tsTypeAnnotation;
  11535. exports.tSTypeParameterInstantiation = exports.tsTypeParameterInstantiation = tsTypeParameterInstantiation;
  11536. exports.tSTypeParameterDeclaration = exports.tsTypeParameterDeclaration = tsTypeParameterDeclaration;
  11537. exports.tSTypeParameter = exports.tsTypeParameter = tsTypeParameter;
  11538. exports.numberLiteral = NumberLiteral;
  11539. exports.regexLiteral = RegexLiteral;
  11540. exports.restProperty = RestProperty;
  11541. exports.spreadProperty = SpreadProperty;
  11542. function arrayExpression(elements) {
  11543. return (0, builder_1.default)("ArrayExpression", ...arguments);
  11544. }
  11545. function assignmentExpression(operator, left, right) {
  11546. return (0, builder_1.default)("AssignmentExpression", ...arguments);
  11547. }
  11548. function binaryExpression(operator, left, right) {
  11549. return (0, builder_1.default)("BinaryExpression", ...arguments);
  11550. }
  11551. function interpreterDirective(value) {
  11552. return (0, builder_1.default)("InterpreterDirective", ...arguments);
  11553. }
  11554. function directive(value) {
  11555. return (0, builder_1.default)("Directive", ...arguments);
  11556. }
  11557. function directiveLiteral(value) {
  11558. return (0, builder_1.default)("DirectiveLiteral", ...arguments);
  11559. }
  11560. function blockStatement(body, directives) {
  11561. return (0, builder_1.default)("BlockStatement", ...arguments);
  11562. }
  11563. function breakStatement(label) {
  11564. return (0, builder_1.default)("BreakStatement", ...arguments);
  11565. }
  11566. function callExpression(callee, _arguments) {
  11567. return (0, builder_1.default)("CallExpression", ...arguments);
  11568. }
  11569. function catchClause(param, body) {
  11570. return (0, builder_1.default)("CatchClause", ...arguments);
  11571. }
  11572. function conditionalExpression(test, consequent, alternate) {
  11573. return (0, builder_1.default)("ConditionalExpression", ...arguments);
  11574. }
  11575. function continueStatement(label) {
  11576. return (0, builder_1.default)("ContinueStatement", ...arguments);
  11577. }
  11578. function debuggerStatement() {
  11579. return (0, builder_1.default)("DebuggerStatement", ...arguments);
  11580. }
  11581. function doWhileStatement(test, body) {
  11582. return (0, builder_1.default)("DoWhileStatement", ...arguments);
  11583. }
  11584. function emptyStatement() {
  11585. return (0, builder_1.default)("EmptyStatement", ...arguments);
  11586. }
  11587. function expressionStatement(expression) {
  11588. return (0, builder_1.default)("ExpressionStatement", ...arguments);
  11589. }
  11590. function file(program, comments, tokens) {
  11591. return (0, builder_1.default)("File", ...arguments);
  11592. }
  11593. function forInStatement(left, right, body) {
  11594. return (0, builder_1.default)("ForInStatement", ...arguments);
  11595. }
  11596. function forStatement(init, test, update, body) {
  11597. return (0, builder_1.default)("ForStatement", ...arguments);
  11598. }
  11599. function functionDeclaration(id, params, body, generator, async) {
  11600. return (0, builder_1.default)("FunctionDeclaration", ...arguments);
  11601. }
  11602. function functionExpression(id, params, body, generator, async) {
  11603. return (0, builder_1.default)("FunctionExpression", ...arguments);
  11604. }
  11605. function identifier(name) {
  11606. return (0, builder_1.default)("Identifier", ...arguments);
  11607. }
  11608. function ifStatement(test, consequent, alternate) {
  11609. return (0, builder_1.default)("IfStatement", ...arguments);
  11610. }
  11611. function labeledStatement(label, body) {
  11612. return (0, builder_1.default)("LabeledStatement", ...arguments);
  11613. }
  11614. function stringLiteral(value) {
  11615. return (0, builder_1.default)("StringLiteral", ...arguments);
  11616. }
  11617. function numericLiteral(value) {
  11618. return (0, builder_1.default)("NumericLiteral", ...arguments);
  11619. }
  11620. function nullLiteral() {
  11621. return (0, builder_1.default)("NullLiteral", ...arguments);
  11622. }
  11623. function booleanLiteral(value) {
  11624. return (0, builder_1.default)("BooleanLiteral", ...arguments);
  11625. }
  11626. function regExpLiteral(pattern, flags) {
  11627. return (0, builder_1.default)("RegExpLiteral", ...arguments);
  11628. }
  11629. function logicalExpression(operator, left, right) {
  11630. return (0, builder_1.default)("LogicalExpression", ...arguments);
  11631. }
  11632. function memberExpression(object, property, computed, optional) {
  11633. return (0, builder_1.default)("MemberExpression", ...arguments);
  11634. }
  11635. function newExpression(callee, _arguments) {
  11636. return (0, builder_1.default)("NewExpression", ...arguments);
  11637. }
  11638. function program(body, directives, sourceType, interpreter) {
  11639. return (0, builder_1.default)("Program", ...arguments);
  11640. }
  11641. function objectExpression(properties) {
  11642. return (0, builder_1.default)("ObjectExpression", ...arguments);
  11643. }
  11644. function objectMethod(kind, key, params, body, computed, generator, async) {
  11645. return (0, builder_1.default)("ObjectMethod", ...arguments);
  11646. }
  11647. function objectProperty(key, value, computed, shorthand, decorators) {
  11648. return (0, builder_1.default)("ObjectProperty", ...arguments);
  11649. }
  11650. function restElement(argument) {
  11651. return (0, builder_1.default)("RestElement", ...arguments);
  11652. }
  11653. function returnStatement(argument) {
  11654. return (0, builder_1.default)("ReturnStatement", ...arguments);
  11655. }
  11656. function sequenceExpression(expressions) {
  11657. return (0, builder_1.default)("SequenceExpression", ...arguments);
  11658. }
  11659. function parenthesizedExpression(expression) {
  11660. return (0, builder_1.default)("ParenthesizedExpression", ...arguments);
  11661. }
  11662. function switchCase(test, consequent) {
  11663. return (0, builder_1.default)("SwitchCase", ...arguments);
  11664. }
  11665. function switchStatement(discriminant, cases) {
  11666. return (0, builder_1.default)("SwitchStatement", ...arguments);
  11667. }
  11668. function thisExpression() {
  11669. return (0, builder_1.default)("ThisExpression", ...arguments);
  11670. }
  11671. function throwStatement(argument) {
  11672. return (0, builder_1.default)("ThrowStatement", ...arguments);
  11673. }
  11674. function tryStatement(block, handler, finalizer) {
  11675. return (0, builder_1.default)("TryStatement", ...arguments);
  11676. }
  11677. function unaryExpression(operator, argument, prefix) {
  11678. return (0, builder_1.default)("UnaryExpression", ...arguments);
  11679. }
  11680. function updateExpression(operator, argument, prefix) {
  11681. return (0, builder_1.default)("UpdateExpression", ...arguments);
  11682. }
  11683. function variableDeclaration(kind, declarations) {
  11684. return (0, builder_1.default)("VariableDeclaration", ...arguments);
  11685. }
  11686. function variableDeclarator(id, init) {
  11687. return (0, builder_1.default)("VariableDeclarator", ...arguments);
  11688. }
  11689. function whileStatement(test, body) {
  11690. return (0, builder_1.default)("WhileStatement", ...arguments);
  11691. }
  11692. function withStatement(object, body) {
  11693. return (0, builder_1.default)("WithStatement", ...arguments);
  11694. }
  11695. function assignmentPattern(left, right) {
  11696. return (0, builder_1.default)("AssignmentPattern", ...arguments);
  11697. }
  11698. function arrayPattern(elements) {
  11699. return (0, builder_1.default)("ArrayPattern", ...arguments);
  11700. }
  11701. function arrowFunctionExpression(params, body, async) {
  11702. return (0, builder_1.default)("ArrowFunctionExpression", ...arguments);
  11703. }
  11704. function classBody(body) {
  11705. return (0, builder_1.default)("ClassBody", ...arguments);
  11706. }
  11707. function classExpression(id, superClass, body, decorators) {
  11708. return (0, builder_1.default)("ClassExpression", ...arguments);
  11709. }
  11710. function classDeclaration(id, superClass, body, decorators) {
  11711. return (0, builder_1.default)("ClassDeclaration", ...arguments);
  11712. }
  11713. function exportAllDeclaration(source) {
  11714. return (0, builder_1.default)("ExportAllDeclaration", ...arguments);
  11715. }
  11716. function exportDefaultDeclaration(declaration) {
  11717. return (0, builder_1.default)("ExportDefaultDeclaration", ...arguments);
  11718. }
  11719. function exportNamedDeclaration(declaration, specifiers, source) {
  11720. return (0, builder_1.default)("ExportNamedDeclaration", ...arguments);
  11721. }
  11722. function exportSpecifier(local, exported) {
  11723. return (0, builder_1.default)("ExportSpecifier", ...arguments);
  11724. }
  11725. function forOfStatement(left, right, body, _await) {
  11726. return (0, builder_1.default)("ForOfStatement", ...arguments);
  11727. }
  11728. function importDeclaration(specifiers, source) {
  11729. return (0, builder_1.default)("ImportDeclaration", ...arguments);
  11730. }
  11731. function importDefaultSpecifier(local) {
  11732. return (0, builder_1.default)("ImportDefaultSpecifier", ...arguments);
  11733. }
  11734. function importNamespaceSpecifier(local) {
  11735. return (0, builder_1.default)("ImportNamespaceSpecifier", ...arguments);
  11736. }
  11737. function importSpecifier(local, imported) {
  11738. return (0, builder_1.default)("ImportSpecifier", ...arguments);
  11739. }
  11740. function metaProperty(meta, property) {
  11741. return (0, builder_1.default)("MetaProperty", ...arguments);
  11742. }
  11743. function classMethod(kind, key, params, body, computed, _static, generator, async) {
  11744. return (0, builder_1.default)("ClassMethod", ...arguments);
  11745. }
  11746. function objectPattern(properties) {
  11747. return (0, builder_1.default)("ObjectPattern", ...arguments);
  11748. }
  11749. function spreadElement(argument) {
  11750. return (0, builder_1.default)("SpreadElement", ...arguments);
  11751. }
  11752. function _super() {
  11753. return (0, builder_1.default)("Super", ...arguments);
  11754. }
  11755. function taggedTemplateExpression(tag, quasi) {
  11756. return (0, builder_1.default)("TaggedTemplateExpression", ...arguments);
  11757. }
  11758. function templateElement(value, tail) {
  11759. return (0, builder_1.default)("TemplateElement", ...arguments);
  11760. }
  11761. function templateLiteral(quasis, expressions) {
  11762. return (0, builder_1.default)("TemplateLiteral", ...arguments);
  11763. }
  11764. function yieldExpression(argument, delegate) {
  11765. return (0, builder_1.default)("YieldExpression", ...arguments);
  11766. }
  11767. function awaitExpression(argument) {
  11768. return (0, builder_1.default)("AwaitExpression", ...arguments);
  11769. }
  11770. function _import() {
  11771. return (0, builder_1.default)("Import", ...arguments);
  11772. }
  11773. function bigIntLiteral(value) {
  11774. return (0, builder_1.default)("BigIntLiteral", ...arguments);
  11775. }
  11776. function exportNamespaceSpecifier(exported) {
  11777. return (0, builder_1.default)("ExportNamespaceSpecifier", ...arguments);
  11778. }
  11779. function optionalMemberExpression(object, property, computed, optional) {
  11780. return (0, builder_1.default)("OptionalMemberExpression", ...arguments);
  11781. }
  11782. function optionalCallExpression(callee, _arguments, optional) {
  11783. return (0, builder_1.default)("OptionalCallExpression", ...arguments);
  11784. }
  11785. function classProperty(key, value, typeAnnotation, decorators, computed, _static) {
  11786. return (0, builder_1.default)("ClassProperty", ...arguments);
  11787. }
  11788. function classPrivateProperty(key, value, decorators, _static) {
  11789. return (0, builder_1.default)("ClassPrivateProperty", ...arguments);
  11790. }
  11791. function classPrivateMethod(kind, key, params, body, _static) {
  11792. return (0, builder_1.default)("ClassPrivateMethod", ...arguments);
  11793. }
  11794. function privateName(id) {
  11795. return (0, builder_1.default)("PrivateName", ...arguments);
  11796. }
  11797. function anyTypeAnnotation() {
  11798. return (0, builder_1.default)("AnyTypeAnnotation", ...arguments);
  11799. }
  11800. function arrayTypeAnnotation(elementType) {
  11801. return (0, builder_1.default)("ArrayTypeAnnotation", ...arguments);
  11802. }
  11803. function booleanTypeAnnotation() {
  11804. return (0, builder_1.default)("BooleanTypeAnnotation", ...arguments);
  11805. }
  11806. function booleanLiteralTypeAnnotation(value) {
  11807. return (0, builder_1.default)("BooleanLiteralTypeAnnotation", ...arguments);
  11808. }
  11809. function nullLiteralTypeAnnotation() {
  11810. return (0, builder_1.default)("NullLiteralTypeAnnotation", ...arguments);
  11811. }
  11812. function classImplements(id, typeParameters) {
  11813. return (0, builder_1.default)("ClassImplements", ...arguments);
  11814. }
  11815. function declareClass(id, typeParameters, _extends, body) {
  11816. return (0, builder_1.default)("DeclareClass", ...arguments);
  11817. }
  11818. function declareFunction(id) {
  11819. return (0, builder_1.default)("DeclareFunction", ...arguments);
  11820. }
  11821. function declareInterface(id, typeParameters, _extends, body) {
  11822. return (0, builder_1.default)("DeclareInterface", ...arguments);
  11823. }
  11824. function declareModule(id, body, kind) {
  11825. return (0, builder_1.default)("DeclareModule", ...arguments);
  11826. }
  11827. function declareModuleExports(typeAnnotation) {
  11828. return (0, builder_1.default)("DeclareModuleExports", ...arguments);
  11829. }
  11830. function declareTypeAlias(id, typeParameters, right) {
  11831. return (0, builder_1.default)("DeclareTypeAlias", ...arguments);
  11832. }
  11833. function declareOpaqueType(id, typeParameters, supertype) {
  11834. return (0, builder_1.default)("DeclareOpaqueType", ...arguments);
  11835. }
  11836. function declareVariable(id) {
  11837. return (0, builder_1.default)("DeclareVariable", ...arguments);
  11838. }
  11839. function declareExportDeclaration(declaration, specifiers, source) {
  11840. return (0, builder_1.default)("DeclareExportDeclaration", ...arguments);
  11841. }
  11842. function declareExportAllDeclaration(source) {
  11843. return (0, builder_1.default)("DeclareExportAllDeclaration", ...arguments);
  11844. }
  11845. function declaredPredicate(value) {
  11846. return (0, builder_1.default)("DeclaredPredicate", ...arguments);
  11847. }
  11848. function existsTypeAnnotation() {
  11849. return (0, builder_1.default)("ExistsTypeAnnotation", ...arguments);
  11850. }
  11851. function functionTypeAnnotation(typeParameters, params, rest, returnType) {
  11852. return (0, builder_1.default)("FunctionTypeAnnotation", ...arguments);
  11853. }
  11854. function functionTypeParam(name, typeAnnotation) {
  11855. return (0, builder_1.default)("FunctionTypeParam", ...arguments);
  11856. }
  11857. function genericTypeAnnotation(id, typeParameters) {
  11858. return (0, builder_1.default)("GenericTypeAnnotation", ...arguments);
  11859. }
  11860. function inferredPredicate() {
  11861. return (0, builder_1.default)("InferredPredicate", ...arguments);
  11862. }
  11863. function interfaceExtends(id, typeParameters) {
  11864. return (0, builder_1.default)("InterfaceExtends", ...arguments);
  11865. }
  11866. function interfaceDeclaration(id, typeParameters, _extends, body) {
  11867. return (0, builder_1.default)("InterfaceDeclaration", ...arguments);
  11868. }
  11869. function interfaceTypeAnnotation(_extends, body) {
  11870. return (0, builder_1.default)("InterfaceTypeAnnotation", ...arguments);
  11871. }
  11872. function intersectionTypeAnnotation(types) {
  11873. return (0, builder_1.default)("IntersectionTypeAnnotation", ...arguments);
  11874. }
  11875. function mixedTypeAnnotation() {
  11876. return (0, builder_1.default)("MixedTypeAnnotation", ...arguments);
  11877. }
  11878. function emptyTypeAnnotation() {
  11879. return (0, builder_1.default)("EmptyTypeAnnotation", ...arguments);
  11880. }
  11881. function nullableTypeAnnotation(typeAnnotation) {
  11882. return (0, builder_1.default)("NullableTypeAnnotation", ...arguments);
  11883. }
  11884. function numberLiteralTypeAnnotation(value) {
  11885. return (0, builder_1.default)("NumberLiteralTypeAnnotation", ...arguments);
  11886. }
  11887. function numberTypeAnnotation() {
  11888. return (0, builder_1.default)("NumberTypeAnnotation", ...arguments);
  11889. }
  11890. function objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact) {
  11891. return (0, builder_1.default)("ObjectTypeAnnotation", ...arguments);
  11892. }
  11893. function objectTypeInternalSlot(id, value, optional, _static, method) {
  11894. return (0, builder_1.default)("ObjectTypeInternalSlot", ...arguments);
  11895. }
  11896. function objectTypeCallProperty(value) {
  11897. return (0, builder_1.default)("ObjectTypeCallProperty", ...arguments);
  11898. }
  11899. function objectTypeIndexer(id, key, value, variance) {
  11900. return (0, builder_1.default)("ObjectTypeIndexer", ...arguments);
  11901. }
  11902. function objectTypeProperty(key, value, variance) {
  11903. return (0, builder_1.default)("ObjectTypeProperty", ...arguments);
  11904. }
  11905. function objectTypeSpreadProperty(argument) {
  11906. return (0, builder_1.default)("ObjectTypeSpreadProperty", ...arguments);
  11907. }
  11908. function opaqueType(id, typeParameters, supertype, impltype) {
  11909. return (0, builder_1.default)("OpaqueType", ...arguments);
  11910. }
  11911. function qualifiedTypeIdentifier(id, qualification) {
  11912. return (0, builder_1.default)("QualifiedTypeIdentifier", ...arguments);
  11913. }
  11914. function stringLiteralTypeAnnotation(value) {
  11915. return (0, builder_1.default)("StringLiteralTypeAnnotation", ...arguments);
  11916. }
  11917. function stringTypeAnnotation() {
  11918. return (0, builder_1.default)("StringTypeAnnotation", ...arguments);
  11919. }
  11920. function symbolTypeAnnotation() {
  11921. return (0, builder_1.default)("SymbolTypeAnnotation", ...arguments);
  11922. }
  11923. function thisTypeAnnotation() {
  11924. return (0, builder_1.default)("ThisTypeAnnotation", ...arguments);
  11925. }
  11926. function tupleTypeAnnotation(types) {
  11927. return (0, builder_1.default)("TupleTypeAnnotation", ...arguments);
  11928. }
  11929. function typeofTypeAnnotation(argument) {
  11930. return (0, builder_1.default)("TypeofTypeAnnotation", ...arguments);
  11931. }
  11932. function typeAlias(id, typeParameters, right) {
  11933. return (0, builder_1.default)("TypeAlias", ...arguments);
  11934. }
  11935. function typeAnnotation(typeAnnotation) {
  11936. return (0, builder_1.default)("TypeAnnotation", ...arguments);
  11937. }
  11938. function typeCastExpression(expression, typeAnnotation) {
  11939. return (0, builder_1.default)("TypeCastExpression", ...arguments);
  11940. }
  11941. function typeParameter(bound, _default, variance) {
  11942. return (0, builder_1.default)("TypeParameter", ...arguments);
  11943. }
  11944. function typeParameterDeclaration(params) {
  11945. return (0, builder_1.default)("TypeParameterDeclaration", ...arguments);
  11946. }
  11947. function typeParameterInstantiation(params) {
  11948. return (0, builder_1.default)("TypeParameterInstantiation", ...arguments);
  11949. }
  11950. function unionTypeAnnotation(types) {
  11951. return (0, builder_1.default)("UnionTypeAnnotation", ...arguments);
  11952. }
  11953. function variance(kind) {
  11954. return (0, builder_1.default)("Variance", ...arguments);
  11955. }
  11956. function voidTypeAnnotation() {
  11957. return (0, builder_1.default)("VoidTypeAnnotation", ...arguments);
  11958. }
  11959. function enumDeclaration(id, body) {
  11960. return (0, builder_1.default)("EnumDeclaration", ...arguments);
  11961. }
  11962. function enumBooleanBody(members) {
  11963. return (0, builder_1.default)("EnumBooleanBody", ...arguments);
  11964. }
  11965. function enumNumberBody(members) {
  11966. return (0, builder_1.default)("EnumNumberBody", ...arguments);
  11967. }
  11968. function enumStringBody(members) {
  11969. return (0, builder_1.default)("EnumStringBody", ...arguments);
  11970. }
  11971. function enumSymbolBody(members) {
  11972. return (0, builder_1.default)("EnumSymbolBody", ...arguments);
  11973. }
  11974. function enumBooleanMember(id) {
  11975. return (0, builder_1.default)("EnumBooleanMember", ...arguments);
  11976. }
  11977. function enumNumberMember(id, init) {
  11978. return (0, builder_1.default)("EnumNumberMember", ...arguments);
  11979. }
  11980. function enumStringMember(id, init) {
  11981. return (0, builder_1.default)("EnumStringMember", ...arguments);
  11982. }
  11983. function enumDefaultedMember(id) {
  11984. return (0, builder_1.default)("EnumDefaultedMember", ...arguments);
  11985. }
  11986. function indexedAccessType(objectType, indexType) {
  11987. return (0, builder_1.default)("IndexedAccessType", ...arguments);
  11988. }
  11989. function optionalIndexedAccessType(objectType, indexType) {
  11990. return (0, builder_1.default)("OptionalIndexedAccessType", ...arguments);
  11991. }
  11992. function jsxAttribute(name, value) {
  11993. return (0, builder_1.default)("JSXAttribute", ...arguments);
  11994. }
  11995. function jsxClosingElement(name) {
  11996. return (0, builder_1.default)("JSXClosingElement", ...arguments);
  11997. }
  11998. function jsxElement(openingElement, closingElement, children, selfClosing) {
  11999. return (0, builder_1.default)("JSXElement", ...arguments);
  12000. }
  12001. function jsxEmptyExpression() {
  12002. return (0, builder_1.default)("JSXEmptyExpression", ...arguments);
  12003. }
  12004. function jsxExpressionContainer(expression) {
  12005. return (0, builder_1.default)("JSXExpressionContainer", ...arguments);
  12006. }
  12007. function jsxSpreadChild(expression) {
  12008. return (0, builder_1.default)("JSXSpreadChild", ...arguments);
  12009. }
  12010. function jsxIdentifier(name) {
  12011. return (0, builder_1.default)("JSXIdentifier", ...arguments);
  12012. }
  12013. function jsxMemberExpression(object, property) {
  12014. return (0, builder_1.default)("JSXMemberExpression", ...arguments);
  12015. }
  12016. function jsxNamespacedName(namespace, name) {
  12017. return (0, builder_1.default)("JSXNamespacedName", ...arguments);
  12018. }
  12019. function jsxOpeningElement(name, attributes, selfClosing) {
  12020. return (0, builder_1.default)("JSXOpeningElement", ...arguments);
  12021. }
  12022. function jsxSpreadAttribute(argument) {
  12023. return (0, builder_1.default)("JSXSpreadAttribute", ...arguments);
  12024. }
  12025. function jsxText(value) {
  12026. return (0, builder_1.default)("JSXText", ...arguments);
  12027. }
  12028. function jsxFragment(openingFragment, closingFragment, children) {
  12029. return (0, builder_1.default)("JSXFragment", ...arguments);
  12030. }
  12031. function jsxOpeningFragment() {
  12032. return (0, builder_1.default)("JSXOpeningFragment", ...arguments);
  12033. }
  12034. function jsxClosingFragment() {
  12035. return (0, builder_1.default)("JSXClosingFragment", ...arguments);
  12036. }
  12037. function noop() {
  12038. return (0, builder_1.default)("Noop", ...arguments);
  12039. }
  12040. function placeholder(expectedNode, name) {
  12041. return (0, builder_1.default)("Placeholder", ...arguments);
  12042. }
  12043. function v8IntrinsicIdentifier(name) {
  12044. return (0, builder_1.default)("V8IntrinsicIdentifier", ...arguments);
  12045. }
  12046. function argumentPlaceholder() {
  12047. return (0, builder_1.default)("ArgumentPlaceholder", ...arguments);
  12048. }
  12049. function bindExpression(object, callee) {
  12050. return (0, builder_1.default)("BindExpression", ...arguments);
  12051. }
  12052. function importAttribute(key, value) {
  12053. return (0, builder_1.default)("ImportAttribute", ...arguments);
  12054. }
  12055. function decorator(expression) {
  12056. return (0, builder_1.default)("Decorator", ...arguments);
  12057. }
  12058. function doExpression(body, async) {
  12059. return (0, builder_1.default)("DoExpression", ...arguments);
  12060. }
  12061. function exportDefaultSpecifier(exported) {
  12062. return (0, builder_1.default)("ExportDefaultSpecifier", ...arguments);
  12063. }
  12064. function recordExpression(properties) {
  12065. return (0, builder_1.default)("RecordExpression", ...arguments);
  12066. }
  12067. function tupleExpression(elements) {
  12068. return (0, builder_1.default)("TupleExpression", ...arguments);
  12069. }
  12070. function decimalLiteral(value) {
  12071. return (0, builder_1.default)("DecimalLiteral", ...arguments);
  12072. }
  12073. function staticBlock(body) {
  12074. return (0, builder_1.default)("StaticBlock", ...arguments);
  12075. }
  12076. function moduleExpression(body) {
  12077. return (0, builder_1.default)("ModuleExpression", ...arguments);
  12078. }
  12079. function topicReference() {
  12080. return (0, builder_1.default)("TopicReference", ...arguments);
  12081. }
  12082. function pipelineTopicExpression(expression) {
  12083. return (0, builder_1.default)("PipelineTopicExpression", ...arguments);
  12084. }
  12085. function pipelineBareFunction(callee) {
  12086. return (0, builder_1.default)("PipelineBareFunction", ...arguments);
  12087. }
  12088. function pipelinePrimaryTopicReference() {
  12089. return (0, builder_1.default)("PipelinePrimaryTopicReference", ...arguments);
  12090. }
  12091. function tsParameterProperty(parameter) {
  12092. return (0, builder_1.default)("TSParameterProperty", ...arguments);
  12093. }
  12094. function tsDeclareFunction(id, typeParameters, params, returnType) {
  12095. return (0, builder_1.default)("TSDeclareFunction", ...arguments);
  12096. }
  12097. function tsDeclareMethod(decorators, key, typeParameters, params, returnType) {
  12098. return (0, builder_1.default)("TSDeclareMethod", ...arguments);
  12099. }
  12100. function tsQualifiedName(left, right) {
  12101. return (0, builder_1.default)("TSQualifiedName", ...arguments);
  12102. }
  12103. function tsCallSignatureDeclaration(typeParameters, parameters, typeAnnotation) {
  12104. return (0, builder_1.default)("TSCallSignatureDeclaration", ...arguments);
  12105. }
  12106. function tsConstructSignatureDeclaration(typeParameters, parameters, typeAnnotation) {
  12107. return (0, builder_1.default)("TSConstructSignatureDeclaration", ...arguments);
  12108. }
  12109. function tsPropertySignature(key, typeAnnotation, initializer) {
  12110. return (0, builder_1.default)("TSPropertySignature", ...arguments);
  12111. }
  12112. function tsMethodSignature(key, typeParameters, parameters, typeAnnotation) {
  12113. return (0, builder_1.default)("TSMethodSignature", ...arguments);
  12114. }
  12115. function tsIndexSignature(parameters, typeAnnotation) {
  12116. return (0, builder_1.default)("TSIndexSignature", ...arguments);
  12117. }
  12118. function tsAnyKeyword() {
  12119. return (0, builder_1.default)("TSAnyKeyword", ...arguments);
  12120. }
  12121. function tsBooleanKeyword() {
  12122. return (0, builder_1.default)("TSBooleanKeyword", ...arguments);
  12123. }
  12124. function tsBigIntKeyword() {
  12125. return (0, builder_1.default)("TSBigIntKeyword", ...arguments);
  12126. }
  12127. function tsIntrinsicKeyword() {
  12128. return (0, builder_1.default)("TSIntrinsicKeyword", ...arguments);
  12129. }
  12130. function tsNeverKeyword() {
  12131. return (0, builder_1.default)("TSNeverKeyword", ...arguments);
  12132. }
  12133. function tsNullKeyword() {
  12134. return (0, builder_1.default)("TSNullKeyword", ...arguments);
  12135. }
  12136. function tsNumberKeyword() {
  12137. return (0, builder_1.default)("TSNumberKeyword", ...arguments);
  12138. }
  12139. function tsObjectKeyword() {
  12140. return (0, builder_1.default)("TSObjectKeyword", ...arguments);
  12141. }
  12142. function tsStringKeyword() {
  12143. return (0, builder_1.default)("TSStringKeyword", ...arguments);
  12144. }
  12145. function tsSymbolKeyword() {
  12146. return (0, builder_1.default)("TSSymbolKeyword", ...arguments);
  12147. }
  12148. function tsUndefinedKeyword() {
  12149. return (0, builder_1.default)("TSUndefinedKeyword", ...arguments);
  12150. }
  12151. function tsUnknownKeyword() {
  12152. return (0, builder_1.default)("TSUnknownKeyword", ...arguments);
  12153. }
  12154. function tsVoidKeyword() {
  12155. return (0, builder_1.default)("TSVoidKeyword", ...arguments);
  12156. }
  12157. function tsThisType() {
  12158. return (0, builder_1.default)("TSThisType", ...arguments);
  12159. }
  12160. function tsFunctionType(typeParameters, parameters, typeAnnotation) {
  12161. return (0, builder_1.default)("TSFunctionType", ...arguments);
  12162. }
  12163. function tsConstructorType(typeParameters, parameters, typeAnnotation) {
  12164. return (0, builder_1.default)("TSConstructorType", ...arguments);
  12165. }
  12166. function tsTypeReference(typeName, typeParameters) {
  12167. return (0, builder_1.default)("TSTypeReference", ...arguments);
  12168. }
  12169. function tsTypePredicate(parameterName, typeAnnotation, asserts) {
  12170. return (0, builder_1.default)("TSTypePredicate", ...arguments);
  12171. }
  12172. function tsTypeQuery(exprName) {
  12173. return (0, builder_1.default)("TSTypeQuery", ...arguments);
  12174. }
  12175. function tsTypeLiteral(members) {
  12176. return (0, builder_1.default)("TSTypeLiteral", ...arguments);
  12177. }
  12178. function tsArrayType(elementType) {
  12179. return (0, builder_1.default)("TSArrayType", ...arguments);
  12180. }
  12181. function tsTupleType(elementTypes) {
  12182. return (0, builder_1.default)("TSTupleType", ...arguments);
  12183. }
  12184. function tsOptionalType(typeAnnotation) {
  12185. return (0, builder_1.default)("TSOptionalType", ...arguments);
  12186. }
  12187. function tsRestType(typeAnnotation) {
  12188. return (0, builder_1.default)("TSRestType", ...arguments);
  12189. }
  12190. function tsNamedTupleMember(label, elementType, optional) {
  12191. return (0, builder_1.default)("TSNamedTupleMember", ...arguments);
  12192. }
  12193. function tsUnionType(types) {
  12194. return (0, builder_1.default)("TSUnionType", ...arguments);
  12195. }
  12196. function tsIntersectionType(types) {
  12197. return (0, builder_1.default)("TSIntersectionType", ...arguments);
  12198. }
  12199. function tsConditionalType(checkType, extendsType, trueType, falseType) {
  12200. return (0, builder_1.default)("TSConditionalType", ...arguments);
  12201. }
  12202. function tsInferType(typeParameter) {
  12203. return (0, builder_1.default)("TSInferType", ...arguments);
  12204. }
  12205. function tsParenthesizedType(typeAnnotation) {
  12206. return (0, builder_1.default)("TSParenthesizedType", ...arguments);
  12207. }
  12208. function tsTypeOperator(typeAnnotation) {
  12209. return (0, builder_1.default)("TSTypeOperator", ...arguments);
  12210. }
  12211. function tsIndexedAccessType(objectType, indexType) {
  12212. return (0, builder_1.default)("TSIndexedAccessType", ...arguments);
  12213. }
  12214. function tsMappedType(typeParameter, typeAnnotation, nameType) {
  12215. return (0, builder_1.default)("TSMappedType", ...arguments);
  12216. }
  12217. function tsLiteralType(literal) {
  12218. return (0, builder_1.default)("TSLiteralType", ...arguments);
  12219. }
  12220. function tsExpressionWithTypeArguments(expression, typeParameters) {
  12221. return (0, builder_1.default)("TSExpressionWithTypeArguments", ...arguments);
  12222. }
  12223. function tsInterfaceDeclaration(id, typeParameters, _extends, body) {
  12224. return (0, builder_1.default)("TSInterfaceDeclaration", ...arguments);
  12225. }
  12226. function tsInterfaceBody(body) {
  12227. return (0, builder_1.default)("TSInterfaceBody", ...arguments);
  12228. }
  12229. function tsTypeAliasDeclaration(id, typeParameters, typeAnnotation) {
  12230. return (0, builder_1.default)("TSTypeAliasDeclaration", ...arguments);
  12231. }
  12232. function tsAsExpression(expression, typeAnnotation) {
  12233. return (0, builder_1.default)("TSAsExpression", ...arguments);
  12234. }
  12235. function tsTypeAssertion(typeAnnotation, expression) {
  12236. return (0, builder_1.default)("TSTypeAssertion", ...arguments);
  12237. }
  12238. function tsEnumDeclaration(id, members) {
  12239. return (0, builder_1.default)("TSEnumDeclaration", ...arguments);
  12240. }
  12241. function tsEnumMember(id, initializer) {
  12242. return (0, builder_1.default)("TSEnumMember", ...arguments);
  12243. }
  12244. function tsModuleDeclaration(id, body) {
  12245. return (0, builder_1.default)("TSModuleDeclaration", ...arguments);
  12246. }
  12247. function tsModuleBlock(body) {
  12248. return (0, builder_1.default)("TSModuleBlock", ...arguments);
  12249. }
  12250. function tsImportType(argument, qualifier, typeParameters) {
  12251. return (0, builder_1.default)("TSImportType", ...arguments);
  12252. }
  12253. function tsImportEqualsDeclaration(id, moduleReference) {
  12254. return (0, builder_1.default)("TSImportEqualsDeclaration", ...arguments);
  12255. }
  12256. function tsExternalModuleReference(expression) {
  12257. return (0, builder_1.default)("TSExternalModuleReference", ...arguments);
  12258. }
  12259. function tsNonNullExpression(expression) {
  12260. return (0, builder_1.default)("TSNonNullExpression", ...arguments);
  12261. }
  12262. function tsExportAssignment(expression) {
  12263. return (0, builder_1.default)("TSExportAssignment", ...arguments);
  12264. }
  12265. function tsNamespaceExportDeclaration(id) {
  12266. return (0, builder_1.default)("TSNamespaceExportDeclaration", ...arguments);
  12267. }
  12268. function tsTypeAnnotation(typeAnnotation) {
  12269. return (0, builder_1.default)("TSTypeAnnotation", ...arguments);
  12270. }
  12271. function tsTypeParameterInstantiation(params) {
  12272. return (0, builder_1.default)("TSTypeParameterInstantiation", ...arguments);
  12273. }
  12274. function tsTypeParameterDeclaration(params) {
  12275. return (0, builder_1.default)("TSTypeParameterDeclaration", ...arguments);
  12276. }
  12277. function tsTypeParameter(constraint, _default, name) {
  12278. return (0, builder_1.default)("TSTypeParameter", ...arguments);
  12279. }
  12280. function NumberLiteral(...args) {
  12281. console.trace("The node type NumberLiteral has been renamed to NumericLiteral");
  12282. return (0, builder_1.default)("NumberLiteral", ...args);
  12283. }
  12284. function RegexLiteral(...args) {
  12285. console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
  12286. return (0, builder_1.default)("RegexLiteral", ...args);
  12287. }
  12288. function RestProperty(...args) {
  12289. console.trace("The node type RestProperty has been renamed to RestElement");
  12290. return (0, builder_1.default)("RestProperty", ...args);
  12291. }
  12292. function SpreadProperty(...args) {
  12293. console.trace("The node type SpreadProperty has been renamed to SpreadElement");
  12294. return (0, builder_1.default)("SpreadProperty", ...args);
  12295. }
  12296. });
  12297. var _default$a = cleanJSXElementLiteralChild;
  12298. function cleanJSXElementLiteralChild(child, args) {
  12299. const lines = child.value.split(/\r\n|\n|\r/);
  12300. let lastNonEmptyLine = 0;
  12301. for (let i = 0; i < lines.length; i++) {
  12302. if (lines[i].match(/[^ \t]/)) {
  12303. lastNonEmptyLine = i;
  12304. }
  12305. }
  12306. let str = "";
  12307. for (let i = 0; i < lines.length; i++) {
  12308. const line = lines[i];
  12309. const isFirstLine = i === 0;
  12310. const isLastLine = i === lines.length - 1;
  12311. const isLastNonEmptyLine = i === lastNonEmptyLine;
  12312. let trimmedLine = line.replace(/\t/g, " ");
  12313. if (!isFirstLine) {
  12314. trimmedLine = trimmedLine.replace(/^[ ]+/, "");
  12315. }
  12316. if (!isLastLine) {
  12317. trimmedLine = trimmedLine.replace(/[ ]+$/, "");
  12318. }
  12319. if (trimmedLine) {
  12320. if (!isLastNonEmptyLine) {
  12321. trimmedLine += " ";
  12322. }
  12323. str += trimmedLine;
  12324. }
  12325. }
  12326. if (str) args.push((0, generated$1.stringLiteral)(str));
  12327. }
  12328. var cleanJSXElementLiteralChild_1 = /*#__PURE__*/Object.defineProperty({
  12329. default: _default$a
  12330. }, '__esModule', {value: true});
  12331. var _default$b = buildChildren;
  12332. function buildChildren(node) {
  12333. const elements = [];
  12334. for (let i = 0; i < node.children.length; i++) {
  12335. let child = node.children[i];
  12336. if ((0, generated.isJSXText)(child)) {
  12337. (0, cleanJSXElementLiteralChild_1.default)(child, elements);
  12338. continue;
  12339. }
  12340. if ((0, generated.isJSXExpressionContainer)(child)) child = child.expression;
  12341. if ((0, generated.isJSXEmptyExpression)(child)) continue;
  12342. elements.push(child);
  12343. }
  12344. return elements;
  12345. }
  12346. var buildChildren_1 = /*#__PURE__*/Object.defineProperty({
  12347. default: _default$b
  12348. }, '__esModule', {value: true});
  12349. var _default$c = isNode;
  12350. function isNode(node) {
  12351. return !!(node && definitions.VISITOR_KEYS[node.type]);
  12352. }
  12353. var isNode_1 = /*#__PURE__*/Object.defineProperty({
  12354. default: _default$c
  12355. }, '__esModule', {value: true});
  12356. var _default$d = assertNode;
  12357. function assertNode(node) {
  12358. if (!(0, isNode_1.default)(node)) {
  12359. var _node$type;
  12360. const type = (_node$type = node == null ? void 0 : node.type) != null ? _node$type : JSON.stringify(node);
  12361. throw new TypeError(`Not a valid node of type "${type}"`);
  12362. }
  12363. }
  12364. var assertNode_1 = /*#__PURE__*/Object.defineProperty({
  12365. default: _default$d
  12366. }, '__esModule', {value: true});
  12367. var assertArrayExpression_1 = assertArrayExpression;
  12368. var assertAssignmentExpression_1 = assertAssignmentExpression;
  12369. var assertBinaryExpression_1 = assertBinaryExpression;
  12370. var assertInterpreterDirective_1 = assertInterpreterDirective;
  12371. var assertDirective_1 = assertDirective;
  12372. var assertDirectiveLiteral_1 = assertDirectiveLiteral;
  12373. var assertBlockStatement_1 = assertBlockStatement;
  12374. var assertBreakStatement_1 = assertBreakStatement;
  12375. var assertCallExpression_1 = assertCallExpression;
  12376. var assertCatchClause_1 = assertCatchClause;
  12377. var assertConditionalExpression_1 = assertConditionalExpression;
  12378. var assertContinueStatement_1 = assertContinueStatement;
  12379. var assertDebuggerStatement_1 = assertDebuggerStatement;
  12380. var assertDoWhileStatement_1 = assertDoWhileStatement;
  12381. var assertEmptyStatement_1 = assertEmptyStatement;
  12382. var assertExpressionStatement_1 = assertExpressionStatement;
  12383. var assertFile_1 = assertFile;
  12384. var assertForInStatement_1 = assertForInStatement;
  12385. var assertForStatement_1 = assertForStatement;
  12386. var assertFunctionDeclaration_1 = assertFunctionDeclaration;
  12387. var assertFunctionExpression_1 = assertFunctionExpression;
  12388. var assertIdentifier_1 = assertIdentifier;
  12389. var assertIfStatement_1 = assertIfStatement;
  12390. var assertLabeledStatement_1 = assertLabeledStatement;
  12391. var assertStringLiteral_1 = assertStringLiteral;
  12392. var assertNumericLiteral_1 = assertNumericLiteral;
  12393. var assertNullLiteral_1 = assertNullLiteral;
  12394. var assertBooleanLiteral_1 = assertBooleanLiteral;
  12395. var assertRegExpLiteral_1 = assertRegExpLiteral;
  12396. var assertLogicalExpression_1 = assertLogicalExpression;
  12397. var assertMemberExpression_1 = assertMemberExpression;
  12398. var assertNewExpression_1 = assertNewExpression;
  12399. var assertProgram_1 = assertProgram;
  12400. var assertObjectExpression_1 = assertObjectExpression;
  12401. var assertObjectMethod_1 = assertObjectMethod;
  12402. var assertObjectProperty_1 = assertObjectProperty;
  12403. var assertRestElement_1 = assertRestElement;
  12404. var assertReturnStatement_1 = assertReturnStatement;
  12405. var assertSequenceExpression_1 = assertSequenceExpression;
  12406. var assertParenthesizedExpression_1 = assertParenthesizedExpression;
  12407. var assertSwitchCase_1 = assertSwitchCase;
  12408. var assertSwitchStatement_1 = assertSwitchStatement;
  12409. var assertThisExpression_1 = assertThisExpression;
  12410. var assertThrowStatement_1 = assertThrowStatement;
  12411. var assertTryStatement_1 = assertTryStatement;
  12412. var assertUnaryExpression_1 = assertUnaryExpression;
  12413. var assertUpdateExpression_1 = assertUpdateExpression;
  12414. var assertVariableDeclaration_1 = assertVariableDeclaration;
  12415. var assertVariableDeclarator_1 = assertVariableDeclarator;
  12416. var assertWhileStatement_1 = assertWhileStatement;
  12417. var assertWithStatement_1 = assertWithStatement;
  12418. var assertAssignmentPattern_1 = assertAssignmentPattern;
  12419. var assertArrayPattern_1 = assertArrayPattern;
  12420. var assertArrowFunctionExpression_1 = assertArrowFunctionExpression;
  12421. var assertClassBody_1 = assertClassBody;
  12422. var assertClassExpression_1 = assertClassExpression;
  12423. var assertClassDeclaration_1 = assertClassDeclaration;
  12424. var assertExportAllDeclaration_1 = assertExportAllDeclaration;
  12425. var assertExportDefaultDeclaration_1 = assertExportDefaultDeclaration;
  12426. var assertExportNamedDeclaration_1 = assertExportNamedDeclaration;
  12427. var assertExportSpecifier_1 = assertExportSpecifier;
  12428. var assertForOfStatement_1 = assertForOfStatement;
  12429. var assertImportDeclaration_1 = assertImportDeclaration;
  12430. var assertImportDefaultSpecifier_1 = assertImportDefaultSpecifier;
  12431. var assertImportNamespaceSpecifier_1 = assertImportNamespaceSpecifier;
  12432. var assertImportSpecifier_1 = assertImportSpecifier;
  12433. var assertMetaProperty_1 = assertMetaProperty;
  12434. var assertClassMethod_1 = assertClassMethod;
  12435. var assertObjectPattern_1 = assertObjectPattern;
  12436. var assertSpreadElement_1 = assertSpreadElement;
  12437. var assertSuper_1 = assertSuper;
  12438. var assertTaggedTemplateExpression_1 = assertTaggedTemplateExpression;
  12439. var assertTemplateElement_1 = assertTemplateElement;
  12440. var assertTemplateLiteral_1 = assertTemplateLiteral;
  12441. var assertYieldExpression_1 = assertYieldExpression;
  12442. var assertAwaitExpression_1 = assertAwaitExpression;
  12443. var assertImport_1 = assertImport;
  12444. var assertBigIntLiteral_1 = assertBigIntLiteral;
  12445. var assertExportNamespaceSpecifier_1 = assertExportNamespaceSpecifier;
  12446. var assertOptionalMemberExpression_1 = assertOptionalMemberExpression;
  12447. var assertOptionalCallExpression_1 = assertOptionalCallExpression;
  12448. var assertClassProperty_1 = assertClassProperty;
  12449. var assertClassPrivateProperty_1 = assertClassPrivateProperty;
  12450. var assertClassPrivateMethod_1 = assertClassPrivateMethod;
  12451. var assertPrivateName_1 = assertPrivateName;
  12452. var assertAnyTypeAnnotation_1 = assertAnyTypeAnnotation;
  12453. var assertArrayTypeAnnotation_1 = assertArrayTypeAnnotation;
  12454. var assertBooleanTypeAnnotation_1 = assertBooleanTypeAnnotation;
  12455. var assertBooleanLiteralTypeAnnotation_1 = assertBooleanLiteralTypeAnnotation;
  12456. var assertNullLiteralTypeAnnotation_1 = assertNullLiteralTypeAnnotation;
  12457. var assertClassImplements_1 = assertClassImplements;
  12458. var assertDeclareClass_1 = assertDeclareClass;
  12459. var assertDeclareFunction_1 = assertDeclareFunction;
  12460. var assertDeclareInterface_1 = assertDeclareInterface;
  12461. var assertDeclareModule_1 = assertDeclareModule;
  12462. var assertDeclareModuleExports_1 = assertDeclareModuleExports;
  12463. var assertDeclareTypeAlias_1 = assertDeclareTypeAlias;
  12464. var assertDeclareOpaqueType_1 = assertDeclareOpaqueType;
  12465. var assertDeclareVariable_1 = assertDeclareVariable;
  12466. var assertDeclareExportDeclaration_1 = assertDeclareExportDeclaration;
  12467. var assertDeclareExportAllDeclaration_1 = assertDeclareExportAllDeclaration;
  12468. var assertDeclaredPredicate_1 = assertDeclaredPredicate;
  12469. var assertExistsTypeAnnotation_1 = assertExistsTypeAnnotation;
  12470. var assertFunctionTypeAnnotation_1 = assertFunctionTypeAnnotation;
  12471. var assertFunctionTypeParam_1 = assertFunctionTypeParam;
  12472. var assertGenericTypeAnnotation_1 = assertGenericTypeAnnotation;
  12473. var assertInferredPredicate_1 = assertInferredPredicate;
  12474. var assertInterfaceExtends_1 = assertInterfaceExtends;
  12475. var assertInterfaceDeclaration_1 = assertInterfaceDeclaration;
  12476. var assertInterfaceTypeAnnotation_1 = assertInterfaceTypeAnnotation;
  12477. var assertIntersectionTypeAnnotation_1 = assertIntersectionTypeAnnotation;
  12478. var assertMixedTypeAnnotation_1 = assertMixedTypeAnnotation;
  12479. var assertEmptyTypeAnnotation_1 = assertEmptyTypeAnnotation;
  12480. var assertNullableTypeAnnotation_1 = assertNullableTypeAnnotation;
  12481. var assertNumberLiteralTypeAnnotation_1 = assertNumberLiteralTypeAnnotation;
  12482. var assertNumberTypeAnnotation_1 = assertNumberTypeAnnotation;
  12483. var assertObjectTypeAnnotation_1 = assertObjectTypeAnnotation;
  12484. var assertObjectTypeInternalSlot_1 = assertObjectTypeInternalSlot;
  12485. var assertObjectTypeCallProperty_1 = assertObjectTypeCallProperty;
  12486. var assertObjectTypeIndexer_1 = assertObjectTypeIndexer;
  12487. var assertObjectTypeProperty_1 = assertObjectTypeProperty;
  12488. var assertObjectTypeSpreadProperty_1 = assertObjectTypeSpreadProperty;
  12489. var assertOpaqueType_1 = assertOpaqueType;
  12490. var assertQualifiedTypeIdentifier_1 = assertQualifiedTypeIdentifier;
  12491. var assertStringLiteralTypeAnnotation_1 = assertStringLiteralTypeAnnotation;
  12492. var assertStringTypeAnnotation_1 = assertStringTypeAnnotation;
  12493. var assertSymbolTypeAnnotation_1 = assertSymbolTypeAnnotation;
  12494. var assertThisTypeAnnotation_1 = assertThisTypeAnnotation;
  12495. var assertTupleTypeAnnotation_1 = assertTupleTypeAnnotation;
  12496. var assertTypeofTypeAnnotation_1 = assertTypeofTypeAnnotation;
  12497. var assertTypeAlias_1 = assertTypeAlias;
  12498. var assertTypeAnnotation_1 = assertTypeAnnotation;
  12499. var assertTypeCastExpression_1 = assertTypeCastExpression;
  12500. var assertTypeParameter_1 = assertTypeParameter;
  12501. var assertTypeParameterDeclaration_1 = assertTypeParameterDeclaration;
  12502. var assertTypeParameterInstantiation_1 = assertTypeParameterInstantiation;
  12503. var assertUnionTypeAnnotation_1 = assertUnionTypeAnnotation;
  12504. var assertVariance_1 = assertVariance;
  12505. var assertVoidTypeAnnotation_1 = assertVoidTypeAnnotation;
  12506. var assertEnumDeclaration_1 = assertEnumDeclaration;
  12507. var assertEnumBooleanBody_1 = assertEnumBooleanBody;
  12508. var assertEnumNumberBody_1 = assertEnumNumberBody;
  12509. var assertEnumStringBody_1 = assertEnumStringBody;
  12510. var assertEnumSymbolBody_1 = assertEnumSymbolBody;
  12511. var assertEnumBooleanMember_1 = assertEnumBooleanMember;
  12512. var assertEnumNumberMember_1 = assertEnumNumberMember;
  12513. var assertEnumStringMember_1 = assertEnumStringMember;
  12514. var assertEnumDefaultedMember_1 = assertEnumDefaultedMember;
  12515. var assertIndexedAccessType_1 = assertIndexedAccessType;
  12516. var assertOptionalIndexedAccessType_1 = assertOptionalIndexedAccessType;
  12517. var assertJSXAttribute_1 = assertJSXAttribute;
  12518. var assertJSXClosingElement_1 = assertJSXClosingElement;
  12519. var assertJSXElement_1 = assertJSXElement;
  12520. var assertJSXEmptyExpression_1 = assertJSXEmptyExpression;
  12521. var assertJSXExpressionContainer_1 = assertJSXExpressionContainer;
  12522. var assertJSXSpreadChild_1 = assertJSXSpreadChild;
  12523. var assertJSXIdentifier_1 = assertJSXIdentifier;
  12524. var assertJSXMemberExpression_1 = assertJSXMemberExpression;
  12525. var assertJSXNamespacedName_1 = assertJSXNamespacedName;
  12526. var assertJSXOpeningElement_1 = assertJSXOpeningElement;
  12527. var assertJSXSpreadAttribute_1 = assertJSXSpreadAttribute;
  12528. var assertJSXText_1 = assertJSXText;
  12529. var assertJSXFragment_1 = assertJSXFragment;
  12530. var assertJSXOpeningFragment_1 = assertJSXOpeningFragment;
  12531. var assertJSXClosingFragment_1 = assertJSXClosingFragment;
  12532. var assertNoop_1 = assertNoop;
  12533. var assertPlaceholder_1 = assertPlaceholder;
  12534. var assertV8IntrinsicIdentifier_1 = assertV8IntrinsicIdentifier;
  12535. var assertArgumentPlaceholder_1 = assertArgumentPlaceholder;
  12536. var assertBindExpression_1 = assertBindExpression;
  12537. var assertImportAttribute_1 = assertImportAttribute;
  12538. var assertDecorator_1 = assertDecorator;
  12539. var assertDoExpression_1 = assertDoExpression;
  12540. var assertExportDefaultSpecifier_1 = assertExportDefaultSpecifier;
  12541. var assertRecordExpression_1 = assertRecordExpression;
  12542. var assertTupleExpression_1 = assertTupleExpression;
  12543. var assertDecimalLiteral_1 = assertDecimalLiteral;
  12544. var assertStaticBlock_1 = assertStaticBlock;
  12545. var assertModuleExpression_1 = assertModuleExpression;
  12546. var assertTopicReference_1 = assertTopicReference;
  12547. var assertPipelineTopicExpression_1 = assertPipelineTopicExpression;
  12548. var assertPipelineBareFunction_1 = assertPipelineBareFunction;
  12549. var assertPipelinePrimaryTopicReference_1 = assertPipelinePrimaryTopicReference;
  12550. var assertTSParameterProperty_1 = assertTSParameterProperty;
  12551. var assertTSDeclareFunction_1 = assertTSDeclareFunction;
  12552. var assertTSDeclareMethod_1 = assertTSDeclareMethod;
  12553. var assertTSQualifiedName_1 = assertTSQualifiedName;
  12554. var assertTSCallSignatureDeclaration_1 = assertTSCallSignatureDeclaration;
  12555. var assertTSConstructSignatureDeclaration_1 = assertTSConstructSignatureDeclaration;
  12556. var assertTSPropertySignature_1 = assertTSPropertySignature;
  12557. var assertTSMethodSignature_1 = assertTSMethodSignature;
  12558. var assertTSIndexSignature_1 = assertTSIndexSignature;
  12559. var assertTSAnyKeyword_1 = assertTSAnyKeyword;
  12560. var assertTSBooleanKeyword_1 = assertTSBooleanKeyword;
  12561. var assertTSBigIntKeyword_1 = assertTSBigIntKeyword;
  12562. var assertTSIntrinsicKeyword_1 = assertTSIntrinsicKeyword;
  12563. var assertTSNeverKeyword_1 = assertTSNeverKeyword;
  12564. var assertTSNullKeyword_1 = assertTSNullKeyword;
  12565. var assertTSNumberKeyword_1 = assertTSNumberKeyword;
  12566. var assertTSObjectKeyword_1 = assertTSObjectKeyword;
  12567. var assertTSStringKeyword_1 = assertTSStringKeyword;
  12568. var assertTSSymbolKeyword_1 = assertTSSymbolKeyword;
  12569. var assertTSUndefinedKeyword_1 = assertTSUndefinedKeyword;
  12570. var assertTSUnknownKeyword_1 = assertTSUnknownKeyword;
  12571. var assertTSVoidKeyword_1 = assertTSVoidKeyword;
  12572. var assertTSThisType_1 = assertTSThisType;
  12573. var assertTSFunctionType_1 = assertTSFunctionType;
  12574. var assertTSConstructorType_1 = assertTSConstructorType;
  12575. var assertTSTypeReference_1 = assertTSTypeReference;
  12576. var assertTSTypePredicate_1 = assertTSTypePredicate;
  12577. var assertTSTypeQuery_1 = assertTSTypeQuery;
  12578. var assertTSTypeLiteral_1 = assertTSTypeLiteral;
  12579. var assertTSArrayType_1 = assertTSArrayType;
  12580. var assertTSTupleType_1 = assertTSTupleType;
  12581. var assertTSOptionalType_1 = assertTSOptionalType;
  12582. var assertTSRestType_1 = assertTSRestType;
  12583. var assertTSNamedTupleMember_1 = assertTSNamedTupleMember;
  12584. var assertTSUnionType_1 = assertTSUnionType;
  12585. var assertTSIntersectionType_1 = assertTSIntersectionType;
  12586. var assertTSConditionalType_1 = assertTSConditionalType;
  12587. var assertTSInferType_1 = assertTSInferType;
  12588. var assertTSParenthesizedType_1 = assertTSParenthesizedType;
  12589. var assertTSTypeOperator_1 = assertTSTypeOperator;
  12590. var assertTSIndexedAccessType_1 = assertTSIndexedAccessType;
  12591. var assertTSMappedType_1 = assertTSMappedType;
  12592. var assertTSLiteralType_1 = assertTSLiteralType;
  12593. var assertTSExpressionWithTypeArguments_1 = assertTSExpressionWithTypeArguments;
  12594. var assertTSInterfaceDeclaration_1 = assertTSInterfaceDeclaration;
  12595. var assertTSInterfaceBody_1 = assertTSInterfaceBody;
  12596. var assertTSTypeAliasDeclaration_1 = assertTSTypeAliasDeclaration;
  12597. var assertTSAsExpression_1 = assertTSAsExpression;
  12598. var assertTSTypeAssertion_1 = assertTSTypeAssertion;
  12599. var assertTSEnumDeclaration_1 = assertTSEnumDeclaration;
  12600. var assertTSEnumMember_1 = assertTSEnumMember;
  12601. var assertTSModuleDeclaration_1 = assertTSModuleDeclaration;
  12602. var assertTSModuleBlock_1 = assertTSModuleBlock;
  12603. var assertTSImportType_1 = assertTSImportType;
  12604. var assertTSImportEqualsDeclaration_1 = assertTSImportEqualsDeclaration;
  12605. var assertTSExternalModuleReference_1 = assertTSExternalModuleReference;
  12606. var assertTSNonNullExpression_1 = assertTSNonNullExpression;
  12607. var assertTSExportAssignment_1 = assertTSExportAssignment;
  12608. var assertTSNamespaceExportDeclaration_1 = assertTSNamespaceExportDeclaration;
  12609. var assertTSTypeAnnotation_1 = assertTSTypeAnnotation;
  12610. var assertTSTypeParameterInstantiation_1 = assertTSTypeParameterInstantiation;
  12611. var assertTSTypeParameterDeclaration_1 = assertTSTypeParameterDeclaration;
  12612. var assertTSTypeParameter_1 = assertTSTypeParameter;
  12613. var assertExpression_1 = assertExpression;
  12614. var assertBinary_1 = assertBinary;
  12615. var assertScopable_1 = assertScopable;
  12616. var assertBlockParent_1 = assertBlockParent;
  12617. var assertBlock_1 = assertBlock;
  12618. var assertStatement_1 = assertStatement;
  12619. var assertTerminatorless_1 = assertTerminatorless;
  12620. var assertCompletionStatement_1 = assertCompletionStatement;
  12621. var assertConditional_1 = assertConditional;
  12622. var assertLoop_1 = assertLoop;
  12623. var assertWhile_1 = assertWhile;
  12624. var assertExpressionWrapper_1 = assertExpressionWrapper;
  12625. var assertFor_1 = assertFor;
  12626. var assertForXStatement_1 = assertForXStatement;
  12627. var assertFunction_1 = assertFunction;
  12628. var assertFunctionParent_1 = assertFunctionParent;
  12629. var assertPureish_1 = assertPureish;
  12630. var assertDeclaration_1 = assertDeclaration;
  12631. var assertPatternLike_1 = assertPatternLike;
  12632. var assertLVal_1 = assertLVal;
  12633. var assertTSEntityName_1 = assertTSEntityName;
  12634. var assertLiteral_1 = assertLiteral;
  12635. var assertImmutable_1 = assertImmutable;
  12636. var assertUserWhitespacable_1 = assertUserWhitespacable;
  12637. var assertMethod_1 = assertMethod;
  12638. var assertObjectMember_1 = assertObjectMember;
  12639. var assertProperty_1 = assertProperty;
  12640. var assertUnaryLike_1 = assertUnaryLike;
  12641. var assertPattern_1 = assertPattern;
  12642. var assertClass_1 = assertClass;
  12643. var assertModuleDeclaration_1 = assertModuleDeclaration;
  12644. var assertExportDeclaration_1 = assertExportDeclaration;
  12645. var assertModuleSpecifier_1 = assertModuleSpecifier;
  12646. var assertPrivate_1 = assertPrivate;
  12647. var assertFlow_1 = assertFlow;
  12648. var assertFlowType_1 = assertFlowType;
  12649. var assertFlowBaseAnnotation_1 = assertFlowBaseAnnotation;
  12650. var assertFlowDeclaration_1 = assertFlowDeclaration;
  12651. var assertFlowPredicate_1 = assertFlowPredicate;
  12652. var assertEnumBody_1 = assertEnumBody;
  12653. var assertEnumMember_1 = assertEnumMember;
  12654. var assertJSX_1 = assertJSX;
  12655. var assertTSTypeElement_1 = assertTSTypeElement;
  12656. var assertTSType_1 = assertTSType;
  12657. var assertTSBaseType_1 = assertTSBaseType;
  12658. var assertNumberLiteral_1 = assertNumberLiteral;
  12659. var assertRegexLiteral_1 = assertRegexLiteral;
  12660. var assertRestProperty_1 = assertRestProperty;
  12661. var assertSpreadProperty_1 = assertSpreadProperty;
  12662. function assert$1(type, node, opts) {
  12663. if (!(0, is_1.default)(type, node, opts)) {
  12664. throw new Error(`Expected type "${type}" with option ${JSON.stringify(opts)}, ` + `but instead got "${node.type}".`);
  12665. }
  12666. }
  12667. function assertArrayExpression(node, opts) {
  12668. assert$1("ArrayExpression", node, opts);
  12669. }
  12670. function assertAssignmentExpression(node, opts) {
  12671. assert$1("AssignmentExpression", node, opts);
  12672. }
  12673. function assertBinaryExpression(node, opts) {
  12674. assert$1("BinaryExpression", node, opts);
  12675. }
  12676. function assertInterpreterDirective(node, opts) {
  12677. assert$1("InterpreterDirective", node, opts);
  12678. }
  12679. function assertDirective(node, opts) {
  12680. assert$1("Directive", node, opts);
  12681. }
  12682. function assertDirectiveLiteral(node, opts) {
  12683. assert$1("DirectiveLiteral", node, opts);
  12684. }
  12685. function assertBlockStatement(node, opts) {
  12686. assert$1("BlockStatement", node, opts);
  12687. }
  12688. function assertBreakStatement(node, opts) {
  12689. assert$1("BreakStatement", node, opts);
  12690. }
  12691. function assertCallExpression(node, opts) {
  12692. assert$1("CallExpression", node, opts);
  12693. }
  12694. function assertCatchClause(node, opts) {
  12695. assert$1("CatchClause", node, opts);
  12696. }
  12697. function assertConditionalExpression(node, opts) {
  12698. assert$1("ConditionalExpression", node, opts);
  12699. }
  12700. function assertContinueStatement(node, opts) {
  12701. assert$1("ContinueStatement", node, opts);
  12702. }
  12703. function assertDebuggerStatement(node, opts) {
  12704. assert$1("DebuggerStatement", node, opts);
  12705. }
  12706. function assertDoWhileStatement(node, opts) {
  12707. assert$1("DoWhileStatement", node, opts);
  12708. }
  12709. function assertEmptyStatement(node, opts) {
  12710. assert$1("EmptyStatement", node, opts);
  12711. }
  12712. function assertExpressionStatement(node, opts) {
  12713. assert$1("ExpressionStatement", node, opts);
  12714. }
  12715. function assertFile(node, opts) {
  12716. assert$1("File", node, opts);
  12717. }
  12718. function assertForInStatement(node, opts) {
  12719. assert$1("ForInStatement", node, opts);
  12720. }
  12721. function assertForStatement(node, opts) {
  12722. assert$1("ForStatement", node, opts);
  12723. }
  12724. function assertFunctionDeclaration(node, opts) {
  12725. assert$1("FunctionDeclaration", node, opts);
  12726. }
  12727. function assertFunctionExpression(node, opts) {
  12728. assert$1("FunctionExpression", node, opts);
  12729. }
  12730. function assertIdentifier(node, opts) {
  12731. assert$1("Identifier", node, opts);
  12732. }
  12733. function assertIfStatement(node, opts) {
  12734. assert$1("IfStatement", node, opts);
  12735. }
  12736. function assertLabeledStatement(node, opts) {
  12737. assert$1("LabeledStatement", node, opts);
  12738. }
  12739. function assertStringLiteral(node, opts) {
  12740. assert$1("StringLiteral", node, opts);
  12741. }
  12742. function assertNumericLiteral(node, opts) {
  12743. assert$1("NumericLiteral", node, opts);
  12744. }
  12745. function assertNullLiteral(node, opts) {
  12746. assert$1("NullLiteral", node, opts);
  12747. }
  12748. function assertBooleanLiteral(node, opts) {
  12749. assert$1("BooleanLiteral", node, opts);
  12750. }
  12751. function assertRegExpLiteral(node, opts) {
  12752. assert$1("RegExpLiteral", node, opts);
  12753. }
  12754. function assertLogicalExpression(node, opts) {
  12755. assert$1("LogicalExpression", node, opts);
  12756. }
  12757. function assertMemberExpression(node, opts) {
  12758. assert$1("MemberExpression", node, opts);
  12759. }
  12760. function assertNewExpression(node, opts) {
  12761. assert$1("NewExpression", node, opts);
  12762. }
  12763. function assertProgram(node, opts) {
  12764. assert$1("Program", node, opts);
  12765. }
  12766. function assertObjectExpression(node, opts) {
  12767. assert$1("ObjectExpression", node, opts);
  12768. }
  12769. function assertObjectMethod(node, opts) {
  12770. assert$1("ObjectMethod", node, opts);
  12771. }
  12772. function assertObjectProperty(node, opts) {
  12773. assert$1("ObjectProperty", node, opts);
  12774. }
  12775. function assertRestElement(node, opts) {
  12776. assert$1("RestElement", node, opts);
  12777. }
  12778. function assertReturnStatement(node, opts) {
  12779. assert$1("ReturnStatement", node, opts);
  12780. }
  12781. function assertSequenceExpression(node, opts) {
  12782. assert$1("SequenceExpression", node, opts);
  12783. }
  12784. function assertParenthesizedExpression(node, opts) {
  12785. assert$1("ParenthesizedExpression", node, opts);
  12786. }
  12787. function assertSwitchCase(node, opts) {
  12788. assert$1("SwitchCase", node, opts);
  12789. }
  12790. function assertSwitchStatement(node, opts) {
  12791. assert$1("SwitchStatement", node, opts);
  12792. }
  12793. function assertThisExpression(node, opts) {
  12794. assert$1("ThisExpression", node, opts);
  12795. }
  12796. function assertThrowStatement(node, opts) {
  12797. assert$1("ThrowStatement", node, opts);
  12798. }
  12799. function assertTryStatement(node, opts) {
  12800. assert$1("TryStatement", node, opts);
  12801. }
  12802. function assertUnaryExpression(node, opts) {
  12803. assert$1("UnaryExpression", node, opts);
  12804. }
  12805. function assertUpdateExpression(node, opts) {
  12806. assert$1("UpdateExpression", node, opts);
  12807. }
  12808. function assertVariableDeclaration(node, opts) {
  12809. assert$1("VariableDeclaration", node, opts);
  12810. }
  12811. function assertVariableDeclarator(node, opts) {
  12812. assert$1("VariableDeclarator", node, opts);
  12813. }
  12814. function assertWhileStatement(node, opts) {
  12815. assert$1("WhileStatement", node, opts);
  12816. }
  12817. function assertWithStatement(node, opts) {
  12818. assert$1("WithStatement", node, opts);
  12819. }
  12820. function assertAssignmentPattern(node, opts) {
  12821. assert$1("AssignmentPattern", node, opts);
  12822. }
  12823. function assertArrayPattern(node, opts) {
  12824. assert$1("ArrayPattern", node, opts);
  12825. }
  12826. function assertArrowFunctionExpression(node, opts) {
  12827. assert$1("ArrowFunctionExpression", node, opts);
  12828. }
  12829. function assertClassBody(node, opts) {
  12830. assert$1("ClassBody", node, opts);
  12831. }
  12832. function assertClassExpression(node, opts) {
  12833. assert$1("ClassExpression", node, opts);
  12834. }
  12835. function assertClassDeclaration(node, opts) {
  12836. assert$1("ClassDeclaration", node, opts);
  12837. }
  12838. function assertExportAllDeclaration(node, opts) {
  12839. assert$1("ExportAllDeclaration", node, opts);
  12840. }
  12841. function assertExportDefaultDeclaration(node, opts) {
  12842. assert$1("ExportDefaultDeclaration", node, opts);
  12843. }
  12844. function assertExportNamedDeclaration(node, opts) {
  12845. assert$1("ExportNamedDeclaration", node, opts);
  12846. }
  12847. function assertExportSpecifier(node, opts) {
  12848. assert$1("ExportSpecifier", node, opts);
  12849. }
  12850. function assertForOfStatement(node, opts) {
  12851. assert$1("ForOfStatement", node, opts);
  12852. }
  12853. function assertImportDeclaration(node, opts) {
  12854. assert$1("ImportDeclaration", node, opts);
  12855. }
  12856. function assertImportDefaultSpecifier(node, opts) {
  12857. assert$1("ImportDefaultSpecifier", node, opts);
  12858. }
  12859. function assertImportNamespaceSpecifier(node, opts) {
  12860. assert$1("ImportNamespaceSpecifier", node, opts);
  12861. }
  12862. function assertImportSpecifier(node, opts) {
  12863. assert$1("ImportSpecifier", node, opts);
  12864. }
  12865. function assertMetaProperty(node, opts) {
  12866. assert$1("MetaProperty", node, opts);
  12867. }
  12868. function assertClassMethod(node, opts) {
  12869. assert$1("ClassMethod", node, opts);
  12870. }
  12871. function assertObjectPattern(node, opts) {
  12872. assert$1("ObjectPattern", node, opts);
  12873. }
  12874. function assertSpreadElement(node, opts) {
  12875. assert$1("SpreadElement", node, opts);
  12876. }
  12877. function assertSuper(node, opts) {
  12878. assert$1("Super", node, opts);
  12879. }
  12880. function assertTaggedTemplateExpression(node, opts) {
  12881. assert$1("TaggedTemplateExpression", node, opts);
  12882. }
  12883. function assertTemplateElement(node, opts) {
  12884. assert$1("TemplateElement", node, opts);
  12885. }
  12886. function assertTemplateLiteral(node, opts) {
  12887. assert$1("TemplateLiteral", node, opts);
  12888. }
  12889. function assertYieldExpression(node, opts) {
  12890. assert$1("YieldExpression", node, opts);
  12891. }
  12892. function assertAwaitExpression(node, opts) {
  12893. assert$1("AwaitExpression", node, opts);
  12894. }
  12895. function assertImport(node, opts) {
  12896. assert$1("Import", node, opts);
  12897. }
  12898. function assertBigIntLiteral(node, opts) {
  12899. assert$1("BigIntLiteral", node, opts);
  12900. }
  12901. function assertExportNamespaceSpecifier(node, opts) {
  12902. assert$1("ExportNamespaceSpecifier", node, opts);
  12903. }
  12904. function assertOptionalMemberExpression(node, opts) {
  12905. assert$1("OptionalMemberExpression", node, opts);
  12906. }
  12907. function assertOptionalCallExpression(node, opts) {
  12908. assert$1("OptionalCallExpression", node, opts);
  12909. }
  12910. function assertClassProperty(node, opts) {
  12911. assert$1("ClassProperty", node, opts);
  12912. }
  12913. function assertClassPrivateProperty(node, opts) {
  12914. assert$1("ClassPrivateProperty", node, opts);
  12915. }
  12916. function assertClassPrivateMethod(node, opts) {
  12917. assert$1("ClassPrivateMethod", node, opts);
  12918. }
  12919. function assertPrivateName(node, opts) {
  12920. assert$1("PrivateName", node, opts);
  12921. }
  12922. function assertAnyTypeAnnotation(node, opts) {
  12923. assert$1("AnyTypeAnnotation", node, opts);
  12924. }
  12925. function assertArrayTypeAnnotation(node, opts) {
  12926. assert$1("ArrayTypeAnnotation", node, opts);
  12927. }
  12928. function assertBooleanTypeAnnotation(node, opts) {
  12929. assert$1("BooleanTypeAnnotation", node, opts);
  12930. }
  12931. function assertBooleanLiteralTypeAnnotation(node, opts) {
  12932. assert$1("BooleanLiteralTypeAnnotation", node, opts);
  12933. }
  12934. function assertNullLiteralTypeAnnotation(node, opts) {
  12935. assert$1("NullLiteralTypeAnnotation", node, opts);
  12936. }
  12937. function assertClassImplements(node, opts) {
  12938. assert$1("ClassImplements", node, opts);
  12939. }
  12940. function assertDeclareClass(node, opts) {
  12941. assert$1("DeclareClass", node, opts);
  12942. }
  12943. function assertDeclareFunction(node, opts) {
  12944. assert$1("DeclareFunction", node, opts);
  12945. }
  12946. function assertDeclareInterface(node, opts) {
  12947. assert$1("DeclareInterface", node, opts);
  12948. }
  12949. function assertDeclareModule(node, opts) {
  12950. assert$1("DeclareModule", node, opts);
  12951. }
  12952. function assertDeclareModuleExports(node, opts) {
  12953. assert$1("DeclareModuleExports", node, opts);
  12954. }
  12955. function assertDeclareTypeAlias(node, opts) {
  12956. assert$1("DeclareTypeAlias", node, opts);
  12957. }
  12958. function assertDeclareOpaqueType(node, opts) {
  12959. assert$1("DeclareOpaqueType", node, opts);
  12960. }
  12961. function assertDeclareVariable(node, opts) {
  12962. assert$1("DeclareVariable", node, opts);
  12963. }
  12964. function assertDeclareExportDeclaration(node, opts) {
  12965. assert$1("DeclareExportDeclaration", node, opts);
  12966. }
  12967. function assertDeclareExportAllDeclaration(node, opts) {
  12968. assert$1("DeclareExportAllDeclaration", node, opts);
  12969. }
  12970. function assertDeclaredPredicate(node, opts) {
  12971. assert$1("DeclaredPredicate", node, opts);
  12972. }
  12973. function assertExistsTypeAnnotation(node, opts) {
  12974. assert$1("ExistsTypeAnnotation", node, opts);
  12975. }
  12976. function assertFunctionTypeAnnotation(node, opts) {
  12977. assert$1("FunctionTypeAnnotation", node, opts);
  12978. }
  12979. function assertFunctionTypeParam(node, opts) {
  12980. assert$1("FunctionTypeParam", node, opts);
  12981. }
  12982. function assertGenericTypeAnnotation(node, opts) {
  12983. assert$1("GenericTypeAnnotation", node, opts);
  12984. }
  12985. function assertInferredPredicate(node, opts) {
  12986. assert$1("InferredPredicate", node, opts);
  12987. }
  12988. function assertInterfaceExtends(node, opts) {
  12989. assert$1("InterfaceExtends", node, opts);
  12990. }
  12991. function assertInterfaceDeclaration(node, opts) {
  12992. assert$1("InterfaceDeclaration", node, opts);
  12993. }
  12994. function assertInterfaceTypeAnnotation(node, opts) {
  12995. assert$1("InterfaceTypeAnnotation", node, opts);
  12996. }
  12997. function assertIntersectionTypeAnnotation(node, opts) {
  12998. assert$1("IntersectionTypeAnnotation", node, opts);
  12999. }
  13000. function assertMixedTypeAnnotation(node, opts) {
  13001. assert$1("MixedTypeAnnotation", node, opts);
  13002. }
  13003. function assertEmptyTypeAnnotation(node, opts) {
  13004. assert$1("EmptyTypeAnnotation", node, opts);
  13005. }
  13006. function assertNullableTypeAnnotation(node, opts) {
  13007. assert$1("NullableTypeAnnotation", node, opts);
  13008. }
  13009. function assertNumberLiteralTypeAnnotation(node, opts) {
  13010. assert$1("NumberLiteralTypeAnnotation", node, opts);
  13011. }
  13012. function assertNumberTypeAnnotation(node, opts) {
  13013. assert$1("NumberTypeAnnotation", node, opts);
  13014. }
  13015. function assertObjectTypeAnnotation(node, opts) {
  13016. assert$1("ObjectTypeAnnotation", node, opts);
  13017. }
  13018. function assertObjectTypeInternalSlot(node, opts) {
  13019. assert$1("ObjectTypeInternalSlot", node, opts);
  13020. }
  13021. function assertObjectTypeCallProperty(node, opts) {
  13022. assert$1("ObjectTypeCallProperty", node, opts);
  13023. }
  13024. function assertObjectTypeIndexer(node, opts) {
  13025. assert$1("ObjectTypeIndexer", node, opts);
  13026. }
  13027. function assertObjectTypeProperty(node, opts) {
  13028. assert$1("ObjectTypeProperty", node, opts);
  13029. }
  13030. function assertObjectTypeSpreadProperty(node, opts) {
  13031. assert$1("ObjectTypeSpreadProperty", node, opts);
  13032. }
  13033. function assertOpaqueType(node, opts) {
  13034. assert$1("OpaqueType", node, opts);
  13035. }
  13036. function assertQualifiedTypeIdentifier(node, opts) {
  13037. assert$1("QualifiedTypeIdentifier", node, opts);
  13038. }
  13039. function assertStringLiteralTypeAnnotation(node, opts) {
  13040. assert$1("StringLiteralTypeAnnotation", node, opts);
  13041. }
  13042. function assertStringTypeAnnotation(node, opts) {
  13043. assert$1("StringTypeAnnotation", node, opts);
  13044. }
  13045. function assertSymbolTypeAnnotation(node, opts) {
  13046. assert$1("SymbolTypeAnnotation", node, opts);
  13047. }
  13048. function assertThisTypeAnnotation(node, opts) {
  13049. assert$1("ThisTypeAnnotation", node, opts);
  13050. }
  13051. function assertTupleTypeAnnotation(node, opts) {
  13052. assert$1("TupleTypeAnnotation", node, opts);
  13053. }
  13054. function assertTypeofTypeAnnotation(node, opts) {
  13055. assert$1("TypeofTypeAnnotation", node, opts);
  13056. }
  13057. function assertTypeAlias(node, opts) {
  13058. assert$1("TypeAlias", node, opts);
  13059. }
  13060. function assertTypeAnnotation(node, opts) {
  13061. assert$1("TypeAnnotation", node, opts);
  13062. }
  13063. function assertTypeCastExpression(node, opts) {
  13064. assert$1("TypeCastExpression", node, opts);
  13065. }
  13066. function assertTypeParameter(node, opts) {
  13067. assert$1("TypeParameter", node, opts);
  13068. }
  13069. function assertTypeParameterDeclaration(node, opts) {
  13070. assert$1("TypeParameterDeclaration", node, opts);
  13071. }
  13072. function assertTypeParameterInstantiation(node, opts) {
  13073. assert$1("TypeParameterInstantiation", node, opts);
  13074. }
  13075. function assertUnionTypeAnnotation(node, opts) {
  13076. assert$1("UnionTypeAnnotation", node, opts);
  13077. }
  13078. function assertVariance(node, opts) {
  13079. assert$1("Variance", node, opts);
  13080. }
  13081. function assertVoidTypeAnnotation(node, opts) {
  13082. assert$1("VoidTypeAnnotation", node, opts);
  13083. }
  13084. function assertEnumDeclaration(node, opts) {
  13085. assert$1("EnumDeclaration", node, opts);
  13086. }
  13087. function assertEnumBooleanBody(node, opts) {
  13088. assert$1("EnumBooleanBody", node, opts);
  13089. }
  13090. function assertEnumNumberBody(node, opts) {
  13091. assert$1("EnumNumberBody", node, opts);
  13092. }
  13093. function assertEnumStringBody(node, opts) {
  13094. assert$1("EnumStringBody", node, opts);
  13095. }
  13096. function assertEnumSymbolBody(node, opts) {
  13097. assert$1("EnumSymbolBody", node, opts);
  13098. }
  13099. function assertEnumBooleanMember(node, opts) {
  13100. assert$1("EnumBooleanMember", node, opts);
  13101. }
  13102. function assertEnumNumberMember(node, opts) {
  13103. assert$1("EnumNumberMember", node, opts);
  13104. }
  13105. function assertEnumStringMember(node, opts) {
  13106. assert$1("EnumStringMember", node, opts);
  13107. }
  13108. function assertEnumDefaultedMember(node, opts) {
  13109. assert$1("EnumDefaultedMember", node, opts);
  13110. }
  13111. function assertIndexedAccessType(node, opts) {
  13112. assert$1("IndexedAccessType", node, opts);
  13113. }
  13114. function assertOptionalIndexedAccessType(node, opts) {
  13115. assert$1("OptionalIndexedAccessType", node, opts);
  13116. }
  13117. function assertJSXAttribute(node, opts) {
  13118. assert$1("JSXAttribute", node, opts);
  13119. }
  13120. function assertJSXClosingElement(node, opts) {
  13121. assert$1("JSXClosingElement", node, opts);
  13122. }
  13123. function assertJSXElement(node, opts) {
  13124. assert$1("JSXElement", node, opts);
  13125. }
  13126. function assertJSXEmptyExpression(node, opts) {
  13127. assert$1("JSXEmptyExpression", node, opts);
  13128. }
  13129. function assertJSXExpressionContainer(node, opts) {
  13130. assert$1("JSXExpressionContainer", node, opts);
  13131. }
  13132. function assertJSXSpreadChild(node, opts) {
  13133. assert$1("JSXSpreadChild", node, opts);
  13134. }
  13135. function assertJSXIdentifier(node, opts) {
  13136. assert$1("JSXIdentifier", node, opts);
  13137. }
  13138. function assertJSXMemberExpression(node, opts) {
  13139. assert$1("JSXMemberExpression", node, opts);
  13140. }
  13141. function assertJSXNamespacedName(node, opts) {
  13142. assert$1("JSXNamespacedName", node, opts);
  13143. }
  13144. function assertJSXOpeningElement(node, opts) {
  13145. assert$1("JSXOpeningElement", node, opts);
  13146. }
  13147. function assertJSXSpreadAttribute(node, opts) {
  13148. assert$1("JSXSpreadAttribute", node, opts);
  13149. }
  13150. function assertJSXText(node, opts) {
  13151. assert$1("JSXText", node, opts);
  13152. }
  13153. function assertJSXFragment(node, opts) {
  13154. assert$1("JSXFragment", node, opts);
  13155. }
  13156. function assertJSXOpeningFragment(node, opts) {
  13157. assert$1("JSXOpeningFragment", node, opts);
  13158. }
  13159. function assertJSXClosingFragment(node, opts) {
  13160. assert$1("JSXClosingFragment", node, opts);
  13161. }
  13162. function assertNoop(node, opts) {
  13163. assert$1("Noop", node, opts);
  13164. }
  13165. function assertPlaceholder(node, opts) {
  13166. assert$1("Placeholder", node, opts);
  13167. }
  13168. function assertV8IntrinsicIdentifier(node, opts) {
  13169. assert$1("V8IntrinsicIdentifier", node, opts);
  13170. }
  13171. function assertArgumentPlaceholder(node, opts) {
  13172. assert$1("ArgumentPlaceholder", node, opts);
  13173. }
  13174. function assertBindExpression(node, opts) {
  13175. assert$1("BindExpression", node, opts);
  13176. }
  13177. function assertImportAttribute(node, opts) {
  13178. assert$1("ImportAttribute", node, opts);
  13179. }
  13180. function assertDecorator(node, opts) {
  13181. assert$1("Decorator", node, opts);
  13182. }
  13183. function assertDoExpression(node, opts) {
  13184. assert$1("DoExpression", node, opts);
  13185. }
  13186. function assertExportDefaultSpecifier(node, opts) {
  13187. assert$1("ExportDefaultSpecifier", node, opts);
  13188. }
  13189. function assertRecordExpression(node, opts) {
  13190. assert$1("RecordExpression", node, opts);
  13191. }
  13192. function assertTupleExpression(node, opts) {
  13193. assert$1("TupleExpression", node, opts);
  13194. }
  13195. function assertDecimalLiteral(node, opts) {
  13196. assert$1("DecimalLiteral", node, opts);
  13197. }
  13198. function assertStaticBlock(node, opts) {
  13199. assert$1("StaticBlock", node, opts);
  13200. }
  13201. function assertModuleExpression(node, opts) {
  13202. assert$1("ModuleExpression", node, opts);
  13203. }
  13204. function assertTopicReference(node, opts) {
  13205. assert$1("TopicReference", node, opts);
  13206. }
  13207. function assertPipelineTopicExpression(node, opts) {
  13208. assert$1("PipelineTopicExpression", node, opts);
  13209. }
  13210. function assertPipelineBareFunction(node, opts) {
  13211. assert$1("PipelineBareFunction", node, opts);
  13212. }
  13213. function assertPipelinePrimaryTopicReference(node, opts) {
  13214. assert$1("PipelinePrimaryTopicReference", node, opts);
  13215. }
  13216. function assertTSParameterProperty(node, opts) {
  13217. assert$1("TSParameterProperty", node, opts);
  13218. }
  13219. function assertTSDeclareFunction(node, opts) {
  13220. assert$1("TSDeclareFunction", node, opts);
  13221. }
  13222. function assertTSDeclareMethod(node, opts) {
  13223. assert$1("TSDeclareMethod", node, opts);
  13224. }
  13225. function assertTSQualifiedName(node, opts) {
  13226. assert$1("TSQualifiedName", node, opts);
  13227. }
  13228. function assertTSCallSignatureDeclaration(node, opts) {
  13229. assert$1("TSCallSignatureDeclaration", node, opts);
  13230. }
  13231. function assertTSConstructSignatureDeclaration(node, opts) {
  13232. assert$1("TSConstructSignatureDeclaration", node, opts);
  13233. }
  13234. function assertTSPropertySignature(node, opts) {
  13235. assert$1("TSPropertySignature", node, opts);
  13236. }
  13237. function assertTSMethodSignature(node, opts) {
  13238. assert$1("TSMethodSignature", node, opts);
  13239. }
  13240. function assertTSIndexSignature(node, opts) {
  13241. assert$1("TSIndexSignature", node, opts);
  13242. }
  13243. function assertTSAnyKeyword(node, opts) {
  13244. assert$1("TSAnyKeyword", node, opts);
  13245. }
  13246. function assertTSBooleanKeyword(node, opts) {
  13247. assert$1("TSBooleanKeyword", node, opts);
  13248. }
  13249. function assertTSBigIntKeyword(node, opts) {
  13250. assert$1("TSBigIntKeyword", node, opts);
  13251. }
  13252. function assertTSIntrinsicKeyword(node, opts) {
  13253. assert$1("TSIntrinsicKeyword", node, opts);
  13254. }
  13255. function assertTSNeverKeyword(node, opts) {
  13256. assert$1("TSNeverKeyword", node, opts);
  13257. }
  13258. function assertTSNullKeyword(node, opts) {
  13259. assert$1("TSNullKeyword", node, opts);
  13260. }
  13261. function assertTSNumberKeyword(node, opts) {
  13262. assert$1("TSNumberKeyword", node, opts);
  13263. }
  13264. function assertTSObjectKeyword(node, opts) {
  13265. assert$1("TSObjectKeyword", node, opts);
  13266. }
  13267. function assertTSStringKeyword(node, opts) {
  13268. assert$1("TSStringKeyword", node, opts);
  13269. }
  13270. function assertTSSymbolKeyword(node, opts) {
  13271. assert$1("TSSymbolKeyword", node, opts);
  13272. }
  13273. function assertTSUndefinedKeyword(node, opts) {
  13274. assert$1("TSUndefinedKeyword", node, opts);
  13275. }
  13276. function assertTSUnknownKeyword(node, opts) {
  13277. assert$1("TSUnknownKeyword", node, opts);
  13278. }
  13279. function assertTSVoidKeyword(node, opts) {
  13280. assert$1("TSVoidKeyword", node, opts);
  13281. }
  13282. function assertTSThisType(node, opts) {
  13283. assert$1("TSThisType", node, opts);
  13284. }
  13285. function assertTSFunctionType(node, opts) {
  13286. assert$1("TSFunctionType", node, opts);
  13287. }
  13288. function assertTSConstructorType(node, opts) {
  13289. assert$1("TSConstructorType", node, opts);
  13290. }
  13291. function assertTSTypeReference(node, opts) {
  13292. assert$1("TSTypeReference", node, opts);
  13293. }
  13294. function assertTSTypePredicate(node, opts) {
  13295. assert$1("TSTypePredicate", node, opts);
  13296. }
  13297. function assertTSTypeQuery(node, opts) {
  13298. assert$1("TSTypeQuery", node, opts);
  13299. }
  13300. function assertTSTypeLiteral(node, opts) {
  13301. assert$1("TSTypeLiteral", node, opts);
  13302. }
  13303. function assertTSArrayType(node, opts) {
  13304. assert$1("TSArrayType", node, opts);
  13305. }
  13306. function assertTSTupleType(node, opts) {
  13307. assert$1("TSTupleType", node, opts);
  13308. }
  13309. function assertTSOptionalType(node, opts) {
  13310. assert$1("TSOptionalType", node, opts);
  13311. }
  13312. function assertTSRestType(node, opts) {
  13313. assert$1("TSRestType", node, opts);
  13314. }
  13315. function assertTSNamedTupleMember(node, opts) {
  13316. assert$1("TSNamedTupleMember", node, opts);
  13317. }
  13318. function assertTSUnionType(node, opts) {
  13319. assert$1("TSUnionType", node, opts);
  13320. }
  13321. function assertTSIntersectionType(node, opts) {
  13322. assert$1("TSIntersectionType", node, opts);
  13323. }
  13324. function assertTSConditionalType(node, opts) {
  13325. assert$1("TSConditionalType", node, opts);
  13326. }
  13327. function assertTSInferType(node, opts) {
  13328. assert$1("TSInferType", node, opts);
  13329. }
  13330. function assertTSParenthesizedType(node, opts) {
  13331. assert$1("TSParenthesizedType", node, opts);
  13332. }
  13333. function assertTSTypeOperator(node, opts) {
  13334. assert$1("TSTypeOperator", node, opts);
  13335. }
  13336. function assertTSIndexedAccessType(node, opts) {
  13337. assert$1("TSIndexedAccessType", node, opts);
  13338. }
  13339. function assertTSMappedType(node, opts) {
  13340. assert$1("TSMappedType", node, opts);
  13341. }
  13342. function assertTSLiteralType(node, opts) {
  13343. assert$1("TSLiteralType", node, opts);
  13344. }
  13345. function assertTSExpressionWithTypeArguments(node, opts) {
  13346. assert$1("TSExpressionWithTypeArguments", node, opts);
  13347. }
  13348. function assertTSInterfaceDeclaration(node, opts) {
  13349. assert$1("TSInterfaceDeclaration", node, opts);
  13350. }
  13351. function assertTSInterfaceBody(node, opts) {
  13352. assert$1("TSInterfaceBody", node, opts);
  13353. }
  13354. function assertTSTypeAliasDeclaration(node, opts) {
  13355. assert$1("TSTypeAliasDeclaration", node, opts);
  13356. }
  13357. function assertTSAsExpression(node, opts) {
  13358. assert$1("TSAsExpression", node, opts);
  13359. }
  13360. function assertTSTypeAssertion(node, opts) {
  13361. assert$1("TSTypeAssertion", node, opts);
  13362. }
  13363. function assertTSEnumDeclaration(node, opts) {
  13364. assert$1("TSEnumDeclaration", node, opts);
  13365. }
  13366. function assertTSEnumMember(node, opts) {
  13367. assert$1("TSEnumMember", node, opts);
  13368. }
  13369. function assertTSModuleDeclaration(node, opts) {
  13370. assert$1("TSModuleDeclaration", node, opts);
  13371. }
  13372. function assertTSModuleBlock(node, opts) {
  13373. assert$1("TSModuleBlock", node, opts);
  13374. }
  13375. function assertTSImportType(node, opts) {
  13376. assert$1("TSImportType", node, opts);
  13377. }
  13378. function assertTSImportEqualsDeclaration(node, opts) {
  13379. assert$1("TSImportEqualsDeclaration", node, opts);
  13380. }
  13381. function assertTSExternalModuleReference(node, opts) {
  13382. assert$1("TSExternalModuleReference", node, opts);
  13383. }
  13384. function assertTSNonNullExpression(node, opts) {
  13385. assert$1("TSNonNullExpression", node, opts);
  13386. }
  13387. function assertTSExportAssignment(node, opts) {
  13388. assert$1("TSExportAssignment", node, opts);
  13389. }
  13390. function assertTSNamespaceExportDeclaration(node, opts) {
  13391. assert$1("TSNamespaceExportDeclaration", node, opts);
  13392. }
  13393. function assertTSTypeAnnotation(node, opts) {
  13394. assert$1("TSTypeAnnotation", node, opts);
  13395. }
  13396. function assertTSTypeParameterInstantiation(node, opts) {
  13397. assert$1("TSTypeParameterInstantiation", node, opts);
  13398. }
  13399. function assertTSTypeParameterDeclaration(node, opts) {
  13400. assert$1("TSTypeParameterDeclaration", node, opts);
  13401. }
  13402. function assertTSTypeParameter(node, opts) {
  13403. assert$1("TSTypeParameter", node, opts);
  13404. }
  13405. function assertExpression(node, opts) {
  13406. assert$1("Expression", node, opts);
  13407. }
  13408. function assertBinary(node, opts) {
  13409. assert$1("Binary", node, opts);
  13410. }
  13411. function assertScopable(node, opts) {
  13412. assert$1("Scopable", node, opts);
  13413. }
  13414. function assertBlockParent(node, opts) {
  13415. assert$1("BlockParent", node, opts);
  13416. }
  13417. function assertBlock(node, opts) {
  13418. assert$1("Block", node, opts);
  13419. }
  13420. function assertStatement(node, opts) {
  13421. assert$1("Statement", node, opts);
  13422. }
  13423. function assertTerminatorless(node, opts) {
  13424. assert$1("Terminatorless", node, opts);
  13425. }
  13426. function assertCompletionStatement(node, opts) {
  13427. assert$1("CompletionStatement", node, opts);
  13428. }
  13429. function assertConditional(node, opts) {
  13430. assert$1("Conditional", node, opts);
  13431. }
  13432. function assertLoop(node, opts) {
  13433. assert$1("Loop", node, opts);
  13434. }
  13435. function assertWhile(node, opts) {
  13436. assert$1("While", node, opts);
  13437. }
  13438. function assertExpressionWrapper(node, opts) {
  13439. assert$1("ExpressionWrapper", node, opts);
  13440. }
  13441. function assertFor(node, opts) {
  13442. assert$1("For", node, opts);
  13443. }
  13444. function assertForXStatement(node, opts) {
  13445. assert$1("ForXStatement", node, opts);
  13446. }
  13447. function assertFunction(node, opts) {
  13448. assert$1("Function", node, opts);
  13449. }
  13450. function assertFunctionParent(node, opts) {
  13451. assert$1("FunctionParent", node, opts);
  13452. }
  13453. function assertPureish(node, opts) {
  13454. assert$1("Pureish", node, opts);
  13455. }
  13456. function assertDeclaration(node, opts) {
  13457. assert$1("Declaration", node, opts);
  13458. }
  13459. function assertPatternLike(node, opts) {
  13460. assert$1("PatternLike", node, opts);
  13461. }
  13462. function assertLVal(node, opts) {
  13463. assert$1("LVal", node, opts);
  13464. }
  13465. function assertTSEntityName(node, opts) {
  13466. assert$1("TSEntityName", node, opts);
  13467. }
  13468. function assertLiteral(node, opts) {
  13469. assert$1("Literal", node, opts);
  13470. }
  13471. function assertImmutable(node, opts) {
  13472. assert$1("Immutable", node, opts);
  13473. }
  13474. function assertUserWhitespacable(node, opts) {
  13475. assert$1("UserWhitespacable", node, opts);
  13476. }
  13477. function assertMethod(node, opts) {
  13478. assert$1("Method", node, opts);
  13479. }
  13480. function assertObjectMember(node, opts) {
  13481. assert$1("ObjectMember", node, opts);
  13482. }
  13483. function assertProperty(node, opts) {
  13484. assert$1("Property", node, opts);
  13485. }
  13486. function assertUnaryLike(node, opts) {
  13487. assert$1("UnaryLike", node, opts);
  13488. }
  13489. function assertPattern(node, opts) {
  13490. assert$1("Pattern", node, opts);
  13491. }
  13492. function assertClass(node, opts) {
  13493. assert$1("Class", node, opts);
  13494. }
  13495. function assertModuleDeclaration(node, opts) {
  13496. assert$1("ModuleDeclaration", node, opts);
  13497. }
  13498. function assertExportDeclaration(node, opts) {
  13499. assert$1("ExportDeclaration", node, opts);
  13500. }
  13501. function assertModuleSpecifier(node, opts) {
  13502. assert$1("ModuleSpecifier", node, opts);
  13503. }
  13504. function assertPrivate(node, opts) {
  13505. assert$1("Private", node, opts);
  13506. }
  13507. function assertFlow(node, opts) {
  13508. assert$1("Flow", node, opts);
  13509. }
  13510. function assertFlowType(node, opts) {
  13511. assert$1("FlowType", node, opts);
  13512. }
  13513. function assertFlowBaseAnnotation(node, opts) {
  13514. assert$1("FlowBaseAnnotation", node, opts);
  13515. }
  13516. function assertFlowDeclaration(node, opts) {
  13517. assert$1("FlowDeclaration", node, opts);
  13518. }
  13519. function assertFlowPredicate(node, opts) {
  13520. assert$1("FlowPredicate", node, opts);
  13521. }
  13522. function assertEnumBody(node, opts) {
  13523. assert$1("EnumBody", node, opts);
  13524. }
  13525. function assertEnumMember(node, opts) {
  13526. assert$1("EnumMember", node, opts);
  13527. }
  13528. function assertJSX(node, opts) {
  13529. assert$1("JSX", node, opts);
  13530. }
  13531. function assertTSTypeElement(node, opts) {
  13532. assert$1("TSTypeElement", node, opts);
  13533. }
  13534. function assertTSType(node, opts) {
  13535. assert$1("TSType", node, opts);
  13536. }
  13537. function assertTSBaseType(node, opts) {
  13538. assert$1("TSBaseType", node, opts);
  13539. }
  13540. function assertNumberLiteral(node, opts) {
  13541. console.trace("The node type NumberLiteral has been renamed to NumericLiteral");
  13542. assert$1("NumberLiteral", node, opts);
  13543. }
  13544. function assertRegexLiteral(node, opts) {
  13545. console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
  13546. assert$1("RegexLiteral", node, opts);
  13547. }
  13548. function assertRestProperty(node, opts) {
  13549. console.trace("The node type RestProperty has been renamed to RestElement");
  13550. assert$1("RestProperty", node, opts);
  13551. }
  13552. function assertSpreadProperty(node, opts) {
  13553. console.trace("The node type SpreadProperty has been renamed to SpreadElement");
  13554. assert$1("SpreadProperty", node, opts);
  13555. }
  13556. var generated$2 = /*#__PURE__*/Object.defineProperty({
  13557. assertArrayExpression: assertArrayExpression_1,
  13558. assertAssignmentExpression: assertAssignmentExpression_1,
  13559. assertBinaryExpression: assertBinaryExpression_1,
  13560. assertInterpreterDirective: assertInterpreterDirective_1,
  13561. assertDirective: assertDirective_1,
  13562. assertDirectiveLiteral: assertDirectiveLiteral_1,
  13563. assertBlockStatement: assertBlockStatement_1,
  13564. assertBreakStatement: assertBreakStatement_1,
  13565. assertCallExpression: assertCallExpression_1,
  13566. assertCatchClause: assertCatchClause_1,
  13567. assertConditionalExpression: assertConditionalExpression_1,
  13568. assertContinueStatement: assertContinueStatement_1,
  13569. assertDebuggerStatement: assertDebuggerStatement_1,
  13570. assertDoWhileStatement: assertDoWhileStatement_1,
  13571. assertEmptyStatement: assertEmptyStatement_1,
  13572. assertExpressionStatement: assertExpressionStatement_1,
  13573. assertFile: assertFile_1,
  13574. assertForInStatement: assertForInStatement_1,
  13575. assertForStatement: assertForStatement_1,
  13576. assertFunctionDeclaration: assertFunctionDeclaration_1,
  13577. assertFunctionExpression: assertFunctionExpression_1,
  13578. assertIdentifier: assertIdentifier_1,
  13579. assertIfStatement: assertIfStatement_1,
  13580. assertLabeledStatement: assertLabeledStatement_1,
  13581. assertStringLiteral: assertStringLiteral_1,
  13582. assertNumericLiteral: assertNumericLiteral_1,
  13583. assertNullLiteral: assertNullLiteral_1,
  13584. assertBooleanLiteral: assertBooleanLiteral_1,
  13585. assertRegExpLiteral: assertRegExpLiteral_1,
  13586. assertLogicalExpression: assertLogicalExpression_1,
  13587. assertMemberExpression: assertMemberExpression_1,
  13588. assertNewExpression: assertNewExpression_1,
  13589. assertProgram: assertProgram_1,
  13590. assertObjectExpression: assertObjectExpression_1,
  13591. assertObjectMethod: assertObjectMethod_1,
  13592. assertObjectProperty: assertObjectProperty_1,
  13593. assertRestElement: assertRestElement_1,
  13594. assertReturnStatement: assertReturnStatement_1,
  13595. assertSequenceExpression: assertSequenceExpression_1,
  13596. assertParenthesizedExpression: assertParenthesizedExpression_1,
  13597. assertSwitchCase: assertSwitchCase_1,
  13598. assertSwitchStatement: assertSwitchStatement_1,
  13599. assertThisExpression: assertThisExpression_1,
  13600. assertThrowStatement: assertThrowStatement_1,
  13601. assertTryStatement: assertTryStatement_1,
  13602. assertUnaryExpression: assertUnaryExpression_1,
  13603. assertUpdateExpression: assertUpdateExpression_1,
  13604. assertVariableDeclaration: assertVariableDeclaration_1,
  13605. assertVariableDeclarator: assertVariableDeclarator_1,
  13606. assertWhileStatement: assertWhileStatement_1,
  13607. assertWithStatement: assertWithStatement_1,
  13608. assertAssignmentPattern: assertAssignmentPattern_1,
  13609. assertArrayPattern: assertArrayPattern_1,
  13610. assertArrowFunctionExpression: assertArrowFunctionExpression_1,
  13611. assertClassBody: assertClassBody_1,
  13612. assertClassExpression: assertClassExpression_1,
  13613. assertClassDeclaration: assertClassDeclaration_1,
  13614. assertExportAllDeclaration: assertExportAllDeclaration_1,
  13615. assertExportDefaultDeclaration: assertExportDefaultDeclaration_1,
  13616. assertExportNamedDeclaration: assertExportNamedDeclaration_1,
  13617. assertExportSpecifier: assertExportSpecifier_1,
  13618. assertForOfStatement: assertForOfStatement_1,
  13619. assertImportDeclaration: assertImportDeclaration_1,
  13620. assertImportDefaultSpecifier: assertImportDefaultSpecifier_1,
  13621. assertImportNamespaceSpecifier: assertImportNamespaceSpecifier_1,
  13622. assertImportSpecifier: assertImportSpecifier_1,
  13623. assertMetaProperty: assertMetaProperty_1,
  13624. assertClassMethod: assertClassMethod_1,
  13625. assertObjectPattern: assertObjectPattern_1,
  13626. assertSpreadElement: assertSpreadElement_1,
  13627. assertSuper: assertSuper_1,
  13628. assertTaggedTemplateExpression: assertTaggedTemplateExpression_1,
  13629. assertTemplateElement: assertTemplateElement_1,
  13630. assertTemplateLiteral: assertTemplateLiteral_1,
  13631. assertYieldExpression: assertYieldExpression_1,
  13632. assertAwaitExpression: assertAwaitExpression_1,
  13633. assertImport: assertImport_1,
  13634. assertBigIntLiteral: assertBigIntLiteral_1,
  13635. assertExportNamespaceSpecifier: assertExportNamespaceSpecifier_1,
  13636. assertOptionalMemberExpression: assertOptionalMemberExpression_1,
  13637. assertOptionalCallExpression: assertOptionalCallExpression_1,
  13638. assertClassProperty: assertClassProperty_1,
  13639. assertClassPrivateProperty: assertClassPrivateProperty_1,
  13640. assertClassPrivateMethod: assertClassPrivateMethod_1,
  13641. assertPrivateName: assertPrivateName_1,
  13642. assertAnyTypeAnnotation: assertAnyTypeAnnotation_1,
  13643. assertArrayTypeAnnotation: assertArrayTypeAnnotation_1,
  13644. assertBooleanTypeAnnotation: assertBooleanTypeAnnotation_1,
  13645. assertBooleanLiteralTypeAnnotation: assertBooleanLiteralTypeAnnotation_1,
  13646. assertNullLiteralTypeAnnotation: assertNullLiteralTypeAnnotation_1,
  13647. assertClassImplements: assertClassImplements_1,
  13648. assertDeclareClass: assertDeclareClass_1,
  13649. assertDeclareFunction: assertDeclareFunction_1,
  13650. assertDeclareInterface: assertDeclareInterface_1,
  13651. assertDeclareModule: assertDeclareModule_1,
  13652. assertDeclareModuleExports: assertDeclareModuleExports_1,
  13653. assertDeclareTypeAlias: assertDeclareTypeAlias_1,
  13654. assertDeclareOpaqueType: assertDeclareOpaqueType_1,
  13655. assertDeclareVariable: assertDeclareVariable_1,
  13656. assertDeclareExportDeclaration: assertDeclareExportDeclaration_1,
  13657. assertDeclareExportAllDeclaration: assertDeclareExportAllDeclaration_1,
  13658. assertDeclaredPredicate: assertDeclaredPredicate_1,
  13659. assertExistsTypeAnnotation: assertExistsTypeAnnotation_1,
  13660. assertFunctionTypeAnnotation: assertFunctionTypeAnnotation_1,
  13661. assertFunctionTypeParam: assertFunctionTypeParam_1,
  13662. assertGenericTypeAnnotation: assertGenericTypeAnnotation_1,
  13663. assertInferredPredicate: assertInferredPredicate_1,
  13664. assertInterfaceExtends: assertInterfaceExtends_1,
  13665. assertInterfaceDeclaration: assertInterfaceDeclaration_1,
  13666. assertInterfaceTypeAnnotation: assertInterfaceTypeAnnotation_1,
  13667. assertIntersectionTypeAnnotation: assertIntersectionTypeAnnotation_1,
  13668. assertMixedTypeAnnotation: assertMixedTypeAnnotation_1,
  13669. assertEmptyTypeAnnotation: assertEmptyTypeAnnotation_1,
  13670. assertNullableTypeAnnotation: assertNullableTypeAnnotation_1,
  13671. assertNumberLiteralTypeAnnotation: assertNumberLiteralTypeAnnotation_1,
  13672. assertNumberTypeAnnotation: assertNumberTypeAnnotation_1,
  13673. assertObjectTypeAnnotation: assertObjectTypeAnnotation_1,
  13674. assertObjectTypeInternalSlot: assertObjectTypeInternalSlot_1,
  13675. assertObjectTypeCallProperty: assertObjectTypeCallProperty_1,
  13676. assertObjectTypeIndexer: assertObjectTypeIndexer_1,
  13677. assertObjectTypeProperty: assertObjectTypeProperty_1,
  13678. assertObjectTypeSpreadProperty: assertObjectTypeSpreadProperty_1,
  13679. assertOpaqueType: assertOpaqueType_1,
  13680. assertQualifiedTypeIdentifier: assertQualifiedTypeIdentifier_1,
  13681. assertStringLiteralTypeAnnotation: assertStringLiteralTypeAnnotation_1,
  13682. assertStringTypeAnnotation: assertStringTypeAnnotation_1,
  13683. assertSymbolTypeAnnotation: assertSymbolTypeAnnotation_1,
  13684. assertThisTypeAnnotation: assertThisTypeAnnotation_1,
  13685. assertTupleTypeAnnotation: assertTupleTypeAnnotation_1,
  13686. assertTypeofTypeAnnotation: assertTypeofTypeAnnotation_1,
  13687. assertTypeAlias: assertTypeAlias_1,
  13688. assertTypeAnnotation: assertTypeAnnotation_1,
  13689. assertTypeCastExpression: assertTypeCastExpression_1,
  13690. assertTypeParameter: assertTypeParameter_1,
  13691. assertTypeParameterDeclaration: assertTypeParameterDeclaration_1,
  13692. assertTypeParameterInstantiation: assertTypeParameterInstantiation_1,
  13693. assertUnionTypeAnnotation: assertUnionTypeAnnotation_1,
  13694. assertVariance: assertVariance_1,
  13695. assertVoidTypeAnnotation: assertVoidTypeAnnotation_1,
  13696. assertEnumDeclaration: assertEnumDeclaration_1,
  13697. assertEnumBooleanBody: assertEnumBooleanBody_1,
  13698. assertEnumNumberBody: assertEnumNumberBody_1,
  13699. assertEnumStringBody: assertEnumStringBody_1,
  13700. assertEnumSymbolBody: assertEnumSymbolBody_1,
  13701. assertEnumBooleanMember: assertEnumBooleanMember_1,
  13702. assertEnumNumberMember: assertEnumNumberMember_1,
  13703. assertEnumStringMember: assertEnumStringMember_1,
  13704. assertEnumDefaultedMember: assertEnumDefaultedMember_1,
  13705. assertIndexedAccessType: assertIndexedAccessType_1,
  13706. assertOptionalIndexedAccessType: assertOptionalIndexedAccessType_1,
  13707. assertJSXAttribute: assertJSXAttribute_1,
  13708. assertJSXClosingElement: assertJSXClosingElement_1,
  13709. assertJSXElement: assertJSXElement_1,
  13710. assertJSXEmptyExpression: assertJSXEmptyExpression_1,
  13711. assertJSXExpressionContainer: assertJSXExpressionContainer_1,
  13712. assertJSXSpreadChild: assertJSXSpreadChild_1,
  13713. assertJSXIdentifier: assertJSXIdentifier_1,
  13714. assertJSXMemberExpression: assertJSXMemberExpression_1,
  13715. assertJSXNamespacedName: assertJSXNamespacedName_1,
  13716. assertJSXOpeningElement: assertJSXOpeningElement_1,
  13717. assertJSXSpreadAttribute: assertJSXSpreadAttribute_1,
  13718. assertJSXText: assertJSXText_1,
  13719. assertJSXFragment: assertJSXFragment_1,
  13720. assertJSXOpeningFragment: assertJSXOpeningFragment_1,
  13721. assertJSXClosingFragment: assertJSXClosingFragment_1,
  13722. assertNoop: assertNoop_1,
  13723. assertPlaceholder: assertPlaceholder_1,
  13724. assertV8IntrinsicIdentifier: assertV8IntrinsicIdentifier_1,
  13725. assertArgumentPlaceholder: assertArgumentPlaceholder_1,
  13726. assertBindExpression: assertBindExpression_1,
  13727. assertImportAttribute: assertImportAttribute_1,
  13728. assertDecorator: assertDecorator_1,
  13729. assertDoExpression: assertDoExpression_1,
  13730. assertExportDefaultSpecifier: assertExportDefaultSpecifier_1,
  13731. assertRecordExpression: assertRecordExpression_1,
  13732. assertTupleExpression: assertTupleExpression_1,
  13733. assertDecimalLiteral: assertDecimalLiteral_1,
  13734. assertStaticBlock: assertStaticBlock_1,
  13735. assertModuleExpression: assertModuleExpression_1,
  13736. assertTopicReference: assertTopicReference_1,
  13737. assertPipelineTopicExpression: assertPipelineTopicExpression_1,
  13738. assertPipelineBareFunction: assertPipelineBareFunction_1,
  13739. assertPipelinePrimaryTopicReference: assertPipelinePrimaryTopicReference_1,
  13740. assertTSParameterProperty: assertTSParameterProperty_1,
  13741. assertTSDeclareFunction: assertTSDeclareFunction_1,
  13742. assertTSDeclareMethod: assertTSDeclareMethod_1,
  13743. assertTSQualifiedName: assertTSQualifiedName_1,
  13744. assertTSCallSignatureDeclaration: assertTSCallSignatureDeclaration_1,
  13745. assertTSConstructSignatureDeclaration: assertTSConstructSignatureDeclaration_1,
  13746. assertTSPropertySignature: assertTSPropertySignature_1,
  13747. assertTSMethodSignature: assertTSMethodSignature_1,
  13748. assertTSIndexSignature: assertTSIndexSignature_1,
  13749. assertTSAnyKeyword: assertTSAnyKeyword_1,
  13750. assertTSBooleanKeyword: assertTSBooleanKeyword_1,
  13751. assertTSBigIntKeyword: assertTSBigIntKeyword_1,
  13752. assertTSIntrinsicKeyword: assertTSIntrinsicKeyword_1,
  13753. assertTSNeverKeyword: assertTSNeverKeyword_1,
  13754. assertTSNullKeyword: assertTSNullKeyword_1,
  13755. assertTSNumberKeyword: assertTSNumberKeyword_1,
  13756. assertTSObjectKeyword: assertTSObjectKeyword_1,
  13757. assertTSStringKeyword: assertTSStringKeyword_1,
  13758. assertTSSymbolKeyword: assertTSSymbolKeyword_1,
  13759. assertTSUndefinedKeyword: assertTSUndefinedKeyword_1,
  13760. assertTSUnknownKeyword: assertTSUnknownKeyword_1,
  13761. assertTSVoidKeyword: assertTSVoidKeyword_1,
  13762. assertTSThisType: assertTSThisType_1,
  13763. assertTSFunctionType: assertTSFunctionType_1,
  13764. assertTSConstructorType: assertTSConstructorType_1,
  13765. assertTSTypeReference: assertTSTypeReference_1,
  13766. assertTSTypePredicate: assertTSTypePredicate_1,
  13767. assertTSTypeQuery: assertTSTypeQuery_1,
  13768. assertTSTypeLiteral: assertTSTypeLiteral_1,
  13769. assertTSArrayType: assertTSArrayType_1,
  13770. assertTSTupleType: assertTSTupleType_1,
  13771. assertTSOptionalType: assertTSOptionalType_1,
  13772. assertTSRestType: assertTSRestType_1,
  13773. assertTSNamedTupleMember: assertTSNamedTupleMember_1,
  13774. assertTSUnionType: assertTSUnionType_1,
  13775. assertTSIntersectionType: assertTSIntersectionType_1,
  13776. assertTSConditionalType: assertTSConditionalType_1,
  13777. assertTSInferType: assertTSInferType_1,
  13778. assertTSParenthesizedType: assertTSParenthesizedType_1,
  13779. assertTSTypeOperator: assertTSTypeOperator_1,
  13780. assertTSIndexedAccessType: assertTSIndexedAccessType_1,
  13781. assertTSMappedType: assertTSMappedType_1,
  13782. assertTSLiteralType: assertTSLiteralType_1,
  13783. assertTSExpressionWithTypeArguments: assertTSExpressionWithTypeArguments_1,
  13784. assertTSInterfaceDeclaration: assertTSInterfaceDeclaration_1,
  13785. assertTSInterfaceBody: assertTSInterfaceBody_1,
  13786. assertTSTypeAliasDeclaration: assertTSTypeAliasDeclaration_1,
  13787. assertTSAsExpression: assertTSAsExpression_1,
  13788. assertTSTypeAssertion: assertTSTypeAssertion_1,
  13789. assertTSEnumDeclaration: assertTSEnumDeclaration_1,
  13790. assertTSEnumMember: assertTSEnumMember_1,
  13791. assertTSModuleDeclaration: assertTSModuleDeclaration_1,
  13792. assertTSModuleBlock: assertTSModuleBlock_1,
  13793. assertTSImportType: assertTSImportType_1,
  13794. assertTSImportEqualsDeclaration: assertTSImportEqualsDeclaration_1,
  13795. assertTSExternalModuleReference: assertTSExternalModuleReference_1,
  13796. assertTSNonNullExpression: assertTSNonNullExpression_1,
  13797. assertTSExportAssignment: assertTSExportAssignment_1,
  13798. assertTSNamespaceExportDeclaration: assertTSNamespaceExportDeclaration_1,
  13799. assertTSTypeAnnotation: assertTSTypeAnnotation_1,
  13800. assertTSTypeParameterInstantiation: assertTSTypeParameterInstantiation_1,
  13801. assertTSTypeParameterDeclaration: assertTSTypeParameterDeclaration_1,
  13802. assertTSTypeParameter: assertTSTypeParameter_1,
  13803. assertExpression: assertExpression_1,
  13804. assertBinary: assertBinary_1,
  13805. assertScopable: assertScopable_1,
  13806. assertBlockParent: assertBlockParent_1,
  13807. assertBlock: assertBlock_1,
  13808. assertStatement: assertStatement_1,
  13809. assertTerminatorless: assertTerminatorless_1,
  13810. assertCompletionStatement: assertCompletionStatement_1,
  13811. assertConditional: assertConditional_1,
  13812. assertLoop: assertLoop_1,
  13813. assertWhile: assertWhile_1,
  13814. assertExpressionWrapper: assertExpressionWrapper_1,
  13815. assertFor: assertFor_1,
  13816. assertForXStatement: assertForXStatement_1,
  13817. assertFunction: assertFunction_1,
  13818. assertFunctionParent: assertFunctionParent_1,
  13819. assertPureish: assertPureish_1,
  13820. assertDeclaration: assertDeclaration_1,
  13821. assertPatternLike: assertPatternLike_1,
  13822. assertLVal: assertLVal_1,
  13823. assertTSEntityName: assertTSEntityName_1,
  13824. assertLiteral: assertLiteral_1,
  13825. assertImmutable: assertImmutable_1,
  13826. assertUserWhitespacable: assertUserWhitespacable_1,
  13827. assertMethod: assertMethod_1,
  13828. assertObjectMember: assertObjectMember_1,
  13829. assertProperty: assertProperty_1,
  13830. assertUnaryLike: assertUnaryLike_1,
  13831. assertPattern: assertPattern_1,
  13832. assertClass: assertClass_1,
  13833. assertModuleDeclaration: assertModuleDeclaration_1,
  13834. assertExportDeclaration: assertExportDeclaration_1,
  13835. assertModuleSpecifier: assertModuleSpecifier_1,
  13836. assertPrivate: assertPrivate_1,
  13837. assertFlow: assertFlow_1,
  13838. assertFlowType: assertFlowType_1,
  13839. assertFlowBaseAnnotation: assertFlowBaseAnnotation_1,
  13840. assertFlowDeclaration: assertFlowDeclaration_1,
  13841. assertFlowPredicate: assertFlowPredicate_1,
  13842. assertEnumBody: assertEnumBody_1,
  13843. assertEnumMember: assertEnumMember_1,
  13844. assertJSX: assertJSX_1,
  13845. assertTSTypeElement: assertTSTypeElement_1,
  13846. assertTSType: assertTSType_1,
  13847. assertTSBaseType: assertTSBaseType_1,
  13848. assertNumberLiteral: assertNumberLiteral_1,
  13849. assertRegexLiteral: assertRegexLiteral_1,
  13850. assertRestProperty: assertRestProperty_1,
  13851. assertSpreadProperty: assertSpreadProperty_1
  13852. }, '__esModule', {value: true});
  13853. var _default$e = createTypeAnnotationBasedOnTypeof;
  13854. function createTypeAnnotationBasedOnTypeof(type) {
  13855. if (type === "string") {
  13856. return (0, generated$1.stringTypeAnnotation)();
  13857. } else if (type === "number") {
  13858. return (0, generated$1.numberTypeAnnotation)();
  13859. } else if (type === "undefined") {
  13860. return (0, generated$1.voidTypeAnnotation)();
  13861. } else if (type === "boolean") {
  13862. return (0, generated$1.booleanTypeAnnotation)();
  13863. } else if (type === "function") {
  13864. return (0, generated$1.genericTypeAnnotation)((0, generated$1.identifier)("Function"));
  13865. } else if (type === "object") {
  13866. return (0, generated$1.genericTypeAnnotation)((0, generated$1.identifier)("Object"));
  13867. } else if (type === "symbol") {
  13868. return (0, generated$1.genericTypeAnnotation)((0, generated$1.identifier)("Symbol"));
  13869. } else if (type === "bigint") {
  13870. return (0, generated$1.anyTypeAnnotation)();
  13871. } else {
  13872. throw new Error("Invalid typeof value: " + type);
  13873. }
  13874. }
  13875. var createTypeAnnotationBasedOnTypeof_1 = /*#__PURE__*/Object.defineProperty({
  13876. default: _default$e
  13877. }, '__esModule', {value: true});
  13878. var _default$f = removeTypeDuplicates;
  13879. function getQualifiedName(node) {
  13880. return (0, generated.isIdentifier)(node) ? node.name : `${node.id.name}.${getQualifiedName(node.qualification)}`;
  13881. }
  13882. function removeTypeDuplicates(nodes) {
  13883. const generics = {};
  13884. const bases = {};
  13885. const typeGroups = [];
  13886. const types = [];
  13887. for (let i = 0; i < nodes.length; i++) {
  13888. const node = nodes[i];
  13889. if (!node) continue;
  13890. if (types.indexOf(node) >= 0) {
  13891. continue;
  13892. }
  13893. if ((0, generated.isAnyTypeAnnotation)(node)) {
  13894. return [node];
  13895. }
  13896. if ((0, generated.isFlowBaseAnnotation)(node)) {
  13897. bases[node.type] = node;
  13898. continue;
  13899. }
  13900. if ((0, generated.isUnionTypeAnnotation)(node)) {
  13901. if (typeGroups.indexOf(node.types) < 0) {
  13902. nodes = nodes.concat(node.types);
  13903. typeGroups.push(node.types);
  13904. }
  13905. continue;
  13906. }
  13907. if ((0, generated.isGenericTypeAnnotation)(node)) {
  13908. const name = getQualifiedName(node.id);
  13909. if (generics[name]) {
  13910. let existing = generics[name];
  13911. if (existing.typeParameters) {
  13912. if (node.typeParameters) {
  13913. existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
  13914. }
  13915. } else {
  13916. existing = node.typeParameters;
  13917. }
  13918. } else {
  13919. generics[name] = node;
  13920. }
  13921. continue;
  13922. }
  13923. types.push(node);
  13924. }
  13925. for (const type of Object.keys(bases)) {
  13926. types.push(bases[type]);
  13927. }
  13928. for (const name of Object.keys(generics)) {
  13929. types.push(generics[name]);
  13930. }
  13931. return types;
  13932. }
  13933. var removeTypeDuplicates_1 = /*#__PURE__*/Object.defineProperty({
  13934. default: _default$f
  13935. }, '__esModule', {value: true});
  13936. var _default$g = createFlowUnionType;
  13937. function createFlowUnionType(types) {
  13938. const flattened = (0, removeTypeDuplicates_1.default)(types);
  13939. if (flattened.length === 1) {
  13940. return flattened[0];
  13941. } else {
  13942. return (0, generated$1.unionTypeAnnotation)(flattened);
  13943. }
  13944. }
  13945. var createFlowUnionType_1 = /*#__PURE__*/Object.defineProperty({
  13946. default: _default$g
  13947. }, '__esModule', {value: true});
  13948. var _default$h = removeTypeDuplicates$1;
  13949. function removeTypeDuplicates$1(nodes) {
  13950. const generics = {};
  13951. const bases = {};
  13952. const typeGroups = [];
  13953. const types = [];
  13954. for (let i = 0; i < nodes.length; i++) {
  13955. const node = nodes[i];
  13956. if (!node) continue;
  13957. if (types.indexOf(node) >= 0) {
  13958. continue;
  13959. }
  13960. if ((0, generated.isTSAnyKeyword)(node)) {
  13961. return [node];
  13962. }
  13963. if ((0, generated.isTSBaseType)(node)) {
  13964. bases[node.type] = node;
  13965. continue;
  13966. }
  13967. if ((0, generated.isTSUnionType)(node)) {
  13968. if (typeGroups.indexOf(node.types) < 0) {
  13969. nodes = nodes.concat(node.types);
  13970. typeGroups.push(node.types);
  13971. }
  13972. continue;
  13973. }
  13974. types.push(node);
  13975. }
  13976. for (const type of Object.keys(bases)) {
  13977. types.push(bases[type]);
  13978. }
  13979. for (const name of Object.keys(generics)) {
  13980. types.push(generics[name]);
  13981. }
  13982. return types;
  13983. }
  13984. var removeTypeDuplicates_1$1 = /*#__PURE__*/Object.defineProperty({
  13985. default: _default$h
  13986. }, '__esModule', {value: true});
  13987. var _default$i = createTSUnionType;
  13988. function createTSUnionType(typeAnnotations) {
  13989. const types = typeAnnotations.map(type => type.typeAnnotation);
  13990. const flattened = (0, removeTypeDuplicates_1$1.default)(types);
  13991. if (flattened.length === 1) {
  13992. return flattened[0];
  13993. } else {
  13994. return (0, generated$1.tsUnionType)(flattened);
  13995. }
  13996. }
  13997. var createTSUnionType_1 = /*#__PURE__*/Object.defineProperty({
  13998. default: _default$i
  13999. }, '__esModule', {value: true});
  14000. var uppercase = createCommonjsModule(function (module, exports) {
  14001. Object.defineProperty(exports, "__esModule", {
  14002. value: true
  14003. });
  14004. Object.defineProperty(exports, "ArrayExpression", {
  14005. enumerable: true,
  14006. get: function () {
  14007. return generated$1.arrayExpression;
  14008. }
  14009. });
  14010. Object.defineProperty(exports, "AssignmentExpression", {
  14011. enumerable: true,
  14012. get: function () {
  14013. return generated$1.assignmentExpression;
  14014. }
  14015. });
  14016. Object.defineProperty(exports, "BinaryExpression", {
  14017. enumerable: true,
  14018. get: function () {
  14019. return generated$1.binaryExpression;
  14020. }
  14021. });
  14022. Object.defineProperty(exports, "InterpreterDirective", {
  14023. enumerable: true,
  14024. get: function () {
  14025. return generated$1.interpreterDirective;
  14026. }
  14027. });
  14028. Object.defineProperty(exports, "Directive", {
  14029. enumerable: true,
  14030. get: function () {
  14031. return generated$1.directive;
  14032. }
  14033. });
  14034. Object.defineProperty(exports, "DirectiveLiteral", {
  14035. enumerable: true,
  14036. get: function () {
  14037. return generated$1.directiveLiteral;
  14038. }
  14039. });
  14040. Object.defineProperty(exports, "BlockStatement", {
  14041. enumerable: true,
  14042. get: function () {
  14043. return generated$1.blockStatement;
  14044. }
  14045. });
  14046. Object.defineProperty(exports, "BreakStatement", {
  14047. enumerable: true,
  14048. get: function () {
  14049. return generated$1.breakStatement;
  14050. }
  14051. });
  14052. Object.defineProperty(exports, "CallExpression", {
  14053. enumerable: true,
  14054. get: function () {
  14055. return generated$1.callExpression;
  14056. }
  14057. });
  14058. Object.defineProperty(exports, "CatchClause", {
  14059. enumerable: true,
  14060. get: function () {
  14061. return generated$1.catchClause;
  14062. }
  14063. });
  14064. Object.defineProperty(exports, "ConditionalExpression", {
  14065. enumerable: true,
  14066. get: function () {
  14067. return generated$1.conditionalExpression;
  14068. }
  14069. });
  14070. Object.defineProperty(exports, "ContinueStatement", {
  14071. enumerable: true,
  14072. get: function () {
  14073. return generated$1.continueStatement;
  14074. }
  14075. });
  14076. Object.defineProperty(exports, "DebuggerStatement", {
  14077. enumerable: true,
  14078. get: function () {
  14079. return generated$1.debuggerStatement;
  14080. }
  14081. });
  14082. Object.defineProperty(exports, "DoWhileStatement", {
  14083. enumerable: true,
  14084. get: function () {
  14085. return generated$1.doWhileStatement;
  14086. }
  14087. });
  14088. Object.defineProperty(exports, "EmptyStatement", {
  14089. enumerable: true,
  14090. get: function () {
  14091. return generated$1.emptyStatement;
  14092. }
  14093. });
  14094. Object.defineProperty(exports, "ExpressionStatement", {
  14095. enumerable: true,
  14096. get: function () {
  14097. return generated$1.expressionStatement;
  14098. }
  14099. });
  14100. Object.defineProperty(exports, "File", {
  14101. enumerable: true,
  14102. get: function () {
  14103. return generated$1.file;
  14104. }
  14105. });
  14106. Object.defineProperty(exports, "ForInStatement", {
  14107. enumerable: true,
  14108. get: function () {
  14109. return generated$1.forInStatement;
  14110. }
  14111. });
  14112. Object.defineProperty(exports, "ForStatement", {
  14113. enumerable: true,
  14114. get: function () {
  14115. return generated$1.forStatement;
  14116. }
  14117. });
  14118. Object.defineProperty(exports, "FunctionDeclaration", {
  14119. enumerable: true,
  14120. get: function () {
  14121. return generated$1.functionDeclaration;
  14122. }
  14123. });
  14124. Object.defineProperty(exports, "FunctionExpression", {
  14125. enumerable: true,
  14126. get: function () {
  14127. return generated$1.functionExpression;
  14128. }
  14129. });
  14130. Object.defineProperty(exports, "Identifier", {
  14131. enumerable: true,
  14132. get: function () {
  14133. return generated$1.identifier;
  14134. }
  14135. });
  14136. Object.defineProperty(exports, "IfStatement", {
  14137. enumerable: true,
  14138. get: function () {
  14139. return generated$1.ifStatement;
  14140. }
  14141. });
  14142. Object.defineProperty(exports, "LabeledStatement", {
  14143. enumerable: true,
  14144. get: function () {
  14145. return generated$1.labeledStatement;
  14146. }
  14147. });
  14148. Object.defineProperty(exports, "StringLiteral", {
  14149. enumerable: true,
  14150. get: function () {
  14151. return generated$1.stringLiteral;
  14152. }
  14153. });
  14154. Object.defineProperty(exports, "NumericLiteral", {
  14155. enumerable: true,
  14156. get: function () {
  14157. return generated$1.numericLiteral;
  14158. }
  14159. });
  14160. Object.defineProperty(exports, "NullLiteral", {
  14161. enumerable: true,
  14162. get: function () {
  14163. return generated$1.nullLiteral;
  14164. }
  14165. });
  14166. Object.defineProperty(exports, "BooleanLiteral", {
  14167. enumerable: true,
  14168. get: function () {
  14169. return generated$1.booleanLiteral;
  14170. }
  14171. });
  14172. Object.defineProperty(exports, "RegExpLiteral", {
  14173. enumerable: true,
  14174. get: function () {
  14175. return generated$1.regExpLiteral;
  14176. }
  14177. });
  14178. Object.defineProperty(exports, "LogicalExpression", {
  14179. enumerable: true,
  14180. get: function () {
  14181. return generated$1.logicalExpression;
  14182. }
  14183. });
  14184. Object.defineProperty(exports, "MemberExpression", {
  14185. enumerable: true,
  14186. get: function () {
  14187. return generated$1.memberExpression;
  14188. }
  14189. });
  14190. Object.defineProperty(exports, "NewExpression", {
  14191. enumerable: true,
  14192. get: function () {
  14193. return generated$1.newExpression;
  14194. }
  14195. });
  14196. Object.defineProperty(exports, "Program", {
  14197. enumerable: true,
  14198. get: function () {
  14199. return generated$1.program;
  14200. }
  14201. });
  14202. Object.defineProperty(exports, "ObjectExpression", {
  14203. enumerable: true,
  14204. get: function () {
  14205. return generated$1.objectExpression;
  14206. }
  14207. });
  14208. Object.defineProperty(exports, "ObjectMethod", {
  14209. enumerable: true,
  14210. get: function () {
  14211. return generated$1.objectMethod;
  14212. }
  14213. });
  14214. Object.defineProperty(exports, "ObjectProperty", {
  14215. enumerable: true,
  14216. get: function () {
  14217. return generated$1.objectProperty;
  14218. }
  14219. });
  14220. Object.defineProperty(exports, "RestElement", {
  14221. enumerable: true,
  14222. get: function () {
  14223. return generated$1.restElement;
  14224. }
  14225. });
  14226. Object.defineProperty(exports, "ReturnStatement", {
  14227. enumerable: true,
  14228. get: function () {
  14229. return generated$1.returnStatement;
  14230. }
  14231. });
  14232. Object.defineProperty(exports, "SequenceExpression", {
  14233. enumerable: true,
  14234. get: function () {
  14235. return generated$1.sequenceExpression;
  14236. }
  14237. });
  14238. Object.defineProperty(exports, "ParenthesizedExpression", {
  14239. enumerable: true,
  14240. get: function () {
  14241. return generated$1.parenthesizedExpression;
  14242. }
  14243. });
  14244. Object.defineProperty(exports, "SwitchCase", {
  14245. enumerable: true,
  14246. get: function () {
  14247. return generated$1.switchCase;
  14248. }
  14249. });
  14250. Object.defineProperty(exports, "SwitchStatement", {
  14251. enumerable: true,
  14252. get: function () {
  14253. return generated$1.switchStatement;
  14254. }
  14255. });
  14256. Object.defineProperty(exports, "ThisExpression", {
  14257. enumerable: true,
  14258. get: function () {
  14259. return generated$1.thisExpression;
  14260. }
  14261. });
  14262. Object.defineProperty(exports, "ThrowStatement", {
  14263. enumerable: true,
  14264. get: function () {
  14265. return generated$1.throwStatement;
  14266. }
  14267. });
  14268. Object.defineProperty(exports, "TryStatement", {
  14269. enumerable: true,
  14270. get: function () {
  14271. return generated$1.tryStatement;
  14272. }
  14273. });
  14274. Object.defineProperty(exports, "UnaryExpression", {
  14275. enumerable: true,
  14276. get: function () {
  14277. return generated$1.unaryExpression;
  14278. }
  14279. });
  14280. Object.defineProperty(exports, "UpdateExpression", {
  14281. enumerable: true,
  14282. get: function () {
  14283. return generated$1.updateExpression;
  14284. }
  14285. });
  14286. Object.defineProperty(exports, "VariableDeclaration", {
  14287. enumerable: true,
  14288. get: function () {
  14289. return generated$1.variableDeclaration;
  14290. }
  14291. });
  14292. Object.defineProperty(exports, "VariableDeclarator", {
  14293. enumerable: true,
  14294. get: function () {
  14295. return generated$1.variableDeclarator;
  14296. }
  14297. });
  14298. Object.defineProperty(exports, "WhileStatement", {
  14299. enumerable: true,
  14300. get: function () {
  14301. return generated$1.whileStatement;
  14302. }
  14303. });
  14304. Object.defineProperty(exports, "WithStatement", {
  14305. enumerable: true,
  14306. get: function () {
  14307. return generated$1.withStatement;
  14308. }
  14309. });
  14310. Object.defineProperty(exports, "AssignmentPattern", {
  14311. enumerable: true,
  14312. get: function () {
  14313. return generated$1.assignmentPattern;
  14314. }
  14315. });
  14316. Object.defineProperty(exports, "ArrayPattern", {
  14317. enumerable: true,
  14318. get: function () {
  14319. return generated$1.arrayPattern;
  14320. }
  14321. });
  14322. Object.defineProperty(exports, "ArrowFunctionExpression", {
  14323. enumerable: true,
  14324. get: function () {
  14325. return generated$1.arrowFunctionExpression;
  14326. }
  14327. });
  14328. Object.defineProperty(exports, "ClassBody", {
  14329. enumerable: true,
  14330. get: function () {
  14331. return generated$1.classBody;
  14332. }
  14333. });
  14334. Object.defineProperty(exports, "ClassExpression", {
  14335. enumerable: true,
  14336. get: function () {
  14337. return generated$1.classExpression;
  14338. }
  14339. });
  14340. Object.defineProperty(exports, "ClassDeclaration", {
  14341. enumerable: true,
  14342. get: function () {
  14343. return generated$1.classDeclaration;
  14344. }
  14345. });
  14346. Object.defineProperty(exports, "ExportAllDeclaration", {
  14347. enumerable: true,
  14348. get: function () {
  14349. return generated$1.exportAllDeclaration;
  14350. }
  14351. });
  14352. Object.defineProperty(exports, "ExportDefaultDeclaration", {
  14353. enumerable: true,
  14354. get: function () {
  14355. return generated$1.exportDefaultDeclaration;
  14356. }
  14357. });
  14358. Object.defineProperty(exports, "ExportNamedDeclaration", {
  14359. enumerable: true,
  14360. get: function () {
  14361. return generated$1.exportNamedDeclaration;
  14362. }
  14363. });
  14364. Object.defineProperty(exports, "ExportSpecifier", {
  14365. enumerable: true,
  14366. get: function () {
  14367. return generated$1.exportSpecifier;
  14368. }
  14369. });
  14370. Object.defineProperty(exports, "ForOfStatement", {
  14371. enumerable: true,
  14372. get: function () {
  14373. return generated$1.forOfStatement;
  14374. }
  14375. });
  14376. Object.defineProperty(exports, "ImportDeclaration", {
  14377. enumerable: true,
  14378. get: function () {
  14379. return generated$1.importDeclaration;
  14380. }
  14381. });
  14382. Object.defineProperty(exports, "ImportDefaultSpecifier", {
  14383. enumerable: true,
  14384. get: function () {
  14385. return generated$1.importDefaultSpecifier;
  14386. }
  14387. });
  14388. Object.defineProperty(exports, "ImportNamespaceSpecifier", {
  14389. enumerable: true,
  14390. get: function () {
  14391. return generated$1.importNamespaceSpecifier;
  14392. }
  14393. });
  14394. Object.defineProperty(exports, "ImportSpecifier", {
  14395. enumerable: true,
  14396. get: function () {
  14397. return generated$1.importSpecifier;
  14398. }
  14399. });
  14400. Object.defineProperty(exports, "MetaProperty", {
  14401. enumerable: true,
  14402. get: function () {
  14403. return generated$1.metaProperty;
  14404. }
  14405. });
  14406. Object.defineProperty(exports, "ClassMethod", {
  14407. enumerable: true,
  14408. get: function () {
  14409. return generated$1.classMethod;
  14410. }
  14411. });
  14412. Object.defineProperty(exports, "ObjectPattern", {
  14413. enumerable: true,
  14414. get: function () {
  14415. return generated$1.objectPattern;
  14416. }
  14417. });
  14418. Object.defineProperty(exports, "SpreadElement", {
  14419. enumerable: true,
  14420. get: function () {
  14421. return generated$1.spreadElement;
  14422. }
  14423. });
  14424. Object.defineProperty(exports, "Super", {
  14425. enumerable: true,
  14426. get: function () {
  14427. return generated$1.super;
  14428. }
  14429. });
  14430. Object.defineProperty(exports, "TaggedTemplateExpression", {
  14431. enumerable: true,
  14432. get: function () {
  14433. return generated$1.taggedTemplateExpression;
  14434. }
  14435. });
  14436. Object.defineProperty(exports, "TemplateElement", {
  14437. enumerable: true,
  14438. get: function () {
  14439. return generated$1.templateElement;
  14440. }
  14441. });
  14442. Object.defineProperty(exports, "TemplateLiteral", {
  14443. enumerable: true,
  14444. get: function () {
  14445. return generated$1.templateLiteral;
  14446. }
  14447. });
  14448. Object.defineProperty(exports, "YieldExpression", {
  14449. enumerable: true,
  14450. get: function () {
  14451. return generated$1.yieldExpression;
  14452. }
  14453. });
  14454. Object.defineProperty(exports, "AwaitExpression", {
  14455. enumerable: true,
  14456. get: function () {
  14457. return generated$1.awaitExpression;
  14458. }
  14459. });
  14460. Object.defineProperty(exports, "Import", {
  14461. enumerable: true,
  14462. get: function () {
  14463. return generated$1.import;
  14464. }
  14465. });
  14466. Object.defineProperty(exports, "BigIntLiteral", {
  14467. enumerable: true,
  14468. get: function () {
  14469. return generated$1.bigIntLiteral;
  14470. }
  14471. });
  14472. Object.defineProperty(exports, "ExportNamespaceSpecifier", {
  14473. enumerable: true,
  14474. get: function () {
  14475. return generated$1.exportNamespaceSpecifier;
  14476. }
  14477. });
  14478. Object.defineProperty(exports, "OptionalMemberExpression", {
  14479. enumerable: true,
  14480. get: function () {
  14481. return generated$1.optionalMemberExpression;
  14482. }
  14483. });
  14484. Object.defineProperty(exports, "OptionalCallExpression", {
  14485. enumerable: true,
  14486. get: function () {
  14487. return generated$1.optionalCallExpression;
  14488. }
  14489. });
  14490. Object.defineProperty(exports, "ClassProperty", {
  14491. enumerable: true,
  14492. get: function () {
  14493. return generated$1.classProperty;
  14494. }
  14495. });
  14496. Object.defineProperty(exports, "ClassPrivateProperty", {
  14497. enumerable: true,
  14498. get: function () {
  14499. return generated$1.classPrivateProperty;
  14500. }
  14501. });
  14502. Object.defineProperty(exports, "ClassPrivateMethod", {
  14503. enumerable: true,
  14504. get: function () {
  14505. return generated$1.classPrivateMethod;
  14506. }
  14507. });
  14508. Object.defineProperty(exports, "PrivateName", {
  14509. enumerable: true,
  14510. get: function () {
  14511. return generated$1.privateName;
  14512. }
  14513. });
  14514. Object.defineProperty(exports, "AnyTypeAnnotation", {
  14515. enumerable: true,
  14516. get: function () {
  14517. return generated$1.anyTypeAnnotation;
  14518. }
  14519. });
  14520. Object.defineProperty(exports, "ArrayTypeAnnotation", {
  14521. enumerable: true,
  14522. get: function () {
  14523. return generated$1.arrayTypeAnnotation;
  14524. }
  14525. });
  14526. Object.defineProperty(exports, "BooleanTypeAnnotation", {
  14527. enumerable: true,
  14528. get: function () {
  14529. return generated$1.booleanTypeAnnotation;
  14530. }
  14531. });
  14532. Object.defineProperty(exports, "BooleanLiteralTypeAnnotation", {
  14533. enumerable: true,
  14534. get: function () {
  14535. return generated$1.booleanLiteralTypeAnnotation;
  14536. }
  14537. });
  14538. Object.defineProperty(exports, "NullLiteralTypeAnnotation", {
  14539. enumerable: true,
  14540. get: function () {
  14541. return generated$1.nullLiteralTypeAnnotation;
  14542. }
  14543. });
  14544. Object.defineProperty(exports, "ClassImplements", {
  14545. enumerable: true,
  14546. get: function () {
  14547. return generated$1.classImplements;
  14548. }
  14549. });
  14550. Object.defineProperty(exports, "DeclareClass", {
  14551. enumerable: true,
  14552. get: function () {
  14553. return generated$1.declareClass;
  14554. }
  14555. });
  14556. Object.defineProperty(exports, "DeclareFunction", {
  14557. enumerable: true,
  14558. get: function () {
  14559. return generated$1.declareFunction;
  14560. }
  14561. });
  14562. Object.defineProperty(exports, "DeclareInterface", {
  14563. enumerable: true,
  14564. get: function () {
  14565. return generated$1.declareInterface;
  14566. }
  14567. });
  14568. Object.defineProperty(exports, "DeclareModule", {
  14569. enumerable: true,
  14570. get: function () {
  14571. return generated$1.declareModule;
  14572. }
  14573. });
  14574. Object.defineProperty(exports, "DeclareModuleExports", {
  14575. enumerable: true,
  14576. get: function () {
  14577. return generated$1.declareModuleExports;
  14578. }
  14579. });
  14580. Object.defineProperty(exports, "DeclareTypeAlias", {
  14581. enumerable: true,
  14582. get: function () {
  14583. return generated$1.declareTypeAlias;
  14584. }
  14585. });
  14586. Object.defineProperty(exports, "DeclareOpaqueType", {
  14587. enumerable: true,
  14588. get: function () {
  14589. return generated$1.declareOpaqueType;
  14590. }
  14591. });
  14592. Object.defineProperty(exports, "DeclareVariable", {
  14593. enumerable: true,
  14594. get: function () {
  14595. return generated$1.declareVariable;
  14596. }
  14597. });
  14598. Object.defineProperty(exports, "DeclareExportDeclaration", {
  14599. enumerable: true,
  14600. get: function () {
  14601. return generated$1.declareExportDeclaration;
  14602. }
  14603. });
  14604. Object.defineProperty(exports, "DeclareExportAllDeclaration", {
  14605. enumerable: true,
  14606. get: function () {
  14607. return generated$1.declareExportAllDeclaration;
  14608. }
  14609. });
  14610. Object.defineProperty(exports, "DeclaredPredicate", {
  14611. enumerable: true,
  14612. get: function () {
  14613. return generated$1.declaredPredicate;
  14614. }
  14615. });
  14616. Object.defineProperty(exports, "ExistsTypeAnnotation", {
  14617. enumerable: true,
  14618. get: function () {
  14619. return generated$1.existsTypeAnnotation;
  14620. }
  14621. });
  14622. Object.defineProperty(exports, "FunctionTypeAnnotation", {
  14623. enumerable: true,
  14624. get: function () {
  14625. return generated$1.functionTypeAnnotation;
  14626. }
  14627. });
  14628. Object.defineProperty(exports, "FunctionTypeParam", {
  14629. enumerable: true,
  14630. get: function () {
  14631. return generated$1.functionTypeParam;
  14632. }
  14633. });
  14634. Object.defineProperty(exports, "GenericTypeAnnotation", {
  14635. enumerable: true,
  14636. get: function () {
  14637. return generated$1.genericTypeAnnotation;
  14638. }
  14639. });
  14640. Object.defineProperty(exports, "InferredPredicate", {
  14641. enumerable: true,
  14642. get: function () {
  14643. return generated$1.inferredPredicate;
  14644. }
  14645. });
  14646. Object.defineProperty(exports, "InterfaceExtends", {
  14647. enumerable: true,
  14648. get: function () {
  14649. return generated$1.interfaceExtends;
  14650. }
  14651. });
  14652. Object.defineProperty(exports, "InterfaceDeclaration", {
  14653. enumerable: true,
  14654. get: function () {
  14655. return generated$1.interfaceDeclaration;
  14656. }
  14657. });
  14658. Object.defineProperty(exports, "InterfaceTypeAnnotation", {
  14659. enumerable: true,
  14660. get: function () {
  14661. return generated$1.interfaceTypeAnnotation;
  14662. }
  14663. });
  14664. Object.defineProperty(exports, "IntersectionTypeAnnotation", {
  14665. enumerable: true,
  14666. get: function () {
  14667. return generated$1.intersectionTypeAnnotation;
  14668. }
  14669. });
  14670. Object.defineProperty(exports, "MixedTypeAnnotation", {
  14671. enumerable: true,
  14672. get: function () {
  14673. return generated$1.mixedTypeAnnotation;
  14674. }
  14675. });
  14676. Object.defineProperty(exports, "EmptyTypeAnnotation", {
  14677. enumerable: true,
  14678. get: function () {
  14679. return generated$1.emptyTypeAnnotation;
  14680. }
  14681. });
  14682. Object.defineProperty(exports, "NullableTypeAnnotation", {
  14683. enumerable: true,
  14684. get: function () {
  14685. return generated$1.nullableTypeAnnotation;
  14686. }
  14687. });
  14688. Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
  14689. enumerable: true,
  14690. get: function () {
  14691. return generated$1.numberLiteralTypeAnnotation;
  14692. }
  14693. });
  14694. Object.defineProperty(exports, "NumberTypeAnnotation", {
  14695. enumerable: true,
  14696. get: function () {
  14697. return generated$1.numberTypeAnnotation;
  14698. }
  14699. });
  14700. Object.defineProperty(exports, "ObjectTypeAnnotation", {
  14701. enumerable: true,
  14702. get: function () {
  14703. return generated$1.objectTypeAnnotation;
  14704. }
  14705. });
  14706. Object.defineProperty(exports, "ObjectTypeInternalSlot", {
  14707. enumerable: true,
  14708. get: function () {
  14709. return generated$1.objectTypeInternalSlot;
  14710. }
  14711. });
  14712. Object.defineProperty(exports, "ObjectTypeCallProperty", {
  14713. enumerable: true,
  14714. get: function () {
  14715. return generated$1.objectTypeCallProperty;
  14716. }
  14717. });
  14718. Object.defineProperty(exports, "ObjectTypeIndexer", {
  14719. enumerable: true,
  14720. get: function () {
  14721. return generated$1.objectTypeIndexer;
  14722. }
  14723. });
  14724. Object.defineProperty(exports, "ObjectTypeProperty", {
  14725. enumerable: true,
  14726. get: function () {
  14727. return generated$1.objectTypeProperty;
  14728. }
  14729. });
  14730. Object.defineProperty(exports, "ObjectTypeSpreadProperty", {
  14731. enumerable: true,
  14732. get: function () {
  14733. return generated$1.objectTypeSpreadProperty;
  14734. }
  14735. });
  14736. Object.defineProperty(exports, "OpaqueType", {
  14737. enumerable: true,
  14738. get: function () {
  14739. return generated$1.opaqueType;
  14740. }
  14741. });
  14742. Object.defineProperty(exports, "QualifiedTypeIdentifier", {
  14743. enumerable: true,
  14744. get: function () {
  14745. return generated$1.qualifiedTypeIdentifier;
  14746. }
  14747. });
  14748. Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
  14749. enumerable: true,
  14750. get: function () {
  14751. return generated$1.stringLiteralTypeAnnotation;
  14752. }
  14753. });
  14754. Object.defineProperty(exports, "StringTypeAnnotation", {
  14755. enumerable: true,
  14756. get: function () {
  14757. return generated$1.stringTypeAnnotation;
  14758. }
  14759. });
  14760. Object.defineProperty(exports, "SymbolTypeAnnotation", {
  14761. enumerable: true,
  14762. get: function () {
  14763. return generated$1.symbolTypeAnnotation;
  14764. }
  14765. });
  14766. Object.defineProperty(exports, "ThisTypeAnnotation", {
  14767. enumerable: true,
  14768. get: function () {
  14769. return generated$1.thisTypeAnnotation;
  14770. }
  14771. });
  14772. Object.defineProperty(exports, "TupleTypeAnnotation", {
  14773. enumerable: true,
  14774. get: function () {
  14775. return generated$1.tupleTypeAnnotation;
  14776. }
  14777. });
  14778. Object.defineProperty(exports, "TypeofTypeAnnotation", {
  14779. enumerable: true,
  14780. get: function () {
  14781. return generated$1.typeofTypeAnnotation;
  14782. }
  14783. });
  14784. Object.defineProperty(exports, "TypeAlias", {
  14785. enumerable: true,
  14786. get: function () {
  14787. return generated$1.typeAlias;
  14788. }
  14789. });
  14790. Object.defineProperty(exports, "TypeAnnotation", {
  14791. enumerable: true,
  14792. get: function () {
  14793. return generated$1.typeAnnotation;
  14794. }
  14795. });
  14796. Object.defineProperty(exports, "TypeCastExpression", {
  14797. enumerable: true,
  14798. get: function () {
  14799. return generated$1.typeCastExpression;
  14800. }
  14801. });
  14802. Object.defineProperty(exports, "TypeParameter", {
  14803. enumerable: true,
  14804. get: function () {
  14805. return generated$1.typeParameter;
  14806. }
  14807. });
  14808. Object.defineProperty(exports, "TypeParameterDeclaration", {
  14809. enumerable: true,
  14810. get: function () {
  14811. return generated$1.typeParameterDeclaration;
  14812. }
  14813. });
  14814. Object.defineProperty(exports, "TypeParameterInstantiation", {
  14815. enumerable: true,
  14816. get: function () {
  14817. return generated$1.typeParameterInstantiation;
  14818. }
  14819. });
  14820. Object.defineProperty(exports, "UnionTypeAnnotation", {
  14821. enumerable: true,
  14822. get: function () {
  14823. return generated$1.unionTypeAnnotation;
  14824. }
  14825. });
  14826. Object.defineProperty(exports, "Variance", {
  14827. enumerable: true,
  14828. get: function () {
  14829. return generated$1.variance;
  14830. }
  14831. });
  14832. Object.defineProperty(exports, "VoidTypeAnnotation", {
  14833. enumerable: true,
  14834. get: function () {
  14835. return generated$1.voidTypeAnnotation;
  14836. }
  14837. });
  14838. Object.defineProperty(exports, "EnumDeclaration", {
  14839. enumerable: true,
  14840. get: function () {
  14841. return generated$1.enumDeclaration;
  14842. }
  14843. });
  14844. Object.defineProperty(exports, "EnumBooleanBody", {
  14845. enumerable: true,
  14846. get: function () {
  14847. return generated$1.enumBooleanBody;
  14848. }
  14849. });
  14850. Object.defineProperty(exports, "EnumNumberBody", {
  14851. enumerable: true,
  14852. get: function () {
  14853. return generated$1.enumNumberBody;
  14854. }
  14855. });
  14856. Object.defineProperty(exports, "EnumStringBody", {
  14857. enumerable: true,
  14858. get: function () {
  14859. return generated$1.enumStringBody;
  14860. }
  14861. });
  14862. Object.defineProperty(exports, "EnumSymbolBody", {
  14863. enumerable: true,
  14864. get: function () {
  14865. return generated$1.enumSymbolBody;
  14866. }
  14867. });
  14868. Object.defineProperty(exports, "EnumBooleanMember", {
  14869. enumerable: true,
  14870. get: function () {
  14871. return generated$1.enumBooleanMember;
  14872. }
  14873. });
  14874. Object.defineProperty(exports, "EnumNumberMember", {
  14875. enumerable: true,
  14876. get: function () {
  14877. return generated$1.enumNumberMember;
  14878. }
  14879. });
  14880. Object.defineProperty(exports, "EnumStringMember", {
  14881. enumerable: true,
  14882. get: function () {
  14883. return generated$1.enumStringMember;
  14884. }
  14885. });
  14886. Object.defineProperty(exports, "EnumDefaultedMember", {
  14887. enumerable: true,
  14888. get: function () {
  14889. return generated$1.enumDefaultedMember;
  14890. }
  14891. });
  14892. Object.defineProperty(exports, "IndexedAccessType", {
  14893. enumerable: true,
  14894. get: function () {
  14895. return generated$1.indexedAccessType;
  14896. }
  14897. });
  14898. Object.defineProperty(exports, "OptionalIndexedAccessType", {
  14899. enumerable: true,
  14900. get: function () {
  14901. return generated$1.optionalIndexedAccessType;
  14902. }
  14903. });
  14904. Object.defineProperty(exports, "JSXAttribute", {
  14905. enumerable: true,
  14906. get: function () {
  14907. return generated$1.jsxAttribute;
  14908. }
  14909. });
  14910. Object.defineProperty(exports, "JSXClosingElement", {
  14911. enumerable: true,
  14912. get: function () {
  14913. return generated$1.jsxClosingElement;
  14914. }
  14915. });
  14916. Object.defineProperty(exports, "JSXElement", {
  14917. enumerable: true,
  14918. get: function () {
  14919. return generated$1.jsxElement;
  14920. }
  14921. });
  14922. Object.defineProperty(exports, "JSXEmptyExpression", {
  14923. enumerable: true,
  14924. get: function () {
  14925. return generated$1.jsxEmptyExpression;
  14926. }
  14927. });
  14928. Object.defineProperty(exports, "JSXExpressionContainer", {
  14929. enumerable: true,
  14930. get: function () {
  14931. return generated$1.jsxExpressionContainer;
  14932. }
  14933. });
  14934. Object.defineProperty(exports, "JSXSpreadChild", {
  14935. enumerable: true,
  14936. get: function () {
  14937. return generated$1.jsxSpreadChild;
  14938. }
  14939. });
  14940. Object.defineProperty(exports, "JSXIdentifier", {
  14941. enumerable: true,
  14942. get: function () {
  14943. return generated$1.jsxIdentifier;
  14944. }
  14945. });
  14946. Object.defineProperty(exports, "JSXMemberExpression", {
  14947. enumerable: true,
  14948. get: function () {
  14949. return generated$1.jsxMemberExpression;
  14950. }
  14951. });
  14952. Object.defineProperty(exports, "JSXNamespacedName", {
  14953. enumerable: true,
  14954. get: function () {
  14955. return generated$1.jsxNamespacedName;
  14956. }
  14957. });
  14958. Object.defineProperty(exports, "JSXOpeningElement", {
  14959. enumerable: true,
  14960. get: function () {
  14961. return generated$1.jsxOpeningElement;
  14962. }
  14963. });
  14964. Object.defineProperty(exports, "JSXSpreadAttribute", {
  14965. enumerable: true,
  14966. get: function () {
  14967. return generated$1.jsxSpreadAttribute;
  14968. }
  14969. });
  14970. Object.defineProperty(exports, "JSXText", {
  14971. enumerable: true,
  14972. get: function () {
  14973. return generated$1.jsxText;
  14974. }
  14975. });
  14976. Object.defineProperty(exports, "JSXFragment", {
  14977. enumerable: true,
  14978. get: function () {
  14979. return generated$1.jsxFragment;
  14980. }
  14981. });
  14982. Object.defineProperty(exports, "JSXOpeningFragment", {
  14983. enumerable: true,
  14984. get: function () {
  14985. return generated$1.jsxOpeningFragment;
  14986. }
  14987. });
  14988. Object.defineProperty(exports, "JSXClosingFragment", {
  14989. enumerable: true,
  14990. get: function () {
  14991. return generated$1.jsxClosingFragment;
  14992. }
  14993. });
  14994. Object.defineProperty(exports, "Noop", {
  14995. enumerable: true,
  14996. get: function () {
  14997. return generated$1.noop;
  14998. }
  14999. });
  15000. Object.defineProperty(exports, "Placeholder", {
  15001. enumerable: true,
  15002. get: function () {
  15003. return generated$1.placeholder;
  15004. }
  15005. });
  15006. Object.defineProperty(exports, "V8IntrinsicIdentifier", {
  15007. enumerable: true,
  15008. get: function () {
  15009. return generated$1.v8IntrinsicIdentifier;
  15010. }
  15011. });
  15012. Object.defineProperty(exports, "ArgumentPlaceholder", {
  15013. enumerable: true,
  15014. get: function () {
  15015. return generated$1.argumentPlaceholder;
  15016. }
  15017. });
  15018. Object.defineProperty(exports, "BindExpression", {
  15019. enumerable: true,
  15020. get: function () {
  15021. return generated$1.bindExpression;
  15022. }
  15023. });
  15024. Object.defineProperty(exports, "ImportAttribute", {
  15025. enumerable: true,
  15026. get: function () {
  15027. return generated$1.importAttribute;
  15028. }
  15029. });
  15030. Object.defineProperty(exports, "Decorator", {
  15031. enumerable: true,
  15032. get: function () {
  15033. return generated$1.decorator;
  15034. }
  15035. });
  15036. Object.defineProperty(exports, "DoExpression", {
  15037. enumerable: true,
  15038. get: function () {
  15039. return generated$1.doExpression;
  15040. }
  15041. });
  15042. Object.defineProperty(exports, "ExportDefaultSpecifier", {
  15043. enumerable: true,
  15044. get: function () {
  15045. return generated$1.exportDefaultSpecifier;
  15046. }
  15047. });
  15048. Object.defineProperty(exports, "RecordExpression", {
  15049. enumerable: true,
  15050. get: function () {
  15051. return generated$1.recordExpression;
  15052. }
  15053. });
  15054. Object.defineProperty(exports, "TupleExpression", {
  15055. enumerable: true,
  15056. get: function () {
  15057. return generated$1.tupleExpression;
  15058. }
  15059. });
  15060. Object.defineProperty(exports, "DecimalLiteral", {
  15061. enumerable: true,
  15062. get: function () {
  15063. return generated$1.decimalLiteral;
  15064. }
  15065. });
  15066. Object.defineProperty(exports, "StaticBlock", {
  15067. enumerable: true,
  15068. get: function () {
  15069. return generated$1.staticBlock;
  15070. }
  15071. });
  15072. Object.defineProperty(exports, "ModuleExpression", {
  15073. enumerable: true,
  15074. get: function () {
  15075. return generated$1.moduleExpression;
  15076. }
  15077. });
  15078. Object.defineProperty(exports, "TopicReference", {
  15079. enumerable: true,
  15080. get: function () {
  15081. return generated$1.topicReference;
  15082. }
  15083. });
  15084. Object.defineProperty(exports, "PipelineTopicExpression", {
  15085. enumerable: true,
  15086. get: function () {
  15087. return generated$1.pipelineTopicExpression;
  15088. }
  15089. });
  15090. Object.defineProperty(exports, "PipelineBareFunction", {
  15091. enumerable: true,
  15092. get: function () {
  15093. return generated$1.pipelineBareFunction;
  15094. }
  15095. });
  15096. Object.defineProperty(exports, "PipelinePrimaryTopicReference", {
  15097. enumerable: true,
  15098. get: function () {
  15099. return generated$1.pipelinePrimaryTopicReference;
  15100. }
  15101. });
  15102. Object.defineProperty(exports, "TSParameterProperty", {
  15103. enumerable: true,
  15104. get: function () {
  15105. return generated$1.tsParameterProperty;
  15106. }
  15107. });
  15108. Object.defineProperty(exports, "TSDeclareFunction", {
  15109. enumerable: true,
  15110. get: function () {
  15111. return generated$1.tsDeclareFunction;
  15112. }
  15113. });
  15114. Object.defineProperty(exports, "TSDeclareMethod", {
  15115. enumerable: true,
  15116. get: function () {
  15117. return generated$1.tsDeclareMethod;
  15118. }
  15119. });
  15120. Object.defineProperty(exports, "TSQualifiedName", {
  15121. enumerable: true,
  15122. get: function () {
  15123. return generated$1.tsQualifiedName;
  15124. }
  15125. });
  15126. Object.defineProperty(exports, "TSCallSignatureDeclaration", {
  15127. enumerable: true,
  15128. get: function () {
  15129. return generated$1.tsCallSignatureDeclaration;
  15130. }
  15131. });
  15132. Object.defineProperty(exports, "TSConstructSignatureDeclaration", {
  15133. enumerable: true,
  15134. get: function () {
  15135. return generated$1.tsConstructSignatureDeclaration;
  15136. }
  15137. });
  15138. Object.defineProperty(exports, "TSPropertySignature", {
  15139. enumerable: true,
  15140. get: function () {
  15141. return generated$1.tsPropertySignature;
  15142. }
  15143. });
  15144. Object.defineProperty(exports, "TSMethodSignature", {
  15145. enumerable: true,
  15146. get: function () {
  15147. return generated$1.tsMethodSignature;
  15148. }
  15149. });
  15150. Object.defineProperty(exports, "TSIndexSignature", {
  15151. enumerable: true,
  15152. get: function () {
  15153. return generated$1.tsIndexSignature;
  15154. }
  15155. });
  15156. Object.defineProperty(exports, "TSAnyKeyword", {
  15157. enumerable: true,
  15158. get: function () {
  15159. return generated$1.tsAnyKeyword;
  15160. }
  15161. });
  15162. Object.defineProperty(exports, "TSBooleanKeyword", {
  15163. enumerable: true,
  15164. get: function () {
  15165. return generated$1.tsBooleanKeyword;
  15166. }
  15167. });
  15168. Object.defineProperty(exports, "TSBigIntKeyword", {
  15169. enumerable: true,
  15170. get: function () {
  15171. return generated$1.tsBigIntKeyword;
  15172. }
  15173. });
  15174. Object.defineProperty(exports, "TSIntrinsicKeyword", {
  15175. enumerable: true,
  15176. get: function () {
  15177. return generated$1.tsIntrinsicKeyword;
  15178. }
  15179. });
  15180. Object.defineProperty(exports, "TSNeverKeyword", {
  15181. enumerable: true,
  15182. get: function () {
  15183. return generated$1.tsNeverKeyword;
  15184. }
  15185. });
  15186. Object.defineProperty(exports, "TSNullKeyword", {
  15187. enumerable: true,
  15188. get: function () {
  15189. return generated$1.tsNullKeyword;
  15190. }
  15191. });
  15192. Object.defineProperty(exports, "TSNumberKeyword", {
  15193. enumerable: true,
  15194. get: function () {
  15195. return generated$1.tsNumberKeyword;
  15196. }
  15197. });
  15198. Object.defineProperty(exports, "TSObjectKeyword", {
  15199. enumerable: true,
  15200. get: function () {
  15201. return generated$1.tsObjectKeyword;
  15202. }
  15203. });
  15204. Object.defineProperty(exports, "TSStringKeyword", {
  15205. enumerable: true,
  15206. get: function () {
  15207. return generated$1.tsStringKeyword;
  15208. }
  15209. });
  15210. Object.defineProperty(exports, "TSSymbolKeyword", {
  15211. enumerable: true,
  15212. get: function () {
  15213. return generated$1.tsSymbolKeyword;
  15214. }
  15215. });
  15216. Object.defineProperty(exports, "TSUndefinedKeyword", {
  15217. enumerable: true,
  15218. get: function () {
  15219. return generated$1.tsUndefinedKeyword;
  15220. }
  15221. });
  15222. Object.defineProperty(exports, "TSUnknownKeyword", {
  15223. enumerable: true,
  15224. get: function () {
  15225. return generated$1.tsUnknownKeyword;
  15226. }
  15227. });
  15228. Object.defineProperty(exports, "TSVoidKeyword", {
  15229. enumerable: true,
  15230. get: function () {
  15231. return generated$1.tsVoidKeyword;
  15232. }
  15233. });
  15234. Object.defineProperty(exports, "TSThisType", {
  15235. enumerable: true,
  15236. get: function () {
  15237. return generated$1.tsThisType;
  15238. }
  15239. });
  15240. Object.defineProperty(exports, "TSFunctionType", {
  15241. enumerable: true,
  15242. get: function () {
  15243. return generated$1.tsFunctionType;
  15244. }
  15245. });
  15246. Object.defineProperty(exports, "TSConstructorType", {
  15247. enumerable: true,
  15248. get: function () {
  15249. return generated$1.tsConstructorType;
  15250. }
  15251. });
  15252. Object.defineProperty(exports, "TSTypeReference", {
  15253. enumerable: true,
  15254. get: function () {
  15255. return generated$1.tsTypeReference;
  15256. }
  15257. });
  15258. Object.defineProperty(exports, "TSTypePredicate", {
  15259. enumerable: true,
  15260. get: function () {
  15261. return generated$1.tsTypePredicate;
  15262. }
  15263. });
  15264. Object.defineProperty(exports, "TSTypeQuery", {
  15265. enumerable: true,
  15266. get: function () {
  15267. return generated$1.tsTypeQuery;
  15268. }
  15269. });
  15270. Object.defineProperty(exports, "TSTypeLiteral", {
  15271. enumerable: true,
  15272. get: function () {
  15273. return generated$1.tsTypeLiteral;
  15274. }
  15275. });
  15276. Object.defineProperty(exports, "TSArrayType", {
  15277. enumerable: true,
  15278. get: function () {
  15279. return generated$1.tsArrayType;
  15280. }
  15281. });
  15282. Object.defineProperty(exports, "TSTupleType", {
  15283. enumerable: true,
  15284. get: function () {
  15285. return generated$1.tsTupleType;
  15286. }
  15287. });
  15288. Object.defineProperty(exports, "TSOptionalType", {
  15289. enumerable: true,
  15290. get: function () {
  15291. return generated$1.tsOptionalType;
  15292. }
  15293. });
  15294. Object.defineProperty(exports, "TSRestType", {
  15295. enumerable: true,
  15296. get: function () {
  15297. return generated$1.tsRestType;
  15298. }
  15299. });
  15300. Object.defineProperty(exports, "TSNamedTupleMember", {
  15301. enumerable: true,
  15302. get: function () {
  15303. return generated$1.tsNamedTupleMember;
  15304. }
  15305. });
  15306. Object.defineProperty(exports, "TSUnionType", {
  15307. enumerable: true,
  15308. get: function () {
  15309. return generated$1.tsUnionType;
  15310. }
  15311. });
  15312. Object.defineProperty(exports, "TSIntersectionType", {
  15313. enumerable: true,
  15314. get: function () {
  15315. return generated$1.tsIntersectionType;
  15316. }
  15317. });
  15318. Object.defineProperty(exports, "TSConditionalType", {
  15319. enumerable: true,
  15320. get: function () {
  15321. return generated$1.tsConditionalType;
  15322. }
  15323. });
  15324. Object.defineProperty(exports, "TSInferType", {
  15325. enumerable: true,
  15326. get: function () {
  15327. return generated$1.tsInferType;
  15328. }
  15329. });
  15330. Object.defineProperty(exports, "TSParenthesizedType", {
  15331. enumerable: true,
  15332. get: function () {
  15333. return generated$1.tsParenthesizedType;
  15334. }
  15335. });
  15336. Object.defineProperty(exports, "TSTypeOperator", {
  15337. enumerable: true,
  15338. get: function () {
  15339. return generated$1.tsTypeOperator;
  15340. }
  15341. });
  15342. Object.defineProperty(exports, "TSIndexedAccessType", {
  15343. enumerable: true,
  15344. get: function () {
  15345. return generated$1.tsIndexedAccessType;
  15346. }
  15347. });
  15348. Object.defineProperty(exports, "TSMappedType", {
  15349. enumerable: true,
  15350. get: function () {
  15351. return generated$1.tsMappedType;
  15352. }
  15353. });
  15354. Object.defineProperty(exports, "TSLiteralType", {
  15355. enumerable: true,
  15356. get: function () {
  15357. return generated$1.tsLiteralType;
  15358. }
  15359. });
  15360. Object.defineProperty(exports, "TSExpressionWithTypeArguments", {
  15361. enumerable: true,
  15362. get: function () {
  15363. return generated$1.tsExpressionWithTypeArguments;
  15364. }
  15365. });
  15366. Object.defineProperty(exports, "TSInterfaceDeclaration", {
  15367. enumerable: true,
  15368. get: function () {
  15369. return generated$1.tsInterfaceDeclaration;
  15370. }
  15371. });
  15372. Object.defineProperty(exports, "TSInterfaceBody", {
  15373. enumerable: true,
  15374. get: function () {
  15375. return generated$1.tsInterfaceBody;
  15376. }
  15377. });
  15378. Object.defineProperty(exports, "TSTypeAliasDeclaration", {
  15379. enumerable: true,
  15380. get: function () {
  15381. return generated$1.tsTypeAliasDeclaration;
  15382. }
  15383. });
  15384. Object.defineProperty(exports, "TSAsExpression", {
  15385. enumerable: true,
  15386. get: function () {
  15387. return generated$1.tsAsExpression;
  15388. }
  15389. });
  15390. Object.defineProperty(exports, "TSTypeAssertion", {
  15391. enumerable: true,
  15392. get: function () {
  15393. return generated$1.tsTypeAssertion;
  15394. }
  15395. });
  15396. Object.defineProperty(exports, "TSEnumDeclaration", {
  15397. enumerable: true,
  15398. get: function () {
  15399. return generated$1.tsEnumDeclaration;
  15400. }
  15401. });
  15402. Object.defineProperty(exports, "TSEnumMember", {
  15403. enumerable: true,
  15404. get: function () {
  15405. return generated$1.tsEnumMember;
  15406. }
  15407. });
  15408. Object.defineProperty(exports, "TSModuleDeclaration", {
  15409. enumerable: true,
  15410. get: function () {
  15411. return generated$1.tsModuleDeclaration;
  15412. }
  15413. });
  15414. Object.defineProperty(exports, "TSModuleBlock", {
  15415. enumerable: true,
  15416. get: function () {
  15417. return generated$1.tsModuleBlock;
  15418. }
  15419. });
  15420. Object.defineProperty(exports, "TSImportType", {
  15421. enumerable: true,
  15422. get: function () {
  15423. return generated$1.tsImportType;
  15424. }
  15425. });
  15426. Object.defineProperty(exports, "TSImportEqualsDeclaration", {
  15427. enumerable: true,
  15428. get: function () {
  15429. return generated$1.tsImportEqualsDeclaration;
  15430. }
  15431. });
  15432. Object.defineProperty(exports, "TSExternalModuleReference", {
  15433. enumerable: true,
  15434. get: function () {
  15435. return generated$1.tsExternalModuleReference;
  15436. }
  15437. });
  15438. Object.defineProperty(exports, "TSNonNullExpression", {
  15439. enumerable: true,
  15440. get: function () {
  15441. return generated$1.tsNonNullExpression;
  15442. }
  15443. });
  15444. Object.defineProperty(exports, "TSExportAssignment", {
  15445. enumerable: true,
  15446. get: function () {
  15447. return generated$1.tsExportAssignment;
  15448. }
  15449. });
  15450. Object.defineProperty(exports, "TSNamespaceExportDeclaration", {
  15451. enumerable: true,
  15452. get: function () {
  15453. return generated$1.tsNamespaceExportDeclaration;
  15454. }
  15455. });
  15456. Object.defineProperty(exports, "TSTypeAnnotation", {
  15457. enumerable: true,
  15458. get: function () {
  15459. return generated$1.tsTypeAnnotation;
  15460. }
  15461. });
  15462. Object.defineProperty(exports, "TSTypeParameterInstantiation", {
  15463. enumerable: true,
  15464. get: function () {
  15465. return generated$1.tsTypeParameterInstantiation;
  15466. }
  15467. });
  15468. Object.defineProperty(exports, "TSTypeParameterDeclaration", {
  15469. enumerable: true,
  15470. get: function () {
  15471. return generated$1.tsTypeParameterDeclaration;
  15472. }
  15473. });
  15474. Object.defineProperty(exports, "TSTypeParameter", {
  15475. enumerable: true,
  15476. get: function () {
  15477. return generated$1.tsTypeParameter;
  15478. }
  15479. });
  15480. Object.defineProperty(exports, "NumberLiteral", {
  15481. enumerable: true,
  15482. get: function () {
  15483. return generated$1.numberLiteral;
  15484. }
  15485. });
  15486. Object.defineProperty(exports, "RegexLiteral", {
  15487. enumerable: true,
  15488. get: function () {
  15489. return generated$1.regexLiteral;
  15490. }
  15491. });
  15492. Object.defineProperty(exports, "RestProperty", {
  15493. enumerable: true,
  15494. get: function () {
  15495. return generated$1.restProperty;
  15496. }
  15497. });
  15498. Object.defineProperty(exports, "SpreadProperty", {
  15499. enumerable: true,
  15500. get: function () {
  15501. return generated$1.spreadProperty;
  15502. }
  15503. });
  15504. });
  15505. var _default$j = cloneNode;
  15506. const has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  15507. function cloneIfNode(obj, deep, withoutLoc) {
  15508. if (obj && typeof obj.type === "string") {
  15509. return cloneNode(obj, deep, withoutLoc);
  15510. }
  15511. return obj;
  15512. }
  15513. function cloneIfNodeOrArray(obj, deep, withoutLoc) {
  15514. if (Array.isArray(obj)) {
  15515. return obj.map(node => cloneIfNode(node, deep, withoutLoc));
  15516. }
  15517. return cloneIfNode(obj, deep, withoutLoc);
  15518. }
  15519. function cloneNode(node, deep = true, withoutLoc = false) {
  15520. if (!node) return node;
  15521. const {
  15522. type
  15523. } = node;
  15524. const newNode = {
  15525. type: node.type
  15526. };
  15527. if ((0, generated.isIdentifier)(node)) {
  15528. newNode.name = node.name;
  15529. if (has$1(node, "optional") && typeof node.optional === "boolean") {
  15530. newNode.optional = node.optional;
  15531. }
  15532. if (has$1(node, "typeAnnotation")) {
  15533. newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc) : node.typeAnnotation;
  15534. }
  15535. } else if (!has$1(definitions.NODE_FIELDS, type)) {
  15536. throw new Error(`Unknown node type: "${type}"`);
  15537. } else {
  15538. for (const field of Object.keys(definitions.NODE_FIELDS[type])) {
  15539. if (has$1(node, field)) {
  15540. if (deep) {
  15541. newNode[field] = (0, generated.isFile)(node) && field === "comments" ? maybeCloneComments(node.comments, deep, withoutLoc) : cloneIfNodeOrArray(node[field], true, withoutLoc);
  15542. } else {
  15543. newNode[field] = node[field];
  15544. }
  15545. }
  15546. }
  15547. }
  15548. if (has$1(node, "loc")) {
  15549. if (withoutLoc) {
  15550. newNode.loc = null;
  15551. } else {
  15552. newNode.loc = node.loc;
  15553. }
  15554. }
  15555. if (has$1(node, "leadingComments")) {
  15556. newNode.leadingComments = maybeCloneComments(node.leadingComments, deep, withoutLoc);
  15557. }
  15558. if (has$1(node, "innerComments")) {
  15559. newNode.innerComments = maybeCloneComments(node.innerComments, deep, withoutLoc);
  15560. }
  15561. if (has$1(node, "trailingComments")) {
  15562. newNode.trailingComments = maybeCloneComments(node.trailingComments, deep, withoutLoc);
  15563. }
  15564. if (has$1(node, "extra")) {
  15565. newNode.extra = Object.assign({}, node.extra);
  15566. }
  15567. return newNode;
  15568. }
  15569. function maybeCloneComments(comments, deep, withoutLoc) {
  15570. if (!comments || !deep) {
  15571. return comments;
  15572. }
  15573. return comments.map(({
  15574. type,
  15575. value,
  15576. loc
  15577. }) => {
  15578. if (withoutLoc) {
  15579. return {
  15580. type,
  15581. value,
  15582. loc: null
  15583. };
  15584. }
  15585. return {
  15586. type,
  15587. value,
  15588. loc
  15589. };
  15590. });
  15591. }
  15592. var cloneNode_1 = /*#__PURE__*/Object.defineProperty({
  15593. default: _default$j
  15594. }, '__esModule', {value: true});
  15595. var _default$k = clone;
  15596. function clone(node) {
  15597. return (0, cloneNode_1.default)(node, false);
  15598. }
  15599. var clone_1 = /*#__PURE__*/Object.defineProperty({
  15600. default: _default$k
  15601. }, '__esModule', {value: true});
  15602. var _default$l = cloneDeep;
  15603. function cloneDeep(node) {
  15604. return (0, cloneNode_1.default)(node);
  15605. }
  15606. var cloneDeep_1 = /*#__PURE__*/Object.defineProperty({
  15607. default: _default$l
  15608. }, '__esModule', {value: true});
  15609. var _default$m = cloneDeepWithoutLoc;
  15610. function cloneDeepWithoutLoc(node) {
  15611. return (0, cloneNode_1.default)(node, true, true);
  15612. }
  15613. var cloneDeepWithoutLoc_1 = /*#__PURE__*/Object.defineProperty({
  15614. default: _default$m
  15615. }, '__esModule', {value: true});
  15616. var _default$n = cloneWithoutLoc;
  15617. function cloneWithoutLoc(node) {
  15618. return (0, cloneNode_1.default)(node, false, true);
  15619. }
  15620. var cloneWithoutLoc_1 = /*#__PURE__*/Object.defineProperty({
  15621. default: _default$n
  15622. }, '__esModule', {value: true});
  15623. var _default$o = addComments;
  15624. function addComments(node, type, comments) {
  15625. if (!comments || !node) return node;
  15626. const key = `${type}Comments`;
  15627. if (node[key]) {
  15628. if (type === "leading") {
  15629. node[key] = comments.concat(node[key]);
  15630. } else {
  15631. node[key] = node[key].concat(comments);
  15632. }
  15633. } else {
  15634. node[key] = comments;
  15635. }
  15636. return node;
  15637. }
  15638. var addComments_1 = /*#__PURE__*/Object.defineProperty({
  15639. default: _default$o
  15640. }, '__esModule', {value: true});
  15641. var _default$p = addComment;
  15642. function addComment(node, type, content, line) {
  15643. return (0, addComments_1.default)(node, type, [{
  15644. type: line ? "CommentLine" : "CommentBlock",
  15645. value: content
  15646. }]);
  15647. }
  15648. var addComment_1 = /*#__PURE__*/Object.defineProperty({
  15649. default: _default$p
  15650. }, '__esModule', {value: true});
  15651. var _default$q = inherit;
  15652. function inherit(key, child, parent) {
  15653. if (child && parent) {
  15654. child[key] = Array.from(new Set([].concat(child[key], parent[key]).filter(Boolean)));
  15655. }
  15656. }
  15657. var inherit_1 = /*#__PURE__*/Object.defineProperty({
  15658. default: _default$q
  15659. }, '__esModule', {value: true});
  15660. var _default$r = inheritInnerComments;
  15661. function inheritInnerComments(child, parent) {
  15662. (0, inherit_1.default)("innerComments", child, parent);
  15663. }
  15664. var inheritInnerComments_1 = /*#__PURE__*/Object.defineProperty({
  15665. default: _default$r
  15666. }, '__esModule', {value: true});
  15667. var _default$s = inheritLeadingComments;
  15668. function inheritLeadingComments(child, parent) {
  15669. (0, inherit_1.default)("leadingComments", child, parent);
  15670. }
  15671. var inheritLeadingComments_1 = /*#__PURE__*/Object.defineProperty({
  15672. default: _default$s
  15673. }, '__esModule', {value: true});
  15674. var _default$t = inheritTrailingComments;
  15675. function inheritTrailingComments(child, parent) {
  15676. (0, inherit_1.default)("trailingComments", child, parent);
  15677. }
  15678. var inheritTrailingComments_1 = /*#__PURE__*/Object.defineProperty({
  15679. default: _default$t
  15680. }, '__esModule', {value: true});
  15681. var _default$u = inheritsComments;
  15682. function inheritsComments(child, parent) {
  15683. (0, inheritTrailingComments_1.default)(child, parent);
  15684. (0, inheritLeadingComments_1.default)(child, parent);
  15685. (0, inheritInnerComments_1.default)(child, parent);
  15686. return child;
  15687. }
  15688. var inheritsComments_1 = /*#__PURE__*/Object.defineProperty({
  15689. default: _default$u
  15690. }, '__esModule', {value: true});
  15691. var _default$v = removeComments;
  15692. function removeComments(node) {
  15693. constants.COMMENT_KEYS.forEach(key => {
  15694. node[key] = null;
  15695. });
  15696. return node;
  15697. }
  15698. var removeComments_1 = /*#__PURE__*/Object.defineProperty({
  15699. default: _default$v
  15700. }, '__esModule', {value: true});
  15701. var generated$3 = createCommonjsModule(function (module, exports) {
  15702. Object.defineProperty(exports, "__esModule", {
  15703. value: true
  15704. });
  15705. exports.TSBASETYPE_TYPES = exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.JSX_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.PRIVATE_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0;
  15706. const EXPRESSION_TYPES = definitions.FLIPPED_ALIAS_KEYS["Expression"];
  15707. exports.EXPRESSION_TYPES = EXPRESSION_TYPES;
  15708. const BINARY_TYPES = definitions.FLIPPED_ALIAS_KEYS["Binary"];
  15709. exports.BINARY_TYPES = BINARY_TYPES;
  15710. const SCOPABLE_TYPES = definitions.FLIPPED_ALIAS_KEYS["Scopable"];
  15711. exports.SCOPABLE_TYPES = SCOPABLE_TYPES;
  15712. const BLOCKPARENT_TYPES = definitions.FLIPPED_ALIAS_KEYS["BlockParent"];
  15713. exports.BLOCKPARENT_TYPES = BLOCKPARENT_TYPES;
  15714. const BLOCK_TYPES = definitions.FLIPPED_ALIAS_KEYS["Block"];
  15715. exports.BLOCK_TYPES = BLOCK_TYPES;
  15716. const STATEMENT_TYPES = definitions.FLIPPED_ALIAS_KEYS["Statement"];
  15717. exports.STATEMENT_TYPES = STATEMENT_TYPES;
  15718. const TERMINATORLESS_TYPES = definitions.FLIPPED_ALIAS_KEYS["Terminatorless"];
  15719. exports.TERMINATORLESS_TYPES = TERMINATORLESS_TYPES;
  15720. const COMPLETIONSTATEMENT_TYPES = definitions.FLIPPED_ALIAS_KEYS["CompletionStatement"];
  15721. exports.COMPLETIONSTATEMENT_TYPES = COMPLETIONSTATEMENT_TYPES;
  15722. const CONDITIONAL_TYPES = definitions.FLIPPED_ALIAS_KEYS["Conditional"];
  15723. exports.CONDITIONAL_TYPES = CONDITIONAL_TYPES;
  15724. const LOOP_TYPES = definitions.FLIPPED_ALIAS_KEYS["Loop"];
  15725. exports.LOOP_TYPES = LOOP_TYPES;
  15726. const WHILE_TYPES = definitions.FLIPPED_ALIAS_KEYS["While"];
  15727. exports.WHILE_TYPES = WHILE_TYPES;
  15728. const EXPRESSIONWRAPPER_TYPES = definitions.FLIPPED_ALIAS_KEYS["ExpressionWrapper"];
  15729. exports.EXPRESSIONWRAPPER_TYPES = EXPRESSIONWRAPPER_TYPES;
  15730. const FOR_TYPES = definitions.FLIPPED_ALIAS_KEYS["For"];
  15731. exports.FOR_TYPES = FOR_TYPES;
  15732. const FORXSTATEMENT_TYPES = definitions.FLIPPED_ALIAS_KEYS["ForXStatement"];
  15733. exports.FORXSTATEMENT_TYPES = FORXSTATEMENT_TYPES;
  15734. const FUNCTION_TYPES = definitions.FLIPPED_ALIAS_KEYS["Function"];
  15735. exports.FUNCTION_TYPES = FUNCTION_TYPES;
  15736. const FUNCTIONPARENT_TYPES = definitions.FLIPPED_ALIAS_KEYS["FunctionParent"];
  15737. exports.FUNCTIONPARENT_TYPES = FUNCTIONPARENT_TYPES;
  15738. const PUREISH_TYPES = definitions.FLIPPED_ALIAS_KEYS["Pureish"];
  15739. exports.PUREISH_TYPES = PUREISH_TYPES;
  15740. const DECLARATION_TYPES = definitions.FLIPPED_ALIAS_KEYS["Declaration"];
  15741. exports.DECLARATION_TYPES = DECLARATION_TYPES;
  15742. const PATTERNLIKE_TYPES = definitions.FLIPPED_ALIAS_KEYS["PatternLike"];
  15743. exports.PATTERNLIKE_TYPES = PATTERNLIKE_TYPES;
  15744. const LVAL_TYPES = definitions.FLIPPED_ALIAS_KEYS["LVal"];
  15745. exports.LVAL_TYPES = LVAL_TYPES;
  15746. const TSENTITYNAME_TYPES = definitions.FLIPPED_ALIAS_KEYS["TSEntityName"];
  15747. exports.TSENTITYNAME_TYPES = TSENTITYNAME_TYPES;
  15748. const LITERAL_TYPES = definitions.FLIPPED_ALIAS_KEYS["Literal"];
  15749. exports.LITERAL_TYPES = LITERAL_TYPES;
  15750. const IMMUTABLE_TYPES = definitions.FLIPPED_ALIAS_KEYS["Immutable"];
  15751. exports.IMMUTABLE_TYPES = IMMUTABLE_TYPES;
  15752. const USERWHITESPACABLE_TYPES = definitions.FLIPPED_ALIAS_KEYS["UserWhitespacable"];
  15753. exports.USERWHITESPACABLE_TYPES = USERWHITESPACABLE_TYPES;
  15754. const METHOD_TYPES = definitions.FLIPPED_ALIAS_KEYS["Method"];
  15755. exports.METHOD_TYPES = METHOD_TYPES;
  15756. const OBJECTMEMBER_TYPES = definitions.FLIPPED_ALIAS_KEYS["ObjectMember"];
  15757. exports.OBJECTMEMBER_TYPES = OBJECTMEMBER_TYPES;
  15758. const PROPERTY_TYPES = definitions.FLIPPED_ALIAS_KEYS["Property"];
  15759. exports.PROPERTY_TYPES = PROPERTY_TYPES;
  15760. const UNARYLIKE_TYPES = definitions.FLIPPED_ALIAS_KEYS["UnaryLike"];
  15761. exports.UNARYLIKE_TYPES = UNARYLIKE_TYPES;
  15762. const PATTERN_TYPES = definitions.FLIPPED_ALIAS_KEYS["Pattern"];
  15763. exports.PATTERN_TYPES = PATTERN_TYPES;
  15764. const CLASS_TYPES = definitions.FLIPPED_ALIAS_KEYS["Class"];
  15765. exports.CLASS_TYPES = CLASS_TYPES;
  15766. const MODULEDECLARATION_TYPES = definitions.FLIPPED_ALIAS_KEYS["ModuleDeclaration"];
  15767. exports.MODULEDECLARATION_TYPES = MODULEDECLARATION_TYPES;
  15768. const EXPORTDECLARATION_TYPES = definitions.FLIPPED_ALIAS_KEYS["ExportDeclaration"];
  15769. exports.EXPORTDECLARATION_TYPES = EXPORTDECLARATION_TYPES;
  15770. const MODULESPECIFIER_TYPES = definitions.FLIPPED_ALIAS_KEYS["ModuleSpecifier"];
  15771. exports.MODULESPECIFIER_TYPES = MODULESPECIFIER_TYPES;
  15772. const PRIVATE_TYPES = definitions.FLIPPED_ALIAS_KEYS["Private"];
  15773. exports.PRIVATE_TYPES = PRIVATE_TYPES;
  15774. const FLOW_TYPES = definitions.FLIPPED_ALIAS_KEYS["Flow"];
  15775. exports.FLOW_TYPES = FLOW_TYPES;
  15776. const FLOWTYPE_TYPES = definitions.FLIPPED_ALIAS_KEYS["FlowType"];
  15777. exports.FLOWTYPE_TYPES = FLOWTYPE_TYPES;
  15778. const FLOWBASEANNOTATION_TYPES = definitions.FLIPPED_ALIAS_KEYS["FlowBaseAnnotation"];
  15779. exports.FLOWBASEANNOTATION_TYPES = FLOWBASEANNOTATION_TYPES;
  15780. const FLOWDECLARATION_TYPES = definitions.FLIPPED_ALIAS_KEYS["FlowDeclaration"];
  15781. exports.FLOWDECLARATION_TYPES = FLOWDECLARATION_TYPES;
  15782. const FLOWPREDICATE_TYPES = definitions.FLIPPED_ALIAS_KEYS["FlowPredicate"];
  15783. exports.FLOWPREDICATE_TYPES = FLOWPREDICATE_TYPES;
  15784. const ENUMBODY_TYPES = definitions.FLIPPED_ALIAS_KEYS["EnumBody"];
  15785. exports.ENUMBODY_TYPES = ENUMBODY_TYPES;
  15786. const ENUMMEMBER_TYPES = definitions.FLIPPED_ALIAS_KEYS["EnumMember"];
  15787. exports.ENUMMEMBER_TYPES = ENUMMEMBER_TYPES;
  15788. const JSX_TYPES = definitions.FLIPPED_ALIAS_KEYS["JSX"];
  15789. exports.JSX_TYPES = JSX_TYPES;
  15790. const TSTYPEELEMENT_TYPES = definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"];
  15791. exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES;
  15792. const TSTYPE_TYPES = definitions.FLIPPED_ALIAS_KEYS["TSType"];
  15793. exports.TSTYPE_TYPES = TSTYPE_TYPES;
  15794. const TSBASETYPE_TYPES = definitions.FLIPPED_ALIAS_KEYS["TSBaseType"];
  15795. exports.TSBASETYPE_TYPES = TSBASETYPE_TYPES;
  15796. });
  15797. var _default$w = toBlock;
  15798. function toBlock(node, parent) {
  15799. if ((0, generated.isBlockStatement)(node)) {
  15800. return node;
  15801. }
  15802. let blockNodes = [];
  15803. if ((0, generated.isEmptyStatement)(node)) {
  15804. blockNodes = [];
  15805. } else {
  15806. if (!(0, generated.isStatement)(node)) {
  15807. if ((0, generated.isFunction)(parent)) {
  15808. node = (0, generated$1.returnStatement)(node);
  15809. } else {
  15810. node = (0, generated$1.expressionStatement)(node);
  15811. }
  15812. }
  15813. blockNodes = [node];
  15814. }
  15815. return (0, generated$1.blockStatement)(blockNodes);
  15816. }
  15817. var toBlock_1 = /*#__PURE__*/Object.defineProperty({
  15818. default: _default$w
  15819. }, '__esModule', {value: true});
  15820. var _default$x = ensureBlock;
  15821. function ensureBlock(node, key = "body") {
  15822. return node[key] = (0, toBlock_1.default)(node[key], node);
  15823. }
  15824. var ensureBlock_1 = /*#__PURE__*/Object.defineProperty({
  15825. default: _default$x
  15826. }, '__esModule', {value: true});
  15827. var _default$y = toIdentifier;
  15828. function toIdentifier(input) {
  15829. input = input + "";
  15830. let name = "";
  15831. for (const c of input) {
  15832. name += (0, lib.isIdentifierChar)(c.codePointAt(0)) ? c : "-";
  15833. }
  15834. name = name.replace(/^[-0-9]+/, "");
  15835. name = name.replace(/[-\s]+(.)?/g, function (match, c) {
  15836. return c ? c.toUpperCase() : "";
  15837. });
  15838. if (!(0, isValidIdentifier_1.default)(name)) {
  15839. name = `_${name}`;
  15840. }
  15841. return name || "_";
  15842. }
  15843. var toIdentifier_1 = /*#__PURE__*/Object.defineProperty({
  15844. default: _default$y
  15845. }, '__esModule', {value: true});
  15846. var _default$z = toBindingIdentifierName;
  15847. function toBindingIdentifierName(name) {
  15848. name = (0, toIdentifier_1.default)(name);
  15849. if (name === "eval" || name === "arguments") name = "_" + name;
  15850. return name;
  15851. }
  15852. var toBindingIdentifierName_1 = /*#__PURE__*/Object.defineProperty({
  15853. default: _default$z
  15854. }, '__esModule', {value: true});
  15855. var _default$A = toComputedKey;
  15856. function toComputedKey(node, key = node.key || node.property) {
  15857. if (!node.computed && (0, generated.isIdentifier)(key)) key = (0, generated$1.stringLiteral)(key.name);
  15858. return key;
  15859. }
  15860. var toComputedKey_1 = /*#__PURE__*/Object.defineProperty({
  15861. default: _default$A
  15862. }, '__esModule', {value: true});
  15863. var toExpression_1 = createCommonjsModule(function (module, exports) {
  15864. Object.defineProperty(exports, "__esModule", {
  15865. value: true
  15866. });
  15867. exports.default = void 0;
  15868. var _default = toExpression;
  15869. exports.default = _default;
  15870. function toExpression(node) {
  15871. if ((0, generated.isExpressionStatement)(node)) {
  15872. node = node.expression;
  15873. }
  15874. if ((0, generated.isExpression)(node)) {
  15875. return node;
  15876. }
  15877. if ((0, generated.isClass)(node)) {
  15878. node.type = "ClassExpression";
  15879. } else if ((0, generated.isFunction)(node)) {
  15880. node.type = "FunctionExpression";
  15881. }
  15882. if (!(0, generated.isExpression)(node)) {
  15883. throw new Error(`cannot turn ${node.type} to an expression`);
  15884. }
  15885. return node;
  15886. }
  15887. });
  15888. var _default$B = traverseFast;
  15889. function traverseFast(node, enter, opts) {
  15890. if (!node) return;
  15891. const keys = definitions.VISITOR_KEYS[node.type];
  15892. if (!keys) return;
  15893. opts = opts || {};
  15894. enter(node, opts);
  15895. for (const key of keys) {
  15896. const subNode = node[key];
  15897. if (Array.isArray(subNode)) {
  15898. for (const node of subNode) {
  15899. traverseFast(node, enter, opts);
  15900. }
  15901. } else {
  15902. traverseFast(subNode, enter, opts);
  15903. }
  15904. }
  15905. }
  15906. var traverseFast_1 = /*#__PURE__*/Object.defineProperty({
  15907. default: _default$B
  15908. }, '__esModule', {value: true});
  15909. var _default$C = removeProperties;
  15910. const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"];
  15911. const CLEAR_KEYS_PLUS_COMMENTS = constants.COMMENT_KEYS.concat(["comments"]).concat(CLEAR_KEYS);
  15912. function removeProperties(node, opts = {}) {
  15913. const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;
  15914. for (const key of map) {
  15915. if (node[key] != null) node[key] = undefined;
  15916. }
  15917. for (const key of Object.keys(node)) {
  15918. if (key[0] === "_" && node[key] != null) node[key] = undefined;
  15919. }
  15920. const symbols = Object.getOwnPropertySymbols(node);
  15921. for (const sym of symbols) {
  15922. node[sym] = null;
  15923. }
  15924. }
  15925. var removeProperties_1 = /*#__PURE__*/Object.defineProperty({
  15926. default: _default$C
  15927. }, '__esModule', {value: true});
  15928. var _default$D = removePropertiesDeep;
  15929. function removePropertiesDeep(tree, opts) {
  15930. (0, traverseFast_1.default)(tree, removeProperties_1.default, opts);
  15931. return tree;
  15932. }
  15933. var removePropertiesDeep_1 = /*#__PURE__*/Object.defineProperty({
  15934. default: _default$D
  15935. }, '__esModule', {value: true});
  15936. var _default$E = toKeyAlias;
  15937. function toKeyAlias(node, key = node.key) {
  15938. let alias;
  15939. if (node.kind === "method") {
  15940. return toKeyAlias.increment() + "";
  15941. } else if ((0, generated.isIdentifier)(key)) {
  15942. alias = key.name;
  15943. } else if ((0, generated.isStringLiteral)(key)) {
  15944. alias = JSON.stringify(key.value);
  15945. } else {
  15946. alias = JSON.stringify((0, removePropertiesDeep_1.default)((0, cloneNode_1.default)(key)));
  15947. }
  15948. if (node.computed) {
  15949. alias = `[${alias}]`;
  15950. }
  15951. if (node.static) {
  15952. alias = `static:${alias}`;
  15953. }
  15954. return alias;
  15955. }
  15956. toKeyAlias.uid = 0;
  15957. toKeyAlias.increment = function () {
  15958. if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) {
  15959. return toKeyAlias.uid = 0;
  15960. } else {
  15961. return toKeyAlias.uid++;
  15962. }
  15963. };
  15964. var toKeyAlias_1 = /*#__PURE__*/Object.defineProperty({
  15965. default: _default$E
  15966. }, '__esModule', {value: true});
  15967. var _default$F = getBindingIdentifiers;
  15968. function getBindingIdentifiers(node, duplicates, outerOnly) {
  15969. let search = [].concat(node);
  15970. const ids = Object.create(null);
  15971. while (search.length) {
  15972. const id = search.shift();
  15973. if (!id) continue;
  15974. const keys = getBindingIdentifiers.keys[id.type];
  15975. if ((0, generated.isIdentifier)(id)) {
  15976. if (duplicates) {
  15977. const _ids = ids[id.name] = ids[id.name] || [];
  15978. _ids.push(id);
  15979. } else {
  15980. ids[id.name] = id;
  15981. }
  15982. continue;
  15983. }
  15984. if ((0, generated.isExportDeclaration)(id) && !(0, generated.isExportAllDeclaration)(id)) {
  15985. if ((0, generated.isDeclaration)(id.declaration)) {
  15986. search.push(id.declaration);
  15987. }
  15988. continue;
  15989. }
  15990. if (outerOnly) {
  15991. if ((0, generated.isFunctionDeclaration)(id)) {
  15992. search.push(id.id);
  15993. continue;
  15994. }
  15995. if ((0, generated.isFunctionExpression)(id)) {
  15996. continue;
  15997. }
  15998. }
  15999. if (keys) {
  16000. for (let i = 0; i < keys.length; i++) {
  16001. const key = keys[i];
  16002. if (id[key]) {
  16003. search = search.concat(id[key]);
  16004. }
  16005. }
  16006. }
  16007. }
  16008. return ids;
  16009. }
  16010. getBindingIdentifiers.keys = {
  16011. DeclareClass: ["id"],
  16012. DeclareFunction: ["id"],
  16013. DeclareModule: ["id"],
  16014. DeclareVariable: ["id"],
  16015. DeclareInterface: ["id"],
  16016. DeclareTypeAlias: ["id"],
  16017. DeclareOpaqueType: ["id"],
  16018. InterfaceDeclaration: ["id"],
  16019. TypeAlias: ["id"],
  16020. OpaqueType: ["id"],
  16021. CatchClause: ["param"],
  16022. LabeledStatement: ["label"],
  16023. UnaryExpression: ["argument"],
  16024. AssignmentExpression: ["left"],
  16025. ImportSpecifier: ["local"],
  16026. ImportNamespaceSpecifier: ["local"],
  16027. ImportDefaultSpecifier: ["local"],
  16028. ImportDeclaration: ["specifiers"],
  16029. ExportSpecifier: ["exported"],
  16030. ExportNamespaceSpecifier: ["exported"],
  16031. ExportDefaultSpecifier: ["exported"],
  16032. FunctionDeclaration: ["id", "params"],
  16033. FunctionExpression: ["id", "params"],
  16034. ArrowFunctionExpression: ["params"],
  16035. ObjectMethod: ["params"],
  16036. ClassMethod: ["params"],
  16037. ForInStatement: ["left"],
  16038. ForOfStatement: ["left"],
  16039. ClassDeclaration: ["id"],
  16040. ClassExpression: ["id"],
  16041. RestElement: ["argument"],
  16042. UpdateExpression: ["argument"],
  16043. ObjectProperty: ["value"],
  16044. AssignmentPattern: ["left"],
  16045. ArrayPattern: ["elements"],
  16046. ObjectPattern: ["properties"],
  16047. VariableDeclaration: ["declarations"],
  16048. VariableDeclarator: ["id"]
  16049. };
  16050. var getBindingIdentifiers_1 = /*#__PURE__*/Object.defineProperty({
  16051. default: _default$F
  16052. }, '__esModule', {value: true});
  16053. var _default$G = gatherSequenceExpressions;
  16054. function gatherSequenceExpressions(nodes, scope, declars) {
  16055. const exprs = [];
  16056. let ensureLastUndefined = true;
  16057. for (const node of nodes) {
  16058. if (!(0, generated.isEmptyStatement)(node)) {
  16059. ensureLastUndefined = false;
  16060. }
  16061. if ((0, generated.isExpression)(node)) {
  16062. exprs.push(node);
  16063. } else if ((0, generated.isExpressionStatement)(node)) {
  16064. exprs.push(node.expression);
  16065. } else if ((0, generated.isVariableDeclaration)(node)) {
  16066. if (node.kind !== "var") return;
  16067. for (const declar of node.declarations) {
  16068. const bindings = (0, getBindingIdentifiers_1.default)(declar);
  16069. for (const key of Object.keys(bindings)) {
  16070. declars.push({
  16071. kind: node.kind,
  16072. id: (0, cloneNode_1.default)(bindings[key])
  16073. });
  16074. }
  16075. if (declar.init) {
  16076. exprs.push((0, generated$1.assignmentExpression)("=", declar.id, declar.init));
  16077. }
  16078. }
  16079. ensureLastUndefined = true;
  16080. } else if ((0, generated.isIfStatement)(node)) {
  16081. const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], scope, declars) : scope.buildUndefinedNode();
  16082. const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], scope, declars) : scope.buildUndefinedNode();
  16083. if (!consequent || !alternate) return;
  16084. exprs.push((0, generated$1.conditionalExpression)(node.test, consequent, alternate));
  16085. } else if ((0, generated.isBlockStatement)(node)) {
  16086. const body = gatherSequenceExpressions(node.body, scope, declars);
  16087. if (!body) return;
  16088. exprs.push(body);
  16089. } else if ((0, generated.isEmptyStatement)(node)) {
  16090. if (nodes.indexOf(node) === 0) {
  16091. ensureLastUndefined = true;
  16092. }
  16093. } else {
  16094. return;
  16095. }
  16096. }
  16097. if (ensureLastUndefined) {
  16098. exprs.push(scope.buildUndefinedNode());
  16099. }
  16100. if (exprs.length === 1) {
  16101. return exprs[0];
  16102. } else {
  16103. return (0, generated$1.sequenceExpression)(exprs);
  16104. }
  16105. }
  16106. var gatherSequenceExpressions_1 = /*#__PURE__*/Object.defineProperty({
  16107. default: _default$G
  16108. }, '__esModule', {value: true});
  16109. var _default$H = toSequenceExpression;
  16110. function toSequenceExpression(nodes, scope) {
  16111. if (!(nodes != null && nodes.length)) return;
  16112. const declars = [];
  16113. const result = (0, gatherSequenceExpressions_1.default)(nodes, scope, declars);
  16114. if (!result) return;
  16115. for (const declar of declars) {
  16116. scope.push(declar);
  16117. }
  16118. return result;
  16119. }
  16120. var toSequenceExpression_1 = /*#__PURE__*/Object.defineProperty({
  16121. default: _default$H
  16122. }, '__esModule', {value: true});
  16123. var toStatement_1 = createCommonjsModule(function (module, exports) {
  16124. Object.defineProperty(exports, "__esModule", {
  16125. value: true
  16126. });
  16127. exports.default = void 0;
  16128. var _default = toStatement;
  16129. exports.default = _default;
  16130. function toStatement(node, ignore) {
  16131. if ((0, generated.isStatement)(node)) {
  16132. return node;
  16133. }
  16134. let mustHaveId = false;
  16135. let newType;
  16136. if ((0, generated.isClass)(node)) {
  16137. mustHaveId = true;
  16138. newType = "ClassDeclaration";
  16139. } else if ((0, generated.isFunction)(node)) {
  16140. mustHaveId = true;
  16141. newType = "FunctionDeclaration";
  16142. } else if ((0, generated.isAssignmentExpression)(node)) {
  16143. return (0, generated$1.expressionStatement)(node);
  16144. }
  16145. if (mustHaveId && !node.id) {
  16146. newType = false;
  16147. }
  16148. if (!newType) {
  16149. if (ignore) {
  16150. return false;
  16151. } else {
  16152. throw new Error(`cannot turn ${node.type} to a statement`);
  16153. }
  16154. }
  16155. node.type = newType;
  16156. return node;
  16157. }
  16158. });
  16159. var valueToNode_1 = createCommonjsModule(function (module, exports) {
  16160. Object.defineProperty(exports, "__esModule", {
  16161. value: true
  16162. });
  16163. exports.default = void 0;
  16164. var _default = valueToNode;
  16165. exports.default = _default;
  16166. const objectToString = Function.call.bind(Object.prototype.toString);
  16167. function isRegExp(value) {
  16168. return objectToString(value) === "[object RegExp]";
  16169. }
  16170. function isPlainObject(value) {
  16171. if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Object]") {
  16172. return false;
  16173. }
  16174. const proto = Object.getPrototypeOf(value);
  16175. return proto === null || Object.getPrototypeOf(proto) === null;
  16176. }
  16177. function valueToNode(value) {
  16178. if (value === undefined) {
  16179. return (0, generated$1.identifier)("undefined");
  16180. }
  16181. if (value === true || value === false) {
  16182. return (0, generated$1.booleanLiteral)(value);
  16183. }
  16184. if (value === null) {
  16185. return (0, generated$1.nullLiteral)();
  16186. }
  16187. if (typeof value === "string") {
  16188. return (0, generated$1.stringLiteral)(value);
  16189. }
  16190. if (typeof value === "number") {
  16191. let result;
  16192. if (Number.isFinite(value)) {
  16193. result = (0, generated$1.numericLiteral)(Math.abs(value));
  16194. } else {
  16195. let numerator;
  16196. if (Number.isNaN(value)) {
  16197. numerator = (0, generated$1.numericLiteral)(0);
  16198. } else {
  16199. numerator = (0, generated$1.numericLiteral)(1);
  16200. }
  16201. result = (0, generated$1.binaryExpression)("/", numerator, (0, generated$1.numericLiteral)(0));
  16202. }
  16203. if (value < 0 || Object.is(value, -0)) {
  16204. result = (0, generated$1.unaryExpression)("-", result);
  16205. }
  16206. return result;
  16207. }
  16208. if (isRegExp(value)) {
  16209. const pattern = value.source;
  16210. const flags = value.toString().match(/\/([a-z]+|)$/)[1];
  16211. return (0, generated$1.regExpLiteral)(pattern, flags);
  16212. }
  16213. if (Array.isArray(value)) {
  16214. return (0, generated$1.arrayExpression)(value.map(valueToNode));
  16215. }
  16216. if (isPlainObject(value)) {
  16217. const props = [];
  16218. for (const key of Object.keys(value)) {
  16219. let nodeKey;
  16220. if ((0, isValidIdentifier_1.default)(key)) {
  16221. nodeKey = (0, generated$1.identifier)(key);
  16222. } else {
  16223. nodeKey = (0, generated$1.stringLiteral)(key);
  16224. }
  16225. props.push((0, generated$1.objectProperty)(nodeKey, valueToNode(value[key])));
  16226. }
  16227. return (0, generated$1.objectExpression)(props);
  16228. }
  16229. throw new Error("don't know how to turn this value into a node");
  16230. }
  16231. });
  16232. var _default$I = appendToMemberExpression;
  16233. function appendToMemberExpression(member, append, computed = false) {
  16234. member.object = (0, generated$1.memberExpression)(member.object, member.property, member.computed);
  16235. member.property = append;
  16236. member.computed = !!computed;
  16237. return member;
  16238. }
  16239. var appendToMemberExpression_1 = /*#__PURE__*/Object.defineProperty({
  16240. default: _default$I
  16241. }, '__esModule', {value: true});
  16242. var _default$J = inherits;
  16243. function inherits(child, parent) {
  16244. if (!child || !parent) return child;
  16245. for (const key of constants.INHERIT_KEYS.optional) {
  16246. if (child[key] == null) {
  16247. child[key] = parent[key];
  16248. }
  16249. }
  16250. for (const key of Object.keys(parent)) {
  16251. if (key[0] === "_" && key !== "__clone") child[key] = parent[key];
  16252. }
  16253. for (const key of constants.INHERIT_KEYS.force) {
  16254. child[key] = parent[key];
  16255. }
  16256. (0, inheritsComments_1.default)(child, parent);
  16257. return child;
  16258. }
  16259. var inherits_1 = /*#__PURE__*/Object.defineProperty({
  16260. default: _default$J
  16261. }, '__esModule', {value: true});
  16262. var _default$K = prependToMemberExpression;
  16263. function prependToMemberExpression(member, prepend) {
  16264. member.object = (0, generated$1.memberExpression)(prepend, member.object);
  16265. return member;
  16266. }
  16267. var prependToMemberExpression_1 = /*#__PURE__*/Object.defineProperty({
  16268. default: _default$K
  16269. }, '__esModule', {value: true});
  16270. var getOuterBindingIdentifiers_1 = createCommonjsModule(function (module, exports) {
  16271. Object.defineProperty(exports, "__esModule", {
  16272. value: true
  16273. });
  16274. exports.default = void 0;
  16275. var _default = getOuterBindingIdentifiers;
  16276. exports.default = _default;
  16277. function getOuterBindingIdentifiers(node, duplicates) {
  16278. return (0, getBindingIdentifiers_1.default)(node, duplicates, true);
  16279. }
  16280. });
  16281. var _default$L = traverse;
  16282. function traverse(node, handlers, state) {
  16283. if (typeof handlers === "function") {
  16284. handlers = {
  16285. enter: handlers
  16286. };
  16287. }
  16288. const {
  16289. enter,
  16290. exit
  16291. } = handlers;
  16292. traverseSimpleImpl(node, enter, exit, state, []);
  16293. }
  16294. function traverseSimpleImpl(node, enter, exit, state, ancestors) {
  16295. const keys = definitions.VISITOR_KEYS[node.type];
  16296. if (!keys) return;
  16297. if (enter) enter(node, ancestors, state);
  16298. for (const key of keys) {
  16299. const subNode = node[key];
  16300. if (Array.isArray(subNode)) {
  16301. for (let i = 0; i < subNode.length; i++) {
  16302. const child = subNode[i];
  16303. if (!child) continue;
  16304. ancestors.push({
  16305. node,
  16306. key,
  16307. index: i
  16308. });
  16309. traverseSimpleImpl(child, enter, exit, state, ancestors);
  16310. ancestors.pop();
  16311. }
  16312. } else if (subNode) {
  16313. ancestors.push({
  16314. node,
  16315. key
  16316. });
  16317. traverseSimpleImpl(subNode, enter, exit, state, ancestors);
  16318. ancestors.pop();
  16319. }
  16320. }
  16321. if (exit) exit(node, ancestors, state);
  16322. }
  16323. var traverse_1 = /*#__PURE__*/Object.defineProperty({
  16324. default: _default$L
  16325. }, '__esModule', {value: true});
  16326. var _default$M = isBinding;
  16327. function isBinding(node, parent, grandparent) {
  16328. if (grandparent && node.type === "Identifier" && parent.type === "ObjectProperty" && grandparent.type === "ObjectExpression") {
  16329. return false;
  16330. }
  16331. const keys = getBindingIdentifiers_1.default.keys[parent.type];
  16332. if (keys) {
  16333. for (let i = 0; i < keys.length; i++) {
  16334. const key = keys[i];
  16335. const val = parent[key];
  16336. if (Array.isArray(val)) {
  16337. if (val.indexOf(node) >= 0) return true;
  16338. } else {
  16339. if (val === node) return true;
  16340. }
  16341. }
  16342. }
  16343. return false;
  16344. }
  16345. var isBinding_1 = /*#__PURE__*/Object.defineProperty({
  16346. default: _default$M
  16347. }, '__esModule', {value: true});
  16348. var _default$N = isLet;
  16349. function isLet(node) {
  16350. return (0, generated.isVariableDeclaration)(node) && (node.kind !== "var" || node[constants.BLOCK_SCOPED_SYMBOL]);
  16351. }
  16352. var isLet_1 = /*#__PURE__*/Object.defineProperty({
  16353. default: _default$N
  16354. }, '__esModule', {value: true});
  16355. var _default$O = isBlockScoped;
  16356. function isBlockScoped(node) {
  16357. return (0, generated.isFunctionDeclaration)(node) || (0, generated.isClassDeclaration)(node) || (0, isLet_1.default)(node);
  16358. }
  16359. var isBlockScoped_1 = /*#__PURE__*/Object.defineProperty({
  16360. default: _default$O
  16361. }, '__esModule', {value: true});
  16362. var _default$P = isImmutable$1;
  16363. function isImmutable$1(node) {
  16364. if ((0, isType_1.default)(node.type, "Immutable")) return true;
  16365. if ((0, generated.isIdentifier)(node)) {
  16366. if (node.name === "undefined") {
  16367. return true;
  16368. } else {
  16369. return false;
  16370. }
  16371. }
  16372. return false;
  16373. }
  16374. var isImmutable_1$1 = /*#__PURE__*/Object.defineProperty({
  16375. default: _default$P
  16376. }, '__esModule', {value: true});
  16377. var _default$Q = isNodesEquivalent;
  16378. function isNodesEquivalent(a, b) {
  16379. if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
  16380. return a === b;
  16381. }
  16382. if (a.type !== b.type) {
  16383. return false;
  16384. }
  16385. const fields = Object.keys(definitions.NODE_FIELDS[a.type] || a.type);
  16386. const visitorKeys = definitions.VISITOR_KEYS[a.type];
  16387. for (const field of fields) {
  16388. if (typeof a[field] !== typeof b[field]) {
  16389. return false;
  16390. }
  16391. if (a[field] == null && b[field] == null) {
  16392. continue;
  16393. } else if (a[field] == null || b[field] == null) {
  16394. return false;
  16395. }
  16396. if (Array.isArray(a[field])) {
  16397. if (!Array.isArray(b[field])) {
  16398. return false;
  16399. }
  16400. if (a[field].length !== b[field].length) {
  16401. return false;
  16402. }
  16403. for (let i = 0; i < a[field].length; i++) {
  16404. if (!isNodesEquivalent(a[field][i], b[field][i])) {
  16405. return false;
  16406. }
  16407. }
  16408. continue;
  16409. }
  16410. if (typeof a[field] === "object" && !(visitorKeys != null && visitorKeys.includes(field))) {
  16411. for (const key of Object.keys(a[field])) {
  16412. if (a[field][key] !== b[field][key]) {
  16413. return false;
  16414. }
  16415. }
  16416. continue;
  16417. }
  16418. if (!isNodesEquivalent(a[field], b[field])) {
  16419. return false;
  16420. }
  16421. }
  16422. return true;
  16423. }
  16424. var isNodesEquivalent_1 = /*#__PURE__*/Object.defineProperty({
  16425. default: _default$Q
  16426. }, '__esModule', {value: true});
  16427. var _default$R = isReferenced;
  16428. function isReferenced(node, parent, grandparent) {
  16429. switch (parent.type) {
  16430. case "MemberExpression":
  16431. case "JSXMemberExpression":
  16432. case "OptionalMemberExpression":
  16433. if (parent.property === node) {
  16434. return !!parent.computed;
  16435. }
  16436. return parent.object === node;
  16437. case "VariableDeclarator":
  16438. return parent.init === node;
  16439. case "ArrowFunctionExpression":
  16440. return parent.body === node;
  16441. case "PrivateName":
  16442. return false;
  16443. case "ClassMethod":
  16444. case "ClassPrivateMethod":
  16445. case "ObjectMethod":
  16446. if (parent.params.includes(node)) {
  16447. return false;
  16448. }
  16449. case "ObjectProperty":
  16450. case "ClassProperty":
  16451. case "ClassPrivateProperty":
  16452. if (parent.key === node) {
  16453. return !!parent.computed;
  16454. }
  16455. if (parent.value === node) {
  16456. return !grandparent || grandparent.type !== "ObjectPattern";
  16457. }
  16458. return true;
  16459. case "ClassDeclaration":
  16460. case "ClassExpression":
  16461. return parent.superClass === node;
  16462. case "AssignmentExpression":
  16463. return parent.right === node;
  16464. case "AssignmentPattern":
  16465. return parent.right === node;
  16466. case "LabeledStatement":
  16467. return false;
  16468. case "CatchClause":
  16469. return false;
  16470. case "RestElement":
  16471. return false;
  16472. case "BreakStatement":
  16473. case "ContinueStatement":
  16474. return false;
  16475. case "FunctionDeclaration":
  16476. case "FunctionExpression":
  16477. return false;
  16478. case "ExportNamespaceSpecifier":
  16479. case "ExportDefaultSpecifier":
  16480. return false;
  16481. case "ExportSpecifier":
  16482. if (grandparent != null && grandparent.source) {
  16483. return false;
  16484. }
  16485. return parent.local === node;
  16486. case "ImportDefaultSpecifier":
  16487. case "ImportNamespaceSpecifier":
  16488. case "ImportSpecifier":
  16489. return false;
  16490. case "JSXAttribute":
  16491. return false;
  16492. case "ObjectPattern":
  16493. case "ArrayPattern":
  16494. return false;
  16495. case "MetaProperty":
  16496. return false;
  16497. case "ObjectTypeProperty":
  16498. return parent.key !== node;
  16499. case "TSEnumMember":
  16500. return parent.id !== node;
  16501. case "TSPropertySignature":
  16502. if (parent.key === node) {
  16503. return !!parent.computed;
  16504. }
  16505. return true;
  16506. }
  16507. return true;
  16508. }
  16509. var isReferenced_1 = /*#__PURE__*/Object.defineProperty({
  16510. default: _default$R
  16511. }, '__esModule', {value: true});
  16512. var _default$S = isScope;
  16513. function isScope(node, parent) {
  16514. if ((0, generated.isBlockStatement)(node) && ((0, generated.isFunction)(parent) || (0, generated.isCatchClause)(parent))) {
  16515. return false;
  16516. }
  16517. if ((0, generated.isPattern)(node) && ((0, generated.isFunction)(parent) || (0, generated.isCatchClause)(parent))) {
  16518. return true;
  16519. }
  16520. return (0, generated.isScopable)(node);
  16521. }
  16522. var isScope_1 = /*#__PURE__*/Object.defineProperty({
  16523. default: _default$S
  16524. }, '__esModule', {value: true});
  16525. var _default$T = isSpecifierDefault;
  16526. function isSpecifierDefault(specifier) {
  16527. return (0, generated.isImportDefaultSpecifier)(specifier) || (0, generated.isIdentifier)(specifier.imported || specifier.exported, {
  16528. name: "default"
  16529. });
  16530. }
  16531. var isSpecifierDefault_1 = /*#__PURE__*/Object.defineProperty({
  16532. default: _default$T
  16533. }, '__esModule', {value: true});
  16534. var _default$U = isValidES3Identifier;
  16535. const RESERVED_WORDS_ES3_ONLY = new Set(["abstract", "boolean", "byte", "char", "double", "enum", "final", "float", "goto", "implements", "int", "interface", "long", "native", "package", "private", "protected", "public", "short", "static", "synchronized", "throws", "transient", "volatile"]);
  16536. function isValidES3Identifier(name) {
  16537. return (0, isValidIdentifier_1.default)(name) && !RESERVED_WORDS_ES3_ONLY.has(name);
  16538. }
  16539. var isValidES3Identifier_1 = /*#__PURE__*/Object.defineProperty({
  16540. default: _default$U
  16541. }, '__esModule', {value: true});
  16542. var _default$V = isVar;
  16543. function isVar(node) {
  16544. return (0, generated.isVariableDeclaration)(node, {
  16545. kind: "var"
  16546. }) && !node[constants.BLOCK_SCOPED_SYMBOL];
  16547. }
  16548. var isVar_1 = /*#__PURE__*/Object.defineProperty({
  16549. default: _default$V
  16550. }, '__esModule', {value: true});
  16551. var generated$4 = /*#__PURE__*/Object.freeze({
  16552. __proto__: null
  16553. });
  16554. var _generated5 = /*@__PURE__*/getAugmentedNamespace(generated$4);
  16555. var lib$1 = createCommonjsModule(function (module, exports) {
  16556. Object.defineProperty(exports, "__esModule", {
  16557. value: true
  16558. });
  16559. var _exportNames = {
  16560. react: true,
  16561. assertNode: true,
  16562. createTypeAnnotationBasedOnTypeof: true,
  16563. createUnionTypeAnnotation: true,
  16564. createFlowUnionType: true,
  16565. createTSUnionType: true,
  16566. cloneNode: true,
  16567. clone: true,
  16568. cloneDeep: true,
  16569. cloneDeepWithoutLoc: true,
  16570. cloneWithoutLoc: true,
  16571. addComment: true,
  16572. addComments: true,
  16573. inheritInnerComments: true,
  16574. inheritLeadingComments: true,
  16575. inheritsComments: true,
  16576. inheritTrailingComments: true,
  16577. removeComments: true,
  16578. ensureBlock: true,
  16579. toBindingIdentifierName: true,
  16580. toBlock: true,
  16581. toComputedKey: true,
  16582. toExpression: true,
  16583. toIdentifier: true,
  16584. toKeyAlias: true,
  16585. toSequenceExpression: true,
  16586. toStatement: true,
  16587. valueToNode: true,
  16588. appendToMemberExpression: true,
  16589. inherits: true,
  16590. prependToMemberExpression: true,
  16591. removeProperties: true,
  16592. removePropertiesDeep: true,
  16593. removeTypeDuplicates: true,
  16594. getBindingIdentifiers: true,
  16595. getOuterBindingIdentifiers: true,
  16596. traverse: true,
  16597. traverseFast: true,
  16598. shallowEqual: true,
  16599. is: true,
  16600. isBinding: true,
  16601. isBlockScoped: true,
  16602. isImmutable: true,
  16603. isLet: true,
  16604. isNode: true,
  16605. isNodesEquivalent: true,
  16606. isPlaceholderType: true,
  16607. isReferenced: true,
  16608. isScope: true,
  16609. isSpecifierDefault: true,
  16610. isType: true,
  16611. isValidES3Identifier: true,
  16612. isValidIdentifier: true,
  16613. isVar: true,
  16614. matchesPattern: true,
  16615. validate: true,
  16616. buildMatchMemberExpression: true
  16617. };
  16618. Object.defineProperty(exports, "assertNode", {
  16619. enumerable: true,
  16620. get: function () {
  16621. return assertNode_1.default;
  16622. }
  16623. });
  16624. Object.defineProperty(exports, "createTypeAnnotationBasedOnTypeof", {
  16625. enumerable: true,
  16626. get: function () {
  16627. return createTypeAnnotationBasedOnTypeof_1.default;
  16628. }
  16629. });
  16630. Object.defineProperty(exports, "createUnionTypeAnnotation", {
  16631. enumerable: true,
  16632. get: function () {
  16633. return createFlowUnionType_1.default;
  16634. }
  16635. });
  16636. Object.defineProperty(exports, "createFlowUnionType", {
  16637. enumerable: true,
  16638. get: function () {
  16639. return createFlowUnionType_1.default;
  16640. }
  16641. });
  16642. Object.defineProperty(exports, "createTSUnionType", {
  16643. enumerable: true,
  16644. get: function () {
  16645. return createTSUnionType_1.default;
  16646. }
  16647. });
  16648. Object.defineProperty(exports, "cloneNode", {
  16649. enumerable: true,
  16650. get: function () {
  16651. return cloneNode_1.default;
  16652. }
  16653. });
  16654. Object.defineProperty(exports, "clone", {
  16655. enumerable: true,
  16656. get: function () {
  16657. return clone_1.default;
  16658. }
  16659. });
  16660. Object.defineProperty(exports, "cloneDeep", {
  16661. enumerable: true,
  16662. get: function () {
  16663. return cloneDeep_1.default;
  16664. }
  16665. });
  16666. Object.defineProperty(exports, "cloneDeepWithoutLoc", {
  16667. enumerable: true,
  16668. get: function () {
  16669. return cloneDeepWithoutLoc_1.default;
  16670. }
  16671. });
  16672. Object.defineProperty(exports, "cloneWithoutLoc", {
  16673. enumerable: true,
  16674. get: function () {
  16675. return cloneWithoutLoc_1.default;
  16676. }
  16677. });
  16678. Object.defineProperty(exports, "addComment", {
  16679. enumerable: true,
  16680. get: function () {
  16681. return addComment_1.default;
  16682. }
  16683. });
  16684. Object.defineProperty(exports, "addComments", {
  16685. enumerable: true,
  16686. get: function () {
  16687. return addComments_1.default;
  16688. }
  16689. });
  16690. Object.defineProperty(exports, "inheritInnerComments", {
  16691. enumerable: true,
  16692. get: function () {
  16693. return inheritInnerComments_1.default;
  16694. }
  16695. });
  16696. Object.defineProperty(exports, "inheritLeadingComments", {
  16697. enumerable: true,
  16698. get: function () {
  16699. return inheritLeadingComments_1.default;
  16700. }
  16701. });
  16702. Object.defineProperty(exports, "inheritsComments", {
  16703. enumerable: true,
  16704. get: function () {
  16705. return inheritsComments_1.default;
  16706. }
  16707. });
  16708. Object.defineProperty(exports, "inheritTrailingComments", {
  16709. enumerable: true,
  16710. get: function () {
  16711. return inheritTrailingComments_1.default;
  16712. }
  16713. });
  16714. Object.defineProperty(exports, "removeComments", {
  16715. enumerable: true,
  16716. get: function () {
  16717. return removeComments_1.default;
  16718. }
  16719. });
  16720. Object.defineProperty(exports, "ensureBlock", {
  16721. enumerable: true,
  16722. get: function () {
  16723. return ensureBlock_1.default;
  16724. }
  16725. });
  16726. Object.defineProperty(exports, "toBindingIdentifierName", {
  16727. enumerable: true,
  16728. get: function () {
  16729. return toBindingIdentifierName_1.default;
  16730. }
  16731. });
  16732. Object.defineProperty(exports, "toBlock", {
  16733. enumerable: true,
  16734. get: function () {
  16735. return toBlock_1.default;
  16736. }
  16737. });
  16738. Object.defineProperty(exports, "toComputedKey", {
  16739. enumerable: true,
  16740. get: function () {
  16741. return toComputedKey_1.default;
  16742. }
  16743. });
  16744. Object.defineProperty(exports, "toExpression", {
  16745. enumerable: true,
  16746. get: function () {
  16747. return toExpression_1.default;
  16748. }
  16749. });
  16750. Object.defineProperty(exports, "toIdentifier", {
  16751. enumerable: true,
  16752. get: function () {
  16753. return toIdentifier_1.default;
  16754. }
  16755. });
  16756. Object.defineProperty(exports, "toKeyAlias", {
  16757. enumerable: true,
  16758. get: function () {
  16759. return toKeyAlias_1.default;
  16760. }
  16761. });
  16762. Object.defineProperty(exports, "toSequenceExpression", {
  16763. enumerable: true,
  16764. get: function () {
  16765. return toSequenceExpression_1.default;
  16766. }
  16767. });
  16768. Object.defineProperty(exports, "toStatement", {
  16769. enumerable: true,
  16770. get: function () {
  16771. return toStatement_1.default;
  16772. }
  16773. });
  16774. Object.defineProperty(exports, "valueToNode", {
  16775. enumerable: true,
  16776. get: function () {
  16777. return valueToNode_1.default;
  16778. }
  16779. });
  16780. Object.defineProperty(exports, "appendToMemberExpression", {
  16781. enumerable: true,
  16782. get: function () {
  16783. return appendToMemberExpression_1.default;
  16784. }
  16785. });
  16786. Object.defineProperty(exports, "inherits", {
  16787. enumerable: true,
  16788. get: function () {
  16789. return inherits_1.default;
  16790. }
  16791. });
  16792. Object.defineProperty(exports, "prependToMemberExpression", {
  16793. enumerable: true,
  16794. get: function () {
  16795. return prependToMemberExpression_1.default;
  16796. }
  16797. });
  16798. Object.defineProperty(exports, "removeProperties", {
  16799. enumerable: true,
  16800. get: function () {
  16801. return removeProperties_1.default;
  16802. }
  16803. });
  16804. Object.defineProperty(exports, "removePropertiesDeep", {
  16805. enumerable: true,
  16806. get: function () {
  16807. return removePropertiesDeep_1.default;
  16808. }
  16809. });
  16810. Object.defineProperty(exports, "removeTypeDuplicates", {
  16811. enumerable: true,
  16812. get: function () {
  16813. return removeTypeDuplicates_1.default;
  16814. }
  16815. });
  16816. Object.defineProperty(exports, "getBindingIdentifiers", {
  16817. enumerable: true,
  16818. get: function () {
  16819. return getBindingIdentifiers_1.default;
  16820. }
  16821. });
  16822. Object.defineProperty(exports, "getOuterBindingIdentifiers", {
  16823. enumerable: true,
  16824. get: function () {
  16825. return getOuterBindingIdentifiers_1.default;
  16826. }
  16827. });
  16828. Object.defineProperty(exports, "traverse", {
  16829. enumerable: true,
  16830. get: function () {
  16831. return traverse_1.default;
  16832. }
  16833. });
  16834. Object.defineProperty(exports, "traverseFast", {
  16835. enumerable: true,
  16836. get: function () {
  16837. return traverseFast_1.default;
  16838. }
  16839. });
  16840. Object.defineProperty(exports, "shallowEqual", {
  16841. enumerable: true,
  16842. get: function () {
  16843. return shallowEqual_1.default;
  16844. }
  16845. });
  16846. Object.defineProperty(exports, "is", {
  16847. enumerable: true,
  16848. get: function () {
  16849. return is_1.default;
  16850. }
  16851. });
  16852. Object.defineProperty(exports, "isBinding", {
  16853. enumerable: true,
  16854. get: function () {
  16855. return isBinding_1.default;
  16856. }
  16857. });
  16858. Object.defineProperty(exports, "isBlockScoped", {
  16859. enumerable: true,
  16860. get: function () {
  16861. return isBlockScoped_1.default;
  16862. }
  16863. });
  16864. Object.defineProperty(exports, "isImmutable", {
  16865. enumerable: true,
  16866. get: function () {
  16867. return isImmutable_1$1.default;
  16868. }
  16869. });
  16870. Object.defineProperty(exports, "isLet", {
  16871. enumerable: true,
  16872. get: function () {
  16873. return isLet_1.default;
  16874. }
  16875. });
  16876. Object.defineProperty(exports, "isNode", {
  16877. enumerable: true,
  16878. get: function () {
  16879. return isNode_1.default;
  16880. }
  16881. });
  16882. Object.defineProperty(exports, "isNodesEquivalent", {
  16883. enumerable: true,
  16884. get: function () {
  16885. return isNodesEquivalent_1.default;
  16886. }
  16887. });
  16888. Object.defineProperty(exports, "isPlaceholderType", {
  16889. enumerable: true,
  16890. get: function () {
  16891. return isPlaceholderType_1.default;
  16892. }
  16893. });
  16894. Object.defineProperty(exports, "isReferenced", {
  16895. enumerable: true,
  16896. get: function () {
  16897. return isReferenced_1.default;
  16898. }
  16899. });
  16900. Object.defineProperty(exports, "isScope", {
  16901. enumerable: true,
  16902. get: function () {
  16903. return isScope_1.default;
  16904. }
  16905. });
  16906. Object.defineProperty(exports, "isSpecifierDefault", {
  16907. enumerable: true,
  16908. get: function () {
  16909. return isSpecifierDefault_1.default;
  16910. }
  16911. });
  16912. Object.defineProperty(exports, "isType", {
  16913. enumerable: true,
  16914. get: function () {
  16915. return isType_1.default;
  16916. }
  16917. });
  16918. Object.defineProperty(exports, "isValidES3Identifier", {
  16919. enumerable: true,
  16920. get: function () {
  16921. return isValidES3Identifier_1.default;
  16922. }
  16923. });
  16924. Object.defineProperty(exports, "isValidIdentifier", {
  16925. enumerable: true,
  16926. get: function () {
  16927. return isValidIdentifier_1.default;
  16928. }
  16929. });
  16930. Object.defineProperty(exports, "isVar", {
  16931. enumerable: true,
  16932. get: function () {
  16933. return isVar_1.default;
  16934. }
  16935. });
  16936. Object.defineProperty(exports, "matchesPattern", {
  16937. enumerable: true,
  16938. get: function () {
  16939. return matchesPattern_1.default;
  16940. }
  16941. });
  16942. Object.defineProperty(exports, "validate", {
  16943. enumerable: true,
  16944. get: function () {
  16945. return validate_1.default;
  16946. }
  16947. });
  16948. Object.defineProperty(exports, "buildMatchMemberExpression", {
  16949. enumerable: true,
  16950. get: function () {
  16951. return buildMatchMemberExpression_1.default;
  16952. }
  16953. });
  16954. exports.react = void 0;
  16955. Object.keys(generated$2).forEach(function (key) {
  16956. if (key === "default" || key === "__esModule") return;
  16957. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  16958. if (key in exports && exports[key] === generated$2[key]) return;
  16959. Object.defineProperty(exports, key, {
  16960. enumerable: true,
  16961. get: function () {
  16962. return generated$2[key];
  16963. }
  16964. });
  16965. });
  16966. Object.keys(generated$1).forEach(function (key) {
  16967. if (key === "default" || key === "__esModule") return;
  16968. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  16969. if (key in exports && exports[key] === generated$1[key]) return;
  16970. Object.defineProperty(exports, key, {
  16971. enumerable: true,
  16972. get: function () {
  16973. return generated$1[key];
  16974. }
  16975. });
  16976. });
  16977. Object.keys(uppercase).forEach(function (key) {
  16978. if (key === "default" || key === "__esModule") return;
  16979. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  16980. if (key in exports && exports[key] === uppercase[key]) return;
  16981. Object.defineProperty(exports, key, {
  16982. enumerable: true,
  16983. get: function () {
  16984. return uppercase[key];
  16985. }
  16986. });
  16987. });
  16988. Object.keys(generated$3).forEach(function (key) {
  16989. if (key === "default" || key === "__esModule") return;
  16990. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  16991. if (key in exports && exports[key] === generated$3[key]) return;
  16992. Object.defineProperty(exports, key, {
  16993. enumerable: true,
  16994. get: function () {
  16995. return generated$3[key];
  16996. }
  16997. });
  16998. });
  16999. Object.keys(constants).forEach(function (key) {
  17000. if (key === "default" || key === "__esModule") return;
  17001. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  17002. if (key in exports && exports[key] === constants[key]) return;
  17003. Object.defineProperty(exports, key, {
  17004. enumerable: true,
  17005. get: function () {
  17006. return constants[key];
  17007. }
  17008. });
  17009. });
  17010. Object.keys(definitions).forEach(function (key) {
  17011. if (key === "default" || key === "__esModule") return;
  17012. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  17013. if (key in exports && exports[key] === definitions[key]) return;
  17014. Object.defineProperty(exports, key, {
  17015. enumerable: true,
  17016. get: function () {
  17017. return definitions[key];
  17018. }
  17019. });
  17020. });
  17021. Object.keys(traverse_1).forEach(function (key) {
  17022. if (key === "default" || key === "__esModule") return;
  17023. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  17024. if (key in exports && exports[key] === traverse_1[key]) return;
  17025. Object.defineProperty(exports, key, {
  17026. enumerable: true,
  17027. get: function () {
  17028. return traverse_1[key];
  17029. }
  17030. });
  17031. });
  17032. Object.keys(generated).forEach(function (key) {
  17033. if (key === "default" || key === "__esModule") return;
  17034. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  17035. if (key in exports && exports[key] === generated[key]) return;
  17036. Object.defineProperty(exports, key, {
  17037. enumerable: true,
  17038. get: function () {
  17039. return generated[key];
  17040. }
  17041. });
  17042. });
  17043. Object.keys(_generated5).forEach(function (key) {
  17044. if (key === "default" || key === "__esModule") return;
  17045. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  17046. if (key in exports && exports[key] === _generated5[key]) return;
  17047. Object.defineProperty(exports, key, {
  17048. enumerable: true,
  17049. get: function () {
  17050. return _generated5[key];
  17051. }
  17052. });
  17053. });
  17054. const react = {
  17055. isReactComponent: isReactComponent_1.default,
  17056. isCompatTag: isCompatTag_1.default,
  17057. buildChildren: buildChildren_1.default
  17058. };
  17059. exports.react = react;
  17060. });
  17061. // @ts-check
  17062. /** @typedef { import('estree').BaseNode} BaseNode */
  17063. /** @typedef {{
  17064. skip: () => void;
  17065. remove: () => void;
  17066. replace: (node: BaseNode) => void;
  17067. }} WalkerContext */
  17068. class WalkerBase {
  17069. constructor() {
  17070. /** @type {boolean} */
  17071. this.should_skip = false;
  17072. /** @type {boolean} */
  17073. this.should_remove = false;
  17074. /** @type {BaseNode | null} */
  17075. this.replacement = null;
  17076. /** @type {WalkerContext} */
  17077. this.context = {
  17078. skip: () => (this.should_skip = true),
  17079. remove: () => (this.should_remove = true),
  17080. replace: (node) => (this.replacement = node)
  17081. };
  17082. }
  17083. /**
  17084. *
  17085. * @param {any} parent
  17086. * @param {string} prop
  17087. * @param {number} index
  17088. * @param {BaseNode} node
  17089. */
  17090. replace(parent, prop, index, node) {
  17091. if (parent) {
  17092. if (index !== null) {
  17093. parent[prop][index] = node;
  17094. } else {
  17095. parent[prop] = node;
  17096. }
  17097. }
  17098. }
  17099. /**
  17100. *
  17101. * @param {any} parent
  17102. * @param {string} prop
  17103. * @param {number} index
  17104. */
  17105. remove(parent, prop, index) {
  17106. if (parent) {
  17107. if (index !== null) {
  17108. parent[prop].splice(index, 1);
  17109. } else {
  17110. delete parent[prop];
  17111. }
  17112. }
  17113. }
  17114. }
  17115. // @ts-check
  17116. /** @typedef { import('estree').BaseNode} BaseNode */
  17117. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  17118. /** @typedef {(
  17119. * this: WalkerContext,
  17120. * node: BaseNode,
  17121. * parent: BaseNode,
  17122. * key: string,
  17123. * index: number
  17124. * ) => void} SyncHandler */
  17125. class SyncWalker extends WalkerBase {
  17126. /**
  17127. *
  17128. * @param {SyncHandler} enter
  17129. * @param {SyncHandler} leave
  17130. */
  17131. constructor(enter, leave) {
  17132. super();
  17133. /** @type {SyncHandler} */
  17134. this.enter = enter;
  17135. /** @type {SyncHandler} */
  17136. this.leave = leave;
  17137. }
  17138. /**
  17139. *
  17140. * @param {BaseNode} node
  17141. * @param {BaseNode} parent
  17142. * @param {string} [prop]
  17143. * @param {number} [index]
  17144. * @returns {BaseNode}
  17145. */
  17146. visit(node, parent, prop, index) {
  17147. if (node) {
  17148. if (this.enter) {
  17149. const _should_skip = this.should_skip;
  17150. const _should_remove = this.should_remove;
  17151. const _replacement = this.replacement;
  17152. this.should_skip = false;
  17153. this.should_remove = false;
  17154. this.replacement = null;
  17155. this.enter.call(this.context, node, parent, prop, index);
  17156. if (this.replacement) {
  17157. node = this.replacement;
  17158. this.replace(parent, prop, index, node);
  17159. }
  17160. if (this.should_remove) {
  17161. this.remove(parent, prop, index);
  17162. }
  17163. const skipped = this.should_skip;
  17164. const removed = this.should_remove;
  17165. this.should_skip = _should_skip;
  17166. this.should_remove = _should_remove;
  17167. this.replacement = _replacement;
  17168. if (skipped) return node;
  17169. if (removed) return null;
  17170. }
  17171. for (const key in node) {
  17172. const value = node[key];
  17173. if (typeof value !== "object") {
  17174. continue;
  17175. } else if (Array.isArray(value)) {
  17176. for (let i = 0; i < value.length; i += 1) {
  17177. if (value[i] !== null && typeof value[i].type === 'string') {
  17178. if (!this.visit(value[i], node, key, i)) {
  17179. // removed
  17180. i--;
  17181. }
  17182. }
  17183. }
  17184. } else if (value !== null && typeof value.type === "string") {
  17185. this.visit(value, node, key, null);
  17186. }
  17187. }
  17188. if (this.leave) {
  17189. const _replacement = this.replacement;
  17190. const _should_remove = this.should_remove;
  17191. this.replacement = null;
  17192. this.should_remove = false;
  17193. this.leave.call(this.context, node, parent, prop, index);
  17194. if (this.replacement) {
  17195. node = this.replacement;
  17196. this.replace(parent, prop, index, node);
  17197. }
  17198. if (this.should_remove) {
  17199. this.remove(parent, prop, index);
  17200. }
  17201. const removed = this.should_remove;
  17202. this.replacement = _replacement;
  17203. this.should_remove = _should_remove;
  17204. if (removed) return null;
  17205. }
  17206. }
  17207. return node;
  17208. }
  17209. }
  17210. // @ts-check
  17211. /** @typedef { import('estree').BaseNode} BaseNode */
  17212. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  17213. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  17214. /**
  17215. *
  17216. * @param {BaseNode} ast
  17217. * @param {{
  17218. * enter?: SyncHandler
  17219. * leave?: SyncHandler
  17220. * }} walker
  17221. * @returns {BaseNode}
  17222. */
  17223. function walk$1(ast, { enter, leave }) {
  17224. const instance = new SyncWalker(enter, leave);
  17225. return instance.visit(ast, null);
  17226. }
  17227. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = Object.create(null)) {
  17228. const rootExp = root.type === 'Program' &&
  17229. root.body[0].type === 'ExpressionStatement' &&
  17230. root.body[0].expression;
  17231. walk$1(root, {
  17232. enter(node, parent) {
  17233. parent && parentStack.push(parent);
  17234. if (parent &&
  17235. parent.type.startsWith('TS') &&
  17236. parent.type !== 'TSAsExpression' &&
  17237. parent.type !== 'TSNonNullExpression' &&
  17238. parent.type !== 'TSTypeAssertion') {
  17239. return this.skip();
  17240. }
  17241. if (node.type === 'Identifier') {
  17242. const isLocal = !!knownIds[node.name];
  17243. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  17244. if (includeAll || (isRefed && !isLocal)) {
  17245. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  17246. }
  17247. }
  17248. else if (node.type === 'ObjectProperty' &&
  17249. parent.type === 'ObjectPattern') {
  17250. node.inPattern = true;
  17251. }
  17252. else if (isFunctionType(node)) {
  17253. // walk function expressions and add its arguments to known identifiers
  17254. // so that we don't prefix them
  17255. walkFunctionParams(node, id => markScopeIdentifier(node, id, knownIds));
  17256. }
  17257. else if (node.type === 'BlockStatement') {
  17258. // #3445 record block-level local variables
  17259. walkBlockDeclarations(node, id => markScopeIdentifier(node, id, knownIds));
  17260. }
  17261. },
  17262. leave(node, parent) {
  17263. parent && parentStack.pop();
  17264. if (node !== rootExp && node.scopeIds) {
  17265. for (const id of node.scopeIds) {
  17266. knownIds[id]--;
  17267. if (knownIds[id] === 0) {
  17268. delete knownIds[id];
  17269. }
  17270. }
  17271. }
  17272. }
  17273. });
  17274. }
  17275. function isReferencedIdentifier(id, parent, parentStack) {
  17276. if (!parent) {
  17277. return true;
  17278. }
  17279. // is a special keyword but parsed as identifier
  17280. if (id.name === 'arguments') {
  17281. return false;
  17282. }
  17283. if (lib$1.isReferenced(id, parent)) {
  17284. return true;
  17285. }
  17286. // babel's isReferenced check returns false for ids being assigned to, so we
  17287. // need to cover those cases here
  17288. switch (parent.type) {
  17289. case 'AssignmentExpression':
  17290. case 'AssignmentPattern':
  17291. return true;
  17292. case 'ObjectPattern':
  17293. case 'ArrayPattern':
  17294. return isInDestructureAssignment(parent, parentStack);
  17295. }
  17296. return false;
  17297. }
  17298. function isInDestructureAssignment(parent, parentStack) {
  17299. if (parent &&
  17300. (parent.type === 'ObjectProperty' || parent.type === 'ArrayPattern')) {
  17301. let i = parentStack.length;
  17302. while (i--) {
  17303. const p = parentStack[i];
  17304. if (p.type === 'AssignmentExpression') {
  17305. return true;
  17306. }
  17307. else if (p.type !== 'ObjectProperty' && !p.type.endsWith('Pattern')) {
  17308. break;
  17309. }
  17310. }
  17311. }
  17312. return false;
  17313. }
  17314. function walkFunctionParams(node, onIdent) {
  17315. for (const p of node.params) {
  17316. for (const id of extractIdentifiers(p)) {
  17317. onIdent(id);
  17318. }
  17319. }
  17320. }
  17321. function walkBlockDeclarations(block, onIdent) {
  17322. for (const stmt of block.body) {
  17323. if (stmt.type === 'VariableDeclaration') {
  17324. if (stmt.declare)
  17325. continue;
  17326. for (const decl of stmt.declarations) {
  17327. for (const id of extractIdentifiers(decl.id)) {
  17328. onIdent(id);
  17329. }
  17330. }
  17331. }
  17332. else if (stmt.type === 'FunctionDeclaration' ||
  17333. stmt.type === 'ClassDeclaration') {
  17334. if (stmt.declare || !stmt.id)
  17335. continue;
  17336. onIdent(stmt.id);
  17337. }
  17338. }
  17339. }
  17340. function extractIdentifiers(param, nodes = []) {
  17341. switch (param.type) {
  17342. case 'Identifier':
  17343. nodes.push(param);
  17344. break;
  17345. case 'MemberExpression':
  17346. let object = param;
  17347. while (object.type === 'MemberExpression') {
  17348. object = object.object;
  17349. }
  17350. nodes.push(object);
  17351. break;
  17352. case 'ObjectPattern':
  17353. for (const prop of param.properties) {
  17354. if (prop.type === 'RestElement') {
  17355. extractIdentifiers(prop.argument, nodes);
  17356. }
  17357. else {
  17358. extractIdentifiers(prop.value, nodes);
  17359. }
  17360. }
  17361. break;
  17362. case 'ArrayPattern':
  17363. param.elements.forEach(element => {
  17364. if (element)
  17365. extractIdentifiers(element, nodes);
  17366. });
  17367. break;
  17368. case 'RestElement':
  17369. extractIdentifiers(param.argument, nodes);
  17370. break;
  17371. case 'AssignmentPattern':
  17372. extractIdentifiers(param.left, nodes);
  17373. break;
  17374. }
  17375. return nodes;
  17376. }
  17377. function markScopeIdentifier(node, child, knownIds) {
  17378. const { name } = child;
  17379. if (node.scopeIds && node.scopeIds.has(name)) {
  17380. return;
  17381. }
  17382. if (name in knownIds) {
  17383. knownIds[name]++;
  17384. }
  17385. else {
  17386. knownIds[name] = 1;
  17387. }
  17388. (node.scopeIds || (node.scopeIds = new Set())).add(name);
  17389. }
  17390. const isFunctionType = (node) => {
  17391. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  17392. };
  17393. const isStaticProperty = (node) => node &&
  17394. (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
  17395. !node.computed;
  17396. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  17397. const beforeExpr = true;
  17398. const startsExpr = true;
  17399. const isLoop$1 = true;
  17400. const isAssign = true;
  17401. const prefix = true;
  17402. const postfix = true;
  17403. class TokenType {
  17404. constructor(label, conf = {}) {
  17405. this.label = void 0;
  17406. this.keyword = void 0;
  17407. this.beforeExpr = void 0;
  17408. this.startsExpr = void 0;
  17409. this.rightAssociative = void 0;
  17410. this.isLoop = void 0;
  17411. this.isAssign = void 0;
  17412. this.prefix = void 0;
  17413. this.postfix = void 0;
  17414. this.binop = void 0;
  17415. this.updateContext = void 0;
  17416. this.label = label;
  17417. this.keyword = conf.keyword;
  17418. this.beforeExpr = !!conf.beforeExpr;
  17419. this.startsExpr = !!conf.startsExpr;
  17420. this.rightAssociative = !!conf.rightAssociative;
  17421. this.isLoop = !!conf.isLoop;
  17422. this.isAssign = !!conf.isAssign;
  17423. this.prefix = !!conf.prefix;
  17424. this.postfix = !!conf.postfix;
  17425. this.binop = conf.binop != null ? conf.binop : null;
  17426. this.updateContext = null;
  17427. }
  17428. }
  17429. const keywords$1 = new Map();
  17430. function createKeyword(name, options = {}) {
  17431. options.keyword = name;
  17432. const token = new TokenType(name, options);
  17433. keywords$1.set(name, token);
  17434. return token;
  17435. }
  17436. function createBinop(name, binop) {
  17437. return new TokenType(name, {
  17438. beforeExpr,
  17439. binop
  17440. });
  17441. }
  17442. const types$1 = {
  17443. num: new TokenType("num", {
  17444. startsExpr
  17445. }),
  17446. bigint: new TokenType("bigint", {
  17447. startsExpr
  17448. }),
  17449. decimal: new TokenType("decimal", {
  17450. startsExpr
  17451. }),
  17452. regexp: new TokenType("regexp", {
  17453. startsExpr
  17454. }),
  17455. string: new TokenType("string", {
  17456. startsExpr
  17457. }),
  17458. name: new TokenType("name", {
  17459. startsExpr
  17460. }),
  17461. privateName: new TokenType("#name", {
  17462. startsExpr
  17463. }),
  17464. eof: new TokenType("eof"),
  17465. bracketL: new TokenType("[", {
  17466. beforeExpr,
  17467. startsExpr
  17468. }),
  17469. bracketHashL: new TokenType("#[", {
  17470. beforeExpr,
  17471. startsExpr
  17472. }),
  17473. bracketBarL: new TokenType("[|", {
  17474. beforeExpr,
  17475. startsExpr
  17476. }),
  17477. bracketR: new TokenType("]"),
  17478. bracketBarR: new TokenType("|]"),
  17479. braceL: new TokenType("{", {
  17480. beforeExpr,
  17481. startsExpr
  17482. }),
  17483. braceBarL: new TokenType("{|", {
  17484. beforeExpr,
  17485. startsExpr
  17486. }),
  17487. braceHashL: new TokenType("#{", {
  17488. beforeExpr,
  17489. startsExpr
  17490. }),
  17491. braceR: new TokenType("}", {
  17492. beforeExpr
  17493. }),
  17494. braceBarR: new TokenType("|}"),
  17495. parenL: new TokenType("(", {
  17496. beforeExpr,
  17497. startsExpr
  17498. }),
  17499. parenR: new TokenType(")"),
  17500. comma: new TokenType(",", {
  17501. beforeExpr
  17502. }),
  17503. semi: new TokenType(";", {
  17504. beforeExpr
  17505. }),
  17506. colon: new TokenType(":", {
  17507. beforeExpr
  17508. }),
  17509. doubleColon: new TokenType("::", {
  17510. beforeExpr
  17511. }),
  17512. dot: new TokenType("."),
  17513. question: new TokenType("?", {
  17514. beforeExpr
  17515. }),
  17516. questionDot: new TokenType("?."),
  17517. arrow: new TokenType("=>", {
  17518. beforeExpr
  17519. }),
  17520. template: new TokenType("template"),
  17521. ellipsis: new TokenType("...", {
  17522. beforeExpr
  17523. }),
  17524. backQuote: new TokenType("`", {
  17525. startsExpr
  17526. }),
  17527. dollarBraceL: new TokenType("${", {
  17528. beforeExpr,
  17529. startsExpr
  17530. }),
  17531. at: new TokenType("@"),
  17532. hash: new TokenType("#", {
  17533. startsExpr
  17534. }),
  17535. interpreterDirective: new TokenType("#!..."),
  17536. eq: new TokenType("=", {
  17537. beforeExpr,
  17538. isAssign
  17539. }),
  17540. assign: new TokenType("_=", {
  17541. beforeExpr,
  17542. isAssign
  17543. }),
  17544. slashAssign: new TokenType("_=", {
  17545. beforeExpr,
  17546. isAssign
  17547. }),
  17548. moduloAssign: new TokenType("_=", {
  17549. beforeExpr,
  17550. isAssign
  17551. }),
  17552. incDec: new TokenType("++/--", {
  17553. prefix,
  17554. postfix,
  17555. startsExpr
  17556. }),
  17557. bang: new TokenType("!", {
  17558. beforeExpr,
  17559. prefix,
  17560. startsExpr
  17561. }),
  17562. tilde: new TokenType("~", {
  17563. beforeExpr,
  17564. prefix,
  17565. startsExpr
  17566. }),
  17567. pipeline: createBinop("|>", 0),
  17568. nullishCoalescing: createBinop("??", 1),
  17569. logicalOR: createBinop("||", 1),
  17570. logicalAND: createBinop("&&", 2),
  17571. bitwiseOR: createBinop("|", 3),
  17572. bitwiseXOR: createBinop("^", 4),
  17573. bitwiseAND: createBinop("&", 5),
  17574. equality: createBinop("==/!=/===/!==", 6),
  17575. relational: createBinop("</>/<=/>=", 7),
  17576. bitShift: createBinop("<</>>/>>>", 8),
  17577. plusMin: new TokenType("+/-", {
  17578. beforeExpr,
  17579. binop: 9,
  17580. prefix,
  17581. startsExpr
  17582. }),
  17583. modulo: new TokenType("%", {
  17584. binop: 10,
  17585. startsExpr
  17586. }),
  17587. star: new TokenType("*", {
  17588. binop: 10
  17589. }),
  17590. slash: createBinop("/", 10),
  17591. exponent: new TokenType("**", {
  17592. beforeExpr,
  17593. binop: 11,
  17594. rightAssociative: true
  17595. }),
  17596. _break: createKeyword("break"),
  17597. _case: createKeyword("case", {
  17598. beforeExpr
  17599. }),
  17600. _catch: createKeyword("catch"),
  17601. _continue: createKeyword("continue"),
  17602. _debugger: createKeyword("debugger"),
  17603. _default: createKeyword("default", {
  17604. beforeExpr
  17605. }),
  17606. _do: createKeyword("do", {
  17607. isLoop: isLoop$1,
  17608. beforeExpr
  17609. }),
  17610. _else: createKeyword("else", {
  17611. beforeExpr
  17612. }),
  17613. _finally: createKeyword("finally"),
  17614. _for: createKeyword("for", {
  17615. isLoop: isLoop$1
  17616. }),
  17617. _function: createKeyword("function", {
  17618. startsExpr
  17619. }),
  17620. _if: createKeyword("if"),
  17621. _return: createKeyword("return", {
  17622. beforeExpr
  17623. }),
  17624. _switch: createKeyword("switch"),
  17625. _throw: createKeyword("throw", {
  17626. beforeExpr,
  17627. prefix,
  17628. startsExpr
  17629. }),
  17630. _try: createKeyword("try"),
  17631. _var: createKeyword("var"),
  17632. _const: createKeyword("const"),
  17633. _while: createKeyword("while", {
  17634. isLoop: isLoop$1
  17635. }),
  17636. _with: createKeyword("with"),
  17637. _new: createKeyword("new", {
  17638. beforeExpr,
  17639. startsExpr
  17640. }),
  17641. _this: createKeyword("this", {
  17642. startsExpr
  17643. }),
  17644. _super: createKeyword("super", {
  17645. startsExpr
  17646. }),
  17647. _class: createKeyword("class", {
  17648. startsExpr
  17649. }),
  17650. _extends: createKeyword("extends", {
  17651. beforeExpr
  17652. }),
  17653. _export: createKeyword("export"),
  17654. _import: createKeyword("import", {
  17655. startsExpr
  17656. }),
  17657. _null: createKeyword("null", {
  17658. startsExpr
  17659. }),
  17660. _true: createKeyword("true", {
  17661. startsExpr
  17662. }),
  17663. _false: createKeyword("false", {
  17664. startsExpr
  17665. }),
  17666. _in: createKeyword("in", {
  17667. beforeExpr,
  17668. binop: 7
  17669. }),
  17670. _instanceof: createKeyword("instanceof", {
  17671. beforeExpr,
  17672. binop: 7
  17673. }),
  17674. _typeof: createKeyword("typeof", {
  17675. beforeExpr,
  17676. prefix,
  17677. startsExpr
  17678. }),
  17679. _void: createKeyword("void", {
  17680. beforeExpr,
  17681. prefix,
  17682. startsExpr
  17683. }),
  17684. _delete: createKeyword("delete", {
  17685. beforeExpr,
  17686. prefix,
  17687. startsExpr
  17688. })
  17689. };
  17690. const lineBreak = /\r\n?|[\n\u2028\u2029]/;
  17691. const lineBreakG = new RegExp(lineBreak.source, "g");
  17692. function isNewLine(code) {
  17693. switch (code) {
  17694. case 10:
  17695. case 13:
  17696. case 8232:
  17697. case 8233:
  17698. return true;
  17699. default:
  17700. return false;
  17701. }
  17702. }
  17703. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  17704. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
  17705. const skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
  17706. function isWhitespace(code) {
  17707. switch (code) {
  17708. case 0x0009:
  17709. case 0x000b:
  17710. case 0x000c:
  17711. case 32:
  17712. case 160:
  17713. case 5760:
  17714. case 0x2000:
  17715. case 0x2001:
  17716. case 0x2002:
  17717. case 0x2003:
  17718. case 0x2004:
  17719. case 0x2005:
  17720. case 0x2006:
  17721. case 0x2007:
  17722. case 0x2008:
  17723. case 0x2009:
  17724. case 0x200a:
  17725. case 0x202f:
  17726. case 0x205f:
  17727. case 0x3000:
  17728. case 0xfeff:
  17729. return true;
  17730. default:
  17731. return false;
  17732. }
  17733. }
  17734. class Position {
  17735. constructor(line, col) {
  17736. this.line = void 0;
  17737. this.column = void 0;
  17738. this.line = line;
  17739. this.column = col;
  17740. }
  17741. }
  17742. class SourceLocation {
  17743. constructor(start, end) {
  17744. this.start = void 0;
  17745. this.end = void 0;
  17746. this.filename = void 0;
  17747. this.identifierName = void 0;
  17748. this.start = start;
  17749. this.end = end;
  17750. }
  17751. }
  17752. function getLineInfo(input, offset) {
  17753. let line = 1;
  17754. let lineStart = 0;
  17755. let match;
  17756. lineBreakG.lastIndex = 0;
  17757. while ((match = lineBreakG.exec(input)) && match.index < offset) {
  17758. line++;
  17759. lineStart = lineBreakG.lastIndex;
  17760. }
  17761. return new Position(line, offset - lineStart);
  17762. }
  17763. class BaseParser {
  17764. constructor() {
  17765. this.sawUnambiguousESM = false;
  17766. this.ambiguousScriptDifferentAst = false;
  17767. }
  17768. hasPlugin(name) {
  17769. return this.plugins.has(name);
  17770. }
  17771. getPluginOption(plugin, name) {
  17772. if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];
  17773. }
  17774. }
  17775. function setTrailingComments(node, comments) {
  17776. if (node.trailingComments === undefined) {
  17777. node.trailingComments = comments;
  17778. } else {
  17779. node.trailingComments.unshift(...comments);
  17780. }
  17781. }
  17782. function setInnerComments(node, comments) {
  17783. if (node.innerComments === undefined) {
  17784. node.innerComments = comments;
  17785. } else if (comments !== undefined) {
  17786. node.innerComments.unshift(...comments);
  17787. }
  17788. }
  17789. function adjustInnerComments(node, elements, commentWS) {
  17790. let lastElement = null;
  17791. let i = elements.length;
  17792. while (lastElement === null && i > 0) {
  17793. lastElement = elements[--i];
  17794. }
  17795. if (lastElement === null || lastElement.start > commentWS.start) {
  17796. setInnerComments(node, commentWS.comments);
  17797. } else {
  17798. setTrailingComments(lastElement, commentWS.comments);
  17799. }
  17800. }
  17801. class CommentsParser extends BaseParser {
  17802. addComment(comment) {
  17803. if (this.filename) comment.loc.filename = this.filename;
  17804. this.state.comments.push(comment);
  17805. }
  17806. processComment(node) {
  17807. const {
  17808. commentStack
  17809. } = this.state;
  17810. const commentStackLength = commentStack.length;
  17811. if (commentStackLength === 0) return;
  17812. let i = commentStackLength - 1;
  17813. const lastCommentWS = commentStack[i];
  17814. if (lastCommentWS.start === node.end) {
  17815. lastCommentWS.leadingNode = node;
  17816. i--;
  17817. }
  17818. const {
  17819. start: nodeStart
  17820. } = node;
  17821. for (; i >= 0; i--) {
  17822. const commentWS = commentStack[i];
  17823. const commentEnd = commentWS.end;
  17824. if (commentEnd > nodeStart) {
  17825. commentWS.containingNode = node;
  17826. this.finalizeComment(commentWS);
  17827. commentStack.splice(i, 1);
  17828. } else {
  17829. if (commentEnd === nodeStart) {
  17830. commentWS.trailingNode = node;
  17831. }
  17832. break;
  17833. }
  17834. }
  17835. }
  17836. finalizeComment(commentWS) {
  17837. const {
  17838. comments
  17839. } = commentWS;
  17840. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  17841. if (commentWS.leadingNode !== null) {
  17842. setTrailingComments(commentWS.leadingNode, comments);
  17843. }
  17844. if (commentWS.trailingNode !== null) {
  17845. commentWS.trailingNode.leadingComments = comments;
  17846. }
  17847. } else {
  17848. const {
  17849. containingNode: node,
  17850. start: commentStart
  17851. } = commentWS;
  17852. if (this.input.charCodeAt(commentStart - 1) === 44) {
  17853. switch (node.type) {
  17854. case "ObjectExpression":
  17855. case "ObjectPattern":
  17856. case "RecordExpression":
  17857. adjustInnerComments(node, node.properties, commentWS);
  17858. break;
  17859. case "CallExpression":
  17860. case "OptionalCallExpression":
  17861. adjustInnerComments(node, node.arguments, commentWS);
  17862. break;
  17863. case "FunctionDeclaration":
  17864. case "FunctionExpression":
  17865. case "ArrowFunctionExpression":
  17866. case "ObjectMethod":
  17867. case "ClassMethod":
  17868. case "ClassPrivateMethod":
  17869. adjustInnerComments(node, node.params, commentWS);
  17870. break;
  17871. case "ArrayExpression":
  17872. case "ArrayPattern":
  17873. case "TupleExpression":
  17874. adjustInnerComments(node, node.elements, commentWS);
  17875. break;
  17876. case "ExportNamedDeclaration":
  17877. case "ImportDeclaration":
  17878. adjustInnerComments(node, node.specifiers, commentWS);
  17879. break;
  17880. default:
  17881. {
  17882. setInnerComments(node, comments);
  17883. }
  17884. }
  17885. } else {
  17886. setInnerComments(node, comments);
  17887. }
  17888. }
  17889. }
  17890. finalizeRemainingComments() {
  17891. const {
  17892. commentStack
  17893. } = this.state;
  17894. for (let i = commentStack.length - 1; i >= 0; i--) {
  17895. this.finalizeComment(commentStack[i]);
  17896. }
  17897. this.state.commentStack = [];
  17898. }
  17899. resetPreviousNodeTrailingComments(node) {
  17900. const {
  17901. commentStack
  17902. } = this.state;
  17903. const {
  17904. length
  17905. } = commentStack;
  17906. if (length === 0) return;
  17907. const commentWS = commentStack[length - 1];
  17908. if (commentWS.leadingNode === node) {
  17909. commentWS.leadingNode = null;
  17910. }
  17911. }
  17912. }
  17913. const ErrorCodes = Object.freeze({
  17914. SyntaxError: "BABEL_PARSER_SYNTAX_ERROR",
  17915. SourceTypeModuleError: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"
  17916. });
  17917. const ErrorMessages = makeErrorTemplates({
  17918. AccessorIsGenerator: "A %0ter cannot be a generator.",
  17919. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  17920. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  17921. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  17922. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  17923. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  17924. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  17925. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  17926. BadGetterArity: "A 'get' accesor must not have any formal parameters.",
  17927. BadSetterArity: "A 'set' accesor must have exactly one formal parameter.",
  17928. BadSetterRestParameter: "A 'set' accesor function argument must not be a rest parameter.",
  17929. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  17930. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  17931. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  17932. ConstructorIsAsync: "Constructor can't be an async function.",
  17933. ConstructorIsGenerator: "Constructor can't be a generator.",
  17934. DeclarationMissingInitializer: "'%0' require an initialization value.",
  17935. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax.",
  17936. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  17937. DecoratorExportClass: "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.",
  17938. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  17939. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  17940. DeletePrivateField: "Deleting a private field is not allowed.",
  17941. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  17942. DuplicateConstructor: "Duplicate constructor in the same class.",
  17943. DuplicateDefaultExport: "Only one default export allowed per module.",
  17944. DuplicateExport: "`%0` has already been exported. Exported identifiers must be unique.",
  17945. DuplicateProto: "Redefinition of __proto__ property.",
  17946. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  17947. ElementAfterRest: "Rest element must be last element.",
  17948. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  17949. ExportBindingIsString: "A string literal cannot be used as an exported binding without `from`.\n- Did you mean `export { '%0' as '%1' } from 'some-module'`?",
  17950. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  17951. ForInOfLoopInitializer: "'%0' loop variable declaration may not have an initializer.",
  17952. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  17953. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  17954. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  17955. IllegalBreakContinue: "Unsyntactic %0.",
  17956. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  17957. IllegalReturn: "'return' outside of function.",
  17958. ImportBindingIsString: 'A string literal cannot be used as an imported binding.\n- Did you mean `import { "%0" as foo }`?',
  17959. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  17960. ImportCallArity: "`import()` requires exactly %0.",
  17961. ImportCallNotNewExpression: "Cannot use new with import(...).",
  17962. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  17963. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  17964. InvalidCodePoint: "Code point out of bounds.",
  17965. InvalidDecimal: "Invalid decimal.",
  17966. InvalidDigit: "Expected number in radix %0.",
  17967. InvalidEscapeSequence: "Bad character escape sequence.",
  17968. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  17969. InvalidEscapedReservedWord: "Escape sequence in keyword %0.",
  17970. InvalidIdentifier: "Invalid identifier %0.",
  17971. InvalidLhs: "Invalid left-hand side in %0.",
  17972. InvalidLhsBinding: "Binding invalid left-hand side in %0.",
  17973. InvalidNumber: "Invalid number.",
  17974. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  17975. InvalidOrUnexpectedToken: "Unexpected character '%0'.",
  17976. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  17977. InvalidPrivateFieldResolution: "Private name #%0 is not defined.",
  17978. InvalidPropertyBindingPattern: "Binding member expression.",
  17979. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  17980. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  17981. LabelRedeclaration: "Label '%0' is already declared.",
  17982. LetInLexicalBinding: "'let' is not allowed to be used as a name in 'let' or 'const' declarations.",
  17983. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  17984. MalformedRegExpFlags: "Invalid regular expression flag.",
  17985. MissingClassName: "A class name is required.",
  17986. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  17987. MissingSemicolon: "Missing semicolon.",
  17988. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  17989. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  17990. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  17991. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  17992. ModuleAttributesWithDuplicateKeys: 'Duplicate key "%0" is not allowed in module attributes.',
  17993. ModuleExportNameHasLoneSurrogate: "An export name cannot include a lone surrogate, found '\\u%0'.",
  17994. ModuleExportUndefined: "Export '%0' is not defined.",
  17995. MultipleDefaultsInSwitch: "Multiple default clauses.",
  17996. NewlineAfterThrow: "Illegal newline after throw.",
  17997. NoCatchOrFinally: "Missing catch or finally clause.",
  17998. NumberIdentifier: "Identifier directly after number.",
  17999. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  18000. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  18001. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  18002. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  18003. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  18004. ParamDupe: "Argument name clash.",
  18005. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  18006. PatternHasMethod: "Object pattern can't contain methods.",
  18007. PipeBodyIsTighter: "Unexpected %0 after pipeline body; any %0 expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  18008. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  18009. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  18010. PipeTopicUnconfiguredToken: 'Invalid topic token %0. In order to use %0 as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "%0" }.',
  18011. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  18012. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  18013. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  18014. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  18015. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  18016. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  18017. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  18018. PrivateInExpectedIn: "Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`).",
  18019. PrivateNameRedeclaration: "Duplicate private name #%0.",
  18020. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  18021. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  18022. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  18023. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  18024. RestTrailingComma: "Unexpected trailing comma after rest element.",
  18025. SloppyFunction: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
  18026. StaticPrototype: "Classes may not have static property named prototype.",
  18027. StrictDelete: "Deleting local variable in strict mode.",
  18028. StrictEvalArguments: "Assigning to '%0' in strict mode.",
  18029. StrictEvalArgumentsBinding: "Binding '%0' in strict mode.",
  18030. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  18031. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  18032. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  18033. StrictWith: "'with' in strict mode.",
  18034. 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?",
  18035. SuperPrivateField: "Private fields can't be accessed on super.",
  18036. TrailingDecorator: "Decorators must be attached to a class element.",
  18037. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  18038. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  18039. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  18040. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  18041. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  18042. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  18043. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  18044. UnexpectedKeyword: "Unexpected keyword '%0'.",
  18045. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  18046. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  18047. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  18048. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  18049. UnexpectedPrivateField: "Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p).",
  18050. UnexpectedReservedWord: "Unexpected reserved word '%0'.",
  18051. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  18052. UnexpectedToken: "Unexpected token '%0'.",
  18053. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  18054. UnsupportedBind: "Binding should be performed on object property.",
  18055. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  18056. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  18057. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  18058. UnsupportedMetaProperty: "The only valid meta property for %0 is %0.%1.",
  18059. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  18060. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  18061. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  18062. UnterminatedComment: "Unterminated comment.",
  18063. UnterminatedRegExp: "Unterminated regular expression.",
  18064. UnterminatedString: "Unterminated string constant.",
  18065. UnterminatedTemplate: "Unterminated template.",
  18066. VarRedeclaration: "Identifier '%0' has already been declared.",
  18067. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  18068. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  18069. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  18070. }, ErrorCodes.SyntaxError);
  18071. const SourceTypeModuleErrorMessages = makeErrorTemplates({
  18072. ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: "module"'`,
  18073. ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: "module"'`
  18074. }, ErrorCodes.SourceTypeModuleError);
  18075. function makeErrorTemplates(messages, code) {
  18076. const templates = {};
  18077. Object.keys(messages).forEach(reasonCode => {
  18078. templates[reasonCode] = Object.freeze({
  18079. code,
  18080. reasonCode,
  18081. template: messages[reasonCode]
  18082. });
  18083. });
  18084. return Object.freeze(templates);
  18085. }
  18086. class ParserError extends CommentsParser {
  18087. getLocationForPosition(pos) {
  18088. let loc;
  18089. if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos);
  18090. return loc;
  18091. }
  18092. raise(pos, {
  18093. code,
  18094. reasonCode,
  18095. template
  18096. }, ...params) {
  18097. return this.raiseWithData(pos, {
  18098. code,
  18099. reasonCode
  18100. }, template, ...params);
  18101. }
  18102. raiseOverwrite(pos, {
  18103. code,
  18104. template
  18105. }, ...params) {
  18106. const loc = this.getLocationForPosition(pos);
  18107. const message = template.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`;
  18108. if (this.options.errorRecovery) {
  18109. const errors = this.state.errors;
  18110. for (let i = errors.length - 1; i >= 0; i--) {
  18111. const error = errors[i];
  18112. if (error.pos === pos) {
  18113. return Object.assign(error, {
  18114. message
  18115. });
  18116. } else if (error.pos < pos) {
  18117. break;
  18118. }
  18119. }
  18120. }
  18121. return this._raise({
  18122. code,
  18123. loc,
  18124. pos
  18125. }, message);
  18126. }
  18127. raiseWithData(pos, data, errorTemplate, ...params) {
  18128. const loc = this.getLocationForPosition(pos);
  18129. const message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`;
  18130. return this._raise(Object.assign({
  18131. loc,
  18132. pos
  18133. }, data), message);
  18134. }
  18135. _raise(errorContext, message) {
  18136. const err = new SyntaxError(message);
  18137. Object.assign(err, errorContext);
  18138. if (this.options.errorRecovery) {
  18139. if (!this.isLookahead) this.state.errors.push(err);
  18140. return err;
  18141. } else {
  18142. throw err;
  18143. }
  18144. }
  18145. }
  18146. var estree = (superClass => class extends superClass {
  18147. parseRegExpLiteral({
  18148. pattern,
  18149. flags
  18150. }) {
  18151. let regex = null;
  18152. try {
  18153. regex = new RegExp(pattern, flags);
  18154. } catch (e) {}
  18155. const node = this.estreeParseLiteral(regex);
  18156. node.regex = {
  18157. pattern,
  18158. flags
  18159. };
  18160. return node;
  18161. }
  18162. parseBigIntLiteral(value) {
  18163. let bigInt;
  18164. try {
  18165. bigInt = BigInt(value);
  18166. } catch (_unused) {
  18167. bigInt = null;
  18168. }
  18169. const node = this.estreeParseLiteral(bigInt);
  18170. node.bigint = String(node.value || value);
  18171. return node;
  18172. }
  18173. parseDecimalLiteral(value) {
  18174. const decimal = null;
  18175. const node = this.estreeParseLiteral(decimal);
  18176. node.decimal = String(node.value || value);
  18177. return node;
  18178. }
  18179. estreeParseLiteral(value) {
  18180. return this.parseLiteral(value, "Literal");
  18181. }
  18182. parseStringLiteral(value) {
  18183. return this.estreeParseLiteral(value);
  18184. }
  18185. parseNumericLiteral(value) {
  18186. return this.estreeParseLiteral(value);
  18187. }
  18188. parseNullLiteral() {
  18189. return this.estreeParseLiteral(null);
  18190. }
  18191. parseBooleanLiteral(value) {
  18192. return this.estreeParseLiteral(value);
  18193. }
  18194. directiveToStmt(directive) {
  18195. const directiveLiteral = directive.value;
  18196. const stmt = this.startNodeAt(directive.start, directive.loc.start);
  18197. const expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
  18198. expression.value = directiveLiteral.extra.expressionValue;
  18199. expression.raw = directiveLiteral.extra.raw;
  18200. stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end);
  18201. stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
  18202. return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end);
  18203. }
  18204. initFunction(node, isAsync) {
  18205. super.initFunction(node, isAsync);
  18206. node.expression = false;
  18207. }
  18208. checkDeclaration(node) {
  18209. if (node != null && this.isObjectProperty(node)) {
  18210. this.checkDeclaration(node.value);
  18211. } else {
  18212. super.checkDeclaration(node);
  18213. }
  18214. }
  18215. getObjectOrClassMethodParams(method) {
  18216. return method.value.params;
  18217. }
  18218. isValidDirective(stmt) {
  18219. var _stmt$expression$extr;
  18220. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  18221. }
  18222. stmtToDirective(stmt) {
  18223. const value = stmt.expression.value;
  18224. const directive = super.stmtToDirective(stmt);
  18225. this.addExtra(directive.value, "expressionValue", value);
  18226. return directive;
  18227. }
  18228. parseBlockBody(node, ...args) {
  18229. super.parseBlockBody(node, ...args);
  18230. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  18231. node.body = directiveStatements.concat(node.body);
  18232. delete node.directives;
  18233. }
  18234. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  18235. this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
  18236. if (method.typeParameters) {
  18237. method.value.typeParameters = method.typeParameters;
  18238. delete method.typeParameters;
  18239. }
  18240. classBody.body.push(method);
  18241. }
  18242. parseMaybePrivateName(...args) {
  18243. const node = super.parseMaybePrivateName(...args);
  18244. if (node.type === "PrivateName" && this.getPluginOption("estree", "classFeatures")) {
  18245. return this.convertPrivateNameToPrivateIdentifier(node);
  18246. }
  18247. return node;
  18248. }
  18249. convertPrivateNameToPrivateIdentifier(node) {
  18250. const name = super.getPrivateNameSV(node);
  18251. node = node;
  18252. delete node.id;
  18253. node.name = name;
  18254. node.type = "PrivateIdentifier";
  18255. return node;
  18256. }
  18257. isPrivateName(node) {
  18258. if (!this.getPluginOption("estree", "classFeatures")) {
  18259. return super.isPrivateName(node);
  18260. }
  18261. return node.type === "PrivateIdentifier";
  18262. }
  18263. getPrivateNameSV(node) {
  18264. if (!this.getPluginOption("estree", "classFeatures")) {
  18265. return super.getPrivateNameSV(node);
  18266. }
  18267. return node.name;
  18268. }
  18269. parseLiteral(value, type) {
  18270. const node = super.parseLiteral(value, type);
  18271. node.raw = node.extra.raw;
  18272. delete node.extra;
  18273. return node;
  18274. }
  18275. parseFunctionBody(node, allowExpression, isMethod = false) {
  18276. super.parseFunctionBody(node, allowExpression, isMethod);
  18277. node.expression = node.body.type !== "BlockStatement";
  18278. }
  18279. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  18280. let funcNode = this.startNode();
  18281. funcNode.kind = node.kind;
  18282. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  18283. funcNode.type = "FunctionExpression";
  18284. delete funcNode.kind;
  18285. node.value = funcNode;
  18286. if (type === "ClassPrivateMethod") {
  18287. node.computed = false;
  18288. }
  18289. type = "MethodDefinition";
  18290. return this.finishNode(node, type);
  18291. }
  18292. parseClassProperty(...args) {
  18293. const propertyNode = super.parseClassProperty(...args);
  18294. if (this.getPluginOption("estree", "classFeatures")) {
  18295. propertyNode.type = "PropertyDefinition";
  18296. }
  18297. return propertyNode;
  18298. }
  18299. parseClassPrivateProperty(...args) {
  18300. const propertyNode = super.parseClassPrivateProperty(...args);
  18301. if (this.getPluginOption("estree", "classFeatures")) {
  18302. propertyNode.type = "PropertyDefinition";
  18303. propertyNode.computed = false;
  18304. }
  18305. return propertyNode;
  18306. }
  18307. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  18308. const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
  18309. if (node) {
  18310. node.type = "Property";
  18311. if (node.kind === "method") node.kind = "init";
  18312. node.shorthand = false;
  18313. }
  18314. return node;
  18315. }
  18316. parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) {
  18317. const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors);
  18318. if (node) {
  18319. node.kind = "init";
  18320. node.type = "Property";
  18321. }
  18322. return node;
  18323. }
  18324. isAssignable(node, isBinding) {
  18325. if (node != null && this.isObjectProperty(node)) {
  18326. return this.isAssignable(node.value, isBinding);
  18327. }
  18328. return super.isAssignable(node, isBinding);
  18329. }
  18330. toAssignable(node, isLHS = false) {
  18331. if (node != null && this.isObjectProperty(node)) {
  18332. this.toAssignable(node.value, isLHS);
  18333. return node;
  18334. }
  18335. return super.toAssignable(node, isLHS);
  18336. }
  18337. toAssignableObjectExpressionProp(prop, ...args) {
  18338. if (prop.kind === "get" || prop.kind === "set") {
  18339. this.raise(prop.key.start, ErrorMessages.PatternHasAccessor);
  18340. } else if (prop.method) {
  18341. this.raise(prop.key.start, ErrorMessages.PatternHasMethod);
  18342. } else {
  18343. super.toAssignableObjectExpressionProp(prop, ...args);
  18344. }
  18345. }
  18346. finishCallExpression(node, optional) {
  18347. super.finishCallExpression(node, optional);
  18348. if (node.callee.type === "Import") {
  18349. node.type = "ImportExpression";
  18350. node.source = node.arguments[0];
  18351. if (this.hasPlugin("importAssertions")) {
  18352. var _node$arguments$;
  18353. node.attributes = (_node$arguments$ = node.arguments[1]) != null ? _node$arguments$ : null;
  18354. }
  18355. delete node.arguments;
  18356. delete node.callee;
  18357. }
  18358. return node;
  18359. }
  18360. toReferencedArguments(node) {
  18361. if (node.type === "ImportExpression") {
  18362. return;
  18363. }
  18364. super.toReferencedArguments(node);
  18365. }
  18366. parseExport(node) {
  18367. super.parseExport(node);
  18368. switch (node.type) {
  18369. case "ExportAllDeclaration":
  18370. node.exported = null;
  18371. break;
  18372. case "ExportNamedDeclaration":
  18373. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  18374. node.type = "ExportAllDeclaration";
  18375. node.exported = node.specifiers[0].exported;
  18376. delete node.specifiers;
  18377. }
  18378. break;
  18379. }
  18380. return node;
  18381. }
  18382. parseSubscript(base, startPos, startLoc, noCalls, state) {
  18383. const node = super.parseSubscript(base, startPos, startLoc, noCalls, state);
  18384. if (state.optionalChainMember) {
  18385. if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
  18386. node.type = node.type.substring(8);
  18387. }
  18388. if (state.stop) {
  18389. const chain = this.startNodeAtNode(node);
  18390. chain.expression = node;
  18391. return this.finishNode(chain, "ChainExpression");
  18392. }
  18393. } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
  18394. node.optional = false;
  18395. }
  18396. return node;
  18397. }
  18398. hasPropertyAsPrivateName(node) {
  18399. if (node.type === "ChainExpression") {
  18400. node = node.expression;
  18401. }
  18402. return super.hasPropertyAsPrivateName(node);
  18403. }
  18404. isOptionalChain(node) {
  18405. return node.type === "ChainExpression";
  18406. }
  18407. isObjectProperty(node) {
  18408. return node.type === "Property" && node.kind === "init" && !node.method;
  18409. }
  18410. isObjectMethod(node) {
  18411. return node.method || node.kind === "get" || node.kind === "set";
  18412. }
  18413. });
  18414. class TokContext {
  18415. constructor(token, preserveSpace) {
  18416. this.token = void 0;
  18417. this.preserveSpace = void 0;
  18418. this.token = token;
  18419. this.preserveSpace = !!preserveSpace;
  18420. }
  18421. }
  18422. const types = {
  18423. brace: new TokContext("{"),
  18424. template: new TokContext("`", true)
  18425. };
  18426. types$1.braceR.updateContext = context => {
  18427. context.pop();
  18428. };
  18429. types$1.braceL.updateContext = types$1.braceHashL.updateContext = types$1.dollarBraceL.updateContext = context => {
  18430. context.push(types.brace);
  18431. };
  18432. types$1.backQuote.updateContext = context => {
  18433. if (context[context.length - 1] === types.template) {
  18434. context.pop();
  18435. } else {
  18436. context.push(types.template);
  18437. }
  18438. };
  18439. let nonASCIIidentifierStartChars$1 = "\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\u08a0-\u08b4\u08b6-\u08c7\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\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\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-\u170c\u170e-\u1711\u1720-\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-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\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-\u2c2e\u2c30-\u2c5e\u2c60-\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-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\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";
  18440. let nonASCIIidentifierChars$1 = "\u200c\u200d\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\u08d3-\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\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\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-\u0ecd\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-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\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-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\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";
  18441. const nonASCIIidentifierStart$1 = new RegExp("[" + nonASCIIidentifierStartChars$1 + "]");
  18442. const nonASCIIidentifier$1 = new RegExp("[" + nonASCIIidentifierStartChars$1 + nonASCIIidentifierChars$1 + "]");
  18443. nonASCIIidentifierStartChars$1 = nonASCIIidentifierChars$1 = null;
  18444. const astralIdentifierStartCodes$1 = [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, 157, 310, 10, 21, 11, 7, 153, 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, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 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, 85, 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, 159, 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, 230, 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, 35, 56, 264, 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, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 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, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 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, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
  18445. const astralIdentifierCodes$1 = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 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, 406, 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, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 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, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  18446. function isInAstralSet$1(code, set) {
  18447. let pos = 0x10000;
  18448. for (let i = 0, length = set.length; i < length; i += 2) {
  18449. pos += set[i];
  18450. if (pos > code) return false;
  18451. pos += set[i + 1];
  18452. if (pos >= code) return true;
  18453. }
  18454. return false;
  18455. }
  18456. function isIdentifierStart$1(code) {
  18457. if (code < 65) return code === 36;
  18458. if (code <= 90) return true;
  18459. if (code < 97) return code === 95;
  18460. if (code <= 122) return true;
  18461. if (code <= 0xffff) {
  18462. return code >= 0xaa && nonASCIIidentifierStart$1.test(String.fromCharCode(code));
  18463. }
  18464. return isInAstralSet$1(code, astralIdentifierStartCodes$1);
  18465. }
  18466. function isIdentifierChar$1(code) {
  18467. if (code < 48) return code === 36;
  18468. if (code < 58) return true;
  18469. if (code < 65) return false;
  18470. if (code <= 90) return true;
  18471. if (code < 97) return code === 95;
  18472. if (code <= 122) return true;
  18473. if (code <= 0xffff) {
  18474. return code >= 0xaa && nonASCIIidentifier$1.test(String.fromCharCode(code));
  18475. }
  18476. return isInAstralSet$1(code, astralIdentifierStartCodes$1) || isInAstralSet$1(code, astralIdentifierCodes$1);
  18477. }
  18478. const reservedWords$1 = {
  18479. 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"],
  18480. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  18481. strictBind: ["eval", "arguments"]
  18482. };
  18483. const keywords$2 = new Set(reservedWords$1.keyword);
  18484. const reservedWordsStrictSet$1 = new Set(reservedWords$1.strict);
  18485. const reservedWordsStrictBindSet$1 = new Set(reservedWords$1.strictBind);
  18486. function isReservedWord$1(word, inModule) {
  18487. return inModule && word === "await" || word === "enum";
  18488. }
  18489. function isStrictReservedWord$1(word, inModule) {
  18490. return isReservedWord$1(word, inModule) || reservedWordsStrictSet$1.has(word);
  18491. }
  18492. function isStrictBindOnlyReservedWord$1(word) {
  18493. return reservedWordsStrictBindSet$1.has(word);
  18494. }
  18495. function isStrictBindReservedWord$1(word, inModule) {
  18496. return isStrictReservedWord$1(word, inModule) || isStrictBindOnlyReservedWord$1(word);
  18497. }
  18498. function isKeyword$1(word) {
  18499. return keywords$2.has(word);
  18500. }
  18501. function isIteratorStart(current, next) {
  18502. return current === 64 && next === 64;
  18503. }
  18504. 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"]);
  18505. function canBeReservedWord(word) {
  18506. return reservedWordLikeSet.has(word);
  18507. }
  18508. const SCOPE_OTHER = 0b000000000,
  18509. SCOPE_PROGRAM = 0b000000001,
  18510. SCOPE_FUNCTION = 0b000000010,
  18511. SCOPE_ARROW = 0b000000100,
  18512. SCOPE_SIMPLE_CATCH = 0b000001000,
  18513. SCOPE_SUPER = 0b000010000,
  18514. SCOPE_DIRECT_SUPER = 0b000100000,
  18515. SCOPE_CLASS = 0b001000000,
  18516. SCOPE_STATIC_BLOCK = 0b010000000,
  18517. SCOPE_TS_MODULE = 0b100000000,
  18518. SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;
  18519. const BIND_KIND_VALUE = 0b000000000001,
  18520. BIND_KIND_TYPE = 0b000000000010,
  18521. BIND_SCOPE_VAR = 0b000000000100,
  18522. BIND_SCOPE_LEXICAL = 0b000000001000,
  18523. BIND_SCOPE_FUNCTION = 0b000000010000,
  18524. BIND_FLAGS_NONE = 0b000001000000,
  18525. BIND_FLAGS_CLASS = 0b000010000000,
  18526. BIND_FLAGS_TS_ENUM = 0b000100000000,
  18527. BIND_FLAGS_TS_CONST_ENUM = 0b001000000000,
  18528. BIND_FLAGS_TS_EXPORT_ONLY = 0b010000000000,
  18529. BIND_FLAGS_FLOW_DECLARE_FN = 0b100000000000;
  18530. const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS,
  18531. BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0,
  18532. BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0,
  18533. BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0,
  18534. BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS,
  18535. BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0,
  18536. BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,
  18537. BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
  18538. BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE,
  18539. BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE,
  18540. BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,
  18541. BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
  18542. BIND_FLOW_DECLARE_FN = BIND_FLAGS_FLOW_DECLARE_FN;
  18543. const CLASS_ELEMENT_FLAG_STATIC = 0b100,
  18544. CLASS_ELEMENT_KIND_GETTER = 0b010,
  18545. CLASS_ELEMENT_KIND_SETTER = 0b001,
  18546. CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;
  18547. const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,
  18548. CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,
  18549. CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,
  18550. CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,
  18551. CLASS_ELEMENT_OTHER = 0;
  18552. class Scope {
  18553. constructor(flags) {
  18554. this.var = new Set();
  18555. this.lexical = new Set();
  18556. this.functions = new Set();
  18557. this.flags = flags;
  18558. }
  18559. }
  18560. class ScopeHandler {
  18561. constructor(raise, inModule) {
  18562. this.scopeStack = [];
  18563. this.undefinedExports = new Map();
  18564. this.undefinedPrivateNames = new Map();
  18565. this.raise = raise;
  18566. this.inModule = inModule;
  18567. }
  18568. get inFunction() {
  18569. return (this.currentVarScopeFlags() & SCOPE_FUNCTION) > 0;
  18570. }
  18571. get allowSuper() {
  18572. return (this.currentThisScopeFlags() & SCOPE_SUPER) > 0;
  18573. }
  18574. get allowDirectSuper() {
  18575. return (this.currentThisScopeFlags() & SCOPE_DIRECT_SUPER) > 0;
  18576. }
  18577. get inClass() {
  18578. return (this.currentThisScopeFlags() & SCOPE_CLASS) > 0;
  18579. }
  18580. get inClassAndNotInNonArrowFunction() {
  18581. const flags = this.currentThisScopeFlags();
  18582. return (flags & SCOPE_CLASS) > 0 && (flags & SCOPE_FUNCTION) === 0;
  18583. }
  18584. get inStaticBlock() {
  18585. for (let i = this.scopeStack.length - 1;; i--) {
  18586. const {
  18587. flags
  18588. } = this.scopeStack[i];
  18589. if (flags & SCOPE_STATIC_BLOCK) {
  18590. return true;
  18591. }
  18592. if (flags & (SCOPE_VAR | SCOPE_CLASS)) {
  18593. return false;
  18594. }
  18595. }
  18596. }
  18597. get inNonArrowFunction() {
  18598. return (this.currentThisScopeFlags() & SCOPE_FUNCTION) > 0;
  18599. }
  18600. get treatFunctionsAsVar() {
  18601. return this.treatFunctionsAsVarInScope(this.currentScope());
  18602. }
  18603. createScope(flags) {
  18604. return new Scope(flags);
  18605. }
  18606. enter(flags) {
  18607. this.scopeStack.push(this.createScope(flags));
  18608. }
  18609. exit() {
  18610. this.scopeStack.pop();
  18611. }
  18612. treatFunctionsAsVarInScope(scope) {
  18613. return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
  18614. }
  18615. declareName(name, bindingType, pos) {
  18616. let scope = this.currentScope();
  18617. if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
  18618. this.checkRedeclarationInScope(scope, name, bindingType, pos);
  18619. if (bindingType & BIND_SCOPE_FUNCTION) {
  18620. scope.functions.add(name);
  18621. } else {
  18622. scope.lexical.add(name);
  18623. }
  18624. if (bindingType & BIND_SCOPE_LEXICAL) {
  18625. this.maybeExportDefined(scope, name);
  18626. }
  18627. } else if (bindingType & BIND_SCOPE_VAR) {
  18628. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  18629. scope = this.scopeStack[i];
  18630. this.checkRedeclarationInScope(scope, name, bindingType, pos);
  18631. scope.var.add(name);
  18632. this.maybeExportDefined(scope, name);
  18633. if (scope.flags & SCOPE_VAR) break;
  18634. }
  18635. }
  18636. if (this.inModule && scope.flags & SCOPE_PROGRAM) {
  18637. this.undefinedExports.delete(name);
  18638. }
  18639. }
  18640. maybeExportDefined(scope, name) {
  18641. if (this.inModule && scope.flags & SCOPE_PROGRAM) {
  18642. this.undefinedExports.delete(name);
  18643. }
  18644. }
  18645. checkRedeclarationInScope(scope, name, bindingType, pos) {
  18646. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  18647. this.raise(pos, ErrorMessages.VarRedeclaration, name);
  18648. }
  18649. }
  18650. isRedeclaredInScope(scope, name, bindingType) {
  18651. if (!(bindingType & BIND_KIND_VALUE)) return false;
  18652. if (bindingType & BIND_SCOPE_LEXICAL) {
  18653. return scope.lexical.has(name) || scope.functions.has(name) || scope.var.has(name);
  18654. }
  18655. if (bindingType & BIND_SCOPE_FUNCTION) {
  18656. return scope.lexical.has(name) || !this.treatFunctionsAsVarInScope(scope) && scope.var.has(name);
  18657. }
  18658. return scope.lexical.has(name) && !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical.values().next().value === name) || !this.treatFunctionsAsVarInScope(scope) && scope.functions.has(name);
  18659. }
  18660. checkLocalExport(id) {
  18661. const {
  18662. name
  18663. } = id;
  18664. const topLevelScope = this.scopeStack[0];
  18665. if (!topLevelScope.lexical.has(name) && !topLevelScope.var.has(name) && !topLevelScope.functions.has(name)) {
  18666. this.undefinedExports.set(name, id.start);
  18667. }
  18668. }
  18669. currentScope() {
  18670. return this.scopeStack[this.scopeStack.length - 1];
  18671. }
  18672. currentVarScopeFlags() {
  18673. for (let i = this.scopeStack.length - 1;; i--) {
  18674. const {
  18675. flags
  18676. } = this.scopeStack[i];
  18677. if (flags & SCOPE_VAR) {
  18678. return flags;
  18679. }
  18680. }
  18681. }
  18682. currentThisScopeFlags() {
  18683. for (let i = this.scopeStack.length - 1;; i--) {
  18684. const {
  18685. flags
  18686. } = this.scopeStack[i];
  18687. if (flags & (SCOPE_VAR | SCOPE_CLASS) && !(flags & SCOPE_ARROW)) {
  18688. return flags;
  18689. }
  18690. }
  18691. }
  18692. }
  18693. class FlowScope extends Scope {
  18694. constructor(...args) {
  18695. super(...args);
  18696. this.declareFunctions = new Set();
  18697. }
  18698. }
  18699. class FlowScopeHandler extends ScopeHandler {
  18700. createScope(flags) {
  18701. return new FlowScope(flags);
  18702. }
  18703. declareName(name, bindingType, pos) {
  18704. const scope = this.currentScope();
  18705. if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
  18706. this.checkRedeclarationInScope(scope, name, bindingType, pos);
  18707. this.maybeExportDefined(scope, name);
  18708. scope.declareFunctions.add(name);
  18709. return;
  18710. }
  18711. super.declareName(...arguments);
  18712. }
  18713. isRedeclaredInScope(scope, name, bindingType) {
  18714. if (super.isRedeclaredInScope(...arguments)) return true;
  18715. if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
  18716. return !scope.declareFunctions.has(name) && (scope.lexical.has(name) || scope.functions.has(name));
  18717. }
  18718. return false;
  18719. }
  18720. checkLocalExport(id) {
  18721. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  18722. super.checkLocalExport(id);
  18723. }
  18724. }
  18725. }
  18726. class State {
  18727. constructor() {
  18728. this.strict = void 0;
  18729. this.curLine = void 0;
  18730. this.startLoc = void 0;
  18731. this.endLoc = void 0;
  18732. this.errors = [];
  18733. this.potentialArrowAt = -1;
  18734. this.noArrowAt = [];
  18735. this.noArrowParamsConversionAt = [];
  18736. this.maybeInArrowParameters = false;
  18737. this.inType = false;
  18738. this.noAnonFunctionType = false;
  18739. this.inPropertyName = false;
  18740. this.hasFlowComment = false;
  18741. this.isAmbientContext = false;
  18742. this.inAbstractClass = false;
  18743. this.topicContext = {
  18744. maxNumOfResolvableTopics: 0,
  18745. maxTopicIndex: null
  18746. };
  18747. this.soloAwait = false;
  18748. this.inFSharpPipelineDirectBody = false;
  18749. this.labels = [];
  18750. this.decoratorStack = [[]];
  18751. this.comments = [];
  18752. this.commentStack = [];
  18753. this.pos = 0;
  18754. this.lineStart = 0;
  18755. this.type = types$1.eof;
  18756. this.value = null;
  18757. this.start = 0;
  18758. this.end = 0;
  18759. this.lastTokEndLoc = null;
  18760. this.lastTokStartLoc = null;
  18761. this.lastTokStart = 0;
  18762. this.lastTokEnd = 0;
  18763. this.context = [types.brace];
  18764. this.exprAllowed = true;
  18765. this.containsEsc = false;
  18766. this.strictErrors = new Map();
  18767. this.tokensLength = 0;
  18768. }
  18769. init(options) {
  18770. this.strict = options.strictMode === false ? false : options.strictMode === true ? true : options.sourceType === "module";
  18771. this.curLine = options.startLine;
  18772. this.startLoc = this.endLoc = this.curPosition();
  18773. }
  18774. curPosition() {
  18775. return new Position(this.curLine, this.pos - this.lineStart);
  18776. }
  18777. clone(skipArrays) {
  18778. const state = new State();
  18779. const keys = Object.keys(this);
  18780. for (let i = 0, length = keys.length; i < length; i++) {
  18781. const key = keys[i];
  18782. let val = this[key];
  18783. if (!skipArrays && Array.isArray(val)) {
  18784. val = val.slice();
  18785. }
  18786. state[key] = val;
  18787. }
  18788. return state;
  18789. }
  18790. }
  18791. var _isDigit = function isDigit(code) {
  18792. return code >= 48 && code <= 57;
  18793. };
  18794. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100]);
  18795. const forbiddenNumericSeparatorSiblings = {
  18796. decBinOct: [46, 66, 69, 79, 95, 98, 101, 111],
  18797. hex: [46, 88, 95, 120]
  18798. };
  18799. const allowedNumericSeparatorSiblings = {};
  18800. allowedNumericSeparatorSiblings.bin = [48, 49];
  18801. allowedNumericSeparatorSiblings.oct = [...allowedNumericSeparatorSiblings.bin, 50, 51, 52, 53, 54, 55];
  18802. allowedNumericSeparatorSiblings.dec = [...allowedNumericSeparatorSiblings.oct, 56, 57];
  18803. allowedNumericSeparatorSiblings.hex = [...allowedNumericSeparatorSiblings.dec, 65, 66, 67, 68, 69, 70, 97, 98, 99, 100, 101, 102];
  18804. class Token {
  18805. constructor(state) {
  18806. this.type = state.type;
  18807. this.value = state.value;
  18808. this.start = state.start;
  18809. this.end = state.end;
  18810. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  18811. }
  18812. }
  18813. class Tokenizer extends ParserError {
  18814. constructor(options, input) {
  18815. super();
  18816. this.isLookahead = void 0;
  18817. this.tokens = [];
  18818. this.state = new State();
  18819. this.state.init(options);
  18820. this.input = input;
  18821. this.length = input.length;
  18822. this.isLookahead = false;
  18823. }
  18824. pushToken(token) {
  18825. this.tokens.length = this.state.tokensLength;
  18826. this.tokens.push(token);
  18827. ++this.state.tokensLength;
  18828. }
  18829. next() {
  18830. this.checkKeywordEscapes();
  18831. if (this.options.tokens) {
  18832. this.pushToken(new Token(this.state));
  18833. }
  18834. this.state.lastTokEnd = this.state.end;
  18835. this.state.lastTokStart = this.state.start;
  18836. this.state.lastTokEndLoc = this.state.endLoc;
  18837. this.state.lastTokStartLoc = this.state.startLoc;
  18838. this.nextToken();
  18839. }
  18840. eat(type) {
  18841. if (this.match(type)) {
  18842. this.next();
  18843. return true;
  18844. } else {
  18845. return false;
  18846. }
  18847. }
  18848. match(type) {
  18849. return this.state.type === type;
  18850. }
  18851. createLookaheadState(state) {
  18852. return {
  18853. pos: state.pos,
  18854. value: null,
  18855. type: state.type,
  18856. start: state.start,
  18857. end: state.end,
  18858. lastTokEnd: state.end,
  18859. context: [this.curContext()],
  18860. inType: state.inType
  18861. };
  18862. }
  18863. lookahead() {
  18864. const old = this.state;
  18865. this.state = this.createLookaheadState(old);
  18866. this.isLookahead = true;
  18867. this.nextToken();
  18868. this.isLookahead = false;
  18869. const curr = this.state;
  18870. this.state = old;
  18871. return curr;
  18872. }
  18873. nextTokenStart() {
  18874. return this.nextTokenStartSince(this.state.pos);
  18875. }
  18876. nextTokenStartSince(pos) {
  18877. skipWhiteSpace.lastIndex = pos;
  18878. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  18879. }
  18880. lookaheadCharCode() {
  18881. return this.input.charCodeAt(this.nextTokenStart());
  18882. }
  18883. codePointAtPos(pos) {
  18884. let cp = this.input.charCodeAt(pos);
  18885. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  18886. const trail = this.input.charCodeAt(pos);
  18887. if ((trail & 0xfc00) === 0xdc00) {
  18888. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  18889. }
  18890. }
  18891. return cp;
  18892. }
  18893. setStrict(strict) {
  18894. this.state.strict = strict;
  18895. if (strict) {
  18896. this.state.strictErrors.forEach((message, pos) => this.raise(pos, message));
  18897. this.state.strictErrors.clear();
  18898. }
  18899. }
  18900. curContext() {
  18901. return this.state.context[this.state.context.length - 1];
  18902. }
  18903. nextToken() {
  18904. const curContext = this.curContext();
  18905. if (!curContext.preserveSpace) this.skipSpace();
  18906. this.state.start = this.state.pos;
  18907. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  18908. if (this.state.pos >= this.length) {
  18909. this.finishToken(types$1.eof);
  18910. return;
  18911. }
  18912. if (curContext === types.template) {
  18913. this.readTmplToken();
  18914. } else {
  18915. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  18916. }
  18917. }
  18918. skipBlockComment() {
  18919. let startLoc;
  18920. if (!this.isLookahead) startLoc = this.state.curPosition();
  18921. const start = this.state.pos;
  18922. const end = this.input.indexOf("*/", start + 2);
  18923. if (end === -1) throw this.raise(start, ErrorMessages.UnterminatedComment);
  18924. this.state.pos = end + 2;
  18925. lineBreakG.lastIndex = start + 2;
  18926. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  18927. ++this.state.curLine;
  18928. this.state.lineStart = lineBreakG.lastIndex;
  18929. }
  18930. if (this.isLookahead) return;
  18931. const comment = {
  18932. type: "CommentBlock",
  18933. value: this.input.slice(start + 2, end),
  18934. start,
  18935. end: end + 2,
  18936. loc: new SourceLocation(startLoc, this.state.curPosition())
  18937. };
  18938. if (this.options.tokens) this.pushToken(comment);
  18939. return comment;
  18940. }
  18941. skipLineComment(startSkip) {
  18942. const start = this.state.pos;
  18943. let startLoc;
  18944. if (!this.isLookahead) startLoc = this.state.curPosition();
  18945. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  18946. if (this.state.pos < this.length) {
  18947. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  18948. ch = this.input.charCodeAt(this.state.pos);
  18949. }
  18950. }
  18951. if (this.isLookahead) return;
  18952. const end = this.state.pos;
  18953. const value = this.input.slice(start + startSkip, end);
  18954. const comment = {
  18955. type: "CommentLine",
  18956. value,
  18957. start,
  18958. end,
  18959. loc: new SourceLocation(startLoc, this.state.curPosition())
  18960. };
  18961. if (this.options.tokens) this.pushToken(comment);
  18962. return comment;
  18963. }
  18964. skipSpace() {
  18965. const spaceStart = this.state.pos;
  18966. const comments = [];
  18967. loop: while (this.state.pos < this.length) {
  18968. const ch = this.input.charCodeAt(this.state.pos);
  18969. switch (ch) {
  18970. case 32:
  18971. case 160:
  18972. case 9:
  18973. ++this.state.pos;
  18974. break;
  18975. case 13:
  18976. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  18977. ++this.state.pos;
  18978. }
  18979. case 10:
  18980. case 8232:
  18981. case 8233:
  18982. ++this.state.pos;
  18983. ++this.state.curLine;
  18984. this.state.lineStart = this.state.pos;
  18985. break;
  18986. case 47:
  18987. switch (this.input.charCodeAt(this.state.pos + 1)) {
  18988. case 42:
  18989. {
  18990. const comment = this.skipBlockComment();
  18991. if (comment !== undefined) {
  18992. this.addComment(comment);
  18993. if (this.options.attachComment) comments.push(comment);
  18994. }
  18995. break;
  18996. }
  18997. case 47:
  18998. {
  18999. const comment = this.skipLineComment(2);
  19000. if (comment !== undefined) {
  19001. this.addComment(comment);
  19002. if (this.options.attachComment) comments.push(comment);
  19003. }
  19004. break;
  19005. }
  19006. default:
  19007. break loop;
  19008. }
  19009. break;
  19010. default:
  19011. if (isWhitespace(ch)) {
  19012. ++this.state.pos;
  19013. } else if (ch === 45 && !this.inModule) {
  19014. const pos = this.state.pos;
  19015. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  19016. const comment = this.skipLineComment(3);
  19017. if (comment !== undefined) {
  19018. this.addComment(comment);
  19019. if (this.options.attachComment) comments.push(comment);
  19020. }
  19021. } else {
  19022. break loop;
  19023. }
  19024. } else if (ch === 60 && !this.inModule) {
  19025. const pos = this.state.pos;
  19026. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  19027. const comment = this.skipLineComment(4);
  19028. if (comment !== undefined) {
  19029. this.addComment(comment);
  19030. if (this.options.attachComment) comments.push(comment);
  19031. }
  19032. } else {
  19033. break loop;
  19034. }
  19035. } else {
  19036. break loop;
  19037. }
  19038. }
  19039. }
  19040. if (comments.length > 0) {
  19041. const end = this.state.pos;
  19042. const CommentWhitespace = {
  19043. start: spaceStart,
  19044. end,
  19045. comments,
  19046. leadingNode: null,
  19047. trailingNode: null,
  19048. containingNode: null
  19049. };
  19050. this.state.commentStack.push(CommentWhitespace);
  19051. }
  19052. }
  19053. finishToken(type, val) {
  19054. this.state.end = this.state.pos;
  19055. const prevType = this.state.type;
  19056. this.state.type = type;
  19057. this.state.value = val;
  19058. if (!this.isLookahead) {
  19059. this.state.endLoc = this.state.curPosition();
  19060. this.updateContext(prevType);
  19061. }
  19062. }
  19063. readToken_numberSign() {
  19064. if (this.state.pos === 0 && this.readToken_interpreter()) {
  19065. return;
  19066. }
  19067. const nextPos = this.state.pos + 1;
  19068. const next = this.codePointAtPos(nextPos);
  19069. if (next >= 48 && next <= 57) {
  19070. throw this.raise(this.state.pos, ErrorMessages.UnexpectedDigitAfterHash);
  19071. }
  19072. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  19073. this.expectPlugin("recordAndTuple");
  19074. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
  19075. throw this.raise(this.state.pos, next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType);
  19076. }
  19077. this.state.pos += 2;
  19078. if (next === 123) {
  19079. this.finishToken(types$1.braceHashL);
  19080. } else {
  19081. this.finishToken(types$1.bracketHashL);
  19082. }
  19083. } else if (isIdentifierStart$1(next)) {
  19084. ++this.state.pos;
  19085. this.finishToken(types$1.privateName, this.readWord1(next));
  19086. } else if (next === 92) {
  19087. ++this.state.pos;
  19088. this.finishToken(types$1.privateName, this.readWord1());
  19089. } else {
  19090. this.finishOp(types$1.hash, 1);
  19091. }
  19092. }
  19093. readToken_dot() {
  19094. const next = this.input.charCodeAt(this.state.pos + 1);
  19095. if (next >= 48 && next <= 57) {
  19096. this.readNumber(true);
  19097. return;
  19098. }
  19099. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  19100. this.state.pos += 3;
  19101. this.finishToken(types$1.ellipsis);
  19102. } else {
  19103. ++this.state.pos;
  19104. this.finishToken(types$1.dot);
  19105. }
  19106. }
  19107. readToken_slash() {
  19108. const next = this.input.charCodeAt(this.state.pos + 1);
  19109. if (next === 61) {
  19110. this.finishOp(types$1.slashAssign, 2);
  19111. } else {
  19112. this.finishOp(types$1.slash, 1);
  19113. }
  19114. }
  19115. readToken_interpreter() {
  19116. if (this.state.pos !== 0 || this.length < 2) return false;
  19117. let ch = this.input.charCodeAt(this.state.pos + 1);
  19118. if (ch !== 33) return false;
  19119. const start = this.state.pos;
  19120. this.state.pos += 1;
  19121. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  19122. ch = this.input.charCodeAt(this.state.pos);
  19123. }
  19124. const value = this.input.slice(start + 2, this.state.pos);
  19125. this.finishToken(types$1.interpreterDirective, value);
  19126. return true;
  19127. }
  19128. readToken_mult_modulo(code) {
  19129. let type = code === 42 ? types$1.star : types$1.modulo;
  19130. let width = 1;
  19131. let next = this.input.charCodeAt(this.state.pos + 1);
  19132. if (code === 42 && next === 42) {
  19133. width++;
  19134. next = this.input.charCodeAt(this.state.pos + 2);
  19135. type = types$1.exponent;
  19136. }
  19137. if (next === 61 && !this.state.inType) {
  19138. width++;
  19139. type = code === 37 ? types$1.moduloAssign : types$1.assign;
  19140. }
  19141. this.finishOp(type, width);
  19142. }
  19143. readToken_pipe_amp(code) {
  19144. const next = this.input.charCodeAt(this.state.pos + 1);
  19145. if (next === code) {
  19146. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  19147. this.finishOp(types$1.assign, 3);
  19148. } else {
  19149. this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2);
  19150. }
  19151. return;
  19152. }
  19153. if (code === 124) {
  19154. if (next === 62) {
  19155. this.finishOp(types$1.pipeline, 2);
  19156. return;
  19157. }
  19158. if (this.hasPlugin("recordAndTuple") && next === 125) {
  19159. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  19160. throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType);
  19161. }
  19162. this.state.pos += 2;
  19163. this.finishToken(types$1.braceBarR);
  19164. return;
  19165. }
  19166. if (this.hasPlugin("recordAndTuple") && next === 93) {
  19167. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  19168. throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType);
  19169. }
  19170. this.state.pos += 2;
  19171. this.finishToken(types$1.bracketBarR);
  19172. return;
  19173. }
  19174. }
  19175. if (next === 61) {
  19176. this.finishOp(types$1.assign, 2);
  19177. return;
  19178. }
  19179. this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1);
  19180. }
  19181. readToken_caret() {
  19182. const next = this.input.charCodeAt(this.state.pos + 1);
  19183. if (next === 61) {
  19184. this.finishOp(types$1.assign, 2);
  19185. } else {
  19186. this.finishOp(types$1.bitwiseXOR, 1);
  19187. }
  19188. }
  19189. readToken_plus_min(code) {
  19190. const next = this.input.charCodeAt(this.state.pos + 1);
  19191. if (next === code) {
  19192. this.finishOp(types$1.incDec, 2);
  19193. return;
  19194. }
  19195. if (next === 61) {
  19196. this.finishOp(types$1.assign, 2);
  19197. } else {
  19198. this.finishOp(types$1.plusMin, 1);
  19199. }
  19200. }
  19201. readToken_lt_gt(code) {
  19202. const next = this.input.charCodeAt(this.state.pos + 1);
  19203. let size = 1;
  19204. if (next === code) {
  19205. size = code === 62 && this.input.charCodeAt(this.state.pos + 2) === 62 ? 3 : 2;
  19206. if (this.input.charCodeAt(this.state.pos + size) === 61) {
  19207. this.finishOp(types$1.assign, size + 1);
  19208. return;
  19209. }
  19210. this.finishOp(types$1.bitShift, size);
  19211. return;
  19212. }
  19213. if (next === 61) {
  19214. size = 2;
  19215. }
  19216. this.finishOp(types$1.relational, size);
  19217. }
  19218. readToken_eq_excl(code) {
  19219. const next = this.input.charCodeAt(this.state.pos + 1);
  19220. if (next === 61) {
  19221. this.finishOp(types$1.equality, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  19222. return;
  19223. }
  19224. if (code === 61 && next === 62) {
  19225. this.state.pos += 2;
  19226. this.finishToken(types$1.arrow);
  19227. return;
  19228. }
  19229. this.finishOp(code === 61 ? types$1.eq : types$1.bang, 1);
  19230. }
  19231. readToken_question() {
  19232. const next = this.input.charCodeAt(this.state.pos + 1);
  19233. const next2 = this.input.charCodeAt(this.state.pos + 2);
  19234. if (next === 63) {
  19235. if (next2 === 61) {
  19236. this.finishOp(types$1.assign, 3);
  19237. } else {
  19238. this.finishOp(types$1.nullishCoalescing, 2);
  19239. }
  19240. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  19241. this.state.pos += 2;
  19242. this.finishToken(types$1.questionDot);
  19243. } else {
  19244. ++this.state.pos;
  19245. this.finishToken(types$1.question);
  19246. }
  19247. }
  19248. getTokenFromCode(code) {
  19249. switch (code) {
  19250. case 46:
  19251. this.readToken_dot();
  19252. return;
  19253. case 40:
  19254. ++this.state.pos;
  19255. this.finishToken(types$1.parenL);
  19256. return;
  19257. case 41:
  19258. ++this.state.pos;
  19259. this.finishToken(types$1.parenR);
  19260. return;
  19261. case 59:
  19262. ++this.state.pos;
  19263. this.finishToken(types$1.semi);
  19264. return;
  19265. case 44:
  19266. ++this.state.pos;
  19267. this.finishToken(types$1.comma);
  19268. return;
  19269. case 91:
  19270. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  19271. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  19272. throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType);
  19273. }
  19274. this.state.pos += 2;
  19275. this.finishToken(types$1.bracketBarL);
  19276. } else {
  19277. ++this.state.pos;
  19278. this.finishToken(types$1.bracketL);
  19279. }
  19280. return;
  19281. case 93:
  19282. ++this.state.pos;
  19283. this.finishToken(types$1.bracketR);
  19284. return;
  19285. case 123:
  19286. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  19287. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  19288. throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType);
  19289. }
  19290. this.state.pos += 2;
  19291. this.finishToken(types$1.braceBarL);
  19292. } else {
  19293. ++this.state.pos;
  19294. this.finishToken(types$1.braceL);
  19295. }
  19296. return;
  19297. case 125:
  19298. ++this.state.pos;
  19299. this.finishToken(types$1.braceR);
  19300. return;
  19301. case 58:
  19302. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  19303. this.finishOp(types$1.doubleColon, 2);
  19304. } else {
  19305. ++this.state.pos;
  19306. this.finishToken(types$1.colon);
  19307. }
  19308. return;
  19309. case 63:
  19310. this.readToken_question();
  19311. return;
  19312. case 96:
  19313. ++this.state.pos;
  19314. this.finishToken(types$1.backQuote);
  19315. return;
  19316. case 48:
  19317. {
  19318. const next = this.input.charCodeAt(this.state.pos + 1);
  19319. if (next === 120 || next === 88) {
  19320. this.readRadixNumber(16);
  19321. return;
  19322. }
  19323. if (next === 111 || next === 79) {
  19324. this.readRadixNumber(8);
  19325. return;
  19326. }
  19327. if (next === 98 || next === 66) {
  19328. this.readRadixNumber(2);
  19329. return;
  19330. }
  19331. }
  19332. case 49:
  19333. case 50:
  19334. case 51:
  19335. case 52:
  19336. case 53:
  19337. case 54:
  19338. case 55:
  19339. case 56:
  19340. case 57:
  19341. this.readNumber(false);
  19342. return;
  19343. case 34:
  19344. case 39:
  19345. this.readString(code);
  19346. return;
  19347. case 47:
  19348. this.readToken_slash();
  19349. return;
  19350. case 37:
  19351. case 42:
  19352. this.readToken_mult_modulo(code);
  19353. return;
  19354. case 124:
  19355. case 38:
  19356. this.readToken_pipe_amp(code);
  19357. return;
  19358. case 94:
  19359. this.readToken_caret();
  19360. return;
  19361. case 43:
  19362. case 45:
  19363. this.readToken_plus_min(code);
  19364. return;
  19365. case 60:
  19366. case 62:
  19367. this.readToken_lt_gt(code);
  19368. return;
  19369. case 61:
  19370. case 33:
  19371. this.readToken_eq_excl(code);
  19372. return;
  19373. case 126:
  19374. this.finishOp(types$1.tilde, 1);
  19375. return;
  19376. case 64:
  19377. ++this.state.pos;
  19378. this.finishToken(types$1.at);
  19379. return;
  19380. case 35:
  19381. this.readToken_numberSign();
  19382. return;
  19383. case 92:
  19384. this.readWord();
  19385. return;
  19386. default:
  19387. if (isIdentifierStart$1(code)) {
  19388. this.readWord(code);
  19389. return;
  19390. }
  19391. }
  19392. throw this.raise(this.state.pos, ErrorMessages.InvalidOrUnexpectedToken, String.fromCodePoint(code));
  19393. }
  19394. finishOp(type, size) {
  19395. const str = this.input.slice(this.state.pos, this.state.pos + size);
  19396. this.state.pos += size;
  19397. this.finishToken(type, str);
  19398. }
  19399. readRegexp() {
  19400. const start = this.state.start + 1;
  19401. let escaped, inClass;
  19402. let {
  19403. pos
  19404. } = this.state;
  19405. for (;; ++pos) {
  19406. if (pos >= this.length) {
  19407. throw this.raise(start, ErrorMessages.UnterminatedRegExp);
  19408. }
  19409. const ch = this.input.charCodeAt(pos);
  19410. if (isNewLine(ch)) {
  19411. throw this.raise(start, ErrorMessages.UnterminatedRegExp);
  19412. }
  19413. if (escaped) {
  19414. escaped = false;
  19415. } else {
  19416. if (ch === 91) {
  19417. inClass = true;
  19418. } else if (ch === 93 && inClass) {
  19419. inClass = false;
  19420. } else if (ch === 47 && !inClass) {
  19421. break;
  19422. }
  19423. escaped = ch === 92;
  19424. }
  19425. }
  19426. const content = this.input.slice(start, pos);
  19427. ++pos;
  19428. let mods = "";
  19429. while (pos < this.length) {
  19430. const cp = this.codePointAtPos(pos);
  19431. const char = String.fromCharCode(cp);
  19432. if (VALID_REGEX_FLAGS.has(cp)) {
  19433. if (mods.includes(char)) {
  19434. this.raise(pos + 1, ErrorMessages.DuplicateRegExpFlags);
  19435. }
  19436. } else if (isIdentifierChar$1(cp) || cp === 92) {
  19437. this.raise(pos + 1, ErrorMessages.MalformedRegExpFlags);
  19438. } else {
  19439. break;
  19440. }
  19441. ++pos;
  19442. mods += char;
  19443. }
  19444. this.state.pos = pos;
  19445. this.finishToken(types$1.regexp, {
  19446. pattern: content,
  19447. flags: mods
  19448. });
  19449. }
  19450. readInt(radix, len, forceLen, allowNumSeparator = true) {
  19451. const start = this.state.pos;
  19452. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  19453. const allowedSiblings = radix === 16 ? allowedNumericSeparatorSiblings.hex : radix === 10 ? allowedNumericSeparatorSiblings.dec : radix === 8 ? allowedNumericSeparatorSiblings.oct : allowedNumericSeparatorSiblings.bin;
  19454. let invalid = false;
  19455. let total = 0;
  19456. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  19457. const code = this.input.charCodeAt(this.state.pos);
  19458. let val;
  19459. if (code === 95) {
  19460. const prev = this.input.charCodeAt(this.state.pos - 1);
  19461. const next = this.input.charCodeAt(this.state.pos + 1);
  19462. if (allowedSiblings.indexOf(next) === -1) {
  19463. this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
  19464. } else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
  19465. this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
  19466. }
  19467. if (!allowNumSeparator) {
  19468. this.raise(this.state.pos, ErrorMessages.NumericSeparatorInEscapeSequence);
  19469. }
  19470. ++this.state.pos;
  19471. continue;
  19472. }
  19473. if (code >= 97) {
  19474. val = code - 97 + 10;
  19475. } else if (code >= 65) {
  19476. val = code - 65 + 10;
  19477. } else if (_isDigit(code)) {
  19478. val = code - 48;
  19479. } else {
  19480. val = Infinity;
  19481. }
  19482. if (val >= radix) {
  19483. if (this.options.errorRecovery && val <= 9) {
  19484. val = 0;
  19485. this.raise(this.state.start + i + 2, ErrorMessages.InvalidDigit, radix);
  19486. } else if (forceLen) {
  19487. val = 0;
  19488. invalid = true;
  19489. } else {
  19490. break;
  19491. }
  19492. }
  19493. ++this.state.pos;
  19494. total = total * radix + val;
  19495. }
  19496. if (this.state.pos === start || len != null && this.state.pos - start !== len || invalid) {
  19497. return null;
  19498. }
  19499. return total;
  19500. }
  19501. readRadixNumber(radix) {
  19502. const start = this.state.pos;
  19503. let isBigInt = false;
  19504. this.state.pos += 2;
  19505. const val = this.readInt(radix);
  19506. if (val == null) {
  19507. this.raise(this.state.start + 2, ErrorMessages.InvalidDigit, radix);
  19508. }
  19509. const next = this.input.charCodeAt(this.state.pos);
  19510. if (next === 110) {
  19511. ++this.state.pos;
  19512. isBigInt = true;
  19513. } else if (next === 109) {
  19514. throw this.raise(start, ErrorMessages.InvalidDecimal);
  19515. }
  19516. if (isIdentifierStart$1(this.codePointAtPos(this.state.pos))) {
  19517. throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
  19518. }
  19519. if (isBigInt) {
  19520. const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
  19521. this.finishToken(types$1.bigint, str);
  19522. return;
  19523. }
  19524. this.finishToken(types$1.num, val);
  19525. }
  19526. readNumber(startsWithDot) {
  19527. const start = this.state.pos;
  19528. let isFloat = false;
  19529. let isBigInt = false;
  19530. let isDecimal = false;
  19531. let hasExponent = false;
  19532. let isOctal = false;
  19533. if (!startsWithDot && this.readInt(10) === null) {
  19534. this.raise(start, ErrorMessages.InvalidNumber);
  19535. }
  19536. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  19537. if (hasLeadingZero) {
  19538. const integer = this.input.slice(start, this.state.pos);
  19539. this.recordStrictModeErrors(start, ErrorMessages.StrictOctalLiteral);
  19540. if (!this.state.strict) {
  19541. const underscorePos = integer.indexOf("_");
  19542. if (underscorePos > 0) {
  19543. this.raise(underscorePos + start, ErrorMessages.ZeroDigitNumericSeparator);
  19544. }
  19545. }
  19546. isOctal = hasLeadingZero && !/[89]/.test(integer);
  19547. }
  19548. let next = this.input.charCodeAt(this.state.pos);
  19549. if (next === 46 && !isOctal) {
  19550. ++this.state.pos;
  19551. this.readInt(10);
  19552. isFloat = true;
  19553. next = this.input.charCodeAt(this.state.pos);
  19554. }
  19555. if ((next === 69 || next === 101) && !isOctal) {
  19556. next = this.input.charCodeAt(++this.state.pos);
  19557. if (next === 43 || next === 45) {
  19558. ++this.state.pos;
  19559. }
  19560. if (this.readInt(10) === null) {
  19561. this.raise(start, ErrorMessages.InvalidOrMissingExponent);
  19562. }
  19563. isFloat = true;
  19564. hasExponent = true;
  19565. next = this.input.charCodeAt(this.state.pos);
  19566. }
  19567. if (next === 110) {
  19568. if (isFloat || hasLeadingZero) {
  19569. this.raise(start, ErrorMessages.InvalidBigIntLiteral);
  19570. }
  19571. ++this.state.pos;
  19572. isBigInt = true;
  19573. }
  19574. if (next === 109) {
  19575. this.expectPlugin("decimal", this.state.pos);
  19576. if (hasExponent || hasLeadingZero) {
  19577. this.raise(start, ErrorMessages.InvalidDecimal);
  19578. }
  19579. ++this.state.pos;
  19580. isDecimal = true;
  19581. }
  19582. if (isIdentifierStart$1(this.codePointAtPos(this.state.pos))) {
  19583. throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
  19584. }
  19585. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  19586. if (isBigInt) {
  19587. this.finishToken(types$1.bigint, str);
  19588. return;
  19589. }
  19590. if (isDecimal) {
  19591. this.finishToken(types$1.decimal, str);
  19592. return;
  19593. }
  19594. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  19595. this.finishToken(types$1.num, val);
  19596. }
  19597. readCodePoint(throwOnInvalid) {
  19598. const ch = this.input.charCodeAt(this.state.pos);
  19599. let code;
  19600. if (ch === 123) {
  19601. const codePos = ++this.state.pos;
  19602. code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid);
  19603. ++this.state.pos;
  19604. if (code !== null && code > 0x10ffff) {
  19605. if (throwOnInvalid) {
  19606. this.raise(codePos, ErrorMessages.InvalidCodePoint);
  19607. } else {
  19608. return null;
  19609. }
  19610. }
  19611. } else {
  19612. code = this.readHexChar(4, false, throwOnInvalid);
  19613. }
  19614. return code;
  19615. }
  19616. readString(quote) {
  19617. let out = "",
  19618. chunkStart = ++this.state.pos;
  19619. for (;;) {
  19620. if (this.state.pos >= this.length) {
  19621. throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
  19622. }
  19623. const ch = this.input.charCodeAt(this.state.pos);
  19624. if (ch === quote) break;
  19625. if (ch === 92) {
  19626. out += this.input.slice(chunkStart, this.state.pos);
  19627. out += this.readEscapedChar(false);
  19628. chunkStart = this.state.pos;
  19629. } else if (ch === 8232 || ch === 8233) {
  19630. ++this.state.pos;
  19631. ++this.state.curLine;
  19632. this.state.lineStart = this.state.pos;
  19633. } else if (isNewLine(ch)) {
  19634. throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
  19635. } else {
  19636. ++this.state.pos;
  19637. }
  19638. }
  19639. out += this.input.slice(chunkStart, this.state.pos++);
  19640. this.finishToken(types$1.string, out);
  19641. }
  19642. readTmplToken() {
  19643. let out = "",
  19644. chunkStart = this.state.pos,
  19645. containsInvalid = false;
  19646. for (;;) {
  19647. if (this.state.pos >= this.length) {
  19648. throw this.raise(this.state.start, ErrorMessages.UnterminatedTemplate);
  19649. }
  19650. const ch = this.input.charCodeAt(this.state.pos);
  19651. if (ch === 96 || ch === 36 && this.input.charCodeAt(this.state.pos + 1) === 123) {
  19652. if (this.state.pos === this.state.start && this.match(types$1.template)) {
  19653. if (ch === 36) {
  19654. this.state.pos += 2;
  19655. this.finishToken(types$1.dollarBraceL);
  19656. return;
  19657. } else {
  19658. ++this.state.pos;
  19659. this.finishToken(types$1.backQuote);
  19660. return;
  19661. }
  19662. }
  19663. out += this.input.slice(chunkStart, this.state.pos);
  19664. this.finishToken(types$1.template, containsInvalid ? null : out);
  19665. return;
  19666. }
  19667. if (ch === 92) {
  19668. out += this.input.slice(chunkStart, this.state.pos);
  19669. const escaped = this.readEscapedChar(true);
  19670. if (escaped === null) {
  19671. containsInvalid = true;
  19672. } else {
  19673. out += escaped;
  19674. }
  19675. chunkStart = this.state.pos;
  19676. } else if (isNewLine(ch)) {
  19677. out += this.input.slice(chunkStart, this.state.pos);
  19678. ++this.state.pos;
  19679. switch (ch) {
  19680. case 13:
  19681. if (this.input.charCodeAt(this.state.pos) === 10) {
  19682. ++this.state.pos;
  19683. }
  19684. case 10:
  19685. out += "\n";
  19686. break;
  19687. default:
  19688. out += String.fromCharCode(ch);
  19689. break;
  19690. }
  19691. ++this.state.curLine;
  19692. this.state.lineStart = this.state.pos;
  19693. chunkStart = this.state.pos;
  19694. } else {
  19695. ++this.state.pos;
  19696. }
  19697. }
  19698. }
  19699. recordStrictModeErrors(pos, message) {
  19700. if (this.state.strict && !this.state.strictErrors.has(pos)) {
  19701. this.raise(pos, message);
  19702. } else {
  19703. this.state.strictErrors.set(pos, message);
  19704. }
  19705. }
  19706. readEscapedChar(inTemplate) {
  19707. const throwOnInvalid = !inTemplate;
  19708. const ch = this.input.charCodeAt(++this.state.pos);
  19709. ++this.state.pos;
  19710. switch (ch) {
  19711. case 110:
  19712. return "\n";
  19713. case 114:
  19714. return "\r";
  19715. case 120:
  19716. {
  19717. const code = this.readHexChar(2, false, throwOnInvalid);
  19718. return code === null ? null : String.fromCharCode(code);
  19719. }
  19720. case 117:
  19721. {
  19722. const code = this.readCodePoint(throwOnInvalid);
  19723. return code === null ? null : String.fromCodePoint(code);
  19724. }
  19725. case 116:
  19726. return "\t";
  19727. case 98:
  19728. return "\b";
  19729. case 118:
  19730. return "\u000b";
  19731. case 102:
  19732. return "\f";
  19733. case 13:
  19734. if (this.input.charCodeAt(this.state.pos) === 10) {
  19735. ++this.state.pos;
  19736. }
  19737. case 10:
  19738. this.state.lineStart = this.state.pos;
  19739. ++this.state.curLine;
  19740. case 8232:
  19741. case 8233:
  19742. return "";
  19743. case 56:
  19744. case 57:
  19745. if (inTemplate) {
  19746. return null;
  19747. } else {
  19748. this.recordStrictModeErrors(this.state.pos - 1, ErrorMessages.StrictNumericEscape);
  19749. }
  19750. default:
  19751. if (ch >= 48 && ch <= 55) {
  19752. const codePos = this.state.pos - 1;
  19753. const match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
  19754. let octalStr = match[0];
  19755. let octal = parseInt(octalStr, 8);
  19756. if (octal > 255) {
  19757. octalStr = octalStr.slice(0, -1);
  19758. octal = parseInt(octalStr, 8);
  19759. }
  19760. this.state.pos += octalStr.length - 1;
  19761. const next = this.input.charCodeAt(this.state.pos);
  19762. if (octalStr !== "0" || next === 56 || next === 57) {
  19763. if (inTemplate) {
  19764. return null;
  19765. } else {
  19766. this.recordStrictModeErrors(codePos, ErrorMessages.StrictNumericEscape);
  19767. }
  19768. }
  19769. return String.fromCharCode(octal);
  19770. }
  19771. return String.fromCharCode(ch);
  19772. }
  19773. }
  19774. readHexChar(len, forceLen, throwOnInvalid) {
  19775. const codePos = this.state.pos;
  19776. const n = this.readInt(16, len, forceLen, false);
  19777. if (n === null) {
  19778. if (throwOnInvalid) {
  19779. this.raise(codePos, ErrorMessages.InvalidEscapeSequence);
  19780. } else {
  19781. this.state.pos = codePos - 1;
  19782. }
  19783. }
  19784. return n;
  19785. }
  19786. readWord1(firstCode) {
  19787. this.state.containsEsc = false;
  19788. let word = "";
  19789. const start = this.state.pos;
  19790. let chunkStart = this.state.pos;
  19791. if (firstCode !== undefined) {
  19792. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  19793. }
  19794. while (this.state.pos < this.length) {
  19795. const ch = this.codePointAtPos(this.state.pos);
  19796. if (isIdentifierChar$1(ch)) {
  19797. this.state.pos += ch <= 0xffff ? 1 : 2;
  19798. } else if (ch === 92) {
  19799. this.state.containsEsc = true;
  19800. word += this.input.slice(chunkStart, this.state.pos);
  19801. const escStart = this.state.pos;
  19802. const identifierCheck = this.state.pos === start ? isIdentifierStart$1 : isIdentifierChar$1;
  19803. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  19804. this.raise(this.state.pos, ErrorMessages.MissingUnicodeEscape);
  19805. chunkStart = this.state.pos - 1;
  19806. continue;
  19807. }
  19808. ++this.state.pos;
  19809. const esc = this.readCodePoint(true);
  19810. if (esc !== null) {
  19811. if (!identifierCheck(esc)) {
  19812. this.raise(escStart, ErrorMessages.EscapedCharNotAnIdentifier);
  19813. }
  19814. word += String.fromCodePoint(esc);
  19815. }
  19816. chunkStart = this.state.pos;
  19817. } else {
  19818. break;
  19819. }
  19820. }
  19821. return word + this.input.slice(chunkStart, this.state.pos);
  19822. }
  19823. readWord(firstCode) {
  19824. const word = this.readWord1(firstCode);
  19825. const type = keywords$1.get(word) || types$1.name;
  19826. this.finishToken(type, word);
  19827. }
  19828. checkKeywordEscapes() {
  19829. const kw = this.state.type.keyword;
  19830. if (kw && this.state.containsEsc) {
  19831. this.raise(this.state.start, ErrorMessages.InvalidEscapedReservedWord, kw);
  19832. }
  19833. }
  19834. updateContext(prevType) {
  19835. var _this$state$type$upda, _this$state$type;
  19836. (_this$state$type$upda = (_this$state$type = this.state.type).updateContext) == null ? void 0 : _this$state$type$upda.call(_this$state$type, this.state.context);
  19837. }
  19838. }
  19839. class ClassScope {
  19840. constructor() {
  19841. this.privateNames = new Set();
  19842. this.loneAccessors = new Map();
  19843. this.undefinedPrivateNames = new Map();
  19844. }
  19845. }
  19846. class ClassScopeHandler {
  19847. constructor(raise) {
  19848. this.stack = [];
  19849. this.undefinedPrivateNames = new Map();
  19850. this.raise = raise;
  19851. }
  19852. current() {
  19853. return this.stack[this.stack.length - 1];
  19854. }
  19855. enter() {
  19856. this.stack.push(new ClassScope());
  19857. }
  19858. exit() {
  19859. const oldClassScope = this.stack.pop();
  19860. const current = this.current();
  19861. for (const [name, pos] of Array.from(oldClassScope.undefinedPrivateNames)) {
  19862. if (current) {
  19863. if (!current.undefinedPrivateNames.has(name)) {
  19864. current.undefinedPrivateNames.set(name, pos);
  19865. }
  19866. } else {
  19867. this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
  19868. }
  19869. }
  19870. }
  19871. declarePrivateName(name, elementType, pos) {
  19872. const classScope = this.current();
  19873. let redefined = classScope.privateNames.has(name);
  19874. if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) {
  19875. const accessor = redefined && classScope.loneAccessors.get(name);
  19876. if (accessor) {
  19877. const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC;
  19878. const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC;
  19879. const oldKind = accessor & CLASS_ELEMENT_KIND_ACCESSOR;
  19880. const newKind = elementType & CLASS_ELEMENT_KIND_ACCESSOR;
  19881. redefined = oldKind === newKind || oldStatic !== newStatic;
  19882. if (!redefined) classScope.loneAccessors.delete(name);
  19883. } else if (!redefined) {
  19884. classScope.loneAccessors.set(name, elementType);
  19885. }
  19886. }
  19887. if (redefined) {
  19888. this.raise(pos, ErrorMessages.PrivateNameRedeclaration, name);
  19889. }
  19890. classScope.privateNames.add(name);
  19891. classScope.undefinedPrivateNames.delete(name);
  19892. }
  19893. usePrivateName(name, pos) {
  19894. let classScope;
  19895. for (classScope of this.stack) {
  19896. if (classScope.privateNames.has(name)) return;
  19897. }
  19898. if (classScope) {
  19899. classScope.undefinedPrivateNames.set(name, pos);
  19900. } else {
  19901. this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
  19902. }
  19903. }
  19904. }
  19905. const kExpression = 0,
  19906. kMaybeArrowParameterDeclaration = 1,
  19907. kMaybeAsyncArrowParameterDeclaration = 2,
  19908. kParameterDeclaration = 3;
  19909. class ExpressionScope {
  19910. constructor(type = kExpression) {
  19911. this.type = void 0;
  19912. this.type = type;
  19913. }
  19914. canBeArrowParameterDeclaration() {
  19915. return this.type === kMaybeAsyncArrowParameterDeclaration || this.type === kMaybeArrowParameterDeclaration;
  19916. }
  19917. isCertainlyParameterDeclaration() {
  19918. return this.type === kParameterDeclaration;
  19919. }
  19920. }
  19921. class ArrowHeadParsingScope extends ExpressionScope {
  19922. constructor(type) {
  19923. super(type);
  19924. this.errors = new Map();
  19925. }
  19926. recordDeclarationError(pos, template) {
  19927. this.errors.set(pos, template);
  19928. }
  19929. clearDeclarationError(pos) {
  19930. this.errors.delete(pos);
  19931. }
  19932. iterateErrors(iterator) {
  19933. this.errors.forEach(iterator);
  19934. }
  19935. }
  19936. class ExpressionScopeHandler {
  19937. constructor(raise) {
  19938. this.stack = [new ExpressionScope()];
  19939. this.raise = raise;
  19940. }
  19941. enter(scope) {
  19942. this.stack.push(scope);
  19943. }
  19944. exit() {
  19945. this.stack.pop();
  19946. }
  19947. recordParameterInitializerError(pos, template) {
  19948. const {
  19949. stack
  19950. } = this;
  19951. let i = stack.length - 1;
  19952. let scope = stack[i];
  19953. while (!scope.isCertainlyParameterDeclaration()) {
  19954. if (scope.canBeArrowParameterDeclaration()) {
  19955. scope.recordDeclarationError(pos, template);
  19956. } else {
  19957. return;
  19958. }
  19959. scope = stack[--i];
  19960. }
  19961. this.raise(pos, template);
  19962. }
  19963. recordParenthesizedIdentifierError(pos, template) {
  19964. const {
  19965. stack
  19966. } = this;
  19967. const scope = stack[stack.length - 1];
  19968. if (scope.isCertainlyParameterDeclaration()) {
  19969. this.raise(pos, template);
  19970. } else if (scope.canBeArrowParameterDeclaration()) {
  19971. scope.recordDeclarationError(pos, template);
  19972. } else {
  19973. return;
  19974. }
  19975. }
  19976. recordAsyncArrowParametersError(pos, template) {
  19977. const {
  19978. stack
  19979. } = this;
  19980. let i = stack.length - 1;
  19981. let scope = stack[i];
  19982. while (scope.canBeArrowParameterDeclaration()) {
  19983. if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
  19984. scope.recordDeclarationError(pos, template);
  19985. }
  19986. scope = stack[--i];
  19987. }
  19988. }
  19989. validateAsPattern() {
  19990. const {
  19991. stack
  19992. } = this;
  19993. const currentScope = stack[stack.length - 1];
  19994. if (!currentScope.canBeArrowParameterDeclaration()) return;
  19995. currentScope.iterateErrors((template, pos) => {
  19996. this.raise(pos, template);
  19997. let i = stack.length - 2;
  19998. let scope = stack[i];
  19999. while (scope.canBeArrowParameterDeclaration()) {
  20000. scope.clearDeclarationError(pos);
  20001. scope = stack[--i];
  20002. }
  20003. });
  20004. }
  20005. }
  20006. function newParameterDeclarationScope() {
  20007. return new ExpressionScope(kParameterDeclaration);
  20008. }
  20009. function newArrowHeadScope() {
  20010. return new ArrowHeadParsingScope(kMaybeArrowParameterDeclaration);
  20011. }
  20012. function newAsyncArrowScope() {
  20013. return new ArrowHeadParsingScope(kMaybeAsyncArrowParameterDeclaration);
  20014. }
  20015. function newExpressionScope() {
  20016. return new ExpressionScope();
  20017. }
  20018. const PARAM = 0b0000,
  20019. PARAM_YIELD = 0b0001,
  20020. PARAM_AWAIT = 0b0010,
  20021. PARAM_RETURN = 0b0100,
  20022. PARAM_IN = 0b1000;
  20023. class ProductionParameterHandler {
  20024. constructor() {
  20025. this.stacks = [];
  20026. }
  20027. enter(flags) {
  20028. this.stacks.push(flags);
  20029. }
  20030. exit() {
  20031. this.stacks.pop();
  20032. }
  20033. currentFlags() {
  20034. return this.stacks[this.stacks.length - 1];
  20035. }
  20036. get hasAwait() {
  20037. return (this.currentFlags() & PARAM_AWAIT) > 0;
  20038. }
  20039. get hasYield() {
  20040. return (this.currentFlags() & PARAM_YIELD) > 0;
  20041. }
  20042. get hasReturn() {
  20043. return (this.currentFlags() & PARAM_RETURN) > 0;
  20044. }
  20045. get hasIn() {
  20046. return (this.currentFlags() & PARAM_IN) > 0;
  20047. }
  20048. }
  20049. function functionFlags(isAsync, isGenerator) {
  20050. return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);
  20051. }
  20052. class UtilParser extends Tokenizer {
  20053. addExtra(node, key, val) {
  20054. if (!node) return;
  20055. const extra = node.extra = node.extra || {};
  20056. extra[key] = val;
  20057. }
  20058. isRelational(op) {
  20059. return this.match(types$1.relational) && this.state.value === op;
  20060. }
  20061. expectRelational(op) {
  20062. if (this.isRelational(op)) {
  20063. this.next();
  20064. } else {
  20065. this.unexpected(null, types$1.relational);
  20066. }
  20067. }
  20068. isContextual(name) {
  20069. return this.match(types$1.name) && this.state.value === name && !this.state.containsEsc;
  20070. }
  20071. isUnparsedContextual(nameStart, name) {
  20072. const nameEnd = nameStart + name.length;
  20073. if (this.input.slice(nameStart, nameEnd) === name) {
  20074. const nextCh = this.input.charCodeAt(nameEnd);
  20075. return !(isIdentifierChar$1(nextCh) || (nextCh & 0xfc00) === 0xd800);
  20076. }
  20077. return false;
  20078. }
  20079. isLookaheadContextual(name) {
  20080. const next = this.nextTokenStart();
  20081. return this.isUnparsedContextual(next, name);
  20082. }
  20083. eatContextual(name) {
  20084. return this.isContextual(name) && this.eat(types$1.name);
  20085. }
  20086. expectContextual(name, template) {
  20087. if (!this.eatContextual(name)) this.unexpected(null, template);
  20088. }
  20089. canInsertSemicolon() {
  20090. return this.match(types$1.eof) || this.match(types$1.braceR) || this.hasPrecedingLineBreak();
  20091. }
  20092. hasPrecedingLineBreak() {
  20093. return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
  20094. }
  20095. hasFollowingLineBreak() {
  20096. skipWhiteSpaceToLineBreak.lastIndex = this.state.end;
  20097. return skipWhiteSpaceToLineBreak.test(this.input);
  20098. }
  20099. isLineTerminator() {
  20100. return this.eat(types$1.semi) || this.canInsertSemicolon();
  20101. }
  20102. semicolon(allowAsi = true) {
  20103. if (allowAsi ? this.isLineTerminator() : this.eat(types$1.semi)) return;
  20104. this.raise(this.state.lastTokEnd, ErrorMessages.MissingSemicolon);
  20105. }
  20106. expect(type, pos) {
  20107. this.eat(type) || this.unexpected(pos, type);
  20108. }
  20109. assertNoSpace(message = "Unexpected space.") {
  20110. if (this.state.start > this.state.lastTokEnd) {
  20111. this.raise(this.state.lastTokEnd, {
  20112. code: ErrorCodes.SyntaxError,
  20113. reasonCode: "UnexpectedSpace",
  20114. template: message
  20115. });
  20116. }
  20117. }
  20118. unexpected(pos, messageOrType = {
  20119. code: ErrorCodes.SyntaxError,
  20120. reasonCode: "UnexpectedToken",
  20121. template: "Unexpected token"
  20122. }) {
  20123. if (messageOrType instanceof TokenType) {
  20124. messageOrType = {
  20125. code: ErrorCodes.SyntaxError,
  20126. reasonCode: "UnexpectedToken",
  20127. template: `Unexpected token, expected "${messageOrType.label}"`
  20128. };
  20129. }
  20130. throw this.raise(pos != null ? pos : this.state.start, messageOrType);
  20131. }
  20132. expectPlugin(name, pos) {
  20133. if (!this.hasPlugin(name)) {
  20134. throw this.raiseWithData(pos != null ? pos : this.state.start, {
  20135. missingPlugin: [name]
  20136. }, `This experimental syntax requires enabling the parser plugin: '${name}'`);
  20137. }
  20138. return true;
  20139. }
  20140. expectOnePlugin(names, pos) {
  20141. if (!names.some(n => this.hasPlugin(n))) {
  20142. throw this.raiseWithData(pos != null ? pos : this.state.start, {
  20143. missingPlugin: names
  20144. }, `This experimental syntax requires enabling one of the following parser plugin(s): '${names.join(", ")}'`);
  20145. }
  20146. }
  20147. tryParse(fn, oldState = this.state.clone()) {
  20148. const abortSignal = {
  20149. node: null
  20150. };
  20151. try {
  20152. const node = fn((node = null) => {
  20153. abortSignal.node = node;
  20154. throw abortSignal;
  20155. });
  20156. if (this.state.errors.length > oldState.errors.length) {
  20157. const failState = this.state;
  20158. this.state = oldState;
  20159. this.state.tokensLength = failState.tokensLength;
  20160. return {
  20161. node,
  20162. error: failState.errors[oldState.errors.length],
  20163. thrown: false,
  20164. aborted: false,
  20165. failState
  20166. };
  20167. }
  20168. return {
  20169. node,
  20170. error: null,
  20171. thrown: false,
  20172. aborted: false,
  20173. failState: null
  20174. };
  20175. } catch (error) {
  20176. const failState = this.state;
  20177. this.state = oldState;
  20178. if (error instanceof SyntaxError) {
  20179. return {
  20180. node: null,
  20181. error,
  20182. thrown: true,
  20183. aborted: false,
  20184. failState
  20185. };
  20186. }
  20187. if (error === abortSignal) {
  20188. return {
  20189. node: abortSignal.node,
  20190. error: null,
  20191. thrown: false,
  20192. aborted: true,
  20193. failState
  20194. };
  20195. }
  20196. throw error;
  20197. }
  20198. }
  20199. checkExpressionErrors(refExpressionErrors, andThrow) {
  20200. if (!refExpressionErrors) return false;
  20201. const {
  20202. shorthandAssign,
  20203. doubleProto,
  20204. optionalParameters
  20205. } = refExpressionErrors;
  20206. if (!andThrow) {
  20207. return shorthandAssign >= 0 || doubleProto >= 0 || optionalParameters >= 0;
  20208. }
  20209. if (shorthandAssign >= 0) {
  20210. this.unexpected(shorthandAssign);
  20211. }
  20212. if (doubleProto >= 0) {
  20213. this.raise(doubleProto, ErrorMessages.DuplicateProto);
  20214. }
  20215. if (optionalParameters >= 0) {
  20216. this.unexpected(optionalParameters);
  20217. }
  20218. }
  20219. isLiteralPropertyName() {
  20220. return this.match(types$1.name) || !!this.state.type.keyword || this.match(types$1.string) || this.match(types$1.num) || this.match(types$1.bigint) || this.match(types$1.decimal);
  20221. }
  20222. isPrivateName(node) {
  20223. return node.type === "PrivateName";
  20224. }
  20225. getPrivateNameSV(node) {
  20226. return node.id.name;
  20227. }
  20228. hasPropertyAsPrivateName(node) {
  20229. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  20230. }
  20231. isOptionalChain(node) {
  20232. return node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression";
  20233. }
  20234. isObjectProperty(node) {
  20235. return node.type === "ObjectProperty";
  20236. }
  20237. isObjectMethod(node) {
  20238. return node.type === "ObjectMethod";
  20239. }
  20240. initializeScopes(inModule = this.options.sourceType === "module") {
  20241. const oldLabels = this.state.labels;
  20242. this.state.labels = [];
  20243. const oldExportedIdentifiers = this.exportedIdentifiers;
  20244. this.exportedIdentifiers = new Set();
  20245. const oldInModule = this.inModule;
  20246. this.inModule = inModule;
  20247. const oldScope = this.scope;
  20248. const ScopeHandler = this.getScopeHandler();
  20249. this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
  20250. const oldProdParam = this.prodParam;
  20251. this.prodParam = new ProductionParameterHandler();
  20252. const oldClassScope = this.classScope;
  20253. this.classScope = new ClassScopeHandler(this.raise.bind(this));
  20254. const oldExpressionScope = this.expressionScope;
  20255. this.expressionScope = new ExpressionScopeHandler(this.raise.bind(this));
  20256. return () => {
  20257. this.state.labels = oldLabels;
  20258. this.exportedIdentifiers = oldExportedIdentifiers;
  20259. this.inModule = oldInModule;
  20260. this.scope = oldScope;
  20261. this.prodParam = oldProdParam;
  20262. this.classScope = oldClassScope;
  20263. this.expressionScope = oldExpressionScope;
  20264. };
  20265. }
  20266. enterInitialScopes() {
  20267. let paramFlags = PARAM;
  20268. if (this.inModule) {
  20269. paramFlags |= PARAM_AWAIT;
  20270. }
  20271. this.scope.enter(SCOPE_PROGRAM);
  20272. this.prodParam.enter(paramFlags);
  20273. }
  20274. }
  20275. class ExpressionErrors {
  20276. constructor() {
  20277. this.shorthandAssign = -1;
  20278. this.doubleProto = -1;
  20279. this.optionalParameters = -1;
  20280. }
  20281. }
  20282. class Node {
  20283. constructor(parser, pos, loc) {
  20284. this.type = "";
  20285. this.start = pos;
  20286. this.end = 0;
  20287. this.loc = new SourceLocation(loc);
  20288. if (parser != null && parser.options.ranges) this.range = [pos, 0];
  20289. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  20290. }
  20291. }
  20292. const NodePrototype = Node.prototype;
  20293. {
  20294. NodePrototype.__clone = function () {
  20295. const newNode = new Node();
  20296. const keys = Object.keys(this);
  20297. for (let i = 0, length = keys.length; i < length; i++) {
  20298. const key = keys[i];
  20299. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  20300. newNode[key] = this[key];
  20301. }
  20302. }
  20303. return newNode;
  20304. };
  20305. }
  20306. function clonePlaceholder(node) {
  20307. return cloneIdentifier(node);
  20308. }
  20309. function cloneIdentifier(node) {
  20310. const {
  20311. type,
  20312. start,
  20313. end,
  20314. loc,
  20315. range,
  20316. extra,
  20317. name
  20318. } = node;
  20319. const cloned = Object.create(NodePrototype);
  20320. cloned.type = type;
  20321. cloned.start = start;
  20322. cloned.end = end;
  20323. cloned.loc = loc;
  20324. cloned.range = range;
  20325. cloned.extra = extra;
  20326. cloned.name = name;
  20327. if (type === "Placeholder") {
  20328. cloned.expectedNode = node.expectedNode;
  20329. }
  20330. return cloned;
  20331. }
  20332. function cloneStringLiteral(node) {
  20333. const {
  20334. type,
  20335. start,
  20336. end,
  20337. loc,
  20338. range,
  20339. extra
  20340. } = node;
  20341. if (type === "Placeholder") {
  20342. return clonePlaceholder(node);
  20343. }
  20344. const cloned = Object.create(NodePrototype);
  20345. cloned.type = "StringLiteral";
  20346. cloned.start = start;
  20347. cloned.end = end;
  20348. cloned.loc = loc;
  20349. cloned.range = range;
  20350. cloned.extra = extra;
  20351. cloned.value = node.value;
  20352. return cloned;
  20353. }
  20354. class NodeUtils extends UtilParser {
  20355. startNode() {
  20356. return new Node(this, this.state.start, this.state.startLoc);
  20357. }
  20358. startNodeAt(pos, loc) {
  20359. return new Node(this, pos, loc);
  20360. }
  20361. startNodeAtNode(type) {
  20362. return this.startNodeAt(type.start, type.loc.start);
  20363. }
  20364. finishNode(node, type) {
  20365. return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc);
  20366. }
  20367. finishNodeAt(node, type, pos, loc) {
  20368. node.type = type;
  20369. node.end = pos;
  20370. node.loc.end = loc;
  20371. if (this.options.ranges) node.range[1] = pos;
  20372. if (this.options.attachComment) this.processComment(node);
  20373. return node;
  20374. }
  20375. resetStartLocation(node, start, startLoc) {
  20376. node.start = start;
  20377. node.loc.start = startLoc;
  20378. if (this.options.ranges) node.range[0] = start;
  20379. }
  20380. resetEndLocation(node, end = this.state.lastTokEnd, endLoc = this.state.lastTokEndLoc) {
  20381. node.end = end;
  20382. node.loc.end = endLoc;
  20383. if (this.options.ranges) node.range[1] = end;
  20384. }
  20385. resetStartLocationFromNode(node, locationNode) {
  20386. this.resetStartLocation(node, locationNode.start, locationNode.loc.start);
  20387. }
  20388. }
  20389. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  20390. const FlowErrors = makeErrorTemplates({
  20391. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  20392. 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.",
  20393. AssignReservedType: "Cannot overwrite reserved type %0.",
  20394. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  20395. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  20396. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  20397. EnumBooleanMemberNotInitialized: "Boolean enum members need to be initialized. Use either `%0 = true,` or `%0 = false,` in enum `%1`.",
  20398. EnumDuplicateMemberName: "Enum member names need to be unique, but the name `%0` has already been used before in enum `%1`.",
  20399. EnumInconsistentMemberValues: "Enum `%0` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.",
  20400. EnumInvalidExplicitType: "Enum type `%1` is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.",
  20401. EnumInvalidExplicitTypeUnknownSupplied: "Supplied enum type is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.",
  20402. EnumInvalidMemberInitializerPrimaryType: "Enum `%0` has type `%2`, so the initializer of `%1` needs to be a %2 literal.",
  20403. EnumInvalidMemberInitializerSymbolType: "Symbol enum members cannot be initialized. Use `%1,` in enum `%0`.",
  20404. EnumInvalidMemberInitializerUnknownType: "The enum member initializer for `%1` needs to be a literal (either a boolean, number, or string) in enum `%0`.",
  20405. EnumInvalidMemberName: "Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `%0`, consider using `%1`, in enum `%2`.",
  20406. EnumNumberMemberNotInitialized: "Number enum members need to be initialized, e.g. `%1 = 1` in enum `%0`.",
  20407. EnumStringMemberInconsistentlyInitailized: "String enum members need to consistently either all use initializers, or use no initializers, in enum `%0`.",
  20408. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  20409. 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.",
  20410. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  20411. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  20412. InexactVariance: "Explicit inexact syntax cannot have variance.",
  20413. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  20414. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  20415. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  20416. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  20417. OptionalBindingPattern: "A binding pattern parameter cannot be optional in an implementation signature.",
  20418. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  20419. SpreadVariance: "Spread properties cannot have variance.",
  20420. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  20421. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  20422. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  20423. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  20424. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  20425. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  20426. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  20427. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  20428. UnexpectedReservedType: "Unexpected reserved type %0.",
  20429. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  20430. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  20431. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  20432. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  20433. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  20434. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  20435. UnsupportedDeclareExportKind: "`declare export %0` is not supported. Use `%1` instead.",
  20436. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  20437. UnterminatedFlowComment: "Unterminated flow-comment."
  20438. }, ErrorCodes.SyntaxError);
  20439. function isEsModuleType(bodyElement) {
  20440. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  20441. }
  20442. function hasTypeImportKind(node) {
  20443. return node.importKind === "type" || node.importKind === "typeof";
  20444. }
  20445. function isMaybeDefaultImport(state) {
  20446. return (state.type === types$1.name || !!state.type.keyword) && state.value !== "from";
  20447. }
  20448. const exportSuggestions = {
  20449. const: "declare export var",
  20450. let: "declare export var",
  20451. type: "export type",
  20452. interface: "export interface"
  20453. };
  20454. function partition(list, test) {
  20455. const list1 = [];
  20456. const list2 = [];
  20457. for (let i = 0; i < list.length; i++) {
  20458. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  20459. }
  20460. return [list1, list2];
  20461. }
  20462. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  20463. var flow = (superClass => class extends superClass {
  20464. constructor(...args) {
  20465. super(...args);
  20466. this.flowPragma = undefined;
  20467. }
  20468. getScopeHandler() {
  20469. return FlowScopeHandler;
  20470. }
  20471. shouldParseTypes() {
  20472. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  20473. }
  20474. shouldParseEnums() {
  20475. return !!this.getPluginOption("flow", "enums");
  20476. }
  20477. finishToken(type, val) {
  20478. if (type !== types$1.string && type !== types$1.semi && type !== types$1.interpreterDirective) {
  20479. if (this.flowPragma === undefined) {
  20480. this.flowPragma = null;
  20481. }
  20482. }
  20483. return super.finishToken(type, val);
  20484. }
  20485. addComment(comment) {
  20486. if (this.flowPragma === undefined) {
  20487. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  20488. if (!matches) ; else if (matches[1] === "flow") {
  20489. this.flowPragma = "flow";
  20490. } else if (matches[1] === "noflow") {
  20491. this.flowPragma = "noflow";
  20492. } else {
  20493. throw new Error("Unexpected flow pragma");
  20494. }
  20495. }
  20496. return super.addComment(comment);
  20497. }
  20498. flowParseTypeInitialiser(tok) {
  20499. const oldInType = this.state.inType;
  20500. this.state.inType = true;
  20501. this.expect(tok || types$1.colon);
  20502. const type = this.flowParseType();
  20503. this.state.inType = oldInType;
  20504. return type;
  20505. }
  20506. flowParsePredicate() {
  20507. const node = this.startNode();
  20508. const moduloPos = this.state.start;
  20509. this.next();
  20510. this.expectContextual("checks");
  20511. if (this.state.lastTokStart > moduloPos + 1) {
  20512. this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks);
  20513. }
  20514. if (this.eat(types$1.parenL)) {
  20515. node.value = this.parseExpression();
  20516. this.expect(types$1.parenR);
  20517. return this.finishNode(node, "DeclaredPredicate");
  20518. } else {
  20519. return this.finishNode(node, "InferredPredicate");
  20520. }
  20521. }
  20522. flowParseTypeAndPredicateInitialiser() {
  20523. const oldInType = this.state.inType;
  20524. this.state.inType = true;
  20525. this.expect(types$1.colon);
  20526. let type = null;
  20527. let predicate = null;
  20528. if (this.match(types$1.modulo)) {
  20529. this.state.inType = oldInType;
  20530. predicate = this.flowParsePredicate();
  20531. } else {
  20532. type = this.flowParseType();
  20533. this.state.inType = oldInType;
  20534. if (this.match(types$1.modulo)) {
  20535. predicate = this.flowParsePredicate();
  20536. }
  20537. }
  20538. return [type, predicate];
  20539. }
  20540. flowParseDeclareClass(node) {
  20541. this.next();
  20542. this.flowParseInterfaceish(node, true);
  20543. return this.finishNode(node, "DeclareClass");
  20544. }
  20545. flowParseDeclareFunction(node) {
  20546. this.next();
  20547. const id = node.id = this.parseIdentifier();
  20548. const typeNode = this.startNode();
  20549. const typeContainer = this.startNode();
  20550. if (this.isRelational("<")) {
  20551. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  20552. } else {
  20553. typeNode.typeParameters = null;
  20554. }
  20555. this.expect(types$1.parenL);
  20556. const tmp = this.flowParseFunctionTypeParams();
  20557. typeNode.params = tmp.params;
  20558. typeNode.rest = tmp.rest;
  20559. typeNode.this = tmp._this;
  20560. this.expect(types$1.parenR);
  20561. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  20562. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  20563. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  20564. this.resetEndLocation(id);
  20565. this.semicolon();
  20566. this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.start);
  20567. return this.finishNode(node, "DeclareFunction");
  20568. }
  20569. flowParseDeclare(node, insideModule) {
  20570. if (this.match(types$1._class)) {
  20571. return this.flowParseDeclareClass(node);
  20572. } else if (this.match(types$1._function)) {
  20573. return this.flowParseDeclareFunction(node);
  20574. } else if (this.match(types$1._var)) {
  20575. return this.flowParseDeclareVariable(node);
  20576. } else if (this.eatContextual("module")) {
  20577. if (this.match(types$1.dot)) {
  20578. return this.flowParseDeclareModuleExports(node);
  20579. } else {
  20580. if (insideModule) {
  20581. this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule);
  20582. }
  20583. return this.flowParseDeclareModule(node);
  20584. }
  20585. } else if (this.isContextual("type")) {
  20586. return this.flowParseDeclareTypeAlias(node);
  20587. } else if (this.isContextual("opaque")) {
  20588. return this.flowParseDeclareOpaqueType(node);
  20589. } else if (this.isContextual("interface")) {
  20590. return this.flowParseDeclareInterface(node);
  20591. } else if (this.match(types$1._export)) {
  20592. return this.flowParseDeclareExportDeclaration(node, insideModule);
  20593. } else {
  20594. throw this.unexpected();
  20595. }
  20596. }
  20597. flowParseDeclareVariable(node) {
  20598. this.next();
  20599. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  20600. this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
  20601. this.semicolon();
  20602. return this.finishNode(node, "DeclareVariable");
  20603. }
  20604. flowParseDeclareModule(node) {
  20605. this.scope.enter(SCOPE_OTHER);
  20606. if (this.match(types$1.string)) {
  20607. node.id = this.parseExprAtom();
  20608. } else {
  20609. node.id = this.parseIdentifier();
  20610. }
  20611. const bodyNode = node.body = this.startNode();
  20612. const body = bodyNode.body = [];
  20613. this.expect(types$1.braceL);
  20614. while (!this.match(types$1.braceR)) {
  20615. let bodyNode = this.startNode();
  20616. if (this.match(types$1._import)) {
  20617. this.next();
  20618. if (!this.isContextual("type") && !this.match(types$1._typeof)) {
  20619. this.raise(this.state.lastTokStart, FlowErrors.InvalidNonTypeImportInDeclareModule);
  20620. }
  20621. this.parseImport(bodyNode);
  20622. } else {
  20623. this.expectContextual("declare", FlowErrors.UnsupportedStatementInDeclareModule);
  20624. bodyNode = this.flowParseDeclare(bodyNode, true);
  20625. }
  20626. body.push(bodyNode);
  20627. }
  20628. this.scope.exit();
  20629. this.expect(types$1.braceR);
  20630. this.finishNode(bodyNode, "BlockStatement");
  20631. let kind = null;
  20632. let hasModuleExport = false;
  20633. body.forEach(bodyElement => {
  20634. if (isEsModuleType(bodyElement)) {
  20635. if (kind === "CommonJS") {
  20636. this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
  20637. }
  20638. kind = "ES";
  20639. } else if (bodyElement.type === "DeclareModuleExports") {
  20640. if (hasModuleExport) {
  20641. this.raise(bodyElement.start, FlowErrors.DuplicateDeclareModuleExports);
  20642. }
  20643. if (kind === "ES") {
  20644. this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
  20645. }
  20646. kind = "CommonJS";
  20647. hasModuleExport = true;
  20648. }
  20649. });
  20650. node.kind = kind || "CommonJS";
  20651. return this.finishNode(node, "DeclareModule");
  20652. }
  20653. flowParseDeclareExportDeclaration(node, insideModule) {
  20654. this.expect(types$1._export);
  20655. if (this.eat(types$1._default)) {
  20656. if (this.match(types$1._function) || this.match(types$1._class)) {
  20657. node.declaration = this.flowParseDeclare(this.startNode());
  20658. } else {
  20659. node.declaration = this.flowParseType();
  20660. this.semicolon();
  20661. }
  20662. node.default = true;
  20663. return this.finishNode(node, "DeclareExportDeclaration");
  20664. } else {
  20665. if (this.match(types$1._const) || this.isLet() || (this.isContextual("type") || this.isContextual("interface")) && !insideModule) {
  20666. const label = this.state.value;
  20667. const suggestion = exportSuggestions[label];
  20668. throw this.raise(this.state.start, FlowErrors.UnsupportedDeclareExportKind, label, suggestion);
  20669. }
  20670. if (this.match(types$1._var) || this.match(types$1._function) || this.match(types$1._class) || this.isContextual("opaque")) {
  20671. node.declaration = this.flowParseDeclare(this.startNode());
  20672. node.default = false;
  20673. return this.finishNode(node, "DeclareExportDeclaration");
  20674. } else if (this.match(types$1.star) || this.match(types$1.braceL) || this.isContextual("interface") || this.isContextual("type") || this.isContextual("opaque")) {
  20675. node = this.parseExport(node);
  20676. if (node.type === "ExportNamedDeclaration") {
  20677. node.type = "ExportDeclaration";
  20678. node.default = false;
  20679. delete node.exportKind;
  20680. }
  20681. node.type = "Declare" + node.type;
  20682. return node;
  20683. }
  20684. }
  20685. throw this.unexpected();
  20686. }
  20687. flowParseDeclareModuleExports(node) {
  20688. this.next();
  20689. this.expectContextual("exports");
  20690. node.typeAnnotation = this.flowParseTypeAnnotation();
  20691. this.semicolon();
  20692. return this.finishNode(node, "DeclareModuleExports");
  20693. }
  20694. flowParseDeclareTypeAlias(node) {
  20695. this.next();
  20696. this.flowParseTypeAlias(node);
  20697. node.type = "DeclareTypeAlias";
  20698. return node;
  20699. }
  20700. flowParseDeclareOpaqueType(node) {
  20701. this.next();
  20702. this.flowParseOpaqueType(node, true);
  20703. node.type = "DeclareOpaqueType";
  20704. return node;
  20705. }
  20706. flowParseDeclareInterface(node) {
  20707. this.next();
  20708. this.flowParseInterfaceish(node);
  20709. return this.finishNode(node, "DeclareInterface");
  20710. }
  20711. flowParseInterfaceish(node, isClass = false) {
  20712. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  20713. this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start);
  20714. if (this.isRelational("<")) {
  20715. node.typeParameters = this.flowParseTypeParameterDeclaration();
  20716. } else {
  20717. node.typeParameters = null;
  20718. }
  20719. node.extends = [];
  20720. node.implements = [];
  20721. node.mixins = [];
  20722. if (this.eat(types$1._extends)) {
  20723. do {
  20724. node.extends.push(this.flowParseInterfaceExtends());
  20725. } while (!isClass && this.eat(types$1.comma));
  20726. }
  20727. if (this.isContextual("mixins")) {
  20728. this.next();
  20729. do {
  20730. node.mixins.push(this.flowParseInterfaceExtends());
  20731. } while (this.eat(types$1.comma));
  20732. }
  20733. if (this.isContextual("implements")) {
  20734. this.next();
  20735. do {
  20736. node.implements.push(this.flowParseInterfaceExtends());
  20737. } while (this.eat(types$1.comma));
  20738. }
  20739. node.body = this.flowParseObjectType({
  20740. allowStatic: isClass,
  20741. allowExact: false,
  20742. allowSpread: false,
  20743. allowProto: isClass,
  20744. allowInexact: false
  20745. });
  20746. }
  20747. flowParseInterfaceExtends() {
  20748. const node = this.startNode();
  20749. node.id = this.flowParseQualifiedTypeIdentifier();
  20750. if (this.isRelational("<")) {
  20751. node.typeParameters = this.flowParseTypeParameterInstantiation();
  20752. } else {
  20753. node.typeParameters = null;
  20754. }
  20755. return this.finishNode(node, "InterfaceExtends");
  20756. }
  20757. flowParseInterface(node) {
  20758. this.flowParseInterfaceish(node);
  20759. return this.finishNode(node, "InterfaceDeclaration");
  20760. }
  20761. checkNotUnderscore(word) {
  20762. if (word === "_") {
  20763. this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore);
  20764. }
  20765. }
  20766. checkReservedType(word, startLoc, declaration) {
  20767. if (!reservedTypes.has(word)) return;
  20768. this.raise(startLoc, declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, word);
  20769. }
  20770. flowParseRestrictedIdentifier(liberal, declaration) {
  20771. this.checkReservedType(this.state.value, this.state.start, declaration);
  20772. return this.parseIdentifier(liberal);
  20773. }
  20774. flowParseTypeAlias(node) {
  20775. node.id = this.flowParseRestrictedIdentifier(false, true);
  20776. this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
  20777. if (this.isRelational("<")) {
  20778. node.typeParameters = this.flowParseTypeParameterDeclaration();
  20779. } else {
  20780. node.typeParameters = null;
  20781. }
  20782. node.right = this.flowParseTypeInitialiser(types$1.eq);
  20783. this.semicolon();
  20784. return this.finishNode(node, "TypeAlias");
  20785. }
  20786. flowParseOpaqueType(node, declare) {
  20787. this.expectContextual("type");
  20788. node.id = this.flowParseRestrictedIdentifier(true, true);
  20789. this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
  20790. if (this.isRelational("<")) {
  20791. node.typeParameters = this.flowParseTypeParameterDeclaration();
  20792. } else {
  20793. node.typeParameters = null;
  20794. }
  20795. node.supertype = null;
  20796. if (this.match(types$1.colon)) {
  20797. node.supertype = this.flowParseTypeInitialiser(types$1.colon);
  20798. }
  20799. node.impltype = null;
  20800. if (!declare) {
  20801. node.impltype = this.flowParseTypeInitialiser(types$1.eq);
  20802. }
  20803. this.semicolon();
  20804. return this.finishNode(node, "OpaqueType");
  20805. }
  20806. flowParseTypeParameter(requireDefault = false) {
  20807. const nodeStart = this.state.start;
  20808. const node = this.startNode();
  20809. const variance = this.flowParseVariance();
  20810. const ident = this.flowParseTypeAnnotatableIdentifier();
  20811. node.name = ident.name;
  20812. node.variance = variance;
  20813. node.bound = ident.typeAnnotation;
  20814. if (this.match(types$1.eq)) {
  20815. this.eat(types$1.eq);
  20816. node.default = this.flowParseType();
  20817. } else {
  20818. if (requireDefault) {
  20819. this.raise(nodeStart, FlowErrors.MissingTypeParamDefault);
  20820. }
  20821. }
  20822. return this.finishNode(node, "TypeParameter");
  20823. }
  20824. flowParseTypeParameterDeclaration() {
  20825. const oldInType = this.state.inType;
  20826. const node = this.startNode();
  20827. node.params = [];
  20828. this.state.inType = true;
  20829. if (this.isRelational("<") || this.match(types$1.jsxTagStart)) {
  20830. this.next();
  20831. } else {
  20832. this.unexpected();
  20833. }
  20834. let defaultRequired = false;
  20835. do {
  20836. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  20837. node.params.push(typeParameter);
  20838. if (typeParameter.default) {
  20839. defaultRequired = true;
  20840. }
  20841. if (!this.isRelational(">")) {
  20842. this.expect(types$1.comma);
  20843. }
  20844. } while (!this.isRelational(">"));
  20845. this.expectRelational(">");
  20846. this.state.inType = oldInType;
  20847. return this.finishNode(node, "TypeParameterDeclaration");
  20848. }
  20849. flowParseTypeParameterInstantiation() {
  20850. const node = this.startNode();
  20851. const oldInType = this.state.inType;
  20852. node.params = [];
  20853. this.state.inType = true;
  20854. this.expectRelational("<");
  20855. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  20856. this.state.noAnonFunctionType = false;
  20857. while (!this.isRelational(">")) {
  20858. node.params.push(this.flowParseType());
  20859. if (!this.isRelational(">")) {
  20860. this.expect(types$1.comma);
  20861. }
  20862. }
  20863. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  20864. this.expectRelational(">");
  20865. this.state.inType = oldInType;
  20866. return this.finishNode(node, "TypeParameterInstantiation");
  20867. }
  20868. flowParseTypeParameterInstantiationCallOrNew() {
  20869. const node = this.startNode();
  20870. const oldInType = this.state.inType;
  20871. node.params = [];
  20872. this.state.inType = true;
  20873. this.expectRelational("<");
  20874. while (!this.isRelational(">")) {
  20875. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  20876. if (!this.isRelational(">")) {
  20877. this.expect(types$1.comma);
  20878. }
  20879. }
  20880. this.expectRelational(">");
  20881. this.state.inType = oldInType;
  20882. return this.finishNode(node, "TypeParameterInstantiation");
  20883. }
  20884. flowParseInterfaceType() {
  20885. const node = this.startNode();
  20886. this.expectContextual("interface");
  20887. node.extends = [];
  20888. if (this.eat(types$1._extends)) {
  20889. do {
  20890. node.extends.push(this.flowParseInterfaceExtends());
  20891. } while (this.eat(types$1.comma));
  20892. }
  20893. node.body = this.flowParseObjectType({
  20894. allowStatic: false,
  20895. allowExact: false,
  20896. allowSpread: false,
  20897. allowProto: false,
  20898. allowInexact: false
  20899. });
  20900. return this.finishNode(node, "InterfaceTypeAnnotation");
  20901. }
  20902. flowParseObjectPropertyKey() {
  20903. return this.match(types$1.num) || this.match(types$1.string) ? this.parseExprAtom() : this.parseIdentifier(true);
  20904. }
  20905. flowParseObjectTypeIndexer(node, isStatic, variance) {
  20906. node.static = isStatic;
  20907. if (this.lookahead().type === types$1.colon) {
  20908. node.id = this.flowParseObjectPropertyKey();
  20909. node.key = this.flowParseTypeInitialiser();
  20910. } else {
  20911. node.id = null;
  20912. node.key = this.flowParseType();
  20913. }
  20914. this.expect(types$1.bracketR);
  20915. node.value = this.flowParseTypeInitialiser();
  20916. node.variance = variance;
  20917. return this.finishNode(node, "ObjectTypeIndexer");
  20918. }
  20919. flowParseObjectTypeInternalSlot(node, isStatic) {
  20920. node.static = isStatic;
  20921. node.id = this.flowParseObjectPropertyKey();
  20922. this.expect(types$1.bracketR);
  20923. this.expect(types$1.bracketR);
  20924. if (this.isRelational("<") || this.match(types$1.parenL)) {
  20925. node.method = true;
  20926. node.optional = false;
  20927. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
  20928. } else {
  20929. node.method = false;
  20930. if (this.eat(types$1.question)) {
  20931. node.optional = true;
  20932. }
  20933. node.value = this.flowParseTypeInitialiser();
  20934. }
  20935. return this.finishNode(node, "ObjectTypeInternalSlot");
  20936. }
  20937. flowParseObjectTypeMethodish(node) {
  20938. node.params = [];
  20939. node.rest = null;
  20940. node.typeParameters = null;
  20941. node.this = null;
  20942. if (this.isRelational("<")) {
  20943. node.typeParameters = this.flowParseTypeParameterDeclaration();
  20944. }
  20945. this.expect(types$1.parenL);
  20946. if (this.match(types$1._this)) {
  20947. node.this = this.flowParseFunctionTypeParam(true);
  20948. node.this.name = null;
  20949. if (!this.match(types$1.parenR)) {
  20950. this.expect(types$1.comma);
  20951. }
  20952. }
  20953. while (!this.match(types$1.parenR) && !this.match(types$1.ellipsis)) {
  20954. node.params.push(this.flowParseFunctionTypeParam(false));
  20955. if (!this.match(types$1.parenR)) {
  20956. this.expect(types$1.comma);
  20957. }
  20958. }
  20959. if (this.eat(types$1.ellipsis)) {
  20960. node.rest = this.flowParseFunctionTypeParam(false);
  20961. }
  20962. this.expect(types$1.parenR);
  20963. node.returnType = this.flowParseTypeInitialiser();
  20964. return this.finishNode(node, "FunctionTypeAnnotation");
  20965. }
  20966. flowParseObjectTypeCallProperty(node, isStatic) {
  20967. const valueNode = this.startNode();
  20968. node.static = isStatic;
  20969. node.value = this.flowParseObjectTypeMethodish(valueNode);
  20970. return this.finishNode(node, "ObjectTypeCallProperty");
  20971. }
  20972. flowParseObjectType({
  20973. allowStatic,
  20974. allowExact,
  20975. allowSpread,
  20976. allowProto,
  20977. allowInexact
  20978. }) {
  20979. const oldInType = this.state.inType;
  20980. this.state.inType = true;
  20981. const nodeStart = this.startNode();
  20982. nodeStart.callProperties = [];
  20983. nodeStart.properties = [];
  20984. nodeStart.indexers = [];
  20985. nodeStart.internalSlots = [];
  20986. let endDelim;
  20987. let exact;
  20988. let inexact = false;
  20989. if (allowExact && this.match(types$1.braceBarL)) {
  20990. this.expect(types$1.braceBarL);
  20991. endDelim = types$1.braceBarR;
  20992. exact = true;
  20993. } else {
  20994. this.expect(types$1.braceL);
  20995. endDelim = types$1.braceR;
  20996. exact = false;
  20997. }
  20998. nodeStart.exact = exact;
  20999. while (!this.match(endDelim)) {
  21000. let isStatic = false;
  21001. let protoStart = null;
  21002. let inexactStart = null;
  21003. const node = this.startNode();
  21004. if (allowProto && this.isContextual("proto")) {
  21005. const lookahead = this.lookahead();
  21006. if (lookahead.type !== types$1.colon && lookahead.type !== types$1.question) {
  21007. this.next();
  21008. protoStart = this.state.start;
  21009. allowStatic = false;
  21010. }
  21011. }
  21012. if (allowStatic && this.isContextual("static")) {
  21013. const lookahead = this.lookahead();
  21014. if (lookahead.type !== types$1.colon && lookahead.type !== types$1.question) {
  21015. this.next();
  21016. isStatic = true;
  21017. }
  21018. }
  21019. const variance = this.flowParseVariance();
  21020. if (this.eat(types$1.bracketL)) {
  21021. if (protoStart != null) {
  21022. this.unexpected(protoStart);
  21023. }
  21024. if (this.eat(types$1.bracketL)) {
  21025. if (variance) {
  21026. this.unexpected(variance.start);
  21027. }
  21028. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  21029. } else {
  21030. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  21031. }
  21032. } else if (this.match(types$1.parenL) || this.isRelational("<")) {
  21033. if (protoStart != null) {
  21034. this.unexpected(protoStart);
  21035. }
  21036. if (variance) {
  21037. this.unexpected(variance.start);
  21038. }
  21039. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  21040. } else {
  21041. let kind = "init";
  21042. if (this.isContextual("get") || this.isContextual("set")) {
  21043. const lookahead = this.lookahead();
  21044. if (lookahead.type === types$1.name || lookahead.type === types$1.string || lookahead.type === types$1.num) {
  21045. kind = this.state.value;
  21046. this.next();
  21047. }
  21048. }
  21049. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  21050. if (propOrInexact === null) {
  21051. inexact = true;
  21052. inexactStart = this.state.lastTokStart;
  21053. } else {
  21054. nodeStart.properties.push(propOrInexact);
  21055. }
  21056. }
  21057. this.flowObjectTypeSemicolon();
  21058. if (inexactStart && !this.match(types$1.braceR) && !this.match(types$1.braceBarR)) {
  21059. this.raise(inexactStart, FlowErrors.UnexpectedExplicitInexactInObject);
  21060. }
  21061. }
  21062. this.expect(endDelim);
  21063. if (allowSpread) {
  21064. nodeStart.inexact = inexact;
  21065. }
  21066. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  21067. this.state.inType = oldInType;
  21068. return out;
  21069. }
  21070. flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) {
  21071. if (this.eat(types$1.ellipsis)) {
  21072. const isInexactToken = this.match(types$1.comma) || this.match(types$1.semi) || this.match(types$1.braceR) || this.match(types$1.braceBarR);
  21073. if (isInexactToken) {
  21074. if (!allowSpread) {
  21075. this.raise(this.state.lastTokStart, FlowErrors.InexactInsideNonObject);
  21076. } else if (!allowInexact) {
  21077. this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact);
  21078. }
  21079. if (variance) {
  21080. this.raise(variance.start, FlowErrors.InexactVariance);
  21081. }
  21082. return null;
  21083. }
  21084. if (!allowSpread) {
  21085. this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType);
  21086. }
  21087. if (protoStart != null) {
  21088. this.unexpected(protoStart);
  21089. }
  21090. if (variance) {
  21091. this.raise(variance.start, FlowErrors.SpreadVariance);
  21092. }
  21093. node.argument = this.flowParseType();
  21094. return this.finishNode(node, "ObjectTypeSpreadProperty");
  21095. } else {
  21096. node.key = this.flowParseObjectPropertyKey();
  21097. node.static = isStatic;
  21098. node.proto = protoStart != null;
  21099. node.kind = kind;
  21100. let optional = false;
  21101. if (this.isRelational("<") || this.match(types$1.parenL)) {
  21102. node.method = true;
  21103. if (protoStart != null) {
  21104. this.unexpected(protoStart);
  21105. }
  21106. if (variance) {
  21107. this.unexpected(variance.start);
  21108. }
  21109. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
  21110. if (kind === "get" || kind === "set") {
  21111. this.flowCheckGetterSetterParams(node);
  21112. }
  21113. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  21114. this.raise(node.value.this.start, FlowErrors.ThisParamBannedInConstructor);
  21115. }
  21116. } else {
  21117. if (kind !== "init") this.unexpected();
  21118. node.method = false;
  21119. if (this.eat(types$1.question)) {
  21120. optional = true;
  21121. }
  21122. node.value = this.flowParseTypeInitialiser();
  21123. node.variance = variance;
  21124. }
  21125. node.optional = optional;
  21126. return this.finishNode(node, "ObjectTypeProperty");
  21127. }
  21128. }
  21129. flowCheckGetterSetterParams(property) {
  21130. const paramCount = property.kind === "get" ? 0 : 1;
  21131. const start = property.start;
  21132. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  21133. if (property.value.this) {
  21134. this.raise(property.value.this.start, property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam);
  21135. }
  21136. if (length !== paramCount) {
  21137. if (property.kind === "get") {
  21138. this.raise(start, ErrorMessages.BadGetterArity);
  21139. } else {
  21140. this.raise(start, ErrorMessages.BadSetterArity);
  21141. }
  21142. }
  21143. if (property.kind === "set" && property.value.rest) {
  21144. this.raise(start, ErrorMessages.BadSetterRestParameter);
  21145. }
  21146. }
  21147. flowObjectTypeSemicolon() {
  21148. if (!this.eat(types$1.semi) && !this.eat(types$1.comma) && !this.match(types$1.braceR) && !this.match(types$1.braceBarR)) {
  21149. this.unexpected();
  21150. }
  21151. }
  21152. flowParseQualifiedTypeIdentifier(startPos, startLoc, id) {
  21153. startPos = startPos || this.state.start;
  21154. startLoc = startLoc || this.state.startLoc;
  21155. let node = id || this.flowParseRestrictedIdentifier(true);
  21156. while (this.eat(types$1.dot)) {
  21157. const node2 = this.startNodeAt(startPos, startLoc);
  21158. node2.qualification = node;
  21159. node2.id = this.flowParseRestrictedIdentifier(true);
  21160. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  21161. }
  21162. return node;
  21163. }
  21164. flowParseGenericType(startPos, startLoc, id) {
  21165. const node = this.startNodeAt(startPos, startLoc);
  21166. node.typeParameters = null;
  21167. node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id);
  21168. if (this.isRelational("<")) {
  21169. node.typeParameters = this.flowParseTypeParameterInstantiation();
  21170. }
  21171. return this.finishNode(node, "GenericTypeAnnotation");
  21172. }
  21173. flowParseTypeofType() {
  21174. const node = this.startNode();
  21175. this.expect(types$1._typeof);
  21176. node.argument = this.flowParsePrimaryType();
  21177. return this.finishNode(node, "TypeofTypeAnnotation");
  21178. }
  21179. flowParseTupleType() {
  21180. const node = this.startNode();
  21181. node.types = [];
  21182. this.expect(types$1.bracketL);
  21183. while (this.state.pos < this.length && !this.match(types$1.bracketR)) {
  21184. node.types.push(this.flowParseType());
  21185. if (this.match(types$1.bracketR)) break;
  21186. this.expect(types$1.comma);
  21187. }
  21188. this.expect(types$1.bracketR);
  21189. return this.finishNode(node, "TupleTypeAnnotation");
  21190. }
  21191. flowParseFunctionTypeParam(first) {
  21192. let name = null;
  21193. let optional = false;
  21194. let typeAnnotation = null;
  21195. const node = this.startNode();
  21196. const lh = this.lookahead();
  21197. const isThis = this.state.type === types$1._this;
  21198. if (lh.type === types$1.colon || lh.type === types$1.question) {
  21199. if (isThis && !first) {
  21200. this.raise(node.start, FlowErrors.ThisParamMustBeFirst);
  21201. }
  21202. name = this.parseIdentifier(isThis);
  21203. if (this.eat(types$1.question)) {
  21204. optional = true;
  21205. if (isThis) {
  21206. this.raise(node.start, FlowErrors.ThisParamMayNotBeOptional);
  21207. }
  21208. }
  21209. typeAnnotation = this.flowParseTypeInitialiser();
  21210. } else {
  21211. typeAnnotation = this.flowParseType();
  21212. }
  21213. node.name = name;
  21214. node.optional = optional;
  21215. node.typeAnnotation = typeAnnotation;
  21216. return this.finishNode(node, "FunctionTypeParam");
  21217. }
  21218. reinterpretTypeAsFunctionTypeParam(type) {
  21219. const node = this.startNodeAt(type.start, type.loc.start);
  21220. node.name = null;
  21221. node.optional = false;
  21222. node.typeAnnotation = type;
  21223. return this.finishNode(node, "FunctionTypeParam");
  21224. }
  21225. flowParseFunctionTypeParams(params = []) {
  21226. let rest = null;
  21227. let _this = null;
  21228. if (this.match(types$1._this)) {
  21229. _this = this.flowParseFunctionTypeParam(true);
  21230. _this.name = null;
  21231. if (!this.match(types$1.parenR)) {
  21232. this.expect(types$1.comma);
  21233. }
  21234. }
  21235. while (!this.match(types$1.parenR) && !this.match(types$1.ellipsis)) {
  21236. params.push(this.flowParseFunctionTypeParam(false));
  21237. if (!this.match(types$1.parenR)) {
  21238. this.expect(types$1.comma);
  21239. }
  21240. }
  21241. if (this.eat(types$1.ellipsis)) {
  21242. rest = this.flowParseFunctionTypeParam(false);
  21243. }
  21244. return {
  21245. params,
  21246. rest,
  21247. _this
  21248. };
  21249. }
  21250. flowIdentToTypeAnnotation(startPos, startLoc, node, id) {
  21251. switch (id.name) {
  21252. case "any":
  21253. return this.finishNode(node, "AnyTypeAnnotation");
  21254. case "bool":
  21255. case "boolean":
  21256. return this.finishNode(node, "BooleanTypeAnnotation");
  21257. case "mixed":
  21258. return this.finishNode(node, "MixedTypeAnnotation");
  21259. case "empty":
  21260. return this.finishNode(node, "EmptyTypeAnnotation");
  21261. case "number":
  21262. return this.finishNode(node, "NumberTypeAnnotation");
  21263. case "string":
  21264. return this.finishNode(node, "StringTypeAnnotation");
  21265. case "symbol":
  21266. return this.finishNode(node, "SymbolTypeAnnotation");
  21267. default:
  21268. this.checkNotUnderscore(id.name);
  21269. return this.flowParseGenericType(startPos, startLoc, id);
  21270. }
  21271. }
  21272. flowParsePrimaryType() {
  21273. const startPos = this.state.start;
  21274. const startLoc = this.state.startLoc;
  21275. const node = this.startNode();
  21276. let tmp;
  21277. let type;
  21278. let isGroupedType = false;
  21279. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  21280. switch (this.state.type) {
  21281. case types$1.name:
  21282. if (this.isContextual("interface")) {
  21283. return this.flowParseInterfaceType();
  21284. }
  21285. return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdentifier());
  21286. case types$1.braceL:
  21287. return this.flowParseObjectType({
  21288. allowStatic: false,
  21289. allowExact: false,
  21290. allowSpread: true,
  21291. allowProto: false,
  21292. allowInexact: true
  21293. });
  21294. case types$1.braceBarL:
  21295. return this.flowParseObjectType({
  21296. allowStatic: false,
  21297. allowExact: true,
  21298. allowSpread: true,
  21299. allowProto: false,
  21300. allowInexact: false
  21301. });
  21302. case types$1.bracketL:
  21303. this.state.noAnonFunctionType = false;
  21304. type = this.flowParseTupleType();
  21305. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  21306. return type;
  21307. case types$1.relational:
  21308. if (this.state.value === "<") {
  21309. node.typeParameters = this.flowParseTypeParameterDeclaration();
  21310. this.expect(types$1.parenL);
  21311. tmp = this.flowParseFunctionTypeParams();
  21312. node.params = tmp.params;
  21313. node.rest = tmp.rest;
  21314. node.this = tmp._this;
  21315. this.expect(types$1.parenR);
  21316. this.expect(types$1.arrow);
  21317. node.returnType = this.flowParseType();
  21318. return this.finishNode(node, "FunctionTypeAnnotation");
  21319. }
  21320. break;
  21321. case types$1.parenL:
  21322. this.next();
  21323. if (!this.match(types$1.parenR) && !this.match(types$1.ellipsis)) {
  21324. if (this.match(types$1.name) || this.match(types$1._this)) {
  21325. const token = this.lookahead().type;
  21326. isGroupedType = token !== types$1.question && token !== types$1.colon;
  21327. } else {
  21328. isGroupedType = true;
  21329. }
  21330. }
  21331. if (isGroupedType) {
  21332. this.state.noAnonFunctionType = false;
  21333. type = this.flowParseType();
  21334. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  21335. if (this.state.noAnonFunctionType || !(this.match(types$1.comma) || this.match(types$1.parenR) && this.lookahead().type === types$1.arrow)) {
  21336. this.expect(types$1.parenR);
  21337. return type;
  21338. } else {
  21339. this.eat(types$1.comma);
  21340. }
  21341. }
  21342. if (type) {
  21343. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  21344. } else {
  21345. tmp = this.flowParseFunctionTypeParams();
  21346. }
  21347. node.params = tmp.params;
  21348. node.rest = tmp.rest;
  21349. node.this = tmp._this;
  21350. this.expect(types$1.parenR);
  21351. this.expect(types$1.arrow);
  21352. node.returnType = this.flowParseType();
  21353. node.typeParameters = null;
  21354. return this.finishNode(node, "FunctionTypeAnnotation");
  21355. case types$1.string:
  21356. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  21357. case types$1._true:
  21358. case types$1._false:
  21359. node.value = this.match(types$1._true);
  21360. this.next();
  21361. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  21362. case types$1.plusMin:
  21363. if (this.state.value === "-") {
  21364. this.next();
  21365. if (this.match(types$1.num)) {
  21366. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  21367. }
  21368. if (this.match(types$1.bigint)) {
  21369. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  21370. }
  21371. throw this.raise(this.state.start, FlowErrors.UnexpectedSubtractionOperand);
  21372. }
  21373. throw this.unexpected();
  21374. case types$1.num:
  21375. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  21376. case types$1.bigint:
  21377. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  21378. case types$1._void:
  21379. this.next();
  21380. return this.finishNode(node, "VoidTypeAnnotation");
  21381. case types$1._null:
  21382. this.next();
  21383. return this.finishNode(node, "NullLiteralTypeAnnotation");
  21384. case types$1._this:
  21385. this.next();
  21386. return this.finishNode(node, "ThisTypeAnnotation");
  21387. case types$1.star:
  21388. this.next();
  21389. return this.finishNode(node, "ExistsTypeAnnotation");
  21390. default:
  21391. if (this.state.type.keyword === "typeof") {
  21392. return this.flowParseTypeofType();
  21393. } else if (this.state.type.keyword) {
  21394. const label = this.state.type.label;
  21395. this.next();
  21396. return super.createIdentifier(node, label);
  21397. }
  21398. }
  21399. throw this.unexpected();
  21400. }
  21401. flowParsePostfixType() {
  21402. const startPos = this.state.start;
  21403. const startLoc = this.state.startLoc;
  21404. let type = this.flowParsePrimaryType();
  21405. let seenOptionalIndexedAccess = false;
  21406. while ((this.match(types$1.bracketL) || this.match(types$1.questionDot)) && !this.canInsertSemicolon()) {
  21407. const node = this.startNodeAt(startPos, startLoc);
  21408. const optional = this.eat(types$1.questionDot);
  21409. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  21410. this.expect(types$1.bracketL);
  21411. if (!optional && this.match(types$1.bracketR)) {
  21412. node.elementType = type;
  21413. this.next();
  21414. type = this.finishNode(node, "ArrayTypeAnnotation");
  21415. } else {
  21416. node.objectType = type;
  21417. node.indexType = this.flowParseType();
  21418. this.expect(types$1.bracketR);
  21419. if (seenOptionalIndexedAccess) {
  21420. node.optional = optional;
  21421. type = this.finishNode(node, "OptionalIndexedAccessType");
  21422. } else {
  21423. type = this.finishNode(node, "IndexedAccessType");
  21424. }
  21425. }
  21426. }
  21427. return type;
  21428. }
  21429. flowParsePrefixType() {
  21430. const node = this.startNode();
  21431. if (this.eat(types$1.question)) {
  21432. node.typeAnnotation = this.flowParsePrefixType();
  21433. return this.finishNode(node, "NullableTypeAnnotation");
  21434. } else {
  21435. return this.flowParsePostfixType();
  21436. }
  21437. }
  21438. flowParseAnonFunctionWithoutParens() {
  21439. const param = this.flowParsePrefixType();
  21440. if (!this.state.noAnonFunctionType && this.eat(types$1.arrow)) {
  21441. const node = this.startNodeAt(param.start, param.loc.start);
  21442. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  21443. node.rest = null;
  21444. node.this = null;
  21445. node.returnType = this.flowParseType();
  21446. node.typeParameters = null;
  21447. return this.finishNode(node, "FunctionTypeAnnotation");
  21448. }
  21449. return param;
  21450. }
  21451. flowParseIntersectionType() {
  21452. const node = this.startNode();
  21453. this.eat(types$1.bitwiseAND);
  21454. const type = this.flowParseAnonFunctionWithoutParens();
  21455. node.types = [type];
  21456. while (this.eat(types$1.bitwiseAND)) {
  21457. node.types.push(this.flowParseAnonFunctionWithoutParens());
  21458. }
  21459. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  21460. }
  21461. flowParseUnionType() {
  21462. const node = this.startNode();
  21463. this.eat(types$1.bitwiseOR);
  21464. const type = this.flowParseIntersectionType();
  21465. node.types = [type];
  21466. while (this.eat(types$1.bitwiseOR)) {
  21467. node.types.push(this.flowParseIntersectionType());
  21468. }
  21469. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  21470. }
  21471. flowParseType() {
  21472. const oldInType = this.state.inType;
  21473. this.state.inType = true;
  21474. const type = this.flowParseUnionType();
  21475. this.state.inType = oldInType;
  21476. return type;
  21477. }
  21478. flowParseTypeOrImplicitInstantiation() {
  21479. if (this.state.type === types$1.name && this.state.value === "_") {
  21480. const startPos = this.state.start;
  21481. const startLoc = this.state.startLoc;
  21482. const node = this.parseIdentifier();
  21483. return this.flowParseGenericType(startPos, startLoc, node);
  21484. } else {
  21485. return this.flowParseType();
  21486. }
  21487. }
  21488. flowParseTypeAnnotation() {
  21489. const node = this.startNode();
  21490. node.typeAnnotation = this.flowParseTypeInitialiser();
  21491. return this.finishNode(node, "TypeAnnotation");
  21492. }
  21493. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  21494. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  21495. if (this.match(types$1.colon)) {
  21496. ident.typeAnnotation = this.flowParseTypeAnnotation();
  21497. this.resetEndLocation(ident);
  21498. }
  21499. return ident;
  21500. }
  21501. typeCastToParameter(node) {
  21502. node.expression.typeAnnotation = node.typeAnnotation;
  21503. this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
  21504. return node.expression;
  21505. }
  21506. flowParseVariance() {
  21507. let variance = null;
  21508. if (this.match(types$1.plusMin)) {
  21509. variance = this.startNode();
  21510. if (this.state.value === "+") {
  21511. variance.kind = "plus";
  21512. } else {
  21513. variance.kind = "minus";
  21514. }
  21515. this.next();
  21516. this.finishNode(variance, "Variance");
  21517. }
  21518. return variance;
  21519. }
  21520. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  21521. if (allowExpressionBody) {
  21522. return this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  21523. }
  21524. return super.parseFunctionBody(node, false, isMethod);
  21525. }
  21526. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  21527. if (this.match(types$1.colon)) {
  21528. const typeNode = this.startNode();
  21529. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  21530. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  21531. }
  21532. super.parseFunctionBodyAndFinish(node, type, isMethod);
  21533. }
  21534. parseStatement(context, topLevel) {
  21535. if (this.state.strict && this.match(types$1.name) && this.state.value === "interface") {
  21536. const lookahead = this.lookahead();
  21537. if (lookahead.type === types$1.name || isKeyword$1(lookahead.value)) {
  21538. const node = this.startNode();
  21539. this.next();
  21540. return this.flowParseInterface(node);
  21541. }
  21542. } else if (this.shouldParseEnums() && this.isContextual("enum")) {
  21543. const node = this.startNode();
  21544. this.next();
  21545. return this.flowParseEnumDeclaration(node);
  21546. }
  21547. const stmt = super.parseStatement(context, topLevel);
  21548. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  21549. this.flowPragma = null;
  21550. }
  21551. return stmt;
  21552. }
  21553. parseExpressionStatement(node, expr) {
  21554. if (expr.type === "Identifier") {
  21555. if (expr.name === "declare") {
  21556. if (this.match(types$1._class) || this.match(types$1.name) || this.match(types$1._function) || this.match(types$1._var) || this.match(types$1._export)) {
  21557. return this.flowParseDeclare(node);
  21558. }
  21559. } else if (this.match(types$1.name)) {
  21560. if (expr.name === "interface") {
  21561. return this.flowParseInterface(node);
  21562. } else if (expr.name === "type") {
  21563. return this.flowParseTypeAlias(node);
  21564. } else if (expr.name === "opaque") {
  21565. return this.flowParseOpaqueType(node, false);
  21566. }
  21567. }
  21568. }
  21569. return super.parseExpressionStatement(node, expr);
  21570. }
  21571. shouldParseExportDeclaration() {
  21572. return this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || this.shouldParseEnums() && this.isContextual("enum") || super.shouldParseExportDeclaration();
  21573. }
  21574. isExportDefaultSpecifier() {
  21575. if (this.match(types$1.name) && (this.state.value === "type" || this.state.value === "interface" || this.state.value === "opaque" || this.shouldParseEnums() && this.state.value === "enum")) {
  21576. return false;
  21577. }
  21578. return super.isExportDefaultSpecifier();
  21579. }
  21580. parseExportDefaultExpression() {
  21581. if (this.shouldParseEnums() && this.isContextual("enum")) {
  21582. const node = this.startNode();
  21583. this.next();
  21584. return this.flowParseEnumDeclaration(node);
  21585. }
  21586. return super.parseExportDefaultExpression();
  21587. }
  21588. parseConditional(expr, startPos, startLoc, refExpressionErrors) {
  21589. if (!this.match(types$1.question)) return expr;
  21590. if (this.state.maybeInArrowParameters) {
  21591. const nextCh = this.lookaheadCharCode();
  21592. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  21593. this.setOptionalParametersError(refExpressionErrors);
  21594. return expr;
  21595. }
  21596. }
  21597. this.expect(types$1.question);
  21598. const state = this.state.clone();
  21599. const originalNoArrowAt = this.state.noArrowAt;
  21600. const node = this.startNodeAt(startPos, startLoc);
  21601. let {
  21602. consequent,
  21603. failed
  21604. } = this.tryParseConditionalConsequent();
  21605. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  21606. if (failed || invalid.length > 0) {
  21607. const noArrowAt = [...originalNoArrowAt];
  21608. if (invalid.length > 0) {
  21609. this.state = state;
  21610. this.state.noArrowAt = noArrowAt;
  21611. for (let i = 0; i < invalid.length; i++) {
  21612. noArrowAt.push(invalid[i].start);
  21613. }
  21614. ({
  21615. consequent,
  21616. failed
  21617. } = this.tryParseConditionalConsequent());
  21618. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  21619. }
  21620. if (failed && valid.length > 1) {
  21621. this.raise(state.start, FlowErrors.AmbiguousConditionalArrow);
  21622. }
  21623. if (failed && valid.length === 1) {
  21624. this.state = state;
  21625. this.state.noArrowAt = noArrowAt.concat(valid[0].start);
  21626. ({
  21627. consequent,
  21628. failed
  21629. } = this.tryParseConditionalConsequent());
  21630. }
  21631. }
  21632. this.getArrowLikeExpressions(consequent, true);
  21633. this.state.noArrowAt = originalNoArrowAt;
  21634. this.expect(types$1.colon);
  21635. node.test = expr;
  21636. node.consequent = consequent;
  21637. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  21638. return this.finishNode(node, "ConditionalExpression");
  21639. }
  21640. tryParseConditionalConsequent() {
  21641. this.state.noArrowParamsConversionAt.push(this.state.start);
  21642. const consequent = this.parseMaybeAssignAllowIn();
  21643. const failed = !this.match(types$1.colon);
  21644. this.state.noArrowParamsConversionAt.pop();
  21645. return {
  21646. consequent,
  21647. failed
  21648. };
  21649. }
  21650. getArrowLikeExpressions(node, disallowInvalid) {
  21651. const stack = [node];
  21652. const arrows = [];
  21653. while (stack.length !== 0) {
  21654. const node = stack.pop();
  21655. if (node.type === "ArrowFunctionExpression") {
  21656. if (node.typeParameters || !node.returnType) {
  21657. this.finishArrowValidation(node);
  21658. } else {
  21659. arrows.push(node);
  21660. }
  21661. stack.push(node.body);
  21662. } else if (node.type === "ConditionalExpression") {
  21663. stack.push(node.consequent);
  21664. stack.push(node.alternate);
  21665. }
  21666. }
  21667. if (disallowInvalid) {
  21668. arrows.forEach(node => this.finishArrowValidation(node));
  21669. return [arrows, []];
  21670. }
  21671. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  21672. }
  21673. finishArrowValidation(node) {
  21674. var _node$extra;
  21675. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma, false);
  21676. this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
  21677. super.checkParams(node, false, true);
  21678. this.scope.exit();
  21679. }
  21680. forwardNoArrowParamsConversionAt(node, parse) {
  21681. let result;
  21682. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  21683. this.state.noArrowParamsConversionAt.push(this.state.start);
  21684. result = parse();
  21685. this.state.noArrowParamsConversionAt.pop();
  21686. } else {
  21687. result = parse();
  21688. }
  21689. return result;
  21690. }
  21691. parseParenItem(node, startPos, startLoc) {
  21692. node = super.parseParenItem(node, startPos, startLoc);
  21693. if (this.eat(types$1.question)) {
  21694. node.optional = true;
  21695. this.resetEndLocation(node);
  21696. }
  21697. if (this.match(types$1.colon)) {
  21698. const typeCastNode = this.startNodeAt(startPos, startLoc);
  21699. typeCastNode.expression = node;
  21700. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  21701. return this.finishNode(typeCastNode, "TypeCastExpression");
  21702. }
  21703. return node;
  21704. }
  21705. assertModuleNodeAllowed(node) {
  21706. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  21707. return;
  21708. }
  21709. super.assertModuleNodeAllowed(node);
  21710. }
  21711. parseExport(node) {
  21712. const decl = super.parseExport(node);
  21713. if (decl.type === "ExportNamedDeclaration" || decl.type === "ExportAllDeclaration") {
  21714. decl.exportKind = decl.exportKind || "value";
  21715. }
  21716. return decl;
  21717. }
  21718. parseExportDeclaration(node) {
  21719. if (this.isContextual("type")) {
  21720. node.exportKind = "type";
  21721. const declarationNode = this.startNode();
  21722. this.next();
  21723. if (this.match(types$1.braceL)) {
  21724. node.specifiers = this.parseExportSpecifiers();
  21725. this.parseExportFrom(node);
  21726. return null;
  21727. } else {
  21728. return this.flowParseTypeAlias(declarationNode);
  21729. }
  21730. } else if (this.isContextual("opaque")) {
  21731. node.exportKind = "type";
  21732. const declarationNode = this.startNode();
  21733. this.next();
  21734. return this.flowParseOpaqueType(declarationNode, false);
  21735. } else if (this.isContextual("interface")) {
  21736. node.exportKind = "type";
  21737. const declarationNode = this.startNode();
  21738. this.next();
  21739. return this.flowParseInterface(declarationNode);
  21740. } else if (this.shouldParseEnums() && this.isContextual("enum")) {
  21741. node.exportKind = "value";
  21742. const declarationNode = this.startNode();
  21743. this.next();
  21744. return this.flowParseEnumDeclaration(declarationNode);
  21745. } else {
  21746. return super.parseExportDeclaration(node);
  21747. }
  21748. }
  21749. eatExportStar(node) {
  21750. if (super.eatExportStar(...arguments)) return true;
  21751. if (this.isContextual("type") && this.lookahead().type === types$1.star) {
  21752. node.exportKind = "type";
  21753. this.next();
  21754. this.next();
  21755. return true;
  21756. }
  21757. return false;
  21758. }
  21759. maybeParseExportNamespaceSpecifier(node) {
  21760. const pos = this.state.start;
  21761. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  21762. if (hasNamespace && node.exportKind === "type") {
  21763. this.unexpected(pos);
  21764. }
  21765. return hasNamespace;
  21766. }
  21767. parseClassId(node, isStatement, optionalId) {
  21768. super.parseClassId(node, isStatement, optionalId);
  21769. if (this.isRelational("<")) {
  21770. node.typeParameters = this.flowParseTypeParameterDeclaration();
  21771. }
  21772. }
  21773. parseClassMember(classBody, member, state) {
  21774. const pos = this.state.start;
  21775. if (this.isContextual("declare")) {
  21776. if (this.parseClassMemberFromModifier(classBody, member)) {
  21777. return;
  21778. }
  21779. member.declare = true;
  21780. }
  21781. super.parseClassMember(classBody, member, state);
  21782. if (member.declare) {
  21783. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  21784. this.raise(pos, FlowErrors.DeclareClassElement);
  21785. } else if (member.value) {
  21786. this.raise(member.value.start, FlowErrors.DeclareClassFieldInitializer);
  21787. }
  21788. }
  21789. }
  21790. isIterator(word) {
  21791. return word === "iterator" || word === "asyncIterator";
  21792. }
  21793. readIterator() {
  21794. const word = super.readWord1();
  21795. const fullWord = "@@" + word;
  21796. if (!this.isIterator(word) || !this.state.inType) {
  21797. this.raise(this.state.pos, ErrorMessages.InvalidIdentifier, fullWord);
  21798. }
  21799. this.finishToken(types$1.name, fullWord);
  21800. }
  21801. getTokenFromCode(code) {
  21802. const next = this.input.charCodeAt(this.state.pos + 1);
  21803. if (code === 123 && next === 124) {
  21804. return this.finishOp(types$1.braceBarL, 2);
  21805. } else if (this.state.inType && (code === 62 || code === 60)) {
  21806. return this.finishOp(types$1.relational, 1);
  21807. } else if (this.state.inType && code === 63) {
  21808. if (next === 46) {
  21809. return this.finishOp(types$1.questionDot, 2);
  21810. }
  21811. return this.finishOp(types$1.question, 1);
  21812. } else if (isIteratorStart(code, next)) {
  21813. this.state.pos += 2;
  21814. return this.readIterator();
  21815. } else {
  21816. return super.getTokenFromCode(code);
  21817. }
  21818. }
  21819. isAssignable(node, isBinding) {
  21820. if (node.type === "TypeCastExpression") {
  21821. return this.isAssignable(node.expression, isBinding);
  21822. } else {
  21823. return super.isAssignable(node, isBinding);
  21824. }
  21825. }
  21826. toAssignable(node, isLHS = false) {
  21827. if (node.type === "TypeCastExpression") {
  21828. return super.toAssignable(this.typeCastToParameter(node), isLHS);
  21829. } else {
  21830. return super.toAssignable(node, isLHS);
  21831. }
  21832. }
  21833. toAssignableList(exprList, trailingCommaPos, isLHS) {
  21834. for (let i = 0; i < exprList.length; i++) {
  21835. const expr = exprList[i];
  21836. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  21837. exprList[i] = this.typeCastToParameter(expr);
  21838. }
  21839. }
  21840. return super.toAssignableList(exprList, trailingCommaPos, isLHS);
  21841. }
  21842. toReferencedList(exprList, isParenthesizedExpr) {
  21843. for (let i = 0; i < exprList.length; i++) {
  21844. var _expr$extra;
  21845. const expr = exprList[i];
  21846. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  21847. this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern);
  21848. }
  21849. }
  21850. return exprList;
  21851. }
  21852. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  21853. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  21854. if (canBePattern && !this.state.maybeInArrowParameters) {
  21855. this.toReferencedList(node.elements);
  21856. }
  21857. return node;
  21858. }
  21859. checkLVal(expr, ...args) {
  21860. if (expr.type !== "TypeCastExpression") {
  21861. return super.checkLVal(expr, ...args);
  21862. }
  21863. }
  21864. parseClassProperty(node) {
  21865. if (this.match(types$1.colon)) {
  21866. node.typeAnnotation = this.flowParseTypeAnnotation();
  21867. }
  21868. return super.parseClassProperty(node);
  21869. }
  21870. parseClassPrivateProperty(node) {
  21871. if (this.match(types$1.colon)) {
  21872. node.typeAnnotation = this.flowParseTypeAnnotation();
  21873. }
  21874. return super.parseClassPrivateProperty(node);
  21875. }
  21876. isClassMethod() {
  21877. return this.isRelational("<") || super.isClassMethod();
  21878. }
  21879. isClassProperty() {
  21880. return this.match(types$1.colon) || super.isClassProperty();
  21881. }
  21882. isNonstaticConstructor(method) {
  21883. return !this.match(types$1.colon) && super.isNonstaticConstructor(method);
  21884. }
  21885. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  21886. if (method.variance) {
  21887. this.unexpected(method.variance.start);
  21888. }
  21889. delete method.variance;
  21890. if (this.isRelational("<")) {
  21891. method.typeParameters = this.flowParseTypeParameterDeclaration();
  21892. }
  21893. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  21894. if (method.params && isConstructor) {
  21895. const params = method.params;
  21896. if (params.length > 0 && this.isThisParam(params[0])) {
  21897. this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
  21898. }
  21899. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  21900. const params = method.value.params;
  21901. if (params.length > 0 && this.isThisParam(params[0])) {
  21902. this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
  21903. }
  21904. }
  21905. }
  21906. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  21907. if (method.variance) {
  21908. this.unexpected(method.variance.start);
  21909. }
  21910. delete method.variance;
  21911. if (this.isRelational("<")) {
  21912. method.typeParameters = this.flowParseTypeParameterDeclaration();
  21913. }
  21914. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  21915. }
  21916. parseClassSuper(node) {
  21917. super.parseClassSuper(node);
  21918. if (node.superClass && this.isRelational("<")) {
  21919. node.superTypeParameters = this.flowParseTypeParameterInstantiation();
  21920. }
  21921. if (this.isContextual("implements")) {
  21922. this.next();
  21923. const implemented = node.implements = [];
  21924. do {
  21925. const node = this.startNode();
  21926. node.id = this.flowParseRestrictedIdentifier(true);
  21927. if (this.isRelational("<")) {
  21928. node.typeParameters = this.flowParseTypeParameterInstantiation();
  21929. } else {
  21930. node.typeParameters = null;
  21931. }
  21932. implemented.push(this.finishNode(node, "ClassImplements"));
  21933. } while (this.eat(types$1.comma));
  21934. }
  21935. }
  21936. checkGetterSetterParams(method) {
  21937. super.checkGetterSetterParams(method);
  21938. const params = this.getObjectOrClassMethodParams(method);
  21939. if (params.length > 0) {
  21940. const param = params[0];
  21941. if (this.isThisParam(param) && method.kind === "get") {
  21942. this.raise(param.start, FlowErrors.GetterMayNotHaveThisParam);
  21943. } else if (this.isThisParam(param)) {
  21944. this.raise(param.start, FlowErrors.SetterMayNotHaveThisParam);
  21945. }
  21946. }
  21947. }
  21948. parsePropertyName(node, isPrivateNameAllowed) {
  21949. const variance = this.flowParseVariance();
  21950. const key = super.parsePropertyName(node, isPrivateNameAllowed);
  21951. node.variance = variance;
  21952. return key;
  21953. }
  21954. parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  21955. if (prop.variance) {
  21956. this.unexpected(prop.variance.start);
  21957. }
  21958. delete prop.variance;
  21959. let typeParameters;
  21960. if (this.isRelational("<") && !isAccessor) {
  21961. typeParameters = this.flowParseTypeParameterDeclaration();
  21962. if (!this.match(types$1.parenL)) this.unexpected();
  21963. }
  21964. super.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  21965. if (typeParameters) {
  21966. (prop.value || prop).typeParameters = typeParameters;
  21967. }
  21968. }
  21969. parseAssignableListItemTypes(param) {
  21970. if (this.eat(types$1.question)) {
  21971. if (param.type !== "Identifier") {
  21972. this.raise(param.start, FlowErrors.OptionalBindingPattern);
  21973. }
  21974. if (this.isThisParam(param)) {
  21975. this.raise(param.start, FlowErrors.ThisParamMayNotBeOptional);
  21976. }
  21977. param.optional = true;
  21978. }
  21979. if (this.match(types$1.colon)) {
  21980. param.typeAnnotation = this.flowParseTypeAnnotation();
  21981. } else if (this.isThisParam(param)) {
  21982. this.raise(param.start, FlowErrors.ThisParamAnnotationRequired);
  21983. }
  21984. if (this.match(types$1.eq) && this.isThisParam(param)) {
  21985. this.raise(param.start, FlowErrors.ThisParamNoDefault);
  21986. }
  21987. this.resetEndLocation(param);
  21988. return param;
  21989. }
  21990. parseMaybeDefault(startPos, startLoc, left) {
  21991. const node = super.parseMaybeDefault(startPos, startLoc, left);
  21992. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  21993. this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer);
  21994. }
  21995. return node;
  21996. }
  21997. shouldParseDefaultImport(node) {
  21998. if (!hasTypeImportKind(node)) {
  21999. return super.shouldParseDefaultImport(node);
  22000. }
  22001. return isMaybeDefaultImport(this.state);
  22002. }
  22003. parseImportSpecifierLocal(node, specifier, type, contextDescription) {
  22004. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  22005. this.checkLVal(specifier.local, contextDescription, BIND_LEXICAL);
  22006. node.specifiers.push(this.finishNode(specifier, type));
  22007. }
  22008. maybeParseDefaultImportSpecifier(node) {
  22009. node.importKind = "value";
  22010. let kind = null;
  22011. if (this.match(types$1._typeof)) {
  22012. kind = "typeof";
  22013. } else if (this.isContextual("type")) {
  22014. kind = "type";
  22015. }
  22016. if (kind) {
  22017. const lh = this.lookahead();
  22018. if (kind === "type" && lh.type === types$1.star) {
  22019. this.unexpected(lh.start);
  22020. }
  22021. if (isMaybeDefaultImport(lh) || lh.type === types$1.braceL || lh.type === types$1.star) {
  22022. this.next();
  22023. node.importKind = kind;
  22024. }
  22025. }
  22026. return super.maybeParseDefaultImportSpecifier(node);
  22027. }
  22028. parseImportSpecifier(node) {
  22029. const specifier = this.startNode();
  22030. const firstIdentIsString = this.match(types$1.string);
  22031. const firstIdent = this.parseModuleExportName();
  22032. let specifierTypeKind = null;
  22033. if (firstIdent.type === "Identifier") {
  22034. if (firstIdent.name === "type") {
  22035. specifierTypeKind = "type";
  22036. } else if (firstIdent.name === "typeof") {
  22037. specifierTypeKind = "typeof";
  22038. }
  22039. }
  22040. let isBinding = false;
  22041. if (this.isContextual("as") && !this.isLookaheadContextual("as")) {
  22042. const as_ident = this.parseIdentifier(true);
  22043. if (specifierTypeKind !== null && !this.match(types$1.name) && !this.state.type.keyword) {
  22044. specifier.imported = as_ident;
  22045. specifier.importKind = specifierTypeKind;
  22046. specifier.local = cloneIdentifier(as_ident);
  22047. } else {
  22048. specifier.imported = firstIdent;
  22049. specifier.importKind = null;
  22050. specifier.local = this.parseIdentifier();
  22051. }
  22052. } else {
  22053. if (specifierTypeKind !== null && (this.match(types$1.name) || this.state.type.keyword)) {
  22054. specifier.imported = this.parseIdentifier(true);
  22055. specifier.importKind = specifierTypeKind;
  22056. } else {
  22057. if (firstIdentIsString) {
  22058. throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, firstIdent.value);
  22059. }
  22060. specifier.imported = firstIdent;
  22061. specifier.importKind = null;
  22062. }
  22063. if (this.eatContextual("as")) {
  22064. specifier.local = this.parseIdentifier();
  22065. } else {
  22066. isBinding = true;
  22067. specifier.local = cloneIdentifier(specifier.imported);
  22068. }
  22069. }
  22070. const nodeIsTypeImport = hasTypeImportKind(node);
  22071. const specifierIsTypeImport = hasTypeImportKind(specifier);
  22072. if (nodeIsTypeImport && specifierIsTypeImport) {
  22073. this.raise(specifier.start, FlowErrors.ImportTypeShorthandOnlyInPureImport);
  22074. }
  22075. if (nodeIsTypeImport || specifierIsTypeImport) {
  22076. this.checkReservedType(specifier.local.name, specifier.local.start, true);
  22077. }
  22078. if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) {
  22079. this.checkReservedWord(specifier.local.name, specifier.start, true, true);
  22080. }
  22081. this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
  22082. node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
  22083. }
  22084. parseBindingAtom() {
  22085. switch (this.state.type) {
  22086. case types$1._this:
  22087. return this.parseIdentifier(true);
  22088. default:
  22089. return super.parseBindingAtom();
  22090. }
  22091. }
  22092. parseFunctionParams(node, allowModifiers) {
  22093. const kind = node.kind;
  22094. if (kind !== "get" && kind !== "set" && this.isRelational("<")) {
  22095. node.typeParameters = this.flowParseTypeParameterDeclaration();
  22096. }
  22097. super.parseFunctionParams(node, allowModifiers);
  22098. }
  22099. parseVarId(decl, kind) {
  22100. super.parseVarId(decl, kind);
  22101. if (this.match(types$1.colon)) {
  22102. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  22103. this.resetEndLocation(decl.id);
  22104. }
  22105. }
  22106. parseAsyncArrowFromCallExpression(node, call) {
  22107. if (this.match(types$1.colon)) {
  22108. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  22109. this.state.noAnonFunctionType = true;
  22110. node.returnType = this.flowParseTypeAnnotation();
  22111. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  22112. }
  22113. return super.parseAsyncArrowFromCallExpression(node, call);
  22114. }
  22115. shouldParseAsyncArrow() {
  22116. return this.match(types$1.colon) || super.shouldParseAsyncArrow();
  22117. }
  22118. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  22119. var _jsx;
  22120. let state = null;
  22121. let jsx;
  22122. if (this.hasPlugin("jsx") && (this.match(types$1.jsxTagStart) || this.isRelational("<"))) {
  22123. state = this.state.clone();
  22124. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  22125. if (!jsx.error) return jsx.node;
  22126. const {
  22127. context
  22128. } = this.state;
  22129. const curContext = context[context.length - 1];
  22130. if (curContext === types.j_oTag) {
  22131. context.length -= 2;
  22132. } else if (curContext === types.j_expr) {
  22133. context.length -= 1;
  22134. }
  22135. }
  22136. if ((_jsx = jsx) != null && _jsx.error || this.isRelational("<")) {
  22137. var _jsx2, _jsx3;
  22138. state = state || this.state.clone();
  22139. let typeParameters;
  22140. const arrow = this.tryParse(abort => {
  22141. var _arrowExpression$extr;
  22142. typeParameters = this.flowParseTypeParameterDeclaration();
  22143. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  22144. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  22145. this.resetStartLocationFromNode(result, typeParameters);
  22146. return result;
  22147. });
  22148. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  22149. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  22150. if (expr.type !== "ArrowFunctionExpression") abort();
  22151. expr.typeParameters = typeParameters;
  22152. this.resetStartLocationFromNode(expr, typeParameters);
  22153. return arrowExpression;
  22154. }, state);
  22155. let arrowExpression = null;
  22156. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  22157. if (!arrow.error && !arrow.aborted) {
  22158. if (arrow.node.async) {
  22159. this.raise(typeParameters.start, FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction);
  22160. }
  22161. return arrow.node;
  22162. }
  22163. arrowExpression = arrow.node;
  22164. }
  22165. if ((_jsx2 = jsx) != null && _jsx2.node) {
  22166. this.state = jsx.failState;
  22167. return jsx.node;
  22168. }
  22169. if (arrowExpression) {
  22170. this.state = arrow.failState;
  22171. return arrowExpression;
  22172. }
  22173. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  22174. if (arrow.thrown) throw arrow.error;
  22175. throw this.raise(typeParameters.start, FlowErrors.UnexpectedTokenAfterTypeParameter);
  22176. }
  22177. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  22178. }
  22179. parseArrow(node) {
  22180. if (this.match(types$1.colon)) {
  22181. const result = this.tryParse(() => {
  22182. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  22183. this.state.noAnonFunctionType = true;
  22184. const typeNode = this.startNode();
  22185. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  22186. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  22187. if (this.canInsertSemicolon()) this.unexpected();
  22188. if (!this.match(types$1.arrow)) this.unexpected();
  22189. return typeNode;
  22190. });
  22191. if (result.thrown) return null;
  22192. if (result.error) this.state = result.failState;
  22193. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  22194. }
  22195. return super.parseArrow(node);
  22196. }
  22197. shouldParseArrow(params) {
  22198. return this.match(types$1.colon) || super.shouldParseArrow(params);
  22199. }
  22200. setArrowFunctionParameters(node, params) {
  22201. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  22202. node.params = params;
  22203. } else {
  22204. super.setArrowFunctionParameters(node, params);
  22205. }
  22206. }
  22207. checkParams(node, allowDuplicates, isArrowFunction) {
  22208. if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  22209. return;
  22210. }
  22211. for (let i = 0; i < node.params.length; i++) {
  22212. if (this.isThisParam(node.params[i]) && i > 0) {
  22213. this.raise(node.params[i].start, FlowErrors.ThisParamMustBeFirst);
  22214. }
  22215. }
  22216. return super.checkParams(...arguments);
  22217. }
  22218. parseParenAndDistinguishExpression(canBeArrow) {
  22219. return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
  22220. }
  22221. parseSubscripts(base, startPos, startLoc, noCalls) {
  22222. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startPos) !== -1) {
  22223. this.next();
  22224. const node = this.startNodeAt(startPos, startLoc);
  22225. node.callee = base;
  22226. node.arguments = this.parseCallExpressionArguments(types$1.parenR, false);
  22227. base = this.finishNode(node, "CallExpression");
  22228. } else if (base.type === "Identifier" && base.name === "async" && this.isRelational("<")) {
  22229. const state = this.state.clone();
  22230. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startPos, startLoc) || abort(), state);
  22231. if (!arrow.error && !arrow.aborted) return arrow.node;
  22232. const result = this.tryParse(() => super.parseSubscripts(base, startPos, startLoc, noCalls), state);
  22233. if (result.node && !result.error) return result.node;
  22234. if (arrow.node) {
  22235. this.state = arrow.failState;
  22236. return arrow.node;
  22237. }
  22238. if (result.node) {
  22239. this.state = result.failState;
  22240. return result.node;
  22241. }
  22242. throw arrow.error || result.error;
  22243. }
  22244. return super.parseSubscripts(base, startPos, startLoc, noCalls);
  22245. }
  22246. parseSubscript(base, startPos, startLoc, noCalls, subscriptState) {
  22247. if (this.match(types$1.questionDot) && this.isLookaheadToken_lt()) {
  22248. subscriptState.optionalChainMember = true;
  22249. if (noCalls) {
  22250. subscriptState.stop = true;
  22251. return base;
  22252. }
  22253. this.next();
  22254. const node = this.startNodeAt(startPos, startLoc);
  22255. node.callee = base;
  22256. node.typeArguments = this.flowParseTypeParameterInstantiation();
  22257. this.expect(types$1.parenL);
  22258. node.arguments = this.parseCallExpressionArguments(types$1.parenR, false);
  22259. node.optional = true;
  22260. return this.finishCallExpression(node, true);
  22261. } else if (!noCalls && this.shouldParseTypes() && this.isRelational("<")) {
  22262. const node = this.startNodeAt(startPos, startLoc);
  22263. node.callee = base;
  22264. const result = this.tryParse(() => {
  22265. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  22266. this.expect(types$1.parenL);
  22267. node.arguments = this.parseCallExpressionArguments(types$1.parenR, false);
  22268. if (subscriptState.optionalChainMember) node.optional = false;
  22269. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  22270. });
  22271. if (result.node) {
  22272. if (result.error) this.state = result.failState;
  22273. return result.node;
  22274. }
  22275. }
  22276. return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState);
  22277. }
  22278. parseNewArguments(node) {
  22279. let targs = null;
  22280. if (this.shouldParseTypes() && this.isRelational("<")) {
  22281. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  22282. }
  22283. node.typeArguments = targs;
  22284. super.parseNewArguments(node);
  22285. }
  22286. parseAsyncArrowWithTypeParameters(startPos, startLoc) {
  22287. const node = this.startNodeAt(startPos, startLoc);
  22288. this.parseFunctionParams(node);
  22289. if (!this.parseArrow(node)) return;
  22290. return this.parseArrowExpression(node, undefined, true);
  22291. }
  22292. readToken_mult_modulo(code) {
  22293. const next = this.input.charCodeAt(this.state.pos + 1);
  22294. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  22295. this.state.hasFlowComment = false;
  22296. this.state.pos += 2;
  22297. this.nextToken();
  22298. return;
  22299. }
  22300. super.readToken_mult_modulo(code);
  22301. }
  22302. readToken_pipe_amp(code) {
  22303. const next = this.input.charCodeAt(this.state.pos + 1);
  22304. if (code === 124 && next === 125) {
  22305. this.finishOp(types$1.braceBarR, 2);
  22306. return;
  22307. }
  22308. super.readToken_pipe_amp(code);
  22309. }
  22310. parseTopLevel(file, program) {
  22311. const fileNode = super.parseTopLevel(file, program);
  22312. if (this.state.hasFlowComment) {
  22313. this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment);
  22314. }
  22315. return fileNode;
  22316. }
  22317. skipBlockComment() {
  22318. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  22319. if (this.state.hasFlowComment) {
  22320. this.unexpected(null, FlowErrors.NestedFlowComment);
  22321. }
  22322. this.hasFlowCommentCompletion();
  22323. this.state.pos += this.skipFlowComment();
  22324. this.state.hasFlowComment = true;
  22325. return;
  22326. }
  22327. if (this.state.hasFlowComment) {
  22328. const end = this.input.indexOf("*-/", this.state.pos += 2);
  22329. if (end === -1) {
  22330. throw this.raise(this.state.pos - 2, ErrorMessages.UnterminatedComment);
  22331. }
  22332. this.state.pos = end + 3;
  22333. return;
  22334. }
  22335. return super.skipBlockComment();
  22336. }
  22337. skipFlowComment() {
  22338. const {
  22339. pos
  22340. } = this.state;
  22341. let shiftToFirstNonWhiteSpace = 2;
  22342. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  22343. shiftToFirstNonWhiteSpace++;
  22344. }
  22345. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  22346. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  22347. if (ch2 === 58 && ch3 === 58) {
  22348. return shiftToFirstNonWhiteSpace + 2;
  22349. }
  22350. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  22351. return shiftToFirstNonWhiteSpace + 12;
  22352. }
  22353. if (ch2 === 58 && ch3 !== 58) {
  22354. return shiftToFirstNonWhiteSpace;
  22355. }
  22356. return false;
  22357. }
  22358. hasFlowCommentCompletion() {
  22359. const end = this.input.indexOf("*/", this.state.pos);
  22360. if (end === -1) {
  22361. throw this.raise(this.state.pos, ErrorMessages.UnterminatedComment);
  22362. }
  22363. }
  22364. flowEnumErrorBooleanMemberNotInitialized(pos, {
  22365. enumName,
  22366. memberName
  22367. }) {
  22368. this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName);
  22369. }
  22370. flowEnumErrorInvalidMemberName(pos, {
  22371. enumName,
  22372. memberName
  22373. }) {
  22374. const suggestion = memberName[0].toUpperCase() + memberName.slice(1);
  22375. this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName);
  22376. }
  22377. flowEnumErrorDuplicateMemberName(pos, {
  22378. enumName,
  22379. memberName
  22380. }) {
  22381. this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName);
  22382. }
  22383. flowEnumErrorInconsistentMemberValues(pos, {
  22384. enumName
  22385. }) {
  22386. this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);
  22387. }
  22388. flowEnumErrorInvalidExplicitType(pos, {
  22389. enumName,
  22390. suppliedType
  22391. }) {
  22392. return this.raise(pos, suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, enumName, suppliedType);
  22393. }
  22394. flowEnumErrorInvalidMemberInitializer(pos, {
  22395. enumName,
  22396. explicitType,
  22397. memberName
  22398. }) {
  22399. let message = null;
  22400. switch (explicitType) {
  22401. case "boolean":
  22402. case "number":
  22403. case "string":
  22404. message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;
  22405. break;
  22406. case "symbol":
  22407. message = FlowErrors.EnumInvalidMemberInitializerSymbolType;
  22408. break;
  22409. default:
  22410. message = FlowErrors.EnumInvalidMemberInitializerUnknownType;
  22411. }
  22412. return this.raise(pos, message, enumName, memberName, explicitType);
  22413. }
  22414. flowEnumErrorNumberMemberNotInitialized(pos, {
  22415. enumName,
  22416. memberName
  22417. }) {
  22418. this.raise(pos, FlowErrors.EnumNumberMemberNotInitialized, enumName, memberName);
  22419. }
  22420. flowEnumErrorStringMemberInconsistentlyInitailized(pos, {
  22421. enumName
  22422. }) {
  22423. this.raise(pos, FlowErrors.EnumStringMemberInconsistentlyInitailized, enumName);
  22424. }
  22425. flowEnumMemberInit() {
  22426. const startPos = this.state.start;
  22427. const endOfInit = () => this.match(types$1.comma) || this.match(types$1.braceR);
  22428. switch (this.state.type) {
  22429. case types$1.num:
  22430. {
  22431. const literal = this.parseNumericLiteral(this.state.value);
  22432. if (endOfInit()) {
  22433. return {
  22434. type: "number",
  22435. pos: literal.start,
  22436. value: literal
  22437. };
  22438. }
  22439. return {
  22440. type: "invalid",
  22441. pos: startPos
  22442. };
  22443. }
  22444. case types$1.string:
  22445. {
  22446. const literal = this.parseStringLiteral(this.state.value);
  22447. if (endOfInit()) {
  22448. return {
  22449. type: "string",
  22450. pos: literal.start,
  22451. value: literal
  22452. };
  22453. }
  22454. return {
  22455. type: "invalid",
  22456. pos: startPos
  22457. };
  22458. }
  22459. case types$1._true:
  22460. case types$1._false:
  22461. {
  22462. const literal = this.parseBooleanLiteral(this.match(types$1._true));
  22463. if (endOfInit()) {
  22464. return {
  22465. type: "boolean",
  22466. pos: literal.start,
  22467. value: literal
  22468. };
  22469. }
  22470. return {
  22471. type: "invalid",
  22472. pos: startPos
  22473. };
  22474. }
  22475. default:
  22476. return {
  22477. type: "invalid",
  22478. pos: startPos
  22479. };
  22480. }
  22481. }
  22482. flowEnumMemberRaw() {
  22483. const pos = this.state.start;
  22484. const id = this.parseIdentifier(true);
  22485. const init = this.eat(types$1.eq) ? this.flowEnumMemberInit() : {
  22486. type: "none",
  22487. pos
  22488. };
  22489. return {
  22490. id,
  22491. init
  22492. };
  22493. }
  22494. flowEnumCheckExplicitTypeMismatch(pos, context, expectedType) {
  22495. const {
  22496. explicitType
  22497. } = context;
  22498. if (explicitType === null) {
  22499. return;
  22500. }
  22501. if (explicitType !== expectedType) {
  22502. this.flowEnumErrorInvalidMemberInitializer(pos, context);
  22503. }
  22504. }
  22505. flowEnumMembers({
  22506. enumName,
  22507. explicitType
  22508. }) {
  22509. const seenNames = new Set();
  22510. const members = {
  22511. booleanMembers: [],
  22512. numberMembers: [],
  22513. stringMembers: [],
  22514. defaultedMembers: []
  22515. };
  22516. let hasUnknownMembers = false;
  22517. while (!this.match(types$1.braceR)) {
  22518. if (this.eat(types$1.ellipsis)) {
  22519. hasUnknownMembers = true;
  22520. break;
  22521. }
  22522. const memberNode = this.startNode();
  22523. const {
  22524. id,
  22525. init
  22526. } = this.flowEnumMemberRaw();
  22527. const memberName = id.name;
  22528. if (memberName === "") {
  22529. continue;
  22530. }
  22531. if (/^[a-z]/.test(memberName)) {
  22532. this.flowEnumErrorInvalidMemberName(id.start, {
  22533. enumName,
  22534. memberName
  22535. });
  22536. }
  22537. if (seenNames.has(memberName)) {
  22538. this.flowEnumErrorDuplicateMemberName(id.start, {
  22539. enumName,
  22540. memberName
  22541. });
  22542. }
  22543. seenNames.add(memberName);
  22544. const context = {
  22545. enumName,
  22546. explicitType,
  22547. memberName
  22548. };
  22549. memberNode.id = id;
  22550. switch (init.type) {
  22551. case "boolean":
  22552. {
  22553. this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "boolean");
  22554. memberNode.init = init.value;
  22555. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  22556. break;
  22557. }
  22558. case "number":
  22559. {
  22560. this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number");
  22561. memberNode.init = init.value;
  22562. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  22563. break;
  22564. }
  22565. case "string":
  22566. {
  22567. this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string");
  22568. memberNode.init = init.value;
  22569. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  22570. break;
  22571. }
  22572. case "invalid":
  22573. {
  22574. throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context);
  22575. }
  22576. case "none":
  22577. {
  22578. switch (explicitType) {
  22579. case "boolean":
  22580. this.flowEnumErrorBooleanMemberNotInitialized(init.pos, context);
  22581. break;
  22582. case "number":
  22583. this.flowEnumErrorNumberMemberNotInitialized(init.pos, context);
  22584. break;
  22585. default:
  22586. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  22587. }
  22588. }
  22589. }
  22590. if (!this.match(types$1.braceR)) {
  22591. this.expect(types$1.comma);
  22592. }
  22593. }
  22594. return {
  22595. members,
  22596. hasUnknownMembers
  22597. };
  22598. }
  22599. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  22600. enumName
  22601. }) {
  22602. if (initializedMembers.length === 0) {
  22603. return defaultedMembers;
  22604. } else if (defaultedMembers.length === 0) {
  22605. return initializedMembers;
  22606. } else if (defaultedMembers.length > initializedMembers.length) {
  22607. for (const member of initializedMembers) {
  22608. this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, {
  22609. enumName
  22610. });
  22611. }
  22612. return defaultedMembers;
  22613. } else {
  22614. for (const member of defaultedMembers) {
  22615. this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, {
  22616. enumName
  22617. });
  22618. }
  22619. return initializedMembers;
  22620. }
  22621. }
  22622. flowEnumParseExplicitType({
  22623. enumName
  22624. }) {
  22625. if (this.eatContextual("of")) {
  22626. if (!this.match(types$1.name)) {
  22627. throw this.flowEnumErrorInvalidExplicitType(this.state.start, {
  22628. enumName,
  22629. suppliedType: null
  22630. });
  22631. }
  22632. const {
  22633. value
  22634. } = this.state;
  22635. this.next();
  22636. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  22637. this.flowEnumErrorInvalidExplicitType(this.state.start, {
  22638. enumName,
  22639. suppliedType: value
  22640. });
  22641. }
  22642. return value;
  22643. }
  22644. return null;
  22645. }
  22646. flowEnumBody(node, {
  22647. enumName,
  22648. nameLoc
  22649. }) {
  22650. const explicitType = this.flowEnumParseExplicitType({
  22651. enumName
  22652. });
  22653. this.expect(types$1.braceL);
  22654. const {
  22655. members,
  22656. hasUnknownMembers
  22657. } = this.flowEnumMembers({
  22658. enumName,
  22659. explicitType
  22660. });
  22661. node.hasUnknownMembers = hasUnknownMembers;
  22662. switch (explicitType) {
  22663. case "boolean":
  22664. node.explicitType = true;
  22665. node.members = members.booleanMembers;
  22666. this.expect(types$1.braceR);
  22667. return this.finishNode(node, "EnumBooleanBody");
  22668. case "number":
  22669. node.explicitType = true;
  22670. node.members = members.numberMembers;
  22671. this.expect(types$1.braceR);
  22672. return this.finishNode(node, "EnumNumberBody");
  22673. case "string":
  22674. node.explicitType = true;
  22675. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  22676. enumName
  22677. });
  22678. this.expect(types$1.braceR);
  22679. return this.finishNode(node, "EnumStringBody");
  22680. case "symbol":
  22681. node.members = members.defaultedMembers;
  22682. this.expect(types$1.braceR);
  22683. return this.finishNode(node, "EnumSymbolBody");
  22684. default:
  22685. {
  22686. const empty = () => {
  22687. node.members = [];
  22688. this.expect(types$1.braceR);
  22689. return this.finishNode(node, "EnumStringBody");
  22690. };
  22691. node.explicitType = false;
  22692. const boolsLen = members.booleanMembers.length;
  22693. const numsLen = members.numberMembers.length;
  22694. const strsLen = members.stringMembers.length;
  22695. const defaultedLen = members.defaultedMembers.length;
  22696. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  22697. return empty();
  22698. } else if (!boolsLen && !numsLen) {
  22699. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  22700. enumName
  22701. });
  22702. this.expect(types$1.braceR);
  22703. return this.finishNode(node, "EnumStringBody");
  22704. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  22705. for (const member of members.defaultedMembers) {
  22706. this.flowEnumErrorBooleanMemberNotInitialized(member.start, {
  22707. enumName,
  22708. memberName: member.id.name
  22709. });
  22710. }
  22711. node.members = members.booleanMembers;
  22712. this.expect(types$1.braceR);
  22713. return this.finishNode(node, "EnumBooleanBody");
  22714. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  22715. for (const member of members.defaultedMembers) {
  22716. this.flowEnumErrorNumberMemberNotInitialized(member.start, {
  22717. enumName,
  22718. memberName: member.id.name
  22719. });
  22720. }
  22721. node.members = members.numberMembers;
  22722. this.expect(types$1.braceR);
  22723. return this.finishNode(node, "EnumNumberBody");
  22724. } else {
  22725. this.flowEnumErrorInconsistentMemberValues(nameLoc, {
  22726. enumName
  22727. });
  22728. return empty();
  22729. }
  22730. }
  22731. }
  22732. }
  22733. flowParseEnumDeclaration(node) {
  22734. const id = this.parseIdentifier();
  22735. node.id = id;
  22736. node.body = this.flowEnumBody(this.startNode(), {
  22737. enumName: id.name,
  22738. nameLoc: id.start
  22739. });
  22740. return this.finishNode(node, "EnumDeclaration");
  22741. }
  22742. isLookaheadToken_lt() {
  22743. const next = this.nextTokenStart();
  22744. if (this.input.charCodeAt(next) === 60) {
  22745. const afterNext = this.input.charCodeAt(next + 1);
  22746. return afterNext !== 60 && afterNext !== 61;
  22747. }
  22748. return false;
  22749. }
  22750. maybeUnwrapTypeCastExpression(node) {
  22751. return node.type === "TypeCastExpression" ? node.expression : node;
  22752. }
  22753. });
  22754. const entities = {
  22755. quot: "\u0022",
  22756. amp: "&",
  22757. apos: "\u0027",
  22758. lt: "<",
  22759. gt: ">",
  22760. nbsp: "\u00A0",
  22761. iexcl: "\u00A1",
  22762. cent: "\u00A2",
  22763. pound: "\u00A3",
  22764. curren: "\u00A4",
  22765. yen: "\u00A5",
  22766. brvbar: "\u00A6",
  22767. sect: "\u00A7",
  22768. uml: "\u00A8",
  22769. copy: "\u00A9",
  22770. ordf: "\u00AA",
  22771. laquo: "\u00AB",
  22772. not: "\u00AC",
  22773. shy: "\u00AD",
  22774. reg: "\u00AE",
  22775. macr: "\u00AF",
  22776. deg: "\u00B0",
  22777. plusmn: "\u00B1",
  22778. sup2: "\u00B2",
  22779. sup3: "\u00B3",
  22780. acute: "\u00B4",
  22781. micro: "\u00B5",
  22782. para: "\u00B6",
  22783. middot: "\u00B7",
  22784. cedil: "\u00B8",
  22785. sup1: "\u00B9",
  22786. ordm: "\u00BA",
  22787. raquo: "\u00BB",
  22788. frac14: "\u00BC",
  22789. frac12: "\u00BD",
  22790. frac34: "\u00BE",
  22791. iquest: "\u00BF",
  22792. Agrave: "\u00C0",
  22793. Aacute: "\u00C1",
  22794. Acirc: "\u00C2",
  22795. Atilde: "\u00C3",
  22796. Auml: "\u00C4",
  22797. Aring: "\u00C5",
  22798. AElig: "\u00C6",
  22799. Ccedil: "\u00C7",
  22800. Egrave: "\u00C8",
  22801. Eacute: "\u00C9",
  22802. Ecirc: "\u00CA",
  22803. Euml: "\u00CB",
  22804. Igrave: "\u00CC",
  22805. Iacute: "\u00CD",
  22806. Icirc: "\u00CE",
  22807. Iuml: "\u00CF",
  22808. ETH: "\u00D0",
  22809. Ntilde: "\u00D1",
  22810. Ograve: "\u00D2",
  22811. Oacute: "\u00D3",
  22812. Ocirc: "\u00D4",
  22813. Otilde: "\u00D5",
  22814. Ouml: "\u00D6",
  22815. times: "\u00D7",
  22816. Oslash: "\u00D8",
  22817. Ugrave: "\u00D9",
  22818. Uacute: "\u00DA",
  22819. Ucirc: "\u00DB",
  22820. Uuml: "\u00DC",
  22821. Yacute: "\u00DD",
  22822. THORN: "\u00DE",
  22823. szlig: "\u00DF",
  22824. agrave: "\u00E0",
  22825. aacute: "\u00E1",
  22826. acirc: "\u00E2",
  22827. atilde: "\u00E3",
  22828. auml: "\u00E4",
  22829. aring: "\u00E5",
  22830. aelig: "\u00E6",
  22831. ccedil: "\u00E7",
  22832. egrave: "\u00E8",
  22833. eacute: "\u00E9",
  22834. ecirc: "\u00EA",
  22835. euml: "\u00EB",
  22836. igrave: "\u00EC",
  22837. iacute: "\u00ED",
  22838. icirc: "\u00EE",
  22839. iuml: "\u00EF",
  22840. eth: "\u00F0",
  22841. ntilde: "\u00F1",
  22842. ograve: "\u00F2",
  22843. oacute: "\u00F3",
  22844. ocirc: "\u00F4",
  22845. otilde: "\u00F5",
  22846. ouml: "\u00F6",
  22847. divide: "\u00F7",
  22848. oslash: "\u00F8",
  22849. ugrave: "\u00F9",
  22850. uacute: "\u00FA",
  22851. ucirc: "\u00FB",
  22852. uuml: "\u00FC",
  22853. yacute: "\u00FD",
  22854. thorn: "\u00FE",
  22855. yuml: "\u00FF",
  22856. OElig: "\u0152",
  22857. oelig: "\u0153",
  22858. Scaron: "\u0160",
  22859. scaron: "\u0161",
  22860. Yuml: "\u0178",
  22861. fnof: "\u0192",
  22862. circ: "\u02C6",
  22863. tilde: "\u02DC",
  22864. Alpha: "\u0391",
  22865. Beta: "\u0392",
  22866. Gamma: "\u0393",
  22867. Delta: "\u0394",
  22868. Epsilon: "\u0395",
  22869. Zeta: "\u0396",
  22870. Eta: "\u0397",
  22871. Theta: "\u0398",
  22872. Iota: "\u0399",
  22873. Kappa: "\u039A",
  22874. Lambda: "\u039B",
  22875. Mu: "\u039C",
  22876. Nu: "\u039D",
  22877. Xi: "\u039E",
  22878. Omicron: "\u039F",
  22879. Pi: "\u03A0",
  22880. Rho: "\u03A1",
  22881. Sigma: "\u03A3",
  22882. Tau: "\u03A4",
  22883. Upsilon: "\u03A5",
  22884. Phi: "\u03A6",
  22885. Chi: "\u03A7",
  22886. Psi: "\u03A8",
  22887. Omega: "\u03A9",
  22888. alpha: "\u03B1",
  22889. beta: "\u03B2",
  22890. gamma: "\u03B3",
  22891. delta: "\u03B4",
  22892. epsilon: "\u03B5",
  22893. zeta: "\u03B6",
  22894. eta: "\u03B7",
  22895. theta: "\u03B8",
  22896. iota: "\u03B9",
  22897. kappa: "\u03BA",
  22898. lambda: "\u03BB",
  22899. mu: "\u03BC",
  22900. nu: "\u03BD",
  22901. xi: "\u03BE",
  22902. omicron: "\u03BF",
  22903. pi: "\u03C0",
  22904. rho: "\u03C1",
  22905. sigmaf: "\u03C2",
  22906. sigma: "\u03C3",
  22907. tau: "\u03C4",
  22908. upsilon: "\u03C5",
  22909. phi: "\u03C6",
  22910. chi: "\u03C7",
  22911. psi: "\u03C8",
  22912. omega: "\u03C9",
  22913. thetasym: "\u03D1",
  22914. upsih: "\u03D2",
  22915. piv: "\u03D6",
  22916. ensp: "\u2002",
  22917. emsp: "\u2003",
  22918. thinsp: "\u2009",
  22919. zwnj: "\u200C",
  22920. zwj: "\u200D",
  22921. lrm: "\u200E",
  22922. rlm: "\u200F",
  22923. ndash: "\u2013",
  22924. mdash: "\u2014",
  22925. lsquo: "\u2018",
  22926. rsquo: "\u2019",
  22927. sbquo: "\u201A",
  22928. ldquo: "\u201C",
  22929. rdquo: "\u201D",
  22930. bdquo: "\u201E",
  22931. dagger: "\u2020",
  22932. Dagger: "\u2021",
  22933. bull: "\u2022",
  22934. hellip: "\u2026",
  22935. permil: "\u2030",
  22936. prime: "\u2032",
  22937. Prime: "\u2033",
  22938. lsaquo: "\u2039",
  22939. rsaquo: "\u203A",
  22940. oline: "\u203E",
  22941. frasl: "\u2044",
  22942. euro: "\u20AC",
  22943. image: "\u2111",
  22944. weierp: "\u2118",
  22945. real: "\u211C",
  22946. trade: "\u2122",
  22947. alefsym: "\u2135",
  22948. larr: "\u2190",
  22949. uarr: "\u2191",
  22950. rarr: "\u2192",
  22951. darr: "\u2193",
  22952. harr: "\u2194",
  22953. crarr: "\u21B5",
  22954. lArr: "\u21D0",
  22955. uArr: "\u21D1",
  22956. rArr: "\u21D2",
  22957. dArr: "\u21D3",
  22958. hArr: "\u21D4",
  22959. forall: "\u2200",
  22960. part: "\u2202",
  22961. exist: "\u2203",
  22962. empty: "\u2205",
  22963. nabla: "\u2207",
  22964. isin: "\u2208",
  22965. notin: "\u2209",
  22966. ni: "\u220B",
  22967. prod: "\u220F",
  22968. sum: "\u2211",
  22969. minus: "\u2212",
  22970. lowast: "\u2217",
  22971. radic: "\u221A",
  22972. prop: "\u221D",
  22973. infin: "\u221E",
  22974. ang: "\u2220",
  22975. and: "\u2227",
  22976. or: "\u2228",
  22977. cap: "\u2229",
  22978. cup: "\u222A",
  22979. int: "\u222B",
  22980. there4: "\u2234",
  22981. sim: "\u223C",
  22982. cong: "\u2245",
  22983. asymp: "\u2248",
  22984. ne: "\u2260",
  22985. equiv: "\u2261",
  22986. le: "\u2264",
  22987. ge: "\u2265",
  22988. sub: "\u2282",
  22989. sup: "\u2283",
  22990. nsub: "\u2284",
  22991. sube: "\u2286",
  22992. supe: "\u2287",
  22993. oplus: "\u2295",
  22994. otimes: "\u2297",
  22995. perp: "\u22A5",
  22996. sdot: "\u22C5",
  22997. lceil: "\u2308",
  22998. rceil: "\u2309",
  22999. lfloor: "\u230A",
  23000. rfloor: "\u230B",
  23001. lang: "\u2329",
  23002. rang: "\u232A",
  23003. loz: "\u25CA",
  23004. spades: "\u2660",
  23005. clubs: "\u2663",
  23006. hearts: "\u2665",
  23007. diams: "\u2666"
  23008. };
  23009. const HEX_NUMBER = /^[\da-fA-F]+$/;
  23010. const DECIMAL_NUMBER = /^\d+$/;
  23011. const JsxErrors = makeErrorTemplates({
  23012. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  23013. MissingClosingTagElement: "Expected corresponding JSX closing tag for <%0>.",
  23014. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  23015. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  23016. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  23017. UnterminatedJsxContent: "Unterminated JSX contents.",
  23018. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  23019. }, ErrorCodes.SyntaxError);
  23020. types.j_oTag = new TokContext("<tag");
  23021. types.j_cTag = new TokContext("</tag");
  23022. types.j_expr = new TokContext("<tag>...</tag>", true);
  23023. types$1.jsxName = new TokenType("jsxName");
  23024. types$1.jsxText = new TokenType("jsxText", {
  23025. beforeExpr: true
  23026. });
  23027. types$1.jsxTagStart = new TokenType("jsxTagStart", {
  23028. startsExpr: true
  23029. });
  23030. types$1.jsxTagEnd = new TokenType("jsxTagEnd");
  23031. types$1.jsxTagStart.updateContext = context => {
  23032. context.push(types.j_expr, types.j_oTag);
  23033. };
  23034. function isFragment(object) {
  23035. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  23036. }
  23037. function getQualifiedJSXName(object) {
  23038. if (object.type === "JSXIdentifier") {
  23039. return object.name;
  23040. }
  23041. if (object.type === "JSXNamespacedName") {
  23042. return object.namespace.name + ":" + object.name.name;
  23043. }
  23044. if (object.type === "JSXMemberExpression") {
  23045. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  23046. }
  23047. throw new Error("Node had unexpected type: " + object.type);
  23048. }
  23049. var jsx = (superClass => class extends superClass {
  23050. jsxReadToken() {
  23051. let out = "";
  23052. let chunkStart = this.state.pos;
  23053. for (;;) {
  23054. if (this.state.pos >= this.length) {
  23055. throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);
  23056. }
  23057. const ch = this.input.charCodeAt(this.state.pos);
  23058. switch (ch) {
  23059. case 60:
  23060. case 123:
  23061. if (this.state.pos === this.state.start) {
  23062. if (ch === 60 && this.state.exprAllowed) {
  23063. ++this.state.pos;
  23064. return this.finishToken(types$1.jsxTagStart);
  23065. }
  23066. return super.getTokenFromCode(ch);
  23067. }
  23068. out += this.input.slice(chunkStart, this.state.pos);
  23069. return this.finishToken(types$1.jsxText, out);
  23070. case 38:
  23071. out += this.input.slice(chunkStart, this.state.pos);
  23072. out += this.jsxReadEntity();
  23073. chunkStart = this.state.pos;
  23074. break;
  23075. case 62:
  23076. case 125:
  23077. default:
  23078. if (isNewLine(ch)) {
  23079. out += this.input.slice(chunkStart, this.state.pos);
  23080. out += this.jsxReadNewLine(true);
  23081. chunkStart = this.state.pos;
  23082. } else {
  23083. ++this.state.pos;
  23084. }
  23085. }
  23086. }
  23087. }
  23088. jsxReadNewLine(normalizeCRLF) {
  23089. const ch = this.input.charCodeAt(this.state.pos);
  23090. let out;
  23091. ++this.state.pos;
  23092. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  23093. ++this.state.pos;
  23094. out = normalizeCRLF ? "\n" : "\r\n";
  23095. } else {
  23096. out = String.fromCharCode(ch);
  23097. }
  23098. ++this.state.curLine;
  23099. this.state.lineStart = this.state.pos;
  23100. return out;
  23101. }
  23102. jsxReadString(quote) {
  23103. let out = "";
  23104. let chunkStart = ++this.state.pos;
  23105. for (;;) {
  23106. if (this.state.pos >= this.length) {
  23107. throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
  23108. }
  23109. const ch = this.input.charCodeAt(this.state.pos);
  23110. if (ch === quote) break;
  23111. if (ch === 38) {
  23112. out += this.input.slice(chunkStart, this.state.pos);
  23113. out += this.jsxReadEntity();
  23114. chunkStart = this.state.pos;
  23115. } else if (isNewLine(ch)) {
  23116. out += this.input.slice(chunkStart, this.state.pos);
  23117. out += this.jsxReadNewLine(false);
  23118. chunkStart = this.state.pos;
  23119. } else {
  23120. ++this.state.pos;
  23121. }
  23122. }
  23123. out += this.input.slice(chunkStart, this.state.pos++);
  23124. return this.finishToken(types$1.string, out);
  23125. }
  23126. jsxReadEntity() {
  23127. let str = "";
  23128. let count = 0;
  23129. let entity;
  23130. let ch = this.input[this.state.pos];
  23131. const startPos = ++this.state.pos;
  23132. while (this.state.pos < this.length && count++ < 10) {
  23133. ch = this.input[this.state.pos++];
  23134. if (ch === ";") {
  23135. if (str[0] === "#") {
  23136. if (str[1] === "x") {
  23137. str = str.substr(2);
  23138. if (HEX_NUMBER.test(str)) {
  23139. entity = String.fromCodePoint(parseInt(str, 16));
  23140. }
  23141. } else {
  23142. str = str.substr(1);
  23143. if (DECIMAL_NUMBER.test(str)) {
  23144. entity = String.fromCodePoint(parseInt(str, 10));
  23145. }
  23146. }
  23147. } else {
  23148. entity = entities[str];
  23149. }
  23150. break;
  23151. }
  23152. str += ch;
  23153. }
  23154. if (!entity) {
  23155. this.state.pos = startPos;
  23156. return "&";
  23157. }
  23158. return entity;
  23159. }
  23160. jsxReadWord() {
  23161. let ch;
  23162. const start = this.state.pos;
  23163. do {
  23164. ch = this.input.charCodeAt(++this.state.pos);
  23165. } while (isIdentifierChar$1(ch) || ch === 45);
  23166. return this.finishToken(types$1.jsxName, this.input.slice(start, this.state.pos));
  23167. }
  23168. jsxParseIdentifier() {
  23169. const node = this.startNode();
  23170. if (this.match(types$1.jsxName)) {
  23171. node.name = this.state.value;
  23172. } else if (this.state.type.keyword) {
  23173. node.name = this.state.type.keyword;
  23174. } else {
  23175. this.unexpected();
  23176. }
  23177. this.next();
  23178. return this.finishNode(node, "JSXIdentifier");
  23179. }
  23180. jsxParseNamespacedName() {
  23181. const startPos = this.state.start;
  23182. const startLoc = this.state.startLoc;
  23183. const name = this.jsxParseIdentifier();
  23184. if (!this.eat(types$1.colon)) return name;
  23185. const node = this.startNodeAt(startPos, startLoc);
  23186. node.namespace = name;
  23187. node.name = this.jsxParseIdentifier();
  23188. return this.finishNode(node, "JSXNamespacedName");
  23189. }
  23190. jsxParseElementName() {
  23191. const startPos = this.state.start;
  23192. const startLoc = this.state.startLoc;
  23193. let node = this.jsxParseNamespacedName();
  23194. if (node.type === "JSXNamespacedName") {
  23195. return node;
  23196. }
  23197. while (this.eat(types$1.dot)) {
  23198. const newNode = this.startNodeAt(startPos, startLoc);
  23199. newNode.object = node;
  23200. newNode.property = this.jsxParseIdentifier();
  23201. node = this.finishNode(newNode, "JSXMemberExpression");
  23202. }
  23203. return node;
  23204. }
  23205. jsxParseAttributeValue() {
  23206. let node;
  23207. switch (this.state.type) {
  23208. case types$1.braceL:
  23209. node = this.startNode();
  23210. this.next();
  23211. node = this.jsxParseExpressionContainer(node);
  23212. if (node.expression.type === "JSXEmptyExpression") {
  23213. this.raise(node.start, JsxErrors.AttributeIsEmpty);
  23214. }
  23215. return node;
  23216. case types$1.jsxTagStart:
  23217. case types$1.string:
  23218. return this.parseExprAtom();
  23219. default:
  23220. throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);
  23221. }
  23222. }
  23223. jsxParseEmptyExpression() {
  23224. const node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
  23225. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
  23226. }
  23227. jsxParseSpreadChild(node) {
  23228. this.next();
  23229. node.expression = this.parseExpression();
  23230. this.expect(types$1.braceR);
  23231. return this.finishNode(node, "JSXSpreadChild");
  23232. }
  23233. jsxParseExpressionContainer(node) {
  23234. if (this.match(types$1.braceR)) {
  23235. node.expression = this.jsxParseEmptyExpression();
  23236. } else {
  23237. const expression = this.parseExpression();
  23238. node.expression = expression;
  23239. }
  23240. this.expect(types$1.braceR);
  23241. return this.finishNode(node, "JSXExpressionContainer");
  23242. }
  23243. jsxParseAttribute() {
  23244. const node = this.startNode();
  23245. if (this.eat(types$1.braceL)) {
  23246. this.expect(types$1.ellipsis);
  23247. node.argument = this.parseMaybeAssignAllowIn();
  23248. this.expect(types$1.braceR);
  23249. return this.finishNode(node, "JSXSpreadAttribute");
  23250. }
  23251. node.name = this.jsxParseNamespacedName();
  23252. node.value = this.eat(types$1.eq) ? this.jsxParseAttributeValue() : null;
  23253. return this.finishNode(node, "JSXAttribute");
  23254. }
  23255. jsxParseOpeningElementAt(startPos, startLoc) {
  23256. const node = this.startNodeAt(startPos, startLoc);
  23257. if (this.match(types$1.jsxTagEnd)) {
  23258. this.expect(types$1.jsxTagEnd);
  23259. return this.finishNode(node, "JSXOpeningFragment");
  23260. }
  23261. node.name = this.jsxParseElementName();
  23262. return this.jsxParseOpeningElementAfterName(node);
  23263. }
  23264. jsxParseOpeningElementAfterName(node) {
  23265. const attributes = [];
  23266. while (!this.match(types$1.slash) && !this.match(types$1.jsxTagEnd)) {
  23267. attributes.push(this.jsxParseAttribute());
  23268. }
  23269. node.attributes = attributes;
  23270. node.selfClosing = this.eat(types$1.slash);
  23271. this.expect(types$1.jsxTagEnd);
  23272. return this.finishNode(node, "JSXOpeningElement");
  23273. }
  23274. jsxParseClosingElementAt(startPos, startLoc) {
  23275. const node = this.startNodeAt(startPos, startLoc);
  23276. if (this.match(types$1.jsxTagEnd)) {
  23277. this.expect(types$1.jsxTagEnd);
  23278. return this.finishNode(node, "JSXClosingFragment");
  23279. }
  23280. node.name = this.jsxParseElementName();
  23281. this.expect(types$1.jsxTagEnd);
  23282. return this.finishNode(node, "JSXClosingElement");
  23283. }
  23284. jsxParseElementAt(startPos, startLoc) {
  23285. const node = this.startNodeAt(startPos, startLoc);
  23286. const children = [];
  23287. const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
  23288. let closingElement = null;
  23289. if (!openingElement.selfClosing) {
  23290. contents: for (;;) {
  23291. switch (this.state.type) {
  23292. case types$1.jsxTagStart:
  23293. startPos = this.state.start;
  23294. startLoc = this.state.startLoc;
  23295. this.next();
  23296. if (this.eat(types$1.slash)) {
  23297. closingElement = this.jsxParseClosingElementAt(startPos, startLoc);
  23298. break contents;
  23299. }
  23300. children.push(this.jsxParseElementAt(startPos, startLoc));
  23301. break;
  23302. case types$1.jsxText:
  23303. children.push(this.parseExprAtom());
  23304. break;
  23305. case types$1.braceL:
  23306. {
  23307. const node = this.startNode();
  23308. this.next();
  23309. if (this.match(types$1.ellipsis)) {
  23310. children.push(this.jsxParseSpreadChild(node));
  23311. } else {
  23312. children.push(this.jsxParseExpressionContainer(node));
  23313. }
  23314. break;
  23315. }
  23316. default:
  23317. throw this.unexpected();
  23318. }
  23319. }
  23320. if (isFragment(openingElement) && !isFragment(closingElement)) {
  23321. this.raise(closingElement.start, JsxErrors.MissingClosingTagFragment);
  23322. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  23323. this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
  23324. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  23325. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  23326. this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
  23327. }
  23328. }
  23329. }
  23330. if (isFragment(openingElement)) {
  23331. node.openingFragment = openingElement;
  23332. node.closingFragment = closingElement;
  23333. } else {
  23334. node.openingElement = openingElement;
  23335. node.closingElement = closingElement;
  23336. }
  23337. node.children = children;
  23338. if (this.isRelational("<")) {
  23339. throw this.raise(this.state.start, JsxErrors.UnwrappedAdjacentJSXElements);
  23340. }
  23341. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  23342. }
  23343. jsxParseElement() {
  23344. const startPos = this.state.start;
  23345. const startLoc = this.state.startLoc;
  23346. this.next();
  23347. return this.jsxParseElementAt(startPos, startLoc);
  23348. }
  23349. parseExprAtom(refExpressionErrors) {
  23350. if (this.match(types$1.jsxText)) {
  23351. return this.parseLiteral(this.state.value, "JSXText");
  23352. } else if (this.match(types$1.jsxTagStart)) {
  23353. return this.jsxParseElement();
  23354. } else if (this.isRelational("<") && this.input.charCodeAt(this.state.pos) !== 33) {
  23355. this.finishToken(types$1.jsxTagStart);
  23356. return this.jsxParseElement();
  23357. } else {
  23358. return super.parseExprAtom(refExpressionErrors);
  23359. }
  23360. }
  23361. createLookaheadState(state) {
  23362. const lookaheadState = super.createLookaheadState(state);
  23363. lookaheadState.inPropertyName = state.inPropertyName;
  23364. return lookaheadState;
  23365. }
  23366. getTokenFromCode(code) {
  23367. if (this.state.inPropertyName) return super.getTokenFromCode(code);
  23368. const context = this.curContext();
  23369. if (context === types.j_expr) {
  23370. return this.jsxReadToken();
  23371. }
  23372. if (context === types.j_oTag || context === types.j_cTag) {
  23373. if (isIdentifierStart$1(code)) {
  23374. return this.jsxReadWord();
  23375. }
  23376. if (code === 62) {
  23377. ++this.state.pos;
  23378. return this.finishToken(types$1.jsxTagEnd);
  23379. }
  23380. if ((code === 34 || code === 39) && context === types.j_oTag) {
  23381. return this.jsxReadString(code);
  23382. }
  23383. }
  23384. if (code === 60 && this.state.exprAllowed && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  23385. ++this.state.pos;
  23386. return this.finishToken(types$1.jsxTagStart);
  23387. }
  23388. return super.getTokenFromCode(code);
  23389. }
  23390. updateContext(prevType) {
  23391. super.updateContext(prevType);
  23392. const {
  23393. context,
  23394. type
  23395. } = this.state;
  23396. if (type === types$1.slash && prevType === types$1.jsxTagStart) {
  23397. context.splice(-2, 2, types.j_cTag);
  23398. this.state.exprAllowed = false;
  23399. } else if (type === types$1.jsxTagEnd) {
  23400. const out = context.pop();
  23401. if (out === types.j_oTag && prevType === types$1.slash || out === types.j_cTag) {
  23402. context.pop();
  23403. this.state.exprAllowed = context[context.length - 1] === types.j_expr;
  23404. } else {
  23405. this.state.exprAllowed = true;
  23406. }
  23407. } else if (type.keyword && (prevType === types$1.dot || prevType === types$1.questionDot)) {
  23408. this.state.exprAllowed = false;
  23409. } else {
  23410. this.state.exprAllowed = type.beforeExpr;
  23411. }
  23412. }
  23413. });
  23414. class TypeScriptScope extends Scope {
  23415. constructor(...args) {
  23416. super(...args);
  23417. this.types = new Set();
  23418. this.enums = new Set();
  23419. this.constEnums = new Set();
  23420. this.classes = new Set();
  23421. this.exportOnlyBindings = new Set();
  23422. }
  23423. }
  23424. class TypeScriptScopeHandler extends ScopeHandler {
  23425. createScope(flags) {
  23426. return new TypeScriptScope(flags);
  23427. }
  23428. declareName(name, bindingType, pos) {
  23429. const scope = this.currentScope();
  23430. if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
  23431. this.maybeExportDefined(scope, name);
  23432. scope.exportOnlyBindings.add(name);
  23433. return;
  23434. }
  23435. super.declareName(...arguments);
  23436. if (bindingType & BIND_KIND_TYPE) {
  23437. if (!(bindingType & BIND_KIND_VALUE)) {
  23438. this.checkRedeclarationInScope(scope, name, bindingType, pos);
  23439. this.maybeExportDefined(scope, name);
  23440. }
  23441. scope.types.add(name);
  23442. }
  23443. if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.add(name);
  23444. if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.add(name);
  23445. if (bindingType & BIND_FLAGS_CLASS) scope.classes.add(name);
  23446. }
  23447. isRedeclaredInScope(scope, name, bindingType) {
  23448. if (scope.enums.has(name)) {
  23449. if (bindingType & BIND_FLAGS_TS_ENUM) {
  23450. const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM);
  23451. const wasConst = scope.constEnums.has(name);
  23452. return isConst !== wasConst;
  23453. }
  23454. return true;
  23455. }
  23456. if (bindingType & BIND_FLAGS_CLASS && scope.classes.has(name)) {
  23457. if (scope.lexical.has(name)) {
  23458. return !!(bindingType & BIND_KIND_VALUE);
  23459. } else {
  23460. return false;
  23461. }
  23462. }
  23463. if (bindingType & BIND_KIND_TYPE && scope.types.has(name)) {
  23464. return true;
  23465. }
  23466. return super.isRedeclaredInScope(...arguments);
  23467. }
  23468. checkLocalExport(id) {
  23469. const topLevelScope = this.scopeStack[0];
  23470. const {
  23471. name
  23472. } = id;
  23473. if (!topLevelScope.types.has(name) && !topLevelScope.exportOnlyBindings.has(name)) {
  23474. super.checkLocalExport(id);
  23475. }
  23476. }
  23477. }
  23478. function nonNull(x) {
  23479. if (x == null) {
  23480. throw new Error(`Unexpected ${x} value.`);
  23481. }
  23482. return x;
  23483. }
  23484. function assert$2(x) {
  23485. if (!x) {
  23486. throw new Error("Assert fail");
  23487. }
  23488. }
  23489. const TSErrors = makeErrorTemplates({
  23490. AbstractMethodHasImplementation: "Method '%0' cannot have an implementation because it is marked abstract.",
  23491. AbstractPropertyHasInitializer: "Property '%0' cannot have an initializer because it is marked abstract.",
  23492. AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  23493. AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  23494. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  23495. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  23496. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  23497. DeclareAccessor: "'declare' is not allowed in %0ters.",
  23498. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  23499. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  23500. DuplicateAccessibilityModifier: "Accessibility modifier already seen.",
  23501. DuplicateModifier: "Duplicate modifier: '%0'.",
  23502. EmptyHeritageClauseType: "'%0' list cannot be empty.",
  23503. EmptyTypeArguments: "Type argument list cannot be empty.",
  23504. EmptyTypeParameters: "Type parameter list cannot be empty.",
  23505. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  23506. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  23507. IncompatibleModifiers: "'%0' modifier cannot be used with '%1' modifier.",
  23508. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  23509. IndexSignatureHasAccessibility: "Index signatures cannot have an accessibility modifier ('%0').",
  23510. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  23511. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  23512. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  23513. InvalidModifierOnTypeMember: "'%0' modifier cannot appear on a type member.",
  23514. InvalidModifiersOrder: "'%0' modifier must precede '%1' modifier.",
  23515. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  23516. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  23517. MixedLabeledAndUnlabeledElements: "Tuple members must all have names or all not have names.",
  23518. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  23519. NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
  23520. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  23521. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  23522. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  23523. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  23524. PrivateElementHasAccessibility: "Private elements cannot have an accessibility modifier ('%0').",
  23525. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  23526. SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  23527. SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  23528. SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  23529. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  23530. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  23531. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  23532. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  23533. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  23534. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  23535. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  23536. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  23537. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  23538. UnsupportedSignatureParameterKind: "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got %0."
  23539. }, ErrorCodes.SyntaxError);
  23540. function keywordTypeFromName(value) {
  23541. switch (value) {
  23542. case "any":
  23543. return "TSAnyKeyword";
  23544. case "boolean":
  23545. return "TSBooleanKeyword";
  23546. case "bigint":
  23547. return "TSBigIntKeyword";
  23548. case "never":
  23549. return "TSNeverKeyword";
  23550. case "number":
  23551. return "TSNumberKeyword";
  23552. case "object":
  23553. return "TSObjectKeyword";
  23554. case "string":
  23555. return "TSStringKeyword";
  23556. case "symbol":
  23557. return "TSSymbolKeyword";
  23558. case "undefined":
  23559. return "TSUndefinedKeyword";
  23560. case "unknown":
  23561. return "TSUnknownKeyword";
  23562. default:
  23563. return undefined;
  23564. }
  23565. }
  23566. function tsIsAccessModifier(modifier) {
  23567. return modifier === "private" || modifier === "public" || modifier === "protected";
  23568. }
  23569. var typescript = (superClass => class extends superClass {
  23570. getScopeHandler() {
  23571. return TypeScriptScopeHandler;
  23572. }
  23573. tsIsIdentifier() {
  23574. return this.match(types$1.name);
  23575. }
  23576. tsTokenCanFollowModifier() {
  23577. return (this.match(types$1.bracketL) || this.match(types$1.braceL) || this.match(types$1.star) || this.match(types$1.ellipsis) || this.match(types$1.privateName) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
  23578. }
  23579. tsNextTokenCanFollowModifier() {
  23580. this.next();
  23581. return this.tsTokenCanFollowModifier();
  23582. }
  23583. tsParseModifier(allowedModifiers) {
  23584. if (!this.match(types$1.name)) {
  23585. return undefined;
  23586. }
  23587. const modifier = this.state.value;
  23588. if (allowedModifiers.indexOf(modifier) !== -1 && this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  23589. return modifier;
  23590. }
  23591. return undefined;
  23592. }
  23593. tsParseModifiers(modified, allowedModifiers, disallowedModifiers, errorTemplate) {
  23594. const enforceOrder = (pos, modifier, before, after) => {
  23595. if (modifier === before && modified[after]) {
  23596. this.raise(pos, TSErrors.InvalidModifiersOrder, before, after);
  23597. }
  23598. };
  23599. const incompatible = (pos, modifier, mod1, mod2) => {
  23600. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  23601. this.raise(pos, TSErrors.IncompatibleModifiers, mod1, mod2);
  23602. }
  23603. };
  23604. for (;;) {
  23605. const startPos = this.state.start;
  23606. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []));
  23607. if (!modifier) break;
  23608. if (tsIsAccessModifier(modifier)) {
  23609. if (modified.accessibility) {
  23610. this.raise(startPos, TSErrors.DuplicateAccessibilityModifier);
  23611. } else {
  23612. enforceOrder(startPos, modifier, modifier, "override");
  23613. enforceOrder(startPos, modifier, modifier, "static");
  23614. enforceOrder(startPos, modifier, modifier, "readonly");
  23615. modified.accessibility = modifier;
  23616. }
  23617. } else {
  23618. if (Object.hasOwnProperty.call(modified, modifier)) {
  23619. this.raise(startPos, TSErrors.DuplicateModifier, modifier);
  23620. } else {
  23621. enforceOrder(startPos, modifier, "static", "readonly");
  23622. enforceOrder(startPos, modifier, "static", "override");
  23623. enforceOrder(startPos, modifier, "override", "readonly");
  23624. enforceOrder(startPos, modifier, "abstract", "override");
  23625. incompatible(startPos, modifier, "declare", "override");
  23626. incompatible(startPos, modifier, "static", "abstract");
  23627. }
  23628. modified[modifier] = true;
  23629. }
  23630. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  23631. this.raise(startPos, errorTemplate, modifier);
  23632. }
  23633. }
  23634. }
  23635. tsIsListTerminator(kind) {
  23636. switch (kind) {
  23637. case "EnumMembers":
  23638. case "TypeMembers":
  23639. return this.match(types$1.braceR);
  23640. case "HeritageClauseElement":
  23641. return this.match(types$1.braceL);
  23642. case "TupleElementTypes":
  23643. return this.match(types$1.bracketR);
  23644. case "TypeParametersOrArguments":
  23645. return this.isRelational(">");
  23646. }
  23647. throw new Error("Unreachable");
  23648. }
  23649. tsParseList(kind, parseElement) {
  23650. const result = [];
  23651. while (!this.tsIsListTerminator(kind)) {
  23652. result.push(parseElement());
  23653. }
  23654. return result;
  23655. }
  23656. tsParseDelimitedList(kind, parseElement) {
  23657. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true));
  23658. }
  23659. tsParseDelimitedListWorker(kind, parseElement, expectSuccess) {
  23660. const result = [];
  23661. for (;;) {
  23662. if (this.tsIsListTerminator(kind)) {
  23663. break;
  23664. }
  23665. const element = parseElement();
  23666. if (element == null) {
  23667. return undefined;
  23668. }
  23669. result.push(element);
  23670. if (this.eat(types$1.comma)) {
  23671. continue;
  23672. }
  23673. if (this.tsIsListTerminator(kind)) {
  23674. break;
  23675. }
  23676. if (expectSuccess) {
  23677. this.expect(types$1.comma);
  23678. }
  23679. return undefined;
  23680. }
  23681. return result;
  23682. }
  23683. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken) {
  23684. if (!skipFirstToken) {
  23685. if (bracket) {
  23686. this.expect(types$1.bracketL);
  23687. } else {
  23688. this.expectRelational("<");
  23689. }
  23690. }
  23691. const result = this.tsParseDelimitedList(kind, parseElement);
  23692. if (bracket) {
  23693. this.expect(types$1.bracketR);
  23694. } else {
  23695. this.expectRelational(">");
  23696. }
  23697. return result;
  23698. }
  23699. tsParseImportType() {
  23700. const node = this.startNode();
  23701. this.expect(types$1._import);
  23702. this.expect(types$1.parenL);
  23703. if (!this.match(types$1.string)) {
  23704. this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument);
  23705. }
  23706. node.argument = this.parseExprAtom();
  23707. this.expect(types$1.parenR);
  23708. if (this.eat(types$1.dot)) {
  23709. node.qualifier = this.tsParseEntityName(true);
  23710. }
  23711. if (this.isRelational("<")) {
  23712. node.typeParameters = this.tsParseTypeArguments();
  23713. }
  23714. return this.finishNode(node, "TSImportType");
  23715. }
  23716. tsParseEntityName(allowReservedWords) {
  23717. let entity = this.parseIdentifier();
  23718. while (this.eat(types$1.dot)) {
  23719. const node = this.startNodeAtNode(entity);
  23720. node.left = entity;
  23721. node.right = this.parseIdentifier(allowReservedWords);
  23722. entity = this.finishNode(node, "TSQualifiedName");
  23723. }
  23724. return entity;
  23725. }
  23726. tsParseTypeReference() {
  23727. const node = this.startNode();
  23728. node.typeName = this.tsParseEntityName(false);
  23729. if (!this.hasPrecedingLineBreak() && this.isRelational("<")) {
  23730. node.typeParameters = this.tsParseTypeArguments();
  23731. }
  23732. return this.finishNode(node, "TSTypeReference");
  23733. }
  23734. tsParseThisTypePredicate(lhs) {
  23735. this.next();
  23736. const node = this.startNodeAtNode(lhs);
  23737. node.parameterName = lhs;
  23738. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  23739. node.asserts = false;
  23740. return this.finishNode(node, "TSTypePredicate");
  23741. }
  23742. tsParseThisTypeNode() {
  23743. const node = this.startNode();
  23744. this.next();
  23745. return this.finishNode(node, "TSThisType");
  23746. }
  23747. tsParseTypeQuery() {
  23748. const node = this.startNode();
  23749. this.expect(types$1._typeof);
  23750. if (this.match(types$1._import)) {
  23751. node.exprName = this.tsParseImportType();
  23752. } else {
  23753. node.exprName = this.tsParseEntityName(true);
  23754. }
  23755. return this.finishNode(node, "TSTypeQuery");
  23756. }
  23757. tsParseTypeParameter() {
  23758. const node = this.startNode();
  23759. node.name = this.tsParseTypeParameterName();
  23760. node.constraint = this.tsEatThenParseType(types$1._extends);
  23761. node.default = this.tsEatThenParseType(types$1.eq);
  23762. return this.finishNode(node, "TSTypeParameter");
  23763. }
  23764. tsTryParseTypeParameters() {
  23765. if (this.isRelational("<")) {
  23766. return this.tsParseTypeParameters();
  23767. }
  23768. }
  23769. tsParseTypeParameters() {
  23770. const node = this.startNode();
  23771. if (this.isRelational("<") || this.match(types$1.jsxTagStart)) {
  23772. this.next();
  23773. } else {
  23774. this.unexpected();
  23775. }
  23776. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true);
  23777. if (node.params.length === 0) {
  23778. this.raise(node.start, TSErrors.EmptyTypeParameters);
  23779. }
  23780. return this.finishNode(node, "TSTypeParameterDeclaration");
  23781. }
  23782. tsTryNextParseConstantContext() {
  23783. if (this.lookahead().type === types$1._const) {
  23784. this.next();
  23785. return this.tsParseTypeReference();
  23786. }
  23787. return null;
  23788. }
  23789. tsFillSignature(returnToken, signature) {
  23790. const returnTokenRequired = returnToken === types$1.arrow;
  23791. signature.typeParameters = this.tsTryParseTypeParameters();
  23792. this.expect(types$1.parenL);
  23793. signature.parameters = this.tsParseBindingListForSignature();
  23794. if (returnTokenRequired) {
  23795. signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  23796. } else if (this.match(returnToken)) {
  23797. signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  23798. }
  23799. }
  23800. tsParseBindingListForSignature() {
  23801. return this.parseBindingList(types$1.parenR, 41).map(pattern => {
  23802. if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
  23803. this.raise(pattern.start, TSErrors.UnsupportedSignatureParameterKind, pattern.type);
  23804. }
  23805. return pattern;
  23806. });
  23807. }
  23808. tsParseTypeMemberSemicolon() {
  23809. if (!this.eat(types$1.comma) && !this.isLineTerminator()) {
  23810. this.expect(types$1.semi);
  23811. }
  23812. }
  23813. tsParseSignatureMember(kind, node) {
  23814. this.tsFillSignature(types$1.colon, node);
  23815. this.tsParseTypeMemberSemicolon();
  23816. return this.finishNode(node, kind);
  23817. }
  23818. tsIsUnambiguouslyIndexSignature() {
  23819. this.next();
  23820. return this.eat(types$1.name) && this.match(types$1.colon);
  23821. }
  23822. tsTryParseIndexSignature(node) {
  23823. if (!(this.match(types$1.bracketL) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  23824. return undefined;
  23825. }
  23826. this.expect(types$1.bracketL);
  23827. const id = this.parseIdentifier();
  23828. id.typeAnnotation = this.tsParseTypeAnnotation();
  23829. this.resetEndLocation(id);
  23830. this.expect(types$1.bracketR);
  23831. node.parameters = [id];
  23832. const type = this.tsTryParseTypeAnnotation();
  23833. if (type) node.typeAnnotation = type;
  23834. this.tsParseTypeMemberSemicolon();
  23835. return this.finishNode(node, "TSIndexSignature");
  23836. }
  23837. tsParsePropertyOrMethodSignature(node, readonly) {
  23838. if (this.eat(types$1.question)) node.optional = true;
  23839. const nodeAny = node;
  23840. if (this.match(types$1.parenL) || this.isRelational("<")) {
  23841. if (readonly) {
  23842. this.raise(node.start, TSErrors.ReadonlyForMethodSignature);
  23843. }
  23844. const method = nodeAny;
  23845. if (method.kind && this.isRelational("<")) {
  23846. this.raise(this.state.pos, TSErrors.AccesorCannotHaveTypeParameters);
  23847. }
  23848. this.tsFillSignature(types$1.colon, method);
  23849. this.tsParseTypeMemberSemicolon();
  23850. if (method.kind === "get") {
  23851. if (method.parameters.length > 0) {
  23852. this.raise(this.state.pos, ErrorMessages.BadGetterArity);
  23853. if (this.isThisParam(method.parameters[0])) {
  23854. this.raise(this.state.pos, TSErrors.AccesorCannotDeclareThisParameter);
  23855. }
  23856. }
  23857. } else if (method.kind === "set") {
  23858. if (method.parameters.length !== 1) {
  23859. this.raise(this.state.pos, ErrorMessages.BadSetterArity);
  23860. } else {
  23861. const firstParameter = method.parameters[0];
  23862. if (this.isThisParam(firstParameter)) {
  23863. this.raise(this.state.pos, TSErrors.AccesorCannotDeclareThisParameter);
  23864. }
  23865. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  23866. this.raise(this.state.pos, TSErrors.SetAccesorCannotHaveOptionalParameter);
  23867. }
  23868. if (firstParameter.type === "RestElement") {
  23869. this.raise(this.state.pos, TSErrors.SetAccesorCannotHaveRestParameter);
  23870. }
  23871. }
  23872. if (method.typeAnnotation) {
  23873. this.raise(method.typeAnnotation.start, TSErrors.SetAccesorCannotHaveReturnType);
  23874. }
  23875. } else {
  23876. method.kind = "method";
  23877. }
  23878. return this.finishNode(method, "TSMethodSignature");
  23879. } else {
  23880. const property = nodeAny;
  23881. if (readonly) property.readonly = true;
  23882. const type = this.tsTryParseTypeAnnotation();
  23883. if (type) property.typeAnnotation = type;
  23884. this.tsParseTypeMemberSemicolon();
  23885. return this.finishNode(property, "TSPropertySignature");
  23886. }
  23887. }
  23888. tsParseTypeMember() {
  23889. const node = this.startNode();
  23890. if (this.match(types$1.parenL) || this.isRelational("<")) {
  23891. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  23892. }
  23893. if (this.match(types$1._new)) {
  23894. const id = this.startNode();
  23895. this.next();
  23896. if (this.match(types$1.parenL) || this.isRelational("<")) {
  23897. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  23898. } else {
  23899. node.key = this.createIdentifier(id, "new");
  23900. return this.tsParsePropertyOrMethodSignature(node, false);
  23901. }
  23902. }
  23903. this.tsParseModifiers(node, ["readonly"], ["declare", "abstract", "private", "protected", "public", "static", "override"], TSErrors.InvalidModifierOnTypeMember);
  23904. const idx = this.tsTryParseIndexSignature(node);
  23905. if (idx) {
  23906. return idx;
  23907. }
  23908. this.parsePropertyName(node, false);
  23909. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  23910. node.kind = node.key.name;
  23911. this.parsePropertyName(node, false);
  23912. }
  23913. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  23914. }
  23915. tsParseTypeLiteral() {
  23916. const node = this.startNode();
  23917. node.members = this.tsParseObjectTypeMembers();
  23918. return this.finishNode(node, "TSTypeLiteral");
  23919. }
  23920. tsParseObjectTypeMembers() {
  23921. this.expect(types$1.braceL);
  23922. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  23923. this.expect(types$1.braceR);
  23924. return members;
  23925. }
  23926. tsIsStartOfMappedType() {
  23927. this.next();
  23928. if (this.eat(types$1.plusMin)) {
  23929. return this.isContextual("readonly");
  23930. }
  23931. if (this.isContextual("readonly")) {
  23932. this.next();
  23933. }
  23934. if (!this.match(types$1.bracketL)) {
  23935. return false;
  23936. }
  23937. this.next();
  23938. if (!this.tsIsIdentifier()) {
  23939. return false;
  23940. }
  23941. this.next();
  23942. return this.match(types$1._in);
  23943. }
  23944. tsParseMappedTypeParameter() {
  23945. const node = this.startNode();
  23946. node.name = this.tsParseTypeParameterName();
  23947. node.constraint = this.tsExpectThenParseType(types$1._in);
  23948. return this.finishNode(node, "TSTypeParameter");
  23949. }
  23950. tsParseMappedType() {
  23951. const node = this.startNode();
  23952. this.expect(types$1.braceL);
  23953. if (this.match(types$1.plusMin)) {
  23954. node.readonly = this.state.value;
  23955. this.next();
  23956. this.expectContextual("readonly");
  23957. } else if (this.eatContextual("readonly")) {
  23958. node.readonly = true;
  23959. }
  23960. this.expect(types$1.bracketL);
  23961. node.typeParameter = this.tsParseMappedTypeParameter();
  23962. node.nameType = this.eatContextual("as") ? this.tsParseType() : null;
  23963. this.expect(types$1.bracketR);
  23964. if (this.match(types$1.plusMin)) {
  23965. node.optional = this.state.value;
  23966. this.next();
  23967. this.expect(types$1.question);
  23968. } else if (this.eat(types$1.question)) {
  23969. node.optional = true;
  23970. }
  23971. node.typeAnnotation = this.tsTryParseType();
  23972. this.semicolon();
  23973. this.expect(types$1.braceR);
  23974. return this.finishNode(node, "TSMappedType");
  23975. }
  23976. tsParseTupleType() {
  23977. const node = this.startNode();
  23978. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  23979. let seenOptionalElement = false;
  23980. let labeledElements = null;
  23981. node.elementTypes.forEach(elementNode => {
  23982. var _labeledElements;
  23983. let {
  23984. type
  23985. } = elementNode;
  23986. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  23987. this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired);
  23988. }
  23989. seenOptionalElement = seenOptionalElement || type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType";
  23990. if (type === "TSRestType") {
  23991. elementNode = elementNode.typeAnnotation;
  23992. type = elementNode.type;
  23993. }
  23994. const isLabeled = type === "TSNamedTupleMember";
  23995. labeledElements = (_labeledElements = labeledElements) != null ? _labeledElements : isLabeled;
  23996. if (labeledElements !== isLabeled) {
  23997. this.raise(elementNode.start, TSErrors.MixedLabeledAndUnlabeledElements);
  23998. }
  23999. });
  24000. return this.finishNode(node, "TSTupleType");
  24001. }
  24002. tsParseTupleElementType() {
  24003. const {
  24004. start: startPos,
  24005. startLoc
  24006. } = this.state;
  24007. const rest = this.eat(types$1.ellipsis);
  24008. let type = this.tsParseType();
  24009. const optional = this.eat(types$1.question);
  24010. const labeled = this.eat(types$1.colon);
  24011. if (labeled) {
  24012. const labeledNode = this.startNodeAtNode(type);
  24013. labeledNode.optional = optional;
  24014. if (type.type === "TSTypeReference" && !type.typeParameters && type.typeName.type === "Identifier") {
  24015. labeledNode.label = type.typeName;
  24016. } else {
  24017. this.raise(type.start, TSErrors.InvalidTupleMemberLabel);
  24018. labeledNode.label = type;
  24019. }
  24020. labeledNode.elementType = this.tsParseType();
  24021. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  24022. } else if (optional) {
  24023. const optionalTypeNode = this.startNodeAtNode(type);
  24024. optionalTypeNode.typeAnnotation = type;
  24025. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  24026. }
  24027. if (rest) {
  24028. const restNode = this.startNodeAt(startPos, startLoc);
  24029. restNode.typeAnnotation = type;
  24030. type = this.finishNode(restNode, "TSRestType");
  24031. }
  24032. return type;
  24033. }
  24034. tsParseParenthesizedType() {
  24035. const node = this.startNode();
  24036. this.expect(types$1.parenL);
  24037. node.typeAnnotation = this.tsParseType();
  24038. this.expect(types$1.parenR);
  24039. return this.finishNode(node, "TSParenthesizedType");
  24040. }
  24041. tsParseFunctionOrConstructorType(type, abstract) {
  24042. const node = this.startNode();
  24043. if (type === "TSConstructorType") {
  24044. node.abstract = !!abstract;
  24045. if (abstract) this.next();
  24046. this.next();
  24047. }
  24048. this.tsFillSignature(types$1.arrow, node);
  24049. return this.finishNode(node, type);
  24050. }
  24051. tsParseLiteralTypeNode() {
  24052. const node = this.startNode();
  24053. node.literal = (() => {
  24054. switch (this.state.type) {
  24055. case types$1.num:
  24056. case types$1.bigint:
  24057. case types$1.string:
  24058. case types$1._true:
  24059. case types$1._false:
  24060. return this.parseExprAtom();
  24061. default:
  24062. throw this.unexpected();
  24063. }
  24064. })();
  24065. return this.finishNode(node, "TSLiteralType");
  24066. }
  24067. tsParseTemplateLiteralType() {
  24068. const node = this.startNode();
  24069. node.literal = this.parseTemplate(false);
  24070. return this.finishNode(node, "TSLiteralType");
  24071. }
  24072. parseTemplateSubstitution() {
  24073. if (this.state.inType) return this.tsParseType();
  24074. return super.parseTemplateSubstitution();
  24075. }
  24076. tsParseThisTypeOrThisTypePredicate() {
  24077. const thisKeyword = this.tsParseThisTypeNode();
  24078. if (this.isContextual("is") && !this.hasPrecedingLineBreak()) {
  24079. return this.tsParseThisTypePredicate(thisKeyword);
  24080. } else {
  24081. return thisKeyword;
  24082. }
  24083. }
  24084. tsParseNonArrayType() {
  24085. switch (this.state.type) {
  24086. case types$1.name:
  24087. case types$1._void:
  24088. case types$1._null:
  24089. {
  24090. const type = this.match(types$1._void) ? "TSVoidKeyword" : this.match(types$1._null) ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  24091. if (type !== undefined && this.lookaheadCharCode() !== 46) {
  24092. const node = this.startNode();
  24093. this.next();
  24094. return this.finishNode(node, type);
  24095. }
  24096. return this.tsParseTypeReference();
  24097. }
  24098. case types$1.string:
  24099. case types$1.num:
  24100. case types$1.bigint:
  24101. case types$1._true:
  24102. case types$1._false:
  24103. return this.tsParseLiteralTypeNode();
  24104. case types$1.plusMin:
  24105. if (this.state.value === "-") {
  24106. const node = this.startNode();
  24107. const nextToken = this.lookahead();
  24108. if (nextToken.type !== types$1.num && nextToken.type !== types$1.bigint) {
  24109. throw this.unexpected();
  24110. }
  24111. node.literal = this.parseMaybeUnary();
  24112. return this.finishNode(node, "TSLiteralType");
  24113. }
  24114. break;
  24115. case types$1._this:
  24116. return this.tsParseThisTypeOrThisTypePredicate();
  24117. case types$1._typeof:
  24118. return this.tsParseTypeQuery();
  24119. case types$1._import:
  24120. return this.tsParseImportType();
  24121. case types$1.braceL:
  24122. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  24123. case types$1.bracketL:
  24124. return this.tsParseTupleType();
  24125. case types$1.parenL:
  24126. return this.tsParseParenthesizedType();
  24127. case types$1.backQuote:
  24128. return this.tsParseTemplateLiteralType();
  24129. }
  24130. throw this.unexpected();
  24131. }
  24132. tsParseArrayTypeOrHigher() {
  24133. let type = this.tsParseNonArrayType();
  24134. while (!this.hasPrecedingLineBreak() && this.eat(types$1.bracketL)) {
  24135. if (this.match(types$1.bracketR)) {
  24136. const node = this.startNodeAtNode(type);
  24137. node.elementType = type;
  24138. this.expect(types$1.bracketR);
  24139. type = this.finishNode(node, "TSArrayType");
  24140. } else {
  24141. const node = this.startNodeAtNode(type);
  24142. node.objectType = type;
  24143. node.indexType = this.tsParseType();
  24144. this.expect(types$1.bracketR);
  24145. type = this.finishNode(node, "TSIndexedAccessType");
  24146. }
  24147. }
  24148. return type;
  24149. }
  24150. tsParseTypeOperator(operator) {
  24151. const node = this.startNode();
  24152. this.expectContextual(operator);
  24153. node.operator = operator;
  24154. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  24155. if (operator === "readonly") {
  24156. this.tsCheckTypeAnnotationForReadOnly(node);
  24157. }
  24158. return this.finishNode(node, "TSTypeOperator");
  24159. }
  24160. tsCheckTypeAnnotationForReadOnly(node) {
  24161. switch (node.typeAnnotation.type) {
  24162. case "TSTupleType":
  24163. case "TSArrayType":
  24164. return;
  24165. default:
  24166. this.raise(node.start, TSErrors.UnexpectedReadonly);
  24167. }
  24168. }
  24169. tsParseInferType() {
  24170. const node = this.startNode();
  24171. this.expectContextual("infer");
  24172. const typeParameter = this.startNode();
  24173. typeParameter.name = this.tsParseTypeParameterName();
  24174. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  24175. return this.finishNode(node, "TSInferType");
  24176. }
  24177. tsParseTypeOperatorOrHigher() {
  24178. const operator = ["keyof", "unique", "readonly"].find(kw => this.isContextual(kw));
  24179. return operator ? this.tsParseTypeOperator(operator) : this.isContextual("infer") ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
  24180. }
  24181. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  24182. const node = this.startNode();
  24183. const hasLeadingOperator = this.eat(operator);
  24184. const types = [];
  24185. do {
  24186. types.push(parseConstituentType());
  24187. } while (this.eat(operator));
  24188. if (types.length === 1 && !hasLeadingOperator) {
  24189. return types[0];
  24190. }
  24191. node.types = types;
  24192. return this.finishNode(node, kind);
  24193. }
  24194. tsParseIntersectionTypeOrHigher() {
  24195. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), types$1.bitwiseAND);
  24196. }
  24197. tsParseUnionTypeOrHigher() {
  24198. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), types$1.bitwiseOR);
  24199. }
  24200. tsIsStartOfFunctionType() {
  24201. if (this.isRelational("<")) {
  24202. return true;
  24203. }
  24204. return this.match(types$1.parenL) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  24205. }
  24206. tsSkipParameterStart() {
  24207. if (this.match(types$1.name) || this.match(types$1._this)) {
  24208. this.next();
  24209. return true;
  24210. }
  24211. if (this.match(types$1.braceL)) {
  24212. let braceStackCounter = 1;
  24213. this.next();
  24214. while (braceStackCounter > 0) {
  24215. if (this.match(types$1.braceL)) {
  24216. ++braceStackCounter;
  24217. } else if (this.match(types$1.braceR)) {
  24218. --braceStackCounter;
  24219. }
  24220. this.next();
  24221. }
  24222. return true;
  24223. }
  24224. if (this.match(types$1.bracketL)) {
  24225. let braceStackCounter = 1;
  24226. this.next();
  24227. while (braceStackCounter > 0) {
  24228. if (this.match(types$1.bracketL)) {
  24229. ++braceStackCounter;
  24230. } else if (this.match(types$1.bracketR)) {
  24231. --braceStackCounter;
  24232. }
  24233. this.next();
  24234. }
  24235. return true;
  24236. }
  24237. return false;
  24238. }
  24239. tsIsUnambiguouslyStartOfFunctionType() {
  24240. this.next();
  24241. if (this.match(types$1.parenR) || this.match(types$1.ellipsis)) {
  24242. return true;
  24243. }
  24244. if (this.tsSkipParameterStart()) {
  24245. if (this.match(types$1.colon) || this.match(types$1.comma) || this.match(types$1.question) || this.match(types$1.eq)) {
  24246. return true;
  24247. }
  24248. if (this.match(types$1.parenR)) {
  24249. this.next();
  24250. if (this.match(types$1.arrow)) {
  24251. return true;
  24252. }
  24253. }
  24254. }
  24255. return false;
  24256. }
  24257. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  24258. return this.tsInType(() => {
  24259. const t = this.startNode();
  24260. this.expect(returnToken);
  24261. const node = this.startNode();
  24262. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  24263. if (asserts && this.match(types$1._this)) {
  24264. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  24265. if (thisTypePredicate.type === "TSThisType") {
  24266. node.parameterName = thisTypePredicate;
  24267. node.asserts = true;
  24268. node.typeAnnotation = null;
  24269. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  24270. } else {
  24271. this.resetStartLocationFromNode(thisTypePredicate, node);
  24272. thisTypePredicate.asserts = true;
  24273. }
  24274. t.typeAnnotation = thisTypePredicate;
  24275. return this.finishNode(t, "TSTypeAnnotation");
  24276. }
  24277. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  24278. if (!typePredicateVariable) {
  24279. if (!asserts) {
  24280. return this.tsParseTypeAnnotation(false, t);
  24281. }
  24282. node.parameterName = this.parseIdentifier();
  24283. node.asserts = asserts;
  24284. node.typeAnnotation = null;
  24285. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  24286. return this.finishNode(t, "TSTypeAnnotation");
  24287. }
  24288. const type = this.tsParseTypeAnnotation(false);
  24289. node.parameterName = typePredicateVariable;
  24290. node.typeAnnotation = type;
  24291. node.asserts = asserts;
  24292. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  24293. return this.finishNode(t, "TSTypeAnnotation");
  24294. });
  24295. }
  24296. tsTryParseTypeOrTypePredicateAnnotation() {
  24297. return this.match(types$1.colon) ? this.tsParseTypeOrTypePredicateAnnotation(types$1.colon) : undefined;
  24298. }
  24299. tsTryParseTypeAnnotation() {
  24300. return this.match(types$1.colon) ? this.tsParseTypeAnnotation() : undefined;
  24301. }
  24302. tsTryParseType() {
  24303. return this.tsEatThenParseType(types$1.colon);
  24304. }
  24305. tsParseTypePredicatePrefix() {
  24306. const id = this.parseIdentifier();
  24307. if (this.isContextual("is") && !this.hasPrecedingLineBreak()) {
  24308. this.next();
  24309. return id;
  24310. }
  24311. }
  24312. tsParseTypePredicateAsserts() {
  24313. if (!this.match(types$1.name) || this.state.value !== "asserts" || this.hasPrecedingLineBreak()) {
  24314. return false;
  24315. }
  24316. const containsEsc = this.state.containsEsc;
  24317. this.next();
  24318. if (!this.match(types$1.name) && !this.match(types$1._this)) {
  24319. return false;
  24320. }
  24321. if (containsEsc) {
  24322. this.raise(this.state.lastTokStart, ErrorMessages.InvalidEscapedReservedWord, "asserts");
  24323. }
  24324. return true;
  24325. }
  24326. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  24327. this.tsInType(() => {
  24328. if (eatColon) this.expect(types$1.colon);
  24329. t.typeAnnotation = this.tsParseType();
  24330. });
  24331. return this.finishNode(t, "TSTypeAnnotation");
  24332. }
  24333. tsParseType() {
  24334. assert$2(this.state.inType);
  24335. const type = this.tsParseNonConditionalType();
  24336. if (this.hasPrecedingLineBreak() || !this.eat(types$1._extends)) {
  24337. return type;
  24338. }
  24339. const node = this.startNodeAtNode(type);
  24340. node.checkType = type;
  24341. node.extendsType = this.tsParseNonConditionalType();
  24342. this.expect(types$1.question);
  24343. node.trueType = this.tsParseType();
  24344. this.expect(types$1.colon);
  24345. node.falseType = this.tsParseType();
  24346. return this.finishNode(node, "TSConditionalType");
  24347. }
  24348. isAbstractConstructorSignature() {
  24349. return this.isContextual("abstract") && this.lookahead().type === types$1._new;
  24350. }
  24351. tsParseNonConditionalType() {
  24352. if (this.tsIsStartOfFunctionType()) {
  24353. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  24354. }
  24355. if (this.match(types$1._new)) {
  24356. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  24357. } else if (this.isAbstractConstructorSignature()) {
  24358. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  24359. }
  24360. return this.tsParseUnionTypeOrHigher();
  24361. }
  24362. tsParseTypeAssertion() {
  24363. const node = this.startNode();
  24364. const _const = this.tsTryNextParseConstantContext();
  24365. node.typeAnnotation = _const || this.tsNextThenParseType();
  24366. this.expectRelational(">");
  24367. node.expression = this.parseMaybeUnary();
  24368. return this.finishNode(node, "TSTypeAssertion");
  24369. }
  24370. tsParseHeritageClause(descriptor) {
  24371. const originalStart = this.state.start;
  24372. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
  24373. if (!delimitedList.length) {
  24374. this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor);
  24375. }
  24376. return delimitedList;
  24377. }
  24378. tsParseExpressionWithTypeArguments() {
  24379. const node = this.startNode();
  24380. node.expression = this.tsParseEntityName(false);
  24381. if (this.isRelational("<")) {
  24382. node.typeParameters = this.tsParseTypeArguments();
  24383. }
  24384. return this.finishNode(node, "TSExpressionWithTypeArguments");
  24385. }
  24386. tsParseInterfaceDeclaration(node) {
  24387. if (this.match(types$1.name)) {
  24388. node.id = this.parseIdentifier();
  24389. this.checkLVal(node.id, "typescript interface declaration", BIND_TS_INTERFACE);
  24390. } else {
  24391. node.id = null;
  24392. this.raise(this.state.start, TSErrors.MissingInterfaceName);
  24393. }
  24394. node.typeParameters = this.tsTryParseTypeParameters();
  24395. if (this.eat(types$1._extends)) {
  24396. node.extends = this.tsParseHeritageClause("extends");
  24397. }
  24398. const body = this.startNode();
  24399. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  24400. node.body = this.finishNode(body, "TSInterfaceBody");
  24401. return this.finishNode(node, "TSInterfaceDeclaration");
  24402. }
  24403. tsParseTypeAliasDeclaration(node) {
  24404. node.id = this.parseIdentifier();
  24405. this.checkLVal(node.id, "typescript type alias", BIND_TS_TYPE);
  24406. node.typeParameters = this.tsTryParseTypeParameters();
  24407. node.typeAnnotation = this.tsInType(() => {
  24408. this.expect(types$1.eq);
  24409. if (this.isContextual("intrinsic") && this.lookahead().type !== types$1.dot) {
  24410. const node = this.startNode();
  24411. this.next();
  24412. return this.finishNode(node, "TSIntrinsicKeyword");
  24413. }
  24414. return this.tsParseType();
  24415. });
  24416. this.semicolon();
  24417. return this.finishNode(node, "TSTypeAliasDeclaration");
  24418. }
  24419. tsInNoContext(cb) {
  24420. const oldContext = this.state.context;
  24421. this.state.context = [oldContext[0]];
  24422. try {
  24423. return cb();
  24424. } finally {
  24425. this.state.context = oldContext;
  24426. }
  24427. }
  24428. tsInType(cb) {
  24429. const oldInType = this.state.inType;
  24430. this.state.inType = true;
  24431. try {
  24432. return cb();
  24433. } finally {
  24434. this.state.inType = oldInType;
  24435. }
  24436. }
  24437. tsEatThenParseType(token) {
  24438. return !this.match(token) ? undefined : this.tsNextThenParseType();
  24439. }
  24440. tsExpectThenParseType(token) {
  24441. return this.tsDoThenParseType(() => this.expect(token));
  24442. }
  24443. tsNextThenParseType() {
  24444. return this.tsDoThenParseType(() => this.next());
  24445. }
  24446. tsDoThenParseType(cb) {
  24447. return this.tsInType(() => {
  24448. cb();
  24449. return this.tsParseType();
  24450. });
  24451. }
  24452. tsParseEnumMember() {
  24453. const node = this.startNode();
  24454. node.id = this.match(types$1.string) ? this.parseExprAtom() : this.parseIdentifier(true);
  24455. if (this.eat(types$1.eq)) {
  24456. node.initializer = this.parseMaybeAssignAllowIn();
  24457. }
  24458. return this.finishNode(node, "TSEnumMember");
  24459. }
  24460. tsParseEnumDeclaration(node, isConst) {
  24461. if (isConst) node.const = true;
  24462. node.id = this.parseIdentifier();
  24463. this.checkLVal(node.id, "typescript enum declaration", isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM);
  24464. this.expect(types$1.braceL);
  24465. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  24466. this.expect(types$1.braceR);
  24467. return this.finishNode(node, "TSEnumDeclaration");
  24468. }
  24469. tsParseModuleBlock() {
  24470. const node = this.startNode();
  24471. this.scope.enter(SCOPE_OTHER);
  24472. this.expect(types$1.braceL);
  24473. this.parseBlockOrModuleBlockBody(node.body = [], undefined, true, types$1.braceR);
  24474. this.scope.exit();
  24475. return this.finishNode(node, "TSModuleBlock");
  24476. }
  24477. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  24478. node.id = this.parseIdentifier();
  24479. if (!nested) {
  24480. this.checkLVal(node.id, "module or namespace declaration", BIND_TS_NAMESPACE);
  24481. }
  24482. if (this.eat(types$1.dot)) {
  24483. const inner = this.startNode();
  24484. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  24485. node.body = inner;
  24486. } else {
  24487. this.scope.enter(SCOPE_TS_MODULE);
  24488. this.prodParam.enter(PARAM);
  24489. node.body = this.tsParseModuleBlock();
  24490. this.prodParam.exit();
  24491. this.scope.exit();
  24492. }
  24493. return this.finishNode(node, "TSModuleDeclaration");
  24494. }
  24495. tsParseAmbientExternalModuleDeclaration(node) {
  24496. if (this.isContextual("global")) {
  24497. node.global = true;
  24498. node.id = this.parseIdentifier();
  24499. } else if (this.match(types$1.string)) {
  24500. node.id = this.parseExprAtom();
  24501. } else {
  24502. this.unexpected();
  24503. }
  24504. if (this.match(types$1.braceL)) {
  24505. this.scope.enter(SCOPE_TS_MODULE);
  24506. this.prodParam.enter(PARAM);
  24507. node.body = this.tsParseModuleBlock();
  24508. this.prodParam.exit();
  24509. this.scope.exit();
  24510. } else {
  24511. this.semicolon();
  24512. }
  24513. return this.finishNode(node, "TSModuleDeclaration");
  24514. }
  24515. tsParseImportEqualsDeclaration(node, isExport) {
  24516. node.isExport = isExport || false;
  24517. node.id = this.parseIdentifier();
  24518. this.checkLVal(node.id, "import equals declaration", BIND_LEXICAL);
  24519. this.expect(types$1.eq);
  24520. const moduleReference = this.tsParseModuleReference();
  24521. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  24522. this.raise(moduleReference.start, TSErrors.ImportAliasHasImportType);
  24523. }
  24524. node.moduleReference = moduleReference;
  24525. this.semicolon();
  24526. return this.finishNode(node, "TSImportEqualsDeclaration");
  24527. }
  24528. tsIsExternalModuleReference() {
  24529. return this.isContextual("require") && this.lookaheadCharCode() === 40;
  24530. }
  24531. tsParseModuleReference() {
  24532. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
  24533. }
  24534. tsParseExternalModuleReference() {
  24535. const node = this.startNode();
  24536. this.expectContextual("require");
  24537. this.expect(types$1.parenL);
  24538. if (!this.match(types$1.string)) {
  24539. throw this.unexpected();
  24540. }
  24541. node.expression = this.parseExprAtom();
  24542. this.expect(types$1.parenR);
  24543. return this.finishNode(node, "TSExternalModuleReference");
  24544. }
  24545. tsLookAhead(f) {
  24546. const state = this.state.clone();
  24547. const res = f();
  24548. this.state = state;
  24549. return res;
  24550. }
  24551. tsTryParseAndCatch(f) {
  24552. const result = this.tryParse(abort => f() || abort());
  24553. if (result.aborted || !result.node) return undefined;
  24554. if (result.error) this.state = result.failState;
  24555. return result.node;
  24556. }
  24557. tsTryParse(f) {
  24558. const state = this.state.clone();
  24559. const result = f();
  24560. if (result !== undefined && result !== false) {
  24561. return result;
  24562. } else {
  24563. this.state = state;
  24564. return undefined;
  24565. }
  24566. }
  24567. tsTryParseDeclare(nany) {
  24568. if (this.isLineTerminator()) {
  24569. return;
  24570. }
  24571. let starttype = this.state.type;
  24572. let kind;
  24573. if (this.isContextual("let")) {
  24574. starttype = types$1._var;
  24575. kind = "let";
  24576. }
  24577. return this.tsInAmbientContext(() => {
  24578. switch (starttype) {
  24579. case types$1._function:
  24580. nany.declare = true;
  24581. return this.parseFunctionStatement(nany, false, true);
  24582. case types$1._class:
  24583. nany.declare = true;
  24584. return this.parseClass(nany, true, false);
  24585. case types$1._const:
  24586. if (this.match(types$1._const) && this.isLookaheadContextual("enum")) {
  24587. this.expect(types$1._const);
  24588. this.expectContextual("enum");
  24589. return this.tsParseEnumDeclaration(nany, true);
  24590. }
  24591. case types$1._var:
  24592. kind = kind || this.state.value;
  24593. return this.parseVarStatement(nany, kind);
  24594. case types$1.name:
  24595. {
  24596. const value = this.state.value;
  24597. if (value === "global") {
  24598. return this.tsParseAmbientExternalModuleDeclaration(nany);
  24599. } else {
  24600. return this.tsParseDeclaration(nany, value, true);
  24601. }
  24602. }
  24603. }
  24604. });
  24605. }
  24606. tsTryParseExportDeclaration() {
  24607. return this.tsParseDeclaration(this.startNode(), this.state.value, true);
  24608. }
  24609. tsParseExpressionStatement(node, expr) {
  24610. switch (expr.name) {
  24611. case "declare":
  24612. {
  24613. const declaration = this.tsTryParseDeclare(node);
  24614. if (declaration) {
  24615. declaration.declare = true;
  24616. return declaration;
  24617. }
  24618. break;
  24619. }
  24620. case "global":
  24621. if (this.match(types$1.braceL)) {
  24622. this.scope.enter(SCOPE_TS_MODULE);
  24623. this.prodParam.enter(PARAM);
  24624. const mod = node;
  24625. mod.global = true;
  24626. mod.id = expr;
  24627. mod.body = this.tsParseModuleBlock();
  24628. this.scope.exit();
  24629. this.prodParam.exit();
  24630. return this.finishNode(mod, "TSModuleDeclaration");
  24631. }
  24632. break;
  24633. default:
  24634. return this.tsParseDeclaration(node, expr.name, false);
  24635. }
  24636. }
  24637. tsParseDeclaration(node, value, next) {
  24638. switch (value) {
  24639. case "abstract":
  24640. if (this.tsCheckLineTerminator(next) && (this.match(types$1._class) || this.match(types$1.name))) {
  24641. return this.tsParseAbstractDeclaration(node);
  24642. }
  24643. break;
  24644. case "enum":
  24645. if (next || this.match(types$1.name)) {
  24646. if (next) this.next();
  24647. return this.tsParseEnumDeclaration(node, false);
  24648. }
  24649. break;
  24650. case "interface":
  24651. if (this.tsCheckLineTerminator(next) && this.match(types$1.name)) {
  24652. return this.tsParseInterfaceDeclaration(node);
  24653. }
  24654. break;
  24655. case "module":
  24656. if (this.tsCheckLineTerminator(next)) {
  24657. if (this.match(types$1.string)) {
  24658. return this.tsParseAmbientExternalModuleDeclaration(node);
  24659. } else if (this.match(types$1.name)) {
  24660. return this.tsParseModuleOrNamespaceDeclaration(node);
  24661. }
  24662. }
  24663. break;
  24664. case "namespace":
  24665. if (this.tsCheckLineTerminator(next) && this.match(types$1.name)) {
  24666. return this.tsParseModuleOrNamespaceDeclaration(node);
  24667. }
  24668. break;
  24669. case "type":
  24670. if (this.tsCheckLineTerminator(next) && this.match(types$1.name)) {
  24671. return this.tsParseTypeAliasDeclaration(node);
  24672. }
  24673. break;
  24674. }
  24675. }
  24676. tsCheckLineTerminator(next) {
  24677. if (next) {
  24678. if (this.hasFollowingLineBreak()) return false;
  24679. this.next();
  24680. return true;
  24681. }
  24682. return !this.isLineTerminator();
  24683. }
  24684. tsTryParseGenericAsyncArrowFunction(startPos, startLoc) {
  24685. if (!this.isRelational("<")) {
  24686. return undefined;
  24687. }
  24688. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  24689. this.state.maybeInArrowParameters = true;
  24690. const res = this.tsTryParseAndCatch(() => {
  24691. const node = this.startNodeAt(startPos, startLoc);
  24692. node.typeParameters = this.tsParseTypeParameters();
  24693. super.parseFunctionParams(node);
  24694. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  24695. this.expect(types$1.arrow);
  24696. return node;
  24697. });
  24698. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  24699. if (!res) {
  24700. return undefined;
  24701. }
  24702. return this.parseArrowExpression(res, null, true);
  24703. }
  24704. tsParseTypeArguments() {
  24705. const node = this.startNode();
  24706. node.params = this.tsInType(() => this.tsInNoContext(() => {
  24707. this.expectRelational("<");
  24708. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  24709. }));
  24710. if (node.params.length === 0) {
  24711. this.raise(node.start, TSErrors.EmptyTypeArguments);
  24712. }
  24713. this.expectRelational(">");
  24714. return this.finishNode(node, "TSTypeParameterInstantiation");
  24715. }
  24716. tsIsDeclarationStart() {
  24717. if (this.match(types$1.name)) {
  24718. switch (this.state.value) {
  24719. case "abstract":
  24720. case "declare":
  24721. case "enum":
  24722. case "interface":
  24723. case "module":
  24724. case "namespace":
  24725. case "type":
  24726. return true;
  24727. }
  24728. }
  24729. return false;
  24730. }
  24731. isExportDefaultSpecifier() {
  24732. if (this.tsIsDeclarationStart()) return false;
  24733. return super.isExportDefaultSpecifier();
  24734. }
  24735. parseAssignableListItem(allowModifiers, decorators) {
  24736. const startPos = this.state.start;
  24737. const startLoc = this.state.startLoc;
  24738. let accessibility;
  24739. let readonly = false;
  24740. let override = false;
  24741. if (allowModifiers !== undefined) {
  24742. const modified = {};
  24743. this.tsParseModifiers(modified, ["public", "private", "protected", "override", "readonly"]);
  24744. accessibility = modified.accessibility;
  24745. override = modified.override;
  24746. readonly = modified.readonly;
  24747. if (allowModifiers === false && (accessibility || readonly || override)) {
  24748. this.raise(startPos, TSErrors.UnexpectedParameterModifier);
  24749. }
  24750. }
  24751. const left = this.parseMaybeDefault();
  24752. this.parseAssignableListItemTypes(left);
  24753. const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
  24754. if (accessibility || readonly || override) {
  24755. const pp = this.startNodeAt(startPos, startLoc);
  24756. if (decorators.length) {
  24757. pp.decorators = decorators;
  24758. }
  24759. if (accessibility) pp.accessibility = accessibility;
  24760. if (readonly) pp.readonly = readonly;
  24761. if (override) pp.override = override;
  24762. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  24763. this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind);
  24764. }
  24765. pp.parameter = elt;
  24766. return this.finishNode(pp, "TSParameterProperty");
  24767. }
  24768. if (decorators.length) {
  24769. left.decorators = decorators;
  24770. }
  24771. return elt;
  24772. }
  24773. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  24774. if (this.match(types$1.colon)) {
  24775. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(types$1.colon);
  24776. }
  24777. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" ? "TSDeclareMethod" : undefined;
  24778. if (bodilessType && !this.match(types$1.braceL) && this.isLineTerminator()) {
  24779. this.finishNode(node, bodilessType);
  24780. return;
  24781. }
  24782. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  24783. this.raise(node.start, TSErrors.DeclareFunctionHasImplementation);
  24784. if (node.declare) {
  24785. super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  24786. return;
  24787. }
  24788. }
  24789. super.parseFunctionBodyAndFinish(node, type, isMethod);
  24790. }
  24791. registerFunctionStatementId(node) {
  24792. if (!node.body && node.id) {
  24793. this.checkLVal(node.id, "function name", BIND_TS_AMBIENT);
  24794. } else {
  24795. super.registerFunctionStatementId(...arguments);
  24796. }
  24797. }
  24798. tsCheckForInvalidTypeCasts(items) {
  24799. items.forEach(node => {
  24800. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  24801. this.raise(node.typeAnnotation.start, TSErrors.UnexpectedTypeAnnotation);
  24802. }
  24803. });
  24804. }
  24805. toReferencedList(exprList, isInParens) {
  24806. this.tsCheckForInvalidTypeCasts(exprList);
  24807. return exprList;
  24808. }
  24809. parseArrayLike(...args) {
  24810. const node = super.parseArrayLike(...args);
  24811. if (node.type === "ArrayExpression") {
  24812. this.tsCheckForInvalidTypeCasts(node.elements);
  24813. }
  24814. return node;
  24815. }
  24816. parseSubscript(base, startPos, startLoc, noCalls, state) {
  24817. if (!this.hasPrecedingLineBreak() && this.match(types$1.bang)) {
  24818. this.state.exprAllowed = false;
  24819. this.next();
  24820. const nonNullExpression = this.startNodeAt(startPos, startLoc);
  24821. nonNullExpression.expression = base;
  24822. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  24823. }
  24824. let isOptionalCall = false;
  24825. if (this.match(types$1.questionDot) && this.lookaheadCharCode() === 60) {
  24826. if (noCalls) {
  24827. state.stop = true;
  24828. return base;
  24829. }
  24830. state.optionalChainMember = isOptionalCall = true;
  24831. this.next();
  24832. }
  24833. if (this.isRelational("<")) {
  24834. let missingParenErrorPos;
  24835. const result = this.tsTryParseAndCatch(() => {
  24836. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  24837. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
  24838. if (asyncArrowFn) {
  24839. return asyncArrowFn;
  24840. }
  24841. }
  24842. const node = this.startNodeAt(startPos, startLoc);
  24843. node.callee = base;
  24844. const typeArguments = this.tsParseTypeArguments();
  24845. if (typeArguments) {
  24846. if (isOptionalCall && !this.match(types$1.parenL)) {
  24847. missingParenErrorPos = this.state.pos;
  24848. this.unexpected();
  24849. }
  24850. if (!noCalls && this.eat(types$1.parenL)) {
  24851. node.arguments = this.parseCallExpressionArguments(types$1.parenR, false);
  24852. this.tsCheckForInvalidTypeCasts(node.arguments);
  24853. node.typeParameters = typeArguments;
  24854. if (state.optionalChainMember) {
  24855. node.optional = isOptionalCall;
  24856. }
  24857. return this.finishCallExpression(node, state.optionalChainMember);
  24858. } else if (this.match(types$1.backQuote)) {
  24859. const result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
  24860. result.typeParameters = typeArguments;
  24861. return result;
  24862. }
  24863. }
  24864. this.unexpected();
  24865. });
  24866. if (missingParenErrorPos) {
  24867. this.unexpected(missingParenErrorPos, types$1.parenL);
  24868. }
  24869. if (result) return result;
  24870. }
  24871. return super.parseSubscript(base, startPos, startLoc, noCalls, state);
  24872. }
  24873. parseNewArguments(node) {
  24874. if (this.isRelational("<")) {
  24875. const typeParameters = this.tsTryParseAndCatch(() => {
  24876. const args = this.tsParseTypeArguments();
  24877. if (!this.match(types$1.parenL)) this.unexpected();
  24878. return args;
  24879. });
  24880. if (typeParameters) {
  24881. node.typeParameters = typeParameters;
  24882. }
  24883. }
  24884. super.parseNewArguments(node);
  24885. }
  24886. parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
  24887. if (nonNull(types$1._in.binop) > minPrec && !this.hasPrecedingLineBreak() && this.isContextual("as")) {
  24888. const node = this.startNodeAt(leftStartPos, leftStartLoc);
  24889. node.expression = left;
  24890. const _const = this.tsTryNextParseConstantContext();
  24891. if (_const) {
  24892. node.typeAnnotation = _const;
  24893. } else {
  24894. node.typeAnnotation = this.tsNextThenParseType();
  24895. }
  24896. this.finishNode(node, "TSAsExpression");
  24897. this.reScan_lt_gt();
  24898. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
  24899. }
  24900. return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec);
  24901. }
  24902. checkReservedWord(word, startLoc, checkKeywords, isBinding) {}
  24903. checkDuplicateExports() {}
  24904. parseImport(node) {
  24905. node.importKind = "value";
  24906. if (this.match(types$1.name) || this.match(types$1.star) || this.match(types$1.braceL)) {
  24907. let ahead = this.lookahead();
  24908. if (this.isContextual("type") && ahead.type !== types$1.comma && !(ahead.type === types$1.name && ahead.value === "from") && ahead.type !== types$1.eq) {
  24909. node.importKind = "type";
  24910. this.next();
  24911. ahead = this.lookahead();
  24912. }
  24913. if (this.match(types$1.name) && ahead.type === types$1.eq) {
  24914. return this.tsParseImportEqualsDeclaration(node);
  24915. }
  24916. }
  24917. const importNode = super.parseImport(node);
  24918. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  24919. this.raise(importNode.start, TSErrors.TypeImportCannotSpecifyDefaultAndNamed);
  24920. }
  24921. return importNode;
  24922. }
  24923. parseExport(node) {
  24924. if (this.match(types$1._import)) {
  24925. this.next();
  24926. if (this.isContextual("type") && this.lookaheadCharCode() !== 61) {
  24927. node.importKind = "type";
  24928. this.next();
  24929. } else {
  24930. node.importKind = "value";
  24931. }
  24932. return this.tsParseImportEqualsDeclaration(node, true);
  24933. } else if (this.eat(types$1.eq)) {
  24934. const assign = node;
  24935. assign.expression = this.parseExpression();
  24936. this.semicolon();
  24937. return this.finishNode(assign, "TSExportAssignment");
  24938. } else if (this.eatContextual("as")) {
  24939. const decl = node;
  24940. this.expectContextual("namespace");
  24941. decl.id = this.parseIdentifier();
  24942. this.semicolon();
  24943. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  24944. } else {
  24945. if (this.isContextual("type") && this.lookahead().type === types$1.braceL) {
  24946. this.next();
  24947. node.exportKind = "type";
  24948. } else {
  24949. node.exportKind = "value";
  24950. }
  24951. return super.parseExport(node);
  24952. }
  24953. }
  24954. isAbstractClass() {
  24955. return this.isContextual("abstract") && this.lookahead().type === types$1._class;
  24956. }
  24957. parseExportDefaultExpression() {
  24958. if (this.isAbstractClass()) {
  24959. const cls = this.startNode();
  24960. this.next();
  24961. cls.abstract = true;
  24962. this.parseClass(cls, true, true);
  24963. return cls;
  24964. }
  24965. if (this.state.value === "interface") {
  24966. const interfaceNode = this.startNode();
  24967. this.next();
  24968. const result = this.tsParseInterfaceDeclaration(interfaceNode);
  24969. if (result) return result;
  24970. }
  24971. return super.parseExportDefaultExpression();
  24972. }
  24973. parseStatementContent(context, topLevel) {
  24974. if (this.state.type === types$1._const) {
  24975. const ahead = this.lookahead();
  24976. if (ahead.type === types$1.name && ahead.value === "enum") {
  24977. const node = this.startNode();
  24978. this.expect(types$1._const);
  24979. this.expectContextual("enum");
  24980. return this.tsParseEnumDeclaration(node, true);
  24981. }
  24982. }
  24983. return super.parseStatementContent(context, topLevel);
  24984. }
  24985. parseAccessModifier() {
  24986. return this.tsParseModifier(["public", "protected", "private"]);
  24987. }
  24988. tsHasSomeModifiers(member, modifiers) {
  24989. return modifiers.some(modifier => {
  24990. if (tsIsAccessModifier(modifier)) {
  24991. return member.accessibility === modifier;
  24992. }
  24993. return !!member[modifier];
  24994. });
  24995. }
  24996. parseClassMember(classBody, member, state) {
  24997. const invalidModifersForStaticBlocks = ["declare", "private", "public", "protected", "override", "abstract", "readonly"];
  24998. this.tsParseModifiers(member, invalidModifersForStaticBlocks.concat(["static"]));
  24999. const callParseClassMemberWithIsStatic = () => {
  25000. const isStatic = !!member.static;
  25001. if (isStatic && this.eat(types$1.braceL)) {
  25002. if (this.tsHasSomeModifiers(member, invalidModifersForStaticBlocks)) {
  25003. this.raise(this.state.pos, TSErrors.StaticBlockCannotHaveModifier);
  25004. }
  25005. this.parseClassStaticBlock(classBody, member);
  25006. } else {
  25007. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  25008. }
  25009. };
  25010. if (member.declare) {
  25011. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  25012. } else {
  25013. callParseClassMemberWithIsStatic();
  25014. }
  25015. }
  25016. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  25017. const idx = this.tsTryParseIndexSignature(member);
  25018. if (idx) {
  25019. classBody.body.push(idx);
  25020. if (member.abstract) {
  25021. this.raise(member.start, TSErrors.IndexSignatureHasAbstract);
  25022. }
  25023. if (member.accessibility) {
  25024. this.raise(member.start, TSErrors.IndexSignatureHasAccessibility, member.accessibility);
  25025. }
  25026. if (member.declare) {
  25027. this.raise(member.start, TSErrors.IndexSignatureHasDeclare);
  25028. }
  25029. if (member.override) {
  25030. this.raise(member.start, TSErrors.IndexSignatureHasOverride);
  25031. }
  25032. return;
  25033. }
  25034. if (!this.state.inAbstractClass && member.abstract) {
  25035. this.raise(member.start, TSErrors.NonAbstractClassHasAbstractMethod);
  25036. }
  25037. if (member.override) {
  25038. if (!state.hadSuperClass) {
  25039. this.raise(member.start, TSErrors.OverrideNotInSubClass);
  25040. }
  25041. }
  25042. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  25043. }
  25044. parsePostMemberNameModifiers(methodOrProp) {
  25045. const optional = this.eat(types$1.question);
  25046. if (optional) methodOrProp.optional = true;
  25047. if (methodOrProp.readonly && this.match(types$1.parenL)) {
  25048. this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly);
  25049. }
  25050. if (methodOrProp.declare && this.match(types$1.parenL)) {
  25051. this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare);
  25052. }
  25053. }
  25054. parseExpressionStatement(node, expr) {
  25055. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr) : undefined;
  25056. return decl || super.parseExpressionStatement(node, expr);
  25057. }
  25058. shouldParseExportDeclaration() {
  25059. if (this.tsIsDeclarationStart()) return true;
  25060. return super.shouldParseExportDeclaration();
  25061. }
  25062. parseConditional(expr, startPos, startLoc, refExpressionErrors) {
  25063. if (!this.state.maybeInArrowParameters || !this.match(types$1.question)) {
  25064. return super.parseConditional(expr, startPos, startLoc, refExpressionErrors);
  25065. }
  25066. const result = this.tryParse(() => super.parseConditional(expr, startPos, startLoc));
  25067. if (!result.node) {
  25068. if (result.error) {
  25069. super.setOptionalParametersError(refExpressionErrors, result.error);
  25070. }
  25071. return expr;
  25072. }
  25073. if (result.error) this.state = result.failState;
  25074. return result.node;
  25075. }
  25076. parseParenItem(node, startPos, startLoc) {
  25077. node = super.parseParenItem(node, startPos, startLoc);
  25078. if (this.eat(types$1.question)) {
  25079. node.optional = true;
  25080. this.resetEndLocation(node);
  25081. }
  25082. if (this.match(types$1.colon)) {
  25083. const typeCastNode = this.startNodeAt(startPos, startLoc);
  25084. typeCastNode.expression = node;
  25085. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  25086. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  25087. }
  25088. return node;
  25089. }
  25090. parseExportDeclaration(node) {
  25091. const startPos = this.state.start;
  25092. const startLoc = this.state.startLoc;
  25093. const isDeclare = this.eatContextual("declare");
  25094. if (isDeclare && (this.isContextual("declare") || !this.shouldParseExportDeclaration())) {
  25095. throw this.raise(this.state.start, TSErrors.ExpectedAmbientAfterExportDeclare);
  25096. }
  25097. let declaration;
  25098. if (this.match(types$1.name)) {
  25099. declaration = this.tsTryParseExportDeclaration();
  25100. }
  25101. if (!declaration) {
  25102. declaration = super.parseExportDeclaration(node);
  25103. }
  25104. if (declaration && (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare)) {
  25105. node.exportKind = "type";
  25106. }
  25107. if (declaration && isDeclare) {
  25108. this.resetStartLocation(declaration, startPos, startLoc);
  25109. declaration.declare = true;
  25110. }
  25111. return declaration;
  25112. }
  25113. parseClassId(node, isStatement, optionalId) {
  25114. if ((!isStatement || optionalId) && this.isContextual("implements")) {
  25115. return;
  25116. }
  25117. super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS);
  25118. const typeParameters = this.tsTryParseTypeParameters();
  25119. if (typeParameters) node.typeParameters = typeParameters;
  25120. }
  25121. parseClassPropertyAnnotation(node) {
  25122. if (!node.optional && this.eat(types$1.bang)) {
  25123. node.definite = true;
  25124. }
  25125. const type = this.tsTryParseTypeAnnotation();
  25126. if (type) node.typeAnnotation = type;
  25127. }
  25128. parseClassProperty(node) {
  25129. this.parseClassPropertyAnnotation(node);
  25130. if (this.state.isAmbientContext && this.match(types$1.eq)) {
  25131. this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);
  25132. }
  25133. if (node.abstract && this.match(types$1.eq)) {
  25134. const {
  25135. key
  25136. } = node;
  25137. this.raise(this.state.start, TSErrors.AbstractPropertyHasInitializer, key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`);
  25138. }
  25139. return super.parseClassProperty(node);
  25140. }
  25141. parseClassPrivateProperty(node) {
  25142. if (node.abstract) {
  25143. this.raise(node.start, TSErrors.PrivateElementHasAbstract);
  25144. }
  25145. if (node.accessibility) {
  25146. this.raise(node.start, TSErrors.PrivateElementHasAccessibility, node.accessibility);
  25147. }
  25148. this.parseClassPropertyAnnotation(node);
  25149. return super.parseClassPrivateProperty(node);
  25150. }
  25151. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  25152. const typeParameters = this.tsTryParseTypeParameters();
  25153. if (typeParameters && isConstructor) {
  25154. this.raise(typeParameters.start, TSErrors.ConstructorHasTypeParameters);
  25155. }
  25156. if (method.declare && (method.kind === "get" || method.kind === "set")) {
  25157. this.raise(method.start, TSErrors.DeclareAccessor, method.kind);
  25158. }
  25159. if (typeParameters) method.typeParameters = typeParameters;
  25160. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  25161. }
  25162. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  25163. const typeParameters = this.tsTryParseTypeParameters();
  25164. if (typeParameters) method.typeParameters = typeParameters;
  25165. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  25166. }
  25167. parseClassSuper(node) {
  25168. super.parseClassSuper(node);
  25169. if (node.superClass && this.isRelational("<")) {
  25170. node.superTypeParameters = this.tsParseTypeArguments();
  25171. }
  25172. if (this.eatContextual("implements")) {
  25173. node.implements = this.tsParseHeritageClause("implements");
  25174. }
  25175. }
  25176. parseObjPropValue(prop, ...args) {
  25177. const typeParameters = this.tsTryParseTypeParameters();
  25178. if (typeParameters) prop.typeParameters = typeParameters;
  25179. super.parseObjPropValue(prop, ...args);
  25180. }
  25181. parseFunctionParams(node, allowModifiers) {
  25182. const typeParameters = this.tsTryParseTypeParameters();
  25183. if (typeParameters) node.typeParameters = typeParameters;
  25184. super.parseFunctionParams(node, allowModifiers);
  25185. }
  25186. parseVarId(decl, kind) {
  25187. super.parseVarId(decl, kind);
  25188. if (decl.id.type === "Identifier" && this.eat(types$1.bang)) {
  25189. decl.definite = true;
  25190. }
  25191. const type = this.tsTryParseTypeAnnotation();
  25192. if (type) {
  25193. decl.id.typeAnnotation = type;
  25194. this.resetEndLocation(decl.id);
  25195. }
  25196. }
  25197. parseAsyncArrowFromCallExpression(node, call) {
  25198. if (this.match(types$1.colon)) {
  25199. node.returnType = this.tsParseTypeAnnotation();
  25200. }
  25201. return super.parseAsyncArrowFromCallExpression(node, call);
  25202. }
  25203. parseMaybeAssign(...args) {
  25204. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2, _jsx4, _typeCast3;
  25205. let state;
  25206. let jsx;
  25207. let typeCast;
  25208. if (this.hasPlugin("jsx") && (this.match(types$1.jsxTagStart) || this.isRelational("<"))) {
  25209. state = this.state.clone();
  25210. jsx = this.tryParse(() => super.parseMaybeAssign(...args), state);
  25211. if (!jsx.error) return jsx.node;
  25212. const {
  25213. context
  25214. } = this.state;
  25215. if (context[context.length - 1] === types.j_oTag) {
  25216. context.length -= 2;
  25217. } else if (context[context.length - 1] === types.j_expr) {
  25218. context.length -= 1;
  25219. }
  25220. }
  25221. if (!((_jsx = jsx) != null && _jsx.error) && !this.isRelational("<")) {
  25222. return super.parseMaybeAssign(...args);
  25223. }
  25224. let typeParameters;
  25225. state = state || this.state.clone();
  25226. const arrow = this.tryParse(abort => {
  25227. var _expr$extra, _typeParameters;
  25228. typeParameters = this.tsParseTypeParameters();
  25229. const expr = super.parseMaybeAssign(...args);
  25230. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  25231. abort();
  25232. }
  25233. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  25234. this.resetStartLocationFromNode(expr, typeParameters);
  25235. }
  25236. expr.typeParameters = typeParameters;
  25237. return expr;
  25238. }, state);
  25239. if (!arrow.error && !arrow.aborted) return arrow.node;
  25240. if (!jsx) {
  25241. assert$2(!this.hasPlugin("jsx"));
  25242. typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state);
  25243. if (!typeCast.error) return typeCast.node;
  25244. }
  25245. if ((_jsx2 = jsx) != null && _jsx2.node) {
  25246. this.state = jsx.failState;
  25247. return jsx.node;
  25248. }
  25249. if (arrow.node) {
  25250. this.state = arrow.failState;
  25251. return arrow.node;
  25252. }
  25253. if ((_typeCast = typeCast) != null && _typeCast.node) {
  25254. this.state = typeCast.failState;
  25255. return typeCast.node;
  25256. }
  25257. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  25258. if (arrow.thrown) throw arrow.error;
  25259. if ((_typeCast2 = typeCast) != null && _typeCast2.thrown) throw typeCast.error;
  25260. throw ((_jsx4 = jsx) == null ? void 0 : _jsx4.error) || arrow.error || ((_typeCast3 = typeCast) == null ? void 0 : _typeCast3.error);
  25261. }
  25262. parseMaybeUnary(refExpressionErrors) {
  25263. if (!this.hasPlugin("jsx") && this.isRelational("<")) {
  25264. return this.tsParseTypeAssertion();
  25265. } else {
  25266. return super.parseMaybeUnary(refExpressionErrors);
  25267. }
  25268. }
  25269. parseArrow(node) {
  25270. if (this.match(types$1.colon)) {
  25271. const result = this.tryParse(abort => {
  25272. const returnType = this.tsParseTypeOrTypePredicateAnnotation(types$1.colon);
  25273. if (this.canInsertSemicolon() || !this.match(types$1.arrow)) abort();
  25274. return returnType;
  25275. });
  25276. if (result.aborted) return;
  25277. if (!result.thrown) {
  25278. if (result.error) this.state = result.failState;
  25279. node.returnType = result.node;
  25280. }
  25281. }
  25282. return super.parseArrow(node);
  25283. }
  25284. parseAssignableListItemTypes(param) {
  25285. if (this.eat(types$1.question)) {
  25286. if (param.type !== "Identifier" && !this.state.isAmbientContext && !this.state.inType) {
  25287. this.raise(param.start, TSErrors.PatternIsOptional);
  25288. }
  25289. param.optional = true;
  25290. }
  25291. const type = this.tsTryParseTypeAnnotation();
  25292. if (type) param.typeAnnotation = type;
  25293. this.resetEndLocation(param);
  25294. return param;
  25295. }
  25296. isAssignable(node, isBinding) {
  25297. switch (node.type) {
  25298. case "TSTypeCastExpression":
  25299. return this.isAssignable(node.expression, isBinding);
  25300. case "TSParameterProperty":
  25301. return true;
  25302. default:
  25303. return super.isAssignable(node, isBinding);
  25304. }
  25305. }
  25306. toAssignable(node, isLHS = false) {
  25307. switch (node.type) {
  25308. case "TSTypeCastExpression":
  25309. return super.toAssignable(this.typeCastToParameter(node), isLHS);
  25310. case "TSParameterProperty":
  25311. return super.toAssignable(node, isLHS);
  25312. case "ParenthesizedExpression":
  25313. return this.toAssignableParenthesizedExpression(node, isLHS);
  25314. case "TSAsExpression":
  25315. case "TSNonNullExpression":
  25316. case "TSTypeAssertion":
  25317. node.expression = this.toAssignable(node.expression, isLHS);
  25318. return node;
  25319. default:
  25320. return super.toAssignable(node, isLHS);
  25321. }
  25322. }
  25323. toAssignableParenthesizedExpression(node, isLHS) {
  25324. switch (node.expression.type) {
  25325. case "TSAsExpression":
  25326. case "TSNonNullExpression":
  25327. case "TSTypeAssertion":
  25328. case "ParenthesizedExpression":
  25329. node.expression = this.toAssignable(node.expression, isLHS);
  25330. return node;
  25331. default:
  25332. return super.toAssignable(node, isLHS);
  25333. }
  25334. }
  25335. checkLVal(expr, contextDescription, ...args) {
  25336. var _expr$extra2;
  25337. switch (expr.type) {
  25338. case "TSTypeCastExpression":
  25339. return;
  25340. case "TSParameterProperty":
  25341. this.checkLVal(expr.parameter, "parameter property", ...args);
  25342. return;
  25343. case "TSAsExpression":
  25344. case "TSTypeAssertion":
  25345. if (!args[0] && contextDescription !== "parenthesized expression" && !((_expr$extra2 = expr.extra) != null && _expr$extra2.parenthesized)) {
  25346. this.raise(expr.start, ErrorMessages.InvalidLhs, contextDescription);
  25347. break;
  25348. }
  25349. this.checkLVal(expr.expression, "parenthesized expression", ...args);
  25350. return;
  25351. case "TSNonNullExpression":
  25352. this.checkLVal(expr.expression, contextDescription, ...args);
  25353. return;
  25354. default:
  25355. super.checkLVal(expr, contextDescription, ...args);
  25356. return;
  25357. }
  25358. }
  25359. parseBindingAtom() {
  25360. switch (this.state.type) {
  25361. case types$1._this:
  25362. return this.parseIdentifier(true);
  25363. default:
  25364. return super.parseBindingAtom();
  25365. }
  25366. }
  25367. parseMaybeDecoratorArguments(expr) {
  25368. if (this.isRelational("<")) {
  25369. const typeArguments = this.tsParseTypeArguments();
  25370. if (this.match(types$1.parenL)) {
  25371. const call = super.parseMaybeDecoratorArguments(expr);
  25372. call.typeParameters = typeArguments;
  25373. return call;
  25374. }
  25375. this.unexpected(this.state.start, types$1.parenL);
  25376. }
  25377. return super.parseMaybeDecoratorArguments(expr);
  25378. }
  25379. checkCommaAfterRest(close) {
  25380. if (this.state.isAmbientContext && this.match(types$1.comma) && this.lookaheadCharCode() === close) {
  25381. this.next();
  25382. } else {
  25383. super.checkCommaAfterRest(close);
  25384. }
  25385. }
  25386. isClassMethod() {
  25387. return this.isRelational("<") || super.isClassMethod();
  25388. }
  25389. isClassProperty() {
  25390. return this.match(types$1.bang) || this.match(types$1.colon) || super.isClassProperty();
  25391. }
  25392. parseMaybeDefault(...args) {
  25393. const node = super.parseMaybeDefault(...args);
  25394. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  25395. this.raise(node.typeAnnotation.start, TSErrors.TypeAnnotationAfterAssign);
  25396. }
  25397. return node;
  25398. }
  25399. getTokenFromCode(code) {
  25400. if (this.state.inType && (code === 62 || code === 60)) {
  25401. return this.finishOp(types$1.relational, 1);
  25402. } else {
  25403. return super.getTokenFromCode(code);
  25404. }
  25405. }
  25406. reScan_lt_gt() {
  25407. if (this.match(types$1.relational)) {
  25408. const code = this.input.charCodeAt(this.state.start);
  25409. if (code === 60 || code === 62) {
  25410. this.state.pos -= 1;
  25411. this.readToken_lt_gt(code);
  25412. }
  25413. }
  25414. }
  25415. toAssignableList(exprList) {
  25416. for (let i = 0; i < exprList.length; i++) {
  25417. const expr = exprList[i];
  25418. if (!expr) continue;
  25419. switch (expr.type) {
  25420. case "TSTypeCastExpression":
  25421. exprList[i] = this.typeCastToParameter(expr);
  25422. break;
  25423. case "TSAsExpression":
  25424. case "TSTypeAssertion":
  25425. if (!this.state.maybeInArrowParameters) {
  25426. exprList[i] = this.typeCastToParameter(expr);
  25427. } else {
  25428. this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter);
  25429. }
  25430. break;
  25431. }
  25432. }
  25433. return super.toAssignableList(...arguments);
  25434. }
  25435. typeCastToParameter(node) {
  25436. node.expression.typeAnnotation = node.typeAnnotation;
  25437. this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
  25438. return node.expression;
  25439. }
  25440. shouldParseArrow(params) {
  25441. if (this.match(types$1.colon)) {
  25442. return params.every(expr => this.isAssignable(expr, true));
  25443. }
  25444. return super.shouldParseArrow(params);
  25445. }
  25446. shouldParseAsyncArrow() {
  25447. return this.match(types$1.colon) || super.shouldParseAsyncArrow();
  25448. }
  25449. canHaveLeadingDecorator() {
  25450. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  25451. }
  25452. jsxParseOpeningElementAfterName(node) {
  25453. if (this.isRelational("<")) {
  25454. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments());
  25455. if (typeArguments) node.typeParameters = typeArguments;
  25456. }
  25457. return super.jsxParseOpeningElementAfterName(node);
  25458. }
  25459. getGetterSetterExpectedParamCount(method) {
  25460. const baseCount = super.getGetterSetterExpectedParamCount(method);
  25461. const params = this.getObjectOrClassMethodParams(method);
  25462. const firstParam = params[0];
  25463. const hasContextParam = firstParam && this.isThisParam(firstParam);
  25464. return hasContextParam ? baseCount + 1 : baseCount;
  25465. }
  25466. parseCatchClauseParam() {
  25467. const param = super.parseCatchClauseParam();
  25468. const type = this.tsTryParseTypeAnnotation();
  25469. if (type) {
  25470. param.typeAnnotation = type;
  25471. this.resetEndLocation(param);
  25472. }
  25473. return param;
  25474. }
  25475. tsInAmbientContext(cb) {
  25476. const oldIsAmbientContext = this.state.isAmbientContext;
  25477. this.state.isAmbientContext = true;
  25478. try {
  25479. return cb();
  25480. } finally {
  25481. this.state.isAmbientContext = oldIsAmbientContext;
  25482. }
  25483. }
  25484. parseClass(node, ...args) {
  25485. const oldInAbstractClass = this.state.inAbstractClass;
  25486. this.state.inAbstractClass = !!node.abstract;
  25487. try {
  25488. return super.parseClass(node, ...args);
  25489. } finally {
  25490. this.state.inAbstractClass = oldInAbstractClass;
  25491. }
  25492. }
  25493. tsParseAbstractDeclaration(node) {
  25494. if (this.match(types$1._class)) {
  25495. node.abstract = true;
  25496. return this.parseClass(node, true, false);
  25497. } else if (this.isContextual("interface")) {
  25498. if (!this.hasFollowingLineBreak()) {
  25499. node.abstract = true;
  25500. this.raise(node.start, TSErrors.NonClassMethodPropertyHasAbstractModifer);
  25501. this.next();
  25502. return this.tsParseInterfaceDeclaration(node);
  25503. }
  25504. } else {
  25505. this.unexpected(null, types$1._class);
  25506. }
  25507. }
  25508. parseMethod(...args) {
  25509. const method = super.parseMethod(...args);
  25510. if (method.abstract) {
  25511. const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body;
  25512. if (hasBody) {
  25513. const {
  25514. key
  25515. } = method;
  25516. this.raise(method.start, TSErrors.AbstractMethodHasImplementation, key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`);
  25517. }
  25518. }
  25519. return method;
  25520. }
  25521. tsParseTypeParameterName() {
  25522. const typeName = this.parseIdentifier();
  25523. return typeName.name;
  25524. }
  25525. shouldParseAsAmbientContext() {
  25526. return !!this.getPluginOption("typescript", "dts");
  25527. }
  25528. parse() {
  25529. if (this.shouldParseAsAmbientContext()) {
  25530. this.state.isAmbientContext = true;
  25531. }
  25532. return super.parse();
  25533. }
  25534. getExpression() {
  25535. if (this.shouldParseAsAmbientContext()) {
  25536. this.state.isAmbientContext = true;
  25537. }
  25538. return super.getExpression();
  25539. }
  25540. });
  25541. types$1.placeholder = new TokenType("%%", {
  25542. startsExpr: true
  25543. });
  25544. const PlaceHolderErrors = makeErrorTemplates({
  25545. ClassNameIsRequired: "A class name is required."
  25546. }, ErrorCodes.SyntaxError);
  25547. var placeholders$1 = (superClass => class extends superClass {
  25548. parsePlaceholder(expectedNode) {
  25549. if (this.match(types$1.placeholder)) {
  25550. const node = this.startNode();
  25551. this.next();
  25552. this.assertNoSpace("Unexpected space in placeholder.");
  25553. node.name = super.parseIdentifier(true);
  25554. this.assertNoSpace("Unexpected space in placeholder.");
  25555. this.expect(types$1.placeholder);
  25556. return this.finishPlaceholder(node, expectedNode);
  25557. }
  25558. }
  25559. finishPlaceholder(node, expectedNode) {
  25560. const isFinished = !!(node.expectedNode && node.type === "Placeholder");
  25561. node.expectedNode = expectedNode;
  25562. return isFinished ? node : this.finishNode(node, "Placeholder");
  25563. }
  25564. getTokenFromCode(code) {
  25565. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  25566. return this.finishOp(types$1.placeholder, 2);
  25567. }
  25568. return super.getTokenFromCode(...arguments);
  25569. }
  25570. parseExprAtom() {
  25571. return this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments);
  25572. }
  25573. parseIdentifier() {
  25574. return this.parsePlaceholder("Identifier") || super.parseIdentifier(...arguments);
  25575. }
  25576. checkReservedWord(word) {
  25577. if (word !== undefined) super.checkReservedWord(...arguments);
  25578. }
  25579. parseBindingAtom() {
  25580. return this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments);
  25581. }
  25582. checkLVal(expr) {
  25583. if (expr.type !== "Placeholder") super.checkLVal(...arguments);
  25584. }
  25585. toAssignable(node) {
  25586. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  25587. node.expectedNode = "Pattern";
  25588. return node;
  25589. }
  25590. return super.toAssignable(...arguments);
  25591. }
  25592. isLet(context) {
  25593. if (super.isLet(context)) {
  25594. return true;
  25595. }
  25596. if (!this.isContextual("let")) {
  25597. return false;
  25598. }
  25599. if (context) return false;
  25600. const nextToken = this.lookahead();
  25601. if (nextToken.type === types$1.placeholder) {
  25602. return true;
  25603. }
  25604. return false;
  25605. }
  25606. verifyBreakContinue(node) {
  25607. if (node.label && node.label.type === "Placeholder") return;
  25608. super.verifyBreakContinue(...arguments);
  25609. }
  25610. parseExpressionStatement(node, expr) {
  25611. if (expr.type !== "Placeholder" || expr.extra && expr.extra.parenthesized) {
  25612. return super.parseExpressionStatement(...arguments);
  25613. }
  25614. if (this.match(types$1.colon)) {
  25615. const stmt = node;
  25616. stmt.label = this.finishPlaceholder(expr, "Identifier");
  25617. this.next();
  25618. stmt.body = this.parseStatement("label");
  25619. return this.finishNode(stmt, "LabeledStatement");
  25620. }
  25621. this.semicolon();
  25622. node.name = expr.name;
  25623. return this.finishPlaceholder(node, "Statement");
  25624. }
  25625. parseBlock() {
  25626. return this.parsePlaceholder("BlockStatement") || super.parseBlock(...arguments);
  25627. }
  25628. parseFunctionId() {
  25629. return this.parsePlaceholder("Identifier") || super.parseFunctionId(...arguments);
  25630. }
  25631. parseClass(node, isStatement, optionalId) {
  25632. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  25633. this.next();
  25634. this.takeDecorators(node);
  25635. const oldStrict = this.state.strict;
  25636. const placeholder = this.parsePlaceholder("Identifier");
  25637. if (placeholder) {
  25638. if (this.match(types$1._extends) || this.match(types$1.placeholder) || this.match(types$1.braceL)) {
  25639. node.id = placeholder;
  25640. } else if (optionalId || !isStatement) {
  25641. node.id = null;
  25642. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  25643. return this.finishNode(node, type);
  25644. } else {
  25645. this.unexpected(null, PlaceHolderErrors.ClassNameIsRequired);
  25646. }
  25647. } else {
  25648. this.parseClassId(node, isStatement, optionalId);
  25649. }
  25650. this.parseClassSuper(node);
  25651. node.body = this.parsePlaceholder("ClassBody") || this.parseClassBody(!!node.superClass, oldStrict);
  25652. return this.finishNode(node, type);
  25653. }
  25654. parseExport(node) {
  25655. const placeholder = this.parsePlaceholder("Identifier");
  25656. if (!placeholder) return super.parseExport(...arguments);
  25657. if (!this.isContextual("from") && !this.match(types$1.comma)) {
  25658. node.specifiers = [];
  25659. node.source = null;
  25660. node.declaration = this.finishPlaceholder(placeholder, "Declaration");
  25661. return this.finishNode(node, "ExportNamedDeclaration");
  25662. }
  25663. this.expectPlugin("exportDefaultFrom");
  25664. const specifier = this.startNode();
  25665. specifier.exported = placeholder;
  25666. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  25667. return super.parseExport(node);
  25668. }
  25669. isExportDefaultSpecifier() {
  25670. if (this.match(types$1._default)) {
  25671. const next = this.nextTokenStart();
  25672. if (this.isUnparsedContextual(next, "from")) {
  25673. if (this.input.startsWith(types$1.placeholder.label, this.nextTokenStartSince(next + 4))) {
  25674. return true;
  25675. }
  25676. }
  25677. }
  25678. return super.isExportDefaultSpecifier();
  25679. }
  25680. maybeParseExportDefaultSpecifier(node) {
  25681. if (node.specifiers && node.specifiers.length > 0) {
  25682. return true;
  25683. }
  25684. return super.maybeParseExportDefaultSpecifier(...arguments);
  25685. }
  25686. checkExport(node) {
  25687. const {
  25688. specifiers
  25689. } = node;
  25690. if (specifiers != null && specifiers.length) {
  25691. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  25692. }
  25693. super.checkExport(node);
  25694. node.specifiers = specifiers;
  25695. }
  25696. parseImport(node) {
  25697. const placeholder = this.parsePlaceholder("Identifier");
  25698. if (!placeholder) return super.parseImport(...arguments);
  25699. node.specifiers = [];
  25700. if (!this.isContextual("from") && !this.match(types$1.comma)) {
  25701. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  25702. this.semicolon();
  25703. return this.finishNode(node, "ImportDeclaration");
  25704. }
  25705. const specifier = this.startNodeAtNode(placeholder);
  25706. specifier.local = placeholder;
  25707. this.finishNode(specifier, "ImportDefaultSpecifier");
  25708. node.specifiers.push(specifier);
  25709. if (this.eat(types$1.comma)) {
  25710. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  25711. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  25712. }
  25713. this.expectContextual("from");
  25714. node.source = this.parseImportSource();
  25715. this.semicolon();
  25716. return this.finishNode(node, "ImportDeclaration");
  25717. }
  25718. parseImportSource() {
  25719. return this.parsePlaceholder("StringLiteral") || super.parseImportSource(...arguments);
  25720. }
  25721. });
  25722. var v8intrinsic = (superClass => class extends superClass {
  25723. parseV8Intrinsic() {
  25724. if (this.match(types$1.modulo)) {
  25725. const v8IntrinsicStart = this.state.start;
  25726. const node = this.startNode();
  25727. this.eat(types$1.modulo);
  25728. if (this.match(types$1.name)) {
  25729. const name = this.parseIdentifierName(this.state.start);
  25730. const identifier = this.createIdentifier(node, name);
  25731. identifier.type = "V8IntrinsicIdentifier";
  25732. if (this.match(types$1.parenL)) {
  25733. return identifier;
  25734. }
  25735. }
  25736. this.unexpected(v8IntrinsicStart);
  25737. }
  25738. }
  25739. parseExprAtom() {
  25740. return this.parseV8Intrinsic() || super.parseExprAtom(...arguments);
  25741. }
  25742. });
  25743. function hasPlugin(plugins, name) {
  25744. return plugins.some(plugin => {
  25745. if (Array.isArray(plugin)) {
  25746. return plugin[0] === name;
  25747. } else {
  25748. return plugin === name;
  25749. }
  25750. });
  25751. }
  25752. function getPluginOption(plugins, name, option) {
  25753. const plugin = plugins.find(plugin => {
  25754. if (Array.isArray(plugin)) {
  25755. return plugin[0] === name;
  25756. } else {
  25757. return plugin === name;
  25758. }
  25759. });
  25760. if (plugin && Array.isArray(plugin)) {
  25761. return plugin[1][option];
  25762. }
  25763. return null;
  25764. }
  25765. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  25766. const TOPIC_TOKENS = ["%", "#"];
  25767. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  25768. function validatePlugins(plugins) {
  25769. if (hasPlugin(plugins, "decorators")) {
  25770. if (hasPlugin(plugins, "decorators-legacy")) {
  25771. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  25772. }
  25773. const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
  25774. if (decoratorsBeforeExport == null) {
  25775. throw new Error("The 'decorators' plugin requires a 'decoratorsBeforeExport' option," + " whose value must be a boolean. If you are migrating from" + " Babylon/Babel 6 or want to use the old decorators proposal, you" + " should use the 'decorators-legacy' plugin instead of 'decorators'.");
  25776. } else if (typeof decoratorsBeforeExport !== "boolean") {
  25777. throw new Error("'decoratorsBeforeExport' must be a boolean.");
  25778. }
  25779. }
  25780. if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
  25781. throw new Error("Cannot combine flow and typescript plugins.");
  25782. }
  25783. if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
  25784. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  25785. }
  25786. if (hasPlugin(plugins, "pipelineOperator")) {
  25787. const proposal = getPluginOption(plugins, "pipelineOperator", "proposal");
  25788. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  25789. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  25790. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  25791. }
  25792. const tupleSyntaxIsHash = hasPlugin(plugins, "recordAndTuple") && getPluginOption(plugins, "recordAndTuple", "syntaxType") === "hash";
  25793. if (proposal === "hack") {
  25794. if (hasPlugin(plugins, "placeholders")) {
  25795. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  25796. }
  25797. if (hasPlugin(plugins, "v8intrinsic")) {
  25798. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  25799. }
  25800. const topicToken = getPluginOption(plugins, "pipelineOperator", "topicToken");
  25801. if (!TOPIC_TOKENS.includes(topicToken)) {
  25802. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  25803. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  25804. }
  25805. if (topicToken === "#" && tupleSyntaxIsHash) {
  25806. throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
  25807. }
  25808. } else if (proposal === "smart" && tupleSyntaxIsHash) {
  25809. throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
  25810. }
  25811. }
  25812. if (hasPlugin(plugins, "moduleAttributes")) {
  25813. {
  25814. if (hasPlugin(plugins, "importAssertions")) {
  25815. throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
  25816. }
  25817. const moduleAttributesVerionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
  25818. if (moduleAttributesVerionPluginOption !== "may-2020") {
  25819. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  25820. }
  25821. }
  25822. }
  25823. if (hasPlugin(plugins, "recordAndTuple") && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins, "recordAndTuple", "syntaxType"))) {
  25824. throw new Error("'recordAndTuple' requires 'syntaxType' option whose value should be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  25825. }
  25826. if (hasPlugin(plugins, "asyncDoExpressions") && !hasPlugin(plugins, "doExpressions")) {
  25827. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  25828. error.missingPlugins = "doExpressions";
  25829. throw error;
  25830. }
  25831. }
  25832. const mixinPlugins = {
  25833. estree,
  25834. jsx,
  25835. flow,
  25836. typescript,
  25837. v8intrinsic,
  25838. placeholders: placeholders$1
  25839. };
  25840. const mixinPluginNames = Object.keys(mixinPlugins);
  25841. const defaultOptions = {
  25842. sourceType: "script",
  25843. sourceFilename: undefined,
  25844. startLine: 1,
  25845. allowAwaitOutsideFunction: false,
  25846. allowReturnOutsideFunction: false,
  25847. allowImportExportEverywhere: false,
  25848. allowSuperOutsideMethod: false,
  25849. allowUndeclaredExports: false,
  25850. plugins: [],
  25851. strictMode: null,
  25852. ranges: false,
  25853. tokens: false,
  25854. createParenthesizedExpressions: false,
  25855. errorRecovery: false,
  25856. attachComment: true
  25857. };
  25858. function getOptions(opts) {
  25859. const options = {};
  25860. for (const key of Object.keys(defaultOptions)) {
  25861. options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key];
  25862. }
  25863. return options;
  25864. }
  25865. const unwrapParenthesizedExpression = node => {
  25866. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  25867. };
  25868. class LValParser extends NodeUtils {
  25869. toAssignable(node, isLHS = false) {
  25870. var _node$extra, _node$extra3;
  25871. let parenthesized = undefined;
  25872. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  25873. parenthesized = unwrapParenthesizedExpression(node);
  25874. if (isLHS) {
  25875. if (parenthesized.type === "Identifier") {
  25876. this.expressionScope.recordParenthesizedIdentifierError(node.start, ErrorMessages.InvalidParenthesizedAssignment);
  25877. } else if (parenthesized.type !== "MemberExpression") {
  25878. this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
  25879. }
  25880. } else {
  25881. this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
  25882. }
  25883. }
  25884. switch (node.type) {
  25885. case "Identifier":
  25886. case "ObjectPattern":
  25887. case "ArrayPattern":
  25888. case "AssignmentPattern":
  25889. case "RestElement":
  25890. break;
  25891. case "ObjectExpression":
  25892. node.type = "ObjectPattern";
  25893. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  25894. var _node$extra2;
  25895. const prop = node.properties[i];
  25896. const isLast = i === last;
  25897. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  25898. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingComma) {
  25899. this.raiseRestNotLast(node.extra.trailingComma);
  25900. }
  25901. }
  25902. break;
  25903. case "ObjectProperty":
  25904. this.toAssignable(node.value, isLHS);
  25905. break;
  25906. case "SpreadElement":
  25907. {
  25908. this.checkToRestConversion(node);
  25909. node.type = "RestElement";
  25910. const arg = node.argument;
  25911. this.toAssignable(arg, isLHS);
  25912. break;
  25913. }
  25914. case "ArrayExpression":
  25915. node.type = "ArrayPattern";
  25916. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma, isLHS);
  25917. break;
  25918. case "AssignmentExpression":
  25919. if (node.operator !== "=") {
  25920. this.raise(node.left.end, ErrorMessages.MissingEqInAssignment);
  25921. }
  25922. node.type = "AssignmentPattern";
  25923. delete node.operator;
  25924. this.toAssignable(node.left, isLHS);
  25925. break;
  25926. case "ParenthesizedExpression":
  25927. this.toAssignable(parenthesized, isLHS);
  25928. break;
  25929. }
  25930. return node;
  25931. }
  25932. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  25933. if (prop.type === "ObjectMethod") {
  25934. const error = prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod;
  25935. this.raise(prop.key.start, error);
  25936. } else if (prop.type === "SpreadElement" && !isLast) {
  25937. this.raiseRestNotLast(prop.start);
  25938. } else {
  25939. this.toAssignable(prop, isLHS);
  25940. }
  25941. }
  25942. toAssignableList(exprList, trailingCommaPos, isLHS) {
  25943. let end = exprList.length;
  25944. if (end) {
  25945. const last = exprList[end - 1];
  25946. if ((last == null ? void 0 : last.type) === "RestElement") {
  25947. --end;
  25948. } else if ((last == null ? void 0 : last.type) === "SpreadElement") {
  25949. last.type = "RestElement";
  25950. let arg = last.argument;
  25951. this.toAssignable(arg, isLHS);
  25952. arg = unwrapParenthesizedExpression(arg);
  25953. if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
  25954. this.unexpected(arg.start);
  25955. }
  25956. if (trailingCommaPos) {
  25957. this.raiseTrailingCommaAfterRest(trailingCommaPos);
  25958. }
  25959. --end;
  25960. }
  25961. }
  25962. for (let i = 0; i < end; i++) {
  25963. const elt = exprList[i];
  25964. if (elt) {
  25965. this.toAssignable(elt, isLHS);
  25966. if (elt.type === "RestElement") {
  25967. this.raiseRestNotLast(elt.start);
  25968. }
  25969. }
  25970. }
  25971. return exprList;
  25972. }
  25973. isAssignable(node, isBinding) {
  25974. switch (node.type) {
  25975. case "Identifier":
  25976. case "ObjectPattern":
  25977. case "ArrayPattern":
  25978. case "AssignmentPattern":
  25979. case "RestElement":
  25980. return true;
  25981. case "ObjectExpression":
  25982. {
  25983. const last = node.properties.length - 1;
  25984. return node.properties.every((prop, i) => {
  25985. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  25986. });
  25987. }
  25988. case "ObjectProperty":
  25989. return this.isAssignable(node.value);
  25990. case "SpreadElement":
  25991. return this.isAssignable(node.argument);
  25992. case "ArrayExpression":
  25993. return node.elements.every(element => element === null || this.isAssignable(element));
  25994. case "AssignmentExpression":
  25995. return node.operator === "=";
  25996. case "ParenthesizedExpression":
  25997. return this.isAssignable(node.expression);
  25998. case "MemberExpression":
  25999. case "OptionalMemberExpression":
  26000. return !isBinding;
  26001. default:
  26002. return false;
  26003. }
  26004. }
  26005. toReferencedList(exprList, isParenthesizedExpr) {
  26006. return exprList;
  26007. }
  26008. toReferencedListDeep(exprList, isParenthesizedExpr) {
  26009. this.toReferencedList(exprList, isParenthesizedExpr);
  26010. for (const expr of exprList) {
  26011. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  26012. this.toReferencedListDeep(expr.elements);
  26013. }
  26014. }
  26015. }
  26016. parseSpread(refExpressionErrors, refNeedsArrowPos) {
  26017. const node = this.startNode();
  26018. this.next();
  26019. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined, refNeedsArrowPos);
  26020. return this.finishNode(node, "SpreadElement");
  26021. }
  26022. parseRestBinding() {
  26023. const node = this.startNode();
  26024. this.next();
  26025. node.argument = this.parseBindingAtom();
  26026. return this.finishNode(node, "RestElement");
  26027. }
  26028. parseBindingAtom() {
  26029. switch (this.state.type) {
  26030. case types$1.bracketL:
  26031. {
  26032. const node = this.startNode();
  26033. this.next();
  26034. node.elements = this.parseBindingList(types$1.bracketR, 93, true);
  26035. return this.finishNode(node, "ArrayPattern");
  26036. }
  26037. case types$1.braceL:
  26038. return this.parseObjectLike(types$1.braceR, true);
  26039. }
  26040. return this.parseIdentifier();
  26041. }
  26042. parseBindingList(close, closeCharCode, allowEmpty, allowModifiers) {
  26043. const elts = [];
  26044. let first = true;
  26045. while (!this.eat(close)) {
  26046. if (first) {
  26047. first = false;
  26048. } else {
  26049. this.expect(types$1.comma);
  26050. }
  26051. if (allowEmpty && this.match(types$1.comma)) {
  26052. elts.push(null);
  26053. } else if (this.eat(close)) {
  26054. break;
  26055. } else if (this.match(types$1.ellipsis)) {
  26056. elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
  26057. this.checkCommaAfterRest(closeCharCode);
  26058. this.expect(close);
  26059. break;
  26060. } else {
  26061. const decorators = [];
  26062. if (this.match(types$1.at) && this.hasPlugin("decorators")) {
  26063. this.raise(this.state.start, ErrorMessages.UnsupportedParameterDecorator);
  26064. }
  26065. while (this.match(types$1.at)) {
  26066. decorators.push(this.parseDecorator());
  26067. }
  26068. elts.push(this.parseAssignableListItem(allowModifiers, decorators));
  26069. }
  26070. }
  26071. return elts;
  26072. }
  26073. parseAssignableListItem(allowModifiers, decorators) {
  26074. const left = this.parseMaybeDefault();
  26075. this.parseAssignableListItemTypes(left);
  26076. const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
  26077. if (decorators.length) {
  26078. left.decorators = decorators;
  26079. }
  26080. return elt;
  26081. }
  26082. parseAssignableListItemTypes(param) {
  26083. return param;
  26084. }
  26085. parseMaybeDefault(startPos, startLoc, left) {
  26086. var _startLoc, _startPos, _left;
  26087. startLoc = (_startLoc = startLoc) != null ? _startLoc : this.state.startLoc;
  26088. startPos = (_startPos = startPos) != null ? _startPos : this.state.start;
  26089. left = (_left = left) != null ? _left : this.parseBindingAtom();
  26090. if (!this.eat(types$1.eq)) return left;
  26091. const node = this.startNodeAt(startPos, startLoc);
  26092. node.left = left;
  26093. node.right = this.parseMaybeAssignAllowIn();
  26094. return this.finishNode(node, "AssignmentPattern");
  26095. }
  26096. checkLVal(expr, contextDescription, bindingType = BIND_NONE, checkClashes, disallowLetBinding, strictModeChanged = false) {
  26097. switch (expr.type) {
  26098. case "Identifier":
  26099. {
  26100. const {
  26101. name
  26102. } = expr;
  26103. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord$1(name, this.inModule) : isStrictBindOnlyReservedWord$1(name))) {
  26104. this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, name);
  26105. }
  26106. if (checkClashes) {
  26107. if (checkClashes.has(name)) {
  26108. this.raise(expr.start, ErrorMessages.ParamDupe);
  26109. } else {
  26110. checkClashes.add(name);
  26111. }
  26112. }
  26113. if (disallowLetBinding && name === "let") {
  26114. this.raise(expr.start, ErrorMessages.LetInLexicalBinding);
  26115. }
  26116. if (!(bindingType & BIND_NONE)) {
  26117. this.scope.declareName(name, bindingType, expr.start);
  26118. }
  26119. break;
  26120. }
  26121. case "MemberExpression":
  26122. if (bindingType !== BIND_NONE) {
  26123. this.raise(expr.start, ErrorMessages.InvalidPropertyBindingPattern);
  26124. }
  26125. break;
  26126. case "ObjectPattern":
  26127. for (let prop of expr.properties) {
  26128. if (this.isObjectProperty(prop)) prop = prop.value;else if (this.isObjectMethod(prop)) continue;
  26129. this.checkLVal(prop, "object destructuring pattern", bindingType, checkClashes, disallowLetBinding);
  26130. }
  26131. break;
  26132. case "ArrayPattern":
  26133. for (const elem of expr.elements) {
  26134. if (elem) {
  26135. this.checkLVal(elem, "array destructuring pattern", bindingType, checkClashes, disallowLetBinding);
  26136. }
  26137. }
  26138. break;
  26139. case "AssignmentPattern":
  26140. this.checkLVal(expr.left, "assignment pattern", bindingType, checkClashes);
  26141. break;
  26142. case "RestElement":
  26143. this.checkLVal(expr.argument, "rest element", bindingType, checkClashes);
  26144. break;
  26145. case "ParenthesizedExpression":
  26146. this.checkLVal(expr.expression, "parenthesized expression", bindingType, checkClashes);
  26147. break;
  26148. default:
  26149. {
  26150. this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, contextDescription);
  26151. }
  26152. }
  26153. }
  26154. checkToRestConversion(node) {
  26155. if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
  26156. this.raise(node.argument.start, ErrorMessages.InvalidRestAssignmentPattern);
  26157. }
  26158. }
  26159. checkCommaAfterRest(close) {
  26160. if (this.match(types$1.comma)) {
  26161. if (this.lookaheadCharCode() === close) {
  26162. this.raiseTrailingCommaAfterRest(this.state.start);
  26163. } else {
  26164. this.raiseRestNotLast(this.state.start);
  26165. }
  26166. }
  26167. }
  26168. raiseRestNotLast(pos) {
  26169. throw this.raise(pos, ErrorMessages.ElementAfterRest);
  26170. }
  26171. raiseTrailingCommaAfterRest(pos) {
  26172. this.raise(pos, ErrorMessages.RestTrailingComma);
  26173. }
  26174. }
  26175. class ExpressionParser extends LValParser {
  26176. checkProto(prop, isRecord, protoRef, refExpressionErrors) {
  26177. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  26178. return;
  26179. }
  26180. const key = prop.key;
  26181. const name = key.type === "Identifier" ? key.name : key.value;
  26182. if (name === "__proto__") {
  26183. if (isRecord) {
  26184. this.raise(key.start, ErrorMessages.RecordNoProto);
  26185. return;
  26186. }
  26187. if (protoRef.used) {
  26188. if (refExpressionErrors) {
  26189. if (refExpressionErrors.doubleProto === -1) {
  26190. refExpressionErrors.doubleProto = key.start;
  26191. }
  26192. } else {
  26193. this.raise(key.start, ErrorMessages.DuplicateProto);
  26194. }
  26195. }
  26196. protoRef.used = true;
  26197. }
  26198. }
  26199. shouldExitDescending(expr, potentialArrowAt) {
  26200. return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
  26201. }
  26202. getExpression() {
  26203. this.enterInitialScopes();
  26204. this.nextToken();
  26205. const expr = this.parseExpression();
  26206. if (!this.match(types$1.eof)) {
  26207. this.unexpected();
  26208. }
  26209. this.finalizeRemainingComments();
  26210. expr.comments = this.state.comments;
  26211. expr.errors = this.state.errors;
  26212. if (this.options.tokens) {
  26213. expr.tokens = this.tokens;
  26214. }
  26215. return expr;
  26216. }
  26217. parseExpression(disallowIn, refExpressionErrors) {
  26218. if (disallowIn) {
  26219. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  26220. }
  26221. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  26222. }
  26223. parseExpressionBase(refExpressionErrors) {
  26224. const startPos = this.state.start;
  26225. const startLoc = this.state.startLoc;
  26226. const expr = this.parseMaybeAssign(refExpressionErrors);
  26227. if (this.match(types$1.comma)) {
  26228. const node = this.startNodeAt(startPos, startLoc);
  26229. node.expressions = [expr];
  26230. while (this.eat(types$1.comma)) {
  26231. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  26232. }
  26233. this.toReferencedList(node.expressions);
  26234. return this.finishNode(node, "SequenceExpression");
  26235. }
  26236. return expr;
  26237. }
  26238. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  26239. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  26240. }
  26241. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  26242. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  26243. }
  26244. setOptionalParametersError(refExpressionErrors, resultError) {
  26245. var _resultError$pos;
  26246. refExpressionErrors.optionalParameters = (_resultError$pos = resultError == null ? void 0 : resultError.pos) != null ? _resultError$pos : this.state.start;
  26247. }
  26248. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  26249. const startPos = this.state.start;
  26250. const startLoc = this.state.startLoc;
  26251. if (this.isContextual("yield")) {
  26252. if (this.prodParam.hasYield) {
  26253. let left = this.parseYield();
  26254. if (afterLeftParse) {
  26255. left = afterLeftParse.call(this, left, startPos, startLoc);
  26256. }
  26257. return left;
  26258. }
  26259. }
  26260. let ownExpressionErrors;
  26261. if (refExpressionErrors) {
  26262. ownExpressionErrors = false;
  26263. } else {
  26264. refExpressionErrors = new ExpressionErrors();
  26265. ownExpressionErrors = true;
  26266. }
  26267. if (this.match(types$1.parenL) || this.match(types$1.name)) {
  26268. this.state.potentialArrowAt = this.state.start;
  26269. }
  26270. let left = this.parseMaybeConditional(refExpressionErrors);
  26271. if (afterLeftParse) {
  26272. left = afterLeftParse.call(this, left, startPos, startLoc);
  26273. }
  26274. if (this.state.type.isAssign) {
  26275. const node = this.startNodeAt(startPos, startLoc);
  26276. const operator = this.state.value;
  26277. node.operator = operator;
  26278. const leftIsHackPipeExpression = left.type === "BinaryExpression" && left.operator === "|>" && this.getPluginOption("pipelineOperator", "proposal") === "hack";
  26279. if (leftIsHackPipeExpression) {
  26280. throw this.raise(this.state.start, ErrorMessages.PipeBodyIsTighter, operator);
  26281. }
  26282. if (this.match(types$1.eq)) {
  26283. node.left = this.toAssignable(left, true);
  26284. refExpressionErrors.doubleProto = -1;
  26285. } else {
  26286. node.left = left;
  26287. }
  26288. if (refExpressionErrors.shorthandAssign >= node.left.start) {
  26289. refExpressionErrors.shorthandAssign = -1;
  26290. }
  26291. this.checkLVal(left, "assignment expression");
  26292. this.next();
  26293. node.right = this.parseMaybeAssign();
  26294. return this.finishNode(node, "AssignmentExpression");
  26295. } else if (ownExpressionErrors) {
  26296. this.checkExpressionErrors(refExpressionErrors, true);
  26297. }
  26298. return left;
  26299. }
  26300. parseMaybeConditional(refExpressionErrors) {
  26301. const startPos = this.state.start;
  26302. const startLoc = this.state.startLoc;
  26303. const potentialArrowAt = this.state.potentialArrowAt;
  26304. const expr = this.parseExprOps(refExpressionErrors);
  26305. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  26306. return expr;
  26307. }
  26308. return this.parseConditional(expr, startPos, startLoc, refExpressionErrors);
  26309. }
  26310. parseConditional(expr, startPos, startLoc, refExpressionErrors) {
  26311. if (this.eat(types$1.question)) {
  26312. const node = this.startNodeAt(startPos, startLoc);
  26313. node.test = expr;
  26314. node.consequent = this.parseMaybeAssignAllowIn();
  26315. this.expect(types$1.colon);
  26316. node.alternate = this.parseMaybeAssign();
  26317. return this.finishNode(node, "ConditionalExpression");
  26318. }
  26319. return expr;
  26320. }
  26321. parseExprOps(refExpressionErrors) {
  26322. const startPos = this.state.start;
  26323. const startLoc = this.state.startLoc;
  26324. const potentialArrowAt = this.state.potentialArrowAt;
  26325. const expr = this.parseMaybeUnary(refExpressionErrors);
  26326. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  26327. return expr;
  26328. }
  26329. return this.parseExprOp(expr, startPos, startLoc, -1);
  26330. }
  26331. parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
  26332. let prec = this.state.type.binop;
  26333. if (prec != null && (this.prodParam.hasIn || !this.match(types$1._in))) {
  26334. if (prec > minPrec) {
  26335. const op = this.state.type;
  26336. if (op === types$1.pipeline) {
  26337. this.expectPlugin("pipelineOperator");
  26338. if (this.state.inFSharpPipelineDirectBody) {
  26339. return left;
  26340. }
  26341. this.checkPipelineAtInfixOperator(left, leftStartPos);
  26342. }
  26343. const node = this.startNodeAt(leftStartPos, leftStartLoc);
  26344. node.left = left;
  26345. node.operator = this.state.value;
  26346. const logical = op === types$1.logicalOR || op === types$1.logicalAND;
  26347. const coalesce = op === types$1.nullishCoalescing;
  26348. if (coalesce) {
  26349. prec = types$1.logicalAND.binop;
  26350. }
  26351. this.next();
  26352. if (op === types$1.pipeline && this.getPluginOption("pipelineOperator", "proposal") === "minimal") {
  26353. if (this.match(types$1.name) && this.state.value === "await" && this.prodParam.hasAwait) {
  26354. throw this.raise(this.state.start, ErrorMessages.UnexpectedAwaitAfterPipelineBody);
  26355. }
  26356. }
  26357. node.right = this.parseExprOpRightExpr(op, prec);
  26358. this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  26359. const nextOp = this.state.type;
  26360. if (coalesce && (nextOp === types$1.logicalOR || nextOp === types$1.logicalAND) || logical && nextOp === types$1.nullishCoalescing) {
  26361. throw this.raise(this.state.start, ErrorMessages.MixingCoalesceWithLogical);
  26362. }
  26363. return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
  26364. }
  26365. }
  26366. return left;
  26367. }
  26368. parseExprOpRightExpr(op, prec) {
  26369. const startPos = this.state.start;
  26370. const startLoc = this.state.startLoc;
  26371. switch (op) {
  26372. case types$1.pipeline:
  26373. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  26374. case "hack":
  26375. return this.withTopicBindingContext(() => {
  26376. const bodyExpr = this.parseHackPipeBody(op, prec);
  26377. this.checkHackPipeBodyEarlyErrors(startPos);
  26378. return bodyExpr;
  26379. });
  26380. case "smart":
  26381. return this.withTopicBindingContext(() => {
  26382. const childExpr = this.parseHackPipeBody(op, prec);
  26383. return this.parseSmartPipelineBodyInStyle(childExpr, startPos, startLoc);
  26384. });
  26385. case "fsharp":
  26386. return this.withSoloAwaitPermittingContext(() => {
  26387. return this.parseFSharpPipelineBody(prec);
  26388. });
  26389. }
  26390. default:
  26391. return this.parseExprOpBaseRightExpr(op, prec);
  26392. }
  26393. }
  26394. parseExprOpBaseRightExpr(op, prec) {
  26395. const startPos = this.state.start;
  26396. const startLoc = this.state.startLoc;
  26397. return this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, op.rightAssociative ? prec - 1 : prec);
  26398. }
  26399. parseHackPipeBody(op, prec) {
  26400. const bodyIsInGeneratorContext = this.prodParam.hasYield;
  26401. const bodyIsYieldExpression = bodyIsInGeneratorContext && this.isContextual("yield");
  26402. if (bodyIsYieldExpression) {
  26403. throw this.raise(this.state.start, ErrorMessages.PipeBodyIsTighter, this.state.value);
  26404. } else {
  26405. return this.parseExprOpBaseRightExpr(op, prec);
  26406. }
  26407. }
  26408. checkExponentialAfterUnary(node) {
  26409. if (this.match(types$1.exponent)) {
  26410. this.raise(node.argument.start, ErrorMessages.UnexpectedTokenUnaryExponentiation);
  26411. }
  26412. }
  26413. parseMaybeUnary(refExpressionErrors, sawUnary) {
  26414. const startPos = this.state.start;
  26415. const startLoc = this.state.startLoc;
  26416. const isAwait = this.isContextual("await");
  26417. if (isAwait && this.isAwaitAllowed()) {
  26418. this.next();
  26419. const expr = this.parseAwait(startPos, startLoc);
  26420. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  26421. return expr;
  26422. }
  26423. const update = this.match(types$1.incDec);
  26424. const node = this.startNode();
  26425. if (this.state.type.prefix) {
  26426. node.operator = this.state.value;
  26427. node.prefix = true;
  26428. if (this.match(types$1._throw)) {
  26429. this.expectPlugin("throwExpressions");
  26430. }
  26431. const isDelete = this.match(types$1._delete);
  26432. this.next();
  26433. node.argument = this.parseMaybeUnary(null, true);
  26434. this.checkExpressionErrors(refExpressionErrors, true);
  26435. if (this.state.strict && isDelete) {
  26436. const arg = node.argument;
  26437. if (arg.type === "Identifier") {
  26438. this.raise(node.start, ErrorMessages.StrictDelete);
  26439. } else if (this.hasPropertyAsPrivateName(arg)) {
  26440. this.raise(node.start, ErrorMessages.DeletePrivateField);
  26441. }
  26442. }
  26443. if (!update) {
  26444. if (!sawUnary) this.checkExponentialAfterUnary(node);
  26445. return this.finishNode(node, "UnaryExpression");
  26446. }
  26447. }
  26448. const expr = this.parseUpdate(node, update, refExpressionErrors);
  26449. if (isAwait) {
  26450. const startsExpr = this.hasPlugin("v8intrinsic") ? this.state.type.startsExpr : this.state.type.startsExpr && !this.match(types$1.modulo);
  26451. if (startsExpr && !this.isAmbiguousAwait()) {
  26452. this.raiseOverwrite(startPos, ErrorMessages.AwaitNotInAsyncContext);
  26453. return this.parseAwait(startPos, startLoc);
  26454. }
  26455. }
  26456. return expr;
  26457. }
  26458. parseUpdate(node, update, refExpressionErrors) {
  26459. if (update) {
  26460. this.checkLVal(node.argument, "prefix operation");
  26461. return this.finishNode(node, "UpdateExpression");
  26462. }
  26463. const startPos = this.state.start;
  26464. const startLoc = this.state.startLoc;
  26465. let expr = this.parseExprSubscripts(refExpressionErrors);
  26466. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  26467. while (this.state.type.postfix && !this.canInsertSemicolon()) {
  26468. const node = this.startNodeAt(startPos, startLoc);
  26469. node.operator = this.state.value;
  26470. node.prefix = false;
  26471. node.argument = expr;
  26472. this.checkLVal(expr, "postfix operation");
  26473. this.next();
  26474. expr = this.finishNode(node, "UpdateExpression");
  26475. }
  26476. return expr;
  26477. }
  26478. parseExprSubscripts(refExpressionErrors) {
  26479. const startPos = this.state.start;
  26480. const startLoc = this.state.startLoc;
  26481. const potentialArrowAt = this.state.potentialArrowAt;
  26482. const expr = this.parseExprAtom(refExpressionErrors);
  26483. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  26484. return expr;
  26485. }
  26486. return this.parseSubscripts(expr, startPos, startLoc);
  26487. }
  26488. parseSubscripts(base, startPos, startLoc, noCalls) {
  26489. const state = {
  26490. optionalChainMember: false,
  26491. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  26492. stop: false
  26493. };
  26494. do {
  26495. base = this.parseSubscript(base, startPos, startLoc, noCalls, state);
  26496. state.maybeAsyncArrow = false;
  26497. } while (!state.stop);
  26498. return base;
  26499. }
  26500. parseSubscript(base, startPos, startLoc, noCalls, state) {
  26501. if (!noCalls && this.eat(types$1.doubleColon)) {
  26502. return this.parseBind(base, startPos, startLoc, noCalls, state);
  26503. } else if (this.match(types$1.backQuote)) {
  26504. return this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
  26505. }
  26506. let optional = false;
  26507. if (this.match(types$1.questionDot)) {
  26508. if (noCalls && this.lookaheadCharCode() === 40) {
  26509. state.stop = true;
  26510. return base;
  26511. }
  26512. state.optionalChainMember = optional = true;
  26513. this.next();
  26514. }
  26515. if (!noCalls && this.match(types$1.parenL)) {
  26516. return this.parseCoverCallAndAsyncArrowHead(base, startPos, startLoc, state, optional);
  26517. } else if (optional || this.match(types$1.bracketL) || this.eat(types$1.dot)) {
  26518. return this.parseMember(base, startPos, startLoc, state, optional);
  26519. } else {
  26520. state.stop = true;
  26521. return base;
  26522. }
  26523. }
  26524. parseMember(base, startPos, startLoc, state, optional) {
  26525. const node = this.startNodeAt(startPos, startLoc);
  26526. const computed = this.eat(types$1.bracketL);
  26527. node.object = base;
  26528. node.computed = computed;
  26529. const privateName = !computed && this.match(types$1.privateName) && this.state.value;
  26530. const property = computed ? this.parseExpression() : privateName ? this.parsePrivateName() : this.parseIdentifier(true);
  26531. if (privateName !== false) {
  26532. if (node.object.type === "Super") {
  26533. this.raise(startPos, ErrorMessages.SuperPrivateField);
  26534. }
  26535. this.classScope.usePrivateName(privateName, property.start);
  26536. }
  26537. node.property = property;
  26538. if (computed) {
  26539. this.expect(types$1.bracketR);
  26540. }
  26541. if (state.optionalChainMember) {
  26542. node.optional = optional;
  26543. return this.finishNode(node, "OptionalMemberExpression");
  26544. } else {
  26545. return this.finishNode(node, "MemberExpression");
  26546. }
  26547. }
  26548. parseBind(base, startPos, startLoc, noCalls, state) {
  26549. const node = this.startNodeAt(startPos, startLoc);
  26550. node.object = base;
  26551. node.callee = this.parseNoCallExpr();
  26552. state.stop = true;
  26553. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls);
  26554. }
  26555. parseCoverCallAndAsyncArrowHead(base, startPos, startLoc, state, optional) {
  26556. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  26557. let refExpressionErrors = null;
  26558. this.state.maybeInArrowParameters = true;
  26559. this.next();
  26560. let node = this.startNodeAt(startPos, startLoc);
  26561. node.callee = base;
  26562. if (state.maybeAsyncArrow) {
  26563. this.expressionScope.enter(newAsyncArrowScope());
  26564. refExpressionErrors = new ExpressionErrors();
  26565. }
  26566. if (state.optionalChainMember) {
  26567. node.optional = optional;
  26568. }
  26569. if (optional) {
  26570. node.arguments = this.parseCallExpressionArguments(types$1.parenR);
  26571. } else {
  26572. node.arguments = this.parseCallExpressionArguments(types$1.parenR, base.type === "Import", base.type !== "Super", node, refExpressionErrors);
  26573. }
  26574. this.finishCallExpression(node, state.optionalChainMember);
  26575. if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  26576. state.stop = true;
  26577. this.expressionScope.validateAsPattern();
  26578. this.expressionScope.exit();
  26579. node = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node);
  26580. } else {
  26581. if (state.maybeAsyncArrow) {
  26582. this.checkExpressionErrors(refExpressionErrors, true);
  26583. this.expressionScope.exit();
  26584. }
  26585. this.toReferencedArguments(node);
  26586. }
  26587. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  26588. return node;
  26589. }
  26590. toReferencedArguments(node, isParenthesizedExpr) {
  26591. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  26592. }
  26593. parseTaggedTemplateExpression(base, startPos, startLoc, state) {
  26594. const node = this.startNodeAt(startPos, startLoc);
  26595. node.tag = base;
  26596. node.quasi = this.parseTemplate(true);
  26597. if (state.optionalChainMember) {
  26598. this.raise(startPos, ErrorMessages.OptionalChainingNoTemplate);
  26599. }
  26600. return this.finishNode(node, "TaggedTemplateExpression");
  26601. }
  26602. atPossibleAsyncArrow(base) {
  26603. return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
  26604. }
  26605. finishCallExpression(node, optional) {
  26606. if (node.callee.type === "Import") {
  26607. if (node.arguments.length === 2) {
  26608. {
  26609. if (!this.hasPlugin("moduleAttributes")) {
  26610. this.expectPlugin("importAssertions");
  26611. }
  26612. }
  26613. }
  26614. if (node.arguments.length === 0 || node.arguments.length > 2) {
  26615. this.raise(node.start, ErrorMessages.ImportCallArity, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
  26616. } else {
  26617. for (const arg of node.arguments) {
  26618. if (arg.type === "SpreadElement") {
  26619. this.raise(arg.start, ErrorMessages.ImportCallSpreadArgument);
  26620. }
  26621. }
  26622. }
  26623. }
  26624. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  26625. }
  26626. parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) {
  26627. const elts = [];
  26628. let first = true;
  26629. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  26630. this.state.inFSharpPipelineDirectBody = false;
  26631. while (!this.eat(close)) {
  26632. if (first) {
  26633. first = false;
  26634. } else {
  26635. this.expect(types$1.comma);
  26636. if (this.match(close)) {
  26637. if (dynamicImport && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
  26638. this.raise(this.state.lastTokStart, ErrorMessages.ImportCallArgumentTrailingComma);
  26639. }
  26640. if (nodeForExtra) {
  26641. this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
  26642. }
  26643. this.next();
  26644. break;
  26645. }
  26646. }
  26647. elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
  26648. }
  26649. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  26650. return elts;
  26651. }
  26652. shouldParseAsyncArrow() {
  26653. return this.match(types$1.arrow) && !this.canInsertSemicolon();
  26654. }
  26655. parseAsyncArrowFromCallExpression(node, call) {
  26656. var _call$extra;
  26657. this.resetPreviousNodeTrailingComments(call);
  26658. this.expect(types$1.arrow);
  26659. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingComma);
  26660. setInnerComments(node, call.innerComments);
  26661. setInnerComments(node, call.callee.trailingComments);
  26662. return node;
  26663. }
  26664. parseNoCallExpr() {
  26665. const startPos = this.state.start;
  26666. const startLoc = this.state.startLoc;
  26667. return this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
  26668. }
  26669. parseExprAtom(refExpressionErrors) {
  26670. let node;
  26671. switch (this.state.type) {
  26672. case types$1._super:
  26673. return this.parseSuper();
  26674. case types$1._import:
  26675. node = this.startNode();
  26676. this.next();
  26677. if (this.match(types$1.dot)) {
  26678. return this.parseImportMetaProperty(node);
  26679. }
  26680. if (!this.match(types$1.parenL)) {
  26681. this.raise(this.state.lastTokStart, ErrorMessages.UnsupportedImport);
  26682. }
  26683. return this.finishNode(node, "Import");
  26684. case types$1._this:
  26685. node = this.startNode();
  26686. this.next();
  26687. return this.finishNode(node, "ThisExpression");
  26688. case types$1.name:
  26689. {
  26690. if (this.isContextual("module") && this.lookaheadCharCode() === 123 && !this.hasFollowingLineBreak()) {
  26691. return this.parseModuleExpression();
  26692. }
  26693. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  26694. const containsEsc = this.state.containsEsc;
  26695. const id = this.parseIdentifier();
  26696. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  26697. if (this.match(types$1._function)) {
  26698. this.resetPreviousNodeTrailingComments(id);
  26699. this.next();
  26700. return this.parseFunction(this.startNodeAtNode(id), undefined, true);
  26701. } else if (this.match(types$1.name)) {
  26702. if (this.lookaheadCharCode() === 61) {
  26703. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  26704. } else {
  26705. return id;
  26706. }
  26707. } else if (this.match(types$1._do)) {
  26708. this.resetPreviousNodeTrailingComments(id);
  26709. return this.parseDo(this.startNodeAtNode(id), true);
  26710. }
  26711. }
  26712. if (canBeArrow && this.match(types$1.arrow) && !this.canInsertSemicolon()) {
  26713. this.next();
  26714. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  26715. }
  26716. return id;
  26717. }
  26718. case types$1._do:
  26719. {
  26720. return this.parseDo(this.startNode(), false);
  26721. }
  26722. case types$1.slash:
  26723. case types$1.slashAssign:
  26724. {
  26725. this.readRegexp();
  26726. return this.parseRegExpLiteral(this.state.value);
  26727. }
  26728. case types$1.num:
  26729. return this.parseNumericLiteral(this.state.value);
  26730. case types$1.bigint:
  26731. return this.parseBigIntLiteral(this.state.value);
  26732. case types$1.decimal:
  26733. return this.parseDecimalLiteral(this.state.value);
  26734. case types$1.string:
  26735. return this.parseStringLiteral(this.state.value);
  26736. case types$1._null:
  26737. return this.parseNullLiteral();
  26738. case types$1._true:
  26739. return this.parseBooleanLiteral(true);
  26740. case types$1._false:
  26741. return this.parseBooleanLiteral(false);
  26742. case types$1.parenL:
  26743. {
  26744. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  26745. return this.parseParenAndDistinguishExpression(canBeArrow);
  26746. }
  26747. case types$1.bracketBarL:
  26748. case types$1.bracketHashL:
  26749. {
  26750. return this.parseArrayLike(this.state.type === types$1.bracketBarL ? types$1.bracketBarR : types$1.bracketR, false, true, refExpressionErrors);
  26751. }
  26752. case types$1.bracketL:
  26753. {
  26754. return this.parseArrayLike(types$1.bracketR, true, false, refExpressionErrors);
  26755. }
  26756. case types$1.braceBarL:
  26757. case types$1.braceHashL:
  26758. {
  26759. return this.parseObjectLike(this.state.type === types$1.braceBarL ? types$1.braceBarR : types$1.braceR, false, true, refExpressionErrors);
  26760. }
  26761. case types$1.braceL:
  26762. {
  26763. return this.parseObjectLike(types$1.braceR, false, false, refExpressionErrors);
  26764. }
  26765. case types$1._function:
  26766. return this.parseFunctionOrFunctionSent();
  26767. case types$1.at:
  26768. this.parseDecorators();
  26769. case types$1._class:
  26770. node = this.startNode();
  26771. this.takeDecorators(node);
  26772. return this.parseClass(node, false);
  26773. case types$1._new:
  26774. return this.parseNewOrNewTarget();
  26775. case types$1.backQuote:
  26776. return this.parseTemplate(false);
  26777. case types$1.doubleColon:
  26778. {
  26779. node = this.startNode();
  26780. this.next();
  26781. node.object = null;
  26782. const callee = node.callee = this.parseNoCallExpr();
  26783. if (callee.type === "MemberExpression") {
  26784. return this.finishNode(node, "BindExpression");
  26785. } else {
  26786. throw this.raise(callee.start, ErrorMessages.UnsupportedBind);
  26787. }
  26788. }
  26789. case types$1.privateName:
  26790. {
  26791. const {
  26792. value,
  26793. start
  26794. } = this.state;
  26795. node = this.parsePrivateName();
  26796. if (this.match(types$1._in)) {
  26797. this.classScope.usePrivateName(value, start);
  26798. } else {
  26799. this.raise(start, ErrorMessages.PrivateInExpectedIn, value);
  26800. }
  26801. return node;
  26802. }
  26803. case types$1.moduloAssign:
  26804. if (this.getPluginOption("pipelineOperator", "proposal") === "hack" && this.getPluginOption("pipelineOperator", "topicToken") === "%") {
  26805. this.state.value = "%";
  26806. this.state.type = types$1.modulo;
  26807. this.state.pos--;
  26808. this.state.end--;
  26809. this.state.endLoc.column--;
  26810. } else {
  26811. throw this.unexpected();
  26812. }
  26813. case types$1.modulo:
  26814. case types$1.hash:
  26815. {
  26816. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  26817. if (pipeProposal) {
  26818. node = this.startNode();
  26819. const start = this.state.start;
  26820. const tokenType = this.state.type;
  26821. this.next();
  26822. return this.finishTopicReference(node, start, pipeProposal, tokenType);
  26823. }
  26824. }
  26825. case types$1.relational:
  26826. {
  26827. if (this.state.value === "<") {
  26828. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  26829. if (isIdentifierStart$1(lookaheadCh) || lookaheadCh === 62) {
  26830. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  26831. }
  26832. }
  26833. }
  26834. default:
  26835. throw this.unexpected();
  26836. }
  26837. }
  26838. finishTopicReference(node, start, pipeProposal, tokenType) {
  26839. if (this.testTopicReferenceConfiguration(pipeProposal, start, tokenType)) {
  26840. let nodeType;
  26841. if (pipeProposal === "smart") {
  26842. nodeType = "PipelinePrimaryTopicReference";
  26843. } else {
  26844. nodeType = "TopicReference";
  26845. }
  26846. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  26847. if (pipeProposal === "smart") {
  26848. this.raise(start, ErrorMessages.PrimaryTopicNotAllowed);
  26849. } else {
  26850. this.raise(start, ErrorMessages.PipeTopicUnbound);
  26851. }
  26852. }
  26853. this.registerTopicReference();
  26854. return this.finishNode(node, nodeType);
  26855. } else {
  26856. throw this.raise(start, ErrorMessages.PipeTopicUnconfiguredToken, tokenType.label);
  26857. }
  26858. }
  26859. testTopicReferenceConfiguration(pipeProposal, start, tokenType) {
  26860. switch (pipeProposal) {
  26861. case "hack":
  26862. {
  26863. const pluginTopicToken = this.getPluginOption("pipelineOperator", "topicToken");
  26864. return tokenType.label === pluginTopicToken;
  26865. }
  26866. case "smart":
  26867. return tokenType === types$1.hash;
  26868. default:
  26869. throw this.raise(start, ErrorMessages.PipeTopicRequiresHackPipes);
  26870. }
  26871. }
  26872. parseAsyncArrowUnaryFunction(node) {
  26873. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  26874. const params = [this.parseIdentifier()];
  26875. this.prodParam.exit();
  26876. if (this.hasPrecedingLineBreak()) {
  26877. this.raise(this.state.pos, ErrorMessages.LineTerminatorBeforeArrow);
  26878. }
  26879. this.expect(types$1.arrow);
  26880. this.parseArrowExpression(node, params, true);
  26881. return node;
  26882. }
  26883. parseDo(node, isAsync) {
  26884. this.expectPlugin("doExpressions");
  26885. if (isAsync) {
  26886. this.expectPlugin("asyncDoExpressions");
  26887. }
  26888. node.async = isAsync;
  26889. this.next();
  26890. const oldLabels = this.state.labels;
  26891. this.state.labels = [];
  26892. if (isAsync) {
  26893. this.prodParam.enter(PARAM_AWAIT);
  26894. node.body = this.parseBlock();
  26895. this.prodParam.exit();
  26896. } else {
  26897. node.body = this.parseBlock();
  26898. }
  26899. this.state.labels = oldLabels;
  26900. return this.finishNode(node, "DoExpression");
  26901. }
  26902. parseSuper() {
  26903. const node = this.startNode();
  26904. this.next();
  26905. if (this.match(types$1.parenL) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
  26906. this.raise(node.start, ErrorMessages.SuperNotAllowed);
  26907. } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
  26908. this.raise(node.start, ErrorMessages.UnexpectedSuper);
  26909. }
  26910. if (!this.match(types$1.parenL) && !this.match(types$1.bracketL) && !this.match(types$1.dot)) {
  26911. this.raise(node.start, ErrorMessages.UnsupportedSuper);
  26912. }
  26913. return this.finishNode(node, "Super");
  26914. }
  26915. parseMaybePrivateName(isPrivateNameAllowed) {
  26916. const isPrivate = this.match(types$1.privateName);
  26917. if (isPrivate) {
  26918. if (!isPrivateNameAllowed) {
  26919. this.raise(this.state.start + 1, ErrorMessages.UnexpectedPrivateField);
  26920. }
  26921. return this.parsePrivateName();
  26922. } else {
  26923. return this.parseIdentifier(true);
  26924. }
  26925. }
  26926. parsePrivateName() {
  26927. const node = this.startNode();
  26928. const id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart));
  26929. const name = this.state.value;
  26930. this.next();
  26931. node.id = this.createIdentifier(id, name);
  26932. return this.finishNode(node, "PrivateName");
  26933. }
  26934. parseFunctionOrFunctionSent() {
  26935. const node = this.startNode();
  26936. this.next();
  26937. if (this.prodParam.hasYield && this.match(types$1.dot)) {
  26938. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  26939. this.next();
  26940. return this.parseMetaProperty(node, meta, "sent");
  26941. }
  26942. return this.parseFunction(node);
  26943. }
  26944. parseMetaProperty(node, meta, propertyName) {
  26945. node.meta = meta;
  26946. if (meta.name === "function" && propertyName === "sent") {
  26947. if (this.isContextual(propertyName)) {
  26948. this.expectPlugin("functionSent");
  26949. } else if (!this.hasPlugin("functionSent")) {
  26950. this.unexpected();
  26951. }
  26952. }
  26953. const containsEsc = this.state.containsEsc;
  26954. node.property = this.parseIdentifier(true);
  26955. if (node.property.name !== propertyName || containsEsc) {
  26956. this.raise(node.property.start, ErrorMessages.UnsupportedMetaProperty, meta.name, propertyName);
  26957. }
  26958. return this.finishNode(node, "MetaProperty");
  26959. }
  26960. parseImportMetaProperty(node) {
  26961. const id = this.createIdentifier(this.startNodeAtNode(node), "import");
  26962. this.next();
  26963. if (this.isContextual("meta")) {
  26964. if (!this.inModule) {
  26965. this.raise(id.start, SourceTypeModuleErrorMessages.ImportMetaOutsideModule);
  26966. }
  26967. this.sawUnambiguousESM = true;
  26968. }
  26969. return this.parseMetaProperty(node, id, "meta");
  26970. }
  26971. parseLiteralAtNode(value, type, node) {
  26972. this.addExtra(node, "rawValue", value);
  26973. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  26974. node.value = value;
  26975. this.next();
  26976. return this.finishNode(node, type);
  26977. }
  26978. parseLiteral(value, type) {
  26979. const node = this.startNode();
  26980. return this.parseLiteralAtNode(value, type, node);
  26981. }
  26982. parseStringLiteral(value) {
  26983. return this.parseLiteral(value, "StringLiteral");
  26984. }
  26985. parseNumericLiteral(value) {
  26986. return this.parseLiteral(value, "NumericLiteral");
  26987. }
  26988. parseBigIntLiteral(value) {
  26989. return this.parseLiteral(value, "BigIntLiteral");
  26990. }
  26991. parseDecimalLiteral(value) {
  26992. return this.parseLiteral(value, "DecimalLiteral");
  26993. }
  26994. parseRegExpLiteral(value) {
  26995. const node = this.parseLiteral(value.value, "RegExpLiteral");
  26996. node.pattern = value.pattern;
  26997. node.flags = value.flags;
  26998. return node;
  26999. }
  27000. parseBooleanLiteral(value) {
  27001. const node = this.startNode();
  27002. node.value = value;
  27003. this.next();
  27004. return this.finishNode(node, "BooleanLiteral");
  27005. }
  27006. parseNullLiteral() {
  27007. const node = this.startNode();
  27008. this.next();
  27009. return this.finishNode(node, "NullLiteral");
  27010. }
  27011. parseParenAndDistinguishExpression(canBeArrow) {
  27012. const startPos = this.state.start;
  27013. const startLoc = this.state.startLoc;
  27014. let val;
  27015. this.next();
  27016. this.expressionScope.enter(newArrowHeadScope());
  27017. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  27018. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  27019. this.state.maybeInArrowParameters = true;
  27020. this.state.inFSharpPipelineDirectBody = false;
  27021. const innerStartPos = this.state.start;
  27022. const innerStartLoc = this.state.startLoc;
  27023. const exprList = [];
  27024. const refExpressionErrors = new ExpressionErrors();
  27025. let first = true;
  27026. let spreadStart;
  27027. let optionalCommaStart;
  27028. while (!this.match(types$1.parenR)) {
  27029. if (first) {
  27030. first = false;
  27031. } else {
  27032. this.expect(types$1.comma, refExpressionErrors.optionalParameters === -1 ? null : refExpressionErrors.optionalParameters);
  27033. if (this.match(types$1.parenR)) {
  27034. optionalCommaStart = this.state.start;
  27035. break;
  27036. }
  27037. }
  27038. if (this.match(types$1.ellipsis)) {
  27039. const spreadNodeStartPos = this.state.start;
  27040. const spreadNodeStartLoc = this.state.startLoc;
  27041. spreadStart = this.state.start;
  27042. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
  27043. this.checkCommaAfterRest(41);
  27044. break;
  27045. } else {
  27046. exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
  27047. }
  27048. }
  27049. const innerEndPos = this.state.lastTokEnd;
  27050. const innerEndLoc = this.state.lastTokEndLoc;
  27051. this.expect(types$1.parenR);
  27052. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  27053. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  27054. let arrowNode = this.startNodeAt(startPos, startLoc);
  27055. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  27056. this.expressionScope.validateAsPattern();
  27057. this.expressionScope.exit();
  27058. this.parseArrowExpression(arrowNode, exprList, false);
  27059. return arrowNode;
  27060. }
  27061. this.expressionScope.exit();
  27062. if (!exprList.length) {
  27063. this.unexpected(this.state.lastTokStart);
  27064. }
  27065. if (optionalCommaStart) this.unexpected(optionalCommaStart);
  27066. if (spreadStart) this.unexpected(spreadStart);
  27067. this.checkExpressionErrors(refExpressionErrors, true);
  27068. this.toReferencedListDeep(exprList, true);
  27069. if (exprList.length > 1) {
  27070. val = this.startNodeAt(innerStartPos, innerStartLoc);
  27071. val.expressions = exprList;
  27072. this.finishNode(val, "SequenceExpression");
  27073. val.end = innerEndPos;
  27074. val.loc.end = innerEndLoc;
  27075. } else {
  27076. val = exprList[0];
  27077. }
  27078. if (!this.options.createParenthesizedExpressions) {
  27079. this.addExtra(val, "parenthesized", true);
  27080. this.addExtra(val, "parenStart", startPos);
  27081. return val;
  27082. }
  27083. const parenExpression = this.startNodeAt(startPos, startLoc);
  27084. parenExpression.expression = val;
  27085. this.finishNode(parenExpression, "ParenthesizedExpression");
  27086. return parenExpression;
  27087. }
  27088. shouldParseArrow(params) {
  27089. return !this.canInsertSemicolon();
  27090. }
  27091. parseArrow(node) {
  27092. if (this.eat(types$1.arrow)) {
  27093. return node;
  27094. }
  27095. }
  27096. parseParenItem(node, startPos, startLoc) {
  27097. return node;
  27098. }
  27099. parseNewOrNewTarget() {
  27100. const node = this.startNode();
  27101. this.next();
  27102. if (this.match(types$1.dot)) {
  27103. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  27104. this.next();
  27105. const metaProp = this.parseMetaProperty(node, meta, "target");
  27106. if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
  27107. this.raise(metaProp.start, ErrorMessages.UnexpectedNewTarget);
  27108. }
  27109. return metaProp;
  27110. }
  27111. return this.parseNew(node);
  27112. }
  27113. parseNew(node) {
  27114. node.callee = this.parseNoCallExpr();
  27115. if (node.callee.type === "Import") {
  27116. this.raise(node.callee.start, ErrorMessages.ImportCallNotNewExpression);
  27117. } else if (this.isOptionalChain(node.callee)) {
  27118. this.raise(this.state.lastTokEnd, ErrorMessages.OptionalChainingNoNew);
  27119. } else if (this.eat(types$1.questionDot)) {
  27120. this.raise(this.state.start, ErrorMessages.OptionalChainingNoNew);
  27121. }
  27122. this.parseNewArguments(node);
  27123. return this.finishNode(node, "NewExpression");
  27124. }
  27125. parseNewArguments(node) {
  27126. if (this.eat(types$1.parenL)) {
  27127. const args = this.parseExprList(types$1.parenR);
  27128. this.toReferencedList(args);
  27129. node.arguments = args;
  27130. } else {
  27131. node.arguments = [];
  27132. }
  27133. }
  27134. parseTemplateElement(isTagged) {
  27135. const elem = this.startNode();
  27136. if (this.state.value === null) {
  27137. if (!isTagged) {
  27138. this.raise(this.state.start + 1, ErrorMessages.InvalidEscapeSequenceTemplate);
  27139. }
  27140. }
  27141. elem.value = {
  27142. raw: this.input.slice(this.state.start, this.state.end).replace(/\r\n?/g, "\n"),
  27143. cooked: this.state.value
  27144. };
  27145. this.next();
  27146. elem.tail = this.match(types$1.backQuote);
  27147. return this.finishNode(elem, "TemplateElement");
  27148. }
  27149. parseTemplate(isTagged) {
  27150. const node = this.startNode();
  27151. this.next();
  27152. node.expressions = [];
  27153. let curElt = this.parseTemplateElement(isTagged);
  27154. node.quasis = [curElt];
  27155. while (!curElt.tail) {
  27156. this.expect(types$1.dollarBraceL);
  27157. node.expressions.push(this.parseTemplateSubstitution());
  27158. this.expect(types$1.braceR);
  27159. node.quasis.push(curElt = this.parseTemplateElement(isTagged));
  27160. }
  27161. this.next();
  27162. return this.finishNode(node, "TemplateLiteral");
  27163. }
  27164. parseTemplateSubstitution() {
  27165. return this.parseExpression();
  27166. }
  27167. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  27168. if (isRecord) {
  27169. this.expectPlugin("recordAndTuple");
  27170. }
  27171. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  27172. this.state.inFSharpPipelineDirectBody = false;
  27173. const propHash = Object.create(null);
  27174. let first = true;
  27175. const node = this.startNode();
  27176. node.properties = [];
  27177. this.next();
  27178. while (!this.match(close)) {
  27179. if (first) {
  27180. first = false;
  27181. } else {
  27182. this.expect(types$1.comma);
  27183. if (this.match(close)) {
  27184. this.addExtra(node, "trailingComma", this.state.lastTokStart);
  27185. break;
  27186. }
  27187. }
  27188. const prop = this.parsePropertyDefinition(isPattern, refExpressionErrors);
  27189. if (!isPattern) {
  27190. this.checkProto(prop, isRecord, propHash, refExpressionErrors);
  27191. }
  27192. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  27193. this.raise(prop.start, ErrorMessages.InvalidRecordProperty);
  27194. }
  27195. if (prop.shorthand) {
  27196. this.addExtra(prop, "shorthand", true);
  27197. }
  27198. node.properties.push(prop);
  27199. }
  27200. this.next();
  27201. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  27202. let type = "ObjectExpression";
  27203. if (isPattern) {
  27204. type = "ObjectPattern";
  27205. } else if (isRecord) {
  27206. type = "RecordExpression";
  27207. }
  27208. return this.finishNode(node, type);
  27209. }
  27210. maybeAsyncOrAccessorProp(prop) {
  27211. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(types$1.bracketL) || this.match(types$1.star));
  27212. }
  27213. parsePropertyDefinition(isPattern, refExpressionErrors) {
  27214. let decorators = [];
  27215. if (this.match(types$1.at)) {
  27216. if (this.hasPlugin("decorators")) {
  27217. this.raise(this.state.start, ErrorMessages.UnsupportedPropertyDecorator);
  27218. }
  27219. while (this.match(types$1.at)) {
  27220. decorators.push(this.parseDecorator());
  27221. }
  27222. }
  27223. const prop = this.startNode();
  27224. let isGenerator = false;
  27225. let isAsync = false;
  27226. let isAccessor = false;
  27227. let startPos;
  27228. let startLoc;
  27229. if (this.match(types$1.ellipsis)) {
  27230. if (decorators.length) this.unexpected();
  27231. if (isPattern) {
  27232. this.next();
  27233. prop.argument = this.parseIdentifier();
  27234. this.checkCommaAfterRest(125);
  27235. return this.finishNode(prop, "RestElement");
  27236. }
  27237. return this.parseSpread();
  27238. }
  27239. if (decorators.length) {
  27240. prop.decorators = decorators;
  27241. decorators = [];
  27242. }
  27243. prop.method = false;
  27244. if (isPattern || refExpressionErrors) {
  27245. startPos = this.state.start;
  27246. startLoc = this.state.startLoc;
  27247. }
  27248. if (!isPattern) {
  27249. isGenerator = this.eat(types$1.star);
  27250. }
  27251. const containsEsc = this.state.containsEsc;
  27252. const key = this.parsePropertyName(prop, false);
  27253. if (!isPattern && !isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  27254. const keyName = key.name;
  27255. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  27256. isAsync = true;
  27257. this.resetPreviousNodeTrailingComments(key);
  27258. isGenerator = this.eat(types$1.star);
  27259. this.parsePropertyName(prop, false);
  27260. }
  27261. if (keyName === "get" || keyName === "set") {
  27262. isAccessor = true;
  27263. this.resetPreviousNodeTrailingComments(key);
  27264. prop.kind = keyName;
  27265. if (this.match(types$1.star)) {
  27266. isGenerator = true;
  27267. this.raise(this.state.pos, ErrorMessages.AccessorIsGenerator, keyName);
  27268. this.next();
  27269. }
  27270. this.parsePropertyName(prop, false);
  27271. }
  27272. }
  27273. this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  27274. return prop;
  27275. }
  27276. getGetterSetterExpectedParamCount(method) {
  27277. return method.kind === "get" ? 0 : 1;
  27278. }
  27279. getObjectOrClassMethodParams(method) {
  27280. return method.params;
  27281. }
  27282. checkGetterSetterParams(method) {
  27283. var _params;
  27284. const paramCount = this.getGetterSetterExpectedParamCount(method);
  27285. const params = this.getObjectOrClassMethodParams(method);
  27286. const start = method.start;
  27287. if (params.length !== paramCount) {
  27288. if (method.kind === "get") {
  27289. this.raise(start, ErrorMessages.BadGetterArity);
  27290. } else {
  27291. this.raise(start, ErrorMessages.BadSetterArity);
  27292. }
  27293. }
  27294. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  27295. this.raise(start, ErrorMessages.BadSetterRestParameter);
  27296. }
  27297. }
  27298. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  27299. if (isAccessor) {
  27300. this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  27301. this.checkGetterSetterParams(prop);
  27302. return prop;
  27303. }
  27304. if (isAsync || isGenerator || this.match(types$1.parenL)) {
  27305. if (isPattern) this.unexpected();
  27306. prop.kind = "method";
  27307. prop.method = true;
  27308. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  27309. }
  27310. }
  27311. parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) {
  27312. prop.shorthand = false;
  27313. if (this.eat(types$1.colon)) {
  27314. prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
  27315. return this.finishNode(prop, "ObjectProperty");
  27316. }
  27317. if (!prop.computed && prop.key.type === "Identifier") {
  27318. this.checkReservedWord(prop.key.name, prop.key.start, true, false);
  27319. if (isPattern) {
  27320. prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
  27321. } else if (this.match(types$1.eq) && refExpressionErrors) {
  27322. if (refExpressionErrors.shorthandAssign === -1) {
  27323. refExpressionErrors.shorthandAssign = this.state.start;
  27324. }
  27325. prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
  27326. } else {
  27327. prop.value = cloneIdentifier(prop.key);
  27328. }
  27329. prop.shorthand = true;
  27330. return this.finishNode(prop, "ObjectProperty");
  27331. }
  27332. }
  27333. parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  27334. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors);
  27335. if (!node) this.unexpected();
  27336. return node;
  27337. }
  27338. parsePropertyName(prop, isPrivateNameAllowed) {
  27339. if (this.eat(types$1.bracketL)) {
  27340. prop.computed = true;
  27341. prop.key = this.parseMaybeAssignAllowIn();
  27342. this.expect(types$1.bracketR);
  27343. } else {
  27344. const oldInPropertyName = this.state.inPropertyName;
  27345. this.state.inPropertyName = true;
  27346. const type = this.state.type;
  27347. prop.key = type === types$1.num || type === types$1.string || type === types$1.bigint || type === types$1.decimal ? this.parseExprAtom() : this.parseMaybePrivateName(isPrivateNameAllowed);
  27348. if (type !== types$1.privateName) {
  27349. prop.computed = false;
  27350. }
  27351. this.state.inPropertyName = oldInPropertyName;
  27352. }
  27353. return prop.key;
  27354. }
  27355. initFunction(node, isAsync) {
  27356. node.id = null;
  27357. node.generator = false;
  27358. node.async = !!isAsync;
  27359. }
  27360. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  27361. this.initFunction(node, isAsync);
  27362. node.generator = !!isGenerator;
  27363. const allowModifiers = isConstructor;
  27364. this.scope.enter(SCOPE_FUNCTION | SCOPE_SUPER | (inClassScope ? SCOPE_CLASS : 0) | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
  27365. this.prodParam.enter(functionFlags(isAsync, node.generator));
  27366. this.parseFunctionParams(node, allowModifiers);
  27367. this.parseFunctionBodyAndFinish(node, type, true);
  27368. this.prodParam.exit();
  27369. this.scope.exit();
  27370. return node;
  27371. }
  27372. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  27373. if (isTuple) {
  27374. this.expectPlugin("recordAndTuple");
  27375. }
  27376. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  27377. this.state.inFSharpPipelineDirectBody = false;
  27378. const node = this.startNode();
  27379. this.next();
  27380. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  27381. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  27382. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  27383. }
  27384. parseArrowExpression(node, params, isAsync, trailingCommaPos) {
  27385. this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
  27386. let flags = functionFlags(isAsync, false);
  27387. if (!this.match(types$1.bracketL) && this.prodParam.hasIn) {
  27388. flags |= PARAM_IN;
  27389. }
  27390. this.prodParam.enter(flags);
  27391. this.initFunction(node, isAsync);
  27392. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  27393. if (params) {
  27394. this.state.maybeInArrowParameters = true;
  27395. this.setArrowFunctionParameters(node, params, trailingCommaPos);
  27396. }
  27397. this.state.maybeInArrowParameters = false;
  27398. this.parseFunctionBody(node, true);
  27399. this.prodParam.exit();
  27400. this.scope.exit();
  27401. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  27402. return this.finishNode(node, "ArrowFunctionExpression");
  27403. }
  27404. setArrowFunctionParameters(node, params, trailingCommaPos) {
  27405. node.params = this.toAssignableList(params, trailingCommaPos, false);
  27406. }
  27407. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  27408. this.parseFunctionBody(node, false, isMethod);
  27409. this.finishNode(node, type);
  27410. }
  27411. parseFunctionBody(node, allowExpression, isMethod = false) {
  27412. const isExpression = allowExpression && !this.match(types$1.braceL);
  27413. this.expressionScope.enter(newExpressionScope());
  27414. if (isExpression) {
  27415. node.body = this.parseMaybeAssign();
  27416. this.checkParams(node, false, allowExpression, false);
  27417. } else {
  27418. const oldStrict = this.state.strict;
  27419. const oldLabels = this.state.labels;
  27420. this.state.labels = [];
  27421. this.prodParam.enter(this.prodParam.currentFlags() | PARAM_RETURN);
  27422. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  27423. const nonSimple = !this.isSimpleParamList(node.params);
  27424. if (hasStrictModeDirective && nonSimple) {
  27425. const errorPos = (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.end : node.start;
  27426. this.raise(errorPos, ErrorMessages.IllegalLanguageModeDirective);
  27427. }
  27428. const strictModeChanged = !oldStrict && this.state.strict;
  27429. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  27430. if (this.state.strict && node.id) {
  27431. this.checkLVal(node.id, "function name", BIND_OUTSIDE, undefined, undefined, strictModeChanged);
  27432. }
  27433. });
  27434. this.prodParam.exit();
  27435. this.expressionScope.exit();
  27436. this.state.labels = oldLabels;
  27437. }
  27438. }
  27439. isSimpleParamList(params) {
  27440. for (let i = 0, len = params.length; i < len; i++) {
  27441. if (params[i].type !== "Identifier") return false;
  27442. }
  27443. return true;
  27444. }
  27445. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  27446. const checkClashes = new Set();
  27447. for (const param of node.params) {
  27448. this.checkLVal(param, "function parameter list", BIND_VAR, allowDuplicates ? null : checkClashes, undefined, strictModeChanged);
  27449. }
  27450. }
  27451. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  27452. const elts = [];
  27453. let first = true;
  27454. while (!this.eat(close)) {
  27455. if (first) {
  27456. first = false;
  27457. } else {
  27458. this.expect(types$1.comma);
  27459. if (this.match(close)) {
  27460. if (nodeForExtra) {
  27461. this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
  27462. }
  27463. this.next();
  27464. break;
  27465. }
  27466. }
  27467. elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
  27468. }
  27469. return elts;
  27470. }
  27471. parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
  27472. let elt;
  27473. if (this.match(types$1.comma)) {
  27474. if (!allowEmpty) {
  27475. this.raise(this.state.pos, ErrorMessages.UnexpectedToken, ",");
  27476. }
  27477. elt = null;
  27478. } else if (this.match(types$1.ellipsis)) {
  27479. const spreadNodeStartPos = this.state.start;
  27480. const spreadNodeStartLoc = this.state.startLoc;
  27481. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartPos, spreadNodeStartLoc);
  27482. } else if (this.match(types$1.question)) {
  27483. this.expectPlugin("partialApplication");
  27484. if (!allowPlaceholder) {
  27485. this.raise(this.state.start, ErrorMessages.UnexpectedArgumentPlaceholder);
  27486. }
  27487. const node = this.startNode();
  27488. this.next();
  27489. elt = this.finishNode(node, "ArgumentPlaceholder");
  27490. } else {
  27491. elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
  27492. }
  27493. return elt;
  27494. }
  27495. parseIdentifier(liberal) {
  27496. const node = this.startNode();
  27497. const name = this.parseIdentifierName(node.start, liberal);
  27498. return this.createIdentifier(node, name);
  27499. }
  27500. createIdentifier(node, name) {
  27501. node.name = name;
  27502. node.loc.identifierName = name;
  27503. return this.finishNode(node, "Identifier");
  27504. }
  27505. parseIdentifierName(pos, liberal) {
  27506. let name;
  27507. const {
  27508. start,
  27509. type
  27510. } = this.state;
  27511. if (type === types$1.name) {
  27512. name = this.state.value;
  27513. } else if (type.keyword) {
  27514. name = type.keyword;
  27515. } else {
  27516. throw this.unexpected();
  27517. }
  27518. if (liberal) {
  27519. this.state.type = types$1.name;
  27520. } else {
  27521. this.checkReservedWord(name, start, !!type.keyword, false);
  27522. }
  27523. this.next();
  27524. return name;
  27525. }
  27526. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  27527. if (word.length > 10) {
  27528. return;
  27529. }
  27530. if (!canBeReservedWord(word)) {
  27531. return;
  27532. }
  27533. if (word === "yield") {
  27534. if (this.prodParam.hasYield) {
  27535. this.raise(startLoc, ErrorMessages.YieldBindingIdentifier);
  27536. return;
  27537. }
  27538. } else if (word === "await") {
  27539. if (this.prodParam.hasAwait) {
  27540. this.raise(startLoc, ErrorMessages.AwaitBindingIdentifier);
  27541. return;
  27542. } else if (this.scope.inStaticBlock) {
  27543. this.raise(startLoc, ErrorMessages.AwaitBindingIdentifierInStaticBlock);
  27544. return;
  27545. } else {
  27546. this.expressionScope.recordAsyncArrowParametersError(startLoc, ErrorMessages.AwaitBindingIdentifier);
  27547. }
  27548. } else if (word === "arguments") {
  27549. if (this.scope.inClassAndNotInNonArrowFunction) {
  27550. this.raise(startLoc, ErrorMessages.ArgumentsInClass);
  27551. return;
  27552. }
  27553. }
  27554. if (checkKeywords && isKeyword$1(word)) {
  27555. this.raise(startLoc, ErrorMessages.UnexpectedKeyword, word);
  27556. return;
  27557. }
  27558. const reservedTest = !this.state.strict ? isReservedWord$1 : isBinding ? isStrictBindReservedWord$1 : isStrictReservedWord$1;
  27559. if (reservedTest(word, this.inModule)) {
  27560. this.raise(startLoc, ErrorMessages.UnexpectedReservedWord, word);
  27561. }
  27562. }
  27563. isAwaitAllowed() {
  27564. if (this.prodParam.hasAwait) return true;
  27565. if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
  27566. return true;
  27567. }
  27568. return false;
  27569. }
  27570. parseAwait(startPos, startLoc) {
  27571. const node = this.startNodeAt(startPos, startLoc);
  27572. this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.AwaitExpressionFormalParameter);
  27573. if (this.eat(types$1.star)) {
  27574. this.raise(node.start, ErrorMessages.ObsoleteAwaitStar);
  27575. }
  27576. if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
  27577. if (this.isAmbiguousAwait()) {
  27578. this.ambiguousScriptDifferentAst = true;
  27579. } else {
  27580. this.sawUnambiguousESM = true;
  27581. }
  27582. }
  27583. if (!this.state.soloAwait) {
  27584. node.argument = this.parseMaybeUnary(null, true);
  27585. }
  27586. return this.finishNode(node, "AwaitExpression");
  27587. }
  27588. isAmbiguousAwait() {
  27589. return this.hasPrecedingLineBreak() || this.match(types$1.plusMin) || this.match(types$1.parenL) || this.match(types$1.bracketL) || this.match(types$1.backQuote) || this.match(types$1.regexp) || this.match(types$1.slash) || this.hasPlugin("v8intrinsic") && this.match(types$1.modulo);
  27590. }
  27591. parseYield() {
  27592. const node = this.startNode();
  27593. this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.YieldInParameter);
  27594. this.next();
  27595. let delegating = false;
  27596. let argument = null;
  27597. if (!this.hasPrecedingLineBreak()) {
  27598. delegating = this.eat(types$1.star);
  27599. switch (this.state.type) {
  27600. case types$1.semi:
  27601. case types$1.eof:
  27602. case types$1.braceR:
  27603. case types$1.parenR:
  27604. case types$1.bracketR:
  27605. case types$1.braceBarR:
  27606. case types$1.colon:
  27607. case types$1.comma:
  27608. if (!delegating) break;
  27609. default:
  27610. argument = this.parseMaybeAssign();
  27611. }
  27612. }
  27613. node.delegate = delegating;
  27614. node.argument = argument;
  27615. return this.finishNode(node, "YieldExpression");
  27616. }
  27617. checkPipelineAtInfixOperator(left, leftStartPos) {
  27618. if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
  27619. if (left.type === "SequenceExpression") {
  27620. this.raise(leftStartPos, ErrorMessages.PipelineHeadSequenceExpression);
  27621. }
  27622. }
  27623. }
  27624. checkHackPipeBodyEarlyErrors(startPos) {
  27625. if (this.match(types$1.arrow)) {
  27626. throw this.raise(this.state.start, ErrorMessages.PipeBodyIsTighter, types$1.arrow.label);
  27627. } else if (!this.topicReferenceWasUsedInCurrentContext()) {
  27628. this.raise(startPos, ErrorMessages.PipeTopicUnused);
  27629. }
  27630. }
  27631. parseSmartPipelineBodyInStyle(childExpr, startPos, startLoc) {
  27632. const bodyNode = this.startNodeAt(startPos, startLoc);
  27633. if (this.isSimpleReference(childExpr)) {
  27634. bodyNode.callee = childExpr;
  27635. return this.finishNode(bodyNode, "PipelineBareFunction");
  27636. } else {
  27637. this.checkSmartPipeTopicBodyEarlyErrors(startPos);
  27638. bodyNode.expression = childExpr;
  27639. return this.finishNode(bodyNode, "PipelineTopicExpression");
  27640. }
  27641. }
  27642. isSimpleReference(expression) {
  27643. switch (expression.type) {
  27644. case "MemberExpression":
  27645. return !expression.computed && this.isSimpleReference(expression.object);
  27646. case "Identifier":
  27647. return true;
  27648. default:
  27649. return false;
  27650. }
  27651. }
  27652. checkSmartPipeTopicBodyEarlyErrors(startPos) {
  27653. if (this.match(types$1.arrow)) {
  27654. throw this.raise(this.state.start, ErrorMessages.PipelineBodyNoArrow);
  27655. } else if (!this.topicReferenceWasUsedInCurrentContext()) {
  27656. this.raise(startPos, ErrorMessages.PipelineTopicUnused);
  27657. }
  27658. }
  27659. withTopicBindingContext(callback) {
  27660. const outerContextTopicState = this.state.topicContext;
  27661. this.state.topicContext = {
  27662. maxNumOfResolvableTopics: 1,
  27663. maxTopicIndex: null
  27664. };
  27665. try {
  27666. return callback();
  27667. } finally {
  27668. this.state.topicContext = outerContextTopicState;
  27669. }
  27670. }
  27671. withSmartMixTopicForbiddingContext(callback) {
  27672. const proposal = this.getPluginOption("pipelineOperator", "proposal");
  27673. if (proposal === "smart") {
  27674. const outerContextTopicState = this.state.topicContext;
  27675. this.state.topicContext = {
  27676. maxNumOfResolvableTopics: 0,
  27677. maxTopicIndex: null
  27678. };
  27679. try {
  27680. return callback();
  27681. } finally {
  27682. this.state.topicContext = outerContextTopicState;
  27683. }
  27684. } else {
  27685. return callback();
  27686. }
  27687. }
  27688. withSoloAwaitPermittingContext(callback) {
  27689. const outerContextSoloAwaitState = this.state.soloAwait;
  27690. this.state.soloAwait = true;
  27691. try {
  27692. return callback();
  27693. } finally {
  27694. this.state.soloAwait = outerContextSoloAwaitState;
  27695. }
  27696. }
  27697. allowInAnd(callback) {
  27698. const flags = this.prodParam.currentFlags();
  27699. const prodParamToSet = PARAM_IN & ~flags;
  27700. if (prodParamToSet) {
  27701. this.prodParam.enter(flags | PARAM_IN);
  27702. try {
  27703. return callback();
  27704. } finally {
  27705. this.prodParam.exit();
  27706. }
  27707. }
  27708. return callback();
  27709. }
  27710. disallowInAnd(callback) {
  27711. const flags = this.prodParam.currentFlags();
  27712. const prodParamToClear = PARAM_IN & flags;
  27713. if (prodParamToClear) {
  27714. this.prodParam.enter(flags & ~PARAM_IN);
  27715. try {
  27716. return callback();
  27717. } finally {
  27718. this.prodParam.exit();
  27719. }
  27720. }
  27721. return callback();
  27722. }
  27723. registerTopicReference() {
  27724. this.state.topicContext.maxTopicIndex = 0;
  27725. }
  27726. topicReferenceIsAllowedInCurrentContext() {
  27727. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  27728. }
  27729. topicReferenceWasUsedInCurrentContext() {
  27730. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  27731. }
  27732. parseFSharpPipelineBody(prec) {
  27733. const startPos = this.state.start;
  27734. const startLoc = this.state.startLoc;
  27735. this.state.potentialArrowAt = this.state.start;
  27736. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  27737. this.state.inFSharpPipelineDirectBody = true;
  27738. const ret = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec);
  27739. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  27740. return ret;
  27741. }
  27742. parseModuleExpression() {
  27743. this.expectPlugin("moduleBlocks");
  27744. const node = this.startNode();
  27745. this.next();
  27746. this.eat(types$1.braceL);
  27747. const revertScopes = this.initializeScopes(true);
  27748. this.enterInitialScopes();
  27749. const program = this.startNode();
  27750. try {
  27751. node.body = this.parseProgram(program, types$1.braceR, "module");
  27752. } finally {
  27753. revertScopes();
  27754. }
  27755. this.eat(types$1.braceR);
  27756. return this.finishNode(node, "ModuleExpression");
  27757. }
  27758. }
  27759. const loopLabel = {
  27760. kind: "loop"
  27761. },
  27762. switchLabel = {
  27763. kind: "switch"
  27764. };
  27765. const FUNC_NO_FLAGS = 0b000,
  27766. FUNC_STATEMENT = 0b001,
  27767. FUNC_HANGING_STATEMENT = 0b010,
  27768. FUNC_NULLABLE_ID = 0b100;
  27769. const loneSurrogate = /[\uD800-\uDFFF]/u;
  27770. const keywordRelationalOperator = /in(?:stanceof)?/y;
  27771. function babel7CompatTokens(tokens) {
  27772. {
  27773. for (let i = 0; i < tokens.length; i++) {
  27774. const token = tokens[i];
  27775. if (token.type === types$1.privateName) {
  27776. const {
  27777. loc,
  27778. start,
  27779. value,
  27780. end
  27781. } = token;
  27782. const hashEndPos = start + 1;
  27783. const hashEndLoc = new Position(loc.start.line, loc.start.column + 1);
  27784. tokens.splice(i, 1, new Token({
  27785. type: types$1.hash,
  27786. value: "#",
  27787. start: start,
  27788. end: hashEndPos,
  27789. startLoc: loc.start,
  27790. endLoc: hashEndLoc
  27791. }), new Token({
  27792. type: types$1.name,
  27793. value: value,
  27794. start: hashEndPos,
  27795. end: end,
  27796. startLoc: hashEndLoc,
  27797. endLoc: loc.end
  27798. }));
  27799. }
  27800. }
  27801. }
  27802. return tokens;
  27803. }
  27804. class StatementParser extends ExpressionParser {
  27805. parseTopLevel(file, program) {
  27806. file.program = this.parseProgram(program);
  27807. file.comments = this.state.comments;
  27808. if (this.options.tokens) file.tokens = babel7CompatTokens(this.tokens);
  27809. return this.finishNode(file, "File");
  27810. }
  27811. parseProgram(program, end = types$1.eof, sourceType = this.options.sourceType) {
  27812. program.sourceType = sourceType;
  27813. program.interpreter = this.parseInterpreterDirective();
  27814. this.parseBlockBody(program, true, true, end);
  27815. if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
  27816. for (const [name] of Array.from(this.scope.undefinedExports)) {
  27817. const pos = this.scope.undefinedExports.get(name);
  27818. this.raise(pos, ErrorMessages.ModuleExportUndefined, name);
  27819. }
  27820. }
  27821. return this.finishNode(program, "Program");
  27822. }
  27823. stmtToDirective(stmt) {
  27824. const directive = stmt;
  27825. directive.type = "Directive";
  27826. directive.value = directive.expression;
  27827. delete directive.expression;
  27828. const directiveLiteral = directive.value;
  27829. const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end);
  27830. const val = directiveLiteral.value = raw.slice(1, -1);
  27831. this.addExtra(directiveLiteral, "raw", raw);
  27832. this.addExtra(directiveLiteral, "rawValue", val);
  27833. directiveLiteral.type = "DirectiveLiteral";
  27834. return directive;
  27835. }
  27836. parseInterpreterDirective() {
  27837. if (!this.match(types$1.interpreterDirective)) {
  27838. return null;
  27839. }
  27840. const node = this.startNode();
  27841. node.value = this.state.value;
  27842. this.next();
  27843. return this.finishNode(node, "InterpreterDirective");
  27844. }
  27845. isLet(context) {
  27846. if (!this.isContextual("let")) {
  27847. return false;
  27848. }
  27849. return this.isLetKeyword(context);
  27850. }
  27851. isLetKeyword(context) {
  27852. const next = this.nextTokenStart();
  27853. const nextCh = this.codePointAtPos(next);
  27854. if (nextCh === 92 || nextCh === 91) {
  27855. return true;
  27856. }
  27857. if (context) return false;
  27858. if (nextCh === 123) return true;
  27859. if (isIdentifierStart$1(nextCh)) {
  27860. keywordRelationalOperator.lastIndex = next;
  27861. if (keywordRelationalOperator.test(this.input)) {
  27862. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  27863. if (!isIdentifierChar$1(endCh) && endCh !== 92) {
  27864. return false;
  27865. }
  27866. }
  27867. return true;
  27868. }
  27869. return false;
  27870. }
  27871. parseStatement(context, topLevel) {
  27872. if (this.match(types$1.at)) {
  27873. this.parseDecorators(true);
  27874. }
  27875. return this.parseStatementContent(context, topLevel);
  27876. }
  27877. parseStatementContent(context, topLevel) {
  27878. let starttype = this.state.type;
  27879. const node = this.startNode();
  27880. let kind;
  27881. if (this.isLet(context)) {
  27882. starttype = types$1._var;
  27883. kind = "let";
  27884. }
  27885. switch (starttype) {
  27886. case types$1._break:
  27887. case types$1._continue:
  27888. return this.parseBreakContinueStatement(node, starttype.keyword);
  27889. case types$1._debugger:
  27890. return this.parseDebuggerStatement(node);
  27891. case types$1._do:
  27892. return this.parseDoStatement(node);
  27893. case types$1._for:
  27894. return this.parseForStatement(node);
  27895. case types$1._function:
  27896. if (this.lookaheadCharCode() === 46) break;
  27897. if (context) {
  27898. if (this.state.strict) {
  27899. this.raise(this.state.start, ErrorMessages.StrictFunction);
  27900. } else if (context !== "if" && context !== "label") {
  27901. this.raise(this.state.start, ErrorMessages.SloppyFunction);
  27902. }
  27903. }
  27904. return this.parseFunctionStatement(node, false, !context);
  27905. case types$1._class:
  27906. if (context) this.unexpected();
  27907. return this.parseClass(node, true);
  27908. case types$1._if:
  27909. return this.parseIfStatement(node);
  27910. case types$1._return:
  27911. return this.parseReturnStatement(node);
  27912. case types$1._switch:
  27913. return this.parseSwitchStatement(node);
  27914. case types$1._throw:
  27915. return this.parseThrowStatement(node);
  27916. case types$1._try:
  27917. return this.parseTryStatement(node);
  27918. case types$1._const:
  27919. case types$1._var:
  27920. kind = kind || this.state.value;
  27921. if (context && kind !== "var") {
  27922. this.raise(this.state.start, ErrorMessages.UnexpectedLexicalDeclaration);
  27923. }
  27924. return this.parseVarStatement(node, kind);
  27925. case types$1._while:
  27926. return this.parseWhileStatement(node);
  27927. case types$1._with:
  27928. return this.parseWithStatement(node);
  27929. case types$1.braceL:
  27930. return this.parseBlock();
  27931. case types$1.semi:
  27932. return this.parseEmptyStatement(node);
  27933. case types$1._import:
  27934. {
  27935. const nextTokenCharCode = this.lookaheadCharCode();
  27936. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  27937. break;
  27938. }
  27939. }
  27940. case types$1._export:
  27941. {
  27942. if (!this.options.allowImportExportEverywhere && !topLevel) {
  27943. this.raise(this.state.start, ErrorMessages.UnexpectedImportExport);
  27944. }
  27945. this.next();
  27946. let result;
  27947. if (starttype === types$1._import) {
  27948. result = this.parseImport(node);
  27949. if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
  27950. this.sawUnambiguousESM = true;
  27951. }
  27952. } else {
  27953. result = this.parseExport(node);
  27954. if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
  27955. this.sawUnambiguousESM = true;
  27956. }
  27957. }
  27958. this.assertModuleNodeAllowed(node);
  27959. return result;
  27960. }
  27961. default:
  27962. {
  27963. if (this.isAsyncFunction()) {
  27964. if (context) {
  27965. this.raise(this.state.start, ErrorMessages.AsyncFunctionInSingleStatementContext);
  27966. }
  27967. this.next();
  27968. return this.parseFunctionStatement(node, true, !context);
  27969. }
  27970. }
  27971. }
  27972. const maybeName = this.state.value;
  27973. const expr = this.parseExpression();
  27974. if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) {
  27975. return this.parseLabeledStatement(node, maybeName, expr, context);
  27976. } else {
  27977. return this.parseExpressionStatement(node, expr);
  27978. }
  27979. }
  27980. assertModuleNodeAllowed(node) {
  27981. if (!this.options.allowImportExportEverywhere && !this.inModule) {
  27982. this.raise(node.start, SourceTypeModuleErrorMessages.ImportOutsideModule);
  27983. }
  27984. }
  27985. takeDecorators(node) {
  27986. const decorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
  27987. if (decorators.length) {
  27988. node.decorators = decorators;
  27989. this.resetStartLocationFromNode(node, decorators[0]);
  27990. this.state.decoratorStack[this.state.decoratorStack.length - 1] = [];
  27991. }
  27992. }
  27993. canHaveLeadingDecorator() {
  27994. return this.match(types$1._class);
  27995. }
  27996. parseDecorators(allowExport) {
  27997. const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
  27998. while (this.match(types$1.at)) {
  27999. const decorator = this.parseDecorator();
  28000. currentContextDecorators.push(decorator);
  28001. }
  28002. if (this.match(types$1._export)) {
  28003. if (!allowExport) {
  28004. this.unexpected();
  28005. }
  28006. if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
  28007. this.raise(this.state.start, ErrorMessages.DecoratorExportClass);
  28008. }
  28009. } else if (!this.canHaveLeadingDecorator()) {
  28010. throw this.raise(this.state.start, ErrorMessages.UnexpectedLeadingDecorator);
  28011. }
  28012. }
  28013. parseDecorator() {
  28014. this.expectOnePlugin(["decorators-legacy", "decorators"]);
  28015. const node = this.startNode();
  28016. this.next();
  28017. if (this.hasPlugin("decorators")) {
  28018. this.state.decoratorStack.push([]);
  28019. const startPos = this.state.start;
  28020. const startLoc = this.state.startLoc;
  28021. let expr;
  28022. if (this.eat(types$1.parenL)) {
  28023. expr = this.parseExpression();
  28024. this.expect(types$1.parenR);
  28025. } else {
  28026. expr = this.parseIdentifier(false);
  28027. while (this.eat(types$1.dot)) {
  28028. const node = this.startNodeAt(startPos, startLoc);
  28029. node.object = expr;
  28030. node.property = this.parseIdentifier(true);
  28031. node.computed = false;
  28032. expr = this.finishNode(node, "MemberExpression");
  28033. }
  28034. }
  28035. node.expression = this.parseMaybeDecoratorArguments(expr);
  28036. this.state.decoratorStack.pop();
  28037. } else {
  28038. node.expression = this.parseExprSubscripts();
  28039. }
  28040. return this.finishNode(node, "Decorator");
  28041. }
  28042. parseMaybeDecoratorArguments(expr) {
  28043. if (this.eat(types$1.parenL)) {
  28044. const node = this.startNodeAtNode(expr);
  28045. node.callee = expr;
  28046. node.arguments = this.parseCallExpressionArguments(types$1.parenR, false);
  28047. this.toReferencedList(node.arguments);
  28048. return this.finishNode(node, "CallExpression");
  28049. }
  28050. return expr;
  28051. }
  28052. parseBreakContinueStatement(node, keyword) {
  28053. const isBreak = keyword === "break";
  28054. this.next();
  28055. if (this.isLineTerminator()) {
  28056. node.label = null;
  28057. } else {
  28058. node.label = this.parseIdentifier();
  28059. this.semicolon();
  28060. }
  28061. this.verifyBreakContinue(node, keyword);
  28062. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  28063. }
  28064. verifyBreakContinue(node, keyword) {
  28065. const isBreak = keyword === "break";
  28066. let i;
  28067. for (i = 0; i < this.state.labels.length; ++i) {
  28068. const lab = this.state.labels[i];
  28069. if (node.label == null || lab.name === node.label.name) {
  28070. if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
  28071. if (node.label && isBreak) break;
  28072. }
  28073. }
  28074. if (i === this.state.labels.length) {
  28075. this.raise(node.start, ErrorMessages.IllegalBreakContinue, keyword);
  28076. }
  28077. }
  28078. parseDebuggerStatement(node) {
  28079. this.next();
  28080. this.semicolon();
  28081. return this.finishNode(node, "DebuggerStatement");
  28082. }
  28083. parseHeaderExpression() {
  28084. this.expect(types$1.parenL);
  28085. const val = this.parseExpression();
  28086. this.expect(types$1.parenR);
  28087. return val;
  28088. }
  28089. parseDoStatement(node) {
  28090. this.next();
  28091. this.state.labels.push(loopLabel);
  28092. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement("do"));
  28093. this.state.labels.pop();
  28094. this.expect(types$1._while);
  28095. node.test = this.parseHeaderExpression();
  28096. this.eat(types$1.semi);
  28097. return this.finishNode(node, "DoWhileStatement");
  28098. }
  28099. parseForStatement(node) {
  28100. this.next();
  28101. this.state.labels.push(loopLabel);
  28102. let awaitAt = -1;
  28103. if (this.isAwaitAllowed() && this.eatContextual("await")) {
  28104. awaitAt = this.state.lastTokStart;
  28105. }
  28106. this.scope.enter(SCOPE_OTHER);
  28107. this.expect(types$1.parenL);
  28108. if (this.match(types$1.semi)) {
  28109. if (awaitAt > -1) {
  28110. this.unexpected(awaitAt);
  28111. }
  28112. return this.parseFor(node, null);
  28113. }
  28114. const startsWithLet = this.isContextual("let");
  28115. const isLet = startsWithLet && this.isLetKeyword();
  28116. if (this.match(types$1._var) || this.match(types$1._const) || isLet) {
  28117. const init = this.startNode();
  28118. const kind = isLet ? "let" : this.state.value;
  28119. this.next();
  28120. this.parseVar(init, true, kind);
  28121. this.finishNode(init, "VariableDeclaration");
  28122. if ((this.match(types$1._in) || this.isContextual("of")) && init.declarations.length === 1) {
  28123. return this.parseForIn(node, init, awaitAt);
  28124. }
  28125. if (awaitAt > -1) {
  28126. this.unexpected(awaitAt);
  28127. }
  28128. return this.parseFor(node, init);
  28129. }
  28130. const startsWithUnescapedName = this.match(types$1.name) && !this.state.containsEsc;
  28131. const refExpressionErrors = new ExpressionErrors();
  28132. const init = this.parseExpression(true, refExpressionErrors);
  28133. const isForOf = this.isContextual("of");
  28134. if (isForOf) {
  28135. if (startsWithLet) {
  28136. this.raise(init.start, ErrorMessages.ForOfLet);
  28137. } else if (awaitAt === -1 && startsWithUnescapedName && init.type === "Identifier" && init.name === "async") {
  28138. this.raise(init.start, ErrorMessages.ForOfAsync);
  28139. }
  28140. }
  28141. if (isForOf || this.match(types$1._in)) {
  28142. this.toAssignable(init, true);
  28143. const description = isForOf ? "for-of statement" : "for-in statement";
  28144. this.checkLVal(init, description);
  28145. return this.parseForIn(node, init, awaitAt);
  28146. } else {
  28147. this.checkExpressionErrors(refExpressionErrors, true);
  28148. }
  28149. if (awaitAt > -1) {
  28150. this.unexpected(awaitAt);
  28151. }
  28152. return this.parseFor(node, init);
  28153. }
  28154. parseFunctionStatement(node, isAsync, declarationPosition) {
  28155. this.next();
  28156. return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), isAsync);
  28157. }
  28158. parseIfStatement(node) {
  28159. this.next();
  28160. node.test = this.parseHeaderExpression();
  28161. node.consequent = this.parseStatement("if");
  28162. node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
  28163. return this.finishNode(node, "IfStatement");
  28164. }
  28165. parseReturnStatement(node) {
  28166. if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
  28167. this.raise(this.state.start, ErrorMessages.IllegalReturn);
  28168. }
  28169. this.next();
  28170. if (this.isLineTerminator()) {
  28171. node.argument = null;
  28172. } else {
  28173. node.argument = this.parseExpression();
  28174. this.semicolon();
  28175. }
  28176. return this.finishNode(node, "ReturnStatement");
  28177. }
  28178. parseSwitchStatement(node) {
  28179. this.next();
  28180. node.discriminant = this.parseHeaderExpression();
  28181. const cases = node.cases = [];
  28182. this.expect(types$1.braceL);
  28183. this.state.labels.push(switchLabel);
  28184. this.scope.enter(SCOPE_OTHER);
  28185. let cur;
  28186. for (let sawDefault; !this.match(types$1.braceR);) {
  28187. if (this.match(types$1._case) || this.match(types$1._default)) {
  28188. const isCase = this.match(types$1._case);
  28189. if (cur) this.finishNode(cur, "SwitchCase");
  28190. cases.push(cur = this.startNode());
  28191. cur.consequent = [];
  28192. this.next();
  28193. if (isCase) {
  28194. cur.test = this.parseExpression();
  28195. } else {
  28196. if (sawDefault) {
  28197. this.raise(this.state.lastTokStart, ErrorMessages.MultipleDefaultsInSwitch);
  28198. }
  28199. sawDefault = true;
  28200. cur.test = null;
  28201. }
  28202. this.expect(types$1.colon);
  28203. } else {
  28204. if (cur) {
  28205. cur.consequent.push(this.parseStatement(null));
  28206. } else {
  28207. this.unexpected();
  28208. }
  28209. }
  28210. }
  28211. this.scope.exit();
  28212. if (cur) this.finishNode(cur, "SwitchCase");
  28213. this.next();
  28214. this.state.labels.pop();
  28215. return this.finishNode(node, "SwitchStatement");
  28216. }
  28217. parseThrowStatement(node) {
  28218. this.next();
  28219. if (this.hasPrecedingLineBreak()) {
  28220. this.raise(this.state.lastTokEnd, ErrorMessages.NewlineAfterThrow);
  28221. }
  28222. node.argument = this.parseExpression();
  28223. this.semicolon();
  28224. return this.finishNode(node, "ThrowStatement");
  28225. }
  28226. parseCatchClauseParam() {
  28227. const param = this.parseBindingAtom();
  28228. const simple = param.type === "Identifier";
  28229. this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0);
  28230. this.checkLVal(param, "catch clause", BIND_LEXICAL);
  28231. return param;
  28232. }
  28233. parseTryStatement(node) {
  28234. this.next();
  28235. node.block = this.parseBlock();
  28236. node.handler = null;
  28237. if (this.match(types$1._catch)) {
  28238. const clause = this.startNode();
  28239. this.next();
  28240. if (this.match(types$1.parenL)) {
  28241. this.expect(types$1.parenL);
  28242. clause.param = this.parseCatchClauseParam();
  28243. this.expect(types$1.parenR);
  28244. } else {
  28245. clause.param = null;
  28246. this.scope.enter(SCOPE_OTHER);
  28247. }
  28248. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  28249. this.scope.exit();
  28250. node.handler = this.finishNode(clause, "CatchClause");
  28251. }
  28252. node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
  28253. if (!node.handler && !node.finalizer) {
  28254. this.raise(node.start, ErrorMessages.NoCatchOrFinally);
  28255. }
  28256. return this.finishNode(node, "TryStatement");
  28257. }
  28258. parseVarStatement(node, kind) {
  28259. this.next();
  28260. this.parseVar(node, false, kind);
  28261. this.semicolon();
  28262. return this.finishNode(node, "VariableDeclaration");
  28263. }
  28264. parseWhileStatement(node) {
  28265. this.next();
  28266. node.test = this.parseHeaderExpression();
  28267. this.state.labels.push(loopLabel);
  28268. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement("while"));
  28269. this.state.labels.pop();
  28270. return this.finishNode(node, "WhileStatement");
  28271. }
  28272. parseWithStatement(node) {
  28273. if (this.state.strict) {
  28274. this.raise(this.state.start, ErrorMessages.StrictWith);
  28275. }
  28276. this.next();
  28277. node.object = this.parseHeaderExpression();
  28278. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement("with"));
  28279. return this.finishNode(node, "WithStatement");
  28280. }
  28281. parseEmptyStatement(node) {
  28282. this.next();
  28283. return this.finishNode(node, "EmptyStatement");
  28284. }
  28285. parseLabeledStatement(node, maybeName, expr, context) {
  28286. for (const label of this.state.labels) {
  28287. if (label.name === maybeName) {
  28288. this.raise(expr.start, ErrorMessages.LabelRedeclaration, maybeName);
  28289. }
  28290. }
  28291. const kind = this.state.type.isLoop ? "loop" : this.match(types$1._switch) ? "switch" : null;
  28292. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  28293. const label = this.state.labels[i];
  28294. if (label.statementStart === node.start) {
  28295. label.statementStart = this.state.start;
  28296. label.kind = kind;
  28297. } else {
  28298. break;
  28299. }
  28300. }
  28301. this.state.labels.push({
  28302. name: maybeName,
  28303. kind: kind,
  28304. statementStart: this.state.start
  28305. });
  28306. node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
  28307. this.state.labels.pop();
  28308. node.label = expr;
  28309. return this.finishNode(node, "LabeledStatement");
  28310. }
  28311. parseExpressionStatement(node, expr) {
  28312. node.expression = expr;
  28313. this.semicolon();
  28314. return this.finishNode(node, "ExpressionStatement");
  28315. }
  28316. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  28317. const node = this.startNode();
  28318. if (allowDirectives) {
  28319. this.state.strictErrors.clear();
  28320. }
  28321. this.expect(types$1.braceL);
  28322. if (createNewLexicalScope) {
  28323. this.scope.enter(SCOPE_OTHER);
  28324. }
  28325. this.parseBlockBody(node, allowDirectives, false, types$1.braceR, afterBlockParse);
  28326. if (createNewLexicalScope) {
  28327. this.scope.exit();
  28328. }
  28329. return this.finishNode(node, "BlockStatement");
  28330. }
  28331. isValidDirective(stmt) {
  28332. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  28333. }
  28334. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  28335. const body = node.body = [];
  28336. const directives = node.directives = [];
  28337. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  28338. }
  28339. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  28340. const oldStrict = this.state.strict;
  28341. let hasStrictModeDirective = false;
  28342. let parsedNonDirective = false;
  28343. while (!this.match(end)) {
  28344. const stmt = this.parseStatement(null, topLevel);
  28345. if (directives && !parsedNonDirective) {
  28346. if (this.isValidDirective(stmt)) {
  28347. const directive = this.stmtToDirective(stmt);
  28348. directives.push(directive);
  28349. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  28350. hasStrictModeDirective = true;
  28351. this.setStrict(true);
  28352. }
  28353. continue;
  28354. }
  28355. parsedNonDirective = true;
  28356. this.state.strictErrors.clear();
  28357. }
  28358. body.push(stmt);
  28359. }
  28360. if (afterBlockParse) {
  28361. afterBlockParse.call(this, hasStrictModeDirective);
  28362. }
  28363. if (!oldStrict) {
  28364. this.setStrict(false);
  28365. }
  28366. this.next();
  28367. }
  28368. parseFor(node, init) {
  28369. node.init = init;
  28370. this.semicolon(false);
  28371. node.test = this.match(types$1.semi) ? null : this.parseExpression();
  28372. this.semicolon(false);
  28373. node.update = this.match(types$1.parenR) ? null : this.parseExpression();
  28374. this.expect(types$1.parenR);
  28375. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement("for"));
  28376. this.scope.exit();
  28377. this.state.labels.pop();
  28378. return this.finishNode(node, "ForStatement");
  28379. }
  28380. parseForIn(node, init, awaitAt) {
  28381. const isForIn = this.match(types$1._in);
  28382. this.next();
  28383. if (isForIn) {
  28384. if (awaitAt > -1) this.unexpected(awaitAt);
  28385. } else {
  28386. node.await = awaitAt > -1;
  28387. }
  28388. if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
  28389. this.raise(init.start, ErrorMessages.ForInOfLoopInitializer, isForIn ? "for-in" : "for-of");
  28390. } else if (init.type === "AssignmentPattern") {
  28391. this.raise(init.start, ErrorMessages.InvalidLhs, "for-loop");
  28392. }
  28393. node.left = init;
  28394. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  28395. this.expect(types$1.parenR);
  28396. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement("for"));
  28397. this.scope.exit();
  28398. this.state.labels.pop();
  28399. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  28400. }
  28401. parseVar(node, isFor, kind) {
  28402. const declarations = node.declarations = [];
  28403. const isTypescript = this.hasPlugin("typescript");
  28404. node.kind = kind;
  28405. for (;;) {
  28406. const decl = this.startNode();
  28407. this.parseVarId(decl, kind);
  28408. if (this.eat(types$1.eq)) {
  28409. decl.init = isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  28410. } else {
  28411. if (kind === "const" && !(this.match(types$1._in) || this.isContextual("of"))) {
  28412. if (!isTypescript) {
  28413. this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Const declarations");
  28414. }
  28415. } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(types$1._in) || this.isContextual("of")))) {
  28416. this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Complex binding patterns");
  28417. }
  28418. decl.init = null;
  28419. }
  28420. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  28421. if (!this.eat(types$1.comma)) break;
  28422. }
  28423. return node;
  28424. }
  28425. parseVarId(decl, kind) {
  28426. decl.id = this.parseBindingAtom();
  28427. this.checkLVal(decl.id, "variable declaration", kind === "var" ? BIND_VAR : BIND_LEXICAL, undefined, kind !== "var");
  28428. }
  28429. parseFunction(node, statement = FUNC_NO_FLAGS, isAsync = false) {
  28430. const isStatement = statement & FUNC_STATEMENT;
  28431. const isHangingStatement = statement & FUNC_HANGING_STATEMENT;
  28432. const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID);
  28433. this.initFunction(node, isAsync);
  28434. if (this.match(types$1.star) && isHangingStatement) {
  28435. this.raise(this.state.start, ErrorMessages.GeneratorInSingleStatementContext);
  28436. }
  28437. node.generator = this.eat(types$1.star);
  28438. if (isStatement) {
  28439. node.id = this.parseFunctionId(requireId);
  28440. }
  28441. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  28442. this.state.maybeInArrowParameters = false;
  28443. this.scope.enter(SCOPE_FUNCTION);
  28444. this.prodParam.enter(functionFlags(isAsync, node.generator));
  28445. if (!isStatement) {
  28446. node.id = this.parseFunctionId();
  28447. }
  28448. this.parseFunctionParams(node, false);
  28449. this.withSmartMixTopicForbiddingContext(() => {
  28450. this.parseFunctionBodyAndFinish(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
  28451. });
  28452. this.prodParam.exit();
  28453. this.scope.exit();
  28454. if (isStatement && !isHangingStatement) {
  28455. this.registerFunctionStatementId(node);
  28456. }
  28457. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  28458. return node;
  28459. }
  28460. parseFunctionId(requireId) {
  28461. return requireId || this.match(types$1.name) ? this.parseIdentifier() : null;
  28462. }
  28463. parseFunctionParams(node, allowModifiers) {
  28464. this.expect(types$1.parenL);
  28465. this.expressionScope.enter(newParameterDeclarationScope());
  28466. node.params = this.parseBindingList(types$1.parenR, 41, false, allowModifiers);
  28467. this.expressionScope.exit();
  28468. }
  28469. registerFunctionStatementId(node) {
  28470. if (!node.id) return;
  28471. this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.start);
  28472. }
  28473. parseClass(node, isStatement, optionalId) {
  28474. this.next();
  28475. this.takeDecorators(node);
  28476. const oldStrict = this.state.strict;
  28477. this.state.strict = true;
  28478. this.parseClassId(node, isStatement, optionalId);
  28479. this.parseClassSuper(node);
  28480. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  28481. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  28482. }
  28483. isClassProperty() {
  28484. return this.match(types$1.eq) || this.match(types$1.semi) || this.match(types$1.braceR);
  28485. }
  28486. isClassMethod() {
  28487. return this.match(types$1.parenL);
  28488. }
  28489. isNonstaticConstructor(method) {
  28490. return !method.computed && !method.static && (method.key.name === "constructor" || method.key.value === "constructor");
  28491. }
  28492. parseClassBody(hadSuperClass, oldStrict) {
  28493. this.classScope.enter();
  28494. const state = {
  28495. hadConstructor: false,
  28496. hadSuperClass
  28497. };
  28498. let decorators = [];
  28499. const classBody = this.startNode();
  28500. classBody.body = [];
  28501. this.expect(types$1.braceL);
  28502. this.withSmartMixTopicForbiddingContext(() => {
  28503. while (!this.match(types$1.braceR)) {
  28504. if (this.eat(types$1.semi)) {
  28505. if (decorators.length > 0) {
  28506. throw this.raise(this.state.lastTokEnd, ErrorMessages.DecoratorSemicolon);
  28507. }
  28508. continue;
  28509. }
  28510. if (this.match(types$1.at)) {
  28511. decorators.push(this.parseDecorator());
  28512. continue;
  28513. }
  28514. const member = this.startNode();
  28515. if (decorators.length) {
  28516. member.decorators = decorators;
  28517. this.resetStartLocationFromNode(member, decorators[0]);
  28518. decorators = [];
  28519. }
  28520. this.parseClassMember(classBody, member, state);
  28521. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  28522. this.raise(member.start, ErrorMessages.DecoratorConstructor);
  28523. }
  28524. }
  28525. });
  28526. this.state.strict = oldStrict;
  28527. this.next();
  28528. if (decorators.length) {
  28529. throw this.raise(this.state.start, ErrorMessages.TrailingDecorator);
  28530. }
  28531. this.classScope.exit();
  28532. return this.finishNode(classBody, "ClassBody");
  28533. }
  28534. parseClassMemberFromModifier(classBody, member) {
  28535. const key = this.parseIdentifier(true);
  28536. if (this.isClassMethod()) {
  28537. const method = member;
  28538. method.kind = "method";
  28539. method.computed = false;
  28540. method.key = key;
  28541. method.static = false;
  28542. this.pushClassMethod(classBody, method, false, false, false, false);
  28543. return true;
  28544. } else if (this.isClassProperty()) {
  28545. const prop = member;
  28546. prop.computed = false;
  28547. prop.key = key;
  28548. prop.static = false;
  28549. classBody.body.push(this.parseClassProperty(prop));
  28550. return true;
  28551. }
  28552. this.resetPreviousNodeTrailingComments(key);
  28553. return false;
  28554. }
  28555. parseClassMember(classBody, member, state) {
  28556. const isStatic = this.isContextual("static");
  28557. if (isStatic) {
  28558. if (this.parseClassMemberFromModifier(classBody, member)) {
  28559. return;
  28560. }
  28561. if (this.eat(types$1.braceL)) {
  28562. this.parseClassStaticBlock(classBody, member);
  28563. return;
  28564. }
  28565. }
  28566. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  28567. }
  28568. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  28569. const publicMethod = member;
  28570. const privateMethod = member;
  28571. const publicProp = member;
  28572. const privateProp = member;
  28573. const method = publicMethod;
  28574. const publicMember = publicMethod;
  28575. member.static = isStatic;
  28576. if (this.eat(types$1.star)) {
  28577. method.kind = "method";
  28578. const isPrivateName = this.match(types$1.privateName);
  28579. this.parseClassElementName(method);
  28580. if (isPrivateName) {
  28581. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  28582. return;
  28583. }
  28584. if (this.isNonstaticConstructor(publicMethod)) {
  28585. this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsGenerator);
  28586. }
  28587. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  28588. return;
  28589. }
  28590. const isContextual = this.match(types$1.name) && !this.state.containsEsc;
  28591. const isPrivate = this.match(types$1.privateName);
  28592. const key = this.parseClassElementName(member);
  28593. const maybeQuestionTokenStart = this.state.start;
  28594. this.parsePostMemberNameModifiers(publicMember);
  28595. if (this.isClassMethod()) {
  28596. method.kind = "method";
  28597. if (isPrivate) {
  28598. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  28599. return;
  28600. }
  28601. const isConstructor = this.isNonstaticConstructor(publicMethod);
  28602. let allowsDirectSuper = false;
  28603. if (isConstructor) {
  28604. publicMethod.kind = "constructor";
  28605. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  28606. this.raise(key.start, ErrorMessages.DuplicateConstructor);
  28607. }
  28608. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  28609. this.raise(key.start, ErrorMessages.OverrideOnConstructor);
  28610. }
  28611. state.hadConstructor = true;
  28612. allowsDirectSuper = state.hadSuperClass;
  28613. }
  28614. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  28615. } else if (this.isClassProperty()) {
  28616. if (isPrivate) {
  28617. this.pushClassPrivateProperty(classBody, privateProp);
  28618. } else {
  28619. this.pushClassProperty(classBody, publicProp);
  28620. }
  28621. } else if (isContextual && key.name === "async" && !this.isLineTerminator()) {
  28622. this.resetPreviousNodeTrailingComments(key);
  28623. const isGenerator = this.eat(types$1.star);
  28624. if (publicMember.optional) {
  28625. this.unexpected(maybeQuestionTokenStart);
  28626. }
  28627. method.kind = "method";
  28628. const isPrivate = this.match(types$1.privateName);
  28629. this.parseClassElementName(method);
  28630. this.parsePostMemberNameModifiers(publicMember);
  28631. if (isPrivate) {
  28632. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  28633. } else {
  28634. if (this.isNonstaticConstructor(publicMethod)) {
  28635. this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAsync);
  28636. }
  28637. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  28638. }
  28639. } else if (isContextual && (key.name === "get" || key.name === "set") && !(this.match(types$1.star) && this.isLineTerminator())) {
  28640. this.resetPreviousNodeTrailingComments(key);
  28641. method.kind = key.name;
  28642. const isPrivate = this.match(types$1.privateName);
  28643. this.parseClassElementName(publicMethod);
  28644. if (isPrivate) {
  28645. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  28646. } else {
  28647. if (this.isNonstaticConstructor(publicMethod)) {
  28648. this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAccessor);
  28649. }
  28650. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  28651. }
  28652. this.checkGetterSetterParams(publicMethod);
  28653. } else if (this.isLineTerminator()) {
  28654. if (isPrivate) {
  28655. this.pushClassPrivateProperty(classBody, privateProp);
  28656. } else {
  28657. this.pushClassProperty(classBody, publicProp);
  28658. }
  28659. } else {
  28660. this.unexpected();
  28661. }
  28662. }
  28663. parseClassElementName(member) {
  28664. const {
  28665. type,
  28666. value,
  28667. start
  28668. } = this.state;
  28669. if ((type === types$1.name || type === types$1.string) && member.static && value === "prototype") {
  28670. this.raise(start, ErrorMessages.StaticPrototype);
  28671. }
  28672. if (type === types$1.privateName && value === "constructor") {
  28673. this.raise(start, ErrorMessages.ConstructorClassPrivateField);
  28674. }
  28675. return this.parsePropertyName(member, true);
  28676. }
  28677. parseClassStaticBlock(classBody, member) {
  28678. var _member$decorators;
  28679. this.expectPlugin("classStaticBlock", member.start);
  28680. this.scope.enter(SCOPE_CLASS | SCOPE_STATIC_BLOCK | SCOPE_SUPER);
  28681. const oldLabels = this.state.labels;
  28682. this.state.labels = [];
  28683. this.prodParam.enter(PARAM);
  28684. const body = member.body = [];
  28685. this.parseBlockOrModuleBlockBody(body, undefined, false, types$1.braceR);
  28686. this.prodParam.exit();
  28687. this.scope.exit();
  28688. this.state.labels = oldLabels;
  28689. classBody.body.push(this.finishNode(member, "StaticBlock"));
  28690. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  28691. this.raise(member.start, ErrorMessages.DecoratorStaticBlock);
  28692. }
  28693. }
  28694. pushClassProperty(classBody, prop) {
  28695. if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
  28696. this.raise(prop.key.start, ErrorMessages.ConstructorClassField);
  28697. }
  28698. classBody.body.push(this.parseClassProperty(prop));
  28699. }
  28700. pushClassPrivateProperty(classBody, prop) {
  28701. const node = this.parseClassPrivateProperty(prop);
  28702. classBody.body.push(node);
  28703. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.start);
  28704. }
  28705. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  28706. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  28707. }
  28708. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  28709. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  28710. classBody.body.push(node);
  28711. const kind = node.kind === "get" ? node.static ? CLASS_ELEMENT_STATIC_GETTER : CLASS_ELEMENT_INSTANCE_GETTER : node.kind === "set" ? node.static ? CLASS_ELEMENT_STATIC_SETTER : CLASS_ELEMENT_INSTANCE_SETTER : CLASS_ELEMENT_OTHER;
  28712. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.start);
  28713. }
  28714. parsePostMemberNameModifiers(methodOrProp) {}
  28715. parseClassPrivateProperty(node) {
  28716. this.parseInitializer(node);
  28717. this.semicolon();
  28718. return this.finishNode(node, "ClassPrivateProperty");
  28719. }
  28720. parseClassProperty(node) {
  28721. this.parseInitializer(node);
  28722. this.semicolon();
  28723. return this.finishNode(node, "ClassProperty");
  28724. }
  28725. parseInitializer(node) {
  28726. this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
  28727. this.expressionScope.enter(newExpressionScope());
  28728. this.prodParam.enter(PARAM);
  28729. node.value = this.eat(types$1.eq) ? this.parseMaybeAssignAllowIn() : null;
  28730. this.expressionScope.exit();
  28731. this.prodParam.exit();
  28732. this.scope.exit();
  28733. }
  28734. parseClassId(node, isStatement, optionalId, bindingType = BIND_CLASS) {
  28735. if (this.match(types$1.name)) {
  28736. node.id = this.parseIdentifier();
  28737. if (isStatement) {
  28738. this.checkLVal(node.id, "class name", bindingType);
  28739. }
  28740. } else {
  28741. if (optionalId || !isStatement) {
  28742. node.id = null;
  28743. } else {
  28744. this.unexpected(null, ErrorMessages.MissingClassName);
  28745. }
  28746. }
  28747. }
  28748. parseClassSuper(node) {
  28749. node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts() : null;
  28750. }
  28751. parseExport(node) {
  28752. const hasDefault = this.maybeParseExportDefaultSpecifier(node);
  28753. const parseAfterDefault = !hasDefault || this.eat(types$1.comma);
  28754. const hasStar = parseAfterDefault && this.eatExportStar(node);
  28755. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  28756. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(types$1.comma));
  28757. const isFromRequired = hasDefault || hasStar;
  28758. if (hasStar && !hasNamespace) {
  28759. if (hasDefault) this.unexpected();
  28760. this.parseExportFrom(node, true);
  28761. return this.finishNode(node, "ExportAllDeclaration");
  28762. }
  28763. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  28764. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers || hasNamespace && parseAfterNamespace && !hasSpecifiers) {
  28765. throw this.unexpected(null, types$1.braceL);
  28766. }
  28767. let hasDeclaration;
  28768. if (isFromRequired || hasSpecifiers) {
  28769. hasDeclaration = false;
  28770. this.parseExportFrom(node, isFromRequired);
  28771. } else {
  28772. hasDeclaration = this.maybeParseExportDeclaration(node);
  28773. }
  28774. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  28775. this.checkExport(node, true, false, !!node.source);
  28776. return this.finishNode(node, "ExportNamedDeclaration");
  28777. }
  28778. if (this.eat(types$1._default)) {
  28779. node.declaration = this.parseExportDefaultExpression();
  28780. this.checkExport(node, true, true);
  28781. return this.finishNode(node, "ExportDefaultDeclaration");
  28782. }
  28783. throw this.unexpected(null, types$1.braceL);
  28784. }
  28785. eatExportStar(node) {
  28786. return this.eat(types$1.star);
  28787. }
  28788. maybeParseExportDefaultSpecifier(node) {
  28789. if (this.isExportDefaultSpecifier()) {
  28790. this.expectPlugin("exportDefaultFrom");
  28791. const specifier = this.startNode();
  28792. specifier.exported = this.parseIdentifier(true);
  28793. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  28794. return true;
  28795. }
  28796. return false;
  28797. }
  28798. maybeParseExportNamespaceSpecifier(node) {
  28799. if (this.isContextual("as")) {
  28800. if (!node.specifiers) node.specifiers = [];
  28801. const specifier = this.startNodeAt(this.state.lastTokStart, this.state.lastTokStartLoc);
  28802. this.next();
  28803. specifier.exported = this.parseModuleExportName();
  28804. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  28805. return true;
  28806. }
  28807. return false;
  28808. }
  28809. maybeParseExportNamedSpecifiers(node) {
  28810. if (this.match(types$1.braceL)) {
  28811. if (!node.specifiers) node.specifiers = [];
  28812. node.specifiers.push(...this.parseExportSpecifiers());
  28813. node.source = null;
  28814. node.declaration = null;
  28815. return true;
  28816. }
  28817. return false;
  28818. }
  28819. maybeParseExportDeclaration(node) {
  28820. if (this.shouldParseExportDeclaration()) {
  28821. node.specifiers = [];
  28822. node.source = null;
  28823. node.declaration = this.parseExportDeclaration(node);
  28824. return true;
  28825. }
  28826. return false;
  28827. }
  28828. isAsyncFunction() {
  28829. if (!this.isContextual("async")) return false;
  28830. const next = this.nextTokenStart();
  28831. return !lineBreak.test(this.input.slice(this.state.pos, next)) && this.isUnparsedContextual(next, "function");
  28832. }
  28833. parseExportDefaultExpression() {
  28834. const expr = this.startNode();
  28835. const isAsync = this.isAsyncFunction();
  28836. if (this.match(types$1._function) || isAsync) {
  28837. this.next();
  28838. if (isAsync) {
  28839. this.next();
  28840. }
  28841. return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
  28842. } else if (this.match(types$1._class)) {
  28843. return this.parseClass(expr, true, true);
  28844. } else if (this.match(types$1.at)) {
  28845. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
  28846. this.raise(this.state.start, ErrorMessages.DecoratorBeforeExport);
  28847. }
  28848. this.parseDecorators(false);
  28849. return this.parseClass(expr, true, true);
  28850. } else if (this.match(types$1._const) || this.match(types$1._var) || this.isLet()) {
  28851. throw this.raise(this.state.start, ErrorMessages.UnsupportedDefaultExport);
  28852. } else {
  28853. const res = this.parseMaybeAssignAllowIn();
  28854. this.semicolon();
  28855. return res;
  28856. }
  28857. }
  28858. parseExportDeclaration(node) {
  28859. return this.parseStatement(null);
  28860. }
  28861. isExportDefaultSpecifier() {
  28862. if (this.match(types$1.name)) {
  28863. const value = this.state.value;
  28864. if (value === "async" && !this.state.containsEsc || value === "let") {
  28865. return false;
  28866. }
  28867. if ((value === "type" || value === "interface") && !this.state.containsEsc) {
  28868. const l = this.lookahead();
  28869. if (l.type === types$1.name && l.value !== "from" || l.type === types$1.braceL) {
  28870. this.expectOnePlugin(["flow", "typescript"]);
  28871. return false;
  28872. }
  28873. }
  28874. } else if (!this.match(types$1._default)) {
  28875. return false;
  28876. }
  28877. const next = this.nextTokenStart();
  28878. const hasFrom = this.isUnparsedContextual(next, "from");
  28879. if (this.input.charCodeAt(next) === 44 || this.match(types$1.name) && hasFrom) {
  28880. return true;
  28881. }
  28882. if (this.match(types$1._default) && hasFrom) {
  28883. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  28884. return nextAfterFrom === 34 || nextAfterFrom === 39;
  28885. }
  28886. return false;
  28887. }
  28888. parseExportFrom(node, expect) {
  28889. if (this.eatContextual("from")) {
  28890. node.source = this.parseImportSource();
  28891. this.checkExport(node);
  28892. const assertions = this.maybeParseImportAssertions();
  28893. if (assertions) {
  28894. node.assertions = assertions;
  28895. }
  28896. } else {
  28897. if (expect) {
  28898. this.unexpected();
  28899. } else {
  28900. node.source = null;
  28901. }
  28902. }
  28903. this.semicolon();
  28904. }
  28905. shouldParseExportDeclaration() {
  28906. if (this.match(types$1.at)) {
  28907. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  28908. if (this.hasPlugin("decorators")) {
  28909. if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
  28910. this.unexpected(this.state.start, ErrorMessages.DecoratorBeforeExport);
  28911. } else {
  28912. return true;
  28913. }
  28914. }
  28915. }
  28916. return this.state.type.keyword === "var" || this.state.type.keyword === "const" || this.state.type.keyword === "function" || this.state.type.keyword === "class" || this.isLet() || this.isAsyncFunction();
  28917. }
  28918. checkExport(node, checkNames, isDefault, isFrom) {
  28919. if (checkNames) {
  28920. if (isDefault) {
  28921. this.checkDuplicateExports(node, "default");
  28922. if (this.hasPlugin("exportDefaultFrom")) {
  28923. var _declaration$extra;
  28924. const declaration = node.declaration;
  28925. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  28926. this.raise(declaration.start, ErrorMessages.ExportDefaultFromAsIdentifier);
  28927. }
  28928. }
  28929. } else if (node.specifiers && node.specifiers.length) {
  28930. for (const specifier of node.specifiers) {
  28931. const {
  28932. exported
  28933. } = specifier;
  28934. const exportedName = exported.type === "Identifier" ? exported.name : exported.value;
  28935. this.checkDuplicateExports(specifier, exportedName);
  28936. if (!isFrom && specifier.local) {
  28937. const {
  28938. local
  28939. } = specifier;
  28940. if (local.type !== "Identifier") {
  28941. this.raise(specifier.start, ErrorMessages.ExportBindingIsString, local.value, exportedName);
  28942. } else {
  28943. this.checkReservedWord(local.name, local.start, true, false);
  28944. this.scope.checkLocalExport(local);
  28945. }
  28946. }
  28947. }
  28948. } else if (node.declaration) {
  28949. if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
  28950. const id = node.declaration.id;
  28951. if (!id) throw new Error("Assertion failure");
  28952. this.checkDuplicateExports(node, id.name);
  28953. } else if (node.declaration.type === "VariableDeclaration") {
  28954. for (const declaration of node.declaration.declarations) {
  28955. this.checkDeclaration(declaration.id);
  28956. }
  28957. }
  28958. }
  28959. }
  28960. const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
  28961. if (currentContextDecorators.length) {
  28962. throw this.raise(node.start, ErrorMessages.UnsupportedDecoratorExport);
  28963. }
  28964. }
  28965. checkDeclaration(node) {
  28966. if (node.type === "Identifier") {
  28967. this.checkDuplicateExports(node, node.name);
  28968. } else if (node.type === "ObjectPattern") {
  28969. for (const prop of node.properties) {
  28970. this.checkDeclaration(prop);
  28971. }
  28972. } else if (node.type === "ArrayPattern") {
  28973. for (const elem of node.elements) {
  28974. if (elem) {
  28975. this.checkDeclaration(elem);
  28976. }
  28977. }
  28978. } else if (node.type === "ObjectProperty") {
  28979. this.checkDeclaration(node.value);
  28980. } else if (node.type === "RestElement") {
  28981. this.checkDeclaration(node.argument);
  28982. } else if (node.type === "AssignmentPattern") {
  28983. this.checkDeclaration(node.left);
  28984. }
  28985. }
  28986. checkDuplicateExports(node, name) {
  28987. if (this.exportedIdentifiers.has(name)) {
  28988. this.raise(node.start, name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, name);
  28989. }
  28990. this.exportedIdentifiers.add(name);
  28991. }
  28992. parseExportSpecifiers() {
  28993. const nodes = [];
  28994. let first = true;
  28995. this.expect(types$1.braceL);
  28996. while (!this.eat(types$1.braceR)) {
  28997. if (first) {
  28998. first = false;
  28999. } else {
  29000. this.expect(types$1.comma);
  29001. if (this.eat(types$1.braceR)) break;
  29002. }
  29003. const node = this.startNode();
  29004. const isString = this.match(types$1.string);
  29005. const local = this.parseModuleExportName();
  29006. node.local = local;
  29007. if (this.eatContextual("as")) {
  29008. node.exported = this.parseModuleExportName();
  29009. } else if (isString) {
  29010. node.exported = cloneStringLiteral(local);
  29011. } else {
  29012. node.exported = cloneIdentifier(local);
  29013. }
  29014. nodes.push(this.finishNode(node, "ExportSpecifier"));
  29015. }
  29016. return nodes;
  29017. }
  29018. parseModuleExportName() {
  29019. if (this.match(types$1.string)) {
  29020. const result = this.parseStringLiteral(this.state.value);
  29021. const surrogate = result.value.match(loneSurrogate);
  29022. if (surrogate) {
  29023. this.raise(result.start, ErrorMessages.ModuleExportNameHasLoneSurrogate, surrogate[0].charCodeAt(0).toString(16));
  29024. }
  29025. return result;
  29026. }
  29027. return this.parseIdentifier(true);
  29028. }
  29029. parseImport(node) {
  29030. node.specifiers = [];
  29031. if (!this.match(types$1.string)) {
  29032. const hasDefault = this.maybeParseDefaultImportSpecifier(node);
  29033. const parseNext = !hasDefault || this.eat(types$1.comma);
  29034. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  29035. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  29036. this.expectContextual("from");
  29037. }
  29038. node.source = this.parseImportSource();
  29039. const assertions = this.maybeParseImportAssertions();
  29040. if (assertions) {
  29041. node.assertions = assertions;
  29042. } else {
  29043. const attributes = this.maybeParseModuleAttributes();
  29044. if (attributes) {
  29045. node.attributes = attributes;
  29046. }
  29047. }
  29048. this.semicolon();
  29049. return this.finishNode(node, "ImportDeclaration");
  29050. }
  29051. parseImportSource() {
  29052. if (!this.match(types$1.string)) this.unexpected();
  29053. return this.parseExprAtom();
  29054. }
  29055. shouldParseDefaultImport(node) {
  29056. return this.match(types$1.name);
  29057. }
  29058. parseImportSpecifierLocal(node, specifier, type, contextDescription) {
  29059. specifier.local = this.parseIdentifier();
  29060. this.checkLVal(specifier.local, contextDescription, BIND_LEXICAL);
  29061. node.specifiers.push(this.finishNode(specifier, type));
  29062. }
  29063. parseAssertEntries() {
  29064. const attrs = [];
  29065. const attrNames = new Set();
  29066. do {
  29067. if (this.match(types$1.braceR)) {
  29068. break;
  29069. }
  29070. const node = this.startNode();
  29071. const keyName = this.state.value;
  29072. if (attrNames.has(keyName)) {
  29073. this.raise(this.state.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, keyName);
  29074. }
  29075. attrNames.add(keyName);
  29076. if (this.match(types$1.string)) {
  29077. node.key = this.parseStringLiteral(keyName);
  29078. } else {
  29079. node.key = this.parseIdentifier(true);
  29080. }
  29081. this.expect(types$1.colon);
  29082. if (!this.match(types$1.string)) {
  29083. throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
  29084. }
  29085. node.value = this.parseStringLiteral(this.state.value);
  29086. this.finishNode(node, "ImportAttribute");
  29087. attrs.push(node);
  29088. } while (this.eat(types$1.comma));
  29089. return attrs;
  29090. }
  29091. maybeParseModuleAttributes() {
  29092. if (this.match(types$1._with) && !this.hasPrecedingLineBreak()) {
  29093. this.expectPlugin("moduleAttributes");
  29094. this.next();
  29095. } else {
  29096. if (this.hasPlugin("moduleAttributes")) return [];
  29097. return null;
  29098. }
  29099. const attrs = [];
  29100. const attributes = new Set();
  29101. do {
  29102. const node = this.startNode();
  29103. node.key = this.parseIdentifier(true);
  29104. if (node.key.name !== "type") {
  29105. this.raise(node.key.start, ErrorMessages.ModuleAttributeDifferentFromType, node.key.name);
  29106. }
  29107. if (attributes.has(node.key.name)) {
  29108. this.raise(node.key.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, node.key.name);
  29109. }
  29110. attributes.add(node.key.name);
  29111. this.expect(types$1.colon);
  29112. if (!this.match(types$1.string)) {
  29113. throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
  29114. }
  29115. node.value = this.parseStringLiteral(this.state.value);
  29116. this.finishNode(node, "ImportAttribute");
  29117. attrs.push(node);
  29118. } while (this.eat(types$1.comma));
  29119. return attrs;
  29120. }
  29121. maybeParseImportAssertions() {
  29122. if (this.isContextual("assert") && !this.hasPrecedingLineBreak()) {
  29123. this.expectPlugin("importAssertions");
  29124. this.next();
  29125. } else {
  29126. if (this.hasPlugin("importAssertions")) return [];
  29127. return null;
  29128. }
  29129. this.eat(types$1.braceL);
  29130. const attrs = this.parseAssertEntries();
  29131. this.eat(types$1.braceR);
  29132. return attrs;
  29133. }
  29134. maybeParseDefaultImportSpecifier(node) {
  29135. if (this.shouldParseDefaultImport(node)) {
  29136. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier", "default import specifier");
  29137. return true;
  29138. }
  29139. return false;
  29140. }
  29141. maybeParseStarImportSpecifier(node) {
  29142. if (this.match(types$1.star)) {
  29143. const specifier = this.startNode();
  29144. this.next();
  29145. this.expectContextual("as");
  29146. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier", "import namespace specifier");
  29147. return true;
  29148. }
  29149. return false;
  29150. }
  29151. parseNamedImportSpecifiers(node) {
  29152. let first = true;
  29153. this.expect(types$1.braceL);
  29154. while (!this.eat(types$1.braceR)) {
  29155. if (first) {
  29156. first = false;
  29157. } else {
  29158. if (this.eat(types$1.colon)) {
  29159. throw this.raise(this.state.start, ErrorMessages.DestructureNamedImport);
  29160. }
  29161. this.expect(types$1.comma);
  29162. if (this.eat(types$1.braceR)) break;
  29163. }
  29164. this.parseImportSpecifier(node);
  29165. }
  29166. }
  29167. parseImportSpecifier(node) {
  29168. const specifier = this.startNode();
  29169. const importedIsString = this.match(types$1.string);
  29170. specifier.imported = this.parseModuleExportName();
  29171. if (this.eatContextual("as")) {
  29172. specifier.local = this.parseIdentifier();
  29173. } else {
  29174. const {
  29175. imported
  29176. } = specifier;
  29177. if (importedIsString) {
  29178. throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, imported.value);
  29179. }
  29180. this.checkReservedWord(imported.name, specifier.start, true, true);
  29181. specifier.local = cloneIdentifier(imported);
  29182. }
  29183. this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
  29184. node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
  29185. }
  29186. isThisParam(param) {
  29187. return param.type === "Identifier" && param.name === "this";
  29188. }
  29189. }
  29190. class Parser extends StatementParser {
  29191. constructor(options, input) {
  29192. options = getOptions(options);
  29193. super(options, input);
  29194. this.options = options;
  29195. this.initializeScopes();
  29196. this.plugins = pluginsMap(this.options.plugins);
  29197. this.filename = options.sourceFilename;
  29198. }
  29199. getScopeHandler() {
  29200. return ScopeHandler;
  29201. }
  29202. parse() {
  29203. this.enterInitialScopes();
  29204. const file = this.startNode();
  29205. const program = this.startNode();
  29206. this.nextToken();
  29207. file.errors = null;
  29208. this.parseTopLevel(file, program);
  29209. file.errors = this.state.errors;
  29210. return file;
  29211. }
  29212. }
  29213. function pluginsMap(plugins) {
  29214. const pluginMap = new Map();
  29215. for (const plugin of plugins) {
  29216. const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
  29217. if (!pluginMap.has(name)) pluginMap.set(name, options || {});
  29218. }
  29219. return pluginMap;
  29220. }
  29221. function parse(input, options) {
  29222. var _options;
  29223. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  29224. options = Object.assign({}, options);
  29225. try {
  29226. options.sourceType = "module";
  29227. const parser = getParser(options, input);
  29228. const ast = parser.parse();
  29229. if (parser.sawUnambiguousESM) {
  29230. return ast;
  29231. }
  29232. if (parser.ambiguousScriptDifferentAst) {
  29233. try {
  29234. options.sourceType = "script";
  29235. return getParser(options, input).parse();
  29236. } catch (_unused) {}
  29237. } else {
  29238. ast.program.sourceType = "script";
  29239. }
  29240. return ast;
  29241. } catch (moduleError) {
  29242. try {
  29243. options.sourceType = "script";
  29244. return getParser(options, input).parse();
  29245. } catch (_unused2) {}
  29246. throw moduleError;
  29247. }
  29248. } else {
  29249. return getParser(options, input).parse();
  29250. }
  29251. }
  29252. function parseExpression(input, options) {
  29253. const parser = getParser(options, input);
  29254. if (parser.options.strictMode) {
  29255. parser.state.strict = true;
  29256. }
  29257. return parser.getExpression();
  29258. }
  29259. function getParser(options, input) {
  29260. let cls = Parser;
  29261. if (options != null && options.plugins) {
  29262. validatePlugins(options.plugins);
  29263. cls = getParserClass(options.plugins);
  29264. }
  29265. return new cls(options, input);
  29266. }
  29267. const parserClassCache = {};
  29268. function getParserClass(pluginsFromOptions) {
  29269. const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name));
  29270. const key = pluginList.join("/");
  29271. let cls = parserClassCache[key];
  29272. if (!cls) {
  29273. cls = Parser;
  29274. for (const plugin of pluginList) {
  29275. cls = mixinPlugins[plugin](cls);
  29276. }
  29277. parserClassCache[key] = cls;
  29278. }
  29279. return cls;
  29280. }
  29281. var parse_1 = parse;
  29282. var parseExpression_1 = parseExpression;
  29283. var tokTypes = types$1;
  29284. //# sourceMappingURL=index.js.map
  29285. /*#__PURE__*/Object.defineProperty({
  29286. parse: parse_1,
  29287. parseExpression: parseExpression_1,
  29288. tokTypes: tokTypes
  29289. }, '__esModule', {value: true});
  29290. const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this');
  29291. const transformExpression = (node, context) => {
  29292. if (node.type === 5 /* INTERPOLATION */) {
  29293. node.content = processExpression(node.content, context);
  29294. }
  29295. else if (node.type === 1 /* ELEMENT */) {
  29296. // handle directives on element
  29297. for (let i = 0; i < node.props.length; i++) {
  29298. const dir = node.props[i];
  29299. // do not process for v-on & v-for since they are special handled
  29300. if (dir.type === 7 /* DIRECTIVE */ && dir.name !== 'for') {
  29301. const exp = dir.exp;
  29302. const arg = dir.arg;
  29303. // do not process exp if this is v-on:arg - we need special handling
  29304. // for wrapping inline statements.
  29305. if (exp &&
  29306. exp.type === 4 /* SIMPLE_EXPRESSION */ &&
  29307. !(dir.name === 'on' && arg)) {
  29308. dir.exp = processExpression(exp, context,
  29309. // slot args must be processed as function params
  29310. dir.name === 'slot');
  29311. }
  29312. if (arg && arg.type === 4 /* SIMPLE_EXPRESSION */ && !arg.isStatic) {
  29313. dir.arg = processExpression(arg, context);
  29314. }
  29315. }
  29316. }
  29317. }
  29318. };
  29319. // Important: since this function uses Node.js only dependencies, it should
  29320. // always be used with a leading !false check so that it can be
  29321. // tree-shaken from the browser build.
  29322. function processExpression(node, context,
  29323. // some expressions like v-slot props & v-for aliases should be parsed as
  29324. // function params
  29325. asParams = false,
  29326. // v-on handler values may contain multiple statements
  29327. asRawStatements = false) {
  29328. if (!context.prefixIdentifiers || !node.content.trim()) {
  29329. return node;
  29330. }
  29331. const { inline, bindingMetadata } = context;
  29332. const rewriteIdentifier = (raw, parent, id) => {
  29333. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  29334. if (inline) {
  29335. // x = y
  29336. const isAssignmentLVal = parent && parent.type === 'AssignmentExpression' && parent.left === id;
  29337. // x++
  29338. const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
  29339. // ({ x } = y)
  29340. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  29341. if (type === "setup-const" /* SETUP_CONST */) {
  29342. return raw;
  29343. }
  29344. else if (type === "setup-ref" /* SETUP_REF */) {
  29345. return `${raw}.value`;
  29346. }
  29347. else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
  29348. // const binding that may or may not be ref
  29349. // if it's not a ref, then assignments don't make sense -
  29350. // so we ignore the non-ref assignment case and generate code
  29351. // that assumes the value to be a ref for more efficiency
  29352. return isAssignmentLVal || isUpdateArg || isDestructureAssignment
  29353. ? `${raw}.value`
  29354. : `${context.helperString(UNREF)}(${raw})`;
  29355. }
  29356. else if (type === "setup-let" /* SETUP_LET */) {
  29357. if (isAssignmentLVal) {
  29358. // let binding.
  29359. // this is a bit more tricky as we need to cover the case where
  29360. // let is a local non-ref value, and we need to replicate the
  29361. // right hand side value.
  29362. // x = y --> isRef(x) ? x.value = y : x = y
  29363. const { right: rVal, operator } = parent;
  29364. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  29365. const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context));
  29366. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  29367. }
  29368. else if (isUpdateArg) {
  29369. // make id replace parent in the code range so the raw update operator
  29370. // is removed
  29371. id.start = parent.start;
  29372. id.end = parent.end;
  29373. const { prefix: isPrefix, operator } = parent;
  29374. const prefix = isPrefix ? operator : ``;
  29375. const postfix = isPrefix ? `` : operator;
  29376. // let binding.
  29377. // x++ --> isRef(a) ? a.value++ : a++
  29378. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  29379. }
  29380. else if (isDestructureAssignment) {
  29381. // TODO
  29382. // let binding in a destructure assignment - it's very tricky to
  29383. // handle both possible cases here without altering the original
  29384. // structure of the code, so we just assume it's not a ref here
  29385. // for now
  29386. return raw;
  29387. }
  29388. else {
  29389. return `${context.helperString(UNREF)}(${raw})`;
  29390. }
  29391. }
  29392. else if (type === "props" /* PROPS */) {
  29393. // use __props which is generated by compileScript so in ts mode
  29394. // it gets correct type
  29395. return `__props.${raw}`;
  29396. }
  29397. }
  29398. else {
  29399. if (type && type.startsWith('setup')) {
  29400. // setup bindings in non-inline mode
  29401. return `$setup.${raw}`;
  29402. }
  29403. else if (type) {
  29404. return `$${type}.${raw}`;
  29405. }
  29406. }
  29407. // fallback to ctx
  29408. return `_ctx.${raw}`;
  29409. };
  29410. // fast path if expression is a simple identifier.
  29411. const rawExp = node.content;
  29412. // bail constant on parens (function invocation) and dot (member access)
  29413. const bailConstant = rawExp.indexOf(`(`) > -1 || rawExp.indexOf('.') > 0;
  29414. if (isSimpleIdentifier(rawExp)) {
  29415. const isScopeVarReference = context.identifiers[rawExp];
  29416. const isAllowedGlobal = isGloballyWhitelisted(rawExp);
  29417. const isLiteral = isLiteralWhitelisted(rawExp);
  29418. if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
  29419. // const bindings exposed from setup can be skipped for patching but
  29420. // cannot be hoisted to module scope
  29421. if (bindingMetadata[node.content] === "setup-const" /* SETUP_CONST */) {
  29422. node.constType = 1 /* CAN_SKIP_PATCH */;
  29423. }
  29424. node.content = rewriteIdentifier(rawExp);
  29425. }
  29426. else if (!isScopeVarReference) {
  29427. if (isLiteral) {
  29428. node.constType = 3 /* CAN_STRINGIFY */;
  29429. }
  29430. else {
  29431. node.constType = 2 /* CAN_HOIST */;
  29432. }
  29433. }
  29434. return node;
  29435. }
  29436. let ast;
  29437. // exp needs to be parsed differently:
  29438. // 1. Multiple inline statements (v-on, with presence of `;`): parse as raw
  29439. // exp, but make sure to pad with spaces for consistent ranges
  29440. // 2. Expressions: wrap with parens (for e.g. object expressions)
  29441. // 3. Function arguments (v-for, v-slot): place in a function argument position
  29442. const source = asRawStatements
  29443. ? ` ${rawExp} `
  29444. : `(${rawExp})${asParams ? `=>{}` : ``}`;
  29445. try {
  29446. ast = parse_1(source, {
  29447. plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
  29448. }).program;
  29449. }
  29450. catch (e) {
  29451. context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
  29452. return node;
  29453. }
  29454. const ids = [];
  29455. const parentStack = [];
  29456. const knownIds = Object.create(context.identifiers);
  29457. walkIdentifiers(ast, (node, parent, _, isReferenced, isLocal) => {
  29458. if (isStaticPropertyKey(node, parent)) {
  29459. return;
  29460. }
  29461. const needPrefix = isReferenced && canPrefix(node);
  29462. if (needPrefix && !isLocal) {
  29463. if (isStaticProperty(parent) && parent.shorthand) {
  29464. node.prefix = `${node.name}: `;
  29465. }
  29466. node.name = rewriteIdentifier(node.name, parent, node);
  29467. ids.push(node);
  29468. }
  29469. else {
  29470. // The identifier is considered constant unless it's pointing to a
  29471. // local scope variable (a v-for alias, or a v-slot prop)
  29472. if (!(needPrefix && isLocal) && !bailConstant) {
  29473. node.isConstant = true;
  29474. }
  29475. // also generate sub-expressions for other identifiers for better
  29476. // source map support. (except for property keys which are static)
  29477. ids.push(node);
  29478. }
  29479. }, true, // invoke on ALL identifiers
  29480. parentStack, knownIds);
  29481. // We break up the compound expression into an array of strings and sub
  29482. // expressions (for identifiers that have been prefixed). In codegen, if
  29483. // an ExpressionNode has the `.children` property, it will be used instead of
  29484. // `.content`.
  29485. const children = [];
  29486. ids.sort((a, b) => a.start - b.start);
  29487. ids.forEach((id, i) => {
  29488. // range is offset by -1 due to the wrapping parens when parsed
  29489. const start = id.start - 1;
  29490. const end = id.end - 1;
  29491. const last = ids[i - 1];
  29492. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  29493. if (leadingText.length || id.prefix) {
  29494. children.push(leadingText + (id.prefix || ``));
  29495. }
  29496. const source = rawExp.slice(start, end);
  29497. children.push(createSimpleExpression(id.name, false, {
  29498. source,
  29499. start: advancePositionWithClone(node.loc.start, source, start),
  29500. end: advancePositionWithClone(node.loc.start, source, end)
  29501. }, id.isConstant ? 3 /* CAN_STRINGIFY */ : 0 /* NOT_CONSTANT */));
  29502. if (i === ids.length - 1 && end < rawExp.length) {
  29503. children.push(rawExp.slice(end));
  29504. }
  29505. });
  29506. let ret;
  29507. if (children.length) {
  29508. ret = createCompoundExpression(children, node.loc);
  29509. }
  29510. else {
  29511. ret = node;
  29512. ret.constType = bailConstant
  29513. ? 0 /* NOT_CONSTANT */
  29514. : 3 /* CAN_STRINGIFY */;
  29515. }
  29516. ret.identifiers = Object.keys(knownIds);
  29517. return ret;
  29518. }
  29519. function canPrefix(id) {
  29520. // skip whitelisted globals
  29521. if (isGloballyWhitelisted(id.name)) {
  29522. return false;
  29523. }
  29524. // special case for webpack compilation
  29525. if (id.name === 'require') {
  29526. return false;
  29527. }
  29528. return true;
  29529. }
  29530. function stringifyExpression(exp) {
  29531. if (isString(exp)) {
  29532. return exp;
  29533. }
  29534. else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
  29535. return exp.content;
  29536. }
  29537. else {
  29538. return exp.children
  29539. .map(stringifyExpression)
  29540. .join('');
  29541. }
  29542. }
  29543. const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (node, dir, context) => {
  29544. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  29545. // #1587: We need to dynamically increment the key based on the current
  29546. // node's sibling nodes, since chained v-if/else branches are
  29547. // rendered at the same depth
  29548. const siblings = context.parent.children;
  29549. let i = siblings.indexOf(ifNode);
  29550. let key = 0;
  29551. while (i-- >= 0) {
  29552. const sibling = siblings[i];
  29553. if (sibling && sibling.type === 9 /* IF */) {
  29554. key += sibling.branches.length;
  29555. }
  29556. }
  29557. // Exit callback. Complete the codegenNode when all children have been
  29558. // transformed.
  29559. return () => {
  29560. if (isRoot) {
  29561. ifNode.codegenNode = createCodegenNodeForBranch(branch, key, context);
  29562. }
  29563. else {
  29564. // attach this branch's codegen node to the v-if root.
  29565. const parentCondition = getParentCondition(ifNode.codegenNode);
  29566. parentCondition.alternate = createCodegenNodeForBranch(branch, key + ifNode.branches.length - 1, context);
  29567. }
  29568. };
  29569. });
  29570. });
  29571. // target-agnostic transform used for both Client and SSR
  29572. function processIf(node, dir, context, processCodegen) {
  29573. if (dir.name !== 'else' &&
  29574. (!dir.exp || !dir.exp.content.trim())) {
  29575. const loc = dir.exp ? dir.exp.loc : node.loc;
  29576. context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
  29577. dir.exp = createSimpleExpression(`true`, false, loc);
  29578. }
  29579. if (context.prefixIdentifiers && dir.exp) {
  29580. // dir.exp can only be simple expression because vIf transform is applied
  29581. // before expression transform.
  29582. dir.exp = processExpression(dir.exp, context);
  29583. }
  29584. if (dir.name === 'if') {
  29585. const branch = createIfBranch(node, dir);
  29586. const ifNode = {
  29587. type: 9 /* IF */,
  29588. loc: node.loc,
  29589. branches: [branch]
  29590. };
  29591. context.replaceNode(ifNode);
  29592. if (processCodegen) {
  29593. return processCodegen(ifNode, branch, true);
  29594. }
  29595. }
  29596. else {
  29597. // locate the adjacent v-if
  29598. const siblings = context.parent.children;
  29599. const comments = [];
  29600. let i = siblings.indexOf(node);
  29601. while (i-- >= -1) {
  29602. const sibling = siblings[i];
  29603. if (sibling && sibling.type === 3 /* COMMENT */) {
  29604. context.removeNode(sibling);
  29605. comments.unshift(sibling);
  29606. continue;
  29607. }
  29608. if (sibling &&
  29609. sibling.type === 2 /* TEXT */ &&
  29610. !sibling.content.trim().length) {
  29611. context.removeNode(sibling);
  29612. continue;
  29613. }
  29614. if (sibling && sibling.type === 9 /* IF */) {
  29615. // move the node to the if node's branches
  29616. context.removeNode();
  29617. const branch = createIfBranch(node, dir);
  29618. if (comments.length &&
  29619. // #3619 ignore comments if the v-if is direct child of <transition>
  29620. !(context.parent &&
  29621. context.parent.type === 1 /* ELEMENT */ &&
  29622. isBuiltInType(context.parent.tag, 'transition'))) {
  29623. branch.children = [...comments, ...branch.children];
  29624. }
  29625. // check if user is forcing same key on different branches
  29626. {
  29627. const key = branch.userKey;
  29628. if (key) {
  29629. sibling.branches.forEach(({ userKey }) => {
  29630. if (isSameKey(userKey, key)) {
  29631. context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
  29632. }
  29633. });
  29634. }
  29635. }
  29636. sibling.branches.push(branch);
  29637. const onExit = processCodegen && processCodegen(sibling, branch, false);
  29638. // since the branch was removed, it will not be traversed.
  29639. // make sure to traverse here.
  29640. traverseNode(branch, context);
  29641. // call on exit
  29642. if (onExit)
  29643. onExit();
  29644. // make sure to reset currentNode after traversal to indicate this
  29645. // node has been removed.
  29646. context.currentNode = null;
  29647. }
  29648. else {
  29649. context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
  29650. }
  29651. break;
  29652. }
  29653. }
  29654. }
  29655. function createIfBranch(node, dir) {
  29656. return {
  29657. type: 10 /* IF_BRANCH */,
  29658. loc: node.loc,
  29659. condition: dir.name === 'else' ? undefined : dir.exp,
  29660. children: node.tagType === 3 /* TEMPLATE */ && !findDir(node, 'for')
  29661. ? node.children
  29662. : [node],
  29663. userKey: findProp(node, `key`)
  29664. };
  29665. }
  29666. function createCodegenNodeForBranch(branch, keyIndex, context) {
  29667. if (branch.condition) {
  29668. return createConditionalExpression(branch.condition, createChildrenCodegenNode(branch, keyIndex, context),
  29669. // make sure to pass in asBlock: true so that the comment node call
  29670. // closes the current block.
  29671. createCallExpression(context.helper(CREATE_COMMENT), [
  29672. '"v-if"' ,
  29673. 'true'
  29674. ]));
  29675. }
  29676. else {
  29677. return createChildrenCodegenNode(branch, keyIndex, context);
  29678. }
  29679. }
  29680. function createChildrenCodegenNode(branch, keyIndex, context) {
  29681. const { helper } = context;
  29682. const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* CAN_HOIST */));
  29683. const { children } = branch;
  29684. const firstChild = children[0];
  29685. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* ELEMENT */;
  29686. if (needFragmentWrapper) {
  29687. if (children.length === 1 && firstChild.type === 11 /* FOR */) {
  29688. // optimize away nested fragments when child is a ForNode
  29689. const vnodeCall = firstChild.codegenNode;
  29690. injectProp(vnodeCall, keyProperty, context);
  29691. return vnodeCall;
  29692. }
  29693. else {
  29694. let patchFlag = 64 /* STABLE_FRAGMENT */;
  29695. let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
  29696. // check if the fragment actually contains a single valid child with
  29697. // the rest being comments
  29698. if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
  29699. patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
  29700. patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
  29701. }
  29702. return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false /* isComponent */, branch.loc);
  29703. }
  29704. }
  29705. else {
  29706. const ret = firstChild.codegenNode;
  29707. const vnodeCall = getMemoedVNodeCall(ret);
  29708. // Change createVNode to createBlock.
  29709. if (vnodeCall.type === 13 /* VNODE_CALL */) {
  29710. makeBlock(vnodeCall, context);
  29711. }
  29712. // inject branch key
  29713. injectProp(vnodeCall, keyProperty, context);
  29714. return ret;
  29715. }
  29716. }
  29717. function isSameKey(a, b) {
  29718. if (!a || a.type !== b.type) {
  29719. return false;
  29720. }
  29721. if (a.type === 6 /* ATTRIBUTE */) {
  29722. if (a.value.content !== b.value.content) {
  29723. return false;
  29724. }
  29725. }
  29726. else {
  29727. // directive
  29728. const exp = a.exp;
  29729. const branchExp = b.exp;
  29730. if (exp.type !== branchExp.type) {
  29731. return false;
  29732. }
  29733. if (exp.type !== 4 /* SIMPLE_EXPRESSION */ ||
  29734. exp.isStatic !== branchExp.isStatic ||
  29735. exp.content !== branchExp.content) {
  29736. return false;
  29737. }
  29738. }
  29739. return true;
  29740. }
  29741. function getParentCondition(node) {
  29742. while (true) {
  29743. if (node.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
  29744. if (node.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
  29745. node = node.alternate;
  29746. }
  29747. else {
  29748. return node;
  29749. }
  29750. }
  29751. else if (node.type === 20 /* JS_CACHE_EXPRESSION */) {
  29752. node = node.value;
  29753. }
  29754. }
  29755. }
  29756. const transformFor = createStructuralDirectiveTransform('for', (node, dir, context) => {
  29757. const { helper, removeHelper } = context;
  29758. return processFor(node, dir, context, forNode => {
  29759. // create the loop render function expression now, and add the
  29760. // iterator on exit after all children have been traversed
  29761. const renderExp = createCallExpression(helper(RENDER_LIST), [
  29762. forNode.source
  29763. ]);
  29764. const memo = findDir(node, 'memo');
  29765. const keyProp = findProp(node, `key`);
  29766. const keyExp = keyProp &&
  29767. (keyProp.type === 6 /* ATTRIBUTE */
  29768. ? createSimpleExpression(keyProp.value.content, true)
  29769. : keyProp.exp);
  29770. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  29771. if (context.prefixIdentifiers && keyProperty) {
  29772. // #2085 process :key expression needs to be processed in order for it
  29773. // to behave consistently for <template v-for> and <div v-for>.
  29774. // In the case of `<template v-for>`, the node is discarded and never
  29775. // traversed so its key expression won't be processed by the normal
  29776. // transforms.
  29777. keyProperty.value = processExpression(keyProperty.value, context);
  29778. }
  29779. const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
  29780. forNode.source.constType > 0 /* NOT_CONSTANT */;
  29781. const fragmentFlag = isStableFragment
  29782. ? 64 /* STABLE_FRAGMENT */
  29783. : keyProp
  29784. ? 128 /* KEYED_FRAGMENT */
  29785. : 256 /* UNKEYED_FRAGMENT */;
  29786. forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
  29787. (` /* ${PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true /* isBlock */, !isStableFragment /* disableTracking */, false /* isComponent */, node.loc);
  29788. return () => {
  29789. // finish the codegen now that all children have been traversed
  29790. let childBlock;
  29791. const isTemplate = isTemplateNode(node);
  29792. const { children } = forNode;
  29793. // check <template v-for> key placement
  29794. if (isTemplate) {
  29795. node.children.some(c => {
  29796. if (c.type === 1 /* ELEMENT */) {
  29797. const key = findProp(c, 'key');
  29798. if (key) {
  29799. context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
  29800. return true;
  29801. }
  29802. }
  29803. });
  29804. }
  29805. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* ELEMENT */;
  29806. const slotOutlet = isSlotOutlet(node)
  29807. ? node
  29808. : isTemplate &&
  29809. node.children.length === 1 &&
  29810. isSlotOutlet(node.children[0])
  29811. ? node.children[0] // api-extractor somehow fails to infer this
  29812. : null;
  29813. if (slotOutlet) {
  29814. // <slot v-for="..."> or <template v-for="..."><slot/></template>
  29815. childBlock = slotOutlet.codegenNode;
  29816. if (isTemplate && keyProperty) {
  29817. // <template v-for="..." :key="..."><slot/></template>
  29818. // we need to inject the key to the renderSlot() call.
  29819. // the props for renderSlot is passed as the 3rd argument.
  29820. injectProp(childBlock, keyProperty, context);
  29821. }
  29822. }
  29823. else if (needFragmentWrapper) {
  29824. // <template v-for="..."> with text or multi-elements
  29825. // should generate a fragment block for each loop
  29826. childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* STABLE_FRAGMENT */ +
  29827. (` /* ${PatchFlagNames[64 /* STABLE_FRAGMENT */]} */`
  29828. ), undefined, undefined, true, undefined, false /* isComponent */);
  29829. }
  29830. else {
  29831. // Normal element v-for. Directly use the child's codegenNode
  29832. // but mark it as a block.
  29833. childBlock = children[0]
  29834. .codegenNode;
  29835. if (isTemplate && keyProperty) {
  29836. injectProp(childBlock, keyProperty, context);
  29837. }
  29838. if (childBlock.isBlock !== !isStableFragment) {
  29839. if (childBlock.isBlock) {
  29840. // switch from block to vnode
  29841. removeHelper(OPEN_BLOCK);
  29842. removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  29843. }
  29844. else {
  29845. // switch from vnode to block
  29846. removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  29847. }
  29848. }
  29849. childBlock.isBlock = !isStableFragment;
  29850. if (childBlock.isBlock) {
  29851. helper(OPEN_BLOCK);
  29852. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  29853. }
  29854. else {
  29855. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  29856. }
  29857. }
  29858. if (memo) {
  29859. const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [
  29860. createSimpleExpression(`_cached`)
  29861. ]));
  29862. loop.body = createBlockStatement([
  29863. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  29864. createCompoundExpression([
  29865. `if (_cached`,
  29866. ...(keyExp ? [` && _cached.key === `, keyExp] : []),
  29867. ` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
  29868. ]),
  29869. createCompoundExpression([`const _item = `, childBlock]),
  29870. createSimpleExpression(`_item.memo = _memo`),
  29871. createSimpleExpression(`return _item`)
  29872. ]);
  29873. renderExp.arguments.push(loop, createSimpleExpression(`_cache`), createSimpleExpression(String(context.cached++)));
  29874. }
  29875. else {
  29876. renderExp.arguments.push(createFunctionExpression(createForLoopParams(forNode.parseResult), childBlock, true /* force newline */));
  29877. }
  29878. };
  29879. });
  29880. });
  29881. // target-agnostic transform used for both Client and SSR
  29882. function processFor(node, dir, context, processCodegen) {
  29883. if (!dir.exp) {
  29884. context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
  29885. return;
  29886. }
  29887. const parseResult = parseForExpression(
  29888. // can only be simple expression because vFor transform is applied
  29889. // before expression transform.
  29890. dir.exp, context);
  29891. if (!parseResult) {
  29892. context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
  29893. return;
  29894. }
  29895. const { addIdentifiers, removeIdentifiers, scopes } = context;
  29896. const { source, value, key, index } = parseResult;
  29897. const forNode = {
  29898. type: 11 /* FOR */,
  29899. loc: dir.loc,
  29900. source,
  29901. valueAlias: value,
  29902. keyAlias: key,
  29903. objectIndexAlias: index,
  29904. parseResult,
  29905. children: isTemplateNode(node) ? node.children : [node]
  29906. };
  29907. context.replaceNode(forNode);
  29908. // bookkeeping
  29909. scopes.vFor++;
  29910. if (context.prefixIdentifiers) {
  29911. // scope management
  29912. // inject identifiers to context
  29913. value && addIdentifiers(value);
  29914. key && addIdentifiers(key);
  29915. index && addIdentifiers(index);
  29916. }
  29917. const onExit = processCodegen && processCodegen(forNode);
  29918. return () => {
  29919. scopes.vFor--;
  29920. if (context.prefixIdentifiers) {
  29921. value && removeIdentifiers(value);
  29922. key && removeIdentifiers(key);
  29923. index && removeIdentifiers(index);
  29924. }
  29925. if (onExit)
  29926. onExit();
  29927. };
  29928. }
  29929. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  29930. // This regex doesn't cover the case if key or index aliases have destructuring,
  29931. // but those do not make sense in the first place, so this works in practice.
  29932. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  29933. const stripParensRE = /^\(|\)$/g;
  29934. function parseForExpression(input, context) {
  29935. const loc = input.loc;
  29936. const exp = input.content;
  29937. const inMatch = exp.match(forAliasRE);
  29938. if (!inMatch)
  29939. return;
  29940. const [, LHS, RHS] = inMatch;
  29941. const result = {
  29942. source: createAliasExpression(loc, RHS.trim(), exp.indexOf(RHS, LHS.length)),
  29943. value: undefined,
  29944. key: undefined,
  29945. index: undefined
  29946. };
  29947. if (context.prefixIdentifiers) {
  29948. result.source = processExpression(result.source, context);
  29949. }
  29950. let valueContent = LHS.trim().replace(stripParensRE, '').trim();
  29951. const trimmedOffset = LHS.indexOf(valueContent);
  29952. const iteratorMatch = valueContent.match(forIteratorRE);
  29953. if (iteratorMatch) {
  29954. valueContent = valueContent.replace(forIteratorRE, '').trim();
  29955. const keyContent = iteratorMatch[1].trim();
  29956. let keyOffset;
  29957. if (keyContent) {
  29958. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  29959. result.key = createAliasExpression(loc, keyContent, keyOffset);
  29960. if (context.prefixIdentifiers) {
  29961. result.key = processExpression(result.key, context, true);
  29962. }
  29963. }
  29964. if (iteratorMatch[2]) {
  29965. const indexContent = iteratorMatch[2].trim();
  29966. if (indexContent) {
  29967. result.index = createAliasExpression(loc, indexContent, exp.indexOf(indexContent, result.key
  29968. ? keyOffset + keyContent.length
  29969. : trimmedOffset + valueContent.length));
  29970. if (context.prefixIdentifiers) {
  29971. result.index = processExpression(result.index, context, true);
  29972. }
  29973. }
  29974. }
  29975. }
  29976. if (valueContent) {
  29977. result.value = createAliasExpression(loc, valueContent, trimmedOffset);
  29978. if (context.prefixIdentifiers) {
  29979. result.value = processExpression(result.value, context, true);
  29980. }
  29981. }
  29982. return result;
  29983. }
  29984. function createAliasExpression(range, content, offset) {
  29985. return createSimpleExpression(content, false, getInnerRange(range, offset, content.length));
  29986. }
  29987. function createForLoopParams({ value, key, index }, memoArgs = []) {
  29988. return createParamsList([value, key, index, ...memoArgs]);
  29989. }
  29990. function createParamsList(args) {
  29991. let i = args.length;
  29992. while (i--) {
  29993. if (args[i])
  29994. break;
  29995. }
  29996. return args
  29997. .slice(0, i + 1)
  29998. .map((arg, i) => arg || createSimpleExpression(`_`.repeat(i + 1), false));
  29999. }
  30000. const defaultFallback = createSimpleExpression(`undefined`, false);
  30001. // A NodeTransform that:
  30002. // 1. Tracks scope identifiers for scoped slots so that they don't get prefixed
  30003. // by transformExpression. This is only applied in non-browser builds with
  30004. // { prefixIdentifiers: true }.
  30005. // 2. Track v-slot depths so that we know a slot is inside another slot.
  30006. // Note the exit callback is executed before buildSlots() on the same node,
  30007. // so only nested slots see positive numbers.
  30008. const trackSlotScopes = (node, context) => {
  30009. if (node.type === 1 /* ELEMENT */ &&
  30010. (node.tagType === 1 /* COMPONENT */ ||
  30011. node.tagType === 3 /* TEMPLATE */)) {
  30012. // We are only checking non-empty v-slot here
  30013. // since we only care about slots that introduce scope variables.
  30014. const vSlot = findDir(node, 'slot');
  30015. if (vSlot) {
  30016. const slotProps = vSlot.exp;
  30017. if (context.prefixIdentifiers) {
  30018. slotProps && context.addIdentifiers(slotProps);
  30019. }
  30020. context.scopes.vSlot++;
  30021. return () => {
  30022. if (context.prefixIdentifiers) {
  30023. slotProps && context.removeIdentifiers(slotProps);
  30024. }
  30025. context.scopes.vSlot--;
  30026. };
  30027. }
  30028. }
  30029. };
  30030. // A NodeTransform that tracks scope identifiers for scoped slots with v-for.
  30031. // This transform is only applied in non-browser builds with { prefixIdentifiers: true }
  30032. const trackVForSlotScopes = (node, context) => {
  30033. let vFor;
  30034. if (isTemplateNode(node) &&
  30035. node.props.some(isVSlot) &&
  30036. (vFor = findDir(node, 'for'))) {
  30037. const result = (vFor.parseResult = parseForExpression(vFor.exp, context));
  30038. if (result) {
  30039. const { value, key, index } = result;
  30040. const { addIdentifiers, removeIdentifiers } = context;
  30041. value && addIdentifiers(value);
  30042. key && addIdentifiers(key);
  30043. index && addIdentifiers(index);
  30044. return () => {
  30045. value && removeIdentifiers(value);
  30046. key && removeIdentifiers(key);
  30047. index && removeIdentifiers(index);
  30048. };
  30049. }
  30050. }
  30051. };
  30052. const buildClientSlotFn = (props, children, loc) => createFunctionExpression(props, children, false /* newline */, true /* isSlot */, children.length ? children[0].loc : loc);
  30053. // Instead of being a DirectiveTransform, v-slot processing is called during
  30054. // transformElement to build the slots object for a component.
  30055. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  30056. context.helper(WITH_CTX);
  30057. const { children, loc } = node;
  30058. const slotsProperties = [];
  30059. const dynamicSlots = [];
  30060. // If the slot is inside a v-for or another v-slot, force it to be dynamic
  30061. // since it likely uses a scope variable.
  30062. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  30063. // with `prefixIdentifiers: true`, this can be further optimized to make
  30064. // it dynamic only when the slot actually uses the scope variables.
  30065. if (!context.ssr && context.prefixIdentifiers) {
  30066. hasDynamicSlots = hasScopeRef(node, context.identifiers);
  30067. }
  30068. // 1. Check for slot with slotProps on component itself.
  30069. // <Comp v-slot="{ prop }"/>
  30070. const onComponentSlot = findDir(node, 'slot', true);
  30071. if (onComponentSlot) {
  30072. const { arg, exp } = onComponentSlot;
  30073. if (arg && !isStaticExp(arg)) {
  30074. hasDynamicSlots = true;
  30075. }
  30076. slotsProperties.push(createObjectProperty(arg || createSimpleExpression('default', true), buildSlotFn(exp, children, loc)));
  30077. }
  30078. // 2. Iterate through children and check for template slots
  30079. // <template v-slot:foo="{ prop }">
  30080. let hasTemplateSlots = false;
  30081. let hasNamedDefaultSlot = false;
  30082. const implicitDefaultChildren = [];
  30083. const seenSlotNames = new Set();
  30084. for (let i = 0; i < children.length; i++) {
  30085. const slotElement = children[i];
  30086. let slotDir;
  30087. if (!isTemplateNode(slotElement) ||
  30088. !(slotDir = findDir(slotElement, 'slot', true))) {
  30089. // not a <template v-slot>, skip.
  30090. if (slotElement.type !== 3 /* COMMENT */) {
  30091. implicitDefaultChildren.push(slotElement);
  30092. }
  30093. continue;
  30094. }
  30095. if (onComponentSlot) {
  30096. // already has on-component slot - this is incorrect usage.
  30097. context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
  30098. break;
  30099. }
  30100. hasTemplateSlots = true;
  30101. const { children: slotChildren, loc: slotLoc } = slotElement;
  30102. const { arg: slotName = createSimpleExpression(`default`, true), exp: slotProps, loc: dirLoc } = slotDir;
  30103. // check if name is dynamic.
  30104. let staticSlotName;
  30105. if (isStaticExp(slotName)) {
  30106. staticSlotName = slotName ? slotName.content : `default`;
  30107. }
  30108. else {
  30109. hasDynamicSlots = true;
  30110. }
  30111. const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
  30112. // check if this slot is conditional (v-if/v-for)
  30113. let vIf;
  30114. let vElse;
  30115. let vFor;
  30116. if ((vIf = findDir(slotElement, 'if'))) {
  30117. hasDynamicSlots = true;
  30118. dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
  30119. }
  30120. else if ((vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))) {
  30121. // find adjacent v-if
  30122. let j = i;
  30123. let prev;
  30124. while (j--) {
  30125. prev = children[j];
  30126. if (prev.type !== 3 /* COMMENT */) {
  30127. break;
  30128. }
  30129. }
  30130. if (prev && isTemplateNode(prev) && findDir(prev, 'if')) {
  30131. // remove node
  30132. children.splice(i, 1);
  30133. i--;
  30134. // attach this slot to previous conditional
  30135. let conditional = dynamicSlots[dynamicSlots.length - 1];
  30136. while (conditional.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
  30137. conditional = conditional.alternate;
  30138. }
  30139. conditional.alternate = vElse.exp
  30140. ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
  30141. : buildDynamicSlot(slotName, slotFunction);
  30142. }
  30143. else {
  30144. context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
  30145. }
  30146. }
  30147. else if ((vFor = findDir(slotElement, 'for'))) {
  30148. hasDynamicSlots = true;
  30149. const parseResult = vFor.parseResult ||
  30150. parseForExpression(vFor.exp, context);
  30151. if (parseResult) {
  30152. // Render the dynamic slots as an array and add it to the createSlot()
  30153. // args. The runtime knows how to handle it appropriately.
  30154. dynamicSlots.push(createCallExpression(context.helper(RENDER_LIST), [
  30155. parseResult.source,
  30156. createFunctionExpression(createForLoopParams(parseResult), buildDynamicSlot(slotName, slotFunction), true /* force newline */)
  30157. ]));
  30158. }
  30159. else {
  30160. context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
  30161. }
  30162. }
  30163. else {
  30164. // check duplicate static names
  30165. if (staticSlotName) {
  30166. if (seenSlotNames.has(staticSlotName)) {
  30167. context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
  30168. continue;
  30169. }
  30170. seenSlotNames.add(staticSlotName);
  30171. if (staticSlotName === 'default') {
  30172. hasNamedDefaultSlot = true;
  30173. }
  30174. }
  30175. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  30176. }
  30177. }
  30178. if (!onComponentSlot) {
  30179. const buildDefaultSlotProperty = (props, children) => {
  30180. const fn = buildSlotFn(props, children, loc);
  30181. return createObjectProperty(`default`, fn);
  30182. };
  30183. if (!hasTemplateSlots) {
  30184. // implicit default slot (on component)
  30185. slotsProperties.push(buildDefaultSlotProperty(undefined, children));
  30186. }
  30187. else if (implicitDefaultChildren.length &&
  30188. // #3766
  30189. // with whitespace: 'preserve', whitespaces between slots will end up in
  30190. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  30191. implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
  30192. // implicit default slot (mixed with named slots)
  30193. if (hasNamedDefaultSlot) {
  30194. context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
  30195. }
  30196. else {
  30197. slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
  30198. }
  30199. }
  30200. }
  30201. const slotFlag = hasDynamicSlots
  30202. ? 2 /* DYNAMIC */
  30203. : hasForwardedSlots(node.children)
  30204. ? 3 /* FORWARDED */
  30205. : 1 /* STABLE */;
  30206. let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
  30207. // 2 = compiled but dynamic = can skip normalization, but must run diff
  30208. // 1 = compiled and static = can skip normalization AND diff as optimized
  30209. createSimpleExpression(slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ), false))), loc);
  30210. if (dynamicSlots.length) {
  30211. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  30212. slots,
  30213. createArrayExpression(dynamicSlots)
  30214. ]);
  30215. }
  30216. return {
  30217. slots,
  30218. hasDynamicSlots
  30219. };
  30220. }
  30221. function buildDynamicSlot(name, fn) {
  30222. return createObjectExpression([
  30223. createObjectProperty(`name`, name),
  30224. createObjectProperty(`fn`, fn)
  30225. ]);
  30226. }
  30227. function hasForwardedSlots(children) {
  30228. for (let i = 0; i < children.length; i++) {
  30229. const child = children[i];
  30230. switch (child.type) {
  30231. case 1 /* ELEMENT */:
  30232. if (child.tagType === 2 /* SLOT */ ||
  30233. hasForwardedSlots(child.children)) {
  30234. return true;
  30235. }
  30236. break;
  30237. case 9 /* IF */:
  30238. if (hasForwardedSlots(child.branches))
  30239. return true;
  30240. break;
  30241. case 10 /* IF_BRANCH */:
  30242. case 11 /* FOR */:
  30243. if (hasForwardedSlots(child.children))
  30244. return true;
  30245. break;
  30246. }
  30247. }
  30248. return false;
  30249. }
  30250. function isNonWhitespaceContent(node) {
  30251. if (node.type !== 2 /* TEXT */ && node.type !== 12 /* TEXT_CALL */)
  30252. return true;
  30253. return node.type === 2 /* TEXT */
  30254. ? !!node.content.trim()
  30255. : isNonWhitespaceContent(node.content);
  30256. }
  30257. // some directive transforms (e.g. v-model) may return a symbol for runtime
  30258. // import, which should be used instead of a resolveDirective call.
  30259. const directiveImportMap = new WeakMap();
  30260. // generate a JavaScript AST for this element's codegen
  30261. const transformElement = (node, context) => {
  30262. // perform the work on exit, after all child expressions have been
  30263. // processed and merged.
  30264. return function postTransformElement() {
  30265. node = context.currentNode;
  30266. if (!(node.type === 1 /* ELEMENT */ &&
  30267. (node.tagType === 0 /* ELEMENT */ ||
  30268. node.tagType === 1 /* COMPONENT */))) {
  30269. return;
  30270. }
  30271. const { tag, props } = node;
  30272. const isComponent = node.tagType === 1 /* COMPONENT */;
  30273. // The goal of the transform is to create a codegenNode implementing the
  30274. // VNodeCall interface.
  30275. let vnodeTag = isComponent
  30276. ? resolveComponentType(node, context)
  30277. : `"${tag}"`;
  30278. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  30279. let vnodeProps;
  30280. let vnodeChildren;
  30281. let vnodePatchFlag;
  30282. let patchFlag = 0;
  30283. let vnodeDynamicProps;
  30284. let dynamicPropNames;
  30285. let vnodeDirectives;
  30286. let shouldUseBlock =
  30287. // dynamic component may resolve to plain elements
  30288. isDynamicComponent ||
  30289. vnodeTag === TELEPORT ||
  30290. vnodeTag === SUSPENSE ||
  30291. (!isComponent &&
  30292. // <svg> and <foreignObject> must be forced into blocks so that block
  30293. // updates inside get proper isSVG flag at runtime. (#639, #643)
  30294. // This is technically web-specific, but splitting the logic out of core
  30295. // leads to too much unnecessary complexity.
  30296. (tag === 'svg' ||
  30297. tag === 'foreignObject' ||
  30298. // #938: elements with dynamic keys should be forced into blocks
  30299. findProp(node, 'key', true)));
  30300. // props
  30301. if (props.length > 0) {
  30302. const propsBuildResult = buildProps(node, context);
  30303. vnodeProps = propsBuildResult.props;
  30304. patchFlag = propsBuildResult.patchFlag;
  30305. dynamicPropNames = propsBuildResult.dynamicPropNames;
  30306. const directives = propsBuildResult.directives;
  30307. vnodeDirectives =
  30308. directives && directives.length
  30309. ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
  30310. : undefined;
  30311. }
  30312. // children
  30313. if (node.children.length > 0) {
  30314. if (vnodeTag === KEEP_ALIVE) {
  30315. // Although a built-in component, we compile KeepAlive with raw children
  30316. // instead of slot functions so that it can be used inside Transition
  30317. // or other Transition-wrapping HOCs.
  30318. // To ensure correct updates with block optimizations, we need to:
  30319. // 1. Force keep-alive into a block. This avoids its children being
  30320. // collected by a parent block.
  30321. shouldUseBlock = true;
  30322. // 2. Force keep-alive to always be updated, since it uses raw children.
  30323. patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  30324. if (node.children.length > 1) {
  30325. context.onError(createCompilerError(45 /* X_KEEP_ALIVE_INVALID_CHILDREN */, {
  30326. start: node.children[0].loc.start,
  30327. end: node.children[node.children.length - 1].loc.end,
  30328. source: ''
  30329. }));
  30330. }
  30331. }
  30332. const shouldBuildAsSlots = isComponent &&
  30333. // Teleport is not a real component and has dedicated runtime handling
  30334. vnodeTag !== TELEPORT &&
  30335. // explained above.
  30336. vnodeTag !== KEEP_ALIVE;
  30337. if (shouldBuildAsSlots) {
  30338. const { slots, hasDynamicSlots } = buildSlots(node, context);
  30339. vnodeChildren = slots;
  30340. if (hasDynamicSlots) {
  30341. patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  30342. }
  30343. }
  30344. else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  30345. const child = node.children[0];
  30346. const type = child.type;
  30347. // check for dynamic text children
  30348. const hasDynamicTextChild = type === 5 /* INTERPOLATION */ ||
  30349. type === 8 /* COMPOUND_EXPRESSION */;
  30350. if (hasDynamicTextChild &&
  30351. getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
  30352. patchFlag |= 1 /* TEXT */;
  30353. }
  30354. // pass directly if the only child is a text node
  30355. // (plain / interpolation / expression)
  30356. if (hasDynamicTextChild || type === 2 /* TEXT */) {
  30357. vnodeChildren = child;
  30358. }
  30359. else {
  30360. vnodeChildren = node.children;
  30361. }
  30362. }
  30363. else {
  30364. vnodeChildren = node.children;
  30365. }
  30366. }
  30367. // patchFlag & dynamicPropNames
  30368. if (patchFlag !== 0) {
  30369. {
  30370. if (patchFlag < 0) {
  30371. // special flags (negative and mutually exclusive)
  30372. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  30373. }
  30374. else {
  30375. // bitwise flags
  30376. const flagNames = Object.keys(PatchFlagNames)
  30377. .map(Number)
  30378. .filter(n => n > 0 && patchFlag & n)
  30379. .map(n => PatchFlagNames[n])
  30380. .join(`, `);
  30381. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  30382. }
  30383. }
  30384. if (dynamicPropNames && dynamicPropNames.length) {
  30385. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  30386. }
  30387. }
  30388. node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, vnodePatchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false /* disableTracking */, isComponent, node.loc);
  30389. };
  30390. };
  30391. function resolveComponentType(node, context, ssr = false) {
  30392. let { tag } = node;
  30393. // 1. dynamic component
  30394. const isExplicitDynamic = isComponentTag(tag);
  30395. const isProp = findProp(node, 'is');
  30396. if (isProp) {
  30397. if (isExplicitDynamic ||
  30398. (false )) {
  30399. const exp = isProp.type === 6 /* ATTRIBUTE */
  30400. ? isProp.value && createSimpleExpression(isProp.value.content, true)
  30401. : isProp.exp;
  30402. if (exp) {
  30403. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  30404. exp
  30405. ]);
  30406. }
  30407. }
  30408. else if (isProp.type === 6 /* ATTRIBUTE */ &&
  30409. isProp.value.content.startsWith('vue:')) {
  30410. // <button is="vue:xxx">
  30411. // if not <component>, only is value that starts with "vue:" will be
  30412. // treated as component by the parse phase and reach here, unless it's
  30413. // compat mode where all is values are considered components
  30414. tag = isProp.value.content.slice(4);
  30415. }
  30416. }
  30417. // 1.5 v-is (TODO: Deprecate)
  30418. const isDir = !isExplicitDynamic && findDir(node, 'is');
  30419. if (isDir && isDir.exp) {
  30420. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  30421. isDir.exp
  30422. ]);
  30423. }
  30424. // 2. built-in components (Teleport, Transition, KeepAlive, Suspense...)
  30425. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  30426. if (builtIn) {
  30427. // built-ins are simply fallthroughs / have special handling during ssr
  30428. // so we don't need to import their runtime equivalents
  30429. if (!ssr)
  30430. context.helper(builtIn);
  30431. return builtIn;
  30432. }
  30433. // 3. user component (from setup bindings)
  30434. // this is skipped in browser build since browser builds do not perform
  30435. // binding analysis.
  30436. {
  30437. const fromSetup = resolveSetupReference(tag, context);
  30438. if (fromSetup) {
  30439. return fromSetup;
  30440. }
  30441. const dotIndex = tag.indexOf('.');
  30442. if (dotIndex > 0) {
  30443. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  30444. if (ns) {
  30445. return ns + tag.slice(dotIndex);
  30446. }
  30447. }
  30448. }
  30449. // 4. Self referencing component (inferred from filename)
  30450. if (context.selfName &&
  30451. capitalize(camelize(tag)) === context.selfName) {
  30452. context.helper(RESOLVE_COMPONENT);
  30453. // codegen.ts has special check for __self postfix when generating
  30454. // component imports, which will pass additional `maybeSelfReference` flag
  30455. // to `resolveComponent`.
  30456. context.components.add(tag + `__self`);
  30457. return toValidAssetId(tag, `component`);
  30458. }
  30459. // 5. user component (resolve)
  30460. context.helper(RESOLVE_COMPONENT);
  30461. context.components.add(tag);
  30462. return toValidAssetId(tag, `component`);
  30463. }
  30464. function resolveSetupReference(name, context) {
  30465. const bindings = context.bindingMetadata;
  30466. if (!bindings || bindings.__isScriptSetup === false) {
  30467. return;
  30468. }
  30469. const camelName = camelize(name);
  30470. const PascalName = capitalize(camelName);
  30471. const checkType = (type) => {
  30472. if (bindings[name] === type) {
  30473. return name;
  30474. }
  30475. if (bindings[camelName] === type) {
  30476. return camelName;
  30477. }
  30478. if (bindings[PascalName] === type) {
  30479. return PascalName;
  30480. }
  30481. };
  30482. const fromConst = checkType("setup-const" /* SETUP_CONST */);
  30483. if (fromConst) {
  30484. return context.inline
  30485. ? // in inline mode, const setup bindings (e.g. imports) can be used as-is
  30486. fromConst
  30487. : `$setup[${JSON.stringify(fromConst)}]`;
  30488. }
  30489. const fromMaybeRef = checkType("setup-let" /* SETUP_LET */) ||
  30490. checkType("setup-ref" /* SETUP_REF */) ||
  30491. checkType("setup-maybe-ref" /* SETUP_MAYBE_REF */);
  30492. if (fromMaybeRef) {
  30493. return context.inline
  30494. ? // setup scope bindings that may be refs need to be unrefed
  30495. `${context.helperString(UNREF)}(${fromMaybeRef})`
  30496. : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  30497. }
  30498. }
  30499. function buildProps(node, context, props = node.props, ssr = false) {
  30500. const { tag, loc: elementLoc } = node;
  30501. const isComponent = node.tagType === 1 /* COMPONENT */;
  30502. let properties = [];
  30503. const mergeArgs = [];
  30504. const runtimeDirectives = [];
  30505. // patchFlag analysis
  30506. let patchFlag = 0;
  30507. let hasRef = false;
  30508. let hasClassBinding = false;
  30509. let hasStyleBinding = false;
  30510. let hasHydrationEventBinding = false;
  30511. let hasDynamicKeys = false;
  30512. let hasVnodeHook = false;
  30513. const dynamicPropNames = [];
  30514. const analyzePatchFlag = ({ key, value }) => {
  30515. if (isStaticExp(key)) {
  30516. const name = key.content;
  30517. const isEventHandler = isOn(name);
  30518. if (!isComponent &&
  30519. isEventHandler &&
  30520. // omit the flag for click handlers because hydration gives click
  30521. // dedicated fast path.
  30522. name.toLowerCase() !== 'onclick' &&
  30523. // omit v-model handlers
  30524. name !== 'onUpdate:modelValue' &&
  30525. // omit onVnodeXXX hooks
  30526. !isReservedProp(name)) {
  30527. hasHydrationEventBinding = true;
  30528. }
  30529. if (isEventHandler && isReservedProp(name)) {
  30530. hasVnodeHook = true;
  30531. }
  30532. if (value.type === 20 /* JS_CACHE_EXPRESSION */ ||
  30533. ((value.type === 4 /* SIMPLE_EXPRESSION */ ||
  30534. value.type === 8 /* COMPOUND_EXPRESSION */) &&
  30535. getConstantType(value, context) > 0)) {
  30536. // skip if the prop is a cached handler or has constant value
  30537. return;
  30538. }
  30539. if (name === 'ref') {
  30540. hasRef = true;
  30541. }
  30542. else if (name === 'class') {
  30543. hasClassBinding = true;
  30544. }
  30545. else if (name === 'style') {
  30546. hasStyleBinding = true;
  30547. }
  30548. else if (name !== 'key' && !dynamicPropNames.includes(name)) {
  30549. dynamicPropNames.push(name);
  30550. }
  30551. // treat the dynamic class and style binding of the component as dynamic props
  30552. if (isComponent &&
  30553. (name === 'class' || name === 'style') &&
  30554. !dynamicPropNames.includes(name)) {
  30555. dynamicPropNames.push(name);
  30556. }
  30557. }
  30558. else {
  30559. hasDynamicKeys = true;
  30560. }
  30561. };
  30562. for (let i = 0; i < props.length; i++) {
  30563. // static attribute
  30564. const prop = props[i];
  30565. if (prop.type === 6 /* ATTRIBUTE */) {
  30566. const { loc, name, value } = prop;
  30567. let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
  30568. if (name === 'ref') {
  30569. hasRef = true;
  30570. // in inline mode there is no setupState object, so we can't use string
  30571. // keys to set the ref. Instead, we need to transform it to pass the
  30572. // acrtual ref instead.
  30573. if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
  30574. valueNode = createFunctionExpression(['_value', '_refs']);
  30575. valueNode.body = createBlockStatement(processInlineRef(context.bindingMetadata, value.content));
  30576. }
  30577. }
  30578. // skip is on <component>, or is="vue:xxx"
  30579. if (name === 'is' &&
  30580. (isComponentTag(tag) ||
  30581. (value && value.content.startsWith('vue:')) ||
  30582. (false ))) {
  30583. continue;
  30584. }
  30585. properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
  30586. }
  30587. else {
  30588. // directives
  30589. const { name, arg, exp, loc } = prop;
  30590. const isVBind = name === 'bind';
  30591. const isVOn = name === 'on';
  30592. // skip v-slot - it is handled by its dedicated transform.
  30593. if (name === 'slot') {
  30594. if (!isComponent) {
  30595. context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
  30596. }
  30597. continue;
  30598. }
  30599. // skip v-once/v-memo - they are handled by dedicated transforms.
  30600. if (name === 'once' || name === 'memo') {
  30601. continue;
  30602. }
  30603. // skip v-is and :is on <component>
  30604. if (name === 'is' ||
  30605. (isVBind &&
  30606. isBindKey(arg, 'is') &&
  30607. (isComponentTag(tag) ||
  30608. (false )))) {
  30609. continue;
  30610. }
  30611. // skip v-on in SSR compilation
  30612. if (isVOn && ssr) {
  30613. continue;
  30614. }
  30615. // special case for v-bind and v-on with no argument
  30616. if (!arg && (isVBind || isVOn)) {
  30617. hasDynamicKeys = true;
  30618. if (exp) {
  30619. if (properties.length) {
  30620. mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
  30621. properties = [];
  30622. }
  30623. if (isVBind) {
  30624. mergeArgs.push(exp);
  30625. }
  30626. else {
  30627. // v-on="obj" -> toHandlers(obj)
  30628. mergeArgs.push({
  30629. type: 14 /* JS_CALL_EXPRESSION */,
  30630. loc,
  30631. callee: context.helper(TO_HANDLERS),
  30632. arguments: [exp]
  30633. });
  30634. }
  30635. }
  30636. else {
  30637. context.onError(createCompilerError(isVBind
  30638. ? 34 /* X_V_BIND_NO_EXPRESSION */
  30639. : 35 /* X_V_ON_NO_EXPRESSION */, loc));
  30640. }
  30641. continue;
  30642. }
  30643. const directiveTransform = context.directiveTransforms[name];
  30644. if (directiveTransform) {
  30645. // has built-in directive transform.
  30646. const { props, needRuntime } = directiveTransform(prop, node, context);
  30647. !ssr && props.forEach(analyzePatchFlag);
  30648. properties.push(...props);
  30649. if (needRuntime) {
  30650. runtimeDirectives.push(prop);
  30651. if (isSymbol(needRuntime)) {
  30652. directiveImportMap.set(prop, needRuntime);
  30653. }
  30654. }
  30655. }
  30656. else {
  30657. // no built-in transform, this is a user custom directive.
  30658. runtimeDirectives.push(prop);
  30659. }
  30660. }
  30661. }
  30662. let propsExpression = undefined;
  30663. // has v-bind="object" or v-on="object", wrap with mergeProps
  30664. if (mergeArgs.length) {
  30665. if (properties.length) {
  30666. mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
  30667. }
  30668. if (mergeArgs.length > 1) {
  30669. propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
  30670. }
  30671. else {
  30672. // single v-bind with nothing else - no need for a mergeProps call
  30673. propsExpression = mergeArgs[0];
  30674. }
  30675. }
  30676. else if (properties.length) {
  30677. propsExpression = createObjectExpression(dedupeProperties(properties), elementLoc);
  30678. }
  30679. // patchFlag analysis
  30680. if (hasDynamicKeys) {
  30681. patchFlag |= 16 /* FULL_PROPS */;
  30682. }
  30683. else {
  30684. if (hasClassBinding && !isComponent) {
  30685. patchFlag |= 2 /* CLASS */;
  30686. }
  30687. if (hasStyleBinding && !isComponent) {
  30688. patchFlag |= 4 /* STYLE */;
  30689. }
  30690. if (dynamicPropNames.length) {
  30691. patchFlag |= 8 /* PROPS */;
  30692. }
  30693. if (hasHydrationEventBinding) {
  30694. patchFlag |= 32 /* HYDRATE_EVENTS */;
  30695. }
  30696. }
  30697. if ((patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
  30698. (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  30699. patchFlag |= 512 /* NEED_PATCH */;
  30700. }
  30701. // pre-normalize props, SSR is skipped for now
  30702. if (!context.inSSR && propsExpression) {
  30703. switch (propsExpression.type) {
  30704. case 15 /* JS_OBJECT_EXPRESSION */:
  30705. // means that there is no v-bind,
  30706. // but still need to deal with dynamic key binding
  30707. let classKeyIndex = -1;
  30708. let styleKeyIndex = -1;
  30709. let hasDynamicKey = false;
  30710. for (let i = 0; i < propsExpression.properties.length; i++) {
  30711. const key = propsExpression.properties[i].key;
  30712. if (isStaticExp(key)) {
  30713. if (key.content === 'class') {
  30714. classKeyIndex = i;
  30715. }
  30716. else if (key.content === 'style') {
  30717. styleKeyIndex = i;
  30718. }
  30719. }
  30720. else if (!key.isHandlerKey) {
  30721. hasDynamicKey = true;
  30722. }
  30723. }
  30724. const classProp = propsExpression.properties[classKeyIndex];
  30725. const styleProp = propsExpression.properties[styleKeyIndex];
  30726. // no dynamic key
  30727. if (!hasDynamicKey) {
  30728. if (classProp && !isStaticExp(classProp.value)) {
  30729. classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
  30730. }
  30731. if (styleProp &&
  30732. !isStaticExp(styleProp.value) &&
  30733. // the static style is compiled into an object,
  30734. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  30735. (hasStyleBinding ||
  30736. // v-bind:style and style both exist,
  30737. // v-bind:style with static literal object
  30738. styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
  30739. styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
  30740. }
  30741. }
  30742. else {
  30743. // dynamic key binding, wrap with `normalizeProps`
  30744. propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
  30745. }
  30746. break;
  30747. case 14 /* JS_CALL_EXPRESSION */:
  30748. // mergeProps call, do nothing
  30749. break;
  30750. default:
  30751. // single v-bind
  30752. propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [
  30753. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  30754. propsExpression
  30755. ])
  30756. ]);
  30757. break;
  30758. }
  30759. }
  30760. return {
  30761. props: propsExpression,
  30762. directives: runtimeDirectives,
  30763. patchFlag,
  30764. dynamicPropNames
  30765. };
  30766. }
  30767. // Dedupe props in an object literal.
  30768. // Literal duplicated attributes would have been warned during the parse phase,
  30769. // however, it's possible to encounter duplicated `onXXX` handlers with different
  30770. // modifiers. We also need to merge static and dynamic class / style attributes.
  30771. // - onXXX handlers / style: merge into array
  30772. // - class: merge into single expression with concatenation
  30773. function dedupeProperties(properties) {
  30774. const knownProps = new Map();
  30775. const deduped = [];
  30776. for (let i = 0; i < properties.length; i++) {
  30777. const prop = properties[i];
  30778. // dynamic keys are always allowed
  30779. if (prop.key.type === 8 /* COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
  30780. deduped.push(prop);
  30781. continue;
  30782. }
  30783. const name = prop.key.content;
  30784. const existing = knownProps.get(name);
  30785. if (existing) {
  30786. if (name === 'style' || name === 'class' || name.startsWith('on')) {
  30787. mergeAsArray(existing, prop);
  30788. }
  30789. // unexpected duplicate, should have emitted error during parse
  30790. }
  30791. else {
  30792. knownProps.set(name, prop);
  30793. deduped.push(prop);
  30794. }
  30795. }
  30796. return deduped;
  30797. }
  30798. function mergeAsArray(existing, incoming) {
  30799. if (existing.value.type === 17 /* JS_ARRAY_EXPRESSION */) {
  30800. existing.value.elements.push(incoming.value);
  30801. }
  30802. else {
  30803. existing.value = createArrayExpression([existing.value, incoming.value], existing.loc);
  30804. }
  30805. }
  30806. function buildDirectiveArgs(dir, context) {
  30807. const dirArgs = [];
  30808. const runtime = directiveImportMap.get(dir);
  30809. if (runtime) {
  30810. // built-in directive with runtime
  30811. dirArgs.push(context.helperString(runtime));
  30812. }
  30813. else {
  30814. // user directive.
  30815. // see if we have directives exposed via <script setup>
  30816. const fromSetup = resolveSetupReference('v-' + dir.name, context);
  30817. if (fromSetup) {
  30818. dirArgs.push(fromSetup);
  30819. }
  30820. else {
  30821. // inject statement for resolving directive
  30822. context.helper(RESOLVE_DIRECTIVE);
  30823. context.directives.add(dir.name);
  30824. dirArgs.push(toValidAssetId(dir.name, `directive`));
  30825. }
  30826. }
  30827. const { loc } = dir;
  30828. if (dir.exp)
  30829. dirArgs.push(dir.exp);
  30830. if (dir.arg) {
  30831. if (!dir.exp) {
  30832. dirArgs.push(`void 0`);
  30833. }
  30834. dirArgs.push(dir.arg);
  30835. }
  30836. if (Object.keys(dir.modifiers).length) {
  30837. if (!dir.arg) {
  30838. if (!dir.exp) {
  30839. dirArgs.push(`void 0`);
  30840. }
  30841. dirArgs.push(`void 0`);
  30842. }
  30843. const trueExpression = createSimpleExpression(`true`, false, loc);
  30844. dirArgs.push(createObjectExpression(dir.modifiers.map(modifier => createObjectProperty(modifier, trueExpression)), loc));
  30845. }
  30846. return createArrayExpression(dirArgs, dir.loc);
  30847. }
  30848. function stringifyDynamicPropNames(props) {
  30849. let propsNamesString = `[`;
  30850. for (let i = 0, l = props.length; i < l; i++) {
  30851. propsNamesString += JSON.stringify(props[i]);
  30852. if (i < l - 1)
  30853. propsNamesString += ', ';
  30854. }
  30855. return propsNamesString + `]`;
  30856. }
  30857. function isComponentTag(tag) {
  30858. return tag[0].toLowerCase() + tag.slice(1) === 'component';
  30859. }
  30860. function processInlineRef(bindings, raw) {
  30861. const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
  30862. const type = bindings[raw];
  30863. if (type === "setup-ref" /* SETUP_REF */) {
  30864. body.push(createSimpleExpression(`${raw}.value = _value`));
  30865. }
  30866. else if (type === "setup-let" /* SETUP_LET */) {
  30867. body.push(createSimpleExpression(`${raw} = _value`));
  30868. }
  30869. return body;
  30870. }
  30871. const transformSlotOutlet = (node, context) => {
  30872. if (isSlotOutlet(node)) {
  30873. const { children, loc } = node;
  30874. const { slotName, slotProps } = processSlotOutlet(node, context);
  30875. const slotArgs = [
  30876. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  30877. slotName
  30878. ];
  30879. if (slotProps) {
  30880. slotArgs.push(slotProps);
  30881. }
  30882. if (children.length) {
  30883. if (!slotProps) {
  30884. slotArgs.push(`{}`);
  30885. }
  30886. slotArgs.push(createFunctionExpression([], children, false, false, loc));
  30887. }
  30888. if (context.scopeId && !context.slotted) {
  30889. if (!slotProps) {
  30890. slotArgs.push(`{}`);
  30891. }
  30892. if (!children.length) {
  30893. slotArgs.push(`undefined`);
  30894. }
  30895. slotArgs.push(`true`);
  30896. }
  30897. node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
  30898. }
  30899. };
  30900. function processSlotOutlet(node, context) {
  30901. let slotName = `"default"`;
  30902. let slotProps = undefined;
  30903. const nonNameProps = [];
  30904. for (let i = 0; i < node.props.length; i++) {
  30905. const p = node.props[i];
  30906. if (p.type === 6 /* ATTRIBUTE */) {
  30907. if (p.value) {
  30908. if (p.name === 'name') {
  30909. slotName = JSON.stringify(p.value.content);
  30910. }
  30911. else {
  30912. p.name = camelize(p.name);
  30913. nonNameProps.push(p);
  30914. }
  30915. }
  30916. }
  30917. else {
  30918. if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
  30919. if (p.exp)
  30920. slotName = p.exp;
  30921. }
  30922. else {
  30923. if (p.name === 'bind' && p.arg && isStaticExp(p.arg)) {
  30924. p.arg.content = camelize(p.arg.content);
  30925. }
  30926. nonNameProps.push(p);
  30927. }
  30928. }
  30929. }
  30930. if (nonNameProps.length > 0) {
  30931. const { props, directives } = buildProps(node, context, nonNameProps);
  30932. slotProps = props;
  30933. if (directives.length) {
  30934. context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
  30935. }
  30936. }
  30937. return {
  30938. slotName,
  30939. slotProps
  30940. };
  30941. }
  30942. const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
  30943. const transformOn = (dir, node, context, augmentor) => {
  30944. const { loc, modifiers, arg } = dir;
  30945. if (!dir.exp && !modifiers.length) {
  30946. context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
  30947. }
  30948. let eventName;
  30949. if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
  30950. if (arg.isStatic) {
  30951. const rawName = arg.content;
  30952. // for all event listeners, auto convert it to camelCase. See issue #2249
  30953. eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
  30954. }
  30955. else {
  30956. // #2388
  30957. eventName = createCompoundExpression([
  30958. `${context.helperString(TO_HANDLER_KEY)}(`,
  30959. arg,
  30960. `)`
  30961. ]);
  30962. }
  30963. }
  30964. else {
  30965. // already a compound expression.
  30966. eventName = arg;
  30967. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  30968. eventName.children.push(`)`);
  30969. }
  30970. // handler processing
  30971. let exp = dir.exp;
  30972. if (exp && !exp.content.trim()) {
  30973. exp = undefined;
  30974. }
  30975. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  30976. if (exp) {
  30977. const isMemberExp = isMemberExpression(exp.content);
  30978. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  30979. const hasMultipleStatements = exp.content.includes(`;`);
  30980. // process the expression since it's been skipped
  30981. if (context.prefixIdentifiers) {
  30982. isInlineStatement && context.addIdentifiers(`$event`);
  30983. exp = dir.exp = processExpression(exp, context, false, hasMultipleStatements);
  30984. isInlineStatement && context.removeIdentifiers(`$event`);
  30985. // with scope analysis, the function is hoistable if it has no reference
  30986. // to scope variables.
  30987. shouldCache =
  30988. context.cacheHandlers &&
  30989. // unnecessary to cache inside v-once
  30990. !context.inVOnce &&
  30991. // runtime constants don't need to be cached
  30992. // (this is analyzed by compileScript in SFC <script setup>)
  30993. !(exp.type === 4 /* SIMPLE_EXPRESSION */ && exp.constType > 0) &&
  30994. // #1541 bail if this is a member exp handler passed to a component -
  30995. // we need to use the original function to preserve arity,
  30996. // e.g. <transition> relies on checking cb.length to determine
  30997. // transition end handling. Inline function is ok since its arity
  30998. // is preserved even when cached.
  30999. !(isMemberExp && node.tagType === 1 /* COMPONENT */) &&
  31000. // bail if the function references closure variables (v-for, v-slot)
  31001. // it must be passed fresh to avoid stale values.
  31002. !hasScopeRef(exp, context.identifiers);
  31003. // If the expression is optimizable and is a member expression pointing
  31004. // to a function, turn it into invocation (and wrap in an arrow function
  31005. // below) so that it always accesses the latest value when called - thus
  31006. // avoiding the need to be patched.
  31007. if (shouldCache && isMemberExp) {
  31008. if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
  31009. exp.content = `${exp.content} && ${exp.content}(...args)`;
  31010. }
  31011. else {
  31012. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  31013. }
  31014. }
  31015. }
  31016. if (isInlineStatement || (shouldCache && isMemberExp)) {
  31017. // wrap inline statement in a function expression
  31018. exp = createCompoundExpression([
  31019. `${isInlineStatement
  31020. ? context.isTS
  31021. ? `($event: any)`
  31022. : `$event`
  31023. : `${context.isTS ? `\n//@ts-ignore\n` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  31024. exp,
  31025. hasMultipleStatements ? `}` : `)`
  31026. ]);
  31027. }
  31028. }
  31029. let ret = {
  31030. props: [
  31031. createObjectProperty(eventName, exp || createSimpleExpression(`() => {}`, false, loc))
  31032. ]
  31033. };
  31034. // apply extended compiler augmentor
  31035. if (augmentor) {
  31036. ret = augmentor(ret);
  31037. }
  31038. if (shouldCache) {
  31039. // cache handlers so that it's always the same handler being passed down.
  31040. // this avoids unnecessary re-renders when users use inline handlers on
  31041. // components.
  31042. ret.props[0].value = context.cache(ret.props[0].value);
  31043. }
  31044. // mark the key as handler for props normalization check
  31045. ret.props.forEach(p => (p.key.isHandlerKey = true));
  31046. return ret;
  31047. };
  31048. // v-bind without arg is handled directly in ./transformElements.ts due to it affecting
  31049. // codegen for the entire props object. This transform here is only for v-bind
  31050. // *with* args.
  31051. const transformBind = (dir, _node, context) => {
  31052. const { exp, modifiers, loc } = dir;
  31053. const arg = dir.arg;
  31054. if (arg.type !== 4 /* SIMPLE_EXPRESSION */) {
  31055. arg.children.unshift(`(`);
  31056. arg.children.push(`) || ""`);
  31057. }
  31058. else if (!arg.isStatic) {
  31059. arg.content = `${arg.content} || ""`;
  31060. }
  31061. // .sync is replaced by v-model:arg
  31062. if (modifiers.includes('camel')) {
  31063. if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
  31064. if (arg.isStatic) {
  31065. arg.content = camelize(arg.content);
  31066. }
  31067. else {
  31068. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  31069. }
  31070. }
  31071. else {
  31072. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  31073. arg.children.push(`)`);
  31074. }
  31075. }
  31076. if (!context.inSSR) {
  31077. if (modifiers.includes('prop')) {
  31078. injectPrefix(arg, '.');
  31079. }
  31080. if (modifiers.includes('attr')) {
  31081. injectPrefix(arg, '^');
  31082. }
  31083. }
  31084. if (!exp ||
  31085. (exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
  31086. context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
  31087. return {
  31088. props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
  31089. };
  31090. }
  31091. return {
  31092. props: [createObjectProperty(arg, exp)]
  31093. };
  31094. };
  31095. const injectPrefix = (arg, prefix) => {
  31096. if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
  31097. if (arg.isStatic) {
  31098. arg.content = prefix + arg.content;
  31099. }
  31100. else {
  31101. arg.content = `\`${prefix}\${${arg.content}}\``;
  31102. }
  31103. }
  31104. else {
  31105. arg.children.unshift(`'${prefix}' + (`);
  31106. arg.children.push(`)`);
  31107. }
  31108. };
  31109. // Merge adjacent text nodes and expressions into a single expression
  31110. // e.g. <div>abc {{ d }} {{ e }}</div> should have a single expression node as child.
  31111. const transformText = (node, context) => {
  31112. if (node.type === 0 /* ROOT */ ||
  31113. node.type === 1 /* ELEMENT */ ||
  31114. node.type === 11 /* FOR */ ||
  31115. node.type === 10 /* IF_BRANCH */) {
  31116. // perform the transform on node exit so that all expressions have already
  31117. // been processed.
  31118. return () => {
  31119. const children = node.children;
  31120. let currentContainer = undefined;
  31121. let hasText = false;
  31122. for (let i = 0; i < children.length; i++) {
  31123. const child = children[i];
  31124. if (isText(child)) {
  31125. hasText = true;
  31126. for (let j = i + 1; j < children.length; j++) {
  31127. const next = children[j];
  31128. if (isText(next)) {
  31129. if (!currentContainer) {
  31130. currentContainer = children[i] = {
  31131. type: 8 /* COMPOUND_EXPRESSION */,
  31132. loc: child.loc,
  31133. children: [child]
  31134. };
  31135. }
  31136. // merge adjacent text node into current
  31137. currentContainer.children.push(` + `, next);
  31138. children.splice(j, 1);
  31139. j--;
  31140. }
  31141. else {
  31142. currentContainer = undefined;
  31143. break;
  31144. }
  31145. }
  31146. }
  31147. }
  31148. if (!hasText ||
  31149. // if this is a plain element with a single text child, leave it
  31150. // as-is since the runtime has dedicated fast path for this by directly
  31151. // setting textContent of the element.
  31152. // for component root it's always normalized anyway.
  31153. (children.length === 1 &&
  31154. (node.type === 0 /* ROOT */ ||
  31155. (node.type === 1 /* ELEMENT */ &&
  31156. node.tagType === 0 /* ELEMENT */ &&
  31157. // #3756
  31158. // custom directives can potentially add DOM elements arbitrarily,
  31159. // we need to avoid setting textContent of the element at runtime
  31160. // to avoid accidentally overwriting the DOM elements added
  31161. // by the user through custom directives.
  31162. !node.props.find(p => p.type === 7 /* DIRECTIVE */ &&
  31163. !context.directiveTransforms[p.name]) &&
  31164. // in compat mode, <template> tags with no special directives
  31165. // will be rendered as a fragment so its children must be
  31166. // converted into vnodes.
  31167. !(false ))))) {
  31168. return;
  31169. }
  31170. // pre-convert text nodes into createTextVNode(text) calls to avoid
  31171. // runtime normalization.
  31172. for (let i = 0; i < children.length; i++) {
  31173. const child = children[i];
  31174. if (isText(child) || child.type === 8 /* COMPOUND_EXPRESSION */) {
  31175. const callArgs = [];
  31176. // createTextVNode defaults to single whitespace, so if it is a
  31177. // single space the code could be an empty call to save bytes.
  31178. if (child.type !== 2 /* TEXT */ || child.content !== ' ') {
  31179. callArgs.push(child);
  31180. }
  31181. // mark dynamic text with flag so it gets patched inside a block
  31182. if (!context.ssr &&
  31183. getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
  31184. callArgs.push(1 /* TEXT */ +
  31185. (` /* ${PatchFlagNames[1 /* TEXT */]} */` ));
  31186. }
  31187. children[i] = {
  31188. type: 12 /* TEXT_CALL */,
  31189. content: child,
  31190. loc: child.loc,
  31191. codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
  31192. };
  31193. }
  31194. }
  31195. };
  31196. }
  31197. };
  31198. const seen = new WeakSet();
  31199. const transformOnce = (node, context) => {
  31200. if (node.type === 1 /* ELEMENT */ && findDir(node, 'once', true)) {
  31201. if (seen.has(node) || context.inVOnce) {
  31202. return;
  31203. }
  31204. seen.add(node);
  31205. context.inVOnce = true;
  31206. context.helper(SET_BLOCK_TRACKING);
  31207. return () => {
  31208. context.inVOnce = false;
  31209. const cur = context.currentNode;
  31210. if (cur.codegenNode) {
  31211. cur.codegenNode = context.cache(cur.codegenNode, true /* isVNode */);
  31212. }
  31213. };
  31214. }
  31215. };
  31216. const transformModel = (dir, node, context) => {
  31217. const { exp, arg } = dir;
  31218. if (!exp) {
  31219. context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
  31220. return createTransformProps();
  31221. }
  31222. const rawExp = exp.loc.source;
  31223. const expString = exp.type === 4 /* SIMPLE_EXPRESSION */ ? exp.content : rawExp;
  31224. // im SFC <script setup> inline mode, the exp may have been transformed into
  31225. // _unref(exp)
  31226. const bindingType = context.bindingMetadata[rawExp];
  31227. const maybeRef = context.inline &&
  31228. bindingType &&
  31229. bindingType !== "setup-const" /* SETUP_CONST */;
  31230. if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
  31231. context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
  31232. return createTransformProps();
  31233. }
  31234. if (context.prefixIdentifiers &&
  31235. isSimpleIdentifier(expString) &&
  31236. context.identifiers[expString]) {
  31237. context.onError(createCompilerError(43 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
  31238. return createTransformProps();
  31239. }
  31240. const propName = arg ? arg : createSimpleExpression('modelValue', true);
  31241. const eventName = arg
  31242. ? isStaticExp(arg)
  31243. ? `onUpdate:${arg.content}`
  31244. : createCompoundExpression(['"onUpdate:" + ', arg])
  31245. : `onUpdate:modelValue`;
  31246. let assignmentExp;
  31247. const eventArg = context.isTS ? `($event: any)` : `$event`;
  31248. if (maybeRef) {
  31249. if (bindingType === "setup-ref" /* SETUP_REF */) {
  31250. // v-model used on known ref.
  31251. assignmentExp = createCompoundExpression([
  31252. `${eventArg} => (`,
  31253. createSimpleExpression(rawExp, false, exp.loc),
  31254. `.value = $event)`
  31255. ]);
  31256. }
  31257. else {
  31258. // v-model used on a potentially ref binding in <script setup> inline mode.
  31259. // the assignment needs to check whether the binding is actually a ref.
  31260. const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
  31261. assignmentExp = createCompoundExpression([
  31262. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? `,
  31263. createSimpleExpression(rawExp, false, exp.loc),
  31264. `.value = $event : ${altAssignment})`
  31265. ]);
  31266. }
  31267. }
  31268. else {
  31269. assignmentExp = createCompoundExpression([
  31270. `${eventArg} => (`,
  31271. exp,
  31272. ` = $event)`
  31273. ]);
  31274. }
  31275. const props = [
  31276. // modelValue: foo
  31277. createObjectProperty(propName, dir.exp),
  31278. // "onUpdate:modelValue": $event => (foo = $event)
  31279. createObjectProperty(eventName, assignmentExp)
  31280. ];
  31281. // cache v-model handler if applicable (when it doesn't refer any scope vars)
  31282. if (context.prefixIdentifiers &&
  31283. !context.inVOnce &&
  31284. context.cacheHandlers &&
  31285. !hasScopeRef(exp, context.identifiers)) {
  31286. props[1].value = context.cache(props[1].value);
  31287. }
  31288. // modelModifiers: { foo: true, "bar-baz": true }
  31289. if (dir.modifiers.length && node.tagType === 1 /* COMPONENT */) {
  31290. const modifiers = dir.modifiers
  31291. .map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
  31292. .join(`, `);
  31293. const modifiersKey = arg
  31294. ? isStaticExp(arg)
  31295. ? `${arg.content}Modifiers`
  31296. : createCompoundExpression([arg, ' + "Modifiers"'])
  31297. : `modelModifiers`;
  31298. props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* CAN_HOIST */)));
  31299. }
  31300. return createTransformProps(props);
  31301. };
  31302. function createTransformProps(props = []) {
  31303. return { props };
  31304. }
  31305. const seen$1 = new WeakSet();
  31306. const transformMemo = (node, context) => {
  31307. if (node.type === 1 /* ELEMENT */) {
  31308. const dir = findDir(node, 'memo');
  31309. if (!dir || seen$1.has(node)) {
  31310. return;
  31311. }
  31312. seen$1.add(node);
  31313. return () => {
  31314. const codegenNode = node.codegenNode ||
  31315. context.currentNode.codegenNode;
  31316. if (codegenNode && codegenNode.type === 13 /* VNODE_CALL */) {
  31317. // non-component sub tree should be turned into a block
  31318. if (node.tagType !== 1 /* COMPONENT */) {
  31319. makeBlock(codegenNode, context);
  31320. }
  31321. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  31322. dir.exp,
  31323. createFunctionExpression(undefined, codegenNode),
  31324. `_cache`,
  31325. String(context.cached++)
  31326. ]);
  31327. }
  31328. };
  31329. }
  31330. };
  31331. function getBaseTransformPreset(prefixIdentifiers) {
  31332. return [
  31333. [
  31334. transformOnce,
  31335. transformIf,
  31336. transformMemo,
  31337. transformFor,
  31338. ...([]),
  31339. ...(prefixIdentifiers
  31340. ? [
  31341. // order is important
  31342. trackVForSlotScopes,
  31343. transformExpression
  31344. ]
  31345. : []),
  31346. transformSlotOutlet,
  31347. transformElement,
  31348. trackSlotScopes,
  31349. transformText
  31350. ],
  31351. {
  31352. on: transformOn,
  31353. bind: transformBind,
  31354. model: transformModel
  31355. }
  31356. ];
  31357. }
  31358. // we name it `baseCompile` so that higher order compilers like
  31359. // @vue/compiler-dom can export `compile` while re-exporting everything else.
  31360. function baseCompile(template, options = {}) {
  31361. const onError = options.onError || defaultOnError;
  31362. const isModuleMode = options.mode === 'module';
  31363. const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
  31364. if (!prefixIdentifiers && options.cacheHandlers) {
  31365. onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
  31366. }
  31367. if (options.scopeId && !isModuleMode) {
  31368. onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
  31369. }
  31370. const ast = isString(template) ? baseParse(template, options) : template;
  31371. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  31372. transform(ast, extend({}, options, {
  31373. prefixIdentifiers,
  31374. nodeTransforms: [
  31375. ...nodeTransforms,
  31376. ...(options.nodeTransforms || []) // user transforms
  31377. ],
  31378. directiveTransforms: extend({}, directiveTransforms, options.directiveTransforms || {} // user transforms
  31379. )
  31380. }));
  31381. return generate(ast, extend({}, options, {
  31382. prefixIdentifiers
  31383. }));
  31384. }
  31385. const noopDirectiveTransform = () => ({ props: [] });
  31386. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  31387. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  31388. const V_MODEL_TEXT = Symbol(`vModelText` );
  31389. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  31390. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  31391. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  31392. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  31393. const V_SHOW = Symbol(`vShow` );
  31394. const TRANSITION = Symbol(`Transition` );
  31395. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  31396. registerRuntimeHelpers({
  31397. [V_MODEL_RADIO]: `vModelRadio`,
  31398. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  31399. [V_MODEL_TEXT]: `vModelText`,
  31400. [V_MODEL_SELECT]: `vModelSelect`,
  31401. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  31402. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  31403. [V_ON_WITH_KEYS]: `withKeys`,
  31404. [V_SHOW]: `vShow`,
  31405. [TRANSITION]: `Transition`,
  31406. [TRANSITION_GROUP]: `TransitionGroup`
  31407. });
  31408. var namedCharacterReferences = {
  31409. GT: ">",
  31410. gt: ">",
  31411. LT: "<",
  31412. lt: "<",
  31413. "ac;": "∾",
  31414. "af;": "⁡",
  31415. AMP: "&",
  31416. amp: "&",
  31417. "ap;": "≈",
  31418. "DD;": "ⅅ",
  31419. "dd;": "ⅆ",
  31420. deg: "°",
  31421. "ee;": "ⅇ",
  31422. "eg;": "⪚",
  31423. "el;": "⪙",
  31424. ETH: "Ð",
  31425. eth: "ð",
  31426. "gE;": "≧",
  31427. "ge;": "≥",
  31428. "Gg;": "⋙",
  31429. "gg;": "≫",
  31430. "gl;": "≷",
  31431. "GT;": ">",
  31432. "Gt;": "≫",
  31433. "gt;": ">",
  31434. "ic;": "⁣",
  31435. "ii;": "ⅈ",
  31436. "Im;": "ℑ",
  31437. "in;": "∈",
  31438. "it;": "⁢",
  31439. "lE;": "≦",
  31440. "le;": "≤",
  31441. "lg;": "≶",
  31442. "Ll;": "⋘",
  31443. "ll;": "≪",
  31444. "LT;": "<",
  31445. "Lt;": "≪",
  31446. "lt;": "<",
  31447. "mp;": "∓",
  31448. "Mu;": "Μ",
  31449. "mu;": "μ",
  31450. "ne;": "≠",
  31451. "ni;": "∋",
  31452. not: "¬",
  31453. "Nu;": "Ν",
  31454. "nu;": "ν",
  31455. "Or;": "⩔",
  31456. "or;": "∨",
  31457. "oS;": "Ⓢ",
  31458. "Pi;": "Π",
  31459. "pi;": "π",
  31460. "pm;": "±",
  31461. "Pr;": "⪻",
  31462. "pr;": "≺",
  31463. "Re;": "ℜ",
  31464. REG: "®",
  31465. reg: "®",
  31466. "rx;": "℞",
  31467. "Sc;": "⪼",
  31468. "sc;": "≻",
  31469. shy: "­",
  31470. uml: "¨",
  31471. "wp;": "℘",
  31472. "wr;": "≀",
  31473. "Xi;": "Ξ",
  31474. "xi;": "ξ",
  31475. yen: "¥",
  31476. "acd;": "∿",
  31477. "acE;": "∾̳",
  31478. "Acy;": "А",
  31479. "acy;": "а",
  31480. "Afr;": "𝔄",
  31481. "afr;": "𝔞",
  31482. "AMP;": "&",
  31483. "amp;": "&",
  31484. "And;": "⩓",
  31485. "and;": "∧",
  31486. "ang;": "∠",
  31487. "apE;": "⩰",
  31488. "ape;": "≊",
  31489. "ast;": "*",
  31490. Auml: "Ä",
  31491. auml: "ä",
  31492. "Bcy;": "Б",
  31493. "bcy;": "б",
  31494. "Bfr;": "𝔅",
  31495. "bfr;": "𝔟",
  31496. "bne;": "=⃥",
  31497. "bot;": "⊥",
  31498. "Cap;": "⋒",
  31499. "cap;": "∩",
  31500. cent: "¢",
  31501. "Cfr;": "ℭ",
  31502. "cfr;": "𝔠",
  31503. "Chi;": "Χ",
  31504. "chi;": "χ",
  31505. "cir;": "○",
  31506. COPY: "©",
  31507. copy: "©",
  31508. "Cup;": "⋓",
  31509. "cup;": "∪",
  31510. "Dcy;": "Д",
  31511. "dcy;": "д",
  31512. "deg;": "°",
  31513. "Del;": "∇",
  31514. "Dfr;": "𝔇",
  31515. "dfr;": "𝔡",
  31516. "die;": "¨",
  31517. "div;": "÷",
  31518. "Dot;": "¨",
  31519. "dot;": "˙",
  31520. "Ecy;": "Э",
  31521. "ecy;": "э",
  31522. "Efr;": "𝔈",
  31523. "efr;": "𝔢",
  31524. "egs;": "⪖",
  31525. "ell;": "ℓ",
  31526. "els;": "⪕",
  31527. "ENG;": "Ŋ",
  31528. "eng;": "ŋ",
  31529. "Eta;": "Η",
  31530. "eta;": "η",
  31531. "ETH;": "Ð",
  31532. "eth;": "ð",
  31533. Euml: "Ë",
  31534. euml: "ë",
  31535. "Fcy;": "Ф",
  31536. "fcy;": "ф",
  31537. "Ffr;": "𝔉",
  31538. "ffr;": "𝔣",
  31539. "gap;": "⪆",
  31540. "Gcy;": "Г",
  31541. "gcy;": "г",
  31542. "gEl;": "⪌",
  31543. "gel;": "⋛",
  31544. "geq;": "≥",
  31545. "ges;": "⩾",
  31546. "Gfr;": "𝔊",
  31547. "gfr;": "𝔤",
  31548. "ggg;": "⋙",
  31549. "gla;": "⪥",
  31550. "glE;": "⪒",
  31551. "glj;": "⪤",
  31552. "gnE;": "≩",
  31553. "gne;": "⪈",
  31554. "Hat;": "^",
  31555. "Hfr;": "ℌ",
  31556. "hfr;": "𝔥",
  31557. "Icy;": "И",
  31558. "icy;": "и",
  31559. "iff;": "⇔",
  31560. "Ifr;": "ℑ",
  31561. "ifr;": "𝔦",
  31562. "Int;": "∬",
  31563. "int;": "∫",
  31564. Iuml: "Ï",
  31565. iuml: "ï",
  31566. "Jcy;": "Й",
  31567. "jcy;": "й",
  31568. "Jfr;": "𝔍",
  31569. "jfr;": "𝔧",
  31570. "Kcy;": "К",
  31571. "kcy;": "к",
  31572. "Kfr;": "𝔎",
  31573. "kfr;": "𝔨",
  31574. "lap;": "⪅",
  31575. "lat;": "⪫",
  31576. "Lcy;": "Л",
  31577. "lcy;": "л",
  31578. "lEg;": "⪋",
  31579. "leg;": "⋚",
  31580. "leq;": "≤",
  31581. "les;": "⩽",
  31582. "Lfr;": "𝔏",
  31583. "lfr;": "𝔩",
  31584. "lgE;": "⪑",
  31585. "lnE;": "≨",
  31586. "lne;": "⪇",
  31587. "loz;": "◊",
  31588. "lrm;": "‎",
  31589. "Lsh;": "↰",
  31590. "lsh;": "↰",
  31591. macr: "¯",
  31592. "Map;": "⤅",
  31593. "map;": "↦",
  31594. "Mcy;": "М",
  31595. "mcy;": "м",
  31596. "Mfr;": "𝔐",
  31597. "mfr;": "𝔪",
  31598. "mho;": "℧",
  31599. "mid;": "∣",
  31600. "nap;": "≉",
  31601. nbsp: " ",
  31602. "Ncy;": "Н",
  31603. "ncy;": "н",
  31604. "Nfr;": "𝔑",
  31605. "nfr;": "𝔫",
  31606. "ngE;": "≧̸",
  31607. "nge;": "≱",
  31608. "nGg;": "⋙̸",
  31609. "nGt;": "≫⃒",
  31610. "ngt;": "≯",
  31611. "nis;": "⋼",
  31612. "niv;": "∋",
  31613. "nlE;": "≦̸",
  31614. "nle;": "≰",
  31615. "nLl;": "⋘̸",
  31616. "nLt;": "≪⃒",
  31617. "nlt;": "≮",
  31618. "Not;": "⫬",
  31619. "not;": "¬",
  31620. "npr;": "⊀",
  31621. "nsc;": "⊁",
  31622. "num;": "#",
  31623. "Ocy;": "О",
  31624. "ocy;": "о",
  31625. "Ofr;": "𝔒",
  31626. "ofr;": "𝔬",
  31627. "ogt;": "⧁",
  31628. "ohm;": "Ω",
  31629. "olt;": "⧀",
  31630. "ord;": "⩝",
  31631. ordf: "ª",
  31632. ordm: "º",
  31633. "orv;": "⩛",
  31634. Ouml: "Ö",
  31635. ouml: "ö",
  31636. "par;": "∥",
  31637. para: "¶",
  31638. "Pcy;": "П",
  31639. "pcy;": "п",
  31640. "Pfr;": "𝔓",
  31641. "pfr;": "𝔭",
  31642. "Phi;": "Φ",
  31643. "phi;": "φ",
  31644. "piv;": "ϖ",
  31645. "prE;": "⪳",
  31646. "pre;": "⪯",
  31647. "Psi;": "Ψ",
  31648. "psi;": "ψ",
  31649. "Qfr;": "𝔔",
  31650. "qfr;": "𝔮",
  31651. QUOT: "\"",
  31652. quot: "\"",
  31653. "Rcy;": "Р",
  31654. "rcy;": "р",
  31655. "REG;": "®",
  31656. "reg;": "®",
  31657. "Rfr;": "ℜ",
  31658. "rfr;": "𝔯",
  31659. "Rho;": "Ρ",
  31660. "rho;": "ρ",
  31661. "rlm;": "‏",
  31662. "Rsh;": "↱",
  31663. "rsh;": "↱",
  31664. "scE;": "⪴",
  31665. "sce;": "⪰",
  31666. "Scy;": "С",
  31667. "scy;": "с",
  31668. sect: "§",
  31669. "Sfr;": "𝔖",
  31670. "sfr;": "𝔰",
  31671. "shy;": "­",
  31672. "sim;": "∼",
  31673. "smt;": "⪪",
  31674. "sol;": "/",
  31675. "squ;": "□",
  31676. "Sub;": "⋐",
  31677. "sub;": "⊂",
  31678. "Sum;": "∑",
  31679. "sum;": "∑",
  31680. "Sup;": "⋑",
  31681. "sup;": "⊃",
  31682. sup1: "¹",
  31683. sup2: "²",
  31684. sup3: "³",
  31685. "Tab;": "\t",
  31686. "Tau;": "Τ",
  31687. "tau;": "τ",
  31688. "Tcy;": "Т",
  31689. "tcy;": "т",
  31690. "Tfr;": "𝔗",
  31691. "tfr;": "𝔱",
  31692. "top;": "⊤",
  31693. "Ucy;": "У",
  31694. "ucy;": "у",
  31695. "Ufr;": "𝔘",
  31696. "ufr;": "𝔲",
  31697. "uml;": "¨",
  31698. Uuml: "Ü",
  31699. uuml: "ü",
  31700. "Vcy;": "В",
  31701. "vcy;": "в",
  31702. "Vee;": "⋁",
  31703. "vee;": "∨",
  31704. "Vfr;": "𝔙",
  31705. "vfr;": "𝔳",
  31706. "Wfr;": "𝔚",
  31707. "wfr;": "𝔴",
  31708. "Xfr;": "𝔛",
  31709. "xfr;": "𝔵",
  31710. "Ycy;": "Ы",
  31711. "ycy;": "ы",
  31712. "yen;": "¥",
  31713. "Yfr;": "𝔜",
  31714. "yfr;": "𝔶",
  31715. yuml: "ÿ",
  31716. "Zcy;": "З",
  31717. "zcy;": "з",
  31718. "Zfr;": "ℨ",
  31719. "zfr;": "𝔷",
  31720. "zwj;": "‍",
  31721. Acirc: "Â",
  31722. acirc: "â",
  31723. acute: "´",
  31724. AElig: "Æ",
  31725. aelig: "æ",
  31726. "andd;": "⩜",
  31727. "andv;": "⩚",
  31728. "ange;": "⦤",
  31729. "Aopf;": "𝔸",
  31730. "aopf;": "𝕒",
  31731. "apid;": "≋",
  31732. "apos;": "'",
  31733. Aring: "Å",
  31734. aring: "å",
  31735. "Ascr;": "𝒜",
  31736. "ascr;": "𝒶",
  31737. "Auml;": "Ä",
  31738. "auml;": "ä",
  31739. "Barv;": "⫧",
  31740. "bbrk;": "⎵",
  31741. "Beta;": "Β",
  31742. "beta;": "β",
  31743. "beth;": "ℶ",
  31744. "bNot;": "⫭",
  31745. "bnot;": "⌐",
  31746. "Bopf;": "𝔹",
  31747. "bopf;": "𝕓",
  31748. "boxH;": "═",
  31749. "boxh;": "─",
  31750. "boxV;": "║",
  31751. "boxv;": "│",
  31752. "Bscr;": "ℬ",
  31753. "bscr;": "𝒷",
  31754. "bsim;": "∽",
  31755. "bsol;": "\\",
  31756. "bull;": "•",
  31757. "bump;": "≎",
  31758. "caps;": "∩︀",
  31759. "Cdot;": "Ċ",
  31760. "cdot;": "ċ",
  31761. cedil: "¸",
  31762. "cent;": "¢",
  31763. "CHcy;": "Ч",
  31764. "chcy;": "ч",
  31765. "circ;": "ˆ",
  31766. "cirE;": "⧃",
  31767. "cire;": "≗",
  31768. "comp;": "∁",
  31769. "cong;": "≅",
  31770. "Copf;": "ℂ",
  31771. "copf;": "𝕔",
  31772. "COPY;": "©",
  31773. "copy;": "©",
  31774. "Cscr;": "𝒞",
  31775. "cscr;": "𝒸",
  31776. "csub;": "⫏",
  31777. "csup;": "⫐",
  31778. "cups;": "∪︀",
  31779. "Darr;": "↡",
  31780. "dArr;": "⇓",
  31781. "darr;": "↓",
  31782. "dash;": "‐",
  31783. "dHar;": "⥥",
  31784. "diam;": "⋄",
  31785. "DJcy;": "Ђ",
  31786. "djcy;": "ђ",
  31787. "Dopf;": "𝔻",
  31788. "dopf;": "𝕕",
  31789. "Dscr;": "𝒟",
  31790. "dscr;": "𝒹",
  31791. "DScy;": "Ѕ",
  31792. "dscy;": "ѕ",
  31793. "dsol;": "⧶",
  31794. "dtri;": "▿",
  31795. "DZcy;": "Џ",
  31796. "dzcy;": "џ",
  31797. "ecir;": "≖",
  31798. Ecirc: "Ê",
  31799. ecirc: "ê",
  31800. "Edot;": "Ė",
  31801. "eDot;": "≑",
  31802. "edot;": "ė",
  31803. "emsp;": " ",
  31804. "ensp;": " ",
  31805. "Eopf;": "𝔼",
  31806. "eopf;": "𝕖",
  31807. "epar;": "⋕",
  31808. "epsi;": "ε",
  31809. "Escr;": "ℰ",
  31810. "escr;": "ℯ",
  31811. "Esim;": "⩳",
  31812. "esim;": "≂",
  31813. "Euml;": "Ë",
  31814. "euml;": "ë",
  31815. "euro;": "€",
  31816. "excl;": "!",
  31817. "flat;": "♭",
  31818. "fnof;": "ƒ",
  31819. "Fopf;": "𝔽",
  31820. "fopf;": "𝕗",
  31821. "fork;": "⋔",
  31822. "Fscr;": "ℱ",
  31823. "fscr;": "𝒻",
  31824. "Gdot;": "Ġ",
  31825. "gdot;": "ġ",
  31826. "geqq;": "≧",
  31827. "gesl;": "⋛︀",
  31828. "GJcy;": "Ѓ",
  31829. "gjcy;": "ѓ",
  31830. "gnap;": "⪊",
  31831. "gneq;": "⪈",
  31832. "Gopf;": "𝔾",
  31833. "gopf;": "𝕘",
  31834. "Gscr;": "𝒢",
  31835. "gscr;": "ℊ",
  31836. "gsim;": "≳",
  31837. "gtcc;": "⪧",
  31838. "gvnE;": "≩︀",
  31839. "half;": "½",
  31840. "hArr;": "⇔",
  31841. "harr;": "↔",
  31842. "hbar;": "ℏ",
  31843. "Hopf;": "ℍ",
  31844. "hopf;": "𝕙",
  31845. "Hscr;": "ℋ",
  31846. "hscr;": "𝒽",
  31847. Icirc: "Î",
  31848. icirc: "î",
  31849. "Idot;": "İ",
  31850. "IEcy;": "Е",
  31851. "iecy;": "е",
  31852. iexcl: "¡",
  31853. "imof;": "⊷",
  31854. "IOcy;": "Ё",
  31855. "iocy;": "ё",
  31856. "Iopf;": "𝕀",
  31857. "iopf;": "𝕚",
  31858. "Iota;": "Ι",
  31859. "iota;": "ι",
  31860. "Iscr;": "ℐ",
  31861. "iscr;": "𝒾",
  31862. "isin;": "∈",
  31863. "Iuml;": "Ï",
  31864. "iuml;": "ï",
  31865. "Jopf;": "𝕁",
  31866. "jopf;": "𝕛",
  31867. "Jscr;": "𝒥",
  31868. "jscr;": "𝒿",
  31869. "KHcy;": "Х",
  31870. "khcy;": "х",
  31871. "KJcy;": "Ќ",
  31872. "kjcy;": "ќ",
  31873. "Kopf;": "𝕂",
  31874. "kopf;": "𝕜",
  31875. "Kscr;": "𝒦",
  31876. "kscr;": "𝓀",
  31877. "Lang;": "⟪",
  31878. "lang;": "⟨",
  31879. laquo: "«",
  31880. "Larr;": "↞",
  31881. "lArr;": "⇐",
  31882. "larr;": "←",
  31883. "late;": "⪭",
  31884. "lcub;": "{",
  31885. "ldca;": "⤶",
  31886. "ldsh;": "↲",
  31887. "leqq;": "≦",
  31888. "lesg;": "⋚︀",
  31889. "lHar;": "⥢",
  31890. "LJcy;": "Љ",
  31891. "ljcy;": "љ",
  31892. "lnap;": "⪉",
  31893. "lneq;": "⪇",
  31894. "Lopf;": "𝕃",
  31895. "lopf;": "𝕝",
  31896. "lozf;": "⧫",
  31897. "lpar;": "(",
  31898. "Lscr;": "ℒ",
  31899. "lscr;": "𝓁",
  31900. "lsim;": "≲",
  31901. "lsqb;": "[",
  31902. "ltcc;": "⪦",
  31903. "ltri;": "◃",
  31904. "lvnE;": "≨︀",
  31905. "macr;": "¯",
  31906. "male;": "♂",
  31907. "malt;": "✠",
  31908. micro: "µ",
  31909. "mlcp;": "⫛",
  31910. "mldr;": "…",
  31911. "Mopf;": "𝕄",
  31912. "mopf;": "𝕞",
  31913. "Mscr;": "ℳ",
  31914. "mscr;": "𝓂",
  31915. "nang;": "∠⃒",
  31916. "napE;": "⩰̸",
  31917. "nbsp;": " ",
  31918. "ncap;": "⩃",
  31919. "ncup;": "⩂",
  31920. "ngeq;": "≱",
  31921. "nges;": "⩾̸",
  31922. "ngtr;": "≯",
  31923. "nGtv;": "≫̸",
  31924. "nisd;": "⋺",
  31925. "NJcy;": "Њ",
  31926. "njcy;": "њ",
  31927. "nldr;": "‥",
  31928. "nleq;": "≰",
  31929. "nles;": "⩽̸",
  31930. "nLtv;": "≪̸",
  31931. "nmid;": "∤",
  31932. "Nopf;": "ℕ",
  31933. "nopf;": "𝕟",
  31934. "npar;": "∦",
  31935. "npre;": "⪯̸",
  31936. "nsce;": "⪰̸",
  31937. "Nscr;": "𝒩",
  31938. "nscr;": "𝓃",
  31939. "nsim;": "≁",
  31940. "nsub;": "⊄",
  31941. "nsup;": "⊅",
  31942. "ntgl;": "≹",
  31943. "ntlg;": "≸",
  31944. "nvap;": "≍⃒",
  31945. "nvge;": "≥⃒",
  31946. "nvgt;": ">⃒",
  31947. "nvle;": "≤⃒",
  31948. "nvlt;": "<⃒",
  31949. "oast;": "⊛",
  31950. "ocir;": "⊚",
  31951. Ocirc: "Ô",
  31952. ocirc: "ô",
  31953. "odiv;": "⨸",
  31954. "odot;": "⊙",
  31955. "ogon;": "˛",
  31956. "oint;": "∮",
  31957. "omid;": "⦶",
  31958. "Oopf;": "𝕆",
  31959. "oopf;": "𝕠",
  31960. "opar;": "⦷",
  31961. "ordf;": "ª",
  31962. "ordm;": "º",
  31963. "oror;": "⩖",
  31964. "Oscr;": "𝒪",
  31965. "oscr;": "ℴ",
  31966. "osol;": "⊘",
  31967. "Ouml;": "Ö",
  31968. "ouml;": "ö",
  31969. "para;": "¶",
  31970. "part;": "∂",
  31971. "perp;": "⊥",
  31972. "phiv;": "ϕ",
  31973. "plus;": "+",
  31974. "Popf;": "ℙ",
  31975. "popf;": "𝕡",
  31976. pound: "£",
  31977. "prap;": "⪷",
  31978. "prec;": "≺",
  31979. "prnE;": "⪵",
  31980. "prod;": "∏",
  31981. "prop;": "∝",
  31982. "Pscr;": "𝒫",
  31983. "pscr;": "𝓅",
  31984. "qint;": "⨌",
  31985. "Qopf;": "ℚ",
  31986. "qopf;": "𝕢",
  31987. "Qscr;": "𝒬",
  31988. "qscr;": "𝓆",
  31989. "QUOT;": "\"",
  31990. "quot;": "\"",
  31991. "race;": "∽̱",
  31992. "Rang;": "⟫",
  31993. "rang;": "⟩",
  31994. raquo: "»",
  31995. "Rarr;": "↠",
  31996. "rArr;": "⇒",
  31997. "rarr;": "→",
  31998. "rcub;": "}",
  31999. "rdca;": "⤷",
  32000. "rdsh;": "↳",
  32001. "real;": "ℜ",
  32002. "rect;": "▭",
  32003. "rHar;": "⥤",
  32004. "rhov;": "ϱ",
  32005. "ring;": "˚",
  32006. "Ropf;": "ℝ",
  32007. "ropf;": "𝕣",
  32008. "rpar;": ")",
  32009. "Rscr;": "ℛ",
  32010. "rscr;": "𝓇",
  32011. "rsqb;": "]",
  32012. "rtri;": "▹",
  32013. "scap;": "⪸",
  32014. "scnE;": "⪶",
  32015. "sdot;": "⋅",
  32016. "sect;": "§",
  32017. "semi;": ";",
  32018. "sext;": "✶",
  32019. "SHcy;": "Ш",
  32020. "shcy;": "ш",
  32021. "sime;": "≃",
  32022. "simg;": "⪞",
  32023. "siml;": "⪝",
  32024. "smid;": "∣",
  32025. "smte;": "⪬",
  32026. "solb;": "⧄",
  32027. "Sopf;": "𝕊",
  32028. "sopf;": "𝕤",
  32029. "spar;": "∥",
  32030. "Sqrt;": "√",
  32031. "squf;": "▪",
  32032. "Sscr;": "𝒮",
  32033. "sscr;": "𝓈",
  32034. "Star;": "⋆",
  32035. "star;": "☆",
  32036. "subE;": "⫅",
  32037. "sube;": "⊆",
  32038. "succ;": "≻",
  32039. "sung;": "♪",
  32040. "sup1;": "¹",
  32041. "sup2;": "²",
  32042. "sup3;": "³",
  32043. "supE;": "⫆",
  32044. "supe;": "⊇",
  32045. szlig: "ß",
  32046. "tbrk;": "⎴",
  32047. "tdot;": "⃛",
  32048. THORN: "Þ",
  32049. thorn: "þ",
  32050. times: "×",
  32051. "tint;": "∭",
  32052. "toea;": "⤨",
  32053. "Topf;": "𝕋",
  32054. "topf;": "𝕥",
  32055. "tosa;": "⤩",
  32056. "trie;": "≜",
  32057. "Tscr;": "𝒯",
  32058. "tscr;": "𝓉",
  32059. "TScy;": "Ц",
  32060. "tscy;": "ц",
  32061. "Uarr;": "↟",
  32062. "uArr;": "⇑",
  32063. "uarr;": "↑",
  32064. Ucirc: "Û",
  32065. ucirc: "û",
  32066. "uHar;": "⥣",
  32067. "Uopf;": "𝕌",
  32068. "uopf;": "𝕦",
  32069. "Upsi;": "ϒ",
  32070. "upsi;": "υ",
  32071. "Uscr;": "𝒰",
  32072. "uscr;": "𝓊",
  32073. "utri;": "▵",
  32074. "Uuml;": "Ü",
  32075. "uuml;": "ü",
  32076. "vArr;": "⇕",
  32077. "varr;": "↕",
  32078. "Vbar;": "⫫",
  32079. "vBar;": "⫨",
  32080. "Vert;": "‖",
  32081. "vert;": "|",
  32082. "Vopf;": "𝕍",
  32083. "vopf;": "𝕧",
  32084. "Vscr;": "𝒱",
  32085. "vscr;": "𝓋",
  32086. "Wopf;": "𝕎",
  32087. "wopf;": "𝕨",
  32088. "Wscr;": "𝒲",
  32089. "wscr;": "𝓌",
  32090. "xcap;": "⋂",
  32091. "xcup;": "⋃",
  32092. "xmap;": "⟼",
  32093. "xnis;": "⋻",
  32094. "Xopf;": "𝕏",
  32095. "xopf;": "𝕩",
  32096. "Xscr;": "𝒳",
  32097. "xscr;": "𝓍",
  32098. "xvee;": "⋁",
  32099. "YAcy;": "Я",
  32100. "yacy;": "я",
  32101. "YIcy;": "Ї",
  32102. "yicy;": "ї",
  32103. "Yopf;": "𝕐",
  32104. "yopf;": "𝕪",
  32105. "Yscr;": "𝒴",
  32106. "yscr;": "𝓎",
  32107. "YUcy;": "Ю",
  32108. "yucy;": "ю",
  32109. "Yuml;": "Ÿ",
  32110. "yuml;": "ÿ",
  32111. "Zdot;": "Ż",
  32112. "zdot;": "ż",
  32113. "Zeta;": "Ζ",
  32114. "zeta;": "ζ",
  32115. "ZHcy;": "Ж",
  32116. "zhcy;": "ж",
  32117. "Zopf;": "ℤ",
  32118. "zopf;": "𝕫",
  32119. "Zscr;": "𝒵",
  32120. "zscr;": "𝓏",
  32121. "zwnj;": "‌",
  32122. Aacute: "Á",
  32123. aacute: "á",
  32124. "Acirc;": "Â",
  32125. "acirc;": "â",
  32126. "acute;": "´",
  32127. "AElig;": "Æ",
  32128. "aelig;": "æ",
  32129. Agrave: "À",
  32130. agrave: "à",
  32131. "aleph;": "ℵ",
  32132. "Alpha;": "Α",
  32133. "alpha;": "α",
  32134. "Amacr;": "Ā",
  32135. "amacr;": "ā",
  32136. "amalg;": "⨿",
  32137. "angle;": "∠",
  32138. "angrt;": "∟",
  32139. "angst;": "Å",
  32140. "Aogon;": "Ą",
  32141. "aogon;": "ą",
  32142. "Aring;": "Å",
  32143. "aring;": "å",
  32144. "asymp;": "≈",
  32145. Atilde: "Ã",
  32146. atilde: "ã",
  32147. "awint;": "⨑",
  32148. "bcong;": "≌",
  32149. "bdquo;": "„",
  32150. "bepsi;": "϶",
  32151. "blank;": "␣",
  32152. "blk12;": "▒",
  32153. "blk14;": "░",
  32154. "blk34;": "▓",
  32155. "block;": "█",
  32156. "boxDL;": "╗",
  32157. "boxDl;": "╖",
  32158. "boxdL;": "╕",
  32159. "boxdl;": "┐",
  32160. "boxDR;": "╔",
  32161. "boxDr;": "╓",
  32162. "boxdR;": "╒",
  32163. "boxdr;": "┌",
  32164. "boxHD;": "╦",
  32165. "boxHd;": "╤",
  32166. "boxhD;": "╥",
  32167. "boxhd;": "┬",
  32168. "boxHU;": "╩",
  32169. "boxHu;": "╧",
  32170. "boxhU;": "╨",
  32171. "boxhu;": "┴",
  32172. "boxUL;": "╝",
  32173. "boxUl;": "╜",
  32174. "boxuL;": "╛",
  32175. "boxul;": "┘",
  32176. "boxUR;": "╚",
  32177. "boxUr;": "╙",
  32178. "boxuR;": "╘",
  32179. "boxur;": "└",
  32180. "boxVH;": "╬",
  32181. "boxVh;": "╫",
  32182. "boxvH;": "╪",
  32183. "boxvh;": "┼",
  32184. "boxVL;": "╣",
  32185. "boxVl;": "╢",
  32186. "boxvL;": "╡",
  32187. "boxvl;": "┤",
  32188. "boxVR;": "╠",
  32189. "boxVr;": "╟",
  32190. "boxvR;": "╞",
  32191. "boxvr;": "├",
  32192. "Breve;": "˘",
  32193. "breve;": "˘",
  32194. brvbar: "¦",
  32195. "bsemi;": "⁏",
  32196. "bsime;": "⋍",
  32197. "bsolb;": "⧅",
  32198. "bumpE;": "⪮",
  32199. "bumpe;": "≏",
  32200. "caret;": "⁁",
  32201. "caron;": "ˇ",
  32202. "ccaps;": "⩍",
  32203. Ccedil: "Ç",
  32204. ccedil: "ç",
  32205. "Ccirc;": "Ĉ",
  32206. "ccirc;": "ĉ",
  32207. "ccups;": "⩌",
  32208. "cedil;": "¸",
  32209. "check;": "✓",
  32210. "clubs;": "♣",
  32211. "Colon;": "∷",
  32212. "colon;": ":",
  32213. "comma;": ",",
  32214. "crarr;": "↵",
  32215. "Cross;": "⨯",
  32216. "cross;": "✗",
  32217. "csube;": "⫑",
  32218. "csupe;": "⫒",
  32219. "ctdot;": "⋯",
  32220. "cuepr;": "⋞",
  32221. "cuesc;": "⋟",
  32222. "cupor;": "⩅",
  32223. curren: "¤",
  32224. "cuvee;": "⋎",
  32225. "cuwed;": "⋏",
  32226. "cwint;": "∱",
  32227. "Dashv;": "⫤",
  32228. "dashv;": "⊣",
  32229. "dblac;": "˝",
  32230. "ddarr;": "⇊",
  32231. "Delta;": "Δ",
  32232. "delta;": "δ",
  32233. "dharl;": "⇃",
  32234. "dharr;": "⇂",
  32235. "diams;": "♦",
  32236. "disin;": "⋲",
  32237. divide: "÷",
  32238. "doteq;": "≐",
  32239. "dtdot;": "⋱",
  32240. "dtrif;": "▾",
  32241. "duarr;": "⇵",
  32242. "duhar;": "⥯",
  32243. Eacute: "É",
  32244. eacute: "é",
  32245. "Ecirc;": "Ê",
  32246. "ecirc;": "ê",
  32247. "eDDot;": "⩷",
  32248. "efDot;": "≒",
  32249. Egrave: "È",
  32250. egrave: "è",
  32251. "Emacr;": "Ē",
  32252. "emacr;": "ē",
  32253. "empty;": "∅",
  32254. "Eogon;": "Ę",
  32255. "eogon;": "ę",
  32256. "eplus;": "⩱",
  32257. "epsiv;": "ϵ",
  32258. "eqsim;": "≂",
  32259. "Equal;": "⩵",
  32260. "equiv;": "≡",
  32261. "erarr;": "⥱",
  32262. "erDot;": "≓",
  32263. "esdot;": "≐",
  32264. "exist;": "∃",
  32265. "fflig;": "ff",
  32266. "filig;": "fi",
  32267. "fjlig;": "fj",
  32268. "fllig;": "fl",
  32269. "fltns;": "▱",
  32270. "forkv;": "⫙",
  32271. frac12: "½",
  32272. frac14: "¼",
  32273. frac34: "¾",
  32274. "frasl;": "⁄",
  32275. "frown;": "⌢",
  32276. "Gamma;": "Γ",
  32277. "gamma;": "γ",
  32278. "Gcirc;": "Ĝ",
  32279. "gcirc;": "ĝ",
  32280. "gescc;": "⪩",
  32281. "gimel;": "ℷ",
  32282. "gneqq;": "≩",
  32283. "gnsim;": "⋧",
  32284. "grave;": "`",
  32285. "gsime;": "⪎",
  32286. "gsiml;": "⪐",
  32287. "gtcir;": "⩺",
  32288. "gtdot;": "⋗",
  32289. "Hacek;": "ˇ",
  32290. "harrw;": "↭",
  32291. "Hcirc;": "Ĥ",
  32292. "hcirc;": "ĥ",
  32293. "hoarr;": "⇿",
  32294. Iacute: "Í",
  32295. iacute: "í",
  32296. "Icirc;": "Î",
  32297. "icirc;": "î",
  32298. "iexcl;": "¡",
  32299. Igrave: "Ì",
  32300. igrave: "ì",
  32301. "iiint;": "∭",
  32302. "iiota;": "℩",
  32303. "IJlig;": "IJ",
  32304. "ijlig;": "ij",
  32305. "Imacr;": "Ī",
  32306. "imacr;": "ī",
  32307. "image;": "ℑ",
  32308. "imath;": "ı",
  32309. "imped;": "Ƶ",
  32310. "infin;": "∞",
  32311. "Iogon;": "Į",
  32312. "iogon;": "į",
  32313. "iprod;": "⨼",
  32314. iquest: "¿",
  32315. "isinE;": "⋹",
  32316. "isins;": "⋴",
  32317. "isinv;": "∈",
  32318. "Iukcy;": "І",
  32319. "iukcy;": "і",
  32320. "Jcirc;": "Ĵ",
  32321. "jcirc;": "ĵ",
  32322. "jmath;": "ȷ",
  32323. "Jukcy;": "Є",
  32324. "jukcy;": "є",
  32325. "Kappa;": "Κ",
  32326. "kappa;": "κ",
  32327. "lAarr;": "⇚",
  32328. "langd;": "⦑",
  32329. "laquo;": "«",
  32330. "larrb;": "⇤",
  32331. "lates;": "⪭︀",
  32332. "lBarr;": "⤎",
  32333. "lbarr;": "⤌",
  32334. "lbbrk;": "❲",
  32335. "lbrke;": "⦋",
  32336. "lceil;": "⌈",
  32337. "ldquo;": "“",
  32338. "lescc;": "⪨",
  32339. "lhard;": "↽",
  32340. "lharu;": "↼",
  32341. "lhblk;": "▄",
  32342. "llarr;": "⇇",
  32343. "lltri;": "◺",
  32344. "lneqq;": "≨",
  32345. "lnsim;": "⋦",
  32346. "loang;": "⟬",
  32347. "loarr;": "⇽",
  32348. "lobrk;": "⟦",
  32349. "lopar;": "⦅",
  32350. "lrarr;": "⇆",
  32351. "lrhar;": "⇋",
  32352. "lrtri;": "⊿",
  32353. "lsime;": "⪍",
  32354. "lsimg;": "⪏",
  32355. "lsquo;": "‘",
  32356. "ltcir;": "⩹",
  32357. "ltdot;": "⋖",
  32358. "ltrie;": "⊴",
  32359. "ltrif;": "◂",
  32360. "mdash;": "—",
  32361. "mDDot;": "∺",
  32362. "micro;": "µ",
  32363. middot: "·",
  32364. "minus;": "−",
  32365. "mumap;": "⊸",
  32366. "nabla;": "∇",
  32367. "napid;": "≋̸",
  32368. "napos;": "ʼn",
  32369. "natur;": "♮",
  32370. "nbump;": "≎̸",
  32371. "ncong;": "≇",
  32372. "ndash;": "–",
  32373. "neArr;": "⇗",
  32374. "nearr;": "↗",
  32375. "nedot;": "≐̸",
  32376. "nesim;": "≂̸",
  32377. "ngeqq;": "≧̸",
  32378. "ngsim;": "≵",
  32379. "nhArr;": "⇎",
  32380. "nharr;": "↮",
  32381. "nhpar;": "⫲",
  32382. "nlArr;": "⇍",
  32383. "nlarr;": "↚",
  32384. "nleqq;": "≦̸",
  32385. "nless;": "≮",
  32386. "nlsim;": "≴",
  32387. "nltri;": "⋪",
  32388. "notin;": "∉",
  32389. "notni;": "∌",
  32390. "npart;": "∂̸",
  32391. "nprec;": "⊀",
  32392. "nrArr;": "⇏",
  32393. "nrarr;": "↛",
  32394. "nrtri;": "⋫",
  32395. "nsime;": "≄",
  32396. "nsmid;": "∤",
  32397. "nspar;": "∦",
  32398. "nsubE;": "⫅̸",
  32399. "nsube;": "⊈",
  32400. "nsucc;": "⊁",
  32401. "nsupE;": "⫆̸",
  32402. "nsupe;": "⊉",
  32403. Ntilde: "Ñ",
  32404. ntilde: "ñ",
  32405. "numsp;": " ",
  32406. "nvsim;": "∼⃒",
  32407. "nwArr;": "⇖",
  32408. "nwarr;": "↖",
  32409. Oacute: "Ó",
  32410. oacute: "ó",
  32411. "Ocirc;": "Ô",
  32412. "ocirc;": "ô",
  32413. "odash;": "⊝",
  32414. "OElig;": "Œ",
  32415. "oelig;": "œ",
  32416. "ofcir;": "⦿",
  32417. Ograve: "Ò",
  32418. ograve: "ò",
  32419. "ohbar;": "⦵",
  32420. "olarr;": "↺",
  32421. "olcir;": "⦾",
  32422. "oline;": "‾",
  32423. "Omacr;": "Ō",
  32424. "omacr;": "ō",
  32425. "Omega;": "Ω",
  32426. "omega;": "ω",
  32427. "operp;": "⦹",
  32428. "oplus;": "⊕",
  32429. "orarr;": "↻",
  32430. "order;": "ℴ",
  32431. Oslash: "Ø",
  32432. oslash: "ø",
  32433. Otilde: "Õ",
  32434. otilde: "õ",
  32435. "ovbar;": "⌽",
  32436. "parsl;": "⫽",
  32437. "phone;": "☎",
  32438. "plusb;": "⊞",
  32439. "pluse;": "⩲",
  32440. plusmn: "±",
  32441. "pound;": "£",
  32442. "prcue;": "≼",
  32443. "Prime;": "″",
  32444. "prime;": "′",
  32445. "prnap;": "⪹",
  32446. "prsim;": "≾",
  32447. "quest;": "?",
  32448. "rAarr;": "⇛",
  32449. "radic;": "√",
  32450. "rangd;": "⦒",
  32451. "range;": "⦥",
  32452. "raquo;": "»",
  32453. "rarrb;": "⇥",
  32454. "rarrc;": "⤳",
  32455. "rarrw;": "↝",
  32456. "ratio;": "∶",
  32457. "RBarr;": "⤐",
  32458. "rBarr;": "⤏",
  32459. "rbarr;": "⤍",
  32460. "rbbrk;": "❳",
  32461. "rbrke;": "⦌",
  32462. "rceil;": "⌉",
  32463. "rdquo;": "”",
  32464. "reals;": "ℝ",
  32465. "rhard;": "⇁",
  32466. "rharu;": "⇀",
  32467. "rlarr;": "⇄",
  32468. "rlhar;": "⇌",
  32469. "rnmid;": "⫮",
  32470. "roang;": "⟭",
  32471. "roarr;": "⇾",
  32472. "robrk;": "⟧",
  32473. "ropar;": "⦆",
  32474. "rrarr;": "⇉",
  32475. "rsquo;": "’",
  32476. "rtrie;": "⊵",
  32477. "rtrif;": "▸",
  32478. "sbquo;": "‚",
  32479. "sccue;": "≽",
  32480. "Scirc;": "Ŝ",
  32481. "scirc;": "ŝ",
  32482. "scnap;": "⪺",
  32483. "scsim;": "≿",
  32484. "sdotb;": "⊡",
  32485. "sdote;": "⩦",
  32486. "seArr;": "⇘",
  32487. "searr;": "↘",
  32488. "setmn;": "∖",
  32489. "sharp;": "♯",
  32490. "Sigma;": "Σ",
  32491. "sigma;": "σ",
  32492. "simeq;": "≃",
  32493. "simgE;": "⪠",
  32494. "simlE;": "⪟",
  32495. "simne;": "≆",
  32496. "slarr;": "←",
  32497. "smile;": "⌣",
  32498. "smtes;": "⪬︀",
  32499. "sqcap;": "⊓",
  32500. "sqcup;": "⊔",
  32501. "sqsub;": "⊏",
  32502. "sqsup;": "⊐",
  32503. "srarr;": "→",
  32504. "starf;": "★",
  32505. "strns;": "¯",
  32506. "subnE;": "⫋",
  32507. "subne;": "⊊",
  32508. "supnE;": "⫌",
  32509. "supne;": "⊋",
  32510. "swArr;": "⇙",
  32511. "swarr;": "↙",
  32512. "szlig;": "ß",
  32513. "Theta;": "Θ",
  32514. "theta;": "θ",
  32515. "thkap;": "≈",
  32516. "THORN;": "Þ",
  32517. "thorn;": "þ",
  32518. "Tilde;": "∼",
  32519. "tilde;": "˜",
  32520. "times;": "×",
  32521. "TRADE;": "™",
  32522. "trade;": "™",
  32523. "trisb;": "⧍",
  32524. "TSHcy;": "Ћ",
  32525. "tshcy;": "ћ",
  32526. "twixt;": "≬",
  32527. Uacute: "Ú",
  32528. uacute: "ú",
  32529. "Ubrcy;": "Ў",
  32530. "ubrcy;": "ў",
  32531. "Ucirc;": "Û",
  32532. "ucirc;": "û",
  32533. "udarr;": "⇅",
  32534. "udhar;": "⥮",
  32535. Ugrave: "Ù",
  32536. ugrave: "ù",
  32537. "uharl;": "↿",
  32538. "uharr;": "↾",
  32539. "uhblk;": "▀",
  32540. "ultri;": "◸",
  32541. "Umacr;": "Ū",
  32542. "umacr;": "ū",
  32543. "Union;": "⋃",
  32544. "Uogon;": "Ų",
  32545. "uogon;": "ų",
  32546. "uplus;": "⊎",
  32547. "upsih;": "ϒ",
  32548. "UpTee;": "⊥",
  32549. "Uring;": "Ů",
  32550. "uring;": "ů",
  32551. "urtri;": "◹",
  32552. "utdot;": "⋰",
  32553. "utrif;": "▴",
  32554. "uuarr;": "⇈",
  32555. "varpi;": "ϖ",
  32556. "vBarv;": "⫩",
  32557. "VDash;": "⊫",
  32558. "Vdash;": "⊩",
  32559. "vDash;": "⊨",
  32560. "vdash;": "⊢",
  32561. "veeeq;": "≚",
  32562. "vltri;": "⊲",
  32563. "vnsub;": "⊂⃒",
  32564. "vnsup;": "⊃⃒",
  32565. "vprop;": "∝",
  32566. "vrtri;": "⊳",
  32567. "Wcirc;": "Ŵ",
  32568. "wcirc;": "ŵ",
  32569. "Wedge;": "⋀",
  32570. "wedge;": "∧",
  32571. "xcirc;": "◯",
  32572. "xdtri;": "▽",
  32573. "xhArr;": "⟺",
  32574. "xharr;": "⟷",
  32575. "xlArr;": "⟸",
  32576. "xlarr;": "⟵",
  32577. "xodot;": "⨀",
  32578. "xrArr;": "⟹",
  32579. "xrarr;": "⟶",
  32580. "xutri;": "△",
  32581. Yacute: "Ý",
  32582. yacute: "ý",
  32583. "Ycirc;": "Ŷ",
  32584. "ycirc;": "ŷ",
  32585. "Aacute;": "Á",
  32586. "aacute;": "á",
  32587. "Abreve;": "Ă",
  32588. "abreve;": "ă",
  32589. "Agrave;": "À",
  32590. "agrave;": "à",
  32591. "andand;": "⩕",
  32592. "angmsd;": "∡",
  32593. "angsph;": "∢",
  32594. "apacir;": "⩯",
  32595. "approx;": "≈",
  32596. "Assign;": "≔",
  32597. "Atilde;": "Ã",
  32598. "atilde;": "ã",
  32599. "barvee;": "⊽",
  32600. "Barwed;": "⌆",
  32601. "barwed;": "⌅",
  32602. "becaus;": "∵",
  32603. "bernou;": "ℬ",
  32604. "bigcap;": "⋂",
  32605. "bigcup;": "⋃",
  32606. "bigvee;": "⋁",
  32607. "bkarow;": "⤍",
  32608. "bottom;": "⊥",
  32609. "bowtie;": "⋈",
  32610. "boxbox;": "⧉",
  32611. "bprime;": "‵",
  32612. "brvbar;": "¦",
  32613. "bullet;": "•",
  32614. "Bumpeq;": "≎",
  32615. "bumpeq;": "≏",
  32616. "Cacute;": "Ć",
  32617. "cacute;": "ć",
  32618. "capand;": "⩄",
  32619. "capcap;": "⩋",
  32620. "capcup;": "⩇",
  32621. "capdot;": "⩀",
  32622. "Ccaron;": "Č",
  32623. "ccaron;": "č",
  32624. "Ccedil;": "Ç",
  32625. "ccedil;": "ç",
  32626. "circeq;": "≗",
  32627. "cirmid;": "⫯",
  32628. "Colone;": "⩴",
  32629. "colone;": "≔",
  32630. "commat;": "@",
  32631. "compfn;": "∘",
  32632. "Conint;": "∯",
  32633. "conint;": "∮",
  32634. "coprod;": "∐",
  32635. "copysr;": "℗",
  32636. "cularr;": "↶",
  32637. "CupCap;": "≍",
  32638. "cupcap;": "⩆",
  32639. "cupcup;": "⩊",
  32640. "cupdot;": "⊍",
  32641. "curarr;": "↷",
  32642. "curren;": "¤",
  32643. "cylcty;": "⌭",
  32644. "Dagger;": "‡",
  32645. "dagger;": "†",
  32646. "daleth;": "ℸ",
  32647. "Dcaron;": "Ď",
  32648. "dcaron;": "ď",
  32649. "dfisht;": "⥿",
  32650. "divide;": "÷",
  32651. "divonx;": "⋇",
  32652. "dlcorn;": "⌞",
  32653. "dlcrop;": "⌍",
  32654. "dollar;": "$",
  32655. "DotDot;": "⃜",
  32656. "drcorn;": "⌟",
  32657. "drcrop;": "⌌",
  32658. "Dstrok;": "Đ",
  32659. "dstrok;": "đ",
  32660. "Eacute;": "É",
  32661. "eacute;": "é",
  32662. "easter;": "⩮",
  32663. "Ecaron;": "Ě",
  32664. "ecaron;": "ě",
  32665. "ecolon;": "≕",
  32666. "Egrave;": "È",
  32667. "egrave;": "è",
  32668. "egsdot;": "⪘",
  32669. "elsdot;": "⪗",
  32670. "emptyv;": "∅",
  32671. "emsp13;": " ",
  32672. "emsp14;": " ",
  32673. "eparsl;": "⧣",
  32674. "eqcirc;": "≖",
  32675. "equals;": "=",
  32676. "equest;": "≟",
  32677. "Exists;": "∃",
  32678. "female;": "♀",
  32679. "ffilig;": "ffi",
  32680. "ffllig;": "ffl",
  32681. "ForAll;": "∀",
  32682. "forall;": "∀",
  32683. "frac12;": "½",
  32684. "frac13;": "⅓",
  32685. "frac14;": "¼",
  32686. "frac15;": "⅕",
  32687. "frac16;": "⅙",
  32688. "frac18;": "⅛",
  32689. "frac23;": "⅔",
  32690. "frac25;": "⅖",
  32691. "frac34;": "¾",
  32692. "frac35;": "⅗",
  32693. "frac38;": "⅜",
  32694. "frac45;": "⅘",
  32695. "frac56;": "⅚",
  32696. "frac58;": "⅝",
  32697. "frac78;": "⅞",
  32698. "gacute;": "ǵ",
  32699. "Gammad;": "Ϝ",
  32700. "gammad;": "ϝ",
  32701. "Gbreve;": "Ğ",
  32702. "gbreve;": "ğ",
  32703. "Gcedil;": "Ģ",
  32704. "gesdot;": "⪀",
  32705. "gesles;": "⪔",
  32706. "gtlPar;": "⦕",
  32707. "gtrarr;": "⥸",
  32708. "gtrdot;": "⋗",
  32709. "gtrsim;": "≳",
  32710. "hairsp;": " ",
  32711. "hamilt;": "ℋ",
  32712. "HARDcy;": "Ъ",
  32713. "hardcy;": "ъ",
  32714. "hearts;": "♥",
  32715. "hellip;": "…",
  32716. "hercon;": "⊹",
  32717. "homtht;": "∻",
  32718. "horbar;": "―",
  32719. "hslash;": "ℏ",
  32720. "Hstrok;": "Ħ",
  32721. "hstrok;": "ħ",
  32722. "hybull;": "⁃",
  32723. "hyphen;": "‐",
  32724. "Iacute;": "Í",
  32725. "iacute;": "í",
  32726. "Igrave;": "Ì",
  32727. "igrave;": "ì",
  32728. "iiiint;": "⨌",
  32729. "iinfin;": "⧜",
  32730. "incare;": "℅",
  32731. "inodot;": "ı",
  32732. "intcal;": "⊺",
  32733. "iquest;": "¿",
  32734. "isinsv;": "⋳",
  32735. "Itilde;": "Ĩ",
  32736. "itilde;": "ĩ",
  32737. "Jsercy;": "Ј",
  32738. "jsercy;": "ј",
  32739. "kappav;": "ϰ",
  32740. "Kcedil;": "Ķ",
  32741. "kcedil;": "ķ",
  32742. "kgreen;": "ĸ",
  32743. "Lacute;": "Ĺ",
  32744. "lacute;": "ĺ",
  32745. "lagran;": "ℒ",
  32746. "Lambda;": "Λ",
  32747. "lambda;": "λ",
  32748. "langle;": "⟨",
  32749. "larrfs;": "⤝",
  32750. "larrhk;": "↩",
  32751. "larrlp;": "↫",
  32752. "larrpl;": "⤹",
  32753. "larrtl;": "↢",
  32754. "lAtail;": "⤛",
  32755. "latail;": "⤙",
  32756. "lbrace;": "{",
  32757. "lbrack;": "[",
  32758. "Lcaron;": "Ľ",
  32759. "lcaron;": "ľ",
  32760. "Lcedil;": "Ļ",
  32761. "lcedil;": "ļ",
  32762. "ldquor;": "„",
  32763. "lesdot;": "⩿",
  32764. "lesges;": "⪓",
  32765. "lfisht;": "⥼",
  32766. "lfloor;": "⌊",
  32767. "lharul;": "⥪",
  32768. "llhard;": "⥫",
  32769. "Lmidot;": "Ŀ",
  32770. "lmidot;": "ŀ",
  32771. "lmoust;": "⎰",
  32772. "loplus;": "⨭",
  32773. "lowast;": "∗",
  32774. "lowbar;": "_",
  32775. "lparlt;": "⦓",
  32776. "lrhard;": "⥭",
  32777. "lsaquo;": "‹",
  32778. "lsquor;": "‚",
  32779. "Lstrok;": "Ł",
  32780. "lstrok;": "ł",
  32781. "lthree;": "⋋",
  32782. "ltimes;": "⋉",
  32783. "ltlarr;": "⥶",
  32784. "ltrPar;": "⦖",
  32785. "mapsto;": "↦",
  32786. "marker;": "▮",
  32787. "mcomma;": "⨩",
  32788. "midast;": "*",
  32789. "midcir;": "⫰",
  32790. "middot;": "·",
  32791. "minusb;": "⊟",
  32792. "minusd;": "∸",
  32793. "mnplus;": "∓",
  32794. "models;": "⊧",
  32795. "mstpos;": "∾",
  32796. "Nacute;": "Ń",
  32797. "nacute;": "ń",
  32798. "nbumpe;": "≏̸",
  32799. "Ncaron;": "Ň",
  32800. "ncaron;": "ň",
  32801. "Ncedil;": "Ņ",
  32802. "ncedil;": "ņ",
  32803. "nearhk;": "⤤",
  32804. "nequiv;": "≢",
  32805. "nesear;": "⤨",
  32806. "nexist;": "∄",
  32807. "nltrie;": "⋬",
  32808. "notinE;": "⋹̸",
  32809. "nparsl;": "⫽⃥",
  32810. "nprcue;": "⋠",
  32811. "nrarrc;": "⤳̸",
  32812. "nrarrw;": "↝̸",
  32813. "nrtrie;": "⋭",
  32814. "nsccue;": "⋡",
  32815. "nsimeq;": "≄",
  32816. "Ntilde;": "Ñ",
  32817. "ntilde;": "ñ",
  32818. "numero;": "№",
  32819. "nVDash;": "⊯",
  32820. "nVdash;": "⊮",
  32821. "nvDash;": "⊭",
  32822. "nvdash;": "⊬",
  32823. "nvHarr;": "⤄",
  32824. "nvlArr;": "⤂",
  32825. "nvrArr;": "⤃",
  32826. "nwarhk;": "⤣",
  32827. "nwnear;": "⤧",
  32828. "Oacute;": "Ó",
  32829. "oacute;": "ó",
  32830. "Odblac;": "Ő",
  32831. "odblac;": "ő",
  32832. "odsold;": "⦼",
  32833. "Ograve;": "Ò",
  32834. "ograve;": "ò",
  32835. "ominus;": "⊖",
  32836. "origof;": "⊶",
  32837. "Oslash;": "Ø",
  32838. "oslash;": "ø",
  32839. "Otilde;": "Õ",
  32840. "otilde;": "õ",
  32841. "Otimes;": "⨷",
  32842. "otimes;": "⊗",
  32843. "parsim;": "⫳",
  32844. "percnt;": "%",
  32845. "period;": ".",
  32846. "permil;": "‰",
  32847. "phmmat;": "ℳ",
  32848. "planck;": "ℏ",
  32849. "plankv;": "ℏ",
  32850. "plusdo;": "∔",
  32851. "plusdu;": "⨥",
  32852. "plusmn;": "±",
  32853. "preceq;": "⪯",
  32854. "primes;": "ℙ",
  32855. "prnsim;": "⋨",
  32856. "propto;": "∝",
  32857. "prurel;": "⊰",
  32858. "puncsp;": " ",
  32859. "qprime;": "⁗",
  32860. "Racute;": "Ŕ",
  32861. "racute;": "ŕ",
  32862. "rangle;": "⟩",
  32863. "rarrap;": "⥵",
  32864. "rarrfs;": "⤞",
  32865. "rarrhk;": "↪",
  32866. "rarrlp;": "↬",
  32867. "rarrpl;": "⥅",
  32868. "Rarrtl;": "⤖",
  32869. "rarrtl;": "↣",
  32870. "rAtail;": "⤜",
  32871. "ratail;": "⤚",
  32872. "rbrace;": "}",
  32873. "rbrack;": "]",
  32874. "Rcaron;": "Ř",
  32875. "rcaron;": "ř",
  32876. "Rcedil;": "Ŗ",
  32877. "rcedil;": "ŗ",
  32878. "rdquor;": "”",
  32879. "rfisht;": "⥽",
  32880. "rfloor;": "⌋",
  32881. "rharul;": "⥬",
  32882. "rmoust;": "⎱",
  32883. "roplus;": "⨮",
  32884. "rpargt;": "⦔",
  32885. "rsaquo;": "›",
  32886. "rsquor;": "’",
  32887. "rthree;": "⋌",
  32888. "rtimes;": "⋊",
  32889. "Sacute;": "Ś",
  32890. "sacute;": "ś",
  32891. "Scaron;": "Š",
  32892. "scaron;": "š",
  32893. "Scedil;": "Ş",
  32894. "scedil;": "ş",
  32895. "scnsim;": "⋩",
  32896. "searhk;": "⤥",
  32897. "seswar;": "⤩",
  32898. "sfrown;": "⌢",
  32899. "SHCHcy;": "Щ",
  32900. "shchcy;": "щ",
  32901. "sigmaf;": "ς",
  32902. "sigmav;": "ς",
  32903. "simdot;": "⩪",
  32904. "smashp;": "⨳",
  32905. "SOFTcy;": "Ь",
  32906. "softcy;": "ь",
  32907. "solbar;": "⌿",
  32908. "spades;": "♠",
  32909. "sqcaps;": "⊓︀",
  32910. "sqcups;": "⊔︀",
  32911. "sqsube;": "⊑",
  32912. "sqsupe;": "⊒",
  32913. "Square;": "□",
  32914. "square;": "□",
  32915. "squarf;": "▪",
  32916. "ssetmn;": "∖",
  32917. "ssmile;": "⌣",
  32918. "sstarf;": "⋆",
  32919. "subdot;": "⪽",
  32920. "Subset;": "⋐",
  32921. "subset;": "⊂",
  32922. "subsim;": "⫇",
  32923. "subsub;": "⫕",
  32924. "subsup;": "⫓",
  32925. "succeq;": "⪰",
  32926. "supdot;": "⪾",
  32927. "Supset;": "⋑",
  32928. "supset;": "⊃",
  32929. "supsim;": "⫈",
  32930. "supsub;": "⫔",
  32931. "supsup;": "⫖",
  32932. "swarhk;": "⤦",
  32933. "swnwar;": "⤪",
  32934. "target;": "⌖",
  32935. "Tcaron;": "Ť",
  32936. "tcaron;": "ť",
  32937. "Tcedil;": "Ţ",
  32938. "tcedil;": "ţ",
  32939. "telrec;": "⌕",
  32940. "there4;": "∴",
  32941. "thetav;": "ϑ",
  32942. "thinsp;": " ",
  32943. "thksim;": "∼",
  32944. "timesb;": "⊠",
  32945. "timesd;": "⨰",
  32946. "topbot;": "⌶",
  32947. "topcir;": "⫱",
  32948. "tprime;": "‴",
  32949. "tridot;": "◬",
  32950. "Tstrok;": "Ŧ",
  32951. "tstrok;": "ŧ",
  32952. "Uacute;": "Ú",
  32953. "uacute;": "ú",
  32954. "Ubreve;": "Ŭ",
  32955. "ubreve;": "ŭ",
  32956. "Udblac;": "Ű",
  32957. "udblac;": "ű",
  32958. "ufisht;": "⥾",
  32959. "Ugrave;": "Ù",
  32960. "ugrave;": "ù",
  32961. "ulcorn;": "⌜",
  32962. "ulcrop;": "⌏",
  32963. "urcorn;": "⌝",
  32964. "urcrop;": "⌎",
  32965. "Utilde;": "Ũ",
  32966. "utilde;": "ũ",
  32967. "vangrt;": "⦜",
  32968. "varphi;": "ϕ",
  32969. "varrho;": "ϱ",
  32970. "Vdashl;": "⫦",
  32971. "veebar;": "⊻",
  32972. "vellip;": "⋮",
  32973. "Verbar;": "‖",
  32974. "verbar;": "|",
  32975. "vsubnE;": "⫋︀",
  32976. "vsubne;": "⊊︀",
  32977. "vsupnE;": "⫌︀",
  32978. "vsupne;": "⊋︀",
  32979. "Vvdash;": "⊪",
  32980. "wedbar;": "⩟",
  32981. "wedgeq;": "≙",
  32982. "weierp;": "℘",
  32983. "wreath;": "≀",
  32984. "xoplus;": "⨁",
  32985. "xotime;": "⨂",
  32986. "xsqcup;": "⨆",
  32987. "xuplus;": "⨄",
  32988. "xwedge;": "⋀",
  32989. "Yacute;": "Ý",
  32990. "yacute;": "ý",
  32991. "Zacute;": "Ź",
  32992. "zacute;": "ź",
  32993. "Zcaron;": "Ž",
  32994. "zcaron;": "ž",
  32995. "zeetrf;": "ℨ",
  32996. "alefsym;": "ℵ",
  32997. "angrtvb;": "⊾",
  32998. "angzarr;": "⍼",
  32999. "asympeq;": "≍",
  33000. "backsim;": "∽",
  33001. "Because;": "∵",
  33002. "because;": "∵",
  33003. "bemptyv;": "⦰",
  33004. "between;": "≬",
  33005. "bigcirc;": "◯",
  33006. "bigodot;": "⨀",
  33007. "bigstar;": "★",
  33008. "bnequiv;": "≡⃥",
  33009. "boxplus;": "⊞",
  33010. "Cayleys;": "ℭ",
  33011. "Cconint;": "∰",
  33012. "ccupssm;": "⩐",
  33013. "Cedilla;": "¸",
  33014. "cemptyv;": "⦲",
  33015. "cirscir;": "⧂",
  33016. "coloneq;": "≔",
  33017. "congdot;": "⩭",
  33018. "cudarrl;": "⤸",
  33019. "cudarrr;": "⤵",
  33020. "cularrp;": "⤽",
  33021. "curarrm;": "⤼",
  33022. "dbkarow;": "⤏",
  33023. "ddagger;": "‡",
  33024. "ddotseq;": "⩷",
  33025. "demptyv;": "⦱",
  33026. "Diamond;": "⋄",
  33027. "diamond;": "⋄",
  33028. "digamma;": "ϝ",
  33029. "dotplus;": "∔",
  33030. "DownTee;": "⊤",
  33031. "dwangle;": "⦦",
  33032. "Element;": "∈",
  33033. "Epsilon;": "Ε",
  33034. "epsilon;": "ε",
  33035. "eqcolon;": "≕",
  33036. "equivDD;": "⩸",
  33037. "gesdoto;": "⪂",
  33038. "gtquest;": "⩼",
  33039. "gtrless;": "≷",
  33040. "harrcir;": "⥈",
  33041. "Implies;": "⇒",
  33042. "intprod;": "⨼",
  33043. "isindot;": "⋵",
  33044. "larrbfs;": "⤟",
  33045. "larrsim;": "⥳",
  33046. "lbrksld;": "⦏",
  33047. "lbrkslu;": "⦍",
  33048. "ldrdhar;": "⥧",
  33049. "LeftTee;": "⊣",
  33050. "lesdoto;": "⪁",
  33051. "lessdot;": "⋖",
  33052. "lessgtr;": "≶",
  33053. "lesssim;": "≲",
  33054. "lotimes;": "⨴",
  33055. "lozenge;": "◊",
  33056. "ltquest;": "⩻",
  33057. "luruhar;": "⥦",
  33058. "maltese;": "✠",
  33059. "minusdu;": "⨪",
  33060. "napprox;": "≉",
  33061. "natural;": "♮",
  33062. "nearrow;": "↗",
  33063. "NewLine;": "\n",
  33064. "nexists;": "∄",
  33065. "NoBreak;": "⁠",
  33066. "notinva;": "∉",
  33067. "notinvb;": "⋷",
  33068. "notinvc;": "⋶",
  33069. "NotLess;": "≮",
  33070. "notniva;": "∌",
  33071. "notnivb;": "⋾",
  33072. "notnivc;": "⋽",
  33073. "npolint;": "⨔",
  33074. "npreceq;": "⪯̸",
  33075. "nsqsube;": "⋢",
  33076. "nsqsupe;": "⋣",
  33077. "nsubset;": "⊂⃒",
  33078. "nsucceq;": "⪰̸",
  33079. "nsupset;": "⊃⃒",
  33080. "nvinfin;": "⧞",
  33081. "nvltrie;": "⊴⃒",
  33082. "nvrtrie;": "⊵⃒",
  33083. "nwarrow;": "↖",
  33084. "olcross;": "⦻",
  33085. "Omicron;": "Ο",
  33086. "omicron;": "ο",
  33087. "orderof;": "ℴ",
  33088. "orslope;": "⩗",
  33089. "OverBar;": "‾",
  33090. "pertenk;": "‱",
  33091. "planckh;": "ℎ",
  33092. "pluscir;": "⨢",
  33093. "plussim;": "⨦",
  33094. "plustwo;": "⨧",
  33095. "precsim;": "≾",
  33096. "Product;": "∏",
  33097. "quatint;": "⨖",
  33098. "questeq;": "≟",
  33099. "rarrbfs;": "⤠",
  33100. "rarrsim;": "⥴",
  33101. "rbrksld;": "⦎",
  33102. "rbrkslu;": "⦐",
  33103. "rdldhar;": "⥩",
  33104. "realine;": "ℛ",
  33105. "rotimes;": "⨵",
  33106. "ruluhar;": "⥨",
  33107. "searrow;": "↘",
  33108. "simplus;": "⨤",
  33109. "simrarr;": "⥲",
  33110. "subedot;": "⫃",
  33111. "submult;": "⫁",
  33112. "subplus;": "⪿",
  33113. "subrarr;": "⥹",
  33114. "succsim;": "≿",
  33115. "supdsub;": "⫘",
  33116. "supedot;": "⫄",
  33117. "suphsol;": "⟉",
  33118. "suphsub;": "⫗",
  33119. "suplarr;": "⥻",
  33120. "supmult;": "⫂",
  33121. "supplus;": "⫀",
  33122. "swarrow;": "↙",
  33123. "topfork;": "⫚",
  33124. "triplus;": "⨹",
  33125. "tritime;": "⨻",
  33126. "UpArrow;": "↑",
  33127. "Uparrow;": "⇑",
  33128. "uparrow;": "↑",
  33129. "Upsilon;": "Υ",
  33130. "upsilon;": "υ",
  33131. "uwangle;": "⦧",
  33132. "vzigzag;": "⦚",
  33133. "zigrarr;": "⇝",
  33134. "andslope;": "⩘",
  33135. "angmsdaa;": "⦨",
  33136. "angmsdab;": "⦩",
  33137. "angmsdac;": "⦪",
  33138. "angmsdad;": "⦫",
  33139. "angmsdae;": "⦬",
  33140. "angmsdaf;": "⦭",
  33141. "angmsdag;": "⦮",
  33142. "angmsdah;": "⦯",
  33143. "angrtvbd;": "⦝",
  33144. "approxeq;": "≊",
  33145. "awconint;": "∳",
  33146. "backcong;": "≌",
  33147. "barwedge;": "⌅",
  33148. "bbrktbrk;": "⎶",
  33149. "bigoplus;": "⨁",
  33150. "bigsqcup;": "⨆",
  33151. "biguplus;": "⨄",
  33152. "bigwedge;": "⋀",
  33153. "boxminus;": "⊟",
  33154. "boxtimes;": "⊠",
  33155. "bsolhsub;": "⟈",
  33156. "capbrcup;": "⩉",
  33157. "circledR;": "®",
  33158. "circledS;": "Ⓢ",
  33159. "cirfnint;": "⨐",
  33160. "clubsuit;": "♣",
  33161. "cupbrcap;": "⩈",
  33162. "curlyvee;": "⋎",
  33163. "cwconint;": "∲",
  33164. "DDotrahd;": "⤑",
  33165. "doteqdot;": "≑",
  33166. "DotEqual;": "≐",
  33167. "dotminus;": "∸",
  33168. "drbkarow;": "⤐",
  33169. "dzigrarr;": "⟿",
  33170. "elinters;": "⏧",
  33171. "emptyset;": "∅",
  33172. "eqvparsl;": "⧥",
  33173. "fpartint;": "⨍",
  33174. "geqslant;": "⩾",
  33175. "gesdotol;": "⪄",
  33176. "gnapprox;": "⪊",
  33177. "hksearow;": "⤥",
  33178. "hkswarow;": "⤦",
  33179. "imagline;": "ℐ",
  33180. "imagpart;": "ℑ",
  33181. "infintie;": "⧝",
  33182. "integers;": "ℤ",
  33183. "Integral;": "∫",
  33184. "intercal;": "⊺",
  33185. "intlarhk;": "⨗",
  33186. "laemptyv;": "⦴",
  33187. "ldrushar;": "⥋",
  33188. "leqslant;": "⩽",
  33189. "lesdotor;": "⪃",
  33190. "LessLess;": "⪡",
  33191. "llcorner;": "⌞",
  33192. "lnapprox;": "⪉",
  33193. "lrcorner;": "⌟",
  33194. "lurdshar;": "⥊",
  33195. "mapstoup;": "↥",
  33196. "multimap;": "⊸",
  33197. "naturals;": "ℕ",
  33198. "ncongdot;": "⩭̸",
  33199. "NotEqual;": "≠",
  33200. "notindot;": "⋵̸",
  33201. "NotTilde;": "≁",
  33202. "otimesas;": "⨶",
  33203. "parallel;": "∥",
  33204. "PartialD;": "∂",
  33205. "plusacir;": "⨣",
  33206. "pointint;": "⨕",
  33207. "Precedes;": "≺",
  33208. "precneqq;": "⪵",
  33209. "precnsim;": "⋨",
  33210. "profalar;": "⌮",
  33211. "profline;": "⌒",
  33212. "profsurf;": "⌓",
  33213. "raemptyv;": "⦳",
  33214. "realpart;": "ℜ",
  33215. "RightTee;": "⊢",
  33216. "rppolint;": "⨒",
  33217. "rtriltri;": "⧎",
  33218. "scpolint;": "⨓",
  33219. "setminus;": "∖",
  33220. "shortmid;": "∣",
  33221. "smeparsl;": "⧤",
  33222. "sqsubset;": "⊏",
  33223. "sqsupset;": "⊐",
  33224. "subseteq;": "⊆",
  33225. "Succeeds;": "≻",
  33226. "succneqq;": "⪶",
  33227. "succnsim;": "⋩",
  33228. "SuchThat;": "∋",
  33229. "Superset;": "⊃",
  33230. "supseteq;": "⊇",
  33231. "thetasym;": "ϑ",
  33232. "thicksim;": "∼",
  33233. "timesbar;": "⨱",
  33234. "triangle;": "▵",
  33235. "triminus;": "⨺",
  33236. "trpezium;": "⏢",
  33237. "Uarrocir;": "⥉",
  33238. "ulcorner;": "⌜",
  33239. "UnderBar;": "_",
  33240. "urcorner;": "⌝",
  33241. "varkappa;": "ϰ",
  33242. "varsigma;": "ς",
  33243. "vartheta;": "ϑ",
  33244. "backprime;": "‵",
  33245. "backsimeq;": "⋍",
  33246. "Backslash;": "∖",
  33247. "bigotimes;": "⨂",
  33248. "CenterDot;": "·",
  33249. "centerdot;": "·",
  33250. "checkmark;": "✓",
  33251. "CircleDot;": "⊙",
  33252. "complexes;": "ℂ",
  33253. "Congruent;": "≡",
  33254. "Coproduct;": "∐",
  33255. "dotsquare;": "⊡",
  33256. "DoubleDot;": "¨",
  33257. "DownArrow;": "↓",
  33258. "Downarrow;": "⇓",
  33259. "downarrow;": "↓",
  33260. "DownBreve;": "̑",
  33261. "gtrapprox;": "⪆",
  33262. "gtreqless;": "⋛",
  33263. "gvertneqq;": "≩︀",
  33264. "heartsuit;": "♥",
  33265. "HumpEqual;": "≏",
  33266. "LeftArrow;": "←",
  33267. "Leftarrow;": "⇐",
  33268. "leftarrow;": "←",
  33269. "LeftFloor;": "⌊",
  33270. "lesseqgtr;": "⋚",
  33271. "LessTilde;": "≲",
  33272. "lvertneqq;": "≨︀",
  33273. "Mellintrf;": "ℳ",
  33274. "MinusPlus;": "∓",
  33275. "ngeqslant;": "⩾̸",
  33276. "nleqslant;": "⩽̸",
  33277. "NotCupCap;": "≭",
  33278. "NotExists;": "∄",
  33279. "NotSubset;": "⊂⃒",
  33280. "nparallel;": "∦",
  33281. "nshortmid;": "∤",
  33282. "nsubseteq;": "⊈",
  33283. "nsupseteq;": "⊉",
  33284. "OverBrace;": "⏞",
  33285. "pitchfork;": "⋔",
  33286. "PlusMinus;": "±",
  33287. "rationals;": "ℚ",
  33288. "spadesuit;": "♠",
  33289. "subseteqq;": "⫅",
  33290. "subsetneq;": "⊊",
  33291. "supseteqq;": "⫆",
  33292. "supsetneq;": "⊋",
  33293. "Therefore;": "∴",
  33294. "therefore;": "∴",
  33295. "ThinSpace;": " ",
  33296. "triangleq;": "≜",
  33297. "TripleDot;": "⃛",
  33298. "UnionPlus;": "⊎",
  33299. "varpropto;": "∝",
  33300. "Bernoullis;": "ℬ",
  33301. "circledast;": "⊛",
  33302. "CirclePlus;": "⊕",
  33303. "complement;": "∁",
  33304. "curlywedge;": "⋏",
  33305. "eqslantgtr;": "⪖",
  33306. "EqualTilde;": "≂",
  33307. "Fouriertrf;": "ℱ",
  33308. "gtreqqless;": "⪌",
  33309. "ImaginaryI;": "ⅈ",
  33310. "Laplacetrf;": "ℒ",
  33311. "LeftVector;": "↼",
  33312. "lessapprox;": "⪅",
  33313. "lesseqqgtr;": "⪋",
  33314. "Lleftarrow;": "⇚",
  33315. "lmoustache;": "⎰",
  33316. "longmapsto;": "⟼",
  33317. "mapstodown;": "↧",
  33318. "mapstoleft;": "↤",
  33319. "nLeftarrow;": "⇍",
  33320. "nleftarrow;": "↚",
  33321. "NotElement;": "∉",
  33322. "NotGreater;": "≯",
  33323. "nsubseteqq;": "⫅̸",
  33324. "nsupseteqq;": "⫆̸",
  33325. "precapprox;": "⪷",
  33326. "Proportion;": "∷",
  33327. "RightArrow;": "→",
  33328. "Rightarrow;": "⇒",
  33329. "rightarrow;": "→",
  33330. "RightFloor;": "⌋",
  33331. "rmoustache;": "⎱",
  33332. "sqsubseteq;": "⊑",
  33333. "sqsupseteq;": "⊒",
  33334. "subsetneqq;": "⫋",
  33335. "succapprox;": "⪸",
  33336. "supsetneqq;": "⫌",
  33337. "ThickSpace;": "  ",
  33338. "TildeEqual;": "≃",
  33339. "TildeTilde;": "≈",
  33340. "UnderBrace;": "⏟",
  33341. "UpArrowBar;": "⤒",
  33342. "UpTeeArrow;": "↥",
  33343. "upuparrows;": "⇈",
  33344. "varepsilon;": "ϵ",
  33345. "varnothing;": "∅",
  33346. "backepsilon;": "϶",
  33347. "blacksquare;": "▪",
  33348. "circledcirc;": "⊚",
  33349. "circleddash;": "⊝",
  33350. "CircleMinus;": "⊖",
  33351. "CircleTimes;": "⊗",
  33352. "curlyeqprec;": "⋞",
  33353. "curlyeqsucc;": "⋟",
  33354. "diamondsuit;": "♦",
  33355. "eqslantless;": "⪕",
  33356. "Equilibrium;": "⇌",
  33357. "expectation;": "ℰ",
  33358. "GreaterLess;": "≷",
  33359. "LeftCeiling;": "⌈",
  33360. "LessGreater;": "≶",
  33361. "MediumSpace;": " ",
  33362. "NotLessLess;": "≪̸",
  33363. "NotPrecedes;": "⊀",
  33364. "NotSucceeds;": "⊁",
  33365. "NotSuperset;": "⊃⃒",
  33366. "nRightarrow;": "⇏",
  33367. "nrightarrow;": "↛",
  33368. "OverBracket;": "⎴",
  33369. "preccurlyeq;": "≼",
  33370. "precnapprox;": "⪹",
  33371. "quaternions;": "ℍ",
  33372. "RightVector;": "⇀",
  33373. "Rrightarrow;": "⇛",
  33374. "RuleDelayed;": "⧴",
  33375. "SmallCircle;": "∘",
  33376. "SquareUnion;": "⊔",
  33377. "straightphi;": "ϕ",
  33378. "SubsetEqual;": "⊆",
  33379. "succcurlyeq;": "≽",
  33380. "succnapprox;": "⪺",
  33381. "thickapprox;": "≈",
  33382. "UpDownArrow;": "↕",
  33383. "Updownarrow;": "⇕",
  33384. "updownarrow;": "↕",
  33385. "VerticalBar;": "∣",
  33386. "blacklozenge;": "⧫",
  33387. "DownArrowBar;": "⤓",
  33388. "DownTeeArrow;": "↧",
  33389. "ExponentialE;": "ⅇ",
  33390. "exponentiale;": "ⅇ",
  33391. "GreaterEqual;": "≥",
  33392. "GreaterTilde;": "≳",
  33393. "HilbertSpace;": "ℋ",
  33394. "HumpDownHump;": "≎",
  33395. "Intersection;": "⋂",
  33396. "LeftArrowBar;": "⇤",
  33397. "LeftTeeArrow;": "↤",
  33398. "LeftTriangle;": "⊲",
  33399. "LeftUpVector;": "↿",
  33400. "NotCongruent;": "≢",
  33401. "NotHumpEqual;": "≏̸",
  33402. "NotLessEqual;": "≰",
  33403. "NotLessTilde;": "≴",
  33404. "Proportional;": "∝",
  33405. "RightCeiling;": "⌉",
  33406. "risingdotseq;": "≓",
  33407. "RoundImplies;": "⥰",
  33408. "ShortUpArrow;": "↑",
  33409. "SquareSubset;": "⊏",
  33410. "triangledown;": "▿",
  33411. "triangleleft;": "◃",
  33412. "UnderBracket;": "⎵",
  33413. "varsubsetneq;": "⊊︀",
  33414. "varsupsetneq;": "⊋︀",
  33415. "VerticalLine;": "|",
  33416. "ApplyFunction;": "⁡",
  33417. "bigtriangleup;": "△",
  33418. "blacktriangle;": "▴",
  33419. "DifferentialD;": "ⅆ",
  33420. "divideontimes;": "⋇",
  33421. "DoubleLeftTee;": "⫤",
  33422. "DoubleUpArrow;": "⇑",
  33423. "fallingdotseq;": "≒",
  33424. "hookleftarrow;": "↩",
  33425. "leftarrowtail;": "↢",
  33426. "leftharpoonup;": "↼",
  33427. "LeftTeeVector;": "⥚",
  33428. "LeftVectorBar;": "⥒",
  33429. "LessFullEqual;": "≦",
  33430. "LongLeftArrow;": "⟵",
  33431. "Longleftarrow;": "⟸",
  33432. "longleftarrow;": "⟵",
  33433. "looparrowleft;": "↫",
  33434. "measuredangle;": "∡",
  33435. "NotEqualTilde;": "≂̸",
  33436. "NotTildeEqual;": "≄",
  33437. "NotTildeTilde;": "≉",
  33438. "ntriangleleft;": "⋪",
  33439. "Poincareplane;": "ℌ",
  33440. "PrecedesEqual;": "⪯",
  33441. "PrecedesTilde;": "≾",
  33442. "RightArrowBar;": "⇥",
  33443. "RightTeeArrow;": "↦",
  33444. "RightTriangle;": "⊳",
  33445. "RightUpVector;": "↾",
  33446. "shortparallel;": "∥",
  33447. "smallsetminus;": "∖",
  33448. "SucceedsEqual;": "⪰",
  33449. "SucceedsTilde;": "≿",
  33450. "SupersetEqual;": "⊇",
  33451. "triangleright;": "▹",
  33452. "UpEquilibrium;": "⥮",
  33453. "upharpoonleft;": "↿",
  33454. "varsubsetneqq;": "⫋︀",
  33455. "varsupsetneqq;": "⫌︀",
  33456. "VerticalTilde;": "≀",
  33457. "VeryThinSpace;": " ",
  33458. "curvearrowleft;": "↶",
  33459. "DiacriticalDot;": "˙",
  33460. "doublebarwedge;": "⌆",
  33461. "DoubleRightTee;": "⊨",
  33462. "downdownarrows;": "⇊",
  33463. "DownLeftVector;": "↽",
  33464. "GreaterGreater;": "⪢",
  33465. "hookrightarrow;": "↪",
  33466. "HorizontalLine;": "─",
  33467. "InvisibleComma;": "⁣",
  33468. "InvisibleTimes;": "⁢",
  33469. "LeftDownVector;": "⇃",
  33470. "leftleftarrows;": "⇇",
  33471. "LeftRightArrow;": "↔",
  33472. "Leftrightarrow;": "⇔",
  33473. "leftrightarrow;": "↔",
  33474. "leftthreetimes;": "⋋",
  33475. "LessSlantEqual;": "⩽",
  33476. "LongRightArrow;": "⟶",
  33477. "Longrightarrow;": "⟹",
  33478. "longrightarrow;": "⟶",
  33479. "looparrowright;": "↬",
  33480. "LowerLeftArrow;": "↙",
  33481. "NestedLessLess;": "≪",
  33482. "NotGreaterLess;": "≹",
  33483. "NotLessGreater;": "≸",
  33484. "NotSubsetEqual;": "⊈",
  33485. "NotVerticalBar;": "∤",
  33486. "nshortparallel;": "∦",
  33487. "ntriangleright;": "⋫",
  33488. "OpenCurlyQuote;": "‘",
  33489. "ReverseElement;": "∋",
  33490. "rightarrowtail;": "↣",
  33491. "rightharpoonup;": "⇀",
  33492. "RightTeeVector;": "⥛",
  33493. "RightVectorBar;": "⥓",
  33494. "ShortDownArrow;": "↓",
  33495. "ShortLeftArrow;": "←",
  33496. "SquareSuperset;": "⊐",
  33497. "TildeFullEqual;": "≅",
  33498. "trianglelefteq;": "⊴",
  33499. "upharpoonright;": "↾",
  33500. "UpperLeftArrow;": "↖",
  33501. "ZeroWidthSpace;": "​",
  33502. "bigtriangledown;": "▽",
  33503. "circlearrowleft;": "↺",
  33504. "CloseCurlyQuote;": "’",
  33505. "ContourIntegral;": "∮",
  33506. "curvearrowright;": "↷",
  33507. "DoubleDownArrow;": "⇓",
  33508. "DoubleLeftArrow;": "⇐",
  33509. "downharpoonleft;": "⇃",
  33510. "DownRightVector;": "⇁",
  33511. "leftharpoondown;": "↽",
  33512. "leftrightarrows;": "⇆",
  33513. "LeftRightVector;": "⥎",
  33514. "LeftTriangleBar;": "⧏",
  33515. "LeftUpTeeVector;": "⥠",
  33516. "LeftUpVectorBar;": "⥘",
  33517. "LowerRightArrow;": "↘",
  33518. "nLeftrightarrow;": "⇎",
  33519. "nleftrightarrow;": "↮",
  33520. "NotGreaterEqual;": "≱",
  33521. "NotGreaterTilde;": "≵",
  33522. "NotHumpDownHump;": "≎̸",
  33523. "NotLeftTriangle;": "⋪",
  33524. "NotSquareSubset;": "⊏̸",
  33525. "ntrianglelefteq;": "⋬",
  33526. "OverParenthesis;": "⏜",
  33527. "RightDownVector;": "⇂",
  33528. "rightleftarrows;": "⇄",
  33529. "rightsquigarrow;": "↝",
  33530. "rightthreetimes;": "⋌",
  33531. "ShortRightArrow;": "→",
  33532. "straightepsilon;": "ϵ",
  33533. "trianglerighteq;": "⊵",
  33534. "UpperRightArrow;": "↗",
  33535. "vartriangleleft;": "⊲",
  33536. "circlearrowright;": "↻",
  33537. "DiacriticalAcute;": "´",
  33538. "DiacriticalGrave;": "`",
  33539. "DiacriticalTilde;": "˜",
  33540. "DoubleRightArrow;": "⇒",
  33541. "DownArrowUpArrow;": "⇵",
  33542. "downharpoonright;": "⇂",
  33543. "EmptySmallSquare;": "◻",
  33544. "GreaterEqualLess;": "⋛",
  33545. "GreaterFullEqual;": "≧",
  33546. "LeftAngleBracket;": "⟨",
  33547. "LeftUpDownVector;": "⥑",
  33548. "LessEqualGreater;": "⋚",
  33549. "NonBreakingSpace;": " ",
  33550. "NotPrecedesEqual;": "⪯̸",
  33551. "NotRightTriangle;": "⋫",
  33552. "NotSucceedsEqual;": "⪰̸",
  33553. "NotSucceedsTilde;": "≿̸",
  33554. "NotSupersetEqual;": "⊉",
  33555. "ntrianglerighteq;": "⋭",
  33556. "rightharpoondown;": "⇁",
  33557. "rightrightarrows;": "⇉",
  33558. "RightTriangleBar;": "⧐",
  33559. "RightUpTeeVector;": "⥜",
  33560. "RightUpVectorBar;": "⥔",
  33561. "twoheadleftarrow;": "↞",
  33562. "UnderParenthesis;": "⏝",
  33563. "UpArrowDownArrow;": "⇅",
  33564. "vartriangleright;": "⊳",
  33565. "blacktriangledown;": "▾",
  33566. "blacktriangleleft;": "◂",
  33567. "DoubleUpDownArrow;": "⇕",
  33568. "DoubleVerticalBar;": "∥",
  33569. "DownLeftTeeVector;": "⥞",
  33570. "DownLeftVectorBar;": "⥖",
  33571. "FilledSmallSquare;": "◼",
  33572. "GreaterSlantEqual;": "⩾",
  33573. "LeftDoubleBracket;": "⟦",
  33574. "LeftDownTeeVector;": "⥡",
  33575. "LeftDownVectorBar;": "⥙",
  33576. "leftrightharpoons;": "⇋",
  33577. "LeftTriangleEqual;": "⊴",
  33578. "NegativeThinSpace;": "​",
  33579. "NotGreaterGreater;": "≫̸",
  33580. "NotLessSlantEqual;": "⩽̸",
  33581. "NotNestedLessLess;": "⪡̸",
  33582. "NotReverseElement;": "∌",
  33583. "NotSquareSuperset;": "⊐̸",
  33584. "NotTildeFullEqual;": "≇",
  33585. "RightAngleBracket;": "⟩",
  33586. "rightleftharpoons;": "⇌",
  33587. "RightUpDownVector;": "⥏",
  33588. "SquareSubsetEqual;": "⊑",
  33589. "twoheadrightarrow;": "↠",
  33590. "VerticalSeparator;": "❘",
  33591. "blacktriangleright;": "▸",
  33592. "DownRightTeeVector;": "⥟",
  33593. "DownRightVectorBar;": "⥗",
  33594. "LongLeftRightArrow;": "⟷",
  33595. "Longleftrightarrow;": "⟺",
  33596. "longleftrightarrow;": "⟷",
  33597. "NegativeThickSpace;": "​",
  33598. "NotLeftTriangleBar;": "⧏̸",
  33599. "PrecedesSlantEqual;": "≼",
  33600. "ReverseEquilibrium;": "⇋",
  33601. "RightDoubleBracket;": "⟧",
  33602. "RightDownTeeVector;": "⥝",
  33603. "RightDownVectorBar;": "⥕",
  33604. "RightTriangleEqual;": "⊵",
  33605. "SquareIntersection;": "⊓",
  33606. "SucceedsSlantEqual;": "≽",
  33607. "DoubleLongLeftArrow;": "⟸",
  33608. "DownLeftRightVector;": "⥐",
  33609. "LeftArrowRightArrow;": "⇆",
  33610. "leftrightsquigarrow;": "↭",
  33611. "NegativeMediumSpace;": "​",
  33612. "NotGreaterFullEqual;": "≧̸",
  33613. "NotRightTriangleBar;": "⧐̸",
  33614. "RightArrowLeftArrow;": "⇄",
  33615. "SquareSupersetEqual;": "⊒",
  33616. "CapitalDifferentialD;": "ⅅ",
  33617. "DoubleLeftRightArrow;": "⇔",
  33618. "DoubleLongRightArrow;": "⟹",
  33619. "EmptyVerySmallSquare;": "▫",
  33620. "NestedGreaterGreater;": "≫",
  33621. "NotDoubleVerticalBar;": "∦",
  33622. "NotGreaterSlantEqual;": "⩾̸",
  33623. "NotLeftTriangleEqual;": "⋬",
  33624. "NotSquareSubsetEqual;": "⋢",
  33625. "OpenCurlyDoubleQuote;": "“",
  33626. "ReverseUpEquilibrium;": "⥯",
  33627. "CloseCurlyDoubleQuote;": "”",
  33628. "DoubleContourIntegral;": "∯",
  33629. "FilledVerySmallSquare;": "▪",
  33630. "NegativeVeryThinSpace;": "​",
  33631. "NotPrecedesSlantEqual;": "⋠",
  33632. "NotRightTriangleEqual;": "⋭",
  33633. "NotSucceedsSlantEqual;": "⋡",
  33634. "DiacriticalDoubleAcute;": "˝",
  33635. "NotSquareSupersetEqual;": "⋣",
  33636. "NotNestedGreaterGreater;": "⪢̸",
  33637. "ClockwiseContourIntegral;": "∲",
  33638. "DoubleLongLeftRightArrow;": "⟺",
  33639. "CounterClockwiseContourIntegral;": "∳"
  33640. };
  33641. // lazy compute this to make this file tree-shakable for browser
  33642. let maxCRNameLength;
  33643. const decodeHtml = (rawText, asAttr) => {
  33644. let offset = 0;
  33645. const end = rawText.length;
  33646. let decodedText = '';
  33647. function advance(length) {
  33648. offset += length;
  33649. rawText = rawText.slice(length);
  33650. }
  33651. while (offset < end) {
  33652. const head = /&(?:#x?)?/i.exec(rawText);
  33653. if (!head || offset + head.index >= end) {
  33654. const remaining = end - offset;
  33655. decodedText += rawText.slice(0, remaining);
  33656. advance(remaining);
  33657. break;
  33658. }
  33659. // Advance to the "&".
  33660. decodedText += rawText.slice(0, head.index);
  33661. advance(head.index);
  33662. if (head[0] === '&') {
  33663. // Named character reference.
  33664. let name = '';
  33665. let value = undefined;
  33666. if (/[0-9a-z]/i.test(rawText[1])) {
  33667. if (!maxCRNameLength) {
  33668. maxCRNameLength = Object.keys(namedCharacterReferences).reduce((max, name) => Math.max(max, name.length), 0);
  33669. }
  33670. for (let length = maxCRNameLength; !value && length > 0; --length) {
  33671. name = rawText.substr(1, length);
  33672. value = namedCharacterReferences[name];
  33673. }
  33674. if (value) {
  33675. const semi = name.endsWith(';');
  33676. if (asAttr &&
  33677. !semi &&
  33678. /[=a-z0-9]/i.test(rawText[name.length + 1] || '')) {
  33679. decodedText += '&' + name;
  33680. advance(1 + name.length);
  33681. }
  33682. else {
  33683. decodedText += value;
  33684. advance(1 + name.length);
  33685. }
  33686. }
  33687. else {
  33688. decodedText += '&' + name;
  33689. advance(1 + name.length);
  33690. }
  33691. }
  33692. else {
  33693. decodedText += '&';
  33694. advance(1);
  33695. }
  33696. }
  33697. else {
  33698. // Numeric character reference.
  33699. const hex = head[0] === '&#x';
  33700. const pattern = hex ? /^&#x([0-9a-f]+);?/i : /^&#([0-9]+);?/;
  33701. const body = pattern.exec(rawText);
  33702. if (!body) {
  33703. decodedText += head[0];
  33704. advance(head[0].length);
  33705. }
  33706. else {
  33707. // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
  33708. let cp = Number.parseInt(body[1], hex ? 16 : 10);
  33709. if (cp === 0) {
  33710. cp = 0xfffd;
  33711. }
  33712. else if (cp > 0x10ffff) {
  33713. cp = 0xfffd;
  33714. }
  33715. else if (cp >= 0xd800 && cp <= 0xdfff) {
  33716. cp = 0xfffd;
  33717. }
  33718. else if ((cp >= 0xfdd0 && cp <= 0xfdef) || (cp & 0xfffe) === 0xfffe) ;
  33719. else if ((cp >= 0x01 && cp <= 0x08) ||
  33720. cp === 0x0b ||
  33721. (cp >= 0x0d && cp <= 0x1f) ||
  33722. (cp >= 0x7f && cp <= 0x9f)) {
  33723. cp = CCR_REPLACEMENTS[cp] || cp;
  33724. }
  33725. decodedText += String.fromCodePoint(cp);
  33726. advance(body[0].length);
  33727. }
  33728. }
  33729. }
  33730. return decodedText;
  33731. };
  33732. // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
  33733. const CCR_REPLACEMENTS = {
  33734. 0x80: 0x20ac,
  33735. 0x82: 0x201a,
  33736. 0x83: 0x0192,
  33737. 0x84: 0x201e,
  33738. 0x85: 0x2026,
  33739. 0x86: 0x2020,
  33740. 0x87: 0x2021,
  33741. 0x88: 0x02c6,
  33742. 0x89: 0x2030,
  33743. 0x8a: 0x0160,
  33744. 0x8b: 0x2039,
  33745. 0x8c: 0x0152,
  33746. 0x8e: 0x017d,
  33747. 0x91: 0x2018,
  33748. 0x92: 0x2019,
  33749. 0x93: 0x201c,
  33750. 0x94: 0x201d,
  33751. 0x95: 0x2022,
  33752. 0x96: 0x2013,
  33753. 0x97: 0x2014,
  33754. 0x98: 0x02dc,
  33755. 0x99: 0x2122,
  33756. 0x9a: 0x0161,
  33757. 0x9b: 0x203a,
  33758. 0x9c: 0x0153,
  33759. 0x9e: 0x017e,
  33760. 0x9f: 0x0178
  33761. };
  33762. const isRawTextContainer = /*#__PURE__*/ makeMap('style,iframe,script,noscript', true);
  33763. const parserOptions = {
  33764. isVoidTag,
  33765. isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
  33766. isPreTag: tag => tag === 'pre',
  33767. decodeEntities: decodeHtml,
  33768. isBuiltInComponent: (tag) => {
  33769. if (isBuiltInType(tag, `Transition`)) {
  33770. return TRANSITION;
  33771. }
  33772. else if (isBuiltInType(tag, `TransitionGroup`)) {
  33773. return TRANSITION_GROUP;
  33774. }
  33775. },
  33776. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  33777. getNamespace(tag, parent) {
  33778. let ns = parent ? parent.ns : 0 /* HTML */;
  33779. if (parent && ns === 2 /* MATH_ML */) {
  33780. if (parent.tag === 'annotation-xml') {
  33781. if (tag === 'svg') {
  33782. return 1 /* SVG */;
  33783. }
  33784. if (parent.props.some(a => a.type === 6 /* ATTRIBUTE */ &&
  33785. a.name === 'encoding' &&
  33786. a.value != null &&
  33787. (a.value.content === 'text/html' ||
  33788. a.value.content === 'application/xhtml+xml'))) {
  33789. ns = 0 /* HTML */;
  33790. }
  33791. }
  33792. else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
  33793. tag !== 'mglyph' &&
  33794. tag !== 'malignmark') {
  33795. ns = 0 /* HTML */;
  33796. }
  33797. }
  33798. else if (parent && ns === 1 /* SVG */) {
  33799. if (parent.tag === 'foreignObject' ||
  33800. parent.tag === 'desc' ||
  33801. parent.tag === 'title') {
  33802. ns = 0 /* HTML */;
  33803. }
  33804. }
  33805. if (ns === 0 /* HTML */) {
  33806. if (tag === 'svg') {
  33807. return 1 /* SVG */;
  33808. }
  33809. if (tag === 'math') {
  33810. return 2 /* MATH_ML */;
  33811. }
  33812. }
  33813. return ns;
  33814. },
  33815. // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
  33816. getTextMode({ tag, ns }) {
  33817. if (ns === 0 /* HTML */) {
  33818. if (tag === 'textarea' || tag === 'title') {
  33819. return 1 /* RCDATA */;
  33820. }
  33821. if (isRawTextContainer(tag)) {
  33822. return 2 /* RAWTEXT */;
  33823. }
  33824. }
  33825. return 0 /* DATA */;
  33826. }
  33827. };
  33828. // Parse inline CSS strings for static style attributes into an object.
  33829. // This is a NodeTransform since it works on the static `style` attribute and
  33830. // converts it into a dynamic equivalent:
  33831. // style="color: red" -> :style='{ "color": "red" }'
  33832. // It is then processed by `transformElement` and included in the generated
  33833. // props.
  33834. const transformStyle = node => {
  33835. if (node.type === 1 /* ELEMENT */) {
  33836. node.props.forEach((p, i) => {
  33837. if (p.type === 6 /* ATTRIBUTE */ && p.name === 'style' && p.value) {
  33838. // replace p with an expression node
  33839. node.props[i] = {
  33840. type: 7 /* DIRECTIVE */,
  33841. name: `bind`,
  33842. arg: createSimpleExpression(`style`, true, p.loc),
  33843. exp: parseInlineCSS(p.value.content, p.loc),
  33844. modifiers: [],
  33845. loc: p.loc
  33846. };
  33847. }
  33848. });
  33849. }
  33850. };
  33851. const parseInlineCSS = (cssText, loc) => {
  33852. const normalized = parseStringStyle(cssText);
  33853. return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* CAN_STRINGIFY */);
  33854. };
  33855. function createDOMCompilerError(code, loc) {
  33856. return createCompilerError(code, loc, DOMErrorMessages );
  33857. }
  33858. const DOMErrorMessages = {
  33859. [50 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
  33860. [51 /* X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
  33861. [52 /* X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
  33862. [53 /* X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
  33863. [54 /* X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  33864. [55 /* X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
  33865. [56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  33866. [57 /* X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  33867. [58 /* X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
  33868. [59 /* X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
  33869. [60 /* X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  33870. };
  33871. const transformVHtml = (dir, node, context) => {
  33872. const { exp, loc } = dir;
  33873. if (!exp) {
  33874. context.onError(createDOMCompilerError(50 /* X_V_HTML_NO_EXPRESSION */, loc));
  33875. }
  33876. if (node.children.length) {
  33877. context.onError(createDOMCompilerError(51 /* X_V_HTML_WITH_CHILDREN */, loc));
  33878. node.children.length = 0;
  33879. }
  33880. return {
  33881. props: [
  33882. createObjectProperty(createSimpleExpression(`innerHTML`, true, loc), exp || createSimpleExpression('', true))
  33883. ]
  33884. };
  33885. };
  33886. const transformVText = (dir, node, context) => {
  33887. const { exp, loc } = dir;
  33888. if (!exp) {
  33889. context.onError(createDOMCompilerError(52 /* X_V_TEXT_NO_EXPRESSION */, loc));
  33890. }
  33891. if (node.children.length) {
  33892. context.onError(createDOMCompilerError(53 /* X_V_TEXT_WITH_CHILDREN */, loc));
  33893. node.children.length = 0;
  33894. }
  33895. return {
  33896. props: [
  33897. createObjectProperty(createSimpleExpression(`textContent`, true), exp
  33898. ? createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
  33899. : createSimpleExpression('', true))
  33900. ]
  33901. };
  33902. };
  33903. const transformModel$1 = (dir, node, context) => {
  33904. const baseResult = transformModel(dir, node, context);
  33905. // base transform has errors OR component v-model (only need props)
  33906. if (!baseResult.props.length || node.tagType === 1 /* COMPONENT */) {
  33907. return baseResult;
  33908. }
  33909. if (dir.arg) {
  33910. context.onError(createDOMCompilerError(55 /* X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
  33911. }
  33912. function checkDuplicatedValue() {
  33913. const value = findProp(node, 'value');
  33914. if (value) {
  33915. context.onError(createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
  33916. }
  33917. }
  33918. const { tag } = node;
  33919. const isCustomElement = context.isCustomElement(tag);
  33920. if (tag === 'input' ||
  33921. tag === 'textarea' ||
  33922. tag === 'select' ||
  33923. isCustomElement) {
  33924. let directiveToUse = V_MODEL_TEXT;
  33925. let isInvalidType = false;
  33926. if (tag === 'input' || isCustomElement) {
  33927. const type = findProp(node, `type`);
  33928. if (type) {
  33929. if (type.type === 7 /* DIRECTIVE */) {
  33930. // :type="foo"
  33931. directiveToUse = V_MODEL_DYNAMIC;
  33932. }
  33933. else if (type.value) {
  33934. switch (type.value.content) {
  33935. case 'radio':
  33936. directiveToUse = V_MODEL_RADIO;
  33937. break;
  33938. case 'checkbox':
  33939. directiveToUse = V_MODEL_CHECKBOX;
  33940. break;
  33941. case 'file':
  33942. isInvalidType = true;
  33943. context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
  33944. break;
  33945. default:
  33946. // text type
  33947. checkDuplicatedValue();
  33948. break;
  33949. }
  33950. }
  33951. }
  33952. else if (hasDynamicKeyVBind(node)) {
  33953. // element has bindings with dynamic keys, which can possibly contain
  33954. // "type".
  33955. directiveToUse = V_MODEL_DYNAMIC;
  33956. }
  33957. else {
  33958. // text type
  33959. checkDuplicatedValue();
  33960. }
  33961. }
  33962. else if (tag === 'select') {
  33963. directiveToUse = V_MODEL_SELECT;
  33964. }
  33965. else {
  33966. // textarea
  33967. checkDuplicatedValue();
  33968. }
  33969. // inject runtime directive
  33970. // by returning the helper symbol via needRuntime
  33971. // the import will replaced a resolveDirective call.
  33972. if (!isInvalidType) {
  33973. baseResult.needRuntime = context.helper(directiveToUse);
  33974. }
  33975. }
  33976. else {
  33977. context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
  33978. }
  33979. // native vmodel doesn't need the `modelValue` props since they are also
  33980. // passed to the runtime as `binding.value`. removing it reduces code size.
  33981. baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
  33982. p.key.content === 'modelValue'));
  33983. return baseResult;
  33984. };
  33985. const isEventOptionModifier = /*#__PURE__*/ makeMap(`passive,once,capture`);
  33986. const isNonKeyModifier = /*#__PURE__*/ makeMap(
  33987. // event propagation management
  33988. `stop,prevent,self,` +
  33989. // system modifiers + exact
  33990. `ctrl,shift,alt,meta,exact,` +
  33991. // mouse
  33992. `middle`);
  33993. // left & right could be mouse or key modifiers based on event type
  33994. const maybeKeyModifier = /*#__PURE__*/ makeMap('left,right');
  33995. const isKeyboardEvent = /*#__PURE__*/ makeMap(`onkeyup,onkeydown,onkeypress`, true);
  33996. const resolveModifiers = (key, modifiers, context, loc) => {
  33997. const keyModifiers = [];
  33998. const nonKeyModifiers = [];
  33999. const eventOptionModifiers = [];
  34000. for (let i = 0; i < modifiers.length; i++) {
  34001. const modifier = modifiers[i];
  34002. if (isEventOptionModifier(modifier)) {
  34003. // eventOptionModifiers: modifiers for addEventListener() options,
  34004. // e.g. .passive & .capture
  34005. eventOptionModifiers.push(modifier);
  34006. }
  34007. else {
  34008. // runtimeModifiers: modifiers that needs runtime guards
  34009. if (maybeKeyModifier(modifier)) {
  34010. if (isStaticExp(key)) {
  34011. if (isKeyboardEvent(key.content)) {
  34012. keyModifiers.push(modifier);
  34013. }
  34014. else {
  34015. nonKeyModifiers.push(modifier);
  34016. }
  34017. }
  34018. else {
  34019. keyModifiers.push(modifier);
  34020. nonKeyModifiers.push(modifier);
  34021. }
  34022. }
  34023. else {
  34024. if (isNonKeyModifier(modifier)) {
  34025. nonKeyModifiers.push(modifier);
  34026. }
  34027. else {
  34028. keyModifiers.push(modifier);
  34029. }
  34030. }
  34031. }
  34032. }
  34033. return {
  34034. keyModifiers,
  34035. nonKeyModifiers,
  34036. eventOptionModifiers
  34037. };
  34038. };
  34039. const transformClick = (key, event) => {
  34040. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === 'onclick';
  34041. return isStaticClick
  34042. ? createSimpleExpression(event, true)
  34043. : key.type !== 4 /* SIMPLE_EXPRESSION */
  34044. ? createCompoundExpression([
  34045. `(`,
  34046. key,
  34047. `) === "onClick" ? "${event}" : (`,
  34048. key,
  34049. `)`
  34050. ])
  34051. : key;
  34052. };
  34053. const transformOn$1 = (dir, node, context) => {
  34054. return transformOn(dir, node, context, baseResult => {
  34055. const { modifiers } = dir;
  34056. if (!modifiers.length)
  34057. return baseResult;
  34058. let { key, value: handlerExp } = baseResult.props[0];
  34059. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  34060. // normalize click.right and click.middle since they don't actually fire
  34061. if (nonKeyModifiers.includes('right')) {
  34062. key = transformClick(key, `onContextmenu`);
  34063. }
  34064. if (nonKeyModifiers.includes('middle')) {
  34065. key = transformClick(key, `onMouseup`);
  34066. }
  34067. if (nonKeyModifiers.length) {
  34068. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  34069. handlerExp,
  34070. JSON.stringify(nonKeyModifiers)
  34071. ]);
  34072. }
  34073. if (keyModifiers.length &&
  34074. // if event name is dynamic, always wrap with keys guard
  34075. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  34076. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  34077. handlerExp,
  34078. JSON.stringify(keyModifiers)
  34079. ]);
  34080. }
  34081. if (eventOptionModifiers.length) {
  34082. const modifierPostfix = eventOptionModifiers.map(capitalize).join('');
  34083. key = isStaticExp(key)
  34084. ? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
  34085. : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  34086. }
  34087. return {
  34088. props: [createObjectProperty(key, handlerExp)]
  34089. };
  34090. });
  34091. };
  34092. const transformShow = (dir, node, context) => {
  34093. const { exp, loc } = dir;
  34094. if (!exp) {
  34095. context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */, loc));
  34096. }
  34097. return {
  34098. props: [],
  34099. needRuntime: context.helper(V_SHOW)
  34100. };
  34101. };
  34102. const warnTransitionChildren = (node, context) => {
  34103. if (node.type === 1 /* ELEMENT */ &&
  34104. node.tagType === 1 /* COMPONENT */) {
  34105. const component = context.isBuiltInComponent(node.tag);
  34106. if (component === TRANSITION) {
  34107. return () => {
  34108. if (node.children.length && hasMultipleChildren(node)) {
  34109. context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
  34110. start: node.children[0].loc.start,
  34111. end: node.children[node.children.length - 1].loc.end,
  34112. source: ''
  34113. }));
  34114. }
  34115. };
  34116. }
  34117. }
  34118. };
  34119. function hasMultipleChildren(node) {
  34120. // #1352 filter out potential comment nodes.
  34121. const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */));
  34122. const child = children[0];
  34123. return (children.length !== 1 ||
  34124. child.type === 11 /* FOR */ ||
  34125. (child.type === 9 /* IF */ && child.branches.some(hasMultipleChildren)));
  34126. }
  34127. /**
  34128. * This module is Node-only.
  34129. */
  34130. /**
  34131. * Turn eligible hoisted static trees into stringified static nodes, e.g.
  34132. *
  34133. * ```js
  34134. * const _hoisted_1 = createStaticVNode(`<div class="foo">bar</div>`)
  34135. * ```
  34136. *
  34137. * A single static vnode can contain stringified content for **multiple**
  34138. * consecutive nodes (element and plain text), called a "chunk".
  34139. * `@vue/runtime-dom` will create the content via innerHTML in a hidden
  34140. * container element and insert all the nodes in place. The call must also
  34141. * provide the number of nodes contained in the chunk so that during hydration
  34142. * we can know how many nodes the static vnode should adopt.
  34143. *
  34144. * The optimization scans a children list that contains hoisted nodes, and
  34145. * tries to find the largest chunk of consecutive hoisted nodes before running
  34146. * into a non-hoisted node or the end of the list. A chunk is then converted
  34147. * into a single static vnode and replaces the hoisted expression of the first
  34148. * node in the chunk. Other nodes in the chunk are considered "merged" and
  34149. * therefore removed from both the hoist list and the children array.
  34150. *
  34151. * This optimization is only performed in Node.js.
  34152. */
  34153. const stringifyStatic = (children, context, parent) => {
  34154. // bail stringification for slot content
  34155. if (context.scopes.vSlot > 0) {
  34156. return;
  34157. }
  34158. let nc = 0; // current node count
  34159. let ec = 0; // current element with binding count
  34160. const currentChunk = [];
  34161. const stringifyCurrentChunk = (currentIndex) => {
  34162. if (nc >= 20 /* NODE_COUNT */ ||
  34163. ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
  34164. // combine all currently eligible nodes into a single static vnode call
  34165. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  34166. JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')),
  34167. // the 2nd argument indicates the number of DOM nodes this static vnode
  34168. // will insert / hydrate
  34169. String(currentChunk.length)
  34170. ]);
  34171. // replace the first node's hoisted expression with the static vnode call
  34172. replaceHoist(currentChunk[0], staticCall, context);
  34173. if (currentChunk.length > 1) {
  34174. for (let i = 1; i < currentChunk.length; i++) {
  34175. // for the merged nodes, set their hoisted expression to null
  34176. replaceHoist(currentChunk[i], null, context);
  34177. }
  34178. // also remove merged nodes from children
  34179. const deleteCount = currentChunk.length - 1;
  34180. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  34181. return deleteCount;
  34182. }
  34183. }
  34184. return 0;
  34185. };
  34186. let i = 0;
  34187. for (; i < children.length; i++) {
  34188. const child = children[i];
  34189. const hoisted = getHoistedNode(child);
  34190. if (hoisted) {
  34191. // presence of hoisted means child must be a stringifiable node
  34192. const node = child;
  34193. const result = analyzeNode(node);
  34194. if (result) {
  34195. // node is stringifiable, record state
  34196. nc += result[0];
  34197. ec += result[1];
  34198. currentChunk.push(node);
  34199. continue;
  34200. }
  34201. }
  34202. // we only reach here if we ran into a node that is not stringifiable
  34203. // check if currently analyzed nodes meet criteria for stringification.
  34204. // adjust iteration index
  34205. i -= stringifyCurrentChunk(i);
  34206. // reset state
  34207. nc = 0;
  34208. ec = 0;
  34209. currentChunk.length = 0;
  34210. }
  34211. // in case the last node was also stringifiable
  34212. stringifyCurrentChunk(i);
  34213. };
  34214. const getHoistedNode = (node) => ((node.type === 1 /* ELEMENT */ && node.tagType === 0 /* ELEMENT */) ||
  34215. node.type == 12 /* TEXT_CALL */) &&
  34216. node.codegenNode &&
  34217. node.codegenNode.type === 4 /* SIMPLE_EXPRESSION */ &&
  34218. node.codegenNode.hoisted;
  34219. const dataAriaRE = /^(data|aria)-/;
  34220. const isStringifiableAttr = (name, ns) => {
  34221. return ((ns === 0 /* HTML */
  34222. ? isKnownHtmlAttr(name)
  34223. : ns === 1 /* SVG */
  34224. ? isKnownSvgAttr(name)
  34225. : false) || dataAriaRE.test(name));
  34226. };
  34227. const replaceHoist = (node, replacement, context) => {
  34228. const hoistToReplace = node.codegenNode.hoisted;
  34229. context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
  34230. };
  34231. const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
  34232. /**
  34233. * for a hoisted node, analyze it and return:
  34234. * - false: bailed (contains runtime constant)
  34235. * - [nc, ec] where
  34236. * - nc is the number of nodes inside
  34237. * - ec is the number of element with bindings inside
  34238. */
  34239. function analyzeNode(node) {
  34240. if (node.type === 1 /* ELEMENT */ && isNonStringifiable(node.tag)) {
  34241. return false;
  34242. }
  34243. if (node.type === 12 /* TEXT_CALL */) {
  34244. return [1, 0];
  34245. }
  34246. let nc = 1; // node count
  34247. let ec = node.props.length > 0 ? 1 : 0; // element w/ binding count
  34248. let bailed = false;
  34249. const bail = () => {
  34250. bailed = true;
  34251. return false;
  34252. };
  34253. // TODO: check for cases where using innerHTML will result in different
  34254. // output compared to imperative node insertions.
  34255. // probably only need to check for most common case
  34256. // i.e. non-phrasing-content tags inside `<p>`
  34257. function walk(node) {
  34258. for (let i = 0; i < node.props.length; i++) {
  34259. const p = node.props[i];
  34260. // bail on non-attr bindings
  34261. if (p.type === 6 /* ATTRIBUTE */ &&
  34262. !isStringifiableAttr(p.name, node.ns)) {
  34263. return bail();
  34264. }
  34265. if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
  34266. // bail on non-attr bindings
  34267. if (p.arg &&
  34268. (p.arg.type === 8 /* COMPOUND_EXPRESSION */ ||
  34269. (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
  34270. return bail();
  34271. }
  34272. }
  34273. }
  34274. for (let i = 0; i < node.children.length; i++) {
  34275. nc++;
  34276. const child = node.children[i];
  34277. if (child.type === 1 /* ELEMENT */) {
  34278. if (child.props.length > 0) {
  34279. ec++;
  34280. }
  34281. walk(child);
  34282. if (bailed) {
  34283. return false;
  34284. }
  34285. }
  34286. }
  34287. return true;
  34288. }
  34289. return walk(node) ? [nc, ec] : false;
  34290. }
  34291. function stringifyNode(node, context) {
  34292. if (isString(node)) {
  34293. return node;
  34294. }
  34295. if (isSymbol(node)) {
  34296. return ``;
  34297. }
  34298. switch (node.type) {
  34299. case 1 /* ELEMENT */:
  34300. return stringifyElement(node, context);
  34301. case 2 /* TEXT */:
  34302. return escapeHtml(node.content);
  34303. case 3 /* COMMENT */:
  34304. return `<!--${escapeHtml(node.content)}-->`;
  34305. case 5 /* INTERPOLATION */:
  34306. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  34307. case 8 /* COMPOUND_EXPRESSION */:
  34308. return escapeHtml(evaluateConstant(node));
  34309. case 12 /* TEXT_CALL */:
  34310. return stringifyNode(node.content, context);
  34311. default:
  34312. // static trees will not contain if/for nodes
  34313. return '';
  34314. }
  34315. }
  34316. function stringifyElement(node, context) {
  34317. let res = `<${node.tag}`;
  34318. for (let i = 0; i < node.props.length; i++) {
  34319. const p = node.props[i];
  34320. if (p.type === 6 /* ATTRIBUTE */) {
  34321. res += ` ${p.name}`;
  34322. if (p.value) {
  34323. res += `="${escapeHtml(p.value.content)}"`;
  34324. }
  34325. }
  34326. else if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
  34327. // constant v-bind, e.g. :foo="1"
  34328. let evaluated = evaluateConstant(p.exp);
  34329. if (evaluated != null) {
  34330. const arg = p.arg && p.arg.content;
  34331. if (arg === 'class') {
  34332. evaluated = normalizeClass(evaluated);
  34333. }
  34334. else if (arg === 'style') {
  34335. evaluated = stringifyStyle(normalizeStyle(evaluated));
  34336. }
  34337. res += ` ${p.arg.content}="${escapeHtml(evaluated)}"`;
  34338. }
  34339. }
  34340. }
  34341. if (context.scopeId) {
  34342. res += ` ${context.scopeId}`;
  34343. }
  34344. res += `>`;
  34345. for (let i = 0; i < node.children.length; i++) {
  34346. res += stringifyNode(node.children[i], context);
  34347. }
  34348. if (!isVoidTag(node.tag)) {
  34349. res += `</${node.tag}>`;
  34350. }
  34351. return res;
  34352. }
  34353. // __UNSAFE__
  34354. // Reason: eval.
  34355. // It's technically safe to eval because only constant expressions are possible
  34356. // here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
  34357. // in addition, constant exps bail on presence of parens so you can't even
  34358. // run JSFuck in here. But we mark it unsafe for security review purposes.
  34359. // (see compiler-core/src/transformExpressions)
  34360. function evaluateConstant(exp) {
  34361. if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
  34362. return new Function(`return ${exp.content}`)();
  34363. }
  34364. else {
  34365. // compound
  34366. let res = ``;
  34367. exp.children.forEach(c => {
  34368. if (isString(c) || isSymbol(c)) {
  34369. return;
  34370. }
  34371. if (c.type === 2 /* TEXT */) {
  34372. res += c.content;
  34373. }
  34374. else if (c.type === 5 /* INTERPOLATION */) {
  34375. res += toDisplayString(evaluateConstant(c.content));
  34376. }
  34377. else {
  34378. res += evaluateConstant(c);
  34379. }
  34380. });
  34381. return res;
  34382. }
  34383. }
  34384. const ignoreSideEffectTags = (node, context) => {
  34385. if (node.type === 1 /* ELEMENT */ &&
  34386. node.tagType === 0 /* ELEMENT */ &&
  34387. (node.tag === 'script' || node.tag === 'style')) {
  34388. context.onError(createDOMCompilerError(60 /* X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
  34389. context.removeNode();
  34390. }
  34391. };
  34392. const DOMNodeTransforms = [
  34393. transformStyle,
  34394. ...([warnTransitionChildren] )
  34395. ];
  34396. const DOMDirectiveTransforms = {
  34397. cloak: noopDirectiveTransform,
  34398. html: transformVHtml,
  34399. text: transformVText,
  34400. model: transformModel$1,
  34401. on: transformOn$1,
  34402. show: transformShow
  34403. };
  34404. function compile(template, options = {}) {
  34405. return baseCompile(template, extend({}, parserOptions, options, {
  34406. nodeTransforms: [
  34407. // ignore <script> and <tag>
  34408. // this is not put inside DOMNodeTransforms because that list is used
  34409. // by compiler-ssr to generate vnode fallback branches
  34410. ignoreSideEffectTags,
  34411. ...DOMNodeTransforms,
  34412. ...(options.nodeTransforms || [])
  34413. ],
  34414. directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
  34415. transformHoist: stringifyStatic
  34416. }));
  34417. }
  34418. function parse$1(template, options = {}) {
  34419. return baseParse(template, extend({}, parserOptions, options));
  34420. }
  34421. var CompilerDOM = /*#__PURE__*/Object.freeze({
  34422. __proto__: null,
  34423. parserOptions: parserOptions,
  34424. DOMNodeTransforms: DOMNodeTransforms,
  34425. DOMDirectiveTransforms: DOMDirectiveTransforms,
  34426. compile: compile,
  34427. parse: parse$1,
  34428. transformStyle: transformStyle,
  34429. createDOMCompilerError: createDOMCompilerError,
  34430. V_MODEL_RADIO: V_MODEL_RADIO,
  34431. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  34432. V_MODEL_TEXT: V_MODEL_TEXT,
  34433. V_MODEL_SELECT: V_MODEL_SELECT,
  34434. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  34435. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  34436. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  34437. V_SHOW: V_SHOW,
  34438. TRANSITION: TRANSITION,
  34439. TRANSITION_GROUP: TRANSITION_GROUP,
  34440. baseCompile: baseCompile,
  34441. baseParse: baseParse,
  34442. transform: transform,
  34443. createTransformContext: createTransformContext,
  34444. traverseNode: traverseNode,
  34445. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  34446. generate: generate,
  34447. createCompilerError: createCompilerError,
  34448. getBaseTransformPreset: getBaseTransformPreset,
  34449. transformModel: transformModel,
  34450. transformOn: transformOn,
  34451. transformBind: transformBind,
  34452. noopDirectiveTransform: noopDirectiveTransform,
  34453. processIf: processIf,
  34454. processFor: processFor,
  34455. createForLoopParams: createForLoopParams,
  34456. transformExpression: transformExpression,
  34457. processExpression: processExpression,
  34458. buildSlots: buildSlots,
  34459. trackVForSlotScopes: trackVForSlotScopes,
  34460. trackSlotScopes: trackSlotScopes,
  34461. transformElement: transformElement,
  34462. resolveComponentType: resolveComponentType,
  34463. buildProps: buildProps,
  34464. processSlotOutlet: processSlotOutlet,
  34465. generateCodeFrame: generateCodeFrame,
  34466. checkCompatEnabled: checkCompatEnabled,
  34467. warnDeprecation: warnDeprecation,
  34468. locStub: locStub,
  34469. createRoot: createRoot,
  34470. createVNodeCall: createVNodeCall,
  34471. createArrayExpression: createArrayExpression,
  34472. createObjectExpression: createObjectExpression,
  34473. createObjectProperty: createObjectProperty,
  34474. createSimpleExpression: createSimpleExpression,
  34475. createInterpolation: createInterpolation,
  34476. createCompoundExpression: createCompoundExpression,
  34477. createCallExpression: createCallExpression,
  34478. createFunctionExpression: createFunctionExpression,
  34479. createConditionalExpression: createConditionalExpression,
  34480. createCacheExpression: createCacheExpression,
  34481. createBlockStatement: createBlockStatement,
  34482. createTemplateLiteral: createTemplateLiteral,
  34483. createIfStatement: createIfStatement,
  34484. createAssignmentExpression: createAssignmentExpression,
  34485. createSequenceExpression: createSequenceExpression,
  34486. createReturnStatement: createReturnStatement,
  34487. isStaticExp: isStaticExp,
  34488. isBuiltInType: isBuiltInType,
  34489. isCoreComponent: isCoreComponent,
  34490. isSimpleIdentifier: isSimpleIdentifier,
  34491. isMemberExpression: isMemberExpression,
  34492. getInnerRange: getInnerRange,
  34493. advancePositionWithClone: advancePositionWithClone,
  34494. advancePositionWithMutation: advancePositionWithMutation,
  34495. assert: assert,
  34496. findDir: findDir,
  34497. findProp: findProp,
  34498. isBindKey: isBindKey,
  34499. hasDynamicKeyVBind: hasDynamicKeyVBind,
  34500. isText: isText,
  34501. isVSlot: isVSlot,
  34502. isTemplateNode: isTemplateNode,
  34503. isSlotOutlet: isSlotOutlet,
  34504. getVNodeHelper: getVNodeHelper,
  34505. getVNodeBlockHelper: getVNodeBlockHelper,
  34506. injectProp: injectProp,
  34507. toValidAssetId: toValidAssetId,
  34508. hasScopeRef: hasScopeRef,
  34509. getMemoedVNodeCall: getMemoedVNodeCall,
  34510. makeBlock: makeBlock,
  34511. walkIdentifiers: walkIdentifiers,
  34512. isReferencedIdentifier: isReferencedIdentifier,
  34513. isInDestructureAssignment: isInDestructureAssignment,
  34514. walkFunctionParams: walkFunctionParams,
  34515. walkBlockDeclarations: walkBlockDeclarations,
  34516. extractIdentifiers: extractIdentifiers,
  34517. isFunctionType: isFunctionType,
  34518. isStaticProperty: isStaticProperty,
  34519. isStaticPropertyKey: isStaticPropertyKey,
  34520. FRAGMENT: FRAGMENT,
  34521. TELEPORT: TELEPORT,
  34522. SUSPENSE: SUSPENSE,
  34523. KEEP_ALIVE: KEEP_ALIVE,
  34524. BASE_TRANSITION: BASE_TRANSITION,
  34525. OPEN_BLOCK: OPEN_BLOCK,
  34526. CREATE_BLOCK: CREATE_BLOCK,
  34527. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  34528. CREATE_VNODE: CREATE_VNODE,
  34529. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  34530. CREATE_COMMENT: CREATE_COMMENT,
  34531. CREATE_TEXT: CREATE_TEXT,
  34532. CREATE_STATIC: CREATE_STATIC,
  34533. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  34534. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  34535. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  34536. RESOLVE_FILTER: RESOLVE_FILTER,
  34537. WITH_DIRECTIVES: WITH_DIRECTIVES,
  34538. RENDER_LIST: RENDER_LIST,
  34539. RENDER_SLOT: RENDER_SLOT,
  34540. CREATE_SLOTS: CREATE_SLOTS,
  34541. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  34542. MERGE_PROPS: MERGE_PROPS,
  34543. NORMALIZE_CLASS: NORMALIZE_CLASS,
  34544. NORMALIZE_STYLE: NORMALIZE_STYLE,
  34545. NORMALIZE_PROPS: NORMALIZE_PROPS,
  34546. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  34547. TO_HANDLERS: TO_HANDLERS,
  34548. CAMELIZE: CAMELIZE,
  34549. CAPITALIZE: CAPITALIZE,
  34550. TO_HANDLER_KEY: TO_HANDLER_KEY,
  34551. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  34552. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  34553. POP_SCOPE_ID: POP_SCOPE_ID,
  34554. WITH_CTX: WITH_CTX,
  34555. UNREF: UNREF,
  34556. IS_REF: IS_REF,
  34557. WITH_MEMO: WITH_MEMO,
  34558. IS_MEMO_SAME: IS_MEMO_SAME,
  34559. helperNameMap: helperNameMap,
  34560. registerRuntimeHelpers: registerRuntimeHelpers
  34561. });
  34562. function pad (hash, len) {
  34563. while (hash.length < len) {
  34564. hash = '0' + hash;
  34565. }
  34566. return hash;
  34567. }
  34568. function fold (hash, text) {
  34569. var i;
  34570. var chr;
  34571. var len;
  34572. if (text.length === 0) {
  34573. return hash;
  34574. }
  34575. for (i = 0, len = text.length; i < len; i++) {
  34576. chr = text.charCodeAt(i);
  34577. hash = ((hash << 5) - hash) + chr;
  34578. hash |= 0;
  34579. }
  34580. return hash < 0 ? hash * -2 : hash;
  34581. }
  34582. function foldObject (hash, o, seen) {
  34583. return Object.keys(o).sort().reduce(foldKey, hash);
  34584. function foldKey (hash, key) {
  34585. return foldValue(hash, o[key], key, seen);
  34586. }
  34587. }
  34588. function foldValue (input, value, key, seen) {
  34589. var hash = fold(fold(fold(input, key), toString(value)), typeof value);
  34590. if (value === null) {
  34591. return fold(hash, 'null');
  34592. }
  34593. if (value === undefined) {
  34594. return fold(hash, 'undefined');
  34595. }
  34596. if (typeof value === 'object' || typeof value === 'function') {
  34597. if (seen.indexOf(value) !== -1) {
  34598. return fold(hash, '[Circular]' + key);
  34599. }
  34600. seen.push(value);
  34601. var objHash = foldObject(hash, value, seen);
  34602. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  34603. return objHash;
  34604. }
  34605. try {
  34606. return fold(objHash, String(value.valueOf()))
  34607. } catch (err) {
  34608. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  34609. }
  34610. }
  34611. return fold(hash, value.toString());
  34612. }
  34613. function toString (o) {
  34614. return Object.prototype.toString.call(o);
  34615. }
  34616. function sum (o) {
  34617. return pad(foldValue(0, o, '', []).toString(16), 8);
  34618. }
  34619. var hashSum = sum;
  34620. const CSS_VARS_HELPER = `useCssVars`;
  34621. const cssVarRE = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g;
  34622. function genCssVarsFromList(vars, id, isProd) {
  34623. return `{\n ${vars
  34624. .map(key => `"${genVarName(id, key, isProd)}": (${key})`)
  34625. .join(',\n ')}\n}`;
  34626. }
  34627. function genVarName(id, raw, isProd) {
  34628. if (isProd) {
  34629. return hashSum(id + raw);
  34630. }
  34631. else {
  34632. return `${id}-${raw.replace(/([^\w-])/g, '_')}`;
  34633. }
  34634. }
  34635. function parseCssVars(sfc) {
  34636. const vars = [];
  34637. sfc.styles.forEach(style => {
  34638. let match;
  34639. // ignore v-bind() in comments /* ... */
  34640. const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
  34641. while ((match = cssVarRE.exec(content))) {
  34642. const variable = match[1] || match[2] || match[3];
  34643. if (!vars.includes(variable)) {
  34644. vars.push(variable);
  34645. }
  34646. }
  34647. });
  34648. return vars;
  34649. }
  34650. const cssVarsPlugin = opts => {
  34651. const { id, isProd } = opts;
  34652. return {
  34653. postcssPlugin: 'vue-sfc-vars',
  34654. Declaration(decl) {
  34655. // rewrite CSS variables
  34656. if (cssVarRE.test(decl.value)) {
  34657. decl.value = decl.value.replace(cssVarRE, (_, $1, $2, $3) => {
  34658. return `var(--${genVarName(id, $1 || $2 || $3, isProd)})`;
  34659. });
  34660. }
  34661. }
  34662. };
  34663. };
  34664. cssVarsPlugin.postcss = true;
  34665. function genCssVarsCode(vars, bindings, id, isProd) {
  34666. const varsExp = genCssVarsFromList(vars, id, isProd);
  34667. const exp = createSimpleExpression(varsExp, false);
  34668. const context = createTransformContext(createRoot([]), {
  34669. prefixIdentifiers: true,
  34670. inline: true,
  34671. bindingMetadata: bindings.__isScriptSetup === false ? undefined : bindings
  34672. });
  34673. const transformed = processExpression(exp, context);
  34674. const transformedString = transformed.type === 4 /* SIMPLE_EXPRESSION */
  34675. ? transformed.content
  34676. : transformed.children
  34677. .map(c => {
  34678. return typeof c === 'string'
  34679. ? c
  34680. : c.content;
  34681. })
  34682. .join('');
  34683. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  34684. }
  34685. // <script setup> already gets the calls injected as part of the transform
  34686. // this is only for single normal <script>
  34687. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd) {
  34688. return (`\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\n` +
  34689. `const __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\n` +
  34690. `const __setup__ = __default__.setup\n` +
  34691. `__default__.setup = __setup__\n` +
  34692. ` ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n` +
  34693. ` : __injectCSSVars__\n`);
  34694. }
  34695. function createCache(size = 500) {
  34696. return new Map()
  34697. ;
  34698. }
  34699. const sourceToSFC = createCache();
  34700. function parse$2(source, { sourceMap = true, filename = 'anonymous.vue', sourceRoot = '', pad = false, ignoreEmpty = true, compiler = CompilerDOM } = {}) {
  34701. const sourceKey = source + sourceMap + filename + sourceRoot + pad + compiler.parse;
  34702. const cache = sourceToSFC.get(sourceKey);
  34703. if (cache) {
  34704. return cache;
  34705. }
  34706. const descriptor = {
  34707. filename,
  34708. source,
  34709. template: null,
  34710. script: null,
  34711. scriptSetup: null,
  34712. styles: [],
  34713. customBlocks: [],
  34714. cssVars: [],
  34715. slotted: false
  34716. };
  34717. const errors = [];
  34718. const ast = compiler.parse(source, {
  34719. // there are no components at SFC parsing level
  34720. isNativeTag: () => true,
  34721. // preserve all whitespaces
  34722. isPreTag: () => true,
  34723. getTextMode: ({ tag, props }, parent) => {
  34724. // all top level elements except <template> are parsed as raw text
  34725. // containers
  34726. if ((!parent && tag !== 'template') ||
  34727. // <template lang="xxx"> should also be treated as raw text
  34728. (tag === 'template' &&
  34729. props.some(p => p.type === 6 /* ATTRIBUTE */ &&
  34730. p.name === 'lang' &&
  34731. p.value &&
  34732. p.value.content &&
  34733. p.value.content !== 'html'))) {
  34734. return 2 /* RAWTEXT */;
  34735. }
  34736. else {
  34737. return 0 /* DATA */;
  34738. }
  34739. },
  34740. onError: e => {
  34741. errors.push(e);
  34742. }
  34743. });
  34744. ast.children.forEach(node => {
  34745. if (node.type !== 1 /* ELEMENT */) {
  34746. return;
  34747. }
  34748. // we only want to keep the nodes that are not empty (when the tag is not a template)
  34749. if (ignoreEmpty &&
  34750. node.tag !== 'template' &&
  34751. isEmpty(node) &&
  34752. !hasSrc(node)) {
  34753. return;
  34754. }
  34755. switch (node.tag) {
  34756. case 'template':
  34757. if (!descriptor.template) {
  34758. const templateBlock = (descriptor.template = createBlock(node, source, false));
  34759. templateBlock.ast = node;
  34760. // warn against 2.x <template functional>
  34761. if (templateBlock.attrs.functional) {
  34762. const err = new SyntaxError(`<template functional> is no longer supported in Vue 3, since ` +
  34763. `functional components no longer have significant performance ` +
  34764. `difference from stateful ones. Just use a normal <template> ` +
  34765. `instead.`);
  34766. err.loc = node.props.find(p => p.name === 'functional').loc;
  34767. errors.push(err);
  34768. }
  34769. }
  34770. else {
  34771. errors.push(createDuplicateBlockError(node));
  34772. }
  34773. break;
  34774. case 'script':
  34775. const scriptBlock = createBlock(node, source, pad);
  34776. const isSetup = !!scriptBlock.attrs.setup;
  34777. if (isSetup && !descriptor.scriptSetup) {
  34778. descriptor.scriptSetup = scriptBlock;
  34779. break;
  34780. }
  34781. if (!isSetup && !descriptor.script) {
  34782. descriptor.script = scriptBlock;
  34783. break;
  34784. }
  34785. errors.push(createDuplicateBlockError(node, isSetup));
  34786. break;
  34787. case 'style':
  34788. const styleBlock = createBlock(node, source, pad);
  34789. if (styleBlock.attrs.vars) {
  34790. errors.push(new SyntaxError(`<style vars> has been replaced by a new proposal: ` +
  34791. `https://github.com/vuejs/rfcs/pull/231`));
  34792. }
  34793. descriptor.styles.push(styleBlock);
  34794. break;
  34795. default:
  34796. descriptor.customBlocks.push(createBlock(node, source, pad));
  34797. break;
  34798. }
  34799. });
  34800. if (descriptor.scriptSetup) {
  34801. if (descriptor.scriptSetup.src) {
  34802. errors.push(new SyntaxError(`<script setup> cannot use the "src" attribute because ` +
  34803. `its syntax will be ambiguous outside of the component.`));
  34804. descriptor.scriptSetup = null;
  34805. }
  34806. if (descriptor.script && descriptor.script.src) {
  34807. errors.push(new SyntaxError(`<script> cannot use the "src" attribute when <script setup> is ` +
  34808. `also present because they must be processed together.`));
  34809. descriptor.script = null;
  34810. }
  34811. }
  34812. if (sourceMap) {
  34813. const genMap = (block) => {
  34814. if (block && !block.src) {
  34815. block.map = generateSourceMap(filename, source, block.content, sourceRoot, !pad || block.type === 'template' ? block.loc.start.line - 1 : 0);
  34816. }
  34817. };
  34818. genMap(descriptor.template);
  34819. genMap(descriptor.script);
  34820. descriptor.styles.forEach(genMap);
  34821. descriptor.customBlocks.forEach(genMap);
  34822. }
  34823. // parse CSS vars
  34824. descriptor.cssVars = parseCssVars(descriptor);
  34825. // check if the SFC uses :slotted
  34826. const slottedRE = /(?:::v-|:)slotted\(/;
  34827. descriptor.slotted = descriptor.styles.some(s => s.scoped && slottedRE.test(s.content));
  34828. const result = {
  34829. descriptor,
  34830. errors
  34831. };
  34832. sourceToSFC.set(sourceKey, result);
  34833. return result;
  34834. }
  34835. function createDuplicateBlockError(node, isScriptSetup = false) {
  34836. const err = new SyntaxError(`Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`);
  34837. err.loc = node.loc;
  34838. return err;
  34839. }
  34840. function createBlock(node, source, pad) {
  34841. const type = node.tag;
  34842. let { start, end } = node.loc;
  34843. let content = '';
  34844. if (node.children.length) {
  34845. start = node.children[0].loc.start;
  34846. end = node.children[node.children.length - 1].loc.end;
  34847. content = source.slice(start.offset, end.offset);
  34848. }
  34849. else {
  34850. const offset = node.loc.source.indexOf(`</`);
  34851. if (offset > -1) {
  34852. start = {
  34853. line: start.line,
  34854. column: start.column + offset,
  34855. offset: start.offset + offset
  34856. };
  34857. }
  34858. end = Object.assign({}, start);
  34859. }
  34860. const loc = {
  34861. source: content,
  34862. start,
  34863. end
  34864. };
  34865. const attrs = {};
  34866. const block = {
  34867. type,
  34868. content,
  34869. loc,
  34870. attrs
  34871. };
  34872. if (pad) {
  34873. block.content = padContent(source, block, pad) + block.content;
  34874. }
  34875. node.props.forEach(p => {
  34876. if (p.type === 6 /* ATTRIBUTE */) {
  34877. attrs[p.name] = p.value ? p.value.content || true : true;
  34878. if (p.name === 'lang') {
  34879. block.lang = p.value && p.value.content;
  34880. }
  34881. else if (p.name === 'src') {
  34882. block.src = p.value && p.value.content;
  34883. }
  34884. else if (type === 'style') {
  34885. if (p.name === 'scoped') {
  34886. block.scoped = true;
  34887. }
  34888. else if (p.name === 'module') {
  34889. block.module = attrs[p.name];
  34890. }
  34891. }
  34892. else if (type === 'script' && p.name === 'setup') {
  34893. block.setup = attrs.setup;
  34894. }
  34895. }
  34896. });
  34897. return block;
  34898. }
  34899. const splitRE = /\r?\n/g;
  34900. const emptyRE = /^(?:\/\/)?\s*$/;
  34901. const replaceRE = /./g;
  34902. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset) {
  34903. const map = new SourceMapGenerator$2({
  34904. file: filename.replace(/\\/g, '/'),
  34905. sourceRoot: sourceRoot.replace(/\\/g, '/')
  34906. });
  34907. map.setSourceContent(filename, source);
  34908. generated.split(splitRE).forEach((line, index) => {
  34909. if (!emptyRE.test(line)) {
  34910. const originalLine = index + 1 + lineOffset;
  34911. const generatedLine = index + 1;
  34912. for (let i = 0; i < line.length; i++) {
  34913. if (!/\s/.test(line[i])) {
  34914. map.addMapping({
  34915. source: filename,
  34916. original: {
  34917. line: originalLine,
  34918. column: i
  34919. },
  34920. generated: {
  34921. line: generatedLine,
  34922. column: i
  34923. }
  34924. });
  34925. }
  34926. }
  34927. }
  34928. });
  34929. return JSON.parse(map.toString());
  34930. }
  34931. function padContent(content, block, pad) {
  34932. content = content.slice(0, block.loc.start.offset);
  34933. if (pad === 'space') {
  34934. return content.replace(replaceRE, ' ');
  34935. }
  34936. else {
  34937. const offset = content.split(splitRE).length;
  34938. const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n';
  34939. return Array(offset).join(padChar);
  34940. }
  34941. }
  34942. function hasSrc(node) {
  34943. return node.props.some(p => {
  34944. if (p.type !== 6 /* ATTRIBUTE */) {
  34945. return false;
  34946. }
  34947. return p.name === 'src';
  34948. });
  34949. }
  34950. /**
  34951. * Returns true if the node has no children
  34952. * once the empty text nodes (trimmed content) have been filtered out.
  34953. */
  34954. function isEmpty(node) {
  34955. return (node.children.filter(child => child.type !== 2 /* TEXT */ || child.content.trim() !== '').length === 0);
  34956. }
  34957. // Copyright Joyent, Inc. and other Node contributors.
  34958. //
  34959. // Permission is hereby granted, free of charge, to any person obtaining a
  34960. // copy of this software and associated documentation files (the
  34961. // "Software"), to deal in the Software without restriction, including
  34962. // without limitation the rights to use, copy, modify, merge, publish,
  34963. // distribute, sublicense, and/or sell copies of the Software, and to permit
  34964. // persons to whom the Software is furnished to do so, subject to the
  34965. // following conditions:
  34966. //
  34967. // The above copyright notice and this permission notice shall be included
  34968. // in all copies or substantial portions of the Software.
  34969. //
  34970. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  34971. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  34972. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  34973. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  34974. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  34975. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  34976. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  34977. // resolves . and .. elements in a path array with directory names there
  34978. // must be no slashes, empty elements, or device names (c:\) in the array
  34979. // (so also no leading and trailing slashes - it does not distinguish
  34980. // relative and absolute paths)
  34981. function normalizeArray(parts, allowAboveRoot) {
  34982. // if the path tries to go above the root, `up` ends up > 0
  34983. var up = 0;
  34984. for (var i = parts.length - 1; i >= 0; i--) {
  34985. var last = parts[i];
  34986. if (last === '.') {
  34987. parts.splice(i, 1);
  34988. } else if (last === '..') {
  34989. parts.splice(i, 1);
  34990. up++;
  34991. } else if (up) {
  34992. parts.splice(i, 1);
  34993. up--;
  34994. }
  34995. }
  34996. // if the path is allowed to go above the root, restore leading ..s
  34997. if (allowAboveRoot) {
  34998. for (; up--; up) {
  34999. parts.unshift('..');
  35000. }
  35001. }
  35002. return parts;
  35003. }
  35004. // Split a filename into [root, dir, basename, ext], unix version
  35005. // 'root' is just a slash, or nothing.
  35006. var splitPathRe =
  35007. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  35008. var splitPath = function(filename) {
  35009. return splitPathRe.exec(filename).slice(1);
  35010. };
  35011. // path.resolve([from ...], to)
  35012. // posix version
  35013. function resolve() {
  35014. var resolvedPath = '',
  35015. resolvedAbsolute = false;
  35016. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  35017. var path = (i >= 0) ? arguments[i] : '/';
  35018. // Skip empty and invalid entries
  35019. if (typeof path !== 'string') {
  35020. throw new TypeError('Arguments to path.resolve must be strings');
  35021. } else if (!path) {
  35022. continue;
  35023. }
  35024. resolvedPath = path + '/' + resolvedPath;
  35025. resolvedAbsolute = path.charAt(0) === '/';
  35026. }
  35027. // At this point the path should be resolved to a full absolute path, but
  35028. // handle relative paths to be safe (might happen when process.cwd() fails)
  35029. // Normalize the path
  35030. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  35031. return !!p;
  35032. }), !resolvedAbsolute).join('/');
  35033. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  35034. }
  35035. // path.normalize(path)
  35036. // posix version
  35037. function normalize(path) {
  35038. var isPathAbsolute = isAbsolute(path),
  35039. trailingSlash = substr(path, -1) === '/';
  35040. // Normalize the path
  35041. path = normalizeArray(filter(path.split('/'), function(p) {
  35042. return !!p;
  35043. }), !isPathAbsolute).join('/');
  35044. if (!path && !isPathAbsolute) {
  35045. path = '.';
  35046. }
  35047. if (path && trailingSlash) {
  35048. path += '/';
  35049. }
  35050. return (isPathAbsolute ? '/' : '') + path;
  35051. }
  35052. // posix version
  35053. function isAbsolute(path) {
  35054. return path.charAt(0) === '/';
  35055. }
  35056. // posix version
  35057. function join() {
  35058. var paths = Array.prototype.slice.call(arguments, 0);
  35059. return normalize(filter(paths, function(p, index) {
  35060. if (typeof p !== 'string') {
  35061. throw new TypeError('Arguments to path.join must be strings');
  35062. }
  35063. return p;
  35064. }).join('/'));
  35065. }
  35066. // path.relative(from, to)
  35067. // posix version
  35068. function relative(from, to) {
  35069. from = resolve(from).substr(1);
  35070. to = resolve(to).substr(1);
  35071. function trim(arr) {
  35072. var start = 0;
  35073. for (; start < arr.length; start++) {
  35074. if (arr[start] !== '') break;
  35075. }
  35076. var end = arr.length - 1;
  35077. for (; end >= 0; end--) {
  35078. if (arr[end] !== '') break;
  35079. }
  35080. if (start > end) return [];
  35081. return arr.slice(start, end - start + 1);
  35082. }
  35083. var fromParts = trim(from.split('/'));
  35084. var toParts = trim(to.split('/'));
  35085. var length = Math.min(fromParts.length, toParts.length);
  35086. var samePartsLength = length;
  35087. for (var i = 0; i < length; i++) {
  35088. if (fromParts[i] !== toParts[i]) {
  35089. samePartsLength = i;
  35090. break;
  35091. }
  35092. }
  35093. var outputParts = [];
  35094. for (var i = samePartsLength; i < fromParts.length; i++) {
  35095. outputParts.push('..');
  35096. }
  35097. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  35098. return outputParts.join('/');
  35099. }
  35100. var sep = '/';
  35101. var delimiter = ':';
  35102. function dirname(path) {
  35103. var result = splitPath(path),
  35104. root = result[0],
  35105. dir = result[1];
  35106. if (!root && !dir) {
  35107. // No dirname whatsoever
  35108. return '.';
  35109. }
  35110. if (dir) {
  35111. // It has a dirname, strip trailing slash
  35112. dir = dir.substr(0, dir.length - 1);
  35113. }
  35114. return root + dir;
  35115. }
  35116. function basename(path, ext) {
  35117. var f = splitPath(path)[2];
  35118. // TODO: make this comparison case-insensitive on windows?
  35119. if (ext && f.substr(-1 * ext.length) === ext) {
  35120. f = f.substr(0, f.length - ext.length);
  35121. }
  35122. return f;
  35123. }
  35124. function extname(path) {
  35125. return splitPath(path)[3];
  35126. }
  35127. var path = {
  35128. extname: extname,
  35129. basename: basename,
  35130. dirname: dirname,
  35131. sep: sep,
  35132. delimiter: delimiter,
  35133. relative: relative,
  35134. join: join,
  35135. isAbsolute: isAbsolute,
  35136. normalize: normalize,
  35137. resolve: resolve
  35138. };
  35139. function filter (xs, f) {
  35140. if (xs.filter) return xs.filter(f);
  35141. var res = [];
  35142. for (var i = 0; i < xs.length; i++) {
  35143. if (f(xs[i], i, xs)) res.push(xs[i]);
  35144. }
  35145. return res;
  35146. }
  35147. // String.prototype.substr - negative index don't work in IE8
  35148. var substr = 'ab'.substr(-1) === 'b' ?
  35149. function (str, start, len) { return str.substr(start, len) } :
  35150. function (str, start, len) {
  35151. if (start < 0) start = str.length + start;
  35152. return str.substr(start, len);
  35153. }
  35154. ;
  35155. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  35156. __proto__: null,
  35157. resolve: resolve,
  35158. normalize: normalize,
  35159. isAbsolute: isAbsolute,
  35160. join: join,
  35161. relative: relative,
  35162. sep: sep,
  35163. delimiter: delimiter,
  35164. dirname: dirname,
  35165. basename: basename,
  35166. extname: extname,
  35167. 'default': path
  35168. });
  35169. /*! https://mths.be/punycode v1.4.1 by @mathias */
  35170. /** Highest positive signed 32-bit float value */
  35171. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  35172. /** Bootstring parameters */
  35173. var base = 36;
  35174. var tMin = 1;
  35175. var tMax = 26;
  35176. var skew = 38;
  35177. var damp = 700;
  35178. var initialBias = 72;
  35179. var initialN = 128; // 0x80
  35180. var delimiter$1 = '-'; // '\x2D'
  35181. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  35182. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  35183. /** Error messages */
  35184. var errors = {
  35185. 'overflow': 'Overflow: input needs wider integers to process',
  35186. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  35187. 'invalid-input': 'Invalid input'
  35188. };
  35189. /** Convenience shortcuts */
  35190. var baseMinusTMin = base - tMin;
  35191. var floor = Math.floor;
  35192. var stringFromCharCode = String.fromCharCode;
  35193. /*--------------------------------------------------------------------------*/
  35194. /**
  35195. * A generic error utility function.
  35196. * @private
  35197. * @param {String} type The error type.
  35198. * @returns {Error} Throws a `RangeError` with the applicable error message.
  35199. */
  35200. function error(type) {
  35201. throw new RangeError(errors[type]);
  35202. }
  35203. /**
  35204. * A generic `Array#map` utility function.
  35205. * @private
  35206. * @param {Array} array The array to iterate over.
  35207. * @param {Function} callback The function that gets called for every array
  35208. * item.
  35209. * @returns {Array} A new array of values returned by the callback function.
  35210. */
  35211. function map(array, fn) {
  35212. var length = array.length;
  35213. var result = [];
  35214. while (length--) {
  35215. result[length] = fn(array[length]);
  35216. }
  35217. return result;
  35218. }
  35219. /**
  35220. * A simple `Array#map`-like wrapper to work with domain name strings or email
  35221. * addresses.
  35222. * @private
  35223. * @param {String} domain The domain name or email address.
  35224. * @param {Function} callback The function that gets called for every
  35225. * character.
  35226. * @returns {Array} A new string of characters returned by the callback
  35227. * function.
  35228. */
  35229. function mapDomain(string, fn) {
  35230. var parts = string.split('@');
  35231. var result = '';
  35232. if (parts.length > 1) {
  35233. // In email addresses, only the domain name should be punycoded. Leave
  35234. // the local part (i.e. everything up to `@`) intact.
  35235. result = parts[0] + '@';
  35236. string = parts[1];
  35237. }
  35238. // Avoid `split(regex)` for IE8 compatibility. See #17.
  35239. string = string.replace(regexSeparators, '\x2E');
  35240. var labels = string.split('.');
  35241. var encoded = map(labels, fn).join('.');
  35242. return result + encoded;
  35243. }
  35244. /**
  35245. * Creates an array containing the numeric code points of each Unicode
  35246. * character in the string. While JavaScript uses UCS-2 internally,
  35247. * this function will convert a pair of surrogate halves (each of which
  35248. * UCS-2 exposes as separate characters) into a single code point,
  35249. * matching UTF-16.
  35250. * @see `punycode.ucs2.encode`
  35251. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  35252. * @memberOf punycode.ucs2
  35253. * @name decode
  35254. * @param {String} string The Unicode input string (UCS-2).
  35255. * @returns {Array} The new array of code points.
  35256. */
  35257. function ucs2decode(string) {
  35258. var output = [],
  35259. counter = 0,
  35260. length = string.length,
  35261. value,
  35262. extra;
  35263. while (counter < length) {
  35264. value = string.charCodeAt(counter++);
  35265. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  35266. // high surrogate, and there is a next character
  35267. extra = string.charCodeAt(counter++);
  35268. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  35269. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  35270. } else {
  35271. // unmatched surrogate; only append this code unit, in case the next
  35272. // code unit is the high surrogate of a surrogate pair
  35273. output.push(value);
  35274. counter--;
  35275. }
  35276. } else {
  35277. output.push(value);
  35278. }
  35279. }
  35280. return output;
  35281. }
  35282. /**
  35283. * Converts a digit/integer into a basic code point.
  35284. * @see `basicToDigit()`
  35285. * @private
  35286. * @param {Number} digit The numeric value of a basic code point.
  35287. * @returns {Number} The basic code point whose value (when used for
  35288. * representing integers) is `digit`, which needs to be in the range
  35289. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  35290. * used; else, the lowercase form is used. The behavior is undefined
  35291. * if `flag` is non-zero and `digit` has no uppercase form.
  35292. */
  35293. function digitToBasic(digit, flag) {
  35294. // 0..25 map to ASCII a..z or A..Z
  35295. // 26..35 map to ASCII 0..9
  35296. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  35297. }
  35298. /**
  35299. * Bias adaptation function as per section 3.4 of RFC 3492.
  35300. * https://tools.ietf.org/html/rfc3492#section-3.4
  35301. * @private
  35302. */
  35303. function adapt(delta, numPoints, firstTime) {
  35304. var k = 0;
  35305. delta = firstTime ? floor(delta / damp) : delta >> 1;
  35306. delta += floor(delta / numPoints);
  35307. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  35308. delta = floor(delta / baseMinusTMin);
  35309. }
  35310. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  35311. }
  35312. /**
  35313. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  35314. * Punycode string of ASCII-only symbols.
  35315. * @memberOf punycode
  35316. * @param {String} input The string of Unicode symbols.
  35317. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  35318. */
  35319. function encode$2(input) {
  35320. var n,
  35321. delta,
  35322. handledCPCount,
  35323. basicLength,
  35324. bias,
  35325. j,
  35326. m,
  35327. q,
  35328. k,
  35329. t,
  35330. currentValue,
  35331. output = [],
  35332. /** `inputLength` will hold the number of code points in `input`. */
  35333. inputLength,
  35334. /** Cached calculation results */
  35335. handledCPCountPlusOne,
  35336. baseMinusT,
  35337. qMinusT;
  35338. // Convert the input in UCS-2 to Unicode
  35339. input = ucs2decode(input);
  35340. // Cache the length
  35341. inputLength = input.length;
  35342. // Initialize the state
  35343. n = initialN;
  35344. delta = 0;
  35345. bias = initialBias;
  35346. // Handle the basic code points
  35347. for (j = 0; j < inputLength; ++j) {
  35348. currentValue = input[j];
  35349. if (currentValue < 0x80) {
  35350. output.push(stringFromCharCode(currentValue));
  35351. }
  35352. }
  35353. handledCPCount = basicLength = output.length;
  35354. // `handledCPCount` is the number of code points that have been handled;
  35355. // `basicLength` is the number of basic code points.
  35356. // Finish the basic string - if it is not empty - with a delimiter
  35357. if (basicLength) {
  35358. output.push(delimiter$1);
  35359. }
  35360. // Main encoding loop:
  35361. while (handledCPCount < inputLength) {
  35362. // All non-basic code points < n have been handled already. Find the next
  35363. // larger one:
  35364. for (m = maxInt, j = 0; j < inputLength; ++j) {
  35365. currentValue = input[j];
  35366. if (currentValue >= n && currentValue < m) {
  35367. m = currentValue;
  35368. }
  35369. }
  35370. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  35371. // but guard against overflow
  35372. handledCPCountPlusOne = handledCPCount + 1;
  35373. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  35374. error('overflow');
  35375. }
  35376. delta += (m - n) * handledCPCountPlusOne;
  35377. n = m;
  35378. for (j = 0; j < inputLength; ++j) {
  35379. currentValue = input[j];
  35380. if (currentValue < n && ++delta > maxInt) {
  35381. error('overflow');
  35382. }
  35383. if (currentValue == n) {
  35384. // Represent delta as a generalized variable-length integer
  35385. for (q = delta, k = base; /* no condition */ ; k += base) {
  35386. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  35387. if (q < t) {
  35388. break;
  35389. }
  35390. qMinusT = q - t;
  35391. baseMinusT = base - t;
  35392. output.push(
  35393. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  35394. );
  35395. q = floor(qMinusT / baseMinusT);
  35396. }
  35397. output.push(stringFromCharCode(digitToBasic(q, 0)));
  35398. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  35399. delta = 0;
  35400. ++handledCPCount;
  35401. }
  35402. }
  35403. ++delta;
  35404. ++n;
  35405. }
  35406. return output.join('');
  35407. }
  35408. /**
  35409. * Converts a Unicode string representing a domain name or an email address to
  35410. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  35411. * i.e. it doesn't matter if you call it with a domain that's already in
  35412. * ASCII.
  35413. * @memberOf punycode
  35414. * @param {String} input The domain name or email address to convert, as a
  35415. * Unicode string.
  35416. * @returns {String} The Punycode representation of the given domain name or
  35417. * email address.
  35418. */
  35419. function toASCII(input) {
  35420. return mapDomain(input, function(string) {
  35421. return regexNonASCII.test(string) ?
  35422. 'xn--' + encode$2(string) :
  35423. string;
  35424. });
  35425. }
  35426. var lookup = [];
  35427. var revLookup = [];
  35428. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  35429. var inited = false;
  35430. function init () {
  35431. inited = true;
  35432. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  35433. for (var i = 0, len = code.length; i < len; ++i) {
  35434. lookup[i] = code[i];
  35435. revLookup[code.charCodeAt(i)] = i;
  35436. }
  35437. revLookup['-'.charCodeAt(0)] = 62;
  35438. revLookup['_'.charCodeAt(0)] = 63;
  35439. }
  35440. function toByteArray (b64) {
  35441. if (!inited) {
  35442. init();
  35443. }
  35444. var i, j, l, tmp, placeHolders, arr;
  35445. var len = b64.length;
  35446. if (len % 4 > 0) {
  35447. throw new Error('Invalid string. Length must be a multiple of 4')
  35448. }
  35449. // the number of equal signs (place holders)
  35450. // if there are two placeholders, than the two characters before it
  35451. // represent one byte
  35452. // if there is only one, then the three characters before it represent 2 bytes
  35453. // this is just a cheap hack to not do indexOf twice
  35454. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  35455. // base64 is 4/3 + up to two characters of the original data
  35456. arr = new Arr(len * 3 / 4 - placeHolders);
  35457. // if there are placeholders, only get up to the last complete 4 chars
  35458. l = placeHolders > 0 ? len - 4 : len;
  35459. var L = 0;
  35460. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  35461. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  35462. arr[L++] = (tmp >> 16) & 0xFF;
  35463. arr[L++] = (tmp >> 8) & 0xFF;
  35464. arr[L++] = tmp & 0xFF;
  35465. }
  35466. if (placeHolders === 2) {
  35467. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  35468. arr[L++] = tmp & 0xFF;
  35469. } else if (placeHolders === 1) {
  35470. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  35471. arr[L++] = (tmp >> 8) & 0xFF;
  35472. arr[L++] = tmp & 0xFF;
  35473. }
  35474. return arr
  35475. }
  35476. function tripletToBase64 (num) {
  35477. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  35478. }
  35479. function encodeChunk (uint8, start, end) {
  35480. var tmp;
  35481. var output = [];
  35482. for (var i = start; i < end; i += 3) {
  35483. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  35484. output.push(tripletToBase64(tmp));
  35485. }
  35486. return output.join('')
  35487. }
  35488. function fromByteArray (uint8) {
  35489. if (!inited) {
  35490. init();
  35491. }
  35492. var tmp;
  35493. var len = uint8.length;
  35494. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  35495. var output = '';
  35496. var parts = [];
  35497. var maxChunkLength = 16383; // must be multiple of 3
  35498. // go through the array every three bytes, we'll deal with trailing stuff later
  35499. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  35500. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  35501. }
  35502. // pad the end with zeros, but make sure to not forget the extra bytes
  35503. if (extraBytes === 1) {
  35504. tmp = uint8[len - 1];
  35505. output += lookup[tmp >> 2];
  35506. output += lookup[(tmp << 4) & 0x3F];
  35507. output += '==';
  35508. } else if (extraBytes === 2) {
  35509. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  35510. output += lookup[tmp >> 10];
  35511. output += lookup[(tmp >> 4) & 0x3F];
  35512. output += lookup[(tmp << 2) & 0x3F];
  35513. output += '=';
  35514. }
  35515. parts.push(output);
  35516. return parts.join('')
  35517. }
  35518. function read (buffer, offset, isLE, mLen, nBytes) {
  35519. var e, m;
  35520. var eLen = nBytes * 8 - mLen - 1;
  35521. var eMax = (1 << eLen) - 1;
  35522. var eBias = eMax >> 1;
  35523. var nBits = -7;
  35524. var i = isLE ? (nBytes - 1) : 0;
  35525. var d = isLE ? -1 : 1;
  35526. var s = buffer[offset + i];
  35527. i += d;
  35528. e = s & ((1 << (-nBits)) - 1);
  35529. s >>= (-nBits);
  35530. nBits += eLen;
  35531. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  35532. m = e & ((1 << (-nBits)) - 1);
  35533. e >>= (-nBits);
  35534. nBits += mLen;
  35535. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  35536. if (e === 0) {
  35537. e = 1 - eBias;
  35538. } else if (e === eMax) {
  35539. return m ? NaN : ((s ? -1 : 1) * Infinity)
  35540. } else {
  35541. m = m + Math.pow(2, mLen);
  35542. e = e - eBias;
  35543. }
  35544. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  35545. }
  35546. function write (buffer, value, offset, isLE, mLen, nBytes) {
  35547. var e, m, c;
  35548. var eLen = nBytes * 8 - mLen - 1;
  35549. var eMax = (1 << eLen) - 1;
  35550. var eBias = eMax >> 1;
  35551. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  35552. var i = isLE ? 0 : (nBytes - 1);
  35553. var d = isLE ? 1 : -1;
  35554. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  35555. value = Math.abs(value);
  35556. if (isNaN(value) || value === Infinity) {
  35557. m = isNaN(value) ? 1 : 0;
  35558. e = eMax;
  35559. } else {
  35560. e = Math.floor(Math.log(value) / Math.LN2);
  35561. if (value * (c = Math.pow(2, -e)) < 1) {
  35562. e--;
  35563. c *= 2;
  35564. }
  35565. if (e + eBias >= 1) {
  35566. value += rt / c;
  35567. } else {
  35568. value += rt * Math.pow(2, 1 - eBias);
  35569. }
  35570. if (value * c >= 2) {
  35571. e++;
  35572. c /= 2;
  35573. }
  35574. if (e + eBias >= eMax) {
  35575. m = 0;
  35576. e = eMax;
  35577. } else if (e + eBias >= 1) {
  35578. m = (value * c - 1) * Math.pow(2, mLen);
  35579. e = e + eBias;
  35580. } else {
  35581. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  35582. e = 0;
  35583. }
  35584. }
  35585. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  35586. e = (e << mLen) | m;
  35587. eLen += mLen;
  35588. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  35589. buffer[offset + i - d] |= s * 128;
  35590. }
  35591. var toString$1 = {}.toString;
  35592. var isArray$1 = Array.isArray || function (arr) {
  35593. return toString$1.call(arr) == '[object Array]';
  35594. };
  35595. /*!
  35596. * The buffer module from node.js, for the browser.
  35597. *
  35598. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  35599. * @license MIT
  35600. */
  35601. var INSPECT_MAX_BYTES = 50;
  35602. /**
  35603. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  35604. * === true Use Uint8Array implementation (fastest)
  35605. * === false Use Object implementation (most compatible, even IE6)
  35606. *
  35607. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  35608. * Opera 11.6+, iOS 4.2+.
  35609. *
  35610. * Due to various browser bugs, sometimes the Object implementation will be used even
  35611. * when the browser supports typed arrays.
  35612. *
  35613. * Note:
  35614. *
  35615. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  35616. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  35617. *
  35618. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  35619. *
  35620. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  35621. * incorrect length in some situations.
  35622. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  35623. * get the Object implementation, which is slower but behaves correctly.
  35624. */
  35625. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  35626. ? global.TYPED_ARRAY_SUPPORT
  35627. : true;
  35628. function kMaxLength () {
  35629. return Buffer.TYPED_ARRAY_SUPPORT
  35630. ? 0x7fffffff
  35631. : 0x3fffffff
  35632. }
  35633. function createBuffer (that, length) {
  35634. if (kMaxLength() < length) {
  35635. throw new RangeError('Invalid typed array length')
  35636. }
  35637. if (Buffer.TYPED_ARRAY_SUPPORT) {
  35638. // Return an augmented `Uint8Array` instance, for best performance
  35639. that = new Uint8Array(length);
  35640. that.__proto__ = Buffer.prototype;
  35641. } else {
  35642. // Fallback: Return an object instance of the Buffer class
  35643. if (that === null) {
  35644. that = new Buffer(length);
  35645. }
  35646. that.length = length;
  35647. }
  35648. return that
  35649. }
  35650. /**
  35651. * The Buffer constructor returns instances of `Uint8Array` that have their
  35652. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  35653. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  35654. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  35655. * returns a single octet.
  35656. *
  35657. * The `Uint8Array` prototype remains unmodified.
  35658. */
  35659. function Buffer (arg, encodingOrOffset, length) {
  35660. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  35661. return new Buffer(arg, encodingOrOffset, length)
  35662. }
  35663. // Common case.
  35664. if (typeof arg === 'number') {
  35665. if (typeof encodingOrOffset === 'string') {
  35666. throw new Error(
  35667. 'If encoding is specified then the first argument must be a string'
  35668. )
  35669. }
  35670. return allocUnsafe(this, arg)
  35671. }
  35672. return from(this, arg, encodingOrOffset, length)
  35673. }
  35674. Buffer.poolSize = 8192; // not used by this implementation
  35675. // TODO: Legacy, not needed anymore. Remove in next major version.
  35676. Buffer._augment = function (arr) {
  35677. arr.__proto__ = Buffer.prototype;
  35678. return arr
  35679. };
  35680. function from (that, value, encodingOrOffset, length) {
  35681. if (typeof value === 'number') {
  35682. throw new TypeError('"value" argument must not be a number')
  35683. }
  35684. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  35685. return fromArrayBuffer(that, value, encodingOrOffset, length)
  35686. }
  35687. if (typeof value === 'string') {
  35688. return fromString(that, value, encodingOrOffset)
  35689. }
  35690. return fromObject(that, value)
  35691. }
  35692. /**
  35693. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  35694. * if value is a number.
  35695. * Buffer.from(str[, encoding])
  35696. * Buffer.from(array)
  35697. * Buffer.from(buffer)
  35698. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  35699. **/
  35700. Buffer.from = function (value, encodingOrOffset, length) {
  35701. return from(null, value, encodingOrOffset, length)
  35702. };
  35703. if (Buffer.TYPED_ARRAY_SUPPORT) {
  35704. Buffer.prototype.__proto__ = Uint8Array.prototype;
  35705. Buffer.__proto__ = Uint8Array;
  35706. }
  35707. function assertSize (size) {
  35708. if (typeof size !== 'number') {
  35709. throw new TypeError('"size" argument must be a number')
  35710. } else if (size < 0) {
  35711. throw new RangeError('"size" argument must not be negative')
  35712. }
  35713. }
  35714. function alloc (that, size, fill, encoding) {
  35715. assertSize(size);
  35716. if (size <= 0) {
  35717. return createBuffer(that, size)
  35718. }
  35719. if (fill !== undefined) {
  35720. // Only pay attention to encoding if it's a string. This
  35721. // prevents accidentally sending in a number that would
  35722. // be interpretted as a start offset.
  35723. return typeof encoding === 'string'
  35724. ? createBuffer(that, size).fill(fill, encoding)
  35725. : createBuffer(that, size).fill(fill)
  35726. }
  35727. return createBuffer(that, size)
  35728. }
  35729. /**
  35730. * Creates a new filled Buffer instance.
  35731. * alloc(size[, fill[, encoding]])
  35732. **/
  35733. Buffer.alloc = function (size, fill, encoding) {
  35734. return alloc(null, size, fill, encoding)
  35735. };
  35736. function allocUnsafe (that, size) {
  35737. assertSize(size);
  35738. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  35739. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  35740. for (var i = 0; i < size; ++i) {
  35741. that[i] = 0;
  35742. }
  35743. }
  35744. return that
  35745. }
  35746. /**
  35747. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  35748. * */
  35749. Buffer.allocUnsafe = function (size) {
  35750. return allocUnsafe(null, size)
  35751. };
  35752. /**
  35753. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  35754. */
  35755. Buffer.allocUnsafeSlow = function (size) {
  35756. return allocUnsafe(null, size)
  35757. };
  35758. function fromString (that, string, encoding) {
  35759. if (typeof encoding !== 'string' || encoding === '') {
  35760. encoding = 'utf8';
  35761. }
  35762. if (!Buffer.isEncoding(encoding)) {
  35763. throw new TypeError('"encoding" must be a valid string encoding')
  35764. }
  35765. var length = byteLength(string, encoding) | 0;
  35766. that = createBuffer(that, length);
  35767. var actual = that.write(string, encoding);
  35768. if (actual !== length) {
  35769. // Writing a hex string, for example, that contains invalid characters will
  35770. // cause everything after the first invalid character to be ignored. (e.g.
  35771. // 'abxxcd' will be treated as 'ab')
  35772. that = that.slice(0, actual);
  35773. }
  35774. return that
  35775. }
  35776. function fromArrayLike (that, array) {
  35777. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  35778. that = createBuffer(that, length);
  35779. for (var i = 0; i < length; i += 1) {
  35780. that[i] = array[i] & 255;
  35781. }
  35782. return that
  35783. }
  35784. function fromArrayBuffer (that, array, byteOffset, length) {
  35785. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  35786. if (byteOffset < 0 || array.byteLength < byteOffset) {
  35787. throw new RangeError('\'offset\' is out of bounds')
  35788. }
  35789. if (array.byteLength < byteOffset + (length || 0)) {
  35790. throw new RangeError('\'length\' is out of bounds')
  35791. }
  35792. if (byteOffset === undefined && length === undefined) {
  35793. array = new Uint8Array(array);
  35794. } else if (length === undefined) {
  35795. array = new Uint8Array(array, byteOffset);
  35796. } else {
  35797. array = new Uint8Array(array, byteOffset, length);
  35798. }
  35799. if (Buffer.TYPED_ARRAY_SUPPORT) {
  35800. // Return an augmented `Uint8Array` instance, for best performance
  35801. that = array;
  35802. that.__proto__ = Buffer.prototype;
  35803. } else {
  35804. // Fallback: Return an object instance of the Buffer class
  35805. that = fromArrayLike(that, array);
  35806. }
  35807. return that
  35808. }
  35809. function fromObject (that, obj) {
  35810. if (internalIsBuffer(obj)) {
  35811. var len = checked(obj.length) | 0;
  35812. that = createBuffer(that, len);
  35813. if (that.length === 0) {
  35814. return that
  35815. }
  35816. obj.copy(that, 0, 0, len);
  35817. return that
  35818. }
  35819. if (obj) {
  35820. if ((typeof ArrayBuffer !== 'undefined' &&
  35821. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  35822. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  35823. return createBuffer(that, 0)
  35824. }
  35825. return fromArrayLike(that, obj)
  35826. }
  35827. if (obj.type === 'Buffer' && isArray$1(obj.data)) {
  35828. return fromArrayLike(that, obj.data)
  35829. }
  35830. }
  35831. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  35832. }
  35833. function checked (length) {
  35834. // Note: cannot use `length < kMaxLength()` here because that fails when
  35835. // length is NaN (which is otherwise coerced to zero.)
  35836. if (length >= kMaxLength()) {
  35837. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  35838. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  35839. }
  35840. return length | 0
  35841. }
  35842. Buffer.isBuffer = isBuffer;
  35843. function internalIsBuffer (b) {
  35844. return !!(b != null && b._isBuffer)
  35845. }
  35846. Buffer.compare = function compare (a, b) {
  35847. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  35848. throw new TypeError('Arguments must be Buffers')
  35849. }
  35850. if (a === b) return 0
  35851. var x = a.length;
  35852. var y = b.length;
  35853. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  35854. if (a[i] !== b[i]) {
  35855. x = a[i];
  35856. y = b[i];
  35857. break
  35858. }
  35859. }
  35860. if (x < y) return -1
  35861. if (y < x) return 1
  35862. return 0
  35863. };
  35864. Buffer.isEncoding = function isEncoding (encoding) {
  35865. switch (String(encoding).toLowerCase()) {
  35866. case 'hex':
  35867. case 'utf8':
  35868. case 'utf-8':
  35869. case 'ascii':
  35870. case 'latin1':
  35871. case 'binary':
  35872. case 'base64':
  35873. case 'ucs2':
  35874. case 'ucs-2':
  35875. case 'utf16le':
  35876. case 'utf-16le':
  35877. return true
  35878. default:
  35879. return false
  35880. }
  35881. };
  35882. Buffer.concat = function concat (list, length) {
  35883. if (!isArray$1(list)) {
  35884. throw new TypeError('"list" argument must be an Array of Buffers')
  35885. }
  35886. if (list.length === 0) {
  35887. return Buffer.alloc(0)
  35888. }
  35889. var i;
  35890. if (length === undefined) {
  35891. length = 0;
  35892. for (i = 0; i < list.length; ++i) {
  35893. length += list[i].length;
  35894. }
  35895. }
  35896. var buffer = Buffer.allocUnsafe(length);
  35897. var pos = 0;
  35898. for (i = 0; i < list.length; ++i) {
  35899. var buf = list[i];
  35900. if (!internalIsBuffer(buf)) {
  35901. throw new TypeError('"list" argument must be an Array of Buffers')
  35902. }
  35903. buf.copy(buffer, pos);
  35904. pos += buf.length;
  35905. }
  35906. return buffer
  35907. };
  35908. function byteLength (string, encoding) {
  35909. if (internalIsBuffer(string)) {
  35910. return string.length
  35911. }
  35912. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  35913. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  35914. return string.byteLength
  35915. }
  35916. if (typeof string !== 'string') {
  35917. string = '' + string;
  35918. }
  35919. var len = string.length;
  35920. if (len === 0) return 0
  35921. // Use a for loop to avoid recursion
  35922. var loweredCase = false;
  35923. for (;;) {
  35924. switch (encoding) {
  35925. case 'ascii':
  35926. case 'latin1':
  35927. case 'binary':
  35928. return len
  35929. case 'utf8':
  35930. case 'utf-8':
  35931. case undefined:
  35932. return utf8ToBytes(string).length
  35933. case 'ucs2':
  35934. case 'ucs-2':
  35935. case 'utf16le':
  35936. case 'utf-16le':
  35937. return len * 2
  35938. case 'hex':
  35939. return len >>> 1
  35940. case 'base64':
  35941. return base64ToBytes(string).length
  35942. default:
  35943. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  35944. encoding = ('' + encoding).toLowerCase();
  35945. loweredCase = true;
  35946. }
  35947. }
  35948. }
  35949. Buffer.byteLength = byteLength;
  35950. function slowToString (encoding, start, end) {
  35951. var loweredCase = false;
  35952. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  35953. // property of a typed array.
  35954. // This behaves neither like String nor Uint8Array in that we set start/end
  35955. // to their upper/lower bounds if the value passed is out of range.
  35956. // undefined is handled specially as per ECMA-262 6th Edition,
  35957. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  35958. if (start === undefined || start < 0) {
  35959. start = 0;
  35960. }
  35961. // Return early if start > this.length. Done here to prevent potential uint32
  35962. // coercion fail below.
  35963. if (start > this.length) {
  35964. return ''
  35965. }
  35966. if (end === undefined || end > this.length) {
  35967. end = this.length;
  35968. }
  35969. if (end <= 0) {
  35970. return ''
  35971. }
  35972. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  35973. end >>>= 0;
  35974. start >>>= 0;
  35975. if (end <= start) {
  35976. return ''
  35977. }
  35978. if (!encoding) encoding = 'utf8';
  35979. while (true) {
  35980. switch (encoding) {
  35981. case 'hex':
  35982. return hexSlice(this, start, end)
  35983. case 'utf8':
  35984. case 'utf-8':
  35985. return utf8Slice(this, start, end)
  35986. case 'ascii':
  35987. return asciiSlice(this, start, end)
  35988. case 'latin1':
  35989. case 'binary':
  35990. return latin1Slice(this, start, end)
  35991. case 'base64':
  35992. return base64Slice(this, start, end)
  35993. case 'ucs2':
  35994. case 'ucs-2':
  35995. case 'utf16le':
  35996. case 'utf-16le':
  35997. return utf16leSlice(this, start, end)
  35998. default:
  35999. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  36000. encoding = (encoding + '').toLowerCase();
  36001. loweredCase = true;
  36002. }
  36003. }
  36004. }
  36005. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  36006. // Buffer instances.
  36007. Buffer.prototype._isBuffer = true;
  36008. function swap$1 (b, n, m) {
  36009. var i = b[n];
  36010. b[n] = b[m];
  36011. b[m] = i;
  36012. }
  36013. Buffer.prototype.swap16 = function swap16 () {
  36014. var len = this.length;
  36015. if (len % 2 !== 0) {
  36016. throw new RangeError('Buffer size must be a multiple of 16-bits')
  36017. }
  36018. for (var i = 0; i < len; i += 2) {
  36019. swap$1(this, i, i + 1);
  36020. }
  36021. return this
  36022. };
  36023. Buffer.prototype.swap32 = function swap32 () {
  36024. var len = this.length;
  36025. if (len % 4 !== 0) {
  36026. throw new RangeError('Buffer size must be a multiple of 32-bits')
  36027. }
  36028. for (var i = 0; i < len; i += 4) {
  36029. swap$1(this, i, i + 3);
  36030. swap$1(this, i + 1, i + 2);
  36031. }
  36032. return this
  36033. };
  36034. Buffer.prototype.swap64 = function swap64 () {
  36035. var len = this.length;
  36036. if (len % 8 !== 0) {
  36037. throw new RangeError('Buffer size must be a multiple of 64-bits')
  36038. }
  36039. for (var i = 0; i < len; i += 8) {
  36040. swap$1(this, i, i + 7);
  36041. swap$1(this, i + 1, i + 6);
  36042. swap$1(this, i + 2, i + 5);
  36043. swap$1(this, i + 3, i + 4);
  36044. }
  36045. return this
  36046. };
  36047. Buffer.prototype.toString = function toString () {
  36048. var length = this.length | 0;
  36049. if (length === 0) return ''
  36050. if (arguments.length === 0) return utf8Slice(this, 0, length)
  36051. return slowToString.apply(this, arguments)
  36052. };
  36053. Buffer.prototype.equals = function equals (b) {
  36054. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  36055. if (this === b) return true
  36056. return Buffer.compare(this, b) === 0
  36057. };
  36058. Buffer.prototype.inspect = function inspect () {
  36059. var str = '';
  36060. var max = INSPECT_MAX_BYTES;
  36061. if (this.length > 0) {
  36062. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  36063. if (this.length > max) str += ' ... ';
  36064. }
  36065. return '<Buffer ' + str + '>'
  36066. };
  36067. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  36068. if (!internalIsBuffer(target)) {
  36069. throw new TypeError('Argument must be a Buffer')
  36070. }
  36071. if (start === undefined) {
  36072. start = 0;
  36073. }
  36074. if (end === undefined) {
  36075. end = target ? target.length : 0;
  36076. }
  36077. if (thisStart === undefined) {
  36078. thisStart = 0;
  36079. }
  36080. if (thisEnd === undefined) {
  36081. thisEnd = this.length;
  36082. }
  36083. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  36084. throw new RangeError('out of range index')
  36085. }
  36086. if (thisStart >= thisEnd && start >= end) {
  36087. return 0
  36088. }
  36089. if (thisStart >= thisEnd) {
  36090. return -1
  36091. }
  36092. if (start >= end) {
  36093. return 1
  36094. }
  36095. start >>>= 0;
  36096. end >>>= 0;
  36097. thisStart >>>= 0;
  36098. thisEnd >>>= 0;
  36099. if (this === target) return 0
  36100. var x = thisEnd - thisStart;
  36101. var y = end - start;
  36102. var len = Math.min(x, y);
  36103. var thisCopy = this.slice(thisStart, thisEnd);
  36104. var targetCopy = target.slice(start, end);
  36105. for (var i = 0; i < len; ++i) {
  36106. if (thisCopy[i] !== targetCopy[i]) {
  36107. x = thisCopy[i];
  36108. y = targetCopy[i];
  36109. break
  36110. }
  36111. }
  36112. if (x < y) return -1
  36113. if (y < x) return 1
  36114. return 0
  36115. };
  36116. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  36117. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  36118. //
  36119. // Arguments:
  36120. // - buffer - a Buffer to search
  36121. // - val - a string, Buffer, or number
  36122. // - byteOffset - an index into `buffer`; will be clamped to an int32
  36123. // - encoding - an optional encoding, relevant is val is a string
  36124. // - dir - true for indexOf, false for lastIndexOf
  36125. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  36126. // Empty buffer means no match
  36127. if (buffer.length === 0) return -1
  36128. // Normalize byteOffset
  36129. if (typeof byteOffset === 'string') {
  36130. encoding = byteOffset;
  36131. byteOffset = 0;
  36132. } else if (byteOffset > 0x7fffffff) {
  36133. byteOffset = 0x7fffffff;
  36134. } else if (byteOffset < -0x80000000) {
  36135. byteOffset = -0x80000000;
  36136. }
  36137. byteOffset = +byteOffset; // Coerce to Number.
  36138. if (isNaN(byteOffset)) {
  36139. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  36140. byteOffset = dir ? 0 : (buffer.length - 1);
  36141. }
  36142. // Normalize byteOffset: negative offsets start from the end of the buffer
  36143. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  36144. if (byteOffset >= buffer.length) {
  36145. if (dir) return -1
  36146. else byteOffset = buffer.length - 1;
  36147. } else if (byteOffset < 0) {
  36148. if (dir) byteOffset = 0;
  36149. else return -1
  36150. }
  36151. // Normalize val
  36152. if (typeof val === 'string') {
  36153. val = Buffer.from(val, encoding);
  36154. }
  36155. // Finally, search either indexOf (if dir is true) or lastIndexOf
  36156. if (internalIsBuffer(val)) {
  36157. // Special case: looking for empty string/buffer always fails
  36158. if (val.length === 0) {
  36159. return -1
  36160. }
  36161. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  36162. } else if (typeof val === 'number') {
  36163. val = val & 0xFF; // Search for a byte value [0-255]
  36164. if (Buffer.TYPED_ARRAY_SUPPORT &&
  36165. typeof Uint8Array.prototype.indexOf === 'function') {
  36166. if (dir) {
  36167. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  36168. } else {
  36169. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  36170. }
  36171. }
  36172. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  36173. }
  36174. throw new TypeError('val must be string, number or Buffer')
  36175. }
  36176. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  36177. var indexSize = 1;
  36178. var arrLength = arr.length;
  36179. var valLength = val.length;
  36180. if (encoding !== undefined) {
  36181. encoding = String(encoding).toLowerCase();
  36182. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  36183. encoding === 'utf16le' || encoding === 'utf-16le') {
  36184. if (arr.length < 2 || val.length < 2) {
  36185. return -1
  36186. }
  36187. indexSize = 2;
  36188. arrLength /= 2;
  36189. valLength /= 2;
  36190. byteOffset /= 2;
  36191. }
  36192. }
  36193. function read (buf, i) {
  36194. if (indexSize === 1) {
  36195. return buf[i]
  36196. } else {
  36197. return buf.readUInt16BE(i * indexSize)
  36198. }
  36199. }
  36200. var i;
  36201. if (dir) {
  36202. var foundIndex = -1;
  36203. for (i = byteOffset; i < arrLength; i++) {
  36204. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  36205. if (foundIndex === -1) foundIndex = i;
  36206. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  36207. } else {
  36208. if (foundIndex !== -1) i -= i - foundIndex;
  36209. foundIndex = -1;
  36210. }
  36211. }
  36212. } else {
  36213. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  36214. for (i = byteOffset; i >= 0; i--) {
  36215. var found = true;
  36216. for (var j = 0; j < valLength; j++) {
  36217. if (read(arr, i + j) !== read(val, j)) {
  36218. found = false;
  36219. break
  36220. }
  36221. }
  36222. if (found) return i
  36223. }
  36224. }
  36225. return -1
  36226. }
  36227. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  36228. return this.indexOf(val, byteOffset, encoding) !== -1
  36229. };
  36230. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  36231. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  36232. };
  36233. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  36234. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  36235. };
  36236. function hexWrite (buf, string, offset, length) {
  36237. offset = Number(offset) || 0;
  36238. var remaining = buf.length - offset;
  36239. if (!length) {
  36240. length = remaining;
  36241. } else {
  36242. length = Number(length);
  36243. if (length > remaining) {
  36244. length = remaining;
  36245. }
  36246. }
  36247. // must be an even number of digits
  36248. var strLen = string.length;
  36249. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  36250. if (length > strLen / 2) {
  36251. length = strLen / 2;
  36252. }
  36253. for (var i = 0; i < length; ++i) {
  36254. var parsed = parseInt(string.substr(i * 2, 2), 16);
  36255. if (isNaN(parsed)) return i
  36256. buf[offset + i] = parsed;
  36257. }
  36258. return i
  36259. }
  36260. function utf8Write (buf, string, offset, length) {
  36261. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  36262. }
  36263. function asciiWrite (buf, string, offset, length) {
  36264. return blitBuffer(asciiToBytes(string), buf, offset, length)
  36265. }
  36266. function latin1Write (buf, string, offset, length) {
  36267. return asciiWrite(buf, string, offset, length)
  36268. }
  36269. function base64Write (buf, string, offset, length) {
  36270. return blitBuffer(base64ToBytes(string), buf, offset, length)
  36271. }
  36272. function ucs2Write (buf, string, offset, length) {
  36273. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  36274. }
  36275. Buffer.prototype.write = function write (string, offset, length, encoding) {
  36276. // Buffer#write(string)
  36277. if (offset === undefined) {
  36278. encoding = 'utf8';
  36279. length = this.length;
  36280. offset = 0;
  36281. // Buffer#write(string, encoding)
  36282. } else if (length === undefined && typeof offset === 'string') {
  36283. encoding = offset;
  36284. length = this.length;
  36285. offset = 0;
  36286. // Buffer#write(string, offset[, length][, encoding])
  36287. } else if (isFinite(offset)) {
  36288. offset = offset | 0;
  36289. if (isFinite(length)) {
  36290. length = length | 0;
  36291. if (encoding === undefined) encoding = 'utf8';
  36292. } else {
  36293. encoding = length;
  36294. length = undefined;
  36295. }
  36296. // legacy write(string, encoding, offset, length) - remove in v0.13
  36297. } else {
  36298. throw new Error(
  36299. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  36300. )
  36301. }
  36302. var remaining = this.length - offset;
  36303. if (length === undefined || length > remaining) length = remaining;
  36304. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  36305. throw new RangeError('Attempt to write outside buffer bounds')
  36306. }
  36307. if (!encoding) encoding = 'utf8';
  36308. var loweredCase = false;
  36309. for (;;) {
  36310. switch (encoding) {
  36311. case 'hex':
  36312. return hexWrite(this, string, offset, length)
  36313. case 'utf8':
  36314. case 'utf-8':
  36315. return utf8Write(this, string, offset, length)
  36316. case 'ascii':
  36317. return asciiWrite(this, string, offset, length)
  36318. case 'latin1':
  36319. case 'binary':
  36320. return latin1Write(this, string, offset, length)
  36321. case 'base64':
  36322. // Warning: maxLength not taken into account in base64Write
  36323. return base64Write(this, string, offset, length)
  36324. case 'ucs2':
  36325. case 'ucs-2':
  36326. case 'utf16le':
  36327. case 'utf-16le':
  36328. return ucs2Write(this, string, offset, length)
  36329. default:
  36330. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  36331. encoding = ('' + encoding).toLowerCase();
  36332. loweredCase = true;
  36333. }
  36334. }
  36335. };
  36336. Buffer.prototype.toJSON = function toJSON () {
  36337. return {
  36338. type: 'Buffer',
  36339. data: Array.prototype.slice.call(this._arr || this, 0)
  36340. }
  36341. };
  36342. function base64Slice (buf, start, end) {
  36343. if (start === 0 && end === buf.length) {
  36344. return fromByteArray(buf)
  36345. } else {
  36346. return fromByteArray(buf.slice(start, end))
  36347. }
  36348. }
  36349. function utf8Slice (buf, start, end) {
  36350. end = Math.min(buf.length, end);
  36351. var res = [];
  36352. var i = start;
  36353. while (i < end) {
  36354. var firstByte = buf[i];
  36355. var codePoint = null;
  36356. var bytesPerSequence = (firstByte > 0xEF) ? 4
  36357. : (firstByte > 0xDF) ? 3
  36358. : (firstByte > 0xBF) ? 2
  36359. : 1;
  36360. if (i + bytesPerSequence <= end) {
  36361. var secondByte, thirdByte, fourthByte, tempCodePoint;
  36362. switch (bytesPerSequence) {
  36363. case 1:
  36364. if (firstByte < 0x80) {
  36365. codePoint = firstByte;
  36366. }
  36367. break
  36368. case 2:
  36369. secondByte = buf[i + 1];
  36370. if ((secondByte & 0xC0) === 0x80) {
  36371. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  36372. if (tempCodePoint > 0x7F) {
  36373. codePoint = tempCodePoint;
  36374. }
  36375. }
  36376. break
  36377. case 3:
  36378. secondByte = buf[i + 1];
  36379. thirdByte = buf[i + 2];
  36380. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  36381. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  36382. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  36383. codePoint = tempCodePoint;
  36384. }
  36385. }
  36386. break
  36387. case 4:
  36388. secondByte = buf[i + 1];
  36389. thirdByte = buf[i + 2];
  36390. fourthByte = buf[i + 3];
  36391. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  36392. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  36393. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  36394. codePoint = tempCodePoint;
  36395. }
  36396. }
  36397. }
  36398. }
  36399. if (codePoint === null) {
  36400. // we did not generate a valid codePoint so insert a
  36401. // replacement char (U+FFFD) and advance only 1 byte
  36402. codePoint = 0xFFFD;
  36403. bytesPerSequence = 1;
  36404. } else if (codePoint > 0xFFFF) {
  36405. // encode to utf16 (surrogate pair dance)
  36406. codePoint -= 0x10000;
  36407. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  36408. codePoint = 0xDC00 | codePoint & 0x3FF;
  36409. }
  36410. res.push(codePoint);
  36411. i += bytesPerSequence;
  36412. }
  36413. return decodeCodePointsArray(res)
  36414. }
  36415. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  36416. // the lowest limit is Chrome, with 0x10000 args.
  36417. // We go 1 magnitude less, for safety
  36418. var MAX_ARGUMENTS_LENGTH = 0x1000;
  36419. function decodeCodePointsArray (codePoints) {
  36420. var len = codePoints.length;
  36421. if (len <= MAX_ARGUMENTS_LENGTH) {
  36422. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  36423. }
  36424. // Decode in chunks to avoid "call stack size exceeded".
  36425. var res = '';
  36426. var i = 0;
  36427. while (i < len) {
  36428. res += String.fromCharCode.apply(
  36429. String,
  36430. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  36431. );
  36432. }
  36433. return res
  36434. }
  36435. function asciiSlice (buf, start, end) {
  36436. var ret = '';
  36437. end = Math.min(buf.length, end);
  36438. for (var i = start; i < end; ++i) {
  36439. ret += String.fromCharCode(buf[i] & 0x7F);
  36440. }
  36441. return ret
  36442. }
  36443. function latin1Slice (buf, start, end) {
  36444. var ret = '';
  36445. end = Math.min(buf.length, end);
  36446. for (var i = start; i < end; ++i) {
  36447. ret += String.fromCharCode(buf[i]);
  36448. }
  36449. return ret
  36450. }
  36451. function hexSlice (buf, start, end) {
  36452. var len = buf.length;
  36453. if (!start || start < 0) start = 0;
  36454. if (!end || end < 0 || end > len) end = len;
  36455. var out = '';
  36456. for (var i = start; i < end; ++i) {
  36457. out += toHex(buf[i]);
  36458. }
  36459. return out
  36460. }
  36461. function utf16leSlice (buf, start, end) {
  36462. var bytes = buf.slice(start, end);
  36463. var res = '';
  36464. for (var i = 0; i < bytes.length; i += 2) {
  36465. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  36466. }
  36467. return res
  36468. }
  36469. Buffer.prototype.slice = function slice (start, end) {
  36470. var len = this.length;
  36471. start = ~~start;
  36472. end = end === undefined ? len : ~~end;
  36473. if (start < 0) {
  36474. start += len;
  36475. if (start < 0) start = 0;
  36476. } else if (start > len) {
  36477. start = len;
  36478. }
  36479. if (end < 0) {
  36480. end += len;
  36481. if (end < 0) end = 0;
  36482. } else if (end > len) {
  36483. end = len;
  36484. }
  36485. if (end < start) end = start;
  36486. var newBuf;
  36487. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36488. newBuf = this.subarray(start, end);
  36489. newBuf.__proto__ = Buffer.prototype;
  36490. } else {
  36491. var sliceLen = end - start;
  36492. newBuf = new Buffer(sliceLen, undefined);
  36493. for (var i = 0; i < sliceLen; ++i) {
  36494. newBuf[i] = this[i + start];
  36495. }
  36496. }
  36497. return newBuf
  36498. };
  36499. /*
  36500. * Need to make sure that buffer isn't trying to write out of bounds.
  36501. */
  36502. function checkOffset (offset, ext, length) {
  36503. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  36504. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  36505. }
  36506. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  36507. offset = offset | 0;
  36508. byteLength = byteLength | 0;
  36509. if (!noAssert) checkOffset(offset, byteLength, this.length);
  36510. var val = this[offset];
  36511. var mul = 1;
  36512. var i = 0;
  36513. while (++i < byteLength && (mul *= 0x100)) {
  36514. val += this[offset + i] * mul;
  36515. }
  36516. return val
  36517. };
  36518. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  36519. offset = offset | 0;
  36520. byteLength = byteLength | 0;
  36521. if (!noAssert) {
  36522. checkOffset(offset, byteLength, this.length);
  36523. }
  36524. var val = this[offset + --byteLength];
  36525. var mul = 1;
  36526. while (byteLength > 0 && (mul *= 0x100)) {
  36527. val += this[offset + --byteLength] * mul;
  36528. }
  36529. return val
  36530. };
  36531. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  36532. if (!noAssert) checkOffset(offset, 1, this.length);
  36533. return this[offset]
  36534. };
  36535. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  36536. if (!noAssert) checkOffset(offset, 2, this.length);
  36537. return this[offset] | (this[offset + 1] << 8)
  36538. };
  36539. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  36540. if (!noAssert) checkOffset(offset, 2, this.length);
  36541. return (this[offset] << 8) | this[offset + 1]
  36542. };
  36543. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  36544. if (!noAssert) checkOffset(offset, 4, this.length);
  36545. return ((this[offset]) |
  36546. (this[offset + 1] << 8) |
  36547. (this[offset + 2] << 16)) +
  36548. (this[offset + 3] * 0x1000000)
  36549. };
  36550. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  36551. if (!noAssert) checkOffset(offset, 4, this.length);
  36552. return (this[offset] * 0x1000000) +
  36553. ((this[offset + 1] << 16) |
  36554. (this[offset + 2] << 8) |
  36555. this[offset + 3])
  36556. };
  36557. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  36558. offset = offset | 0;
  36559. byteLength = byteLength | 0;
  36560. if (!noAssert) checkOffset(offset, byteLength, this.length);
  36561. var val = this[offset];
  36562. var mul = 1;
  36563. var i = 0;
  36564. while (++i < byteLength && (mul *= 0x100)) {
  36565. val += this[offset + i] * mul;
  36566. }
  36567. mul *= 0x80;
  36568. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  36569. return val
  36570. };
  36571. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  36572. offset = offset | 0;
  36573. byteLength = byteLength | 0;
  36574. if (!noAssert) checkOffset(offset, byteLength, this.length);
  36575. var i = byteLength;
  36576. var mul = 1;
  36577. var val = this[offset + --i];
  36578. while (i > 0 && (mul *= 0x100)) {
  36579. val += this[offset + --i] * mul;
  36580. }
  36581. mul *= 0x80;
  36582. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  36583. return val
  36584. };
  36585. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  36586. if (!noAssert) checkOffset(offset, 1, this.length);
  36587. if (!(this[offset] & 0x80)) return (this[offset])
  36588. return ((0xff - this[offset] + 1) * -1)
  36589. };
  36590. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  36591. if (!noAssert) checkOffset(offset, 2, this.length);
  36592. var val = this[offset] | (this[offset + 1] << 8);
  36593. return (val & 0x8000) ? val | 0xFFFF0000 : val
  36594. };
  36595. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  36596. if (!noAssert) checkOffset(offset, 2, this.length);
  36597. var val = this[offset + 1] | (this[offset] << 8);
  36598. return (val & 0x8000) ? val | 0xFFFF0000 : val
  36599. };
  36600. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  36601. if (!noAssert) checkOffset(offset, 4, this.length);
  36602. return (this[offset]) |
  36603. (this[offset + 1] << 8) |
  36604. (this[offset + 2] << 16) |
  36605. (this[offset + 3] << 24)
  36606. };
  36607. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  36608. if (!noAssert) checkOffset(offset, 4, this.length);
  36609. return (this[offset] << 24) |
  36610. (this[offset + 1] << 16) |
  36611. (this[offset + 2] << 8) |
  36612. (this[offset + 3])
  36613. };
  36614. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  36615. if (!noAssert) checkOffset(offset, 4, this.length);
  36616. return read(this, offset, true, 23, 4)
  36617. };
  36618. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  36619. if (!noAssert) checkOffset(offset, 4, this.length);
  36620. return read(this, offset, false, 23, 4)
  36621. };
  36622. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  36623. if (!noAssert) checkOffset(offset, 8, this.length);
  36624. return read(this, offset, true, 52, 8)
  36625. };
  36626. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  36627. if (!noAssert) checkOffset(offset, 8, this.length);
  36628. return read(this, offset, false, 52, 8)
  36629. };
  36630. function checkInt (buf, value, offset, ext, max, min) {
  36631. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  36632. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  36633. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  36634. }
  36635. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  36636. value = +value;
  36637. offset = offset | 0;
  36638. byteLength = byteLength | 0;
  36639. if (!noAssert) {
  36640. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  36641. checkInt(this, value, offset, byteLength, maxBytes, 0);
  36642. }
  36643. var mul = 1;
  36644. var i = 0;
  36645. this[offset] = value & 0xFF;
  36646. while (++i < byteLength && (mul *= 0x100)) {
  36647. this[offset + i] = (value / mul) & 0xFF;
  36648. }
  36649. return offset + byteLength
  36650. };
  36651. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  36652. value = +value;
  36653. offset = offset | 0;
  36654. byteLength = byteLength | 0;
  36655. if (!noAssert) {
  36656. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  36657. checkInt(this, value, offset, byteLength, maxBytes, 0);
  36658. }
  36659. var i = byteLength - 1;
  36660. var mul = 1;
  36661. this[offset + i] = value & 0xFF;
  36662. while (--i >= 0 && (mul *= 0x100)) {
  36663. this[offset + i] = (value / mul) & 0xFF;
  36664. }
  36665. return offset + byteLength
  36666. };
  36667. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  36668. value = +value;
  36669. offset = offset | 0;
  36670. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  36671. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  36672. this[offset] = (value & 0xff);
  36673. return offset + 1
  36674. };
  36675. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  36676. if (value < 0) value = 0xffff + value + 1;
  36677. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  36678. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  36679. (littleEndian ? i : 1 - i) * 8;
  36680. }
  36681. }
  36682. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  36683. value = +value;
  36684. offset = offset | 0;
  36685. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  36686. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36687. this[offset] = (value & 0xff);
  36688. this[offset + 1] = (value >>> 8);
  36689. } else {
  36690. objectWriteUInt16(this, value, offset, true);
  36691. }
  36692. return offset + 2
  36693. };
  36694. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  36695. value = +value;
  36696. offset = offset | 0;
  36697. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  36698. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36699. this[offset] = (value >>> 8);
  36700. this[offset + 1] = (value & 0xff);
  36701. } else {
  36702. objectWriteUInt16(this, value, offset, false);
  36703. }
  36704. return offset + 2
  36705. };
  36706. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  36707. if (value < 0) value = 0xffffffff + value + 1;
  36708. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  36709. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  36710. }
  36711. }
  36712. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  36713. value = +value;
  36714. offset = offset | 0;
  36715. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  36716. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36717. this[offset + 3] = (value >>> 24);
  36718. this[offset + 2] = (value >>> 16);
  36719. this[offset + 1] = (value >>> 8);
  36720. this[offset] = (value & 0xff);
  36721. } else {
  36722. objectWriteUInt32(this, value, offset, true);
  36723. }
  36724. return offset + 4
  36725. };
  36726. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  36727. value = +value;
  36728. offset = offset | 0;
  36729. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  36730. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36731. this[offset] = (value >>> 24);
  36732. this[offset + 1] = (value >>> 16);
  36733. this[offset + 2] = (value >>> 8);
  36734. this[offset + 3] = (value & 0xff);
  36735. } else {
  36736. objectWriteUInt32(this, value, offset, false);
  36737. }
  36738. return offset + 4
  36739. };
  36740. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  36741. value = +value;
  36742. offset = offset | 0;
  36743. if (!noAssert) {
  36744. var limit = Math.pow(2, 8 * byteLength - 1);
  36745. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  36746. }
  36747. var i = 0;
  36748. var mul = 1;
  36749. var sub = 0;
  36750. this[offset] = value & 0xFF;
  36751. while (++i < byteLength && (mul *= 0x100)) {
  36752. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  36753. sub = 1;
  36754. }
  36755. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  36756. }
  36757. return offset + byteLength
  36758. };
  36759. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  36760. value = +value;
  36761. offset = offset | 0;
  36762. if (!noAssert) {
  36763. var limit = Math.pow(2, 8 * byteLength - 1);
  36764. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  36765. }
  36766. var i = byteLength - 1;
  36767. var mul = 1;
  36768. var sub = 0;
  36769. this[offset + i] = value & 0xFF;
  36770. while (--i >= 0 && (mul *= 0x100)) {
  36771. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  36772. sub = 1;
  36773. }
  36774. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  36775. }
  36776. return offset + byteLength
  36777. };
  36778. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  36779. value = +value;
  36780. offset = offset | 0;
  36781. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  36782. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  36783. if (value < 0) value = 0xff + value + 1;
  36784. this[offset] = (value & 0xff);
  36785. return offset + 1
  36786. };
  36787. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  36788. value = +value;
  36789. offset = offset | 0;
  36790. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  36791. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36792. this[offset] = (value & 0xff);
  36793. this[offset + 1] = (value >>> 8);
  36794. } else {
  36795. objectWriteUInt16(this, value, offset, true);
  36796. }
  36797. return offset + 2
  36798. };
  36799. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  36800. value = +value;
  36801. offset = offset | 0;
  36802. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  36803. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36804. this[offset] = (value >>> 8);
  36805. this[offset + 1] = (value & 0xff);
  36806. } else {
  36807. objectWriteUInt16(this, value, offset, false);
  36808. }
  36809. return offset + 2
  36810. };
  36811. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  36812. value = +value;
  36813. offset = offset | 0;
  36814. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  36815. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36816. this[offset] = (value & 0xff);
  36817. this[offset + 1] = (value >>> 8);
  36818. this[offset + 2] = (value >>> 16);
  36819. this[offset + 3] = (value >>> 24);
  36820. } else {
  36821. objectWriteUInt32(this, value, offset, true);
  36822. }
  36823. return offset + 4
  36824. };
  36825. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  36826. value = +value;
  36827. offset = offset | 0;
  36828. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  36829. if (value < 0) value = 0xffffffff + value + 1;
  36830. if (Buffer.TYPED_ARRAY_SUPPORT) {
  36831. this[offset] = (value >>> 24);
  36832. this[offset + 1] = (value >>> 16);
  36833. this[offset + 2] = (value >>> 8);
  36834. this[offset + 3] = (value & 0xff);
  36835. } else {
  36836. objectWriteUInt32(this, value, offset, false);
  36837. }
  36838. return offset + 4
  36839. };
  36840. function checkIEEE754 (buf, value, offset, ext, max, min) {
  36841. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  36842. if (offset < 0) throw new RangeError('Index out of range')
  36843. }
  36844. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  36845. if (!noAssert) {
  36846. checkIEEE754(buf, value, offset, 4);
  36847. }
  36848. write(buf, value, offset, littleEndian, 23, 4);
  36849. return offset + 4
  36850. }
  36851. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  36852. return writeFloat(this, value, offset, true, noAssert)
  36853. };
  36854. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  36855. return writeFloat(this, value, offset, false, noAssert)
  36856. };
  36857. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  36858. if (!noAssert) {
  36859. checkIEEE754(buf, value, offset, 8);
  36860. }
  36861. write(buf, value, offset, littleEndian, 52, 8);
  36862. return offset + 8
  36863. }
  36864. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  36865. return writeDouble(this, value, offset, true, noAssert)
  36866. };
  36867. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  36868. return writeDouble(this, value, offset, false, noAssert)
  36869. };
  36870. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  36871. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  36872. if (!start) start = 0;
  36873. if (!end && end !== 0) end = this.length;
  36874. if (targetStart >= target.length) targetStart = target.length;
  36875. if (!targetStart) targetStart = 0;
  36876. if (end > 0 && end < start) end = start;
  36877. // Copy 0 bytes; we're done
  36878. if (end === start) return 0
  36879. if (target.length === 0 || this.length === 0) return 0
  36880. // Fatal error conditions
  36881. if (targetStart < 0) {
  36882. throw new RangeError('targetStart out of bounds')
  36883. }
  36884. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  36885. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  36886. // Are we oob?
  36887. if (end > this.length) end = this.length;
  36888. if (target.length - targetStart < end - start) {
  36889. end = target.length - targetStart + start;
  36890. }
  36891. var len = end - start;
  36892. var i;
  36893. if (this === target && start < targetStart && targetStart < end) {
  36894. // descending copy from end
  36895. for (i = len - 1; i >= 0; --i) {
  36896. target[i + targetStart] = this[i + start];
  36897. }
  36898. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  36899. // ascending copy from start
  36900. for (i = 0; i < len; ++i) {
  36901. target[i + targetStart] = this[i + start];
  36902. }
  36903. } else {
  36904. Uint8Array.prototype.set.call(
  36905. target,
  36906. this.subarray(start, start + len),
  36907. targetStart
  36908. );
  36909. }
  36910. return len
  36911. };
  36912. // Usage:
  36913. // buffer.fill(number[, offset[, end]])
  36914. // buffer.fill(buffer[, offset[, end]])
  36915. // buffer.fill(string[, offset[, end]][, encoding])
  36916. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  36917. // Handle string cases:
  36918. if (typeof val === 'string') {
  36919. if (typeof start === 'string') {
  36920. encoding = start;
  36921. start = 0;
  36922. end = this.length;
  36923. } else if (typeof end === 'string') {
  36924. encoding = end;
  36925. end = this.length;
  36926. }
  36927. if (val.length === 1) {
  36928. var code = val.charCodeAt(0);
  36929. if (code < 256) {
  36930. val = code;
  36931. }
  36932. }
  36933. if (encoding !== undefined && typeof encoding !== 'string') {
  36934. throw new TypeError('encoding must be a string')
  36935. }
  36936. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  36937. throw new TypeError('Unknown encoding: ' + encoding)
  36938. }
  36939. } else if (typeof val === 'number') {
  36940. val = val & 255;
  36941. }
  36942. // Invalid ranges are not set to a default, so can range check early.
  36943. if (start < 0 || this.length < start || this.length < end) {
  36944. throw new RangeError('Out of range index')
  36945. }
  36946. if (end <= start) {
  36947. return this
  36948. }
  36949. start = start >>> 0;
  36950. end = end === undefined ? this.length : end >>> 0;
  36951. if (!val) val = 0;
  36952. var i;
  36953. if (typeof val === 'number') {
  36954. for (i = start; i < end; ++i) {
  36955. this[i] = val;
  36956. }
  36957. } else {
  36958. var bytes = internalIsBuffer(val)
  36959. ? val
  36960. : utf8ToBytes(new Buffer(val, encoding).toString());
  36961. var len = bytes.length;
  36962. for (i = 0; i < end - start; ++i) {
  36963. this[i + start] = bytes[i % len];
  36964. }
  36965. }
  36966. return this
  36967. };
  36968. // HELPER FUNCTIONS
  36969. // ================
  36970. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  36971. function base64clean (str) {
  36972. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  36973. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  36974. // Node converts strings with length < 2 to ''
  36975. if (str.length < 2) return ''
  36976. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  36977. while (str.length % 4 !== 0) {
  36978. str = str + '=';
  36979. }
  36980. return str
  36981. }
  36982. function stringtrim (str) {
  36983. if (str.trim) return str.trim()
  36984. return str.replace(/^\s+|\s+$/g, '')
  36985. }
  36986. function toHex (n) {
  36987. if (n < 16) return '0' + n.toString(16)
  36988. return n.toString(16)
  36989. }
  36990. function utf8ToBytes (string, units) {
  36991. units = units || Infinity;
  36992. var codePoint;
  36993. var length = string.length;
  36994. var leadSurrogate = null;
  36995. var bytes = [];
  36996. for (var i = 0; i < length; ++i) {
  36997. codePoint = string.charCodeAt(i);
  36998. // is surrogate component
  36999. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  37000. // last char was a lead
  37001. if (!leadSurrogate) {
  37002. // no lead yet
  37003. if (codePoint > 0xDBFF) {
  37004. // unexpected trail
  37005. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  37006. continue
  37007. } else if (i + 1 === length) {
  37008. // unpaired lead
  37009. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  37010. continue
  37011. }
  37012. // valid lead
  37013. leadSurrogate = codePoint;
  37014. continue
  37015. }
  37016. // 2 leads in a row
  37017. if (codePoint < 0xDC00) {
  37018. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  37019. leadSurrogate = codePoint;
  37020. continue
  37021. }
  37022. // valid surrogate pair
  37023. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  37024. } else if (leadSurrogate) {
  37025. // valid bmp char, but last char was a lead
  37026. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  37027. }
  37028. leadSurrogate = null;
  37029. // encode utf8
  37030. if (codePoint < 0x80) {
  37031. if ((units -= 1) < 0) break
  37032. bytes.push(codePoint);
  37033. } else if (codePoint < 0x800) {
  37034. if ((units -= 2) < 0) break
  37035. bytes.push(
  37036. codePoint >> 0x6 | 0xC0,
  37037. codePoint & 0x3F | 0x80
  37038. );
  37039. } else if (codePoint < 0x10000) {
  37040. if ((units -= 3) < 0) break
  37041. bytes.push(
  37042. codePoint >> 0xC | 0xE0,
  37043. codePoint >> 0x6 & 0x3F | 0x80,
  37044. codePoint & 0x3F | 0x80
  37045. );
  37046. } else if (codePoint < 0x110000) {
  37047. if ((units -= 4) < 0) break
  37048. bytes.push(
  37049. codePoint >> 0x12 | 0xF0,
  37050. codePoint >> 0xC & 0x3F | 0x80,
  37051. codePoint >> 0x6 & 0x3F | 0x80,
  37052. codePoint & 0x3F | 0x80
  37053. );
  37054. } else {
  37055. throw new Error('Invalid code point')
  37056. }
  37057. }
  37058. return bytes
  37059. }
  37060. function asciiToBytes (str) {
  37061. var byteArray = [];
  37062. for (var i = 0; i < str.length; ++i) {
  37063. // Node's code seems to be doing this and not & 0x7F..
  37064. byteArray.push(str.charCodeAt(i) & 0xFF);
  37065. }
  37066. return byteArray
  37067. }
  37068. function utf16leToBytes (str, units) {
  37069. var c, hi, lo;
  37070. var byteArray = [];
  37071. for (var i = 0; i < str.length; ++i) {
  37072. if ((units -= 2) < 0) break
  37073. c = str.charCodeAt(i);
  37074. hi = c >> 8;
  37075. lo = c % 256;
  37076. byteArray.push(lo);
  37077. byteArray.push(hi);
  37078. }
  37079. return byteArray
  37080. }
  37081. function base64ToBytes (str) {
  37082. return toByteArray(base64clean(str))
  37083. }
  37084. function blitBuffer (src, dst, offset, length) {
  37085. for (var i = 0; i < length; ++i) {
  37086. if ((i + offset >= dst.length) || (i >= src.length)) break
  37087. dst[i + offset] = src[i];
  37088. }
  37089. return i
  37090. }
  37091. function isnan (val) {
  37092. return val !== val // eslint-disable-line no-self-compare
  37093. }
  37094. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  37095. // The _isBuffer check is for Safari 5-7 support, because it's missing
  37096. // Object.prototype.constructor. Remove this eventually
  37097. function isBuffer(obj) {
  37098. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  37099. }
  37100. function isFastBuffer (obj) {
  37101. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  37102. }
  37103. // For Node v0.10 support. Remove this eventually.
  37104. function isSlowBuffer (obj) {
  37105. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  37106. }
  37107. var inherits$1;
  37108. if (typeof Object.create === 'function'){
  37109. inherits$1 = function inherits(ctor, superCtor) {
  37110. // implementation from standard node.js 'util' module
  37111. ctor.super_ = superCtor;
  37112. ctor.prototype = Object.create(superCtor.prototype, {
  37113. constructor: {
  37114. value: ctor,
  37115. enumerable: false,
  37116. writable: true,
  37117. configurable: true
  37118. }
  37119. });
  37120. };
  37121. } else {
  37122. inherits$1 = function inherits(ctor, superCtor) {
  37123. ctor.super_ = superCtor;
  37124. var TempCtor = function () {};
  37125. TempCtor.prototype = superCtor.prototype;
  37126. ctor.prototype = new TempCtor();
  37127. ctor.prototype.constructor = ctor;
  37128. };
  37129. }
  37130. var inherits$2 = inherits$1;
  37131. var formatRegExp = /%[sdj%]/g;
  37132. function format(f) {
  37133. if (!isString$1(f)) {
  37134. var objects = [];
  37135. for (var i = 0; i < arguments.length; i++) {
  37136. objects.push(inspect(arguments[i]));
  37137. }
  37138. return objects.join(' ');
  37139. }
  37140. var i = 1;
  37141. var args = arguments;
  37142. var len = args.length;
  37143. var str = String(f).replace(formatRegExp, function(x) {
  37144. if (x === '%%') return '%';
  37145. if (i >= len) return x;
  37146. switch (x) {
  37147. case '%s': return String(args[i++]);
  37148. case '%d': return Number(args[i++]);
  37149. case '%j':
  37150. try {
  37151. return JSON.stringify(args[i++]);
  37152. } catch (_) {
  37153. return '[Circular]';
  37154. }
  37155. default:
  37156. return x;
  37157. }
  37158. });
  37159. for (var x = args[i]; i < len; x = args[++i]) {
  37160. if (isNull(x) || !isObject$1(x)) {
  37161. str += ' ' + x;
  37162. } else {
  37163. str += ' ' + inspect(x);
  37164. }
  37165. }
  37166. return str;
  37167. }
  37168. // Mark that a method should not be used.
  37169. // Returns a modified function which warns once by default.
  37170. // If --no-deprecation is set, then it is a no-op.
  37171. function deprecate(fn, msg) {
  37172. // Allow for deprecating things in the process of starting up.
  37173. if (isUndefined(global.process)) {
  37174. return function() {
  37175. return deprecate(fn, msg).apply(this, arguments);
  37176. };
  37177. }
  37178. var warned = false;
  37179. function deprecated() {
  37180. if (!warned) {
  37181. {
  37182. console.error(msg);
  37183. }
  37184. warned = true;
  37185. }
  37186. return fn.apply(this, arguments);
  37187. }
  37188. return deprecated;
  37189. }
  37190. var debugs = {};
  37191. var debugEnviron;
  37192. function debuglog(set) {
  37193. if (isUndefined(debugEnviron))
  37194. debugEnviron = '';
  37195. set = set.toUpperCase();
  37196. if (!debugs[set]) {
  37197. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  37198. var pid = 0;
  37199. debugs[set] = function() {
  37200. var msg = format.apply(null, arguments);
  37201. console.error('%s %d: %s', set, pid, msg);
  37202. };
  37203. } else {
  37204. debugs[set] = function() {};
  37205. }
  37206. }
  37207. return debugs[set];
  37208. }
  37209. /**
  37210. * Echos the value of a value. Trys to print the value out
  37211. * in the best way possible given the different types.
  37212. *
  37213. * @param {Object} obj The object to print out.
  37214. * @param {Object} opts Optional options object that alters the output.
  37215. */
  37216. /* legacy: obj, showHidden, depth, colors*/
  37217. function inspect(obj, opts) {
  37218. // default options
  37219. var ctx = {
  37220. seen: [],
  37221. stylize: stylizeNoColor
  37222. };
  37223. // legacy...
  37224. if (arguments.length >= 3) ctx.depth = arguments[2];
  37225. if (arguments.length >= 4) ctx.colors = arguments[3];
  37226. if (isBoolean(opts)) {
  37227. // legacy...
  37228. ctx.showHidden = opts;
  37229. } else if (opts) {
  37230. // got an "options" object
  37231. _extend(ctx, opts);
  37232. }
  37233. // set default options
  37234. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  37235. if (isUndefined(ctx.depth)) ctx.depth = 2;
  37236. if (isUndefined(ctx.colors)) ctx.colors = false;
  37237. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  37238. if (ctx.colors) ctx.stylize = stylizeWithColor;
  37239. return formatValue(ctx, obj, ctx.depth);
  37240. }
  37241. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  37242. inspect.colors = {
  37243. 'bold' : [1, 22],
  37244. 'italic' : [3, 23],
  37245. 'underline' : [4, 24],
  37246. 'inverse' : [7, 27],
  37247. 'white' : [37, 39],
  37248. 'grey' : [90, 39],
  37249. 'black' : [30, 39],
  37250. 'blue' : [34, 39],
  37251. 'cyan' : [36, 39],
  37252. 'green' : [32, 39],
  37253. 'magenta' : [35, 39],
  37254. 'red' : [31, 39],
  37255. 'yellow' : [33, 39]
  37256. };
  37257. // Don't use 'blue' not visible on cmd.exe
  37258. inspect.styles = {
  37259. 'special': 'cyan',
  37260. 'number': 'yellow',
  37261. 'boolean': 'yellow',
  37262. 'undefined': 'grey',
  37263. 'null': 'bold',
  37264. 'string': 'green',
  37265. 'date': 'magenta',
  37266. // "name": intentionally not styling
  37267. 'regexp': 'red'
  37268. };
  37269. function stylizeWithColor(str, styleType) {
  37270. var style = inspect.styles[styleType];
  37271. if (style) {
  37272. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  37273. '\u001b[' + inspect.colors[style][1] + 'm';
  37274. } else {
  37275. return str;
  37276. }
  37277. }
  37278. function stylizeNoColor(str, styleType) {
  37279. return str;
  37280. }
  37281. function arrayToHash(array) {
  37282. var hash = {};
  37283. array.forEach(function(val, idx) {
  37284. hash[val] = true;
  37285. });
  37286. return hash;
  37287. }
  37288. function formatValue(ctx, value, recurseTimes) {
  37289. // Provide a hook for user-specified inspect functions.
  37290. // Check that value is an object with an inspect function on it
  37291. if (ctx.customInspect &&
  37292. value &&
  37293. isFunction$2(value.inspect) &&
  37294. // Filter out the util module, it's inspect function is special
  37295. value.inspect !== inspect &&
  37296. // Also filter out any prototype objects using the circular check.
  37297. !(value.constructor && value.constructor.prototype === value)) {
  37298. var ret = value.inspect(recurseTimes, ctx);
  37299. if (!isString$1(ret)) {
  37300. ret = formatValue(ctx, ret, recurseTimes);
  37301. }
  37302. return ret;
  37303. }
  37304. // Primitive types cannot have properties
  37305. var primitive = formatPrimitive(ctx, value);
  37306. if (primitive) {
  37307. return primitive;
  37308. }
  37309. // Look up the keys of the object.
  37310. var keys = Object.keys(value);
  37311. var visibleKeys = arrayToHash(keys);
  37312. if (ctx.showHidden) {
  37313. keys = Object.getOwnPropertyNames(value);
  37314. }
  37315. // IE doesn't make error fields non-enumerable
  37316. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  37317. if (isError(value)
  37318. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  37319. return formatError(value);
  37320. }
  37321. // Some type of object without properties can be shortcutted.
  37322. if (keys.length === 0) {
  37323. if (isFunction$2(value)) {
  37324. var name = value.name ? ': ' + value.name : '';
  37325. return ctx.stylize('[Function' + name + ']', 'special');
  37326. }
  37327. if (isRegExp(value)) {
  37328. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  37329. }
  37330. if (isDate(value)) {
  37331. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  37332. }
  37333. if (isError(value)) {
  37334. return formatError(value);
  37335. }
  37336. }
  37337. var base = '', array = false, braces = ['{', '}'];
  37338. // Make Array say that they are Array
  37339. if (isArray$2(value)) {
  37340. array = true;
  37341. braces = ['[', ']'];
  37342. }
  37343. // Make functions say that they are functions
  37344. if (isFunction$2(value)) {
  37345. var n = value.name ? ': ' + value.name : '';
  37346. base = ' [Function' + n + ']';
  37347. }
  37348. // Make RegExps say that they are RegExps
  37349. if (isRegExp(value)) {
  37350. base = ' ' + RegExp.prototype.toString.call(value);
  37351. }
  37352. // Make dates with properties first say the date
  37353. if (isDate(value)) {
  37354. base = ' ' + Date.prototype.toUTCString.call(value);
  37355. }
  37356. // Make error with message first say the error
  37357. if (isError(value)) {
  37358. base = ' ' + formatError(value);
  37359. }
  37360. if (keys.length === 0 && (!array || value.length == 0)) {
  37361. return braces[0] + base + braces[1];
  37362. }
  37363. if (recurseTimes < 0) {
  37364. if (isRegExp(value)) {
  37365. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  37366. } else {
  37367. return ctx.stylize('[Object]', 'special');
  37368. }
  37369. }
  37370. ctx.seen.push(value);
  37371. var output;
  37372. if (array) {
  37373. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  37374. } else {
  37375. output = keys.map(function(key) {
  37376. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  37377. });
  37378. }
  37379. ctx.seen.pop();
  37380. return reduceToSingleString(output, base, braces);
  37381. }
  37382. function formatPrimitive(ctx, value) {
  37383. if (isUndefined(value))
  37384. return ctx.stylize('undefined', 'undefined');
  37385. if (isString$1(value)) {
  37386. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  37387. .replace(/'/g, "\\'")
  37388. .replace(/\\"/g, '"') + '\'';
  37389. return ctx.stylize(simple, 'string');
  37390. }
  37391. if (isNumber(value))
  37392. return ctx.stylize('' + value, 'number');
  37393. if (isBoolean(value))
  37394. return ctx.stylize('' + value, 'boolean');
  37395. // For some reason typeof null is "object", so special case here.
  37396. if (isNull(value))
  37397. return ctx.stylize('null', 'null');
  37398. }
  37399. function formatError(value) {
  37400. return '[' + Error.prototype.toString.call(value) + ']';
  37401. }
  37402. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  37403. var output = [];
  37404. for (var i = 0, l = value.length; i < l; ++i) {
  37405. if (hasOwnProperty$1(value, String(i))) {
  37406. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  37407. String(i), true));
  37408. } else {
  37409. output.push('');
  37410. }
  37411. }
  37412. keys.forEach(function(key) {
  37413. if (!key.match(/^\d+$/)) {
  37414. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  37415. key, true));
  37416. }
  37417. });
  37418. return output;
  37419. }
  37420. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  37421. var name, str, desc;
  37422. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  37423. if (desc.get) {
  37424. if (desc.set) {
  37425. str = ctx.stylize('[Getter/Setter]', 'special');
  37426. } else {
  37427. str = ctx.stylize('[Getter]', 'special');
  37428. }
  37429. } else {
  37430. if (desc.set) {
  37431. str = ctx.stylize('[Setter]', 'special');
  37432. }
  37433. }
  37434. if (!hasOwnProperty$1(visibleKeys, key)) {
  37435. name = '[' + key + ']';
  37436. }
  37437. if (!str) {
  37438. if (ctx.seen.indexOf(desc.value) < 0) {
  37439. if (isNull(recurseTimes)) {
  37440. str = formatValue(ctx, desc.value, null);
  37441. } else {
  37442. str = formatValue(ctx, desc.value, recurseTimes - 1);
  37443. }
  37444. if (str.indexOf('\n') > -1) {
  37445. if (array) {
  37446. str = str.split('\n').map(function(line) {
  37447. return ' ' + line;
  37448. }).join('\n').substr(2);
  37449. } else {
  37450. str = '\n' + str.split('\n').map(function(line) {
  37451. return ' ' + line;
  37452. }).join('\n');
  37453. }
  37454. }
  37455. } else {
  37456. str = ctx.stylize('[Circular]', 'special');
  37457. }
  37458. }
  37459. if (isUndefined(name)) {
  37460. if (array && key.match(/^\d+$/)) {
  37461. return str;
  37462. }
  37463. name = JSON.stringify('' + key);
  37464. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  37465. name = name.substr(1, name.length - 2);
  37466. name = ctx.stylize(name, 'name');
  37467. } else {
  37468. name = name.replace(/'/g, "\\'")
  37469. .replace(/\\"/g, '"')
  37470. .replace(/(^"|"$)/g, "'");
  37471. name = ctx.stylize(name, 'string');
  37472. }
  37473. }
  37474. return name + ': ' + str;
  37475. }
  37476. function reduceToSingleString(output, base, braces) {
  37477. var length = output.reduce(function(prev, cur) {
  37478. if (cur.indexOf('\n') >= 0) ;
  37479. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  37480. }, 0);
  37481. if (length > 60) {
  37482. return braces[0] +
  37483. (base === '' ? '' : base + '\n ') +
  37484. ' ' +
  37485. output.join(',\n ') +
  37486. ' ' +
  37487. braces[1];
  37488. }
  37489. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  37490. }
  37491. // NOTE: These type checking functions intentionally don't use `instanceof`
  37492. // because it is fragile and can be easily faked with `Object.create()`.
  37493. function isArray$2(ar) {
  37494. return Array.isArray(ar);
  37495. }
  37496. function isBoolean(arg) {
  37497. return typeof arg === 'boolean';
  37498. }
  37499. function isNull(arg) {
  37500. return arg === null;
  37501. }
  37502. function isNullOrUndefined(arg) {
  37503. return arg == null;
  37504. }
  37505. function isNumber(arg) {
  37506. return typeof arg === 'number';
  37507. }
  37508. function isString$1(arg) {
  37509. return typeof arg === 'string';
  37510. }
  37511. function isSymbol$1(arg) {
  37512. return typeof arg === 'symbol';
  37513. }
  37514. function isUndefined(arg) {
  37515. return arg === void 0;
  37516. }
  37517. function isRegExp(re) {
  37518. return isObject$1(re) && objectToString$1(re) === '[object RegExp]';
  37519. }
  37520. function isObject$1(arg) {
  37521. return typeof arg === 'object' && arg !== null;
  37522. }
  37523. function isDate(d) {
  37524. return isObject$1(d) && objectToString$1(d) === '[object Date]';
  37525. }
  37526. function isError(e) {
  37527. return isObject$1(e) &&
  37528. (objectToString$1(e) === '[object Error]' || e instanceof Error);
  37529. }
  37530. function isFunction$2(arg) {
  37531. return typeof arg === 'function';
  37532. }
  37533. function isPrimitive(arg) {
  37534. return arg === null ||
  37535. typeof arg === 'boolean' ||
  37536. typeof arg === 'number' ||
  37537. typeof arg === 'string' ||
  37538. typeof arg === 'symbol' || // ES6 symbol
  37539. typeof arg === 'undefined';
  37540. }
  37541. function isBuffer$1(maybeBuf) {
  37542. return Buffer.isBuffer(maybeBuf);
  37543. }
  37544. function objectToString$1(o) {
  37545. return Object.prototype.toString.call(o);
  37546. }
  37547. function pad$1(n) {
  37548. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  37549. }
  37550. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  37551. 'Oct', 'Nov', 'Dec'];
  37552. // 26 Feb 16:19:34
  37553. function timestamp() {
  37554. var d = new Date();
  37555. var time = [pad$1(d.getHours()),
  37556. pad$1(d.getMinutes()),
  37557. pad$1(d.getSeconds())].join(':');
  37558. return [d.getDate(), months[d.getMonth()], time].join(' ');
  37559. }
  37560. // log is just a thin wrapper to console.log that prepends a timestamp
  37561. function log() {
  37562. console.log('%s - %s', timestamp(), format.apply(null, arguments));
  37563. }
  37564. function _extend(origin, add) {
  37565. // Don't do anything if add isn't an object
  37566. if (!add || !isObject$1(add)) return origin;
  37567. var keys = Object.keys(add);
  37568. var i = keys.length;
  37569. while (i--) {
  37570. origin[keys[i]] = add[keys[i]];
  37571. }
  37572. return origin;
  37573. }
  37574. function hasOwnProperty$1(obj, prop) {
  37575. return Object.prototype.hasOwnProperty.call(obj, prop);
  37576. }
  37577. var _polyfillNode_util = {
  37578. inherits: inherits$2,
  37579. _extend: _extend,
  37580. log: log,
  37581. isBuffer: isBuffer$1,
  37582. isPrimitive: isPrimitive,
  37583. isFunction: isFunction$2,
  37584. isError: isError,
  37585. isDate: isDate,
  37586. isObject: isObject$1,
  37587. isRegExp: isRegExp,
  37588. isUndefined: isUndefined,
  37589. isSymbol: isSymbol$1,
  37590. isString: isString$1,
  37591. isNumber: isNumber,
  37592. isNullOrUndefined: isNullOrUndefined,
  37593. isNull: isNull,
  37594. isBoolean: isBoolean,
  37595. isArray: isArray$2,
  37596. inspect: inspect,
  37597. deprecate: deprecate,
  37598. format: format,
  37599. debuglog: debuglog
  37600. };
  37601. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  37602. __proto__: null,
  37603. format: format,
  37604. deprecate: deprecate,
  37605. debuglog: debuglog,
  37606. inspect: inspect,
  37607. isArray: isArray$2,
  37608. isBoolean: isBoolean,
  37609. isNull: isNull,
  37610. isNullOrUndefined: isNullOrUndefined,
  37611. isNumber: isNumber,
  37612. isString: isString$1,
  37613. isSymbol: isSymbol$1,
  37614. isUndefined: isUndefined,
  37615. isRegExp: isRegExp,
  37616. isObject: isObject$1,
  37617. isDate: isDate,
  37618. isError: isError,
  37619. isFunction: isFunction$2,
  37620. isPrimitive: isPrimitive,
  37621. isBuffer: isBuffer$1,
  37622. log: log,
  37623. inherits: inherits$2,
  37624. _extend: _extend,
  37625. 'default': _polyfillNode_util
  37626. });
  37627. // Copyright Joyent, Inc. and other Node contributors.
  37628. //
  37629. // Permission is hereby granted, free of charge, to any person obtaining a
  37630. // copy of this software and associated documentation files (the
  37631. // "Software"), to deal in the Software without restriction, including
  37632. // without limitation the rights to use, copy, modify, merge, publish,
  37633. // distribute, sublicense, and/or sell copies of the Software, and to permit
  37634. // persons to whom the Software is furnished to do so, subject to the
  37635. // following conditions:
  37636. //
  37637. // The above copyright notice and this permission notice shall be included
  37638. // in all copies or substantial portions of the Software.
  37639. //
  37640. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  37641. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  37642. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  37643. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  37644. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  37645. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  37646. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  37647. // If obj.hasOwnProperty has been overridden, then calling
  37648. // obj.hasOwnProperty(prop) will break.
  37649. // See: https://github.com/joyent/node/issues/1707
  37650. function hasOwnProperty$2(obj, prop) {
  37651. return Object.prototype.hasOwnProperty.call(obj, prop);
  37652. }
  37653. var isArray$3 = Array.isArray || function (xs) {
  37654. return Object.prototype.toString.call(xs) === '[object Array]';
  37655. };
  37656. function stringifyPrimitive(v) {
  37657. switch (typeof v) {
  37658. case 'string':
  37659. return v;
  37660. case 'boolean':
  37661. return v ? 'true' : 'false';
  37662. case 'number':
  37663. return isFinite(v) ? v : '';
  37664. default:
  37665. return '';
  37666. }
  37667. }
  37668. function stringify (obj, sep, eq, name) {
  37669. sep = sep || '&';
  37670. eq = eq || '=';
  37671. if (obj === null) {
  37672. obj = undefined;
  37673. }
  37674. if (typeof obj === 'object') {
  37675. return map$1(objectKeys(obj), function(k) {
  37676. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  37677. if (isArray$3(obj[k])) {
  37678. return map$1(obj[k], function(v) {
  37679. return ks + encodeURIComponent(stringifyPrimitive(v));
  37680. }).join(sep);
  37681. } else {
  37682. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  37683. }
  37684. }).join(sep);
  37685. }
  37686. if (!name) return '';
  37687. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  37688. encodeURIComponent(stringifyPrimitive(obj));
  37689. }
  37690. function map$1 (xs, f) {
  37691. if (xs.map) return xs.map(f);
  37692. var res = [];
  37693. for (var i = 0; i < xs.length; i++) {
  37694. res.push(f(xs[i], i));
  37695. }
  37696. return res;
  37697. }
  37698. var objectKeys = Object.keys || function (obj) {
  37699. var res = [];
  37700. for (var key in obj) {
  37701. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  37702. }
  37703. return res;
  37704. };
  37705. function parse$3(qs, sep, eq, options) {
  37706. sep = sep || '&';
  37707. eq = eq || '=';
  37708. var obj = {};
  37709. if (typeof qs !== 'string' || qs.length === 0) {
  37710. return obj;
  37711. }
  37712. var regexp = /\+/g;
  37713. qs = qs.split(sep);
  37714. var maxKeys = 1000;
  37715. if (options && typeof options.maxKeys === 'number') {
  37716. maxKeys = options.maxKeys;
  37717. }
  37718. var len = qs.length;
  37719. // maxKeys <= 0 means that we should not limit keys count
  37720. if (maxKeys > 0 && len > maxKeys) {
  37721. len = maxKeys;
  37722. }
  37723. for (var i = 0; i < len; ++i) {
  37724. var x = qs[i].replace(regexp, '%20'),
  37725. idx = x.indexOf(eq),
  37726. kstr, vstr, k, v;
  37727. if (idx >= 0) {
  37728. kstr = x.substr(0, idx);
  37729. vstr = x.substr(idx + 1);
  37730. } else {
  37731. kstr = x;
  37732. vstr = '';
  37733. }
  37734. k = decodeURIComponent(kstr);
  37735. v = decodeURIComponent(vstr);
  37736. if (!hasOwnProperty$2(obj, k)) {
  37737. obj[k] = v;
  37738. } else if (isArray$3(obj[k])) {
  37739. obj[k].push(v);
  37740. } else {
  37741. obj[k] = [obj[k], v];
  37742. }
  37743. }
  37744. return obj;
  37745. }
  37746. // Copyright Joyent, Inc. and other Node contributors.
  37747. var _polyfillNode_url = {
  37748. parse: urlParse,
  37749. resolve: urlResolve,
  37750. resolveObject: urlResolveObject,
  37751. format: urlFormat,
  37752. Url: Url
  37753. };
  37754. function Url() {
  37755. this.protocol = null;
  37756. this.slashes = null;
  37757. this.auth = null;
  37758. this.host = null;
  37759. this.port = null;
  37760. this.hostname = null;
  37761. this.hash = null;
  37762. this.search = null;
  37763. this.query = null;
  37764. this.pathname = null;
  37765. this.path = null;
  37766. this.href = null;
  37767. }
  37768. // Reference: RFC 3986, RFC 1808, RFC 2396
  37769. // define these here so at least they only have to be
  37770. // compiled once on the first module load.
  37771. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  37772. portPattern = /:[0-9]*$/,
  37773. // Special case for a simple path URL
  37774. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  37775. // RFC 2396: characters reserved for delimiting URLs.
  37776. // We actually just auto-escape these.
  37777. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  37778. // RFC 2396: characters not allowed for various reasons.
  37779. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  37780. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  37781. autoEscape = ['\''].concat(unwise),
  37782. // Characters that are never ever allowed in a hostname.
  37783. // Note that any invalid chars are also handled, but these
  37784. // are the ones that are *expected* to be seen, so we fast-path
  37785. // them.
  37786. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  37787. hostEndingChars = ['/', '?', '#'],
  37788. hostnameMaxLen = 255,
  37789. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  37790. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  37791. // protocols that can allow "unsafe" and "unwise" chars.
  37792. unsafeProtocol = {
  37793. 'javascript': true,
  37794. 'javascript:': true
  37795. },
  37796. // protocols that never have a hostname.
  37797. hostlessProtocol = {
  37798. 'javascript': true,
  37799. 'javascript:': true
  37800. },
  37801. // protocols that always contain a // bit.
  37802. slashedProtocol = {
  37803. 'http': true,
  37804. 'https': true,
  37805. 'ftp': true,
  37806. 'gopher': true,
  37807. 'file': true,
  37808. 'http:': true,
  37809. 'https:': true,
  37810. 'ftp:': true,
  37811. 'gopher:': true,
  37812. 'file:': true
  37813. };
  37814. function urlParse(url, parseQueryString, slashesDenoteHost) {
  37815. if (url && isObject$1(url) && url instanceof Url) return url;
  37816. var u = new Url;
  37817. u.parse(url, parseQueryString, slashesDenoteHost);
  37818. return u;
  37819. }
  37820. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  37821. return parse$4(this, url, parseQueryString, slashesDenoteHost);
  37822. };
  37823. function parse$4(self, url, parseQueryString, slashesDenoteHost) {
  37824. if (!isString$1(url)) {
  37825. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  37826. }
  37827. // Copy chrome, IE, opera backslash-handling behavior.
  37828. // Back slashes before the query string get converted to forward slashes
  37829. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  37830. var queryIndex = url.indexOf('?'),
  37831. splitter =
  37832. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  37833. uSplit = url.split(splitter),
  37834. slashRegex = /\\/g;
  37835. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  37836. url = uSplit.join(splitter);
  37837. var rest = url;
  37838. // trim before proceeding.
  37839. // This is to support parse stuff like " http://foo.com \n"
  37840. rest = rest.trim();
  37841. if (!slashesDenoteHost && url.split('#').length === 1) {
  37842. // Try fast path regexp
  37843. var simplePath = simplePathPattern.exec(rest);
  37844. if (simplePath) {
  37845. self.path = rest;
  37846. self.href = rest;
  37847. self.pathname = simplePath[1];
  37848. if (simplePath[2]) {
  37849. self.search = simplePath[2];
  37850. if (parseQueryString) {
  37851. self.query = parse$3(self.search.substr(1));
  37852. } else {
  37853. self.query = self.search.substr(1);
  37854. }
  37855. } else if (parseQueryString) {
  37856. self.search = '';
  37857. self.query = {};
  37858. }
  37859. return self;
  37860. }
  37861. }
  37862. var proto = protocolPattern.exec(rest);
  37863. if (proto) {
  37864. proto = proto[0];
  37865. var lowerProto = proto.toLowerCase();
  37866. self.protocol = lowerProto;
  37867. rest = rest.substr(proto.length);
  37868. }
  37869. // figure out if it's got a host
  37870. // user@server is *always* interpreted as a hostname, and url
  37871. // resolution will treat //foo/bar as host=foo,path=bar because that's
  37872. // how the browser resolves relative URLs.
  37873. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  37874. var slashes = rest.substr(0, 2) === '//';
  37875. if (slashes && !(proto && hostlessProtocol[proto])) {
  37876. rest = rest.substr(2);
  37877. self.slashes = true;
  37878. }
  37879. }
  37880. var i, hec, l, p;
  37881. if (!hostlessProtocol[proto] &&
  37882. (slashes || (proto && !slashedProtocol[proto]))) {
  37883. // there's a hostname.
  37884. // the first instance of /, ?, ;, or # ends the host.
  37885. //
  37886. // If there is an @ in the hostname, then non-host chars *are* allowed
  37887. // to the left of the last @ sign, unless some host-ending character
  37888. // comes *before* the @-sign.
  37889. // URLs are obnoxious.
  37890. //
  37891. // ex:
  37892. // http://a@b@c/ => user:a@b host:c
  37893. // http://a@b?@c => user:a host:c path:/?@c
  37894. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  37895. // Review our test case against browsers more comprehensively.
  37896. // find the first instance of any hostEndingChars
  37897. var hostEnd = -1;
  37898. for (i = 0; i < hostEndingChars.length; i++) {
  37899. hec = rest.indexOf(hostEndingChars[i]);
  37900. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  37901. hostEnd = hec;
  37902. }
  37903. // at this point, either we have an explicit point where the
  37904. // auth portion cannot go past, or the last @ char is the decider.
  37905. var auth, atSign;
  37906. if (hostEnd === -1) {
  37907. // atSign can be anywhere.
  37908. atSign = rest.lastIndexOf('@');
  37909. } else {
  37910. // atSign must be in auth portion.
  37911. // http://a@b/c@d => host:b auth:a path:/c@d
  37912. atSign = rest.lastIndexOf('@', hostEnd);
  37913. }
  37914. // Now we have a portion which is definitely the auth.
  37915. // Pull that off.
  37916. if (atSign !== -1) {
  37917. auth = rest.slice(0, atSign);
  37918. rest = rest.slice(atSign + 1);
  37919. self.auth = decodeURIComponent(auth);
  37920. }
  37921. // the host is the remaining to the left of the first non-host char
  37922. hostEnd = -1;
  37923. for (i = 0; i < nonHostChars.length; i++) {
  37924. hec = rest.indexOf(nonHostChars[i]);
  37925. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  37926. hostEnd = hec;
  37927. }
  37928. // if we still have not hit it, then the entire thing is a host.
  37929. if (hostEnd === -1)
  37930. hostEnd = rest.length;
  37931. self.host = rest.slice(0, hostEnd);
  37932. rest = rest.slice(hostEnd);
  37933. // pull out port.
  37934. parseHost(self);
  37935. // we've indicated that there is a hostname,
  37936. // so even if it's empty, it has to be present.
  37937. self.hostname = self.hostname || '';
  37938. // if hostname begins with [ and ends with ]
  37939. // assume that it's an IPv6 address.
  37940. var ipv6Hostname = self.hostname[0] === '[' &&
  37941. self.hostname[self.hostname.length - 1] === ']';
  37942. // validate a little.
  37943. if (!ipv6Hostname) {
  37944. var hostparts = self.hostname.split(/\./);
  37945. for (i = 0, l = hostparts.length; i < l; i++) {
  37946. var part = hostparts[i];
  37947. if (!part) continue;
  37948. if (!part.match(hostnamePartPattern)) {
  37949. var newpart = '';
  37950. for (var j = 0, k = part.length; j < k; j++) {
  37951. if (part.charCodeAt(j) > 127) {
  37952. // we replace non-ASCII char with a temporary placeholder
  37953. // we need this to make sure size of hostname is not
  37954. // broken by replacing non-ASCII by nothing
  37955. newpart += 'x';
  37956. } else {
  37957. newpart += part[j];
  37958. }
  37959. }
  37960. // we test again with ASCII char only
  37961. if (!newpart.match(hostnamePartPattern)) {
  37962. var validParts = hostparts.slice(0, i);
  37963. var notHost = hostparts.slice(i + 1);
  37964. var bit = part.match(hostnamePartStart);
  37965. if (bit) {
  37966. validParts.push(bit[1]);
  37967. notHost.unshift(bit[2]);
  37968. }
  37969. if (notHost.length) {
  37970. rest = '/' + notHost.join('.') + rest;
  37971. }
  37972. self.hostname = validParts.join('.');
  37973. break;
  37974. }
  37975. }
  37976. }
  37977. }
  37978. if (self.hostname.length > hostnameMaxLen) {
  37979. self.hostname = '';
  37980. } else {
  37981. // hostnames are always lower case.
  37982. self.hostname = self.hostname.toLowerCase();
  37983. }
  37984. if (!ipv6Hostname) {
  37985. // IDNA Support: Returns a punycoded representation of "domain".
  37986. // It only converts parts of the domain name that
  37987. // have non-ASCII characters, i.e. it doesn't matter if
  37988. // you call it with a domain that already is ASCII-only.
  37989. self.hostname = toASCII(self.hostname);
  37990. }
  37991. p = self.port ? ':' + self.port : '';
  37992. var h = self.hostname || '';
  37993. self.host = h + p;
  37994. self.href += self.host;
  37995. // strip [ and ] from the hostname
  37996. // the host field still retains them, though
  37997. if (ipv6Hostname) {
  37998. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  37999. if (rest[0] !== '/') {
  38000. rest = '/' + rest;
  38001. }
  38002. }
  38003. }
  38004. // now rest is set to the post-host stuff.
  38005. // chop off any delim chars.
  38006. if (!unsafeProtocol[lowerProto]) {
  38007. // First, make 100% sure that any "autoEscape" chars get
  38008. // escaped, even if encodeURIComponent doesn't think they
  38009. // need to be.
  38010. for (i = 0, l = autoEscape.length; i < l; i++) {
  38011. var ae = autoEscape[i];
  38012. if (rest.indexOf(ae) === -1)
  38013. continue;
  38014. var esc = encodeURIComponent(ae);
  38015. if (esc === ae) {
  38016. esc = escape(ae);
  38017. }
  38018. rest = rest.split(ae).join(esc);
  38019. }
  38020. }
  38021. // chop off from the tail first.
  38022. var hash = rest.indexOf('#');
  38023. if (hash !== -1) {
  38024. // got a fragment string.
  38025. self.hash = rest.substr(hash);
  38026. rest = rest.slice(0, hash);
  38027. }
  38028. var qm = rest.indexOf('?');
  38029. if (qm !== -1) {
  38030. self.search = rest.substr(qm);
  38031. self.query = rest.substr(qm + 1);
  38032. if (parseQueryString) {
  38033. self.query = parse$3(self.query);
  38034. }
  38035. rest = rest.slice(0, qm);
  38036. } else if (parseQueryString) {
  38037. // no query string, but parseQueryString still requested
  38038. self.search = '';
  38039. self.query = {};
  38040. }
  38041. if (rest) self.pathname = rest;
  38042. if (slashedProtocol[lowerProto] &&
  38043. self.hostname && !self.pathname) {
  38044. self.pathname = '/';
  38045. }
  38046. //to support http.request
  38047. if (self.pathname || self.search) {
  38048. p = self.pathname || '';
  38049. var s = self.search || '';
  38050. self.path = p + s;
  38051. }
  38052. // finally, reconstruct the href based on what has been validated.
  38053. self.href = format$1(self);
  38054. return self;
  38055. }
  38056. // format a parsed object into a url string
  38057. function urlFormat(obj) {
  38058. // ensure it's an object, and not a string url.
  38059. // If it's an obj, this is a no-op.
  38060. // this way, you can call url_format() on strings
  38061. // to clean up potentially wonky urls.
  38062. if (isString$1(obj)) obj = parse$4({}, obj);
  38063. return format$1(obj);
  38064. }
  38065. function format$1(self) {
  38066. var auth = self.auth || '';
  38067. if (auth) {
  38068. auth = encodeURIComponent(auth);
  38069. auth = auth.replace(/%3A/i, ':');
  38070. auth += '@';
  38071. }
  38072. var protocol = self.protocol || '',
  38073. pathname = self.pathname || '',
  38074. hash = self.hash || '',
  38075. host = false,
  38076. query = '';
  38077. if (self.host) {
  38078. host = auth + self.host;
  38079. } else if (self.hostname) {
  38080. host = auth + (self.hostname.indexOf(':') === -1 ?
  38081. self.hostname :
  38082. '[' + this.hostname + ']');
  38083. if (self.port) {
  38084. host += ':' + self.port;
  38085. }
  38086. }
  38087. if (self.query &&
  38088. isObject$1(self.query) &&
  38089. Object.keys(self.query).length) {
  38090. query = stringify(self.query);
  38091. }
  38092. var search = self.search || (query && ('?' + query)) || '';
  38093. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  38094. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  38095. // unless they had them to begin with.
  38096. if (self.slashes ||
  38097. (!protocol || slashedProtocol[protocol]) && host !== false) {
  38098. host = '//' + (host || '');
  38099. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  38100. } else if (!host) {
  38101. host = '';
  38102. }
  38103. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  38104. if (search && search.charAt(0) !== '?') search = '?' + search;
  38105. pathname = pathname.replace(/[?#]/g, function(match) {
  38106. return encodeURIComponent(match);
  38107. });
  38108. search = search.replace('#', '%23');
  38109. return protocol + host + pathname + search + hash;
  38110. }
  38111. Url.prototype.format = function() {
  38112. return format$1(this);
  38113. };
  38114. function urlResolve(source, relative) {
  38115. return urlParse(source, false, true).resolve(relative);
  38116. }
  38117. Url.prototype.resolve = function(relative) {
  38118. return this.resolveObject(urlParse(relative, false, true)).format();
  38119. };
  38120. function urlResolveObject(source, relative) {
  38121. if (!source) return relative;
  38122. return urlParse(source, false, true).resolveObject(relative);
  38123. }
  38124. Url.prototype.resolveObject = function(relative) {
  38125. if (isString$1(relative)) {
  38126. var rel = new Url();
  38127. rel.parse(relative, false, true);
  38128. relative = rel;
  38129. }
  38130. var result = new Url();
  38131. var tkeys = Object.keys(this);
  38132. for (var tk = 0; tk < tkeys.length; tk++) {
  38133. var tkey = tkeys[tk];
  38134. result[tkey] = this[tkey];
  38135. }
  38136. // hash is always overridden, no matter what.
  38137. // even href="" will remove it.
  38138. result.hash = relative.hash;
  38139. // if the relative url is empty, then there's nothing left to do here.
  38140. if (relative.href === '') {
  38141. result.href = result.format();
  38142. return result;
  38143. }
  38144. // hrefs like //foo/bar always cut to the protocol.
  38145. if (relative.slashes && !relative.protocol) {
  38146. // take everything except the protocol from relative
  38147. var rkeys = Object.keys(relative);
  38148. for (var rk = 0; rk < rkeys.length; rk++) {
  38149. var rkey = rkeys[rk];
  38150. if (rkey !== 'protocol')
  38151. result[rkey] = relative[rkey];
  38152. }
  38153. //urlParse appends trailing / to urls like http://www.example.com
  38154. if (slashedProtocol[result.protocol] &&
  38155. result.hostname && !result.pathname) {
  38156. result.path = result.pathname = '/';
  38157. }
  38158. result.href = result.format();
  38159. return result;
  38160. }
  38161. var relPath;
  38162. if (relative.protocol && relative.protocol !== result.protocol) {
  38163. // if it's a known url protocol, then changing
  38164. // the protocol does weird things
  38165. // first, if it's not file:, then we MUST have a host,
  38166. // and if there was a path
  38167. // to begin with, then we MUST have a path.
  38168. // if it is file:, then the host is dropped,
  38169. // because that's known to be hostless.
  38170. // anything else is assumed to be absolute.
  38171. if (!slashedProtocol[relative.protocol]) {
  38172. var keys = Object.keys(relative);
  38173. for (var v = 0; v < keys.length; v++) {
  38174. var k = keys[v];
  38175. result[k] = relative[k];
  38176. }
  38177. result.href = result.format();
  38178. return result;
  38179. }
  38180. result.protocol = relative.protocol;
  38181. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  38182. relPath = (relative.pathname || '').split('/');
  38183. while (relPath.length && !(relative.host = relPath.shift()));
  38184. if (!relative.host) relative.host = '';
  38185. if (!relative.hostname) relative.hostname = '';
  38186. if (relPath[0] !== '') relPath.unshift('');
  38187. if (relPath.length < 2) relPath.unshift('');
  38188. result.pathname = relPath.join('/');
  38189. } else {
  38190. result.pathname = relative.pathname;
  38191. }
  38192. result.search = relative.search;
  38193. result.query = relative.query;
  38194. result.host = relative.host || '';
  38195. result.auth = relative.auth;
  38196. result.hostname = relative.hostname || relative.host;
  38197. result.port = relative.port;
  38198. // to support http.request
  38199. if (result.pathname || result.search) {
  38200. var p = result.pathname || '';
  38201. var s = result.search || '';
  38202. result.path = p + s;
  38203. }
  38204. result.slashes = result.slashes || relative.slashes;
  38205. result.href = result.format();
  38206. return result;
  38207. }
  38208. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  38209. isRelAbs = (
  38210. relative.host ||
  38211. relative.pathname && relative.pathname.charAt(0) === '/'
  38212. ),
  38213. mustEndAbs = (isRelAbs || isSourceAbs ||
  38214. (result.host && relative.pathname)),
  38215. removeAllDots = mustEndAbs,
  38216. srcPath = result.pathname && result.pathname.split('/') || [],
  38217. psychotic = result.protocol && !slashedProtocol[result.protocol];
  38218. relPath = relative.pathname && relative.pathname.split('/') || [];
  38219. // if the url is a non-slashed url, then relative
  38220. // links like ../.. should be able
  38221. // to crawl up to the hostname, as well. This is strange.
  38222. // result.protocol has already been set by now.
  38223. // Later on, put the first path part into the host field.
  38224. if (psychotic) {
  38225. result.hostname = '';
  38226. result.port = null;
  38227. if (result.host) {
  38228. if (srcPath[0] === '') srcPath[0] = result.host;
  38229. else srcPath.unshift(result.host);
  38230. }
  38231. result.host = '';
  38232. if (relative.protocol) {
  38233. relative.hostname = null;
  38234. relative.port = null;
  38235. if (relative.host) {
  38236. if (relPath[0] === '') relPath[0] = relative.host;
  38237. else relPath.unshift(relative.host);
  38238. }
  38239. relative.host = null;
  38240. }
  38241. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  38242. }
  38243. var authInHost;
  38244. if (isRelAbs) {
  38245. // it's absolute.
  38246. result.host = (relative.host || relative.host === '') ?
  38247. relative.host : result.host;
  38248. result.hostname = (relative.hostname || relative.hostname === '') ?
  38249. relative.hostname : result.hostname;
  38250. result.search = relative.search;
  38251. result.query = relative.query;
  38252. srcPath = relPath;
  38253. // fall through to the dot-handling below.
  38254. } else if (relPath.length) {
  38255. // it's relative
  38256. // throw away the existing file, and take the new path instead.
  38257. if (!srcPath) srcPath = [];
  38258. srcPath.pop();
  38259. srcPath = srcPath.concat(relPath);
  38260. result.search = relative.search;
  38261. result.query = relative.query;
  38262. } else if (!isNullOrUndefined(relative.search)) {
  38263. // just pull out the search.
  38264. // like href='?foo'.
  38265. // Put this after the other two cases because it simplifies the booleans
  38266. if (psychotic) {
  38267. result.hostname = result.host = srcPath.shift();
  38268. //occationaly the auth can get stuck only in host
  38269. //this especially happens in cases like
  38270. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  38271. authInHost = result.host && result.host.indexOf('@') > 0 ?
  38272. result.host.split('@') : false;
  38273. if (authInHost) {
  38274. result.auth = authInHost.shift();
  38275. result.host = result.hostname = authInHost.shift();
  38276. }
  38277. }
  38278. result.search = relative.search;
  38279. result.query = relative.query;
  38280. //to support http.request
  38281. if (!isNull(result.pathname) || !isNull(result.search)) {
  38282. result.path = (result.pathname ? result.pathname : '') +
  38283. (result.search ? result.search : '');
  38284. }
  38285. result.href = result.format();
  38286. return result;
  38287. }
  38288. if (!srcPath.length) {
  38289. // no path at all. easy.
  38290. // we've already handled the other stuff above.
  38291. result.pathname = null;
  38292. //to support http.request
  38293. if (result.search) {
  38294. result.path = '/' + result.search;
  38295. } else {
  38296. result.path = null;
  38297. }
  38298. result.href = result.format();
  38299. return result;
  38300. }
  38301. // if a url ENDs in . or .., then it must get a trailing slash.
  38302. // however, if it ends in anything else non-slashy,
  38303. // then it must NOT get a trailing slash.
  38304. var last = srcPath.slice(-1)[0];
  38305. var hasTrailingSlash = (
  38306. (result.host || relative.host || srcPath.length > 1) &&
  38307. (last === '.' || last === '..') || last === '');
  38308. // strip single dots, resolve double dots to parent dir
  38309. // if the path tries to go above the root, `up` ends up > 0
  38310. var up = 0;
  38311. for (var i = srcPath.length; i >= 0; i--) {
  38312. last = srcPath[i];
  38313. if (last === '.') {
  38314. srcPath.splice(i, 1);
  38315. } else if (last === '..') {
  38316. srcPath.splice(i, 1);
  38317. up++;
  38318. } else if (up) {
  38319. srcPath.splice(i, 1);
  38320. up--;
  38321. }
  38322. }
  38323. // if the path is allowed to go above the root, restore leading ..s
  38324. if (!mustEndAbs && !removeAllDots) {
  38325. for (; up--; up) {
  38326. srcPath.unshift('..');
  38327. }
  38328. }
  38329. if (mustEndAbs && srcPath[0] !== '' &&
  38330. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  38331. srcPath.unshift('');
  38332. }
  38333. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  38334. srcPath.push('');
  38335. }
  38336. var isAbsolute = srcPath[0] === '' ||
  38337. (srcPath[0] && srcPath[0].charAt(0) === '/');
  38338. // put the host back
  38339. if (psychotic) {
  38340. result.hostname = result.host = isAbsolute ? '' :
  38341. srcPath.length ? srcPath.shift() : '';
  38342. //occationaly the auth can get stuck only in host
  38343. //this especially happens in cases like
  38344. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  38345. authInHost = result.host && result.host.indexOf('@') > 0 ?
  38346. result.host.split('@') : false;
  38347. if (authInHost) {
  38348. result.auth = authInHost.shift();
  38349. result.host = result.hostname = authInHost.shift();
  38350. }
  38351. }
  38352. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  38353. if (mustEndAbs && !isAbsolute) {
  38354. srcPath.unshift('');
  38355. }
  38356. if (!srcPath.length) {
  38357. result.pathname = null;
  38358. result.path = null;
  38359. } else {
  38360. result.pathname = srcPath.join('/');
  38361. }
  38362. //to support request.http
  38363. if (!isNull(result.pathname) || !isNull(result.search)) {
  38364. result.path = (result.pathname ? result.pathname : '') +
  38365. (result.search ? result.search : '');
  38366. }
  38367. result.auth = relative.auth || result.auth;
  38368. result.slashes = result.slashes || relative.slashes;
  38369. result.href = result.format();
  38370. return result;
  38371. };
  38372. Url.prototype.parseHost = function() {
  38373. return parseHost(this);
  38374. };
  38375. function parseHost(self) {
  38376. var host = self.host;
  38377. var port = portPattern.exec(host);
  38378. if (port) {
  38379. port = port[0];
  38380. if (port !== ':') {
  38381. self.port = port.substr(1);
  38382. }
  38383. host = host.substr(0, host.length - port.length);
  38384. }
  38385. if (host) self.hostname = host;
  38386. }
  38387. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  38388. __proto__: null,
  38389. parse: urlParse,
  38390. resolve: urlResolve,
  38391. resolveObject: urlResolveObject,
  38392. format: urlFormat,
  38393. 'default': _polyfillNode_url,
  38394. Url: Url
  38395. });
  38396. function isRelativeUrl(url) {
  38397. const firstChar = url.charAt(0);
  38398. return firstChar === '.' || firstChar === '~' || firstChar === '@';
  38399. }
  38400. const externalRE = /^https?:\/\//;
  38401. function isExternalUrl(url) {
  38402. return externalRE.test(url);
  38403. }
  38404. const dataUrlRE = /^\s*data:/i;
  38405. function isDataUrl(url) {
  38406. return dataUrlRE.test(url);
  38407. }
  38408. /**
  38409. * Parses string url into URL object.
  38410. */
  38411. function parseUrl(url) {
  38412. const firstChar = url.charAt(0);
  38413. if (firstChar === '~') {
  38414. const secondChar = url.charAt(1);
  38415. url = url.slice(secondChar === '/' ? 2 : 1);
  38416. }
  38417. return parseUriParts(url);
  38418. }
  38419. /**
  38420. * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
  38421. * @param urlString an url as a string
  38422. */
  38423. function parseUriParts(urlString) {
  38424. // A TypeError is thrown if urlString is not a string
  38425. // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
  38426. return urlParse(isString(urlString) ? urlString : '', false, true);
  38427. }
  38428. const defaultAssetUrlOptions = {
  38429. base: null,
  38430. includeAbsolute: false,
  38431. tags: {
  38432. video: ['src', 'poster'],
  38433. source: ['src'],
  38434. img: ['src'],
  38435. image: ['xlink:href', 'href'],
  38436. use: ['xlink:href', 'href']
  38437. }
  38438. };
  38439. const normalizeOptions = (options) => {
  38440. if (Object.keys(options).some(key => isArray(options[key]))) {
  38441. // legacy option format which directly passes in tags config
  38442. return Object.assign(Object.assign({}, defaultAssetUrlOptions), { tags: options });
  38443. }
  38444. return Object.assign(Object.assign({}, defaultAssetUrlOptions), options);
  38445. };
  38446. const createAssetUrlTransformWithOptions = (options) => {
  38447. return (node, context) => transformAssetUrl(node, context, options);
  38448. };
  38449. /**
  38450. * A `@vue/compiler-core` plugin that transforms relative asset urls into
  38451. * either imports or absolute urls.
  38452. *
  38453. * ``` js
  38454. * // Before
  38455. * createVNode('img', { src: './logo.png' })
  38456. *
  38457. * // After
  38458. * import _imports_0 from './logo.png'
  38459. * createVNode('img', { src: _imports_0 })
  38460. * ```
  38461. */
  38462. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  38463. if (node.type === 1 /* ELEMENT */) {
  38464. if (!node.props.length) {
  38465. return;
  38466. }
  38467. const tags = options.tags || defaultAssetUrlOptions.tags;
  38468. const attrs = tags[node.tag];
  38469. const wildCardAttrs = tags['*'];
  38470. if (!attrs && !wildCardAttrs) {
  38471. return;
  38472. }
  38473. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  38474. node.props.forEach((attr, index) => {
  38475. if (attr.type !== 6 /* ATTRIBUTE */ ||
  38476. !assetAttrs.includes(attr.name) ||
  38477. !attr.value ||
  38478. isExternalUrl(attr.value.content) ||
  38479. isDataUrl(attr.value.content) ||
  38480. attr.value.content[0] === '#' ||
  38481. (!options.includeAbsolute && !isRelativeUrl(attr.value.content))) {
  38482. return;
  38483. }
  38484. const url = parseUrl(attr.value.content);
  38485. if (options.base && attr.value.content[0] === '.') {
  38486. // explicit base - directly rewrite relative urls into absolute url
  38487. // to avoid generating extra imports
  38488. // Allow for full hostnames provided in options.base
  38489. const base = parseUrl(options.base);
  38490. const protocol = base.protocol || '';
  38491. const host = base.host ? protocol + '//' + base.host : '';
  38492. const basePath = base.path || '/';
  38493. // when packaged in the browser, path will be using the posix-
  38494. // only version provided by rollup-plugin-node-builtins.
  38495. attr.value.content =
  38496. host +
  38497. (path.posix || path).join(basePath, url.path + (url.hash || ''));
  38498. return;
  38499. }
  38500. // otherwise, transform the url into an import.
  38501. // this assumes a bundler will resolve the import into the correct
  38502. // absolute url (e.g. webpack file-loader)
  38503. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  38504. node.props[index] = {
  38505. type: 7 /* DIRECTIVE */,
  38506. name: 'bind',
  38507. arg: createSimpleExpression(attr.name, true, attr.loc),
  38508. exp,
  38509. modifiers: [],
  38510. loc: attr.loc
  38511. };
  38512. });
  38513. }
  38514. };
  38515. function getImportsExpressionExp(path, hash, loc, context) {
  38516. if (path) {
  38517. const existing = context.imports.find(i => i.path === path);
  38518. if (existing) {
  38519. return existing.exp;
  38520. }
  38521. const name = `_imports_${context.imports.length}`;
  38522. const exp = createSimpleExpression(name, false, loc, 2 /* CAN_HOIST */);
  38523. context.imports.push({ exp, path });
  38524. if (hash && path) {
  38525. return context.hoist(createSimpleExpression(`${name} + '${hash}'`, false, loc, 2 /* CAN_HOIST */));
  38526. }
  38527. else {
  38528. return exp;
  38529. }
  38530. }
  38531. else {
  38532. return createSimpleExpression(`''`, false, loc, 2 /* CAN_HOIST */);
  38533. }
  38534. }
  38535. const srcsetTags = ['img', 'source'];
  38536. // http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
  38537. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  38538. const createSrcsetTransformWithOptions = (options) => {
  38539. return (node, context) => transformSrcset(node, context, options);
  38540. };
  38541. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  38542. if (node.type === 1 /* ELEMENT */) {
  38543. if (srcsetTags.includes(node.tag) && node.props.length) {
  38544. node.props.forEach((attr, index) => {
  38545. if (attr.name === 'srcset' && attr.type === 6 /* ATTRIBUTE */) {
  38546. if (!attr.value)
  38547. return;
  38548. const value = attr.value.content;
  38549. if (!value)
  38550. return;
  38551. const imageCandidates = value.split(',').map(s => {
  38552. // The attribute value arrives here with all whitespace, except
  38553. // normal spaces, represented by escape sequences
  38554. const [url, descriptor] = s
  38555. .replace(escapedSpaceCharacters, ' ')
  38556. .trim()
  38557. .split(' ', 2);
  38558. return { url, descriptor };
  38559. });
  38560. // data urls contains comma after the ecoding so we need to re-merge
  38561. // them
  38562. for (let i = 0; i < imageCandidates.length; i++) {
  38563. const { url } = imageCandidates[i];
  38564. if (isDataUrl(url)) {
  38565. imageCandidates[i + 1].url =
  38566. url + ',' + imageCandidates[i + 1].url;
  38567. imageCandidates.splice(i, 1);
  38568. }
  38569. }
  38570. const hasQualifiedUrl = imageCandidates.some(({ url }) => {
  38571. return (!isExternalUrl(url) &&
  38572. !isDataUrl(url) &&
  38573. (options.includeAbsolute || isRelativeUrl(url)));
  38574. });
  38575. // When srcset does not contain any qualified URLs, skip transforming
  38576. if (!hasQualifiedUrl) {
  38577. return;
  38578. }
  38579. if (options.base) {
  38580. const base = options.base;
  38581. const set = [];
  38582. imageCandidates.forEach(({ url, descriptor }) => {
  38583. descriptor = descriptor ? ` ${descriptor}` : ``;
  38584. if (isRelativeUrl(url)) {
  38585. set.push((path.posix || path).join(base, url) + descriptor);
  38586. }
  38587. else {
  38588. set.push(url + descriptor);
  38589. }
  38590. });
  38591. attr.value.content = set.join(', ');
  38592. return;
  38593. }
  38594. const compoundExpression = createCompoundExpression([], attr.loc);
  38595. imageCandidates.forEach(({ url, descriptor }, index) => {
  38596. if (!isExternalUrl(url) &&
  38597. !isDataUrl(url) &&
  38598. (options.includeAbsolute || isRelativeUrl(url))) {
  38599. const { path } = parseUrl(url);
  38600. let exp;
  38601. if (path) {
  38602. const existingImportsIndex = context.imports.findIndex(i => i.path === path);
  38603. if (existingImportsIndex > -1) {
  38604. exp = createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 2 /* CAN_HOIST */);
  38605. }
  38606. else {
  38607. exp = createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 2 /* CAN_HOIST */);
  38608. context.imports.push({ exp, path });
  38609. }
  38610. compoundExpression.children.push(exp);
  38611. }
  38612. }
  38613. else {
  38614. const exp = createSimpleExpression(`"${url}"`, false, attr.loc, 2 /* CAN_HOIST */);
  38615. compoundExpression.children.push(exp);
  38616. }
  38617. const isNotLast = imageCandidates.length - 1 > index;
  38618. if (descriptor && isNotLast) {
  38619. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  38620. }
  38621. else if (descriptor) {
  38622. compoundExpression.children.push(` + ' ${descriptor}'`);
  38623. }
  38624. else if (isNotLast) {
  38625. compoundExpression.children.push(` + ', ' + `);
  38626. }
  38627. });
  38628. const hoisted = context.hoist(compoundExpression);
  38629. hoisted.constType = 2 /* CAN_HOIST */;
  38630. node.props[index] = {
  38631. type: 7 /* DIRECTIVE */,
  38632. name: 'bind',
  38633. arg: createSimpleExpression('srcset', true, attr.loc),
  38634. exp: hoisted,
  38635. modifiers: [],
  38636. loc: attr.loc
  38637. };
  38638. }
  38639. });
  38640. }
  38641. }
  38642. };
  38643. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  38644. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  38645. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  38646. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  38647. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  38648. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  38649. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  38650. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  38651. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  38652. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  38653. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(`ssrIncludeBooleanAttr`);
  38654. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  38655. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  38656. const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
  38657. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
  38658. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  38659. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  38660. const ssrHelpers = {
  38661. [SSR_INTERPOLATE]: `ssrInterpolate`,
  38662. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  38663. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  38664. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  38665. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  38666. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  38667. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  38668. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  38669. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  38670. [SSR_RENDER_LIST]: `ssrRenderList`,
  38671. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  38672. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  38673. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  38674. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  38675. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  38676. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  38677. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`
  38678. };
  38679. // Note: these are helpers imported from @vue/server-renderer
  38680. // make sure the names match!
  38681. registerRuntimeHelpers(ssrHelpers);
  38682. // Plugin for the first transform pass, which simply constructs the AST node
  38683. const ssrTransformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, processIf);
  38684. // This is called during the 2nd transform pass to construct the SSR-specific
  38685. // codegen nodes.
  38686. function ssrProcessIf(node, context, disableNestedFragments = false) {
  38687. const [rootBranch] = node.branches;
  38688. const ifStatement = createIfStatement(rootBranch.condition, processIfBranch(rootBranch, context, disableNestedFragments));
  38689. context.pushStatement(ifStatement);
  38690. let currentIf = ifStatement;
  38691. for (let i = 1; i < node.branches.length; i++) {
  38692. const branch = node.branches[i];
  38693. const branchBlockStatement = processIfBranch(branch, context, disableNestedFragments);
  38694. if (branch.condition) {
  38695. // else-if
  38696. currentIf = currentIf.alternate = createIfStatement(branch.condition, branchBlockStatement);
  38697. }
  38698. else {
  38699. // else
  38700. currentIf.alternate = branchBlockStatement;
  38701. }
  38702. }
  38703. if (!currentIf.alternate) {
  38704. currentIf.alternate = createBlockStatement([
  38705. createCallExpression(`_push`, ['`<!---->`'])
  38706. ]);
  38707. }
  38708. }
  38709. function processIfBranch(branch, context, disableNestedFragments = false) {
  38710. const { children } = branch;
  38711. const needFragmentWrapper = !disableNestedFragments &&
  38712. (children.length !== 1 || children[0].type !== 1 /* ELEMENT */) &&
  38713. // optimize away nested fragments when the only child is a ForNode
  38714. !(children.length === 1 && children[0].type === 11 /* FOR */);
  38715. return processChildrenAsStatement(children, context, needFragmentWrapper);
  38716. }
  38717. // Plugin for the first transform pass, which simply constructs the AST node
  38718. const ssrTransformFor = createStructuralDirectiveTransform('for', processFor);
  38719. // This is called during the 2nd transform pass to construct the SSR-specific
  38720. // codegen nodes.
  38721. function ssrProcessFor(node, context, disableNestedFragments = false) {
  38722. const needFragmentWrapper = !disableNestedFragments &&
  38723. (node.children.length !== 1 || node.children[0].type !== 1 /* ELEMENT */);
  38724. const renderLoop = createFunctionExpression(createForLoopParams(node.parseResult));
  38725. renderLoop.body = processChildrenAsStatement(node.children, context, needFragmentWrapper);
  38726. // v-for always renders a fragment unless explicitly disabled
  38727. if (!disableNestedFragments) {
  38728. context.pushStringPart(`<!--[-->`);
  38729. }
  38730. context.pushStatement(createCallExpression(context.helper(SSR_RENDER_LIST), [
  38731. node.source,
  38732. renderLoop
  38733. ]));
  38734. if (!disableNestedFragments) {
  38735. context.pushStringPart(`<!--]-->`);
  38736. }
  38737. }
  38738. const ssrTransformSlotOutlet = (node, context) => {
  38739. if (isSlotOutlet(node)) {
  38740. const { slotName, slotProps } = processSlotOutlet(node, context);
  38741. const args = [
  38742. `_ctx.$slots`,
  38743. slotName,
  38744. slotProps || `{}`,
  38745. // fallback content placeholder. will be replaced in the process phase
  38746. `null`,
  38747. `_push`,
  38748. `_parent`
  38749. ];
  38750. // inject slot scope id if current template uses :slotted
  38751. if (context.scopeId && context.slotted !== false) {
  38752. args.push(`"${context.scopeId}-s"`);
  38753. }
  38754. node.ssrCodegenNode = createCallExpression(context.helper(SSR_RENDER_SLOT), args);
  38755. }
  38756. };
  38757. function ssrProcessSlotOutlet(node, context) {
  38758. const renderCall = node.ssrCodegenNode;
  38759. // has fallback content
  38760. if (node.children.length) {
  38761. const fallbackRenderFn = createFunctionExpression([]);
  38762. fallbackRenderFn.body = processChildrenAsStatement(node.children, context);
  38763. // _renderSlot(slots, name, props, fallback, ...)
  38764. renderCall.arguments[3] = fallbackRenderFn;
  38765. }
  38766. // Forwarded <slot/>. Merge slot scope ids
  38767. if (context.withSlotScopeId) {
  38768. const slotScopeId = renderCall.arguments[6];
  38769. renderCall.arguments[6] = slotScopeId
  38770. ? `${slotScopeId} + _scopeId`
  38771. : `_scopeId`;
  38772. }
  38773. context.pushStatement(node.ssrCodegenNode);
  38774. }
  38775. function createSSRCompilerError(code, loc) {
  38776. return createCompilerError(code, loc, SSRErrorMessages);
  38777. }
  38778. const SSRErrorMessages = {
  38779. [61 /* X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM */]: `Custom directive is missing corresponding SSR transform and will be ignored.`,
  38780. [62 /* X_SSR_UNSAFE_ATTR_NAME */]: `Unsafe attribute name for SSR.`,
  38781. [63 /* X_SSR_NO_TELEPORT_TARGET */]: `Missing the 'to' prop on teleport element.`,
  38782. [64 /* X_SSR_INVALID_AST_NODE */]: `Invalid AST node during SSR transform.`
  38783. };
  38784. // Note: this is a 2nd-pass codegen transform.
  38785. function ssrProcessTeleport(node, context) {
  38786. const targetProp = findProp(node, 'to');
  38787. if (!targetProp) {
  38788. context.onError(createSSRCompilerError(63 /* X_SSR_NO_TELEPORT_TARGET */, node.loc));
  38789. return;
  38790. }
  38791. let target;
  38792. if (targetProp.type === 6 /* ATTRIBUTE */) {
  38793. target =
  38794. targetProp.value && createSimpleExpression(targetProp.value.content, true);
  38795. }
  38796. else {
  38797. target = targetProp.exp;
  38798. }
  38799. if (!target) {
  38800. context.onError(createSSRCompilerError(63 /* X_SSR_NO_TELEPORT_TARGET */, targetProp.loc));
  38801. return;
  38802. }
  38803. const disabledProp = findProp(node, 'disabled', false, true /* allow empty */);
  38804. const disabled = disabledProp
  38805. ? disabledProp.type === 6 /* ATTRIBUTE */
  38806. ? `true`
  38807. : disabledProp.exp || `false`
  38808. : `false`;
  38809. const contentRenderFn = createFunctionExpression([`_push`], undefined, // Body is added later
  38810. true, // newline
  38811. false, // isSlot
  38812. node.loc);
  38813. contentRenderFn.body = processChildrenAsStatement(node.children, context);
  38814. context.pushStatement(createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  38815. `_push`,
  38816. contentRenderFn,
  38817. target,
  38818. disabled,
  38819. `_parent`
  38820. ]));
  38821. }
  38822. const wipMap = new WeakMap();
  38823. // phase 1
  38824. function ssrTransformSuspense(node, context) {
  38825. return () => {
  38826. if (node.children.length) {
  38827. const wipEntry = {
  38828. slotsExp: null,
  38829. wipSlots: []
  38830. };
  38831. wipMap.set(node, wipEntry);
  38832. wipEntry.slotsExp = buildSlots(node, context, (_props, children, loc) => {
  38833. const fn = createFunctionExpression([], undefined, // no return, assign body later
  38834. true, // newline
  38835. false, // suspense slots are not treated as normal slots
  38836. loc);
  38837. wipEntry.wipSlots.push({
  38838. fn,
  38839. children
  38840. });
  38841. return fn;
  38842. }).slots;
  38843. }
  38844. };
  38845. }
  38846. // phase 2
  38847. function ssrProcessSuspense(node, context) {
  38848. // complete wip slots with ssr code
  38849. const wipEntry = wipMap.get(node);
  38850. if (!wipEntry) {
  38851. return;
  38852. }
  38853. const { slotsExp, wipSlots } = wipEntry;
  38854. for (let i = 0; i < wipSlots.length; i++) {
  38855. const { fn, children } = wipSlots[i];
  38856. fn.body = processChildrenAsStatement(children, context);
  38857. }
  38858. // _push(ssrRenderSuspense(slots))
  38859. context.pushStatement(createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  38860. `_push`,
  38861. slotsExp
  38862. ]));
  38863. }
  38864. function ssrProcessTransitionGroup(node, context) {
  38865. const tag = findProp(node, 'tag');
  38866. if (tag) {
  38867. if (tag.type === 7 /* DIRECTIVE */) {
  38868. // dynamic :tag
  38869. context.pushStringPart(`<`);
  38870. context.pushStringPart(tag.exp);
  38871. context.pushStringPart(`>`);
  38872. processChildren(node.children, context, false,
  38873. /**
  38874. * TransitionGroup has the special runtime behavior of flattening and
  38875. * concatenating all children into a single fragment (in order for them to
  38876. * be pathced using the same key map) so we need to account for that here
  38877. * by disabling nested fragment wrappers from being generated.
  38878. */
  38879. true);
  38880. context.pushStringPart(`</`);
  38881. context.pushStringPart(tag.exp);
  38882. context.pushStringPart(`>`);
  38883. }
  38884. else {
  38885. // static tag
  38886. context.pushStringPart(`<${tag.value.content}>`);
  38887. processChildren(node.children, context, false, true);
  38888. context.pushStringPart(`</${tag.value.content}>`);
  38889. }
  38890. }
  38891. else {
  38892. // fragment
  38893. processChildren(node.children, context, true, true);
  38894. }
  38895. }
  38896. // We need to construct the slot functions in the 1st pass to ensure proper
  38897. // scope tracking, but the children of each slot cannot be processed until
  38898. // the 2nd pass, so we store the WIP slot functions in a weakmap during the 1st
  38899. // pass and complete them in the 2nd pass.
  38900. const wipMap$1 = new WeakMap();
  38901. const componentTypeMap = new WeakMap();
  38902. // ssr component transform is done in two phases:
  38903. // In phase 1. we use `buildSlot` to analyze the children of the component into
  38904. // WIP slot functions (it must be done in phase 1 because `buildSlot` relies on
  38905. // the core transform context).
  38906. // In phase 2. we convert the WIP slots from phase 1 into ssr-specific codegen
  38907. // nodes.
  38908. const ssrTransformComponent = (node, context) => {
  38909. if (node.type !== 1 /* ELEMENT */ ||
  38910. node.tagType !== 1 /* COMPONENT */) {
  38911. return;
  38912. }
  38913. const component = resolveComponentType(node, context, true /* ssr */);
  38914. componentTypeMap.set(node, component);
  38915. if (isSymbol(component)) {
  38916. if (component === SUSPENSE) {
  38917. return ssrTransformSuspense(node, context);
  38918. }
  38919. return; // built-in component: fallthrough
  38920. }
  38921. // Build the fallback vnode-based branch for the component's slots.
  38922. // We need to clone the node into a fresh copy and use the buildSlots' logic
  38923. // to get access to the children of each slot. We then compile them with
  38924. // a child transform pipeline using vnode-based transforms (instead of ssr-
  38925. // based ones), and save the result branch (a ReturnStatement) in an array.
  38926. // The branch is retrieved when processing slots again in ssr mode.
  38927. const vnodeBranches = [];
  38928. const clonedNode = clone$1(node);
  38929. return function ssrPostTransformComponent() {
  38930. // Using the cloned node, build the normal VNode-based branches (for
  38931. // fallback in case the child is render-fn based). Store them in an array
  38932. // for later use.
  38933. if (clonedNode.children.length) {
  38934. buildSlots(clonedNode, context, (props, children) => {
  38935. vnodeBranches.push(createVNodeSlotBranch(props, children, context));
  38936. return createFunctionExpression(undefined);
  38937. });
  38938. }
  38939. const props = node.props.length > 0
  38940. ? // note we are not passing ssr: true here because for components, v-on
  38941. // handlers should still be passed
  38942. buildProps(node, context).props || `null`
  38943. : `null`;
  38944. const wipEntries = [];
  38945. wipMap$1.set(node, wipEntries);
  38946. const buildSSRSlotFn = (props, children, loc) => {
  38947. const fn = createFunctionExpression([props || `_`, `_push`, `_parent`, `_scopeId`], undefined, // no return, assign body later
  38948. true, // newline
  38949. true, // isSlot
  38950. loc);
  38951. wipEntries.push({
  38952. fn,
  38953. children,
  38954. // also collect the corresponding vnode branch built earlier
  38955. vnodeBranch: vnodeBranches[wipEntries.length]
  38956. });
  38957. return fn;
  38958. };
  38959. const slots = node.children.length
  38960. ? buildSlots(node, context, buildSSRSlotFn).slots
  38961. : `null`;
  38962. if (typeof component !== 'string') {
  38963. // dynamic component that resolved to a `resolveDynamicComponent` call
  38964. // expression - since the resolved result may be a plain element (string)
  38965. // or a VNode, handle it with `renderVNode`.
  38966. node.ssrCodegenNode = createCallExpression(context.helper(SSR_RENDER_VNODE), [
  38967. `_push`,
  38968. createCallExpression(context.helper(CREATE_VNODE), [
  38969. component,
  38970. props,
  38971. slots
  38972. ]),
  38973. `_parent`
  38974. ]);
  38975. }
  38976. else {
  38977. node.ssrCodegenNode = createCallExpression(context.helper(SSR_RENDER_COMPONENT), [component, props, slots, `_parent`]);
  38978. }
  38979. };
  38980. };
  38981. function ssrProcessComponent(node, context) {
  38982. const component = componentTypeMap.get(node);
  38983. if (!node.ssrCodegenNode) {
  38984. // this is a built-in component that fell-through.
  38985. if (component === TELEPORT) {
  38986. return ssrProcessTeleport(node, context);
  38987. }
  38988. else if (component === SUSPENSE) {
  38989. return ssrProcessSuspense(node, context);
  38990. }
  38991. else if (component === TRANSITION_GROUP) {
  38992. return ssrProcessTransitionGroup(node, context);
  38993. }
  38994. else {
  38995. // real fall-through: Transition / KeepAlive
  38996. // just render its children.
  38997. processChildren(node.children, context);
  38998. }
  38999. }
  39000. else {
  39001. // finish up slot function expressions from the 1st pass.
  39002. const wipEntries = wipMap$1.get(node) || [];
  39003. for (let i = 0; i < wipEntries.length; i++) {
  39004. const { fn, children, vnodeBranch } = wipEntries[i];
  39005. // For each slot, we generate two branches: one SSR-optimized branch and
  39006. // one normal vnode-based branch. The branches are taken based on the
  39007. // presence of the 2nd `_push` argument (which is only present if the slot
  39008. // is called by `_ssrRenderSlot`.
  39009. fn.body = createIfStatement(createSimpleExpression(`_push`, false), processChildrenAsStatement(children, context, false, true /* withSlotScopeId */), vnodeBranch);
  39010. }
  39011. // component is inside a slot, inherit slot scope Id
  39012. if (context.withSlotScopeId) {
  39013. node.ssrCodegenNode.arguments.push(`_scopeId`);
  39014. }
  39015. if (typeof component === 'string') {
  39016. // static component
  39017. context.pushStatement(createCallExpression(`_push`, [node.ssrCodegenNode]));
  39018. }
  39019. else {
  39020. // dynamic component (`resolveDynamicComponent` call)
  39021. // the codegen node is a `renderVNode` call
  39022. context.pushStatement(node.ssrCodegenNode);
  39023. }
  39024. }
  39025. }
  39026. const rawOptionsMap = new WeakMap();
  39027. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  39028. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  39029. const vnodeDirectiveTransforms = Object.assign(Object.assign({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  39030. function createVNodeSlotBranch(props, children, parentContext) {
  39031. // apply a sub-transform using vnode-based transforms.
  39032. const rawOptions = rawOptionsMap.get(parentContext.root);
  39033. const subOptions = Object.assign(Object.assign({}, rawOptions), {
  39034. // overwrite with vnode-based transforms
  39035. nodeTransforms: [
  39036. ...vnodeNodeTransforms,
  39037. ...(rawOptions.nodeTransforms || [])
  39038. ], directiveTransforms: Object.assign(Object.assign({}, vnodeDirectiveTransforms), (rawOptions.directiveTransforms || {})) });
  39039. // wrap the children with a wrapper template for proper children treatment.
  39040. const wrapperNode = {
  39041. type: 1 /* ELEMENT */,
  39042. ns: 0 /* HTML */,
  39043. tag: 'template',
  39044. tagType: 3 /* TEMPLATE */,
  39045. isSelfClosing: false,
  39046. // important: provide v-slot="props" on the wrapper for proper
  39047. // scope analysis
  39048. props: [
  39049. {
  39050. type: 7 /* DIRECTIVE */,
  39051. name: 'slot',
  39052. exp: props,
  39053. arg: undefined,
  39054. modifiers: [],
  39055. loc: locStub
  39056. }
  39057. ],
  39058. children,
  39059. loc: locStub,
  39060. codegenNode: undefined
  39061. };
  39062. subTransform(wrapperNode, subOptions, parentContext);
  39063. return createReturnStatement(children);
  39064. }
  39065. function subTransform(node, options, parentContext) {
  39066. const childRoot = createRoot([node]);
  39067. const childContext = createTransformContext(childRoot, options);
  39068. // this sub transform is for vnode fallback branch so it should be handled
  39069. // like normal render functions
  39070. childContext.ssr = false;
  39071. // inherit parent scope analysis state
  39072. childContext.scopes = Object.assign({}, parentContext.scopes);
  39073. childContext.identifiers = Object.assign({}, parentContext.identifiers);
  39074. childContext.imports = parentContext.imports;
  39075. // traverse
  39076. traverseNode(childRoot, childContext);
  39077. ['helpers', 'components', 'directives'].forEach(key => {
  39078. childContext[key].forEach((value, helperKey) => {
  39079. if (key === 'helpers') {
  39080. const parentCount = parentContext.helpers.get(helperKey);
  39081. if (parentCount === undefined) {
  39082. parentContext.helpers.set(helperKey, value);
  39083. }
  39084. else {
  39085. parentContext.helpers.set(helperKey, value + parentCount);
  39086. }
  39087. }
  39088. else {
  39089. parentContext[key].add(value);
  39090. }
  39091. });
  39092. });
  39093. // imports/hoists are not merged because:
  39094. // - imports are only used for asset urls and should be consistent between
  39095. // node/client branches
  39096. // - hoists are not enabled for the client branch here
  39097. }
  39098. function clone$1(v) {
  39099. if (isArray(v)) {
  39100. return v.map(clone$1);
  39101. }
  39102. else if (isObject(v)) {
  39103. const res = {};
  39104. for (const key in v) {
  39105. res[key] = clone$1(v[key]);
  39106. }
  39107. return res;
  39108. }
  39109. else {
  39110. return v;
  39111. }
  39112. }
  39113. // for directives with children overwrite (e.g. v-html & v-text), we need to
  39114. // store the raw children so that they can be added in the 2nd pass.
  39115. const rawChildrenMap = new WeakMap();
  39116. const ssrTransformElement = (node, context) => {
  39117. if (node.type !== 1 /* ELEMENT */ ||
  39118. node.tagType !== 0 /* ELEMENT */) {
  39119. return;
  39120. }
  39121. return function ssrPostTransformElement() {
  39122. // element
  39123. // generate the template literal representing the open tag.
  39124. const openTag = [`<${node.tag}`];
  39125. // some tags need to be passed to runtime for special checks
  39126. const needTagForRuntime = node.tag === 'textarea' || node.tag.indexOf('-') > 0;
  39127. // v-bind="obj" or v-bind:[key] can potentially overwrite other static
  39128. // attrs and can affect final rendering result, so when they are present
  39129. // we need to bail out to full `renderAttrs`
  39130. const hasDynamicVBind = hasDynamicKeyVBind(node);
  39131. if (hasDynamicVBind) {
  39132. const { props } = buildProps(node, context, node.props, true /* ssr */);
  39133. if (props) {
  39134. const propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [props]);
  39135. if (node.tag === 'textarea') {
  39136. const existingText = node.children[0];
  39137. // If interpolation, this is dynamic <textarea> content, potentially
  39138. // injected by v-model and takes higher priority than v-bind value
  39139. if (!existingText || existingText.type !== 5 /* INTERPOLATION */) {
  39140. // <textarea> with dynamic v-bind. We don't know if the final props
  39141. // will contain .value, so we will have to do something special:
  39142. // assign the merged props to a temp variable, and check whether
  39143. // it contains value (if yes, render is as children).
  39144. const tempId = `_temp${context.temps++}`;
  39145. propsExp.arguments = [
  39146. createAssignmentExpression(createSimpleExpression(tempId, false), props)
  39147. ];
  39148. rawChildrenMap.set(node, createCallExpression(context.helper(SSR_INTERPOLATE), [
  39149. createConditionalExpression(createSimpleExpression(`"value" in ${tempId}`, false), createSimpleExpression(`${tempId}.value`, false), createSimpleExpression(existingText ? existingText.content : ``, true), false)
  39150. ]));
  39151. }
  39152. }
  39153. else if (node.tag === 'input') {
  39154. // <input v-bind="obj" v-model>
  39155. // we need to determine the props to render for the dynamic v-model
  39156. // and merge it with the v-bind expression.
  39157. const vModel = findVModel(node);
  39158. if (vModel) {
  39159. // 1. save the props (san v-model) in a temp variable
  39160. const tempId = `_temp${context.temps++}`;
  39161. const tempExp = createSimpleExpression(tempId, false);
  39162. propsExp.arguments = [
  39163. createSequenceExpression([
  39164. createAssignmentExpression(tempExp, props),
  39165. createCallExpression(context.helper(MERGE_PROPS), [
  39166. tempExp,
  39167. createCallExpression(context.helper(SSR_GET_DYNAMIC_MODEL_PROPS), [
  39168. tempExp,
  39169. vModel.exp // model
  39170. ])
  39171. ])
  39172. ])
  39173. ];
  39174. }
  39175. }
  39176. if (needTagForRuntime) {
  39177. propsExp.arguments.push(`"${node.tag}"`);
  39178. }
  39179. openTag.push(propsExp);
  39180. }
  39181. }
  39182. // book keeping static/dynamic class merging.
  39183. let dynamicClassBinding = undefined;
  39184. let staticClassBinding = undefined;
  39185. // all style bindings are converted to dynamic by transformStyle.
  39186. // but we need to make sure to merge them.
  39187. let dynamicStyleBinding = undefined;
  39188. for (let i = 0; i < node.props.length; i++) {
  39189. const prop = node.props[i];
  39190. // ignore true-value/false-value on input
  39191. if (node.tag === 'input' && isTrueFalseValue(prop)) {
  39192. continue;
  39193. }
  39194. // special cases with children override
  39195. if (prop.type === 7 /* DIRECTIVE */) {
  39196. if (prop.name === 'html' && prop.exp) {
  39197. rawChildrenMap.set(node, prop.exp);
  39198. }
  39199. else if (prop.name === 'text' && prop.exp) {
  39200. node.children = [createInterpolation(prop.exp, prop.loc)];
  39201. }
  39202. else if (prop.name === 'slot') {
  39203. context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, prop.loc));
  39204. }
  39205. else if (isTextareaWithValue(node, prop) && prop.exp) {
  39206. if (!hasDynamicVBind) {
  39207. node.children = [createInterpolation(prop.exp, prop.loc)];
  39208. }
  39209. }
  39210. else {
  39211. // Directive transforms.
  39212. const directiveTransform = context.directiveTransforms[prop.name];
  39213. if (!directiveTransform) {
  39214. // no corresponding ssr directive transform found.
  39215. context.onError(createSSRCompilerError(61 /* X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM */, prop.loc));
  39216. }
  39217. else if (!hasDynamicVBind) {
  39218. const { props, ssrTagParts } = directiveTransform(prop, node, context);
  39219. if (ssrTagParts) {
  39220. openTag.push(...ssrTagParts);
  39221. }
  39222. for (let j = 0; j < props.length; j++) {
  39223. const { key, value } = props[j];
  39224. if (isStaticExp(key)) {
  39225. let attrName = key.content;
  39226. // static key attr
  39227. if (attrName === 'key' || attrName === 'ref') {
  39228. continue;
  39229. }
  39230. if (attrName === 'class') {
  39231. openTag.push(` class="`, (dynamicClassBinding = createCallExpression(context.helper(SSR_RENDER_CLASS), [value])), `"`);
  39232. }
  39233. else if (attrName === 'style') {
  39234. if (dynamicStyleBinding) {
  39235. // already has style binding, merge into it.
  39236. mergeCall(dynamicStyleBinding, value);
  39237. }
  39238. else {
  39239. openTag.push(` style="`, (dynamicStyleBinding = createCallExpression(context.helper(SSR_RENDER_STYLE), [value])), `"`);
  39240. }
  39241. }
  39242. else {
  39243. attrName =
  39244. node.tag.indexOf('-') > 0
  39245. ? attrName // preserve raw name on custom elements
  39246. : propsToAttrMap[attrName] || attrName.toLowerCase();
  39247. if (isBooleanAttr(attrName)) {
  39248. openTag.push(createConditionalExpression(createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [value]), createSimpleExpression(' ' + attrName, true), createSimpleExpression('', true), false /* no newline */));
  39249. }
  39250. else if (isSSRSafeAttrName(attrName)) {
  39251. openTag.push(createCallExpression(context.helper(SSR_RENDER_ATTR), [
  39252. key,
  39253. value
  39254. ]));
  39255. }
  39256. else {
  39257. context.onError(createSSRCompilerError(62 /* X_SSR_UNSAFE_ATTR_NAME */, key.loc));
  39258. }
  39259. }
  39260. }
  39261. else {
  39262. // dynamic key attr
  39263. // this branch is only encountered for custom directive
  39264. // transforms that returns properties with dynamic keys
  39265. const args = [key, value];
  39266. if (needTagForRuntime) {
  39267. args.push(`"${node.tag}"`);
  39268. }
  39269. openTag.push(createCallExpression(context.helper(SSR_RENDER_DYNAMIC_ATTR), args));
  39270. }
  39271. }
  39272. }
  39273. }
  39274. }
  39275. else {
  39276. // special case: value on <textarea>
  39277. if (node.tag === 'textarea' && prop.name === 'value' && prop.value) {
  39278. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  39279. }
  39280. else if (!hasDynamicVBind) {
  39281. if (prop.name === 'key' || prop.name === 'ref') {
  39282. continue;
  39283. }
  39284. // static prop
  39285. if (prop.name === 'class' && prop.value) {
  39286. staticClassBinding = JSON.stringify(prop.value.content);
  39287. }
  39288. openTag.push(` ${prop.name}` +
  39289. (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``));
  39290. }
  39291. }
  39292. }
  39293. // handle co-existence of dynamic + static class bindings
  39294. if (dynamicClassBinding && staticClassBinding) {
  39295. mergeCall(dynamicClassBinding, staticClassBinding);
  39296. removeStaticBinding(openTag, 'class');
  39297. }
  39298. if (context.scopeId) {
  39299. openTag.push(` ${context.scopeId}`);
  39300. }
  39301. node.ssrCodegenNode = createTemplateLiteral(openTag);
  39302. };
  39303. };
  39304. function isTrueFalseValue(prop) {
  39305. if (prop.type === 7 /* DIRECTIVE */) {
  39306. return (prop.name === 'bind' &&
  39307. prop.arg &&
  39308. isStaticExp(prop.arg) &&
  39309. (prop.arg.content === 'true-value' || prop.arg.content === 'false-value'));
  39310. }
  39311. else {
  39312. return prop.name === 'true-value' || prop.name === 'false-value';
  39313. }
  39314. }
  39315. function isTextareaWithValue(node, prop) {
  39316. return !!(node.tag === 'textarea' &&
  39317. prop.name === 'bind' &&
  39318. isBindKey(prop.arg, 'value'));
  39319. }
  39320. function mergeCall(call, arg) {
  39321. const existing = call.arguments[0];
  39322. if (existing.type === 17 /* JS_ARRAY_EXPRESSION */) {
  39323. existing.elements.push(arg);
  39324. }
  39325. else {
  39326. call.arguments[0] = createArrayExpression([existing, arg]);
  39327. }
  39328. }
  39329. function removeStaticBinding(tag, binding) {
  39330. const regExp = new RegExp(`^ ${binding}=".+"$`);
  39331. const i = tag.findIndex(e => typeof e === 'string' && regExp.test(e));
  39332. if (i > -1) {
  39333. tag.splice(i, 1);
  39334. }
  39335. }
  39336. function findVModel(node) {
  39337. return node.props.find(p => p.type === 7 /* DIRECTIVE */ && p.name === 'model' && p.exp);
  39338. }
  39339. function ssrProcessElement(node, context) {
  39340. const isVoidTag = context.options.isVoidTag || NO;
  39341. const elementsToAdd = node.ssrCodegenNode.elements;
  39342. for (let j = 0; j < elementsToAdd.length; j++) {
  39343. context.pushStringPart(elementsToAdd[j]);
  39344. }
  39345. // Handle slot scopeId
  39346. if (context.withSlotScopeId) {
  39347. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  39348. }
  39349. // close open tag
  39350. context.pushStringPart(`>`);
  39351. const rawChildren = rawChildrenMap.get(node);
  39352. if (rawChildren) {
  39353. context.pushStringPart(rawChildren);
  39354. }
  39355. else if (node.children.length) {
  39356. processChildren(node.children, context);
  39357. }
  39358. if (!isVoidTag(node.tag)) {
  39359. // push closing tag
  39360. context.pushStringPart(`</${node.tag}>`);
  39361. }
  39362. }
  39363. // Because SSR codegen output is completely different from client-side output
  39364. // (e.g. multiple elements can be concatenated into a single template literal
  39365. // instead of each getting a corresponding call), we need to apply an extra
  39366. // transform pass to convert the template AST into a fresh JS AST before
  39367. // passing it to codegen.
  39368. function ssrCodegenTransform(ast, options) {
  39369. const context = createSSRTransformContext(ast, options);
  39370. // inject SFC <style> CSS variables
  39371. // we do this instead of inlining the expression to ensure the vars are
  39372. // only resolved once per render
  39373. if (options.ssrCssVars) {
  39374. const varsExp = processExpression(createSimpleExpression(options.ssrCssVars, false), createTransformContext(createRoot([]), options));
  39375. context.body.push(createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`]));
  39376. }
  39377. const isFragment = ast.children.length > 1 && ast.children.some(c => !isText(c));
  39378. processChildren(ast.children, context, isFragment);
  39379. ast.codegenNode = createBlockStatement(context.body);
  39380. // Finalize helpers.
  39381. // We need to separate helpers imported from 'vue' vs. '@vue/server-renderer'
  39382. ast.ssrHelpers = Array.from(new Set([...ast.helpers.filter(h => h in ssrHelpers), ...context.helpers]));
  39383. ast.helpers = ast.helpers.filter(h => !(h in ssrHelpers));
  39384. }
  39385. function createSSRTransformContext(root, options, helpers = new Set(), withSlotScopeId = false) {
  39386. const body = [];
  39387. let currentString = null;
  39388. return {
  39389. root,
  39390. options,
  39391. body,
  39392. helpers,
  39393. withSlotScopeId,
  39394. onError: options.onError ||
  39395. (e => {
  39396. throw e;
  39397. }),
  39398. helper(name) {
  39399. helpers.add(name);
  39400. return name;
  39401. },
  39402. pushStringPart(part) {
  39403. if (!currentString) {
  39404. const currentCall = createCallExpression(`_push`);
  39405. body.push(currentCall);
  39406. currentString = createTemplateLiteral([]);
  39407. currentCall.arguments.push(currentString);
  39408. }
  39409. const bufferedElements = currentString.elements;
  39410. const lastItem = bufferedElements[bufferedElements.length - 1];
  39411. if (isString(part) && isString(lastItem)) {
  39412. bufferedElements[bufferedElements.length - 1] += part;
  39413. }
  39414. else {
  39415. bufferedElements.push(part);
  39416. }
  39417. },
  39418. pushStatement(statement) {
  39419. // close current string
  39420. currentString = null;
  39421. body.push(statement);
  39422. }
  39423. };
  39424. }
  39425. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  39426. // ensure child inherits parent helpers
  39427. return createSSRTransformContext(parent.root, parent.options, parent.helpers, withSlotScopeId);
  39428. }
  39429. function processChildren(children, context, asFragment = false, disableNestedFragments = false) {
  39430. if (asFragment) {
  39431. context.pushStringPart(`<!--[-->`);
  39432. }
  39433. for (let i = 0; i < children.length; i++) {
  39434. const child = children[i];
  39435. switch (child.type) {
  39436. case 1 /* ELEMENT */:
  39437. switch (child.tagType) {
  39438. case 0 /* ELEMENT */:
  39439. ssrProcessElement(child, context);
  39440. break;
  39441. case 1 /* COMPONENT */:
  39442. ssrProcessComponent(child, context);
  39443. break;
  39444. case 2 /* SLOT */:
  39445. ssrProcessSlotOutlet(child, context);
  39446. break;
  39447. case 3 /* TEMPLATE */:
  39448. // TODO
  39449. break;
  39450. default:
  39451. context.onError(createSSRCompilerError(64 /* X_SSR_INVALID_AST_NODE */, child.loc));
  39452. // make sure we exhaust all possible types
  39453. const exhaustiveCheck = child;
  39454. return exhaustiveCheck;
  39455. }
  39456. break;
  39457. case 2 /* TEXT */:
  39458. context.pushStringPart(escapeHtml(child.content));
  39459. break;
  39460. case 3 /* COMMENT */:
  39461. // no need to escape comment here because the AST can only
  39462. // contain valid comments.
  39463. context.pushStringPart(`<!--${child.content}-->`);
  39464. break;
  39465. case 5 /* INTERPOLATION */:
  39466. context.pushStringPart(createCallExpression(context.helper(SSR_INTERPOLATE), [child.content]));
  39467. break;
  39468. case 9 /* IF */:
  39469. ssrProcessIf(child, context, disableNestedFragments);
  39470. break;
  39471. case 11 /* FOR */:
  39472. ssrProcessFor(child, context, disableNestedFragments);
  39473. break;
  39474. case 10 /* IF_BRANCH */:
  39475. // no-op - handled by ssrProcessIf
  39476. break;
  39477. case 12 /* TEXT_CALL */:
  39478. case 8 /* COMPOUND_EXPRESSION */:
  39479. // no-op - these two types can never appear as template child node since
  39480. // `transformText` is not used during SSR compile.
  39481. break;
  39482. default:
  39483. context.onError(createSSRCompilerError(64 /* X_SSR_INVALID_AST_NODE */, child.loc));
  39484. // make sure we exhaust all possible types
  39485. const exhaustiveCheck = child;
  39486. return exhaustiveCheck;
  39487. }
  39488. }
  39489. if (asFragment) {
  39490. context.pushStringPart(`<!--]-->`);
  39491. }
  39492. }
  39493. function processChildrenAsStatement(children, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  39494. const childContext = createChildContext(parentContext, withSlotScopeId);
  39495. processChildren(children, childContext, asFragment);
  39496. return createBlockStatement(childContext.body);
  39497. }
  39498. const ssrTransformModel = (dir, node, context) => {
  39499. const model = dir.exp;
  39500. function checkDuplicatedValue() {
  39501. const value = findProp(node, 'value');
  39502. if (value) {
  39503. context.onError(createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
  39504. }
  39505. }
  39506. if (node.tagType === 0 /* ELEMENT */) {
  39507. const res = { props: [] };
  39508. const defaultProps = [
  39509. // default value binding for text type inputs
  39510. createObjectProperty(`value`, model)
  39511. ];
  39512. if (node.tag === 'input') {
  39513. const type = findProp(node, 'type');
  39514. if (type) {
  39515. const value = findValueBinding(node);
  39516. if (type.type === 7 /* DIRECTIVE */) {
  39517. // dynamic type
  39518. res.ssrTagParts = [
  39519. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  39520. type.exp,
  39521. model,
  39522. value
  39523. ])
  39524. ];
  39525. }
  39526. else if (type.value) {
  39527. // static type
  39528. switch (type.value.content) {
  39529. case 'radio':
  39530. res.props = [
  39531. createObjectProperty(`checked`, createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  39532. model,
  39533. value
  39534. ]))
  39535. ];
  39536. break;
  39537. case 'checkbox':
  39538. const trueValueBinding = findProp(node, 'true-value');
  39539. if (trueValueBinding) {
  39540. const trueValue = trueValueBinding.type === 6 /* ATTRIBUTE */
  39541. ? JSON.stringify(trueValueBinding.value.content)
  39542. : trueValueBinding.exp;
  39543. res.props = [
  39544. createObjectProperty(`checked`, createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  39545. model,
  39546. trueValue
  39547. ]))
  39548. ];
  39549. }
  39550. else {
  39551. res.props = [
  39552. createObjectProperty(`checked`, createConditionalExpression(createCallExpression(`Array.isArray`, [model]), createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  39553. model,
  39554. value
  39555. ]), model))
  39556. ];
  39557. }
  39558. break;
  39559. case 'file':
  39560. context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
  39561. break;
  39562. default:
  39563. checkDuplicatedValue();
  39564. res.props = defaultProps;
  39565. break;
  39566. }
  39567. }
  39568. }
  39569. else if (hasDynamicKeyVBind(node)) ;
  39570. else {
  39571. // text type
  39572. checkDuplicatedValue();
  39573. res.props = defaultProps;
  39574. }
  39575. }
  39576. else if (node.tag === 'textarea') {
  39577. checkDuplicatedValue();
  39578. node.children = [createInterpolation(model, model.loc)];
  39579. }
  39580. else if (node.tag === 'select') ;
  39581. else {
  39582. context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
  39583. }
  39584. return res;
  39585. }
  39586. else {
  39587. // component v-model
  39588. return transformModel(dir, node, context);
  39589. }
  39590. };
  39591. function findValueBinding(node) {
  39592. const valueBinding = findProp(node, 'value');
  39593. return valueBinding
  39594. ? valueBinding.type === 7 /* DIRECTIVE */
  39595. ? valueBinding.exp
  39596. : createSimpleExpression(valueBinding.value.content, true)
  39597. : createSimpleExpression(`null`, false);
  39598. }
  39599. const ssrTransformShow = (dir, node, context) => {
  39600. if (!dir.exp) {
  39601. context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */));
  39602. }
  39603. return {
  39604. props: [
  39605. createObjectProperty(`style`, createConditionalExpression(dir.exp, createSimpleExpression(`null`, false), createObjectExpression([
  39606. createObjectProperty(`display`, createSimpleExpression(`none`, true))
  39607. ]), false /* no newline */))
  39608. ]
  39609. };
  39610. };
  39611. const hasSingleChild = (node) => node.children.filter(n => n.type !== 3 /* COMMENT */).length === 1;
  39612. const ssrInjectFallthroughAttrs = (node, context) => {
  39613. // _attrs is provided as a function argument.
  39614. // mark it as a known identifier so that it doesn't get prefixed by
  39615. // transformExpression.
  39616. if (node.type === 0 /* ROOT */) {
  39617. context.identifiers._attrs = 1;
  39618. }
  39619. if (node.type === 1 /* ELEMENT */ &&
  39620. node.tagType === 1 /* COMPONENT */ &&
  39621. (isBuiltInType(node.tag, 'Transition') ||
  39622. isBuiltInType(node.tag, 'KeepAlive'))) {
  39623. if (hasSingleChild(node)) {
  39624. injectFallthroughAttrs(node.children[0]);
  39625. }
  39626. return;
  39627. }
  39628. const parent = context.parent;
  39629. if (!parent || parent.type !== 0 /* ROOT */) {
  39630. return;
  39631. }
  39632. if (node.type === 10 /* IF_BRANCH */ && hasSingleChild(node)) {
  39633. injectFallthroughAttrs(node.children[0]);
  39634. }
  39635. else if (hasSingleChild(parent)) {
  39636. injectFallthroughAttrs(node);
  39637. }
  39638. };
  39639. function injectFallthroughAttrs(node) {
  39640. if (node.type === 1 /* ELEMENT */ &&
  39641. (node.tagType === 0 /* ELEMENT */ ||
  39642. node.tagType === 1 /* COMPONENT */) &&
  39643. !findDir(node, 'for')) {
  39644. node.props.push({
  39645. type: 7 /* DIRECTIVE */,
  39646. name: 'bind',
  39647. arg: undefined,
  39648. exp: createSimpleExpression(`_attrs`, false),
  39649. modifiers: [],
  39650. loc: locStub
  39651. });
  39652. }
  39653. }
  39654. const ssrInjectCssVars = (node, context) => {
  39655. if (!context.ssrCssVars) {
  39656. return;
  39657. }
  39658. // _cssVars is initialized once per render function
  39659. // the code is injected in ssrCodegenTransform when creating the
  39660. // ssr transform context
  39661. if (node.type === 0 /* ROOT */) {
  39662. context.identifiers._cssVars = 1;
  39663. }
  39664. const parent = context.parent;
  39665. if (!parent || parent.type !== 0 /* ROOT */) {
  39666. return;
  39667. }
  39668. if (node.type === 10 /* IF_BRANCH */) {
  39669. for (const child of node.children) {
  39670. injectCssVars(child);
  39671. }
  39672. }
  39673. else {
  39674. injectCssVars(node);
  39675. }
  39676. };
  39677. function injectCssVars(node) {
  39678. if (node.type === 1 /* ELEMENT */ &&
  39679. (node.tagType === 0 /* ELEMENT */ ||
  39680. node.tagType === 1 /* COMPONENT */) &&
  39681. !findDir(node, 'for')) {
  39682. if (isBuiltInType(node.tag, 'Suspense')) {
  39683. for (const child of node.children) {
  39684. if (child.type === 1 /* ELEMENT */ &&
  39685. child.tagType === 3 /* TEMPLATE */) {
  39686. // suspense slot
  39687. child.children.forEach(injectCssVars);
  39688. }
  39689. else {
  39690. injectCssVars(child);
  39691. }
  39692. }
  39693. }
  39694. else {
  39695. node.props.push({
  39696. type: 7 /* DIRECTIVE */,
  39697. name: 'bind',
  39698. arg: undefined,
  39699. exp: createSimpleExpression(`_cssVars`, false),
  39700. modifiers: [],
  39701. loc: locStub
  39702. });
  39703. }
  39704. }
  39705. }
  39706. function compile$1(template, options = {}) {
  39707. options = Object.assign(Object.assign(Object.assign({}, options), parserOptions), { ssr: true, inSSR: true, scopeId: options.mode === 'function' ? null : options.scopeId,
  39708. // always prefix since compiler-ssr doesn't have size concern
  39709. prefixIdentifiers: true,
  39710. // disable optimizations that are unnecessary for ssr
  39711. cacheHandlers: false, hoistStatic: false });
  39712. const ast = baseParse(template, options);
  39713. // Save raw options for AST. This is needed when performing sub-transforms
  39714. // on slot vnode branches.
  39715. rawOptionsMap.set(ast, options);
  39716. transform(ast, Object.assign(Object.assign({}, options), { hoistStatic: false, nodeTransforms: [
  39717. ssrTransformIf,
  39718. ssrTransformFor,
  39719. trackVForSlotScopes,
  39720. transformExpression,
  39721. ssrTransformSlotOutlet,
  39722. ssrInjectFallthroughAttrs,
  39723. ssrInjectCssVars,
  39724. ssrTransformElement,
  39725. ssrTransformComponent,
  39726. trackSlotScopes,
  39727. transformStyle,
  39728. ...(options.nodeTransforms || []) // user transforms
  39729. ], directiveTransforms: Object.assign({
  39730. // reusing core v-bind
  39731. bind: transformBind,
  39732. // model and show has dedicated SSR handling
  39733. model: ssrTransformModel, show: ssrTransformShow,
  39734. // the following are ignored during SSR
  39735. on: noopDirectiveTransform, cloak: noopDirectiveTransform, once: noopDirectiveTransform }, (options.directiveTransforms || {}) // user transforms
  39736. ) }));
  39737. // traverse the template AST and convert into SSR codegen AST
  39738. // by replacing ast.codegenNode.
  39739. ssrCodegenTransform(ast, options);
  39740. return generate(ast, options);
  39741. }
  39742. var CompilerSSR = /*#__PURE__*/Object.freeze({
  39743. __proto__: null,
  39744. compile: compile$1
  39745. });
  39746. const hasWarned = {};
  39747. function warnOnce(msg) {
  39748. const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
  39749. if (!isNodeProd && !false && !hasWarned[msg]) {
  39750. hasWarned[msg] = true;
  39751. warn(msg);
  39752. }
  39753. }
  39754. function warn(msg) {
  39755. console.warn(`\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`);
  39756. }
  39757. function preprocess({ source, filename, preprocessOptions }, preprocessor) {
  39758. // Consolidate exposes a callback based API, but the callback is in fact
  39759. // called synchronously for most templating engines. In our case, we have to
  39760. // expose a synchronous API so that it is usable in Jest transforms (which
  39761. // have to be sync because they are applied via Node.js require hooks)
  39762. let res = '';
  39763. let err = null;
  39764. preprocessor.render(source, Object.assign({ filename }, preprocessOptions), (_err, _res) => {
  39765. if (_err)
  39766. err = _err;
  39767. res = _res;
  39768. });
  39769. if (err)
  39770. throw err;
  39771. return res;
  39772. }
  39773. function compileTemplate(options) {
  39774. const { preprocessLang, preprocessCustomRequire } = options;
  39775. if (preprocessLang &&
  39776. !preprocessCustomRequire) {
  39777. throw new Error(`[@vue/compiler-sfc] Template preprocessing in the browser build must ` +
  39778. `provide the \`preprocessCustomRequire\` option to return the in-browser ` +
  39779. `version of the preprocessor in the shape of { render(): string }.`);
  39780. }
  39781. const preprocessor = preprocessLang
  39782. ? preprocessCustomRequire
  39783. ? preprocessCustomRequire(preprocessLang)
  39784. : require('consolidate')[preprocessLang]
  39785. : false;
  39786. if (preprocessor) {
  39787. try {
  39788. return doCompileTemplate(Object.assign(Object.assign({}, options), { source: preprocess(options, preprocessor) }));
  39789. }
  39790. catch (e) {
  39791. return {
  39792. code: `export default function render() {}`,
  39793. source: options.source,
  39794. tips: [],
  39795. errors: [e]
  39796. };
  39797. }
  39798. }
  39799. else if (preprocessLang) {
  39800. return {
  39801. code: `export default function render() {}`,
  39802. source: options.source,
  39803. tips: [
  39804. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  39805. ],
  39806. errors: [
  39807. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  39808. ]
  39809. };
  39810. }
  39811. else {
  39812. return doCompileTemplate(options);
  39813. }
  39814. }
  39815. function doCompileTemplate({ filename, id, scoped, slotted, inMap, source, ssr = false, ssrCssVars, isProd = false, compiler = ssr ? CompilerSSR : CompilerDOM, compilerOptions = {}, transformAssetUrls }) {
  39816. const errors = [];
  39817. const warnings = [];
  39818. let nodeTransforms = [];
  39819. if (isObject(transformAssetUrls)) {
  39820. const assetOptions = normalizeOptions(transformAssetUrls);
  39821. nodeTransforms = [
  39822. createAssetUrlTransformWithOptions(assetOptions),
  39823. createSrcsetTransformWithOptions(assetOptions)
  39824. ];
  39825. }
  39826. else if (transformAssetUrls !== false) {
  39827. nodeTransforms = [transformAssetUrl, transformSrcset];
  39828. }
  39829. if (ssr && !ssrCssVars) {
  39830. warnOnce(`compileTemplate is called with \`ssr: true\` but no ` +
  39831. `corresponding \`cssVars\` option.\`.`);
  39832. }
  39833. if (!id) {
  39834. warnOnce(`compileTemplate now requires the \`id\` option.\`.`);
  39835. id = '';
  39836. }
  39837. const shortId = id.replace(/^data-v-/, '');
  39838. const longId = `data-v-${shortId}`;
  39839. let { code, ast, preamble, map } = compiler.compile(source, Object.assign(Object.assign({ mode: 'module', prefixIdentifiers: true, hoistStatic: true, cacheHandlers: true, ssrCssVars: ssr && ssrCssVars && ssrCssVars.length
  39840. ? genCssVarsFromList(ssrCssVars, shortId, isProd)
  39841. : '', scopeId: scoped ? longId : undefined, slotted }, compilerOptions), { nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []), filename, sourceMap: true, onError: e => errors.push(e), onWarn: w => warnings.push(w) }));
  39842. // inMap should be the map produced by ./parse.ts which is a simple line-only
  39843. // mapping. If it is present, we need to adjust the final map and errors to
  39844. // reflect the original line numbers.
  39845. if (inMap) {
  39846. if (map) {
  39847. map = mapLines(inMap, map);
  39848. }
  39849. if (errors.length) {
  39850. patchErrors(errors, source, inMap);
  39851. }
  39852. }
  39853. const tips = warnings.map(w => {
  39854. let msg = w.message;
  39855. if (w.loc) {
  39856. msg += `\n${generateCodeFrame(source, w.loc.start.offset, w.loc.end.offset)}`;
  39857. }
  39858. return msg;
  39859. });
  39860. return { code, ast, preamble, source, errors, tips, map };
  39861. }
  39862. function mapLines(oldMap, newMap) {
  39863. if (!oldMap)
  39864. return newMap;
  39865. if (!newMap)
  39866. return oldMap;
  39867. const oldMapConsumer = new SourceMapConsumer$1(oldMap);
  39868. const newMapConsumer = new SourceMapConsumer$1(newMap);
  39869. const mergedMapGenerator = new SourceMapGenerator$2();
  39870. newMapConsumer.eachMapping(m => {
  39871. if (m.originalLine == null) {
  39872. return;
  39873. }
  39874. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  39875. line: m.originalLine,
  39876. column: m.originalColumn
  39877. });
  39878. if (origPosInOldMap.source == null) {
  39879. return;
  39880. }
  39881. mergedMapGenerator.addMapping({
  39882. generated: {
  39883. line: m.generatedLine,
  39884. column: m.generatedColumn
  39885. },
  39886. original: {
  39887. line: origPosInOldMap.line,
  39888. // use current column, since the oldMap produced by @vue/compiler-sfc
  39889. // does not
  39890. column: m.originalColumn
  39891. },
  39892. source: origPosInOldMap.source,
  39893. name: origPosInOldMap.name
  39894. });
  39895. });
  39896. // source-map's type definition is incomplete
  39897. const generator = mergedMapGenerator;
  39898. oldMapConsumer.sources.forEach((sourceFile) => {
  39899. generator._sources.add(sourceFile);
  39900. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  39901. if (sourceContent != null) {
  39902. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  39903. }
  39904. });
  39905. generator._sourceRoot = oldMap.sourceRoot;
  39906. generator._file = oldMap.file;
  39907. return generator.toJSON();
  39908. }
  39909. function patchErrors(errors, source, inMap) {
  39910. const originalSource = inMap.sourcesContent[0];
  39911. const offset = originalSource.indexOf(source);
  39912. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  39913. errors.forEach(err => {
  39914. if (err.loc) {
  39915. err.loc.start.line += lineOffset;
  39916. err.loc.start.offset += offset;
  39917. if (err.loc.end !== err.loc.start) {
  39918. err.loc.end.line += lineOffset;
  39919. err.loc.end.offset += offset;
  39920. }
  39921. }
  39922. });
  39923. }
  39924. const env$1 = process.env;
  39925. const isDisabled = "NO_COLOR" in env$1;
  39926. const isForced = "FORCE_COLOR" in env$1;
  39927. const isWindows = process.platform === "win32";
  39928. const isCompatibleTerminal =
  39929. process.stdout != null &&
  39930. process.stdout.isTTY &&
  39931. env$1.TERM &&
  39932. env$1.TERM !== "dumb";
  39933. const isCI =
  39934. "CI" in env$1 &&
  39935. ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
  39936. let enabled =
  39937. !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
  39938. const raw = (open, close, searchRegex, replaceValue) => (s) =>
  39939. enabled
  39940. ? open +
  39941. (~(s += "").indexOf(close, 4) // skip opening \x1b[
  39942. ? s.replace(searchRegex, replaceValue)
  39943. : s) +
  39944. close
  39945. : s;
  39946. const init$1 = (open, close) => {
  39947. return raw(
  39948. `\x1b[${open}m`,
  39949. `\x1b[${close}m`,
  39950. new RegExp(`\\x1b\\[${close}m`, "g"),
  39951. `\x1b[${open}m`
  39952. )
  39953. };
  39954. var options = Object.defineProperty({}, "enabled", {
  39955. get: () => enabled,
  39956. set: (value) => (enabled = value),
  39957. });
  39958. var reset = init$1(0, 0);
  39959. var bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m");
  39960. var dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m");
  39961. var italic = init$1(3, 23);
  39962. var underline = init$1(4, 24);
  39963. var inverse = init$1(7, 27);
  39964. var hidden = init$1(8, 28);
  39965. var strikethrough = init$1(9, 29);
  39966. var black = init$1(30, 39);
  39967. var red = init$1(31, 39);
  39968. var green = init$1(32, 39);
  39969. var yellow = init$1(33, 39);
  39970. var blue = init$1(34, 39);
  39971. var magenta = init$1(35, 39);
  39972. var cyan = init$1(36, 39);
  39973. var white = init$1(37, 39);
  39974. var gray = init$1(90, 39);
  39975. var bgBlack = init$1(40, 49);
  39976. var bgRed = init$1(41, 49);
  39977. var bgGreen = init$1(42, 49);
  39978. var bgYellow = init$1(43, 49);
  39979. var bgBlue = init$1(44, 49);
  39980. var bgMagenta = init$1(45, 49);
  39981. var bgCyan = init$1(46, 49);
  39982. var bgWhite = init$1(47, 49);
  39983. var blackBright = init$1(90, 39);
  39984. var redBright = init$1(91, 39);
  39985. var greenBright = init$1(92, 39);
  39986. var yellowBright = init$1(93, 39);
  39987. var blueBright = init$1(94, 39);
  39988. var magentaBright = init$1(95, 39);
  39989. var cyanBright = init$1(96, 39);
  39990. var whiteBright = init$1(97, 39);
  39991. var bgBlackBright = init$1(100, 49);
  39992. var bgRedBright = init$1(101, 49);
  39993. var bgGreenBright = init$1(102, 49);
  39994. var bgYellowBright = init$1(103, 49);
  39995. var bgBlueBright = init$1(104, 49);
  39996. var bgMagentaBright = init$1(105, 49);
  39997. var bgCyanBright = init$1(106, 49);
  39998. var bgWhiteBright = init$1(107, 49);
  39999. var colorette = {
  40000. options: options,
  40001. reset: reset,
  40002. bold: bold,
  40003. dim: dim,
  40004. italic: italic,
  40005. underline: underline,
  40006. inverse: inverse,
  40007. hidden: hidden,
  40008. strikethrough: strikethrough,
  40009. black: black,
  40010. red: red,
  40011. green: green,
  40012. yellow: yellow,
  40013. blue: blue,
  40014. magenta: magenta,
  40015. cyan: cyan,
  40016. white: white,
  40017. gray: gray,
  40018. bgBlack: bgBlack,
  40019. bgRed: bgRed,
  40020. bgGreen: bgGreen,
  40021. bgYellow: bgYellow,
  40022. bgBlue: bgBlue,
  40023. bgMagenta: bgMagenta,
  40024. bgCyan: bgCyan,
  40025. bgWhite: bgWhite,
  40026. blackBright: blackBright,
  40027. redBright: redBright,
  40028. greenBright: greenBright,
  40029. yellowBright: yellowBright,
  40030. blueBright: blueBright,
  40031. magentaBright: magentaBright,
  40032. cyanBright: cyanBright,
  40033. whiteBright: whiteBright,
  40034. bgBlackBright: bgBlackBright,
  40035. bgRedBright: bgRedBright,
  40036. bgGreenBright: bgGreenBright,
  40037. bgYellowBright: bgYellowBright,
  40038. bgBlueBright: bgBlueBright,
  40039. bgMagentaBright: bgMagentaBright,
  40040. bgCyanBright: bgCyanBright,
  40041. bgWhiteBright: bgWhiteBright
  40042. };
  40043. const SINGLE_QUOTE = "'".charCodeAt(0);
  40044. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  40045. const BACKSLASH = '\\'.charCodeAt(0);
  40046. const SLASH = '/'.charCodeAt(0);
  40047. const NEWLINE = '\n'.charCodeAt(0);
  40048. const SPACE = ' '.charCodeAt(0);
  40049. const FEED = '\f'.charCodeAt(0);
  40050. const TAB = '\t'.charCodeAt(0);
  40051. const CR = '\r'.charCodeAt(0);
  40052. const OPEN_SQUARE = '['.charCodeAt(0);
  40053. const CLOSE_SQUARE = ']'.charCodeAt(0);
  40054. const OPEN_PARENTHESES = '('.charCodeAt(0);
  40055. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  40056. const OPEN_CURLY = '{'.charCodeAt(0);
  40057. const CLOSE_CURLY = '}'.charCodeAt(0);
  40058. const SEMICOLON = ';'.charCodeAt(0);
  40059. const ASTERISK = '*'.charCodeAt(0);
  40060. const COLON = ':'.charCodeAt(0);
  40061. const AT = '@'.charCodeAt(0);
  40062. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  40063. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  40064. const RE_BAD_BRACKET = /.[\n"'(/\\]/;
  40065. const RE_HEX_ESCAPE = /[\da-f]/i;
  40066. var tokenize = function tokenizer(input, options = {}) {
  40067. let css = input.css.valueOf();
  40068. let ignore = options.ignoreErrors;
  40069. let code, next, quote, content, escape;
  40070. let escaped, escapePos, prev, n, currentToken;
  40071. let length = css.length;
  40072. let pos = 0;
  40073. let buffer = [];
  40074. let returned = [];
  40075. function position() {
  40076. return pos
  40077. }
  40078. function unclosed(what) {
  40079. throw input.error('Unclosed ' + what, pos)
  40080. }
  40081. function endOfFile() {
  40082. return returned.length === 0 && pos >= length
  40083. }
  40084. function nextToken(opts) {
  40085. if (returned.length) return returned.pop()
  40086. if (pos >= length) return
  40087. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  40088. code = css.charCodeAt(pos);
  40089. switch (code) {
  40090. case NEWLINE:
  40091. case SPACE:
  40092. case TAB:
  40093. case CR:
  40094. case FEED: {
  40095. next = pos;
  40096. do {
  40097. next += 1;
  40098. code = css.charCodeAt(next);
  40099. } while (
  40100. code === SPACE ||
  40101. code === NEWLINE ||
  40102. code === TAB ||
  40103. code === CR ||
  40104. code === FEED
  40105. )
  40106. currentToken = ['space', css.slice(pos, next)];
  40107. pos = next - 1;
  40108. break
  40109. }
  40110. case OPEN_SQUARE:
  40111. case CLOSE_SQUARE:
  40112. case OPEN_CURLY:
  40113. case CLOSE_CURLY:
  40114. case COLON:
  40115. case SEMICOLON:
  40116. case CLOSE_PARENTHESES: {
  40117. let controlChar = String.fromCharCode(code);
  40118. currentToken = [controlChar, controlChar, pos];
  40119. break
  40120. }
  40121. case OPEN_PARENTHESES: {
  40122. prev = buffer.length ? buffer.pop()[1] : '';
  40123. n = css.charCodeAt(pos + 1);
  40124. if (
  40125. prev === 'url' &&
  40126. n !== SINGLE_QUOTE &&
  40127. n !== DOUBLE_QUOTE &&
  40128. n !== SPACE &&
  40129. n !== NEWLINE &&
  40130. n !== TAB &&
  40131. n !== FEED &&
  40132. n !== CR
  40133. ) {
  40134. next = pos;
  40135. do {
  40136. escaped = false;
  40137. next = css.indexOf(')', next + 1);
  40138. if (next === -1) {
  40139. if (ignore || ignoreUnclosed) {
  40140. next = pos;
  40141. break
  40142. } else {
  40143. unclosed('bracket');
  40144. }
  40145. }
  40146. escapePos = next;
  40147. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  40148. escapePos -= 1;
  40149. escaped = !escaped;
  40150. }
  40151. } while (escaped)
  40152. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  40153. pos = next;
  40154. } else {
  40155. next = css.indexOf(')', pos + 1);
  40156. content = css.slice(pos, next + 1);
  40157. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  40158. currentToken = ['(', '(', pos];
  40159. } else {
  40160. currentToken = ['brackets', content, pos, next];
  40161. pos = next;
  40162. }
  40163. }
  40164. break
  40165. }
  40166. case SINGLE_QUOTE:
  40167. case DOUBLE_QUOTE: {
  40168. quote = code === SINGLE_QUOTE ? "'" : '"';
  40169. next = pos;
  40170. do {
  40171. escaped = false;
  40172. next = css.indexOf(quote, next + 1);
  40173. if (next === -1) {
  40174. if (ignore || ignoreUnclosed) {
  40175. next = pos + 1;
  40176. break
  40177. } else {
  40178. unclosed('string');
  40179. }
  40180. }
  40181. escapePos = next;
  40182. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  40183. escapePos -= 1;
  40184. escaped = !escaped;
  40185. }
  40186. } while (escaped)
  40187. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  40188. pos = next;
  40189. break
  40190. }
  40191. case AT: {
  40192. RE_AT_END.lastIndex = pos + 1;
  40193. RE_AT_END.test(css);
  40194. if (RE_AT_END.lastIndex === 0) {
  40195. next = css.length - 1;
  40196. } else {
  40197. next = RE_AT_END.lastIndex - 2;
  40198. }
  40199. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  40200. pos = next;
  40201. break
  40202. }
  40203. case BACKSLASH: {
  40204. next = pos;
  40205. escape = true;
  40206. while (css.charCodeAt(next + 1) === BACKSLASH) {
  40207. next += 1;
  40208. escape = !escape;
  40209. }
  40210. code = css.charCodeAt(next + 1);
  40211. if (
  40212. escape &&
  40213. code !== SLASH &&
  40214. code !== SPACE &&
  40215. code !== NEWLINE &&
  40216. code !== TAB &&
  40217. code !== CR &&
  40218. code !== FEED
  40219. ) {
  40220. next += 1;
  40221. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  40222. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  40223. next += 1;
  40224. }
  40225. if (css.charCodeAt(next + 1) === SPACE) {
  40226. next += 1;
  40227. }
  40228. }
  40229. }
  40230. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  40231. pos = next;
  40232. break
  40233. }
  40234. default: {
  40235. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  40236. next = css.indexOf('*/', pos + 2) + 1;
  40237. if (next === 0) {
  40238. if (ignore || ignoreUnclosed) {
  40239. next = css.length;
  40240. } else {
  40241. unclosed('comment');
  40242. }
  40243. }
  40244. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  40245. pos = next;
  40246. } else {
  40247. RE_WORD_END.lastIndex = pos + 1;
  40248. RE_WORD_END.test(css);
  40249. if (RE_WORD_END.lastIndex === 0) {
  40250. next = css.length - 1;
  40251. } else {
  40252. next = RE_WORD_END.lastIndex - 2;
  40253. }
  40254. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  40255. buffer.push(currentToken);
  40256. pos = next;
  40257. }
  40258. break
  40259. }
  40260. }
  40261. pos++;
  40262. return currentToken
  40263. }
  40264. function back(token) {
  40265. returned.push(token);
  40266. }
  40267. return {
  40268. back,
  40269. nextToken,
  40270. endOfFile,
  40271. position
  40272. }
  40273. };
  40274. let { cyan: cyan$1, gray: gray$1, green: green$1, yellow: yellow$1, magenta: magenta$1 } = colorette;
  40275. let Input;
  40276. function registerInput(dependant) {
  40277. Input = dependant;
  40278. }
  40279. const HIGHLIGHT_THEME = {
  40280. 'brackets': cyan$1,
  40281. 'at-word': cyan$1,
  40282. 'comment': gray$1,
  40283. 'string': green$1,
  40284. 'class': yellow$1,
  40285. 'hash': magenta$1,
  40286. 'call': cyan$1,
  40287. '(': cyan$1,
  40288. ')': cyan$1,
  40289. '{': yellow$1,
  40290. '}': yellow$1,
  40291. '[': yellow$1,
  40292. ']': yellow$1,
  40293. ':': yellow$1,
  40294. ';': yellow$1
  40295. };
  40296. function getTokenType([type, value], processor) {
  40297. if (type === 'word') {
  40298. if (value[0] === '.') {
  40299. return 'class'
  40300. }
  40301. if (value[0] === '#') {
  40302. return 'hash'
  40303. }
  40304. }
  40305. if (!processor.endOfFile()) {
  40306. let next = processor.nextToken();
  40307. processor.back(next);
  40308. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  40309. }
  40310. return type
  40311. }
  40312. function terminalHighlight(css) {
  40313. let processor = tokenize(new Input(css), { ignoreErrors: true });
  40314. let result = '';
  40315. while (!processor.endOfFile()) {
  40316. let token = processor.nextToken();
  40317. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  40318. if (color) {
  40319. result += token[1]
  40320. .split(/\r?\n/)
  40321. .map(i => color(i))
  40322. .join('\n');
  40323. } else {
  40324. result += token[1];
  40325. }
  40326. }
  40327. return result
  40328. }
  40329. terminalHighlight.registerInput = registerInput;
  40330. var terminalHighlight_1 = terminalHighlight;
  40331. let { red: red$1, bold: bold$1, gray: gray$2, options: colorette$1 } = colorette;
  40332. class CssSyntaxError extends Error {
  40333. constructor(message, line, column, source, file, plugin) {
  40334. super(message);
  40335. this.name = 'CssSyntaxError';
  40336. this.reason = message;
  40337. if (file) {
  40338. this.file = file;
  40339. }
  40340. if (source) {
  40341. this.source = source;
  40342. }
  40343. if (plugin) {
  40344. this.plugin = plugin;
  40345. }
  40346. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  40347. this.line = line;
  40348. this.column = column;
  40349. }
  40350. this.setMessage();
  40351. if (Error.captureStackTrace) {
  40352. Error.captureStackTrace(this, CssSyntaxError);
  40353. }
  40354. }
  40355. setMessage() {
  40356. this.message = this.plugin ? this.plugin + ': ' : '';
  40357. this.message += this.file ? this.file : '<css input>';
  40358. if (typeof this.line !== 'undefined') {
  40359. this.message += ':' + this.line + ':' + this.column;
  40360. }
  40361. this.message += ': ' + this.reason;
  40362. }
  40363. showSourceCode(color) {
  40364. if (!this.source) return ''
  40365. let css = this.source;
  40366. if (color == null) color = colorette$1.enabled;
  40367. if (terminalHighlight_1) {
  40368. if (color) css = terminalHighlight_1(css);
  40369. }
  40370. let lines = css.split(/\r?\n/);
  40371. let start = Math.max(this.line - 3, 0);
  40372. let end = Math.min(this.line + 2, lines.length);
  40373. let maxWidth = String(end).length;
  40374. let mark, aside;
  40375. if (color) {
  40376. mark = text => bold$1(red$1(text));
  40377. aside = text => gray$2(text);
  40378. } else {
  40379. mark = aside = str => str;
  40380. }
  40381. return lines
  40382. .slice(start, end)
  40383. .map((line, index) => {
  40384. let number = start + 1 + index;
  40385. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  40386. if (number === this.line) {
  40387. let spacing =
  40388. aside(gutter.replace(/\d/g, ' ')) +
  40389. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  40390. return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
  40391. }
  40392. return ' ' + aside(gutter) + line
  40393. })
  40394. .join('\n')
  40395. }
  40396. toString() {
  40397. let code = this.showSourceCode();
  40398. if (code) {
  40399. code = '\n\n' + code + '\n';
  40400. }
  40401. return this.name + ': ' + this.message + code
  40402. }
  40403. }
  40404. var cssSyntaxError = CssSyntaxError;
  40405. CssSyntaxError.default = CssSyntaxError;
  40406. var isClean = Symbol('isClean');
  40407. var my = Symbol('my');
  40408. var symbols = {
  40409. isClean: isClean,
  40410. my: my
  40411. };
  40412. const DEFAULT_RAW = {
  40413. colon: ': ',
  40414. indent: ' ',
  40415. beforeDecl: '\n',
  40416. beforeRule: '\n',
  40417. beforeOpen: ' ',
  40418. beforeClose: '\n',
  40419. beforeComment: '\n',
  40420. after: '\n',
  40421. emptyBody: '',
  40422. commentLeft: ' ',
  40423. commentRight: ' ',
  40424. semicolon: false
  40425. };
  40426. function capitalize$1(str) {
  40427. return str[0].toUpperCase() + str.slice(1)
  40428. }
  40429. class Stringifier {
  40430. constructor(builder) {
  40431. this.builder = builder;
  40432. }
  40433. stringify(node, semicolon) {
  40434. /* istanbul ignore if */
  40435. if (!this[node.type]) {
  40436. throw new Error(
  40437. 'Unknown AST node type ' +
  40438. node.type +
  40439. '. ' +
  40440. 'Maybe you need to change PostCSS stringifier.'
  40441. )
  40442. }
  40443. this[node.type](node, semicolon);
  40444. }
  40445. document(node) {
  40446. this.body(node);
  40447. }
  40448. root(node) {
  40449. this.body(node);
  40450. if (node.raws.after) this.builder(node.raws.after);
  40451. }
  40452. comment(node) {
  40453. let left = this.raw(node, 'left', 'commentLeft');
  40454. let right = this.raw(node, 'right', 'commentRight');
  40455. this.builder('/*' + left + node.text + right + '*/', node);
  40456. }
  40457. decl(node, semicolon) {
  40458. let between = this.raw(node, 'between', 'colon');
  40459. let string = node.prop + between + this.rawValue(node, 'value');
  40460. if (node.important) {
  40461. string += node.raws.important || ' !important';
  40462. }
  40463. if (semicolon) string += ';';
  40464. this.builder(string, node);
  40465. }
  40466. rule(node) {
  40467. this.block(node, this.rawValue(node, 'selector'));
  40468. if (node.raws.ownSemicolon) {
  40469. this.builder(node.raws.ownSemicolon, node, 'end');
  40470. }
  40471. }
  40472. atrule(node, semicolon) {
  40473. let name = '@' + node.name;
  40474. let params = node.params ? this.rawValue(node, 'params') : '';
  40475. if (typeof node.raws.afterName !== 'undefined') {
  40476. name += node.raws.afterName;
  40477. } else if (params) {
  40478. name += ' ';
  40479. }
  40480. if (node.nodes) {
  40481. this.block(node, name + params);
  40482. } else {
  40483. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  40484. this.builder(name + params + end, node);
  40485. }
  40486. }
  40487. body(node) {
  40488. let last = node.nodes.length - 1;
  40489. while (last > 0) {
  40490. if (node.nodes[last].type !== 'comment') break
  40491. last -= 1;
  40492. }
  40493. let semicolon = this.raw(node, 'semicolon');
  40494. for (let i = 0; i < node.nodes.length; i++) {
  40495. let child = node.nodes[i];
  40496. let before = this.raw(child, 'before');
  40497. if (before) this.builder(before);
  40498. this.stringify(child, last !== i || semicolon);
  40499. }
  40500. }
  40501. block(node, start) {
  40502. let between = this.raw(node, 'between', 'beforeOpen');
  40503. this.builder(start + between + '{', node, 'start');
  40504. let after;
  40505. if (node.nodes && node.nodes.length) {
  40506. this.body(node);
  40507. after = this.raw(node, 'after');
  40508. } else {
  40509. after = this.raw(node, 'after', 'emptyBody');
  40510. }
  40511. if (after) this.builder(after);
  40512. this.builder('}', node, 'end');
  40513. }
  40514. raw(node, own, detect) {
  40515. let value;
  40516. if (!detect) detect = own;
  40517. // Already had
  40518. if (own) {
  40519. value = node.raws[own];
  40520. if (typeof value !== 'undefined') return value
  40521. }
  40522. let parent = node.parent;
  40523. if (detect === 'before') {
  40524. // Hack for first rule in CSS
  40525. if (!parent || (parent.type === 'root' && parent.first === node)) {
  40526. return ''
  40527. }
  40528. // `root` nodes in `document` should use only their own raws
  40529. if (parent && parent.type === 'document') {
  40530. return ''
  40531. }
  40532. }
  40533. // Floating child without parent
  40534. if (!parent) return DEFAULT_RAW[detect]
  40535. // Detect style by other nodes
  40536. let root = node.root();
  40537. if (!root.rawCache) root.rawCache = {};
  40538. if (typeof root.rawCache[detect] !== 'undefined') {
  40539. return root.rawCache[detect]
  40540. }
  40541. if (detect === 'before' || detect === 'after') {
  40542. return this.beforeAfter(node, detect)
  40543. } else {
  40544. let method = 'raw' + capitalize$1(detect);
  40545. if (this[method]) {
  40546. value = this[method](root, node);
  40547. } else {
  40548. root.walk(i => {
  40549. value = i.raws[own];
  40550. if (typeof value !== 'undefined') return false
  40551. });
  40552. }
  40553. }
  40554. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  40555. root.rawCache[detect] = value;
  40556. return value
  40557. }
  40558. rawSemicolon(root) {
  40559. let value;
  40560. root.walk(i => {
  40561. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  40562. value = i.raws.semicolon;
  40563. if (typeof value !== 'undefined') return false
  40564. }
  40565. });
  40566. return value
  40567. }
  40568. rawEmptyBody(root) {
  40569. let value;
  40570. root.walk(i => {
  40571. if (i.nodes && i.nodes.length === 0) {
  40572. value = i.raws.after;
  40573. if (typeof value !== 'undefined') return false
  40574. }
  40575. });
  40576. return value
  40577. }
  40578. rawIndent(root) {
  40579. if (root.raws.indent) return root.raws.indent
  40580. let value;
  40581. root.walk(i => {
  40582. let p = i.parent;
  40583. if (p && p !== root && p.parent && p.parent === root) {
  40584. if (typeof i.raws.before !== 'undefined') {
  40585. let parts = i.raws.before.split('\n');
  40586. value = parts[parts.length - 1];
  40587. value = value.replace(/\S/g, '');
  40588. return false
  40589. }
  40590. }
  40591. });
  40592. return value
  40593. }
  40594. rawBeforeComment(root, node) {
  40595. let value;
  40596. root.walkComments(i => {
  40597. if (typeof i.raws.before !== 'undefined') {
  40598. value = i.raws.before;
  40599. if (value.includes('\n')) {
  40600. value = value.replace(/[^\n]+$/, '');
  40601. }
  40602. return false
  40603. }
  40604. });
  40605. if (typeof value === 'undefined') {
  40606. value = this.raw(node, null, 'beforeDecl');
  40607. } else if (value) {
  40608. value = value.replace(/\S/g, '');
  40609. }
  40610. return value
  40611. }
  40612. rawBeforeDecl(root, node) {
  40613. let value;
  40614. root.walkDecls(i => {
  40615. if (typeof i.raws.before !== 'undefined') {
  40616. value = i.raws.before;
  40617. if (value.includes('\n')) {
  40618. value = value.replace(/[^\n]+$/, '');
  40619. }
  40620. return false
  40621. }
  40622. });
  40623. if (typeof value === 'undefined') {
  40624. value = this.raw(node, null, 'beforeRule');
  40625. } else if (value) {
  40626. value = value.replace(/\S/g, '');
  40627. }
  40628. return value
  40629. }
  40630. rawBeforeRule(root) {
  40631. let value;
  40632. root.walk(i => {
  40633. if (i.nodes && (i.parent !== root || root.first !== i)) {
  40634. if (typeof i.raws.before !== 'undefined') {
  40635. value = i.raws.before;
  40636. if (value.includes('\n')) {
  40637. value = value.replace(/[^\n]+$/, '');
  40638. }
  40639. return false
  40640. }
  40641. }
  40642. });
  40643. if (value) value = value.replace(/\S/g, '');
  40644. return value
  40645. }
  40646. rawBeforeClose(root) {
  40647. let value;
  40648. root.walk(i => {
  40649. if (i.nodes && i.nodes.length > 0) {
  40650. if (typeof i.raws.after !== 'undefined') {
  40651. value = i.raws.after;
  40652. if (value.includes('\n')) {
  40653. value = value.replace(/[^\n]+$/, '');
  40654. }
  40655. return false
  40656. }
  40657. }
  40658. });
  40659. if (value) value = value.replace(/\S/g, '');
  40660. return value
  40661. }
  40662. rawBeforeOpen(root) {
  40663. let value;
  40664. root.walk(i => {
  40665. if (i.type !== 'decl') {
  40666. value = i.raws.between;
  40667. if (typeof value !== 'undefined') return false
  40668. }
  40669. });
  40670. return value
  40671. }
  40672. rawColon(root) {
  40673. let value;
  40674. root.walkDecls(i => {
  40675. if (typeof i.raws.between !== 'undefined') {
  40676. value = i.raws.between.replace(/[^\s:]/g, '');
  40677. return false
  40678. }
  40679. });
  40680. return value
  40681. }
  40682. beforeAfter(node, detect) {
  40683. let value;
  40684. if (node.type === 'decl') {
  40685. value = this.raw(node, null, 'beforeDecl');
  40686. } else if (node.type === 'comment') {
  40687. value = this.raw(node, null, 'beforeComment');
  40688. } else if (detect === 'before') {
  40689. value = this.raw(node, null, 'beforeRule');
  40690. } else {
  40691. value = this.raw(node, null, 'beforeClose');
  40692. }
  40693. let buf = node.parent;
  40694. let depth = 0;
  40695. while (buf && buf.type !== 'root') {
  40696. depth += 1;
  40697. buf = buf.parent;
  40698. }
  40699. if (value.includes('\n')) {
  40700. let indent = this.raw(node, null, 'indent');
  40701. if (indent.length) {
  40702. for (let step = 0; step < depth; step++) value += indent;
  40703. }
  40704. }
  40705. return value
  40706. }
  40707. rawValue(node, prop) {
  40708. let value = node[prop];
  40709. let raw = node.raws[prop];
  40710. if (raw && raw.value === value) {
  40711. return raw.raw
  40712. }
  40713. return value
  40714. }
  40715. }
  40716. var stringifier = Stringifier;
  40717. function stringify$1(node, builder) {
  40718. let str = new stringifier(builder);
  40719. str.stringify(node);
  40720. }
  40721. var stringify_1 = stringify$1;
  40722. stringify$1.default = stringify$1;
  40723. let { isClean: isClean$1, my: my$1 } = symbols;
  40724. function cloneNode$1(obj, parent) {
  40725. let cloned = new obj.constructor();
  40726. for (let i in obj) {
  40727. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  40728. // istanbul ignore next
  40729. continue
  40730. }
  40731. if (i === 'proxyCache') continue
  40732. let value = obj[i];
  40733. let type = typeof value;
  40734. if (i === 'parent' && type === 'object') {
  40735. if (parent) cloned[i] = parent;
  40736. } else if (i === 'source') {
  40737. cloned[i] = value;
  40738. } else if (Array.isArray(value)) {
  40739. cloned[i] = value.map(j => cloneNode$1(j, cloned));
  40740. } else {
  40741. if (type === 'object' && value !== null) value = cloneNode$1(value);
  40742. cloned[i] = value;
  40743. }
  40744. }
  40745. return cloned
  40746. }
  40747. class Node$1 {
  40748. constructor(defaults = {}) {
  40749. this.raws = {};
  40750. this[isClean$1] = false;
  40751. this[my$1] = true;
  40752. for (let name in defaults) {
  40753. if (name === 'nodes') {
  40754. this.nodes = [];
  40755. for (let node of defaults[name]) {
  40756. if (typeof node.clone === 'function') {
  40757. this.append(node.clone());
  40758. } else {
  40759. this.append(node);
  40760. }
  40761. }
  40762. } else {
  40763. this[name] = defaults[name];
  40764. }
  40765. }
  40766. }
  40767. error(message, opts = {}) {
  40768. if (this.source) {
  40769. let pos = this.positionBy(opts);
  40770. return this.source.input.error(message, pos.line, pos.column, opts)
  40771. }
  40772. return new cssSyntaxError(message)
  40773. }
  40774. warn(result, text, opts) {
  40775. let data = { node: this };
  40776. for (let i in opts) data[i] = opts[i];
  40777. return result.warn(text, data)
  40778. }
  40779. remove() {
  40780. if (this.parent) {
  40781. this.parent.removeChild(this);
  40782. }
  40783. this.parent = undefined;
  40784. return this
  40785. }
  40786. toString(stringifier = stringify_1) {
  40787. if (stringifier.stringify) stringifier = stringifier.stringify;
  40788. let result = '';
  40789. stringifier(this, i => {
  40790. result += i;
  40791. });
  40792. return result
  40793. }
  40794. assign(overrides = {}) {
  40795. for (let name in overrides) {
  40796. this[name] = overrides[name];
  40797. }
  40798. return this
  40799. }
  40800. clone(overrides = {}) {
  40801. let cloned = cloneNode$1(this);
  40802. for (let name in overrides) {
  40803. cloned[name] = overrides[name];
  40804. }
  40805. return cloned
  40806. }
  40807. cloneBefore(overrides = {}) {
  40808. let cloned = this.clone(overrides);
  40809. this.parent.insertBefore(this, cloned);
  40810. return cloned
  40811. }
  40812. cloneAfter(overrides = {}) {
  40813. let cloned = this.clone(overrides);
  40814. this.parent.insertAfter(this, cloned);
  40815. return cloned
  40816. }
  40817. replaceWith(...nodes) {
  40818. if (this.parent) {
  40819. let bookmark = this;
  40820. let foundSelf = false;
  40821. for (let node of nodes) {
  40822. if (node === this) {
  40823. foundSelf = true;
  40824. } else if (foundSelf) {
  40825. this.parent.insertAfter(bookmark, node);
  40826. bookmark = node;
  40827. } else {
  40828. this.parent.insertBefore(bookmark, node);
  40829. }
  40830. }
  40831. if (!foundSelf) {
  40832. this.remove();
  40833. }
  40834. }
  40835. return this
  40836. }
  40837. next() {
  40838. if (!this.parent) return undefined
  40839. let index = this.parent.index(this);
  40840. return this.parent.nodes[index + 1]
  40841. }
  40842. prev() {
  40843. if (!this.parent) return undefined
  40844. let index = this.parent.index(this);
  40845. return this.parent.nodes[index - 1]
  40846. }
  40847. before(add) {
  40848. this.parent.insertBefore(this, add);
  40849. return this
  40850. }
  40851. after(add) {
  40852. this.parent.insertAfter(this, add);
  40853. return this
  40854. }
  40855. root() {
  40856. let result = this;
  40857. while (result.parent && result.parent.type !== 'document') {
  40858. result = result.parent;
  40859. }
  40860. return result
  40861. }
  40862. raw(prop, defaultType) {
  40863. let str = new stringifier();
  40864. return str.raw(this, prop, defaultType)
  40865. }
  40866. cleanRaws(keepBetween) {
  40867. delete this.raws.before;
  40868. delete this.raws.after;
  40869. if (!keepBetween) delete this.raws.between;
  40870. }
  40871. toJSON(_, inputs) {
  40872. let fixed = {};
  40873. let emitInputs = inputs == null;
  40874. inputs = inputs || new Map();
  40875. let inputsNextIndex = 0;
  40876. for (let name in this) {
  40877. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  40878. // istanbul ignore next
  40879. continue
  40880. }
  40881. if (name === 'parent' || name === 'proxyCache') continue
  40882. let value = this[name];
  40883. if (Array.isArray(value)) {
  40884. fixed[name] = value.map(i => {
  40885. if (typeof i === 'object' && i.toJSON) {
  40886. return i.toJSON(null, inputs)
  40887. } else {
  40888. return i
  40889. }
  40890. });
  40891. } else if (typeof value === 'object' && value.toJSON) {
  40892. fixed[name] = value.toJSON(null, inputs);
  40893. } else if (name === 'source') {
  40894. let inputId = inputs.get(value.input);
  40895. if (inputId == null) {
  40896. inputId = inputsNextIndex;
  40897. inputs.set(value.input, inputsNextIndex);
  40898. inputsNextIndex++;
  40899. }
  40900. fixed[name] = {
  40901. inputId,
  40902. start: value.start,
  40903. end: value.end
  40904. };
  40905. } else {
  40906. fixed[name] = value;
  40907. }
  40908. }
  40909. if (emitInputs) {
  40910. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  40911. }
  40912. return fixed
  40913. }
  40914. positionInside(index) {
  40915. let string = this.toString();
  40916. let column = this.source.start.column;
  40917. let line = this.source.start.line;
  40918. for (let i = 0; i < index; i++) {
  40919. if (string[i] === '\n') {
  40920. column = 1;
  40921. line += 1;
  40922. } else {
  40923. column += 1;
  40924. }
  40925. }
  40926. return { line, column }
  40927. }
  40928. positionBy(opts) {
  40929. let pos = this.source.start;
  40930. if (opts.index) {
  40931. pos = this.positionInside(opts.index);
  40932. } else if (opts.word) {
  40933. let index = this.toString().indexOf(opts.word);
  40934. if (index !== -1) pos = this.positionInside(index);
  40935. }
  40936. return pos
  40937. }
  40938. getProxyProcessor() {
  40939. return {
  40940. set(node, prop, value) {
  40941. if (node[prop] === value) return true
  40942. node[prop] = value;
  40943. if (
  40944. prop === 'prop' ||
  40945. prop === 'value' ||
  40946. prop === 'name' ||
  40947. prop === 'params' ||
  40948. prop === 'important' ||
  40949. prop === 'text'
  40950. ) {
  40951. node.markDirty();
  40952. }
  40953. return true
  40954. },
  40955. get(node, prop) {
  40956. if (prop === 'proxyOf') {
  40957. return node
  40958. } else if (prop === 'root') {
  40959. return () => node.root().toProxy()
  40960. } else {
  40961. return node[prop]
  40962. }
  40963. }
  40964. }
  40965. }
  40966. toProxy() {
  40967. if (!this.proxyCache) {
  40968. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  40969. }
  40970. return this.proxyCache
  40971. }
  40972. addToError(error) {
  40973. error.postcssNode = this;
  40974. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  40975. let s = this.source;
  40976. error.stack = error.stack.replace(
  40977. /\n\s{4}at /,
  40978. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  40979. );
  40980. }
  40981. return error
  40982. }
  40983. markDirty() {
  40984. if (this[isClean$1]) {
  40985. this[isClean$1] = false;
  40986. let next = this;
  40987. while ((next = next.parent)) {
  40988. next[isClean$1] = false;
  40989. }
  40990. }
  40991. }
  40992. get proxyOf() {
  40993. return this
  40994. }
  40995. }
  40996. var node_1 = Node$1;
  40997. Node$1.default = Node$1;
  40998. class Declaration extends node_1 {
  40999. constructor(defaults) {
  41000. if (
  41001. defaults &&
  41002. typeof defaults.value !== 'undefined' &&
  41003. typeof defaults.value !== 'string'
  41004. ) {
  41005. defaults = { ...defaults, value: String(defaults.value) };
  41006. }
  41007. super(defaults);
  41008. this.type = 'decl';
  41009. }
  41010. get variable() {
  41011. return this.prop.startsWith('--') || this.prop[0] === '$'
  41012. }
  41013. }
  41014. var declaration = Declaration;
  41015. Declaration.default = Declaration;
  41016. /* -*- Mode: js; js-indent-level: 2; -*- */
  41017. /*
  41018. * Copyright 2011 Mozilla Foundation and contributors
  41019. * Licensed under the New BSD license. See LICENSE or:
  41020. * http://opensource.org/licenses/BSD-3-Clause
  41021. */
  41022. var intToCharMap$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  41023. /**
  41024. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  41025. */
  41026. var encode$3 = function (number) {
  41027. if (0 <= number && number < intToCharMap$1.length) {
  41028. return intToCharMap$1[number];
  41029. }
  41030. throw new TypeError("Must be between 0 and 63: " + number);
  41031. };
  41032. /**
  41033. * Decode a single base 64 character code digit to an integer. Returns -1 on
  41034. * failure.
  41035. */
  41036. var decode$2 = function (charCode) {
  41037. var bigA = 65; // 'A'
  41038. var bigZ = 90; // 'Z'
  41039. var littleA = 97; // 'a'
  41040. var littleZ = 122; // 'z'
  41041. var zero = 48; // '0'
  41042. var nine = 57; // '9'
  41043. var plus = 43; // '+'
  41044. var slash = 47; // '/'
  41045. var littleOffset = 26;
  41046. var numberOffset = 52;
  41047. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  41048. if (bigA <= charCode && charCode <= bigZ) {
  41049. return (charCode - bigA);
  41050. }
  41051. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  41052. if (littleA <= charCode && charCode <= littleZ) {
  41053. return (charCode - littleA + littleOffset);
  41054. }
  41055. // 52 - 61: 0123456789
  41056. if (zero <= charCode && charCode <= nine) {
  41057. return (charCode - zero + numberOffset);
  41058. }
  41059. // 62: +
  41060. if (charCode == plus) {
  41061. return 62;
  41062. }
  41063. // 63: /
  41064. if (charCode == slash) {
  41065. return 63;
  41066. }
  41067. // Invalid base64 digit.
  41068. return -1;
  41069. };
  41070. var base64$1 = {
  41071. encode: encode$3,
  41072. decode: decode$2
  41073. };
  41074. /* -*- Mode: js; js-indent-level: 2; -*- */
  41075. /*
  41076. * Copyright 2011 Mozilla Foundation and contributors
  41077. * Licensed under the New BSD license. See LICENSE or:
  41078. * http://opensource.org/licenses/BSD-3-Clause
  41079. *
  41080. * Based on the Base 64 VLQ implementation in Closure Compiler:
  41081. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  41082. *
  41083. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  41084. * Redistribution and use in source and binary forms, with or without
  41085. * modification, are permitted provided that the following conditions are
  41086. * met:
  41087. *
  41088. * * Redistributions of source code must retain the above copyright
  41089. * notice, this list of conditions and the following disclaimer.
  41090. * * Redistributions in binary form must reproduce the above
  41091. * copyright notice, this list of conditions and the following
  41092. * disclaimer in the documentation and/or other materials provided
  41093. * with the distribution.
  41094. * * Neither the name of Google Inc. nor the names of its
  41095. * contributors may be used to endorse or promote products derived
  41096. * from this software without specific prior written permission.
  41097. *
  41098. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  41099. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  41100. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  41101. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  41102. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41103. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41104. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  41105. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  41106. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  41107. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  41108. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  41109. */
  41110. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  41111. // length quantities we use in the source map spec, the first bit is the sign,
  41112. // the next four bits are the actual value, and the 6th bit is the
  41113. // continuation bit. The continuation bit tells us whether there are more
  41114. // digits in this value following this digit.
  41115. //
  41116. // Continuation
  41117. // | Sign
  41118. // | |
  41119. // V V
  41120. // 101011
  41121. var VLQ_BASE_SHIFT$1 = 5;
  41122. // binary: 100000
  41123. var VLQ_BASE$1 = 1 << VLQ_BASE_SHIFT$1;
  41124. // binary: 011111
  41125. var VLQ_BASE_MASK$1 = VLQ_BASE$1 - 1;
  41126. // binary: 100000
  41127. var VLQ_CONTINUATION_BIT$1 = VLQ_BASE$1;
  41128. /**
  41129. * Converts from a two-complement value to a value where the sign bit is
  41130. * placed in the least significant bit. For example, as decimals:
  41131. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  41132. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  41133. */
  41134. function toVLQSigned$1(aValue) {
  41135. return aValue < 0
  41136. ? ((-aValue) << 1) + 1
  41137. : (aValue << 1) + 0;
  41138. }
  41139. /**
  41140. * Converts to a two-complement value from a value where the sign bit is
  41141. * placed in the least significant bit. For example, as decimals:
  41142. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  41143. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  41144. */
  41145. function fromVLQSigned$1(aValue) {
  41146. var isNegative = (aValue & 1) === 1;
  41147. var shifted = aValue >> 1;
  41148. return isNegative
  41149. ? -shifted
  41150. : shifted;
  41151. }
  41152. /**
  41153. * Returns the base 64 VLQ encoded value.
  41154. */
  41155. var encode$4 = function base64VLQ_encode(aValue) {
  41156. var encoded = "";
  41157. var digit;
  41158. var vlq = toVLQSigned$1(aValue);
  41159. do {
  41160. digit = vlq & VLQ_BASE_MASK$1;
  41161. vlq >>>= VLQ_BASE_SHIFT$1;
  41162. if (vlq > 0) {
  41163. // There are still more digits in this value, so we must make sure the
  41164. // continuation bit is marked.
  41165. digit |= VLQ_CONTINUATION_BIT$1;
  41166. }
  41167. encoded += base64$1.encode(digit);
  41168. } while (vlq > 0);
  41169. return encoded;
  41170. };
  41171. /**
  41172. * Decodes the next base 64 VLQ value from the given string and returns the
  41173. * value and the rest of the string via the out parameter.
  41174. */
  41175. var decode$3 = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  41176. var strLen = aStr.length;
  41177. var result = 0;
  41178. var shift = 0;
  41179. var continuation, digit;
  41180. do {
  41181. if (aIndex >= strLen) {
  41182. throw new Error("Expected more digits in base 64 VLQ value.");
  41183. }
  41184. digit = base64$1.decode(aStr.charCodeAt(aIndex++));
  41185. if (digit === -1) {
  41186. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  41187. }
  41188. continuation = !!(digit & VLQ_CONTINUATION_BIT$1);
  41189. digit &= VLQ_BASE_MASK$1;
  41190. result = result + (digit << shift);
  41191. shift += VLQ_BASE_SHIFT$1;
  41192. } while (continuation);
  41193. aOutParam.value = fromVLQSigned$1(result);
  41194. aOutParam.rest = aIndex;
  41195. };
  41196. var base64Vlq$1 = {
  41197. encode: encode$4,
  41198. decode: decode$3
  41199. };
  41200. /* -*- Mode: js; js-indent-level: 2; -*- */
  41201. var util$1 = createCommonjsModule(function (module, exports) {
  41202. /*
  41203. * Copyright 2011 Mozilla Foundation and contributors
  41204. * Licensed under the New BSD license. See LICENSE or:
  41205. * http://opensource.org/licenses/BSD-3-Clause
  41206. */
  41207. /**
  41208. * This is a helper function for getting values from parameter/options
  41209. * objects.
  41210. *
  41211. * @param args The object we are extracting values from
  41212. * @param name The name of the property we are getting.
  41213. * @param defaultValue An optional value to return if the property is missing
  41214. * from the object. If this is not specified and the property is missing, an
  41215. * error will be thrown.
  41216. */
  41217. function getArg(aArgs, aName, aDefaultValue) {
  41218. if (aName in aArgs) {
  41219. return aArgs[aName];
  41220. } else if (arguments.length === 3) {
  41221. return aDefaultValue;
  41222. } else {
  41223. throw new Error('"' + aName + '" is a required argument.');
  41224. }
  41225. }
  41226. exports.getArg = getArg;
  41227. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  41228. var dataUrlRegexp = /^data:.+\,.+$/;
  41229. function urlParse(aUrl) {
  41230. var match = aUrl.match(urlRegexp);
  41231. if (!match) {
  41232. return null;
  41233. }
  41234. return {
  41235. scheme: match[1],
  41236. auth: match[2],
  41237. host: match[3],
  41238. port: match[4],
  41239. path: match[5]
  41240. };
  41241. }
  41242. exports.urlParse = urlParse;
  41243. function urlGenerate(aParsedUrl) {
  41244. var url = '';
  41245. if (aParsedUrl.scheme) {
  41246. url += aParsedUrl.scheme + ':';
  41247. }
  41248. url += '//';
  41249. if (aParsedUrl.auth) {
  41250. url += aParsedUrl.auth + '@';
  41251. }
  41252. if (aParsedUrl.host) {
  41253. url += aParsedUrl.host;
  41254. }
  41255. if (aParsedUrl.port) {
  41256. url += ":" + aParsedUrl.port;
  41257. }
  41258. if (aParsedUrl.path) {
  41259. url += aParsedUrl.path;
  41260. }
  41261. return url;
  41262. }
  41263. exports.urlGenerate = urlGenerate;
  41264. var MAX_CACHED_INPUTS = 32;
  41265. /**
  41266. * Takes some function `f(input) -> result` and returns a memoized version of
  41267. * `f`.
  41268. *
  41269. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  41270. * memoization is a dumb-simple, linear least-recently-used cache.
  41271. */
  41272. function lruMemoize(f) {
  41273. var cache = [];
  41274. return function(input) {
  41275. for (var i = 0; i < cache.length; i++) {
  41276. if (cache[i].input === input) {
  41277. var temp = cache[0];
  41278. cache[0] = cache[i];
  41279. cache[i] = temp;
  41280. return cache[0].result;
  41281. }
  41282. }
  41283. var result = f(input);
  41284. cache.unshift({
  41285. input,
  41286. result,
  41287. });
  41288. if (cache.length > MAX_CACHED_INPUTS) {
  41289. cache.pop();
  41290. }
  41291. return result;
  41292. };
  41293. }
  41294. /**
  41295. * Normalizes a path, or the path portion of a URL:
  41296. *
  41297. * - Replaces consecutive slashes with one slash.
  41298. * - Removes unnecessary '.' parts.
  41299. * - Removes unnecessary '<dir>/..' parts.
  41300. *
  41301. * Based on code in the Node.js 'path' core module.
  41302. *
  41303. * @param aPath The path or url to normalize.
  41304. */
  41305. var normalize = lruMemoize(function normalize(aPath) {
  41306. var path = aPath;
  41307. var url = urlParse(aPath);
  41308. if (url) {
  41309. if (!url.path) {
  41310. return aPath;
  41311. }
  41312. path = url.path;
  41313. }
  41314. var isAbsolute = exports.isAbsolute(path);
  41315. // Split the path into parts between `/` characters. This is much faster than
  41316. // using `.split(/\/+/g)`.
  41317. var parts = [];
  41318. var start = 0;
  41319. var i = 0;
  41320. while (true) {
  41321. start = i;
  41322. i = path.indexOf("/", start);
  41323. if (i === -1) {
  41324. parts.push(path.slice(start));
  41325. break;
  41326. } else {
  41327. parts.push(path.slice(start, i));
  41328. while (i < path.length && path[i] === "/") {
  41329. i++;
  41330. }
  41331. }
  41332. }
  41333. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  41334. part = parts[i];
  41335. if (part === '.') {
  41336. parts.splice(i, 1);
  41337. } else if (part === '..') {
  41338. up++;
  41339. } else if (up > 0) {
  41340. if (part === '') {
  41341. // The first part is blank if the path is absolute. Trying to go
  41342. // above the root is a no-op. Therefore we can remove all '..' parts
  41343. // directly after the root.
  41344. parts.splice(i + 1, up);
  41345. up = 0;
  41346. } else {
  41347. parts.splice(i, 2);
  41348. up--;
  41349. }
  41350. }
  41351. }
  41352. path = parts.join('/');
  41353. if (path === '') {
  41354. path = isAbsolute ? '/' : '.';
  41355. }
  41356. if (url) {
  41357. url.path = path;
  41358. return urlGenerate(url);
  41359. }
  41360. return path;
  41361. });
  41362. exports.normalize = normalize;
  41363. /**
  41364. * Joins two paths/URLs.
  41365. *
  41366. * @param aRoot The root path or URL.
  41367. * @param aPath The path or URL to be joined with the root.
  41368. *
  41369. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  41370. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  41371. * first.
  41372. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  41373. * is updated with the result and aRoot is returned. Otherwise the result
  41374. * is returned.
  41375. * - If aPath is absolute, the result is aPath.
  41376. * - Otherwise the two paths are joined with a slash.
  41377. * - Joining for example 'http://' and 'www.example.com' is also supported.
  41378. */
  41379. function join(aRoot, aPath) {
  41380. if (aRoot === "") {
  41381. aRoot = ".";
  41382. }
  41383. if (aPath === "") {
  41384. aPath = ".";
  41385. }
  41386. var aPathUrl = urlParse(aPath);
  41387. var aRootUrl = urlParse(aRoot);
  41388. if (aRootUrl) {
  41389. aRoot = aRootUrl.path || '/';
  41390. }
  41391. // `join(foo, '//www.example.org')`
  41392. if (aPathUrl && !aPathUrl.scheme) {
  41393. if (aRootUrl) {
  41394. aPathUrl.scheme = aRootUrl.scheme;
  41395. }
  41396. return urlGenerate(aPathUrl);
  41397. }
  41398. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  41399. return aPath;
  41400. }
  41401. // `join('http://', 'www.example.com')`
  41402. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  41403. aRootUrl.host = aPath;
  41404. return urlGenerate(aRootUrl);
  41405. }
  41406. var joined = aPath.charAt(0) === '/'
  41407. ? aPath
  41408. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  41409. if (aRootUrl) {
  41410. aRootUrl.path = joined;
  41411. return urlGenerate(aRootUrl);
  41412. }
  41413. return joined;
  41414. }
  41415. exports.join = join;
  41416. exports.isAbsolute = function (aPath) {
  41417. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  41418. };
  41419. /**
  41420. * Make a path relative to a URL or another path.
  41421. *
  41422. * @param aRoot The root path or URL.
  41423. * @param aPath The path or URL to be made relative to aRoot.
  41424. */
  41425. function relative(aRoot, aPath) {
  41426. if (aRoot === "") {
  41427. aRoot = ".";
  41428. }
  41429. aRoot = aRoot.replace(/\/$/, '');
  41430. // It is possible for the path to be above the root. In this case, simply
  41431. // checking whether the root is a prefix of the path won't work. Instead, we
  41432. // need to remove components from the root one by one, until either we find
  41433. // a prefix that fits, or we run out of components to remove.
  41434. var level = 0;
  41435. while (aPath.indexOf(aRoot + '/') !== 0) {
  41436. var index = aRoot.lastIndexOf("/");
  41437. if (index < 0) {
  41438. return aPath;
  41439. }
  41440. // If the only part of the root that is left is the scheme (i.e. http://,
  41441. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  41442. // have exhausted all components, so the path is not relative to the root.
  41443. aRoot = aRoot.slice(0, index);
  41444. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  41445. return aPath;
  41446. }
  41447. ++level;
  41448. }
  41449. // Make sure we add a "../" for each component we removed from the root.
  41450. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  41451. }
  41452. exports.relative = relative;
  41453. var supportsNullProto = (function () {
  41454. var obj = Object.create(null);
  41455. return !('__proto__' in obj);
  41456. }());
  41457. function identity (s) {
  41458. return s;
  41459. }
  41460. /**
  41461. * Because behavior goes wacky when you set `__proto__` on objects, we
  41462. * have to prefix all the strings in our set with an arbitrary character.
  41463. *
  41464. * See https://github.com/mozilla/source-map/pull/31 and
  41465. * https://github.com/mozilla/source-map/issues/30
  41466. *
  41467. * @param String aStr
  41468. */
  41469. function toSetString(aStr) {
  41470. if (isProtoString(aStr)) {
  41471. return '$' + aStr;
  41472. }
  41473. return aStr;
  41474. }
  41475. exports.toSetString = supportsNullProto ? identity : toSetString;
  41476. function fromSetString(aStr) {
  41477. if (isProtoString(aStr)) {
  41478. return aStr.slice(1);
  41479. }
  41480. return aStr;
  41481. }
  41482. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  41483. function isProtoString(s) {
  41484. if (!s) {
  41485. return false;
  41486. }
  41487. var length = s.length;
  41488. if (length < 9 /* "__proto__".length */) {
  41489. return false;
  41490. }
  41491. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  41492. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  41493. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  41494. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  41495. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  41496. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  41497. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  41498. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  41499. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  41500. return false;
  41501. }
  41502. for (var i = length - 10; i >= 0; i--) {
  41503. if (s.charCodeAt(i) !== 36 /* '$' */) {
  41504. return false;
  41505. }
  41506. }
  41507. return true;
  41508. }
  41509. /**
  41510. * Comparator between two mappings where the original positions are compared.
  41511. *
  41512. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  41513. * mappings with the same original source/line/column, but different generated
  41514. * line and column the same. Useful when searching for a mapping with a
  41515. * stubbed out mapping.
  41516. */
  41517. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  41518. var cmp = strcmp(mappingA.source, mappingB.source);
  41519. if (cmp !== 0) {
  41520. return cmp;
  41521. }
  41522. cmp = mappingA.originalLine - mappingB.originalLine;
  41523. if (cmp !== 0) {
  41524. return cmp;
  41525. }
  41526. cmp = mappingA.originalColumn - mappingB.originalColumn;
  41527. if (cmp !== 0 || onlyCompareOriginal) {
  41528. return cmp;
  41529. }
  41530. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  41531. if (cmp !== 0) {
  41532. return cmp;
  41533. }
  41534. cmp = mappingA.generatedLine - mappingB.generatedLine;
  41535. if (cmp !== 0) {
  41536. return cmp;
  41537. }
  41538. return strcmp(mappingA.name, mappingB.name);
  41539. }
  41540. exports.compareByOriginalPositions = compareByOriginalPositions;
  41541. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  41542. var cmp;
  41543. cmp = mappingA.originalLine - mappingB.originalLine;
  41544. if (cmp !== 0) {
  41545. return cmp;
  41546. }
  41547. cmp = mappingA.originalColumn - mappingB.originalColumn;
  41548. if (cmp !== 0 || onlyCompareOriginal) {
  41549. return cmp;
  41550. }
  41551. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  41552. if (cmp !== 0) {
  41553. return cmp;
  41554. }
  41555. cmp = mappingA.generatedLine - mappingB.generatedLine;
  41556. if (cmp !== 0) {
  41557. return cmp;
  41558. }
  41559. return strcmp(mappingA.name, mappingB.name);
  41560. }
  41561. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  41562. /**
  41563. * Comparator between two mappings with deflated source and name indices where
  41564. * the generated positions are compared.
  41565. *
  41566. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  41567. * mappings with the same generated line and column, but different
  41568. * source/name/original line and column the same. Useful when searching for a
  41569. * mapping with a stubbed out mapping.
  41570. */
  41571. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  41572. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  41573. if (cmp !== 0) {
  41574. return cmp;
  41575. }
  41576. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  41577. if (cmp !== 0 || onlyCompareGenerated) {
  41578. return cmp;
  41579. }
  41580. cmp = strcmp(mappingA.source, mappingB.source);
  41581. if (cmp !== 0) {
  41582. return cmp;
  41583. }
  41584. cmp = mappingA.originalLine - mappingB.originalLine;
  41585. if (cmp !== 0) {
  41586. return cmp;
  41587. }
  41588. cmp = mappingA.originalColumn - mappingB.originalColumn;
  41589. if (cmp !== 0) {
  41590. return cmp;
  41591. }
  41592. return strcmp(mappingA.name, mappingB.name);
  41593. }
  41594. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  41595. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  41596. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  41597. if (cmp !== 0 || onlyCompareGenerated) {
  41598. return cmp;
  41599. }
  41600. cmp = strcmp(mappingA.source, mappingB.source);
  41601. if (cmp !== 0) {
  41602. return cmp;
  41603. }
  41604. cmp = mappingA.originalLine - mappingB.originalLine;
  41605. if (cmp !== 0) {
  41606. return cmp;
  41607. }
  41608. cmp = mappingA.originalColumn - mappingB.originalColumn;
  41609. if (cmp !== 0) {
  41610. return cmp;
  41611. }
  41612. return strcmp(mappingA.name, mappingB.name);
  41613. }
  41614. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  41615. function strcmp(aStr1, aStr2) {
  41616. if (aStr1 === aStr2) {
  41617. return 0;
  41618. }
  41619. if (aStr1 === null) {
  41620. return 1; // aStr2 !== null
  41621. }
  41622. if (aStr2 === null) {
  41623. return -1; // aStr1 !== null
  41624. }
  41625. if (aStr1 > aStr2) {
  41626. return 1;
  41627. }
  41628. return -1;
  41629. }
  41630. /**
  41631. * Comparator between two mappings with inflated source and name strings where
  41632. * the generated positions are compared.
  41633. */
  41634. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  41635. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  41636. if (cmp !== 0) {
  41637. return cmp;
  41638. }
  41639. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  41640. if (cmp !== 0) {
  41641. return cmp;
  41642. }
  41643. cmp = strcmp(mappingA.source, mappingB.source);
  41644. if (cmp !== 0) {
  41645. return cmp;
  41646. }
  41647. cmp = mappingA.originalLine - mappingB.originalLine;
  41648. if (cmp !== 0) {
  41649. return cmp;
  41650. }
  41651. cmp = mappingA.originalColumn - mappingB.originalColumn;
  41652. if (cmp !== 0) {
  41653. return cmp;
  41654. }
  41655. return strcmp(mappingA.name, mappingB.name);
  41656. }
  41657. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  41658. /**
  41659. * Strip any JSON XSSI avoidance prefix from the string (as documented
  41660. * in the source maps specification), and then parse the string as
  41661. * JSON.
  41662. */
  41663. function parseSourceMapInput(str) {
  41664. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  41665. }
  41666. exports.parseSourceMapInput = parseSourceMapInput;
  41667. /**
  41668. * Compute the URL of a source given the the source root, the source's
  41669. * URL, and the source map's URL.
  41670. */
  41671. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  41672. sourceURL = sourceURL || '';
  41673. if (sourceRoot) {
  41674. // This follows what Chrome does.
  41675. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  41676. sourceRoot += '/';
  41677. }
  41678. // The spec says:
  41679. // Line 4: An optional source root, useful for relocating source
  41680. // files on a server or removing repeated values in the
  41681. // “sources” entry. This value is prepended to the individual
  41682. // entries in the “source” field.
  41683. sourceURL = sourceRoot + sourceURL;
  41684. }
  41685. // Historically, SourceMapConsumer did not take the sourceMapURL as
  41686. // a parameter. This mode is still somewhat supported, which is why
  41687. // this code block is conditional. However, it's preferable to pass
  41688. // the source map URL to SourceMapConsumer, so that this function
  41689. // can implement the source URL resolution algorithm as outlined in
  41690. // the spec. This block is basically the equivalent of:
  41691. // new URL(sourceURL, sourceMapURL).toString()
  41692. // ... except it avoids using URL, which wasn't available in the
  41693. // older releases of node still supported by this library.
  41694. //
  41695. // The spec says:
  41696. // If the sources are not absolute URLs after prepending of the
  41697. // “sourceRoot”, the sources are resolved relative to the
  41698. // SourceMap (like resolving script src in a html document).
  41699. if (sourceMapURL) {
  41700. var parsed = urlParse(sourceMapURL);
  41701. if (!parsed) {
  41702. throw new Error("sourceMapURL could not be parsed");
  41703. }
  41704. if (parsed.path) {
  41705. // Strip the last path component, but keep the "/".
  41706. var index = parsed.path.lastIndexOf('/');
  41707. if (index >= 0) {
  41708. parsed.path = parsed.path.substring(0, index + 1);
  41709. }
  41710. }
  41711. sourceURL = join(urlGenerate(parsed), sourceURL);
  41712. }
  41713. return normalize(sourceURL);
  41714. }
  41715. exports.computeSourceURL = computeSourceURL;
  41716. });
  41717. /* -*- Mode: js; js-indent-level: 2; -*- */
  41718. /*
  41719. * Copyright 2011 Mozilla Foundation and contributors
  41720. * Licensed under the New BSD license. See LICENSE or:
  41721. * http://opensource.org/licenses/BSD-3-Clause
  41722. */
  41723. var has$2 = Object.prototype.hasOwnProperty;
  41724. var hasNativeMap$1 = typeof Map !== "undefined";
  41725. /**
  41726. * A data structure which is a combination of an array and a set. Adding a new
  41727. * member is O(1), testing for membership is O(1), and finding the index of an
  41728. * element is O(1). Removing elements from the set is not supported. Only
  41729. * strings are supported for membership.
  41730. */
  41731. function ArraySet$3() {
  41732. this._array = [];
  41733. this._set = hasNativeMap$1 ? new Map() : Object.create(null);
  41734. }
  41735. /**
  41736. * Static method for creating ArraySet instances from an existing array.
  41737. */
  41738. ArraySet$3.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  41739. var set = new ArraySet$3();
  41740. for (var i = 0, len = aArray.length; i < len; i++) {
  41741. set.add(aArray[i], aAllowDuplicates);
  41742. }
  41743. return set;
  41744. };
  41745. /**
  41746. * Return how many unique items are in this ArraySet. If duplicates have been
  41747. * added, than those do not count towards the size.
  41748. *
  41749. * @returns Number
  41750. */
  41751. ArraySet$3.prototype.size = function ArraySet_size() {
  41752. return hasNativeMap$1 ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  41753. };
  41754. /**
  41755. * Add the given string to this set.
  41756. *
  41757. * @param String aStr
  41758. */
  41759. ArraySet$3.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  41760. var sStr = hasNativeMap$1 ? aStr : util$1.toSetString(aStr);
  41761. var isDuplicate = hasNativeMap$1 ? this.has(aStr) : has$2.call(this._set, sStr);
  41762. var idx = this._array.length;
  41763. if (!isDuplicate || aAllowDuplicates) {
  41764. this._array.push(aStr);
  41765. }
  41766. if (!isDuplicate) {
  41767. if (hasNativeMap$1) {
  41768. this._set.set(aStr, idx);
  41769. } else {
  41770. this._set[sStr] = idx;
  41771. }
  41772. }
  41773. };
  41774. /**
  41775. * Is the given string a member of this set?
  41776. *
  41777. * @param String aStr
  41778. */
  41779. ArraySet$3.prototype.has = function ArraySet_has(aStr) {
  41780. if (hasNativeMap$1) {
  41781. return this._set.has(aStr);
  41782. } else {
  41783. var sStr = util$1.toSetString(aStr);
  41784. return has$2.call(this._set, sStr);
  41785. }
  41786. };
  41787. /**
  41788. * What is the index of the given string in the array?
  41789. *
  41790. * @param String aStr
  41791. */
  41792. ArraySet$3.prototype.indexOf = function ArraySet_indexOf(aStr) {
  41793. if (hasNativeMap$1) {
  41794. var idx = this._set.get(aStr);
  41795. if (idx >= 0) {
  41796. return idx;
  41797. }
  41798. } else {
  41799. var sStr = util$1.toSetString(aStr);
  41800. if (has$2.call(this._set, sStr)) {
  41801. return this._set[sStr];
  41802. }
  41803. }
  41804. throw new Error('"' + aStr + '" is not in the set.');
  41805. };
  41806. /**
  41807. * What is the element at the given index?
  41808. *
  41809. * @param Number aIdx
  41810. */
  41811. ArraySet$3.prototype.at = function ArraySet_at(aIdx) {
  41812. if (aIdx >= 0 && aIdx < this._array.length) {
  41813. return this._array[aIdx];
  41814. }
  41815. throw new Error('No element indexed by ' + aIdx);
  41816. };
  41817. /**
  41818. * Returns the array representation of this set (which has the proper indices
  41819. * indicated by indexOf). Note that this is a copy of the internal array used
  41820. * for storing the members so that no one can mess with internal state.
  41821. */
  41822. ArraySet$3.prototype.toArray = function ArraySet_toArray() {
  41823. return this._array.slice();
  41824. };
  41825. var ArraySet_1$1 = ArraySet$3;
  41826. var arraySet$1 = {
  41827. ArraySet: ArraySet_1$1
  41828. };
  41829. /* -*- Mode: js; js-indent-level: 2; -*- */
  41830. /*
  41831. * Copyright 2014 Mozilla Foundation and contributors
  41832. * Licensed under the New BSD license. See LICENSE or:
  41833. * http://opensource.org/licenses/BSD-3-Clause
  41834. */
  41835. /**
  41836. * Determine whether mappingB is after mappingA with respect to generated
  41837. * position.
  41838. */
  41839. function generatedPositionAfter$1(mappingA, mappingB) {
  41840. // Optimized for most common case
  41841. var lineA = mappingA.generatedLine;
  41842. var lineB = mappingB.generatedLine;
  41843. var columnA = mappingA.generatedColumn;
  41844. var columnB = mappingB.generatedColumn;
  41845. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  41846. util$1.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  41847. }
  41848. /**
  41849. * A data structure to provide a sorted view of accumulated mappings in a
  41850. * performance conscious manner. It trades a neglibable overhead in general
  41851. * case for a large speedup in case of mappings being added in order.
  41852. */
  41853. function MappingList$2() {
  41854. this._array = [];
  41855. this._sorted = true;
  41856. // Serves as infimum
  41857. this._last = {generatedLine: -1, generatedColumn: 0};
  41858. }
  41859. /**
  41860. * Iterate through internal items. This method takes the same arguments that
  41861. * `Array.prototype.forEach` takes.
  41862. *
  41863. * NOTE: The order of the mappings is NOT guaranteed.
  41864. */
  41865. MappingList$2.prototype.unsortedForEach =
  41866. function MappingList_forEach(aCallback, aThisArg) {
  41867. this._array.forEach(aCallback, aThisArg);
  41868. };
  41869. /**
  41870. * Add the given source mapping.
  41871. *
  41872. * @param Object aMapping
  41873. */
  41874. MappingList$2.prototype.add = function MappingList_add(aMapping) {
  41875. if (generatedPositionAfter$1(this._last, aMapping)) {
  41876. this._last = aMapping;
  41877. this._array.push(aMapping);
  41878. } else {
  41879. this._sorted = false;
  41880. this._array.push(aMapping);
  41881. }
  41882. };
  41883. /**
  41884. * Returns the flat, sorted array of mappings. The mappings are sorted by
  41885. * generated position.
  41886. *
  41887. * WARNING: This method returns internal data without copying, for
  41888. * performance. The return value must NOT be mutated, and should be treated as
  41889. * an immutable borrow. If you want to take ownership, you must make your own
  41890. * copy.
  41891. */
  41892. MappingList$2.prototype.toArray = function MappingList_toArray() {
  41893. if (!this._sorted) {
  41894. this._array.sort(util$1.compareByGeneratedPositionsInflated);
  41895. this._sorted = true;
  41896. }
  41897. return this._array;
  41898. };
  41899. var MappingList_1$1 = MappingList$2;
  41900. var mappingList$1 = {
  41901. MappingList: MappingList_1$1
  41902. };
  41903. /* -*- Mode: js; js-indent-level: 2; -*- */
  41904. /*
  41905. * Copyright 2011 Mozilla Foundation and contributors
  41906. * Licensed under the New BSD license. See LICENSE or:
  41907. * http://opensource.org/licenses/BSD-3-Clause
  41908. */
  41909. var ArraySet$4 = arraySet$1.ArraySet;
  41910. var MappingList$3 = mappingList$1.MappingList;
  41911. /**
  41912. * An instance of the SourceMapGenerator represents a source map which is
  41913. * being built incrementally. You may pass an object with the following
  41914. * properties:
  41915. *
  41916. * - file: The filename of the generated source.
  41917. * - sourceRoot: A root for all relative URLs in this source map.
  41918. */
  41919. function SourceMapGenerator$3(aArgs) {
  41920. if (!aArgs) {
  41921. aArgs = {};
  41922. }
  41923. this._file = util$1.getArg(aArgs, 'file', null);
  41924. this._sourceRoot = util$1.getArg(aArgs, 'sourceRoot', null);
  41925. this._skipValidation = util$1.getArg(aArgs, 'skipValidation', false);
  41926. this._sources = new ArraySet$4();
  41927. this._names = new ArraySet$4();
  41928. this._mappings = new MappingList$3();
  41929. this._sourcesContents = null;
  41930. }
  41931. SourceMapGenerator$3.prototype._version = 3;
  41932. /**
  41933. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  41934. *
  41935. * @param aSourceMapConsumer The SourceMap.
  41936. */
  41937. SourceMapGenerator$3.fromSourceMap =
  41938. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  41939. var sourceRoot = aSourceMapConsumer.sourceRoot;
  41940. var generator = new SourceMapGenerator$3({
  41941. file: aSourceMapConsumer.file,
  41942. sourceRoot: sourceRoot
  41943. });
  41944. aSourceMapConsumer.eachMapping(function (mapping) {
  41945. var newMapping = {
  41946. generated: {
  41947. line: mapping.generatedLine,
  41948. column: mapping.generatedColumn
  41949. }
  41950. };
  41951. if (mapping.source != null) {
  41952. newMapping.source = mapping.source;
  41953. if (sourceRoot != null) {
  41954. newMapping.source = util$1.relative(sourceRoot, newMapping.source);
  41955. }
  41956. newMapping.original = {
  41957. line: mapping.originalLine,
  41958. column: mapping.originalColumn
  41959. };
  41960. if (mapping.name != null) {
  41961. newMapping.name = mapping.name;
  41962. }
  41963. }
  41964. generator.addMapping(newMapping);
  41965. });
  41966. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  41967. var sourceRelative = sourceFile;
  41968. if (sourceRoot !== null) {
  41969. sourceRelative = util$1.relative(sourceRoot, sourceFile);
  41970. }
  41971. if (!generator._sources.has(sourceRelative)) {
  41972. generator._sources.add(sourceRelative);
  41973. }
  41974. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  41975. if (content != null) {
  41976. generator.setSourceContent(sourceFile, content);
  41977. }
  41978. });
  41979. return generator;
  41980. };
  41981. /**
  41982. * Add a single mapping from original source line and column to the generated
  41983. * source's line and column for this source map being created. The mapping
  41984. * object should have the following properties:
  41985. *
  41986. * - generated: An object with the generated line and column positions.
  41987. * - original: An object with the original line and column positions.
  41988. * - source: The original source file (relative to the sourceRoot).
  41989. * - name: An optional original token name for this mapping.
  41990. */
  41991. SourceMapGenerator$3.prototype.addMapping =
  41992. function SourceMapGenerator_addMapping(aArgs) {
  41993. var generated = util$1.getArg(aArgs, 'generated');
  41994. var original = util$1.getArg(aArgs, 'original', null);
  41995. var source = util$1.getArg(aArgs, 'source', null);
  41996. var name = util$1.getArg(aArgs, 'name', null);
  41997. if (!this._skipValidation) {
  41998. this._validateMapping(generated, original, source, name);
  41999. }
  42000. if (source != null) {
  42001. source = String(source);
  42002. if (!this._sources.has(source)) {
  42003. this._sources.add(source);
  42004. }
  42005. }
  42006. if (name != null) {
  42007. name = String(name);
  42008. if (!this._names.has(name)) {
  42009. this._names.add(name);
  42010. }
  42011. }
  42012. this._mappings.add({
  42013. generatedLine: generated.line,
  42014. generatedColumn: generated.column,
  42015. originalLine: original != null && original.line,
  42016. originalColumn: original != null && original.column,
  42017. source: source,
  42018. name: name
  42019. });
  42020. };
  42021. /**
  42022. * Set the source content for a source file.
  42023. */
  42024. SourceMapGenerator$3.prototype.setSourceContent =
  42025. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  42026. var source = aSourceFile;
  42027. if (this._sourceRoot != null) {
  42028. source = util$1.relative(this._sourceRoot, source);
  42029. }
  42030. if (aSourceContent != null) {
  42031. // Add the source content to the _sourcesContents map.
  42032. // Create a new _sourcesContents map if the property is null.
  42033. if (!this._sourcesContents) {
  42034. this._sourcesContents = Object.create(null);
  42035. }
  42036. this._sourcesContents[util$1.toSetString(source)] = aSourceContent;
  42037. } else if (this._sourcesContents) {
  42038. // Remove the source file from the _sourcesContents map.
  42039. // If the _sourcesContents map is empty, set the property to null.
  42040. delete this._sourcesContents[util$1.toSetString(source)];
  42041. if (Object.keys(this._sourcesContents).length === 0) {
  42042. this._sourcesContents = null;
  42043. }
  42044. }
  42045. };
  42046. /**
  42047. * Applies the mappings of a sub-source-map for a specific source file to the
  42048. * source map being generated. Each mapping to the supplied source file is
  42049. * rewritten using the supplied source map. Note: The resolution for the
  42050. * resulting mappings is the minimium of this map and the supplied map.
  42051. *
  42052. * @param aSourceMapConsumer The source map to be applied.
  42053. * @param aSourceFile Optional. The filename of the source file.
  42054. * If omitted, SourceMapConsumer's file property will be used.
  42055. * @param aSourceMapPath Optional. The dirname of the path to the source map
  42056. * to be applied. If relative, it is relative to the SourceMapConsumer.
  42057. * This parameter is needed when the two source maps aren't in the same
  42058. * directory, and the source map to be applied contains relative source
  42059. * paths. If so, those relative source paths need to be rewritten
  42060. * relative to the SourceMapGenerator.
  42061. */
  42062. SourceMapGenerator$3.prototype.applySourceMap =
  42063. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  42064. var sourceFile = aSourceFile;
  42065. // If aSourceFile is omitted, we will use the file property of the SourceMap
  42066. if (aSourceFile == null) {
  42067. if (aSourceMapConsumer.file == null) {
  42068. throw new Error(
  42069. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  42070. 'or the source map\'s "file" property. Both were omitted.'
  42071. );
  42072. }
  42073. sourceFile = aSourceMapConsumer.file;
  42074. }
  42075. var sourceRoot = this._sourceRoot;
  42076. // Make "sourceFile" relative if an absolute Url is passed.
  42077. if (sourceRoot != null) {
  42078. sourceFile = util$1.relative(sourceRoot, sourceFile);
  42079. }
  42080. // Applying the SourceMap can add and remove items from the sources and
  42081. // the names array.
  42082. var newSources = new ArraySet$4();
  42083. var newNames = new ArraySet$4();
  42084. // Find mappings for the "sourceFile"
  42085. this._mappings.unsortedForEach(function (mapping) {
  42086. if (mapping.source === sourceFile && mapping.originalLine != null) {
  42087. // Check if it can be mapped by the source map, then update the mapping.
  42088. var original = aSourceMapConsumer.originalPositionFor({
  42089. line: mapping.originalLine,
  42090. column: mapping.originalColumn
  42091. });
  42092. if (original.source != null) {
  42093. // Copy mapping
  42094. mapping.source = original.source;
  42095. if (aSourceMapPath != null) {
  42096. mapping.source = util$1.join(aSourceMapPath, mapping.source);
  42097. }
  42098. if (sourceRoot != null) {
  42099. mapping.source = util$1.relative(sourceRoot, mapping.source);
  42100. }
  42101. mapping.originalLine = original.line;
  42102. mapping.originalColumn = original.column;
  42103. if (original.name != null) {
  42104. mapping.name = original.name;
  42105. }
  42106. }
  42107. }
  42108. var source = mapping.source;
  42109. if (source != null && !newSources.has(source)) {
  42110. newSources.add(source);
  42111. }
  42112. var name = mapping.name;
  42113. if (name != null && !newNames.has(name)) {
  42114. newNames.add(name);
  42115. }
  42116. }, this);
  42117. this._sources = newSources;
  42118. this._names = newNames;
  42119. // Copy sourcesContents of applied map.
  42120. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  42121. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  42122. if (content != null) {
  42123. if (aSourceMapPath != null) {
  42124. sourceFile = util$1.join(aSourceMapPath, sourceFile);
  42125. }
  42126. if (sourceRoot != null) {
  42127. sourceFile = util$1.relative(sourceRoot, sourceFile);
  42128. }
  42129. this.setSourceContent(sourceFile, content);
  42130. }
  42131. }, this);
  42132. };
  42133. /**
  42134. * A mapping can have one of the three levels of data:
  42135. *
  42136. * 1. Just the generated position.
  42137. * 2. The Generated position, original position, and original source.
  42138. * 3. Generated and original position, original source, as well as a name
  42139. * token.
  42140. *
  42141. * To maintain consistency, we validate that any new mapping being added falls
  42142. * in to one of these categories.
  42143. */
  42144. SourceMapGenerator$3.prototype._validateMapping =
  42145. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  42146. aName) {
  42147. // When aOriginal is truthy but has empty values for .line and .column,
  42148. // it is most likely a programmer error. In this case we throw a very
  42149. // specific error message to try to guide them the right way.
  42150. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  42151. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  42152. throw new Error(
  42153. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  42154. 'the original mapping entirely and only map the generated position. If so, pass ' +
  42155. 'null for the original mapping instead of an object with empty or null values.'
  42156. );
  42157. }
  42158. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  42159. && aGenerated.line > 0 && aGenerated.column >= 0
  42160. && !aOriginal && !aSource && !aName) {
  42161. // Case 1.
  42162. return;
  42163. }
  42164. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  42165. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  42166. && aGenerated.line > 0 && aGenerated.column >= 0
  42167. && aOriginal.line > 0 && aOriginal.column >= 0
  42168. && aSource) {
  42169. // Cases 2 and 3.
  42170. return;
  42171. }
  42172. else {
  42173. throw new Error('Invalid mapping: ' + JSON.stringify({
  42174. generated: aGenerated,
  42175. source: aSource,
  42176. original: aOriginal,
  42177. name: aName
  42178. }));
  42179. }
  42180. };
  42181. /**
  42182. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  42183. * specified by the source map format.
  42184. */
  42185. SourceMapGenerator$3.prototype._serializeMappings =
  42186. function SourceMapGenerator_serializeMappings() {
  42187. var previousGeneratedColumn = 0;
  42188. var previousGeneratedLine = 1;
  42189. var previousOriginalColumn = 0;
  42190. var previousOriginalLine = 0;
  42191. var previousName = 0;
  42192. var previousSource = 0;
  42193. var result = '';
  42194. var next;
  42195. var mapping;
  42196. var nameIdx;
  42197. var sourceIdx;
  42198. var mappings = this._mappings.toArray();
  42199. for (var i = 0, len = mappings.length; i < len; i++) {
  42200. mapping = mappings[i];
  42201. next = '';
  42202. if (mapping.generatedLine !== previousGeneratedLine) {
  42203. previousGeneratedColumn = 0;
  42204. while (mapping.generatedLine !== previousGeneratedLine) {
  42205. next += ';';
  42206. previousGeneratedLine++;
  42207. }
  42208. }
  42209. else {
  42210. if (i > 0) {
  42211. if (!util$1.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  42212. continue;
  42213. }
  42214. next += ',';
  42215. }
  42216. }
  42217. next += base64Vlq$1.encode(mapping.generatedColumn
  42218. - previousGeneratedColumn);
  42219. previousGeneratedColumn = mapping.generatedColumn;
  42220. if (mapping.source != null) {
  42221. sourceIdx = this._sources.indexOf(mapping.source);
  42222. next += base64Vlq$1.encode(sourceIdx - previousSource);
  42223. previousSource = sourceIdx;
  42224. // lines are stored 0-based in SourceMap spec version 3
  42225. next += base64Vlq$1.encode(mapping.originalLine - 1
  42226. - previousOriginalLine);
  42227. previousOriginalLine = mapping.originalLine - 1;
  42228. next += base64Vlq$1.encode(mapping.originalColumn
  42229. - previousOriginalColumn);
  42230. previousOriginalColumn = mapping.originalColumn;
  42231. if (mapping.name != null) {
  42232. nameIdx = this._names.indexOf(mapping.name);
  42233. next += base64Vlq$1.encode(nameIdx - previousName);
  42234. previousName = nameIdx;
  42235. }
  42236. }
  42237. result += next;
  42238. }
  42239. return result;
  42240. };
  42241. SourceMapGenerator$3.prototype._generateSourcesContent =
  42242. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  42243. return aSources.map(function (source) {
  42244. if (!this._sourcesContents) {
  42245. return null;
  42246. }
  42247. if (aSourceRoot != null) {
  42248. source = util$1.relative(aSourceRoot, source);
  42249. }
  42250. var key = util$1.toSetString(source);
  42251. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  42252. ? this._sourcesContents[key]
  42253. : null;
  42254. }, this);
  42255. };
  42256. /**
  42257. * Externalize the source map.
  42258. */
  42259. SourceMapGenerator$3.prototype.toJSON =
  42260. function SourceMapGenerator_toJSON() {
  42261. var map = {
  42262. version: this._version,
  42263. sources: this._sources.toArray(),
  42264. names: this._names.toArray(),
  42265. mappings: this._serializeMappings()
  42266. };
  42267. if (this._file != null) {
  42268. map.file = this._file;
  42269. }
  42270. if (this._sourceRoot != null) {
  42271. map.sourceRoot = this._sourceRoot;
  42272. }
  42273. if (this._sourcesContents) {
  42274. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  42275. }
  42276. return map;
  42277. };
  42278. /**
  42279. * Render the source map being generated to a string.
  42280. */
  42281. SourceMapGenerator$3.prototype.toString =
  42282. function SourceMapGenerator_toString() {
  42283. return JSON.stringify(this.toJSON());
  42284. };
  42285. var SourceMapGenerator_1$1 = SourceMapGenerator$3;
  42286. var sourceMapGenerator$1 = {
  42287. SourceMapGenerator: SourceMapGenerator_1$1
  42288. };
  42289. /* -*- Mode: js; js-indent-level: 2; -*- */
  42290. var binarySearch$1 = createCommonjsModule(function (module, exports) {
  42291. /*
  42292. * Copyright 2011 Mozilla Foundation and contributors
  42293. * Licensed under the New BSD license. See LICENSE or:
  42294. * http://opensource.org/licenses/BSD-3-Clause
  42295. */
  42296. exports.GREATEST_LOWER_BOUND = 1;
  42297. exports.LEAST_UPPER_BOUND = 2;
  42298. /**
  42299. * Recursive implementation of binary search.
  42300. *
  42301. * @param aLow Indices here and lower do not contain the needle.
  42302. * @param aHigh Indices here and higher do not contain the needle.
  42303. * @param aNeedle The element being searched for.
  42304. * @param aHaystack The non-empty array being searched.
  42305. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  42306. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  42307. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  42308. * closest element that is smaller than or greater than the one we are
  42309. * searching for, respectively, if the exact element cannot be found.
  42310. */
  42311. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  42312. // This function terminates when one of the following is true:
  42313. //
  42314. // 1. We find the exact element we are looking for.
  42315. //
  42316. // 2. We did not find the exact element, but we can return the index of
  42317. // the next-closest element.
  42318. //
  42319. // 3. We did not find the exact element, and there is no next-closest
  42320. // element than the one we are searching for, so we return -1.
  42321. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  42322. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  42323. if (cmp === 0) {
  42324. // Found the element we are looking for.
  42325. return mid;
  42326. }
  42327. else if (cmp > 0) {
  42328. // Our needle is greater than aHaystack[mid].
  42329. if (aHigh - mid > 1) {
  42330. // The element is in the upper half.
  42331. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  42332. }
  42333. // The exact needle element was not found in this haystack. Determine if
  42334. // we are in termination case (3) or (2) and return the appropriate thing.
  42335. if (aBias == exports.LEAST_UPPER_BOUND) {
  42336. return aHigh < aHaystack.length ? aHigh : -1;
  42337. } else {
  42338. return mid;
  42339. }
  42340. }
  42341. else {
  42342. // Our needle is less than aHaystack[mid].
  42343. if (mid - aLow > 1) {
  42344. // The element is in the lower half.
  42345. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  42346. }
  42347. // we are in termination case (3) or (2) and return the appropriate thing.
  42348. if (aBias == exports.LEAST_UPPER_BOUND) {
  42349. return mid;
  42350. } else {
  42351. return aLow < 0 ? -1 : aLow;
  42352. }
  42353. }
  42354. }
  42355. /**
  42356. * This is an implementation of binary search which will always try and return
  42357. * the index of the closest element if there is no exact hit. This is because
  42358. * mappings between original and generated line/col pairs are single points,
  42359. * and there is an implicit region between each of them, so a miss just means
  42360. * that you aren't on the very start of a region.
  42361. *
  42362. * @param aNeedle The element you are looking for.
  42363. * @param aHaystack The array that is being searched.
  42364. * @param aCompare A function which takes the needle and an element in the
  42365. * array and returns -1, 0, or 1 depending on whether the needle is less
  42366. * than, equal to, or greater than the element, respectively.
  42367. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  42368. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  42369. * closest element that is smaller than or greater than the one we are
  42370. * searching for, respectively, if the exact element cannot be found.
  42371. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  42372. */
  42373. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  42374. if (aHaystack.length === 0) {
  42375. return -1;
  42376. }
  42377. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  42378. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  42379. if (index < 0) {
  42380. return -1;
  42381. }
  42382. // We have found either the exact element, or the next-closest element than
  42383. // the one we are searching for. However, there may be more than one such
  42384. // element. Make sure we always return the smallest of these.
  42385. while (index - 1 >= 0) {
  42386. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  42387. break;
  42388. }
  42389. --index;
  42390. }
  42391. return index;
  42392. };
  42393. });
  42394. /* -*- Mode: js; js-indent-level: 2; -*- */
  42395. /*
  42396. * Copyright 2011 Mozilla Foundation and contributors
  42397. * Licensed under the New BSD license. See LICENSE or:
  42398. * http://opensource.org/licenses/BSD-3-Clause
  42399. */
  42400. // It turns out that some (most?) JavaScript engines don't self-host
  42401. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  42402. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  42403. // custom comparator function, calling back and forth between the VM's C++ and
  42404. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  42405. // worse generated code for the comparator function than would be optimal. In
  42406. // fact, when sorting with a comparator, these costs outweigh the benefits of
  42407. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  42408. // a ~3500ms mean speed-up in `bench/bench.html`.
  42409. function SortTemplate(comparator) {
  42410. /**
  42411. * Swap the elements indexed by `x` and `y` in the array `ary`.
  42412. *
  42413. * @param {Array} ary
  42414. * The array.
  42415. * @param {Number} x
  42416. * The index of the first item.
  42417. * @param {Number} y
  42418. * The index of the second item.
  42419. */
  42420. function swap(ary, x, y) {
  42421. var temp = ary[x];
  42422. ary[x] = ary[y];
  42423. ary[y] = temp;
  42424. }
  42425. /**
  42426. * Returns a random integer within the range `low .. high` inclusive.
  42427. *
  42428. * @param {Number} low
  42429. * The lower bound on the range.
  42430. * @param {Number} high
  42431. * The upper bound on the range.
  42432. */
  42433. function randomIntInRange(low, high) {
  42434. return Math.round(low + (Math.random() * (high - low)));
  42435. }
  42436. /**
  42437. * The Quick Sort algorithm.
  42438. *
  42439. * @param {Array} ary
  42440. * An array to sort.
  42441. * @param {function} comparator
  42442. * Function to use to compare two items.
  42443. * @param {Number} p
  42444. * Start index of the array
  42445. * @param {Number} r
  42446. * End index of the array
  42447. */
  42448. function doQuickSort(ary, comparator, p, r) {
  42449. // If our lower bound is less than our upper bound, we (1) partition the
  42450. // array into two pieces and (2) recurse on each half. If it is not, this is
  42451. // the empty array and our base case.
  42452. if (p < r) {
  42453. // (1) Partitioning.
  42454. //
  42455. // The partitioning chooses a pivot between `p` and `r` and moves all
  42456. // elements that are less than or equal to the pivot to the before it, and
  42457. // all the elements that are greater than it after it. The effect is that
  42458. // once partition is done, the pivot is in the exact place it will be when
  42459. // the array is put in sorted order, and it will not need to be moved
  42460. // again. This runs in O(n) time.
  42461. // Always choose a random pivot so that an input array which is reverse
  42462. // sorted does not cause O(n^2) running time.
  42463. var pivotIndex = randomIntInRange(p, r);
  42464. var i = p - 1;
  42465. swap(ary, pivotIndex, r);
  42466. var pivot = ary[r];
  42467. // Immediately after `j` is incremented in this loop, the following hold
  42468. // true:
  42469. //
  42470. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  42471. //
  42472. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  42473. for (var j = p; j < r; j++) {
  42474. if (comparator(ary[j], pivot, false) <= 0) {
  42475. i += 1;
  42476. swap(ary, i, j);
  42477. }
  42478. }
  42479. swap(ary, i + 1, j);
  42480. var q = i + 1;
  42481. // (2) Recurse on each half.
  42482. doQuickSort(ary, comparator, p, q - 1);
  42483. doQuickSort(ary, comparator, q + 1, r);
  42484. }
  42485. }
  42486. return doQuickSort;
  42487. }
  42488. function cloneSort(comparator) {
  42489. let template = SortTemplate.toString();
  42490. let templateFn = new Function(`return ${template}`)();
  42491. return templateFn(comparator);
  42492. }
  42493. /**
  42494. * Sort the given array in-place with the given comparator function.
  42495. *
  42496. * @param {Array} ary
  42497. * An array to sort.
  42498. * @param {function} comparator
  42499. * Function to use to compare two items.
  42500. */
  42501. let sortCache = new WeakMap();
  42502. var quickSort_1$1 = function (ary, comparator, start = 0) {
  42503. let doQuickSort = sortCache.get(comparator);
  42504. if (doQuickSort === void 0) {
  42505. doQuickSort = cloneSort(comparator);
  42506. sortCache.set(comparator, doQuickSort);
  42507. }
  42508. doQuickSort(ary, comparator, start, ary.length - 1);
  42509. };
  42510. var quickSort$2 = {
  42511. quickSort: quickSort_1$1
  42512. };
  42513. /* -*- Mode: js; js-indent-level: 2; -*- */
  42514. /*
  42515. * Copyright 2011 Mozilla Foundation and contributors
  42516. * Licensed under the New BSD license. See LICENSE or:
  42517. * http://opensource.org/licenses/BSD-3-Clause
  42518. */
  42519. var ArraySet$5 = arraySet$1.ArraySet;
  42520. var quickSort$3 = quickSort$2.quickSort;
  42521. function SourceMapConsumer$2(aSourceMap, aSourceMapURL) {
  42522. var sourceMap = aSourceMap;
  42523. if (typeof aSourceMap === 'string') {
  42524. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  42525. }
  42526. return sourceMap.sections != null
  42527. ? new IndexedSourceMapConsumer$1(sourceMap, aSourceMapURL)
  42528. : new BasicSourceMapConsumer$1(sourceMap, aSourceMapURL);
  42529. }
  42530. SourceMapConsumer$2.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  42531. return BasicSourceMapConsumer$1.fromSourceMap(aSourceMap, aSourceMapURL);
  42532. };
  42533. /**
  42534. * The version of the source mapping spec that we are consuming.
  42535. */
  42536. SourceMapConsumer$2.prototype._version = 3;
  42537. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  42538. // parsed mapping coordinates from the source map's "mappings" attribute. They
  42539. // are lazily instantiated, accessed via the `_generatedMappings` and
  42540. // `_originalMappings` getters respectively, and we only parse the mappings
  42541. // and create these arrays once queried for a source location. We jump through
  42542. // these hoops because there can be many thousands of mappings, and parsing
  42543. // them is expensive, so we only want to do it if we must.
  42544. //
  42545. // Each object in the arrays is of the form:
  42546. //
  42547. // {
  42548. // generatedLine: The line number in the generated code,
  42549. // generatedColumn: The column number in the generated code,
  42550. // source: The path to the original source file that generated this
  42551. // chunk of code,
  42552. // originalLine: The line number in the original source that
  42553. // corresponds to this chunk of generated code,
  42554. // originalColumn: The column number in the original source that
  42555. // corresponds to this chunk of generated code,
  42556. // name: The name of the original symbol which generated this chunk of
  42557. // code.
  42558. // }
  42559. //
  42560. // All properties except for `generatedLine` and `generatedColumn` can be
  42561. // `null`.
  42562. //
  42563. // `_generatedMappings` is ordered by the generated positions.
  42564. //
  42565. // `_originalMappings` is ordered by the original positions.
  42566. SourceMapConsumer$2.prototype.__generatedMappings = null;
  42567. Object.defineProperty(SourceMapConsumer$2.prototype, '_generatedMappings', {
  42568. configurable: true,
  42569. enumerable: true,
  42570. get: function () {
  42571. if (!this.__generatedMappings) {
  42572. this._parseMappings(this._mappings, this.sourceRoot);
  42573. }
  42574. return this.__generatedMappings;
  42575. }
  42576. });
  42577. SourceMapConsumer$2.prototype.__originalMappings = null;
  42578. Object.defineProperty(SourceMapConsumer$2.prototype, '_originalMappings', {
  42579. configurable: true,
  42580. enumerable: true,
  42581. get: function () {
  42582. if (!this.__originalMappings) {
  42583. this._parseMappings(this._mappings, this.sourceRoot);
  42584. }
  42585. return this.__originalMappings;
  42586. }
  42587. });
  42588. SourceMapConsumer$2.prototype._charIsMappingSeparator =
  42589. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  42590. var c = aStr.charAt(index);
  42591. return c === ";" || c === ",";
  42592. };
  42593. /**
  42594. * Parse the mappings in a string in to a data structure which we can easily
  42595. * query (the ordered arrays in the `this.__generatedMappings` and
  42596. * `this.__originalMappings` properties).
  42597. */
  42598. SourceMapConsumer$2.prototype._parseMappings =
  42599. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  42600. throw new Error("Subclasses must implement _parseMappings");
  42601. };
  42602. SourceMapConsumer$2.GENERATED_ORDER = 1;
  42603. SourceMapConsumer$2.ORIGINAL_ORDER = 2;
  42604. SourceMapConsumer$2.GREATEST_LOWER_BOUND = 1;
  42605. SourceMapConsumer$2.LEAST_UPPER_BOUND = 2;
  42606. /**
  42607. * Iterate over each mapping between an original source/line/column and a
  42608. * generated line/column in this source map.
  42609. *
  42610. * @param Function aCallback
  42611. * The function that is called with each mapping.
  42612. * @param Object aContext
  42613. * Optional. If specified, this object will be the value of `this` every
  42614. * time that `aCallback` is called.
  42615. * @param aOrder
  42616. * Either `SourceMapConsumer.GENERATED_ORDER` or
  42617. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  42618. * iterate over the mappings sorted by the generated file's line/column
  42619. * order or the original's source/line/column order, respectively. Defaults to
  42620. * `SourceMapConsumer.GENERATED_ORDER`.
  42621. */
  42622. SourceMapConsumer$2.prototype.eachMapping =
  42623. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  42624. var context = aContext || null;
  42625. var order = aOrder || SourceMapConsumer$2.GENERATED_ORDER;
  42626. var mappings;
  42627. switch (order) {
  42628. case SourceMapConsumer$2.GENERATED_ORDER:
  42629. mappings = this._generatedMappings;
  42630. break;
  42631. case SourceMapConsumer$2.ORIGINAL_ORDER:
  42632. mappings = this._originalMappings;
  42633. break;
  42634. default:
  42635. throw new Error("Unknown order of iteration.");
  42636. }
  42637. var sourceRoot = this.sourceRoot;
  42638. mappings.map(function (mapping) {
  42639. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  42640. source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  42641. return {
  42642. source: source,
  42643. generatedLine: mapping.generatedLine,
  42644. generatedColumn: mapping.generatedColumn,
  42645. originalLine: mapping.originalLine,
  42646. originalColumn: mapping.originalColumn,
  42647. name: mapping.name === null ? null : this._names.at(mapping.name)
  42648. };
  42649. }, this).forEach(aCallback, context);
  42650. };
  42651. /**
  42652. * Returns all generated line and column information for the original source,
  42653. * line, and column provided. If no column is provided, returns all mappings
  42654. * corresponding to a either the line we are searching for or the next
  42655. * closest line that has any mappings. Otherwise, returns all mappings
  42656. * corresponding to the given line and either the column we are searching for
  42657. * or the next closest column that has any offsets.
  42658. *
  42659. * The only argument is an object with the following properties:
  42660. *
  42661. * - source: The filename of the original source.
  42662. * - line: The line number in the original source. The line number is 1-based.
  42663. * - column: Optional. the column number in the original source.
  42664. * The column number is 0-based.
  42665. *
  42666. * and an array of objects is returned, each with the following properties:
  42667. *
  42668. * - line: The line number in the generated source, or null. The
  42669. * line number is 1-based.
  42670. * - column: The column number in the generated source, or null.
  42671. * The column number is 0-based.
  42672. */
  42673. SourceMapConsumer$2.prototype.allGeneratedPositionsFor =
  42674. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  42675. var line = util$1.getArg(aArgs, 'line');
  42676. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  42677. // returns the index of the closest mapping less than the needle. By
  42678. // setting needle.originalColumn to 0, we thus find the last mapping for
  42679. // the given line, provided such a mapping exists.
  42680. var needle = {
  42681. source: util$1.getArg(aArgs, 'source'),
  42682. originalLine: line,
  42683. originalColumn: util$1.getArg(aArgs, 'column', 0)
  42684. };
  42685. needle.source = this._findSourceIndex(needle.source);
  42686. if (needle.source < 0) {
  42687. return [];
  42688. }
  42689. var mappings = [];
  42690. var index = this._findMapping(needle,
  42691. this._originalMappings,
  42692. "originalLine",
  42693. "originalColumn",
  42694. util$1.compareByOriginalPositions,
  42695. binarySearch$1.LEAST_UPPER_BOUND);
  42696. if (index >= 0) {
  42697. var mapping = this._originalMappings[index];
  42698. if (aArgs.column === undefined) {
  42699. var originalLine = mapping.originalLine;
  42700. // Iterate until either we run out of mappings, or we run into
  42701. // a mapping for a different line than the one we found. Since
  42702. // mappings are sorted, this is guaranteed to find all mappings for
  42703. // the line we found.
  42704. while (mapping && mapping.originalLine === originalLine) {
  42705. mappings.push({
  42706. line: util$1.getArg(mapping, 'generatedLine', null),
  42707. column: util$1.getArg(mapping, 'generatedColumn', null),
  42708. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  42709. });
  42710. mapping = this._originalMappings[++index];
  42711. }
  42712. } else {
  42713. var originalColumn = mapping.originalColumn;
  42714. // Iterate until either we run out of mappings, or we run into
  42715. // a mapping for a different line than the one we were searching for.
  42716. // Since mappings are sorted, this is guaranteed to find all mappings for
  42717. // the line we are searching for.
  42718. while (mapping &&
  42719. mapping.originalLine === line &&
  42720. mapping.originalColumn == originalColumn) {
  42721. mappings.push({
  42722. line: util$1.getArg(mapping, 'generatedLine', null),
  42723. column: util$1.getArg(mapping, 'generatedColumn', null),
  42724. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  42725. });
  42726. mapping = this._originalMappings[++index];
  42727. }
  42728. }
  42729. }
  42730. return mappings;
  42731. };
  42732. var SourceMapConsumer_1$1 = SourceMapConsumer$2;
  42733. /**
  42734. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  42735. * query for information about the original file positions by giving it a file
  42736. * position in the generated source.
  42737. *
  42738. * The first parameter is the raw source map (either as a JSON string, or
  42739. * already parsed to an object). According to the spec, source maps have the
  42740. * following attributes:
  42741. *
  42742. * - version: Which version of the source map spec this map is following.
  42743. * - sources: An array of URLs to the original source files.
  42744. * - names: An array of identifiers which can be referrenced by individual mappings.
  42745. * - sourceRoot: Optional. The URL root from which all sources are relative.
  42746. * - sourcesContent: Optional. An array of contents of the original source files.
  42747. * - mappings: A string of base64 VLQs which contain the actual mappings.
  42748. * - file: Optional. The generated file this source map is associated with.
  42749. *
  42750. * Here is an example source map, taken from the source map spec[0]:
  42751. *
  42752. * {
  42753. * version : 3,
  42754. * file: "out.js",
  42755. * sourceRoot : "",
  42756. * sources: ["foo.js", "bar.js"],
  42757. * names: ["src", "maps", "are", "fun"],
  42758. * mappings: "AA,AB;;ABCDE;"
  42759. * }
  42760. *
  42761. * The second parameter, if given, is a string whose value is the URL
  42762. * at which the source map was found. This URL is used to compute the
  42763. * sources array.
  42764. *
  42765. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  42766. */
  42767. function BasicSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  42768. var sourceMap = aSourceMap;
  42769. if (typeof aSourceMap === 'string') {
  42770. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  42771. }
  42772. var version = util$1.getArg(sourceMap, 'version');
  42773. var sources = util$1.getArg(sourceMap, 'sources');
  42774. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  42775. // requires the array) to play nice here.
  42776. var names = util$1.getArg(sourceMap, 'names', []);
  42777. var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
  42778. var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
  42779. var mappings = util$1.getArg(sourceMap, 'mappings');
  42780. var file = util$1.getArg(sourceMap, 'file', null);
  42781. // Once again, Sass deviates from the spec and supplies the version as a
  42782. // string rather than a number, so we use loose equality checking here.
  42783. if (version != this._version) {
  42784. throw new Error('Unsupported version: ' + version);
  42785. }
  42786. if (sourceRoot) {
  42787. sourceRoot = util$1.normalize(sourceRoot);
  42788. }
  42789. sources = sources
  42790. .map(String)
  42791. // Some source maps produce relative source paths like "./foo.js" instead of
  42792. // "foo.js". Normalize these first so that future comparisons will succeed.
  42793. // See bugzil.la/1090768.
  42794. .map(util$1.normalize)
  42795. // Always ensure that absolute sources are internally stored relative to
  42796. // the source root, if the source root is absolute. Not doing this would
  42797. // be particularly problematic when the source root is a prefix of the
  42798. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  42799. .map(function (source) {
  42800. return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
  42801. ? util$1.relative(sourceRoot, source)
  42802. : source;
  42803. });
  42804. // Pass `true` below to allow duplicate names and sources. While source maps
  42805. // are intended to be compressed and deduplicated, the TypeScript compiler
  42806. // sometimes generates source maps with duplicates in them. See Github issue
  42807. // #72 and bugzil.la/889492.
  42808. this._names = ArraySet$5.fromArray(names.map(String), true);
  42809. this._sources = ArraySet$5.fromArray(sources, true);
  42810. this._absoluteSources = this._sources.toArray().map(function (s) {
  42811. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  42812. });
  42813. this.sourceRoot = sourceRoot;
  42814. this.sourcesContent = sourcesContent;
  42815. this._mappings = mappings;
  42816. this._sourceMapURL = aSourceMapURL;
  42817. this.file = file;
  42818. }
  42819. BasicSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$2.prototype);
  42820. BasicSourceMapConsumer$1.prototype.consumer = SourceMapConsumer$2;
  42821. /**
  42822. * Utility function to find the index of a source. Returns -1 if not
  42823. * found.
  42824. */
  42825. BasicSourceMapConsumer$1.prototype._findSourceIndex = function(aSource) {
  42826. var relativeSource = aSource;
  42827. if (this.sourceRoot != null) {
  42828. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  42829. }
  42830. if (this._sources.has(relativeSource)) {
  42831. return this._sources.indexOf(relativeSource);
  42832. }
  42833. // Maybe aSource is an absolute URL as returned by |sources|. In
  42834. // this case we can't simply undo the transform.
  42835. var i;
  42836. for (i = 0; i < this._absoluteSources.length; ++i) {
  42837. if (this._absoluteSources[i] == aSource) {
  42838. return i;
  42839. }
  42840. }
  42841. return -1;
  42842. };
  42843. /**
  42844. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  42845. *
  42846. * @param SourceMapGenerator aSourceMap
  42847. * The source map that will be consumed.
  42848. * @param String aSourceMapURL
  42849. * The URL at which the source map can be found (optional)
  42850. * @returns BasicSourceMapConsumer
  42851. */
  42852. BasicSourceMapConsumer$1.fromSourceMap =
  42853. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  42854. var smc = Object.create(BasicSourceMapConsumer$1.prototype);
  42855. var names = smc._names = ArraySet$5.fromArray(aSourceMap._names.toArray(), true);
  42856. var sources = smc._sources = ArraySet$5.fromArray(aSourceMap._sources.toArray(), true);
  42857. smc.sourceRoot = aSourceMap._sourceRoot;
  42858. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  42859. smc.sourceRoot);
  42860. smc.file = aSourceMap._file;
  42861. smc._sourceMapURL = aSourceMapURL;
  42862. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  42863. return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  42864. });
  42865. // Because we are modifying the entries (by converting string sources and
  42866. // names to indices into the sources and names ArraySets), we have to make
  42867. // a copy of the entry or else bad things happen. Shared mutable state
  42868. // strikes again! See github issue #191.
  42869. var generatedMappings = aSourceMap._mappings.toArray().slice();
  42870. var destGeneratedMappings = smc.__generatedMappings = [];
  42871. var destOriginalMappings = smc.__originalMappings = [];
  42872. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  42873. var srcMapping = generatedMappings[i];
  42874. var destMapping = new Mapping$1;
  42875. destMapping.generatedLine = srcMapping.generatedLine;
  42876. destMapping.generatedColumn = srcMapping.generatedColumn;
  42877. if (srcMapping.source) {
  42878. destMapping.source = sources.indexOf(srcMapping.source);
  42879. destMapping.originalLine = srcMapping.originalLine;
  42880. destMapping.originalColumn = srcMapping.originalColumn;
  42881. if (srcMapping.name) {
  42882. destMapping.name = names.indexOf(srcMapping.name);
  42883. }
  42884. destOriginalMappings.push(destMapping);
  42885. }
  42886. destGeneratedMappings.push(destMapping);
  42887. }
  42888. quickSort$3(smc.__originalMappings, util$1.compareByOriginalPositions);
  42889. return smc;
  42890. };
  42891. /**
  42892. * The version of the source mapping spec that we are consuming.
  42893. */
  42894. BasicSourceMapConsumer$1.prototype._version = 3;
  42895. /**
  42896. * The list of original sources.
  42897. */
  42898. Object.defineProperty(BasicSourceMapConsumer$1.prototype, 'sources', {
  42899. get: function () {
  42900. return this._absoluteSources.slice();
  42901. }
  42902. });
  42903. /**
  42904. * Provide the JIT with a nice shape / hidden class.
  42905. */
  42906. function Mapping$1() {
  42907. this.generatedLine = 0;
  42908. this.generatedColumn = 0;
  42909. this.source = null;
  42910. this.originalLine = null;
  42911. this.originalColumn = null;
  42912. this.name = null;
  42913. }
  42914. /**
  42915. * Parse the mappings in a string in to a data structure which we can easily
  42916. * query (the ordered arrays in the `this.__generatedMappings` and
  42917. * `this.__originalMappings` properties).
  42918. */
  42919. const compareGenerated = util$1.compareByGeneratedPositionsDeflatedNoLine;
  42920. function sortGenerated(array, start) {
  42921. let l = array.length;
  42922. let n = array.length - start;
  42923. if (n <= 1) {
  42924. return;
  42925. } else if (n == 2) {
  42926. let a = array[start];
  42927. let b = array[start + 1];
  42928. if (compareGenerated(a, b) > 0) {
  42929. array[start] = b;
  42930. array[start + 1] = a;
  42931. }
  42932. } else if (n < 20) {
  42933. for (let i = start; i < l; i++) {
  42934. for (let j = i; j > start; j--) {
  42935. let a = array[j - 1];
  42936. let b = array[j];
  42937. if (compareGenerated(a, b) <= 0) {
  42938. break;
  42939. }
  42940. array[j - 1] = b;
  42941. array[j] = a;
  42942. }
  42943. }
  42944. } else {
  42945. quickSort$3(array, compareGenerated, start);
  42946. }
  42947. }
  42948. BasicSourceMapConsumer$1.prototype._parseMappings =
  42949. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  42950. var generatedLine = 1;
  42951. var previousGeneratedColumn = 0;
  42952. var previousOriginalLine = 0;
  42953. var previousOriginalColumn = 0;
  42954. var previousSource = 0;
  42955. var previousName = 0;
  42956. var length = aStr.length;
  42957. var index = 0;
  42958. var temp = {};
  42959. var originalMappings = [];
  42960. var generatedMappings = [];
  42961. var mapping, segment, end, value;
  42962. let subarrayStart = 0;
  42963. while (index < length) {
  42964. if (aStr.charAt(index) === ';') {
  42965. generatedLine++;
  42966. index++;
  42967. previousGeneratedColumn = 0;
  42968. sortGenerated(generatedMappings, subarrayStart);
  42969. subarrayStart = generatedMappings.length;
  42970. }
  42971. else if (aStr.charAt(index) === ',') {
  42972. index++;
  42973. }
  42974. else {
  42975. mapping = new Mapping$1();
  42976. mapping.generatedLine = generatedLine;
  42977. for (end = index; end < length; end++) {
  42978. if (this._charIsMappingSeparator(aStr, end)) {
  42979. break;
  42980. }
  42981. }
  42982. aStr.slice(index, end);
  42983. segment = [];
  42984. while (index < end) {
  42985. base64Vlq$1.decode(aStr, index, temp);
  42986. value = temp.value;
  42987. index = temp.rest;
  42988. segment.push(value);
  42989. }
  42990. if (segment.length === 2) {
  42991. throw new Error('Found a source, but no line and column');
  42992. }
  42993. if (segment.length === 3) {
  42994. throw new Error('Found a source and line, but no column');
  42995. }
  42996. // Generated column.
  42997. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  42998. previousGeneratedColumn = mapping.generatedColumn;
  42999. if (segment.length > 1) {
  43000. // Original source.
  43001. mapping.source = previousSource + segment[1];
  43002. previousSource += segment[1];
  43003. // Original line.
  43004. mapping.originalLine = previousOriginalLine + segment[2];
  43005. previousOriginalLine = mapping.originalLine;
  43006. // Lines are stored 0-based
  43007. mapping.originalLine += 1;
  43008. // Original column.
  43009. mapping.originalColumn = previousOriginalColumn + segment[3];
  43010. previousOriginalColumn = mapping.originalColumn;
  43011. if (segment.length > 4) {
  43012. // Original name.
  43013. mapping.name = previousName + segment[4];
  43014. previousName += segment[4];
  43015. }
  43016. }
  43017. generatedMappings.push(mapping);
  43018. if (typeof mapping.originalLine === 'number') {
  43019. let currentSource = mapping.source;
  43020. while (originalMappings.length <= currentSource) {
  43021. originalMappings.push(null);
  43022. }
  43023. if (originalMappings[currentSource] === null) {
  43024. originalMappings[currentSource] = [];
  43025. }
  43026. originalMappings[currentSource].push(mapping);
  43027. }
  43028. }
  43029. }
  43030. sortGenerated(generatedMappings, subarrayStart);
  43031. this.__generatedMappings = generatedMappings;
  43032. for (var i = 0; i < originalMappings.length; i++) {
  43033. if (originalMappings[i] != null) {
  43034. quickSort$3(originalMappings[i], util$1.compareByOriginalPositionsNoSource);
  43035. }
  43036. }
  43037. this.__originalMappings = [].concat(...originalMappings);
  43038. };
  43039. /**
  43040. * Find the mapping that best matches the hypothetical "needle" mapping that
  43041. * we are searching for in the given "haystack" of mappings.
  43042. */
  43043. BasicSourceMapConsumer$1.prototype._findMapping =
  43044. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  43045. aColumnName, aComparator, aBias) {
  43046. // To return the position we are searching for, we must first find the
  43047. // mapping for the given position and then return the opposite position it
  43048. // points to. Because the mappings are sorted, we can use binary search to
  43049. // find the best mapping.
  43050. if (aNeedle[aLineName] <= 0) {
  43051. throw new TypeError('Line must be greater than or equal to 1, got '
  43052. + aNeedle[aLineName]);
  43053. }
  43054. if (aNeedle[aColumnName] < 0) {
  43055. throw new TypeError('Column must be greater than or equal to 0, got '
  43056. + aNeedle[aColumnName]);
  43057. }
  43058. return binarySearch$1.search(aNeedle, aMappings, aComparator, aBias);
  43059. };
  43060. /**
  43061. * Compute the last column for each generated mapping. The last column is
  43062. * inclusive.
  43063. */
  43064. BasicSourceMapConsumer$1.prototype.computeColumnSpans =
  43065. function SourceMapConsumer_computeColumnSpans() {
  43066. for (var index = 0; index < this._generatedMappings.length; ++index) {
  43067. var mapping = this._generatedMappings[index];
  43068. // Mappings do not contain a field for the last generated columnt. We
  43069. // can come up with an optimistic estimate, however, by assuming that
  43070. // mappings are contiguous (i.e. given two consecutive mappings, the
  43071. // first mapping ends where the second one starts).
  43072. if (index + 1 < this._generatedMappings.length) {
  43073. var nextMapping = this._generatedMappings[index + 1];
  43074. if (mapping.generatedLine === nextMapping.generatedLine) {
  43075. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  43076. continue;
  43077. }
  43078. }
  43079. // The last mapping for each line spans the entire line.
  43080. mapping.lastGeneratedColumn = Infinity;
  43081. }
  43082. };
  43083. /**
  43084. * Returns the original source, line, and column information for the generated
  43085. * source's line and column positions provided. The only argument is an object
  43086. * with the following properties:
  43087. *
  43088. * - line: The line number in the generated source. The line number
  43089. * is 1-based.
  43090. * - column: The column number in the generated source. The column
  43091. * number is 0-based.
  43092. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  43093. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  43094. * closest element that is smaller than or greater than the one we are
  43095. * searching for, respectively, if the exact element cannot be found.
  43096. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  43097. *
  43098. * and an object is returned with the following properties:
  43099. *
  43100. * - source: The original source file, or null.
  43101. * - line: The line number in the original source, or null. The
  43102. * line number is 1-based.
  43103. * - column: The column number in the original source, or null. The
  43104. * column number is 0-based.
  43105. * - name: The original identifier, or null.
  43106. */
  43107. BasicSourceMapConsumer$1.prototype.originalPositionFor =
  43108. function SourceMapConsumer_originalPositionFor(aArgs) {
  43109. var needle = {
  43110. generatedLine: util$1.getArg(aArgs, 'line'),
  43111. generatedColumn: util$1.getArg(aArgs, 'column')
  43112. };
  43113. var index = this._findMapping(
  43114. needle,
  43115. this._generatedMappings,
  43116. "generatedLine",
  43117. "generatedColumn",
  43118. util$1.compareByGeneratedPositionsDeflated,
  43119. util$1.getArg(aArgs, 'bias', SourceMapConsumer$2.GREATEST_LOWER_BOUND)
  43120. );
  43121. if (index >= 0) {
  43122. var mapping = this._generatedMappings[index];
  43123. if (mapping.generatedLine === needle.generatedLine) {
  43124. var source = util$1.getArg(mapping, 'source', null);
  43125. if (source !== null) {
  43126. source = this._sources.at(source);
  43127. source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  43128. }
  43129. var name = util$1.getArg(mapping, 'name', null);
  43130. if (name !== null) {
  43131. name = this._names.at(name);
  43132. }
  43133. return {
  43134. source: source,
  43135. line: util$1.getArg(mapping, 'originalLine', null),
  43136. column: util$1.getArg(mapping, 'originalColumn', null),
  43137. name: name
  43138. };
  43139. }
  43140. }
  43141. return {
  43142. source: null,
  43143. line: null,
  43144. column: null,
  43145. name: null
  43146. };
  43147. };
  43148. /**
  43149. * Return true if we have the source content for every source in the source
  43150. * map, false otherwise.
  43151. */
  43152. BasicSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  43153. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  43154. if (!this.sourcesContent) {
  43155. return false;
  43156. }
  43157. return this.sourcesContent.length >= this._sources.size() &&
  43158. !this.sourcesContent.some(function (sc) { return sc == null; });
  43159. };
  43160. /**
  43161. * Returns the original source content. The only argument is the url of the
  43162. * original source file. Returns null if no original source content is
  43163. * available.
  43164. */
  43165. BasicSourceMapConsumer$1.prototype.sourceContentFor =
  43166. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  43167. if (!this.sourcesContent) {
  43168. return null;
  43169. }
  43170. var index = this._findSourceIndex(aSource);
  43171. if (index >= 0) {
  43172. return this.sourcesContent[index];
  43173. }
  43174. var relativeSource = aSource;
  43175. if (this.sourceRoot != null) {
  43176. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  43177. }
  43178. var url;
  43179. if (this.sourceRoot != null
  43180. && (url = util$1.urlParse(this.sourceRoot))) {
  43181. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  43182. // many users. We can help them out when they expect file:// URIs to
  43183. // behave like it would if they were running a local HTTP server. See
  43184. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  43185. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  43186. if (url.scheme == "file"
  43187. && this._sources.has(fileUriAbsPath)) {
  43188. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  43189. }
  43190. if ((!url.path || url.path == "/")
  43191. && this._sources.has("/" + relativeSource)) {
  43192. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  43193. }
  43194. }
  43195. // This function is used recursively from
  43196. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  43197. // don't want to throw if we can't find the source - we just want to
  43198. // return null, so we provide a flag to exit gracefully.
  43199. if (nullOnMissing) {
  43200. return null;
  43201. }
  43202. else {
  43203. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  43204. }
  43205. };
  43206. /**
  43207. * Returns the generated line and column information for the original source,
  43208. * line, and column positions provided. The only argument is an object with
  43209. * the following properties:
  43210. *
  43211. * - source: The filename of the original source.
  43212. * - line: The line number in the original source. The line number
  43213. * is 1-based.
  43214. * - column: The column number in the original source. The column
  43215. * number is 0-based.
  43216. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  43217. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  43218. * closest element that is smaller than or greater than the one we are
  43219. * searching for, respectively, if the exact element cannot be found.
  43220. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  43221. *
  43222. * and an object is returned with the following properties:
  43223. *
  43224. * - line: The line number in the generated source, or null. The
  43225. * line number is 1-based.
  43226. * - column: The column number in the generated source, or null.
  43227. * The column number is 0-based.
  43228. */
  43229. BasicSourceMapConsumer$1.prototype.generatedPositionFor =
  43230. function SourceMapConsumer_generatedPositionFor(aArgs) {
  43231. var source = util$1.getArg(aArgs, 'source');
  43232. source = this._findSourceIndex(source);
  43233. if (source < 0) {
  43234. return {
  43235. line: null,
  43236. column: null,
  43237. lastColumn: null
  43238. };
  43239. }
  43240. var needle = {
  43241. source: source,
  43242. originalLine: util$1.getArg(aArgs, 'line'),
  43243. originalColumn: util$1.getArg(aArgs, 'column')
  43244. };
  43245. var index = this._findMapping(
  43246. needle,
  43247. this._originalMappings,
  43248. "originalLine",
  43249. "originalColumn",
  43250. util$1.compareByOriginalPositions,
  43251. util$1.getArg(aArgs, 'bias', SourceMapConsumer$2.GREATEST_LOWER_BOUND)
  43252. );
  43253. if (index >= 0) {
  43254. var mapping = this._originalMappings[index];
  43255. if (mapping.source === needle.source) {
  43256. return {
  43257. line: util$1.getArg(mapping, 'generatedLine', null),
  43258. column: util$1.getArg(mapping, 'generatedColumn', null),
  43259. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  43260. };
  43261. }
  43262. }
  43263. return {
  43264. line: null,
  43265. column: null,
  43266. lastColumn: null
  43267. };
  43268. };
  43269. var BasicSourceMapConsumer_1$1 = BasicSourceMapConsumer$1;
  43270. /**
  43271. * An IndexedSourceMapConsumer instance represents a parsed source map which
  43272. * we can query for information. It differs from BasicSourceMapConsumer in
  43273. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  43274. * input.
  43275. *
  43276. * The first parameter is a raw source map (either as a JSON string, or already
  43277. * parsed to an object). According to the spec for indexed source maps, they
  43278. * have the following attributes:
  43279. *
  43280. * - version: Which version of the source map spec this map is following.
  43281. * - file: Optional. The generated file this source map is associated with.
  43282. * - sections: A list of section definitions.
  43283. *
  43284. * Each value under the "sections" field has two fields:
  43285. * - offset: The offset into the original specified at which this section
  43286. * begins to apply, defined as an object with a "line" and "column"
  43287. * field.
  43288. * - map: A source map definition. This source map could also be indexed,
  43289. * but doesn't have to be.
  43290. *
  43291. * Instead of the "map" field, it's also possible to have a "url" field
  43292. * specifying a URL to retrieve a source map from, but that's currently
  43293. * unsupported.
  43294. *
  43295. * Here's an example source map, taken from the source map spec[0], but
  43296. * modified to omit a section which uses the "url" field.
  43297. *
  43298. * {
  43299. * version : 3,
  43300. * file: "app.js",
  43301. * sections: [{
  43302. * offset: {line:100, column:10},
  43303. * map: {
  43304. * version : 3,
  43305. * file: "section.js",
  43306. * sources: ["foo.js", "bar.js"],
  43307. * names: ["src", "maps", "are", "fun"],
  43308. * mappings: "AAAA,E;;ABCDE;"
  43309. * }
  43310. * }],
  43311. * }
  43312. *
  43313. * The second parameter, if given, is a string whose value is the URL
  43314. * at which the source map was found. This URL is used to compute the
  43315. * sources array.
  43316. *
  43317. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  43318. */
  43319. function IndexedSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  43320. var sourceMap = aSourceMap;
  43321. if (typeof aSourceMap === 'string') {
  43322. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  43323. }
  43324. var version = util$1.getArg(sourceMap, 'version');
  43325. var sections = util$1.getArg(sourceMap, 'sections');
  43326. if (version != this._version) {
  43327. throw new Error('Unsupported version: ' + version);
  43328. }
  43329. this._sources = new ArraySet$5();
  43330. this._names = new ArraySet$5();
  43331. var lastOffset = {
  43332. line: -1,
  43333. column: 0
  43334. };
  43335. this._sections = sections.map(function (s) {
  43336. if (s.url) {
  43337. // The url field will require support for asynchronicity.
  43338. // See https://github.com/mozilla/source-map/issues/16
  43339. throw new Error('Support for url field in sections not implemented.');
  43340. }
  43341. var offset = util$1.getArg(s, 'offset');
  43342. var offsetLine = util$1.getArg(offset, 'line');
  43343. var offsetColumn = util$1.getArg(offset, 'column');
  43344. if (offsetLine < lastOffset.line ||
  43345. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  43346. throw new Error('Section offsets must be ordered and non-overlapping.');
  43347. }
  43348. lastOffset = offset;
  43349. return {
  43350. generatedOffset: {
  43351. // The offset fields are 0-based, but we use 1-based indices when
  43352. // encoding/decoding from VLQ.
  43353. generatedLine: offsetLine + 1,
  43354. generatedColumn: offsetColumn + 1
  43355. },
  43356. consumer: new SourceMapConsumer$2(util$1.getArg(s, 'map'), aSourceMapURL)
  43357. }
  43358. });
  43359. }
  43360. IndexedSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$2.prototype);
  43361. IndexedSourceMapConsumer$1.prototype.constructor = SourceMapConsumer$2;
  43362. /**
  43363. * The version of the source mapping spec that we are consuming.
  43364. */
  43365. IndexedSourceMapConsumer$1.prototype._version = 3;
  43366. /**
  43367. * The list of original sources.
  43368. */
  43369. Object.defineProperty(IndexedSourceMapConsumer$1.prototype, 'sources', {
  43370. get: function () {
  43371. var sources = [];
  43372. for (var i = 0; i < this._sections.length; i++) {
  43373. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  43374. sources.push(this._sections[i].consumer.sources[j]);
  43375. }
  43376. }
  43377. return sources;
  43378. }
  43379. });
  43380. /**
  43381. * Returns the original source, line, and column information for the generated
  43382. * source's line and column positions provided. The only argument is an object
  43383. * with the following properties:
  43384. *
  43385. * - line: The line number in the generated source. The line number
  43386. * is 1-based.
  43387. * - column: The column number in the generated source. The column
  43388. * number is 0-based.
  43389. *
  43390. * and an object is returned with the following properties:
  43391. *
  43392. * - source: The original source file, or null.
  43393. * - line: The line number in the original source, or null. The
  43394. * line number is 1-based.
  43395. * - column: The column number in the original source, or null. The
  43396. * column number is 0-based.
  43397. * - name: The original identifier, or null.
  43398. */
  43399. IndexedSourceMapConsumer$1.prototype.originalPositionFor =
  43400. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  43401. var needle = {
  43402. generatedLine: util$1.getArg(aArgs, 'line'),
  43403. generatedColumn: util$1.getArg(aArgs, 'column')
  43404. };
  43405. // Find the section containing the generated position we're trying to map
  43406. // to an original position.
  43407. var sectionIndex = binarySearch$1.search(needle, this._sections,
  43408. function(needle, section) {
  43409. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  43410. if (cmp) {
  43411. return cmp;
  43412. }
  43413. return (needle.generatedColumn -
  43414. section.generatedOffset.generatedColumn);
  43415. });
  43416. var section = this._sections[sectionIndex];
  43417. if (!section) {
  43418. return {
  43419. source: null,
  43420. line: null,
  43421. column: null,
  43422. name: null
  43423. };
  43424. }
  43425. return section.consumer.originalPositionFor({
  43426. line: needle.generatedLine -
  43427. (section.generatedOffset.generatedLine - 1),
  43428. column: needle.generatedColumn -
  43429. (section.generatedOffset.generatedLine === needle.generatedLine
  43430. ? section.generatedOffset.generatedColumn - 1
  43431. : 0),
  43432. bias: aArgs.bias
  43433. });
  43434. };
  43435. /**
  43436. * Return true if we have the source content for every source in the source
  43437. * map, false otherwise.
  43438. */
  43439. IndexedSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  43440. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  43441. return this._sections.every(function (s) {
  43442. return s.consumer.hasContentsOfAllSources();
  43443. });
  43444. };
  43445. /**
  43446. * Returns the original source content. The only argument is the url of the
  43447. * original source file. Returns null if no original source content is
  43448. * available.
  43449. */
  43450. IndexedSourceMapConsumer$1.prototype.sourceContentFor =
  43451. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  43452. for (var i = 0; i < this._sections.length; i++) {
  43453. var section = this._sections[i];
  43454. var content = section.consumer.sourceContentFor(aSource, true);
  43455. if (content) {
  43456. return content;
  43457. }
  43458. }
  43459. if (nullOnMissing) {
  43460. return null;
  43461. }
  43462. else {
  43463. throw new Error('"' + aSource + '" is not in the SourceMap.');
  43464. }
  43465. };
  43466. /**
  43467. * Returns the generated line and column information for the original source,
  43468. * line, and column positions provided. The only argument is an object with
  43469. * the following properties:
  43470. *
  43471. * - source: The filename of the original source.
  43472. * - line: The line number in the original source. The line number
  43473. * is 1-based.
  43474. * - column: The column number in the original source. The column
  43475. * number is 0-based.
  43476. *
  43477. * and an object is returned with the following properties:
  43478. *
  43479. * - line: The line number in the generated source, or null. The
  43480. * line number is 1-based.
  43481. * - column: The column number in the generated source, or null.
  43482. * The column number is 0-based.
  43483. */
  43484. IndexedSourceMapConsumer$1.prototype.generatedPositionFor =
  43485. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  43486. for (var i = 0; i < this._sections.length; i++) {
  43487. var section = this._sections[i];
  43488. // Only consider this section if the requested source is in the list of
  43489. // sources of the consumer.
  43490. if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
  43491. continue;
  43492. }
  43493. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  43494. if (generatedPosition) {
  43495. var ret = {
  43496. line: generatedPosition.line +
  43497. (section.generatedOffset.generatedLine - 1),
  43498. column: generatedPosition.column +
  43499. (section.generatedOffset.generatedLine === generatedPosition.line
  43500. ? section.generatedOffset.generatedColumn - 1
  43501. : 0)
  43502. };
  43503. return ret;
  43504. }
  43505. }
  43506. return {
  43507. line: null,
  43508. column: null
  43509. };
  43510. };
  43511. /**
  43512. * Parse the mappings in a string in to a data structure which we can easily
  43513. * query (the ordered arrays in the `this.__generatedMappings` and
  43514. * `this.__originalMappings` properties).
  43515. */
  43516. IndexedSourceMapConsumer$1.prototype._parseMappings =
  43517. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  43518. this.__generatedMappings = [];
  43519. this.__originalMappings = [];
  43520. for (var i = 0; i < this._sections.length; i++) {
  43521. var section = this._sections[i];
  43522. var sectionMappings = section.consumer._generatedMappings;
  43523. for (var j = 0; j < sectionMappings.length; j++) {
  43524. var mapping = sectionMappings[j];
  43525. var source = section.consumer._sources.at(mapping.source);
  43526. source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  43527. this._sources.add(source);
  43528. source = this._sources.indexOf(source);
  43529. var name = null;
  43530. if (mapping.name) {
  43531. name = section.consumer._names.at(mapping.name);
  43532. this._names.add(name);
  43533. name = this._names.indexOf(name);
  43534. }
  43535. // The mappings coming from the consumer for the section have
  43536. // generated positions relative to the start of the section, so we
  43537. // need to offset them to be relative to the start of the concatenated
  43538. // generated file.
  43539. var adjustedMapping = {
  43540. source: source,
  43541. generatedLine: mapping.generatedLine +
  43542. (section.generatedOffset.generatedLine - 1),
  43543. generatedColumn: mapping.generatedColumn +
  43544. (section.generatedOffset.generatedLine === mapping.generatedLine
  43545. ? section.generatedOffset.generatedColumn - 1
  43546. : 0),
  43547. originalLine: mapping.originalLine,
  43548. originalColumn: mapping.originalColumn,
  43549. name: name
  43550. };
  43551. this.__generatedMappings.push(adjustedMapping);
  43552. if (typeof adjustedMapping.originalLine === 'number') {
  43553. this.__originalMappings.push(adjustedMapping);
  43554. }
  43555. }
  43556. }
  43557. quickSort$3(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  43558. quickSort$3(this.__originalMappings, util$1.compareByOriginalPositions);
  43559. };
  43560. var IndexedSourceMapConsumer_1$1 = IndexedSourceMapConsumer$1;
  43561. var sourceMapConsumer$1 = {
  43562. SourceMapConsumer: SourceMapConsumer_1$1,
  43563. BasicSourceMapConsumer: BasicSourceMapConsumer_1$1,
  43564. IndexedSourceMapConsumer: IndexedSourceMapConsumer_1$1
  43565. };
  43566. /* -*- Mode: js; js-indent-level: 2; -*- */
  43567. /*
  43568. * Copyright 2011 Mozilla Foundation and contributors
  43569. * Licensed under the New BSD license. See LICENSE or:
  43570. * http://opensource.org/licenses/BSD-3-Clause
  43571. */
  43572. var SourceMapGenerator$4 = sourceMapGenerator$1.SourceMapGenerator;
  43573. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  43574. // operating systems these days (capturing the result).
  43575. var REGEX_NEWLINE$1 = /(\r?\n)/;
  43576. // Newline character code for charCodeAt() comparisons
  43577. var NEWLINE_CODE$1 = 10;
  43578. // Private symbol for identifying `SourceNode`s when multiple versions of
  43579. // the source-map library are loaded. This MUST NOT CHANGE across
  43580. // versions!
  43581. var isSourceNode$1 = "$$$isSourceNode$$$";
  43582. /**
  43583. * SourceNodes provide a way to abstract over interpolating/concatenating
  43584. * snippets of generated JavaScript source code while maintaining the line and
  43585. * column information associated with the original source code.
  43586. *
  43587. * @param aLine The original line number.
  43588. * @param aColumn The original column number.
  43589. * @param aSource The original source's filename.
  43590. * @param aChunks Optional. An array of strings which are snippets of
  43591. * generated JS, or other SourceNodes.
  43592. * @param aName The original identifier.
  43593. */
  43594. function SourceNode$2(aLine, aColumn, aSource, aChunks, aName) {
  43595. this.children = [];
  43596. this.sourceContents = {};
  43597. this.line = aLine == null ? null : aLine;
  43598. this.column = aColumn == null ? null : aColumn;
  43599. this.source = aSource == null ? null : aSource;
  43600. this.name = aName == null ? null : aName;
  43601. this[isSourceNode$1] = true;
  43602. if (aChunks != null) this.add(aChunks);
  43603. }
  43604. /**
  43605. * Creates a SourceNode from generated code and a SourceMapConsumer.
  43606. *
  43607. * @param aGeneratedCode The generated code
  43608. * @param aSourceMapConsumer The SourceMap for the generated code
  43609. * @param aRelativePath Optional. The path that relative sources in the
  43610. * SourceMapConsumer should be relative to.
  43611. */
  43612. SourceNode$2.fromStringWithSourceMap =
  43613. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  43614. // The SourceNode we want to fill with the generated code
  43615. // and the SourceMap
  43616. var node = new SourceNode$2();
  43617. // All even indices of this array are one line of the generated code,
  43618. // while all odd indices are the newlines between two adjacent lines
  43619. // (since `REGEX_NEWLINE` captures its match).
  43620. // Processed fragments are accessed by calling `shiftNextLine`.
  43621. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE$1);
  43622. var remainingLinesIndex = 0;
  43623. var shiftNextLine = function() {
  43624. var lineContents = getNextLine();
  43625. // The last line of a file might not have a newline.
  43626. var newLine = getNextLine() || "";
  43627. return lineContents + newLine;
  43628. function getNextLine() {
  43629. return remainingLinesIndex < remainingLines.length ?
  43630. remainingLines[remainingLinesIndex++] : undefined;
  43631. }
  43632. };
  43633. // We need to remember the position of "remainingLines"
  43634. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  43635. // The generate SourceNodes we need a code range.
  43636. // To extract it current and last mapping is used.
  43637. // Here we store the last mapping.
  43638. var lastMapping = null;
  43639. aSourceMapConsumer.eachMapping(function (mapping) {
  43640. if (lastMapping !== null) {
  43641. // We add the code from "lastMapping" to "mapping":
  43642. // First check if there is a new line in between.
  43643. if (lastGeneratedLine < mapping.generatedLine) {
  43644. // Associate first line with "lastMapping"
  43645. addMappingWithCode(lastMapping, shiftNextLine());
  43646. lastGeneratedLine++;
  43647. lastGeneratedColumn = 0;
  43648. // The remaining code is added without mapping
  43649. } else {
  43650. // There is no new line in between.
  43651. // Associate the code between "lastGeneratedColumn" and
  43652. // "mapping.generatedColumn" with "lastMapping"
  43653. var nextLine = remainingLines[remainingLinesIndex] || '';
  43654. var code = nextLine.substr(0, mapping.generatedColumn -
  43655. lastGeneratedColumn);
  43656. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  43657. lastGeneratedColumn);
  43658. lastGeneratedColumn = mapping.generatedColumn;
  43659. addMappingWithCode(lastMapping, code);
  43660. // No more remaining code, continue
  43661. lastMapping = mapping;
  43662. return;
  43663. }
  43664. }
  43665. // We add the generated code until the first mapping
  43666. // to the SourceNode without any mapping.
  43667. // Each line is added as separate string.
  43668. while (lastGeneratedLine < mapping.generatedLine) {
  43669. node.add(shiftNextLine());
  43670. lastGeneratedLine++;
  43671. }
  43672. if (lastGeneratedColumn < mapping.generatedColumn) {
  43673. var nextLine = remainingLines[remainingLinesIndex] || '';
  43674. node.add(nextLine.substr(0, mapping.generatedColumn));
  43675. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  43676. lastGeneratedColumn = mapping.generatedColumn;
  43677. }
  43678. lastMapping = mapping;
  43679. }, this);
  43680. // We have processed all mappings.
  43681. if (remainingLinesIndex < remainingLines.length) {
  43682. if (lastMapping) {
  43683. // Associate the remaining code in the current line with "lastMapping"
  43684. addMappingWithCode(lastMapping, shiftNextLine());
  43685. }
  43686. // and add the remaining lines without any mapping
  43687. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  43688. }
  43689. // Copy sourcesContent into SourceNode
  43690. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  43691. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  43692. if (content != null) {
  43693. if (aRelativePath != null) {
  43694. sourceFile = util$1.join(aRelativePath, sourceFile);
  43695. }
  43696. node.setSourceContent(sourceFile, content);
  43697. }
  43698. });
  43699. return node;
  43700. function addMappingWithCode(mapping, code) {
  43701. if (mapping === null || mapping.source === undefined) {
  43702. node.add(code);
  43703. } else {
  43704. var source = aRelativePath
  43705. ? util$1.join(aRelativePath, mapping.source)
  43706. : mapping.source;
  43707. node.add(new SourceNode$2(mapping.originalLine,
  43708. mapping.originalColumn,
  43709. source,
  43710. code,
  43711. mapping.name));
  43712. }
  43713. }
  43714. };
  43715. /**
  43716. * Add a chunk of generated JS to this source node.
  43717. *
  43718. * @param aChunk A string snippet of generated JS code, another instance of
  43719. * SourceNode, or an array where each member is one of those things.
  43720. */
  43721. SourceNode$2.prototype.add = function SourceNode_add(aChunk) {
  43722. if (Array.isArray(aChunk)) {
  43723. aChunk.forEach(function (chunk) {
  43724. this.add(chunk);
  43725. }, this);
  43726. }
  43727. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  43728. if (aChunk) {
  43729. this.children.push(aChunk);
  43730. }
  43731. }
  43732. else {
  43733. throw new TypeError(
  43734. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  43735. );
  43736. }
  43737. return this;
  43738. };
  43739. /**
  43740. * Add a chunk of generated JS to the beginning of this source node.
  43741. *
  43742. * @param aChunk A string snippet of generated JS code, another instance of
  43743. * SourceNode, or an array where each member is one of those things.
  43744. */
  43745. SourceNode$2.prototype.prepend = function SourceNode_prepend(aChunk) {
  43746. if (Array.isArray(aChunk)) {
  43747. for (var i = aChunk.length-1; i >= 0; i--) {
  43748. this.prepend(aChunk[i]);
  43749. }
  43750. }
  43751. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  43752. this.children.unshift(aChunk);
  43753. }
  43754. else {
  43755. throw new TypeError(
  43756. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  43757. );
  43758. }
  43759. return this;
  43760. };
  43761. /**
  43762. * Walk over the tree of JS snippets in this node and its children. The
  43763. * walking function is called once for each snippet of JS and is passed that
  43764. * snippet and the its original associated source's line/column location.
  43765. *
  43766. * @param aFn The traversal function.
  43767. */
  43768. SourceNode$2.prototype.walk = function SourceNode_walk(aFn) {
  43769. var chunk;
  43770. for (var i = 0, len = this.children.length; i < len; i++) {
  43771. chunk = this.children[i];
  43772. if (chunk[isSourceNode$1]) {
  43773. chunk.walk(aFn);
  43774. }
  43775. else {
  43776. if (chunk !== '') {
  43777. aFn(chunk, { source: this.source,
  43778. line: this.line,
  43779. column: this.column,
  43780. name: this.name });
  43781. }
  43782. }
  43783. }
  43784. };
  43785. /**
  43786. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  43787. * each of `this.children`.
  43788. *
  43789. * @param aSep The separator.
  43790. */
  43791. SourceNode$2.prototype.join = function SourceNode_join(aSep) {
  43792. var newChildren;
  43793. var i;
  43794. var len = this.children.length;
  43795. if (len > 0) {
  43796. newChildren = [];
  43797. for (i = 0; i < len-1; i++) {
  43798. newChildren.push(this.children[i]);
  43799. newChildren.push(aSep);
  43800. }
  43801. newChildren.push(this.children[i]);
  43802. this.children = newChildren;
  43803. }
  43804. return this;
  43805. };
  43806. /**
  43807. * Call String.prototype.replace on the very right-most source snippet. Useful
  43808. * for trimming whitespace from the end of a source node, etc.
  43809. *
  43810. * @param aPattern The pattern to replace.
  43811. * @param aReplacement The thing to replace the pattern with.
  43812. */
  43813. SourceNode$2.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  43814. var lastChild = this.children[this.children.length - 1];
  43815. if (lastChild[isSourceNode$1]) {
  43816. lastChild.replaceRight(aPattern, aReplacement);
  43817. }
  43818. else if (typeof lastChild === 'string') {
  43819. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  43820. }
  43821. else {
  43822. this.children.push(''.replace(aPattern, aReplacement));
  43823. }
  43824. return this;
  43825. };
  43826. /**
  43827. * Set the source content for a source file. This will be added to the SourceMapGenerator
  43828. * in the sourcesContent field.
  43829. *
  43830. * @param aSourceFile The filename of the source file
  43831. * @param aSourceContent The content of the source file
  43832. */
  43833. SourceNode$2.prototype.setSourceContent =
  43834. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  43835. this.sourceContents[util$1.toSetString(aSourceFile)] = aSourceContent;
  43836. };
  43837. /**
  43838. * Walk over the tree of SourceNodes. The walking function is called for each
  43839. * source file content and is passed the filename and source content.
  43840. *
  43841. * @param aFn The traversal function.
  43842. */
  43843. SourceNode$2.prototype.walkSourceContents =
  43844. function SourceNode_walkSourceContents(aFn) {
  43845. for (var i = 0, len = this.children.length; i < len; i++) {
  43846. if (this.children[i][isSourceNode$1]) {
  43847. this.children[i].walkSourceContents(aFn);
  43848. }
  43849. }
  43850. var sources = Object.keys(this.sourceContents);
  43851. for (var i = 0, len = sources.length; i < len; i++) {
  43852. aFn(util$1.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  43853. }
  43854. };
  43855. /**
  43856. * Return the string representation of this source node. Walks over the tree
  43857. * and concatenates all the various snippets together to one string.
  43858. */
  43859. SourceNode$2.prototype.toString = function SourceNode_toString() {
  43860. var str = "";
  43861. this.walk(function (chunk) {
  43862. str += chunk;
  43863. });
  43864. return str;
  43865. };
  43866. /**
  43867. * Returns the string representation of this source node along with a source
  43868. * map.
  43869. */
  43870. SourceNode$2.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  43871. var generated = {
  43872. code: "",
  43873. line: 1,
  43874. column: 0
  43875. };
  43876. var map = new SourceMapGenerator$4(aArgs);
  43877. var sourceMappingActive = false;
  43878. var lastOriginalSource = null;
  43879. var lastOriginalLine = null;
  43880. var lastOriginalColumn = null;
  43881. var lastOriginalName = null;
  43882. this.walk(function (chunk, original) {
  43883. generated.code += chunk;
  43884. if (original.source !== null
  43885. && original.line !== null
  43886. && original.column !== null) {
  43887. if(lastOriginalSource !== original.source
  43888. || lastOriginalLine !== original.line
  43889. || lastOriginalColumn !== original.column
  43890. || lastOriginalName !== original.name) {
  43891. map.addMapping({
  43892. source: original.source,
  43893. original: {
  43894. line: original.line,
  43895. column: original.column
  43896. },
  43897. generated: {
  43898. line: generated.line,
  43899. column: generated.column
  43900. },
  43901. name: original.name
  43902. });
  43903. }
  43904. lastOriginalSource = original.source;
  43905. lastOriginalLine = original.line;
  43906. lastOriginalColumn = original.column;
  43907. lastOriginalName = original.name;
  43908. sourceMappingActive = true;
  43909. } else if (sourceMappingActive) {
  43910. map.addMapping({
  43911. generated: {
  43912. line: generated.line,
  43913. column: generated.column
  43914. }
  43915. });
  43916. lastOriginalSource = null;
  43917. sourceMappingActive = false;
  43918. }
  43919. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  43920. if (chunk.charCodeAt(idx) === NEWLINE_CODE$1) {
  43921. generated.line++;
  43922. generated.column = 0;
  43923. // Mappings end at eol
  43924. if (idx + 1 === length) {
  43925. lastOriginalSource = null;
  43926. sourceMappingActive = false;
  43927. } else if (sourceMappingActive) {
  43928. map.addMapping({
  43929. source: original.source,
  43930. original: {
  43931. line: original.line,
  43932. column: original.column
  43933. },
  43934. generated: {
  43935. line: generated.line,
  43936. column: generated.column
  43937. },
  43938. name: original.name
  43939. });
  43940. }
  43941. } else {
  43942. generated.column++;
  43943. }
  43944. }
  43945. });
  43946. this.walkSourceContents(function (sourceFile, sourceContent) {
  43947. map.setSourceContent(sourceFile, sourceContent);
  43948. });
  43949. return { code: generated.code, map: map };
  43950. };
  43951. var SourceNode_1$1 = SourceNode$2;
  43952. var sourceNode$1 = {
  43953. SourceNode: SourceNode_1$1
  43954. };
  43955. /*
  43956. * Copyright 2009-2011 Mozilla Foundation and contributors
  43957. * Licensed under the New BSD license. See LICENSE.txt or:
  43958. * http://opensource.org/licenses/BSD-3-Clause
  43959. */
  43960. var SourceMapGenerator$5 = sourceMapGenerator$1.SourceMapGenerator;
  43961. var SourceMapConsumer$3 = sourceMapConsumer$1.SourceMapConsumer;
  43962. var SourceNode$3 = sourceNode$1.SourceNode;
  43963. var sourceMap$1 = {
  43964. SourceMapGenerator: SourceMapGenerator$5,
  43965. SourceMapConsumer: SourceMapConsumer$3,
  43966. SourceNode: SourceNode$3
  43967. };
  43968. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  43969. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  43970. let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$6 } = sourceMap$1;
  43971. let { dirname: dirname$1, resolve: resolve$1, relative: relative$1, sep: sep$1 } = require$$2;
  43972. let { pathToFileURL } = require$$1;
  43973. let sourceMapAvailable = Boolean(SourceMapConsumer$4 && SourceMapGenerator$6);
  43974. let pathAvailable = Boolean(dirname$1 && resolve$1 && relative$1 && sep$1);
  43975. class MapGenerator {
  43976. constructor(stringify, root, opts) {
  43977. this.stringify = stringify;
  43978. this.mapOpts = opts.map || {};
  43979. this.root = root;
  43980. this.opts = opts;
  43981. }
  43982. isMap() {
  43983. if (typeof this.opts.map !== 'undefined') {
  43984. return !!this.opts.map
  43985. }
  43986. return this.previous().length > 0
  43987. }
  43988. previous() {
  43989. if (!this.previousMaps) {
  43990. this.previousMaps = [];
  43991. this.root.walk(node => {
  43992. if (node.source && node.source.input.map) {
  43993. let map = node.source.input.map;
  43994. if (!this.previousMaps.includes(map)) {
  43995. this.previousMaps.push(map);
  43996. }
  43997. }
  43998. });
  43999. }
  44000. return this.previousMaps
  44001. }
  44002. isInline() {
  44003. if (typeof this.mapOpts.inline !== 'undefined') {
  44004. return this.mapOpts.inline
  44005. }
  44006. let annotation = this.mapOpts.annotation;
  44007. if (typeof annotation !== 'undefined' && annotation !== true) {
  44008. return false
  44009. }
  44010. if (this.previous().length) {
  44011. return this.previous().some(i => i.inline)
  44012. }
  44013. return true
  44014. }
  44015. isSourcesContent() {
  44016. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  44017. return this.mapOpts.sourcesContent
  44018. }
  44019. if (this.previous().length) {
  44020. return this.previous().some(i => i.withContent())
  44021. }
  44022. return true
  44023. }
  44024. clearAnnotation() {
  44025. if (this.mapOpts.annotation === false) return
  44026. let node;
  44027. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  44028. node = this.root.nodes[i];
  44029. if (node.type !== 'comment') continue
  44030. if (node.text.indexOf('# sourceMappingURL=') === 0) {
  44031. this.root.removeChild(i);
  44032. }
  44033. }
  44034. }
  44035. setSourcesContent() {
  44036. let already = {};
  44037. this.root.walk(node => {
  44038. if (node.source) {
  44039. let from = node.source.input.from;
  44040. if (from && !already[from]) {
  44041. already[from] = true;
  44042. this.map.setSourceContent(
  44043. this.toUrl(this.path(from)),
  44044. node.source.input.css
  44045. );
  44046. }
  44047. }
  44048. });
  44049. }
  44050. applyPrevMaps() {
  44051. for (let prev of this.previous()) {
  44052. let from = this.toUrl(this.path(prev.file));
  44053. let root = prev.root || dirname$1(prev.file);
  44054. let map;
  44055. if (this.mapOpts.sourcesContent === false) {
  44056. map = new SourceMapConsumer$4(prev.text);
  44057. if (map.sourcesContent) {
  44058. map.sourcesContent = map.sourcesContent.map(() => null);
  44059. }
  44060. } else {
  44061. map = prev.consumer();
  44062. }
  44063. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  44064. }
  44065. }
  44066. isAnnotation() {
  44067. if (this.isInline()) {
  44068. return true
  44069. }
  44070. if (typeof this.mapOpts.annotation !== 'undefined') {
  44071. return this.mapOpts.annotation
  44072. }
  44073. if (this.previous().length) {
  44074. return this.previous().some(i => i.annotation)
  44075. }
  44076. return true
  44077. }
  44078. toBase64(str) {
  44079. if (Buffer) {
  44080. return Buffer.from(str).toString('base64')
  44081. } else {
  44082. // istanbul ignore next
  44083. return window.btoa(unescape(encodeURIComponent(str)))
  44084. }
  44085. }
  44086. addAnnotation() {
  44087. let content;
  44088. if (this.isInline()) {
  44089. content =
  44090. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  44091. } else if (typeof this.mapOpts.annotation === 'string') {
  44092. content = this.mapOpts.annotation;
  44093. } else if (typeof this.mapOpts.annotation === 'function') {
  44094. content = this.mapOpts.annotation(this.opts.to, this.root);
  44095. } else {
  44096. content = this.outputFile() + '.map';
  44097. }
  44098. let eol = '\n';
  44099. if (this.css.includes('\r\n')) eol = '\r\n';
  44100. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  44101. }
  44102. outputFile() {
  44103. if (this.opts.to) {
  44104. return this.path(this.opts.to)
  44105. }
  44106. if (this.opts.from) {
  44107. return this.path(this.opts.from)
  44108. }
  44109. return 'to.css'
  44110. }
  44111. generateMap() {
  44112. this.generateString();
  44113. if (this.isSourcesContent()) this.setSourcesContent();
  44114. if (this.previous().length > 0) this.applyPrevMaps();
  44115. if (this.isAnnotation()) this.addAnnotation();
  44116. if (this.isInline()) {
  44117. return [this.css]
  44118. }
  44119. return [this.css, this.map]
  44120. }
  44121. path(file) {
  44122. if (file.indexOf('<') === 0) return file
  44123. if (/^\w+:\/\//.test(file)) return file
  44124. if (this.mapOpts.absolute) return file
  44125. let from = this.opts.to ? dirname$1(this.opts.to) : '.';
  44126. if (typeof this.mapOpts.annotation === 'string') {
  44127. from = dirname$1(resolve$1(from, this.mapOpts.annotation));
  44128. }
  44129. file = relative$1(from, file);
  44130. return file
  44131. }
  44132. toUrl(path) {
  44133. if (sep$1 === '\\') {
  44134. // istanbul ignore next
  44135. path = path.replace(/\\/g, '/');
  44136. }
  44137. return encodeURI(path).replace(/[#?]/g, encodeURIComponent)
  44138. }
  44139. sourcePath(node) {
  44140. if (this.mapOpts.from) {
  44141. return this.toUrl(this.mapOpts.from)
  44142. } else if (this.mapOpts.absolute) {
  44143. if (pathToFileURL) {
  44144. return pathToFileURL(node.source.input.from).toString()
  44145. } else {
  44146. // istanbul ignore next
  44147. throw new Error(
  44148. '`map.absolute` option is not available in this PostCSS build'
  44149. )
  44150. }
  44151. } else {
  44152. return this.toUrl(this.path(node.source.input.from))
  44153. }
  44154. }
  44155. generateString() {
  44156. this.css = '';
  44157. this.map = new SourceMapGenerator$6({ file: this.outputFile() });
  44158. let line = 1;
  44159. let column = 1;
  44160. let noSource = '<no source>';
  44161. let mapping = {
  44162. source: '',
  44163. generated: { line: 0, column: 0 },
  44164. original: { line: 0, column: 0 }
  44165. };
  44166. let lines, last;
  44167. this.stringify(this.root, (str, node, type) => {
  44168. this.css += str;
  44169. if (node && type !== 'end') {
  44170. mapping.generated.line = line;
  44171. mapping.generated.column = column - 1;
  44172. if (node.source && node.source.start) {
  44173. mapping.source = this.sourcePath(node);
  44174. mapping.original.line = node.source.start.line;
  44175. mapping.original.column = node.source.start.column - 1;
  44176. this.map.addMapping(mapping);
  44177. } else {
  44178. mapping.source = noSource;
  44179. mapping.original.line = 1;
  44180. mapping.original.column = 0;
  44181. this.map.addMapping(mapping);
  44182. }
  44183. }
  44184. lines = str.match(/\n/g);
  44185. if (lines) {
  44186. line += lines.length;
  44187. last = str.lastIndexOf('\n');
  44188. column = str.length - last;
  44189. } else {
  44190. column += str.length;
  44191. }
  44192. if (node && type !== 'start') {
  44193. let p = node.parent || { raws: {} };
  44194. if (node.type !== 'decl' || node !== p.last || p.raws.semicolon) {
  44195. if (node.source && node.source.end) {
  44196. mapping.source = this.sourcePath(node);
  44197. mapping.original.line = node.source.end.line;
  44198. mapping.original.column = node.source.end.column - 1;
  44199. mapping.generated.line = line;
  44200. mapping.generated.column = column - 2;
  44201. this.map.addMapping(mapping);
  44202. } else {
  44203. mapping.source = noSource;
  44204. mapping.original.line = 1;
  44205. mapping.original.column = 0;
  44206. mapping.generated.line = line;
  44207. mapping.generated.column = column - 1;
  44208. this.map.addMapping(mapping);
  44209. }
  44210. }
  44211. }
  44212. });
  44213. }
  44214. generate() {
  44215. this.clearAnnotation();
  44216. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  44217. return this.generateMap()
  44218. }
  44219. let result = '';
  44220. this.stringify(this.root, i => {
  44221. result += i;
  44222. });
  44223. return [result]
  44224. }
  44225. }
  44226. var mapGenerator = MapGenerator;
  44227. class Comment extends node_1 {
  44228. constructor(defaults) {
  44229. super(defaults);
  44230. this.type = 'comment';
  44231. }
  44232. }
  44233. var comment = Comment;
  44234. Comment.default = Comment;
  44235. let { isClean: isClean$2, my: my$2 } = symbols;
  44236. let parse$5, Rule, AtRule;
  44237. function cleanSource(nodes) {
  44238. return nodes.map(i => {
  44239. if (i.nodes) i.nodes = cleanSource(i.nodes);
  44240. delete i.source;
  44241. return i
  44242. })
  44243. }
  44244. function markDirtyUp(node) {
  44245. node[isClean$2] = false;
  44246. if (node.proxyOf.nodes) {
  44247. for (let i of node.proxyOf.nodes) {
  44248. markDirtyUp(i);
  44249. }
  44250. }
  44251. }
  44252. class Container extends node_1 {
  44253. push(child) {
  44254. child.parent = this;
  44255. this.proxyOf.nodes.push(child);
  44256. return this
  44257. }
  44258. each(callback) {
  44259. if (!this.proxyOf.nodes) return undefined
  44260. let iterator = this.getIterator();
  44261. let index, result;
  44262. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  44263. index = this.indexes[iterator];
  44264. result = callback(this.proxyOf.nodes[index], index);
  44265. if (result === false) break
  44266. this.indexes[iterator] += 1;
  44267. }
  44268. delete this.indexes[iterator];
  44269. return result
  44270. }
  44271. walk(callback) {
  44272. return this.each((child, i) => {
  44273. let result;
  44274. try {
  44275. result = callback(child, i);
  44276. } catch (e) {
  44277. throw child.addToError(e)
  44278. }
  44279. if (result !== false && child.walk) {
  44280. result = child.walk(callback);
  44281. }
  44282. return result
  44283. })
  44284. }
  44285. walkDecls(prop, callback) {
  44286. if (!callback) {
  44287. callback = prop;
  44288. return this.walk((child, i) => {
  44289. if (child.type === 'decl') {
  44290. return callback(child, i)
  44291. }
  44292. })
  44293. }
  44294. if (prop instanceof RegExp) {
  44295. return this.walk((child, i) => {
  44296. if (child.type === 'decl' && prop.test(child.prop)) {
  44297. return callback(child, i)
  44298. }
  44299. })
  44300. }
  44301. return this.walk((child, i) => {
  44302. if (child.type === 'decl' && child.prop === prop) {
  44303. return callback(child, i)
  44304. }
  44305. })
  44306. }
  44307. walkRules(selector, callback) {
  44308. if (!callback) {
  44309. callback = selector;
  44310. return this.walk((child, i) => {
  44311. if (child.type === 'rule') {
  44312. return callback(child, i)
  44313. }
  44314. })
  44315. }
  44316. if (selector instanceof RegExp) {
  44317. return this.walk((child, i) => {
  44318. if (child.type === 'rule' && selector.test(child.selector)) {
  44319. return callback(child, i)
  44320. }
  44321. })
  44322. }
  44323. return this.walk((child, i) => {
  44324. if (child.type === 'rule' && child.selector === selector) {
  44325. return callback(child, i)
  44326. }
  44327. })
  44328. }
  44329. walkAtRules(name, callback) {
  44330. if (!callback) {
  44331. callback = name;
  44332. return this.walk((child, i) => {
  44333. if (child.type === 'atrule') {
  44334. return callback(child, i)
  44335. }
  44336. })
  44337. }
  44338. if (name instanceof RegExp) {
  44339. return this.walk((child, i) => {
  44340. if (child.type === 'atrule' && name.test(child.name)) {
  44341. return callback(child, i)
  44342. }
  44343. })
  44344. }
  44345. return this.walk((child, i) => {
  44346. if (child.type === 'atrule' && child.name === name) {
  44347. return callback(child, i)
  44348. }
  44349. })
  44350. }
  44351. walkComments(callback) {
  44352. return this.walk((child, i) => {
  44353. if (child.type === 'comment') {
  44354. return callback(child, i)
  44355. }
  44356. })
  44357. }
  44358. append(...children) {
  44359. for (let child of children) {
  44360. let nodes = this.normalize(child, this.last);
  44361. for (let node of nodes) this.proxyOf.nodes.push(node);
  44362. }
  44363. this.markDirty();
  44364. return this
  44365. }
  44366. prepend(...children) {
  44367. children = children.reverse();
  44368. for (let child of children) {
  44369. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  44370. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  44371. for (let id in this.indexes) {
  44372. this.indexes[id] = this.indexes[id] + nodes.length;
  44373. }
  44374. }
  44375. this.markDirty();
  44376. return this
  44377. }
  44378. cleanRaws(keepBetween) {
  44379. super.cleanRaws(keepBetween);
  44380. if (this.nodes) {
  44381. for (let node of this.nodes) node.cleanRaws(keepBetween);
  44382. }
  44383. }
  44384. insertBefore(exist, add) {
  44385. exist = this.index(exist);
  44386. let type = exist === 0 ? 'prepend' : false;
  44387. let nodes = this.normalize(add, this.proxyOf.nodes[exist], type).reverse();
  44388. for (let node of nodes) this.proxyOf.nodes.splice(exist, 0, node);
  44389. let index;
  44390. for (let id in this.indexes) {
  44391. index = this.indexes[id];
  44392. if (exist <= index) {
  44393. this.indexes[id] = index + nodes.length;
  44394. }
  44395. }
  44396. this.markDirty();
  44397. return this
  44398. }
  44399. insertAfter(exist, add) {
  44400. exist = this.index(exist);
  44401. let nodes = this.normalize(add, this.proxyOf.nodes[exist]).reverse();
  44402. for (let node of nodes) this.proxyOf.nodes.splice(exist + 1, 0, node);
  44403. let index;
  44404. for (let id in this.indexes) {
  44405. index = this.indexes[id];
  44406. if (exist < index) {
  44407. this.indexes[id] = index + nodes.length;
  44408. }
  44409. }
  44410. this.markDirty();
  44411. return this
  44412. }
  44413. removeChild(child) {
  44414. child = this.index(child);
  44415. this.proxyOf.nodes[child].parent = undefined;
  44416. this.proxyOf.nodes.splice(child, 1);
  44417. let index;
  44418. for (let id in this.indexes) {
  44419. index = this.indexes[id];
  44420. if (index >= child) {
  44421. this.indexes[id] = index - 1;
  44422. }
  44423. }
  44424. this.markDirty();
  44425. return this
  44426. }
  44427. removeAll() {
  44428. for (let node of this.proxyOf.nodes) node.parent = undefined;
  44429. this.proxyOf.nodes = [];
  44430. this.markDirty();
  44431. return this
  44432. }
  44433. replaceValues(pattern, opts, callback) {
  44434. if (!callback) {
  44435. callback = opts;
  44436. opts = {};
  44437. }
  44438. this.walkDecls(decl => {
  44439. if (opts.props && !opts.props.includes(decl.prop)) return
  44440. if (opts.fast && !decl.value.includes(opts.fast)) return
  44441. decl.value = decl.value.replace(pattern, callback);
  44442. });
  44443. this.markDirty();
  44444. return this
  44445. }
  44446. every(condition) {
  44447. return this.nodes.every(condition)
  44448. }
  44449. some(condition) {
  44450. return this.nodes.some(condition)
  44451. }
  44452. index(child) {
  44453. if (typeof child === 'number') return child
  44454. if (child.proxyOf) child = child.proxyOf;
  44455. return this.proxyOf.nodes.indexOf(child)
  44456. }
  44457. get first() {
  44458. if (!this.proxyOf.nodes) return undefined
  44459. return this.proxyOf.nodes[0]
  44460. }
  44461. get last() {
  44462. if (!this.proxyOf.nodes) return undefined
  44463. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  44464. }
  44465. normalize(nodes, sample) {
  44466. if (typeof nodes === 'string') {
  44467. nodes = cleanSource(parse$5(nodes).nodes);
  44468. } else if (Array.isArray(nodes)) {
  44469. nodes = nodes.slice(0);
  44470. for (let i of nodes) {
  44471. if (i.parent) i.parent.removeChild(i, 'ignore');
  44472. }
  44473. } else if (nodes.type === 'root' && this.type !== 'document') {
  44474. nodes = nodes.nodes.slice(0);
  44475. for (let i of nodes) {
  44476. if (i.parent) i.parent.removeChild(i, 'ignore');
  44477. }
  44478. } else if (nodes.type) {
  44479. nodes = [nodes];
  44480. } else if (nodes.prop) {
  44481. if (typeof nodes.value === 'undefined') {
  44482. throw new Error('Value field is missed in node creation')
  44483. } else if (typeof nodes.value !== 'string') {
  44484. nodes.value = String(nodes.value);
  44485. }
  44486. nodes = [new declaration(nodes)];
  44487. } else if (nodes.selector) {
  44488. nodes = [new Rule(nodes)];
  44489. } else if (nodes.name) {
  44490. nodes = [new AtRule(nodes)];
  44491. } else if (nodes.text) {
  44492. nodes = [new comment(nodes)];
  44493. } else {
  44494. throw new Error('Unknown node type in node creation')
  44495. }
  44496. let processed = nodes.map(i => {
  44497. // istanbul ignore next
  44498. if (!i[my$2]) Container.rebuild(i);
  44499. i = i.proxyOf;
  44500. if (i.parent) i.parent.removeChild(i);
  44501. if (i[isClean$2]) markDirtyUp(i);
  44502. if (typeof i.raws.before === 'undefined') {
  44503. if (sample && typeof sample.raws.before !== 'undefined') {
  44504. i.raws.before = sample.raws.before.replace(/\S/g, '');
  44505. }
  44506. }
  44507. i.parent = this;
  44508. return i
  44509. });
  44510. return processed
  44511. }
  44512. getProxyProcessor() {
  44513. return {
  44514. set(node, prop, value) {
  44515. if (node[prop] === value) return true
  44516. node[prop] = value;
  44517. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  44518. node.markDirty();
  44519. }
  44520. return true
  44521. },
  44522. get(node, prop) {
  44523. if (prop === 'proxyOf') {
  44524. return node
  44525. } else if (!node[prop]) {
  44526. return node[prop]
  44527. } else if (
  44528. prop === 'each' ||
  44529. (typeof prop === 'string' && prop.startsWith('walk'))
  44530. ) {
  44531. return (...args) => {
  44532. return node[prop](
  44533. ...args.map(i => {
  44534. if (typeof i === 'function') {
  44535. return (child, index) => i(child.toProxy(), index)
  44536. } else {
  44537. return i
  44538. }
  44539. })
  44540. )
  44541. }
  44542. } else if (prop === 'every' || prop === 'some') {
  44543. return cb => {
  44544. return node[prop]((child, ...other) =>
  44545. cb(child.toProxy(), ...other)
  44546. )
  44547. }
  44548. } else if (prop === 'root') {
  44549. return () => node.root().toProxy()
  44550. } else if (prop === 'nodes') {
  44551. return node.nodes.map(i => i.toProxy())
  44552. } else if (prop === 'first' || prop === 'last') {
  44553. return node[prop].toProxy()
  44554. } else {
  44555. return node[prop]
  44556. }
  44557. }
  44558. }
  44559. }
  44560. getIterator() {
  44561. if (!this.lastEach) this.lastEach = 0;
  44562. if (!this.indexes) this.indexes = {};
  44563. this.lastEach += 1;
  44564. let iterator = this.lastEach;
  44565. this.indexes[iterator] = 0;
  44566. return iterator
  44567. }
  44568. }
  44569. Container.registerParse = dependant => {
  44570. parse$5 = dependant;
  44571. };
  44572. Container.registerRule = dependant => {
  44573. Rule = dependant;
  44574. };
  44575. Container.registerAtRule = dependant => {
  44576. AtRule = dependant;
  44577. };
  44578. var container = Container;
  44579. Container.default = Container;
  44580. // istanbul ignore next
  44581. Container.rebuild = node => {
  44582. if (node.type === 'atrule') {
  44583. Object.setPrototypeOf(node, AtRule.prototype);
  44584. } else if (node.type === 'rule') {
  44585. Object.setPrototypeOf(node, Rule.prototype);
  44586. } else if (node.type === 'decl') {
  44587. Object.setPrototypeOf(node, declaration.prototype);
  44588. } else if (node.type === 'comment') {
  44589. Object.setPrototypeOf(node, comment.prototype);
  44590. }
  44591. node[my$2] = true;
  44592. if (node.nodes) {
  44593. node.nodes.forEach(child => {
  44594. Container.rebuild(child);
  44595. });
  44596. }
  44597. };
  44598. let LazyResult, Processor;
  44599. class Document extends container {
  44600. constructor(defaults) {
  44601. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  44602. super({ type: 'document', ...defaults });
  44603. if (!this.nodes) {
  44604. this.nodes = [];
  44605. }
  44606. }
  44607. toResult(opts = {}) {
  44608. let lazy = new LazyResult(new Processor(), this, opts);
  44609. return lazy.stringify()
  44610. }
  44611. }
  44612. Document.registerLazyResult = dependant => {
  44613. LazyResult = dependant;
  44614. };
  44615. Document.registerProcessor = dependant => {
  44616. Processor = dependant;
  44617. };
  44618. var document = Document;
  44619. Document.default = Document;
  44620. let printed = {};
  44621. var warnOnce$1 = function warnOnce(message) {
  44622. if (printed[message]) return
  44623. printed[message] = true;
  44624. if (typeof console !== 'undefined' && console.warn) {
  44625. console.warn(message);
  44626. }
  44627. };
  44628. class Warning {
  44629. constructor(text, opts = {}) {
  44630. this.type = 'warning';
  44631. this.text = text;
  44632. if (opts.node && opts.node.source) {
  44633. let pos = opts.node.positionBy(opts);
  44634. this.line = pos.line;
  44635. this.column = pos.column;
  44636. }
  44637. for (let opt in opts) this[opt] = opts[opt];
  44638. }
  44639. toString() {
  44640. if (this.node) {
  44641. return this.node.error(this.text, {
  44642. plugin: this.plugin,
  44643. index: this.index,
  44644. word: this.word
  44645. }).message
  44646. }
  44647. if (this.plugin) {
  44648. return this.plugin + ': ' + this.text
  44649. }
  44650. return this.text
  44651. }
  44652. }
  44653. var warning = Warning;
  44654. Warning.default = Warning;
  44655. class Result {
  44656. constructor(processor, root, opts) {
  44657. this.processor = processor;
  44658. this.messages = [];
  44659. this.root = root;
  44660. this.opts = opts;
  44661. this.css = undefined;
  44662. this.map = undefined;
  44663. }
  44664. toString() {
  44665. return this.css
  44666. }
  44667. warn(text, opts = {}) {
  44668. if (!opts.plugin) {
  44669. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  44670. opts.plugin = this.lastPlugin.postcssPlugin;
  44671. }
  44672. }
  44673. let warning$1 = new warning(text, opts);
  44674. this.messages.push(warning$1);
  44675. return warning$1
  44676. }
  44677. warnings() {
  44678. return this.messages.filter(i => i.type === 'warning')
  44679. }
  44680. get content() {
  44681. return this.css
  44682. }
  44683. }
  44684. var result = Result;
  44685. Result.default = Result;
  44686. class AtRule$1 extends container {
  44687. constructor(defaults) {
  44688. super(defaults);
  44689. this.type = 'atrule';
  44690. }
  44691. append(...children) {
  44692. if (!this.proxyOf.nodes) this.nodes = [];
  44693. return super.append(...children)
  44694. }
  44695. prepend(...children) {
  44696. if (!this.proxyOf.nodes) this.nodes = [];
  44697. return super.prepend(...children)
  44698. }
  44699. }
  44700. var atRule = AtRule$1;
  44701. AtRule$1.default = AtRule$1;
  44702. container.registerAtRule(AtRule$1);
  44703. let LazyResult$1, Processor$1;
  44704. class Root extends container {
  44705. constructor(defaults) {
  44706. super(defaults);
  44707. this.type = 'root';
  44708. if (!this.nodes) this.nodes = [];
  44709. }
  44710. removeChild(child, ignore) {
  44711. let index = this.index(child);
  44712. if (!ignore && index === 0 && this.nodes.length > 1) {
  44713. this.nodes[1].raws.before = this.nodes[index].raws.before;
  44714. }
  44715. return super.removeChild(child)
  44716. }
  44717. normalize(child, sample, type) {
  44718. let nodes = super.normalize(child);
  44719. if (sample) {
  44720. if (type === 'prepend') {
  44721. if (this.nodes.length > 1) {
  44722. sample.raws.before = this.nodes[1].raws.before;
  44723. } else {
  44724. delete sample.raws.before;
  44725. }
  44726. } else if (this.first !== sample) {
  44727. for (let node of nodes) {
  44728. node.raws.before = sample.raws.before;
  44729. }
  44730. }
  44731. }
  44732. return nodes
  44733. }
  44734. toResult(opts = {}) {
  44735. let lazy = new LazyResult$1(new Processor$1(), this, opts);
  44736. return lazy.stringify()
  44737. }
  44738. }
  44739. Root.registerLazyResult = dependant => {
  44740. LazyResult$1 = dependant;
  44741. };
  44742. Root.registerProcessor = dependant => {
  44743. Processor$1 = dependant;
  44744. };
  44745. var root = Root;
  44746. Root.default = Root;
  44747. let list = {
  44748. split(string, separators, last) {
  44749. let array = [];
  44750. let current = '';
  44751. let split = false;
  44752. let func = 0;
  44753. let quote = false;
  44754. let escape = false;
  44755. for (let letter of string) {
  44756. if (escape) {
  44757. escape = false;
  44758. } else if (letter === '\\') {
  44759. escape = true;
  44760. } else if (quote) {
  44761. if (letter === quote) {
  44762. quote = false;
  44763. }
  44764. } else if (letter === '"' || letter === "'") {
  44765. quote = letter;
  44766. } else if (letter === '(') {
  44767. func += 1;
  44768. } else if (letter === ')') {
  44769. if (func > 0) func -= 1;
  44770. } else if (func === 0) {
  44771. if (separators.includes(letter)) split = true;
  44772. }
  44773. if (split) {
  44774. if (current !== '') array.push(current.trim());
  44775. current = '';
  44776. split = false;
  44777. } else {
  44778. current += letter;
  44779. }
  44780. }
  44781. if (last || current !== '') array.push(current.trim());
  44782. return array
  44783. },
  44784. space(string) {
  44785. let spaces = [' ', '\n', '\t'];
  44786. return list.split(string, spaces)
  44787. },
  44788. comma(string) {
  44789. return list.split(string, [','], true)
  44790. }
  44791. };
  44792. var list_1 = list;
  44793. list.default = list;
  44794. class Rule$1 extends container {
  44795. constructor(defaults) {
  44796. super(defaults);
  44797. this.type = 'rule';
  44798. if (!this.nodes) this.nodes = [];
  44799. }
  44800. get selectors() {
  44801. return list_1.comma(this.selector)
  44802. }
  44803. set selectors(values) {
  44804. let match = this.selector ? this.selector.match(/,\s*/) : null;
  44805. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  44806. this.selector = values.join(sep);
  44807. }
  44808. }
  44809. var rule = Rule$1;
  44810. Rule$1.default = Rule$1;
  44811. container.registerRule(Rule$1);
  44812. class Parser$1 {
  44813. constructor(input) {
  44814. this.input = input;
  44815. this.root = new root();
  44816. this.current = this.root;
  44817. this.spaces = '';
  44818. this.semicolon = false;
  44819. this.customProperty = false;
  44820. this.createTokenizer();
  44821. this.root.source = { input, start: { offset: 0, line: 1, column: 1 } };
  44822. }
  44823. createTokenizer() {
  44824. this.tokenizer = tokenize(this.input);
  44825. }
  44826. parse() {
  44827. let token;
  44828. while (!this.tokenizer.endOfFile()) {
  44829. token = this.tokenizer.nextToken();
  44830. switch (token[0]) {
  44831. case 'space':
  44832. this.spaces += token[1];
  44833. break
  44834. case ';':
  44835. this.freeSemicolon(token);
  44836. break
  44837. case '}':
  44838. this.end(token);
  44839. break
  44840. case 'comment':
  44841. this.comment(token);
  44842. break
  44843. case 'at-word':
  44844. this.atrule(token);
  44845. break
  44846. case '{':
  44847. this.emptyRule(token);
  44848. break
  44849. default:
  44850. this.other(token);
  44851. break
  44852. }
  44853. }
  44854. this.endFile();
  44855. }
  44856. comment(token) {
  44857. let node = new comment();
  44858. this.init(node, token[2]);
  44859. node.source.end = this.getPosition(token[3] || token[2]);
  44860. let text = token[1].slice(2, -2);
  44861. if (/^\s*$/.test(text)) {
  44862. node.text = '';
  44863. node.raws.left = text;
  44864. node.raws.right = '';
  44865. } else {
  44866. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  44867. node.text = match[2];
  44868. node.raws.left = match[1];
  44869. node.raws.right = match[3];
  44870. }
  44871. }
  44872. emptyRule(token) {
  44873. let node = new rule();
  44874. this.init(node, token[2]);
  44875. node.selector = '';
  44876. node.raws.between = '';
  44877. this.current = node;
  44878. }
  44879. other(start) {
  44880. let end = false;
  44881. let type = null;
  44882. let colon = false;
  44883. let bracket = null;
  44884. let brackets = [];
  44885. let customProperty = start[1].startsWith('--');
  44886. let tokens = [];
  44887. let token = start;
  44888. while (token) {
  44889. type = token[0];
  44890. tokens.push(token);
  44891. if (type === '(' || type === '[') {
  44892. if (!bracket) bracket = token;
  44893. brackets.push(type === '(' ? ')' : ']');
  44894. } else if (customProperty && colon && type === '{') {
  44895. if (!bracket) bracket = token;
  44896. brackets.push('}');
  44897. } else if (brackets.length === 0) {
  44898. if (type === ';') {
  44899. if (colon) {
  44900. this.decl(tokens, customProperty);
  44901. return
  44902. } else {
  44903. break
  44904. }
  44905. } else if (type === '{') {
  44906. this.rule(tokens);
  44907. return
  44908. } else if (type === '}') {
  44909. this.tokenizer.back(tokens.pop());
  44910. end = true;
  44911. break
  44912. } else if (type === ':') {
  44913. colon = true;
  44914. }
  44915. } else if (type === brackets[brackets.length - 1]) {
  44916. brackets.pop();
  44917. if (brackets.length === 0) bracket = null;
  44918. }
  44919. token = this.tokenizer.nextToken();
  44920. }
  44921. if (this.tokenizer.endOfFile()) end = true;
  44922. if (brackets.length > 0) this.unclosedBracket(bracket);
  44923. if (end && colon) {
  44924. while (tokens.length) {
  44925. token = tokens[tokens.length - 1][0];
  44926. if (token !== 'space' && token !== 'comment') break
  44927. this.tokenizer.back(tokens.pop());
  44928. }
  44929. this.decl(tokens, customProperty);
  44930. } else {
  44931. this.unknownWord(tokens);
  44932. }
  44933. }
  44934. rule(tokens) {
  44935. tokens.pop();
  44936. let node = new rule();
  44937. this.init(node, tokens[0][2]);
  44938. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  44939. this.raw(node, 'selector', tokens);
  44940. this.current = node;
  44941. }
  44942. decl(tokens, customProperty) {
  44943. let node = new declaration();
  44944. this.init(node, tokens[0][2]);
  44945. let last = tokens[tokens.length - 1];
  44946. if (last[0] === ';') {
  44947. this.semicolon = true;
  44948. tokens.pop();
  44949. }
  44950. node.source.end = this.getPosition(last[3] || last[2]);
  44951. while (tokens[0][0] !== 'word') {
  44952. if (tokens.length === 1) this.unknownWord(tokens);
  44953. node.raws.before += tokens.shift()[1];
  44954. }
  44955. node.source.start = this.getPosition(tokens[0][2]);
  44956. node.prop = '';
  44957. while (tokens.length) {
  44958. let type = tokens[0][0];
  44959. if (type === ':' || type === 'space' || type === 'comment') {
  44960. break
  44961. }
  44962. node.prop += tokens.shift()[1];
  44963. }
  44964. node.raws.between = '';
  44965. let token;
  44966. while (tokens.length) {
  44967. token = tokens.shift();
  44968. if (token[0] === ':') {
  44969. node.raws.between += token[1];
  44970. break
  44971. } else {
  44972. if (token[0] === 'word' && /\w/.test(token[1])) {
  44973. this.unknownWord([token]);
  44974. }
  44975. node.raws.between += token[1];
  44976. }
  44977. }
  44978. if (node.prop[0] === '_' || node.prop[0] === '*') {
  44979. node.raws.before += node.prop[0];
  44980. node.prop = node.prop.slice(1);
  44981. }
  44982. let firstSpaces = this.spacesAndCommentsFromStart(tokens);
  44983. this.precheckMissedSemicolon(tokens);
  44984. for (let i = tokens.length - 1; i >= 0; i--) {
  44985. token = tokens[i];
  44986. if (token[1].toLowerCase() === '!important') {
  44987. node.important = true;
  44988. let string = this.stringFrom(tokens, i);
  44989. string = this.spacesFromEnd(tokens) + string;
  44990. if (string !== ' !important') node.raws.important = string;
  44991. break
  44992. } else if (token[1].toLowerCase() === 'important') {
  44993. let cache = tokens.slice(0);
  44994. let str = '';
  44995. for (let j = i; j > 0; j--) {
  44996. let type = cache[j][0];
  44997. if (str.trim().indexOf('!') === 0 && type !== 'space') {
  44998. break
  44999. }
  45000. str = cache.pop()[1] + str;
  45001. }
  45002. if (str.trim().indexOf('!') === 0) {
  45003. node.important = true;
  45004. node.raws.important = str;
  45005. tokens = cache;
  45006. }
  45007. }
  45008. if (token[0] !== 'space' && token[0] !== 'comment') {
  45009. break
  45010. }
  45011. }
  45012. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  45013. this.raw(node, 'value', tokens);
  45014. if (hasWord) {
  45015. node.raws.between += firstSpaces;
  45016. } else {
  45017. node.value = firstSpaces + node.value;
  45018. }
  45019. if (node.value.includes(':') && !customProperty) {
  45020. this.checkMissedSemicolon(tokens);
  45021. }
  45022. }
  45023. atrule(token) {
  45024. let node = new atRule();
  45025. node.name = token[1].slice(1);
  45026. if (node.name === '') {
  45027. this.unnamedAtrule(node, token);
  45028. }
  45029. this.init(node, token[2]);
  45030. let type;
  45031. let prev;
  45032. let shift;
  45033. let last = false;
  45034. let open = false;
  45035. let params = [];
  45036. let brackets = [];
  45037. while (!this.tokenizer.endOfFile()) {
  45038. token = this.tokenizer.nextToken();
  45039. type = token[0];
  45040. if (type === '(' || type === '[') {
  45041. brackets.push(type === '(' ? ')' : ']');
  45042. } else if (type === '{' && brackets.length > 0) {
  45043. brackets.push('}');
  45044. } else if (type === brackets[brackets.length - 1]) {
  45045. brackets.pop();
  45046. }
  45047. if (brackets.length === 0) {
  45048. if (type === ';') {
  45049. node.source.end = this.getPosition(token[2]);
  45050. this.semicolon = true;
  45051. break
  45052. } else if (type === '{') {
  45053. open = true;
  45054. break
  45055. } else if (type === '}') {
  45056. if (params.length > 0) {
  45057. shift = params.length - 1;
  45058. prev = params[shift];
  45059. while (prev && prev[0] === 'space') {
  45060. prev = params[--shift];
  45061. }
  45062. if (prev) {
  45063. node.source.end = this.getPosition(prev[3] || prev[2]);
  45064. }
  45065. }
  45066. this.end(token);
  45067. break
  45068. } else {
  45069. params.push(token);
  45070. }
  45071. } else {
  45072. params.push(token);
  45073. }
  45074. if (this.tokenizer.endOfFile()) {
  45075. last = true;
  45076. break
  45077. }
  45078. }
  45079. node.raws.between = this.spacesAndCommentsFromEnd(params);
  45080. if (params.length) {
  45081. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  45082. this.raw(node, 'params', params);
  45083. if (last) {
  45084. token = params[params.length - 1];
  45085. node.source.end = this.getPosition(token[3] || token[2]);
  45086. this.spaces = node.raws.between;
  45087. node.raws.between = '';
  45088. }
  45089. } else {
  45090. node.raws.afterName = '';
  45091. node.params = '';
  45092. }
  45093. if (open) {
  45094. node.nodes = [];
  45095. this.current = node;
  45096. }
  45097. }
  45098. end(token) {
  45099. if (this.current.nodes && this.current.nodes.length) {
  45100. this.current.raws.semicolon = this.semicolon;
  45101. }
  45102. this.semicolon = false;
  45103. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  45104. this.spaces = '';
  45105. if (this.current.parent) {
  45106. this.current.source.end = this.getPosition(token[2]);
  45107. this.current = this.current.parent;
  45108. } else {
  45109. this.unexpectedClose(token);
  45110. }
  45111. }
  45112. endFile() {
  45113. if (this.current.parent) this.unclosedBlock();
  45114. if (this.current.nodes && this.current.nodes.length) {
  45115. this.current.raws.semicolon = this.semicolon;
  45116. }
  45117. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  45118. }
  45119. freeSemicolon(token) {
  45120. this.spaces += token[1];
  45121. if (this.current.nodes) {
  45122. let prev = this.current.nodes[this.current.nodes.length - 1];
  45123. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  45124. prev.raws.ownSemicolon = this.spaces;
  45125. this.spaces = '';
  45126. }
  45127. }
  45128. }
  45129. // Helpers
  45130. getPosition(offset) {
  45131. let pos = this.input.fromOffset(offset);
  45132. return {
  45133. offset,
  45134. line: pos.line,
  45135. column: pos.col
  45136. }
  45137. }
  45138. init(node, offset) {
  45139. this.current.push(node);
  45140. node.source = {
  45141. start: this.getPosition(offset),
  45142. input: this.input
  45143. };
  45144. node.raws.before = this.spaces;
  45145. this.spaces = '';
  45146. if (node.type !== 'comment') this.semicolon = false;
  45147. }
  45148. raw(node, prop, tokens) {
  45149. let token, type;
  45150. let length = tokens.length;
  45151. let value = '';
  45152. let clean = true;
  45153. let next, prev;
  45154. let pattern = /^([#.|])?(\w)+/i;
  45155. for (let i = 0; i < length; i += 1) {
  45156. token = tokens[i];
  45157. type = token[0];
  45158. if (type === 'comment' && node.type === 'rule') {
  45159. prev = tokens[i - 1];
  45160. next = tokens[i + 1];
  45161. if (
  45162. prev[0] !== 'space' &&
  45163. next[0] !== 'space' &&
  45164. pattern.test(prev[1]) &&
  45165. pattern.test(next[1])
  45166. ) {
  45167. value += token[1];
  45168. } else {
  45169. clean = false;
  45170. }
  45171. continue
  45172. }
  45173. if (type === 'comment' || (type === 'space' && i === length - 1)) {
  45174. clean = false;
  45175. } else {
  45176. value += token[1];
  45177. }
  45178. }
  45179. if (!clean) {
  45180. let raw = tokens.reduce((all, i) => all + i[1], '');
  45181. node.raws[prop] = { value, raw };
  45182. }
  45183. node[prop] = value;
  45184. }
  45185. spacesAndCommentsFromEnd(tokens) {
  45186. let lastTokenType;
  45187. let spaces = '';
  45188. while (tokens.length) {
  45189. lastTokenType = tokens[tokens.length - 1][0];
  45190. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  45191. spaces = tokens.pop()[1] + spaces;
  45192. }
  45193. return spaces
  45194. }
  45195. spacesAndCommentsFromStart(tokens) {
  45196. let next;
  45197. let spaces = '';
  45198. while (tokens.length) {
  45199. next = tokens[0][0];
  45200. if (next !== 'space' && next !== 'comment') break
  45201. spaces += tokens.shift()[1];
  45202. }
  45203. return spaces
  45204. }
  45205. spacesFromEnd(tokens) {
  45206. let lastTokenType;
  45207. let spaces = '';
  45208. while (tokens.length) {
  45209. lastTokenType = tokens[tokens.length - 1][0];
  45210. if (lastTokenType !== 'space') break
  45211. spaces = tokens.pop()[1] + spaces;
  45212. }
  45213. return spaces
  45214. }
  45215. stringFrom(tokens, from) {
  45216. let result = '';
  45217. for (let i = from; i < tokens.length; i++) {
  45218. result += tokens[i][1];
  45219. }
  45220. tokens.splice(from, tokens.length - from);
  45221. return result
  45222. }
  45223. colon(tokens) {
  45224. let brackets = 0;
  45225. let token, type, prev;
  45226. for (let [i, element] of tokens.entries()) {
  45227. token = element;
  45228. type = token[0];
  45229. if (type === '(') {
  45230. brackets += 1;
  45231. }
  45232. if (type === ')') {
  45233. brackets -= 1;
  45234. }
  45235. if (brackets === 0 && type === ':') {
  45236. if (!prev) {
  45237. this.doubleColon(token);
  45238. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  45239. continue
  45240. } else {
  45241. return i
  45242. }
  45243. }
  45244. prev = token;
  45245. }
  45246. return false
  45247. }
  45248. // Errors
  45249. unclosedBracket(bracket) {
  45250. throw this.input.error('Unclosed bracket', bracket[2])
  45251. }
  45252. unknownWord(tokens) {
  45253. throw this.input.error('Unknown word', tokens[0][2])
  45254. }
  45255. unexpectedClose(token) {
  45256. throw this.input.error('Unexpected }', token[2])
  45257. }
  45258. unclosedBlock() {
  45259. let pos = this.current.source.start;
  45260. throw this.input.error('Unclosed block', pos.line, pos.column)
  45261. }
  45262. doubleColon(token) {
  45263. throw this.input.error('Double colon', token[2])
  45264. }
  45265. unnamedAtrule(node, token) {
  45266. throw this.input.error('At-rule without name', token[2])
  45267. }
  45268. precheckMissedSemicolon(/* tokens */) {
  45269. // Hook for Safe Parser
  45270. }
  45271. checkMissedSemicolon(tokens) {
  45272. let colon = this.colon(tokens);
  45273. if (colon === false) return
  45274. let founded = 0;
  45275. let token;
  45276. for (let j = colon - 1; j >= 0; j--) {
  45277. token = tokens[j];
  45278. if (token[0] !== 'space') {
  45279. founded += 1;
  45280. if (founded === 2) break
  45281. }
  45282. }
  45283. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  45284. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  45285. // And because we need it after that one we do +1 to get the next one.
  45286. throw this.input.error(
  45287. 'Missed semicolon',
  45288. token[0] === 'word' ? token[3] + 1 : token[2]
  45289. )
  45290. }
  45291. }
  45292. var parser = Parser$1;
  45293. // This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped
  45294. // optimize the gzip compression for this alphabet.
  45295. let urlAlphabet =
  45296. 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
  45297. let customAlphabet = (alphabet, size) => {
  45298. return () => {
  45299. let id = '';
  45300. // A compact alternative for `for (var i = 0; i < step; i++)`.
  45301. let i = size;
  45302. while (i--) {
  45303. // `| 0` is more compact and faster than `Math.floor()`.
  45304. id += alphabet[(Math.random() * alphabet.length) | 0];
  45305. }
  45306. return id
  45307. }
  45308. };
  45309. let nanoid = (size = 21) => {
  45310. let id = '';
  45311. // A compact alternative for `for (var i = 0; i < step; i++)`.
  45312. let i = size;
  45313. while (i--) {
  45314. // `| 0` is more compact and faster than `Math.floor()`.
  45315. id += urlAlphabet[(Math.random() * 64) | 0];
  45316. }
  45317. return id
  45318. };
  45319. var nonSecure = { nanoid, customAlphabet };
  45320. var _polyfillNode_fs = {};
  45321. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  45322. __proto__: null,
  45323. 'default': _polyfillNode_fs
  45324. });
  45325. var require$$1$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  45326. let { SourceMapConsumer: SourceMapConsumer$5, SourceMapGenerator: SourceMapGenerator$7 } = sourceMap$1;
  45327. let { existsSync, readFileSync } = require$$1$1;
  45328. let { dirname: dirname$2, join: join$1 } = require$$2;
  45329. function fromBase64(str) {
  45330. if (Buffer) {
  45331. return Buffer.from(str, 'base64').toString()
  45332. } else {
  45333. // istanbul ignore next
  45334. return window.atob(str)
  45335. }
  45336. }
  45337. class PreviousMap {
  45338. constructor(css, opts) {
  45339. if (opts.map === false) return
  45340. this.loadAnnotation(css);
  45341. this.inline = this.startWith(this.annotation, 'data:');
  45342. let prev = opts.map ? opts.map.prev : undefined;
  45343. let text = this.loadMap(opts.from, prev);
  45344. if (!this.mapFile && opts.from) {
  45345. this.mapFile = opts.from;
  45346. }
  45347. if (this.mapFile) this.root = dirname$2(this.mapFile);
  45348. if (text) this.text = text;
  45349. }
  45350. consumer() {
  45351. if (!this.consumerCache) {
  45352. this.consumerCache = new SourceMapConsumer$5(this.text);
  45353. }
  45354. return this.consumerCache
  45355. }
  45356. withContent() {
  45357. return !!(
  45358. this.consumer().sourcesContent &&
  45359. this.consumer().sourcesContent.length > 0
  45360. )
  45361. }
  45362. startWith(string, start) {
  45363. if (!string) return false
  45364. return string.substr(0, start.length) === start
  45365. }
  45366. getAnnotationURL(sourceMapString) {
  45367. return sourceMapString
  45368. .match(/\/\*\s*# sourceMappingURL=((?:(?!sourceMappingURL=).)*)\*\//)[1]
  45369. .trim()
  45370. }
  45371. loadAnnotation(css) {
  45372. let annotations = css.match(
  45373. /\/\*\s*# sourceMappingURL=(?:(?!sourceMappingURL=).)*\*\//gm
  45374. );
  45375. if (annotations && annotations.length > 0) {
  45376. // Locate the last sourceMappingURL to avoid picking up
  45377. // sourceMappingURLs from comments, strings, etc.
  45378. let lastAnnotation = annotations[annotations.length - 1];
  45379. if (lastAnnotation) {
  45380. this.annotation = this.getAnnotationURL(lastAnnotation);
  45381. }
  45382. }
  45383. }
  45384. decodeInline(text) {
  45385. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  45386. let baseUri = /^data:application\/json;base64,/;
  45387. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  45388. let uri = /^data:application\/json,/;
  45389. if (charsetUri.test(text) || uri.test(text)) {
  45390. return decodeURIComponent(text.substr(RegExp.lastMatch.length))
  45391. }
  45392. if (baseCharsetUri.test(text) || baseUri.test(text)) {
  45393. return fromBase64(text.substr(RegExp.lastMatch.length))
  45394. }
  45395. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  45396. throw new Error('Unsupported source map encoding ' + encoding)
  45397. }
  45398. loadFile(path) {
  45399. this.root = dirname$2(path);
  45400. if (existsSync(path)) {
  45401. this.mapFile = path;
  45402. return readFileSync(path, 'utf-8').toString().trim()
  45403. }
  45404. }
  45405. loadMap(file, prev) {
  45406. if (prev === false) return false
  45407. if (prev) {
  45408. if (typeof prev === 'string') {
  45409. return prev
  45410. } else if (typeof prev === 'function') {
  45411. let prevPath = prev(file);
  45412. if (prevPath) {
  45413. let map = this.loadFile(prevPath);
  45414. if (!map) {
  45415. throw new Error(
  45416. 'Unable to load previous source map: ' + prevPath.toString()
  45417. )
  45418. }
  45419. return map
  45420. }
  45421. } else if (prev instanceof SourceMapConsumer$5) {
  45422. return SourceMapGenerator$7.fromSourceMap(prev).toString()
  45423. } else if (prev instanceof SourceMapGenerator$7) {
  45424. return prev.toString()
  45425. } else if (this.isMap(prev)) {
  45426. return JSON.stringify(prev)
  45427. } else {
  45428. throw new Error(
  45429. 'Unsupported previous source map format: ' + prev.toString()
  45430. )
  45431. }
  45432. } else if (this.inline) {
  45433. return this.decodeInline(this.annotation)
  45434. } else if (this.annotation) {
  45435. let map = this.annotation;
  45436. if (file) map = join$1(dirname$2(file), map);
  45437. return this.loadFile(map)
  45438. }
  45439. }
  45440. isMap(map) {
  45441. if (typeof map !== 'object') return false
  45442. return (
  45443. typeof map.mappings === 'string' ||
  45444. typeof map._mappings === 'string' ||
  45445. Array.isArray(map.sections)
  45446. )
  45447. }
  45448. }
  45449. var previousMap = PreviousMap;
  45450. PreviousMap.default = PreviousMap;
  45451. let { SourceMapConsumer: SourceMapConsumer$6, SourceMapGenerator: SourceMapGenerator$8 } = sourceMap$1;
  45452. let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$1;
  45453. let { resolve: resolve$2, isAbsolute: isAbsolute$1 } = require$$2;
  45454. let { nanoid: nanoid$1 } = nonSecure;
  45455. let fromOffsetCache = Symbol('fromOffsetCache');
  45456. let sourceMapAvailable$1 = Boolean(SourceMapConsumer$6 && SourceMapGenerator$8);
  45457. let pathAvailable$1 = Boolean(resolve$2 && isAbsolute$1);
  45458. class Input$1 {
  45459. constructor(css, opts = {}) {
  45460. if (
  45461. css === null ||
  45462. typeof css === 'undefined' ||
  45463. (typeof css === 'object' && !css.toString)
  45464. ) {
  45465. throw new Error(`PostCSS received ${css} instead of CSS string`)
  45466. }
  45467. this.css = css.toString();
  45468. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  45469. this.hasBOM = true;
  45470. this.css = this.css.slice(1);
  45471. } else {
  45472. this.hasBOM = false;
  45473. }
  45474. if (opts.from) {
  45475. if (
  45476. !pathAvailable$1 ||
  45477. /^\w+:\/\//.test(opts.from) ||
  45478. isAbsolute$1(opts.from)
  45479. ) {
  45480. this.file = opts.from;
  45481. } else {
  45482. this.file = resolve$2(opts.from);
  45483. }
  45484. }
  45485. if (pathAvailable$1 && sourceMapAvailable$1) {
  45486. let map = new previousMap(this.css, opts);
  45487. if (map.text) {
  45488. this.map = map;
  45489. let file = map.consumer().file;
  45490. if (!this.file && file) this.file = this.mapResolve(file);
  45491. }
  45492. }
  45493. if (!this.file) {
  45494. this.id = '<input css ' + nanoid$1(6) + '>';
  45495. }
  45496. if (this.map) this.map.file = this.from;
  45497. }
  45498. fromOffset(offset) {
  45499. let lastLine, lineToIndex;
  45500. if (!this[fromOffsetCache]) {
  45501. let lines = this.css.split('\n');
  45502. lineToIndex = new Array(lines.length);
  45503. let prevIndex = 0;
  45504. for (let i = 0, l = lines.length; i < l; i++) {
  45505. lineToIndex[i] = prevIndex;
  45506. prevIndex += lines[i].length + 1;
  45507. }
  45508. this[fromOffsetCache] = lineToIndex;
  45509. } else {
  45510. lineToIndex = this[fromOffsetCache];
  45511. }
  45512. lastLine = lineToIndex[lineToIndex.length - 1];
  45513. let min = 0;
  45514. if (offset >= lastLine) {
  45515. min = lineToIndex.length - 1;
  45516. } else {
  45517. let max = lineToIndex.length - 2;
  45518. let mid;
  45519. while (min < max) {
  45520. mid = min + ((max - min) >> 1);
  45521. if (offset < lineToIndex[mid]) {
  45522. max = mid - 1;
  45523. } else if (offset >= lineToIndex[mid + 1]) {
  45524. min = mid + 1;
  45525. } else {
  45526. min = mid;
  45527. break
  45528. }
  45529. }
  45530. }
  45531. return {
  45532. line: min + 1,
  45533. col: offset - lineToIndex[min] + 1
  45534. }
  45535. }
  45536. error(message, line, column, opts = {}) {
  45537. let result;
  45538. if (!column) {
  45539. let pos = this.fromOffset(line);
  45540. line = pos.line;
  45541. column = pos.col;
  45542. }
  45543. let origin = this.origin(line, column);
  45544. if (origin) {
  45545. result = new cssSyntaxError(
  45546. message,
  45547. origin.line,
  45548. origin.column,
  45549. origin.source,
  45550. origin.file,
  45551. opts.plugin
  45552. );
  45553. } else {
  45554. result = new cssSyntaxError(
  45555. message,
  45556. line,
  45557. column,
  45558. this.css,
  45559. this.file,
  45560. opts.plugin
  45561. );
  45562. }
  45563. result.input = { line, column, source: this.css };
  45564. if (this.file) {
  45565. if (pathToFileURL$1) {
  45566. result.input.url = pathToFileURL$1(this.file).toString();
  45567. }
  45568. result.input.file = this.file;
  45569. }
  45570. return result
  45571. }
  45572. origin(line, column) {
  45573. if (!this.map) return false
  45574. let consumer = this.map.consumer();
  45575. let from = consumer.originalPositionFor({ line, column });
  45576. if (!from.source) return false
  45577. let fromUrl;
  45578. if (isAbsolute$1(from.source)) {
  45579. fromUrl = pathToFileURL$1(from.source);
  45580. } else {
  45581. fromUrl = new URL(
  45582. from.source,
  45583. this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
  45584. );
  45585. }
  45586. let result = {
  45587. url: fromUrl.toString(),
  45588. line: from.line,
  45589. column: from.column
  45590. };
  45591. if (fromUrl.protocol === 'file:') {
  45592. if (fileURLToPath) {
  45593. result.file = fileURLToPath(fromUrl);
  45594. } else {
  45595. // istanbul ignore next
  45596. throw new Error(`file: protocol is not available in this PostCSS build`)
  45597. }
  45598. }
  45599. let source = consumer.sourceContentFor(from.source);
  45600. if (source) result.source = source;
  45601. return result
  45602. }
  45603. mapResolve(file) {
  45604. if (/^\w+:\/\//.test(file)) {
  45605. return file
  45606. }
  45607. return resolve$2(this.map.consumer().sourceRoot || this.map.root || '.', file)
  45608. }
  45609. get from() {
  45610. return this.file || this.id
  45611. }
  45612. toJSON() {
  45613. let json = {};
  45614. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  45615. if (this[name] != null) {
  45616. json[name] = this[name];
  45617. }
  45618. }
  45619. if (this.map) {
  45620. json.map = { ...this.map };
  45621. if (json.map.consumerCache) {
  45622. json.map.consumerCache = undefined;
  45623. }
  45624. }
  45625. return json
  45626. }
  45627. }
  45628. var input = Input$1;
  45629. Input$1.default = Input$1;
  45630. if (terminalHighlight_1 && terminalHighlight_1.registerInput) {
  45631. terminalHighlight_1.registerInput(Input$1);
  45632. }
  45633. function parse$6(css, opts) {
  45634. let input$1 = new input(css, opts);
  45635. let parser$1 = new parser(input$1);
  45636. try {
  45637. parser$1.parse();
  45638. } catch (e) {
  45639. {
  45640. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  45641. if (/\.scss$/i.test(opts.from)) {
  45642. e.message +=
  45643. '\nYou tried to parse SCSS with ' +
  45644. 'the standard CSS parser; ' +
  45645. 'try again with the postcss-scss parser';
  45646. } else if (/\.sass/i.test(opts.from)) {
  45647. e.message +=
  45648. '\nYou tried to parse Sass with ' +
  45649. 'the standard CSS parser; ' +
  45650. 'try again with the postcss-sass parser';
  45651. } else if (/\.less$/i.test(opts.from)) {
  45652. e.message +=
  45653. '\nYou tried to parse Less with ' +
  45654. 'the standard CSS parser; ' +
  45655. 'try again with the postcss-less parser';
  45656. }
  45657. }
  45658. }
  45659. throw e
  45660. }
  45661. return parser$1.root
  45662. }
  45663. var parse_1$1 = parse$6;
  45664. parse$6.default = parse$6;
  45665. container.registerParse(parse$6);
  45666. let { isClean: isClean$3, my: my$3 } = symbols;
  45667. const TYPE_TO_CLASS_NAME = {
  45668. document: 'Document',
  45669. root: 'Root',
  45670. atrule: 'AtRule',
  45671. rule: 'Rule',
  45672. decl: 'Declaration',
  45673. comment: 'Comment'
  45674. };
  45675. const PLUGIN_PROPS = {
  45676. postcssPlugin: true,
  45677. prepare: true,
  45678. Once: true,
  45679. Document: true,
  45680. Root: true,
  45681. Declaration: true,
  45682. Rule: true,
  45683. AtRule: true,
  45684. Comment: true,
  45685. DeclarationExit: true,
  45686. RuleExit: true,
  45687. AtRuleExit: true,
  45688. CommentExit: true,
  45689. RootExit: true,
  45690. DocumentExit: true,
  45691. OnceExit: true
  45692. };
  45693. const NOT_VISITORS = {
  45694. postcssPlugin: true,
  45695. prepare: true,
  45696. Once: true
  45697. };
  45698. const CHILDREN = 0;
  45699. function isPromise(obj) {
  45700. return typeof obj === 'object' && typeof obj.then === 'function'
  45701. }
  45702. function getEvents(node) {
  45703. let key = false;
  45704. let type = TYPE_TO_CLASS_NAME[node.type];
  45705. if (node.type === 'decl') {
  45706. key = node.prop.toLowerCase();
  45707. } else if (node.type === 'atrule') {
  45708. key = node.name.toLowerCase();
  45709. }
  45710. if (key && node.append) {
  45711. return [
  45712. type,
  45713. type + '-' + key,
  45714. CHILDREN,
  45715. type + 'Exit',
  45716. type + 'Exit-' + key
  45717. ]
  45718. } else if (key) {
  45719. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  45720. } else if (node.append) {
  45721. return [type, CHILDREN, type + 'Exit']
  45722. } else {
  45723. return [type, type + 'Exit']
  45724. }
  45725. }
  45726. function toStack(node) {
  45727. let events;
  45728. if (node.type === 'document') {
  45729. events = ['Document', CHILDREN, 'DocumentExit'];
  45730. } else if (node.type === 'root') {
  45731. events = ['Root', CHILDREN, 'RootExit'];
  45732. } else {
  45733. events = getEvents(node);
  45734. }
  45735. return {
  45736. node,
  45737. events,
  45738. eventIndex: 0,
  45739. visitors: [],
  45740. visitorIndex: 0,
  45741. iterator: 0
  45742. }
  45743. }
  45744. function cleanMarks(node) {
  45745. node[isClean$3] = false;
  45746. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  45747. return node
  45748. }
  45749. let postcss = {};
  45750. class LazyResult$2 {
  45751. constructor(processor, css, opts) {
  45752. this.stringified = false;
  45753. this.processed = false;
  45754. let root;
  45755. if (
  45756. typeof css === 'object' &&
  45757. css !== null &&
  45758. (css.type === 'root' || css.type === 'document')
  45759. ) {
  45760. root = cleanMarks(css);
  45761. } else if (css instanceof LazyResult$2 || css instanceof result) {
  45762. root = cleanMarks(css.root);
  45763. if (css.map) {
  45764. if (typeof opts.map === 'undefined') opts.map = {};
  45765. if (!opts.map.inline) opts.map.inline = false;
  45766. opts.map.prev = css.map;
  45767. }
  45768. } else {
  45769. let parser = parse_1$1;
  45770. if (opts.syntax) parser = opts.syntax.parse;
  45771. if (opts.parser) parser = opts.parser;
  45772. if (parser.parse) parser = parser.parse;
  45773. try {
  45774. root = parser(css, opts);
  45775. } catch (error) {
  45776. this.processed = true;
  45777. this.error = error;
  45778. }
  45779. if (root && !root[my$3]) {
  45780. // istanbul ignore next
  45781. container.rebuild(root);
  45782. }
  45783. }
  45784. this.result = new result(processor, root, opts);
  45785. this.helpers = { ...postcss, result: this.result, postcss };
  45786. this.plugins = this.processor.plugins.map(plugin => {
  45787. if (typeof plugin === 'object' && plugin.prepare) {
  45788. return { ...plugin, ...plugin.prepare(this.result) }
  45789. } else {
  45790. return plugin
  45791. }
  45792. });
  45793. }
  45794. get [Symbol.toStringTag]() {
  45795. return 'LazyResult'
  45796. }
  45797. get processor() {
  45798. return this.result.processor
  45799. }
  45800. get opts() {
  45801. return this.result.opts
  45802. }
  45803. get css() {
  45804. return this.stringify().css
  45805. }
  45806. get content() {
  45807. return this.stringify().content
  45808. }
  45809. get map() {
  45810. return this.stringify().map
  45811. }
  45812. get root() {
  45813. return this.sync().root
  45814. }
  45815. get messages() {
  45816. return this.sync().messages
  45817. }
  45818. warnings() {
  45819. return this.sync().warnings()
  45820. }
  45821. toString() {
  45822. return this.css
  45823. }
  45824. then(onFulfilled, onRejected) {
  45825. {
  45826. if (!('from' in this.opts)) {
  45827. warnOnce$1(
  45828. 'Without `from` option PostCSS could generate wrong source map ' +
  45829. 'and will not find Browserslist config. Set it to CSS file path ' +
  45830. 'or to `undefined` to prevent this warning.'
  45831. );
  45832. }
  45833. }
  45834. return this.async().then(onFulfilled, onRejected)
  45835. }
  45836. catch(onRejected) {
  45837. return this.async().catch(onRejected)
  45838. }
  45839. finally(onFinally) {
  45840. return this.async().then(onFinally, onFinally)
  45841. }
  45842. async() {
  45843. if (this.error) return Promise.reject(this.error)
  45844. if (this.processed) return Promise.resolve(this.result)
  45845. if (!this.processing) {
  45846. this.processing = this.runAsync();
  45847. }
  45848. return this.processing
  45849. }
  45850. sync() {
  45851. if (this.error) throw this.error
  45852. if (this.processed) return this.result
  45853. this.processed = true;
  45854. if (this.processing) {
  45855. throw this.getAsyncError()
  45856. }
  45857. for (let plugin of this.plugins) {
  45858. let promise = this.runOnRoot(plugin);
  45859. if (isPromise(promise)) {
  45860. throw this.getAsyncError()
  45861. }
  45862. }
  45863. this.prepareVisitors();
  45864. if (this.hasListener) {
  45865. let root = this.result.root;
  45866. while (!root[isClean$3]) {
  45867. root[isClean$3] = true;
  45868. this.walkSync(root);
  45869. }
  45870. if (this.listeners.OnceExit) {
  45871. if (root.type === 'document') {
  45872. for (let subRoot of root.nodes) {
  45873. this.visitSync(this.listeners.OnceExit, subRoot);
  45874. }
  45875. } else {
  45876. this.visitSync(this.listeners.OnceExit, root);
  45877. }
  45878. }
  45879. }
  45880. return this.result
  45881. }
  45882. stringify() {
  45883. if (this.error) throw this.error
  45884. if (this.stringified) return this.result
  45885. this.stringified = true;
  45886. this.sync();
  45887. let opts = this.result.opts;
  45888. let str = stringify_1;
  45889. if (opts.syntax) str = opts.syntax.stringify;
  45890. if (opts.stringifier) str = opts.stringifier;
  45891. if (str.stringify) str = str.stringify;
  45892. let map = new mapGenerator(str, this.result.root, this.result.opts);
  45893. let data = map.generate();
  45894. this.result.css = data[0];
  45895. this.result.map = data[1];
  45896. return this.result
  45897. }
  45898. walkSync(node) {
  45899. node[isClean$3] = true;
  45900. let events = getEvents(node);
  45901. for (let event of events) {
  45902. if (event === CHILDREN) {
  45903. if (node.nodes) {
  45904. node.each(child => {
  45905. if (!child[isClean$3]) this.walkSync(child);
  45906. });
  45907. }
  45908. } else {
  45909. let visitors = this.listeners[event];
  45910. if (visitors) {
  45911. if (this.visitSync(visitors, node.toProxy())) return
  45912. }
  45913. }
  45914. }
  45915. }
  45916. visitSync(visitors, node) {
  45917. for (let [plugin, visitor] of visitors) {
  45918. this.result.lastPlugin = plugin;
  45919. let promise;
  45920. try {
  45921. promise = visitor(node, this.helpers);
  45922. } catch (e) {
  45923. throw this.handleError(e, node.proxyOf)
  45924. }
  45925. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  45926. return true
  45927. }
  45928. if (isPromise(promise)) {
  45929. throw this.getAsyncError()
  45930. }
  45931. }
  45932. }
  45933. runOnRoot(plugin) {
  45934. this.result.lastPlugin = plugin;
  45935. try {
  45936. if (typeof plugin === 'object' && plugin.Once) {
  45937. if (this.result.root.type === 'document') {
  45938. let roots = this.result.root.nodes.map(root =>
  45939. plugin.Once(root, this.helpers)
  45940. );
  45941. if (isPromise(roots[0])) {
  45942. return Promise.all(roots)
  45943. }
  45944. return roots
  45945. }
  45946. return plugin.Once(this.result.root, this.helpers)
  45947. } else if (typeof plugin === 'function') {
  45948. return plugin(this.result.root, this.result)
  45949. }
  45950. } catch (error) {
  45951. throw this.handleError(error)
  45952. }
  45953. }
  45954. getAsyncError() {
  45955. throw new Error('Use process(css).then(cb) to work with async plugins')
  45956. }
  45957. handleError(error, node) {
  45958. let plugin = this.result.lastPlugin;
  45959. try {
  45960. if (node) node.addToError(error);
  45961. this.error = error;
  45962. if (error.name === 'CssSyntaxError' && !error.plugin) {
  45963. error.plugin = plugin.postcssPlugin;
  45964. error.setMessage();
  45965. } else if (plugin.postcssVersion) {
  45966. if (browser$1.env.NODE_ENV !== 'production') {
  45967. let pluginName = plugin.postcssPlugin;
  45968. let pluginVer = plugin.postcssVersion;
  45969. let runtimeVer = this.result.processor.version;
  45970. let a = pluginVer.split('.');
  45971. let b = runtimeVer.split('.');
  45972. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  45973. console.error(
  45974. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  45975. 'version is ' +
  45976. runtimeVer +
  45977. ', but ' +
  45978. pluginName +
  45979. ' uses ' +
  45980. pluginVer +
  45981. '. Perhaps this is the source of the error below.'
  45982. );
  45983. }
  45984. }
  45985. }
  45986. } catch (err) {
  45987. // istanbul ignore next
  45988. if (console && console.error) console.error(err);
  45989. }
  45990. return error
  45991. }
  45992. async runAsync() {
  45993. this.plugin = 0;
  45994. for (let i = 0; i < this.plugins.length; i++) {
  45995. let plugin = this.plugins[i];
  45996. let promise = this.runOnRoot(plugin);
  45997. if (isPromise(promise)) {
  45998. try {
  45999. await promise;
  46000. } catch (error) {
  46001. throw this.handleError(error)
  46002. }
  46003. }
  46004. }
  46005. this.prepareVisitors();
  46006. if (this.hasListener) {
  46007. let root = this.result.root;
  46008. while (!root[isClean$3]) {
  46009. root[isClean$3] = true;
  46010. let stack = [toStack(root)];
  46011. while (stack.length > 0) {
  46012. let promise = this.visitTick(stack);
  46013. if (isPromise(promise)) {
  46014. try {
  46015. await promise;
  46016. } catch (e) {
  46017. let node = stack[stack.length - 1].node;
  46018. throw this.handleError(e, node)
  46019. }
  46020. }
  46021. }
  46022. }
  46023. if (this.listeners.OnceExit) {
  46024. for (let [plugin, visitor] of this.listeners.OnceExit) {
  46025. this.result.lastPlugin = plugin;
  46026. try {
  46027. if (root.type === 'document') {
  46028. let roots = root.nodes.map(subRoot =>
  46029. visitor(subRoot, this.helpers)
  46030. );
  46031. await Promise.all(roots);
  46032. } else {
  46033. await visitor(root, this.helpers);
  46034. }
  46035. } catch (e) {
  46036. throw this.handleError(e)
  46037. }
  46038. }
  46039. }
  46040. }
  46041. this.processed = true;
  46042. return this.stringify()
  46043. }
  46044. prepareVisitors() {
  46045. this.listeners = {};
  46046. let add = (plugin, type, cb) => {
  46047. if (!this.listeners[type]) this.listeners[type] = [];
  46048. this.listeners[type].push([plugin, cb]);
  46049. };
  46050. for (let plugin of this.plugins) {
  46051. if (typeof plugin === 'object') {
  46052. for (let event in plugin) {
  46053. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  46054. throw new Error(
  46055. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  46056. `Try to update PostCSS (${this.processor.version} now).`
  46057. )
  46058. }
  46059. if (!NOT_VISITORS[event]) {
  46060. if (typeof plugin[event] === 'object') {
  46061. for (let filter in plugin[event]) {
  46062. if (filter === '*') {
  46063. add(plugin, event, plugin[event][filter]);
  46064. } else {
  46065. add(
  46066. plugin,
  46067. event + '-' + filter.toLowerCase(),
  46068. plugin[event][filter]
  46069. );
  46070. }
  46071. }
  46072. } else if (typeof plugin[event] === 'function') {
  46073. add(plugin, event, plugin[event]);
  46074. }
  46075. }
  46076. }
  46077. }
  46078. }
  46079. this.hasListener = Object.keys(this.listeners).length > 0;
  46080. }
  46081. visitTick(stack) {
  46082. let visit = stack[stack.length - 1];
  46083. let { node, visitors } = visit;
  46084. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  46085. stack.pop();
  46086. return
  46087. }
  46088. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  46089. let [plugin, visitor] = visitors[visit.visitorIndex];
  46090. visit.visitorIndex += 1;
  46091. if (visit.visitorIndex === visitors.length) {
  46092. visit.visitors = [];
  46093. visit.visitorIndex = 0;
  46094. }
  46095. this.result.lastPlugin = plugin;
  46096. try {
  46097. return visitor(node.toProxy(), this.helpers)
  46098. } catch (e) {
  46099. throw this.handleError(e, node)
  46100. }
  46101. }
  46102. if (visit.iterator !== 0) {
  46103. let iterator = visit.iterator;
  46104. let child;
  46105. while ((child = node.nodes[node.indexes[iterator]])) {
  46106. node.indexes[iterator] += 1;
  46107. if (!child[isClean$3]) {
  46108. child[isClean$3] = true;
  46109. stack.push(toStack(child));
  46110. return
  46111. }
  46112. }
  46113. visit.iterator = 0;
  46114. delete node.indexes[iterator];
  46115. }
  46116. let events = visit.events;
  46117. while (visit.eventIndex < events.length) {
  46118. let event = events[visit.eventIndex];
  46119. visit.eventIndex += 1;
  46120. if (event === CHILDREN) {
  46121. if (node.nodes && node.nodes.length) {
  46122. node[isClean$3] = true;
  46123. visit.iterator = node.getIterator();
  46124. }
  46125. return
  46126. } else if (this.listeners[event]) {
  46127. visit.visitors = this.listeners[event];
  46128. return
  46129. }
  46130. }
  46131. stack.pop();
  46132. }
  46133. }
  46134. LazyResult$2.registerPostcss = dependant => {
  46135. postcss = dependant;
  46136. };
  46137. var lazyResult = LazyResult$2;
  46138. LazyResult$2.default = LazyResult$2;
  46139. root.registerLazyResult(LazyResult$2);
  46140. document.registerLazyResult(LazyResult$2);
  46141. class Processor$2 {
  46142. constructor(plugins = []) {
  46143. this.version = '8.3.6';
  46144. this.plugins = this.normalize(plugins);
  46145. }
  46146. use(plugin) {
  46147. this.plugins = this.plugins.concat(this.normalize([plugin]));
  46148. return this
  46149. }
  46150. process(css, opts = {}) {
  46151. if (
  46152. this.plugins.length === 0 &&
  46153. typeof opts.parser === 'undefined' &&
  46154. typeof opts.stringifier === 'undefined' &&
  46155. typeof opts.syntax === 'undefined' &&
  46156. !opts.hideNothingWarning
  46157. ) {
  46158. {
  46159. if (typeof console !== 'undefined' && console.warn) {
  46160. console.warn(
  46161. 'You did not set any plugins, parser, or stringifier. ' +
  46162. 'Right now, PostCSS does nothing. Pick plugins for your case ' +
  46163. 'on https://www.postcss.parts/ and use them in postcss.config.js.'
  46164. );
  46165. }
  46166. }
  46167. }
  46168. return new lazyResult(this, css, opts)
  46169. }
  46170. normalize(plugins) {
  46171. let normalized = [];
  46172. for (let i of plugins) {
  46173. if (i.postcss === true) {
  46174. i = i();
  46175. } else if (i.postcss) {
  46176. i = i.postcss;
  46177. }
  46178. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  46179. normalized = normalized.concat(i.plugins);
  46180. } else if (typeof i === 'object' && i.postcssPlugin) {
  46181. normalized.push(i);
  46182. } else if (typeof i === 'function') {
  46183. normalized.push(i);
  46184. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  46185. {
  46186. throw new Error(
  46187. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  46188. 'one of the syntax/parser/stringifier options as outlined ' +
  46189. 'in your PostCSS runner documentation.'
  46190. )
  46191. }
  46192. } else {
  46193. throw new Error(i + ' is not a PostCSS plugin')
  46194. }
  46195. }
  46196. return normalized
  46197. }
  46198. }
  46199. var processor = Processor$2;
  46200. Processor$2.default = Processor$2;
  46201. root.registerProcessor(Processor$2);
  46202. document.registerProcessor(Processor$2);
  46203. function fromJSON(json, inputs) {
  46204. if (Array.isArray(json)) return json.map(n => fromJSON(n))
  46205. let { inputs: ownInputs, ...defaults } = json;
  46206. if (ownInputs) {
  46207. inputs = [];
  46208. for (let input$1 of ownInputs) {
  46209. let inputHydrated = { ...input$1, __proto__: input.prototype };
  46210. if (inputHydrated.map) {
  46211. inputHydrated.map = {
  46212. ...inputHydrated.map,
  46213. __proto__: previousMap.prototype
  46214. };
  46215. }
  46216. inputs.push(inputHydrated);
  46217. }
  46218. }
  46219. if (defaults.nodes) {
  46220. defaults.nodes = json.nodes.map(n => fromJSON(n, inputs));
  46221. }
  46222. if (defaults.source) {
  46223. let { inputId, ...source } = defaults.source;
  46224. defaults.source = source;
  46225. if (inputId != null) {
  46226. defaults.source.input = inputs[inputId];
  46227. }
  46228. }
  46229. if (defaults.type === 'root') {
  46230. return new root(defaults)
  46231. } else if (defaults.type === 'decl') {
  46232. return new declaration(defaults)
  46233. } else if (defaults.type === 'rule') {
  46234. return new rule(defaults)
  46235. } else if (defaults.type === 'comment') {
  46236. return new comment(defaults)
  46237. } else if (defaults.type === 'atrule') {
  46238. return new atRule(defaults)
  46239. } else {
  46240. throw new Error('Unknown node type: ' + json.type)
  46241. }
  46242. }
  46243. var fromJSON_1 = fromJSON;
  46244. fromJSON.default = fromJSON;
  46245. function postcss$1(...plugins) {
  46246. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  46247. plugins = plugins[0];
  46248. }
  46249. return new processor(plugins)
  46250. }
  46251. postcss$1.plugin = function plugin(name, initializer) {
  46252. if (console && console.warn) {
  46253. console.warn(
  46254. name +
  46255. ': postcss.plugin was deprecated. Migration guide:\n' +
  46256. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  46257. );
  46258. }
  46259. function creator(...args) {
  46260. let transformer = initializer(...args);
  46261. transformer.postcssPlugin = name;
  46262. transformer.postcssVersion = new processor().version;
  46263. return transformer
  46264. }
  46265. let cache;
  46266. Object.defineProperty(creator, 'postcss', {
  46267. get() {
  46268. if (!cache) cache = creator();
  46269. return cache
  46270. }
  46271. });
  46272. creator.process = function (css, processOpts, pluginOpts) {
  46273. return postcss$1([creator(pluginOpts)]).process(css, processOpts)
  46274. };
  46275. return creator
  46276. };
  46277. postcss$1.stringify = stringify_1;
  46278. postcss$1.parse = parse_1$1;
  46279. postcss$1.fromJSON = fromJSON_1;
  46280. postcss$1.list = list_1;
  46281. postcss$1.comment = defaults => new comment(defaults);
  46282. postcss$1.atRule = defaults => new atRule(defaults);
  46283. postcss$1.decl = defaults => new declaration(defaults);
  46284. postcss$1.rule = defaults => new rule(defaults);
  46285. postcss$1.root = defaults => new root(defaults);
  46286. postcss$1.document = defaults => new document(defaults);
  46287. postcss$1.CssSyntaxError = cssSyntaxError;
  46288. postcss$1.Declaration = declaration;
  46289. postcss$1.Container = container;
  46290. postcss$1.Document = document;
  46291. postcss$1.Comment = comment;
  46292. postcss$1.Warning = warning;
  46293. postcss$1.AtRule = atRule;
  46294. postcss$1.Result = result;
  46295. postcss$1.Input = input;
  46296. postcss$1.Rule = rule;
  46297. postcss$1.Root = root;
  46298. postcss$1.Node = node_1;
  46299. lazyResult.registerPostcss(postcss$1);
  46300. var postcss_1 = postcss$1;
  46301. postcss$1.default = postcss$1;
  46302. const trimPlugin = () => {
  46303. return {
  46304. postcssPlugin: 'vue-sfc-trim',
  46305. Once(root) {
  46306. root.walk(({ type, raws }) => {
  46307. if (type === 'rule' || type === 'atrule') {
  46308. if (raws.before)
  46309. raws.before = '\n';
  46310. if ('after' in raws && raws.after)
  46311. raws.after = '\n';
  46312. }
  46313. });
  46314. }
  46315. };
  46316. };
  46317. trimPlugin.postcss = true;
  46318. var unesc_1 = createCommonjsModule(function (module, exports) {
  46319. exports.__esModule = true;
  46320. exports["default"] = unesc;
  46321. // Many thanks for this post which made this migration much easier.
  46322. // https://mathiasbynens.be/notes/css-escapes
  46323. /**
  46324. *
  46325. * @param {string} str
  46326. * @returns {[string, number]|undefined}
  46327. */
  46328. function gobbleHex(str) {
  46329. var lower = str.toLowerCase();
  46330. var hex = '';
  46331. var spaceTerminated = false;
  46332. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  46333. var code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]
  46334. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  46335. spaceTerminated = code === 32;
  46336. if (!valid) {
  46337. break;
  46338. }
  46339. hex += lower[i];
  46340. }
  46341. if (hex.length === 0) {
  46342. return undefined;
  46343. }
  46344. var codePoint = parseInt(hex, 16);
  46345. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; // Add special case for
  46346. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  46347. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  46348. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  46349. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  46350. }
  46351. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  46352. }
  46353. var CONTAINS_ESCAPE = /\\/;
  46354. function unesc(str) {
  46355. var needToProcess = CONTAINS_ESCAPE.test(str);
  46356. if (!needToProcess) {
  46357. return str;
  46358. }
  46359. var ret = "";
  46360. for (var i = 0; i < str.length; i++) {
  46361. if (str[i] === "\\") {
  46362. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  46363. if (gobbled !== undefined) {
  46364. ret += gobbled[0];
  46365. i += gobbled[1];
  46366. continue;
  46367. } // Retain a pair of \\ if double escaped `\\\\`
  46368. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  46369. if (str[i + 1] === "\\") {
  46370. ret += "\\";
  46371. i++;
  46372. continue;
  46373. } // if \\ is at the end of the string retain it
  46374. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  46375. if (str.length === i + 1) {
  46376. ret += str[i];
  46377. }
  46378. continue;
  46379. }
  46380. ret += str[i];
  46381. }
  46382. return ret;
  46383. }
  46384. module.exports = exports.default;
  46385. });
  46386. var getProp_1 = createCommonjsModule(function (module, exports) {
  46387. exports.__esModule = true;
  46388. exports["default"] = getProp;
  46389. function getProp(obj) {
  46390. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  46391. props[_key - 1] = arguments[_key];
  46392. }
  46393. while (props.length > 0) {
  46394. var prop = props.shift();
  46395. if (!obj[prop]) {
  46396. return undefined;
  46397. }
  46398. obj = obj[prop];
  46399. }
  46400. return obj;
  46401. }
  46402. module.exports = exports.default;
  46403. });
  46404. var ensureObject_1 = createCommonjsModule(function (module, exports) {
  46405. exports.__esModule = true;
  46406. exports["default"] = ensureObject;
  46407. function ensureObject(obj) {
  46408. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  46409. props[_key - 1] = arguments[_key];
  46410. }
  46411. while (props.length > 0) {
  46412. var prop = props.shift();
  46413. if (!obj[prop]) {
  46414. obj[prop] = {};
  46415. }
  46416. obj = obj[prop];
  46417. }
  46418. }
  46419. module.exports = exports.default;
  46420. });
  46421. var stripComments_1 = createCommonjsModule(function (module, exports) {
  46422. exports.__esModule = true;
  46423. exports["default"] = stripComments;
  46424. function stripComments(str) {
  46425. var s = "";
  46426. var commentStart = str.indexOf("/*");
  46427. var lastEnd = 0;
  46428. while (commentStart >= 0) {
  46429. s = s + str.slice(lastEnd, commentStart);
  46430. var commentEnd = str.indexOf("*/", commentStart + 2);
  46431. if (commentEnd < 0) {
  46432. return s;
  46433. }
  46434. lastEnd = commentEnd + 2;
  46435. commentStart = str.indexOf("/*", lastEnd);
  46436. }
  46437. s = s + str.slice(lastEnd);
  46438. return s;
  46439. }
  46440. module.exports = exports.default;
  46441. });
  46442. var util$2 = createCommonjsModule(function (module, exports) {
  46443. exports.__esModule = true;
  46444. exports.stripComments = exports.ensureObject = exports.getProp = exports.unesc = void 0;
  46445. var _unesc = _interopRequireDefault(unesc_1);
  46446. exports.unesc = _unesc["default"];
  46447. var _getProp = _interopRequireDefault(getProp_1);
  46448. exports.getProp = _getProp["default"];
  46449. var _ensureObject = _interopRequireDefault(ensureObject_1);
  46450. exports.ensureObject = _ensureObject["default"];
  46451. var _stripComments = _interopRequireDefault(stripComments_1);
  46452. exports.stripComments = _stripComments["default"];
  46453. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  46454. });
  46455. var node = createCommonjsModule(function (module, exports) {
  46456. exports.__esModule = true;
  46457. exports["default"] = void 0;
  46458. 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); } }
  46459. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  46460. var cloneNode = function cloneNode(obj, parent) {
  46461. if (typeof obj !== 'object' || obj === null) {
  46462. return obj;
  46463. }
  46464. var cloned = new obj.constructor();
  46465. for (var i in obj) {
  46466. if (!obj.hasOwnProperty(i)) {
  46467. continue;
  46468. }
  46469. var value = obj[i];
  46470. var type = typeof value;
  46471. if (i === 'parent' && type === 'object') {
  46472. if (parent) {
  46473. cloned[i] = parent;
  46474. }
  46475. } else if (value instanceof Array) {
  46476. cloned[i] = value.map(function (j) {
  46477. return cloneNode(j, cloned);
  46478. });
  46479. } else {
  46480. cloned[i] = cloneNode(value, cloned);
  46481. }
  46482. }
  46483. return cloned;
  46484. };
  46485. var Node = /*#__PURE__*/function () {
  46486. function Node(opts) {
  46487. if (opts === void 0) {
  46488. opts = {};
  46489. }
  46490. Object.assign(this, opts);
  46491. this.spaces = this.spaces || {};
  46492. this.spaces.before = this.spaces.before || '';
  46493. this.spaces.after = this.spaces.after || '';
  46494. }
  46495. var _proto = Node.prototype;
  46496. _proto.remove = function remove() {
  46497. if (this.parent) {
  46498. this.parent.removeChild(this);
  46499. }
  46500. this.parent = undefined;
  46501. return this;
  46502. };
  46503. _proto.replaceWith = function replaceWith() {
  46504. if (this.parent) {
  46505. for (var index in arguments) {
  46506. this.parent.insertBefore(this, arguments[index]);
  46507. }
  46508. this.remove();
  46509. }
  46510. return this;
  46511. };
  46512. _proto.next = function next() {
  46513. return this.parent.at(this.parent.index(this) + 1);
  46514. };
  46515. _proto.prev = function prev() {
  46516. return this.parent.at(this.parent.index(this) - 1);
  46517. };
  46518. _proto.clone = function clone(overrides) {
  46519. if (overrides === void 0) {
  46520. overrides = {};
  46521. }
  46522. var cloned = cloneNode(this);
  46523. for (var name in overrides) {
  46524. cloned[name] = overrides[name];
  46525. }
  46526. return cloned;
  46527. }
  46528. /**
  46529. * Some non-standard syntax doesn't follow normal escaping rules for css.
  46530. * This allows non standard syntax to be appended to an existing property
  46531. * by specifying the escaped value. By specifying the escaped value,
  46532. * illegal characters are allowed to be directly inserted into css output.
  46533. * @param {string} name the property to set
  46534. * @param {any} value the unescaped value of the property
  46535. * @param {string} valueEscaped optional. the escaped value of the property.
  46536. */
  46537. ;
  46538. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  46539. if (!this.raws) {
  46540. this.raws = {};
  46541. }
  46542. var originalValue = this[name];
  46543. var originalEscaped = this.raws[name];
  46544. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  46545. if (originalEscaped || valueEscaped !== value) {
  46546. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  46547. } else {
  46548. delete this.raws[name]; // delete any escaped value that was created by the setter.
  46549. }
  46550. }
  46551. /**
  46552. * Some non-standard syntax doesn't follow normal escaping rules for css.
  46553. * This allows the escaped value to be specified directly, allowing illegal
  46554. * characters to be directly inserted into css output.
  46555. * @param {string} name the property to set
  46556. * @param {any} value the unescaped value of the property
  46557. * @param {string} valueEscaped the escaped value of the property.
  46558. */
  46559. ;
  46560. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  46561. if (!this.raws) {
  46562. this.raws = {};
  46563. }
  46564. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  46565. this.raws[name] = valueEscaped;
  46566. }
  46567. /**
  46568. * When you want a value to passed through to CSS directly. This method
  46569. * deletes the corresponding raw value causing the stringifier to fallback
  46570. * to the unescaped value.
  46571. * @param {string} name the property to set.
  46572. * @param {any} value The value that is both escaped and unescaped.
  46573. */
  46574. ;
  46575. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  46576. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  46577. if (this.raws) {
  46578. delete this.raws[name];
  46579. }
  46580. }
  46581. /**
  46582. *
  46583. * @param {number} line The number (starting with 1)
  46584. * @param {number} column The column number (starting with 1)
  46585. */
  46586. ;
  46587. _proto.isAtPosition = function isAtPosition(line, column) {
  46588. if (this.source && this.source.start && this.source.end) {
  46589. if (this.source.start.line > line) {
  46590. return false;
  46591. }
  46592. if (this.source.end.line < line) {
  46593. return false;
  46594. }
  46595. if (this.source.start.line === line && this.source.start.column > column) {
  46596. return false;
  46597. }
  46598. if (this.source.end.line === line && this.source.end.column < column) {
  46599. return false;
  46600. }
  46601. return true;
  46602. }
  46603. return undefined;
  46604. };
  46605. _proto.stringifyProperty = function stringifyProperty(name) {
  46606. return this.raws && this.raws[name] || this[name];
  46607. };
  46608. _proto.valueToString = function valueToString() {
  46609. return String(this.stringifyProperty("value"));
  46610. };
  46611. _proto.toString = function toString() {
  46612. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  46613. };
  46614. _createClass(Node, [{
  46615. key: "rawSpaceBefore",
  46616. get: function get() {
  46617. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  46618. if (rawSpace === undefined) {
  46619. rawSpace = this.spaces && this.spaces.before;
  46620. }
  46621. return rawSpace || "";
  46622. },
  46623. set: function set(raw) {
  46624. (0, util$2.ensureObject)(this, "raws", "spaces");
  46625. this.raws.spaces.before = raw;
  46626. }
  46627. }, {
  46628. key: "rawSpaceAfter",
  46629. get: function get() {
  46630. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  46631. if (rawSpace === undefined) {
  46632. rawSpace = this.spaces.after;
  46633. }
  46634. return rawSpace || "";
  46635. },
  46636. set: function set(raw) {
  46637. (0, util$2.ensureObject)(this, "raws", "spaces");
  46638. this.raws.spaces.after = raw;
  46639. }
  46640. }]);
  46641. return Node;
  46642. }();
  46643. exports["default"] = Node;
  46644. module.exports = exports.default;
  46645. });
  46646. var types$2 = createCommonjsModule(function (module, exports) {
  46647. exports.__esModule = true;
  46648. exports.UNIVERSAL = exports.ATTRIBUTE = exports.CLASS = exports.COMBINATOR = exports.COMMENT = exports.ID = exports.NESTING = exports.PSEUDO = exports.ROOT = exports.SELECTOR = exports.STRING = exports.TAG = void 0;
  46649. var TAG = 'tag';
  46650. exports.TAG = TAG;
  46651. var STRING = 'string';
  46652. exports.STRING = STRING;
  46653. var SELECTOR = 'selector';
  46654. exports.SELECTOR = SELECTOR;
  46655. var ROOT = 'root';
  46656. exports.ROOT = ROOT;
  46657. var PSEUDO = 'pseudo';
  46658. exports.PSEUDO = PSEUDO;
  46659. var NESTING = 'nesting';
  46660. exports.NESTING = NESTING;
  46661. var ID = 'id';
  46662. exports.ID = ID;
  46663. var COMMENT = 'comment';
  46664. exports.COMMENT = COMMENT;
  46665. var COMBINATOR = 'combinator';
  46666. exports.COMBINATOR = COMBINATOR;
  46667. var CLASS = 'class';
  46668. exports.CLASS = CLASS;
  46669. var ATTRIBUTE = 'attribute';
  46670. exports.ATTRIBUTE = ATTRIBUTE;
  46671. var UNIVERSAL = 'universal';
  46672. exports.UNIVERSAL = UNIVERSAL;
  46673. });
  46674. var container$1 = createCommonjsModule(function (module, exports) {
  46675. exports.__esModule = true;
  46676. exports["default"] = void 0;
  46677. var _node = _interopRequireDefault(node);
  46678. var types = _interopRequireWildcard(types$2);
  46679. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  46680. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  46681. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  46682. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  46683. 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); }
  46684. 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; }
  46685. 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); } }
  46686. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  46687. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  46688. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  46689. var Container = /*#__PURE__*/function (_Node) {
  46690. _inheritsLoose(Container, _Node);
  46691. function Container(opts) {
  46692. var _this;
  46693. _this = _Node.call(this, opts) || this;
  46694. if (!_this.nodes) {
  46695. _this.nodes = [];
  46696. }
  46697. return _this;
  46698. }
  46699. var _proto = Container.prototype;
  46700. _proto.append = function append(selector) {
  46701. selector.parent = this;
  46702. this.nodes.push(selector);
  46703. return this;
  46704. };
  46705. _proto.prepend = function prepend(selector) {
  46706. selector.parent = this;
  46707. this.nodes.unshift(selector);
  46708. return this;
  46709. };
  46710. _proto.at = function at(index) {
  46711. return this.nodes[index];
  46712. };
  46713. _proto.index = function index(child) {
  46714. if (typeof child === 'number') {
  46715. return child;
  46716. }
  46717. return this.nodes.indexOf(child);
  46718. };
  46719. _proto.removeChild = function removeChild(child) {
  46720. child = this.index(child);
  46721. this.at(child).parent = undefined;
  46722. this.nodes.splice(child, 1);
  46723. var index;
  46724. for (var id in this.indexes) {
  46725. index = this.indexes[id];
  46726. if (index >= child) {
  46727. this.indexes[id] = index - 1;
  46728. }
  46729. }
  46730. return this;
  46731. };
  46732. _proto.removeAll = function removeAll() {
  46733. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  46734. var node = _step.value;
  46735. node.parent = undefined;
  46736. }
  46737. this.nodes = [];
  46738. return this;
  46739. };
  46740. _proto.empty = function empty() {
  46741. return this.removeAll();
  46742. };
  46743. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  46744. newNode.parent = this;
  46745. var oldIndex = this.index(oldNode);
  46746. this.nodes.splice(oldIndex + 1, 0, newNode);
  46747. newNode.parent = this;
  46748. var index;
  46749. for (var id in this.indexes) {
  46750. index = this.indexes[id];
  46751. if (oldIndex <= index) {
  46752. this.indexes[id] = index + 1;
  46753. }
  46754. }
  46755. return this;
  46756. };
  46757. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  46758. newNode.parent = this;
  46759. var oldIndex = this.index(oldNode);
  46760. this.nodes.splice(oldIndex, 0, newNode);
  46761. newNode.parent = this;
  46762. var index;
  46763. for (var id in this.indexes) {
  46764. index = this.indexes[id];
  46765. if (index <= oldIndex) {
  46766. this.indexes[id] = index + 1;
  46767. }
  46768. }
  46769. return this;
  46770. };
  46771. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  46772. var found = undefined;
  46773. this.each(function (node) {
  46774. if (node.atPosition) {
  46775. var foundChild = node.atPosition(line, col);
  46776. if (foundChild) {
  46777. found = foundChild;
  46778. return false;
  46779. }
  46780. } else if (node.isAtPosition(line, col)) {
  46781. found = node;
  46782. return false;
  46783. }
  46784. });
  46785. return found;
  46786. }
  46787. /**
  46788. * Return the most specific node at the line and column number given.
  46789. * The source location is based on the original parsed location, locations aren't
  46790. * updated as selector nodes are mutated.
  46791. *
  46792. * Note that this location is relative to the location of the first character
  46793. * of the selector, and not the location of the selector in the overall document
  46794. * when used in conjunction with postcss.
  46795. *
  46796. * If not found, returns undefined.
  46797. * @param {number} line The line number of the node to find. (1-based index)
  46798. * @param {number} col The column number of the node to find. (1-based index)
  46799. */
  46800. ;
  46801. _proto.atPosition = function atPosition(line, col) {
  46802. if (this.isAtPosition(line, col)) {
  46803. return this._findChildAtPosition(line, col) || this;
  46804. } else {
  46805. return undefined;
  46806. }
  46807. };
  46808. _proto._inferEndPosition = function _inferEndPosition() {
  46809. if (this.last && this.last.source && this.last.source.end) {
  46810. this.source = this.source || {};
  46811. this.source.end = this.source.end || {};
  46812. Object.assign(this.source.end, this.last.source.end);
  46813. }
  46814. };
  46815. _proto.each = function each(callback) {
  46816. if (!this.lastEach) {
  46817. this.lastEach = 0;
  46818. }
  46819. if (!this.indexes) {
  46820. this.indexes = {};
  46821. }
  46822. this.lastEach++;
  46823. var id = this.lastEach;
  46824. this.indexes[id] = 0;
  46825. if (!this.length) {
  46826. return undefined;
  46827. }
  46828. var index, result;
  46829. while (this.indexes[id] < this.length) {
  46830. index = this.indexes[id];
  46831. result = callback(this.at(index), index);
  46832. if (result === false) {
  46833. break;
  46834. }
  46835. this.indexes[id] += 1;
  46836. }
  46837. delete this.indexes[id];
  46838. if (result === false) {
  46839. return false;
  46840. }
  46841. };
  46842. _proto.walk = function walk(callback) {
  46843. return this.each(function (node, i) {
  46844. var result = callback(node, i);
  46845. if (result !== false && node.length) {
  46846. result = node.walk(callback);
  46847. }
  46848. if (result === false) {
  46849. return false;
  46850. }
  46851. });
  46852. };
  46853. _proto.walkAttributes = function walkAttributes(callback) {
  46854. var _this2 = this;
  46855. return this.walk(function (selector) {
  46856. if (selector.type === types.ATTRIBUTE) {
  46857. return callback.call(_this2, selector);
  46858. }
  46859. });
  46860. };
  46861. _proto.walkClasses = function walkClasses(callback) {
  46862. var _this3 = this;
  46863. return this.walk(function (selector) {
  46864. if (selector.type === types.CLASS) {
  46865. return callback.call(_this3, selector);
  46866. }
  46867. });
  46868. };
  46869. _proto.walkCombinators = function walkCombinators(callback) {
  46870. var _this4 = this;
  46871. return this.walk(function (selector) {
  46872. if (selector.type === types.COMBINATOR) {
  46873. return callback.call(_this4, selector);
  46874. }
  46875. });
  46876. };
  46877. _proto.walkComments = function walkComments(callback) {
  46878. var _this5 = this;
  46879. return this.walk(function (selector) {
  46880. if (selector.type === types.COMMENT) {
  46881. return callback.call(_this5, selector);
  46882. }
  46883. });
  46884. };
  46885. _proto.walkIds = function walkIds(callback) {
  46886. var _this6 = this;
  46887. return this.walk(function (selector) {
  46888. if (selector.type === types.ID) {
  46889. return callback.call(_this6, selector);
  46890. }
  46891. });
  46892. };
  46893. _proto.walkNesting = function walkNesting(callback) {
  46894. var _this7 = this;
  46895. return this.walk(function (selector) {
  46896. if (selector.type === types.NESTING) {
  46897. return callback.call(_this7, selector);
  46898. }
  46899. });
  46900. };
  46901. _proto.walkPseudos = function walkPseudos(callback) {
  46902. var _this8 = this;
  46903. return this.walk(function (selector) {
  46904. if (selector.type === types.PSEUDO) {
  46905. return callback.call(_this8, selector);
  46906. }
  46907. });
  46908. };
  46909. _proto.walkTags = function walkTags(callback) {
  46910. var _this9 = this;
  46911. return this.walk(function (selector) {
  46912. if (selector.type === types.TAG) {
  46913. return callback.call(_this9, selector);
  46914. }
  46915. });
  46916. };
  46917. _proto.walkUniversals = function walkUniversals(callback) {
  46918. var _this10 = this;
  46919. return this.walk(function (selector) {
  46920. if (selector.type === types.UNIVERSAL) {
  46921. return callback.call(_this10, selector);
  46922. }
  46923. });
  46924. };
  46925. _proto.split = function split(callback) {
  46926. var _this11 = this;
  46927. var current = [];
  46928. return this.reduce(function (memo, node, index) {
  46929. var split = callback.call(_this11, node);
  46930. current.push(node);
  46931. if (split) {
  46932. memo.push(current);
  46933. current = [];
  46934. } else if (index === _this11.length - 1) {
  46935. memo.push(current);
  46936. }
  46937. return memo;
  46938. }, []);
  46939. };
  46940. _proto.map = function map(callback) {
  46941. return this.nodes.map(callback);
  46942. };
  46943. _proto.reduce = function reduce(callback, memo) {
  46944. return this.nodes.reduce(callback, memo);
  46945. };
  46946. _proto.every = function every(callback) {
  46947. return this.nodes.every(callback);
  46948. };
  46949. _proto.some = function some(callback) {
  46950. return this.nodes.some(callback);
  46951. };
  46952. _proto.filter = function filter(callback) {
  46953. return this.nodes.filter(callback);
  46954. };
  46955. _proto.sort = function sort(callback) {
  46956. return this.nodes.sort(callback);
  46957. };
  46958. _proto.toString = function toString() {
  46959. return this.map(String).join('');
  46960. };
  46961. _createClass(Container, [{
  46962. key: "first",
  46963. get: function get() {
  46964. return this.at(0);
  46965. }
  46966. }, {
  46967. key: "last",
  46968. get: function get() {
  46969. return this.at(this.length - 1);
  46970. }
  46971. }, {
  46972. key: "length",
  46973. get: function get() {
  46974. return this.nodes.length;
  46975. }
  46976. }]);
  46977. return Container;
  46978. }(_node["default"]);
  46979. exports["default"] = Container;
  46980. module.exports = exports.default;
  46981. });
  46982. var root$1 = createCommonjsModule(function (module, exports) {
  46983. exports.__esModule = true;
  46984. exports["default"] = void 0;
  46985. var _container = _interopRequireDefault(container$1);
  46986. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  46987. 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); } }
  46988. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  46989. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  46990. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  46991. var Root = /*#__PURE__*/function (_Container) {
  46992. _inheritsLoose(Root, _Container);
  46993. function Root(opts) {
  46994. var _this;
  46995. _this = _Container.call(this, opts) || this;
  46996. _this.type = types$2.ROOT;
  46997. return _this;
  46998. }
  46999. var _proto = Root.prototype;
  47000. _proto.toString = function toString() {
  47001. var str = this.reduce(function (memo, selector) {
  47002. memo.push(String(selector));
  47003. return memo;
  47004. }, []).join(',');
  47005. return this.trailingComma ? str + ',' : str;
  47006. };
  47007. _proto.error = function error(message, options) {
  47008. if (this._error) {
  47009. return this._error(message, options);
  47010. } else {
  47011. return new Error(message);
  47012. }
  47013. };
  47014. _createClass(Root, [{
  47015. key: "errorGenerator",
  47016. set: function set(handler) {
  47017. this._error = handler;
  47018. }
  47019. }]);
  47020. return Root;
  47021. }(_container["default"]);
  47022. exports["default"] = Root;
  47023. module.exports = exports.default;
  47024. });
  47025. var selector = createCommonjsModule(function (module, exports) {
  47026. exports.__esModule = true;
  47027. exports["default"] = void 0;
  47028. var _container = _interopRequireDefault(container$1);
  47029. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47030. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47031. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47032. var Selector = /*#__PURE__*/function (_Container) {
  47033. _inheritsLoose(Selector, _Container);
  47034. function Selector(opts) {
  47035. var _this;
  47036. _this = _Container.call(this, opts) || this;
  47037. _this.type = types$2.SELECTOR;
  47038. return _this;
  47039. }
  47040. return Selector;
  47041. }(_container["default"]);
  47042. exports["default"] = Selector;
  47043. module.exports = exports.default;
  47044. });
  47045. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  47046. var object = {};
  47047. var hasOwnProperty$3 = object.hasOwnProperty;
  47048. var merge = function merge(options, defaults) {
  47049. if (!options) {
  47050. return defaults;
  47051. }
  47052. var result = {};
  47053. for (var key in defaults) {
  47054. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  47055. // only recognized option names are used.
  47056. result[key] = hasOwnProperty$3.call(options, key) ? options[key] : defaults[key];
  47057. }
  47058. return result;
  47059. };
  47060. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  47061. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  47062. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  47063. // https://mathiasbynens.be/notes/css-escapes#css
  47064. var cssesc = function cssesc(string, options) {
  47065. options = merge(options, cssesc.options);
  47066. if (options.quotes != 'single' && options.quotes != 'double') {
  47067. options.quotes = 'single';
  47068. }
  47069. var quote = options.quotes == 'double' ? '"' : '\'';
  47070. var isIdentifier = options.isIdentifier;
  47071. var firstChar = string.charAt(0);
  47072. var output = '';
  47073. var counter = 0;
  47074. var length = string.length;
  47075. while (counter < length) {
  47076. var character = string.charAt(counter++);
  47077. var codePoint = character.charCodeAt();
  47078. var value = void 0;
  47079. // If it’s not a printable ASCII character…
  47080. if (codePoint < 0x20 || codePoint > 0x7E) {
  47081. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  47082. // It’s a high surrogate, and there is a next character.
  47083. var extra = string.charCodeAt(counter++);
  47084. if ((extra & 0xFC00) == 0xDC00) {
  47085. // next character is low surrogate
  47086. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  47087. } else {
  47088. // It’s an unmatched surrogate; only append this code unit, in case
  47089. // the next code unit is the high surrogate of a surrogate pair.
  47090. counter--;
  47091. }
  47092. }
  47093. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  47094. } else {
  47095. if (options.escapeEverything) {
  47096. if (regexAnySingleEscape.test(character)) {
  47097. value = '\\' + character;
  47098. } else {
  47099. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  47100. }
  47101. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  47102. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  47103. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  47104. value = '\\' + character;
  47105. } else {
  47106. value = character;
  47107. }
  47108. }
  47109. output += value;
  47110. }
  47111. if (isIdentifier) {
  47112. if (/^-[-\d]/.test(output)) {
  47113. output = '\\-' + output.slice(1);
  47114. } else if (/\d/.test(firstChar)) {
  47115. output = '\\3' + firstChar + ' ' + output.slice(1);
  47116. }
  47117. }
  47118. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  47119. // since they’re redundant. Note that this is only possible if the escape
  47120. // sequence isn’t preceded by an odd number of backslashes.
  47121. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  47122. if ($1 && $1.length % 2) {
  47123. // It’s not safe to remove the space, so don’t.
  47124. return $0;
  47125. }
  47126. // Strip the space.
  47127. return ($1 || '') + $2;
  47128. });
  47129. if (!isIdentifier && options.wrap) {
  47130. return quote + output + quote;
  47131. }
  47132. return output;
  47133. };
  47134. // Expose default options (so they can be overridden globally).
  47135. cssesc.options = {
  47136. 'escapeEverything': false,
  47137. 'isIdentifier': false,
  47138. 'quotes': 'single',
  47139. 'wrap': false
  47140. };
  47141. cssesc.version = '3.0.0';
  47142. var cssesc_1 = cssesc;
  47143. var className = createCommonjsModule(function (module, exports) {
  47144. exports.__esModule = true;
  47145. exports["default"] = void 0;
  47146. var _cssesc = _interopRequireDefault(cssesc_1);
  47147. var _node = _interopRequireDefault(node);
  47148. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47149. 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); } }
  47150. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  47151. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47152. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47153. var ClassName = /*#__PURE__*/function (_Node) {
  47154. _inheritsLoose(ClassName, _Node);
  47155. function ClassName(opts) {
  47156. var _this;
  47157. _this = _Node.call(this, opts) || this;
  47158. _this.type = types$2.CLASS;
  47159. _this._constructed = true;
  47160. return _this;
  47161. }
  47162. var _proto = ClassName.prototype;
  47163. _proto.valueToString = function valueToString() {
  47164. return '.' + _Node.prototype.valueToString.call(this);
  47165. };
  47166. _createClass(ClassName, [{
  47167. key: "value",
  47168. get: function get() {
  47169. return this._value;
  47170. },
  47171. set: function set(v) {
  47172. if (this._constructed) {
  47173. var escaped = (0, _cssesc["default"])(v, {
  47174. isIdentifier: true
  47175. });
  47176. if (escaped !== v) {
  47177. (0, util$2.ensureObject)(this, "raws");
  47178. this.raws.value = escaped;
  47179. } else if (this.raws) {
  47180. delete this.raws.value;
  47181. }
  47182. }
  47183. this._value = v;
  47184. }
  47185. }]);
  47186. return ClassName;
  47187. }(_node["default"]);
  47188. exports["default"] = ClassName;
  47189. module.exports = exports.default;
  47190. });
  47191. var comment$1 = createCommonjsModule(function (module, exports) {
  47192. exports.__esModule = true;
  47193. exports["default"] = void 0;
  47194. var _node = _interopRequireDefault(node);
  47195. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47196. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47197. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47198. var Comment = /*#__PURE__*/function (_Node) {
  47199. _inheritsLoose(Comment, _Node);
  47200. function Comment(opts) {
  47201. var _this;
  47202. _this = _Node.call(this, opts) || this;
  47203. _this.type = types$2.COMMENT;
  47204. return _this;
  47205. }
  47206. return Comment;
  47207. }(_node["default"]);
  47208. exports["default"] = Comment;
  47209. module.exports = exports.default;
  47210. });
  47211. var id = createCommonjsModule(function (module, exports) {
  47212. exports.__esModule = true;
  47213. exports["default"] = void 0;
  47214. var _node = _interopRequireDefault(node);
  47215. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47216. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47217. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47218. var ID = /*#__PURE__*/function (_Node) {
  47219. _inheritsLoose(ID, _Node);
  47220. function ID(opts) {
  47221. var _this;
  47222. _this = _Node.call(this, opts) || this;
  47223. _this.type = types$2.ID;
  47224. return _this;
  47225. }
  47226. var _proto = ID.prototype;
  47227. _proto.valueToString = function valueToString() {
  47228. return '#' + _Node.prototype.valueToString.call(this);
  47229. };
  47230. return ID;
  47231. }(_node["default"]);
  47232. exports["default"] = ID;
  47233. module.exports = exports.default;
  47234. });
  47235. var namespace = createCommonjsModule(function (module, exports) {
  47236. exports.__esModule = true;
  47237. exports["default"] = void 0;
  47238. var _cssesc = _interopRequireDefault(cssesc_1);
  47239. var _node = _interopRequireDefault(node);
  47240. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47241. 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); } }
  47242. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  47243. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47244. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47245. var Namespace = /*#__PURE__*/function (_Node) {
  47246. _inheritsLoose(Namespace, _Node);
  47247. function Namespace() {
  47248. return _Node.apply(this, arguments) || this;
  47249. }
  47250. var _proto = Namespace.prototype;
  47251. _proto.qualifiedName = function qualifiedName(value) {
  47252. if (this.namespace) {
  47253. return this.namespaceString + "|" + value;
  47254. } else {
  47255. return value;
  47256. }
  47257. };
  47258. _proto.valueToString = function valueToString() {
  47259. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  47260. };
  47261. _createClass(Namespace, [{
  47262. key: "namespace",
  47263. get: function get() {
  47264. return this._namespace;
  47265. },
  47266. set: function set(namespace) {
  47267. if (namespace === true || namespace === "*" || namespace === "&") {
  47268. this._namespace = namespace;
  47269. if (this.raws) {
  47270. delete this.raws.namespace;
  47271. }
  47272. return;
  47273. }
  47274. var escaped = (0, _cssesc["default"])(namespace, {
  47275. isIdentifier: true
  47276. });
  47277. this._namespace = namespace;
  47278. if (escaped !== namespace) {
  47279. (0, util$2.ensureObject)(this, "raws");
  47280. this.raws.namespace = escaped;
  47281. } else if (this.raws) {
  47282. delete this.raws.namespace;
  47283. }
  47284. }
  47285. }, {
  47286. key: "ns",
  47287. get: function get() {
  47288. return this._namespace;
  47289. },
  47290. set: function set(namespace) {
  47291. this.namespace = namespace;
  47292. }
  47293. }, {
  47294. key: "namespaceString",
  47295. get: function get() {
  47296. if (this.namespace) {
  47297. var ns = this.stringifyProperty("namespace");
  47298. if (ns === true) {
  47299. return '';
  47300. } else {
  47301. return ns;
  47302. }
  47303. } else {
  47304. return '';
  47305. }
  47306. }
  47307. }]);
  47308. return Namespace;
  47309. }(_node["default"]);
  47310. exports["default"] = Namespace;
  47311. module.exports = exports.default;
  47312. });
  47313. var tag = createCommonjsModule(function (module, exports) {
  47314. exports.__esModule = true;
  47315. exports["default"] = void 0;
  47316. var _namespace = _interopRequireDefault(namespace);
  47317. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47318. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47319. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47320. var Tag = /*#__PURE__*/function (_Namespace) {
  47321. _inheritsLoose(Tag, _Namespace);
  47322. function Tag(opts) {
  47323. var _this;
  47324. _this = _Namespace.call(this, opts) || this;
  47325. _this.type = types$2.TAG;
  47326. return _this;
  47327. }
  47328. return Tag;
  47329. }(_namespace["default"]);
  47330. exports["default"] = Tag;
  47331. module.exports = exports.default;
  47332. });
  47333. var string = createCommonjsModule(function (module, exports) {
  47334. exports.__esModule = true;
  47335. exports["default"] = void 0;
  47336. var _node = _interopRequireDefault(node);
  47337. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47338. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47339. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47340. var String = /*#__PURE__*/function (_Node) {
  47341. _inheritsLoose(String, _Node);
  47342. function String(opts) {
  47343. var _this;
  47344. _this = _Node.call(this, opts) || this;
  47345. _this.type = types$2.STRING;
  47346. return _this;
  47347. }
  47348. return String;
  47349. }(_node["default"]);
  47350. exports["default"] = String;
  47351. module.exports = exports.default;
  47352. });
  47353. var pseudo = createCommonjsModule(function (module, exports) {
  47354. exports.__esModule = true;
  47355. exports["default"] = void 0;
  47356. var _container = _interopRequireDefault(container$1);
  47357. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47358. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47359. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47360. var Pseudo = /*#__PURE__*/function (_Container) {
  47361. _inheritsLoose(Pseudo, _Container);
  47362. function Pseudo(opts) {
  47363. var _this;
  47364. _this = _Container.call(this, opts) || this;
  47365. _this.type = types$2.PSEUDO;
  47366. return _this;
  47367. }
  47368. var _proto = Pseudo.prototype;
  47369. _proto.toString = function toString() {
  47370. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  47371. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  47372. };
  47373. return Pseudo;
  47374. }(_container["default"]);
  47375. exports["default"] = Pseudo;
  47376. module.exports = exports.default;
  47377. });
  47378. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  47379. /**
  47380. * For Node.js, simply re-export the core `util.deprecate` function.
  47381. */
  47382. var node$1 = require$$0.deprecate;
  47383. var attribute = createCommonjsModule(function (module, exports) {
  47384. exports.__esModule = true;
  47385. exports.unescapeValue = unescapeValue;
  47386. exports["default"] = void 0;
  47387. var _cssesc = _interopRequireDefault(cssesc_1);
  47388. var _unesc = _interopRequireDefault(unesc_1);
  47389. var _namespace = _interopRequireDefault(namespace);
  47390. var _CSSESC_QUOTE_OPTIONS;
  47391. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47392. 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); } }
  47393. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  47394. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47395. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47396. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  47397. var warnOfDeprecatedValueAssignment = node$1(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  47398. var warnOfDeprecatedQuotedAssignment = node$1(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  47399. var warnOfDeprecatedConstructor = node$1(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  47400. function unescapeValue(value) {
  47401. var deprecatedUsage = false;
  47402. var quoteMark = null;
  47403. var unescaped = value;
  47404. var m = unescaped.match(WRAPPED_IN_QUOTES);
  47405. if (m) {
  47406. quoteMark = m[1];
  47407. unescaped = m[2];
  47408. }
  47409. unescaped = (0, _unesc["default"])(unescaped);
  47410. if (unescaped !== value) {
  47411. deprecatedUsage = true;
  47412. }
  47413. return {
  47414. deprecatedUsage: deprecatedUsage,
  47415. unescaped: unescaped,
  47416. quoteMark: quoteMark
  47417. };
  47418. }
  47419. function handleDeprecatedContructorOpts(opts) {
  47420. if (opts.quoteMark !== undefined) {
  47421. return opts;
  47422. }
  47423. if (opts.value === undefined) {
  47424. return opts;
  47425. }
  47426. warnOfDeprecatedConstructor();
  47427. var _unescapeValue = unescapeValue(opts.value),
  47428. quoteMark = _unescapeValue.quoteMark,
  47429. unescaped = _unescapeValue.unescaped;
  47430. if (!opts.raws) {
  47431. opts.raws = {};
  47432. }
  47433. if (opts.raws.value === undefined) {
  47434. opts.raws.value = opts.value;
  47435. }
  47436. opts.value = unescaped;
  47437. opts.quoteMark = quoteMark;
  47438. return opts;
  47439. }
  47440. var Attribute = /*#__PURE__*/function (_Namespace) {
  47441. _inheritsLoose(Attribute, _Namespace);
  47442. function Attribute(opts) {
  47443. var _this;
  47444. if (opts === void 0) {
  47445. opts = {};
  47446. }
  47447. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  47448. _this.type = types$2.ATTRIBUTE;
  47449. _this.raws = _this.raws || {};
  47450. Object.defineProperty(_this.raws, 'unquoted', {
  47451. get: node$1(function () {
  47452. return _this.value;
  47453. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  47454. set: node$1(function () {
  47455. return _this.value;
  47456. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  47457. });
  47458. _this._constructed = true;
  47459. return _this;
  47460. }
  47461. /**
  47462. * Returns the Attribute's value quoted such that it would be legal to use
  47463. * in the value of a css file. The original value's quotation setting
  47464. * used for stringification is left unchanged. See `setValue(value, options)`
  47465. * if you want to control the quote settings of a new value for the attribute.
  47466. *
  47467. * You can also change the quotation used for the current value by setting quoteMark.
  47468. *
  47469. * Options:
  47470. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  47471. * option is not set, the original value for quoteMark will be used. If
  47472. * indeterminate, a double quote is used. The legal values are:
  47473. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  47474. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  47475. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  47476. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  47477. * over the quoteMark option value.
  47478. * * smart {boolean} - if true, will select a quote mark based on the value
  47479. * and the other options specified here. See the `smartQuoteMark()`
  47480. * method.
  47481. **/
  47482. var _proto = Attribute.prototype;
  47483. _proto.getQuotedValue = function getQuotedValue(options) {
  47484. if (options === void 0) {
  47485. options = {};
  47486. }
  47487. var quoteMark = this._determineQuoteMark(options);
  47488. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  47489. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  47490. return escaped;
  47491. };
  47492. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  47493. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  47494. }
  47495. /**
  47496. * Set the unescaped value with the specified quotation options. The value
  47497. * provided must not include any wrapping quote marks -- those quotes will
  47498. * be interpreted as part of the value and escaped accordingly.
  47499. */
  47500. ;
  47501. _proto.setValue = function setValue(value, options) {
  47502. if (options === void 0) {
  47503. options = {};
  47504. }
  47505. this._value = value;
  47506. this._quoteMark = this._determineQuoteMark(options);
  47507. this._syncRawValue();
  47508. }
  47509. /**
  47510. * Intelligently select a quoteMark value based on the value's contents. If
  47511. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  47512. * mark will be picked that minimizes the number of escapes.
  47513. *
  47514. * If there's no clear winner, the quote mark from these options is used,
  47515. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  47516. * true). If the quoteMark is unspecified, a double quote is used.
  47517. *
  47518. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  47519. * from the quoteValue method.
  47520. */
  47521. ;
  47522. _proto.smartQuoteMark = function smartQuoteMark(options) {
  47523. var v = this.value;
  47524. var numSingleQuotes = v.replace(/[^']/g, '').length;
  47525. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  47526. if (numSingleQuotes + numDoubleQuotes === 0) {
  47527. var escaped = (0, _cssesc["default"])(v, {
  47528. isIdentifier: true
  47529. });
  47530. if (escaped === v) {
  47531. return Attribute.NO_QUOTE;
  47532. } else {
  47533. var pref = this.preferredQuoteMark(options);
  47534. if (pref === Attribute.NO_QUOTE) {
  47535. // pick a quote mark that isn't none and see if it's smaller
  47536. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  47537. var opts = CSSESC_QUOTE_OPTIONS[quote];
  47538. var quoteValue = (0, _cssesc["default"])(v, opts);
  47539. if (quoteValue.length < escaped.length) {
  47540. return quote;
  47541. }
  47542. }
  47543. return pref;
  47544. }
  47545. } else if (numDoubleQuotes === numSingleQuotes) {
  47546. return this.preferredQuoteMark(options);
  47547. } else if (numDoubleQuotes < numSingleQuotes) {
  47548. return Attribute.DOUBLE_QUOTE;
  47549. } else {
  47550. return Attribute.SINGLE_QUOTE;
  47551. }
  47552. }
  47553. /**
  47554. * Selects the preferred quote mark based on the options and the current quote mark value.
  47555. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  47556. * instead.
  47557. */
  47558. ;
  47559. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  47560. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  47561. if (quoteMark === undefined) {
  47562. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  47563. }
  47564. if (quoteMark === undefined) {
  47565. quoteMark = Attribute.DOUBLE_QUOTE;
  47566. }
  47567. return quoteMark;
  47568. };
  47569. _proto._syncRawValue = function _syncRawValue() {
  47570. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  47571. if (rawValue === this._value) {
  47572. if (this.raws) {
  47573. delete this.raws.value;
  47574. }
  47575. } else {
  47576. this.raws.value = rawValue;
  47577. }
  47578. };
  47579. _proto._handleEscapes = function _handleEscapes(prop, value) {
  47580. if (this._constructed) {
  47581. var escaped = (0, _cssesc["default"])(value, {
  47582. isIdentifier: true
  47583. });
  47584. if (escaped !== value) {
  47585. this.raws[prop] = escaped;
  47586. } else {
  47587. delete this.raws[prop];
  47588. }
  47589. }
  47590. };
  47591. _proto._spacesFor = function _spacesFor(name) {
  47592. var attrSpaces = {
  47593. before: '',
  47594. after: ''
  47595. };
  47596. var spaces = this.spaces[name] || {};
  47597. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  47598. return Object.assign(attrSpaces, spaces, rawSpaces);
  47599. };
  47600. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  47601. if (spaceName === void 0) {
  47602. spaceName = name;
  47603. }
  47604. if (concat === void 0) {
  47605. concat = defaultAttrConcat;
  47606. }
  47607. var attrSpaces = this._spacesFor(spaceName);
  47608. return concat(this.stringifyProperty(name), attrSpaces);
  47609. }
  47610. /**
  47611. * returns the offset of the attribute part specified relative to the
  47612. * start of the node of the output string.
  47613. *
  47614. * * "ns" - alias for "namespace"
  47615. * * "namespace" - the namespace if it exists.
  47616. * * "attribute" - the attribute name
  47617. * * "attributeNS" - the start of the attribute or its namespace
  47618. * * "operator" - the match operator of the attribute
  47619. * * "value" - The value (string or identifier)
  47620. * * "insensitive" - the case insensitivity flag;
  47621. * @param part One of the possible values inside an attribute.
  47622. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  47623. */
  47624. ;
  47625. _proto.offsetOf = function offsetOf(name) {
  47626. var count = 1;
  47627. var attributeSpaces = this._spacesFor("attribute");
  47628. count += attributeSpaces.before.length;
  47629. if (name === "namespace" || name === "ns") {
  47630. return this.namespace ? count : -1;
  47631. }
  47632. if (name === "attributeNS") {
  47633. return count;
  47634. }
  47635. count += this.namespaceString.length;
  47636. if (this.namespace) {
  47637. count += 1;
  47638. }
  47639. if (name === "attribute") {
  47640. return count;
  47641. }
  47642. count += this.stringifyProperty("attribute").length;
  47643. count += attributeSpaces.after.length;
  47644. var operatorSpaces = this._spacesFor("operator");
  47645. count += operatorSpaces.before.length;
  47646. var operator = this.stringifyProperty("operator");
  47647. if (name === "operator") {
  47648. return operator ? count : -1;
  47649. }
  47650. count += operator.length;
  47651. count += operatorSpaces.after.length;
  47652. var valueSpaces = this._spacesFor("value");
  47653. count += valueSpaces.before.length;
  47654. var value = this.stringifyProperty("value");
  47655. if (name === "value") {
  47656. return value ? count : -1;
  47657. }
  47658. count += value.length;
  47659. count += valueSpaces.after.length;
  47660. var insensitiveSpaces = this._spacesFor("insensitive");
  47661. count += insensitiveSpaces.before.length;
  47662. if (name === "insensitive") {
  47663. return this.insensitive ? count : -1;
  47664. }
  47665. return -1;
  47666. };
  47667. _proto.toString = function toString() {
  47668. var _this2 = this;
  47669. var selector = [this.rawSpaceBefore, '['];
  47670. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  47671. if (this.operator && (this.value || this.value === '')) {
  47672. selector.push(this._stringFor('operator'));
  47673. selector.push(this._stringFor('value'));
  47674. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  47675. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  47676. attrSpaces.before = " ";
  47677. }
  47678. return defaultAttrConcat(attrValue, attrSpaces);
  47679. }));
  47680. }
  47681. selector.push(']');
  47682. selector.push(this.rawSpaceAfter);
  47683. return selector.join('');
  47684. };
  47685. _createClass(Attribute, [{
  47686. key: "quoted",
  47687. get: function get() {
  47688. var qm = this.quoteMark;
  47689. return qm === "'" || qm === '"';
  47690. },
  47691. set: function set(value) {
  47692. warnOfDeprecatedQuotedAssignment();
  47693. }
  47694. /**
  47695. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  47696. * returns `null` if the value is not quoted.
  47697. * returns `undefined` if the quotation state is unknown (this can happen when
  47698. * the attribute is constructed without specifying a quote mark.)
  47699. */
  47700. }, {
  47701. key: "quoteMark",
  47702. get: function get() {
  47703. return this._quoteMark;
  47704. }
  47705. /**
  47706. * Set the quote mark to be used by this attribute's value.
  47707. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  47708. * value is updated accordingly.
  47709. *
  47710. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  47711. */
  47712. ,
  47713. set: function set(quoteMark) {
  47714. if (!this._constructed) {
  47715. this._quoteMark = quoteMark;
  47716. return;
  47717. }
  47718. if (this._quoteMark !== quoteMark) {
  47719. this._quoteMark = quoteMark;
  47720. this._syncRawValue();
  47721. }
  47722. }
  47723. }, {
  47724. key: "qualifiedAttribute",
  47725. get: function get() {
  47726. return this.qualifiedName(this.raws.attribute || this.attribute);
  47727. }
  47728. }, {
  47729. key: "insensitiveFlag",
  47730. get: function get() {
  47731. return this.insensitive ? 'i' : '';
  47732. }
  47733. }, {
  47734. key: "value",
  47735. get: function get() {
  47736. return this._value;
  47737. }
  47738. /**
  47739. * Before 3.0, the value had to be set to an escaped value including any wrapped
  47740. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  47741. * is unescaped during parsing and any quote marks are removed.
  47742. *
  47743. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  47744. * a deprecation warning is raised when the new value contains any characters that would
  47745. * require escaping (including if it contains wrapped quotes).
  47746. *
  47747. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  47748. * how the new value is quoted.
  47749. */
  47750. ,
  47751. set: function set(v) {
  47752. if (this._constructed) {
  47753. var _unescapeValue2 = unescapeValue(v),
  47754. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  47755. unescaped = _unescapeValue2.unescaped,
  47756. quoteMark = _unescapeValue2.quoteMark;
  47757. if (deprecatedUsage) {
  47758. warnOfDeprecatedValueAssignment();
  47759. }
  47760. if (unescaped === this._value && quoteMark === this._quoteMark) {
  47761. return;
  47762. }
  47763. this._value = unescaped;
  47764. this._quoteMark = quoteMark;
  47765. this._syncRawValue();
  47766. } else {
  47767. this._value = v;
  47768. }
  47769. }
  47770. }, {
  47771. key: "attribute",
  47772. get: function get() {
  47773. return this._attribute;
  47774. },
  47775. set: function set(name) {
  47776. this._handleEscapes("attribute", name);
  47777. this._attribute = name;
  47778. }
  47779. }]);
  47780. return Attribute;
  47781. }(_namespace["default"]);
  47782. exports["default"] = Attribute;
  47783. Attribute.NO_QUOTE = null;
  47784. Attribute.SINGLE_QUOTE = "'";
  47785. Attribute.DOUBLE_QUOTE = '"';
  47786. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  47787. "'": {
  47788. quotes: 'single',
  47789. wrap: true
  47790. },
  47791. '"': {
  47792. quotes: 'double',
  47793. wrap: true
  47794. }
  47795. }, _CSSESC_QUOTE_OPTIONS[null] = {
  47796. isIdentifier: true
  47797. }, _CSSESC_QUOTE_OPTIONS);
  47798. function defaultAttrConcat(attrValue, attrSpaces) {
  47799. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  47800. }
  47801. });
  47802. var universal = createCommonjsModule(function (module, exports) {
  47803. exports.__esModule = true;
  47804. exports["default"] = void 0;
  47805. var _namespace = _interopRequireDefault(namespace);
  47806. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47807. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47808. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47809. var Universal = /*#__PURE__*/function (_Namespace) {
  47810. _inheritsLoose(Universal, _Namespace);
  47811. function Universal(opts) {
  47812. var _this;
  47813. _this = _Namespace.call(this, opts) || this;
  47814. _this.type = types$2.UNIVERSAL;
  47815. _this.value = '*';
  47816. return _this;
  47817. }
  47818. return Universal;
  47819. }(_namespace["default"]);
  47820. exports["default"] = Universal;
  47821. module.exports = exports.default;
  47822. });
  47823. var combinator = createCommonjsModule(function (module, exports) {
  47824. exports.__esModule = true;
  47825. exports["default"] = void 0;
  47826. var _node = _interopRequireDefault(node);
  47827. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47828. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47829. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47830. var Combinator = /*#__PURE__*/function (_Node) {
  47831. _inheritsLoose(Combinator, _Node);
  47832. function Combinator(opts) {
  47833. var _this;
  47834. _this = _Node.call(this, opts) || this;
  47835. _this.type = types$2.COMBINATOR;
  47836. return _this;
  47837. }
  47838. return Combinator;
  47839. }(_node["default"]);
  47840. exports["default"] = Combinator;
  47841. module.exports = exports.default;
  47842. });
  47843. var nesting = createCommonjsModule(function (module, exports) {
  47844. exports.__esModule = true;
  47845. exports["default"] = void 0;
  47846. var _node = _interopRequireDefault(node);
  47847. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  47848. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  47849. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  47850. var Nesting = /*#__PURE__*/function (_Node) {
  47851. _inheritsLoose(Nesting, _Node);
  47852. function Nesting(opts) {
  47853. var _this;
  47854. _this = _Node.call(this, opts) || this;
  47855. _this.type = types$2.NESTING;
  47856. _this.value = '&';
  47857. return _this;
  47858. }
  47859. return Nesting;
  47860. }(_node["default"]);
  47861. exports["default"] = Nesting;
  47862. module.exports = exports.default;
  47863. });
  47864. var sortAscending_1 = createCommonjsModule(function (module, exports) {
  47865. exports.__esModule = true;
  47866. exports["default"] = sortAscending;
  47867. function sortAscending(list) {
  47868. return list.sort(function (a, b) {
  47869. return a - b;
  47870. });
  47871. }
  47872. module.exports = exports.default;
  47873. });
  47874. var tokenTypes = createCommonjsModule(function (module, exports) {
  47875. exports.__esModule = true;
  47876. exports.combinator = exports.word = exports.comment = exports.str = exports.tab = exports.newline = exports.feed = exports.cr = exports.backslash = exports.bang = exports.slash = exports.doubleQuote = exports.singleQuote = exports.space = exports.greaterThan = exports.pipe = exports.equals = exports.plus = exports.caret = exports.tilde = exports.dollar = exports.closeSquare = exports.openSquare = exports.closeParenthesis = exports.openParenthesis = exports.semicolon = exports.colon = exports.comma = exports.at = exports.asterisk = exports.ampersand = void 0;
  47877. var ampersand = 38; // `&`.charCodeAt(0);
  47878. exports.ampersand = ampersand;
  47879. var asterisk = 42; // `*`.charCodeAt(0);
  47880. exports.asterisk = asterisk;
  47881. var at = 64; // `@`.charCodeAt(0);
  47882. exports.at = at;
  47883. var comma = 44; // `,`.charCodeAt(0);
  47884. exports.comma = comma;
  47885. var colon = 58; // `:`.charCodeAt(0);
  47886. exports.colon = colon;
  47887. var semicolon = 59; // `;`.charCodeAt(0);
  47888. exports.semicolon = semicolon;
  47889. var openParenthesis = 40; // `(`.charCodeAt(0);
  47890. exports.openParenthesis = openParenthesis;
  47891. var closeParenthesis = 41; // `)`.charCodeAt(0);
  47892. exports.closeParenthesis = closeParenthesis;
  47893. var openSquare = 91; // `[`.charCodeAt(0);
  47894. exports.openSquare = openSquare;
  47895. var closeSquare = 93; // `]`.charCodeAt(0);
  47896. exports.closeSquare = closeSquare;
  47897. var dollar = 36; // `$`.charCodeAt(0);
  47898. exports.dollar = dollar;
  47899. var tilde = 126; // `~`.charCodeAt(0);
  47900. exports.tilde = tilde;
  47901. var caret = 94; // `^`.charCodeAt(0);
  47902. exports.caret = caret;
  47903. var plus = 43; // `+`.charCodeAt(0);
  47904. exports.plus = plus;
  47905. var equals = 61; // `=`.charCodeAt(0);
  47906. exports.equals = equals;
  47907. var pipe = 124; // `|`.charCodeAt(0);
  47908. exports.pipe = pipe;
  47909. var greaterThan = 62; // `>`.charCodeAt(0);
  47910. exports.greaterThan = greaterThan;
  47911. var space = 32; // ` `.charCodeAt(0);
  47912. exports.space = space;
  47913. var singleQuote = 39; // `'`.charCodeAt(0);
  47914. exports.singleQuote = singleQuote;
  47915. var doubleQuote = 34; // `"`.charCodeAt(0);
  47916. exports.doubleQuote = doubleQuote;
  47917. var slash = 47; // `/`.charCodeAt(0);
  47918. exports.slash = slash;
  47919. var bang = 33; // `!`.charCodeAt(0);
  47920. exports.bang = bang;
  47921. var backslash = 92; // '\\'.charCodeAt(0);
  47922. exports.backslash = backslash;
  47923. var cr = 13; // '\r'.charCodeAt(0);
  47924. exports.cr = cr;
  47925. var feed = 12; // '\f'.charCodeAt(0);
  47926. exports.feed = feed;
  47927. var newline = 10; // '\n'.charCodeAt(0);
  47928. exports.newline = newline;
  47929. var tab = 9; // '\t'.charCodeAt(0);
  47930. // Expose aliases primarily for readability.
  47931. exports.tab = tab;
  47932. var str = singleQuote; // No good single character representation!
  47933. exports.str = str;
  47934. var comment = -1;
  47935. exports.comment = comment;
  47936. var word = -2;
  47937. exports.word = word;
  47938. var combinator = -3;
  47939. exports.combinator = combinator;
  47940. });
  47941. var tokenize_1 = createCommonjsModule(function (module, exports) {
  47942. exports.__esModule = true;
  47943. exports["default"] = tokenize;
  47944. exports.FIELDS = void 0;
  47945. var t = _interopRequireWildcard(tokenTypes);
  47946. var _unescapable, _wordDelimiters;
  47947. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  47948. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  47949. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  47950. 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);
  47951. var hex = {};
  47952. var hexChars = "0123456789abcdefABCDEF";
  47953. for (var i = 0; i < hexChars.length; i++) {
  47954. hex[hexChars.charCodeAt(i)] = true;
  47955. }
  47956. /**
  47957. * Returns the last index of the bar css word
  47958. * @param {string} css The string in which the word begins
  47959. * @param {number} start The index into the string where word's first letter occurs
  47960. */
  47961. function consumeWord(css, start) {
  47962. var next = start;
  47963. var code;
  47964. do {
  47965. code = css.charCodeAt(next);
  47966. if (wordDelimiters[code]) {
  47967. return next - 1;
  47968. } else if (code === t.backslash) {
  47969. next = consumeEscape(css, next) + 1;
  47970. } else {
  47971. // All other characters are part of the word
  47972. next++;
  47973. }
  47974. } while (next < css.length);
  47975. return next - 1;
  47976. }
  47977. /**
  47978. * Returns the last index of the escape sequence
  47979. * @param {string} css The string in which the sequence begins
  47980. * @param {number} start The index into the string where escape character (`\`) occurs.
  47981. */
  47982. function consumeEscape(css, start) {
  47983. var next = start;
  47984. var code = css.charCodeAt(next + 1);
  47985. if (unescapable[code]) ; else if (hex[code]) {
  47986. var hexDigits = 0; // consume up to 6 hex chars
  47987. do {
  47988. next++;
  47989. hexDigits++;
  47990. code = css.charCodeAt(next + 1);
  47991. } while (hex[code] && hexDigits < 6); // if fewer than 6 hex chars, a trailing space ends the escape
  47992. if (hexDigits < 6 && code === t.space) {
  47993. next++;
  47994. }
  47995. } else {
  47996. // the next char is part of the current word
  47997. next++;
  47998. }
  47999. return next;
  48000. }
  48001. var FIELDS = {
  48002. TYPE: 0,
  48003. START_LINE: 1,
  48004. START_COL: 2,
  48005. END_LINE: 3,
  48006. END_COL: 4,
  48007. START_POS: 5,
  48008. END_POS: 6
  48009. };
  48010. exports.FIELDS = FIELDS;
  48011. function tokenize(input) {
  48012. var tokens = [];
  48013. var css = input.css.valueOf();
  48014. var _css = css,
  48015. length = _css.length;
  48016. var offset = -1;
  48017. var line = 1;
  48018. var start = 0;
  48019. var end = 0;
  48020. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  48021. function unclosed(what, fix) {
  48022. if (input.safe) {
  48023. // fyi: this is never set to true.
  48024. css += fix;
  48025. next = css.length - 1;
  48026. } else {
  48027. throw input.error('Unclosed ' + what, line, start - offset, start);
  48028. }
  48029. }
  48030. while (start < length) {
  48031. code = css.charCodeAt(start);
  48032. if (code === t.newline) {
  48033. offset = start;
  48034. line += 1;
  48035. }
  48036. switch (code) {
  48037. case t.space:
  48038. case t.tab:
  48039. case t.newline:
  48040. case t.cr:
  48041. case t.feed:
  48042. next = start;
  48043. do {
  48044. next += 1;
  48045. code = css.charCodeAt(next);
  48046. if (code === t.newline) {
  48047. offset = next;
  48048. line += 1;
  48049. }
  48050. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  48051. tokenType = t.space;
  48052. endLine = line;
  48053. endColumn = next - offset - 1;
  48054. end = next;
  48055. break;
  48056. case t.plus:
  48057. case t.greaterThan:
  48058. case t.tilde:
  48059. case t.pipe:
  48060. next = start;
  48061. do {
  48062. next += 1;
  48063. code = css.charCodeAt(next);
  48064. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  48065. tokenType = t.combinator;
  48066. endLine = line;
  48067. endColumn = start - offset;
  48068. end = next;
  48069. break;
  48070. // Consume these characters as single tokens.
  48071. case t.asterisk:
  48072. case t.ampersand:
  48073. case t.bang:
  48074. case t.comma:
  48075. case t.equals:
  48076. case t.dollar:
  48077. case t.caret:
  48078. case t.openSquare:
  48079. case t.closeSquare:
  48080. case t.colon:
  48081. case t.semicolon:
  48082. case t.openParenthesis:
  48083. case t.closeParenthesis:
  48084. next = start;
  48085. tokenType = code;
  48086. endLine = line;
  48087. endColumn = start - offset;
  48088. end = next + 1;
  48089. break;
  48090. case t.singleQuote:
  48091. case t.doubleQuote:
  48092. quote = code === t.singleQuote ? "'" : '"';
  48093. next = start;
  48094. do {
  48095. escaped = false;
  48096. next = css.indexOf(quote, next + 1);
  48097. if (next === -1) {
  48098. unclosed('quote', quote);
  48099. }
  48100. escapePos = next;
  48101. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  48102. escapePos -= 1;
  48103. escaped = !escaped;
  48104. }
  48105. } while (escaped);
  48106. tokenType = t.str;
  48107. endLine = line;
  48108. endColumn = start - offset;
  48109. end = next + 1;
  48110. break;
  48111. default:
  48112. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  48113. next = css.indexOf('*/', start + 2) + 1;
  48114. if (next === 0) {
  48115. unclosed('comment', '*/');
  48116. }
  48117. content = css.slice(start, next + 1);
  48118. lines = content.split('\n');
  48119. last = lines.length - 1;
  48120. if (last > 0) {
  48121. nextLine = line + last;
  48122. nextOffset = next - lines[last].length;
  48123. } else {
  48124. nextLine = line;
  48125. nextOffset = offset;
  48126. }
  48127. tokenType = t.comment;
  48128. line = nextLine;
  48129. endLine = nextLine;
  48130. endColumn = next - nextOffset;
  48131. } else if (code === t.slash) {
  48132. next = start;
  48133. tokenType = code;
  48134. endLine = line;
  48135. endColumn = start - offset;
  48136. end = next + 1;
  48137. } else {
  48138. next = consumeWord(css, start);
  48139. tokenType = t.word;
  48140. endLine = line;
  48141. endColumn = next - offset;
  48142. }
  48143. end = next + 1;
  48144. break;
  48145. } // Ensure that the token structure remains consistent
  48146. tokens.push([tokenType, // [0] Token type
  48147. line, // [1] Starting line
  48148. start - offset, // [2] Starting column
  48149. endLine, // [3] Ending line
  48150. endColumn, // [4] Ending column
  48151. start, // [5] Start position / Source index
  48152. end // [6] End position
  48153. ]); // Reset offset for the next token
  48154. if (nextOffset) {
  48155. offset = nextOffset;
  48156. nextOffset = null;
  48157. }
  48158. start = end;
  48159. }
  48160. return tokens;
  48161. }
  48162. });
  48163. var parser$1 = createCommonjsModule(function (module, exports) {
  48164. exports.__esModule = true;
  48165. exports["default"] = void 0;
  48166. var _root = _interopRequireDefault(root$1);
  48167. var _selector = _interopRequireDefault(selector);
  48168. var _className = _interopRequireDefault(className);
  48169. var _comment = _interopRequireDefault(comment$1);
  48170. var _id = _interopRequireDefault(id);
  48171. var _tag = _interopRequireDefault(tag);
  48172. var _string = _interopRequireDefault(string);
  48173. var _pseudo = _interopRequireDefault(pseudo);
  48174. var _attribute = _interopRequireWildcard(attribute);
  48175. var _universal = _interopRequireDefault(universal);
  48176. var _combinator = _interopRequireDefault(combinator);
  48177. var _nesting = _interopRequireDefault(nesting);
  48178. var _sortAscending = _interopRequireDefault(sortAscending_1);
  48179. var _tokenize = _interopRequireWildcard(tokenize_1);
  48180. var tokens = _interopRequireWildcard(tokenTypes);
  48181. var types = _interopRequireWildcard(types$2);
  48182. var _WHITESPACE_TOKENS, _Object$assign;
  48183. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  48184. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  48185. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  48186. 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); } }
  48187. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  48188. 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);
  48189. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  48190. function tokenStart(token) {
  48191. return {
  48192. line: token[_tokenize.FIELDS.START_LINE],
  48193. column: token[_tokenize.FIELDS.START_COL]
  48194. };
  48195. }
  48196. function tokenEnd(token) {
  48197. return {
  48198. line: token[_tokenize.FIELDS.END_LINE],
  48199. column: token[_tokenize.FIELDS.END_COL]
  48200. };
  48201. }
  48202. function getSource(startLine, startColumn, endLine, endColumn) {
  48203. return {
  48204. start: {
  48205. line: startLine,
  48206. column: startColumn
  48207. },
  48208. end: {
  48209. line: endLine,
  48210. column: endColumn
  48211. }
  48212. };
  48213. }
  48214. function getTokenSource(token) {
  48215. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  48216. }
  48217. function getTokenSourceSpan(startToken, endToken) {
  48218. if (!startToken) {
  48219. return undefined;
  48220. }
  48221. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  48222. }
  48223. function unescapeProp(node, prop) {
  48224. var value = node[prop];
  48225. if (typeof value !== "string") {
  48226. return;
  48227. }
  48228. if (value.indexOf("\\") !== -1) {
  48229. (0, util$2.ensureObject)(node, 'raws');
  48230. node[prop] = (0, util$2.unesc)(value);
  48231. if (node.raws[prop] === undefined) {
  48232. node.raws[prop] = value;
  48233. }
  48234. }
  48235. return node;
  48236. }
  48237. function indexesOf(array, item) {
  48238. var i = -1;
  48239. var indexes = [];
  48240. while ((i = array.indexOf(item, i + 1)) !== -1) {
  48241. indexes.push(i);
  48242. }
  48243. return indexes;
  48244. }
  48245. function uniqs() {
  48246. var list = Array.prototype.concat.apply([], arguments);
  48247. return list.filter(function (item, i) {
  48248. return i === list.indexOf(item);
  48249. });
  48250. }
  48251. var Parser = /*#__PURE__*/function () {
  48252. function Parser(rule, options) {
  48253. if (options === void 0) {
  48254. options = {};
  48255. }
  48256. this.rule = rule;
  48257. this.options = Object.assign({
  48258. lossy: false,
  48259. safe: false
  48260. }, options);
  48261. this.position = 0;
  48262. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  48263. this.tokens = (0, _tokenize["default"])({
  48264. css: this.css,
  48265. error: this._errorGenerator(),
  48266. safe: this.options.safe
  48267. });
  48268. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  48269. this.root = new _root["default"]({
  48270. source: rootSource
  48271. });
  48272. this.root.errorGenerator = this._errorGenerator();
  48273. var selector = new _selector["default"]({
  48274. source: {
  48275. start: {
  48276. line: 1,
  48277. column: 1
  48278. }
  48279. }
  48280. });
  48281. this.root.append(selector);
  48282. this.current = selector;
  48283. this.loop();
  48284. }
  48285. var _proto = Parser.prototype;
  48286. _proto._errorGenerator = function _errorGenerator() {
  48287. var _this = this;
  48288. return function (message, errorOptions) {
  48289. if (typeof _this.rule === 'string') {
  48290. return new Error(message);
  48291. }
  48292. return _this.rule.error(message, errorOptions);
  48293. };
  48294. };
  48295. _proto.attribute = function attribute() {
  48296. var attr = [];
  48297. var startingToken = this.currToken;
  48298. this.position++;
  48299. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  48300. attr.push(this.currToken);
  48301. this.position++;
  48302. }
  48303. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  48304. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  48305. }
  48306. var len = attr.length;
  48307. var node = {
  48308. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  48309. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  48310. };
  48311. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  48312. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  48313. }
  48314. var pos = 0;
  48315. var spaceBefore = '';
  48316. var commentBefore = '';
  48317. var lastAdded = null;
  48318. var spaceAfterMeaningfulToken = false;
  48319. while (pos < len) {
  48320. var token = attr[pos];
  48321. var content = this.content(token);
  48322. var next = attr[pos + 1];
  48323. switch (token[_tokenize.FIELDS.TYPE]) {
  48324. case tokens.space:
  48325. // if (
  48326. // len === 1 ||
  48327. // pos === 0 && this.content(next) === '|'
  48328. // ) {
  48329. // return this.expected('attribute', token[TOKEN.START_POS], content);
  48330. // }
  48331. spaceAfterMeaningfulToken = true;
  48332. if (this.options.lossy) {
  48333. break;
  48334. }
  48335. if (lastAdded) {
  48336. (0, util$2.ensureObject)(node, 'spaces', lastAdded);
  48337. var prevContent = node.spaces[lastAdded].after || '';
  48338. node.spaces[lastAdded].after = prevContent + content;
  48339. var existingComment = (0, util$2.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  48340. if (existingComment) {
  48341. node.raws.spaces[lastAdded].after = existingComment + content;
  48342. }
  48343. } else {
  48344. spaceBefore = spaceBefore + content;
  48345. commentBefore = commentBefore + content;
  48346. }
  48347. break;
  48348. case tokens.asterisk:
  48349. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  48350. node.operator = content;
  48351. lastAdded = 'operator';
  48352. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  48353. if (spaceBefore) {
  48354. (0, util$2.ensureObject)(node, 'spaces', 'attribute');
  48355. node.spaces.attribute.before = spaceBefore;
  48356. spaceBefore = '';
  48357. }
  48358. if (commentBefore) {
  48359. (0, util$2.ensureObject)(node, 'raws', 'spaces', 'attribute');
  48360. node.raws.spaces.attribute.before = spaceBefore;
  48361. commentBefore = '';
  48362. }
  48363. node.namespace = (node.namespace || "") + content;
  48364. var rawValue = (0, util$2.getProp)(node, 'raws', 'namespace') || null;
  48365. if (rawValue) {
  48366. node.raws.namespace += content;
  48367. }
  48368. lastAdded = 'namespace';
  48369. }
  48370. spaceAfterMeaningfulToken = false;
  48371. break;
  48372. case tokens.dollar:
  48373. if (lastAdded === "value") {
  48374. var oldRawValue = (0, util$2.getProp)(node, 'raws', 'value');
  48375. node.value += "$";
  48376. if (oldRawValue) {
  48377. node.raws.value = oldRawValue + "$";
  48378. }
  48379. break;
  48380. }
  48381. // Falls through
  48382. case tokens.caret:
  48383. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  48384. node.operator = content;
  48385. lastAdded = 'operator';
  48386. }
  48387. spaceAfterMeaningfulToken = false;
  48388. break;
  48389. case tokens.combinator:
  48390. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  48391. node.operator = content;
  48392. lastAdded = 'operator';
  48393. }
  48394. if (content !== '|') {
  48395. spaceAfterMeaningfulToken = false;
  48396. break;
  48397. }
  48398. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  48399. node.operator = content;
  48400. lastAdded = 'operator';
  48401. } else if (!node.namespace && !node.attribute) {
  48402. node.namespace = true;
  48403. }
  48404. spaceAfterMeaningfulToken = false;
  48405. break;
  48406. case tokens.word:
  48407. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && // this look-ahead probably fails with comment nodes involved.
  48408. !node.operator && !node.namespace) {
  48409. node.namespace = content;
  48410. lastAdded = 'namespace';
  48411. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  48412. if (spaceBefore) {
  48413. (0, util$2.ensureObject)(node, 'spaces', 'attribute');
  48414. node.spaces.attribute.before = spaceBefore;
  48415. spaceBefore = '';
  48416. }
  48417. if (commentBefore) {
  48418. (0, util$2.ensureObject)(node, 'raws', 'spaces', 'attribute');
  48419. node.raws.spaces.attribute.before = commentBefore;
  48420. commentBefore = '';
  48421. }
  48422. node.attribute = (node.attribute || "") + content;
  48423. var _rawValue = (0, util$2.getProp)(node, 'raws', 'attribute') || null;
  48424. if (_rawValue) {
  48425. node.raws.attribute += content;
  48426. }
  48427. lastAdded = 'attribute';
  48428. } else if (!node.value && node.value !== "" || lastAdded === "value" && !spaceAfterMeaningfulToken) {
  48429. var _unescaped = (0, util$2.unesc)(content);
  48430. var _oldRawValue = (0, util$2.getProp)(node, 'raws', 'value') || '';
  48431. var oldValue = node.value || '';
  48432. node.value = oldValue + _unescaped;
  48433. node.quoteMark = null;
  48434. if (_unescaped !== content || _oldRawValue) {
  48435. (0, util$2.ensureObject)(node, 'raws');
  48436. node.raws.value = (_oldRawValue || oldValue) + content;
  48437. }
  48438. lastAdded = 'value';
  48439. } else {
  48440. var insensitive = content === 'i' || content === "I";
  48441. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  48442. node.insensitive = insensitive;
  48443. if (!insensitive || content === "I") {
  48444. (0, util$2.ensureObject)(node, 'raws');
  48445. node.raws.insensitiveFlag = content;
  48446. }
  48447. lastAdded = 'insensitive';
  48448. if (spaceBefore) {
  48449. (0, util$2.ensureObject)(node, 'spaces', 'insensitive');
  48450. node.spaces.insensitive.before = spaceBefore;
  48451. spaceBefore = '';
  48452. }
  48453. if (commentBefore) {
  48454. (0, util$2.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  48455. node.raws.spaces.insensitive.before = commentBefore;
  48456. commentBefore = '';
  48457. }
  48458. } else if (node.value || node.value === '') {
  48459. lastAdded = 'value';
  48460. node.value += content;
  48461. if (node.raws.value) {
  48462. node.raws.value += content;
  48463. }
  48464. }
  48465. }
  48466. spaceAfterMeaningfulToken = false;
  48467. break;
  48468. case tokens.str:
  48469. if (!node.attribute || !node.operator) {
  48470. return this.error("Expected an attribute followed by an operator preceding the string.", {
  48471. index: token[_tokenize.FIELDS.START_POS]
  48472. });
  48473. }
  48474. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  48475. unescaped = _unescapeValue.unescaped,
  48476. quoteMark = _unescapeValue.quoteMark;
  48477. node.value = unescaped;
  48478. node.quoteMark = quoteMark;
  48479. lastAdded = 'value';
  48480. (0, util$2.ensureObject)(node, 'raws');
  48481. node.raws.value = content;
  48482. spaceAfterMeaningfulToken = false;
  48483. break;
  48484. case tokens.equals:
  48485. if (!node.attribute) {
  48486. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  48487. }
  48488. if (node.value) {
  48489. return this.error('Unexpected "=" found; an operator was already defined.', {
  48490. index: token[_tokenize.FIELDS.START_POS]
  48491. });
  48492. }
  48493. node.operator = node.operator ? node.operator + content : content;
  48494. lastAdded = 'operator';
  48495. spaceAfterMeaningfulToken = false;
  48496. break;
  48497. case tokens.comment:
  48498. if (lastAdded) {
  48499. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  48500. var lastComment = (0, util$2.getProp)(node, 'spaces', lastAdded, 'after') || '';
  48501. var rawLastComment = (0, util$2.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  48502. (0, util$2.ensureObject)(node, 'raws', 'spaces', lastAdded);
  48503. node.raws.spaces[lastAdded].after = rawLastComment + content;
  48504. } else {
  48505. var lastValue = node[lastAdded] || '';
  48506. var rawLastValue = (0, util$2.getProp)(node, 'raws', lastAdded) || lastValue;
  48507. (0, util$2.ensureObject)(node, 'raws');
  48508. node.raws[lastAdded] = rawLastValue + content;
  48509. }
  48510. } else {
  48511. commentBefore = commentBefore + content;
  48512. }
  48513. break;
  48514. default:
  48515. return this.error("Unexpected \"" + content + "\" found.", {
  48516. index: token[_tokenize.FIELDS.START_POS]
  48517. });
  48518. }
  48519. pos++;
  48520. }
  48521. unescapeProp(node, "attribute");
  48522. unescapeProp(node, "namespace");
  48523. this.newNode(new _attribute["default"](node));
  48524. this.position++;
  48525. }
  48526. /**
  48527. * return a node containing meaningless garbage up to (but not including) the specified token position.
  48528. * if the token position is negative, all remaining tokens are consumed.
  48529. *
  48530. * This returns an array containing a single string node if all whitespace,
  48531. * otherwise an array of comment nodes with space before and after.
  48532. *
  48533. * These tokens are not added to the current selector, the caller can add them or use them to amend
  48534. * a previous node's space metadata.
  48535. *
  48536. * In lossy mode, this returns only comments.
  48537. */
  48538. ;
  48539. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  48540. if (stopPosition < 0) {
  48541. stopPosition = this.tokens.length;
  48542. }
  48543. var startPosition = this.position;
  48544. var nodes = [];
  48545. var space = "";
  48546. var lastComment = undefined;
  48547. do {
  48548. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  48549. if (!this.options.lossy) {
  48550. space += this.content();
  48551. }
  48552. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  48553. var spaces = {};
  48554. if (space) {
  48555. spaces.before = space;
  48556. space = "";
  48557. }
  48558. lastComment = new _comment["default"]({
  48559. value: this.content(),
  48560. source: getTokenSource(this.currToken),
  48561. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  48562. spaces: spaces
  48563. });
  48564. nodes.push(lastComment);
  48565. }
  48566. } while (++this.position < stopPosition);
  48567. if (space) {
  48568. if (lastComment) {
  48569. lastComment.spaces.after = space;
  48570. } else if (!this.options.lossy) {
  48571. var firstToken = this.tokens[startPosition];
  48572. var lastToken = this.tokens[this.position - 1];
  48573. nodes.push(new _string["default"]({
  48574. value: '',
  48575. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  48576. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  48577. spaces: {
  48578. before: space,
  48579. after: ''
  48580. }
  48581. }));
  48582. }
  48583. }
  48584. return nodes;
  48585. }
  48586. /**
  48587. *
  48588. * @param {*} nodes
  48589. */
  48590. ;
  48591. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  48592. var _this2 = this;
  48593. if (requiredSpace === void 0) {
  48594. requiredSpace = false;
  48595. }
  48596. var space = "";
  48597. var rawSpace = "";
  48598. nodes.forEach(function (n) {
  48599. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  48600. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  48601. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  48602. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  48603. });
  48604. if (rawSpace === space) {
  48605. rawSpace = undefined;
  48606. }
  48607. var result = {
  48608. space: space,
  48609. rawSpace: rawSpace
  48610. };
  48611. return result;
  48612. };
  48613. _proto.isNamedCombinator = function isNamedCombinator(position) {
  48614. if (position === void 0) {
  48615. position = this.position;
  48616. }
  48617. 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;
  48618. };
  48619. _proto.namedCombinator = function namedCombinator() {
  48620. if (this.isNamedCombinator()) {
  48621. var nameRaw = this.content(this.tokens[this.position + 1]);
  48622. var name = (0, util$2.unesc)(nameRaw).toLowerCase();
  48623. var raws = {};
  48624. if (name !== nameRaw) {
  48625. raws.value = "/" + nameRaw + "/";
  48626. }
  48627. var node = new _combinator["default"]({
  48628. value: "/" + name + "/",
  48629. 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]),
  48630. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  48631. raws: raws
  48632. });
  48633. this.position = this.position + 3;
  48634. return node;
  48635. } else {
  48636. this.unexpected();
  48637. }
  48638. };
  48639. _proto.combinator = function combinator() {
  48640. var _this3 = this;
  48641. if (this.content() === '|') {
  48642. return this.namespace();
  48643. } // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  48644. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  48645. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  48646. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  48647. if (nodes.length > 0) {
  48648. var last = this.current.last;
  48649. if (last) {
  48650. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  48651. space = _this$convertWhitespa.space,
  48652. rawSpace = _this$convertWhitespa.rawSpace;
  48653. if (rawSpace !== undefined) {
  48654. last.rawSpaceAfter += rawSpace;
  48655. }
  48656. last.spaces.after += space;
  48657. } else {
  48658. nodes.forEach(function (n) {
  48659. return _this3.newNode(n);
  48660. });
  48661. }
  48662. }
  48663. return;
  48664. }
  48665. var firstToken = this.currToken;
  48666. var spaceOrDescendantSelectorNodes = undefined;
  48667. if (nextSigTokenPos > this.position) {
  48668. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  48669. }
  48670. var node;
  48671. if (this.isNamedCombinator()) {
  48672. node = this.namedCombinator();
  48673. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  48674. node = new _combinator["default"]({
  48675. value: this.content(),
  48676. source: getTokenSource(this.currToken),
  48677. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  48678. });
  48679. this.position++;
  48680. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  48681. this.unexpected();
  48682. }
  48683. if (node) {
  48684. if (spaceOrDescendantSelectorNodes) {
  48685. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  48686. _space = _this$convertWhitespa2.space,
  48687. _rawSpace = _this$convertWhitespa2.rawSpace;
  48688. node.spaces.before = _space;
  48689. node.rawSpaceBefore = _rawSpace;
  48690. }
  48691. } else {
  48692. // descendant combinator
  48693. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  48694. _space2 = _this$convertWhitespa3.space,
  48695. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  48696. if (!_rawSpace2) {
  48697. _rawSpace2 = _space2;
  48698. }
  48699. var spaces = {};
  48700. var raws = {
  48701. spaces: {}
  48702. };
  48703. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  48704. spaces.before = _space2.slice(0, _space2.length - 1);
  48705. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  48706. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  48707. spaces.after = _space2.slice(1);
  48708. raws.spaces.after = _rawSpace2.slice(1);
  48709. } else {
  48710. raws.value = _rawSpace2;
  48711. }
  48712. node = new _combinator["default"]({
  48713. value: ' ',
  48714. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  48715. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  48716. spaces: spaces,
  48717. raws: raws
  48718. });
  48719. }
  48720. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  48721. node.spaces.after = this.optionalSpace(this.content());
  48722. this.position++;
  48723. }
  48724. return this.newNode(node);
  48725. };
  48726. _proto.comma = function comma() {
  48727. if (this.position === this.tokens.length - 1) {
  48728. this.root.trailingComma = true;
  48729. this.position++;
  48730. return;
  48731. }
  48732. this.current._inferEndPosition();
  48733. var selector = new _selector["default"]({
  48734. source: {
  48735. start: tokenStart(this.tokens[this.position + 1])
  48736. }
  48737. });
  48738. this.current.parent.append(selector);
  48739. this.current = selector;
  48740. this.position++;
  48741. };
  48742. _proto.comment = function comment() {
  48743. var current = this.currToken;
  48744. this.newNode(new _comment["default"]({
  48745. value: this.content(),
  48746. source: getTokenSource(current),
  48747. sourceIndex: current[_tokenize.FIELDS.START_POS]
  48748. }));
  48749. this.position++;
  48750. };
  48751. _proto.error = function error(message, opts) {
  48752. throw this.root.error(message, opts);
  48753. };
  48754. _proto.missingBackslash = function missingBackslash() {
  48755. return this.error('Expected a backslash preceding the semicolon.', {
  48756. index: this.currToken[_tokenize.FIELDS.START_POS]
  48757. });
  48758. };
  48759. _proto.missingParenthesis = function missingParenthesis() {
  48760. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  48761. };
  48762. _proto.missingSquareBracket = function missingSquareBracket() {
  48763. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  48764. };
  48765. _proto.unexpected = function unexpected() {
  48766. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  48767. };
  48768. _proto.namespace = function namespace() {
  48769. var before = this.prevToken && this.content(this.prevToken) || true;
  48770. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  48771. this.position++;
  48772. return this.word(before);
  48773. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  48774. this.position++;
  48775. return this.universal(before);
  48776. }
  48777. };
  48778. _proto.nesting = function nesting() {
  48779. if (this.nextToken) {
  48780. var nextContent = this.content(this.nextToken);
  48781. if (nextContent === "|") {
  48782. this.position++;
  48783. return;
  48784. }
  48785. }
  48786. var current = this.currToken;
  48787. this.newNode(new _nesting["default"]({
  48788. value: this.content(),
  48789. source: getTokenSource(current),
  48790. sourceIndex: current[_tokenize.FIELDS.START_POS]
  48791. }));
  48792. this.position++;
  48793. };
  48794. _proto.parentheses = function parentheses() {
  48795. var last = this.current.last;
  48796. var unbalanced = 1;
  48797. this.position++;
  48798. if (last && last.type === types.PSEUDO) {
  48799. var selector = new _selector["default"]({
  48800. source: {
  48801. start: tokenStart(this.tokens[this.position - 1])
  48802. }
  48803. });
  48804. var cache = this.current;
  48805. last.append(selector);
  48806. this.current = selector;
  48807. while (this.position < this.tokens.length && unbalanced) {
  48808. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  48809. unbalanced++;
  48810. }
  48811. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  48812. unbalanced--;
  48813. }
  48814. if (unbalanced) {
  48815. this.parse();
  48816. } else {
  48817. this.current.source.end = tokenEnd(this.currToken);
  48818. this.current.parent.source.end = tokenEnd(this.currToken);
  48819. this.position++;
  48820. }
  48821. }
  48822. this.current = cache;
  48823. } else {
  48824. // I think this case should be an error. It's used to implement a basic parse of media queries
  48825. // but I don't think it's a good idea.
  48826. var parenStart = this.currToken;
  48827. var parenValue = "(";
  48828. var parenEnd;
  48829. while (this.position < this.tokens.length && unbalanced) {
  48830. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  48831. unbalanced++;
  48832. }
  48833. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  48834. unbalanced--;
  48835. }
  48836. parenEnd = this.currToken;
  48837. parenValue += this.parseParenthesisToken(this.currToken);
  48838. this.position++;
  48839. }
  48840. if (last) {
  48841. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  48842. } else {
  48843. this.newNode(new _string["default"]({
  48844. value: parenValue,
  48845. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  48846. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  48847. }));
  48848. }
  48849. }
  48850. if (unbalanced) {
  48851. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  48852. }
  48853. };
  48854. _proto.pseudo = function pseudo() {
  48855. var _this4 = this;
  48856. var pseudoStr = '';
  48857. var startingToken = this.currToken;
  48858. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  48859. pseudoStr += this.content();
  48860. this.position++;
  48861. }
  48862. if (!this.currToken) {
  48863. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  48864. }
  48865. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  48866. this.splitWord(false, function (first, length) {
  48867. pseudoStr += first;
  48868. _this4.newNode(new _pseudo["default"]({
  48869. value: pseudoStr,
  48870. source: getTokenSourceSpan(startingToken, _this4.currToken),
  48871. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  48872. }));
  48873. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  48874. _this4.error('Misplaced parenthesis.', {
  48875. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  48876. });
  48877. }
  48878. });
  48879. } else {
  48880. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  48881. }
  48882. };
  48883. _proto.space = function space() {
  48884. var content = this.content(); // Handle space before and after the selector
  48885. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  48886. return node.type === 'comment';
  48887. })) {
  48888. this.spaces = this.optionalSpace(content);
  48889. this.position++;
  48890. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  48891. this.current.last.spaces.after = this.optionalSpace(content);
  48892. this.position++;
  48893. } else {
  48894. this.combinator();
  48895. }
  48896. };
  48897. _proto.string = function string() {
  48898. var current = this.currToken;
  48899. this.newNode(new _string["default"]({
  48900. value: this.content(),
  48901. source: getTokenSource(current),
  48902. sourceIndex: current[_tokenize.FIELDS.START_POS]
  48903. }));
  48904. this.position++;
  48905. };
  48906. _proto.universal = function universal(namespace) {
  48907. var nextToken = this.nextToken;
  48908. if (nextToken && this.content(nextToken) === '|') {
  48909. this.position++;
  48910. return this.namespace();
  48911. }
  48912. var current = this.currToken;
  48913. this.newNode(new _universal["default"]({
  48914. value: this.content(),
  48915. source: getTokenSource(current),
  48916. sourceIndex: current[_tokenize.FIELDS.START_POS]
  48917. }), namespace);
  48918. this.position++;
  48919. };
  48920. _proto.splitWord = function splitWord(namespace, firstCallback) {
  48921. var _this5 = this;
  48922. var nextToken = this.nextToken;
  48923. var word = this.content();
  48924. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  48925. this.position++;
  48926. var current = this.content();
  48927. word += current;
  48928. if (current.lastIndexOf('\\') === current.length - 1) {
  48929. var next = this.nextToken;
  48930. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  48931. word += this.requiredSpace(this.content(next));
  48932. this.position++;
  48933. }
  48934. }
  48935. nextToken = this.nextToken;
  48936. }
  48937. var hasClass = indexesOf(word, '.').filter(function (i) {
  48938. return word[i - 1] !== '\\';
  48939. });
  48940. var hasId = indexesOf(word, '#').filter(function (i) {
  48941. return word[i - 1] !== '\\';
  48942. }); // Eliminate Sass interpolations from the list of id indexes
  48943. var interpolations = indexesOf(word, '#{');
  48944. if (interpolations.length) {
  48945. hasId = hasId.filter(function (hashIndex) {
  48946. return !~interpolations.indexOf(hashIndex);
  48947. });
  48948. }
  48949. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  48950. indices.forEach(function (ind, i) {
  48951. var index = indices[i + 1] || word.length;
  48952. var value = word.slice(ind, index);
  48953. if (i === 0 && firstCallback) {
  48954. return firstCallback.call(_this5, value, indices.length);
  48955. }
  48956. var node;
  48957. var current = _this5.currToken;
  48958. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  48959. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  48960. if (~hasClass.indexOf(ind)) {
  48961. var classNameOpts = {
  48962. value: value.slice(1),
  48963. source: source,
  48964. sourceIndex: sourceIndex
  48965. };
  48966. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  48967. } else if (~hasId.indexOf(ind)) {
  48968. var idOpts = {
  48969. value: value.slice(1),
  48970. source: source,
  48971. sourceIndex: sourceIndex
  48972. };
  48973. node = new _id["default"](unescapeProp(idOpts, "value"));
  48974. } else {
  48975. var tagOpts = {
  48976. value: value,
  48977. source: source,
  48978. sourceIndex: sourceIndex
  48979. };
  48980. unescapeProp(tagOpts, "value");
  48981. node = new _tag["default"](tagOpts);
  48982. }
  48983. _this5.newNode(node, namespace); // Ensure that the namespace is used only once
  48984. namespace = null;
  48985. });
  48986. this.position++;
  48987. };
  48988. _proto.word = function word(namespace) {
  48989. var nextToken = this.nextToken;
  48990. if (nextToken && this.content(nextToken) === '|') {
  48991. this.position++;
  48992. return this.namespace();
  48993. }
  48994. return this.splitWord(namespace);
  48995. };
  48996. _proto.loop = function loop() {
  48997. while (this.position < this.tokens.length) {
  48998. this.parse(true);
  48999. }
  49000. this.current._inferEndPosition();
  49001. return this.root;
  49002. };
  49003. _proto.parse = function parse(throwOnParenthesis) {
  49004. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  49005. case tokens.space:
  49006. this.space();
  49007. break;
  49008. case tokens.comment:
  49009. this.comment();
  49010. break;
  49011. case tokens.openParenthesis:
  49012. this.parentheses();
  49013. break;
  49014. case tokens.closeParenthesis:
  49015. if (throwOnParenthesis) {
  49016. this.missingParenthesis();
  49017. }
  49018. break;
  49019. case tokens.openSquare:
  49020. this.attribute();
  49021. break;
  49022. case tokens.dollar:
  49023. case tokens.caret:
  49024. case tokens.equals:
  49025. case tokens.word:
  49026. this.word();
  49027. break;
  49028. case tokens.colon:
  49029. this.pseudo();
  49030. break;
  49031. case tokens.comma:
  49032. this.comma();
  49033. break;
  49034. case tokens.asterisk:
  49035. this.universal();
  49036. break;
  49037. case tokens.ampersand:
  49038. this.nesting();
  49039. break;
  49040. case tokens.slash:
  49041. case tokens.combinator:
  49042. this.combinator();
  49043. break;
  49044. case tokens.str:
  49045. this.string();
  49046. break;
  49047. // These cases throw; no break needed.
  49048. case tokens.closeSquare:
  49049. this.missingSquareBracket();
  49050. case tokens.semicolon:
  49051. this.missingBackslash();
  49052. default:
  49053. this.unexpected();
  49054. }
  49055. }
  49056. /**
  49057. * Helpers
  49058. */
  49059. ;
  49060. _proto.expected = function expected(description, index, found) {
  49061. if (Array.isArray(description)) {
  49062. var last = description.pop();
  49063. description = description.join(', ') + " or " + last;
  49064. }
  49065. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  49066. if (!found) {
  49067. return this.error("Expected " + an + " " + description + ".", {
  49068. index: index
  49069. });
  49070. }
  49071. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  49072. index: index
  49073. });
  49074. };
  49075. _proto.requiredSpace = function requiredSpace(space) {
  49076. return this.options.lossy ? ' ' : space;
  49077. };
  49078. _proto.optionalSpace = function optionalSpace(space) {
  49079. return this.options.lossy ? '' : space;
  49080. };
  49081. _proto.lossySpace = function lossySpace(space, required) {
  49082. if (this.options.lossy) {
  49083. return required ? ' ' : '';
  49084. } else {
  49085. return space;
  49086. }
  49087. };
  49088. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  49089. var content = this.content(token);
  49090. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  49091. return this.requiredSpace(content);
  49092. } else {
  49093. return content;
  49094. }
  49095. };
  49096. _proto.newNode = function newNode(node, namespace) {
  49097. if (namespace) {
  49098. if (/^ +$/.test(namespace)) {
  49099. if (!this.options.lossy) {
  49100. this.spaces = (this.spaces || '') + namespace;
  49101. }
  49102. namespace = true;
  49103. }
  49104. node.namespace = namespace;
  49105. unescapeProp(node, "namespace");
  49106. }
  49107. if (this.spaces) {
  49108. node.spaces.before = this.spaces;
  49109. this.spaces = '';
  49110. }
  49111. return this.current.append(node);
  49112. };
  49113. _proto.content = function content(token) {
  49114. if (token === void 0) {
  49115. token = this.currToken;
  49116. }
  49117. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  49118. };
  49119. /**
  49120. * returns the index of the next non-whitespace, non-comment token.
  49121. * returns -1 if no meaningful token is found.
  49122. */
  49123. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  49124. if (startPosition === void 0) {
  49125. startPosition = this.position + 1;
  49126. }
  49127. var searchPosition = startPosition;
  49128. while (searchPosition < this.tokens.length) {
  49129. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  49130. searchPosition++;
  49131. continue;
  49132. } else {
  49133. return searchPosition;
  49134. }
  49135. }
  49136. return -1;
  49137. };
  49138. _createClass(Parser, [{
  49139. key: "currToken",
  49140. get: function get() {
  49141. return this.tokens[this.position];
  49142. }
  49143. }, {
  49144. key: "nextToken",
  49145. get: function get() {
  49146. return this.tokens[this.position + 1];
  49147. }
  49148. }, {
  49149. key: "prevToken",
  49150. get: function get() {
  49151. return this.tokens[this.position - 1];
  49152. }
  49153. }]);
  49154. return Parser;
  49155. }();
  49156. exports["default"] = Parser;
  49157. module.exports = exports.default;
  49158. });
  49159. var processor$1 = createCommonjsModule(function (module, exports) {
  49160. exports.__esModule = true;
  49161. exports["default"] = void 0;
  49162. var _parser = _interopRequireDefault(parser$1);
  49163. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  49164. var Processor = /*#__PURE__*/function () {
  49165. function Processor(func, options) {
  49166. this.func = func || function noop() {};
  49167. this.funcRes = null;
  49168. this.options = options;
  49169. }
  49170. var _proto = Processor.prototype;
  49171. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  49172. if (options === void 0) {
  49173. options = {};
  49174. }
  49175. var merged = Object.assign({}, this.options, options);
  49176. if (merged.updateSelector === false) {
  49177. return false;
  49178. } else {
  49179. return typeof rule !== "string";
  49180. }
  49181. };
  49182. _proto._isLossy = function _isLossy(options) {
  49183. if (options === void 0) {
  49184. options = {};
  49185. }
  49186. var merged = Object.assign({}, this.options, options);
  49187. if (merged.lossless === false) {
  49188. return true;
  49189. } else {
  49190. return false;
  49191. }
  49192. };
  49193. _proto._root = function _root(rule, options) {
  49194. if (options === void 0) {
  49195. options = {};
  49196. }
  49197. var parser = new _parser["default"](rule, this._parseOptions(options));
  49198. return parser.root;
  49199. };
  49200. _proto._parseOptions = function _parseOptions(options) {
  49201. return {
  49202. lossy: this._isLossy(options)
  49203. };
  49204. };
  49205. _proto._run = function _run(rule, options) {
  49206. var _this = this;
  49207. if (options === void 0) {
  49208. options = {};
  49209. }
  49210. return new Promise(function (resolve, reject) {
  49211. try {
  49212. var root = _this._root(rule, options);
  49213. Promise.resolve(_this.func(root)).then(function (transform) {
  49214. var string = undefined;
  49215. if (_this._shouldUpdateSelector(rule, options)) {
  49216. string = root.toString();
  49217. rule.selector = string;
  49218. }
  49219. return {
  49220. transform: transform,
  49221. root: root,
  49222. string: string
  49223. };
  49224. }).then(resolve, reject);
  49225. } catch (e) {
  49226. reject(e);
  49227. return;
  49228. }
  49229. });
  49230. };
  49231. _proto._runSync = function _runSync(rule, options) {
  49232. if (options === void 0) {
  49233. options = {};
  49234. }
  49235. var root = this._root(rule, options);
  49236. var transform = this.func(root);
  49237. if (transform && typeof transform.then === "function") {
  49238. throw new Error("Selector processor returned a promise to a synchronous call.");
  49239. }
  49240. var string = undefined;
  49241. if (options.updateSelector && typeof rule !== "string") {
  49242. string = root.toString();
  49243. rule.selector = string;
  49244. }
  49245. return {
  49246. transform: transform,
  49247. root: root,
  49248. string: string
  49249. };
  49250. }
  49251. /**
  49252. * Process rule into a selector AST.
  49253. *
  49254. * @param rule {postcss.Rule | string} The css selector to be processed
  49255. * @param options The options for processing
  49256. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  49257. */
  49258. ;
  49259. _proto.ast = function ast(rule, options) {
  49260. return this._run(rule, options).then(function (result) {
  49261. return result.root;
  49262. });
  49263. }
  49264. /**
  49265. * Process rule into a selector AST synchronously.
  49266. *
  49267. * @param rule {postcss.Rule | string} The css selector to be processed
  49268. * @param options The options for processing
  49269. * @returns {parser.Root} The AST of the selector after processing it.
  49270. */
  49271. ;
  49272. _proto.astSync = function astSync(rule, options) {
  49273. return this._runSync(rule, options).root;
  49274. }
  49275. /**
  49276. * Process a selector into a transformed value asynchronously
  49277. *
  49278. * @param rule {postcss.Rule | string} The css selector to be processed
  49279. * @param options The options for processing
  49280. * @returns {Promise<any>} The value returned by the processor.
  49281. */
  49282. ;
  49283. _proto.transform = function transform(rule, options) {
  49284. return this._run(rule, options).then(function (result) {
  49285. return result.transform;
  49286. });
  49287. }
  49288. /**
  49289. * Process a selector into a transformed value synchronously.
  49290. *
  49291. * @param rule {postcss.Rule | string} The css selector to be processed
  49292. * @param options The options for processing
  49293. * @returns {any} The value returned by the processor.
  49294. */
  49295. ;
  49296. _proto.transformSync = function transformSync(rule, options) {
  49297. return this._runSync(rule, options).transform;
  49298. }
  49299. /**
  49300. * Process a selector into a new selector string asynchronously.
  49301. *
  49302. * @param rule {postcss.Rule | string} The css selector to be processed
  49303. * @param options The options for processing
  49304. * @returns {string} the selector after processing.
  49305. */
  49306. ;
  49307. _proto.process = function process(rule, options) {
  49308. return this._run(rule, options).then(function (result) {
  49309. return result.string || result.root.toString();
  49310. });
  49311. }
  49312. /**
  49313. * Process a selector into a new selector string synchronously.
  49314. *
  49315. * @param rule {postcss.Rule | string} The css selector to be processed
  49316. * @param options The options for processing
  49317. * @returns {string} the selector after processing.
  49318. */
  49319. ;
  49320. _proto.processSync = function processSync(rule, options) {
  49321. var result = this._runSync(rule, options);
  49322. return result.string || result.root.toString();
  49323. };
  49324. return Processor;
  49325. }();
  49326. exports["default"] = Processor;
  49327. module.exports = exports.default;
  49328. });
  49329. /*@__PURE__*/getDefaultExportFromCjs(processor$1);
  49330. var constructors = createCommonjsModule(function (module, exports) {
  49331. exports.__esModule = true;
  49332. exports.universal = exports.tag = exports.string = exports.selector = exports.root = exports.pseudo = exports.nesting = exports.id = exports.comment = exports.combinator = exports.className = exports.attribute = void 0;
  49333. var _attribute = _interopRequireDefault(attribute);
  49334. var _className = _interopRequireDefault(className);
  49335. var _combinator = _interopRequireDefault(combinator);
  49336. var _comment = _interopRequireDefault(comment$1);
  49337. var _id = _interopRequireDefault(id);
  49338. var _nesting = _interopRequireDefault(nesting);
  49339. var _pseudo = _interopRequireDefault(pseudo);
  49340. var _root = _interopRequireDefault(root$1);
  49341. var _selector = _interopRequireDefault(selector);
  49342. var _string = _interopRequireDefault(string);
  49343. var _tag = _interopRequireDefault(tag);
  49344. var _universal = _interopRequireDefault(universal);
  49345. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  49346. var attribute$1 = function attribute(opts) {
  49347. return new _attribute["default"](opts);
  49348. };
  49349. exports.attribute = attribute$1;
  49350. var className$1 = function className(opts) {
  49351. return new _className["default"](opts);
  49352. };
  49353. exports.className = className$1;
  49354. var combinator$1 = function combinator(opts) {
  49355. return new _combinator["default"](opts);
  49356. };
  49357. exports.combinator = combinator$1;
  49358. var comment = function comment(opts) {
  49359. return new _comment["default"](opts);
  49360. };
  49361. exports.comment = comment;
  49362. var id$1 = function id(opts) {
  49363. return new _id["default"](opts);
  49364. };
  49365. exports.id = id$1;
  49366. var nesting$1 = function nesting(opts) {
  49367. return new _nesting["default"](opts);
  49368. };
  49369. exports.nesting = nesting$1;
  49370. var pseudo$1 = function pseudo(opts) {
  49371. return new _pseudo["default"](opts);
  49372. };
  49373. exports.pseudo = pseudo$1;
  49374. var root = function root(opts) {
  49375. return new _root["default"](opts);
  49376. };
  49377. exports.root = root;
  49378. var selector$1 = function selector(opts) {
  49379. return new _selector["default"](opts);
  49380. };
  49381. exports.selector = selector$1;
  49382. var string$1 = function string(opts) {
  49383. return new _string["default"](opts);
  49384. };
  49385. exports.string = string$1;
  49386. var tag$1 = function tag(opts) {
  49387. return new _tag["default"](opts);
  49388. };
  49389. exports.tag = tag$1;
  49390. var universal$1 = function universal(opts) {
  49391. return new _universal["default"](opts);
  49392. };
  49393. exports.universal = universal$1;
  49394. });
  49395. var guards = createCommonjsModule(function (module, exports) {
  49396. exports.__esModule = true;
  49397. exports.isNode = isNode;
  49398. exports.isPseudoElement = isPseudoElement;
  49399. exports.isPseudoClass = isPseudoClass;
  49400. exports.isContainer = isContainer;
  49401. exports.isNamespace = isNamespace;
  49402. exports.isUniversal = exports.isTag = exports.isString = exports.isSelector = exports.isRoot = exports.isPseudo = exports.isNesting = exports.isIdentifier = exports.isComment = exports.isCombinator = exports.isClassName = exports.isAttribute = void 0;
  49403. var _IS_TYPE;
  49404. var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[types$2.ATTRIBUTE] = true, _IS_TYPE[types$2.CLASS] = true, _IS_TYPE[types$2.COMBINATOR] = true, _IS_TYPE[types$2.COMMENT] = true, _IS_TYPE[types$2.ID] = true, _IS_TYPE[types$2.NESTING] = true, _IS_TYPE[types$2.PSEUDO] = true, _IS_TYPE[types$2.ROOT] = true, _IS_TYPE[types$2.SELECTOR] = true, _IS_TYPE[types$2.STRING] = true, _IS_TYPE[types$2.TAG] = true, _IS_TYPE[types$2.UNIVERSAL] = true, _IS_TYPE);
  49405. function isNode(node) {
  49406. return typeof node === "object" && IS_TYPE[node.type];
  49407. }
  49408. function isNodeType(type, node) {
  49409. return isNode(node) && node.type === type;
  49410. }
  49411. var isAttribute = isNodeType.bind(null, types$2.ATTRIBUTE);
  49412. exports.isAttribute = isAttribute;
  49413. var isClassName = isNodeType.bind(null, types$2.CLASS);
  49414. exports.isClassName = isClassName;
  49415. var isCombinator = isNodeType.bind(null, types$2.COMBINATOR);
  49416. exports.isCombinator = isCombinator;
  49417. var isComment = isNodeType.bind(null, types$2.COMMENT);
  49418. exports.isComment = isComment;
  49419. var isIdentifier = isNodeType.bind(null, types$2.ID);
  49420. exports.isIdentifier = isIdentifier;
  49421. var isNesting = isNodeType.bind(null, types$2.NESTING);
  49422. exports.isNesting = isNesting;
  49423. var isPseudo = isNodeType.bind(null, types$2.PSEUDO);
  49424. exports.isPseudo = isPseudo;
  49425. var isRoot = isNodeType.bind(null, types$2.ROOT);
  49426. exports.isRoot = isRoot;
  49427. var isSelector = isNodeType.bind(null, types$2.SELECTOR);
  49428. exports.isSelector = isSelector;
  49429. var isString = isNodeType.bind(null, types$2.STRING);
  49430. exports.isString = isString;
  49431. var isTag = isNodeType.bind(null, types$2.TAG);
  49432. exports.isTag = isTag;
  49433. var isUniversal = isNodeType.bind(null, types$2.UNIVERSAL);
  49434. exports.isUniversal = isUniversal;
  49435. function isPseudoElement(node) {
  49436. return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after");
  49437. }
  49438. function isPseudoClass(node) {
  49439. return isPseudo(node) && !isPseudoElement(node);
  49440. }
  49441. function isContainer(node) {
  49442. return !!(isNode(node) && node.walk);
  49443. }
  49444. function isNamespace(node) {
  49445. return isAttribute(node) || isTag(node);
  49446. }
  49447. });
  49448. var selectors = createCommonjsModule(function (module, exports) {
  49449. exports.__esModule = true;
  49450. Object.keys(types$2).forEach(function (key) {
  49451. if (key === "default" || key === "__esModule") return;
  49452. if (key in exports && exports[key] === types$2[key]) return;
  49453. exports[key] = types$2[key];
  49454. });
  49455. Object.keys(constructors).forEach(function (key) {
  49456. if (key === "default" || key === "__esModule") return;
  49457. if (key in exports && exports[key] === constructors[key]) return;
  49458. exports[key] = constructors[key];
  49459. });
  49460. Object.keys(guards).forEach(function (key) {
  49461. if (key === "default" || key === "__esModule") return;
  49462. if (key in exports && exports[key] === guards[key]) return;
  49463. exports[key] = guards[key];
  49464. });
  49465. });
  49466. var dist = createCommonjsModule(function (module, exports) {
  49467. exports.__esModule = true;
  49468. exports["default"] = void 0;
  49469. var _processor = _interopRequireDefault(processor$1);
  49470. var selectors$1 = _interopRequireWildcard(selectors);
  49471. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  49472. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  49473. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  49474. var parser = function parser(processor) {
  49475. return new _processor["default"](processor);
  49476. };
  49477. Object.assign(parser, selectors$1);
  49478. delete parser.__esModule;
  49479. var _default = parser;
  49480. exports["default"] = _default;
  49481. module.exports = exports.default;
  49482. });
  49483. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(dist);
  49484. const animationNameRE = /^(-\w+-)?animation-name$/;
  49485. const animationRE = /^(-\w+-)?animation$/;
  49486. const scopedPlugin = (id = '') => {
  49487. const keyframes = Object.create(null);
  49488. const shortId = id.replace(/^data-v-/, '');
  49489. return {
  49490. postcssPlugin: 'vue-sfc-scoped',
  49491. Rule(rule) {
  49492. processRule(id, rule);
  49493. },
  49494. AtRule(node) {
  49495. if (/-?keyframes$/.test(node.name) &&
  49496. !node.params.endsWith(`-${shortId}`)) {
  49497. // register keyframes
  49498. keyframes[node.params] = node.params = node.params + '-' + shortId;
  49499. }
  49500. },
  49501. OnceExit(root) {
  49502. if (Object.keys(keyframes).length) {
  49503. // If keyframes are found in this <style>, find and rewrite animation names
  49504. // in declarations.
  49505. // Caveat: this only works for keyframes and animation rules in the same
  49506. // <style> element.
  49507. // individual animation-name declaration
  49508. root.walkDecls(decl => {
  49509. if (animationNameRE.test(decl.prop)) {
  49510. decl.value = decl.value
  49511. .split(',')
  49512. .map(v => keyframes[v.trim()] || v.trim())
  49513. .join(',');
  49514. }
  49515. // shorthand
  49516. if (animationRE.test(decl.prop)) {
  49517. decl.value = decl.value
  49518. .split(',')
  49519. .map(v => {
  49520. const vals = v.trim().split(/\s+/);
  49521. const i = vals.findIndex(val => keyframes[val]);
  49522. if (i !== -1) {
  49523. vals.splice(i, 1, keyframes[vals[i]]);
  49524. return vals.join(' ');
  49525. }
  49526. else {
  49527. return v;
  49528. }
  49529. })
  49530. .join(',');
  49531. }
  49532. });
  49533. }
  49534. }
  49535. };
  49536. };
  49537. const processedRules = new WeakSet();
  49538. function processRule(id, rule) {
  49539. if (processedRules.has(rule) ||
  49540. (rule.parent &&
  49541. rule.parent.type === 'atrule' &&
  49542. /-?keyframes$/.test(rule.parent.name))) {
  49543. return;
  49544. }
  49545. processedRules.add(rule);
  49546. rule.selector = selectorParser(selectorRoot => {
  49547. selectorRoot.each(selector => {
  49548. rewriteSelector(id, selector, selectorRoot);
  49549. });
  49550. }).processSync(rule.selector);
  49551. }
  49552. function rewriteSelector(id, selector, selectorRoot, slotted = false) {
  49553. let node = null;
  49554. let shouldInject = true;
  49555. // find the last child node to insert attribute selector
  49556. selector.each(n => {
  49557. // DEPRECATED ">>>" and "/deep/" combinator
  49558. if (n.type === 'combinator' &&
  49559. (n.value === '>>>' || n.value === '/deep/')) {
  49560. n.value = ' ';
  49561. n.spaces.before = n.spaces.after = '';
  49562. warn(`the >>> and /deep/ combinators have been deprecated. ` +
  49563. `Use :deep() instead.`);
  49564. return false;
  49565. }
  49566. if (n.type === 'pseudo') {
  49567. const { value } = n;
  49568. // deep: inject [id] attribute at the node before the ::v-deep
  49569. // combinator.
  49570. if (value === ':deep' || value === '::v-deep') {
  49571. if (n.nodes.length) {
  49572. // .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar
  49573. // replace the current node with ::v-deep's inner selector
  49574. let last = n;
  49575. n.nodes[0].each(ss => {
  49576. selector.insertAfter(last, ss);
  49577. last = ss;
  49578. });
  49579. // insert a space combinator before if it doesn't already have one
  49580. const prev = selector.at(selector.index(n) - 1);
  49581. if (!prev || !isSpaceCombinator(prev)) {
  49582. selector.insertAfter(n, selectorParser.combinator({
  49583. value: ' '
  49584. }));
  49585. }
  49586. selector.removeChild(n);
  49587. }
  49588. else {
  49589. // DEPRECATED usage
  49590. // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
  49591. warn(`::v-deep usage as a combinator has ` +
  49592. `been deprecated. Use :deep(<inner-selector>) instead.`);
  49593. const prev = selector.at(selector.index(n) - 1);
  49594. if (prev && isSpaceCombinator(prev)) {
  49595. selector.removeChild(prev);
  49596. }
  49597. selector.removeChild(n);
  49598. }
  49599. return false;
  49600. }
  49601. // slot: use selector inside `::v-slotted` and inject [id + '-s']
  49602. // instead.
  49603. // ::v-slotted(.foo) -> .foo[xxxxxxx-s]
  49604. if (value === ':slotted' || value === '::v-slotted') {
  49605. rewriteSelector(id, n.nodes[0], selectorRoot, true /* slotted */);
  49606. let last = n;
  49607. n.nodes[0].each(ss => {
  49608. selector.insertAfter(last, ss);
  49609. last = ss;
  49610. });
  49611. // selector.insertAfter(n, n.nodes[0])
  49612. selector.removeChild(n);
  49613. // since slotted attribute already scopes the selector there's no
  49614. // need for the non-slot attribute.
  49615. shouldInject = false;
  49616. return false;
  49617. }
  49618. // global: replace with inner selector and do not inject [id].
  49619. // ::v-global(.foo) -> .foo
  49620. if (value === ':global' || value === '::v-global') {
  49621. selectorRoot.insertAfter(selector, n.nodes[0]);
  49622. selectorRoot.removeChild(selector);
  49623. return false;
  49624. }
  49625. }
  49626. if (n.type !== 'pseudo' && n.type !== 'combinator') {
  49627. node = n;
  49628. }
  49629. });
  49630. if (node) {
  49631. node.spaces.after = '';
  49632. }
  49633. else {
  49634. // For deep selectors & standalone pseudo selectors,
  49635. // the attribute selectors are prepended rather than appended.
  49636. // So all leading spaces must be eliminated to avoid problems.
  49637. selector.first.spaces.before = '';
  49638. }
  49639. if (shouldInject) {
  49640. const idToAdd = slotted ? id + '-s' : id;
  49641. selector.insertAfter(
  49642. // If node is null it means we need to inject [id] at the start
  49643. // insertAfter can handle `null` here
  49644. node, selectorParser.attribute({
  49645. attribute: idToAdd,
  49646. value: idToAdd,
  49647. raws: {},
  49648. quoteMark: `"`
  49649. }));
  49650. }
  49651. }
  49652. function isSpaceCombinator(node) {
  49653. return node.type === 'combinator' && /^\s+$/.test(node.value);
  49654. }
  49655. scopedPlugin.postcss = true;
  49656. var SourceMapConsumer$7 = sourceMap.SourceMapConsumer;
  49657. var SourceMapGenerator$9 = sourceMap.SourceMapGenerator;
  49658. var mergeSourceMap = merge$1;
  49659. /**
  49660. * Merge old source map and new source map and return merged.
  49661. * If old or new source map value is falsy, return another one as it is.
  49662. *
  49663. * @param {object|string} [oldMap] old source map object
  49664. * @param {object|string} [newmap] new source map object
  49665. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  49666. */
  49667. function merge$1(oldMap, newMap) {
  49668. if (!oldMap) return newMap
  49669. if (!newMap) return oldMap
  49670. var oldMapConsumer = new SourceMapConsumer$7(oldMap);
  49671. var newMapConsumer = new SourceMapConsumer$7(newMap);
  49672. var mergedMapGenerator = new SourceMapGenerator$9();
  49673. // iterate on new map and overwrite original position of new map with one of old map
  49674. newMapConsumer.eachMapping(function(m) {
  49675. // pass when `originalLine` is null.
  49676. // It occurs in case that the node does not have origin in original code.
  49677. if (m.originalLine == null) return
  49678. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  49679. line: m.originalLine,
  49680. column: m.originalColumn
  49681. });
  49682. if (origPosInOldMap.source == null) return
  49683. mergedMapGenerator.addMapping({
  49684. original: {
  49685. line: origPosInOldMap.line,
  49686. column: origPosInOldMap.column
  49687. },
  49688. generated: {
  49689. line: m.generatedLine,
  49690. column: m.generatedColumn
  49691. },
  49692. source: origPosInOldMap.source,
  49693. name: origPosInOldMap.name
  49694. });
  49695. });
  49696. var consumers = [oldMapConsumer, newMapConsumer];
  49697. consumers.forEach(function(consumer) {
  49698. consumer.sources.forEach(function(sourceFile) {
  49699. mergedMapGenerator._sources.add(sourceFile);
  49700. var sourceContent = consumer.sourceContentFor(sourceFile);
  49701. if (sourceContent != null) {
  49702. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  49703. }
  49704. });
  49705. });
  49706. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  49707. mergedMapGenerator._file = oldMap.file;
  49708. return JSON.parse(mergedMapGenerator.toString())
  49709. }
  49710. // .scss/.sass processor
  49711. const scss = (source, map, options, load = require) => {
  49712. const nodeSass = load('sass');
  49713. const finalOptions = Object.assign(Object.assign({}, options), { data: getSource(source, options.filename, options.additionalData), file: options.filename, outFile: options.filename, sourceMap: !!map });
  49714. try {
  49715. const result = nodeSass.renderSync(finalOptions);
  49716. const dependencies = result.stats.includedFiles;
  49717. if (map) {
  49718. return {
  49719. code: result.css.toString(),
  49720. map: mergeSourceMap(map, JSON.parse(result.map.toString())),
  49721. errors: [],
  49722. dependencies
  49723. };
  49724. }
  49725. return { code: result.css.toString(), errors: [], dependencies };
  49726. }
  49727. catch (e) {
  49728. return { code: '', errors: [e], dependencies: [] };
  49729. }
  49730. };
  49731. const sass = (source, map, options, load) => scss(source, map, Object.assign(Object.assign({}, options), { indentedSyntax: true }), load);
  49732. // .less
  49733. const less = (source, map, options, load = require) => {
  49734. const nodeLess = load('less');
  49735. let result;
  49736. let error = null;
  49737. nodeLess.render(getSource(source, options.filename, options.additionalData), Object.assign(Object.assign({}, options), { syncImport: true }), (err, output) => {
  49738. error = err;
  49739. result = output;
  49740. });
  49741. if (error)
  49742. return { code: '', errors: [error], dependencies: [] };
  49743. const dependencies = result.imports;
  49744. if (map) {
  49745. return {
  49746. code: result.css.toString(),
  49747. map: mergeSourceMap(map, result.map),
  49748. errors: [],
  49749. dependencies: dependencies
  49750. };
  49751. }
  49752. return {
  49753. code: result.css.toString(),
  49754. errors: [],
  49755. dependencies: dependencies
  49756. };
  49757. };
  49758. // .styl
  49759. const styl = (source, map, options, load = require) => {
  49760. const nodeStylus = load('stylus');
  49761. try {
  49762. const ref = nodeStylus(source);
  49763. Object.keys(options).forEach(key => ref.set(key, options[key]));
  49764. if (map)
  49765. ref.set('sourcemap', { inline: false, comment: false });
  49766. const result = ref.render();
  49767. const dependencies = ref.deps();
  49768. if (map) {
  49769. return {
  49770. code: result,
  49771. map: mergeSourceMap(map, ref.sourcemap),
  49772. errors: [],
  49773. dependencies
  49774. };
  49775. }
  49776. return { code: result, errors: [], dependencies };
  49777. }
  49778. catch (e) {
  49779. return { code: '', errors: [e], dependencies: [] };
  49780. }
  49781. };
  49782. function getSource(source, filename, additionalData) {
  49783. if (!additionalData)
  49784. return source;
  49785. if (isFunction(additionalData)) {
  49786. return additionalData(source, filename);
  49787. }
  49788. return additionalData + source;
  49789. }
  49790. const processors = {
  49791. less,
  49792. sass,
  49793. scss,
  49794. styl,
  49795. stylus: styl
  49796. };
  49797. function compileStyle(options) {
  49798. return doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: false }));
  49799. }
  49800. function compileStyleAsync(options) {
  49801. return doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: true }));
  49802. }
  49803. function doCompileStyle(options) {
  49804. const { filename, id, scoped = false, trim = true, isProd = false, modules = false, modulesOptions = {}, preprocessLang, postcssOptions, postcssPlugins } = options;
  49805. const preprocessor = preprocessLang && processors[preprocessLang];
  49806. const preProcessedSource = preprocessor && preprocess$1(options, preprocessor);
  49807. const map = preProcessedSource
  49808. ? preProcessedSource.map
  49809. : options.inMap || options.map;
  49810. const source = preProcessedSource ? preProcessedSource.code : options.source;
  49811. const shortId = id.replace(/^data-v-/, '');
  49812. const longId = `data-v-${shortId}`;
  49813. const plugins = (postcssPlugins || []).slice();
  49814. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  49815. if (trim) {
  49816. plugins.push(trimPlugin());
  49817. }
  49818. if (scoped) {
  49819. plugins.push(scopedPlugin(longId));
  49820. }
  49821. let cssModules;
  49822. if (modules) {
  49823. {
  49824. throw new Error('[@vue/compiler-sfc] `modules` option is not supported in the browser build.');
  49825. }
  49826. }
  49827. const postCSSOptions = Object.assign(Object.assign({}, postcssOptions), { to: filename, from: filename });
  49828. if (map) {
  49829. postCSSOptions.map = {
  49830. inline: false,
  49831. annotation: false,
  49832. prev: map
  49833. };
  49834. }
  49835. let result;
  49836. let code;
  49837. let outMap;
  49838. // stylus output include plain css. so need remove the repeat item
  49839. const dependencies = new Set(preProcessedSource ? preProcessedSource.dependencies : []);
  49840. // sass has filename self when provided filename option
  49841. dependencies.delete(filename);
  49842. const errors = [];
  49843. if (preProcessedSource && preProcessedSource.errors.length) {
  49844. errors.push(...preProcessedSource.errors);
  49845. }
  49846. const recordPlainCssDependencies = (messages) => {
  49847. messages.forEach(msg => {
  49848. if (msg.type === 'dependency') {
  49849. // postcss output path is absolute position path
  49850. dependencies.add(msg.file);
  49851. }
  49852. });
  49853. return dependencies;
  49854. };
  49855. try {
  49856. result = postcss_1(plugins).process(source, postCSSOptions);
  49857. // In async mode, return a promise.
  49858. if (options.isAsync) {
  49859. return result
  49860. .then(result => ({
  49861. code: result.css || '',
  49862. map: result.map && result.map.toJSON(),
  49863. errors,
  49864. modules: cssModules,
  49865. rawResult: result,
  49866. dependencies: recordPlainCssDependencies(result.messages)
  49867. }))
  49868. .catch(error => ({
  49869. code: '',
  49870. map: undefined,
  49871. errors: [...errors, error],
  49872. rawResult: undefined,
  49873. dependencies
  49874. }));
  49875. }
  49876. recordPlainCssDependencies(result.messages);
  49877. // force synchronous transform (we know we only have sync plugins)
  49878. code = result.css;
  49879. outMap = result.map;
  49880. }
  49881. catch (e) {
  49882. errors.push(e);
  49883. }
  49884. return {
  49885. code: code || ``,
  49886. map: outMap && outMap.toJSON(),
  49887. errors,
  49888. rawResult: result,
  49889. dependencies
  49890. };
  49891. }
  49892. function preprocess$1(options, preprocessor) {
  49893. if (!options.preprocessCustomRequire) {
  49894. throw new Error(`[@vue/compiler-sfc] Style preprocessing in the browser build must ` +
  49895. `provide the \`preprocessCustomRequire\` option to return the in-browser ` +
  49896. `version of the preprocessor.`);
  49897. }
  49898. return preprocessor(options.source, options.inMap || options.map, Object.assign({ filename: options.filename }, options.preprocessOptions), options.preprocessCustomRequire);
  49899. }
  49900. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  49901. function encode$5(decoded) {
  49902. var sourceFileIndex = 0; // second field
  49903. var sourceCodeLine = 0; // third field
  49904. var sourceCodeColumn = 0; // fourth field
  49905. var nameIndex = 0; // fifth field
  49906. var mappings = '';
  49907. for (var i = 0; i < decoded.length; i++) {
  49908. var line = decoded[i];
  49909. if (i > 0)
  49910. mappings += ';';
  49911. if (line.length === 0)
  49912. continue;
  49913. var generatedCodeColumn = 0; // first field
  49914. var lineMappings = [];
  49915. for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
  49916. var segment = line_1[_i];
  49917. var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
  49918. generatedCodeColumn = segment[0];
  49919. if (segment.length > 1) {
  49920. segmentMappings +=
  49921. encodeInteger(segment[1] - sourceFileIndex) +
  49922. encodeInteger(segment[2] - sourceCodeLine) +
  49923. encodeInteger(segment[3] - sourceCodeColumn);
  49924. sourceFileIndex = segment[1];
  49925. sourceCodeLine = segment[2];
  49926. sourceCodeColumn = segment[3];
  49927. }
  49928. if (segment.length === 5) {
  49929. segmentMappings += encodeInteger(segment[4] - nameIndex);
  49930. nameIndex = segment[4];
  49931. }
  49932. lineMappings.push(segmentMappings);
  49933. }
  49934. mappings += lineMappings.join(',');
  49935. }
  49936. return mappings;
  49937. }
  49938. function encodeInteger(num) {
  49939. var result = '';
  49940. num = num < 0 ? (-num << 1) | 1 : num << 1;
  49941. do {
  49942. var clamped = num & 31;
  49943. num >>>= 5;
  49944. if (num > 0) {
  49945. clamped |= 32;
  49946. }
  49947. result += chars[clamped];
  49948. } while (num > 0);
  49949. return result;
  49950. }
  49951. var BitSet = function BitSet(arg) {
  49952. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  49953. };
  49954. BitSet.prototype.add = function add (n) {
  49955. this.bits[n >> 5] |= 1 << (n & 31);
  49956. };
  49957. BitSet.prototype.has = function has (n) {
  49958. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  49959. };
  49960. var Chunk = function Chunk(start, end, content) {
  49961. this.start = start;
  49962. this.end = end;
  49963. this.original = content;
  49964. this.intro = '';
  49965. this.outro = '';
  49966. this.content = content;
  49967. this.storeName = false;
  49968. this.edited = false;
  49969. // we make these non-enumerable, for sanity while debugging
  49970. Object.defineProperties(this, {
  49971. previous: { writable: true, value: null },
  49972. next: { writable: true, value: null }
  49973. });
  49974. };
  49975. Chunk.prototype.appendLeft = function appendLeft (content) {
  49976. this.outro += content;
  49977. };
  49978. Chunk.prototype.appendRight = function appendRight (content) {
  49979. this.intro = this.intro + content;
  49980. };
  49981. Chunk.prototype.clone = function clone () {
  49982. var chunk = new Chunk(this.start, this.end, this.original);
  49983. chunk.intro = this.intro;
  49984. chunk.outro = this.outro;
  49985. chunk.content = this.content;
  49986. chunk.storeName = this.storeName;
  49987. chunk.edited = this.edited;
  49988. return chunk;
  49989. };
  49990. Chunk.prototype.contains = function contains (index) {
  49991. return this.start < index && index < this.end;
  49992. };
  49993. Chunk.prototype.eachNext = function eachNext (fn) {
  49994. var chunk = this;
  49995. while (chunk) {
  49996. fn(chunk);
  49997. chunk = chunk.next;
  49998. }
  49999. };
  50000. Chunk.prototype.eachPrevious = function eachPrevious (fn) {
  50001. var chunk = this;
  50002. while (chunk) {
  50003. fn(chunk);
  50004. chunk = chunk.previous;
  50005. }
  50006. };
  50007. Chunk.prototype.edit = function edit (content, storeName, contentOnly) {
  50008. this.content = content;
  50009. if (!contentOnly) {
  50010. this.intro = '';
  50011. this.outro = '';
  50012. }
  50013. this.storeName = storeName;
  50014. this.edited = true;
  50015. return this;
  50016. };
  50017. Chunk.prototype.prependLeft = function prependLeft (content) {
  50018. this.outro = content + this.outro;
  50019. };
  50020. Chunk.prototype.prependRight = function prependRight (content) {
  50021. this.intro = content + this.intro;
  50022. };
  50023. Chunk.prototype.split = function split (index) {
  50024. var sliceIndex = index - this.start;
  50025. var originalBefore = this.original.slice(0, sliceIndex);
  50026. var originalAfter = this.original.slice(sliceIndex);
  50027. this.original = originalBefore;
  50028. var newChunk = new Chunk(index, this.end, originalAfter);
  50029. newChunk.outro = this.outro;
  50030. this.outro = '';
  50031. this.end = index;
  50032. if (this.edited) {
  50033. // TODO is this block necessary?...
  50034. newChunk.edit('', false);
  50035. this.content = '';
  50036. } else {
  50037. this.content = originalBefore;
  50038. }
  50039. newChunk.next = this.next;
  50040. if (newChunk.next) { newChunk.next.previous = newChunk; }
  50041. newChunk.previous = this;
  50042. this.next = newChunk;
  50043. return newChunk;
  50044. };
  50045. Chunk.prototype.toString = function toString () {
  50046. return this.intro + this.content + this.outro;
  50047. };
  50048. Chunk.prototype.trimEnd = function trimEnd (rx) {
  50049. this.outro = this.outro.replace(rx, '');
  50050. if (this.outro.length) { return true; }
  50051. var trimmed = this.content.replace(rx, '');
  50052. if (trimmed.length) {
  50053. if (trimmed !== this.content) {
  50054. this.split(this.start + trimmed.length).edit('', undefined, true);
  50055. }
  50056. return true;
  50057. } else {
  50058. this.edit('', undefined, true);
  50059. this.intro = this.intro.replace(rx, '');
  50060. if (this.intro.length) { return true; }
  50061. }
  50062. };
  50063. Chunk.prototype.trimStart = function trimStart (rx) {
  50064. this.intro = this.intro.replace(rx, '');
  50065. if (this.intro.length) { return true; }
  50066. var trimmed = this.content.replace(rx, '');
  50067. if (trimmed.length) {
  50068. if (trimmed !== this.content) {
  50069. this.split(this.end - trimmed.length);
  50070. this.edit('', undefined, true);
  50071. }
  50072. return true;
  50073. } else {
  50074. this.edit('', undefined, true);
  50075. this.outro = this.outro.replace(rx, '');
  50076. if (this.outro.length) { return true; }
  50077. }
  50078. };
  50079. var btoa = function () {
  50080. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  50081. };
  50082. if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
  50083. btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
  50084. } else if (typeof Buffer === 'function') {
  50085. btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
  50086. }
  50087. var SourceMap = function SourceMap(properties) {
  50088. this.version = 3;
  50089. this.file = properties.file;
  50090. this.sources = properties.sources;
  50091. this.sourcesContent = properties.sourcesContent;
  50092. this.names = properties.names;
  50093. this.mappings = encode$5(properties.mappings);
  50094. };
  50095. SourceMap.prototype.toString = function toString () {
  50096. return JSON.stringify(this);
  50097. };
  50098. SourceMap.prototype.toUrl = function toUrl () {
  50099. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  50100. };
  50101. function guessIndent(code) {
  50102. var lines = code.split('\n');
  50103. var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
  50104. var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
  50105. if (tabbed.length === 0 && spaced.length === 0) {
  50106. return null;
  50107. }
  50108. // More lines tabbed than spaced? Assume tabs, and
  50109. // default to tabs in the case of a tie (or nothing
  50110. // to go on)
  50111. if (tabbed.length >= spaced.length) {
  50112. return '\t';
  50113. }
  50114. // Otherwise, we need to guess the multiple
  50115. var min = spaced.reduce(function (previous, current) {
  50116. var numSpaces = /^ +/.exec(current)[0].length;
  50117. return Math.min(numSpaces, previous);
  50118. }, Infinity);
  50119. return new Array(min + 1).join(' ');
  50120. }
  50121. function getRelativePath(from, to) {
  50122. var fromParts = from.split(/[/\\]/);
  50123. var toParts = to.split(/[/\\]/);
  50124. fromParts.pop(); // get dirname
  50125. while (fromParts[0] === toParts[0]) {
  50126. fromParts.shift();
  50127. toParts.shift();
  50128. }
  50129. if (fromParts.length) {
  50130. var i = fromParts.length;
  50131. while (i--) { fromParts[i] = '..'; }
  50132. }
  50133. return fromParts.concat(toParts).join('/');
  50134. }
  50135. var toString$2 = Object.prototype.toString;
  50136. function isObject$2(thing) {
  50137. return toString$2.call(thing) === '[object Object]';
  50138. }
  50139. function getLocator(source) {
  50140. var originalLines = source.split('\n');
  50141. var lineOffsets = [];
  50142. for (var i = 0, pos = 0; i < originalLines.length; i++) {
  50143. lineOffsets.push(pos);
  50144. pos += originalLines[i].length + 1;
  50145. }
  50146. return function locate(index) {
  50147. var i = 0;
  50148. var j = lineOffsets.length;
  50149. while (i < j) {
  50150. var m = (i + j) >> 1;
  50151. if (index < lineOffsets[m]) {
  50152. j = m;
  50153. } else {
  50154. i = m + 1;
  50155. }
  50156. }
  50157. var line = i - 1;
  50158. var column = index - lineOffsets[line];
  50159. return { line: line, column: column };
  50160. };
  50161. }
  50162. var Mappings = function Mappings(hires) {
  50163. this.hires = hires;
  50164. this.generatedCodeLine = 0;
  50165. this.generatedCodeColumn = 0;
  50166. this.raw = [];
  50167. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  50168. this.pending = null;
  50169. };
  50170. Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) {
  50171. if (content.length) {
  50172. var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  50173. if (nameIndex >= 0) {
  50174. segment.push(nameIndex);
  50175. }
  50176. this.rawSegments.push(segment);
  50177. } else if (this.pending) {
  50178. this.rawSegments.push(this.pending);
  50179. }
  50180. this.advance(content);
  50181. this.pending = null;
  50182. };
  50183. Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
  50184. var originalCharIndex = chunk.start;
  50185. var first = true;
  50186. while (originalCharIndex < chunk.end) {
  50187. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  50188. this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
  50189. }
  50190. if (original[originalCharIndex] === '\n') {
  50191. loc.line += 1;
  50192. loc.column = 0;
  50193. this.generatedCodeLine += 1;
  50194. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  50195. this.generatedCodeColumn = 0;
  50196. first = true;
  50197. } else {
  50198. loc.column += 1;
  50199. this.generatedCodeColumn += 1;
  50200. first = false;
  50201. }
  50202. originalCharIndex += 1;
  50203. }
  50204. this.pending = null;
  50205. };
  50206. Mappings.prototype.advance = function advance (str) {
  50207. if (!str) { return; }
  50208. var lines = str.split('\n');
  50209. if (lines.length > 1) {
  50210. for (var i = 0; i < lines.length - 1; i++) {
  50211. this.generatedCodeLine++;
  50212. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  50213. }
  50214. this.generatedCodeColumn = 0;
  50215. }
  50216. this.generatedCodeColumn += lines[lines.length - 1].length;
  50217. };
  50218. var n = '\n';
  50219. var warned = {
  50220. insertLeft: false,
  50221. insertRight: false,
  50222. storeName: false
  50223. };
  50224. var MagicString = function MagicString(string, options) {
  50225. if ( options === void 0 ) options = {};
  50226. var chunk = new Chunk(0, string.length, string);
  50227. Object.defineProperties(this, {
  50228. original: { writable: true, value: string },
  50229. outro: { writable: true, value: '' },
  50230. intro: { writable: true, value: '' },
  50231. firstChunk: { writable: true, value: chunk },
  50232. lastChunk: { writable: true, value: chunk },
  50233. lastSearchedChunk: { writable: true, value: chunk },
  50234. byStart: { writable: true, value: {} },
  50235. byEnd: { writable: true, value: {} },
  50236. filename: { writable: true, value: options.filename },
  50237. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  50238. sourcemapLocations: { writable: true, value: new BitSet() },
  50239. storedNames: { writable: true, value: {} },
  50240. indentStr: { writable: true, value: guessIndent(string) }
  50241. });
  50242. this.byStart[0] = chunk;
  50243. this.byEnd[string.length] = chunk;
  50244. };
  50245. MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) {
  50246. this.sourcemapLocations.add(char);
  50247. };
  50248. MagicString.prototype.append = function append (content) {
  50249. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  50250. this.outro += content;
  50251. return this;
  50252. };
  50253. MagicString.prototype.appendLeft = function appendLeft (index, content) {
  50254. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  50255. this._split(index);
  50256. var chunk = this.byEnd[index];
  50257. if (chunk) {
  50258. chunk.appendLeft(content);
  50259. } else {
  50260. this.intro += content;
  50261. }
  50262. return this;
  50263. };
  50264. MagicString.prototype.appendRight = function appendRight (index, content) {
  50265. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  50266. this._split(index);
  50267. var chunk = this.byStart[index];
  50268. if (chunk) {
  50269. chunk.appendRight(content);
  50270. } else {
  50271. this.outro += content;
  50272. }
  50273. return this;
  50274. };
  50275. MagicString.prototype.clone = function clone () {
  50276. var cloned = new MagicString(this.original, { filename: this.filename });
  50277. var originalChunk = this.firstChunk;
  50278. var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  50279. while (originalChunk) {
  50280. cloned.byStart[clonedChunk.start] = clonedChunk;
  50281. cloned.byEnd[clonedChunk.end] = clonedChunk;
  50282. var nextOriginalChunk = originalChunk.next;
  50283. var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  50284. if (nextClonedChunk) {
  50285. clonedChunk.next = nextClonedChunk;
  50286. nextClonedChunk.previous = clonedChunk;
  50287. clonedChunk = nextClonedChunk;
  50288. }
  50289. originalChunk = nextOriginalChunk;
  50290. }
  50291. cloned.lastChunk = clonedChunk;
  50292. if (this.indentExclusionRanges) {
  50293. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  50294. }
  50295. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  50296. cloned.intro = this.intro;
  50297. cloned.outro = this.outro;
  50298. return cloned;
  50299. };
  50300. MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) {
  50301. var this$1 = this;
  50302. options = options || {};
  50303. var sourceIndex = 0;
  50304. var names = Object.keys(this.storedNames);
  50305. var mappings = new Mappings(options.hires);
  50306. var locate = getLocator(this.original);
  50307. if (this.intro) {
  50308. mappings.advance(this.intro);
  50309. }
  50310. this.firstChunk.eachNext(function (chunk) {
  50311. var loc = locate(chunk.start);
  50312. if (chunk.intro.length) { mappings.advance(chunk.intro); }
  50313. if (chunk.edited) {
  50314. mappings.addEdit(
  50315. sourceIndex,
  50316. chunk.content,
  50317. loc,
  50318. chunk.storeName ? names.indexOf(chunk.original) : -1
  50319. );
  50320. } else {
  50321. mappings.addUneditedChunk(sourceIndex, chunk, this$1.original, loc, this$1.sourcemapLocations);
  50322. }
  50323. if (chunk.outro.length) { mappings.advance(chunk.outro); }
  50324. });
  50325. return {
  50326. file: options.file ? options.file.split(/[/\\]/).pop() : null,
  50327. sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
  50328. sourcesContent: options.includeContent ? [this.original] : [null],
  50329. names: names,
  50330. mappings: mappings.raw
  50331. };
  50332. };
  50333. MagicString.prototype.generateMap = function generateMap (options) {
  50334. return new SourceMap(this.generateDecodedMap(options));
  50335. };
  50336. MagicString.prototype.getIndentString = function getIndentString () {
  50337. return this.indentStr === null ? '\t' : this.indentStr;
  50338. };
  50339. MagicString.prototype.indent = function indent (indentStr, options) {
  50340. var pattern = /^[^\r\n]/gm;
  50341. if (isObject$2(indentStr)) {
  50342. options = indentStr;
  50343. indentStr = undefined;
  50344. }
  50345. indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
  50346. if (indentStr === '') { return this; } // noop
  50347. options = options || {};
  50348. // Process exclusion ranges
  50349. var isExcluded = {};
  50350. if (options.exclude) {
  50351. var exclusions =
  50352. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  50353. exclusions.forEach(function (exclusion) {
  50354. for (var i = exclusion[0]; i < exclusion[1]; i += 1) {
  50355. isExcluded[i] = true;
  50356. }
  50357. });
  50358. }
  50359. var shouldIndentNextCharacter = options.indentStart !== false;
  50360. var replacer = function (match) {
  50361. if (shouldIndentNextCharacter) { return ("" + indentStr + match); }
  50362. shouldIndentNextCharacter = true;
  50363. return match;
  50364. };
  50365. this.intro = this.intro.replace(pattern, replacer);
  50366. var charIndex = 0;
  50367. var chunk = this.firstChunk;
  50368. while (chunk) {
  50369. var end = chunk.end;
  50370. if (chunk.edited) {
  50371. if (!isExcluded[charIndex]) {
  50372. chunk.content = chunk.content.replace(pattern, replacer);
  50373. if (chunk.content.length) {
  50374. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  50375. }
  50376. }
  50377. } else {
  50378. charIndex = chunk.start;
  50379. while (charIndex < end) {
  50380. if (!isExcluded[charIndex]) {
  50381. var char = this.original[charIndex];
  50382. if (char === '\n') {
  50383. shouldIndentNextCharacter = true;
  50384. } else if (char !== '\r' && shouldIndentNextCharacter) {
  50385. shouldIndentNextCharacter = false;
  50386. if (charIndex === chunk.start) {
  50387. chunk.prependRight(indentStr);
  50388. } else {
  50389. this._splitChunk(chunk, charIndex);
  50390. chunk = chunk.next;
  50391. chunk.prependRight(indentStr);
  50392. }
  50393. }
  50394. }
  50395. charIndex += 1;
  50396. }
  50397. }
  50398. charIndex = chunk.end;
  50399. chunk = chunk.next;
  50400. }
  50401. this.outro = this.outro.replace(pattern, replacer);
  50402. return this;
  50403. };
  50404. MagicString.prototype.insert = function insert () {
  50405. throw new Error('magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)');
  50406. };
  50407. MagicString.prototype.insertLeft = function insertLeft (index, content) {
  50408. if (!warned.insertLeft) {
  50409. console.warn('magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'); // eslint-disable-line no-console
  50410. warned.insertLeft = true;
  50411. }
  50412. return this.appendLeft(index, content);
  50413. };
  50414. MagicString.prototype.insertRight = function insertRight (index, content) {
  50415. if (!warned.insertRight) {
  50416. console.warn('magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'); // eslint-disable-line no-console
  50417. warned.insertRight = true;
  50418. }
  50419. return this.prependRight(index, content);
  50420. };
  50421. MagicString.prototype.move = function move (start, end, index) {
  50422. if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); }
  50423. this._split(start);
  50424. this._split(end);
  50425. this._split(index);
  50426. var first = this.byStart[start];
  50427. var last = this.byEnd[end];
  50428. var oldLeft = first.previous;
  50429. var oldRight = last.next;
  50430. var newRight = this.byStart[index];
  50431. if (!newRight && last === this.lastChunk) { return this; }
  50432. var newLeft = newRight ? newRight.previous : this.lastChunk;
  50433. if (oldLeft) { oldLeft.next = oldRight; }
  50434. if (oldRight) { oldRight.previous = oldLeft; }
  50435. if (newLeft) { newLeft.next = first; }
  50436. if (newRight) { newRight.previous = last; }
  50437. if (!first.previous) { this.firstChunk = last.next; }
  50438. if (!last.next) {
  50439. this.lastChunk = first.previous;
  50440. this.lastChunk.next = null;
  50441. }
  50442. first.previous = newLeft;
  50443. last.next = newRight || null;
  50444. if (!newLeft) { this.firstChunk = first; }
  50445. if (!newRight) { this.lastChunk = last; }
  50446. return this;
  50447. };
  50448. MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
  50449. if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
  50450. while (start < 0) { start += this.original.length; }
  50451. while (end < 0) { end += this.original.length; }
  50452. if (end > this.original.length) { throw new Error('end is out of bounds'); }
  50453. if (start === end)
  50454. { throw new Error('Cannot overwrite a zero-length range – use appendLeft or prependRight instead'); }
  50455. this._split(start);
  50456. this._split(end);
  50457. if (options === true) {
  50458. if (!warned.storeName) {
  50459. console.warn('The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'); // eslint-disable-line no-console
  50460. warned.storeName = true;
  50461. }
  50462. options = { storeName: true };
  50463. }
  50464. var storeName = options !== undefined ? options.storeName : false;
  50465. var contentOnly = options !== undefined ? options.contentOnly : false;
  50466. if (storeName) {
  50467. var original = this.original.slice(start, end);
  50468. this.storedNames[original] = true;
  50469. }
  50470. var first = this.byStart[start];
  50471. var last = this.byEnd[end];
  50472. if (first) {
  50473. if (end > first.end && first.next !== this.byStart[first.end]) {
  50474. throw new Error('Cannot overwrite across a split point');
  50475. }
  50476. first.edit(content, storeName, contentOnly);
  50477. if (first !== last) {
  50478. var chunk = first.next;
  50479. while (chunk !== last) {
  50480. chunk.edit('', false);
  50481. chunk = chunk.next;
  50482. }
  50483. chunk.edit('', false);
  50484. }
  50485. } else {
  50486. // must be inserting at the end
  50487. var newChunk = new Chunk(start, end, '').edit(content, storeName);
  50488. // TODO last chunk in the array may not be the last chunk, if it's moved...
  50489. last.next = newChunk;
  50490. newChunk.previous = last;
  50491. }
  50492. return this;
  50493. };
  50494. MagicString.prototype.prepend = function prepend (content) {
  50495. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  50496. this.intro = content + this.intro;
  50497. return this;
  50498. };
  50499. MagicString.prototype.prependLeft = function prependLeft (index, content) {
  50500. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  50501. this._split(index);
  50502. var chunk = this.byEnd[index];
  50503. if (chunk) {
  50504. chunk.prependLeft(content);
  50505. } else {
  50506. this.intro = content + this.intro;
  50507. }
  50508. return this;
  50509. };
  50510. MagicString.prototype.prependRight = function prependRight (index, content) {
  50511. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  50512. this._split(index);
  50513. var chunk = this.byStart[index];
  50514. if (chunk) {
  50515. chunk.prependRight(content);
  50516. } else {
  50517. this.outro = content + this.outro;
  50518. }
  50519. return this;
  50520. };
  50521. MagicString.prototype.remove = function remove (start, end) {
  50522. while (start < 0) { start += this.original.length; }
  50523. while (end < 0) { end += this.original.length; }
  50524. if (start === end) { return this; }
  50525. if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); }
  50526. if (start > end) { throw new Error('end must be greater than start'); }
  50527. this._split(start);
  50528. this._split(end);
  50529. var chunk = this.byStart[start];
  50530. while (chunk) {
  50531. chunk.intro = '';
  50532. chunk.outro = '';
  50533. chunk.edit('');
  50534. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  50535. }
  50536. return this;
  50537. };
  50538. MagicString.prototype.lastChar = function lastChar () {
  50539. if (this.outro.length)
  50540. { return this.outro[this.outro.length - 1]; }
  50541. var chunk = this.lastChunk;
  50542. do {
  50543. if (chunk.outro.length)
  50544. { return chunk.outro[chunk.outro.length - 1]; }
  50545. if (chunk.content.length)
  50546. { return chunk.content[chunk.content.length - 1]; }
  50547. if (chunk.intro.length)
  50548. { return chunk.intro[chunk.intro.length - 1]; }
  50549. } while (chunk = chunk.previous);
  50550. if (this.intro.length)
  50551. { return this.intro[this.intro.length - 1]; }
  50552. return '';
  50553. };
  50554. MagicString.prototype.lastLine = function lastLine () {
  50555. var lineIndex = this.outro.lastIndexOf(n);
  50556. if (lineIndex !== -1)
  50557. { return this.outro.substr(lineIndex + 1); }
  50558. var lineStr = this.outro;
  50559. var chunk = this.lastChunk;
  50560. do {
  50561. if (chunk.outro.length > 0) {
  50562. lineIndex = chunk.outro.lastIndexOf(n);
  50563. if (lineIndex !== -1)
  50564. { return chunk.outro.substr(lineIndex + 1) + lineStr; }
  50565. lineStr = chunk.outro + lineStr;
  50566. }
  50567. if (chunk.content.length > 0) {
  50568. lineIndex = chunk.content.lastIndexOf(n);
  50569. if (lineIndex !== -1)
  50570. { return chunk.content.substr(lineIndex + 1) + lineStr; }
  50571. lineStr = chunk.content + lineStr;
  50572. }
  50573. if (chunk.intro.length > 0) {
  50574. lineIndex = chunk.intro.lastIndexOf(n);
  50575. if (lineIndex !== -1)
  50576. { return chunk.intro.substr(lineIndex + 1) + lineStr; }
  50577. lineStr = chunk.intro + lineStr;
  50578. }
  50579. } while (chunk = chunk.previous);
  50580. lineIndex = this.intro.lastIndexOf(n);
  50581. if (lineIndex !== -1)
  50582. { return this.intro.substr(lineIndex + 1) + lineStr; }
  50583. return this.intro + lineStr;
  50584. };
  50585. MagicString.prototype.slice = function slice (start, end) {
  50586. if ( start === void 0 ) start = 0;
  50587. if ( end === void 0 ) end = this.original.length;
  50588. while (start < 0) { start += this.original.length; }
  50589. while (end < 0) { end += this.original.length; }
  50590. var result = '';
  50591. // find start chunk
  50592. var chunk = this.firstChunk;
  50593. while (chunk && (chunk.start > start || chunk.end <= start)) {
  50594. // found end chunk before start
  50595. if (chunk.start < end && chunk.end >= end) {
  50596. return result;
  50597. }
  50598. chunk = chunk.next;
  50599. }
  50600. if (chunk && chunk.edited && chunk.start !== start)
  50601. { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
  50602. var startChunk = chunk;
  50603. while (chunk) {
  50604. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  50605. result += chunk.intro;
  50606. }
  50607. var containsEnd = chunk.start < end && chunk.end >= end;
  50608. if (containsEnd && chunk.edited && chunk.end !== end)
  50609. { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
  50610. var sliceStart = startChunk === chunk ? start - chunk.start : 0;
  50611. var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  50612. result += chunk.content.slice(sliceStart, sliceEnd);
  50613. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  50614. result += chunk.outro;
  50615. }
  50616. if (containsEnd) {
  50617. break;
  50618. }
  50619. chunk = chunk.next;
  50620. }
  50621. return result;
  50622. };
  50623. // TODO deprecate this? not really very useful
  50624. MagicString.prototype.snip = function snip (start, end) {
  50625. var clone = this.clone();
  50626. clone.remove(0, start);
  50627. clone.remove(end, clone.original.length);
  50628. return clone;
  50629. };
  50630. MagicString.prototype._split = function _split (index) {
  50631. if (this.byStart[index] || this.byEnd[index]) { return; }
  50632. var chunk = this.lastSearchedChunk;
  50633. var searchForward = index > chunk.end;
  50634. while (chunk) {
  50635. if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
  50636. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  50637. }
  50638. };
  50639. MagicString.prototype._splitChunk = function _splitChunk (chunk, index) {
  50640. if (chunk.edited && chunk.content.length) {
  50641. // zero-length edited chunks are a special case (overlapping replacements)
  50642. var loc = getLocator(this.original)(index);
  50643. throw new Error(
  50644. ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")")
  50645. );
  50646. }
  50647. var newChunk = chunk.split(index);
  50648. this.byEnd[index] = chunk;
  50649. this.byStart[index] = newChunk;
  50650. this.byEnd[newChunk.end] = newChunk;
  50651. if (chunk === this.lastChunk) { this.lastChunk = newChunk; }
  50652. this.lastSearchedChunk = chunk;
  50653. return true;
  50654. };
  50655. MagicString.prototype.toString = function toString () {
  50656. var str = this.intro;
  50657. var chunk = this.firstChunk;
  50658. while (chunk) {
  50659. str += chunk.toString();
  50660. chunk = chunk.next;
  50661. }
  50662. return str + this.outro;
  50663. };
  50664. MagicString.prototype.isEmpty = function isEmpty () {
  50665. var chunk = this.firstChunk;
  50666. do {
  50667. if (chunk.intro.length && chunk.intro.trim() ||
  50668. chunk.content.length && chunk.content.trim() ||
  50669. chunk.outro.length && chunk.outro.trim())
  50670. { return false; }
  50671. } while (chunk = chunk.next);
  50672. return true;
  50673. };
  50674. MagicString.prototype.length = function length () {
  50675. var chunk = this.firstChunk;
  50676. var length = 0;
  50677. do {
  50678. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  50679. } while (chunk = chunk.next);
  50680. return length;
  50681. };
  50682. MagicString.prototype.trimLines = function trimLines () {
  50683. return this.trim('[\\r\\n]');
  50684. };
  50685. MagicString.prototype.trim = function trim (charType) {
  50686. return this.trimStart(charType).trimEnd(charType);
  50687. };
  50688. MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
  50689. var rx = new RegExp((charType || '\\s') + '+$');
  50690. this.outro = this.outro.replace(rx, '');
  50691. if (this.outro.length) { return true; }
  50692. var chunk = this.lastChunk;
  50693. do {
  50694. var end = chunk.end;
  50695. var aborted = chunk.trimEnd(rx);
  50696. // if chunk was trimmed, we have a new lastChunk
  50697. if (chunk.end !== end) {
  50698. if (this.lastChunk === chunk) {
  50699. this.lastChunk = chunk.next;
  50700. }
  50701. this.byEnd[chunk.end] = chunk;
  50702. this.byStart[chunk.next.start] = chunk.next;
  50703. this.byEnd[chunk.next.end] = chunk.next;
  50704. }
  50705. if (aborted) { return true; }
  50706. chunk = chunk.previous;
  50707. } while (chunk);
  50708. return false;
  50709. };
  50710. MagicString.prototype.trimEnd = function trimEnd (charType) {
  50711. this.trimEndAborted(charType);
  50712. return this;
  50713. };
  50714. MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
  50715. var rx = new RegExp('^' + (charType || '\\s') + '+');
  50716. this.intro = this.intro.replace(rx, '');
  50717. if (this.intro.length) { return true; }
  50718. var chunk = this.firstChunk;
  50719. do {
  50720. var end = chunk.end;
  50721. var aborted = chunk.trimStart(rx);
  50722. if (chunk.end !== end) {
  50723. // special case...
  50724. if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
  50725. this.byEnd[chunk.end] = chunk;
  50726. this.byStart[chunk.next.start] = chunk.next;
  50727. this.byEnd[chunk.next.end] = chunk.next;
  50728. }
  50729. if (aborted) { return true; }
  50730. chunk = chunk.next;
  50731. } while (chunk);
  50732. return false;
  50733. };
  50734. MagicString.prototype.trimStart = function trimStart (charType) {
  50735. this.trimStartAborted(charType);
  50736. return this;
  50737. };
  50738. const defaultExportRE = /((?:^|\n|;)\s*)export(\s*)default/;
  50739. const namedDefaultExportRE = /((?:^|\n|;)\s*)export(.+)as(\s*)default/s;
  50740. const exportDefaultClassRE = /((?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/;
  50741. /**
  50742. * Utility for rewriting `export default` in a script block into a variable
  50743. * declaration so that we can inject things into it
  50744. */
  50745. function rewriteDefault(input, as, parserPlugins) {
  50746. if (!hasDefaultExport(input)) {
  50747. return input + `\nconst ${as} = {}`;
  50748. }
  50749. let replaced;
  50750. const classMatch = input.match(exportDefaultClassRE);
  50751. if (classMatch) {
  50752. replaced =
  50753. input.replace(exportDefaultClassRE, '$1class $2') +
  50754. `\nconst ${as} = ${classMatch[2]}`;
  50755. }
  50756. else {
  50757. replaced = input.replace(defaultExportRE, `$1const ${as} =`);
  50758. }
  50759. if (!hasDefaultExport(replaced)) {
  50760. return replaced;
  50761. }
  50762. // if the script somehow still contains `default export`, it probably has
  50763. // multi-line comments or template strings. fallback to a full parse.
  50764. const s = new MagicString(input);
  50765. const ast = parse_1(input, {
  50766. sourceType: 'module',
  50767. plugins: parserPlugins
  50768. }).program.body;
  50769. ast.forEach(node => {
  50770. if (node.type === 'ExportDefaultDeclaration') {
  50771. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  50772. }
  50773. if (node.type === 'ExportNamedDeclaration') {
  50774. node.specifiers.forEach(specifier => {
  50775. if (specifier.type === 'ExportSpecifier' &&
  50776. specifier.exported.type === 'Identifier' &&
  50777. specifier.exported.name === 'default') {
  50778. const end = specifier.end;
  50779. s.overwrite(specifier.start, input.charAt(end) === ',' ? end + 1 : end, ``);
  50780. s.append(`\nconst ${as} = ${specifier.local.name}`);
  50781. }
  50782. });
  50783. }
  50784. });
  50785. return s.toString();
  50786. }
  50787. function hasDefaultExport(input) {
  50788. return defaultExportRE.test(input) || namedDefaultExportRE.test(input);
  50789. }
  50790. const TO_VAR_SYMBOL = '$';
  50791. const TO_REF_SYMBOL = '$$';
  50792. const shorthands = ['ref', 'computed', 'shallowRef'];
  50793. const transformCheckRE = /[^\w]\$(?:\$|ref|computed|shallowRef)?\s*(\(|\<)/;
  50794. function shouldTransform(src) {
  50795. return transformCheckRE.test(src);
  50796. }
  50797. function transform$1(src, { filename, sourceMap, parserPlugins, importHelpersFrom = 'vue' } = {}) {
  50798. const plugins = parserPlugins || [];
  50799. if (filename) {
  50800. if (/\.tsx?$/.test(filename)) {
  50801. plugins.push('typescript');
  50802. }
  50803. if (filename.endsWith('x')) {
  50804. plugins.push('jsx');
  50805. }
  50806. }
  50807. const ast = parse_1(src, {
  50808. sourceType: 'module',
  50809. plugins: [...new Set([...babelParserDefaultPlugins, ...plugins])]
  50810. });
  50811. const s = new MagicString(src);
  50812. const res = transformAST(ast.program, s);
  50813. // inject helper imports
  50814. if (res.importedHelpers.length) {
  50815. s.prepend(`import { ${res.importedHelpers
  50816. .map(h => `${h} as _${h}`)
  50817. .join(', ')} } from '${importHelpersFrom}'\n`);
  50818. }
  50819. return Object.assign(Object.assign({}, res), { code: s.toString(), map: sourceMap
  50820. ? s.generateMap({
  50821. source: filename,
  50822. hires: true,
  50823. includeContent: true
  50824. })
  50825. : null });
  50826. }
  50827. function transformAST(ast, s, offset = 0, knownRootVars) {
  50828. // TODO remove when out of experimental
  50829. warnExperimental();
  50830. const importedHelpers = new Set();
  50831. const rootScope = {};
  50832. const scopeStack = [rootScope];
  50833. let currentScope = rootScope;
  50834. const excludedIds = new WeakSet();
  50835. const parentStack = [];
  50836. if (knownRootVars) {
  50837. for (const key of knownRootVars) {
  50838. rootScope[key] = true;
  50839. }
  50840. }
  50841. function error(msg, node) {
  50842. const e = new Error(msg);
  50843. e.node = node;
  50844. throw e;
  50845. }
  50846. function helper(msg) {
  50847. importedHelpers.add(msg);
  50848. return `_${msg}`;
  50849. }
  50850. function registerBinding(id, isRef = false) {
  50851. excludedIds.add(id);
  50852. if (currentScope) {
  50853. currentScope[id.name] = isRef;
  50854. }
  50855. else {
  50856. error('registerBinding called without active scope, something is wrong.', id);
  50857. }
  50858. }
  50859. const registerRefBinding = (id) => registerBinding(id, true);
  50860. function walkScope(node) {
  50861. for (const stmt of node.body) {
  50862. if (stmt.type === 'VariableDeclaration') {
  50863. if (stmt.declare)
  50864. continue;
  50865. for (const decl of stmt.declarations) {
  50866. let toVarCall;
  50867. if (decl.init &&
  50868. decl.init.type === 'CallExpression' &&
  50869. decl.init.callee.type === 'Identifier' &&
  50870. (toVarCall = isToVarCall(decl.init.callee.name))) {
  50871. processRefDeclaration(toVarCall, decl.init, decl.id, stmt);
  50872. }
  50873. else {
  50874. for (const id of extractIdentifiers(decl.id)) {
  50875. registerBinding(id);
  50876. }
  50877. }
  50878. }
  50879. }
  50880. else if (stmt.type === 'FunctionDeclaration' ||
  50881. stmt.type === 'ClassDeclaration') {
  50882. if (stmt.declare || !stmt.id)
  50883. continue;
  50884. registerBinding(stmt.id);
  50885. }
  50886. }
  50887. }
  50888. function processRefDeclaration(method, call, id, statement) {
  50889. excludedIds.add(call.callee);
  50890. if (statement.kind !== 'let') {
  50891. error(`${method}() bindings can only be declared with let`, call);
  50892. }
  50893. if (method === TO_VAR_SYMBOL) {
  50894. // $
  50895. // remove macro
  50896. s.remove(call.callee.start + offset, call.callee.end + offset);
  50897. if (id.type === 'Identifier') {
  50898. // single variable
  50899. registerRefBinding(id);
  50900. }
  50901. else if (id.type === 'ObjectPattern') {
  50902. processRefObjectPattern(id, statement);
  50903. }
  50904. else if (id.type === 'ArrayPattern') {
  50905. processRefArrayPattern(id, statement);
  50906. }
  50907. }
  50908. else {
  50909. // shorthands
  50910. if (id.type === 'Identifier') {
  50911. registerRefBinding(id);
  50912. // replace call
  50913. s.overwrite(call.start + offset, call.start + method.length + offset, helper(method.slice(1)));
  50914. }
  50915. else {
  50916. error(`${method}() cannot be used with destructure patterns.`, call);
  50917. }
  50918. }
  50919. }
  50920. function processRefObjectPattern(pattern, statement) {
  50921. for (const p of pattern.properties) {
  50922. let nameId;
  50923. if (p.type === 'ObjectProperty') {
  50924. if (p.key.start === p.value.start) {
  50925. // shorthand { foo } --> { foo: __foo }
  50926. nameId = p.key;
  50927. s.appendLeft(nameId.end + offset, `: __${nameId.name}`);
  50928. if (p.value.type === 'Identifier') {
  50929. // avoid shorthand value identifier from being processed
  50930. excludedIds.add(p.value);
  50931. }
  50932. else if (p.value.type === 'AssignmentPattern' &&
  50933. p.value.left.type === 'Identifier') {
  50934. // { foo = 1 }
  50935. excludedIds.add(p.value.left);
  50936. }
  50937. }
  50938. else {
  50939. if (p.value.type === 'Identifier') {
  50940. // { foo: bar } --> { foo: __bar }
  50941. nameId = p.value;
  50942. s.prependRight(nameId.start + offset, `__`);
  50943. }
  50944. else if (p.value.type === 'ObjectPattern') {
  50945. processRefObjectPattern(p.value, statement);
  50946. }
  50947. else if (p.value.type === 'ArrayPattern') {
  50948. processRefArrayPattern(p.value, statement);
  50949. }
  50950. else if (p.value.type === 'AssignmentPattern') {
  50951. // { foo: bar = 1 } --> { foo: __bar = 1 }
  50952. nameId = p.value.left;
  50953. s.prependRight(nameId.start + offset, `__`);
  50954. }
  50955. }
  50956. }
  50957. else {
  50958. // rest element { ...foo } --> { ...__foo }
  50959. nameId = p.argument;
  50960. s.prependRight(nameId.start + offset, `__`);
  50961. }
  50962. if (nameId) {
  50963. registerRefBinding(nameId);
  50964. // append binding declarations after the parent statement
  50965. s.appendLeft(statement.end + offset, `\nconst ${nameId.name} = ${helper('shallowRef')}(__${nameId.name});`);
  50966. }
  50967. }
  50968. }
  50969. function processRefArrayPattern(pattern, statement) {
  50970. for (const e of pattern.elements) {
  50971. if (!e)
  50972. continue;
  50973. let nameId;
  50974. if (e.type === 'Identifier') {
  50975. // [a] --> [__a]
  50976. nameId = e;
  50977. }
  50978. else if (e.type === 'AssignmentPattern') {
  50979. // [a = 1] --> [__a = 1]
  50980. nameId = e.left;
  50981. }
  50982. else if (e.type === 'RestElement') {
  50983. // [...a] --> [...__a]
  50984. nameId = e.argument;
  50985. }
  50986. else if (e.type === 'ObjectPattern') {
  50987. processRefObjectPattern(e, statement);
  50988. }
  50989. else if (e.type === 'ArrayPattern') {
  50990. processRefArrayPattern(e, statement);
  50991. }
  50992. if (nameId) {
  50993. registerRefBinding(nameId);
  50994. // prefix original
  50995. s.prependRight(nameId.start + offset, `__`);
  50996. // append binding declarations after the parent statement
  50997. s.appendLeft(statement.end + offset, `\nconst ${nameId.name} = ${helper('shallowRef')}(__${nameId.name});`);
  50998. }
  50999. }
  51000. }
  51001. function checkRefId(scope, id, parent, parentStack) {
  51002. if (id.name in scope) {
  51003. if (scope[id.name]) {
  51004. if (isStaticProperty(parent) && parent.shorthand) {
  51005. // let binding used in a property shorthand
  51006. // { foo } -> { foo: foo.value }
  51007. // skip for destructure patterns
  51008. if (!parent.inPattern ||
  51009. isInDestructureAssignment(parent, parentStack)) {
  51010. s.appendLeft(id.end + offset, `: ${id.name}.value`);
  51011. }
  51012. }
  51013. else {
  51014. s.appendLeft(id.end + offset, '.value');
  51015. }
  51016. }
  51017. return true;
  51018. }
  51019. return false;
  51020. }
  51021. // check root scope first
  51022. walkScope(ast);
  51023. walk$1(ast, {
  51024. enter(node, parent) {
  51025. parent && parentStack.push(parent);
  51026. // function scopes
  51027. if (isFunctionType(node)) {
  51028. scopeStack.push((currentScope = {}));
  51029. walkFunctionParams(node, registerBinding);
  51030. if (node.body.type === 'BlockStatement') {
  51031. walkScope(node.body);
  51032. }
  51033. return;
  51034. }
  51035. // non-function block scopes
  51036. if (node.type === 'BlockStatement' && !isFunctionType(parent)) {
  51037. scopeStack.push((currentScope = {}));
  51038. walkScope(node);
  51039. return;
  51040. }
  51041. if (parent &&
  51042. parent.type.startsWith('TS') &&
  51043. parent.type !== 'TSAsExpression' &&
  51044. parent.type !== 'TSNonNullExpression' &&
  51045. parent.type !== 'TSTypeAssertion') {
  51046. return this.skip();
  51047. }
  51048. if (node.type === 'Identifier' &&
  51049. isReferencedIdentifier(node, parent, parentStack) &&
  51050. !excludedIds.has(node)) {
  51051. // walk up the scope chain to check if id should be appended .value
  51052. let i = scopeStack.length;
  51053. while (i--) {
  51054. if (checkRefId(scopeStack[i], node, parent, parentStack)) {
  51055. return;
  51056. }
  51057. }
  51058. }
  51059. if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {
  51060. const callee = node.callee.name;
  51061. const toVarCall = isToVarCall(callee);
  51062. if (toVarCall && (!parent || parent.type !== 'VariableDeclarator')) {
  51063. return error(`${toVarCall} can only be used as the initializer of ` +
  51064. `a variable declaration.`, node);
  51065. }
  51066. if (callee === TO_REF_SYMBOL) {
  51067. s.remove(node.callee.start + offset, node.callee.end + offset);
  51068. return this.skip();
  51069. }
  51070. // TODO remove when out of experimental
  51071. if (callee === '$raw') {
  51072. error(`$raw() has been replaced by $$(). ` +
  51073. `See ${RFC_LINK} for latest updates.`, node);
  51074. }
  51075. if (callee === '$fromRef') {
  51076. error(`$fromRef() has been replaced by $(). ` +
  51077. `See ${RFC_LINK} for latest updates.`, node);
  51078. }
  51079. }
  51080. },
  51081. leave(node, parent) {
  51082. parent && parentStack.pop();
  51083. if ((node.type === 'BlockStatement' && !isFunctionType(parent)) ||
  51084. isFunctionType(node)) {
  51085. scopeStack.pop();
  51086. currentScope = scopeStack[scopeStack.length - 1] || null;
  51087. }
  51088. }
  51089. });
  51090. return {
  51091. rootVars: Object.keys(rootScope).filter(key => rootScope[key]),
  51092. importedHelpers: [...importedHelpers]
  51093. };
  51094. }
  51095. function isToVarCall(callee) {
  51096. if (callee === TO_VAR_SYMBOL) {
  51097. return TO_VAR_SYMBOL;
  51098. }
  51099. if (callee[0] === TO_VAR_SYMBOL && shorthands.includes(callee.slice(1))) {
  51100. return callee;
  51101. }
  51102. return false;
  51103. }
  51104. const RFC_LINK = `https://github.com/vuejs/rfcs/discussions/369`;
  51105. const hasWarned$1 = {};
  51106. function warnExperimental() {
  51107. // eslint-disable-next-line
  51108. if (typeof window !== 'undefined') {
  51109. return;
  51110. }
  51111. warnOnce$2(`@vue/ref-transform is an experimental feature.\n` +
  51112. `Experimental features may change behavior between patch versions.\n` +
  51113. `It is recommended to pin your vue dependencies to exact versions to avoid breakage.\n` +
  51114. `You can follow the proposal's status at ${RFC_LINK}.`);
  51115. }
  51116. function warnOnce$2(msg) {
  51117. const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
  51118. if (!isNodeProd && !false && !hasWarned$1[msg]) {
  51119. hasWarned$1[msg] = true;
  51120. warn$1(msg);
  51121. }
  51122. }
  51123. function warn$1(msg) {
  51124. console.warn(`\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`);
  51125. }
  51126. // Special compiler macros
  51127. const DEFINE_PROPS = 'defineProps';
  51128. const DEFINE_EMITS = 'defineEmits';
  51129. const DEFINE_EXPOSE = 'defineExpose';
  51130. const WITH_DEFAULTS = 'withDefaults';
  51131. const isBuiltInDir = makeMap(`once,memo,if,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
  51132. /**
  51133. * Compile `<script setup>`
  51134. * It requires the whole SFC descriptor because we need to handle and merge
  51135. * normal `<script>` + `<script setup>` if both are present.
  51136. */
  51137. function compileScript(sfc, options) {
  51138. let { script, scriptSetup, source, filename } = sfc;
  51139. // feature flags
  51140. const enableRefTransform = !!options.refSugar || !!options.refTransform;
  51141. let refBindings;
  51142. // for backwards compat
  51143. if (!options) {
  51144. options = { id: '' };
  51145. }
  51146. if (!options.id) {
  51147. warnOnce(`compileScript now requires passing the \`id\` option.\n` +
  51148. `Upgrade your vite or vue-loader version for compatibility with ` +
  51149. `the latest experimental proposals.`);
  51150. }
  51151. const scopeId = options.id ? options.id.replace(/^data-v-/, '') : '';
  51152. const cssVars = sfc.cssVars;
  51153. const scriptLang = script && script.lang;
  51154. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  51155. const isTS = scriptLang === 'ts' ||
  51156. scriptLang === 'tsx' ||
  51157. scriptSetupLang === 'ts' ||
  51158. scriptSetupLang === 'tsx';
  51159. const plugins = [...babelParserDefaultPlugins];
  51160. if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
  51161. plugins.push('jsx');
  51162. }
  51163. if (options.babelParserPlugins)
  51164. plugins.push(...options.babelParserPlugins);
  51165. if (isTS)
  51166. plugins.push('typescript', 'decorators-legacy');
  51167. if (!scriptSetup) {
  51168. if (!script) {
  51169. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  51170. }
  51171. if (scriptLang && !isTS && scriptLang !== 'jsx') {
  51172. // do not process non js/ts script blocks
  51173. return script;
  51174. }
  51175. try {
  51176. let content = script.content;
  51177. let map = script.map;
  51178. const scriptAst = parse_1(content, {
  51179. plugins,
  51180. sourceType: 'module'
  51181. }).program;
  51182. const bindings = analyzeScriptBindings(scriptAst.body);
  51183. if (enableRefTransform && shouldTransform(content)) {
  51184. const s = new MagicString(source);
  51185. const startOffset = script.loc.start.offset;
  51186. const endOffset = script.loc.end.offset;
  51187. const { importedHelpers } = transformAST(scriptAst, s, startOffset);
  51188. if (importedHelpers.length) {
  51189. s.prepend(`import { ${importedHelpers
  51190. .map(h => `${h} as _${h}`)
  51191. .join(', ')} } from 'vue'\n`);
  51192. }
  51193. s.remove(0, startOffset);
  51194. s.remove(endOffset, source.length);
  51195. content = s.toString();
  51196. map = s.generateMap({
  51197. source: filename,
  51198. hires: true,
  51199. includeContent: true
  51200. });
  51201. }
  51202. if (cssVars.length) {
  51203. content = rewriteDefault(content, `__default__`, plugins);
  51204. content += genNormalScriptCssVarsCode(cssVars, bindings, scopeId, !!options.isProd);
  51205. content += `\nexport default __default__`;
  51206. }
  51207. return Object.assign(Object.assign({}, script), { content,
  51208. map,
  51209. bindings, scriptAst: scriptAst.body });
  51210. }
  51211. catch (e) {
  51212. // silently fallback if parse fails since user may be using custom
  51213. // babel syntax
  51214. return script;
  51215. }
  51216. }
  51217. if (script && scriptLang !== scriptSetupLang) {
  51218. throw new Error(`[@vue/compiler-sfc] <script> and <script setup> must have the same ` +
  51219. `language type.`);
  51220. }
  51221. if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
  51222. // do not process non js/ts script blocks
  51223. return scriptSetup;
  51224. }
  51225. // metadata that needs to be returned
  51226. const bindingMetadata = {};
  51227. const defaultTempVar = `__default__`;
  51228. const helperImports = new Set();
  51229. const userImports = Object.create(null);
  51230. const userImportAlias = Object.create(null);
  51231. const setupBindings = Object.create(null);
  51232. let defaultExport;
  51233. let hasDefinePropsCall = false;
  51234. let hasDefineEmitCall = false;
  51235. let hasDefineExposeCall = false;
  51236. let propsRuntimeDecl;
  51237. let propsRuntimeDefaults;
  51238. let propsTypeDecl;
  51239. let propsTypeDeclRaw;
  51240. let propsIdentifier;
  51241. let emitsRuntimeDecl;
  51242. let emitsTypeDecl;
  51243. let emitsTypeDeclRaw;
  51244. let emitIdentifier;
  51245. let hasAwait = false;
  51246. let hasInlinedSsrRenderFn = false;
  51247. // props/emits declared via types
  51248. const typeDeclaredProps = {};
  51249. const typeDeclaredEmits = new Set();
  51250. // record declared types for runtime props type generation
  51251. const declaredTypes = {};
  51252. // magic-string state
  51253. const s = new MagicString(source);
  51254. const startOffset = scriptSetup.loc.start.offset;
  51255. const endOffset = scriptSetup.loc.end.offset;
  51256. const scriptStartOffset = script && script.loc.start.offset;
  51257. const scriptEndOffset = script && script.loc.end.offset;
  51258. function helper(key) {
  51259. helperImports.add(key);
  51260. return `_${key}`;
  51261. }
  51262. function parse(input, options, offset) {
  51263. try {
  51264. return parse_1(input, options).program;
  51265. }
  51266. catch (e) {
  51267. e.message = `[@vue/compiler-sfc] ${e.message}\n\n${sfc.filename}\n${generateCodeFrame(source, e.pos + offset, e.pos + offset + 1)}`;
  51268. throw e;
  51269. }
  51270. }
  51271. function error(msg, node, end = node.end + startOffset) {
  51272. throw new Error(`[@vue/compiler-sfc] ${msg}\n\n${sfc.filename}\n${generateCodeFrame(source, node.start + startOffset, end)}`);
  51273. }
  51274. function registerUserImport(source, local, imported, isType, isFromSetup) {
  51275. if (source === 'vue' && imported) {
  51276. userImportAlias[imported] = local;
  51277. }
  51278. let isUsedInTemplate = true;
  51279. if (isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  51280. isUsedInTemplate = new RegExp(
  51281. // #4274 escape $ since it's a special char in regex
  51282. // (and is the only regex special char that is valid in identifiers)
  51283. `[^\\w$_]${local.replace(/\$/g, '\\$')}[^\\w$_]`).test(resolveTemplateUsageCheckString(sfc));
  51284. }
  51285. userImports[local] = {
  51286. isType,
  51287. imported: imported || 'default',
  51288. source,
  51289. isFromSetup,
  51290. isUsedInTemplate
  51291. };
  51292. }
  51293. function processDefineProps(node) {
  51294. if (!isCallOf(node, DEFINE_PROPS)) {
  51295. return false;
  51296. }
  51297. if (hasDefinePropsCall) {
  51298. error(`duplicate ${DEFINE_PROPS}() call`, node);
  51299. }
  51300. hasDefinePropsCall = true;
  51301. propsRuntimeDecl = node.arguments[0];
  51302. // call has type parameters - infer runtime types from it
  51303. if (node.typeParameters) {
  51304. if (propsRuntimeDecl) {
  51305. error(`${DEFINE_PROPS}() cannot accept both type and non-type arguments ` +
  51306. `at the same time. Use one or the other.`, node);
  51307. }
  51308. propsTypeDeclRaw = node.typeParameters.params[0];
  51309. propsTypeDecl = resolveQualifiedType(propsTypeDeclRaw, node => node.type === 'TSTypeLiteral');
  51310. if (!propsTypeDecl) {
  51311. error(`type argument passed to ${DEFINE_PROPS}() must be a literal type, ` +
  51312. `or a reference to an interface or literal type.`, propsTypeDeclRaw);
  51313. }
  51314. }
  51315. return true;
  51316. }
  51317. function processWithDefaults(node) {
  51318. if (!isCallOf(node, WITH_DEFAULTS)) {
  51319. return false;
  51320. }
  51321. if (processDefineProps(node.arguments[0])) {
  51322. if (propsRuntimeDecl) {
  51323. error(`${WITH_DEFAULTS} can only be used with type-based ` +
  51324. `${DEFINE_PROPS} declaration.`, node);
  51325. }
  51326. propsRuntimeDefaults = node.arguments[1];
  51327. if (!propsRuntimeDefaults ||
  51328. propsRuntimeDefaults.type !== 'ObjectExpression') {
  51329. error(`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`, propsRuntimeDefaults || node);
  51330. }
  51331. }
  51332. else {
  51333. error(`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`, node.arguments[0] || node);
  51334. }
  51335. return true;
  51336. }
  51337. function processDefineEmits(node) {
  51338. if (!isCallOf(node, DEFINE_EMITS)) {
  51339. return false;
  51340. }
  51341. if (hasDefineEmitCall) {
  51342. error(`duplicate ${DEFINE_EMITS}() call`, node);
  51343. }
  51344. hasDefineEmitCall = true;
  51345. emitsRuntimeDecl = node.arguments[0];
  51346. if (node.typeParameters) {
  51347. if (emitsRuntimeDecl) {
  51348. error(`${DEFINE_EMITS}() cannot accept both type and non-type arguments ` +
  51349. `at the same time. Use one or the other.`, node);
  51350. }
  51351. emitsTypeDeclRaw = node.typeParameters.params[0];
  51352. emitsTypeDecl = resolveQualifiedType(emitsTypeDeclRaw, node => node.type === 'TSFunctionType' || node.type === 'TSTypeLiteral');
  51353. if (!emitsTypeDecl) {
  51354. error(`type argument passed to ${DEFINE_EMITS}() must be a function type, ` +
  51355. `a literal type with call signatures, or a reference to the above types.`, emitsTypeDeclRaw);
  51356. }
  51357. }
  51358. return true;
  51359. }
  51360. function resolveQualifiedType(node, qualifier) {
  51361. if (qualifier(node)) {
  51362. return node;
  51363. }
  51364. if (node.type === 'TSTypeReference' &&
  51365. node.typeName.type === 'Identifier') {
  51366. const refName = node.typeName.name;
  51367. const isQualifiedType = (node) => {
  51368. if (node.type === 'TSInterfaceDeclaration' &&
  51369. node.id.name === refName) {
  51370. return node.body;
  51371. }
  51372. else if (node.type === 'TSTypeAliasDeclaration' &&
  51373. node.id.name === refName &&
  51374. qualifier(node.typeAnnotation)) {
  51375. return node.typeAnnotation;
  51376. }
  51377. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  51378. return isQualifiedType(node.declaration);
  51379. }
  51380. };
  51381. for (const node of scriptSetupAst.body) {
  51382. const qualified = isQualifiedType(node);
  51383. if (qualified) {
  51384. return qualified;
  51385. }
  51386. }
  51387. }
  51388. }
  51389. function processDefineExpose(node) {
  51390. if (isCallOf(node, DEFINE_EXPOSE)) {
  51391. if (hasDefineExposeCall) {
  51392. error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  51393. }
  51394. hasDefineExposeCall = true;
  51395. return true;
  51396. }
  51397. return false;
  51398. }
  51399. function checkInvalidScopeReference(node, method) {
  51400. if (!node)
  51401. return;
  51402. walkIdentifiers(node, id => {
  51403. if (setupBindings[id.name]) {
  51404. error(`\`${method}()\` in <script setup> cannot reference locally ` +
  51405. `declared variables because it will be hoisted outside of the ` +
  51406. `setup() function. If your component options requires initialization ` +
  51407. `in the module scope, use a separate normal <script> to export ` +
  51408. `the options instead.`, id);
  51409. }
  51410. });
  51411. }
  51412. /**
  51413. * await foo()
  51414. * -->
  51415. * (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  51416. */
  51417. function processAwait(node, isStatement) {
  51418. s.overwrite(node.start + startOffset, node.argument.start + startOffset, `${isStatement ? `;` : ``}(([__temp,__restore]=${helper(`withAsyncContext`)}(()=>(`);
  51419. s.appendLeft(node.end + startOffset, `))),__temp=await __temp,__restore()${isStatement ? `` : `,__temp`})`);
  51420. }
  51421. /**
  51422. * check defaults. If the default object is an object literal with only
  51423. * static properties, we can directly generate more optimzied default
  51424. * decalrations. Otherwise we will have to fallback to runtime merging.
  51425. */
  51426. function checkStaticDefaults() {
  51427. return (propsRuntimeDefaults &&
  51428. propsRuntimeDefaults.type === 'ObjectExpression' &&
  51429. propsRuntimeDefaults.properties.every(node => (node.type === 'ObjectProperty' && !node.computed) ||
  51430. node.type === 'ObjectMethod'));
  51431. }
  51432. function genRuntimeProps(props) {
  51433. const keys = Object.keys(props);
  51434. if (!keys.length) {
  51435. return ``;
  51436. }
  51437. const hasStaticDefaults = checkStaticDefaults();
  51438. const scriptSetupSource = scriptSetup.content;
  51439. let propsDecls = `{
  51440. ${keys
  51441. .map(key => {
  51442. let defaultString;
  51443. if (hasStaticDefaults) {
  51444. const prop = propsRuntimeDefaults.properties.find((node) => node.key.name === key);
  51445. if (prop) {
  51446. if (prop.type === 'ObjectProperty') {
  51447. // prop has corresponding static default value
  51448. defaultString = `default: ${scriptSetupSource.slice(prop.value.start, prop.value.end)}`;
  51449. }
  51450. else {
  51451. defaultString = `default() ${scriptSetupSource.slice(prop.body.start, prop.body.end)}`;
  51452. }
  51453. }
  51454. }
  51455. {
  51456. const { type, required } = props[key];
  51457. return `${key}: { type: ${toRuntimeTypeString(type)}, required: ${required}${defaultString ? `, ${defaultString}` : ``} }`;
  51458. }
  51459. })
  51460. .join(',\n ')}\n }`;
  51461. if (propsRuntimeDefaults && !hasStaticDefaults) {
  51462. propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(propsRuntimeDefaults.start + startOffset, propsRuntimeDefaults.end + startOffset)})`;
  51463. }
  51464. return `\n props: ${propsDecls},`;
  51465. }
  51466. function genSetupPropsType(node) {
  51467. const scriptSetupSource = scriptSetup.content;
  51468. if (checkStaticDefaults()) {
  51469. // if withDefaults() is used, we need to remove the optional flags
  51470. // on props that have default values
  51471. let res = `{ `;
  51472. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  51473. for (const m of members) {
  51474. if ((m.type === 'TSPropertySignature' ||
  51475. m.type === 'TSMethodSignature') &&
  51476. m.typeAnnotation &&
  51477. m.key.type === 'Identifier') {
  51478. if (propsRuntimeDefaults.properties.some((p) => p.key.name === m.key.name)) {
  51479. res +=
  51480. m.key.name +
  51481. (m.type === 'TSMethodSignature' ? '()' : '') +
  51482. scriptSetupSource.slice(m.typeAnnotation.start, m.typeAnnotation.end) +
  51483. ', ';
  51484. }
  51485. else {
  51486. res += scriptSetupSource.slice(m.start, m.end) + `, `;
  51487. }
  51488. }
  51489. }
  51490. return (res.length ? res.slice(0, -2) : res) + ` }`;
  51491. }
  51492. else {
  51493. return scriptSetupSource.slice(node.start, node.end);
  51494. }
  51495. }
  51496. // 1. process normal <script> first if it exists
  51497. let scriptAst;
  51498. if (script) {
  51499. // import dedupe between <script> and <script setup>
  51500. scriptAst = parse(script.content, {
  51501. plugins,
  51502. sourceType: 'module'
  51503. }, scriptStartOffset);
  51504. for (const node of scriptAst.body) {
  51505. if (node.type === 'ImportDeclaration') {
  51506. // record imports for dedupe
  51507. for (const specifier of node.specifiers) {
  51508. const imported = specifier.type === 'ImportSpecifier' &&
  51509. specifier.imported.type === 'Identifier' &&
  51510. specifier.imported.name;
  51511. registerUserImport(node.source.value, specifier.local.name, imported, node.importKind === 'type', false);
  51512. }
  51513. }
  51514. else if (node.type === 'ExportDefaultDeclaration') {
  51515. // export default
  51516. defaultExport = node;
  51517. const start = node.start + scriptStartOffset;
  51518. const end = node.declaration.start + scriptStartOffset;
  51519. s.overwrite(start, end, `const ${defaultTempVar} = `);
  51520. }
  51521. else if (node.type === 'ExportNamedDeclaration' && node.specifiers) {
  51522. const defaultSpecifier = node.specifiers.find(s => s.exported.type === 'Identifier' && s.exported.name === 'default');
  51523. if (defaultSpecifier) {
  51524. defaultExport = node;
  51525. // 1. remove specifier
  51526. if (node.specifiers.length > 1) {
  51527. s.remove(defaultSpecifier.start + scriptStartOffset, defaultSpecifier.end + scriptStartOffset);
  51528. }
  51529. else {
  51530. s.remove(node.start + scriptStartOffset, node.end + scriptStartOffset);
  51531. }
  51532. if (node.source) {
  51533. // export { x as default } from './x'
  51534. // rewrite to `import { x as __default__ } from './x'` and
  51535. // add to top
  51536. s.prepend(`import { ${defaultSpecifier.local.name} as ${defaultTempVar} } from '${node.source.value}'\n`);
  51537. }
  51538. else {
  51539. // export { x as default }
  51540. // rewrite to `const __default__ = x` and move to end
  51541. s.append(`\nconst ${defaultTempVar} = ${defaultSpecifier.local.name}\n`);
  51542. }
  51543. }
  51544. }
  51545. else if ((node.type === 'VariableDeclaration' ||
  51546. node.type === 'FunctionDeclaration' ||
  51547. node.type === 'ClassDeclaration') &&
  51548. !node.declare) {
  51549. walkDeclaration(node, setupBindings, userImportAlias);
  51550. }
  51551. }
  51552. // apply ref transform
  51553. if (enableRefTransform && shouldTransform(script.content)) {
  51554. const { rootVars, importedHelpers } = transformAST(scriptAst, s, scriptStartOffset);
  51555. refBindings = rootVars;
  51556. for (const h of importedHelpers) {
  51557. helperImports.add(h);
  51558. }
  51559. }
  51560. }
  51561. // 2. parse <script setup> and walk over top level statements
  51562. const scriptSetupAst = parse(scriptSetup.content, {
  51563. plugins: [
  51564. ...plugins,
  51565. // allow top level await but only inside <script setup>
  51566. 'topLevelAwait'
  51567. ],
  51568. sourceType: 'module'
  51569. }, startOffset);
  51570. for (const node of scriptSetupAst.body) {
  51571. const start = node.start + startOffset;
  51572. let end = node.end + startOffset;
  51573. // locate comment
  51574. if (node.trailingComments && node.trailingComments.length > 0) {
  51575. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  51576. end = lastCommentNode.end + startOffset;
  51577. }
  51578. // locate the end of whitespace between this statement and the next
  51579. while (end <= source.length) {
  51580. if (!/\s/.test(source.charAt(end))) {
  51581. break;
  51582. }
  51583. end++;
  51584. }
  51585. // (Dropped) `ref: x` bindings
  51586. if (node.type === 'LabeledStatement' &&
  51587. node.label.name === 'ref' &&
  51588. node.body.type === 'ExpressionStatement') {
  51589. error(`ref sugar using the label syntax was an experimental proposal and ` +
  51590. `has been dropped based on community feedback. Please check out ` +
  51591. `the new proposal at https://github.com/vuejs/rfcs/discussions/369`, node);
  51592. }
  51593. if (node.type === 'ImportDeclaration') {
  51594. // import declarations are moved to top
  51595. s.move(start, end, 0);
  51596. // dedupe imports
  51597. let removed = 0;
  51598. const removeSpecifier = (i) => {
  51599. const removeLeft = i > removed;
  51600. removed++;
  51601. const current = node.specifiers[i];
  51602. const next = node.specifiers[i + 1];
  51603. s.remove(removeLeft
  51604. ? node.specifiers[i - 1].end + startOffset
  51605. : current.start + startOffset, next && !removeLeft
  51606. ? next.start + startOffset
  51607. : current.end + startOffset);
  51608. };
  51609. for (let i = 0; i < node.specifiers.length; i++) {
  51610. const specifier = node.specifiers[i];
  51611. const local = specifier.local.name;
  51612. const imported = specifier.type === 'ImportSpecifier' &&
  51613. specifier.imported.type === 'Identifier' &&
  51614. specifier.imported.name;
  51615. const source = node.source.value;
  51616. const existing = userImports[local];
  51617. if (source === 'vue' &&
  51618. (imported === DEFINE_PROPS ||
  51619. imported === DEFINE_EMITS ||
  51620. imported === DEFINE_EXPOSE)) {
  51621. warnOnce(`\`${imported}\` is a compiler macro and no longer needs to be imported.`);
  51622. removeSpecifier(i);
  51623. }
  51624. else if (existing) {
  51625. if (existing.source === source && existing.imported === imported) {
  51626. // already imported in <script setup>, dedupe
  51627. removeSpecifier(i);
  51628. }
  51629. else {
  51630. error(`different imports aliased to same local name.`, specifier);
  51631. }
  51632. }
  51633. else {
  51634. registerUserImport(source, local, imported, node.importKind === 'type', true);
  51635. }
  51636. }
  51637. if (node.specifiers.length && removed === node.specifiers.length) {
  51638. s.remove(node.start + startOffset, node.end + startOffset);
  51639. }
  51640. }
  51641. if (node.type === 'ExpressionStatement') {
  51642. // process `defineProps` and `defineEmit(s)` calls
  51643. if (processDefineProps(node.expression) ||
  51644. processDefineEmits(node.expression) ||
  51645. processWithDefaults(node.expression)) {
  51646. s.remove(node.start + startOffset, node.end + startOffset);
  51647. }
  51648. else if (processDefineExpose(node.expression)) {
  51649. // defineExpose({}) -> expose({})
  51650. const callee = node.expression.callee;
  51651. s.overwrite(callee.start + startOffset, callee.end + startOffset, 'expose');
  51652. }
  51653. }
  51654. if (node.type === 'VariableDeclaration' && !node.declare) {
  51655. const total = node.declarations.length;
  51656. let left = total;
  51657. for (let i = 0; i < total; i++) {
  51658. const decl = node.declarations[i];
  51659. if (decl.init) {
  51660. // defineProps / defineEmits
  51661. const isDefineProps = processDefineProps(decl.init) || processWithDefaults(decl.init);
  51662. if (isDefineProps) {
  51663. propsIdentifier = scriptSetup.content.slice(decl.id.start, decl.id.end);
  51664. }
  51665. const isDefineEmits = processDefineEmits(decl.init);
  51666. if (isDefineEmits) {
  51667. emitIdentifier = scriptSetup.content.slice(decl.id.start, decl.id.end);
  51668. }
  51669. if (isDefineProps || isDefineEmits) {
  51670. if (left === 1) {
  51671. s.remove(node.start + startOffset, node.end + startOffset);
  51672. }
  51673. else {
  51674. let start = decl.start + startOffset;
  51675. let end = decl.end + startOffset;
  51676. if (i < total - 1) {
  51677. // not the last one, locate the start of the next
  51678. end = node.declarations[i + 1].start + startOffset;
  51679. }
  51680. else {
  51681. // last one, locate the end of the prev
  51682. start = node.declarations[i - 1].end + startOffset;
  51683. }
  51684. s.remove(start, end);
  51685. left--;
  51686. }
  51687. }
  51688. }
  51689. }
  51690. }
  51691. // walk decalrations to record declared bindings
  51692. if ((node.type === 'VariableDeclaration' ||
  51693. node.type === 'FunctionDeclaration' ||
  51694. node.type === 'ClassDeclaration') &&
  51695. !node.declare) {
  51696. walkDeclaration(node, setupBindings, userImportAlias);
  51697. }
  51698. // walk statements & named exports / variable declarations for top level
  51699. // await
  51700. if ((node.type === 'VariableDeclaration' && !node.declare) ||
  51701. node.type.endsWith('Statement')) {
  51702. walk$1(node, {
  51703. enter(child, parent) {
  51704. if (isFunctionType(child)) {
  51705. this.skip();
  51706. }
  51707. if (child.type === 'AwaitExpression') {
  51708. hasAwait = true;
  51709. processAwait(child, parent.type === 'ExpressionStatement');
  51710. }
  51711. }
  51712. });
  51713. }
  51714. if ((node.type === 'ExportNamedDeclaration' && node.exportKind !== 'type') ||
  51715. node.type === 'ExportAllDeclaration' ||
  51716. node.type === 'ExportDefaultDeclaration') {
  51717. error(`<script setup> cannot contain ES module exports. ` +
  51718. `If you are using a previous version of <script setup>, please ` +
  51719. `consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`, node);
  51720. }
  51721. if (isTS) {
  51722. // runtime enum
  51723. if (node.type === 'TSEnumDeclaration') {
  51724. registerBinding(setupBindings, node.id, "setup-const" /* SETUP_CONST */);
  51725. }
  51726. // move all Type declarations to outer scope
  51727. if (node.type.startsWith('TS') ||
  51728. (node.type === 'ExportNamedDeclaration' &&
  51729. node.exportKind === 'type') ||
  51730. (node.type === 'VariableDeclaration' && node.declare)) {
  51731. recordType(node, declaredTypes);
  51732. s.move(start, end, 0);
  51733. }
  51734. }
  51735. }
  51736. // 3. Apply ref sugar transform
  51737. if (enableRefTransform && shouldTransform(scriptSetup.content)) {
  51738. const { rootVars, importedHelpers } = transformAST(scriptSetupAst, s, startOffset, refBindings);
  51739. refBindings = refBindings ? [...refBindings, ...rootVars] : rootVars;
  51740. for (const h of importedHelpers) {
  51741. helperImports.add(h);
  51742. }
  51743. }
  51744. // 4. extract runtime props/emits code from setup context type
  51745. if (propsTypeDecl) {
  51746. extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes);
  51747. }
  51748. if (emitsTypeDecl) {
  51749. extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits);
  51750. }
  51751. // 5. check useOptions args to make sure it doesn't reference setup scope
  51752. // variables
  51753. checkInvalidScopeReference(propsRuntimeDecl, DEFINE_PROPS);
  51754. checkInvalidScopeReference(propsRuntimeDefaults, DEFINE_PROPS);
  51755. checkInvalidScopeReference(emitsRuntimeDecl, DEFINE_PROPS);
  51756. // 6. remove non-script content
  51757. if (script) {
  51758. if (startOffset < scriptStartOffset) {
  51759. // <script setup> before <script>
  51760. s.remove(0, startOffset);
  51761. s.remove(endOffset, scriptStartOffset);
  51762. s.remove(scriptEndOffset, source.length);
  51763. }
  51764. else {
  51765. // <script> before <script setup>
  51766. s.remove(0, scriptStartOffset);
  51767. s.remove(scriptEndOffset, startOffset);
  51768. s.remove(endOffset, source.length);
  51769. }
  51770. }
  51771. else {
  51772. // only <script setup>
  51773. s.remove(0, startOffset);
  51774. s.remove(endOffset, source.length);
  51775. }
  51776. // 7. analyze binding metadata
  51777. if (scriptAst) {
  51778. Object.assign(bindingMetadata, analyzeScriptBindings(scriptAst.body));
  51779. }
  51780. if (propsRuntimeDecl) {
  51781. for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
  51782. bindingMetadata[key] = "props" /* PROPS */;
  51783. }
  51784. }
  51785. for (const key in typeDeclaredProps) {
  51786. bindingMetadata[key] = "props" /* PROPS */;
  51787. }
  51788. for (const [key, { isType, imported, source }] of Object.entries(userImports)) {
  51789. if (isType)
  51790. continue;
  51791. bindingMetadata[key] =
  51792. (imported === 'default' && source.endsWith('.vue')) || source === 'vue'
  51793. ? "setup-const" /* SETUP_CONST */
  51794. : "setup-maybe-ref" /* SETUP_MAYBE_REF */;
  51795. }
  51796. for (const key in setupBindings) {
  51797. bindingMetadata[key] = setupBindings[key];
  51798. }
  51799. // known ref bindings
  51800. if (refBindings) {
  51801. for (const key of refBindings) {
  51802. bindingMetadata[key] = "setup-ref" /* SETUP_REF */;
  51803. }
  51804. }
  51805. // 8. inject `useCssVars` calls
  51806. if (cssVars.length) {
  51807. helperImports.add(CSS_VARS_HELPER);
  51808. helperImports.add('unref');
  51809. s.prependRight(startOffset, `\n${genCssVarsCode(cssVars, bindingMetadata, scopeId, !!options.isProd)}\n`);
  51810. }
  51811. // 9. finalize setup() argument signature
  51812. let args = `__props`;
  51813. if (propsTypeDecl) {
  51814. // mark as any and only cast on assignment
  51815. // since the user defined complex types may be incompatible with the
  51816. // inferred type from generated runtime declarations
  51817. args += `: any`;
  51818. }
  51819. // inject user assignment of props
  51820. // we use a default __props so that template expressions referencing props
  51821. // can use it directly
  51822. if (propsIdentifier) {
  51823. s.prependRight(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}`);
  51824. }
  51825. // inject temp variables for async context preservation
  51826. if (hasAwait) {
  51827. const any = isTS ? `: any` : ``;
  51828. s.prependRight(startOffset, `\nlet __temp${any}, __restore${any}\n`);
  51829. }
  51830. const destructureElements = hasDefineExposeCall || !options.inlineTemplate ? [`expose`] : [];
  51831. if (emitIdentifier) {
  51832. destructureElements.push(emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}`);
  51833. }
  51834. if (destructureElements.length) {
  51835. args += `, { ${destructureElements.join(', ')} }`;
  51836. if (emitsTypeDecl) {
  51837. args += `: { emit: (${scriptSetup.content.slice(emitsTypeDecl.start, emitsTypeDecl.end)}), expose: any, slots: any, attrs: any }`;
  51838. }
  51839. }
  51840. // 10. generate return statement
  51841. let returned;
  51842. if (options.inlineTemplate) {
  51843. if (sfc.template && !sfc.template.src) {
  51844. if (options.templateOptions && options.templateOptions.ssr) {
  51845. hasInlinedSsrRenderFn = true;
  51846. }
  51847. // inline render function mode - we are going to compile the template and
  51848. // inline it right here
  51849. const { code, ast, preamble, tips, errors } = compileTemplate(Object.assign(Object.assign({ filename, source: sfc.template.content, inMap: sfc.template.map }, options.templateOptions), { id: scopeId, scoped: sfc.styles.some(s => s.scoped), isProd: options.isProd, ssrCssVars: sfc.cssVars, compilerOptions: Object.assign(Object.assign({}, (options.templateOptions &&
  51850. options.templateOptions.compilerOptions)), { inline: true, isTS,
  51851. bindingMetadata }) }));
  51852. if (tips.length) {
  51853. tips.forEach(warnOnce);
  51854. }
  51855. const err = errors[0];
  51856. if (typeof err === 'string') {
  51857. throw new Error(err);
  51858. }
  51859. else if (err) {
  51860. if (err.loc) {
  51861. err.message +=
  51862. `\n\n` +
  51863. sfc.filename +
  51864. '\n' +
  51865. generateCodeFrame(source, err.loc.start.offset, err.loc.end.offset) +
  51866. `\n`;
  51867. }
  51868. throw err;
  51869. }
  51870. if (preamble) {
  51871. s.prepend(preamble);
  51872. }
  51873. // avoid duplicated unref import
  51874. // as this may get injected by the render function preamble OR the
  51875. // css vars codegen
  51876. if (ast && ast.helpers.includes(UNREF)) {
  51877. helperImports.delete('unref');
  51878. }
  51879. returned = code;
  51880. }
  51881. else {
  51882. returned = `() => {}`;
  51883. }
  51884. }
  51885. else {
  51886. // return bindings from setup
  51887. const allBindings = Object.assign({}, setupBindings);
  51888. for (const key in userImports) {
  51889. if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
  51890. allBindings[key] = true;
  51891. }
  51892. }
  51893. returned = `{ ${Object.keys(allBindings).join(', ')} }`;
  51894. }
  51895. if (!options.inlineTemplate && !false) {
  51896. // in non-inline mode, the `__isScriptSetup: true` flag is used by
  51897. // componentPublicInstance proxy to allow properties that start with $ or _
  51898. s.appendRight(endOffset, `\nconst __returned__ = ${returned}\n` +
  51899. `Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })\n` +
  51900. `return __returned__` +
  51901. `\n}\n\n`);
  51902. }
  51903. else {
  51904. s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`);
  51905. }
  51906. // 11. finalize default export
  51907. let runtimeOptions = ``;
  51908. if (hasInlinedSsrRenderFn) {
  51909. runtimeOptions += `\n __ssrInlineRender: true,`;
  51910. }
  51911. if (propsRuntimeDecl) {
  51912. runtimeOptions += `\n props: ${scriptSetup.content
  51913. .slice(propsRuntimeDecl.start, propsRuntimeDecl.end)
  51914. .trim()},`;
  51915. }
  51916. else if (propsTypeDecl) {
  51917. runtimeOptions += genRuntimeProps(typeDeclaredProps);
  51918. }
  51919. if (emitsRuntimeDecl) {
  51920. runtimeOptions += `\n emits: ${scriptSetup.content
  51921. .slice(emitsRuntimeDecl.start, emitsRuntimeDecl.end)
  51922. .trim()},`;
  51923. }
  51924. else if (emitsTypeDecl) {
  51925. runtimeOptions += genRuntimeEmits(typeDeclaredEmits);
  51926. }
  51927. // <script setup> components are closed by default. If the user did not
  51928. // explicitly call `defineExpose`, call expose() with no args.
  51929. const exposeCall = hasDefineExposeCall || options.inlineTemplate ? `` : ` expose()\n`;
  51930. if (isTS) {
  51931. // for TS, make sure the exported type is still valid type with
  51932. // correct props information
  51933. // we have to use object spread for types to be merged properly
  51934. // user's TS setting should compile it down to proper targets
  51935. const def = defaultExport ? `\n ...${defaultTempVar},` : ``;
  51936. // wrap setup code with function.
  51937. // export the content of <script setup> as a named export, `setup`.
  51938. // this allows `import { setup } from '*.vue'` for testing purposes.
  51939. if (defaultExport) {
  51940. s.prependLeft(startOffset, `\n${hasAwait ? `async ` : ``}function setup(${args}) {\n`);
  51941. s.append(`\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup})`);
  51942. }
  51943. else {
  51944. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n ${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`);
  51945. s.appendRight(endOffset, `})`);
  51946. }
  51947. }
  51948. else {
  51949. if (defaultExport) {
  51950. // can't rely on spread operator in non ts mode
  51951. s.prependLeft(startOffset, `\n${hasAwait ? `async ` : ``}function setup(${args}) {\n`);
  51952. s.append(`\nexport default /*#__PURE__*/ Object.assign(${defaultTempVar}, {${runtimeOptions}\n setup\n})\n`);
  51953. }
  51954. else {
  51955. s.prependLeft(startOffset, `\nexport default {${runtimeOptions}\n ` +
  51956. `${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`);
  51957. s.appendRight(endOffset, `}`);
  51958. }
  51959. }
  51960. // 12. finalize Vue helper imports
  51961. if (helperImports.size > 0) {
  51962. s.prepend(`import { ${[...helperImports]
  51963. .map(h => `${h} as _${h}`)
  51964. .join(', ')} } from 'vue'\n`);
  51965. }
  51966. s.trim();
  51967. return Object.assign(Object.assign({}, scriptSetup), { bindings: bindingMetadata, content: s.toString(), map: s.generateMap({
  51968. source: filename,
  51969. hires: true,
  51970. includeContent: true
  51971. }), scriptAst: scriptAst === null || scriptAst === void 0 ? void 0 : scriptAst.body, scriptSetupAst: scriptSetupAst === null || scriptSetupAst === void 0 ? void 0 : scriptSetupAst.body });
  51972. }
  51973. function registerBinding(bindings, node, type) {
  51974. bindings[node.name] = type;
  51975. }
  51976. function walkDeclaration(node, bindings, userImportAlias) {
  51977. if (node.type === 'VariableDeclaration') {
  51978. const isConst = node.kind === 'const';
  51979. // export const foo = ...
  51980. for (const { id, init } of node.declarations) {
  51981. const isDefineCall = !!(isConst &&
  51982. isCallOf(init, c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS));
  51983. if (id.type === 'Identifier') {
  51984. let bindingType;
  51985. const userReactiveBinding = userImportAlias['reactive'] || 'reactive';
  51986. if (isCallOf(init, userReactiveBinding)) {
  51987. // treat reactive() calls as let since it's meant to be mutable
  51988. bindingType = "setup-let" /* SETUP_LET */;
  51989. }
  51990. else if (
  51991. // if a declaration is a const literal, we can mark it so that
  51992. // the generated render fn code doesn't need to unref() it
  51993. isDefineCall ||
  51994. (isConst && canNeverBeRef(init, userReactiveBinding))) {
  51995. bindingType = "setup-const" /* SETUP_CONST */;
  51996. }
  51997. else if (isConst) {
  51998. if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
  51999. bindingType = "setup-ref" /* SETUP_REF */;
  52000. }
  52001. else {
  52002. bindingType = "setup-maybe-ref" /* SETUP_MAYBE_REF */;
  52003. }
  52004. }
  52005. else {
  52006. bindingType = "setup-let" /* SETUP_LET */;
  52007. }
  52008. registerBinding(bindings, id, bindingType);
  52009. }
  52010. else if (id.type === 'ObjectPattern') {
  52011. walkObjectPattern(id, bindings, isConst, isDefineCall);
  52012. }
  52013. else if (id.type === 'ArrayPattern') {
  52014. walkArrayPattern(id, bindings, isConst, isDefineCall);
  52015. }
  52016. }
  52017. }
  52018. else if (node.type === 'FunctionDeclaration' ||
  52019. node.type === 'ClassDeclaration') {
  52020. // export function foo() {} / export class Foo {}
  52021. // export declarations must be named.
  52022. bindings[node.id.name] = "setup-const" /* SETUP_CONST */;
  52023. }
  52024. }
  52025. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  52026. for (const p of node.properties) {
  52027. if (p.type === 'ObjectProperty') {
  52028. // key can only be Identifier in ObjectPattern
  52029. if (p.key.type === 'Identifier') {
  52030. if (p.key === p.value) {
  52031. // const { x } = ...
  52032. const type = isDefineCall
  52033. ? "setup-const" /* SETUP_CONST */
  52034. : isConst
  52035. ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
  52036. : "setup-let" /* SETUP_LET */;
  52037. registerBinding(bindings, p.key, type);
  52038. }
  52039. else {
  52040. walkPattern(p.value, bindings, isConst, isDefineCall);
  52041. }
  52042. }
  52043. }
  52044. else {
  52045. // ...rest
  52046. // argument can only be identifer when destructuring
  52047. const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
  52048. registerBinding(bindings, p.argument, type);
  52049. }
  52050. }
  52051. }
  52052. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  52053. for (const e of node.elements) {
  52054. e && walkPattern(e, bindings, isConst, isDefineCall);
  52055. }
  52056. }
  52057. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  52058. if (node.type === 'Identifier') {
  52059. const type = isDefineCall
  52060. ? "setup-const" /* SETUP_CONST */
  52061. : isConst
  52062. ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
  52063. : "setup-let" /* SETUP_LET */;
  52064. registerBinding(bindings, node, type);
  52065. }
  52066. else if (node.type === 'RestElement') {
  52067. // argument can only be identifer when destructuring
  52068. const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
  52069. registerBinding(bindings, node.argument, type);
  52070. }
  52071. else if (node.type === 'ObjectPattern') {
  52072. walkObjectPattern(node, bindings, isConst);
  52073. }
  52074. else if (node.type === 'ArrayPattern') {
  52075. walkArrayPattern(node, bindings, isConst);
  52076. }
  52077. else if (node.type === 'AssignmentPattern') {
  52078. if (node.left.type === 'Identifier') {
  52079. const type = isDefineCall
  52080. ? "setup-const" /* SETUP_CONST */
  52081. : isConst
  52082. ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
  52083. : "setup-let" /* SETUP_LET */;
  52084. registerBinding(bindings, node.left, type);
  52085. }
  52086. else {
  52087. walkPattern(node.left, bindings, isConst);
  52088. }
  52089. }
  52090. }
  52091. function recordType(node, declaredTypes) {
  52092. if (node.type === 'TSInterfaceDeclaration') {
  52093. declaredTypes[node.id.name] = [`Object`];
  52094. }
  52095. else if (node.type === 'TSTypeAliasDeclaration') {
  52096. declaredTypes[node.id.name] = inferRuntimeType(node.typeAnnotation, declaredTypes);
  52097. }
  52098. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  52099. recordType(node.declaration, declaredTypes);
  52100. }
  52101. }
  52102. function extractRuntimeProps(node, props, declaredTypes) {
  52103. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  52104. for (const m of members) {
  52105. if ((m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
  52106. m.key.type === 'Identifier') {
  52107. let type;
  52108. {
  52109. if (m.type === 'TSMethodSignature') {
  52110. type = ['Function'];
  52111. }
  52112. else if (m.typeAnnotation) {
  52113. type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
  52114. }
  52115. }
  52116. props[m.key.name] = {
  52117. key: m.key.name,
  52118. required: !m.optional,
  52119. type: type || [`null`]
  52120. };
  52121. }
  52122. }
  52123. }
  52124. function inferRuntimeType(node, declaredTypes) {
  52125. switch (node.type) {
  52126. case 'TSStringKeyword':
  52127. return ['String'];
  52128. case 'TSNumberKeyword':
  52129. return ['Number'];
  52130. case 'TSBooleanKeyword':
  52131. return ['Boolean'];
  52132. case 'TSObjectKeyword':
  52133. return ['Object'];
  52134. case 'TSTypeLiteral':
  52135. // TODO (nice to have) generate runtime property validation
  52136. return ['Object'];
  52137. case 'TSFunctionType':
  52138. return ['Function'];
  52139. case 'TSArrayType':
  52140. case 'TSTupleType':
  52141. // TODO (nice to have) generate runtime element type/length checks
  52142. return ['Array'];
  52143. case 'TSLiteralType':
  52144. switch (node.literal.type) {
  52145. case 'StringLiteral':
  52146. return ['String'];
  52147. case 'BooleanLiteral':
  52148. return ['Boolean'];
  52149. case 'NumericLiteral':
  52150. case 'BigIntLiteral':
  52151. return ['Number'];
  52152. default:
  52153. return [`null`];
  52154. }
  52155. case 'TSTypeReference':
  52156. if (node.typeName.type === 'Identifier') {
  52157. if (declaredTypes[node.typeName.name]) {
  52158. return declaredTypes[node.typeName.name];
  52159. }
  52160. switch (node.typeName.name) {
  52161. case 'Array':
  52162. case 'Function':
  52163. case 'Object':
  52164. case 'Set':
  52165. case 'Map':
  52166. case 'WeakSet':
  52167. case 'WeakMap':
  52168. return [node.typeName.name];
  52169. case 'Record':
  52170. case 'Partial':
  52171. case 'Readonly':
  52172. case 'Pick':
  52173. case 'Omit':
  52174. case 'Exclude':
  52175. case 'Extract':
  52176. case 'Required':
  52177. case 'InstanceType':
  52178. return ['Object'];
  52179. }
  52180. }
  52181. return [`null`];
  52182. case 'TSParenthesizedType':
  52183. return inferRuntimeType(node.typeAnnotation, declaredTypes);
  52184. case 'TSUnionType':
  52185. return [
  52186. ...new Set([].concat(...node.types.map(t => inferRuntimeType(t, declaredTypes))))
  52187. ];
  52188. case 'TSIntersectionType':
  52189. return ['Object'];
  52190. default:
  52191. return [`null`]; // no runtime check
  52192. }
  52193. }
  52194. function toRuntimeTypeString(types) {
  52195. return types.length > 1 ? `[${types.join(', ')}]` : types[0];
  52196. }
  52197. function extractRuntimeEmits(node, emits) {
  52198. if (node.type === 'TSTypeLiteral' || node.type === 'TSInterfaceBody') {
  52199. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  52200. for (let t of members) {
  52201. if (t.type === 'TSCallSignatureDeclaration') {
  52202. extractEventNames(t.parameters[0], emits);
  52203. }
  52204. }
  52205. return;
  52206. }
  52207. else {
  52208. extractEventNames(node.parameters[0], emits);
  52209. }
  52210. }
  52211. function extractEventNames(eventName, emits) {
  52212. if (eventName.type === 'Identifier' &&
  52213. eventName.typeAnnotation &&
  52214. eventName.typeAnnotation.type === 'TSTypeAnnotation') {
  52215. const typeNode = eventName.typeAnnotation.typeAnnotation;
  52216. if (typeNode.type === 'TSLiteralType') {
  52217. if (typeNode.literal.type !== 'UnaryExpression') {
  52218. emits.add(String(typeNode.literal.value));
  52219. }
  52220. }
  52221. else if (typeNode.type === 'TSUnionType') {
  52222. for (const t of typeNode.types) {
  52223. if (t.type === 'TSLiteralType' &&
  52224. t.literal.type !== 'UnaryExpression') {
  52225. emits.add(String(t.literal.value));
  52226. }
  52227. }
  52228. }
  52229. }
  52230. }
  52231. function genRuntimeEmits(emits) {
  52232. return emits.size
  52233. ? `\n emits: [${Array.from(emits)
  52234. .map(p => JSON.stringify(p))
  52235. .join(', ')}],`
  52236. : ``;
  52237. }
  52238. function isCallOf(node, test) {
  52239. return !!(node &&
  52240. node.type === 'CallExpression' &&
  52241. node.callee.type === 'Identifier' &&
  52242. (typeof test === 'string'
  52243. ? node.callee.name === test
  52244. : test(node.callee.name)));
  52245. }
  52246. function canNeverBeRef(node, userReactiveImport) {
  52247. if (isCallOf(node, userReactiveImport)) {
  52248. return true;
  52249. }
  52250. switch (node.type) {
  52251. case 'UnaryExpression':
  52252. case 'BinaryExpression':
  52253. case 'ArrayExpression':
  52254. case 'ObjectExpression':
  52255. case 'FunctionExpression':
  52256. case 'ArrowFunctionExpression':
  52257. case 'UpdateExpression':
  52258. case 'ClassExpression':
  52259. case 'TaggedTemplateExpression':
  52260. return true;
  52261. case 'SequenceExpression':
  52262. return canNeverBeRef(node.expressions[node.expressions.length - 1], userReactiveImport);
  52263. default:
  52264. if (node.type.endsWith('Literal')) {
  52265. return true;
  52266. }
  52267. return false;
  52268. }
  52269. }
  52270. /**
  52271. * Analyze bindings in normal `<script>`
  52272. * Note that `compileScriptSetup` already analyzes bindings as part of its
  52273. * compilation process so this should only be used on single `<script>` SFCs.
  52274. */
  52275. function analyzeScriptBindings(ast) {
  52276. for (const node of ast) {
  52277. if (node.type === 'ExportDefaultDeclaration' &&
  52278. node.declaration.type === 'ObjectExpression') {
  52279. return analyzeBindingsFromOptions(node.declaration);
  52280. }
  52281. }
  52282. return {};
  52283. }
  52284. function analyzeBindingsFromOptions(node) {
  52285. const bindings = {};
  52286. // #3270, #3275
  52287. // mark non-script-setup so we don't resolve components/directives from these
  52288. Object.defineProperty(bindings, '__isScriptSetup', {
  52289. enumerable: false,
  52290. value: false
  52291. });
  52292. for (const property of node.properties) {
  52293. if (property.type === 'ObjectProperty' &&
  52294. !property.computed &&
  52295. property.key.type === 'Identifier') {
  52296. // props
  52297. if (property.key.name === 'props') {
  52298. // props: ['foo']
  52299. // props: { foo: ... }
  52300. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  52301. bindings[key] = "props" /* PROPS */;
  52302. }
  52303. }
  52304. // inject
  52305. else if (property.key.name === 'inject') {
  52306. // inject: ['foo']
  52307. // inject: { foo: {} }
  52308. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  52309. bindings[key] = "options" /* OPTIONS */;
  52310. }
  52311. }
  52312. // computed & methods
  52313. else if (property.value.type === 'ObjectExpression' &&
  52314. (property.key.name === 'computed' || property.key.name === 'methods')) {
  52315. // methods: { foo() {} }
  52316. // computed: { foo() {} }
  52317. for (const key of getObjectExpressionKeys(property.value)) {
  52318. bindings[key] = "options" /* OPTIONS */;
  52319. }
  52320. }
  52321. }
  52322. // setup & data
  52323. else if (property.type === 'ObjectMethod' &&
  52324. property.key.type === 'Identifier' &&
  52325. (property.key.name === 'setup' || property.key.name === 'data')) {
  52326. for (const bodyItem of property.body.body) {
  52327. // setup() {
  52328. // return {
  52329. // foo: null
  52330. // }
  52331. // }
  52332. if (bodyItem.type === 'ReturnStatement' &&
  52333. bodyItem.argument &&
  52334. bodyItem.argument.type === 'ObjectExpression') {
  52335. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  52336. bindings[key] =
  52337. property.key.name === 'setup'
  52338. ? "setup-maybe-ref" /* SETUP_MAYBE_REF */
  52339. : "data" /* DATA */;
  52340. }
  52341. }
  52342. }
  52343. }
  52344. }
  52345. return bindings;
  52346. }
  52347. function getObjectExpressionKeys(node) {
  52348. const keys = [];
  52349. for (const prop of node.properties) {
  52350. if ((prop.type === 'ObjectProperty' || prop.type === 'ObjectMethod') &&
  52351. !prop.computed) {
  52352. if (prop.key.type === 'Identifier') {
  52353. keys.push(prop.key.name);
  52354. }
  52355. else if (prop.key.type === 'StringLiteral') {
  52356. keys.push(prop.key.value);
  52357. }
  52358. }
  52359. }
  52360. return keys;
  52361. }
  52362. function getArrayExpressionKeys(node) {
  52363. const keys = [];
  52364. for (const element of node.elements) {
  52365. if (element && element.type === 'StringLiteral') {
  52366. keys.push(element.value);
  52367. }
  52368. }
  52369. return keys;
  52370. }
  52371. function getObjectOrArrayExpressionKeys(value) {
  52372. if (value.type === 'ArrayExpression') {
  52373. return getArrayExpressionKeys(value);
  52374. }
  52375. if (value.type === 'ObjectExpression') {
  52376. return getObjectExpressionKeys(value);
  52377. }
  52378. return [];
  52379. }
  52380. const templateUsageCheckCache = createCache();
  52381. function resolveTemplateUsageCheckString(sfc) {
  52382. const { content, ast } = sfc.template;
  52383. const cached = templateUsageCheckCache.get(content);
  52384. if (cached) {
  52385. return cached;
  52386. }
  52387. let code = '';
  52388. transform(createRoot([ast]), {
  52389. nodeTransforms: [
  52390. node => {
  52391. if (node.type === 1 /* ELEMENT */) {
  52392. if (!parserOptions.isNativeTag(node.tag) &&
  52393. !parserOptions.isBuiltInComponent(node.tag)) {
  52394. code += `,${camelize(node.tag)},${capitalize(camelize(node.tag))}`;
  52395. }
  52396. for (let i = 0; i < node.props.length; i++) {
  52397. const prop = node.props[i];
  52398. if (prop.type === 7 /* DIRECTIVE */) {
  52399. if (!isBuiltInDir(prop.name)) {
  52400. code += `,v${capitalize(camelize(prop.name))}`;
  52401. }
  52402. if (prop.exp) {
  52403. code += `,${stripStrings(prop.exp.content)}`;
  52404. }
  52405. }
  52406. }
  52407. }
  52408. else if (node.type === 5 /* INTERPOLATION */) {
  52409. code += `,${stripStrings(node.content.content)}`;
  52410. }
  52411. }
  52412. ]
  52413. });
  52414. code += ';';
  52415. templateUsageCheckCache.set(content, code);
  52416. return code;
  52417. }
  52418. function stripStrings(exp) {
  52419. return exp
  52420. .replace(/'[^']+'|"[^"]+"/g, '')
  52421. .replace(/`[^`]+`/g, stripTemplateString);
  52422. }
  52423. function stripTemplateString(str) {
  52424. const interpMatch = str.match(/\${[^}]+}/g);
  52425. if (interpMatch) {
  52426. return interpMatch.map(m => m.slice(2, -1)).join(',');
  52427. }
  52428. return '';
  52429. }
  52430. export { MagicString, parse_1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, parse$2 as parse, rewriteDefault, shouldTransform as shouldTransformRef, transform$1 as transformRef, transformAST as transformRefAST, walk$1 as walk, walkIdentifiers };