compiler-sfc.esm-browser.js 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061
  1. /**
  2. * @vue/compiler-sfc v3.5.12
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. /*! #__NO_SIDE_EFFECTS__ */
  7. // @__NO_SIDE_EFFECTS__
  8. function makeMap(str) {
  9. const map = /* @__PURE__ */ Object.create(null);
  10. for (const key of str.split(",")) map[key] = 1;
  11. return (val) => val in map;
  12. }
  13. const EMPTY_OBJ = Object.freeze({}) ;
  14. const NOOP = () => {
  15. };
  16. const NO = () => false;
  17. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  18. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  19. const extend = Object.assign;
  20. const hasOwnProperty$3 = Object.prototype.hasOwnProperty;
  21. const hasOwn = (val, key) => hasOwnProperty$3.call(val, key);
  22. const isArray$3 = Array.isArray;
  23. const isMap = (val) => toTypeString(val) === "[object Map]";
  24. const isSet = (val) => toTypeString(val) === "[object Set]";
  25. const isFunction$1 = (val) => typeof val === "function";
  26. const isString$1 = (val) => typeof val === "string";
  27. const isSymbol$1 = (val) => typeof val === "symbol";
  28. const isObject$2 = (val) => val !== null && typeof val === "object";
  29. const objectToString$1 = Object.prototype.toString;
  30. const toTypeString = (value) => objectToString$1.call(value);
  31. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  32. const isReservedProp = /* @__PURE__ */ makeMap(
  33. // the leading comma is intentional so empty string "" is also included
  34. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  35. );
  36. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  37. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  38. );
  39. const cacheStringFunction = (fn) => {
  40. const cache = /* @__PURE__ */ Object.create(null);
  41. return (str) => {
  42. const hit = cache[str];
  43. return hit || (cache[str] = fn(str));
  44. };
  45. };
  46. const camelizeRE = /-(\w)/g;
  47. const camelize = cacheStringFunction(
  48. (str) => {
  49. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  50. }
  51. );
  52. const hyphenateRE = /\B([A-Z])/g;
  53. const hyphenate = cacheStringFunction(
  54. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  55. );
  56. const capitalize = cacheStringFunction((str) => {
  57. return str.charAt(0).toUpperCase() + str.slice(1);
  58. });
  59. const toHandlerKey = cacheStringFunction(
  60. (str) => {
  61. const s = str ? `on${capitalize(str)}` : ``;
  62. return s;
  63. }
  64. );
  65. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  66. function genPropsAccessExp(name) {
  67. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  68. }
  69. function genCacheKey(source, options) {
  70. return source + JSON.stringify(
  71. options,
  72. (_, val) => typeof val === "function" ? val.toString() : val
  73. );
  74. }
  75. const PatchFlagNames = {
  76. [1]: `TEXT`,
  77. [2]: `CLASS`,
  78. [4]: `STYLE`,
  79. [8]: `PROPS`,
  80. [16]: `FULL_PROPS`,
  81. [32]: `NEED_HYDRATION`,
  82. [64]: `STABLE_FRAGMENT`,
  83. [128]: `KEYED_FRAGMENT`,
  84. [256]: `UNKEYED_FRAGMENT`,
  85. [512]: `NEED_PATCH`,
  86. [1024]: `DYNAMIC_SLOTS`,
  87. [2048]: `DEV_ROOT_FRAGMENT`,
  88. [-1]: `HOISTED`,
  89. [-2]: `BAIL`
  90. };
  91. const slotFlagsText = {
  92. [1]: "STABLE",
  93. [2]: "DYNAMIC",
  94. [3]: "FORWARDED"
  95. };
  96. const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
  97. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  98. const range = 2;
  99. function generateCodeFrame(source, start = 0, end = source.length) {
  100. start = Math.max(0, Math.min(start, source.length));
  101. end = Math.max(0, Math.min(end, source.length));
  102. if (start > end) return "";
  103. let lines = source.split(/(\r?\n)/);
  104. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  105. lines = lines.filter((_, idx) => idx % 2 === 0);
  106. let count = 0;
  107. const res = [];
  108. for (let i = 0; i < lines.length; i++) {
  109. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  110. if (count >= start) {
  111. for (let j = i - range; j <= i + range || end > count; j++) {
  112. if (j < 0 || j >= lines.length) continue;
  113. const line = j + 1;
  114. res.push(
  115. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  116. );
  117. const lineLength = lines[j].length;
  118. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  119. if (j === i) {
  120. const pad = start - (count - (lineLength + newLineSeqLength));
  121. const length = Math.max(
  122. 1,
  123. end > count ? lineLength - pad : end - start
  124. );
  125. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  126. } else if (j > i) {
  127. if (end > count) {
  128. const length = Math.max(Math.min(end - count, lineLength), 1);
  129. res.push(` | ` + "^".repeat(length));
  130. }
  131. count += lineLength + newLineSeqLength;
  132. }
  133. }
  134. break;
  135. }
  136. }
  137. return res.join("\n");
  138. }
  139. function normalizeStyle(value) {
  140. if (isArray$3(value)) {
  141. const res = {};
  142. for (let i = 0; i < value.length; i++) {
  143. const item = value[i];
  144. const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
  145. if (normalized) {
  146. for (const key in normalized) {
  147. res[key] = normalized[key];
  148. }
  149. }
  150. }
  151. return res;
  152. } else if (isString$1(value) || isObject$2(value)) {
  153. return value;
  154. }
  155. }
  156. const listDelimiterRE = /;(?![^(]*\))/g;
  157. const propertyDelimiterRE = /:([^]+)/;
  158. const styleCommentRE = /\/\*[^]*?\*\//g;
  159. function parseStringStyle(cssText) {
  160. const ret = {};
  161. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  162. if (item) {
  163. const tmp = item.split(propertyDelimiterRE);
  164. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  165. }
  166. });
  167. return ret;
  168. }
  169. function stringifyStyle(styles) {
  170. let ret = "";
  171. if (!styles || isString$1(styles)) {
  172. return ret;
  173. }
  174. for (const key in styles) {
  175. const value = styles[key];
  176. if (isString$1(value) || typeof value === "number") {
  177. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  178. ret += `${normalizedKey}:${value};`;
  179. }
  180. }
  181. return ret;
  182. }
  183. function normalizeClass(value) {
  184. let res = "";
  185. if (isString$1(value)) {
  186. res = value;
  187. } else if (isArray$3(value)) {
  188. for (let i = 0; i < value.length; i++) {
  189. const normalized = normalizeClass(value[i]);
  190. if (normalized) {
  191. res += normalized + " ";
  192. }
  193. }
  194. } else if (isObject$2(value)) {
  195. for (const name in value) {
  196. if (value[name]) {
  197. res += name + " ";
  198. }
  199. }
  200. }
  201. return res.trim();
  202. }
  203. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  204. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  205. const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
  206. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  207. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  208. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  209. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  210. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  211. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  212. const isBooleanAttr = /* @__PURE__ */ makeMap(
  213. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  214. );
  215. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  216. const attrValidationCache = {};
  217. function isSSRSafeAttrName(name) {
  218. if (attrValidationCache.hasOwnProperty(name)) {
  219. return attrValidationCache[name];
  220. }
  221. const isUnsafe = unsafeAttrCharRE.test(name);
  222. if (isUnsafe) {
  223. console.error(`unsafe attribute name: ${name}`);
  224. }
  225. return attrValidationCache[name] = !isUnsafe;
  226. }
  227. const propsToAttrMap = {
  228. acceptCharset: "accept-charset",
  229. className: "class",
  230. htmlFor: "for",
  231. httpEquiv: "http-equiv"
  232. };
  233. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  234. `accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
  235. );
  236. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  237. `xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
  238. );
  239. const isKnownMathMLAttr = /* @__PURE__ */ makeMap(
  240. `accent,accentunder,actiontype,align,alignmentscope,altimg,altimg-height,altimg-valign,altimg-width,alttext,bevelled,close,columnsalign,columnlines,columnspan,denomalign,depth,dir,display,displaystyle,encoding,equalcolumns,equalrows,fence,fontstyle,fontweight,form,frame,framespacing,groupalign,height,href,id,indentalign,indentalignfirst,indentalignlast,indentshift,indentshiftfirst,indentshiftlast,indextype,justify,largetop,largeop,lquote,lspace,mathbackground,mathcolor,mathsize,mathvariant,maxsize,minlabelspacing,mode,other,overflow,position,rowalign,rowlines,rowspan,rquote,rspace,scriptlevel,scriptminsize,scriptsizemultiplier,selection,separator,separators,shift,side,src,stackalign,stretchy,subscriptshift,superscriptshift,symmetric,voffset,width,widths,xlink:href,xlink:show,xlink:type,xmlns`
  241. );
  242. const escapeRE = /["'&<>]/;
  243. function escapeHtml(string) {
  244. const str = "" + string;
  245. const match = escapeRE.exec(str);
  246. if (!match) {
  247. return str;
  248. }
  249. let html = "";
  250. let escaped;
  251. let index;
  252. let lastIndex = 0;
  253. for (index = match.index; index < str.length; index++) {
  254. switch (str.charCodeAt(index)) {
  255. case 34:
  256. escaped = "&quot;";
  257. break;
  258. case 38:
  259. escaped = "&amp;";
  260. break;
  261. case 39:
  262. escaped = "&#39;";
  263. break;
  264. case 60:
  265. escaped = "&lt;";
  266. break;
  267. case 62:
  268. escaped = "&gt;";
  269. break;
  270. default:
  271. continue;
  272. }
  273. if (lastIndex !== index) {
  274. html += str.slice(lastIndex, index);
  275. }
  276. lastIndex = index + 1;
  277. html += escaped;
  278. }
  279. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  280. }
  281. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  282. function getEscapedCssVarName(key, doubleEscape) {
  283. return key.replace(
  284. cssVarNameEscapeSymbolsRE,
  285. (s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
  286. );
  287. }
  288. const isRef = (val) => {
  289. return !!(val && val["__v_isRef"] === true);
  290. };
  291. const toDisplayString = (val) => {
  292. return isString$1(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$1(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
  293. };
  294. const replacer = (_key, val) => {
  295. if (isRef(val)) {
  296. return replacer(_key, val.value);
  297. } else if (isMap(val)) {
  298. return {
  299. [`Map(${val.size})`]: [...val.entries()].reduce(
  300. (entries, [key, val2], i) => {
  301. entries[stringifySymbol(key, i) + " =>"] = val2;
  302. return entries;
  303. },
  304. {}
  305. )
  306. };
  307. } else if (isSet(val)) {
  308. return {
  309. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  310. };
  311. } else if (isSymbol$1(val)) {
  312. return stringifySymbol(val);
  313. } else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
  314. return String(val);
  315. }
  316. return val;
  317. };
  318. const stringifySymbol = (v, i = "") => {
  319. var _a;
  320. return (
  321. // Symbol.description in es2019+ so we need to cast here to pass
  322. // the lib: es2016 check
  323. isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  324. );
  325. };
  326. const FRAGMENT = Symbol(`Fragment` );
  327. const TELEPORT = Symbol(`Teleport` );
  328. const SUSPENSE = Symbol(`Suspense` );
  329. const KEEP_ALIVE = Symbol(`KeepAlive` );
  330. const BASE_TRANSITION = Symbol(
  331. `BaseTransition`
  332. );
  333. const OPEN_BLOCK = Symbol(`openBlock` );
  334. const CREATE_BLOCK = Symbol(`createBlock` );
  335. const CREATE_ELEMENT_BLOCK = Symbol(
  336. `createElementBlock`
  337. );
  338. const CREATE_VNODE = Symbol(`createVNode` );
  339. const CREATE_ELEMENT_VNODE = Symbol(
  340. `createElementVNode`
  341. );
  342. const CREATE_COMMENT = Symbol(
  343. `createCommentVNode`
  344. );
  345. const CREATE_TEXT = Symbol(
  346. `createTextVNode`
  347. );
  348. const CREATE_STATIC = Symbol(
  349. `createStaticVNode`
  350. );
  351. const RESOLVE_COMPONENT = Symbol(
  352. `resolveComponent`
  353. );
  354. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  355. `resolveDynamicComponent`
  356. );
  357. const RESOLVE_DIRECTIVE = Symbol(
  358. `resolveDirective`
  359. );
  360. const RESOLVE_FILTER = Symbol(
  361. `resolveFilter`
  362. );
  363. const WITH_DIRECTIVES = Symbol(
  364. `withDirectives`
  365. );
  366. const RENDER_LIST = Symbol(`renderList` );
  367. const RENDER_SLOT = Symbol(`renderSlot` );
  368. const CREATE_SLOTS = Symbol(`createSlots` );
  369. const TO_DISPLAY_STRING = Symbol(
  370. `toDisplayString`
  371. );
  372. const MERGE_PROPS = Symbol(`mergeProps` );
  373. const NORMALIZE_CLASS = Symbol(
  374. `normalizeClass`
  375. );
  376. const NORMALIZE_STYLE = Symbol(
  377. `normalizeStyle`
  378. );
  379. const NORMALIZE_PROPS = Symbol(
  380. `normalizeProps`
  381. );
  382. const GUARD_REACTIVE_PROPS = Symbol(
  383. `guardReactiveProps`
  384. );
  385. const TO_HANDLERS = Symbol(`toHandlers` );
  386. const CAMELIZE = Symbol(`camelize` );
  387. const CAPITALIZE = Symbol(`capitalize` );
  388. const TO_HANDLER_KEY = Symbol(
  389. `toHandlerKey`
  390. );
  391. const SET_BLOCK_TRACKING = Symbol(
  392. `setBlockTracking`
  393. );
  394. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  395. const POP_SCOPE_ID = Symbol(`popScopeId` );
  396. const WITH_CTX = Symbol(`withCtx` );
  397. const UNREF = Symbol(`unref` );
  398. const IS_REF = Symbol(`isRef` );
  399. const WITH_MEMO = Symbol(`withMemo` );
  400. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  401. const helperNameMap = {
  402. [FRAGMENT]: `Fragment`,
  403. [TELEPORT]: `Teleport`,
  404. [SUSPENSE]: `Suspense`,
  405. [KEEP_ALIVE]: `KeepAlive`,
  406. [BASE_TRANSITION]: `BaseTransition`,
  407. [OPEN_BLOCK]: `openBlock`,
  408. [CREATE_BLOCK]: `createBlock`,
  409. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  410. [CREATE_VNODE]: `createVNode`,
  411. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  412. [CREATE_COMMENT]: `createCommentVNode`,
  413. [CREATE_TEXT]: `createTextVNode`,
  414. [CREATE_STATIC]: `createStaticVNode`,
  415. [RESOLVE_COMPONENT]: `resolveComponent`,
  416. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  417. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  418. [RESOLVE_FILTER]: `resolveFilter`,
  419. [WITH_DIRECTIVES]: `withDirectives`,
  420. [RENDER_LIST]: `renderList`,
  421. [RENDER_SLOT]: `renderSlot`,
  422. [CREATE_SLOTS]: `createSlots`,
  423. [TO_DISPLAY_STRING]: `toDisplayString`,
  424. [MERGE_PROPS]: `mergeProps`,
  425. [NORMALIZE_CLASS]: `normalizeClass`,
  426. [NORMALIZE_STYLE]: `normalizeStyle`,
  427. [NORMALIZE_PROPS]: `normalizeProps`,
  428. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  429. [TO_HANDLERS]: `toHandlers`,
  430. [CAMELIZE]: `camelize`,
  431. [CAPITALIZE]: `capitalize`,
  432. [TO_HANDLER_KEY]: `toHandlerKey`,
  433. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  434. [PUSH_SCOPE_ID]: `pushScopeId`,
  435. [POP_SCOPE_ID]: `popScopeId`,
  436. [WITH_CTX]: `withCtx`,
  437. [UNREF]: `unref`,
  438. [IS_REF]: `isRef`,
  439. [WITH_MEMO]: `withMemo`,
  440. [IS_MEMO_SAME]: `isMemoSame`
  441. };
  442. function registerRuntimeHelpers(helpers) {
  443. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  444. helperNameMap[s] = helpers[s];
  445. });
  446. }
  447. const Namespaces = {
  448. "HTML": 0,
  449. "0": "HTML",
  450. "SVG": 1,
  451. "1": "SVG",
  452. "MATH_ML": 2,
  453. "2": "MATH_ML"
  454. };
  455. const NodeTypes = {
  456. "ROOT": 0,
  457. "0": "ROOT",
  458. "ELEMENT": 1,
  459. "1": "ELEMENT",
  460. "TEXT": 2,
  461. "2": "TEXT",
  462. "COMMENT": 3,
  463. "3": "COMMENT",
  464. "SIMPLE_EXPRESSION": 4,
  465. "4": "SIMPLE_EXPRESSION",
  466. "INTERPOLATION": 5,
  467. "5": "INTERPOLATION",
  468. "ATTRIBUTE": 6,
  469. "6": "ATTRIBUTE",
  470. "DIRECTIVE": 7,
  471. "7": "DIRECTIVE",
  472. "COMPOUND_EXPRESSION": 8,
  473. "8": "COMPOUND_EXPRESSION",
  474. "IF": 9,
  475. "9": "IF",
  476. "IF_BRANCH": 10,
  477. "10": "IF_BRANCH",
  478. "FOR": 11,
  479. "11": "FOR",
  480. "TEXT_CALL": 12,
  481. "12": "TEXT_CALL",
  482. "VNODE_CALL": 13,
  483. "13": "VNODE_CALL",
  484. "JS_CALL_EXPRESSION": 14,
  485. "14": "JS_CALL_EXPRESSION",
  486. "JS_OBJECT_EXPRESSION": 15,
  487. "15": "JS_OBJECT_EXPRESSION",
  488. "JS_PROPERTY": 16,
  489. "16": "JS_PROPERTY",
  490. "JS_ARRAY_EXPRESSION": 17,
  491. "17": "JS_ARRAY_EXPRESSION",
  492. "JS_FUNCTION_EXPRESSION": 18,
  493. "18": "JS_FUNCTION_EXPRESSION",
  494. "JS_CONDITIONAL_EXPRESSION": 19,
  495. "19": "JS_CONDITIONAL_EXPRESSION",
  496. "JS_CACHE_EXPRESSION": 20,
  497. "20": "JS_CACHE_EXPRESSION",
  498. "JS_BLOCK_STATEMENT": 21,
  499. "21": "JS_BLOCK_STATEMENT",
  500. "JS_TEMPLATE_LITERAL": 22,
  501. "22": "JS_TEMPLATE_LITERAL",
  502. "JS_IF_STATEMENT": 23,
  503. "23": "JS_IF_STATEMENT",
  504. "JS_ASSIGNMENT_EXPRESSION": 24,
  505. "24": "JS_ASSIGNMENT_EXPRESSION",
  506. "JS_SEQUENCE_EXPRESSION": 25,
  507. "25": "JS_SEQUENCE_EXPRESSION",
  508. "JS_RETURN_STATEMENT": 26,
  509. "26": "JS_RETURN_STATEMENT"
  510. };
  511. const ElementTypes = {
  512. "ELEMENT": 0,
  513. "0": "ELEMENT",
  514. "COMPONENT": 1,
  515. "1": "COMPONENT",
  516. "SLOT": 2,
  517. "2": "SLOT",
  518. "TEMPLATE": 3,
  519. "3": "TEMPLATE"
  520. };
  521. const ConstantTypes = {
  522. "NOT_CONSTANT": 0,
  523. "0": "NOT_CONSTANT",
  524. "CAN_SKIP_PATCH": 1,
  525. "1": "CAN_SKIP_PATCH",
  526. "CAN_CACHE": 2,
  527. "2": "CAN_CACHE",
  528. "CAN_STRINGIFY": 3,
  529. "3": "CAN_STRINGIFY"
  530. };
  531. const locStub = {
  532. start: { line: 1, column: 1, offset: 0 },
  533. end: { line: 1, column: 1, offset: 0 },
  534. source: ""
  535. };
  536. function createRoot(children, source = "") {
  537. return {
  538. type: 0,
  539. source,
  540. children,
  541. helpers: /* @__PURE__ */ new Set(),
  542. components: [],
  543. directives: [],
  544. hoists: [],
  545. imports: [],
  546. cached: [],
  547. temps: 0,
  548. codegenNode: void 0,
  549. loc: locStub
  550. };
  551. }
  552. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  553. if (context) {
  554. if (isBlock) {
  555. context.helper(OPEN_BLOCK);
  556. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  557. } else {
  558. context.helper(getVNodeHelper(context.inSSR, isComponent));
  559. }
  560. if (directives) {
  561. context.helper(WITH_DIRECTIVES);
  562. }
  563. }
  564. return {
  565. type: 13,
  566. tag,
  567. props,
  568. children,
  569. patchFlag,
  570. dynamicProps,
  571. directives,
  572. isBlock,
  573. disableTracking,
  574. isComponent,
  575. loc
  576. };
  577. }
  578. function createArrayExpression(elements, loc = locStub) {
  579. return {
  580. type: 17,
  581. loc,
  582. elements
  583. };
  584. }
  585. function createObjectExpression(properties, loc = locStub) {
  586. return {
  587. type: 15,
  588. loc,
  589. properties
  590. };
  591. }
  592. function createObjectProperty(key, value) {
  593. return {
  594. type: 16,
  595. loc: locStub,
  596. key: isString$1(key) ? createSimpleExpression(key, true) : key,
  597. value
  598. };
  599. }
  600. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  601. return {
  602. type: 4,
  603. loc,
  604. content,
  605. isStatic,
  606. constType: isStatic ? 3 : constType
  607. };
  608. }
  609. function createInterpolation(content, loc) {
  610. return {
  611. type: 5,
  612. loc,
  613. content: isString$1(content) ? createSimpleExpression(content, false, loc) : content
  614. };
  615. }
  616. function createCompoundExpression(children, loc = locStub) {
  617. return {
  618. type: 8,
  619. loc,
  620. children
  621. };
  622. }
  623. function createCallExpression(callee, args = [], loc = locStub) {
  624. return {
  625. type: 14,
  626. loc,
  627. callee,
  628. arguments: args
  629. };
  630. }
  631. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  632. return {
  633. type: 18,
  634. params,
  635. returns,
  636. newline,
  637. isSlot,
  638. loc
  639. };
  640. }
  641. function createConditionalExpression(test, consequent, alternate, newline = true) {
  642. return {
  643. type: 19,
  644. test,
  645. consequent,
  646. alternate,
  647. newline,
  648. loc: locStub
  649. };
  650. }
  651. function createCacheExpression(index, value, needPauseTracking = false) {
  652. return {
  653. type: 20,
  654. index,
  655. value,
  656. needPauseTracking,
  657. needArraySpread: false,
  658. loc: locStub
  659. };
  660. }
  661. function createBlockStatement(body) {
  662. return {
  663. type: 21,
  664. body,
  665. loc: locStub
  666. };
  667. }
  668. function createTemplateLiteral(elements) {
  669. return {
  670. type: 22,
  671. elements,
  672. loc: locStub
  673. };
  674. }
  675. function createIfStatement(test, consequent, alternate) {
  676. return {
  677. type: 23,
  678. test,
  679. consequent,
  680. alternate,
  681. loc: locStub
  682. };
  683. }
  684. function createAssignmentExpression(left, right) {
  685. return {
  686. type: 24,
  687. left,
  688. right,
  689. loc: locStub
  690. };
  691. }
  692. function createSequenceExpression(expressions) {
  693. return {
  694. type: 25,
  695. expressions,
  696. loc: locStub
  697. };
  698. }
  699. function createReturnStatement(returns) {
  700. return {
  701. type: 26,
  702. returns,
  703. loc: locStub
  704. };
  705. }
  706. function getVNodeHelper(ssr, isComponent) {
  707. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  708. }
  709. function getVNodeBlockHelper(ssr, isComponent) {
  710. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  711. }
  712. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  713. if (!node.isBlock) {
  714. node.isBlock = true;
  715. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  716. helper(OPEN_BLOCK);
  717. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  718. }
  719. }
  720. // Generated using scripts/write-decode-map.ts
  721. var htmlDecodeTree = new Uint16Array(
  722. // prettier-ignore
  723. "\u1d41<\xd5\u0131\u028a\u049d\u057b\u05d0\u0675\u06de\u07a2\u07d6\u080f\u0a4a\u0a91\u0da1\u0e6d\u0f09\u0f26\u10ca\u1228\u12e1\u1415\u149d\u14c3\u14df\u1525\0\0\0\0\0\0\u156b\u16cd\u198d\u1c12\u1ddd\u1f7e\u2060\u21b0\u228d\u23c0\u23fb\u2442\u2824\u2912\u2d08\u2e48\u2fce\u3016\u32ba\u3639\u37ac\u38fe\u3a28\u3a71\u3ae0\u3b2e\u0800EMabcfglmnoprstu\\bfms\x7f\x84\x8b\x90\x95\x98\xa6\xb3\xb9\xc8\xcflig\u803b\xc6\u40c6P\u803b&\u4026cute\u803b\xc1\u40c1reve;\u4102\u0100iyx}rc\u803b\xc2\u40c2;\u4410r;\uc000\ud835\udd04rave\u803b\xc0\u40c0pha;\u4391acr;\u4100d;\u6a53\u0100gp\x9d\xa1on;\u4104f;\uc000\ud835\udd38plyFunction;\u6061ing\u803b\xc5\u40c5\u0100cs\xbe\xc3r;\uc000\ud835\udc9cign;\u6254ilde\u803b\xc3\u40c3ml\u803b\xc4\u40c4\u0400aceforsu\xe5\xfb\xfe\u0117\u011c\u0122\u0127\u012a\u0100cr\xea\xf2kslash;\u6216\u0176\xf6\xf8;\u6ae7ed;\u6306y;\u4411\u0180crt\u0105\u010b\u0114ause;\u6235noullis;\u612ca;\u4392r;\uc000\ud835\udd05pf;\uc000\ud835\udd39eve;\u42d8c\xf2\u0113mpeq;\u624e\u0700HOacdefhilorsu\u014d\u0151\u0156\u0180\u019e\u01a2\u01b5\u01b7\u01ba\u01dc\u0215\u0273\u0278\u027ecy;\u4427PY\u803b\xa9\u40a9\u0180cpy\u015d\u0162\u017aute;\u4106\u0100;i\u0167\u0168\u62d2talDifferentialD;\u6145leys;\u612d\u0200aeio\u0189\u018e\u0194\u0198ron;\u410cdil\u803b\xc7\u40c7rc;\u4108nint;\u6230ot;\u410a\u0100dn\u01a7\u01adilla;\u40b8terDot;\u40b7\xf2\u017fi;\u43a7rcle\u0200DMPT\u01c7\u01cb\u01d1\u01d6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01e2\u01f8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020foubleQuote;\u601duote;\u6019\u0200lnpu\u021e\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6a74\u0180git\u022f\u0236\u023aruent;\u6261nt;\u622fourIntegral;\u622e\u0100fr\u024c\u024e;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6a2fcr;\uc000\ud835\udc9ep\u0100;C\u0284\u0285\u62d3ap;\u624d\u0580DJSZacefios\u02a0\u02ac\u02b0\u02b4\u02b8\u02cb\u02d7\u02e1\u02e6\u0333\u048d\u0100;o\u0179\u02a5trahd;\u6911cy;\u4402cy;\u4405cy;\u440f\u0180grs\u02bf\u02c4\u02c7ger;\u6021r;\u61a1hv;\u6ae4\u0100ay\u02d0\u02d5ron;\u410e;\u4414l\u0100;t\u02dd\u02de\u6207a;\u4394r;\uc000\ud835\udd07\u0100af\u02eb\u0327\u0100cm\u02f0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031ccute;\u40b4o\u0174\u030b\u030d;\u42d9bleAcute;\u42ddrave;\u4060ilde;\u42dcond;\u62c4ferentialD;\u6146\u0470\u033d\0\0\0\u0342\u0354\0\u0405f;\uc000\ud835\udd3b\u0180;DE\u0348\u0349\u034d\u40a8ot;\u60dcqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03cf\u03e2\u03f8ontourIntegra\xec\u0239o\u0274\u0379\0\0\u037b\xbb\u0349nArrow;\u61d3\u0100eo\u0387\u03a4ft\u0180ART\u0390\u0396\u03a1rrow;\u61d0ightArrow;\u61d4e\xe5\u02cang\u0100LR\u03ab\u03c4eft\u0100AR\u03b3\u03b9rrow;\u67f8ightArrow;\u67faightArrow;\u67f9ight\u0100AT\u03d8\u03derrow;\u61d2ee;\u62a8p\u0241\u03e9\0\0\u03efrrow;\u61d1ownArrow;\u61d5erticalBar;\u6225n\u0300ABLRTa\u0412\u042a\u0430\u045e\u047f\u037crrow\u0180;BU\u041d\u041e\u0422\u6193ar;\u6913pArrow;\u61f5reve;\u4311eft\u02d2\u043a\0\u0446\0\u0450ightVector;\u6950eeVector;\u695eector\u0100;B\u0459\u045a\u61bdar;\u6956ight\u01d4\u0467\0\u0471eeVector;\u695fector\u0100;B\u047a\u047b\u61c1ar;\u6957ee\u0100;A\u0486\u0487\u62a4rrow;\u61a7\u0100ct\u0492\u0497r;\uc000\ud835\udc9frok;\u4110\u0800NTacdfglmopqstux\u04bd\u04c0\u04c4\u04cb\u04de\u04e2\u04e7\u04ee\u04f5\u0521\u052f\u0536\u0552\u055d\u0560\u0565G;\u414aH\u803b\xd0\u40d0cute\u803b\xc9\u40c9\u0180aiy\u04d2\u04d7\u04dcron;\u411arc\u803b\xca\u40ca;\u442dot;\u4116r;\uc000\ud835\udd08rave\u803b\xc8\u40c8ement;\u6208\u0100ap\u04fa\u04fecr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65fberySmallSquare;\u65ab\u0100gp\u0526\u052aon;\u4118f;\uc000\ud835\udd3csilon;\u4395u\u0100ai\u053c\u0549l\u0100;T\u0542\u0543\u6a75ilde;\u6242librium;\u61cc\u0100ci\u0557\u055ar;\u6130m;\u6a73a;\u4397ml\u803b\xcb\u40cb\u0100ip\u056a\u056fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058d\u05b2\u05ccy;\u4424r;\uc000\ud835\udd09lled\u0253\u0597\0\0\u05a3mallSquare;\u65fcerySmallSquare;\u65aa\u0370\u05ba\0\u05bf\0\0\u05c4f;\uc000\ud835\udd3dAll;\u6200riertrf;\u6131c\xf2\u05cb\u0600JTabcdfgorst\u05e8\u05ec\u05ef\u05fa\u0600\u0612\u0616\u061b\u061d\u0623\u066c\u0672cy;\u4403\u803b>\u403emma\u0100;d\u05f7\u05f8\u4393;\u43dcreve;\u411e\u0180eiy\u0607\u060c\u0610dil;\u4122rc;\u411c;\u4413ot;\u4120r;\uc000\ud835\udd0a;\u62d9pf;\uc000\ud835\udd3eeater\u0300EFGLST\u0635\u0644\u064e\u0656\u065b\u0666qual\u0100;L\u063e\u063f\u6265ess;\u62dbullEqual;\u6267reater;\u6aa2ess;\u6277lantEqual;\u6a7eilde;\u6273cr;\uc000\ud835\udca2;\u626b\u0400Aacfiosu\u0685\u068b\u0696\u069b\u069e\u06aa\u06be\u06caRDcy;\u442a\u0100ct\u0690\u0694ek;\u42c7;\u405eirc;\u4124r;\u610clbertSpace;\u610b\u01f0\u06af\0\u06b2f;\u610dizontalLine;\u6500\u0100ct\u06c3\u06c5\xf2\u06a9rok;\u4126mp\u0144\u06d0\u06d8ownHum\xf0\u012fqual;\u624f\u0700EJOacdfgmnostu\u06fa\u06fe\u0703\u0707\u070e\u071a\u071e\u0721\u0728\u0744\u0778\u078b\u078f\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803b\xcd\u40cd\u0100iy\u0713\u0718rc\u803b\xce\u40ce;\u4418ot;\u4130r;\u6111rave\u803b\xcc\u40cc\u0180;ap\u0720\u072f\u073f\u0100cg\u0734\u0737r;\u412ainaryI;\u6148lie\xf3\u03dd\u01f4\u0749\0\u0762\u0100;e\u074d\u074e\u622c\u0100gr\u0753\u0758ral;\u622bsection;\u62c2isible\u0100CT\u076c\u0772omma;\u6063imes;\u6062\u0180gpt\u077f\u0783\u0788on;\u412ef;\uc000\ud835\udd40a;\u4399cr;\u6110ilde;\u4128\u01eb\u079a\0\u079ecy;\u4406l\u803b\xcf\u40cf\u0280cfosu\u07ac\u07b7\u07bc\u07c2\u07d0\u0100iy\u07b1\u07b5rc;\u4134;\u4419r;\uc000\ud835\udd0dpf;\uc000\ud835\udd41\u01e3\u07c7\0\u07ccr;\uc000\ud835\udca5rcy;\u4408kcy;\u4404\u0380HJacfos\u07e4\u07e8\u07ec\u07f1\u07fd\u0802\u0808cy;\u4425cy;\u440cppa;\u439a\u0100ey\u07f6\u07fbdil;\u4136;\u441ar;\uc000\ud835\udd0epf;\uc000\ud835\udd42cr;\uc000\ud835\udca6\u0580JTaceflmost\u0825\u0829\u082c\u0850\u0863\u09b3\u09b8\u09c7\u09cd\u0a37\u0a47cy;\u4409\u803b<\u403c\u0280cmnpr\u0837\u083c\u0841\u0844\u084dute;\u4139bda;\u439bg;\u67ealacetrf;\u6112r;\u619e\u0180aey\u0857\u085c\u0861ron;\u413ddil;\u413b;\u441b\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087e\u08a9\u08b1\u08e0\u08e6\u08fc\u092f\u095b\u0390\u096a\u0100nr\u0883\u088fgleBracket;\u67e8row\u0180;BR\u0899\u089a\u089e\u6190ar;\u61e4ightArrow;\u61c6eiling;\u6308o\u01f5\u08b7\0\u08c3bleBracket;\u67e6n\u01d4\u08c8\0\u08d2eeVector;\u6961ector\u0100;B\u08db\u08dc\u61c3ar;\u6959loor;\u630aight\u0100AV\u08ef\u08f5rrow;\u6194ector;\u694e\u0100er\u0901\u0917e\u0180;AV\u0909\u090a\u0910\u62a3rrow;\u61a4ector;\u695aiangle\u0180;BE\u0924\u0925\u0929\u62b2ar;\u69cfqual;\u62b4p\u0180DTV\u0937\u0942\u094cownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61bfar;\u6958ector\u0100;B\u0965\u0966\u61bcar;\u6952ight\xe1\u039cs\u0300EFGLST\u097e\u098b\u0995\u099d\u09a2\u09adqualGreater;\u62daullEqual;\u6266reater;\u6276ess;\u6aa1lantEqual;\u6a7dilde;\u6272r;\uc000\ud835\udd0f\u0100;e\u09bd\u09be\u62d8ftarrow;\u61daidot;\u413f\u0180npw\u09d4\u0a16\u0a1bg\u0200LRlr\u09de\u09f7\u0a02\u0a10eft\u0100AR\u09e6\u09ecrrow;\u67f5ightArrow;\u67f7ightArrow;\u67f6eft\u0100ar\u03b3\u0a0aight\xe1\u03bfight\xe1\u03caf;\uc000\ud835\udd43er\u0100LR\u0a22\u0a2ceftArrow;\u6199ightArrow;\u6198\u0180cht\u0a3e\u0a40\u0a42\xf2\u084c;\u61b0rok;\u4141;\u626a\u0400acefiosu\u0a5a\u0a5d\u0a60\u0a77\u0a7c\u0a85\u0a8b\u0a8ep;\u6905y;\u441c\u0100dl\u0a65\u0a6fiumSpace;\u605flintrf;\u6133r;\uc000\ud835\udd10nusPlus;\u6213pf;\uc000\ud835\udd44c\xf2\u0a76;\u439c\u0480Jacefostu\u0aa3\u0aa7\u0aad\u0ac0\u0b14\u0b19\u0d91\u0d97\u0d9ecy;\u440acute;\u4143\u0180aey\u0ab4\u0ab9\u0aberon;\u4147dil;\u4145;\u441d\u0180gsw\u0ac7\u0af0\u0b0eative\u0180MTV\u0ad3\u0adf\u0ae8ediumSpace;\u600bhi\u0100cn\u0ae6\u0ad8\xeb\u0ad9eryThi\xee\u0ad9ted\u0100GL\u0af8\u0b06reaterGreate\xf2\u0673essLes\xf3\u0a48Line;\u400ar;\uc000\ud835\udd11\u0200Bnpt\u0b22\u0b28\u0b37\u0b3areak;\u6060BreakingSpace;\u40a0f;\u6115\u0680;CDEGHLNPRSTV\u0b55\u0b56\u0b6a\u0b7c\u0ba1\u0beb\u0c04\u0c5e\u0c84\u0ca6\u0cd8\u0d61\u0d85\u6aec\u0100ou\u0b5b\u0b64ngruent;\u6262pCap;\u626doubleVerticalBar;\u6226\u0180lqx\u0b83\u0b8a\u0b9bement;\u6209ual\u0100;T\u0b92\u0b93\u6260ilde;\uc000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0bb6\u0bb7\u0bbd\u0bc9\u0bd3\u0bd8\u0be5\u626fqual;\u6271ullEqual;\uc000\u2267\u0338reater;\uc000\u226b\u0338ess;\u6279lantEqual;\uc000\u2a7e\u0338ilde;\u6275ump\u0144\u0bf2\u0bfdownHump;\uc000\u224e\u0338qual;\uc000\u224f\u0338e\u0100fs\u0c0a\u0c27tTriangle\u0180;BE\u0c1a\u0c1b\u0c21\u62eaar;\uc000\u29cf\u0338qual;\u62ecs\u0300;EGLST\u0c35\u0c36\u0c3c\u0c44\u0c4b\u0c58\u626equal;\u6270reater;\u6278ess;\uc000\u226a\u0338lantEqual;\uc000\u2a7d\u0338ilde;\u6274ested\u0100GL\u0c68\u0c79reaterGreater;\uc000\u2aa2\u0338essLess;\uc000\u2aa1\u0338recedes\u0180;ES\u0c92\u0c93\u0c9b\u6280qual;\uc000\u2aaf\u0338lantEqual;\u62e0\u0100ei\u0cab\u0cb9verseElement;\u620cghtTriangle\u0180;BE\u0ccb\u0ccc\u0cd2\u62ebar;\uc000\u29d0\u0338qual;\u62ed\u0100qu\u0cdd\u0d0cuareSu\u0100bp\u0ce8\u0cf9set\u0100;E\u0cf0\u0cf3\uc000\u228f\u0338qual;\u62e2erset\u0100;E\u0d03\u0d06\uc000\u2290\u0338qual;\u62e3\u0180bcp\u0d13\u0d24\u0d4eset\u0100;E\u0d1b\u0d1e\uc000\u2282\u20d2qual;\u6288ceeds\u0200;EST\u0d32\u0d33\u0d3b\u0d46\u6281qual;\uc000\u2ab0\u0338lantEqual;\u62e1ilde;\uc000\u227f\u0338erset\u0100;E\u0d58\u0d5b\uc000\u2283\u20d2qual;\u6289ilde\u0200;EFT\u0d6e\u0d6f\u0d75\u0d7f\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uc000\ud835\udca9ilde\u803b\xd1\u40d1;\u439d\u0700Eacdfgmoprstuv\u0dbd\u0dc2\u0dc9\u0dd5\u0ddb\u0de0\u0de7\u0dfc\u0e02\u0e20\u0e22\u0e32\u0e3f\u0e44lig;\u4152cute\u803b\xd3\u40d3\u0100iy\u0dce\u0dd3rc\u803b\xd4\u40d4;\u441eblac;\u4150r;\uc000\ud835\udd12rave\u803b\xd2\u40d2\u0180aei\u0dee\u0df2\u0df6cr;\u414cga;\u43a9cron;\u439fpf;\uc000\ud835\udd46enCurly\u0100DQ\u0e0e\u0e1aoubleQuote;\u601cuote;\u6018;\u6a54\u0100cl\u0e27\u0e2cr;\uc000\ud835\udcaaash\u803b\xd8\u40d8i\u016c\u0e37\u0e3cde\u803b\xd5\u40d5es;\u6a37ml\u803b\xd6\u40d6er\u0100BP\u0e4b\u0e60\u0100ar\u0e50\u0e53r;\u603eac\u0100ek\u0e5a\u0e5c;\u63deet;\u63b4arenthesis;\u63dc\u0480acfhilors\u0e7f\u0e87\u0e8a\u0e8f\u0e92\u0e94\u0e9d\u0eb0\u0efcrtialD;\u6202y;\u441fr;\uc000\ud835\udd13i;\u43a6;\u43a0usMinus;\u40b1\u0100ip\u0ea2\u0eadncareplan\xe5\u069df;\u6119\u0200;eio\u0eb9\u0eba\u0ee0\u0ee4\u6abbcedes\u0200;EST\u0ec8\u0ec9\u0ecf\u0eda\u627aqual;\u6aaflantEqual;\u627cilde;\u627eme;\u6033\u0100dp\u0ee9\u0eeeuct;\u620fortion\u0100;a\u0225\u0ef9l;\u621d\u0100ci\u0f01\u0f06r;\uc000\ud835\udcab;\u43a8\u0200Ufos\u0f11\u0f16\u0f1b\u0f1fOT\u803b\"\u4022r;\uc000\ud835\udd14pf;\u611acr;\uc000\ud835\udcac\u0600BEacefhiorsu\u0f3e\u0f43\u0f47\u0f60\u0f73\u0fa7\u0faa\u0fad\u1096\u10a9\u10b4\u10bearr;\u6910G\u803b\xae\u40ae\u0180cnr\u0f4e\u0f53\u0f56ute;\u4154g;\u67ebr\u0100;t\u0f5c\u0f5d\u61a0l;\u6916\u0180aey\u0f67\u0f6c\u0f71ron;\u4158dil;\u4156;\u4420\u0100;v\u0f78\u0f79\u611cerse\u0100EU\u0f82\u0f99\u0100lq\u0f87\u0f8eement;\u620builibrium;\u61cbpEquilibrium;\u696fr\xbb\u0f79o;\u43a1ght\u0400ACDFTUVa\u0fc1\u0feb\u0ff3\u1022\u1028\u105b\u1087\u03d8\u0100nr\u0fc6\u0fd2gleBracket;\u67e9row\u0180;BL\u0fdc\u0fdd\u0fe1\u6192ar;\u61e5eftArrow;\u61c4eiling;\u6309o\u01f5\u0ff9\0\u1005bleBracket;\u67e7n\u01d4\u100a\0\u1014eeVector;\u695dector\u0100;B\u101d\u101e\u61c2ar;\u6955loor;\u630b\u0100er\u102d\u1043e\u0180;AV\u1035\u1036\u103c\u62a2rrow;\u61a6ector;\u695biangle\u0180;BE\u1050\u1051\u1055\u62b3ar;\u69d0qual;\u62b5p\u0180DTV\u1063\u106e\u1078ownVector;\u694feeVector;\u695cector\u0100;B\u1082\u1083\u61bear;\u6954ector\u0100;B\u1091\u1092\u61c0ar;\u6953\u0100pu\u109b\u109ef;\u611dndImplies;\u6970ightarrow;\u61db\u0100ch\u10b9\u10bcr;\u611b;\u61b1leDelayed;\u69f4\u0680HOacfhimoqstu\u10e4\u10f1\u10f7\u10fd\u1119\u111e\u1151\u1156\u1161\u1167\u11b5\u11bb\u11bf\u0100Cc\u10e9\u10eeHcy;\u4429y;\u4428FTcy;\u442ccute;\u415a\u0280;aeiy\u1108\u1109\u110e\u1113\u1117\u6abcron;\u4160dil;\u415erc;\u415c;\u4421r;\uc000\ud835\udd16ort\u0200DLRU\u112a\u1134\u113e\u1149ownArrow\xbb\u041eeftArrow\xbb\u089aightArrow\xbb\u0fddpArrow;\u6191gma;\u43a3allCircle;\u6218pf;\uc000\ud835\udd4a\u0272\u116d\0\0\u1170t;\u621aare\u0200;ISU\u117b\u117c\u1189\u11af\u65a1ntersection;\u6293u\u0100bp\u118f\u119eset\u0100;E\u1197\u1198\u628fqual;\u6291erset\u0100;E\u11a8\u11a9\u6290qual;\u6292nion;\u6294cr;\uc000\ud835\udcaear;\u62c6\u0200bcmp\u11c8\u11db\u1209\u120b\u0100;s\u11cd\u11ce\u62d0et\u0100;E\u11cd\u11d5qual;\u6286\u0100ch\u11e0\u1205eeds\u0200;EST\u11ed\u11ee\u11f4\u11ff\u627bqual;\u6ab0lantEqual;\u627dilde;\u627fTh\xe1\u0f8c;\u6211\u0180;es\u1212\u1213\u1223\u62d1rset\u0100;E\u121c\u121d\u6283qual;\u6287et\xbb\u1213\u0580HRSacfhiors\u123e\u1244\u1249\u1255\u125e\u1271\u1276\u129f\u12c2\u12c8\u12d1ORN\u803b\xde\u40deADE;\u6122\u0100Hc\u124e\u1252cy;\u440by;\u4426\u0100bu\u125a\u125c;\u4009;\u43a4\u0180aey\u1265\u126a\u126fron;\u4164dil;\u4162;\u4422r;\uc000\ud835\udd17\u0100ei\u127b\u1289\u01f2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128e\u1298kSpace;\uc000\u205f\u200aSpace;\u6009lde\u0200;EFT\u12ab\u12ac\u12b2\u12bc\u623cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uc000\ud835\udd4bipleDot;\u60db\u0100ct\u12d6\u12dbr;\uc000\ud835\udcafrok;\u4166\u0ae1\u12f7\u130e\u131a\u1326\0\u132c\u1331\0\0\0\0\0\u1338\u133d\u1377\u1385\0\u13ff\u1404\u140a\u1410\u0100cr\u12fb\u1301ute\u803b\xda\u40dar\u0100;o\u1307\u1308\u619fcir;\u6949r\u01e3\u1313\0\u1316y;\u440eve;\u416c\u0100iy\u131e\u1323rc\u803b\xdb\u40db;\u4423blac;\u4170r;\uc000\ud835\udd18rave\u803b\xd9\u40d9acr;\u416a\u0100di\u1341\u1369er\u0100BP\u1348\u135d\u0100ar\u134d\u1350r;\u405fac\u0100ek\u1357\u1359;\u63dfet;\u63b5arenthesis;\u63ddon\u0100;P\u1370\u1371\u62c3lus;\u628e\u0100gp\u137b\u137fon;\u4172f;\uc000\ud835\udd4c\u0400ADETadps\u1395\u13ae\u13b8\u13c4\u03e8\u13d2\u13d7\u13f3rrow\u0180;BD\u1150\u13a0\u13a4ar;\u6912ownArrow;\u61c5ownArrow;\u6195quilibrium;\u696eee\u0100;A\u13cb\u13cc\u62a5rrow;\u61a5own\xe1\u03f3er\u0100LR\u13de\u13e8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13f9\u13fa\u43d2on;\u43a5ing;\u416ecr;\uc000\ud835\udcb0ilde;\u4168ml\u803b\xdc\u40dc\u0480Dbcdefosv\u1427\u142c\u1430\u1433\u143e\u1485\u148a\u1490\u1496ash;\u62abar;\u6aeby;\u4412ash\u0100;l\u143b\u143c\u62a9;\u6ae6\u0100er\u1443\u1445;\u62c1\u0180bty\u144c\u1450\u147aar;\u6016\u0100;i\u144f\u1455cal\u0200BLST\u1461\u1465\u146a\u1474ar;\u6223ine;\u407ceparator;\u6758ilde;\u6240ThinSpace;\u600ar;\uc000\ud835\udd19pf;\uc000\ud835\udd4dcr;\uc000\ud835\udcb1dash;\u62aa\u0280cefos\u14a7\u14ac\u14b1\u14b6\u14bcirc;\u4174dge;\u62c0r;\uc000\ud835\udd1apf;\uc000\ud835\udd4ecr;\uc000\ud835\udcb2\u0200fios\u14cb\u14d0\u14d2\u14d8r;\uc000\ud835\udd1b;\u439epf;\uc000\ud835\udd4fcr;\uc000\ud835\udcb3\u0480AIUacfosu\u14f1\u14f5\u14f9\u14fd\u1504\u150f\u1514\u151a\u1520cy;\u442fcy;\u4407cy;\u442ecute\u803b\xdd\u40dd\u0100iy\u1509\u150drc;\u4176;\u442br;\uc000\ud835\udd1cpf;\uc000\ud835\udd50cr;\uc000\ud835\udcb4ml;\u4178\u0400Hacdefos\u1535\u1539\u153f\u154b\u154f\u155d\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417d;\u4417ot;\u417b\u01f2\u1554\0\u155boWidt\xe8\u0ad9a;\u4396r;\u6128pf;\u6124cr;\uc000\ud835\udcb5\u0be1\u1583\u158a\u1590\0\u15b0\u15b6\u15bf\0\0\0\0\u15c6\u15db\u15eb\u165f\u166d\0\u1695\u169b\u16b2\u16b9\0\u16becute\u803b\xe1\u40e1reve;\u4103\u0300;Ediuy\u159c\u159d\u15a1\u15a3\u15a8\u15ad\u623e;\uc000\u223e\u0333;\u623frc\u803b\xe2\u40e2te\u80bb\xb4\u0306;\u4430lig\u803b\xe6\u40e6\u0100;r\xb2\u15ba;\uc000\ud835\udd1erave\u803b\xe0\u40e0\u0100ep\u15ca\u15d6\u0100fp\u15cf\u15d4sym;\u6135\xe8\u15d3ha;\u43b1\u0100ap\u15dfc\u0100cl\u15e4\u15e7r;\u4101g;\u6a3f\u0264\u15f0\0\0\u160a\u0280;adsv\u15fa\u15fb\u15ff\u1601\u1607\u6227nd;\u6a55;\u6a5clope;\u6a58;\u6a5a\u0380;elmrsz\u1618\u1619\u161b\u161e\u163f\u164f\u1659\u6220;\u69a4e\xbb\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163a\u163c\u163e;\u69a8;\u69a9;\u69aa;\u69ab;\u69ac;\u69ad;\u69ae;\u69aft\u0100;v\u1645\u1646\u621fb\u0100;d\u164c\u164d\u62be;\u699d\u0100pt\u1654\u1657h;\u6222\xbb\xb9arr;\u637c\u0100gp\u1663\u1667on;\u4105f;\uc000\ud835\udd52\u0380;Eaeiop\u12c1\u167b\u167d\u1682\u1684\u1687\u168a;\u6a70cir;\u6a6f;\u624ad;\u624bs;\u4027rox\u0100;e\u12c1\u1692\xf1\u1683ing\u803b\xe5\u40e5\u0180cty\u16a1\u16a6\u16a8r;\uc000\ud835\udcb6;\u402amp\u0100;e\u12c1\u16af\xf1\u0288ilde\u803b\xe3\u40e3ml\u803b\xe4\u40e4\u0100ci\u16c2\u16c8onin\xf4\u0272nt;\u6a11\u0800Nabcdefiklnoprsu\u16ed\u16f1\u1730\u173c\u1743\u1748\u1778\u177d\u17e0\u17e6\u1839\u1850\u170d\u193d\u1948\u1970ot;\u6aed\u0100cr\u16f6\u171ek\u0200ceps\u1700\u1705\u170d\u1713ong;\u624cpsilon;\u43f6rime;\u6035im\u0100;e\u171a\u171b\u623dq;\u62cd\u0176\u1722\u1726ee;\u62bded\u0100;g\u172c\u172d\u6305e\xbb\u172drk\u0100;t\u135c\u1737brk;\u63b6\u0100oy\u1701\u1741;\u4431quo;\u601e\u0280cmprt\u1753\u175b\u1761\u1764\u1768aus\u0100;e\u010a\u0109ptyv;\u69b0s\xe9\u170cno\xf5\u0113\u0180ahw\u176f\u1771\u1773;\u43b2;\u6136een;\u626cr;\uc000\ud835\udd1fg\u0380costuvw\u178d\u179d\u17b3\u17c1\u17d5\u17db\u17de\u0180aiu\u1794\u1796\u179a\xf0\u0760rc;\u65efp\xbb\u1371\u0180dpt\u17a4\u17a8\u17adot;\u6a00lus;\u6a01imes;\u6a02\u0271\u17b9\0\0\u17becup;\u6a06ar;\u6605riangle\u0100du\u17cd\u17d2own;\u65bdp;\u65b3plus;\u6a04e\xe5\u1444\xe5\u14adarow;\u690d\u0180ako\u17ed\u1826\u1835\u0100cn\u17f2\u1823k\u0180lst\u17fa\u05ab\u1802ozenge;\u69ebriangle\u0200;dlr\u1812\u1813\u1818\u181d\u65b4own;\u65beeft;\u65c2ight;\u65b8k;\u6423\u01b1\u182b\0\u1833\u01b2\u182f\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183e\u184d\u0100;q\u1843\u1846\uc000=\u20e5uiv;\uc000\u2261\u20e5t;\u6310\u0200ptwx\u1859\u185e\u1867\u186cf;\uc000\ud835\udd53\u0100;t\u13cb\u1863om\xbb\u13cctie;\u62c8\u0600DHUVbdhmptuv\u1885\u1896\u18aa\u18bb\u18d7\u18db\u18ec\u18ff\u1905\u190a\u1910\u1921\u0200LRlr\u188e\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18a1\u18a2\u18a4\u18a6\u18a8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18b3\u18b5\u18b7\u18b9;\u655d;\u655a;\u655c;\u6559\u0380;HLRhlr\u18ca\u18cb\u18cd\u18cf\u18d1\u18d3\u18d5\u6551;\u656c;\u6563;\u6560;\u656b;\u6562;\u655fox;\u69c9\u0200LRlr\u18e4\u18e6\u18e8\u18ea;\u6555;\u6552;\u6510;\u650c\u0280;DUdu\u06bd\u18f7\u18f9\u18fb\u18fd;\u6565;\u6568;\u652c;\u6534inus;\u629flus;\u629eimes;\u62a0\u0200LRlr\u1919\u191b\u191d\u191f;\u655b;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193b\u6502;\u656a;\u6561;\u655e;\u653c;\u6524;\u651c\u0100ev\u0123\u1942bar\u803b\xa6\u40a6\u0200ceio\u1951\u1956\u195a\u1960r;\uc000\ud835\udcb7mi;\u604fm\u0100;e\u171a\u171cl\u0180;bh\u1968\u1969\u196b\u405c;\u69c5sub;\u67c8\u016c\u1974\u197el\u0100;e\u1979\u197a\u6022t\xbb\u197ap\u0180;Ee\u012f\u1985\u1987;\u6aae\u0100;q\u06dc\u06db\u0ce1\u19a7\0\u19e8\u1a11\u1a15\u1a32\0\u1a37\u1a50\0\0\u1ab4\0\0\u1ac1\0\0\u1b21\u1b2e\u1b4d\u1b52\0\u1bfd\0\u1c0c\u0180cpr\u19ad\u19b2\u19ddute;\u4107\u0300;abcds\u19bf\u19c0\u19c4\u19ca\u19d5\u19d9\u6229nd;\u6a44rcup;\u6a49\u0100au\u19cf\u19d2p;\u6a4bp;\u6a47ot;\u6a40;\uc000\u2229\ufe00\u0100eo\u19e2\u19e5t;\u6041\xee\u0693\u0200aeiu\u19f0\u19fb\u1a01\u1a05\u01f0\u19f5\0\u19f8s;\u6a4don;\u410ddil\u803b\xe7\u40e7rc;\u4109ps\u0100;s\u1a0c\u1a0d\u6a4cm;\u6a50ot;\u410b\u0180dmn\u1a1b\u1a20\u1a26il\u80bb\xb8\u01adptyv;\u69b2t\u8100\xa2;e\u1a2d\u1a2e\u40a2r\xe4\u01b2r;\uc000\ud835\udd20\u0180cei\u1a3d\u1a40\u1a4dy;\u4447ck\u0100;m\u1a47\u1a48\u6713ark\xbb\u1a48;\u43c7r\u0380;Ecefms\u1a5f\u1a60\u1a62\u1a6b\u1aa4\u1aaa\u1aae\u65cb;\u69c3\u0180;el\u1a69\u1a6a\u1a6d\u42c6q;\u6257e\u0261\u1a74\0\0\u1a88rrow\u0100lr\u1a7c\u1a81eft;\u61baight;\u61bb\u0280RSacd\u1a92\u1a94\u1a96\u1a9a\u1a9f\xbb\u0f47;\u64c8st;\u629birc;\u629aash;\u629dnint;\u6a10id;\u6aefcir;\u69c2ubs\u0100;u\u1abb\u1abc\u6663it\xbb\u1abc\u02ec\u1ac7\u1ad4\u1afa\0\u1b0aon\u0100;e\u1acd\u1ace\u403a\u0100;q\xc7\xc6\u026d\u1ad9\0\0\u1ae2a\u0100;t\u1ade\u1adf\u402c;\u4040\u0180;fl\u1ae8\u1ae9\u1aeb\u6201\xee\u1160e\u0100mx\u1af1\u1af6ent\xbb\u1ae9e\xf3\u024d\u01e7\u1afe\0\u1b07\u0100;d\u12bb\u1b02ot;\u6a6dn\xf4\u0246\u0180fry\u1b10\u1b14\u1b17;\uc000\ud835\udd54o\xe4\u0254\u8100\xa9;s\u0155\u1b1dr;\u6117\u0100ao\u1b25\u1b29rr;\u61b5ss;\u6717\u0100cu\u1b32\u1b37r;\uc000\ud835\udcb8\u0100bp\u1b3c\u1b44\u0100;e\u1b41\u1b42\u6acf;\u6ad1\u0100;e\u1b49\u1b4a\u6ad0;\u6ad2dot;\u62ef\u0380delprvw\u1b60\u1b6c\u1b77\u1b82\u1bac\u1bd4\u1bf9arr\u0100lr\u1b68\u1b6a;\u6938;\u6935\u0270\u1b72\0\0\u1b75r;\u62dec;\u62dfarr\u0100;p\u1b7f\u1b80\u61b6;\u693d\u0300;bcdos\u1b8f\u1b90\u1b96\u1ba1\u1ba5\u1ba8\u622arcap;\u6a48\u0100au\u1b9b\u1b9ep;\u6a46p;\u6a4aot;\u628dr;\u6a45;\uc000\u222a\ufe00\u0200alrv\u1bb5\u1bbf\u1bde\u1be3rr\u0100;m\u1bbc\u1bbd\u61b7;\u693cy\u0180evw\u1bc7\u1bd4\u1bd8q\u0270\u1bce\0\0\u1bd2re\xe3\u1b73u\xe3\u1b75ee;\u62ceedge;\u62cfen\u803b\xa4\u40a4earrow\u0100lr\u1bee\u1bf3eft\xbb\u1b80ight\xbb\u1bbde\xe4\u1bdd\u0100ci\u1c01\u1c07onin\xf4\u01f7nt;\u6231lcty;\u632d\u0980AHabcdefhijlorstuwz\u1c38\u1c3b\u1c3f\u1c5d\u1c69\u1c75\u1c8a\u1c9e\u1cac\u1cb7\u1cfb\u1cff\u1d0d\u1d7b\u1d91\u1dab\u1dbb\u1dc6\u1dcdr\xf2\u0381ar;\u6965\u0200glrs\u1c48\u1c4d\u1c52\u1c54ger;\u6020eth;\u6138\xf2\u1133h\u0100;v\u1c5a\u1c5b\u6010\xbb\u090a\u016b\u1c61\u1c67arow;\u690fa\xe3\u0315\u0100ay\u1c6e\u1c73ron;\u410f;\u4434\u0180;ao\u0332\u1c7c\u1c84\u0100gr\u02bf\u1c81r;\u61catseq;\u6a77\u0180glm\u1c91\u1c94\u1c98\u803b\xb0\u40b0ta;\u43b4ptyv;\u69b1\u0100ir\u1ca3\u1ca8sht;\u697f;\uc000\ud835\udd21ar\u0100lr\u1cb3\u1cb5\xbb\u08dc\xbb\u101e\u0280aegsv\u1cc2\u0378\u1cd6\u1cdc\u1ce0m\u0180;os\u0326\u1cca\u1cd4nd\u0100;s\u0326\u1cd1uit;\u6666amma;\u43ddin;\u62f2\u0180;io\u1ce7\u1ce8\u1cf8\u40f7de\u8100\xf7;o\u1ce7\u1cf0ntimes;\u62c7n\xf8\u1cf7cy;\u4452c\u026f\u1d06\0\0\u1d0arn;\u631eop;\u630d\u0280lptuw\u1d18\u1d1d\u1d22\u1d49\u1d55lar;\u4024f;\uc000\ud835\udd55\u0280;emps\u030b\u1d2d\u1d37\u1d3d\u1d42q\u0100;d\u0352\u1d33ot;\u6251inus;\u6238lus;\u6214quare;\u62a1blebarwedg\xe5\xfan\u0180adh\u112e\u1d5d\u1d67ownarrow\xf3\u1c83arpoon\u0100lr\u1d72\u1d76ef\xf4\u1cb4igh\xf4\u1cb6\u0162\u1d7f\u1d85karo\xf7\u0f42\u026f\u1d8a\0\0\u1d8ern;\u631fop;\u630c\u0180cot\u1d98\u1da3\u1da6\u0100ry\u1d9d\u1da1;\uc000\ud835\udcb9;\u4455l;\u69f6rok;\u4111\u0100dr\u1db0\u1db4ot;\u62f1i\u0100;f\u1dba\u1816\u65bf\u0100ah\u1dc0\u1dc3r\xf2\u0429a\xf2\u0fa6angle;\u69a6\u0100ci\u1dd2\u1dd5y;\u445fgrarr;\u67ff\u0900Dacdefglmnopqrstux\u1e01\u1e09\u1e19\u1e38\u0578\u1e3c\u1e49\u1e61\u1e7e\u1ea5\u1eaf\u1ebd\u1ee1\u1f2a\u1f37\u1f44\u1f4e\u1f5a\u0100Do\u1e06\u1d34o\xf4\u1c89\u0100cs\u1e0e\u1e14ute\u803b\xe9\u40e9ter;\u6a6e\u0200aioy\u1e22\u1e27\u1e31\u1e36ron;\u411br\u0100;c\u1e2d\u1e2e\u6256\u803b\xea\u40ealon;\u6255;\u444dot;\u4117\u0100Dr\u1e41\u1e45ot;\u6252;\uc000\ud835\udd22\u0180;rs\u1e50\u1e51\u1e57\u6a9aave\u803b\xe8\u40e8\u0100;d\u1e5c\u1e5d\u6a96ot;\u6a98\u0200;ils\u1e6a\u1e6b\u1e72\u1e74\u6a99nters;\u63e7;\u6113\u0100;d\u1e79\u1e7a\u6a95ot;\u6a97\u0180aps\u1e85\u1e89\u1e97cr;\u4113ty\u0180;sv\u1e92\u1e93\u1e95\u6205et\xbb\u1e93p\u01001;\u1e9d\u1ea4\u0133\u1ea1\u1ea3;\u6004;\u6005\u6003\u0100gs\u1eaa\u1eac;\u414bp;\u6002\u0100gp\u1eb4\u1eb8on;\u4119f;\uc000\ud835\udd56\u0180als\u1ec4\u1ece\u1ed2r\u0100;s\u1eca\u1ecb\u62d5l;\u69e3us;\u6a71i\u0180;lv\u1eda\u1edb\u1edf\u43b5on\xbb\u1edb;\u43f5\u0200csuv\u1eea\u1ef3\u1f0b\u1f23\u0100io\u1eef\u1e31rc\xbb\u1e2e\u0269\u1ef9\0\0\u1efb\xed\u0548ant\u0100gl\u1f02\u1f06tr\xbb\u1e5dess\xbb\u1e7a\u0180aei\u1f12\u1f16\u1f1als;\u403dst;\u625fv\u0100;D\u0235\u1f20D;\u6a78parsl;\u69e5\u0100Da\u1f2f\u1f33ot;\u6253rr;\u6971\u0180cdi\u1f3e\u1f41\u1ef8r;\u612fo\xf4\u0352\u0100ah\u1f49\u1f4b;\u43b7\u803b\xf0\u40f0\u0100mr\u1f53\u1f57l\u803b\xeb\u40ebo;\u60ac\u0180cip\u1f61\u1f64\u1f67l;\u4021s\xf4\u056e\u0100eo\u1f6c\u1f74ctatio\xee\u0559nential\xe5\u0579\u09e1\u1f92\0\u1f9e\0\u1fa1\u1fa7\0\0\u1fc6\u1fcc\0\u1fd3\0\u1fe6\u1fea\u2000\0\u2008\u205allingdotse\xf1\u1e44y;\u4444male;\u6640\u0180ilr\u1fad\u1fb3\u1fc1lig;\u8000\ufb03\u0269\u1fb9\0\0\u1fbdg;\u8000\ufb00ig;\u8000\ufb04;\uc000\ud835\udd23lig;\u8000\ufb01lig;\uc000fj\u0180alt\u1fd9\u1fdc\u1fe1t;\u666dig;\u8000\ufb02ns;\u65b1of;\u4192\u01f0\u1fee\0\u1ff3f;\uc000\ud835\udd57\u0100ak\u05bf\u1ff7\u0100;v\u1ffc\u1ffd\u62d4;\u6ad9artint;\u6a0d\u0100ao\u200c\u2055\u0100cs\u2011\u2052\u03b1\u201a\u2030\u2038\u2045\u2048\0\u2050\u03b2\u2022\u2025\u2027\u202a\u202c\0\u202e\u803b\xbd\u40bd;\u6153\u803b\xbc\u40bc;\u6155;\u6159;\u615b\u01b3\u2034\0\u2036;\u6154;\u6156\u02b4\u203e\u2041\0\0\u2043\u803b\xbe\u40be;\u6157;\u615c5;\u6158\u01b6\u204c\0\u204e;\u615a;\u615d8;\u615el;\u6044wn;\u6322cr;\uc000\ud835\udcbb\u0880Eabcdefgijlnorstv\u2082\u2089\u209f\u20a5\u20b0\u20b4\u20f0\u20f5\u20fa\u20ff\u2103\u2112\u2138\u0317\u213e\u2152\u219e\u0100;l\u064d\u2087;\u6a8c\u0180cmp\u2090\u2095\u209dute;\u41f5ma\u0100;d\u209c\u1cda\u43b3;\u6a86reve;\u411f\u0100iy\u20aa\u20aerc;\u411d;\u4433ot;\u4121\u0200;lqs\u063e\u0642\u20bd\u20c9\u0180;qs\u063e\u064c\u20c4lan\xf4\u0665\u0200;cdl\u0665\u20d2\u20d5\u20e5c;\u6aa9ot\u0100;o\u20dc\u20dd\u6a80\u0100;l\u20e2\u20e3\u6a82;\u6a84\u0100;e\u20ea\u20ed\uc000\u22db\ufe00s;\u6a94r;\uc000\ud835\udd24\u0100;g\u0673\u061bmel;\u6137cy;\u4453\u0200;Eaj\u065a\u210c\u210e\u2110;\u6a92;\u6aa5;\u6aa4\u0200Eaes\u211b\u211d\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6a8arox\xbb\u2124\u0100;q\u212e\u212f\u6a88\u0100;q\u212e\u211bim;\u62e7pf;\uc000\ud835\udd58\u0100ci\u2143\u2146r;\u610am\u0180;el\u066b\u214e\u2150;\u6a8e;\u6a90\u8300>;cdlqr\u05ee\u2160\u216a\u216e\u2173\u2179\u0100ci\u2165\u2167;\u6aa7r;\u6a7aot;\u62d7Par;\u6995uest;\u6a7c\u0280adels\u2184\u216a\u2190\u0656\u219b\u01f0\u2189\0\u218epro\xf8\u209er;\u6978q\u0100lq\u063f\u2196les\xf3\u2088i\xed\u066b\u0100en\u21a3\u21adrtneqq;\uc000\u2269\ufe00\xc5\u21aa\u0500Aabcefkosy\u21c4\u21c7\u21f1\u21f5\u21fa\u2218\u221d\u222f\u2268\u227dr\xf2\u03a0\u0200ilmr\u21d0\u21d4\u21d7\u21dbrs\xf0\u1484f\xbb\u2024il\xf4\u06a9\u0100dr\u21e0\u21e4cy;\u444a\u0180;cw\u08f4\u21eb\u21efir;\u6948;\u61adar;\u610firc;\u4125\u0180alr\u2201\u220e\u2213rts\u0100;u\u2209\u220a\u6665it\xbb\u220alip;\u6026con;\u62b9r;\uc000\ud835\udd25s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223a\u223e\u2243\u225e\u2263rr;\u61fftht;\u623bk\u0100lr\u2249\u2253eftarrow;\u61a9ightarrow;\u61aaf;\uc000\ud835\udd59bar;\u6015\u0180clt\u226f\u2274\u2278r;\uc000\ud835\udcbdas\xe8\u21f4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xbb\u1c5b\u0ae1\u22a3\0\u22aa\0\u22b8\u22c5\u22ce\0\u22d5\u22f3\0\0\u22f8\u2322\u2367\u2362\u237f\0\u2386\u23aa\u23b4cute\u803b\xed\u40ed\u0180;iy\u0771\u22b0\u22b5rc\u803b\xee\u40ee;\u4438\u0100cx\u22bc\u22bfy;\u4435cl\u803b\xa1\u40a1\u0100fr\u039f\u22c9;\uc000\ud835\udd26rave\u803b\xec\u40ec\u0200;ino\u073e\u22dd\u22e9\u22ee\u0100in\u22e2\u22e6nt;\u6a0ct;\u622dfin;\u69dcta;\u6129lig;\u4133\u0180aop\u22fe\u231a\u231d\u0180cgt\u2305\u2308\u2317r;\u412b\u0180elp\u071f\u230f\u2313in\xe5\u078ear\xf4\u0720h;\u4131f;\u62b7ed;\u41b5\u0280;cfot\u04f4\u232c\u2331\u233d\u2341are;\u6105in\u0100;t\u2338\u2339\u621eie;\u69dddo\xf4\u2319\u0280;celp\u0757\u234c\u2350\u235b\u2361al;\u62ba\u0100gr\u2355\u2359er\xf3\u1563\xe3\u234darhk;\u6a17rod;\u6a3c\u0200cgpt\u236f\u2372\u2376\u237by;\u4451on;\u412ff;\uc000\ud835\udd5aa;\u43b9uest\u803b\xbf\u40bf\u0100ci\u238a\u238fr;\uc000\ud835\udcben\u0280;Edsv\u04f4\u239b\u239d\u23a1\u04f3;\u62f9ot;\u62f5\u0100;v\u23a6\u23a7\u62f4;\u62f3\u0100;i\u0777\u23aelde;\u4129\u01eb\u23b8\0\u23bccy;\u4456l\u803b\xef\u40ef\u0300cfmosu\u23cc\u23d7\u23dc\u23e1\u23e7\u23f5\u0100iy\u23d1\u23d5rc;\u4135;\u4439r;\uc000\ud835\udd27ath;\u4237pf;\uc000\ud835\udd5b\u01e3\u23ec\0\u23f1r;\uc000\ud835\udcbfrcy;\u4458kcy;\u4454\u0400acfghjos\u240b\u2416\u2422\u2427\u242d\u2431\u2435\u243bppa\u0100;v\u2413\u2414\u43ba;\u43f0\u0100ey\u241b\u2420dil;\u4137;\u443ar;\uc000\ud835\udd28reen;\u4138cy;\u4445cy;\u445cpf;\uc000\ud835\udd5ccr;\uc000\ud835\udcc0\u0b80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248d\u2491\u250e\u253d\u255a\u2580\u264e\u265e\u2665\u2679\u267d\u269a\u26b2\u26d8\u275d\u2768\u278b\u27c0\u2801\u2812\u0180art\u2477\u247a\u247cr\xf2\u09c6\xf2\u0395ail;\u691barr;\u690e\u0100;g\u0994\u248b;\u6a8bar;\u6962\u0963\u24a5\0\u24aa\0\u24b1\0\0\0\0\0\u24b5\u24ba\0\u24c6\u24c8\u24cd\0\u24f9ute;\u413amptyv;\u69b4ra\xee\u084cbda;\u43bbg\u0180;dl\u088e\u24c1\u24c3;\u6991\xe5\u088e;\u6a85uo\u803b\xab\u40abr\u0400;bfhlpst\u0899\u24de\u24e6\u24e9\u24eb\u24ee\u24f1\u24f5\u0100;f\u089d\u24e3s;\u691fs;\u691d\xeb\u2252p;\u61abl;\u6939im;\u6973l;\u61a2\u0180;ae\u24ff\u2500\u2504\u6aabil;\u6919\u0100;s\u2509\u250a\u6aad;\uc000\u2aad\ufe00\u0180abr\u2515\u2519\u251drr;\u690crk;\u6772\u0100ak\u2522\u252cc\u0100ek\u2528\u252a;\u407b;\u405b\u0100es\u2531\u2533;\u698bl\u0100du\u2539\u253b;\u698f;\u698d\u0200aeuy\u2546\u254b\u2556\u2558ron;\u413e\u0100di\u2550\u2554il;\u413c\xec\u08b0\xe2\u2529;\u443b\u0200cqrs\u2563\u2566\u256d\u257da;\u6936uo\u0100;r\u0e19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694bh;\u61b2\u0280;fgqs\u258b\u258c\u0989\u25f3\u25ff\u6264t\u0280ahlrt\u2598\u25a4\u25b7\u25c2\u25e8rrow\u0100;t\u0899\u25a1a\xe9\u24f6arpoon\u0100du\u25af\u25b4own\xbb\u045ap\xbb\u0966eftarrows;\u61c7ight\u0180ahs\u25cd\u25d6\u25derrow\u0100;s\u08f4\u08a7arpoon\xf3\u0f98quigarro\xf7\u21f0hreetimes;\u62cb\u0180;qs\u258b\u0993\u25falan\xf4\u09ac\u0280;cdgs\u09ac\u260a\u260d\u261d\u2628c;\u6aa8ot\u0100;o\u2614\u2615\u6a7f\u0100;r\u261a\u261b\u6a81;\u6a83\u0100;e\u2622\u2625\uc000\u22da\ufe00s;\u6a93\u0280adegs\u2633\u2639\u263d\u2649\u264bppro\xf8\u24c6ot;\u62d6q\u0100gq\u2643\u2645\xf4\u0989gt\xf2\u248c\xf4\u099bi\xed\u09b2\u0180ilr\u2655\u08e1\u265asht;\u697c;\uc000\ud835\udd29\u0100;E\u099c\u2663;\u6a91\u0161\u2669\u2676r\u0100du\u25b2\u266e\u0100;l\u0965\u2673;\u696alk;\u6584cy;\u4459\u0280;acht\u0a48\u2688\u268b\u2691\u2696r\xf2\u25c1orne\xf2\u1d08ard;\u696bri;\u65fa\u0100io\u269f\u26a4dot;\u4140ust\u0100;a\u26ac\u26ad\u63b0che\xbb\u26ad\u0200Eaes\u26bb\u26bd\u26c9\u26d4;\u6268p\u0100;p\u26c3\u26c4\u6a89rox\xbb\u26c4\u0100;q\u26ce\u26cf\u6a87\u0100;q\u26ce\u26bbim;\u62e6\u0400abnoptwz\u26e9\u26f4\u26f7\u271a\u272f\u2741\u2747\u2750\u0100nr\u26ee\u26f1g;\u67ecr;\u61fdr\xeb\u08c1g\u0180lmr\u26ff\u270d\u2714eft\u0100ar\u09e6\u2707ight\xe1\u09f2apsto;\u67fcight\xe1\u09fdparrow\u0100lr\u2725\u2729ef\xf4\u24edight;\u61ac\u0180afl\u2736\u2739\u273dr;\u6985;\uc000\ud835\udd5dus;\u6a2dimes;\u6a34\u0161\u274b\u274fst;\u6217\xe1\u134e\u0180;ef\u2757\u2758\u1800\u65cange\xbb\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277c\u2785\u2787r\xf2\u08a8orne\xf2\u1d8car\u0100;d\u0f98\u2783;\u696d;\u600eri;\u62bf\u0300achiqt\u2798\u279d\u0a40\u27a2\u27ae\u27bbquo;\u6039r;\uc000\ud835\udcc1m\u0180;eg\u09b2\u27aa\u27ac;\u6a8d;\u6a8f\u0100bu\u252a\u27b3o\u0100;r\u0e1f\u27b9;\u601arok;\u4142\u8400<;cdhilqr\u082b\u27d2\u2639\u27dc\u27e0\u27e5\u27ea\u27f0\u0100ci\u27d7\u27d9;\u6aa6r;\u6a79re\xe5\u25f2mes;\u62c9arr;\u6976uest;\u6a7b\u0100Pi\u27f5\u27f9ar;\u6996\u0180;ef\u2800\u092d\u181b\u65c3r\u0100du\u2807\u280dshar;\u694ahar;\u6966\u0100en\u2817\u2821rtneqq;\uc000\u2268\ufe00\xc5\u281e\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288e\u2893\u28a0\u28a5\u28a8\u28da\u28e2\u28e4\u0a83\u28f3\u2902Dot;\u623a\u0200clpr\u284e\u2852\u2863\u287dr\u803b\xaf\u40af\u0100et\u2857\u2859;\u6642\u0100;e\u285e\u285f\u6720se\xbb\u285f\u0100;s\u103b\u2868to\u0200;dlu\u103b\u2873\u2877\u287bow\xee\u048cef\xf4\u090f\xf0\u13d1ker;\u65ae\u0100oy\u2887\u288cmma;\u6a29;\u443cash;\u6014asuredangle\xbb\u1626r;\uc000\ud835\udd2ao;\u6127\u0180cdn\u28af\u28b4\u28c9ro\u803b\xb5\u40b5\u0200;acd\u1464\u28bd\u28c0\u28c4s\xf4\u16a7ir;\u6af0ot\u80bb\xb7\u01b5us\u0180;bd\u28d2\u1903\u28d3\u6212\u0100;u\u1d3c\u28d8;\u6a2a\u0163\u28de\u28e1p;\u6adb\xf2\u2212\xf0\u0a81\u0100dp\u28e9\u28eeels;\u62a7f;\uc000\ud835\udd5e\u0100ct\u28f8\u28fdr;\uc000\ud835\udcc2pos\xbb\u159d\u0180;lm\u2909\u290a\u290d\u43bctimap;\u62b8\u0c00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297e\u2989\u2998\u29da\u29e9\u2a15\u2a1a\u2a58\u2a5d\u2a83\u2a95\u2aa4\u2aa8\u2b04\u2b07\u2b44\u2b7f\u2bae\u2c34\u2c67\u2c7c\u2ce9\u0100gt\u2947\u294b;\uc000\u22d9\u0338\u0100;v\u2950\u0bcf\uc000\u226b\u20d2\u0180elt\u295a\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61cdightarrow;\u61ce;\uc000\u22d8\u0338\u0100;v\u297b\u0c47\uc000\u226a\u20d2ightarrow;\u61cf\u0100Dd\u298e\u2993ash;\u62afash;\u62ae\u0280bcnpt\u29a3\u29a7\u29ac\u29b1\u29ccla\xbb\u02deute;\u4144g;\uc000\u2220\u20d2\u0280;Eiop\u0d84\u29bc\u29c0\u29c5\u29c8;\uc000\u2a70\u0338d;\uc000\u224b\u0338s;\u4149ro\xf8\u0d84ur\u0100;a\u29d3\u29d4\u666el\u0100;s\u29d3\u0b38\u01f3\u29df\0\u29e3p\u80bb\xa0\u0b37mp\u0100;e\u0bf9\u0c00\u0280aeouy\u29f4\u29fe\u2a03\u2a10\u2a13\u01f0\u29f9\0\u29fb;\u6a43on;\u4148dil;\u4146ng\u0100;d\u0d7e\u2a0aot;\uc000\u2a6d\u0338p;\u6a42;\u443dash;\u6013\u0380;Aadqsx\u0b92\u2a29\u2a2d\u2a3b\u2a41\u2a45\u2a50rr;\u61d7r\u0100hr\u2a33\u2a36k;\u6924\u0100;o\u13f2\u13f0ot;\uc000\u2250\u0338ui\xf6\u0b63\u0100ei\u2a4a\u2a4ear;\u6928\xed\u0b98ist\u0100;s\u0ba0\u0b9fr;\uc000\ud835\udd2b\u0200Eest\u0bc5\u2a66\u2a79\u2a7c\u0180;qs\u0bbc\u2a6d\u0be1\u0180;qs\u0bbc\u0bc5\u2a74lan\xf4\u0be2i\xed\u0bea\u0100;r\u0bb6\u2a81\xbb\u0bb7\u0180Aap\u2a8a\u2a8d\u2a91r\xf2\u2971rr;\u61aear;\u6af2\u0180;sv\u0f8d\u2a9c\u0f8c\u0100;d\u2aa1\u2aa2\u62fc;\u62facy;\u445a\u0380AEadest\u2ab7\u2aba\u2abe\u2ac2\u2ac5\u2af6\u2af9r\xf2\u2966;\uc000\u2266\u0338rr;\u619ar;\u6025\u0200;fqs\u0c3b\u2ace\u2ae3\u2aeft\u0100ar\u2ad4\u2ad9rro\xf7\u2ac1ightarro\xf7\u2a90\u0180;qs\u0c3b\u2aba\u2aealan\xf4\u0c55\u0100;s\u0c55\u2af4\xbb\u0c36i\xed\u0c5d\u0100;r\u0c35\u2afei\u0100;e\u0c1a\u0c25i\xe4\u0d90\u0100pt\u2b0c\u2b11f;\uc000\ud835\udd5f\u8180\xac;in\u2b19\u2b1a\u2b36\u40acn\u0200;Edv\u0b89\u2b24\u2b28\u2b2e;\uc000\u22f9\u0338ot;\uc000\u22f5\u0338\u01e1\u0b89\u2b33\u2b35;\u62f7;\u62f6i\u0100;v\u0cb8\u2b3c\u01e1\u0cb8\u2b41\u2b43;\u62fe;\u62fd\u0180aor\u2b4b\u2b63\u2b69r\u0200;ast\u0b7b\u2b55\u2b5a\u2b5flle\xec\u0b7bl;\uc000\u2afd\u20e5;\uc000\u2202\u0338lint;\u6a14\u0180;ce\u0c92\u2b70\u2b73u\xe5\u0ca5\u0100;c\u0c98\u2b78\u0100;e\u0c92\u2b7d\xf1\u0c98\u0200Aait\u2b88\u2b8b\u2b9d\u2ba7r\xf2\u2988rr\u0180;cw\u2b94\u2b95\u2b99\u619b;\uc000\u2933\u0338;\uc000\u219d\u0338ghtarrow\xbb\u2b95ri\u0100;e\u0ccb\u0cd6\u0380chimpqu\u2bbd\u2bcd\u2bd9\u2b04\u0b78\u2be4\u2bef\u0200;cer\u0d32\u2bc6\u0d37\u2bc9u\xe5\u0d45;\uc000\ud835\udcc3ort\u026d\u2b05\0\0\u2bd6ar\xe1\u2b56m\u0100;e\u0d6e\u2bdf\u0100;q\u0d74\u0d73su\u0100bp\u2beb\u2bed\xe5\u0cf8\xe5\u0d0b\u0180bcp\u2bf6\u2c11\u2c19\u0200;Ees\u2bff\u2c00\u0d22\u2c04\u6284;\uc000\u2ac5\u0338et\u0100;e\u0d1b\u2c0bq\u0100;q\u0d23\u2c00c\u0100;e\u0d32\u2c17\xf1\u0d38\u0200;Ees\u2c22\u2c23\u0d5f\u2c27\u6285;\uc000\u2ac6\u0338et\u0100;e\u0d58\u2c2eq\u0100;q\u0d60\u2c23\u0200gilr\u2c3d\u2c3f\u2c45\u2c47\xec\u0bd7lde\u803b\xf1\u40f1\xe7\u0c43iangle\u0100lr\u2c52\u2c5ceft\u0100;e\u0c1a\u2c5a\xf1\u0c26ight\u0100;e\u0ccb\u2c65\xf1\u0cd7\u0100;m\u2c6c\u2c6d\u43bd\u0180;es\u2c74\u2c75\u2c79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2c8f\u2c94\u2c99\u2c9e\u2ca3\u2cb0\u2cb6\u2cd3\u2ce3ash;\u62adarr;\u6904p;\uc000\u224d\u20d2ash;\u62ac\u0100et\u2ca8\u2cac;\uc000\u2265\u20d2;\uc000>\u20d2nfin;\u69de\u0180Aet\u2cbd\u2cc1\u2cc5rr;\u6902;\uc000\u2264\u20d2\u0100;r\u2cca\u2ccd\uc000<\u20d2ie;\uc000\u22b4\u20d2\u0100At\u2cd8\u2cdcrr;\u6903rie;\uc000\u22b5\u20d2im;\uc000\u223c\u20d2\u0180Aan\u2cf0\u2cf4\u2d02rr;\u61d6r\u0100hr\u2cfa\u2cfdk;\u6923\u0100;o\u13e7\u13e5ear;\u6927\u1253\u1a95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2d2d\0\u2d38\u2d48\u2d60\u2d65\u2d72\u2d84\u1b07\0\0\u2d8d\u2dab\0\u2dc8\u2dce\0\u2ddc\u2e19\u2e2b\u2e3e\u2e43\u0100cs\u2d31\u1a97ute\u803b\xf3\u40f3\u0100iy\u2d3c\u2d45r\u0100;c\u1a9e\u2d42\u803b\xf4\u40f4;\u443e\u0280abios\u1aa0\u2d52\u2d57\u01c8\u2d5alac;\u4151v;\u6a38old;\u69bclig;\u4153\u0100cr\u2d69\u2d6dir;\u69bf;\uc000\ud835\udd2c\u036f\u2d79\0\0\u2d7c\0\u2d82n;\u42dbave\u803b\xf2\u40f2;\u69c1\u0100bm\u2d88\u0df4ar;\u69b5\u0200acit\u2d95\u2d98\u2da5\u2da8r\xf2\u1a80\u0100ir\u2d9d\u2da0r;\u69beoss;\u69bbn\xe5\u0e52;\u69c0\u0180aei\u2db1\u2db5\u2db9cr;\u414dga;\u43c9\u0180cdn\u2dc0\u2dc5\u01cdron;\u43bf;\u69b6pf;\uc000\ud835\udd60\u0180ael\u2dd4\u2dd7\u01d2r;\u69b7rp;\u69b9\u0380;adiosv\u2dea\u2deb\u2dee\u2e08\u2e0d\u2e10\u2e16\u6228r\xf2\u1a86\u0200;efm\u2df7\u2df8\u2e02\u2e05\u6a5dr\u0100;o\u2dfe\u2dff\u6134f\xbb\u2dff\u803b\xaa\u40aa\u803b\xba\u40bagof;\u62b6r;\u6a56lope;\u6a57;\u6a5b\u0180clo\u2e1f\u2e21\u2e27\xf2\u2e01ash\u803b\xf8\u40f8l;\u6298i\u016c\u2e2f\u2e34de\u803b\xf5\u40f5es\u0100;a\u01db\u2e3as;\u6a36ml\u803b\xf6\u40f6bar;\u633d\u0ae1\u2e5e\0\u2e7d\0\u2e80\u2e9d\0\u2ea2\u2eb9\0\0\u2ecb\u0e9c\0\u2f13\0\0\u2f2b\u2fbc\0\u2fc8r\u0200;ast\u0403\u2e67\u2e72\u0e85\u8100\xb6;l\u2e6d\u2e6e\u40b6le\xec\u0403\u0269\u2e78\0\0\u2e7bm;\u6af3;\u6afdy;\u443fr\u0280cimpt\u2e8b\u2e8f\u2e93\u1865\u2e97nt;\u4025od;\u402eil;\u6030enk;\u6031r;\uc000\ud835\udd2d\u0180imo\u2ea8\u2eb0\u2eb4\u0100;v\u2ead\u2eae\u43c6;\u43d5ma\xf4\u0a76ne;\u660e\u0180;tv\u2ebf\u2ec0\u2ec8\u43c0chfork\xbb\u1ffd;\u43d6\u0100au\u2ecf\u2edfn\u0100ck\u2ed5\u2eddk\u0100;h\u21f4\u2edb;\u610e\xf6\u21f4s\u0480;abcdemst\u2ef3\u2ef4\u1908\u2ef9\u2efd\u2f04\u2f06\u2f0a\u2f0e\u402bcir;\u6a23ir;\u6a22\u0100ou\u1d40\u2f02;\u6a25;\u6a72n\u80bb\xb1\u0e9dim;\u6a26wo;\u6a27\u0180ipu\u2f19\u2f20\u2f25ntint;\u6a15f;\uc000\ud835\udd61nd\u803b\xa3\u40a3\u0500;Eaceinosu\u0ec8\u2f3f\u2f41\u2f44\u2f47\u2f81\u2f89\u2f92\u2f7e\u2fb6;\u6ab3p;\u6ab7u\xe5\u0ed9\u0100;c\u0ece\u2f4c\u0300;acens\u0ec8\u2f59\u2f5f\u2f66\u2f68\u2f7eppro\xf8\u2f43urlye\xf1\u0ed9\xf1\u0ece\u0180aes\u2f6f\u2f76\u2f7approx;\u6ab9qq;\u6ab5im;\u62e8i\xed\u0edfme\u0100;s\u2f88\u0eae\u6032\u0180Eas\u2f78\u2f90\u2f7a\xf0\u2f75\u0180dfp\u0eec\u2f99\u2faf\u0180als\u2fa0\u2fa5\u2faalar;\u632eine;\u6312urf;\u6313\u0100;t\u0efb\u2fb4\xef\u0efbrel;\u62b0\u0100ci\u2fc0\u2fc5r;\uc000\ud835\udcc5;\u43c8ncsp;\u6008\u0300fiopsu\u2fda\u22e2\u2fdf\u2fe5\u2feb\u2ff1r;\uc000\ud835\udd2epf;\uc000\ud835\udd62rime;\u6057cr;\uc000\ud835\udcc6\u0180aeo\u2ff8\u3009\u3013t\u0100ei\u2ffe\u3005rnion\xf3\u06b0nt;\u6a16st\u0100;e\u3010\u3011\u403f\xf1\u1f19\xf4\u0f14\u0a80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30e0\u310e\u312b\u3147\u3162\u3172\u318e\u3206\u3215\u3224\u3229\u3258\u326e\u3272\u3290\u32b0\u32b7\u0180art\u3047\u304a\u304cr\xf2\u10b3\xf2\u03ddail;\u691car\xf2\u1c65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307f\u308f\u3094\u30cc\u0100eu\u306d\u3071;\uc000\u223d\u0331te;\u4155i\xe3\u116emptyv;\u69b3g\u0200;del\u0fd1\u3089\u308b\u308d;\u6992;\u69a5\xe5\u0fd1uo\u803b\xbb\u40bbr\u0580;abcfhlpstw\u0fdc\u30ac\u30af\u30b7\u30b9\u30bc\u30be\u30c0\u30c3\u30c7\u30cap;\u6975\u0100;f\u0fe0\u30b4s;\u6920;\u6933s;\u691e\xeb\u225d\xf0\u272el;\u6945im;\u6974l;\u61a3;\u619d\u0100ai\u30d1\u30d5il;\u691ao\u0100;n\u30db\u30dc\u6236al\xf3\u0f1e\u0180abr\u30e7\u30ea\u30eer\xf2\u17e5rk;\u6773\u0100ak\u30f3\u30fdc\u0100ek\u30f9\u30fb;\u407d;\u405d\u0100es\u3102\u3104;\u698cl\u0100du\u310a\u310c;\u698e;\u6990\u0200aeuy\u3117\u311c\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xec\u0ff2\xe2\u30fa;\u4440\u0200clqs\u3134\u3137\u313d\u3144a;\u6937dhar;\u6969uo\u0100;r\u020e\u020dh;\u61b3\u0180acg\u314e\u315f\u0f44l\u0200;ips\u0f78\u3158\u315b\u109cn\xe5\u10bbar\xf4\u0fa9t;\u65ad\u0180ilr\u3169\u1023\u316esht;\u697d;\uc000\ud835\udd2f\u0100ao\u3177\u3186r\u0100du\u317d\u317f\xbb\u047b\u0100;l\u1091\u3184;\u696c\u0100;v\u318b\u318c\u43c1;\u43f1\u0180gns\u3195\u31f9\u31fcht\u0300ahlrst\u31a4\u31b0\u31c2\u31d8\u31e4\u31eerrow\u0100;t\u0fdc\u31ada\xe9\u30c8arpoon\u0100du\u31bb\u31bfow\xee\u317ep\xbb\u1092eft\u0100ah\u31ca\u31d0rrow\xf3\u0feaarpoon\xf3\u0551ightarrows;\u61c9quigarro\xf7\u30cbhreetimes;\u62ccg;\u42daingdotse\xf1\u1f32\u0180ahm\u320d\u3210\u3213r\xf2\u0feaa\xf2\u0551;\u600foust\u0100;a\u321e\u321f\u63b1che\xbb\u321fmid;\u6aee\u0200abpt\u3232\u323d\u3240\u3252\u0100nr\u3237\u323ag;\u67edr;\u61fer\xeb\u1003\u0180afl\u3247\u324a\u324er;\u6986;\uc000\ud835\udd63us;\u6a2eimes;\u6a35\u0100ap\u325d\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6a12ar\xf2\u31e3\u0200achq\u327b\u3280\u10bc\u3285quo;\u603ar;\uc000\ud835\udcc7\u0100bu\u30fb\u328ao\u0100;r\u0214\u0213\u0180hir\u3297\u329b\u32a0re\xe5\u31f8mes;\u62cai\u0200;efl\u32aa\u1059\u1821\u32ab\u65b9tri;\u69celuhar;\u6968;\u611e\u0d61\u32d5\u32db\u32df\u332c\u3338\u3371\0\u337a\u33a4\0\0\u33ec\u33f0\0\u3428\u3448\u345a\u34ad\u34b1\u34ca\u34f1\0\u3616\0\0\u3633cute;\u415bqu\xef\u27ba\u0500;Eaceinpsy\u11ed\u32f3\u32f5\u32ff\u3302\u330b\u330f\u331f\u3326\u3329;\u6ab4\u01f0\u32fa\0\u32fc;\u6ab8on;\u4161u\xe5\u11fe\u0100;d\u11f3\u3307il;\u415frc;\u415d\u0180Eas\u3316\u3318\u331b;\u6ab6p;\u6abaim;\u62e9olint;\u6a13i\xed\u1204;\u4441ot\u0180;be\u3334\u1d47\u3335\u62c5;\u6a66\u0380Aacmstx\u3346\u334a\u3357\u335b\u335e\u3363\u336drr;\u61d8r\u0100hr\u3350\u3352\xeb\u2228\u0100;o\u0a36\u0a34t\u803b\xa7\u40a7i;\u403bwar;\u6929m\u0100in\u3369\xf0nu\xf3\xf1t;\u6736r\u0100;o\u3376\u2055\uc000\ud835\udd30\u0200acoy\u3382\u3386\u3391\u33a0rp;\u666f\u0100hy\u338b\u338fcy;\u4449;\u4448rt\u026d\u3399\0\0\u339ci\xe4\u1464ara\xec\u2e6f\u803b\xad\u40ad\u0100gm\u33a8\u33b4ma\u0180;fv\u33b1\u33b2\u33b2\u43c3;\u43c2\u0400;deglnpr\u12ab\u33c5\u33c9\u33ce\u33d6\u33de\u33e1\u33e6ot;\u6a6a\u0100;q\u12b1\u12b0\u0100;E\u33d3\u33d4\u6a9e;\u6aa0\u0100;E\u33db\u33dc\u6a9d;\u6a9fe;\u6246lus;\u6a24arr;\u6972ar\xf2\u113d\u0200aeit\u33f8\u3408\u340f\u3417\u0100ls\u33fd\u3404lsetm\xe9\u336ahp;\u6a33parsl;\u69e4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341c\u341d\u6aaa\u0100;s\u3422\u3423\u6aac;\uc000\u2aac\ufe00\u0180flp\u342e\u3433\u3442tcy;\u444c\u0100;b\u3438\u3439\u402f\u0100;a\u343e\u343f\u69c4r;\u633ff;\uc000\ud835\udd64a\u0100dr\u344d\u0402es\u0100;u\u3454\u3455\u6660it\xbb\u3455\u0180csu\u3460\u3479\u349f\u0100au\u3465\u346fp\u0100;s\u1188\u346b;\uc000\u2293\ufe00p\u0100;s\u11b4\u3475;\uc000\u2294\ufe00u\u0100bp\u347f\u348f\u0180;es\u1197\u119c\u3486et\u0100;e\u1197\u348d\xf1\u119d\u0180;es\u11a8\u11ad\u3496et\u0100;e\u11a8\u349d\xf1\u11ae\u0180;af\u117b\u34a6\u05b0r\u0165\u34ab\u05b1\xbb\u117car\xf2\u1148\u0200cemt\u34b9\u34be\u34c2\u34c5r;\uc000\ud835\udcc8tm\xee\xf1i\xec\u3415ar\xe6\u11be\u0100ar\u34ce\u34d5r\u0100;f\u34d4\u17bf\u6606\u0100an\u34da\u34edight\u0100ep\u34e3\u34eapsilo\xee\u1ee0h\xe9\u2eafs\xbb\u2852\u0280bcmnp\u34fb\u355e\u1209\u358b\u358e\u0480;Edemnprs\u350e\u350f\u3511\u3515\u351e\u3523\u352c\u3531\u3536\u6282;\u6ac5ot;\u6abd\u0100;d\u11da\u351aot;\u6ac3ult;\u6ac1\u0100Ee\u3528\u352a;\u6acb;\u628alus;\u6abfarr;\u6979\u0180eiu\u353d\u3552\u3555t\u0180;en\u350e\u3545\u354bq\u0100;q\u11da\u350feq\u0100;q\u352b\u3528m;\u6ac7\u0100bp\u355a\u355c;\u6ad5;\u6ad3c\u0300;acens\u11ed\u356c\u3572\u3579\u357b\u3326ppro\xf8\u32faurlye\xf1\u11fe\xf1\u11f3\u0180aes\u3582\u3588\u331bppro\xf8\u331aq\xf1\u3317g;\u666a\u0680123;Edehlmnps\u35a9\u35ac\u35af\u121c\u35b2\u35b4\u35c0\u35c9\u35d5\u35da\u35df\u35e8\u35ed\u803b\xb9\u40b9\u803b\xb2\u40b2\u803b\xb3\u40b3;\u6ac6\u0100os\u35b9\u35bct;\u6abeub;\u6ad8\u0100;d\u1222\u35c5ot;\u6ac4s\u0100ou\u35cf\u35d2l;\u67c9b;\u6ad7arr;\u697bult;\u6ac2\u0100Ee\u35e4\u35e6;\u6acc;\u628blus;\u6ac0\u0180eiu\u35f4\u3609\u360ct\u0180;en\u121c\u35fc\u3602q\u0100;q\u1222\u35b2eq\u0100;q\u35e7\u35e4m;\u6ac8\u0100bp\u3611\u3613;\u6ad4;\u6ad6\u0180Aan\u361c\u3620\u362drr;\u61d9r\u0100hr\u3626\u3628\xeb\u222e\u0100;o\u0a2b\u0a29war;\u692alig\u803b\xdf\u40df\u0be1\u3651\u365d\u3660\u12ce\u3673\u3679\0\u367e\u36c2\0\0\0\0\0\u36db\u3703\0\u3709\u376c\0\0\0\u3787\u0272\u3656\0\0\u365bget;\u6316;\u43c4r\xeb\u0e5f\u0180aey\u3666\u366b\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uc000\ud835\udd31\u0200eiko\u3686\u369d\u36b5\u36bc\u01f2\u368b\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369b\u43b8ym;\u43d1\u0100cn\u36a2\u36b2k\u0100as\u36a8\u36aeppro\xf8\u12c1im\xbb\u12acs\xf0\u129e\u0100as\u36ba\u36ae\xf0\u12c1rn\u803b\xfe\u40fe\u01ec\u031f\u36c6\u22e7es\u8180\xd7;bd\u36cf\u36d0\u36d8\u40d7\u0100;a\u190f\u36d5r;\u6a31;\u6a30\u0180eps\u36e1\u36e3\u3700\xe1\u2a4d\u0200;bcf\u0486\u36ec\u36f0\u36f4ot;\u6336ir;\u6af1\u0100;o\u36f9\u36fc\uc000\ud835\udd65rk;\u6ada\xe1\u3362rime;\u6034\u0180aip\u370f\u3712\u3764d\xe5\u1248\u0380adempst\u3721\u374d\u3740\u3751\u3757\u375c\u375fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65b5own\xbb\u1dbbeft\u0100;e\u2800\u373e\xf1\u092e;\u625cight\u0100;e\u32aa\u374b\xf1\u105aot;\u65ecinus;\u6a3alus;\u6a39b;\u69cdime;\u6a3bezium;\u63e2\u0180cht\u3772\u377d\u3781\u0100ry\u3777\u377b;\uc000\ud835\udcc9;\u4446cy;\u445brok;\u4167\u0100io\u378b\u378ex\xf4\u1777head\u0100lr\u3797\u37a0eftarro\xf7\u084fightarrow\xbb\u0f5d\u0900AHabcdfghlmoprstuw\u37d0\u37d3\u37d7\u37e4\u37f0\u37fc\u380e\u381c\u3823\u3834\u3851\u385d\u386b\u38a9\u38cc\u38d2\u38ea\u38f6r\xf2\u03edar;\u6963\u0100cr\u37dc\u37e2ute\u803b\xfa\u40fa\xf2\u1150r\u01e3\u37ea\0\u37edy;\u445eve;\u416d\u0100iy\u37f5\u37farc\u803b\xfb\u40fb;\u4443\u0180abh\u3803\u3806\u380br\xf2\u13adlac;\u4171a\xf2\u13c3\u0100ir\u3813\u3818sht;\u697e;\uc000\ud835\udd32rave\u803b\xf9\u40f9\u0161\u3827\u3831r\u0100lr\u382c\u382e\xbb\u0957\xbb\u1083lk;\u6580\u0100ct\u3839\u384d\u026f\u383f\0\0\u384arn\u0100;e\u3845\u3846\u631cr\xbb\u3846op;\u630fri;\u65f8\u0100al\u3856\u385acr;\u416b\u80bb\xa8\u0349\u0100gp\u3862\u3866on;\u4173f;\uc000\ud835\udd66\u0300adhlsu\u114b\u3878\u387d\u1372\u3891\u38a0own\xe1\u13b3arpoon\u0100lr\u3888\u388cef\xf4\u382digh\xf4\u382fi\u0180;hl\u3899\u389a\u389c\u43c5\xbb\u13faon\xbb\u389aparrows;\u61c8\u0180cit\u38b0\u38c4\u38c8\u026f\u38b6\0\0\u38c1rn\u0100;e\u38bc\u38bd\u631dr\xbb\u38bdop;\u630eng;\u416fri;\u65f9cr;\uc000\ud835\udcca\u0180dir\u38d9\u38dd\u38e2ot;\u62f0lde;\u4169i\u0100;f\u3730\u38e8\xbb\u1813\u0100am\u38ef\u38f2r\xf2\u38a8l\u803b\xfc\u40fcangle;\u69a7\u0780ABDacdeflnoprsz\u391c\u391f\u3929\u392d\u39b5\u39b8\u39bd\u39df\u39e4\u39e8\u39f3\u39f9\u39fd\u3a01\u3a20r\xf2\u03f7ar\u0100;v\u3926\u3927\u6ae8;\u6ae9as\xe8\u03e1\u0100nr\u3932\u3937grt;\u699c\u0380eknprst\u34e3\u3946\u394b\u3952\u395d\u3964\u3996app\xe1\u2415othin\xe7\u1e96\u0180hir\u34eb\u2ec8\u3959op\xf4\u2fb5\u0100;h\u13b7\u3962\xef\u318d\u0100iu\u3969\u396dgm\xe1\u33b3\u0100bp\u3972\u3984setneq\u0100;q\u397d\u3980\uc000\u228a\ufe00;\uc000\u2acb\ufe00setneq\u0100;q\u398f\u3992\uc000\u228b\ufe00;\uc000\u2acc\ufe00\u0100hr\u399b\u399fet\xe1\u369ciangle\u0100lr\u39aa\u39afeft\xbb\u0925ight\xbb\u1051y;\u4432ash\xbb\u1036\u0180elr\u39c4\u39d2\u39d7\u0180;be\u2dea\u39cb\u39cfar;\u62bbq;\u625alip;\u62ee\u0100bt\u39dc\u1468a\xf2\u1469r;\uc000\ud835\udd33tr\xe9\u39aesu\u0100bp\u39ef\u39f1\xbb\u0d1c\xbb\u0d59pf;\uc000\ud835\udd67ro\xf0\u0efbtr\xe9\u39b4\u0100cu\u3a06\u3a0br;\uc000\ud835\udccb\u0100bp\u3a10\u3a18n\u0100Ee\u3980\u3a16\xbb\u397en\u0100Ee\u3992\u3a1e\xbb\u3990igzag;\u699a\u0380cefoprs\u3a36\u3a3b\u3a56\u3a5b\u3a54\u3a61\u3a6airc;\u4175\u0100di\u3a40\u3a51\u0100bg\u3a45\u3a49ar;\u6a5fe\u0100;q\u15fa\u3a4f;\u6259erp;\u6118r;\uc000\ud835\udd34pf;\uc000\ud835\udd68\u0100;e\u1479\u3a66at\xe8\u1479cr;\uc000\ud835\udccc\u0ae3\u178e\u3a87\0\u3a8b\0\u3a90\u3a9b\0\0\u3a9d\u3aa8\u3aab\u3aaf\0\0\u3ac3\u3ace\0\u3ad8\u17dc\u17dftr\xe9\u17d1r;\uc000\ud835\udd35\u0100Aa\u3a94\u3a97r\xf2\u03c3r\xf2\u09f6;\u43be\u0100Aa\u3aa1\u3aa4r\xf2\u03b8r\xf2\u09eba\xf0\u2713is;\u62fb\u0180dpt\u17a4\u3ab5\u3abe\u0100fl\u3aba\u17a9;\uc000\ud835\udd69im\xe5\u17b2\u0100Aa\u3ac7\u3acar\xf2\u03cer\xf2\u0a01\u0100cq\u3ad2\u17b8r;\uc000\ud835\udccd\u0100pt\u17d6\u3adcr\xe9\u17d4\u0400acefiosu\u3af0\u3afd\u3b08\u3b0c\u3b11\u3b15\u3b1b\u3b21c\u0100uy\u3af6\u3afbte\u803b\xfd\u40fd;\u444f\u0100iy\u3b02\u3b06rc;\u4177;\u444bn\u803b\xa5\u40a5r;\uc000\ud835\udd36cy;\u4457pf;\uc000\ud835\udd6acr;\uc000\ud835\udcce\u0100cm\u3b26\u3b29y;\u444el\u803b\xff\u40ff\u0500acdefhiosw\u3b42\u3b48\u3b54\u3b58\u3b64\u3b69\u3b6d\u3b74\u3b7a\u3b80cute;\u417a\u0100ay\u3b4d\u3b52ron;\u417e;\u4437ot;\u417c\u0100et\u3b5d\u3b61tr\xe6\u155fa;\u43b6r;\uc000\ud835\udd37cy;\u4436grarr;\u61ddpf;\uc000\ud835\udd6bcr;\uc000\ud835\udccf\u0100jn\u3b85\u3b87;\u600dj;\u600c"
  724. .split("")
  725. .map((c) => c.charCodeAt(0)));
  726. // Generated using scripts/write-decode-map.ts
  727. var xmlDecodeTree = new Uint16Array(
  728. // prettier-ignore
  729. "\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022"
  730. .split("")
  731. .map((c) => c.charCodeAt(0)));
  732. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  733. var _a$1;
  734. const decodeMap = new Map([
  735. [0, 65533],
  736. // C1 Unicode control character reference replacements
  737. [128, 8364],
  738. [130, 8218],
  739. [131, 402],
  740. [132, 8222],
  741. [133, 8230],
  742. [134, 8224],
  743. [135, 8225],
  744. [136, 710],
  745. [137, 8240],
  746. [138, 352],
  747. [139, 8249],
  748. [140, 338],
  749. [142, 381],
  750. [145, 8216],
  751. [146, 8217],
  752. [147, 8220],
  753. [148, 8221],
  754. [149, 8226],
  755. [150, 8211],
  756. [151, 8212],
  757. [152, 732],
  758. [153, 8482],
  759. [154, 353],
  760. [155, 8250],
  761. [156, 339],
  762. [158, 382],
  763. [159, 376],
  764. ]);
  765. /**
  766. * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
  767. */
  768. const fromCodePoint =
  769. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  770. (_a$1 = String.fromCodePoint) !== null && _a$1 !== void 0 ? _a$1 : function (codePoint) {
  771. let output = "";
  772. if (codePoint > 0xffff) {
  773. codePoint -= 0x10000;
  774. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  775. codePoint = 0xdc00 | (codePoint & 0x3ff);
  776. }
  777. output += String.fromCharCode(codePoint);
  778. return output;
  779. };
  780. /**
  781. * Replace the given code point with a replacement character if it is a
  782. * surrogate or is outside the valid range. Otherwise return the code
  783. * point unchanged.
  784. */
  785. function replaceCodePoint(codePoint) {
  786. var _a;
  787. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  788. return 0xfffd;
  789. }
  790. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  791. }
  792. var CharCodes;
  793. (function (CharCodes) {
  794. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  795. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  796. CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
  797. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  798. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  799. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  800. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  801. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  802. CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
  803. CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
  804. CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
  805. CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
  806. })(CharCodes || (CharCodes = {}));
  807. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  808. const TO_LOWER_BIT = 0b100000;
  809. var BinTrieFlags;
  810. (function (BinTrieFlags) {
  811. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  812. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  813. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  814. })(BinTrieFlags || (BinTrieFlags = {}));
  815. function isNumber$1(code) {
  816. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  817. }
  818. function isHexadecimalCharacter(code) {
  819. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
  820. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
  821. }
  822. function isAsciiAlphaNumeric(code) {
  823. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
  824. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
  825. isNumber$1(code));
  826. }
  827. /**
  828. * Checks if the given character is a valid end character for an entity in an attribute.
  829. *
  830. * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  831. * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  832. */
  833. function isEntityInAttributeInvalidEnd(code) {
  834. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  835. }
  836. var EntityDecoderState;
  837. (function (EntityDecoderState) {
  838. EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
  839. EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
  840. EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
  841. EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
  842. EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
  843. })(EntityDecoderState || (EntityDecoderState = {}));
  844. var DecodingMode;
  845. (function (DecodingMode) {
  846. /** Entities in text nodes that can end with any character. */
  847. DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
  848. /** Only allow entities terminated with a semicolon. */
  849. DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
  850. /** Entities in attributes have limitations on ending characters. */
  851. DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
  852. })(DecodingMode || (DecodingMode = {}));
  853. /**
  854. * Token decoder with support of writing partial entities.
  855. */
  856. class EntityDecoder {
  857. constructor(
  858. /** The tree used to decode entities. */
  859. decodeTree,
  860. /**
  861. * The function that is called when a codepoint is decoded.
  862. *
  863. * For multi-byte named entities, this will be called multiple times,
  864. * with the second codepoint, and the same `consumed` value.
  865. *
  866. * @param codepoint The decoded codepoint.
  867. * @param consumed The number of bytes consumed by the decoder.
  868. */
  869. emitCodePoint,
  870. /** An object that is used to produce errors. */
  871. errors) {
  872. this.decodeTree = decodeTree;
  873. this.emitCodePoint = emitCodePoint;
  874. this.errors = errors;
  875. /** The current state of the decoder. */
  876. this.state = EntityDecoderState.EntityStart;
  877. /** Characters that were consumed while parsing an entity. */
  878. this.consumed = 1;
  879. /**
  880. * The result of the entity.
  881. *
  882. * Either the result index of a numeric entity, or the codepoint of a
  883. * numeric entity.
  884. */
  885. this.result = 0;
  886. /** The current index in the decode tree. */
  887. this.treeIndex = 0;
  888. /** The number of characters that were consumed in excess. */
  889. this.excess = 1;
  890. /** The mode in which the decoder is operating. */
  891. this.decodeMode = DecodingMode.Strict;
  892. }
  893. /** Resets the instance to make it reusable. */
  894. startEntity(decodeMode) {
  895. this.decodeMode = decodeMode;
  896. this.state = EntityDecoderState.EntityStart;
  897. this.result = 0;
  898. this.treeIndex = 0;
  899. this.excess = 1;
  900. this.consumed = 1;
  901. }
  902. /**
  903. * Write an entity to the decoder. This can be called multiple times with partial entities.
  904. * If the entity is incomplete, the decoder will return -1.
  905. *
  906. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  907. * entity is incomplete, and resume when the next string is written.
  908. *
  909. * @param string The string containing the entity (or a continuation of the entity).
  910. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  911. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  912. */
  913. write(str, offset) {
  914. switch (this.state) {
  915. case EntityDecoderState.EntityStart: {
  916. if (str.charCodeAt(offset) === CharCodes.NUM) {
  917. this.state = EntityDecoderState.NumericStart;
  918. this.consumed += 1;
  919. return this.stateNumericStart(str, offset + 1);
  920. }
  921. this.state = EntityDecoderState.NamedEntity;
  922. return this.stateNamedEntity(str, offset);
  923. }
  924. case EntityDecoderState.NumericStart: {
  925. return this.stateNumericStart(str, offset);
  926. }
  927. case EntityDecoderState.NumericDecimal: {
  928. return this.stateNumericDecimal(str, offset);
  929. }
  930. case EntityDecoderState.NumericHex: {
  931. return this.stateNumericHex(str, offset);
  932. }
  933. case EntityDecoderState.NamedEntity: {
  934. return this.stateNamedEntity(str, offset);
  935. }
  936. }
  937. }
  938. /**
  939. * Switches between the numeric decimal and hexadecimal states.
  940. *
  941. * Equivalent to the `Numeric character reference state` in the HTML spec.
  942. *
  943. * @param str The string containing the entity (or a continuation of the entity).
  944. * @param offset The current offset.
  945. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  946. */
  947. stateNumericStart(str, offset) {
  948. if (offset >= str.length) {
  949. return -1;
  950. }
  951. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  952. this.state = EntityDecoderState.NumericHex;
  953. this.consumed += 1;
  954. return this.stateNumericHex(str, offset + 1);
  955. }
  956. this.state = EntityDecoderState.NumericDecimal;
  957. return this.stateNumericDecimal(str, offset);
  958. }
  959. addToNumericResult(str, start, end, base) {
  960. if (start !== end) {
  961. const digitCount = end - start;
  962. this.result =
  963. this.result * Math.pow(base, digitCount) +
  964. parseInt(str.substr(start, digitCount), base);
  965. this.consumed += digitCount;
  966. }
  967. }
  968. /**
  969. * Parses a hexadecimal numeric entity.
  970. *
  971. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  972. *
  973. * @param str The string containing the entity (or a continuation of the entity).
  974. * @param offset The current offset.
  975. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  976. */
  977. stateNumericHex(str, offset) {
  978. const startIdx = offset;
  979. while (offset < str.length) {
  980. const char = str.charCodeAt(offset);
  981. if (isNumber$1(char) || isHexadecimalCharacter(char)) {
  982. offset += 1;
  983. }
  984. else {
  985. this.addToNumericResult(str, startIdx, offset, 16);
  986. return this.emitNumericEntity(char, 3);
  987. }
  988. }
  989. this.addToNumericResult(str, startIdx, offset, 16);
  990. return -1;
  991. }
  992. /**
  993. * Parses a decimal numeric entity.
  994. *
  995. * Equivalent to the `Decimal character reference state` in the HTML spec.
  996. *
  997. * @param str The string containing the entity (or a continuation of the entity).
  998. * @param offset The current offset.
  999. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1000. */
  1001. stateNumericDecimal(str, offset) {
  1002. const startIdx = offset;
  1003. while (offset < str.length) {
  1004. const char = str.charCodeAt(offset);
  1005. if (isNumber$1(char)) {
  1006. offset += 1;
  1007. }
  1008. else {
  1009. this.addToNumericResult(str, startIdx, offset, 10);
  1010. return this.emitNumericEntity(char, 2);
  1011. }
  1012. }
  1013. this.addToNumericResult(str, startIdx, offset, 10);
  1014. return -1;
  1015. }
  1016. /**
  1017. * Validate and emit a numeric entity.
  1018. *
  1019. * Implements the logic from the `Hexademical character reference start
  1020. * state` and `Numeric character reference end state` in the HTML spec.
  1021. *
  1022. * @param lastCp The last code point of the entity. Used to see if the
  1023. * entity was terminated with a semicolon.
  1024. * @param expectedLength The minimum number of characters that should be
  1025. * consumed. Used to validate that at least one digit
  1026. * was consumed.
  1027. * @returns The number of characters that were consumed.
  1028. */
  1029. emitNumericEntity(lastCp, expectedLength) {
  1030. var _a;
  1031. // Ensure we consumed at least one digit.
  1032. if (this.consumed <= expectedLength) {
  1033. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1034. return 0;
  1035. }
  1036. // Figure out if this is a legit end of the entity
  1037. if (lastCp === CharCodes.SEMI) {
  1038. this.consumed += 1;
  1039. }
  1040. else if (this.decodeMode === DecodingMode.Strict) {
  1041. return 0;
  1042. }
  1043. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  1044. if (this.errors) {
  1045. if (lastCp !== CharCodes.SEMI) {
  1046. this.errors.missingSemicolonAfterCharacterReference();
  1047. }
  1048. this.errors.validateNumericCharacterReference(this.result);
  1049. }
  1050. return this.consumed;
  1051. }
  1052. /**
  1053. * Parses a named entity.
  1054. *
  1055. * Equivalent to the `Named character reference state` in the HTML spec.
  1056. *
  1057. * @param str The string containing the entity (or a continuation of the entity).
  1058. * @param offset The current offset.
  1059. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1060. */
  1061. stateNamedEntity(str, offset) {
  1062. const { decodeTree } = this;
  1063. let current = decodeTree[this.treeIndex];
  1064. // The mask is the number of bytes of the value, including the current byte.
  1065. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1066. for (; offset < str.length; offset++, this.excess++) {
  1067. const char = str.charCodeAt(offset);
  1068. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1069. if (this.treeIndex < 0) {
  1070. return this.result === 0 ||
  1071. // If we are parsing an attribute
  1072. (this.decodeMode === DecodingMode.Attribute &&
  1073. // We shouldn't have consumed any characters after the entity,
  1074. (valueLength === 0 ||
  1075. // And there should be no invalid characters.
  1076. isEntityInAttributeInvalidEnd(char)))
  1077. ? 0
  1078. : this.emitNotTerminatedNamedEntity();
  1079. }
  1080. current = decodeTree[this.treeIndex];
  1081. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1082. // If the branch is a value, store it and continue
  1083. if (valueLength !== 0) {
  1084. // If the entity is terminated by a semicolon, we are done.
  1085. if (char === CharCodes.SEMI) {
  1086. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1087. }
  1088. // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
  1089. if (this.decodeMode !== DecodingMode.Strict) {
  1090. this.result = this.treeIndex;
  1091. this.consumed += this.excess;
  1092. this.excess = 0;
  1093. }
  1094. }
  1095. }
  1096. return -1;
  1097. }
  1098. /**
  1099. * Emit a named entity that was not terminated with a semicolon.
  1100. *
  1101. * @returns The number of characters consumed.
  1102. */
  1103. emitNotTerminatedNamedEntity() {
  1104. var _a;
  1105. const { result, decodeTree } = this;
  1106. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1107. this.emitNamedEntityData(result, valueLength, this.consumed);
  1108. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
  1109. return this.consumed;
  1110. }
  1111. /**
  1112. * Emit a named entity.
  1113. *
  1114. * @param result The index of the entity in the decode tree.
  1115. * @param valueLength The number of bytes in the entity.
  1116. * @param consumed The number of characters consumed.
  1117. *
  1118. * @returns The number of characters consumed.
  1119. */
  1120. emitNamedEntityData(result, valueLength, consumed) {
  1121. const { decodeTree } = this;
  1122. this.emitCodePoint(valueLength === 1
  1123. ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
  1124. : decodeTree[result + 1], consumed);
  1125. if (valueLength === 3) {
  1126. // For multi-byte values, we need to emit the second byte.
  1127. this.emitCodePoint(decodeTree[result + 2], consumed);
  1128. }
  1129. return consumed;
  1130. }
  1131. /**
  1132. * Signal to the parser that the end of the input was reached.
  1133. *
  1134. * Remaining data will be emitted and relevant errors will be produced.
  1135. *
  1136. * @returns The number of characters consumed.
  1137. */
  1138. end() {
  1139. var _a;
  1140. switch (this.state) {
  1141. case EntityDecoderState.NamedEntity: {
  1142. // Emit a named entity if we have one.
  1143. return this.result !== 0 &&
  1144. (this.decodeMode !== DecodingMode.Attribute ||
  1145. this.result === this.treeIndex)
  1146. ? this.emitNotTerminatedNamedEntity()
  1147. : 0;
  1148. }
  1149. // Otherwise, emit a numeric entity if we have one.
  1150. case EntityDecoderState.NumericDecimal: {
  1151. return this.emitNumericEntity(0, 2);
  1152. }
  1153. case EntityDecoderState.NumericHex: {
  1154. return this.emitNumericEntity(0, 3);
  1155. }
  1156. case EntityDecoderState.NumericStart: {
  1157. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1158. return 0;
  1159. }
  1160. case EntityDecoderState.EntityStart: {
  1161. // Return 0 if we have no entity.
  1162. return 0;
  1163. }
  1164. }
  1165. }
  1166. }
  1167. /**
  1168. * Creates a function that decodes entities in a string.
  1169. *
  1170. * @param decodeTree The decode tree.
  1171. * @returns A function that decodes entities in a string.
  1172. */
  1173. function getDecoder(decodeTree) {
  1174. let ret = "";
  1175. const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));
  1176. return function decodeWithTrie(str, decodeMode) {
  1177. let lastIndex = 0;
  1178. let offset = 0;
  1179. while ((offset = str.indexOf("&", offset)) >= 0) {
  1180. ret += str.slice(lastIndex, offset);
  1181. decoder.startEntity(decodeMode);
  1182. const len = decoder.write(str,
  1183. // Skip the "&"
  1184. offset + 1);
  1185. if (len < 0) {
  1186. lastIndex = offset + decoder.end();
  1187. break;
  1188. }
  1189. lastIndex = offset + len;
  1190. // If `len` is 0, skip the current `&` and continue.
  1191. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1192. }
  1193. const result = ret + str.slice(lastIndex);
  1194. // Make sure we don't keep a reference to the final string.
  1195. ret = "";
  1196. return result;
  1197. };
  1198. }
  1199. /**
  1200. * Determines the branch of the current node that is taken given the current
  1201. * character. This function is used to traverse the trie.
  1202. *
  1203. * @param decodeTree The trie.
  1204. * @param current The current node.
  1205. * @param nodeIdx The index right after the current node and its value.
  1206. * @param char The current character.
  1207. * @returns The index of the next node, or -1 if no branch is taken.
  1208. */
  1209. function determineBranch(decodeTree, current, nodeIdx, char) {
  1210. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1211. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1212. // Case 1: Single branch encoded in jump offset
  1213. if (branchCount === 0) {
  1214. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1215. }
  1216. // Case 2: Multiple branches encoded in jump table
  1217. if (jumpOffset) {
  1218. const value = char - jumpOffset;
  1219. return value < 0 || value >= branchCount
  1220. ? -1
  1221. : decodeTree[nodeIdx + value] - 1;
  1222. }
  1223. // Case 3: Multiple branches encoded in dictionary
  1224. // Binary search for the character.
  1225. let lo = nodeIdx;
  1226. let hi = lo + branchCount - 1;
  1227. while (lo <= hi) {
  1228. const mid = (lo + hi) >>> 1;
  1229. const midVal = decodeTree[mid];
  1230. if (midVal < char) {
  1231. lo = mid + 1;
  1232. }
  1233. else if (midVal > char) {
  1234. hi = mid - 1;
  1235. }
  1236. else {
  1237. return decodeTree[mid + branchCount];
  1238. }
  1239. }
  1240. return -1;
  1241. }
  1242. const htmlDecoder = getDecoder(htmlDecodeTree);
  1243. getDecoder(xmlDecodeTree);
  1244. /**
  1245. * Decodes an HTML string.
  1246. *
  1247. * @param str The string to decode.
  1248. * @param mode The decoding mode.
  1249. * @returns The decoded string.
  1250. */
  1251. function decodeHTML(str, mode = DecodingMode.Legacy) {
  1252. return htmlDecoder(str, mode);
  1253. }
  1254. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  1255. const defaultDelimitersClose = new Uint8Array([125, 125]);
  1256. function isTagStartChar(c) {
  1257. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  1258. }
  1259. function isWhitespace(c) {
  1260. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  1261. }
  1262. function isEndOfTagSection(c) {
  1263. return c === 47 || c === 62 || isWhitespace(c);
  1264. }
  1265. function toCharCodes(str) {
  1266. const ret = new Uint8Array(str.length);
  1267. for (let i = 0; i < str.length; i++) {
  1268. ret[i] = str.charCodeAt(i);
  1269. }
  1270. return ret;
  1271. }
  1272. const Sequences = {
  1273. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  1274. // CDATA[
  1275. CdataEnd: new Uint8Array([93, 93, 62]),
  1276. // ]]>
  1277. CommentEnd: new Uint8Array([45, 45, 62]),
  1278. // `-->`
  1279. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  1280. // `<\/script`
  1281. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  1282. // `</style`
  1283. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  1284. // `</title`
  1285. TextareaEnd: new Uint8Array([
  1286. 60,
  1287. 47,
  1288. 116,
  1289. 101,
  1290. 120,
  1291. 116,
  1292. 97,
  1293. 114,
  1294. 101,
  1295. 97
  1296. ])
  1297. // `</textarea
  1298. };
  1299. class Tokenizer {
  1300. constructor(stack, cbs) {
  1301. this.stack = stack;
  1302. this.cbs = cbs;
  1303. /** The current state the tokenizer is in. */
  1304. this.state = 1;
  1305. /** The read buffer. */
  1306. this.buffer = "";
  1307. /** The beginning of the section that is currently being read. */
  1308. this.sectionStart = 0;
  1309. /** The index within the buffer that we are currently looking at. */
  1310. this.index = 0;
  1311. /** The start of the last entity. */
  1312. this.entityStart = 0;
  1313. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  1314. this.baseState = 1;
  1315. /** For special parsing behavior inside of script and style tags. */
  1316. this.inRCDATA = false;
  1317. /** For disabling RCDATA tags handling */
  1318. this.inXML = false;
  1319. /** For disabling interpolation parsing in v-pre */
  1320. this.inVPre = false;
  1321. /** Record newline positions for fast line / column calculation */
  1322. this.newlines = [];
  1323. this.mode = 0;
  1324. this.delimiterOpen = defaultDelimitersOpen;
  1325. this.delimiterClose = defaultDelimitersClose;
  1326. this.delimiterIndex = -1;
  1327. this.currentSequence = void 0;
  1328. this.sequenceIndex = 0;
  1329. {
  1330. this.entityDecoder = new EntityDecoder(
  1331. htmlDecodeTree,
  1332. (cp, consumed) => this.emitCodePoint(cp, consumed)
  1333. );
  1334. }
  1335. }
  1336. get inSFCRoot() {
  1337. return this.mode === 2 && this.stack.length === 0;
  1338. }
  1339. reset() {
  1340. this.state = 1;
  1341. this.mode = 0;
  1342. this.buffer = "";
  1343. this.sectionStart = 0;
  1344. this.index = 0;
  1345. this.baseState = 1;
  1346. this.inRCDATA = false;
  1347. this.currentSequence = void 0;
  1348. this.newlines.length = 0;
  1349. this.delimiterOpen = defaultDelimitersOpen;
  1350. this.delimiterClose = defaultDelimitersClose;
  1351. }
  1352. /**
  1353. * Generate Position object with line / column information using recorded
  1354. * newline positions. We know the index is always going to be an already
  1355. * processed index, so all the newlines up to this index should have been
  1356. * recorded.
  1357. */
  1358. getPos(index) {
  1359. let line = 1;
  1360. let column = index + 1;
  1361. for (let i = this.newlines.length - 1; i >= 0; i--) {
  1362. const newlineIndex = this.newlines[i];
  1363. if (index > newlineIndex) {
  1364. line = i + 2;
  1365. column = index - newlineIndex;
  1366. break;
  1367. }
  1368. }
  1369. return {
  1370. column,
  1371. line,
  1372. offset: index
  1373. };
  1374. }
  1375. peek() {
  1376. return this.buffer.charCodeAt(this.index + 1);
  1377. }
  1378. stateText(c) {
  1379. if (c === 60) {
  1380. if (this.index > this.sectionStart) {
  1381. this.cbs.ontext(this.sectionStart, this.index);
  1382. }
  1383. this.state = 5;
  1384. this.sectionStart = this.index;
  1385. } else if (c === 38) {
  1386. this.startEntity();
  1387. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1388. this.state = 2;
  1389. this.delimiterIndex = 0;
  1390. this.stateInterpolationOpen(c);
  1391. }
  1392. }
  1393. stateInterpolationOpen(c) {
  1394. if (c === this.delimiterOpen[this.delimiterIndex]) {
  1395. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  1396. const start = this.index + 1 - this.delimiterOpen.length;
  1397. if (start > this.sectionStart) {
  1398. this.cbs.ontext(this.sectionStart, start);
  1399. }
  1400. this.state = 3;
  1401. this.sectionStart = start;
  1402. } else {
  1403. this.delimiterIndex++;
  1404. }
  1405. } else if (this.inRCDATA) {
  1406. this.state = 32;
  1407. this.stateInRCDATA(c);
  1408. } else {
  1409. this.state = 1;
  1410. this.stateText(c);
  1411. }
  1412. }
  1413. stateInterpolation(c) {
  1414. if (c === this.delimiterClose[0]) {
  1415. this.state = 4;
  1416. this.delimiterIndex = 0;
  1417. this.stateInterpolationClose(c);
  1418. }
  1419. }
  1420. stateInterpolationClose(c) {
  1421. if (c === this.delimiterClose[this.delimiterIndex]) {
  1422. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  1423. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  1424. if (this.inRCDATA) {
  1425. this.state = 32;
  1426. } else {
  1427. this.state = 1;
  1428. }
  1429. this.sectionStart = this.index + 1;
  1430. } else {
  1431. this.delimiterIndex++;
  1432. }
  1433. } else {
  1434. this.state = 3;
  1435. this.stateInterpolation(c);
  1436. }
  1437. }
  1438. stateSpecialStartSequence(c) {
  1439. const isEnd = this.sequenceIndex === this.currentSequence.length;
  1440. const isMatch = isEnd ? (
  1441. // If we are at the end of the sequence, make sure the tag name has ended
  1442. isEndOfTagSection(c)
  1443. ) : (
  1444. // Otherwise, do a case-insensitive comparison
  1445. (c | 32) === this.currentSequence[this.sequenceIndex]
  1446. );
  1447. if (!isMatch) {
  1448. this.inRCDATA = false;
  1449. } else if (!isEnd) {
  1450. this.sequenceIndex++;
  1451. return;
  1452. }
  1453. this.sequenceIndex = 0;
  1454. this.state = 6;
  1455. this.stateInTagName(c);
  1456. }
  1457. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  1458. stateInRCDATA(c) {
  1459. if (this.sequenceIndex === this.currentSequence.length) {
  1460. if (c === 62 || isWhitespace(c)) {
  1461. const endOfText = this.index - this.currentSequence.length;
  1462. if (this.sectionStart < endOfText) {
  1463. const actualIndex = this.index;
  1464. this.index = endOfText;
  1465. this.cbs.ontext(this.sectionStart, endOfText);
  1466. this.index = actualIndex;
  1467. }
  1468. this.sectionStart = endOfText + 2;
  1469. this.stateInClosingTagName(c);
  1470. this.inRCDATA = false;
  1471. return;
  1472. }
  1473. this.sequenceIndex = 0;
  1474. }
  1475. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  1476. this.sequenceIndex += 1;
  1477. } else if (this.sequenceIndex === 0) {
  1478. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  1479. if (c === 38) {
  1480. this.startEntity();
  1481. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1482. this.state = 2;
  1483. this.delimiterIndex = 0;
  1484. this.stateInterpolationOpen(c);
  1485. }
  1486. } else if (this.fastForwardTo(60)) {
  1487. this.sequenceIndex = 1;
  1488. }
  1489. } else {
  1490. this.sequenceIndex = Number(c === 60);
  1491. }
  1492. }
  1493. stateCDATASequence(c) {
  1494. if (c === Sequences.Cdata[this.sequenceIndex]) {
  1495. if (++this.sequenceIndex === Sequences.Cdata.length) {
  1496. this.state = 28;
  1497. this.currentSequence = Sequences.CdataEnd;
  1498. this.sequenceIndex = 0;
  1499. this.sectionStart = this.index + 1;
  1500. }
  1501. } else {
  1502. this.sequenceIndex = 0;
  1503. this.state = 23;
  1504. this.stateInDeclaration(c);
  1505. }
  1506. }
  1507. /**
  1508. * When we wait for one specific character, we can speed things up
  1509. * by skipping through the buffer until we find it.
  1510. *
  1511. * @returns Whether the character was found.
  1512. */
  1513. fastForwardTo(c) {
  1514. while (++this.index < this.buffer.length) {
  1515. const cc = this.buffer.charCodeAt(this.index);
  1516. if (cc === 10) {
  1517. this.newlines.push(this.index);
  1518. }
  1519. if (cc === c) {
  1520. return true;
  1521. }
  1522. }
  1523. this.index = this.buffer.length - 1;
  1524. return false;
  1525. }
  1526. /**
  1527. * Comments and CDATA end with `-->` and `]]>`.
  1528. *
  1529. * Their common qualities are:
  1530. * - Their end sequences have a distinct character they start with.
  1531. * - That character is then repeated, so we have to check multiple repeats.
  1532. * - All characters but the start character of the sequence can be skipped.
  1533. */
  1534. stateInCommentLike(c) {
  1535. if (c === this.currentSequence[this.sequenceIndex]) {
  1536. if (++this.sequenceIndex === this.currentSequence.length) {
  1537. if (this.currentSequence === Sequences.CdataEnd) {
  1538. this.cbs.oncdata(this.sectionStart, this.index - 2);
  1539. } else {
  1540. this.cbs.oncomment(this.sectionStart, this.index - 2);
  1541. }
  1542. this.sequenceIndex = 0;
  1543. this.sectionStart = this.index + 1;
  1544. this.state = 1;
  1545. }
  1546. } else if (this.sequenceIndex === 0) {
  1547. if (this.fastForwardTo(this.currentSequence[0])) {
  1548. this.sequenceIndex = 1;
  1549. }
  1550. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  1551. this.sequenceIndex = 0;
  1552. }
  1553. }
  1554. startSpecial(sequence, offset) {
  1555. this.enterRCDATA(sequence, offset);
  1556. this.state = 31;
  1557. }
  1558. enterRCDATA(sequence, offset) {
  1559. this.inRCDATA = true;
  1560. this.currentSequence = sequence;
  1561. this.sequenceIndex = offset;
  1562. }
  1563. stateBeforeTagName(c) {
  1564. if (c === 33) {
  1565. this.state = 22;
  1566. this.sectionStart = this.index + 1;
  1567. } else if (c === 63) {
  1568. this.state = 24;
  1569. this.sectionStart = this.index + 1;
  1570. } else if (isTagStartChar(c)) {
  1571. this.sectionStart = this.index;
  1572. if (this.mode === 0) {
  1573. this.state = 6;
  1574. } else if (this.inSFCRoot) {
  1575. this.state = 34;
  1576. } else if (!this.inXML) {
  1577. if (c === 116) {
  1578. this.state = 30;
  1579. } else {
  1580. this.state = c === 115 ? 29 : 6;
  1581. }
  1582. } else {
  1583. this.state = 6;
  1584. }
  1585. } else if (c === 47) {
  1586. this.state = 8;
  1587. } else {
  1588. this.state = 1;
  1589. this.stateText(c);
  1590. }
  1591. }
  1592. stateInTagName(c) {
  1593. if (isEndOfTagSection(c)) {
  1594. this.handleTagName(c);
  1595. }
  1596. }
  1597. stateInSFCRootTagName(c) {
  1598. if (isEndOfTagSection(c)) {
  1599. const tag = this.buffer.slice(this.sectionStart, this.index);
  1600. if (tag !== "template") {
  1601. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  1602. }
  1603. this.handleTagName(c);
  1604. }
  1605. }
  1606. handleTagName(c) {
  1607. this.cbs.onopentagname(this.sectionStart, this.index);
  1608. this.sectionStart = -1;
  1609. this.state = 11;
  1610. this.stateBeforeAttrName(c);
  1611. }
  1612. stateBeforeClosingTagName(c) {
  1613. if (isWhitespace(c)) ; else if (c === 62) {
  1614. {
  1615. this.cbs.onerr(14, this.index);
  1616. }
  1617. this.state = 1;
  1618. this.sectionStart = this.index + 1;
  1619. } else {
  1620. this.state = isTagStartChar(c) ? 9 : 27;
  1621. this.sectionStart = this.index;
  1622. }
  1623. }
  1624. stateInClosingTagName(c) {
  1625. if (c === 62 || isWhitespace(c)) {
  1626. this.cbs.onclosetag(this.sectionStart, this.index);
  1627. this.sectionStart = -1;
  1628. this.state = 10;
  1629. this.stateAfterClosingTagName(c);
  1630. }
  1631. }
  1632. stateAfterClosingTagName(c) {
  1633. if (c === 62) {
  1634. this.state = 1;
  1635. this.sectionStart = this.index + 1;
  1636. }
  1637. }
  1638. stateBeforeAttrName(c) {
  1639. if (c === 62) {
  1640. this.cbs.onopentagend(this.index);
  1641. if (this.inRCDATA) {
  1642. this.state = 32;
  1643. } else {
  1644. this.state = 1;
  1645. }
  1646. this.sectionStart = this.index + 1;
  1647. } else if (c === 47) {
  1648. this.state = 7;
  1649. if (this.peek() !== 62) {
  1650. this.cbs.onerr(22, this.index);
  1651. }
  1652. } else if (c === 60 && this.peek() === 47) {
  1653. this.cbs.onopentagend(this.index);
  1654. this.state = 5;
  1655. this.sectionStart = this.index;
  1656. } else if (!isWhitespace(c)) {
  1657. if (c === 61) {
  1658. this.cbs.onerr(
  1659. 19,
  1660. this.index
  1661. );
  1662. }
  1663. this.handleAttrStart(c);
  1664. }
  1665. }
  1666. handleAttrStart(c) {
  1667. if (c === 118 && this.peek() === 45) {
  1668. this.state = 13;
  1669. this.sectionStart = this.index;
  1670. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  1671. this.cbs.ondirname(this.index, this.index + 1);
  1672. this.state = 14;
  1673. this.sectionStart = this.index + 1;
  1674. } else {
  1675. this.state = 12;
  1676. this.sectionStart = this.index;
  1677. }
  1678. }
  1679. stateInSelfClosingTag(c) {
  1680. if (c === 62) {
  1681. this.cbs.onselfclosingtag(this.index);
  1682. this.state = 1;
  1683. this.sectionStart = this.index + 1;
  1684. this.inRCDATA = false;
  1685. } else if (!isWhitespace(c)) {
  1686. this.state = 11;
  1687. this.stateBeforeAttrName(c);
  1688. }
  1689. }
  1690. stateInAttrName(c) {
  1691. if (c === 61 || isEndOfTagSection(c)) {
  1692. this.cbs.onattribname(this.sectionStart, this.index);
  1693. this.handleAttrNameEnd(c);
  1694. } else if (c === 34 || c === 39 || c === 60) {
  1695. this.cbs.onerr(
  1696. 17,
  1697. this.index
  1698. );
  1699. }
  1700. }
  1701. stateInDirName(c) {
  1702. if (c === 61 || isEndOfTagSection(c)) {
  1703. this.cbs.ondirname(this.sectionStart, this.index);
  1704. this.handleAttrNameEnd(c);
  1705. } else if (c === 58) {
  1706. this.cbs.ondirname(this.sectionStart, this.index);
  1707. this.state = 14;
  1708. this.sectionStart = this.index + 1;
  1709. } else if (c === 46) {
  1710. this.cbs.ondirname(this.sectionStart, this.index);
  1711. this.state = 16;
  1712. this.sectionStart = this.index + 1;
  1713. }
  1714. }
  1715. stateInDirArg(c) {
  1716. if (c === 61 || isEndOfTagSection(c)) {
  1717. this.cbs.ondirarg(this.sectionStart, this.index);
  1718. this.handleAttrNameEnd(c);
  1719. } else if (c === 91) {
  1720. this.state = 15;
  1721. } else if (c === 46) {
  1722. this.cbs.ondirarg(this.sectionStart, this.index);
  1723. this.state = 16;
  1724. this.sectionStart = this.index + 1;
  1725. }
  1726. }
  1727. stateInDynamicDirArg(c) {
  1728. if (c === 93) {
  1729. this.state = 14;
  1730. } else if (c === 61 || isEndOfTagSection(c)) {
  1731. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  1732. this.handleAttrNameEnd(c);
  1733. {
  1734. this.cbs.onerr(
  1735. 27,
  1736. this.index
  1737. );
  1738. }
  1739. }
  1740. }
  1741. stateInDirModifier(c) {
  1742. if (c === 61 || isEndOfTagSection(c)) {
  1743. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1744. this.handleAttrNameEnd(c);
  1745. } else if (c === 46) {
  1746. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1747. this.sectionStart = this.index + 1;
  1748. }
  1749. }
  1750. handleAttrNameEnd(c) {
  1751. this.sectionStart = this.index;
  1752. this.state = 17;
  1753. this.cbs.onattribnameend(this.index);
  1754. this.stateAfterAttrName(c);
  1755. }
  1756. stateAfterAttrName(c) {
  1757. if (c === 61) {
  1758. this.state = 18;
  1759. } else if (c === 47 || c === 62) {
  1760. this.cbs.onattribend(0, this.sectionStart);
  1761. this.sectionStart = -1;
  1762. this.state = 11;
  1763. this.stateBeforeAttrName(c);
  1764. } else if (!isWhitespace(c)) {
  1765. this.cbs.onattribend(0, this.sectionStart);
  1766. this.handleAttrStart(c);
  1767. }
  1768. }
  1769. stateBeforeAttrValue(c) {
  1770. if (c === 34) {
  1771. this.state = 19;
  1772. this.sectionStart = this.index + 1;
  1773. } else if (c === 39) {
  1774. this.state = 20;
  1775. this.sectionStart = this.index + 1;
  1776. } else if (!isWhitespace(c)) {
  1777. this.sectionStart = this.index;
  1778. this.state = 21;
  1779. this.stateInAttrValueNoQuotes(c);
  1780. }
  1781. }
  1782. handleInAttrValue(c, quote) {
  1783. if (c === quote || false) {
  1784. this.cbs.onattribdata(this.sectionStart, this.index);
  1785. this.sectionStart = -1;
  1786. this.cbs.onattribend(
  1787. quote === 34 ? 3 : 2,
  1788. this.index + 1
  1789. );
  1790. this.state = 11;
  1791. } else if (c === 38) {
  1792. this.startEntity();
  1793. }
  1794. }
  1795. stateInAttrValueDoubleQuotes(c) {
  1796. this.handleInAttrValue(c, 34);
  1797. }
  1798. stateInAttrValueSingleQuotes(c) {
  1799. this.handleInAttrValue(c, 39);
  1800. }
  1801. stateInAttrValueNoQuotes(c) {
  1802. if (isWhitespace(c) || c === 62) {
  1803. this.cbs.onattribdata(this.sectionStart, this.index);
  1804. this.sectionStart = -1;
  1805. this.cbs.onattribend(1, this.index);
  1806. this.state = 11;
  1807. this.stateBeforeAttrName(c);
  1808. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1809. this.cbs.onerr(
  1810. 18,
  1811. this.index
  1812. );
  1813. } else if (c === 38) {
  1814. this.startEntity();
  1815. }
  1816. }
  1817. stateBeforeDeclaration(c) {
  1818. if (c === 91) {
  1819. this.state = 26;
  1820. this.sequenceIndex = 0;
  1821. } else {
  1822. this.state = c === 45 ? 25 : 23;
  1823. }
  1824. }
  1825. stateInDeclaration(c) {
  1826. if (c === 62 || this.fastForwardTo(62)) {
  1827. this.state = 1;
  1828. this.sectionStart = this.index + 1;
  1829. }
  1830. }
  1831. stateInProcessingInstruction(c) {
  1832. if (c === 62 || this.fastForwardTo(62)) {
  1833. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1834. this.state = 1;
  1835. this.sectionStart = this.index + 1;
  1836. }
  1837. }
  1838. stateBeforeComment(c) {
  1839. if (c === 45) {
  1840. this.state = 28;
  1841. this.currentSequence = Sequences.CommentEnd;
  1842. this.sequenceIndex = 2;
  1843. this.sectionStart = this.index + 1;
  1844. } else {
  1845. this.state = 23;
  1846. }
  1847. }
  1848. stateInSpecialComment(c) {
  1849. if (c === 62 || this.fastForwardTo(62)) {
  1850. this.cbs.oncomment(this.sectionStart, this.index);
  1851. this.state = 1;
  1852. this.sectionStart = this.index + 1;
  1853. }
  1854. }
  1855. stateBeforeSpecialS(c) {
  1856. if (c === Sequences.ScriptEnd[3]) {
  1857. this.startSpecial(Sequences.ScriptEnd, 4);
  1858. } else if (c === Sequences.StyleEnd[3]) {
  1859. this.startSpecial(Sequences.StyleEnd, 4);
  1860. } else {
  1861. this.state = 6;
  1862. this.stateInTagName(c);
  1863. }
  1864. }
  1865. stateBeforeSpecialT(c) {
  1866. if (c === Sequences.TitleEnd[3]) {
  1867. this.startSpecial(Sequences.TitleEnd, 4);
  1868. } else if (c === Sequences.TextareaEnd[3]) {
  1869. this.startSpecial(Sequences.TextareaEnd, 4);
  1870. } else {
  1871. this.state = 6;
  1872. this.stateInTagName(c);
  1873. }
  1874. }
  1875. startEntity() {
  1876. {
  1877. this.baseState = this.state;
  1878. this.state = 33;
  1879. this.entityStart = this.index;
  1880. this.entityDecoder.startEntity(
  1881. this.baseState === 1 || this.baseState === 32 ? DecodingMode.Legacy : DecodingMode.Attribute
  1882. );
  1883. }
  1884. }
  1885. stateInEntity() {
  1886. {
  1887. const length = this.entityDecoder.write(this.buffer, this.index);
  1888. if (length >= 0) {
  1889. this.state = this.baseState;
  1890. if (length === 0) {
  1891. this.index = this.entityStart;
  1892. }
  1893. } else {
  1894. this.index = this.buffer.length - 1;
  1895. }
  1896. }
  1897. }
  1898. /**
  1899. * Iterates through the buffer, calling the function corresponding to the current state.
  1900. *
  1901. * States that are more likely to be hit are higher up, as a performance improvement.
  1902. */
  1903. parse(input) {
  1904. this.buffer = input;
  1905. while (this.index < this.buffer.length) {
  1906. const c = this.buffer.charCodeAt(this.index);
  1907. if (c === 10) {
  1908. this.newlines.push(this.index);
  1909. }
  1910. switch (this.state) {
  1911. case 1: {
  1912. this.stateText(c);
  1913. break;
  1914. }
  1915. case 2: {
  1916. this.stateInterpolationOpen(c);
  1917. break;
  1918. }
  1919. case 3: {
  1920. this.stateInterpolation(c);
  1921. break;
  1922. }
  1923. case 4: {
  1924. this.stateInterpolationClose(c);
  1925. break;
  1926. }
  1927. case 31: {
  1928. this.stateSpecialStartSequence(c);
  1929. break;
  1930. }
  1931. case 32: {
  1932. this.stateInRCDATA(c);
  1933. break;
  1934. }
  1935. case 26: {
  1936. this.stateCDATASequence(c);
  1937. break;
  1938. }
  1939. case 19: {
  1940. this.stateInAttrValueDoubleQuotes(c);
  1941. break;
  1942. }
  1943. case 12: {
  1944. this.stateInAttrName(c);
  1945. break;
  1946. }
  1947. case 13: {
  1948. this.stateInDirName(c);
  1949. break;
  1950. }
  1951. case 14: {
  1952. this.stateInDirArg(c);
  1953. break;
  1954. }
  1955. case 15: {
  1956. this.stateInDynamicDirArg(c);
  1957. break;
  1958. }
  1959. case 16: {
  1960. this.stateInDirModifier(c);
  1961. break;
  1962. }
  1963. case 28: {
  1964. this.stateInCommentLike(c);
  1965. break;
  1966. }
  1967. case 27: {
  1968. this.stateInSpecialComment(c);
  1969. break;
  1970. }
  1971. case 11: {
  1972. this.stateBeforeAttrName(c);
  1973. break;
  1974. }
  1975. case 6: {
  1976. this.stateInTagName(c);
  1977. break;
  1978. }
  1979. case 34: {
  1980. this.stateInSFCRootTagName(c);
  1981. break;
  1982. }
  1983. case 9: {
  1984. this.stateInClosingTagName(c);
  1985. break;
  1986. }
  1987. case 5: {
  1988. this.stateBeforeTagName(c);
  1989. break;
  1990. }
  1991. case 17: {
  1992. this.stateAfterAttrName(c);
  1993. break;
  1994. }
  1995. case 20: {
  1996. this.stateInAttrValueSingleQuotes(c);
  1997. break;
  1998. }
  1999. case 18: {
  2000. this.stateBeforeAttrValue(c);
  2001. break;
  2002. }
  2003. case 8: {
  2004. this.stateBeforeClosingTagName(c);
  2005. break;
  2006. }
  2007. case 10: {
  2008. this.stateAfterClosingTagName(c);
  2009. break;
  2010. }
  2011. case 29: {
  2012. this.stateBeforeSpecialS(c);
  2013. break;
  2014. }
  2015. case 30: {
  2016. this.stateBeforeSpecialT(c);
  2017. break;
  2018. }
  2019. case 21: {
  2020. this.stateInAttrValueNoQuotes(c);
  2021. break;
  2022. }
  2023. case 7: {
  2024. this.stateInSelfClosingTag(c);
  2025. break;
  2026. }
  2027. case 23: {
  2028. this.stateInDeclaration(c);
  2029. break;
  2030. }
  2031. case 22: {
  2032. this.stateBeforeDeclaration(c);
  2033. break;
  2034. }
  2035. case 25: {
  2036. this.stateBeforeComment(c);
  2037. break;
  2038. }
  2039. case 24: {
  2040. this.stateInProcessingInstruction(c);
  2041. break;
  2042. }
  2043. case 33: {
  2044. this.stateInEntity();
  2045. break;
  2046. }
  2047. }
  2048. this.index++;
  2049. }
  2050. this.cleanup();
  2051. this.finish();
  2052. }
  2053. /**
  2054. * Remove data that has already been consumed from the buffer.
  2055. */
  2056. cleanup() {
  2057. if (this.sectionStart !== this.index) {
  2058. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  2059. this.cbs.ontext(this.sectionStart, this.index);
  2060. this.sectionStart = this.index;
  2061. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  2062. this.cbs.onattribdata(this.sectionStart, this.index);
  2063. this.sectionStart = this.index;
  2064. }
  2065. }
  2066. }
  2067. finish() {
  2068. if (this.state === 33) {
  2069. this.entityDecoder.end();
  2070. this.state = this.baseState;
  2071. }
  2072. this.handleTrailingData();
  2073. this.cbs.onend();
  2074. }
  2075. /** Handle any trailing data. */
  2076. handleTrailingData() {
  2077. const endIndex = this.buffer.length;
  2078. if (this.sectionStart >= endIndex) {
  2079. return;
  2080. }
  2081. if (this.state === 28) {
  2082. if (this.currentSequence === Sequences.CdataEnd) {
  2083. this.cbs.oncdata(this.sectionStart, endIndex);
  2084. } else {
  2085. this.cbs.oncomment(this.sectionStart, endIndex);
  2086. }
  2087. } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
  2088. this.cbs.ontext(this.sectionStart, endIndex);
  2089. }
  2090. }
  2091. emitCodePoint(cp, consumed) {
  2092. {
  2093. if (this.baseState !== 1 && this.baseState !== 32) {
  2094. if (this.sectionStart < this.entityStart) {
  2095. this.cbs.onattribdata(this.sectionStart, this.entityStart);
  2096. }
  2097. this.sectionStart = this.entityStart + consumed;
  2098. this.index = this.sectionStart - 1;
  2099. this.cbs.onattribentity(
  2100. fromCodePoint(cp),
  2101. this.entityStart,
  2102. this.sectionStart
  2103. );
  2104. } else {
  2105. if (this.sectionStart < this.entityStart) {
  2106. this.cbs.ontext(this.sectionStart, this.entityStart);
  2107. }
  2108. this.sectionStart = this.entityStart + consumed;
  2109. this.index = this.sectionStart - 1;
  2110. this.cbs.ontextentity(
  2111. fromCodePoint(cp),
  2112. this.entityStart,
  2113. this.sectionStart
  2114. );
  2115. }
  2116. }
  2117. }
  2118. }
  2119. const CompilerDeprecationTypes = {
  2120. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  2121. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  2122. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  2123. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  2124. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2125. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  2126. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  2127. "COMPILER_FILTERS": "COMPILER_FILTERS"
  2128. };
  2129. const deprecationData = {
  2130. ["COMPILER_IS_ON_ELEMENT"]: {
  2131. message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
  2132. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  2133. },
  2134. ["COMPILER_V_BIND_SYNC"]: {
  2135. message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
  2136. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  2137. },
  2138. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  2139. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
  2140. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  2141. },
  2142. ["COMPILER_V_ON_NATIVE"]: {
  2143. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  2144. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  2145. },
  2146. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  2147. message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
  2148. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  2149. },
  2150. ["COMPILER_NATIVE_TEMPLATE"]: {
  2151. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  2152. },
  2153. ["COMPILER_INLINE_TEMPLATE"]: {
  2154. message: `"inline-template" has been removed in Vue 3.`,
  2155. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  2156. },
  2157. ["COMPILER_FILTERS"]: {
  2158. message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
  2159. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  2160. }
  2161. };
  2162. function getCompatValue(key, { compatConfig }) {
  2163. const value = compatConfig && compatConfig[key];
  2164. if (key === "MODE") {
  2165. return value || 3;
  2166. } else {
  2167. return value;
  2168. }
  2169. }
  2170. function isCompatEnabled(key, context) {
  2171. const mode = getCompatValue("MODE", context);
  2172. const value = getCompatValue(key, context);
  2173. return mode === 3 ? value === true : value !== false;
  2174. }
  2175. function checkCompatEnabled(key, context, loc, ...args) {
  2176. const enabled = isCompatEnabled(key, context);
  2177. if (enabled) {
  2178. warnDeprecation(key, context, loc, ...args);
  2179. }
  2180. return enabled;
  2181. }
  2182. function warnDeprecation(key, context, loc, ...args) {
  2183. const val = getCompatValue(key, context);
  2184. if (val === "suppress-warning") {
  2185. return;
  2186. }
  2187. const { message, link } = deprecationData[key];
  2188. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  2189. Details: ${link}` : ``}`;
  2190. const err = new SyntaxError(msg);
  2191. err.code = key;
  2192. if (loc) err.loc = loc;
  2193. context.onWarn(err);
  2194. }
  2195. function defaultOnError(error) {
  2196. throw error;
  2197. }
  2198. function defaultOnWarn(msg) {
  2199. console.warn(`[Vue warn] ${msg.message}`);
  2200. }
  2201. function createCompilerError(code, loc, messages, additionalMessage) {
  2202. const msg = (messages || errorMessages$1)[code] + (additionalMessage || ``) ;
  2203. const error = new SyntaxError(String(msg));
  2204. error.code = code;
  2205. error.loc = loc;
  2206. return error;
  2207. }
  2208. const ErrorCodes = {
  2209. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  2210. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  2211. "CDATA_IN_HTML_CONTENT": 1,
  2212. "1": "CDATA_IN_HTML_CONTENT",
  2213. "DUPLICATE_ATTRIBUTE": 2,
  2214. "2": "DUPLICATE_ATTRIBUTE",
  2215. "END_TAG_WITH_ATTRIBUTES": 3,
  2216. "3": "END_TAG_WITH_ATTRIBUTES",
  2217. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  2218. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  2219. "EOF_BEFORE_TAG_NAME": 5,
  2220. "5": "EOF_BEFORE_TAG_NAME",
  2221. "EOF_IN_CDATA": 6,
  2222. "6": "EOF_IN_CDATA",
  2223. "EOF_IN_COMMENT": 7,
  2224. "7": "EOF_IN_COMMENT",
  2225. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  2226. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  2227. "EOF_IN_TAG": 9,
  2228. "9": "EOF_IN_TAG",
  2229. "INCORRECTLY_CLOSED_COMMENT": 10,
  2230. "10": "INCORRECTLY_CLOSED_COMMENT",
  2231. "INCORRECTLY_OPENED_COMMENT": 11,
  2232. "11": "INCORRECTLY_OPENED_COMMENT",
  2233. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  2234. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  2235. "MISSING_ATTRIBUTE_VALUE": 13,
  2236. "13": "MISSING_ATTRIBUTE_VALUE",
  2237. "MISSING_END_TAG_NAME": 14,
  2238. "14": "MISSING_END_TAG_NAME",
  2239. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  2240. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  2241. "NESTED_COMMENT": 16,
  2242. "16": "NESTED_COMMENT",
  2243. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  2244. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  2245. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  2246. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  2247. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  2248. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  2249. "UNEXPECTED_NULL_CHARACTER": 20,
  2250. "20": "UNEXPECTED_NULL_CHARACTER",
  2251. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  2252. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  2253. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  2254. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  2255. "X_INVALID_END_TAG": 23,
  2256. "23": "X_INVALID_END_TAG",
  2257. "X_MISSING_END_TAG": 24,
  2258. "24": "X_MISSING_END_TAG",
  2259. "X_MISSING_INTERPOLATION_END": 25,
  2260. "25": "X_MISSING_INTERPOLATION_END",
  2261. "X_MISSING_DIRECTIVE_NAME": 26,
  2262. "26": "X_MISSING_DIRECTIVE_NAME",
  2263. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  2264. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  2265. "X_V_IF_NO_EXPRESSION": 28,
  2266. "28": "X_V_IF_NO_EXPRESSION",
  2267. "X_V_IF_SAME_KEY": 29,
  2268. "29": "X_V_IF_SAME_KEY",
  2269. "X_V_ELSE_NO_ADJACENT_IF": 30,
  2270. "30": "X_V_ELSE_NO_ADJACENT_IF",
  2271. "X_V_FOR_NO_EXPRESSION": 31,
  2272. "31": "X_V_FOR_NO_EXPRESSION",
  2273. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  2274. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  2275. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  2276. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  2277. "X_V_BIND_NO_EXPRESSION": 34,
  2278. "34": "X_V_BIND_NO_EXPRESSION",
  2279. "X_V_ON_NO_EXPRESSION": 35,
  2280. "35": "X_V_ON_NO_EXPRESSION",
  2281. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  2282. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  2283. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  2284. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  2285. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  2286. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  2287. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  2288. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  2289. "X_V_SLOT_MISPLACED": 40,
  2290. "40": "X_V_SLOT_MISPLACED",
  2291. "X_V_MODEL_NO_EXPRESSION": 41,
  2292. "41": "X_V_MODEL_NO_EXPRESSION",
  2293. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  2294. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  2295. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  2296. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  2297. "X_V_MODEL_ON_PROPS": 44,
  2298. "44": "X_V_MODEL_ON_PROPS",
  2299. "X_INVALID_EXPRESSION": 45,
  2300. "45": "X_INVALID_EXPRESSION",
  2301. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  2302. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  2303. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  2304. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  2305. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  2306. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  2307. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  2308. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  2309. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  2310. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  2311. "X_VNODE_HOOKS": 51,
  2312. "51": "X_VNODE_HOOKS",
  2313. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  2314. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  2315. "__EXTEND_POINT__": 53,
  2316. "53": "__EXTEND_POINT__"
  2317. };
  2318. const errorMessages$1 = {
  2319. // parse errors
  2320. [0]: "Illegal comment.",
  2321. [1]: "CDATA section is allowed only in XML context.",
  2322. [2]: "Duplicate attribute.",
  2323. [3]: "End tag cannot have attributes.",
  2324. [4]: "Illegal '/' in tags.",
  2325. [5]: "Unexpected EOF in tag.",
  2326. [6]: "Unexpected EOF in CDATA section.",
  2327. [7]: "Unexpected EOF in comment.",
  2328. [8]: "Unexpected EOF in script.",
  2329. [9]: "Unexpected EOF in tag.",
  2330. [10]: "Incorrectly closed comment.",
  2331. [11]: "Incorrectly opened comment.",
  2332. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  2333. [13]: "Attribute value was expected.",
  2334. [14]: "End tag name was expected.",
  2335. [15]: "Whitespace was expected.",
  2336. [16]: "Unexpected '<!--' in comment.",
  2337. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  2338. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  2339. [19]: "Attribute name cannot start with '='.",
  2340. [21]: "'<?' is allowed only in XML context.",
  2341. [20]: `Unexpected null character.`,
  2342. [22]: "Illegal '/' in tags.",
  2343. // Vue-specific parse errors
  2344. [23]: "Invalid end tag.",
  2345. [24]: "Element is missing end tag.",
  2346. [25]: "Interpolation end sign was not found.",
  2347. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  2348. [26]: "Legal directive name was expected.",
  2349. // transform errors
  2350. [28]: `v-if/v-else-if is missing expression.`,
  2351. [29]: `v-if/else branches must use unique keys.`,
  2352. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  2353. [31]: `v-for is missing expression.`,
  2354. [32]: `v-for has invalid expression.`,
  2355. [33]: `<template v-for> key should be placed on the <template> tag.`,
  2356. [34]: `v-bind is missing expression.`,
  2357. [52]: `v-bind with same-name shorthand only allows static argument.`,
  2358. [35]: `v-on is missing expression.`,
  2359. [36]: `Unexpected custom directive on <slot> outlet.`,
  2360. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  2361. [38]: `Duplicate slot names found. `,
  2362. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  2363. [40]: `v-slot can only be used on components or <template> tags.`,
  2364. [41]: `v-model is missing expression.`,
  2365. [42]: `v-model value must be a valid JavaScript member expression.`,
  2366. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  2367. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  2368. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  2369. [45]: `Error parsing JavaScript expression: `,
  2370. [46]: `<KeepAlive> expects exactly one child component.`,
  2371. [51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
  2372. // generic errors
  2373. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  2374. [48]: `ES module mode is not supported in this build of compiler.`,
  2375. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  2376. [50]: `"scopeId" option is only supported in module mode.`,
  2377. // just to fulfill types
  2378. [53]: ``
  2379. };
  2380. function getDefaultExportFromCjs (x) {
  2381. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2382. }
  2383. function getAugmentedNamespace(n) {
  2384. if (n.__esModule) return n;
  2385. var f = n.default;
  2386. if (typeof f == "function") {
  2387. var a = function a () {
  2388. if (this instanceof a) {
  2389. return Reflect.construct(f, arguments, this.constructor);
  2390. }
  2391. return f.apply(this, arguments);
  2392. };
  2393. a.prototype = f.prototype;
  2394. } else a = {};
  2395. Object.defineProperty(a, '__esModule', {value: true});
  2396. Object.keys(n).forEach(function (k) {
  2397. var d = Object.getOwnPropertyDescriptor(n, k);
  2398. Object.defineProperty(a, k, d.get ? d : {
  2399. enumerable: true,
  2400. get: function () {
  2401. return n[k];
  2402. }
  2403. });
  2404. });
  2405. return a;
  2406. }
  2407. var lib = {};
  2408. var hasRequiredLib;
  2409. function requireLib () {
  2410. if (hasRequiredLib) return lib;
  2411. hasRequiredLib = 1;
  2412. Object.defineProperty(lib, '__esModule', {
  2413. value: true
  2414. });
  2415. function _objectWithoutPropertiesLoose(r, e) {
  2416. if (null == r) return {};
  2417. var t = {};
  2418. for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
  2419. if (e.includes(n)) continue;
  2420. t[n] = r[n];
  2421. }
  2422. return t;
  2423. }
  2424. class Position {
  2425. constructor(line, col, index) {
  2426. this.line = void 0;
  2427. this.column = void 0;
  2428. this.index = void 0;
  2429. this.line = line;
  2430. this.column = col;
  2431. this.index = index;
  2432. }
  2433. }
  2434. class SourceLocation {
  2435. constructor(start, end) {
  2436. this.start = void 0;
  2437. this.end = void 0;
  2438. this.filename = void 0;
  2439. this.identifierName = void 0;
  2440. this.start = start;
  2441. this.end = end;
  2442. }
  2443. }
  2444. function createPositionWithColumnOffset(position, columnOffset) {
  2445. const {
  2446. line,
  2447. column,
  2448. index
  2449. } = position;
  2450. return new Position(line, column + columnOffset, index + columnOffset);
  2451. }
  2452. const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
  2453. var ModuleErrors = {
  2454. ImportMetaOutsideModule: {
  2455. message: `import.meta may appear only with 'sourceType: "module"'`,
  2456. code
  2457. },
  2458. ImportOutsideModule: {
  2459. message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
  2460. code
  2461. }
  2462. };
  2463. const NodeDescriptions = {
  2464. ArrayPattern: "array destructuring pattern",
  2465. AssignmentExpression: "assignment expression",
  2466. AssignmentPattern: "assignment expression",
  2467. ArrowFunctionExpression: "arrow function expression",
  2468. ConditionalExpression: "conditional expression",
  2469. CatchClause: "catch clause",
  2470. ForOfStatement: "for-of statement",
  2471. ForInStatement: "for-in statement",
  2472. ForStatement: "for-loop",
  2473. FormalParameters: "function parameter list",
  2474. Identifier: "identifier",
  2475. ImportSpecifier: "import specifier",
  2476. ImportDefaultSpecifier: "import default specifier",
  2477. ImportNamespaceSpecifier: "import namespace specifier",
  2478. ObjectPattern: "object destructuring pattern",
  2479. ParenthesizedExpression: "parenthesized expression",
  2480. RestElement: "rest element",
  2481. UpdateExpression: {
  2482. true: "prefix operation",
  2483. false: "postfix operation"
  2484. },
  2485. VariableDeclarator: "variable declaration",
  2486. YieldExpression: "yield expression"
  2487. };
  2488. const toNodeDescription = node => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type];
  2489. var StandardErrors = {
  2490. AccessorIsGenerator: ({
  2491. kind
  2492. }) => `A ${kind}ter cannot be a generator.`,
  2493. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  2494. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  2495. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  2496. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  2497. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  2498. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  2499. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  2500. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  2501. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  2502. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  2503. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  2504. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  2505. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  2506. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  2507. ConstructorIsAsync: "Constructor can't be an async function.",
  2508. ConstructorIsGenerator: "Constructor can't be a generator.",
  2509. DeclarationMissingInitializer: ({
  2510. kind
  2511. }) => `Missing initializer in ${kind} declaration.`,
  2512. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  2513. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  2514. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  2515. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  2516. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  2517. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  2518. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  2519. DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
  2520. DeletePrivateField: "Deleting a private field is not allowed.",
  2521. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  2522. DuplicateConstructor: "Duplicate constructor in the same class.",
  2523. DuplicateDefaultExport: "Only one default export allowed per module.",
  2524. DuplicateExport: ({
  2525. exportName
  2526. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  2527. DuplicateProto: "Redefinition of __proto__ property.",
  2528. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  2529. DynamicImportPhaseRequiresImportExpressions: ({
  2530. phase
  2531. }) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`,
  2532. ElementAfterRest: "Rest element must be last element.",
  2533. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  2534. ExportBindingIsString: ({
  2535. localName,
  2536. exportName
  2537. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  2538. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  2539. ForInOfLoopInitializer: ({
  2540. type
  2541. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  2542. ForInUsing: "For-in loop may not start with 'using' declaration.",
  2543. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  2544. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  2545. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  2546. IllegalBreakContinue: ({
  2547. type
  2548. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  2549. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  2550. IllegalReturn: "'return' outside of function.",
  2551. ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.",
  2552. ImportBindingIsString: ({
  2553. importName
  2554. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  2555. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  2556. ImportCallArity: ({
  2557. maxArgumentCount
  2558. }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
  2559. ImportCallNotNewExpression: "Cannot use new with import(...).",
  2560. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  2561. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  2562. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  2563. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  2564. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  2565. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  2566. InvalidCodePoint: "Code point out of bounds.",
  2567. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  2568. InvalidDecimal: "Invalid decimal.",
  2569. InvalidDigit: ({
  2570. radix
  2571. }) => `Expected number in radix ${radix}.`,
  2572. InvalidEscapeSequence: "Bad character escape sequence.",
  2573. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  2574. InvalidEscapedReservedWord: ({
  2575. reservedWord
  2576. }) => `Escape sequence in keyword ${reservedWord}.`,
  2577. InvalidIdentifier: ({
  2578. identifierName
  2579. }) => `Invalid identifier ${identifierName}.`,
  2580. InvalidLhs: ({
  2581. ancestor
  2582. }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2583. InvalidLhsBinding: ({
  2584. ancestor
  2585. }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2586. InvalidLhsOptionalChaining: ({
  2587. ancestor
  2588. }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
  2589. InvalidNumber: "Invalid number.",
  2590. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  2591. InvalidOrUnexpectedToken: ({
  2592. unexpected
  2593. }) => `Unexpected character '${unexpected}'.`,
  2594. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  2595. InvalidPrivateFieldResolution: ({
  2596. identifierName
  2597. }) => `Private name #${identifierName} is not defined.`,
  2598. InvalidPropertyBindingPattern: "Binding member expression.",
  2599. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  2600. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  2601. LabelRedeclaration: ({
  2602. labelName
  2603. }) => `Label '${labelName}' is already declared.`,
  2604. LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
  2605. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  2606. MalformedRegExpFlags: "Invalid regular expression flag.",
  2607. MissingClassName: "A class name is required.",
  2608. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  2609. MissingSemicolon: "Missing semicolon.",
  2610. MissingPlugin: ({
  2611. missingPlugin
  2612. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2613. MissingOneOfPlugins: ({
  2614. missingPlugin
  2615. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2616. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  2617. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  2618. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  2619. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  2620. ModuleAttributesWithDuplicateKeys: ({
  2621. key
  2622. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  2623. ModuleExportNameHasLoneSurrogate: ({
  2624. surrogateCharCode
  2625. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  2626. ModuleExportUndefined: ({
  2627. localName
  2628. }) => `Export '${localName}' is not defined.`,
  2629. MultipleDefaultsInSwitch: "Multiple default clauses.",
  2630. NewlineAfterThrow: "Illegal newline after throw.",
  2631. NoCatchOrFinally: "Missing catch or finally clause.",
  2632. NumberIdentifier: "Identifier directly after number.",
  2633. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  2634. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  2635. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  2636. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  2637. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  2638. ParamDupe: "Argument name clash.",
  2639. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  2640. PatternHasMethod: "Object pattern can't contain methods.",
  2641. PrivateInExpectedIn: ({
  2642. identifierName
  2643. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  2644. PrivateNameRedeclaration: ({
  2645. identifierName
  2646. }) => `Duplicate private name #${identifierName}.`,
  2647. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2648. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2649. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2650. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  2651. RestTrailingComma: "Unexpected trailing comma after rest element.",
  2652. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  2653. SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
  2654. SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
  2655. StaticPrototype: "Classes may not have static property named prototype.",
  2656. 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?",
  2657. SuperPrivateField: "Private fields can't be accessed on super.",
  2658. TrailingDecorator: "Decorators must be attached to a class element.",
  2659. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2660. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2661. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2662. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  2663. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  2664. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  2665. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  2666. UnexpectedKeyword: ({
  2667. keyword
  2668. }) => `Unexpected keyword '${keyword}'.`,
  2669. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  2670. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  2671. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  2672. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  2673. UnexpectedPrivateField: "Unexpected private name.",
  2674. UnexpectedReservedWord: ({
  2675. reservedWord
  2676. }) => `Unexpected reserved word '${reservedWord}'.`,
  2677. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  2678. UnexpectedToken: ({
  2679. expected,
  2680. unexpected
  2681. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  2682. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  2683. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
  2684. UnsupportedBind: "Binding should be performed on object property.",
  2685. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  2686. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  2687. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  2688. UnsupportedMetaProperty: ({
  2689. target,
  2690. onlyValidPropertyName
  2691. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  2692. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  2693. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  2694. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  2695. UnterminatedComment: "Unterminated comment.",
  2696. UnterminatedRegExp: "Unterminated regular expression.",
  2697. UnterminatedString: "Unterminated string constant.",
  2698. UnterminatedTemplate: "Unterminated template.",
  2699. UsingDeclarationExport: "Using declaration cannot be exported.",
  2700. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  2701. VarRedeclaration: ({
  2702. identifierName
  2703. }) => `Identifier '${identifierName}' has already been declared.`,
  2704. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  2705. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  2706. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  2707. };
  2708. var StrictModeErrors = {
  2709. StrictDelete: "Deleting local variable in strict mode.",
  2710. StrictEvalArguments: ({
  2711. referenceName
  2712. }) => `Assigning to '${referenceName}' in strict mode.`,
  2713. StrictEvalArgumentsBinding: ({
  2714. bindingName
  2715. }) => `Binding '${bindingName}' in strict mode.`,
  2716. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  2717. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  2718. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  2719. StrictWith: "'with' in strict mode."
  2720. };
  2721. const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
  2722. var PipelineOperatorErrors = {
  2723. PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  2724. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  2725. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  2726. PipeTopicUnconfiguredToken: ({
  2727. token
  2728. }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
  2729. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  2730. PipeUnparenthesizedBody: ({
  2731. type
  2732. }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
  2733. type
  2734. })}; please wrap it in parentheses.`,
  2735. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  2736. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  2737. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  2738. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  2739. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  2740. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
  2741. };
  2742. const _excluded = ["message"];
  2743. function defineHidden(obj, key, value) {
  2744. Object.defineProperty(obj, key, {
  2745. enumerable: false,
  2746. configurable: true,
  2747. value
  2748. });
  2749. }
  2750. function toParseErrorConstructor({
  2751. toMessage,
  2752. code,
  2753. reasonCode,
  2754. syntaxPlugin
  2755. }) {
  2756. const hasMissingPlugin = reasonCode === "MissingPlugin" || reasonCode === "MissingOneOfPlugins";
  2757. return function constructor(loc, details) {
  2758. const error = new SyntaxError();
  2759. error.code = code;
  2760. error.reasonCode = reasonCode;
  2761. error.loc = loc;
  2762. error.pos = loc.index;
  2763. error.syntaxPlugin = syntaxPlugin;
  2764. if (hasMissingPlugin) {
  2765. error.missingPlugin = details.missingPlugin;
  2766. }
  2767. defineHidden(error, "clone", function clone(overrides = {}) {
  2768. var _overrides$loc;
  2769. const {
  2770. line,
  2771. column,
  2772. index
  2773. } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
  2774. return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
  2775. });
  2776. defineHidden(error, "details", details);
  2777. Object.defineProperty(error, "message", {
  2778. configurable: true,
  2779. get() {
  2780. const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
  2781. this.message = message;
  2782. return message;
  2783. },
  2784. set(value) {
  2785. Object.defineProperty(this, "message", {
  2786. value,
  2787. writable: true
  2788. });
  2789. }
  2790. });
  2791. return error;
  2792. };
  2793. }
  2794. function ParseErrorEnum(argument, syntaxPlugin) {
  2795. if (Array.isArray(argument)) {
  2796. return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
  2797. }
  2798. const ParseErrorConstructors = {};
  2799. for (const reasonCode of Object.keys(argument)) {
  2800. const template = argument[reasonCode];
  2801. const _ref = typeof template === "string" ? {
  2802. message: () => template
  2803. } : typeof template === "function" ? {
  2804. message: template
  2805. } : template,
  2806. {
  2807. message
  2808. } = _ref,
  2809. rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  2810. const toMessage = typeof message === "string" ? () => message : message;
  2811. ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
  2812. code: "BABEL_PARSER_SYNTAX_ERROR",
  2813. reasonCode,
  2814. toMessage
  2815. }, syntaxPlugin ? {
  2816. syntaxPlugin
  2817. } : {}, rest));
  2818. }
  2819. return ParseErrorConstructors;
  2820. }
  2821. const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
  2822. const {
  2823. defineProperty
  2824. } = Object;
  2825. const toUnenumerable = (object, key) => {
  2826. if (object) {
  2827. defineProperty(object, key, {
  2828. enumerable: false,
  2829. value: object[key]
  2830. });
  2831. }
  2832. };
  2833. function toESTreeLocation(node) {
  2834. toUnenumerable(node.loc.start, "index");
  2835. toUnenumerable(node.loc.end, "index");
  2836. return node;
  2837. }
  2838. var estree = superClass => class ESTreeParserMixin extends superClass {
  2839. parse() {
  2840. const file = toESTreeLocation(super.parse());
  2841. if (this.options.tokens) {
  2842. file.tokens = file.tokens.map(toESTreeLocation);
  2843. }
  2844. return file;
  2845. }
  2846. parseRegExpLiteral({
  2847. pattern,
  2848. flags
  2849. }) {
  2850. let regex = null;
  2851. try {
  2852. regex = new RegExp(pattern, flags);
  2853. } catch (_) {}
  2854. const node = this.estreeParseLiteral(regex);
  2855. node.regex = {
  2856. pattern,
  2857. flags
  2858. };
  2859. return node;
  2860. }
  2861. parseBigIntLiteral(value) {
  2862. let bigInt;
  2863. try {
  2864. bigInt = BigInt(value);
  2865. } catch (_unused) {
  2866. bigInt = null;
  2867. }
  2868. const node = this.estreeParseLiteral(bigInt);
  2869. node.bigint = String(node.value || value);
  2870. return node;
  2871. }
  2872. parseDecimalLiteral(value) {
  2873. const decimal = null;
  2874. const node = this.estreeParseLiteral(decimal);
  2875. node.decimal = String(node.value || value);
  2876. return node;
  2877. }
  2878. estreeParseLiteral(value) {
  2879. return this.parseLiteral(value, "Literal");
  2880. }
  2881. parseStringLiteral(value) {
  2882. return this.estreeParseLiteral(value);
  2883. }
  2884. parseNumericLiteral(value) {
  2885. return this.estreeParseLiteral(value);
  2886. }
  2887. parseNullLiteral() {
  2888. return this.estreeParseLiteral(null);
  2889. }
  2890. parseBooleanLiteral(value) {
  2891. return this.estreeParseLiteral(value);
  2892. }
  2893. directiveToStmt(directive) {
  2894. const expression = directive.value;
  2895. delete directive.value;
  2896. expression.type = "Literal";
  2897. expression.raw = expression.extra.raw;
  2898. expression.value = expression.extra.expressionValue;
  2899. const stmt = directive;
  2900. stmt.type = "ExpressionStatement";
  2901. stmt.expression = expression;
  2902. stmt.directive = expression.extra.rawValue;
  2903. delete expression.extra;
  2904. return stmt;
  2905. }
  2906. initFunction(node, isAsync) {
  2907. super.initFunction(node, isAsync);
  2908. node.expression = false;
  2909. }
  2910. checkDeclaration(node) {
  2911. if (node != null && this.isObjectProperty(node)) {
  2912. this.checkDeclaration(node.value);
  2913. } else {
  2914. super.checkDeclaration(node);
  2915. }
  2916. }
  2917. getObjectOrClassMethodParams(method) {
  2918. return method.value.params;
  2919. }
  2920. isValidDirective(stmt) {
  2921. var _stmt$expression$extr;
  2922. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  2923. }
  2924. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  2925. super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
  2926. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  2927. node.body = directiveStatements.concat(node.body);
  2928. delete node.directives;
  2929. }
  2930. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  2931. this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
  2932. if (method.typeParameters) {
  2933. method.value.typeParameters = method.typeParameters;
  2934. delete method.typeParameters;
  2935. }
  2936. classBody.body.push(method);
  2937. }
  2938. parsePrivateName() {
  2939. const node = super.parsePrivateName();
  2940. {
  2941. if (!this.getPluginOption("estree", "classFeatures")) {
  2942. return node;
  2943. }
  2944. }
  2945. return this.convertPrivateNameToPrivateIdentifier(node);
  2946. }
  2947. convertPrivateNameToPrivateIdentifier(node) {
  2948. const name = super.getPrivateNameSV(node);
  2949. node = node;
  2950. delete node.id;
  2951. node.name = name;
  2952. node.type = "PrivateIdentifier";
  2953. return node;
  2954. }
  2955. isPrivateName(node) {
  2956. {
  2957. if (!this.getPluginOption("estree", "classFeatures")) {
  2958. return super.isPrivateName(node);
  2959. }
  2960. }
  2961. return node.type === "PrivateIdentifier";
  2962. }
  2963. getPrivateNameSV(node) {
  2964. {
  2965. if (!this.getPluginOption("estree", "classFeatures")) {
  2966. return super.getPrivateNameSV(node);
  2967. }
  2968. }
  2969. return node.name;
  2970. }
  2971. parseLiteral(value, type) {
  2972. const node = super.parseLiteral(value, type);
  2973. node.raw = node.extra.raw;
  2974. delete node.extra;
  2975. return node;
  2976. }
  2977. parseFunctionBody(node, allowExpression, isMethod = false) {
  2978. super.parseFunctionBody(node, allowExpression, isMethod);
  2979. node.expression = node.body.type !== "BlockStatement";
  2980. }
  2981. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  2982. let funcNode = this.startNode();
  2983. funcNode.kind = node.kind;
  2984. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  2985. funcNode.type = "FunctionExpression";
  2986. delete funcNode.kind;
  2987. node.value = funcNode;
  2988. if (type === "ClassPrivateMethod") {
  2989. node.computed = false;
  2990. }
  2991. return this.finishNode(node, "MethodDefinition");
  2992. }
  2993. nameIsConstructor(key) {
  2994. if (key.type === "Literal") return key.value === "constructor";
  2995. return super.nameIsConstructor(key);
  2996. }
  2997. parseClassProperty(...args) {
  2998. const propertyNode = super.parseClassProperty(...args);
  2999. {
  3000. if (!this.getPluginOption("estree", "classFeatures")) {
  3001. return propertyNode;
  3002. }
  3003. }
  3004. propertyNode.type = "PropertyDefinition";
  3005. return propertyNode;
  3006. }
  3007. parseClassPrivateProperty(...args) {
  3008. const propertyNode = super.parseClassPrivateProperty(...args);
  3009. {
  3010. if (!this.getPluginOption("estree", "classFeatures")) {
  3011. return propertyNode;
  3012. }
  3013. }
  3014. propertyNode.type = "PropertyDefinition";
  3015. propertyNode.computed = false;
  3016. return propertyNode;
  3017. }
  3018. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  3019. const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
  3020. if (node) {
  3021. node.type = "Property";
  3022. if (node.kind === "method") {
  3023. node.kind = "init";
  3024. }
  3025. node.shorthand = false;
  3026. }
  3027. return node;
  3028. }
  3029. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  3030. const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  3031. if (node) {
  3032. node.kind = "init";
  3033. node.type = "Property";
  3034. }
  3035. return node;
  3036. }
  3037. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  3038. return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  3039. }
  3040. isAssignable(node, isBinding) {
  3041. if (node != null && this.isObjectProperty(node)) {
  3042. return this.isAssignable(node.value, isBinding);
  3043. }
  3044. return super.isAssignable(node, isBinding);
  3045. }
  3046. toAssignable(node, isLHS = false) {
  3047. if (node != null && this.isObjectProperty(node)) {
  3048. const {
  3049. key,
  3050. value
  3051. } = node;
  3052. if (this.isPrivateName(key)) {
  3053. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  3054. }
  3055. this.toAssignable(value, isLHS);
  3056. } else {
  3057. super.toAssignable(node, isLHS);
  3058. }
  3059. }
  3060. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  3061. if (prop.type === "Property" && (prop.kind === "get" || prop.kind === "set")) {
  3062. this.raise(Errors.PatternHasAccessor, prop.key);
  3063. } else if (prop.type === "Property" && prop.method) {
  3064. this.raise(Errors.PatternHasMethod, prop.key);
  3065. } else {
  3066. super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  3067. }
  3068. }
  3069. finishCallExpression(unfinished, optional) {
  3070. const node = super.finishCallExpression(unfinished, optional);
  3071. if (node.callee.type === "Import") {
  3072. node.type = "ImportExpression";
  3073. node.source = node.arguments[0];
  3074. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  3075. var _ref, _ref2;
  3076. node.options = (_ref = node.arguments[1]) != null ? _ref : null;
  3077. node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
  3078. }
  3079. delete node.arguments;
  3080. delete node.callee;
  3081. }
  3082. return node;
  3083. }
  3084. toReferencedArguments(node) {
  3085. if (node.type === "ImportExpression") {
  3086. return;
  3087. }
  3088. super.toReferencedArguments(node);
  3089. }
  3090. parseExport(unfinished, decorators) {
  3091. const exportStartLoc = this.state.lastTokStartLoc;
  3092. const node = super.parseExport(unfinished, decorators);
  3093. switch (node.type) {
  3094. case "ExportAllDeclaration":
  3095. node.exported = null;
  3096. break;
  3097. case "ExportNamedDeclaration":
  3098. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  3099. node.type = "ExportAllDeclaration";
  3100. node.exported = node.specifiers[0].exported;
  3101. delete node.specifiers;
  3102. }
  3103. case "ExportDefaultDeclaration":
  3104. {
  3105. var _declaration$decorato;
  3106. const {
  3107. declaration
  3108. } = node;
  3109. if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) {
  3110. this.resetStartLocation(node, exportStartLoc);
  3111. }
  3112. }
  3113. break;
  3114. }
  3115. return node;
  3116. }
  3117. parseSubscript(base, startLoc, noCalls, state) {
  3118. const node = super.parseSubscript(base, startLoc, noCalls, state);
  3119. if (state.optionalChainMember) {
  3120. if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
  3121. node.type = node.type.substring(8);
  3122. }
  3123. if (state.stop) {
  3124. const chain = this.startNodeAtNode(node);
  3125. chain.expression = node;
  3126. return this.finishNode(chain, "ChainExpression");
  3127. }
  3128. } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
  3129. node.optional = false;
  3130. }
  3131. return node;
  3132. }
  3133. isOptionalMemberExpression(node) {
  3134. if (node.type === "ChainExpression") {
  3135. return node.expression.type === "MemberExpression";
  3136. }
  3137. return super.isOptionalMemberExpression(node);
  3138. }
  3139. hasPropertyAsPrivateName(node) {
  3140. if (node.type === "ChainExpression") {
  3141. node = node.expression;
  3142. }
  3143. return super.hasPropertyAsPrivateName(node);
  3144. }
  3145. isObjectProperty(node) {
  3146. return node.type === "Property" && node.kind === "init" && !node.method;
  3147. }
  3148. isObjectMethod(node) {
  3149. return node.type === "Property" && (node.method || node.kind === "get" || node.kind === "set");
  3150. }
  3151. finishNodeAt(node, type, endLoc) {
  3152. return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
  3153. }
  3154. resetStartLocation(node, startLoc) {
  3155. super.resetStartLocation(node, startLoc);
  3156. toESTreeLocation(node);
  3157. }
  3158. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  3159. super.resetEndLocation(node, endLoc);
  3160. toESTreeLocation(node);
  3161. }
  3162. };
  3163. class TokContext {
  3164. constructor(token, preserveSpace) {
  3165. this.token = void 0;
  3166. this.preserveSpace = void 0;
  3167. this.token = token;
  3168. this.preserveSpace = !!preserveSpace;
  3169. }
  3170. }
  3171. const types = {
  3172. brace: new TokContext("{"),
  3173. j_oTag: new TokContext("<tag"),
  3174. j_cTag: new TokContext("</tag"),
  3175. j_expr: new TokContext("<tag>...</tag>", true)
  3176. };
  3177. {
  3178. types.template = new TokContext("`", true);
  3179. }
  3180. const beforeExpr = true;
  3181. const startsExpr = true;
  3182. const isLoop = true;
  3183. const isAssign = true;
  3184. const prefix = true;
  3185. const postfix = true;
  3186. class ExportedTokenType {
  3187. constructor(label, conf = {}) {
  3188. this.label = void 0;
  3189. this.keyword = void 0;
  3190. this.beforeExpr = void 0;
  3191. this.startsExpr = void 0;
  3192. this.rightAssociative = void 0;
  3193. this.isLoop = void 0;
  3194. this.isAssign = void 0;
  3195. this.prefix = void 0;
  3196. this.postfix = void 0;
  3197. this.binop = void 0;
  3198. this.label = label;
  3199. this.keyword = conf.keyword;
  3200. this.beforeExpr = !!conf.beforeExpr;
  3201. this.startsExpr = !!conf.startsExpr;
  3202. this.rightAssociative = !!conf.rightAssociative;
  3203. this.isLoop = !!conf.isLoop;
  3204. this.isAssign = !!conf.isAssign;
  3205. this.prefix = !!conf.prefix;
  3206. this.postfix = !!conf.postfix;
  3207. this.binop = conf.binop != null ? conf.binop : null;
  3208. {
  3209. this.updateContext = null;
  3210. }
  3211. }
  3212. }
  3213. const keywords$1 = new Map();
  3214. function createKeyword(name, options = {}) {
  3215. options.keyword = name;
  3216. const token = createToken(name, options);
  3217. keywords$1.set(name, token);
  3218. return token;
  3219. }
  3220. function createBinop(name, binop) {
  3221. return createToken(name, {
  3222. beforeExpr,
  3223. binop
  3224. });
  3225. }
  3226. let tokenTypeCounter = -1;
  3227. const tokenTypes = [];
  3228. const tokenLabels = [];
  3229. const tokenBinops = [];
  3230. const tokenBeforeExprs = [];
  3231. const tokenStartsExprs = [];
  3232. const tokenPrefixes = [];
  3233. function createToken(name, options = {}) {
  3234. var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
  3235. ++tokenTypeCounter;
  3236. tokenLabels.push(name);
  3237. tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
  3238. tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
  3239. tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
  3240. tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
  3241. tokenTypes.push(new ExportedTokenType(name, options));
  3242. return tokenTypeCounter;
  3243. }
  3244. function createKeywordLike(name, options = {}) {
  3245. var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
  3246. ++tokenTypeCounter;
  3247. keywords$1.set(name, tokenTypeCounter);
  3248. tokenLabels.push(name);
  3249. tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
  3250. tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
  3251. tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
  3252. tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
  3253. tokenTypes.push(new ExportedTokenType("name", options));
  3254. return tokenTypeCounter;
  3255. }
  3256. const tt = {
  3257. bracketL: createToken("[", {
  3258. beforeExpr,
  3259. startsExpr
  3260. }),
  3261. bracketHashL: createToken("#[", {
  3262. beforeExpr,
  3263. startsExpr
  3264. }),
  3265. bracketBarL: createToken("[|", {
  3266. beforeExpr,
  3267. startsExpr
  3268. }),
  3269. bracketR: createToken("]"),
  3270. bracketBarR: createToken("|]"),
  3271. braceL: createToken("{", {
  3272. beforeExpr,
  3273. startsExpr
  3274. }),
  3275. braceBarL: createToken("{|", {
  3276. beforeExpr,
  3277. startsExpr
  3278. }),
  3279. braceHashL: createToken("#{", {
  3280. beforeExpr,
  3281. startsExpr
  3282. }),
  3283. braceR: createToken("}"),
  3284. braceBarR: createToken("|}"),
  3285. parenL: createToken("(", {
  3286. beforeExpr,
  3287. startsExpr
  3288. }),
  3289. parenR: createToken(")"),
  3290. comma: createToken(",", {
  3291. beforeExpr
  3292. }),
  3293. semi: createToken(";", {
  3294. beforeExpr
  3295. }),
  3296. colon: createToken(":", {
  3297. beforeExpr
  3298. }),
  3299. doubleColon: createToken("::", {
  3300. beforeExpr
  3301. }),
  3302. dot: createToken("."),
  3303. question: createToken("?", {
  3304. beforeExpr
  3305. }),
  3306. questionDot: createToken("?."),
  3307. arrow: createToken("=>", {
  3308. beforeExpr
  3309. }),
  3310. template: createToken("template"),
  3311. ellipsis: createToken("...", {
  3312. beforeExpr
  3313. }),
  3314. backQuote: createToken("`", {
  3315. startsExpr
  3316. }),
  3317. dollarBraceL: createToken("${", {
  3318. beforeExpr,
  3319. startsExpr
  3320. }),
  3321. templateTail: createToken("...`", {
  3322. startsExpr
  3323. }),
  3324. templateNonTail: createToken("...${", {
  3325. beforeExpr,
  3326. startsExpr
  3327. }),
  3328. at: createToken("@"),
  3329. hash: createToken("#", {
  3330. startsExpr
  3331. }),
  3332. interpreterDirective: createToken("#!..."),
  3333. eq: createToken("=", {
  3334. beforeExpr,
  3335. isAssign
  3336. }),
  3337. assign: createToken("_=", {
  3338. beforeExpr,
  3339. isAssign
  3340. }),
  3341. slashAssign: createToken("_=", {
  3342. beforeExpr,
  3343. isAssign
  3344. }),
  3345. xorAssign: createToken("_=", {
  3346. beforeExpr,
  3347. isAssign
  3348. }),
  3349. moduloAssign: createToken("_=", {
  3350. beforeExpr,
  3351. isAssign
  3352. }),
  3353. incDec: createToken("++/--", {
  3354. prefix,
  3355. postfix,
  3356. startsExpr
  3357. }),
  3358. bang: createToken("!", {
  3359. beforeExpr,
  3360. prefix,
  3361. startsExpr
  3362. }),
  3363. tilde: createToken("~", {
  3364. beforeExpr,
  3365. prefix,
  3366. startsExpr
  3367. }),
  3368. doubleCaret: createToken("^^", {
  3369. startsExpr
  3370. }),
  3371. doubleAt: createToken("@@", {
  3372. startsExpr
  3373. }),
  3374. pipeline: createBinop("|>", 0),
  3375. nullishCoalescing: createBinop("??", 1),
  3376. logicalOR: createBinop("||", 1),
  3377. logicalAND: createBinop("&&", 2),
  3378. bitwiseOR: createBinop("|", 3),
  3379. bitwiseXOR: createBinop("^", 4),
  3380. bitwiseAND: createBinop("&", 5),
  3381. equality: createBinop("==/!=/===/!==", 6),
  3382. lt: createBinop("</>/<=/>=", 7),
  3383. gt: createBinop("</>/<=/>=", 7),
  3384. relational: createBinop("</>/<=/>=", 7),
  3385. bitShift: createBinop("<</>>/>>>", 8),
  3386. bitShiftL: createBinop("<</>>/>>>", 8),
  3387. bitShiftR: createBinop("<</>>/>>>", 8),
  3388. plusMin: createToken("+/-", {
  3389. beforeExpr,
  3390. binop: 9,
  3391. prefix,
  3392. startsExpr
  3393. }),
  3394. modulo: createToken("%", {
  3395. binop: 10,
  3396. startsExpr
  3397. }),
  3398. star: createToken("*", {
  3399. binop: 10
  3400. }),
  3401. slash: createBinop("/", 10),
  3402. exponent: createToken("**", {
  3403. beforeExpr,
  3404. binop: 11,
  3405. rightAssociative: true
  3406. }),
  3407. _in: createKeyword("in", {
  3408. beforeExpr,
  3409. binop: 7
  3410. }),
  3411. _instanceof: createKeyword("instanceof", {
  3412. beforeExpr,
  3413. binop: 7
  3414. }),
  3415. _break: createKeyword("break"),
  3416. _case: createKeyword("case", {
  3417. beforeExpr
  3418. }),
  3419. _catch: createKeyword("catch"),
  3420. _continue: createKeyword("continue"),
  3421. _debugger: createKeyword("debugger"),
  3422. _default: createKeyword("default", {
  3423. beforeExpr
  3424. }),
  3425. _else: createKeyword("else", {
  3426. beforeExpr
  3427. }),
  3428. _finally: createKeyword("finally"),
  3429. _function: createKeyword("function", {
  3430. startsExpr
  3431. }),
  3432. _if: createKeyword("if"),
  3433. _return: createKeyword("return", {
  3434. beforeExpr
  3435. }),
  3436. _switch: createKeyword("switch"),
  3437. _throw: createKeyword("throw", {
  3438. beforeExpr,
  3439. prefix,
  3440. startsExpr
  3441. }),
  3442. _try: createKeyword("try"),
  3443. _var: createKeyword("var"),
  3444. _const: createKeyword("const"),
  3445. _with: createKeyword("with"),
  3446. _new: createKeyword("new", {
  3447. beforeExpr,
  3448. startsExpr
  3449. }),
  3450. _this: createKeyword("this", {
  3451. startsExpr
  3452. }),
  3453. _super: createKeyword("super", {
  3454. startsExpr
  3455. }),
  3456. _class: createKeyword("class", {
  3457. startsExpr
  3458. }),
  3459. _extends: createKeyword("extends", {
  3460. beforeExpr
  3461. }),
  3462. _export: createKeyword("export"),
  3463. _import: createKeyword("import", {
  3464. startsExpr
  3465. }),
  3466. _null: createKeyword("null", {
  3467. startsExpr
  3468. }),
  3469. _true: createKeyword("true", {
  3470. startsExpr
  3471. }),
  3472. _false: createKeyword("false", {
  3473. startsExpr
  3474. }),
  3475. _typeof: createKeyword("typeof", {
  3476. beforeExpr,
  3477. prefix,
  3478. startsExpr
  3479. }),
  3480. _void: createKeyword("void", {
  3481. beforeExpr,
  3482. prefix,
  3483. startsExpr
  3484. }),
  3485. _delete: createKeyword("delete", {
  3486. beforeExpr,
  3487. prefix,
  3488. startsExpr
  3489. }),
  3490. _do: createKeyword("do", {
  3491. isLoop,
  3492. beforeExpr
  3493. }),
  3494. _for: createKeyword("for", {
  3495. isLoop
  3496. }),
  3497. _while: createKeyword("while", {
  3498. isLoop
  3499. }),
  3500. _as: createKeywordLike("as", {
  3501. startsExpr
  3502. }),
  3503. _assert: createKeywordLike("assert", {
  3504. startsExpr
  3505. }),
  3506. _async: createKeywordLike("async", {
  3507. startsExpr
  3508. }),
  3509. _await: createKeywordLike("await", {
  3510. startsExpr
  3511. }),
  3512. _defer: createKeywordLike("defer", {
  3513. startsExpr
  3514. }),
  3515. _from: createKeywordLike("from", {
  3516. startsExpr
  3517. }),
  3518. _get: createKeywordLike("get", {
  3519. startsExpr
  3520. }),
  3521. _let: createKeywordLike("let", {
  3522. startsExpr
  3523. }),
  3524. _meta: createKeywordLike("meta", {
  3525. startsExpr
  3526. }),
  3527. _of: createKeywordLike("of", {
  3528. startsExpr
  3529. }),
  3530. _sent: createKeywordLike("sent", {
  3531. startsExpr
  3532. }),
  3533. _set: createKeywordLike("set", {
  3534. startsExpr
  3535. }),
  3536. _source: createKeywordLike("source", {
  3537. startsExpr
  3538. }),
  3539. _static: createKeywordLike("static", {
  3540. startsExpr
  3541. }),
  3542. _using: createKeywordLike("using", {
  3543. startsExpr
  3544. }),
  3545. _yield: createKeywordLike("yield", {
  3546. startsExpr
  3547. }),
  3548. _asserts: createKeywordLike("asserts", {
  3549. startsExpr
  3550. }),
  3551. _checks: createKeywordLike("checks", {
  3552. startsExpr
  3553. }),
  3554. _exports: createKeywordLike("exports", {
  3555. startsExpr
  3556. }),
  3557. _global: createKeywordLike("global", {
  3558. startsExpr
  3559. }),
  3560. _implements: createKeywordLike("implements", {
  3561. startsExpr
  3562. }),
  3563. _intrinsic: createKeywordLike("intrinsic", {
  3564. startsExpr
  3565. }),
  3566. _infer: createKeywordLike("infer", {
  3567. startsExpr
  3568. }),
  3569. _is: createKeywordLike("is", {
  3570. startsExpr
  3571. }),
  3572. _mixins: createKeywordLike("mixins", {
  3573. startsExpr
  3574. }),
  3575. _proto: createKeywordLike("proto", {
  3576. startsExpr
  3577. }),
  3578. _require: createKeywordLike("require", {
  3579. startsExpr
  3580. }),
  3581. _satisfies: createKeywordLike("satisfies", {
  3582. startsExpr
  3583. }),
  3584. _keyof: createKeywordLike("keyof", {
  3585. startsExpr
  3586. }),
  3587. _readonly: createKeywordLike("readonly", {
  3588. startsExpr
  3589. }),
  3590. _unique: createKeywordLike("unique", {
  3591. startsExpr
  3592. }),
  3593. _abstract: createKeywordLike("abstract", {
  3594. startsExpr
  3595. }),
  3596. _declare: createKeywordLike("declare", {
  3597. startsExpr
  3598. }),
  3599. _enum: createKeywordLike("enum", {
  3600. startsExpr
  3601. }),
  3602. _module: createKeywordLike("module", {
  3603. startsExpr
  3604. }),
  3605. _namespace: createKeywordLike("namespace", {
  3606. startsExpr
  3607. }),
  3608. _interface: createKeywordLike("interface", {
  3609. startsExpr
  3610. }),
  3611. _type: createKeywordLike("type", {
  3612. startsExpr
  3613. }),
  3614. _opaque: createKeywordLike("opaque", {
  3615. startsExpr
  3616. }),
  3617. name: createToken("name", {
  3618. startsExpr
  3619. }),
  3620. string: createToken("string", {
  3621. startsExpr
  3622. }),
  3623. num: createToken("num", {
  3624. startsExpr
  3625. }),
  3626. bigint: createToken("bigint", {
  3627. startsExpr
  3628. }),
  3629. decimal: createToken("decimal", {
  3630. startsExpr
  3631. }),
  3632. regexp: createToken("regexp", {
  3633. startsExpr
  3634. }),
  3635. privateName: createToken("#name", {
  3636. startsExpr
  3637. }),
  3638. eof: createToken("eof"),
  3639. jsxName: createToken("jsxName"),
  3640. jsxText: createToken("jsxText", {
  3641. beforeExpr: true
  3642. }),
  3643. jsxTagStart: createToken("jsxTagStart", {
  3644. startsExpr: true
  3645. }),
  3646. jsxTagEnd: createToken("jsxTagEnd"),
  3647. placeholder: createToken("%%", {
  3648. startsExpr: true
  3649. })
  3650. };
  3651. function tokenIsIdentifier(token) {
  3652. return token >= 93 && token <= 132;
  3653. }
  3654. function tokenKeywordOrIdentifierIsKeyword(token) {
  3655. return token <= 92;
  3656. }
  3657. function tokenIsKeywordOrIdentifier(token) {
  3658. return token >= 58 && token <= 132;
  3659. }
  3660. function tokenIsLiteralPropertyName(token) {
  3661. return token >= 58 && token <= 136;
  3662. }
  3663. function tokenComesBeforeExpression(token) {
  3664. return tokenBeforeExprs[token];
  3665. }
  3666. function tokenCanStartExpression(token) {
  3667. return tokenStartsExprs[token];
  3668. }
  3669. function tokenIsAssignment(token) {
  3670. return token >= 29 && token <= 33;
  3671. }
  3672. function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
  3673. return token >= 129 && token <= 131;
  3674. }
  3675. function tokenIsLoop(token) {
  3676. return token >= 90 && token <= 92;
  3677. }
  3678. function tokenIsKeyword(token) {
  3679. return token >= 58 && token <= 92;
  3680. }
  3681. function tokenIsOperator(token) {
  3682. return token >= 39 && token <= 59;
  3683. }
  3684. function tokenIsPostfix(token) {
  3685. return token === 34;
  3686. }
  3687. function tokenIsPrefix(token) {
  3688. return tokenPrefixes[token];
  3689. }
  3690. function tokenIsTSTypeOperator(token) {
  3691. return token >= 121 && token <= 123;
  3692. }
  3693. function tokenIsTSDeclarationStart(token) {
  3694. return token >= 124 && token <= 130;
  3695. }
  3696. function tokenLabelName(token) {
  3697. return tokenLabels[token];
  3698. }
  3699. function tokenOperatorPrecedence(token) {
  3700. return tokenBinops[token];
  3701. }
  3702. function tokenIsRightAssociative(token) {
  3703. return token === 57;
  3704. }
  3705. function tokenIsTemplate(token) {
  3706. return token >= 24 && token <= 25;
  3707. }
  3708. function getExportedToken(token) {
  3709. return tokenTypes[token];
  3710. }
  3711. {
  3712. tokenTypes[8].updateContext = context => {
  3713. context.pop();
  3714. };
  3715. tokenTypes[5].updateContext = tokenTypes[7].updateContext = tokenTypes[23].updateContext = context => {
  3716. context.push(types.brace);
  3717. };
  3718. tokenTypes[22].updateContext = context => {
  3719. if (context[context.length - 1] === types.template) {
  3720. context.pop();
  3721. } else {
  3722. context.push(types.template);
  3723. }
  3724. };
  3725. tokenTypes[142].updateContext = context => {
  3726. context.push(types.j_expr, types.j_oTag);
  3727. };
  3728. }
  3729. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\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-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
  3730. 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\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
  3731. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3732. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3733. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  3734. const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 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, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 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, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 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, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
  3735. 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, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 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, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
  3736. function isInAstralSet(code, set) {
  3737. let pos = 0x10000;
  3738. for (let i = 0, length = set.length; i < length; i += 2) {
  3739. pos += set[i];
  3740. if (pos > code) return false;
  3741. pos += set[i + 1];
  3742. if (pos >= code) return true;
  3743. }
  3744. return false;
  3745. }
  3746. function isIdentifierStart(code) {
  3747. if (code < 65) return code === 36;
  3748. if (code <= 90) return true;
  3749. if (code < 97) return code === 95;
  3750. if (code <= 122) return true;
  3751. if (code <= 0xffff) {
  3752. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  3753. }
  3754. return isInAstralSet(code, astralIdentifierStartCodes);
  3755. }
  3756. function isIdentifierChar(code) {
  3757. if (code < 48) return code === 36;
  3758. if (code < 58) return true;
  3759. if (code < 65) return false;
  3760. if (code <= 90) return true;
  3761. if (code < 97) return code === 95;
  3762. if (code <= 122) return true;
  3763. if (code <= 0xffff) {
  3764. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  3765. }
  3766. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  3767. }
  3768. const reservedWords = {
  3769. 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"],
  3770. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  3771. strictBind: ["eval", "arguments"]
  3772. };
  3773. const keywords = new Set(reservedWords.keyword);
  3774. const reservedWordsStrictSet = new Set(reservedWords.strict);
  3775. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  3776. function isReservedWord(word, inModule) {
  3777. return inModule && word === "await" || word === "enum";
  3778. }
  3779. function isStrictReservedWord(word, inModule) {
  3780. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  3781. }
  3782. function isStrictBindOnlyReservedWord(word) {
  3783. return reservedWordsStrictBindSet.has(word);
  3784. }
  3785. function isStrictBindReservedWord(word, inModule) {
  3786. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  3787. }
  3788. function isKeyword(word) {
  3789. return keywords.has(word);
  3790. }
  3791. function isIteratorStart(current, next, next2) {
  3792. return current === 64 && next === 64 && isIdentifierStart(next2);
  3793. }
  3794. 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"]);
  3795. function canBeReservedWord(word) {
  3796. return reservedWordLikeSet.has(word);
  3797. }
  3798. class Scope {
  3799. constructor(flags) {
  3800. this.flags = 0;
  3801. this.names = new Map();
  3802. this.firstLexicalName = "";
  3803. this.flags = flags;
  3804. }
  3805. }
  3806. class ScopeHandler {
  3807. constructor(parser, inModule) {
  3808. this.parser = void 0;
  3809. this.scopeStack = [];
  3810. this.inModule = void 0;
  3811. this.undefinedExports = new Map();
  3812. this.parser = parser;
  3813. this.inModule = inModule;
  3814. }
  3815. get inTopLevel() {
  3816. return (this.currentScope().flags & 1) > 0;
  3817. }
  3818. get inFunction() {
  3819. return (this.currentVarScopeFlags() & 2) > 0;
  3820. }
  3821. get allowSuper() {
  3822. return (this.currentThisScopeFlags() & 16) > 0;
  3823. }
  3824. get allowDirectSuper() {
  3825. return (this.currentThisScopeFlags() & 32) > 0;
  3826. }
  3827. get inClass() {
  3828. return (this.currentThisScopeFlags() & 64) > 0;
  3829. }
  3830. get inClassAndNotInNonArrowFunction() {
  3831. const flags = this.currentThisScopeFlags();
  3832. return (flags & 64) > 0 && (flags & 2) === 0;
  3833. }
  3834. get inStaticBlock() {
  3835. for (let i = this.scopeStack.length - 1;; i--) {
  3836. const {
  3837. flags
  3838. } = this.scopeStack[i];
  3839. if (flags & 128) {
  3840. return true;
  3841. }
  3842. if (flags & (387 | 64)) {
  3843. return false;
  3844. }
  3845. }
  3846. }
  3847. get inNonArrowFunction() {
  3848. return (this.currentThisScopeFlags() & 2) > 0;
  3849. }
  3850. get treatFunctionsAsVar() {
  3851. return this.treatFunctionsAsVarInScope(this.currentScope());
  3852. }
  3853. createScope(flags) {
  3854. return new Scope(flags);
  3855. }
  3856. enter(flags) {
  3857. this.scopeStack.push(this.createScope(flags));
  3858. }
  3859. exit() {
  3860. const scope = this.scopeStack.pop();
  3861. return scope.flags;
  3862. }
  3863. treatFunctionsAsVarInScope(scope) {
  3864. return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1);
  3865. }
  3866. declareName(name, bindingType, loc) {
  3867. let scope = this.currentScope();
  3868. if (bindingType & 8 || bindingType & 16) {
  3869. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3870. let type = scope.names.get(name) || 0;
  3871. if (bindingType & 16) {
  3872. type = type | 4;
  3873. } else {
  3874. if (!scope.firstLexicalName) {
  3875. scope.firstLexicalName = name;
  3876. }
  3877. type = type | 2;
  3878. }
  3879. scope.names.set(name, type);
  3880. if (bindingType & 8) {
  3881. this.maybeExportDefined(scope, name);
  3882. }
  3883. } else if (bindingType & 4) {
  3884. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  3885. scope = this.scopeStack[i];
  3886. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3887. scope.names.set(name, (scope.names.get(name) || 0) | 1);
  3888. this.maybeExportDefined(scope, name);
  3889. if (scope.flags & 387) break;
  3890. }
  3891. }
  3892. if (this.parser.inModule && scope.flags & 1) {
  3893. this.undefinedExports.delete(name);
  3894. }
  3895. }
  3896. maybeExportDefined(scope, name) {
  3897. if (this.parser.inModule && scope.flags & 1) {
  3898. this.undefinedExports.delete(name);
  3899. }
  3900. }
  3901. checkRedeclarationInScope(scope, name, bindingType, loc) {
  3902. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  3903. this.parser.raise(Errors.VarRedeclaration, loc, {
  3904. identifierName: name
  3905. });
  3906. }
  3907. }
  3908. isRedeclaredInScope(scope, name, bindingType) {
  3909. if (!(bindingType & 1)) return false;
  3910. if (bindingType & 8) {
  3911. return scope.names.has(name);
  3912. }
  3913. const type = scope.names.get(name);
  3914. if (bindingType & 16) {
  3915. return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0;
  3916. }
  3917. return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0;
  3918. }
  3919. checkLocalExport(id) {
  3920. const {
  3921. name
  3922. } = id;
  3923. const topLevelScope = this.scopeStack[0];
  3924. if (!topLevelScope.names.has(name)) {
  3925. this.undefinedExports.set(name, id.loc.start);
  3926. }
  3927. }
  3928. currentScope() {
  3929. return this.scopeStack[this.scopeStack.length - 1];
  3930. }
  3931. currentVarScopeFlags() {
  3932. for (let i = this.scopeStack.length - 1;; i--) {
  3933. const {
  3934. flags
  3935. } = this.scopeStack[i];
  3936. if (flags & 387) {
  3937. return flags;
  3938. }
  3939. }
  3940. }
  3941. currentThisScopeFlags() {
  3942. for (let i = this.scopeStack.length - 1;; i--) {
  3943. const {
  3944. flags
  3945. } = this.scopeStack[i];
  3946. if (flags & (387 | 64) && !(flags & 4)) {
  3947. return flags;
  3948. }
  3949. }
  3950. }
  3951. }
  3952. class FlowScope extends Scope {
  3953. constructor(...args) {
  3954. super(...args);
  3955. this.declareFunctions = new Set();
  3956. }
  3957. }
  3958. class FlowScopeHandler extends ScopeHandler {
  3959. createScope(flags) {
  3960. return new FlowScope(flags);
  3961. }
  3962. declareName(name, bindingType, loc) {
  3963. const scope = this.currentScope();
  3964. if (bindingType & 2048) {
  3965. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3966. this.maybeExportDefined(scope, name);
  3967. scope.declareFunctions.add(name);
  3968. return;
  3969. }
  3970. super.declareName(name, bindingType, loc);
  3971. }
  3972. isRedeclaredInScope(scope, name, bindingType) {
  3973. if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
  3974. if (bindingType & 2048 && !scope.declareFunctions.has(name)) {
  3975. const type = scope.names.get(name);
  3976. return (type & 4) > 0 || (type & 2) > 0;
  3977. }
  3978. return false;
  3979. }
  3980. checkLocalExport(id) {
  3981. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  3982. super.checkLocalExport(id);
  3983. }
  3984. }
  3985. }
  3986. class BaseParser {
  3987. constructor() {
  3988. this.sawUnambiguousESM = false;
  3989. this.ambiguousScriptDifferentAst = false;
  3990. }
  3991. hasPlugin(pluginConfig) {
  3992. if (typeof pluginConfig === "string") {
  3993. return this.plugins.has(pluginConfig);
  3994. } else {
  3995. const [pluginName, pluginOptions] = pluginConfig;
  3996. if (!this.hasPlugin(pluginName)) {
  3997. return false;
  3998. }
  3999. const actualOptions = this.plugins.get(pluginName);
  4000. for (const key of Object.keys(pluginOptions)) {
  4001. if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) {
  4002. return false;
  4003. }
  4004. }
  4005. return true;
  4006. }
  4007. }
  4008. getPluginOption(plugin, name) {
  4009. var _this$plugins$get;
  4010. return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name];
  4011. }
  4012. }
  4013. function setTrailingComments(node, comments) {
  4014. if (node.trailingComments === undefined) {
  4015. node.trailingComments = comments;
  4016. } else {
  4017. node.trailingComments.unshift(...comments);
  4018. }
  4019. }
  4020. function setLeadingComments(node, comments) {
  4021. if (node.leadingComments === undefined) {
  4022. node.leadingComments = comments;
  4023. } else {
  4024. node.leadingComments.unshift(...comments);
  4025. }
  4026. }
  4027. function setInnerComments(node, comments) {
  4028. if (node.innerComments === undefined) {
  4029. node.innerComments = comments;
  4030. } else {
  4031. node.innerComments.unshift(...comments);
  4032. }
  4033. }
  4034. function adjustInnerComments(node, elements, commentWS) {
  4035. let lastElement = null;
  4036. let i = elements.length;
  4037. while (lastElement === null && i > 0) {
  4038. lastElement = elements[--i];
  4039. }
  4040. if (lastElement === null || lastElement.start > commentWS.start) {
  4041. setInnerComments(node, commentWS.comments);
  4042. } else {
  4043. setTrailingComments(lastElement, commentWS.comments);
  4044. }
  4045. }
  4046. class CommentsParser extends BaseParser {
  4047. addComment(comment) {
  4048. if (this.filename) comment.loc.filename = this.filename;
  4049. const {
  4050. commentsLen
  4051. } = this.state;
  4052. if (this.comments.length !== commentsLen) {
  4053. this.comments.length = commentsLen;
  4054. }
  4055. this.comments.push(comment);
  4056. this.state.commentsLen++;
  4057. }
  4058. processComment(node) {
  4059. const {
  4060. commentStack
  4061. } = this.state;
  4062. const commentStackLength = commentStack.length;
  4063. if (commentStackLength === 0) return;
  4064. let i = commentStackLength - 1;
  4065. const lastCommentWS = commentStack[i];
  4066. if (lastCommentWS.start === node.end) {
  4067. lastCommentWS.leadingNode = node;
  4068. i--;
  4069. }
  4070. const {
  4071. start: nodeStart
  4072. } = node;
  4073. for (; i >= 0; i--) {
  4074. const commentWS = commentStack[i];
  4075. const commentEnd = commentWS.end;
  4076. if (commentEnd > nodeStart) {
  4077. commentWS.containingNode = node;
  4078. this.finalizeComment(commentWS);
  4079. commentStack.splice(i, 1);
  4080. } else {
  4081. if (commentEnd === nodeStart) {
  4082. commentWS.trailingNode = node;
  4083. }
  4084. break;
  4085. }
  4086. }
  4087. }
  4088. finalizeComment(commentWS) {
  4089. const {
  4090. comments
  4091. } = commentWS;
  4092. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  4093. if (commentWS.leadingNode !== null) {
  4094. setTrailingComments(commentWS.leadingNode, comments);
  4095. }
  4096. if (commentWS.trailingNode !== null) {
  4097. setLeadingComments(commentWS.trailingNode, comments);
  4098. }
  4099. } else {
  4100. const {
  4101. containingNode: node,
  4102. start: commentStart
  4103. } = commentWS;
  4104. if (this.input.charCodeAt(commentStart - 1) === 44) {
  4105. switch (node.type) {
  4106. case "ObjectExpression":
  4107. case "ObjectPattern":
  4108. case "RecordExpression":
  4109. adjustInnerComments(node, node.properties, commentWS);
  4110. break;
  4111. case "CallExpression":
  4112. case "OptionalCallExpression":
  4113. adjustInnerComments(node, node.arguments, commentWS);
  4114. break;
  4115. case "FunctionDeclaration":
  4116. case "FunctionExpression":
  4117. case "ArrowFunctionExpression":
  4118. case "ObjectMethod":
  4119. case "ClassMethod":
  4120. case "ClassPrivateMethod":
  4121. adjustInnerComments(node, node.params, commentWS);
  4122. break;
  4123. case "ArrayExpression":
  4124. case "ArrayPattern":
  4125. case "TupleExpression":
  4126. adjustInnerComments(node, node.elements, commentWS);
  4127. break;
  4128. case "ExportNamedDeclaration":
  4129. case "ImportDeclaration":
  4130. adjustInnerComments(node, node.specifiers, commentWS);
  4131. break;
  4132. default:
  4133. {
  4134. setInnerComments(node, comments);
  4135. }
  4136. }
  4137. } else {
  4138. setInnerComments(node, comments);
  4139. }
  4140. }
  4141. }
  4142. finalizeRemainingComments() {
  4143. const {
  4144. commentStack
  4145. } = this.state;
  4146. for (let i = commentStack.length - 1; i >= 0; i--) {
  4147. this.finalizeComment(commentStack[i]);
  4148. }
  4149. this.state.commentStack = [];
  4150. }
  4151. resetPreviousNodeTrailingComments(node) {
  4152. const {
  4153. commentStack
  4154. } = this.state;
  4155. const {
  4156. length
  4157. } = commentStack;
  4158. if (length === 0) return;
  4159. const commentWS = commentStack[length - 1];
  4160. if (commentWS.leadingNode === node) {
  4161. commentWS.leadingNode = null;
  4162. }
  4163. }
  4164. resetPreviousIdentifierLeadingComments(node) {
  4165. const {
  4166. commentStack
  4167. } = this.state;
  4168. const {
  4169. length
  4170. } = commentStack;
  4171. if (length === 0) return;
  4172. if (commentStack[length - 1].trailingNode === node) {
  4173. commentStack[length - 1].trailingNode = null;
  4174. } else if (length >= 2 && commentStack[length - 2].trailingNode === node) {
  4175. commentStack[length - 2].trailingNode = null;
  4176. }
  4177. }
  4178. takeSurroundingComments(node, start, end) {
  4179. const {
  4180. commentStack
  4181. } = this.state;
  4182. const commentStackLength = commentStack.length;
  4183. if (commentStackLength === 0) return;
  4184. let i = commentStackLength - 1;
  4185. for (; i >= 0; i--) {
  4186. const commentWS = commentStack[i];
  4187. const commentEnd = commentWS.end;
  4188. const commentStart = commentWS.start;
  4189. if (commentStart === end) {
  4190. commentWS.leadingNode = node;
  4191. } else if (commentEnd === start) {
  4192. commentWS.trailingNode = node;
  4193. } else if (commentEnd < start) {
  4194. break;
  4195. }
  4196. }
  4197. }
  4198. }
  4199. const lineBreak = /\r\n|[\r\n\u2028\u2029]/;
  4200. const lineBreakG = new RegExp(lineBreak.source, "g");
  4201. function isNewLine(code) {
  4202. switch (code) {
  4203. case 10:
  4204. case 13:
  4205. case 8232:
  4206. case 8233:
  4207. return true;
  4208. default:
  4209. return false;
  4210. }
  4211. }
  4212. function hasNewLine(input, start, end) {
  4213. for (let i = start; i < end; i++) {
  4214. if (isNewLine(input.charCodeAt(i))) {
  4215. return true;
  4216. }
  4217. }
  4218. return false;
  4219. }
  4220. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  4221. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;
  4222. function isWhitespace(code) {
  4223. switch (code) {
  4224. case 0x0009:
  4225. case 0x000b:
  4226. case 0x000c:
  4227. case 32:
  4228. case 160:
  4229. case 5760:
  4230. case 0x2000:
  4231. case 0x2001:
  4232. case 0x2002:
  4233. case 0x2003:
  4234. case 0x2004:
  4235. case 0x2005:
  4236. case 0x2006:
  4237. case 0x2007:
  4238. case 0x2008:
  4239. case 0x2009:
  4240. case 0x200a:
  4241. case 0x202f:
  4242. case 0x205f:
  4243. case 0x3000:
  4244. case 0xfeff:
  4245. return true;
  4246. default:
  4247. return false;
  4248. }
  4249. }
  4250. class State {
  4251. constructor() {
  4252. this.flags = 1024;
  4253. this.curLine = void 0;
  4254. this.lineStart = void 0;
  4255. this.startLoc = void 0;
  4256. this.endLoc = void 0;
  4257. this.errors = [];
  4258. this.potentialArrowAt = -1;
  4259. this.noArrowAt = [];
  4260. this.noArrowParamsConversionAt = [];
  4261. this.topicContext = {
  4262. maxNumOfResolvableTopics: 0,
  4263. maxTopicIndex: null
  4264. };
  4265. this.labels = [];
  4266. this.commentsLen = 0;
  4267. this.commentStack = [];
  4268. this.pos = 0;
  4269. this.type = 139;
  4270. this.value = null;
  4271. this.start = 0;
  4272. this.end = 0;
  4273. this.lastTokEndLoc = null;
  4274. this.lastTokStartLoc = null;
  4275. this.context = [types.brace];
  4276. this.firstInvalidTemplateEscapePos = null;
  4277. this.strictErrors = new Map();
  4278. this.tokensLength = 0;
  4279. }
  4280. get strict() {
  4281. return (this.flags & 1) > 0;
  4282. }
  4283. set strict(v) {
  4284. if (v) this.flags |= 1;else this.flags &= -2;
  4285. }
  4286. init({
  4287. strictMode,
  4288. sourceType,
  4289. startLine,
  4290. startColumn
  4291. }) {
  4292. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  4293. this.curLine = startLine;
  4294. this.lineStart = -startColumn;
  4295. this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
  4296. }
  4297. get maybeInArrowParameters() {
  4298. return (this.flags & 2) > 0;
  4299. }
  4300. set maybeInArrowParameters(v) {
  4301. if (v) this.flags |= 2;else this.flags &= -3;
  4302. }
  4303. get inType() {
  4304. return (this.flags & 4) > 0;
  4305. }
  4306. set inType(v) {
  4307. if (v) this.flags |= 4;else this.flags &= -5;
  4308. }
  4309. get noAnonFunctionType() {
  4310. return (this.flags & 8) > 0;
  4311. }
  4312. set noAnonFunctionType(v) {
  4313. if (v) this.flags |= 8;else this.flags &= -9;
  4314. }
  4315. get hasFlowComment() {
  4316. return (this.flags & 16) > 0;
  4317. }
  4318. set hasFlowComment(v) {
  4319. if (v) this.flags |= 16;else this.flags &= -17;
  4320. }
  4321. get isAmbientContext() {
  4322. return (this.flags & 32) > 0;
  4323. }
  4324. set isAmbientContext(v) {
  4325. if (v) this.flags |= 32;else this.flags &= -33;
  4326. }
  4327. get inAbstractClass() {
  4328. return (this.flags & 64) > 0;
  4329. }
  4330. set inAbstractClass(v) {
  4331. if (v) this.flags |= 64;else this.flags &= -65;
  4332. }
  4333. get inDisallowConditionalTypesContext() {
  4334. return (this.flags & 128) > 0;
  4335. }
  4336. set inDisallowConditionalTypesContext(v) {
  4337. if (v) this.flags |= 128;else this.flags &= -129;
  4338. }
  4339. get soloAwait() {
  4340. return (this.flags & 256) > 0;
  4341. }
  4342. set soloAwait(v) {
  4343. if (v) this.flags |= 256;else this.flags &= -257;
  4344. }
  4345. get inFSharpPipelineDirectBody() {
  4346. return (this.flags & 512) > 0;
  4347. }
  4348. set inFSharpPipelineDirectBody(v) {
  4349. if (v) this.flags |= 512;else this.flags &= -513;
  4350. }
  4351. get canStartJSXElement() {
  4352. return (this.flags & 1024) > 0;
  4353. }
  4354. set canStartJSXElement(v) {
  4355. if (v) this.flags |= 1024;else this.flags &= -1025;
  4356. }
  4357. get containsEsc() {
  4358. return (this.flags & 2048) > 0;
  4359. }
  4360. set containsEsc(v) {
  4361. if (v) this.flags |= 2048;else this.flags &= -2049;
  4362. }
  4363. get hasTopLevelAwait() {
  4364. return (this.flags & 4096) > 0;
  4365. }
  4366. set hasTopLevelAwait(v) {
  4367. if (v) this.flags |= 4096;else this.flags &= -4097;
  4368. }
  4369. curPosition() {
  4370. return new Position(this.curLine, this.pos - this.lineStart, this.pos);
  4371. }
  4372. clone() {
  4373. const state = new State();
  4374. state.flags = this.flags;
  4375. state.curLine = this.curLine;
  4376. state.lineStart = this.lineStart;
  4377. state.startLoc = this.startLoc;
  4378. state.endLoc = this.endLoc;
  4379. state.errors = this.errors.slice();
  4380. state.potentialArrowAt = this.potentialArrowAt;
  4381. state.noArrowAt = this.noArrowAt.slice();
  4382. state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
  4383. state.topicContext = this.topicContext;
  4384. state.labels = this.labels.slice();
  4385. state.commentsLen = this.commentsLen;
  4386. state.commentStack = this.commentStack.slice();
  4387. state.pos = this.pos;
  4388. state.type = this.type;
  4389. state.value = this.value;
  4390. state.start = this.start;
  4391. state.end = this.end;
  4392. state.lastTokEndLoc = this.lastTokEndLoc;
  4393. state.lastTokStartLoc = this.lastTokStartLoc;
  4394. state.context = this.context.slice();
  4395. state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos;
  4396. state.strictErrors = this.strictErrors;
  4397. state.tokensLength = this.tokensLength;
  4398. return state;
  4399. }
  4400. }
  4401. var _isDigit = function isDigit(code) {
  4402. return code >= 48 && code <= 57;
  4403. };
  4404. const forbiddenNumericSeparatorSiblings = {
  4405. decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
  4406. hex: new Set([46, 88, 95, 120])
  4407. };
  4408. const isAllowedNumericSeparatorSibling = {
  4409. bin: ch => ch === 48 || ch === 49,
  4410. oct: ch => ch >= 48 && ch <= 55,
  4411. dec: ch => ch >= 48 && ch <= 57,
  4412. hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
  4413. };
  4414. function readStringContents(type, input, pos, lineStart, curLine, errors) {
  4415. const initialPos = pos;
  4416. const initialLineStart = lineStart;
  4417. const initialCurLine = curLine;
  4418. let out = "";
  4419. let firstInvalidLoc = null;
  4420. let chunkStart = pos;
  4421. const {
  4422. length
  4423. } = input;
  4424. for (;;) {
  4425. if (pos >= length) {
  4426. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4427. out += input.slice(chunkStart, pos);
  4428. break;
  4429. }
  4430. const ch = input.charCodeAt(pos);
  4431. if (isStringEnd(type, ch, input, pos)) {
  4432. out += input.slice(chunkStart, pos);
  4433. break;
  4434. }
  4435. if (ch === 92) {
  4436. out += input.slice(chunkStart, pos);
  4437. const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
  4438. if (res.ch === null && !firstInvalidLoc) {
  4439. firstInvalidLoc = {
  4440. pos,
  4441. lineStart,
  4442. curLine
  4443. };
  4444. } else {
  4445. out += res.ch;
  4446. }
  4447. ({
  4448. pos,
  4449. lineStart,
  4450. curLine
  4451. } = res);
  4452. chunkStart = pos;
  4453. } else if (ch === 8232 || ch === 8233) {
  4454. ++pos;
  4455. ++curLine;
  4456. lineStart = pos;
  4457. } else if (ch === 10 || ch === 13) {
  4458. if (type === "template") {
  4459. out += input.slice(chunkStart, pos) + "\n";
  4460. ++pos;
  4461. if (ch === 13 && input.charCodeAt(pos) === 10) {
  4462. ++pos;
  4463. }
  4464. ++curLine;
  4465. chunkStart = lineStart = pos;
  4466. } else {
  4467. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4468. }
  4469. } else {
  4470. ++pos;
  4471. }
  4472. }
  4473. return {
  4474. pos,
  4475. str: out,
  4476. firstInvalidLoc,
  4477. lineStart,
  4478. curLine,
  4479. containsInvalid: !!firstInvalidLoc
  4480. };
  4481. }
  4482. function isStringEnd(type, ch, input, pos) {
  4483. if (type === "template") {
  4484. return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
  4485. }
  4486. return ch === (type === "double" ? 34 : 39);
  4487. }
  4488. function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
  4489. const throwOnInvalid = !inTemplate;
  4490. pos++;
  4491. const res = ch => ({
  4492. pos,
  4493. ch,
  4494. lineStart,
  4495. curLine
  4496. });
  4497. const ch = input.charCodeAt(pos++);
  4498. switch (ch) {
  4499. case 110:
  4500. return res("\n");
  4501. case 114:
  4502. return res("\r");
  4503. case 120:
  4504. {
  4505. let code;
  4506. ({
  4507. code,
  4508. pos
  4509. } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
  4510. return res(code === null ? null : String.fromCharCode(code));
  4511. }
  4512. case 117:
  4513. {
  4514. let code;
  4515. ({
  4516. code,
  4517. pos
  4518. } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
  4519. return res(code === null ? null : String.fromCodePoint(code));
  4520. }
  4521. case 116:
  4522. return res("\t");
  4523. case 98:
  4524. return res("\b");
  4525. case 118:
  4526. return res("\u000b");
  4527. case 102:
  4528. return res("\f");
  4529. case 13:
  4530. if (input.charCodeAt(pos) === 10) {
  4531. ++pos;
  4532. }
  4533. case 10:
  4534. lineStart = pos;
  4535. ++curLine;
  4536. case 8232:
  4537. case 8233:
  4538. return res("");
  4539. case 56:
  4540. case 57:
  4541. if (inTemplate) {
  4542. return res(null);
  4543. } else {
  4544. errors.strictNumericEscape(pos - 1, lineStart, curLine);
  4545. }
  4546. default:
  4547. if (ch >= 48 && ch <= 55) {
  4548. const startPos = pos - 1;
  4549. const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2));
  4550. let octalStr = match[0];
  4551. let octal = parseInt(octalStr, 8);
  4552. if (octal > 255) {
  4553. octalStr = octalStr.slice(0, -1);
  4554. octal = parseInt(octalStr, 8);
  4555. }
  4556. pos += octalStr.length - 1;
  4557. const next = input.charCodeAt(pos);
  4558. if (octalStr !== "0" || next === 56 || next === 57) {
  4559. if (inTemplate) {
  4560. return res(null);
  4561. } else {
  4562. errors.strictNumericEscape(startPos, lineStart, curLine);
  4563. }
  4564. }
  4565. return res(String.fromCharCode(octal));
  4566. }
  4567. return res(String.fromCharCode(ch));
  4568. }
  4569. }
  4570. function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
  4571. const initialPos = pos;
  4572. let n;
  4573. ({
  4574. n,
  4575. pos
  4576. } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
  4577. if (n === null) {
  4578. if (throwOnInvalid) {
  4579. errors.invalidEscapeSequence(initialPos, lineStart, curLine);
  4580. } else {
  4581. pos = initialPos - 1;
  4582. }
  4583. }
  4584. return {
  4585. code: n,
  4586. pos
  4587. };
  4588. }
  4589. function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
  4590. const start = pos;
  4591. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  4592. const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
  4593. let invalid = false;
  4594. let total = 0;
  4595. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  4596. const code = input.charCodeAt(pos);
  4597. let val;
  4598. if (code === 95 && allowNumSeparator !== "bail") {
  4599. const prev = input.charCodeAt(pos - 1);
  4600. const next = input.charCodeAt(pos + 1);
  4601. if (!allowNumSeparator) {
  4602. if (bailOnError) return {
  4603. n: null,
  4604. pos
  4605. };
  4606. errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
  4607. } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
  4608. if (bailOnError) return {
  4609. n: null,
  4610. pos
  4611. };
  4612. errors.unexpectedNumericSeparator(pos, lineStart, curLine);
  4613. }
  4614. ++pos;
  4615. continue;
  4616. }
  4617. if (code >= 97) {
  4618. val = code - 97 + 10;
  4619. } else if (code >= 65) {
  4620. val = code - 65 + 10;
  4621. } else if (_isDigit(code)) {
  4622. val = code - 48;
  4623. } else {
  4624. val = Infinity;
  4625. }
  4626. if (val >= radix) {
  4627. if (val <= 9 && bailOnError) {
  4628. return {
  4629. n: null,
  4630. pos
  4631. };
  4632. } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
  4633. val = 0;
  4634. } else if (forceLen) {
  4635. val = 0;
  4636. invalid = true;
  4637. } else {
  4638. break;
  4639. }
  4640. }
  4641. ++pos;
  4642. total = total * radix + val;
  4643. }
  4644. if (pos === start || len != null && pos - start !== len || invalid) {
  4645. return {
  4646. n: null,
  4647. pos
  4648. };
  4649. }
  4650. return {
  4651. n: total,
  4652. pos
  4653. };
  4654. }
  4655. function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
  4656. const ch = input.charCodeAt(pos);
  4657. let code;
  4658. if (ch === 123) {
  4659. ++pos;
  4660. ({
  4661. code,
  4662. pos
  4663. } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
  4664. ++pos;
  4665. if (code !== null && code > 0x10ffff) {
  4666. if (throwOnInvalid) {
  4667. errors.invalidCodePoint(pos, lineStart, curLine);
  4668. } else {
  4669. return {
  4670. code: null,
  4671. pos
  4672. };
  4673. }
  4674. }
  4675. } else {
  4676. ({
  4677. code,
  4678. pos
  4679. } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
  4680. }
  4681. return {
  4682. code,
  4683. pos
  4684. };
  4685. }
  4686. function buildPosition(pos, lineStart, curLine) {
  4687. return new Position(curLine, pos - lineStart, pos);
  4688. }
  4689. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
  4690. class Token {
  4691. constructor(state) {
  4692. this.type = state.type;
  4693. this.value = state.value;
  4694. this.start = state.start;
  4695. this.end = state.end;
  4696. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  4697. }
  4698. }
  4699. class Tokenizer extends CommentsParser {
  4700. constructor(options, input) {
  4701. super();
  4702. this.isLookahead = void 0;
  4703. this.tokens = [];
  4704. this.errorHandlers_readInt = {
  4705. invalidDigit: (pos, lineStart, curLine, radix) => {
  4706. if (!this.options.errorRecovery) return false;
  4707. this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
  4708. radix
  4709. });
  4710. return true;
  4711. },
  4712. numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
  4713. unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
  4714. };
  4715. this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, {
  4716. invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
  4717. invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
  4718. });
  4719. this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, {
  4720. strictNumericEscape: (pos, lineStart, curLine) => {
  4721. this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
  4722. },
  4723. unterminated: (pos, lineStart, curLine) => {
  4724. throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
  4725. }
  4726. });
  4727. this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, {
  4728. strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
  4729. unterminated: (pos, lineStart, curLine) => {
  4730. throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
  4731. }
  4732. });
  4733. this.state = new State();
  4734. this.state.init(options);
  4735. this.input = input;
  4736. this.length = input.length;
  4737. this.comments = [];
  4738. this.isLookahead = false;
  4739. }
  4740. pushToken(token) {
  4741. this.tokens.length = this.state.tokensLength;
  4742. this.tokens.push(token);
  4743. ++this.state.tokensLength;
  4744. }
  4745. next() {
  4746. this.checkKeywordEscapes();
  4747. if (this.options.tokens) {
  4748. this.pushToken(new Token(this.state));
  4749. }
  4750. this.state.lastTokEndLoc = this.state.endLoc;
  4751. this.state.lastTokStartLoc = this.state.startLoc;
  4752. this.nextToken();
  4753. }
  4754. eat(type) {
  4755. if (this.match(type)) {
  4756. this.next();
  4757. return true;
  4758. } else {
  4759. return false;
  4760. }
  4761. }
  4762. match(type) {
  4763. return this.state.type === type;
  4764. }
  4765. createLookaheadState(state) {
  4766. return {
  4767. pos: state.pos,
  4768. value: null,
  4769. type: state.type,
  4770. start: state.start,
  4771. end: state.end,
  4772. context: [this.curContext()],
  4773. inType: state.inType,
  4774. startLoc: state.startLoc,
  4775. lastTokEndLoc: state.lastTokEndLoc,
  4776. curLine: state.curLine,
  4777. lineStart: state.lineStart,
  4778. curPosition: state.curPosition
  4779. };
  4780. }
  4781. lookahead() {
  4782. const old = this.state;
  4783. this.state = this.createLookaheadState(old);
  4784. this.isLookahead = true;
  4785. this.nextToken();
  4786. this.isLookahead = false;
  4787. const curr = this.state;
  4788. this.state = old;
  4789. return curr;
  4790. }
  4791. nextTokenStart() {
  4792. return this.nextTokenStartSince(this.state.pos);
  4793. }
  4794. nextTokenStartSince(pos) {
  4795. skipWhiteSpace.lastIndex = pos;
  4796. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  4797. }
  4798. lookaheadCharCode() {
  4799. return this.input.charCodeAt(this.nextTokenStart());
  4800. }
  4801. nextTokenInLineStart() {
  4802. return this.nextTokenInLineStartSince(this.state.pos);
  4803. }
  4804. nextTokenInLineStartSince(pos) {
  4805. skipWhiteSpaceInLine.lastIndex = pos;
  4806. return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
  4807. }
  4808. lookaheadInLineCharCode() {
  4809. return this.input.charCodeAt(this.nextTokenInLineStart());
  4810. }
  4811. codePointAtPos(pos) {
  4812. let cp = this.input.charCodeAt(pos);
  4813. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  4814. const trail = this.input.charCodeAt(pos);
  4815. if ((trail & 0xfc00) === 0xdc00) {
  4816. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  4817. }
  4818. }
  4819. return cp;
  4820. }
  4821. setStrict(strict) {
  4822. this.state.strict = strict;
  4823. if (strict) {
  4824. this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
  4825. this.state.strictErrors.clear();
  4826. }
  4827. }
  4828. curContext() {
  4829. return this.state.context[this.state.context.length - 1];
  4830. }
  4831. nextToken() {
  4832. this.skipSpace();
  4833. this.state.start = this.state.pos;
  4834. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  4835. if (this.state.pos >= this.length) {
  4836. this.finishToken(139);
  4837. return;
  4838. }
  4839. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  4840. }
  4841. skipBlockComment(commentEnd) {
  4842. let startLoc;
  4843. if (!this.isLookahead) startLoc = this.state.curPosition();
  4844. const start = this.state.pos;
  4845. const end = this.input.indexOf(commentEnd, start + 2);
  4846. if (end === -1) {
  4847. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  4848. }
  4849. this.state.pos = end + commentEnd.length;
  4850. lineBreakG.lastIndex = start + 2;
  4851. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  4852. ++this.state.curLine;
  4853. this.state.lineStart = lineBreakG.lastIndex;
  4854. }
  4855. if (this.isLookahead) return;
  4856. const comment = {
  4857. type: "CommentBlock",
  4858. value: this.input.slice(start + 2, end),
  4859. start,
  4860. end: end + commentEnd.length,
  4861. loc: new SourceLocation(startLoc, this.state.curPosition())
  4862. };
  4863. if (this.options.tokens) this.pushToken(comment);
  4864. return comment;
  4865. }
  4866. skipLineComment(startSkip) {
  4867. const start = this.state.pos;
  4868. let startLoc;
  4869. if (!this.isLookahead) startLoc = this.state.curPosition();
  4870. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  4871. if (this.state.pos < this.length) {
  4872. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  4873. ch = this.input.charCodeAt(this.state.pos);
  4874. }
  4875. }
  4876. if (this.isLookahead) return;
  4877. const end = this.state.pos;
  4878. const value = this.input.slice(start + startSkip, end);
  4879. const comment = {
  4880. type: "CommentLine",
  4881. value,
  4882. start,
  4883. end,
  4884. loc: new SourceLocation(startLoc, this.state.curPosition())
  4885. };
  4886. if (this.options.tokens) this.pushToken(comment);
  4887. return comment;
  4888. }
  4889. skipSpace() {
  4890. const spaceStart = this.state.pos;
  4891. const comments = [];
  4892. loop: while (this.state.pos < this.length) {
  4893. const ch = this.input.charCodeAt(this.state.pos);
  4894. switch (ch) {
  4895. case 32:
  4896. case 160:
  4897. case 9:
  4898. ++this.state.pos;
  4899. break;
  4900. case 13:
  4901. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  4902. ++this.state.pos;
  4903. }
  4904. case 10:
  4905. case 8232:
  4906. case 8233:
  4907. ++this.state.pos;
  4908. ++this.state.curLine;
  4909. this.state.lineStart = this.state.pos;
  4910. break;
  4911. case 47:
  4912. switch (this.input.charCodeAt(this.state.pos + 1)) {
  4913. case 42:
  4914. {
  4915. const comment = this.skipBlockComment("*/");
  4916. if (comment !== undefined) {
  4917. this.addComment(comment);
  4918. if (this.options.attachComment) comments.push(comment);
  4919. }
  4920. break;
  4921. }
  4922. case 47:
  4923. {
  4924. const comment = this.skipLineComment(2);
  4925. if (comment !== undefined) {
  4926. this.addComment(comment);
  4927. if (this.options.attachComment) comments.push(comment);
  4928. }
  4929. break;
  4930. }
  4931. default:
  4932. break loop;
  4933. }
  4934. break;
  4935. default:
  4936. if (isWhitespace(ch)) {
  4937. ++this.state.pos;
  4938. } else if (ch === 45 && !this.inModule && this.options.annexB) {
  4939. const pos = this.state.pos;
  4940. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  4941. const comment = this.skipLineComment(3);
  4942. if (comment !== undefined) {
  4943. this.addComment(comment);
  4944. if (this.options.attachComment) comments.push(comment);
  4945. }
  4946. } else {
  4947. break loop;
  4948. }
  4949. } else if (ch === 60 && !this.inModule && this.options.annexB) {
  4950. const pos = this.state.pos;
  4951. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  4952. const comment = this.skipLineComment(4);
  4953. if (comment !== undefined) {
  4954. this.addComment(comment);
  4955. if (this.options.attachComment) comments.push(comment);
  4956. }
  4957. } else {
  4958. break loop;
  4959. }
  4960. } else {
  4961. break loop;
  4962. }
  4963. }
  4964. }
  4965. if (comments.length > 0) {
  4966. const end = this.state.pos;
  4967. const commentWhitespace = {
  4968. start: spaceStart,
  4969. end,
  4970. comments,
  4971. leadingNode: null,
  4972. trailingNode: null,
  4973. containingNode: null
  4974. };
  4975. this.state.commentStack.push(commentWhitespace);
  4976. }
  4977. }
  4978. finishToken(type, val) {
  4979. this.state.end = this.state.pos;
  4980. this.state.endLoc = this.state.curPosition();
  4981. const prevType = this.state.type;
  4982. this.state.type = type;
  4983. this.state.value = val;
  4984. if (!this.isLookahead) {
  4985. this.updateContext(prevType);
  4986. }
  4987. }
  4988. replaceToken(type) {
  4989. this.state.type = type;
  4990. this.updateContext();
  4991. }
  4992. readToken_numberSign() {
  4993. if (this.state.pos === 0 && this.readToken_interpreter()) {
  4994. return;
  4995. }
  4996. const nextPos = this.state.pos + 1;
  4997. const next = this.codePointAtPos(nextPos);
  4998. if (next >= 48 && next <= 57) {
  4999. throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
  5000. }
  5001. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  5002. this.expectPlugin("recordAndTuple");
  5003. if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
  5004. throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
  5005. }
  5006. this.state.pos += 2;
  5007. if (next === 123) {
  5008. this.finishToken(7);
  5009. } else {
  5010. this.finishToken(1);
  5011. }
  5012. } else if (isIdentifierStart(next)) {
  5013. ++this.state.pos;
  5014. this.finishToken(138, this.readWord1(next));
  5015. } else if (next === 92) {
  5016. ++this.state.pos;
  5017. this.finishToken(138, this.readWord1());
  5018. } else {
  5019. this.finishOp(27, 1);
  5020. }
  5021. }
  5022. readToken_dot() {
  5023. const next = this.input.charCodeAt(this.state.pos + 1);
  5024. if (next >= 48 && next <= 57) {
  5025. this.readNumber(true);
  5026. return;
  5027. }
  5028. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  5029. this.state.pos += 3;
  5030. this.finishToken(21);
  5031. } else {
  5032. ++this.state.pos;
  5033. this.finishToken(16);
  5034. }
  5035. }
  5036. readToken_slash() {
  5037. const next = this.input.charCodeAt(this.state.pos + 1);
  5038. if (next === 61) {
  5039. this.finishOp(31, 2);
  5040. } else {
  5041. this.finishOp(56, 1);
  5042. }
  5043. }
  5044. readToken_interpreter() {
  5045. if (this.state.pos !== 0 || this.length < 2) return false;
  5046. let ch = this.input.charCodeAt(this.state.pos + 1);
  5047. if (ch !== 33) return false;
  5048. const start = this.state.pos;
  5049. this.state.pos += 1;
  5050. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  5051. ch = this.input.charCodeAt(this.state.pos);
  5052. }
  5053. const value = this.input.slice(start + 2, this.state.pos);
  5054. this.finishToken(28, value);
  5055. return true;
  5056. }
  5057. readToken_mult_modulo(code) {
  5058. let type = code === 42 ? 55 : 54;
  5059. let width = 1;
  5060. let next = this.input.charCodeAt(this.state.pos + 1);
  5061. if (code === 42 && next === 42) {
  5062. width++;
  5063. next = this.input.charCodeAt(this.state.pos + 2);
  5064. type = 57;
  5065. }
  5066. if (next === 61 && !this.state.inType) {
  5067. width++;
  5068. type = code === 37 ? 33 : 30;
  5069. }
  5070. this.finishOp(type, width);
  5071. }
  5072. readToken_pipe_amp(code) {
  5073. const next = this.input.charCodeAt(this.state.pos + 1);
  5074. if (next === code) {
  5075. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  5076. this.finishOp(30, 3);
  5077. } else {
  5078. this.finishOp(code === 124 ? 41 : 42, 2);
  5079. }
  5080. return;
  5081. }
  5082. if (code === 124) {
  5083. if (next === 62) {
  5084. this.finishOp(39, 2);
  5085. return;
  5086. }
  5087. if (this.hasPlugin("recordAndTuple") && next === 125) {
  5088. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5089. throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5090. }
  5091. this.state.pos += 2;
  5092. this.finishToken(9);
  5093. return;
  5094. }
  5095. if (this.hasPlugin("recordAndTuple") && next === 93) {
  5096. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5097. throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5098. }
  5099. this.state.pos += 2;
  5100. this.finishToken(4);
  5101. return;
  5102. }
  5103. }
  5104. if (next === 61) {
  5105. this.finishOp(30, 2);
  5106. return;
  5107. }
  5108. this.finishOp(code === 124 ? 43 : 45, 1);
  5109. }
  5110. readToken_caret() {
  5111. const next = this.input.charCodeAt(this.state.pos + 1);
  5112. if (next === 61 && !this.state.inType) {
  5113. this.finishOp(32, 2);
  5114. } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
  5115. proposal: "hack",
  5116. topicToken: "^^"
  5117. }])) {
  5118. this.finishOp(37, 2);
  5119. const lookaheadCh = this.input.codePointAt(this.state.pos);
  5120. if (lookaheadCh === 94) {
  5121. this.unexpected();
  5122. }
  5123. } else {
  5124. this.finishOp(44, 1);
  5125. }
  5126. }
  5127. readToken_atSign() {
  5128. const next = this.input.charCodeAt(this.state.pos + 1);
  5129. if (next === 64 && this.hasPlugin(["pipelineOperator", {
  5130. proposal: "hack",
  5131. topicToken: "@@"
  5132. }])) {
  5133. this.finishOp(38, 2);
  5134. } else {
  5135. this.finishOp(26, 1);
  5136. }
  5137. }
  5138. readToken_plus_min(code) {
  5139. const next = this.input.charCodeAt(this.state.pos + 1);
  5140. if (next === code) {
  5141. this.finishOp(34, 2);
  5142. return;
  5143. }
  5144. if (next === 61) {
  5145. this.finishOp(30, 2);
  5146. } else {
  5147. this.finishOp(53, 1);
  5148. }
  5149. }
  5150. readToken_lt() {
  5151. const {
  5152. pos
  5153. } = this.state;
  5154. const next = this.input.charCodeAt(pos + 1);
  5155. if (next === 60) {
  5156. if (this.input.charCodeAt(pos + 2) === 61) {
  5157. this.finishOp(30, 3);
  5158. return;
  5159. }
  5160. this.finishOp(51, 2);
  5161. return;
  5162. }
  5163. if (next === 61) {
  5164. this.finishOp(49, 2);
  5165. return;
  5166. }
  5167. this.finishOp(47, 1);
  5168. }
  5169. readToken_gt() {
  5170. const {
  5171. pos
  5172. } = this.state;
  5173. const next = this.input.charCodeAt(pos + 1);
  5174. if (next === 62) {
  5175. const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
  5176. if (this.input.charCodeAt(pos + size) === 61) {
  5177. this.finishOp(30, size + 1);
  5178. return;
  5179. }
  5180. this.finishOp(52, size);
  5181. return;
  5182. }
  5183. if (next === 61) {
  5184. this.finishOp(49, 2);
  5185. return;
  5186. }
  5187. this.finishOp(48, 1);
  5188. }
  5189. readToken_eq_excl(code) {
  5190. const next = this.input.charCodeAt(this.state.pos + 1);
  5191. if (next === 61) {
  5192. this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  5193. return;
  5194. }
  5195. if (code === 61 && next === 62) {
  5196. this.state.pos += 2;
  5197. this.finishToken(19);
  5198. return;
  5199. }
  5200. this.finishOp(code === 61 ? 29 : 35, 1);
  5201. }
  5202. readToken_question() {
  5203. const next = this.input.charCodeAt(this.state.pos + 1);
  5204. const next2 = this.input.charCodeAt(this.state.pos + 2);
  5205. if (next === 63) {
  5206. if (next2 === 61) {
  5207. this.finishOp(30, 3);
  5208. } else {
  5209. this.finishOp(40, 2);
  5210. }
  5211. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  5212. this.state.pos += 2;
  5213. this.finishToken(18);
  5214. } else {
  5215. ++this.state.pos;
  5216. this.finishToken(17);
  5217. }
  5218. }
  5219. getTokenFromCode(code) {
  5220. switch (code) {
  5221. case 46:
  5222. this.readToken_dot();
  5223. return;
  5224. case 40:
  5225. ++this.state.pos;
  5226. this.finishToken(10);
  5227. return;
  5228. case 41:
  5229. ++this.state.pos;
  5230. this.finishToken(11);
  5231. return;
  5232. case 59:
  5233. ++this.state.pos;
  5234. this.finishToken(13);
  5235. return;
  5236. case 44:
  5237. ++this.state.pos;
  5238. this.finishToken(12);
  5239. return;
  5240. case 91:
  5241. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5242. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5243. throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5244. }
  5245. this.state.pos += 2;
  5246. this.finishToken(2);
  5247. } else {
  5248. ++this.state.pos;
  5249. this.finishToken(0);
  5250. }
  5251. return;
  5252. case 93:
  5253. ++this.state.pos;
  5254. this.finishToken(3);
  5255. return;
  5256. case 123:
  5257. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5258. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5259. throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5260. }
  5261. this.state.pos += 2;
  5262. this.finishToken(6);
  5263. } else {
  5264. ++this.state.pos;
  5265. this.finishToken(5);
  5266. }
  5267. return;
  5268. case 125:
  5269. ++this.state.pos;
  5270. this.finishToken(8);
  5271. return;
  5272. case 58:
  5273. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  5274. this.finishOp(15, 2);
  5275. } else {
  5276. ++this.state.pos;
  5277. this.finishToken(14);
  5278. }
  5279. return;
  5280. case 63:
  5281. this.readToken_question();
  5282. return;
  5283. case 96:
  5284. this.readTemplateToken();
  5285. return;
  5286. case 48:
  5287. {
  5288. const next = this.input.charCodeAt(this.state.pos + 1);
  5289. if (next === 120 || next === 88) {
  5290. this.readRadixNumber(16);
  5291. return;
  5292. }
  5293. if (next === 111 || next === 79) {
  5294. this.readRadixNumber(8);
  5295. return;
  5296. }
  5297. if (next === 98 || next === 66) {
  5298. this.readRadixNumber(2);
  5299. return;
  5300. }
  5301. }
  5302. case 49:
  5303. case 50:
  5304. case 51:
  5305. case 52:
  5306. case 53:
  5307. case 54:
  5308. case 55:
  5309. case 56:
  5310. case 57:
  5311. this.readNumber(false);
  5312. return;
  5313. case 34:
  5314. case 39:
  5315. this.readString(code);
  5316. return;
  5317. case 47:
  5318. this.readToken_slash();
  5319. return;
  5320. case 37:
  5321. case 42:
  5322. this.readToken_mult_modulo(code);
  5323. return;
  5324. case 124:
  5325. case 38:
  5326. this.readToken_pipe_amp(code);
  5327. return;
  5328. case 94:
  5329. this.readToken_caret();
  5330. return;
  5331. case 43:
  5332. case 45:
  5333. this.readToken_plus_min(code);
  5334. return;
  5335. case 60:
  5336. this.readToken_lt();
  5337. return;
  5338. case 62:
  5339. this.readToken_gt();
  5340. return;
  5341. case 61:
  5342. case 33:
  5343. this.readToken_eq_excl(code);
  5344. return;
  5345. case 126:
  5346. this.finishOp(36, 1);
  5347. return;
  5348. case 64:
  5349. this.readToken_atSign();
  5350. return;
  5351. case 35:
  5352. this.readToken_numberSign();
  5353. return;
  5354. case 92:
  5355. this.readWord();
  5356. return;
  5357. default:
  5358. if (isIdentifierStart(code)) {
  5359. this.readWord(code);
  5360. return;
  5361. }
  5362. }
  5363. throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
  5364. unexpected: String.fromCodePoint(code)
  5365. });
  5366. }
  5367. finishOp(type, size) {
  5368. const str = this.input.slice(this.state.pos, this.state.pos + size);
  5369. this.state.pos += size;
  5370. this.finishToken(type, str);
  5371. }
  5372. readRegexp() {
  5373. const startLoc = this.state.startLoc;
  5374. const start = this.state.start + 1;
  5375. let escaped, inClass;
  5376. let {
  5377. pos
  5378. } = this.state;
  5379. for (;; ++pos) {
  5380. if (pos >= this.length) {
  5381. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5382. }
  5383. const ch = this.input.charCodeAt(pos);
  5384. if (isNewLine(ch)) {
  5385. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5386. }
  5387. if (escaped) {
  5388. escaped = false;
  5389. } else {
  5390. if (ch === 91) {
  5391. inClass = true;
  5392. } else if (ch === 93 && inClass) {
  5393. inClass = false;
  5394. } else if (ch === 47 && !inClass) {
  5395. break;
  5396. }
  5397. escaped = ch === 92;
  5398. }
  5399. }
  5400. const content = this.input.slice(start, pos);
  5401. ++pos;
  5402. let mods = "";
  5403. const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
  5404. while (pos < this.length) {
  5405. const cp = this.codePointAtPos(pos);
  5406. const char = String.fromCharCode(cp);
  5407. if (VALID_REGEX_FLAGS.has(cp)) {
  5408. if (cp === 118) {
  5409. if (mods.includes("u")) {
  5410. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5411. }
  5412. } else if (cp === 117) {
  5413. if (mods.includes("v")) {
  5414. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5415. }
  5416. }
  5417. if (mods.includes(char)) {
  5418. this.raise(Errors.DuplicateRegExpFlags, nextPos());
  5419. }
  5420. } else if (isIdentifierChar(cp) || cp === 92) {
  5421. this.raise(Errors.MalformedRegExpFlags, nextPos());
  5422. } else {
  5423. break;
  5424. }
  5425. ++pos;
  5426. mods += char;
  5427. }
  5428. this.state.pos = pos;
  5429. this.finishToken(137, {
  5430. pattern: content,
  5431. flags: mods
  5432. });
  5433. }
  5434. readInt(radix, len, forceLen = false, allowNumSeparator = true) {
  5435. const {
  5436. n,
  5437. pos
  5438. } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
  5439. this.state.pos = pos;
  5440. return n;
  5441. }
  5442. readRadixNumber(radix) {
  5443. const startLoc = this.state.curPosition();
  5444. let isBigInt = false;
  5445. this.state.pos += 2;
  5446. const val = this.readInt(radix);
  5447. if (val == null) {
  5448. this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
  5449. radix
  5450. });
  5451. }
  5452. const next = this.input.charCodeAt(this.state.pos);
  5453. if (next === 110) {
  5454. ++this.state.pos;
  5455. isBigInt = true;
  5456. } else if (next === 109) {
  5457. throw this.raise(Errors.InvalidDecimal, startLoc);
  5458. }
  5459. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5460. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5461. }
  5462. if (isBigInt) {
  5463. const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, "");
  5464. this.finishToken(135, str);
  5465. return;
  5466. }
  5467. this.finishToken(134, val);
  5468. }
  5469. readNumber(startsWithDot) {
  5470. const start = this.state.pos;
  5471. const startLoc = this.state.curPosition();
  5472. let isFloat = false;
  5473. let isBigInt = false;
  5474. let isDecimal = false;
  5475. let hasExponent = false;
  5476. let isOctal = false;
  5477. if (!startsWithDot && this.readInt(10) === null) {
  5478. this.raise(Errors.InvalidNumber, this.state.curPosition());
  5479. }
  5480. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  5481. if (hasLeadingZero) {
  5482. const integer = this.input.slice(start, this.state.pos);
  5483. this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
  5484. if (!this.state.strict) {
  5485. const underscorePos = integer.indexOf("_");
  5486. if (underscorePos > 0) {
  5487. this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
  5488. }
  5489. }
  5490. isOctal = hasLeadingZero && !/[89]/.test(integer);
  5491. }
  5492. let next = this.input.charCodeAt(this.state.pos);
  5493. if (next === 46 && !isOctal) {
  5494. ++this.state.pos;
  5495. this.readInt(10);
  5496. isFloat = true;
  5497. next = this.input.charCodeAt(this.state.pos);
  5498. }
  5499. if ((next === 69 || next === 101) && !isOctal) {
  5500. next = this.input.charCodeAt(++this.state.pos);
  5501. if (next === 43 || next === 45) {
  5502. ++this.state.pos;
  5503. }
  5504. if (this.readInt(10) === null) {
  5505. this.raise(Errors.InvalidOrMissingExponent, startLoc);
  5506. }
  5507. isFloat = true;
  5508. hasExponent = true;
  5509. next = this.input.charCodeAt(this.state.pos);
  5510. }
  5511. if (next === 110) {
  5512. if (isFloat || hasLeadingZero) {
  5513. this.raise(Errors.InvalidBigIntLiteral, startLoc);
  5514. }
  5515. ++this.state.pos;
  5516. isBigInt = true;
  5517. }
  5518. if (next === 109) {
  5519. this.expectPlugin("decimal", this.state.curPosition());
  5520. if (hasExponent || hasLeadingZero) {
  5521. this.raise(Errors.InvalidDecimal, startLoc);
  5522. }
  5523. ++this.state.pos;
  5524. isDecimal = true;
  5525. }
  5526. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5527. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5528. }
  5529. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  5530. if (isBigInt) {
  5531. this.finishToken(135, str);
  5532. return;
  5533. }
  5534. if (isDecimal) {
  5535. this.finishToken(136, str);
  5536. return;
  5537. }
  5538. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  5539. this.finishToken(134, val);
  5540. }
  5541. readCodePoint(throwOnInvalid) {
  5542. const {
  5543. code,
  5544. pos
  5545. } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
  5546. this.state.pos = pos;
  5547. return code;
  5548. }
  5549. readString(quote) {
  5550. const {
  5551. str,
  5552. pos,
  5553. curLine,
  5554. lineStart
  5555. } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
  5556. this.state.pos = pos + 1;
  5557. this.state.lineStart = lineStart;
  5558. this.state.curLine = curLine;
  5559. this.finishToken(133, str);
  5560. }
  5561. readTemplateContinuation() {
  5562. if (!this.match(8)) {
  5563. this.unexpected(null, 8);
  5564. }
  5565. this.state.pos--;
  5566. this.readTemplateToken();
  5567. }
  5568. readTemplateToken() {
  5569. const opening = this.input[this.state.pos];
  5570. const {
  5571. str,
  5572. firstInvalidLoc,
  5573. pos,
  5574. curLine,
  5575. lineStart
  5576. } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
  5577. this.state.pos = pos + 1;
  5578. this.state.lineStart = lineStart;
  5579. this.state.curLine = curLine;
  5580. if (firstInvalidLoc) {
  5581. this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos);
  5582. }
  5583. if (this.input.codePointAt(pos) === 96) {
  5584. this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
  5585. } else {
  5586. this.state.pos++;
  5587. this.finishToken(25, firstInvalidLoc ? null : opening + str + "${");
  5588. }
  5589. }
  5590. recordStrictModeErrors(toParseError, at) {
  5591. const index = at.index;
  5592. if (this.state.strict && !this.state.strictErrors.has(index)) {
  5593. this.raise(toParseError, at);
  5594. } else {
  5595. this.state.strictErrors.set(index, [toParseError, at]);
  5596. }
  5597. }
  5598. readWord1(firstCode) {
  5599. this.state.containsEsc = false;
  5600. let word = "";
  5601. const start = this.state.pos;
  5602. let chunkStart = this.state.pos;
  5603. if (firstCode !== undefined) {
  5604. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  5605. }
  5606. while (this.state.pos < this.length) {
  5607. const ch = this.codePointAtPos(this.state.pos);
  5608. if (isIdentifierChar(ch)) {
  5609. this.state.pos += ch <= 0xffff ? 1 : 2;
  5610. } else if (ch === 92) {
  5611. this.state.containsEsc = true;
  5612. word += this.input.slice(chunkStart, this.state.pos);
  5613. const escStart = this.state.curPosition();
  5614. const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
  5615. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  5616. this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
  5617. chunkStart = this.state.pos - 1;
  5618. continue;
  5619. }
  5620. ++this.state.pos;
  5621. const esc = this.readCodePoint(true);
  5622. if (esc !== null) {
  5623. if (!identifierCheck(esc)) {
  5624. this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
  5625. }
  5626. word += String.fromCodePoint(esc);
  5627. }
  5628. chunkStart = this.state.pos;
  5629. } else {
  5630. break;
  5631. }
  5632. }
  5633. return word + this.input.slice(chunkStart, this.state.pos);
  5634. }
  5635. readWord(firstCode) {
  5636. const word = this.readWord1(firstCode);
  5637. const type = keywords$1.get(word);
  5638. if (type !== undefined) {
  5639. this.finishToken(type, tokenLabelName(type));
  5640. } else {
  5641. this.finishToken(132, word);
  5642. }
  5643. }
  5644. checkKeywordEscapes() {
  5645. const {
  5646. type
  5647. } = this.state;
  5648. if (tokenIsKeyword(type) && this.state.containsEsc) {
  5649. this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
  5650. reservedWord: tokenLabelName(type)
  5651. });
  5652. }
  5653. }
  5654. raise(toParseError, at, details = {}) {
  5655. const loc = at instanceof Position ? at : at.loc.start;
  5656. const error = toParseError(loc, details);
  5657. if (!this.options.errorRecovery) throw error;
  5658. if (!this.isLookahead) this.state.errors.push(error);
  5659. return error;
  5660. }
  5661. raiseOverwrite(toParseError, at, details = {}) {
  5662. const loc = at instanceof Position ? at : at.loc.start;
  5663. const pos = loc.index;
  5664. const errors = this.state.errors;
  5665. for (let i = errors.length - 1; i >= 0; i--) {
  5666. const error = errors[i];
  5667. if (error.loc.index === pos) {
  5668. return errors[i] = toParseError(loc, details);
  5669. }
  5670. if (error.loc.index < pos) break;
  5671. }
  5672. return this.raise(toParseError, at, details);
  5673. }
  5674. updateContext(prevType) {}
  5675. unexpected(loc, type) {
  5676. throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
  5677. expected: type ? tokenLabelName(type) : null
  5678. });
  5679. }
  5680. expectPlugin(pluginName, loc) {
  5681. if (this.hasPlugin(pluginName)) {
  5682. return true;
  5683. }
  5684. throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
  5685. missingPlugin: [pluginName]
  5686. });
  5687. }
  5688. expectOnePlugin(pluginNames) {
  5689. if (!pluginNames.some(name => this.hasPlugin(name))) {
  5690. throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
  5691. missingPlugin: pluginNames
  5692. });
  5693. }
  5694. }
  5695. errorBuilder(error) {
  5696. return (pos, lineStart, curLine) => {
  5697. this.raise(error, buildPosition(pos, lineStart, curLine));
  5698. };
  5699. }
  5700. }
  5701. class ClassScope {
  5702. constructor() {
  5703. this.privateNames = new Set();
  5704. this.loneAccessors = new Map();
  5705. this.undefinedPrivateNames = new Map();
  5706. }
  5707. }
  5708. class ClassScopeHandler {
  5709. constructor(parser) {
  5710. this.parser = void 0;
  5711. this.stack = [];
  5712. this.undefinedPrivateNames = new Map();
  5713. this.parser = parser;
  5714. }
  5715. current() {
  5716. return this.stack[this.stack.length - 1];
  5717. }
  5718. enter() {
  5719. this.stack.push(new ClassScope());
  5720. }
  5721. exit() {
  5722. const oldClassScope = this.stack.pop();
  5723. const current = this.current();
  5724. for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
  5725. if (current) {
  5726. if (!current.undefinedPrivateNames.has(name)) {
  5727. current.undefinedPrivateNames.set(name, loc);
  5728. }
  5729. } else {
  5730. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5731. identifierName: name
  5732. });
  5733. }
  5734. }
  5735. }
  5736. declarePrivateName(name, elementType, loc) {
  5737. const {
  5738. privateNames,
  5739. loneAccessors,
  5740. undefinedPrivateNames
  5741. } = this.current();
  5742. let redefined = privateNames.has(name);
  5743. if (elementType & 3) {
  5744. const accessor = redefined && loneAccessors.get(name);
  5745. if (accessor) {
  5746. const oldStatic = accessor & 4;
  5747. const newStatic = elementType & 4;
  5748. const oldKind = accessor & 3;
  5749. const newKind = elementType & 3;
  5750. redefined = oldKind === newKind || oldStatic !== newStatic;
  5751. if (!redefined) loneAccessors.delete(name);
  5752. } else if (!redefined) {
  5753. loneAccessors.set(name, elementType);
  5754. }
  5755. }
  5756. if (redefined) {
  5757. this.parser.raise(Errors.PrivateNameRedeclaration, loc, {
  5758. identifierName: name
  5759. });
  5760. }
  5761. privateNames.add(name);
  5762. undefinedPrivateNames.delete(name);
  5763. }
  5764. usePrivateName(name, loc) {
  5765. let classScope;
  5766. for (classScope of this.stack) {
  5767. if (classScope.privateNames.has(name)) return;
  5768. }
  5769. if (classScope) {
  5770. classScope.undefinedPrivateNames.set(name, loc);
  5771. } else {
  5772. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5773. identifierName: name
  5774. });
  5775. }
  5776. }
  5777. }
  5778. class ExpressionScope {
  5779. constructor(type = 0) {
  5780. this.type = type;
  5781. }
  5782. canBeArrowParameterDeclaration() {
  5783. return this.type === 2 || this.type === 1;
  5784. }
  5785. isCertainlyParameterDeclaration() {
  5786. return this.type === 3;
  5787. }
  5788. }
  5789. class ArrowHeadParsingScope extends ExpressionScope {
  5790. constructor(type) {
  5791. super(type);
  5792. this.declarationErrors = new Map();
  5793. }
  5794. recordDeclarationError(ParsingErrorClass, at) {
  5795. const index = at.index;
  5796. this.declarationErrors.set(index, [ParsingErrorClass, at]);
  5797. }
  5798. clearDeclarationError(index) {
  5799. this.declarationErrors.delete(index);
  5800. }
  5801. iterateErrors(iterator) {
  5802. this.declarationErrors.forEach(iterator);
  5803. }
  5804. }
  5805. class ExpressionScopeHandler {
  5806. constructor(parser) {
  5807. this.parser = void 0;
  5808. this.stack = [new ExpressionScope()];
  5809. this.parser = parser;
  5810. }
  5811. enter(scope) {
  5812. this.stack.push(scope);
  5813. }
  5814. exit() {
  5815. this.stack.pop();
  5816. }
  5817. recordParameterInitializerError(toParseError, node) {
  5818. const origin = node.loc.start;
  5819. const {
  5820. stack
  5821. } = this;
  5822. let i = stack.length - 1;
  5823. let scope = stack[i];
  5824. while (!scope.isCertainlyParameterDeclaration()) {
  5825. if (scope.canBeArrowParameterDeclaration()) {
  5826. scope.recordDeclarationError(toParseError, origin);
  5827. } else {
  5828. return;
  5829. }
  5830. scope = stack[--i];
  5831. }
  5832. this.parser.raise(toParseError, origin);
  5833. }
  5834. recordArrowParameterBindingError(error, node) {
  5835. const {
  5836. stack
  5837. } = this;
  5838. const scope = stack[stack.length - 1];
  5839. const origin = node.loc.start;
  5840. if (scope.isCertainlyParameterDeclaration()) {
  5841. this.parser.raise(error, origin);
  5842. } else if (scope.canBeArrowParameterDeclaration()) {
  5843. scope.recordDeclarationError(error, origin);
  5844. } else {
  5845. return;
  5846. }
  5847. }
  5848. recordAsyncArrowParametersError(at) {
  5849. const {
  5850. stack
  5851. } = this;
  5852. let i = stack.length - 1;
  5853. let scope = stack[i];
  5854. while (scope.canBeArrowParameterDeclaration()) {
  5855. if (scope.type === 2) {
  5856. scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
  5857. }
  5858. scope = stack[--i];
  5859. }
  5860. }
  5861. validateAsPattern() {
  5862. const {
  5863. stack
  5864. } = this;
  5865. const currentScope = stack[stack.length - 1];
  5866. if (!currentScope.canBeArrowParameterDeclaration()) return;
  5867. currentScope.iterateErrors(([toParseError, loc]) => {
  5868. this.parser.raise(toParseError, loc);
  5869. let i = stack.length - 2;
  5870. let scope = stack[i];
  5871. while (scope.canBeArrowParameterDeclaration()) {
  5872. scope.clearDeclarationError(loc.index);
  5873. scope = stack[--i];
  5874. }
  5875. });
  5876. }
  5877. }
  5878. function newParameterDeclarationScope() {
  5879. return new ExpressionScope(3);
  5880. }
  5881. function newArrowHeadScope() {
  5882. return new ArrowHeadParsingScope(1);
  5883. }
  5884. function newAsyncArrowScope() {
  5885. return new ArrowHeadParsingScope(2);
  5886. }
  5887. function newExpressionScope() {
  5888. return new ExpressionScope();
  5889. }
  5890. class ProductionParameterHandler {
  5891. constructor() {
  5892. this.stacks = [];
  5893. }
  5894. enter(flags) {
  5895. this.stacks.push(flags);
  5896. }
  5897. exit() {
  5898. this.stacks.pop();
  5899. }
  5900. currentFlags() {
  5901. return this.stacks[this.stacks.length - 1];
  5902. }
  5903. get hasAwait() {
  5904. return (this.currentFlags() & 2) > 0;
  5905. }
  5906. get hasYield() {
  5907. return (this.currentFlags() & 1) > 0;
  5908. }
  5909. get hasReturn() {
  5910. return (this.currentFlags() & 4) > 0;
  5911. }
  5912. get hasIn() {
  5913. return (this.currentFlags() & 8) > 0;
  5914. }
  5915. }
  5916. function functionFlags(isAsync, isGenerator) {
  5917. return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
  5918. }
  5919. class UtilParser extends Tokenizer {
  5920. addExtra(node, key, value, enumerable = true) {
  5921. if (!node) return;
  5922. let {
  5923. extra
  5924. } = node;
  5925. if (extra == null) {
  5926. extra = {};
  5927. node.extra = extra;
  5928. }
  5929. if (enumerable) {
  5930. extra[key] = value;
  5931. } else {
  5932. Object.defineProperty(extra, key, {
  5933. enumerable,
  5934. value
  5935. });
  5936. }
  5937. }
  5938. isContextual(token) {
  5939. return this.state.type === token && !this.state.containsEsc;
  5940. }
  5941. isUnparsedContextual(nameStart, name) {
  5942. const nameEnd = nameStart + name.length;
  5943. if (this.input.slice(nameStart, nameEnd) === name) {
  5944. const nextCh = this.input.charCodeAt(nameEnd);
  5945. return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
  5946. }
  5947. return false;
  5948. }
  5949. isLookaheadContextual(name) {
  5950. const next = this.nextTokenStart();
  5951. return this.isUnparsedContextual(next, name);
  5952. }
  5953. eatContextual(token) {
  5954. if (this.isContextual(token)) {
  5955. this.next();
  5956. return true;
  5957. }
  5958. return false;
  5959. }
  5960. expectContextual(token, toParseError) {
  5961. if (!this.eatContextual(token)) {
  5962. if (toParseError != null) {
  5963. throw this.raise(toParseError, this.state.startLoc);
  5964. }
  5965. this.unexpected(null, token);
  5966. }
  5967. }
  5968. canInsertSemicolon() {
  5969. return this.match(139) || this.match(8) || this.hasPrecedingLineBreak();
  5970. }
  5971. hasPrecedingLineBreak() {
  5972. return hasNewLine(this.input, this.state.lastTokEndLoc.index, this.state.start);
  5973. }
  5974. hasFollowingLineBreak() {
  5975. return hasNewLine(this.input, this.state.end, this.nextTokenStart());
  5976. }
  5977. isLineTerminator() {
  5978. return this.eat(13) || this.canInsertSemicolon();
  5979. }
  5980. semicolon(allowAsi = true) {
  5981. if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
  5982. this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc);
  5983. }
  5984. expect(type, loc) {
  5985. if (!this.eat(type)) {
  5986. this.unexpected(loc, type);
  5987. }
  5988. }
  5989. tryParse(fn, oldState = this.state.clone()) {
  5990. const abortSignal = {
  5991. node: null
  5992. };
  5993. try {
  5994. const node = fn((node = null) => {
  5995. abortSignal.node = node;
  5996. throw abortSignal;
  5997. });
  5998. if (this.state.errors.length > oldState.errors.length) {
  5999. const failState = this.state;
  6000. this.state = oldState;
  6001. this.state.tokensLength = failState.tokensLength;
  6002. return {
  6003. node,
  6004. error: failState.errors[oldState.errors.length],
  6005. thrown: false,
  6006. aborted: false,
  6007. failState
  6008. };
  6009. }
  6010. return {
  6011. node,
  6012. error: null,
  6013. thrown: false,
  6014. aborted: false,
  6015. failState: null
  6016. };
  6017. } catch (error) {
  6018. const failState = this.state;
  6019. this.state = oldState;
  6020. if (error instanceof SyntaxError) {
  6021. return {
  6022. node: null,
  6023. error,
  6024. thrown: true,
  6025. aborted: false,
  6026. failState
  6027. };
  6028. }
  6029. if (error === abortSignal) {
  6030. return {
  6031. node: abortSignal.node,
  6032. error: null,
  6033. thrown: false,
  6034. aborted: true,
  6035. failState
  6036. };
  6037. }
  6038. throw error;
  6039. }
  6040. }
  6041. checkExpressionErrors(refExpressionErrors, andThrow) {
  6042. if (!refExpressionErrors) return false;
  6043. const {
  6044. shorthandAssignLoc,
  6045. doubleProtoLoc,
  6046. privateKeyLoc,
  6047. optionalParametersLoc
  6048. } = refExpressionErrors;
  6049. const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc;
  6050. if (!andThrow) {
  6051. return hasErrors;
  6052. }
  6053. if (shorthandAssignLoc != null) {
  6054. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  6055. }
  6056. if (doubleProtoLoc != null) {
  6057. this.raise(Errors.DuplicateProto, doubleProtoLoc);
  6058. }
  6059. if (privateKeyLoc != null) {
  6060. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  6061. }
  6062. if (optionalParametersLoc != null) {
  6063. this.unexpected(optionalParametersLoc);
  6064. }
  6065. }
  6066. isLiteralPropertyName() {
  6067. return tokenIsLiteralPropertyName(this.state.type);
  6068. }
  6069. isPrivateName(node) {
  6070. return node.type === "PrivateName";
  6071. }
  6072. getPrivateNameSV(node) {
  6073. return node.id.name;
  6074. }
  6075. hasPropertyAsPrivateName(node) {
  6076. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  6077. }
  6078. isObjectProperty(node) {
  6079. return node.type === "ObjectProperty";
  6080. }
  6081. isObjectMethod(node) {
  6082. return node.type === "ObjectMethod";
  6083. }
  6084. initializeScopes(inModule = this.options.sourceType === "module") {
  6085. const oldLabels = this.state.labels;
  6086. this.state.labels = [];
  6087. const oldExportedIdentifiers = this.exportedIdentifiers;
  6088. this.exportedIdentifiers = new Set();
  6089. const oldInModule = this.inModule;
  6090. this.inModule = inModule;
  6091. const oldScope = this.scope;
  6092. const ScopeHandler = this.getScopeHandler();
  6093. this.scope = new ScopeHandler(this, inModule);
  6094. const oldProdParam = this.prodParam;
  6095. this.prodParam = new ProductionParameterHandler();
  6096. const oldClassScope = this.classScope;
  6097. this.classScope = new ClassScopeHandler(this);
  6098. const oldExpressionScope = this.expressionScope;
  6099. this.expressionScope = new ExpressionScopeHandler(this);
  6100. return () => {
  6101. this.state.labels = oldLabels;
  6102. this.exportedIdentifiers = oldExportedIdentifiers;
  6103. this.inModule = oldInModule;
  6104. this.scope = oldScope;
  6105. this.prodParam = oldProdParam;
  6106. this.classScope = oldClassScope;
  6107. this.expressionScope = oldExpressionScope;
  6108. };
  6109. }
  6110. enterInitialScopes() {
  6111. let paramFlags = 0;
  6112. if (this.inModule) {
  6113. paramFlags |= 2;
  6114. }
  6115. this.scope.enter(1);
  6116. this.prodParam.enter(paramFlags);
  6117. }
  6118. checkDestructuringPrivate(refExpressionErrors) {
  6119. const {
  6120. privateKeyLoc
  6121. } = refExpressionErrors;
  6122. if (privateKeyLoc !== null) {
  6123. this.expectPlugin("destructuringPrivate", privateKeyLoc);
  6124. }
  6125. }
  6126. }
  6127. class ExpressionErrors {
  6128. constructor() {
  6129. this.shorthandAssignLoc = null;
  6130. this.doubleProtoLoc = null;
  6131. this.privateKeyLoc = null;
  6132. this.optionalParametersLoc = null;
  6133. }
  6134. }
  6135. class Node {
  6136. constructor(parser, pos, loc) {
  6137. this.type = "";
  6138. this.start = pos;
  6139. this.end = 0;
  6140. this.loc = new SourceLocation(loc);
  6141. if (parser != null && parser.options.ranges) this.range = [pos, 0];
  6142. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  6143. }
  6144. }
  6145. const NodePrototype = Node.prototype;
  6146. {
  6147. NodePrototype.__clone = function () {
  6148. const newNode = new Node(undefined, this.start, this.loc.start);
  6149. const keys = Object.keys(this);
  6150. for (let i = 0, length = keys.length; i < length; i++) {
  6151. const key = keys[i];
  6152. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  6153. newNode[key] = this[key];
  6154. }
  6155. }
  6156. return newNode;
  6157. };
  6158. }
  6159. function clonePlaceholder(node) {
  6160. return cloneIdentifier(node);
  6161. }
  6162. function cloneIdentifier(node) {
  6163. const {
  6164. type,
  6165. start,
  6166. end,
  6167. loc,
  6168. range,
  6169. extra,
  6170. name
  6171. } = node;
  6172. const cloned = Object.create(NodePrototype);
  6173. cloned.type = type;
  6174. cloned.start = start;
  6175. cloned.end = end;
  6176. cloned.loc = loc;
  6177. cloned.range = range;
  6178. cloned.extra = extra;
  6179. cloned.name = name;
  6180. if (type === "Placeholder") {
  6181. cloned.expectedNode = node.expectedNode;
  6182. }
  6183. return cloned;
  6184. }
  6185. function cloneStringLiteral(node) {
  6186. const {
  6187. type,
  6188. start,
  6189. end,
  6190. loc,
  6191. range,
  6192. extra
  6193. } = node;
  6194. if (type === "Placeholder") {
  6195. return clonePlaceholder(node);
  6196. }
  6197. const cloned = Object.create(NodePrototype);
  6198. cloned.type = type;
  6199. cloned.start = start;
  6200. cloned.end = end;
  6201. cloned.loc = loc;
  6202. cloned.range = range;
  6203. if (node.raw !== undefined) {
  6204. cloned.raw = node.raw;
  6205. } else {
  6206. cloned.extra = extra;
  6207. }
  6208. cloned.value = node.value;
  6209. return cloned;
  6210. }
  6211. class NodeUtils extends UtilParser {
  6212. startNode() {
  6213. const loc = this.state.startLoc;
  6214. return new Node(this, loc.index, loc);
  6215. }
  6216. startNodeAt(loc) {
  6217. return new Node(this, loc.index, loc);
  6218. }
  6219. startNodeAtNode(type) {
  6220. return this.startNodeAt(type.loc.start);
  6221. }
  6222. finishNode(node, type) {
  6223. return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
  6224. }
  6225. finishNodeAt(node, type, endLoc) {
  6226. node.type = type;
  6227. node.end = endLoc.index;
  6228. node.loc.end = endLoc;
  6229. if (this.options.ranges) node.range[1] = endLoc.index;
  6230. if (this.options.attachComment) this.processComment(node);
  6231. return node;
  6232. }
  6233. resetStartLocation(node, startLoc) {
  6234. node.start = startLoc.index;
  6235. node.loc.start = startLoc;
  6236. if (this.options.ranges) node.range[0] = startLoc.index;
  6237. }
  6238. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  6239. node.end = endLoc.index;
  6240. node.loc.end = endLoc;
  6241. if (this.options.ranges) node.range[1] = endLoc.index;
  6242. }
  6243. resetStartLocationFromNode(node, locationNode) {
  6244. this.resetStartLocation(node, locationNode.loc.start);
  6245. }
  6246. }
  6247. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  6248. const FlowErrors = ParseErrorEnum`flow`({
  6249. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  6250. 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.",
  6251. AssignReservedType: ({
  6252. reservedType
  6253. }) => `Cannot overwrite reserved type ${reservedType}.`,
  6254. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  6255. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  6256. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  6257. EnumBooleanMemberNotInitialized: ({
  6258. memberName,
  6259. enumName
  6260. }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`,
  6261. EnumDuplicateMemberName: ({
  6262. memberName,
  6263. enumName
  6264. }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`,
  6265. EnumInconsistentMemberValues: ({
  6266. enumName
  6267. }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
  6268. EnumInvalidExplicitType: ({
  6269. invalidEnumType,
  6270. enumName
  6271. }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6272. EnumInvalidExplicitTypeUnknownSupplied: ({
  6273. enumName
  6274. }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6275. EnumInvalidMemberInitializerPrimaryType: ({
  6276. enumName,
  6277. memberName,
  6278. explicitType
  6279. }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`,
  6280. EnumInvalidMemberInitializerSymbolType: ({
  6281. enumName,
  6282. memberName
  6283. }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`,
  6284. EnumInvalidMemberInitializerUnknownType: ({
  6285. enumName,
  6286. memberName
  6287. }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
  6288. EnumInvalidMemberName: ({
  6289. enumName,
  6290. memberName,
  6291. suggestion
  6292. }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
  6293. EnumNumberMemberNotInitialized: ({
  6294. enumName,
  6295. memberName
  6296. }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`,
  6297. EnumStringMemberInconsistentlyInitialized: ({
  6298. enumName
  6299. }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
  6300. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  6301. ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.",
  6302. 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.",
  6303. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  6304. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  6305. InexactVariance: "Explicit inexact syntax cannot have variance.",
  6306. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  6307. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  6308. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  6309. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  6310. PatternIsOptional: Object.assign({
  6311. message: "A binding pattern parameter cannot be optional in an implementation signature."
  6312. }, {
  6313. reasonCode: "OptionalBindingPattern"
  6314. }),
  6315. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  6316. SpreadVariance: "Spread properties cannot have variance.",
  6317. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  6318. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  6319. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  6320. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  6321. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  6322. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  6323. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  6324. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  6325. UnexpectedReservedType: ({
  6326. reservedType
  6327. }) => `Unexpected reserved type ${reservedType}.`,
  6328. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  6329. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  6330. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  6331. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  6332. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  6333. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  6334. UnsupportedDeclareExportKind: ({
  6335. unsupportedExportKind,
  6336. suggestion
  6337. }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,
  6338. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  6339. UnterminatedFlowComment: "Unterminated flow-comment."
  6340. });
  6341. function isEsModuleType(bodyElement) {
  6342. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  6343. }
  6344. function hasTypeImportKind(node) {
  6345. return node.importKind === "type" || node.importKind === "typeof";
  6346. }
  6347. const exportSuggestions = {
  6348. const: "declare export var",
  6349. let: "declare export var",
  6350. type: "export type",
  6351. interface: "export interface"
  6352. };
  6353. function partition(list, test) {
  6354. const list1 = [];
  6355. const list2 = [];
  6356. for (let i = 0; i < list.length; i++) {
  6357. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  6358. }
  6359. return [list1, list2];
  6360. }
  6361. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  6362. var flow = superClass => class FlowParserMixin extends superClass {
  6363. constructor(...args) {
  6364. super(...args);
  6365. this.flowPragma = undefined;
  6366. }
  6367. getScopeHandler() {
  6368. return FlowScopeHandler;
  6369. }
  6370. shouldParseTypes() {
  6371. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  6372. }
  6373. shouldParseEnums() {
  6374. return !!this.getPluginOption("flow", "enums");
  6375. }
  6376. finishToken(type, val) {
  6377. if (type !== 133 && type !== 13 && type !== 28) {
  6378. if (this.flowPragma === undefined) {
  6379. this.flowPragma = null;
  6380. }
  6381. }
  6382. super.finishToken(type, val);
  6383. }
  6384. addComment(comment) {
  6385. if (this.flowPragma === undefined) {
  6386. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  6387. if (!matches) ;else if (matches[1] === "flow") {
  6388. this.flowPragma = "flow";
  6389. } else if (matches[1] === "noflow") {
  6390. this.flowPragma = "noflow";
  6391. } else {
  6392. throw new Error("Unexpected flow pragma");
  6393. }
  6394. }
  6395. super.addComment(comment);
  6396. }
  6397. flowParseTypeInitialiser(tok) {
  6398. const oldInType = this.state.inType;
  6399. this.state.inType = true;
  6400. this.expect(tok || 14);
  6401. const type = this.flowParseType();
  6402. this.state.inType = oldInType;
  6403. return type;
  6404. }
  6405. flowParsePredicate() {
  6406. const node = this.startNode();
  6407. const moduloLoc = this.state.startLoc;
  6408. this.next();
  6409. this.expectContextual(110);
  6410. if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
  6411. this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
  6412. }
  6413. if (this.eat(10)) {
  6414. node.value = super.parseExpression();
  6415. this.expect(11);
  6416. return this.finishNode(node, "DeclaredPredicate");
  6417. } else {
  6418. return this.finishNode(node, "InferredPredicate");
  6419. }
  6420. }
  6421. flowParseTypeAndPredicateInitialiser() {
  6422. const oldInType = this.state.inType;
  6423. this.state.inType = true;
  6424. this.expect(14);
  6425. let type = null;
  6426. let predicate = null;
  6427. if (this.match(54)) {
  6428. this.state.inType = oldInType;
  6429. predicate = this.flowParsePredicate();
  6430. } else {
  6431. type = this.flowParseType();
  6432. this.state.inType = oldInType;
  6433. if (this.match(54)) {
  6434. predicate = this.flowParsePredicate();
  6435. }
  6436. }
  6437. return [type, predicate];
  6438. }
  6439. flowParseDeclareClass(node) {
  6440. this.next();
  6441. this.flowParseInterfaceish(node, true);
  6442. return this.finishNode(node, "DeclareClass");
  6443. }
  6444. flowParseDeclareFunction(node) {
  6445. this.next();
  6446. const id = node.id = this.parseIdentifier();
  6447. const typeNode = this.startNode();
  6448. const typeContainer = this.startNode();
  6449. if (this.match(47)) {
  6450. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  6451. } else {
  6452. typeNode.typeParameters = null;
  6453. }
  6454. this.expect(10);
  6455. const tmp = this.flowParseFunctionTypeParams();
  6456. typeNode.params = tmp.params;
  6457. typeNode.rest = tmp.rest;
  6458. typeNode.this = tmp._this;
  6459. this.expect(11);
  6460. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  6461. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  6462. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  6463. this.resetEndLocation(id);
  6464. this.semicolon();
  6465. this.scope.declareName(node.id.name, 2048, node.id.loc.start);
  6466. return this.finishNode(node, "DeclareFunction");
  6467. }
  6468. flowParseDeclare(node, insideModule) {
  6469. if (this.match(80)) {
  6470. return this.flowParseDeclareClass(node);
  6471. } else if (this.match(68)) {
  6472. return this.flowParseDeclareFunction(node);
  6473. } else if (this.match(74)) {
  6474. return this.flowParseDeclareVariable(node);
  6475. } else if (this.eatContextual(127)) {
  6476. if (this.match(16)) {
  6477. return this.flowParseDeclareModuleExports(node);
  6478. } else {
  6479. if (insideModule) {
  6480. this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
  6481. }
  6482. return this.flowParseDeclareModule(node);
  6483. }
  6484. } else if (this.isContextual(130)) {
  6485. return this.flowParseDeclareTypeAlias(node);
  6486. } else if (this.isContextual(131)) {
  6487. return this.flowParseDeclareOpaqueType(node);
  6488. } else if (this.isContextual(129)) {
  6489. return this.flowParseDeclareInterface(node);
  6490. } else if (this.match(82)) {
  6491. return this.flowParseDeclareExportDeclaration(node, insideModule);
  6492. } else {
  6493. this.unexpected();
  6494. }
  6495. }
  6496. flowParseDeclareVariable(node) {
  6497. this.next();
  6498. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  6499. this.scope.declareName(node.id.name, 5, node.id.loc.start);
  6500. this.semicolon();
  6501. return this.finishNode(node, "DeclareVariable");
  6502. }
  6503. flowParseDeclareModule(node) {
  6504. this.scope.enter(0);
  6505. if (this.match(133)) {
  6506. node.id = super.parseExprAtom();
  6507. } else {
  6508. node.id = this.parseIdentifier();
  6509. }
  6510. const bodyNode = node.body = this.startNode();
  6511. const body = bodyNode.body = [];
  6512. this.expect(5);
  6513. while (!this.match(8)) {
  6514. let bodyNode = this.startNode();
  6515. if (this.match(83)) {
  6516. this.next();
  6517. if (!this.isContextual(130) && !this.match(87)) {
  6518. this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
  6519. }
  6520. super.parseImport(bodyNode);
  6521. } else {
  6522. this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
  6523. bodyNode = this.flowParseDeclare(bodyNode, true);
  6524. }
  6525. body.push(bodyNode);
  6526. }
  6527. this.scope.exit();
  6528. this.expect(8);
  6529. this.finishNode(bodyNode, "BlockStatement");
  6530. let kind = null;
  6531. let hasModuleExport = false;
  6532. body.forEach(bodyElement => {
  6533. if (isEsModuleType(bodyElement)) {
  6534. if (kind === "CommonJS") {
  6535. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6536. }
  6537. kind = "ES";
  6538. } else if (bodyElement.type === "DeclareModuleExports") {
  6539. if (hasModuleExport) {
  6540. this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement);
  6541. }
  6542. if (kind === "ES") {
  6543. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6544. }
  6545. kind = "CommonJS";
  6546. hasModuleExport = true;
  6547. }
  6548. });
  6549. node.kind = kind || "CommonJS";
  6550. return this.finishNode(node, "DeclareModule");
  6551. }
  6552. flowParseDeclareExportDeclaration(node, insideModule) {
  6553. this.expect(82);
  6554. if (this.eat(65)) {
  6555. if (this.match(68) || this.match(80)) {
  6556. node.declaration = this.flowParseDeclare(this.startNode());
  6557. } else {
  6558. node.declaration = this.flowParseType();
  6559. this.semicolon();
  6560. }
  6561. node.default = true;
  6562. return this.finishNode(node, "DeclareExportDeclaration");
  6563. } else {
  6564. if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) {
  6565. const label = this.state.value;
  6566. throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
  6567. unsupportedExportKind: label,
  6568. suggestion: exportSuggestions[label]
  6569. });
  6570. }
  6571. if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) {
  6572. node.declaration = this.flowParseDeclare(this.startNode());
  6573. node.default = false;
  6574. return this.finishNode(node, "DeclareExportDeclaration");
  6575. } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) {
  6576. node = this.parseExport(node, null);
  6577. if (node.type === "ExportNamedDeclaration") {
  6578. node.type = "ExportDeclaration";
  6579. node.default = false;
  6580. delete node.exportKind;
  6581. }
  6582. node.type = "Declare" + node.type;
  6583. return node;
  6584. }
  6585. }
  6586. this.unexpected();
  6587. }
  6588. flowParseDeclareModuleExports(node) {
  6589. this.next();
  6590. this.expectContextual(111);
  6591. node.typeAnnotation = this.flowParseTypeAnnotation();
  6592. this.semicolon();
  6593. return this.finishNode(node, "DeclareModuleExports");
  6594. }
  6595. flowParseDeclareTypeAlias(node) {
  6596. this.next();
  6597. const finished = this.flowParseTypeAlias(node);
  6598. finished.type = "DeclareTypeAlias";
  6599. return finished;
  6600. }
  6601. flowParseDeclareOpaqueType(node) {
  6602. this.next();
  6603. const finished = this.flowParseOpaqueType(node, true);
  6604. finished.type = "DeclareOpaqueType";
  6605. return finished;
  6606. }
  6607. flowParseDeclareInterface(node) {
  6608. this.next();
  6609. this.flowParseInterfaceish(node, false);
  6610. return this.finishNode(node, "DeclareInterface");
  6611. }
  6612. flowParseInterfaceish(node, isClass) {
  6613. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  6614. this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start);
  6615. if (this.match(47)) {
  6616. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6617. } else {
  6618. node.typeParameters = null;
  6619. }
  6620. node.extends = [];
  6621. if (this.eat(81)) {
  6622. do {
  6623. node.extends.push(this.flowParseInterfaceExtends());
  6624. } while (!isClass && this.eat(12));
  6625. }
  6626. if (isClass) {
  6627. node.implements = [];
  6628. node.mixins = [];
  6629. if (this.eatContextual(117)) {
  6630. do {
  6631. node.mixins.push(this.flowParseInterfaceExtends());
  6632. } while (this.eat(12));
  6633. }
  6634. if (this.eatContextual(113)) {
  6635. do {
  6636. node.implements.push(this.flowParseInterfaceExtends());
  6637. } while (this.eat(12));
  6638. }
  6639. }
  6640. node.body = this.flowParseObjectType({
  6641. allowStatic: isClass,
  6642. allowExact: false,
  6643. allowSpread: false,
  6644. allowProto: isClass,
  6645. allowInexact: false
  6646. });
  6647. }
  6648. flowParseInterfaceExtends() {
  6649. const node = this.startNode();
  6650. node.id = this.flowParseQualifiedTypeIdentifier();
  6651. if (this.match(47)) {
  6652. node.typeParameters = this.flowParseTypeParameterInstantiation();
  6653. } else {
  6654. node.typeParameters = null;
  6655. }
  6656. return this.finishNode(node, "InterfaceExtends");
  6657. }
  6658. flowParseInterface(node) {
  6659. this.flowParseInterfaceish(node, false);
  6660. return this.finishNode(node, "InterfaceDeclaration");
  6661. }
  6662. checkNotUnderscore(word) {
  6663. if (word === "_") {
  6664. this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc);
  6665. }
  6666. }
  6667. checkReservedType(word, startLoc, declaration) {
  6668. if (!reservedTypes.has(word)) return;
  6669. this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, {
  6670. reservedType: word
  6671. });
  6672. }
  6673. flowParseRestrictedIdentifier(liberal, declaration) {
  6674. this.checkReservedType(this.state.value, this.state.startLoc, declaration);
  6675. return this.parseIdentifier(liberal);
  6676. }
  6677. flowParseTypeAlias(node) {
  6678. node.id = this.flowParseRestrictedIdentifier(false, true);
  6679. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6680. if (this.match(47)) {
  6681. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6682. } else {
  6683. node.typeParameters = null;
  6684. }
  6685. node.right = this.flowParseTypeInitialiser(29);
  6686. this.semicolon();
  6687. return this.finishNode(node, "TypeAlias");
  6688. }
  6689. flowParseOpaqueType(node, declare) {
  6690. this.expectContextual(130);
  6691. node.id = this.flowParseRestrictedIdentifier(true, true);
  6692. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6693. if (this.match(47)) {
  6694. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6695. } else {
  6696. node.typeParameters = null;
  6697. }
  6698. node.supertype = null;
  6699. if (this.match(14)) {
  6700. node.supertype = this.flowParseTypeInitialiser(14);
  6701. }
  6702. node.impltype = null;
  6703. if (!declare) {
  6704. node.impltype = this.flowParseTypeInitialiser(29);
  6705. }
  6706. this.semicolon();
  6707. return this.finishNode(node, "OpaqueType");
  6708. }
  6709. flowParseTypeParameter(requireDefault = false) {
  6710. const nodeStartLoc = this.state.startLoc;
  6711. const node = this.startNode();
  6712. const variance = this.flowParseVariance();
  6713. const ident = this.flowParseTypeAnnotatableIdentifier();
  6714. node.name = ident.name;
  6715. node.variance = variance;
  6716. node.bound = ident.typeAnnotation;
  6717. if (this.match(29)) {
  6718. this.eat(29);
  6719. node.default = this.flowParseType();
  6720. } else {
  6721. if (requireDefault) {
  6722. this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc);
  6723. }
  6724. }
  6725. return this.finishNode(node, "TypeParameter");
  6726. }
  6727. flowParseTypeParameterDeclaration() {
  6728. const oldInType = this.state.inType;
  6729. const node = this.startNode();
  6730. node.params = [];
  6731. this.state.inType = true;
  6732. if (this.match(47) || this.match(142)) {
  6733. this.next();
  6734. } else {
  6735. this.unexpected();
  6736. }
  6737. let defaultRequired = false;
  6738. do {
  6739. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  6740. node.params.push(typeParameter);
  6741. if (typeParameter.default) {
  6742. defaultRequired = true;
  6743. }
  6744. if (!this.match(48)) {
  6745. this.expect(12);
  6746. }
  6747. } while (!this.match(48));
  6748. this.expect(48);
  6749. this.state.inType = oldInType;
  6750. return this.finishNode(node, "TypeParameterDeclaration");
  6751. }
  6752. flowParseTypeParameterInstantiation() {
  6753. const node = this.startNode();
  6754. const oldInType = this.state.inType;
  6755. node.params = [];
  6756. this.state.inType = true;
  6757. this.expect(47);
  6758. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  6759. this.state.noAnonFunctionType = false;
  6760. while (!this.match(48)) {
  6761. node.params.push(this.flowParseType());
  6762. if (!this.match(48)) {
  6763. this.expect(12);
  6764. }
  6765. }
  6766. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  6767. this.expect(48);
  6768. this.state.inType = oldInType;
  6769. return this.finishNode(node, "TypeParameterInstantiation");
  6770. }
  6771. flowParseTypeParameterInstantiationCallOrNew() {
  6772. const node = this.startNode();
  6773. const oldInType = this.state.inType;
  6774. node.params = [];
  6775. this.state.inType = true;
  6776. this.expect(47);
  6777. while (!this.match(48)) {
  6778. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  6779. if (!this.match(48)) {
  6780. this.expect(12);
  6781. }
  6782. }
  6783. this.expect(48);
  6784. this.state.inType = oldInType;
  6785. return this.finishNode(node, "TypeParameterInstantiation");
  6786. }
  6787. flowParseInterfaceType() {
  6788. const node = this.startNode();
  6789. this.expectContextual(129);
  6790. node.extends = [];
  6791. if (this.eat(81)) {
  6792. do {
  6793. node.extends.push(this.flowParseInterfaceExtends());
  6794. } while (this.eat(12));
  6795. }
  6796. node.body = this.flowParseObjectType({
  6797. allowStatic: false,
  6798. allowExact: false,
  6799. allowSpread: false,
  6800. allowProto: false,
  6801. allowInexact: false
  6802. });
  6803. return this.finishNode(node, "InterfaceTypeAnnotation");
  6804. }
  6805. flowParseObjectPropertyKey() {
  6806. return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
  6807. }
  6808. flowParseObjectTypeIndexer(node, isStatic, variance) {
  6809. node.static = isStatic;
  6810. if (this.lookahead().type === 14) {
  6811. node.id = this.flowParseObjectPropertyKey();
  6812. node.key = this.flowParseTypeInitialiser();
  6813. } else {
  6814. node.id = null;
  6815. node.key = this.flowParseType();
  6816. }
  6817. this.expect(3);
  6818. node.value = this.flowParseTypeInitialiser();
  6819. node.variance = variance;
  6820. return this.finishNode(node, "ObjectTypeIndexer");
  6821. }
  6822. flowParseObjectTypeInternalSlot(node, isStatic) {
  6823. node.static = isStatic;
  6824. node.id = this.flowParseObjectPropertyKey();
  6825. this.expect(3);
  6826. this.expect(3);
  6827. if (this.match(47) || this.match(10)) {
  6828. node.method = true;
  6829. node.optional = false;
  6830. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6831. } else {
  6832. node.method = false;
  6833. if (this.eat(17)) {
  6834. node.optional = true;
  6835. }
  6836. node.value = this.flowParseTypeInitialiser();
  6837. }
  6838. return this.finishNode(node, "ObjectTypeInternalSlot");
  6839. }
  6840. flowParseObjectTypeMethodish(node) {
  6841. node.params = [];
  6842. node.rest = null;
  6843. node.typeParameters = null;
  6844. node.this = null;
  6845. if (this.match(47)) {
  6846. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6847. }
  6848. this.expect(10);
  6849. if (this.match(78)) {
  6850. node.this = this.flowParseFunctionTypeParam(true);
  6851. node.this.name = null;
  6852. if (!this.match(11)) {
  6853. this.expect(12);
  6854. }
  6855. }
  6856. while (!this.match(11) && !this.match(21)) {
  6857. node.params.push(this.flowParseFunctionTypeParam(false));
  6858. if (!this.match(11)) {
  6859. this.expect(12);
  6860. }
  6861. }
  6862. if (this.eat(21)) {
  6863. node.rest = this.flowParseFunctionTypeParam(false);
  6864. }
  6865. this.expect(11);
  6866. node.returnType = this.flowParseTypeInitialiser();
  6867. return this.finishNode(node, "FunctionTypeAnnotation");
  6868. }
  6869. flowParseObjectTypeCallProperty(node, isStatic) {
  6870. const valueNode = this.startNode();
  6871. node.static = isStatic;
  6872. node.value = this.flowParseObjectTypeMethodish(valueNode);
  6873. return this.finishNode(node, "ObjectTypeCallProperty");
  6874. }
  6875. flowParseObjectType({
  6876. allowStatic,
  6877. allowExact,
  6878. allowSpread,
  6879. allowProto,
  6880. allowInexact
  6881. }) {
  6882. const oldInType = this.state.inType;
  6883. this.state.inType = true;
  6884. const nodeStart = this.startNode();
  6885. nodeStart.callProperties = [];
  6886. nodeStart.properties = [];
  6887. nodeStart.indexers = [];
  6888. nodeStart.internalSlots = [];
  6889. let endDelim;
  6890. let exact;
  6891. let inexact = false;
  6892. if (allowExact && this.match(6)) {
  6893. this.expect(6);
  6894. endDelim = 9;
  6895. exact = true;
  6896. } else {
  6897. this.expect(5);
  6898. endDelim = 8;
  6899. exact = false;
  6900. }
  6901. nodeStart.exact = exact;
  6902. while (!this.match(endDelim)) {
  6903. let isStatic = false;
  6904. let protoStartLoc = null;
  6905. let inexactStartLoc = null;
  6906. const node = this.startNode();
  6907. if (allowProto && this.isContextual(118)) {
  6908. const lookahead = this.lookahead();
  6909. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6910. this.next();
  6911. protoStartLoc = this.state.startLoc;
  6912. allowStatic = false;
  6913. }
  6914. }
  6915. if (allowStatic && this.isContextual(106)) {
  6916. const lookahead = this.lookahead();
  6917. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6918. this.next();
  6919. isStatic = true;
  6920. }
  6921. }
  6922. const variance = this.flowParseVariance();
  6923. if (this.eat(0)) {
  6924. if (protoStartLoc != null) {
  6925. this.unexpected(protoStartLoc);
  6926. }
  6927. if (this.eat(0)) {
  6928. if (variance) {
  6929. this.unexpected(variance.loc.start);
  6930. }
  6931. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  6932. } else {
  6933. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  6934. }
  6935. } else if (this.match(10) || this.match(47)) {
  6936. if (protoStartLoc != null) {
  6937. this.unexpected(protoStartLoc);
  6938. }
  6939. if (variance) {
  6940. this.unexpected(variance.loc.start);
  6941. }
  6942. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  6943. } else {
  6944. let kind = "init";
  6945. if (this.isContextual(99) || this.isContextual(104)) {
  6946. const lookahead = this.lookahead();
  6947. if (tokenIsLiteralPropertyName(lookahead.type)) {
  6948. kind = this.state.value;
  6949. this.next();
  6950. }
  6951. }
  6952. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  6953. if (propOrInexact === null) {
  6954. inexact = true;
  6955. inexactStartLoc = this.state.lastTokStartLoc;
  6956. } else {
  6957. nodeStart.properties.push(propOrInexact);
  6958. }
  6959. }
  6960. this.flowObjectTypeSemicolon();
  6961. if (inexactStartLoc && !this.match(8) && !this.match(9)) {
  6962. this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc);
  6963. }
  6964. }
  6965. this.expect(endDelim);
  6966. if (allowSpread) {
  6967. nodeStart.inexact = inexact;
  6968. }
  6969. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  6970. this.state.inType = oldInType;
  6971. return out;
  6972. }
  6973. flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
  6974. if (this.eat(21)) {
  6975. const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
  6976. if (isInexactToken) {
  6977. if (!allowSpread) {
  6978. this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc);
  6979. } else if (!allowInexact) {
  6980. this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc);
  6981. }
  6982. if (variance) {
  6983. this.raise(FlowErrors.InexactVariance, variance);
  6984. }
  6985. return null;
  6986. }
  6987. if (!allowSpread) {
  6988. this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc);
  6989. }
  6990. if (protoStartLoc != null) {
  6991. this.unexpected(protoStartLoc);
  6992. }
  6993. if (variance) {
  6994. this.raise(FlowErrors.SpreadVariance, variance);
  6995. }
  6996. node.argument = this.flowParseType();
  6997. return this.finishNode(node, "ObjectTypeSpreadProperty");
  6998. } else {
  6999. node.key = this.flowParseObjectPropertyKey();
  7000. node.static = isStatic;
  7001. node.proto = protoStartLoc != null;
  7002. node.kind = kind;
  7003. let optional = false;
  7004. if (this.match(47) || this.match(10)) {
  7005. node.method = true;
  7006. if (protoStartLoc != null) {
  7007. this.unexpected(protoStartLoc);
  7008. }
  7009. if (variance) {
  7010. this.unexpected(variance.loc.start);
  7011. }
  7012. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  7013. if (kind === "get" || kind === "set") {
  7014. this.flowCheckGetterSetterParams(node);
  7015. }
  7016. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  7017. this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this);
  7018. }
  7019. } else {
  7020. if (kind !== "init") this.unexpected();
  7021. node.method = false;
  7022. if (this.eat(17)) {
  7023. optional = true;
  7024. }
  7025. node.value = this.flowParseTypeInitialiser();
  7026. node.variance = variance;
  7027. }
  7028. node.optional = optional;
  7029. return this.finishNode(node, "ObjectTypeProperty");
  7030. }
  7031. }
  7032. flowCheckGetterSetterParams(property) {
  7033. const paramCount = property.kind === "get" ? 0 : 1;
  7034. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  7035. if (property.value.this) {
  7036. this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this);
  7037. }
  7038. if (length !== paramCount) {
  7039. this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property);
  7040. }
  7041. if (property.kind === "set" && property.value.rest) {
  7042. this.raise(Errors.BadSetterRestParameter, property);
  7043. }
  7044. }
  7045. flowObjectTypeSemicolon() {
  7046. if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) {
  7047. this.unexpected();
  7048. }
  7049. }
  7050. flowParseQualifiedTypeIdentifier(startLoc, id) {
  7051. var _startLoc;
  7052. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  7053. let node = id || this.flowParseRestrictedIdentifier(true);
  7054. while (this.eat(16)) {
  7055. const node2 = this.startNodeAt(startLoc);
  7056. node2.qualification = node;
  7057. node2.id = this.flowParseRestrictedIdentifier(true);
  7058. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  7059. }
  7060. return node;
  7061. }
  7062. flowParseGenericType(startLoc, id) {
  7063. const node = this.startNodeAt(startLoc);
  7064. node.typeParameters = null;
  7065. node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id);
  7066. if (this.match(47)) {
  7067. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7068. }
  7069. return this.finishNode(node, "GenericTypeAnnotation");
  7070. }
  7071. flowParseTypeofType() {
  7072. const node = this.startNode();
  7073. this.expect(87);
  7074. node.argument = this.flowParsePrimaryType();
  7075. return this.finishNode(node, "TypeofTypeAnnotation");
  7076. }
  7077. flowParseTupleType() {
  7078. const node = this.startNode();
  7079. node.types = [];
  7080. this.expect(0);
  7081. while (this.state.pos < this.length && !this.match(3)) {
  7082. node.types.push(this.flowParseType());
  7083. if (this.match(3)) break;
  7084. this.expect(12);
  7085. }
  7086. this.expect(3);
  7087. return this.finishNode(node, "TupleTypeAnnotation");
  7088. }
  7089. flowParseFunctionTypeParam(first) {
  7090. let name = null;
  7091. let optional = false;
  7092. let typeAnnotation = null;
  7093. const node = this.startNode();
  7094. const lh = this.lookahead();
  7095. const isThis = this.state.type === 78;
  7096. if (lh.type === 14 || lh.type === 17) {
  7097. if (isThis && !first) {
  7098. this.raise(FlowErrors.ThisParamMustBeFirst, node);
  7099. }
  7100. name = this.parseIdentifier(isThis);
  7101. if (this.eat(17)) {
  7102. optional = true;
  7103. if (isThis) {
  7104. this.raise(FlowErrors.ThisParamMayNotBeOptional, node);
  7105. }
  7106. }
  7107. typeAnnotation = this.flowParseTypeInitialiser();
  7108. } else {
  7109. typeAnnotation = this.flowParseType();
  7110. }
  7111. node.name = name;
  7112. node.optional = optional;
  7113. node.typeAnnotation = typeAnnotation;
  7114. return this.finishNode(node, "FunctionTypeParam");
  7115. }
  7116. reinterpretTypeAsFunctionTypeParam(type) {
  7117. const node = this.startNodeAt(type.loc.start);
  7118. node.name = null;
  7119. node.optional = false;
  7120. node.typeAnnotation = type;
  7121. return this.finishNode(node, "FunctionTypeParam");
  7122. }
  7123. flowParseFunctionTypeParams(params = []) {
  7124. let rest = null;
  7125. let _this = null;
  7126. if (this.match(78)) {
  7127. _this = this.flowParseFunctionTypeParam(true);
  7128. _this.name = null;
  7129. if (!this.match(11)) {
  7130. this.expect(12);
  7131. }
  7132. }
  7133. while (!this.match(11) && !this.match(21)) {
  7134. params.push(this.flowParseFunctionTypeParam(false));
  7135. if (!this.match(11)) {
  7136. this.expect(12);
  7137. }
  7138. }
  7139. if (this.eat(21)) {
  7140. rest = this.flowParseFunctionTypeParam(false);
  7141. }
  7142. return {
  7143. params,
  7144. rest,
  7145. _this
  7146. };
  7147. }
  7148. flowIdentToTypeAnnotation(startLoc, node, id) {
  7149. switch (id.name) {
  7150. case "any":
  7151. return this.finishNode(node, "AnyTypeAnnotation");
  7152. case "bool":
  7153. case "boolean":
  7154. return this.finishNode(node, "BooleanTypeAnnotation");
  7155. case "mixed":
  7156. return this.finishNode(node, "MixedTypeAnnotation");
  7157. case "empty":
  7158. return this.finishNode(node, "EmptyTypeAnnotation");
  7159. case "number":
  7160. return this.finishNode(node, "NumberTypeAnnotation");
  7161. case "string":
  7162. return this.finishNode(node, "StringTypeAnnotation");
  7163. case "symbol":
  7164. return this.finishNode(node, "SymbolTypeAnnotation");
  7165. default:
  7166. this.checkNotUnderscore(id.name);
  7167. return this.flowParseGenericType(startLoc, id);
  7168. }
  7169. }
  7170. flowParsePrimaryType() {
  7171. const startLoc = this.state.startLoc;
  7172. const node = this.startNode();
  7173. let tmp;
  7174. let type;
  7175. let isGroupedType = false;
  7176. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7177. switch (this.state.type) {
  7178. case 5:
  7179. return this.flowParseObjectType({
  7180. allowStatic: false,
  7181. allowExact: false,
  7182. allowSpread: true,
  7183. allowProto: false,
  7184. allowInexact: true
  7185. });
  7186. case 6:
  7187. return this.flowParseObjectType({
  7188. allowStatic: false,
  7189. allowExact: true,
  7190. allowSpread: true,
  7191. allowProto: false,
  7192. allowInexact: false
  7193. });
  7194. case 0:
  7195. this.state.noAnonFunctionType = false;
  7196. type = this.flowParseTupleType();
  7197. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7198. return type;
  7199. case 47:
  7200. {
  7201. const node = this.startNode();
  7202. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7203. this.expect(10);
  7204. tmp = this.flowParseFunctionTypeParams();
  7205. node.params = tmp.params;
  7206. node.rest = tmp.rest;
  7207. node.this = tmp._this;
  7208. this.expect(11);
  7209. this.expect(19);
  7210. node.returnType = this.flowParseType();
  7211. return this.finishNode(node, "FunctionTypeAnnotation");
  7212. }
  7213. case 10:
  7214. {
  7215. const node = this.startNode();
  7216. this.next();
  7217. if (!this.match(11) && !this.match(21)) {
  7218. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  7219. const token = this.lookahead().type;
  7220. isGroupedType = token !== 17 && token !== 14;
  7221. } else {
  7222. isGroupedType = true;
  7223. }
  7224. }
  7225. if (isGroupedType) {
  7226. this.state.noAnonFunctionType = false;
  7227. type = this.flowParseType();
  7228. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7229. if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) {
  7230. this.expect(11);
  7231. return type;
  7232. } else {
  7233. this.eat(12);
  7234. }
  7235. }
  7236. if (type) {
  7237. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  7238. } else {
  7239. tmp = this.flowParseFunctionTypeParams();
  7240. }
  7241. node.params = tmp.params;
  7242. node.rest = tmp.rest;
  7243. node.this = tmp._this;
  7244. this.expect(11);
  7245. this.expect(19);
  7246. node.returnType = this.flowParseType();
  7247. node.typeParameters = null;
  7248. return this.finishNode(node, "FunctionTypeAnnotation");
  7249. }
  7250. case 133:
  7251. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  7252. case 85:
  7253. case 86:
  7254. node.value = this.match(85);
  7255. this.next();
  7256. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  7257. case 53:
  7258. if (this.state.value === "-") {
  7259. this.next();
  7260. if (this.match(134)) {
  7261. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  7262. }
  7263. if (this.match(135)) {
  7264. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  7265. }
  7266. throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
  7267. }
  7268. this.unexpected();
  7269. return;
  7270. case 134:
  7271. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  7272. case 135:
  7273. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  7274. case 88:
  7275. this.next();
  7276. return this.finishNode(node, "VoidTypeAnnotation");
  7277. case 84:
  7278. this.next();
  7279. return this.finishNode(node, "NullLiteralTypeAnnotation");
  7280. case 78:
  7281. this.next();
  7282. return this.finishNode(node, "ThisTypeAnnotation");
  7283. case 55:
  7284. this.next();
  7285. return this.finishNode(node, "ExistsTypeAnnotation");
  7286. case 87:
  7287. return this.flowParseTypeofType();
  7288. default:
  7289. if (tokenIsKeyword(this.state.type)) {
  7290. const label = tokenLabelName(this.state.type);
  7291. this.next();
  7292. return super.createIdentifier(node, label);
  7293. } else if (tokenIsIdentifier(this.state.type)) {
  7294. if (this.isContextual(129)) {
  7295. return this.flowParseInterfaceType();
  7296. }
  7297. return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
  7298. }
  7299. }
  7300. this.unexpected();
  7301. }
  7302. flowParsePostfixType() {
  7303. const startLoc = this.state.startLoc;
  7304. let type = this.flowParsePrimaryType();
  7305. let seenOptionalIndexedAccess = false;
  7306. while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) {
  7307. const node = this.startNodeAt(startLoc);
  7308. const optional = this.eat(18);
  7309. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  7310. this.expect(0);
  7311. if (!optional && this.match(3)) {
  7312. node.elementType = type;
  7313. this.next();
  7314. type = this.finishNode(node, "ArrayTypeAnnotation");
  7315. } else {
  7316. node.objectType = type;
  7317. node.indexType = this.flowParseType();
  7318. this.expect(3);
  7319. if (seenOptionalIndexedAccess) {
  7320. node.optional = optional;
  7321. type = this.finishNode(node, "OptionalIndexedAccessType");
  7322. } else {
  7323. type = this.finishNode(node, "IndexedAccessType");
  7324. }
  7325. }
  7326. }
  7327. return type;
  7328. }
  7329. flowParsePrefixType() {
  7330. const node = this.startNode();
  7331. if (this.eat(17)) {
  7332. node.typeAnnotation = this.flowParsePrefixType();
  7333. return this.finishNode(node, "NullableTypeAnnotation");
  7334. } else {
  7335. return this.flowParsePostfixType();
  7336. }
  7337. }
  7338. flowParseAnonFunctionWithoutParens() {
  7339. const param = this.flowParsePrefixType();
  7340. if (!this.state.noAnonFunctionType && this.eat(19)) {
  7341. const node = this.startNodeAt(param.loc.start);
  7342. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  7343. node.rest = null;
  7344. node.this = null;
  7345. node.returnType = this.flowParseType();
  7346. node.typeParameters = null;
  7347. return this.finishNode(node, "FunctionTypeAnnotation");
  7348. }
  7349. return param;
  7350. }
  7351. flowParseIntersectionType() {
  7352. const node = this.startNode();
  7353. this.eat(45);
  7354. const type = this.flowParseAnonFunctionWithoutParens();
  7355. node.types = [type];
  7356. while (this.eat(45)) {
  7357. node.types.push(this.flowParseAnonFunctionWithoutParens());
  7358. }
  7359. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  7360. }
  7361. flowParseUnionType() {
  7362. const node = this.startNode();
  7363. this.eat(43);
  7364. const type = this.flowParseIntersectionType();
  7365. node.types = [type];
  7366. while (this.eat(43)) {
  7367. node.types.push(this.flowParseIntersectionType());
  7368. }
  7369. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  7370. }
  7371. flowParseType() {
  7372. const oldInType = this.state.inType;
  7373. this.state.inType = true;
  7374. const type = this.flowParseUnionType();
  7375. this.state.inType = oldInType;
  7376. return type;
  7377. }
  7378. flowParseTypeOrImplicitInstantiation() {
  7379. if (this.state.type === 132 && this.state.value === "_") {
  7380. const startLoc = this.state.startLoc;
  7381. const node = this.parseIdentifier();
  7382. return this.flowParseGenericType(startLoc, node);
  7383. } else {
  7384. return this.flowParseType();
  7385. }
  7386. }
  7387. flowParseTypeAnnotation() {
  7388. const node = this.startNode();
  7389. node.typeAnnotation = this.flowParseTypeInitialiser();
  7390. return this.finishNode(node, "TypeAnnotation");
  7391. }
  7392. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  7393. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  7394. if (this.match(14)) {
  7395. ident.typeAnnotation = this.flowParseTypeAnnotation();
  7396. this.resetEndLocation(ident);
  7397. }
  7398. return ident;
  7399. }
  7400. typeCastToParameter(node) {
  7401. node.expression.typeAnnotation = node.typeAnnotation;
  7402. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  7403. return node.expression;
  7404. }
  7405. flowParseVariance() {
  7406. let variance = null;
  7407. if (this.match(53)) {
  7408. variance = this.startNode();
  7409. if (this.state.value === "+") {
  7410. variance.kind = "plus";
  7411. } else {
  7412. variance.kind = "minus";
  7413. }
  7414. this.next();
  7415. return this.finishNode(variance, "Variance");
  7416. }
  7417. return variance;
  7418. }
  7419. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  7420. if (allowExpressionBody) {
  7421. this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  7422. return;
  7423. }
  7424. super.parseFunctionBody(node, false, isMethod);
  7425. }
  7426. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  7427. if (this.match(14)) {
  7428. const typeNode = this.startNode();
  7429. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  7430. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  7431. }
  7432. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  7433. }
  7434. parseStatementLike(flags) {
  7435. if (this.state.strict && this.isContextual(129)) {
  7436. const lookahead = this.lookahead();
  7437. if (tokenIsKeywordOrIdentifier(lookahead.type)) {
  7438. const node = this.startNode();
  7439. this.next();
  7440. return this.flowParseInterface(node);
  7441. }
  7442. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7443. const node = this.startNode();
  7444. this.next();
  7445. return this.flowParseEnumDeclaration(node);
  7446. }
  7447. const stmt = super.parseStatementLike(flags);
  7448. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  7449. this.flowPragma = null;
  7450. }
  7451. return stmt;
  7452. }
  7453. parseExpressionStatement(node, expr, decorators) {
  7454. if (expr.type === "Identifier") {
  7455. if (expr.name === "declare") {
  7456. if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) {
  7457. return this.flowParseDeclare(node);
  7458. }
  7459. } else if (tokenIsIdentifier(this.state.type)) {
  7460. if (expr.name === "interface") {
  7461. return this.flowParseInterface(node);
  7462. } else if (expr.name === "type") {
  7463. return this.flowParseTypeAlias(node);
  7464. } else if (expr.name === "opaque") {
  7465. return this.flowParseOpaqueType(node, false);
  7466. }
  7467. }
  7468. }
  7469. return super.parseExpressionStatement(node, expr, decorators);
  7470. }
  7471. shouldParseExportDeclaration() {
  7472. const {
  7473. type
  7474. } = this.state;
  7475. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7476. return !this.state.containsEsc;
  7477. }
  7478. return super.shouldParseExportDeclaration();
  7479. }
  7480. isExportDefaultSpecifier() {
  7481. const {
  7482. type
  7483. } = this.state;
  7484. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7485. return this.state.containsEsc;
  7486. }
  7487. return super.isExportDefaultSpecifier();
  7488. }
  7489. parseExportDefaultExpression() {
  7490. if (this.shouldParseEnums() && this.isContextual(126)) {
  7491. const node = this.startNode();
  7492. this.next();
  7493. return this.flowParseEnumDeclaration(node);
  7494. }
  7495. return super.parseExportDefaultExpression();
  7496. }
  7497. parseConditional(expr, startLoc, refExpressionErrors) {
  7498. if (!this.match(17)) return expr;
  7499. if (this.state.maybeInArrowParameters) {
  7500. const nextCh = this.lookaheadCharCode();
  7501. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  7502. this.setOptionalParametersError(refExpressionErrors);
  7503. return expr;
  7504. }
  7505. }
  7506. this.expect(17);
  7507. const state = this.state.clone();
  7508. const originalNoArrowAt = this.state.noArrowAt;
  7509. const node = this.startNodeAt(startLoc);
  7510. let {
  7511. consequent,
  7512. failed
  7513. } = this.tryParseConditionalConsequent();
  7514. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7515. if (failed || invalid.length > 0) {
  7516. const noArrowAt = [...originalNoArrowAt];
  7517. if (invalid.length > 0) {
  7518. this.state = state;
  7519. this.state.noArrowAt = noArrowAt;
  7520. for (let i = 0; i < invalid.length; i++) {
  7521. noArrowAt.push(invalid[i].start);
  7522. }
  7523. ({
  7524. consequent,
  7525. failed
  7526. } = this.tryParseConditionalConsequent());
  7527. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7528. }
  7529. if (failed && valid.length > 1) {
  7530. this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
  7531. }
  7532. if (failed && valid.length === 1) {
  7533. this.state = state;
  7534. noArrowAt.push(valid[0].start);
  7535. this.state.noArrowAt = noArrowAt;
  7536. ({
  7537. consequent,
  7538. failed
  7539. } = this.tryParseConditionalConsequent());
  7540. }
  7541. }
  7542. this.getArrowLikeExpressions(consequent, true);
  7543. this.state.noArrowAt = originalNoArrowAt;
  7544. this.expect(14);
  7545. node.test = expr;
  7546. node.consequent = consequent;
  7547. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  7548. return this.finishNode(node, "ConditionalExpression");
  7549. }
  7550. tryParseConditionalConsequent() {
  7551. this.state.noArrowParamsConversionAt.push(this.state.start);
  7552. const consequent = this.parseMaybeAssignAllowIn();
  7553. const failed = !this.match(14);
  7554. this.state.noArrowParamsConversionAt.pop();
  7555. return {
  7556. consequent,
  7557. failed
  7558. };
  7559. }
  7560. getArrowLikeExpressions(node, disallowInvalid) {
  7561. const stack = [node];
  7562. const arrows = [];
  7563. while (stack.length !== 0) {
  7564. const node = stack.pop();
  7565. if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
  7566. if (node.typeParameters || !node.returnType) {
  7567. this.finishArrowValidation(node);
  7568. } else {
  7569. arrows.push(node);
  7570. }
  7571. stack.push(node.body);
  7572. } else if (node.type === "ConditionalExpression") {
  7573. stack.push(node.consequent);
  7574. stack.push(node.alternate);
  7575. }
  7576. }
  7577. if (disallowInvalid) {
  7578. arrows.forEach(node => this.finishArrowValidation(node));
  7579. return [arrows, []];
  7580. }
  7581. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  7582. }
  7583. finishArrowValidation(node) {
  7584. var _node$extra;
  7585. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
  7586. this.scope.enter(2 | 4);
  7587. super.checkParams(node, false, true);
  7588. this.scope.exit();
  7589. }
  7590. forwardNoArrowParamsConversionAt(node, parse) {
  7591. let result;
  7592. if (this.state.noArrowParamsConversionAt.includes(node.start)) {
  7593. this.state.noArrowParamsConversionAt.push(this.state.start);
  7594. result = parse();
  7595. this.state.noArrowParamsConversionAt.pop();
  7596. } else {
  7597. result = parse();
  7598. }
  7599. return result;
  7600. }
  7601. parseParenItem(node, startLoc) {
  7602. const newNode = super.parseParenItem(node, startLoc);
  7603. if (this.eat(17)) {
  7604. newNode.optional = true;
  7605. this.resetEndLocation(node);
  7606. }
  7607. if (this.match(14)) {
  7608. const typeCastNode = this.startNodeAt(startLoc);
  7609. typeCastNode.expression = newNode;
  7610. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  7611. return this.finishNode(typeCastNode, "TypeCastExpression");
  7612. }
  7613. return newNode;
  7614. }
  7615. assertModuleNodeAllowed(node) {
  7616. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  7617. return;
  7618. }
  7619. super.assertModuleNodeAllowed(node);
  7620. }
  7621. parseExportDeclaration(node) {
  7622. if (this.isContextual(130)) {
  7623. node.exportKind = "type";
  7624. const declarationNode = this.startNode();
  7625. this.next();
  7626. if (this.match(5)) {
  7627. node.specifiers = this.parseExportSpecifiers(true);
  7628. super.parseExportFrom(node);
  7629. return null;
  7630. } else {
  7631. return this.flowParseTypeAlias(declarationNode);
  7632. }
  7633. } else if (this.isContextual(131)) {
  7634. node.exportKind = "type";
  7635. const declarationNode = this.startNode();
  7636. this.next();
  7637. return this.flowParseOpaqueType(declarationNode, false);
  7638. } else if (this.isContextual(129)) {
  7639. node.exportKind = "type";
  7640. const declarationNode = this.startNode();
  7641. this.next();
  7642. return this.flowParseInterface(declarationNode);
  7643. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7644. node.exportKind = "value";
  7645. const declarationNode = this.startNode();
  7646. this.next();
  7647. return this.flowParseEnumDeclaration(declarationNode);
  7648. } else {
  7649. return super.parseExportDeclaration(node);
  7650. }
  7651. }
  7652. eatExportStar(node) {
  7653. if (super.eatExportStar(node)) return true;
  7654. if (this.isContextual(130) && this.lookahead().type === 55) {
  7655. node.exportKind = "type";
  7656. this.next();
  7657. this.next();
  7658. return true;
  7659. }
  7660. return false;
  7661. }
  7662. maybeParseExportNamespaceSpecifier(node) {
  7663. const {
  7664. startLoc
  7665. } = this.state;
  7666. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  7667. if (hasNamespace && node.exportKind === "type") {
  7668. this.unexpected(startLoc);
  7669. }
  7670. return hasNamespace;
  7671. }
  7672. parseClassId(node, isStatement, optionalId) {
  7673. super.parseClassId(node, isStatement, optionalId);
  7674. if (this.match(47)) {
  7675. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7676. }
  7677. }
  7678. parseClassMember(classBody, member, state) {
  7679. const {
  7680. startLoc
  7681. } = this.state;
  7682. if (this.isContextual(125)) {
  7683. if (super.parseClassMemberFromModifier(classBody, member)) {
  7684. return;
  7685. }
  7686. member.declare = true;
  7687. }
  7688. super.parseClassMember(classBody, member, state);
  7689. if (member.declare) {
  7690. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  7691. this.raise(FlowErrors.DeclareClassElement, startLoc);
  7692. } else if (member.value) {
  7693. this.raise(FlowErrors.DeclareClassFieldInitializer, member.value);
  7694. }
  7695. }
  7696. }
  7697. isIterator(word) {
  7698. return word === "iterator" || word === "asyncIterator";
  7699. }
  7700. readIterator() {
  7701. const word = super.readWord1();
  7702. const fullWord = "@@" + word;
  7703. if (!this.isIterator(word) || !this.state.inType) {
  7704. this.raise(Errors.InvalidIdentifier, this.state.curPosition(), {
  7705. identifierName: fullWord
  7706. });
  7707. }
  7708. this.finishToken(132, fullWord);
  7709. }
  7710. getTokenFromCode(code) {
  7711. const next = this.input.charCodeAt(this.state.pos + 1);
  7712. if (code === 123 && next === 124) {
  7713. this.finishOp(6, 2);
  7714. } else if (this.state.inType && (code === 62 || code === 60)) {
  7715. this.finishOp(code === 62 ? 48 : 47, 1);
  7716. } else if (this.state.inType && code === 63) {
  7717. if (next === 46) {
  7718. this.finishOp(18, 2);
  7719. } else {
  7720. this.finishOp(17, 1);
  7721. }
  7722. } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) {
  7723. this.state.pos += 2;
  7724. this.readIterator();
  7725. } else {
  7726. super.getTokenFromCode(code);
  7727. }
  7728. }
  7729. isAssignable(node, isBinding) {
  7730. if (node.type === "TypeCastExpression") {
  7731. return this.isAssignable(node.expression, isBinding);
  7732. } else {
  7733. return super.isAssignable(node, isBinding);
  7734. }
  7735. }
  7736. toAssignable(node, isLHS = false) {
  7737. if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
  7738. node.left = this.typeCastToParameter(node.left);
  7739. }
  7740. super.toAssignable(node, isLHS);
  7741. }
  7742. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  7743. for (let i = 0; i < exprList.length; i++) {
  7744. const expr = exprList[i];
  7745. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  7746. exprList[i] = this.typeCastToParameter(expr);
  7747. }
  7748. }
  7749. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  7750. }
  7751. toReferencedList(exprList, isParenthesizedExpr) {
  7752. for (let i = 0; i < exprList.length; i++) {
  7753. var _expr$extra;
  7754. const expr = exprList[i];
  7755. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  7756. this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation);
  7757. }
  7758. }
  7759. return exprList;
  7760. }
  7761. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  7762. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  7763. if (canBePattern && !this.state.maybeInArrowParameters) {
  7764. this.toReferencedList(node.elements);
  7765. }
  7766. return node;
  7767. }
  7768. isValidLVal(type, isParenthesized, binding) {
  7769. return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding);
  7770. }
  7771. parseClassProperty(node) {
  7772. if (this.match(14)) {
  7773. node.typeAnnotation = this.flowParseTypeAnnotation();
  7774. }
  7775. return super.parseClassProperty(node);
  7776. }
  7777. parseClassPrivateProperty(node) {
  7778. if (this.match(14)) {
  7779. node.typeAnnotation = this.flowParseTypeAnnotation();
  7780. }
  7781. return super.parseClassPrivateProperty(node);
  7782. }
  7783. isClassMethod() {
  7784. return this.match(47) || super.isClassMethod();
  7785. }
  7786. isClassProperty() {
  7787. return this.match(14) || super.isClassProperty();
  7788. }
  7789. isNonstaticConstructor(method) {
  7790. return !this.match(14) && super.isNonstaticConstructor(method);
  7791. }
  7792. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  7793. if (method.variance) {
  7794. this.unexpected(method.variance.loc.start);
  7795. }
  7796. delete method.variance;
  7797. if (this.match(47)) {
  7798. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7799. }
  7800. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  7801. if (method.params && isConstructor) {
  7802. const params = method.params;
  7803. if (params.length > 0 && this.isThisParam(params[0])) {
  7804. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7805. }
  7806. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  7807. const params = method.value.params;
  7808. if (params.length > 0 && this.isThisParam(params[0])) {
  7809. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7810. }
  7811. }
  7812. }
  7813. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  7814. if (method.variance) {
  7815. this.unexpected(method.variance.loc.start);
  7816. }
  7817. delete method.variance;
  7818. if (this.match(47)) {
  7819. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7820. }
  7821. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  7822. }
  7823. parseClassSuper(node) {
  7824. super.parseClassSuper(node);
  7825. if (node.superClass && this.match(47)) {
  7826. node.superTypeParameters = this.flowParseTypeParameterInstantiation();
  7827. }
  7828. if (this.isContextual(113)) {
  7829. this.next();
  7830. const implemented = node.implements = [];
  7831. do {
  7832. const node = this.startNode();
  7833. node.id = this.flowParseRestrictedIdentifier(true);
  7834. if (this.match(47)) {
  7835. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7836. } else {
  7837. node.typeParameters = null;
  7838. }
  7839. implemented.push(this.finishNode(node, "ClassImplements"));
  7840. } while (this.eat(12));
  7841. }
  7842. }
  7843. checkGetterSetterParams(method) {
  7844. super.checkGetterSetterParams(method);
  7845. const params = this.getObjectOrClassMethodParams(method);
  7846. if (params.length > 0) {
  7847. const param = params[0];
  7848. if (this.isThisParam(param) && method.kind === "get") {
  7849. this.raise(FlowErrors.GetterMayNotHaveThisParam, param);
  7850. } else if (this.isThisParam(param)) {
  7851. this.raise(FlowErrors.SetterMayNotHaveThisParam, param);
  7852. }
  7853. }
  7854. }
  7855. parsePropertyNamePrefixOperator(node) {
  7856. node.variance = this.flowParseVariance();
  7857. }
  7858. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  7859. if (prop.variance) {
  7860. this.unexpected(prop.variance.loc.start);
  7861. }
  7862. delete prop.variance;
  7863. let typeParameters;
  7864. if (this.match(47) && !isAccessor) {
  7865. typeParameters = this.flowParseTypeParameterDeclaration();
  7866. if (!this.match(10)) this.unexpected();
  7867. }
  7868. const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  7869. if (typeParameters) {
  7870. (result.value || result).typeParameters = typeParameters;
  7871. }
  7872. return result;
  7873. }
  7874. parseAssignableListItemTypes(param) {
  7875. if (this.eat(17)) {
  7876. if (param.type !== "Identifier") {
  7877. this.raise(FlowErrors.PatternIsOptional, param);
  7878. }
  7879. if (this.isThisParam(param)) {
  7880. this.raise(FlowErrors.ThisParamMayNotBeOptional, param);
  7881. }
  7882. param.optional = true;
  7883. }
  7884. if (this.match(14)) {
  7885. param.typeAnnotation = this.flowParseTypeAnnotation();
  7886. } else if (this.isThisParam(param)) {
  7887. this.raise(FlowErrors.ThisParamAnnotationRequired, param);
  7888. }
  7889. if (this.match(29) && this.isThisParam(param)) {
  7890. this.raise(FlowErrors.ThisParamNoDefault, param);
  7891. }
  7892. this.resetEndLocation(param);
  7893. return param;
  7894. }
  7895. parseMaybeDefault(startLoc, left) {
  7896. const node = super.parseMaybeDefault(startLoc, left);
  7897. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  7898. this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation);
  7899. }
  7900. return node;
  7901. }
  7902. checkImportReflection(node) {
  7903. super.checkImportReflection(node);
  7904. if (node.module && node.importKind !== "value") {
  7905. this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  7906. }
  7907. }
  7908. parseImportSpecifierLocal(node, specifier, type) {
  7909. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  7910. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  7911. }
  7912. isPotentialImportPhase(isExport) {
  7913. if (super.isPotentialImportPhase(isExport)) return true;
  7914. if (this.isContextual(130)) {
  7915. if (!isExport) return true;
  7916. const ch = this.lookaheadCharCode();
  7917. return ch === 123 || ch === 42;
  7918. }
  7919. return !isExport && this.isContextual(87);
  7920. }
  7921. applyImportPhase(node, isExport, phase, loc) {
  7922. super.applyImportPhase(node, isExport, phase, loc);
  7923. if (isExport) {
  7924. if (!phase && this.match(65)) {
  7925. return;
  7926. }
  7927. node.exportKind = phase === "type" ? phase : "value";
  7928. } else {
  7929. if (phase === "type" && this.match(55)) this.unexpected();
  7930. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  7931. }
  7932. }
  7933. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  7934. const firstIdent = specifier.imported;
  7935. let specifierTypeKind = null;
  7936. if (firstIdent.type === "Identifier") {
  7937. if (firstIdent.name === "type") {
  7938. specifierTypeKind = "type";
  7939. } else if (firstIdent.name === "typeof") {
  7940. specifierTypeKind = "typeof";
  7941. }
  7942. }
  7943. let isBinding = false;
  7944. if (this.isContextual(93) && !this.isLookaheadContextual("as")) {
  7945. const as_ident = this.parseIdentifier(true);
  7946. if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
  7947. specifier.imported = as_ident;
  7948. specifier.importKind = specifierTypeKind;
  7949. specifier.local = cloneIdentifier(as_ident);
  7950. } else {
  7951. specifier.imported = firstIdent;
  7952. specifier.importKind = null;
  7953. specifier.local = this.parseIdentifier();
  7954. }
  7955. } else {
  7956. if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) {
  7957. specifier.imported = this.parseIdentifier(true);
  7958. specifier.importKind = specifierTypeKind;
  7959. } else {
  7960. if (importedIsString) {
  7961. throw this.raise(Errors.ImportBindingIsString, specifier, {
  7962. importName: firstIdent.value
  7963. });
  7964. }
  7965. specifier.imported = firstIdent;
  7966. specifier.importKind = null;
  7967. }
  7968. if (this.eatContextual(93)) {
  7969. specifier.local = this.parseIdentifier();
  7970. } else {
  7971. isBinding = true;
  7972. specifier.local = cloneIdentifier(specifier.imported);
  7973. }
  7974. }
  7975. const specifierIsTypeImport = hasTypeImportKind(specifier);
  7976. if (isInTypeOnlyImport && specifierIsTypeImport) {
  7977. this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
  7978. }
  7979. if (isInTypeOnlyImport || specifierIsTypeImport) {
  7980. this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
  7981. }
  7982. if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
  7983. this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
  7984. }
  7985. return this.finishImportSpecifier(specifier, "ImportSpecifier");
  7986. }
  7987. parseBindingAtom() {
  7988. switch (this.state.type) {
  7989. case 78:
  7990. return this.parseIdentifier(true);
  7991. default:
  7992. return super.parseBindingAtom();
  7993. }
  7994. }
  7995. parseFunctionParams(node, isConstructor) {
  7996. const kind = node.kind;
  7997. if (kind !== "get" && kind !== "set" && this.match(47)) {
  7998. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7999. }
  8000. super.parseFunctionParams(node, isConstructor);
  8001. }
  8002. parseVarId(decl, kind) {
  8003. super.parseVarId(decl, kind);
  8004. if (this.match(14)) {
  8005. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  8006. this.resetEndLocation(decl.id);
  8007. }
  8008. }
  8009. parseAsyncArrowFromCallExpression(node, call) {
  8010. if (this.match(14)) {
  8011. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8012. this.state.noAnonFunctionType = true;
  8013. node.returnType = this.flowParseTypeAnnotation();
  8014. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8015. }
  8016. return super.parseAsyncArrowFromCallExpression(node, call);
  8017. }
  8018. shouldParseAsyncArrow() {
  8019. return this.match(14) || super.shouldParseAsyncArrow();
  8020. }
  8021. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  8022. var _jsx;
  8023. let state = null;
  8024. let jsx;
  8025. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  8026. state = this.state.clone();
  8027. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  8028. if (!jsx.error) return jsx.node;
  8029. const {
  8030. context
  8031. } = this.state;
  8032. const currentContext = context[context.length - 1];
  8033. if (currentContext === types.j_oTag || currentContext === types.j_expr) {
  8034. context.pop();
  8035. }
  8036. }
  8037. if ((_jsx = jsx) != null && _jsx.error || this.match(47)) {
  8038. var _jsx2, _jsx3;
  8039. state = state || this.state.clone();
  8040. let typeParameters;
  8041. const arrow = this.tryParse(abort => {
  8042. var _arrowExpression$extr;
  8043. typeParameters = this.flowParseTypeParameterDeclaration();
  8044. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  8045. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  8046. this.resetStartLocationFromNode(result, typeParameters);
  8047. return result;
  8048. });
  8049. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  8050. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  8051. if (expr.type !== "ArrowFunctionExpression") abort();
  8052. expr.typeParameters = typeParameters;
  8053. this.resetStartLocationFromNode(expr, typeParameters);
  8054. return arrowExpression;
  8055. }, state);
  8056. let arrowExpression = null;
  8057. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  8058. if (!arrow.error && !arrow.aborted) {
  8059. if (arrow.node.async) {
  8060. this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters);
  8061. }
  8062. return arrow.node;
  8063. }
  8064. arrowExpression = arrow.node;
  8065. }
  8066. if ((_jsx2 = jsx) != null && _jsx2.node) {
  8067. this.state = jsx.failState;
  8068. return jsx.node;
  8069. }
  8070. if (arrowExpression) {
  8071. this.state = arrow.failState;
  8072. return arrowExpression;
  8073. }
  8074. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  8075. if (arrow.thrown) throw arrow.error;
  8076. throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters);
  8077. }
  8078. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  8079. }
  8080. parseArrow(node) {
  8081. if (this.match(14)) {
  8082. const result = this.tryParse(() => {
  8083. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8084. this.state.noAnonFunctionType = true;
  8085. const typeNode = this.startNode();
  8086. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  8087. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8088. if (this.canInsertSemicolon()) this.unexpected();
  8089. if (!this.match(19)) this.unexpected();
  8090. return typeNode;
  8091. });
  8092. if (result.thrown) return null;
  8093. if (result.error) this.state = result.failState;
  8094. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  8095. }
  8096. return super.parseArrow(node);
  8097. }
  8098. shouldParseArrow(params) {
  8099. return this.match(14) || super.shouldParseArrow(params);
  8100. }
  8101. setArrowFunctionParameters(node, params) {
  8102. if (this.state.noArrowParamsConversionAt.includes(node.start)) {
  8103. node.params = params;
  8104. } else {
  8105. super.setArrowFunctionParameters(node, params);
  8106. }
  8107. }
  8108. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  8109. if (isArrowFunction && this.state.noArrowParamsConversionAt.includes(node.start)) {
  8110. return;
  8111. }
  8112. for (let i = 0; i < node.params.length; i++) {
  8113. if (this.isThisParam(node.params[i]) && i > 0) {
  8114. this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
  8115. }
  8116. }
  8117. super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
  8118. }
  8119. parseParenAndDistinguishExpression(canBeArrow) {
  8120. return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.state.start));
  8121. }
  8122. parseSubscripts(base, startLoc, noCalls) {
  8123. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.includes(startLoc.index)) {
  8124. this.next();
  8125. const node = this.startNodeAt(startLoc);
  8126. node.callee = base;
  8127. node.arguments = super.parseCallExpressionArguments(11, false);
  8128. base = this.finishNode(node, "CallExpression");
  8129. } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
  8130. const state = this.state.clone();
  8131. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
  8132. if (!arrow.error && !arrow.aborted) return arrow.node;
  8133. const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state);
  8134. if (result.node && !result.error) return result.node;
  8135. if (arrow.node) {
  8136. this.state = arrow.failState;
  8137. return arrow.node;
  8138. }
  8139. if (result.node) {
  8140. this.state = result.failState;
  8141. return result.node;
  8142. }
  8143. throw arrow.error || result.error;
  8144. }
  8145. return super.parseSubscripts(base, startLoc, noCalls);
  8146. }
  8147. parseSubscript(base, startLoc, noCalls, subscriptState) {
  8148. if (this.match(18) && this.isLookaheadToken_lt()) {
  8149. subscriptState.optionalChainMember = true;
  8150. if (noCalls) {
  8151. subscriptState.stop = true;
  8152. return base;
  8153. }
  8154. this.next();
  8155. const node = this.startNodeAt(startLoc);
  8156. node.callee = base;
  8157. node.typeArguments = this.flowParseTypeParameterInstantiation();
  8158. this.expect(10);
  8159. node.arguments = this.parseCallExpressionArguments(11, false);
  8160. node.optional = true;
  8161. return this.finishCallExpression(node, true);
  8162. } else if (!noCalls && this.shouldParseTypes() && this.match(47)) {
  8163. const node = this.startNodeAt(startLoc);
  8164. node.callee = base;
  8165. const result = this.tryParse(() => {
  8166. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  8167. this.expect(10);
  8168. node.arguments = super.parseCallExpressionArguments(11, false);
  8169. if (subscriptState.optionalChainMember) {
  8170. node.optional = false;
  8171. }
  8172. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  8173. });
  8174. if (result.node) {
  8175. if (result.error) this.state = result.failState;
  8176. return result.node;
  8177. }
  8178. }
  8179. return super.parseSubscript(base, startLoc, noCalls, subscriptState);
  8180. }
  8181. parseNewCallee(node) {
  8182. super.parseNewCallee(node);
  8183. let targs = null;
  8184. if (this.shouldParseTypes() && this.match(47)) {
  8185. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  8186. }
  8187. node.typeArguments = targs;
  8188. }
  8189. parseAsyncArrowWithTypeParameters(startLoc) {
  8190. const node = this.startNodeAt(startLoc);
  8191. this.parseFunctionParams(node, false);
  8192. if (!this.parseArrow(node)) return;
  8193. return super.parseArrowExpression(node, undefined, true);
  8194. }
  8195. readToken_mult_modulo(code) {
  8196. const next = this.input.charCodeAt(this.state.pos + 1);
  8197. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  8198. this.state.hasFlowComment = false;
  8199. this.state.pos += 2;
  8200. this.nextToken();
  8201. return;
  8202. }
  8203. super.readToken_mult_modulo(code);
  8204. }
  8205. readToken_pipe_amp(code) {
  8206. const next = this.input.charCodeAt(this.state.pos + 1);
  8207. if (code === 124 && next === 125) {
  8208. this.finishOp(9, 2);
  8209. return;
  8210. }
  8211. super.readToken_pipe_amp(code);
  8212. }
  8213. parseTopLevel(file, program) {
  8214. const fileNode = super.parseTopLevel(file, program);
  8215. if (this.state.hasFlowComment) {
  8216. this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition());
  8217. }
  8218. return fileNode;
  8219. }
  8220. skipBlockComment() {
  8221. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  8222. if (this.state.hasFlowComment) {
  8223. throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc);
  8224. }
  8225. this.hasFlowCommentCompletion();
  8226. const commentSkip = this.skipFlowComment();
  8227. if (commentSkip) {
  8228. this.state.pos += commentSkip;
  8229. this.state.hasFlowComment = true;
  8230. }
  8231. return;
  8232. }
  8233. return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/");
  8234. }
  8235. skipFlowComment() {
  8236. const {
  8237. pos
  8238. } = this.state;
  8239. let shiftToFirstNonWhiteSpace = 2;
  8240. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  8241. shiftToFirstNonWhiteSpace++;
  8242. }
  8243. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  8244. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  8245. if (ch2 === 58 && ch3 === 58) {
  8246. return shiftToFirstNonWhiteSpace + 2;
  8247. }
  8248. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  8249. return shiftToFirstNonWhiteSpace + 12;
  8250. }
  8251. if (ch2 === 58 && ch3 !== 58) {
  8252. return shiftToFirstNonWhiteSpace;
  8253. }
  8254. return false;
  8255. }
  8256. hasFlowCommentCompletion() {
  8257. const end = this.input.indexOf("*/", this.state.pos);
  8258. if (end === -1) {
  8259. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  8260. }
  8261. }
  8262. flowEnumErrorBooleanMemberNotInitialized(loc, {
  8263. enumName,
  8264. memberName
  8265. }) {
  8266. this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, {
  8267. memberName,
  8268. enumName
  8269. });
  8270. }
  8271. flowEnumErrorInvalidMemberInitializer(loc, enumContext) {
  8272. return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext);
  8273. }
  8274. flowEnumErrorNumberMemberNotInitialized(loc, details) {
  8275. this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details);
  8276. }
  8277. flowEnumErrorStringMemberInconsistentlyInitialized(node, details) {
  8278. this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details);
  8279. }
  8280. flowEnumMemberInit() {
  8281. const startLoc = this.state.startLoc;
  8282. const endOfInit = () => this.match(12) || this.match(8);
  8283. switch (this.state.type) {
  8284. case 134:
  8285. {
  8286. const literal = this.parseNumericLiteral(this.state.value);
  8287. if (endOfInit()) {
  8288. return {
  8289. type: "number",
  8290. loc: literal.loc.start,
  8291. value: literal
  8292. };
  8293. }
  8294. return {
  8295. type: "invalid",
  8296. loc: startLoc
  8297. };
  8298. }
  8299. case 133:
  8300. {
  8301. const literal = this.parseStringLiteral(this.state.value);
  8302. if (endOfInit()) {
  8303. return {
  8304. type: "string",
  8305. loc: literal.loc.start,
  8306. value: literal
  8307. };
  8308. }
  8309. return {
  8310. type: "invalid",
  8311. loc: startLoc
  8312. };
  8313. }
  8314. case 85:
  8315. case 86:
  8316. {
  8317. const literal = this.parseBooleanLiteral(this.match(85));
  8318. if (endOfInit()) {
  8319. return {
  8320. type: "boolean",
  8321. loc: literal.loc.start,
  8322. value: literal
  8323. };
  8324. }
  8325. return {
  8326. type: "invalid",
  8327. loc: startLoc
  8328. };
  8329. }
  8330. default:
  8331. return {
  8332. type: "invalid",
  8333. loc: startLoc
  8334. };
  8335. }
  8336. }
  8337. flowEnumMemberRaw() {
  8338. const loc = this.state.startLoc;
  8339. const id = this.parseIdentifier(true);
  8340. const init = this.eat(29) ? this.flowEnumMemberInit() : {
  8341. type: "none",
  8342. loc
  8343. };
  8344. return {
  8345. id,
  8346. init
  8347. };
  8348. }
  8349. flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
  8350. const {
  8351. explicitType
  8352. } = context;
  8353. if (explicitType === null) {
  8354. return;
  8355. }
  8356. if (explicitType !== expectedType) {
  8357. this.flowEnumErrorInvalidMemberInitializer(loc, context);
  8358. }
  8359. }
  8360. flowEnumMembers({
  8361. enumName,
  8362. explicitType
  8363. }) {
  8364. const seenNames = new Set();
  8365. const members = {
  8366. booleanMembers: [],
  8367. numberMembers: [],
  8368. stringMembers: [],
  8369. defaultedMembers: []
  8370. };
  8371. let hasUnknownMembers = false;
  8372. while (!this.match(8)) {
  8373. if (this.eat(21)) {
  8374. hasUnknownMembers = true;
  8375. break;
  8376. }
  8377. const memberNode = this.startNode();
  8378. const {
  8379. id,
  8380. init
  8381. } = this.flowEnumMemberRaw();
  8382. const memberName = id.name;
  8383. if (memberName === "") {
  8384. continue;
  8385. }
  8386. if (/^[a-z]/.test(memberName)) {
  8387. this.raise(FlowErrors.EnumInvalidMemberName, id, {
  8388. memberName,
  8389. suggestion: memberName[0].toUpperCase() + memberName.slice(1),
  8390. enumName
  8391. });
  8392. }
  8393. if (seenNames.has(memberName)) {
  8394. this.raise(FlowErrors.EnumDuplicateMemberName, id, {
  8395. memberName,
  8396. enumName
  8397. });
  8398. }
  8399. seenNames.add(memberName);
  8400. const context = {
  8401. enumName,
  8402. explicitType,
  8403. memberName
  8404. };
  8405. memberNode.id = id;
  8406. switch (init.type) {
  8407. case "boolean":
  8408. {
  8409. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
  8410. memberNode.init = init.value;
  8411. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  8412. break;
  8413. }
  8414. case "number":
  8415. {
  8416. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
  8417. memberNode.init = init.value;
  8418. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  8419. break;
  8420. }
  8421. case "string":
  8422. {
  8423. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
  8424. memberNode.init = init.value;
  8425. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  8426. break;
  8427. }
  8428. case "invalid":
  8429. {
  8430. throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
  8431. }
  8432. case "none":
  8433. {
  8434. switch (explicitType) {
  8435. case "boolean":
  8436. this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
  8437. break;
  8438. case "number":
  8439. this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
  8440. break;
  8441. default:
  8442. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  8443. }
  8444. }
  8445. }
  8446. if (!this.match(8)) {
  8447. this.expect(12);
  8448. }
  8449. }
  8450. return {
  8451. members,
  8452. hasUnknownMembers
  8453. };
  8454. }
  8455. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  8456. enumName
  8457. }) {
  8458. if (initializedMembers.length === 0) {
  8459. return defaultedMembers;
  8460. } else if (defaultedMembers.length === 0) {
  8461. return initializedMembers;
  8462. } else if (defaultedMembers.length > initializedMembers.length) {
  8463. for (const member of initializedMembers) {
  8464. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8465. enumName
  8466. });
  8467. }
  8468. return defaultedMembers;
  8469. } else {
  8470. for (const member of defaultedMembers) {
  8471. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8472. enumName
  8473. });
  8474. }
  8475. return initializedMembers;
  8476. }
  8477. }
  8478. flowEnumParseExplicitType({
  8479. enumName
  8480. }) {
  8481. if (!this.eatContextual(102)) return null;
  8482. if (!tokenIsIdentifier(this.state.type)) {
  8483. throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, {
  8484. enumName
  8485. });
  8486. }
  8487. const {
  8488. value
  8489. } = this.state;
  8490. this.next();
  8491. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  8492. this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, {
  8493. enumName,
  8494. invalidEnumType: value
  8495. });
  8496. }
  8497. return value;
  8498. }
  8499. flowEnumBody(node, id) {
  8500. const enumName = id.name;
  8501. const nameLoc = id.loc.start;
  8502. const explicitType = this.flowEnumParseExplicitType({
  8503. enumName
  8504. });
  8505. this.expect(5);
  8506. const {
  8507. members,
  8508. hasUnknownMembers
  8509. } = this.flowEnumMembers({
  8510. enumName,
  8511. explicitType
  8512. });
  8513. node.hasUnknownMembers = hasUnknownMembers;
  8514. switch (explicitType) {
  8515. case "boolean":
  8516. node.explicitType = true;
  8517. node.members = members.booleanMembers;
  8518. this.expect(8);
  8519. return this.finishNode(node, "EnumBooleanBody");
  8520. case "number":
  8521. node.explicitType = true;
  8522. node.members = members.numberMembers;
  8523. this.expect(8);
  8524. return this.finishNode(node, "EnumNumberBody");
  8525. case "string":
  8526. node.explicitType = true;
  8527. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8528. enumName
  8529. });
  8530. this.expect(8);
  8531. return this.finishNode(node, "EnumStringBody");
  8532. case "symbol":
  8533. node.members = members.defaultedMembers;
  8534. this.expect(8);
  8535. return this.finishNode(node, "EnumSymbolBody");
  8536. default:
  8537. {
  8538. const empty = () => {
  8539. node.members = [];
  8540. this.expect(8);
  8541. return this.finishNode(node, "EnumStringBody");
  8542. };
  8543. node.explicitType = false;
  8544. const boolsLen = members.booleanMembers.length;
  8545. const numsLen = members.numberMembers.length;
  8546. const strsLen = members.stringMembers.length;
  8547. const defaultedLen = members.defaultedMembers.length;
  8548. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  8549. return empty();
  8550. } else if (!boolsLen && !numsLen) {
  8551. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8552. enumName
  8553. });
  8554. this.expect(8);
  8555. return this.finishNode(node, "EnumStringBody");
  8556. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  8557. for (const member of members.defaultedMembers) {
  8558. this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
  8559. enumName,
  8560. memberName: member.id.name
  8561. });
  8562. }
  8563. node.members = members.booleanMembers;
  8564. this.expect(8);
  8565. return this.finishNode(node, "EnumBooleanBody");
  8566. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  8567. for (const member of members.defaultedMembers) {
  8568. this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, {
  8569. enumName,
  8570. memberName: member.id.name
  8571. });
  8572. }
  8573. node.members = members.numberMembers;
  8574. this.expect(8);
  8575. return this.finishNode(node, "EnumNumberBody");
  8576. } else {
  8577. this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, {
  8578. enumName
  8579. });
  8580. return empty();
  8581. }
  8582. }
  8583. }
  8584. }
  8585. flowParseEnumDeclaration(node) {
  8586. const id = this.parseIdentifier();
  8587. node.id = id;
  8588. node.body = this.flowEnumBody(this.startNode(), id);
  8589. return this.finishNode(node, "EnumDeclaration");
  8590. }
  8591. isLookaheadToken_lt() {
  8592. const next = this.nextTokenStart();
  8593. if (this.input.charCodeAt(next) === 60) {
  8594. const afterNext = this.input.charCodeAt(next + 1);
  8595. return afterNext !== 60 && afterNext !== 61;
  8596. }
  8597. return false;
  8598. }
  8599. maybeUnwrapTypeCastExpression(node) {
  8600. return node.type === "TypeCastExpression" ? node.expression : node;
  8601. }
  8602. };
  8603. const entities = {
  8604. __proto__: null,
  8605. quot: "\u0022",
  8606. amp: "&",
  8607. apos: "\u0027",
  8608. lt: "<",
  8609. gt: ">",
  8610. nbsp: "\u00A0",
  8611. iexcl: "\u00A1",
  8612. cent: "\u00A2",
  8613. pound: "\u00A3",
  8614. curren: "\u00A4",
  8615. yen: "\u00A5",
  8616. brvbar: "\u00A6",
  8617. sect: "\u00A7",
  8618. uml: "\u00A8",
  8619. copy: "\u00A9",
  8620. ordf: "\u00AA",
  8621. laquo: "\u00AB",
  8622. not: "\u00AC",
  8623. shy: "\u00AD",
  8624. reg: "\u00AE",
  8625. macr: "\u00AF",
  8626. deg: "\u00B0",
  8627. plusmn: "\u00B1",
  8628. sup2: "\u00B2",
  8629. sup3: "\u00B3",
  8630. acute: "\u00B4",
  8631. micro: "\u00B5",
  8632. para: "\u00B6",
  8633. middot: "\u00B7",
  8634. cedil: "\u00B8",
  8635. sup1: "\u00B9",
  8636. ordm: "\u00BA",
  8637. raquo: "\u00BB",
  8638. frac14: "\u00BC",
  8639. frac12: "\u00BD",
  8640. frac34: "\u00BE",
  8641. iquest: "\u00BF",
  8642. Agrave: "\u00C0",
  8643. Aacute: "\u00C1",
  8644. Acirc: "\u00C2",
  8645. Atilde: "\u00C3",
  8646. Auml: "\u00C4",
  8647. Aring: "\u00C5",
  8648. AElig: "\u00C6",
  8649. Ccedil: "\u00C7",
  8650. Egrave: "\u00C8",
  8651. Eacute: "\u00C9",
  8652. Ecirc: "\u00CA",
  8653. Euml: "\u00CB",
  8654. Igrave: "\u00CC",
  8655. Iacute: "\u00CD",
  8656. Icirc: "\u00CE",
  8657. Iuml: "\u00CF",
  8658. ETH: "\u00D0",
  8659. Ntilde: "\u00D1",
  8660. Ograve: "\u00D2",
  8661. Oacute: "\u00D3",
  8662. Ocirc: "\u00D4",
  8663. Otilde: "\u00D5",
  8664. Ouml: "\u00D6",
  8665. times: "\u00D7",
  8666. Oslash: "\u00D8",
  8667. Ugrave: "\u00D9",
  8668. Uacute: "\u00DA",
  8669. Ucirc: "\u00DB",
  8670. Uuml: "\u00DC",
  8671. Yacute: "\u00DD",
  8672. THORN: "\u00DE",
  8673. szlig: "\u00DF",
  8674. agrave: "\u00E0",
  8675. aacute: "\u00E1",
  8676. acirc: "\u00E2",
  8677. atilde: "\u00E3",
  8678. auml: "\u00E4",
  8679. aring: "\u00E5",
  8680. aelig: "\u00E6",
  8681. ccedil: "\u00E7",
  8682. egrave: "\u00E8",
  8683. eacute: "\u00E9",
  8684. ecirc: "\u00EA",
  8685. euml: "\u00EB",
  8686. igrave: "\u00EC",
  8687. iacute: "\u00ED",
  8688. icirc: "\u00EE",
  8689. iuml: "\u00EF",
  8690. eth: "\u00F0",
  8691. ntilde: "\u00F1",
  8692. ograve: "\u00F2",
  8693. oacute: "\u00F3",
  8694. ocirc: "\u00F4",
  8695. otilde: "\u00F5",
  8696. ouml: "\u00F6",
  8697. divide: "\u00F7",
  8698. oslash: "\u00F8",
  8699. ugrave: "\u00F9",
  8700. uacute: "\u00FA",
  8701. ucirc: "\u00FB",
  8702. uuml: "\u00FC",
  8703. yacute: "\u00FD",
  8704. thorn: "\u00FE",
  8705. yuml: "\u00FF",
  8706. OElig: "\u0152",
  8707. oelig: "\u0153",
  8708. Scaron: "\u0160",
  8709. scaron: "\u0161",
  8710. Yuml: "\u0178",
  8711. fnof: "\u0192",
  8712. circ: "\u02C6",
  8713. tilde: "\u02DC",
  8714. Alpha: "\u0391",
  8715. Beta: "\u0392",
  8716. Gamma: "\u0393",
  8717. Delta: "\u0394",
  8718. Epsilon: "\u0395",
  8719. Zeta: "\u0396",
  8720. Eta: "\u0397",
  8721. Theta: "\u0398",
  8722. Iota: "\u0399",
  8723. Kappa: "\u039A",
  8724. Lambda: "\u039B",
  8725. Mu: "\u039C",
  8726. Nu: "\u039D",
  8727. Xi: "\u039E",
  8728. Omicron: "\u039F",
  8729. Pi: "\u03A0",
  8730. Rho: "\u03A1",
  8731. Sigma: "\u03A3",
  8732. Tau: "\u03A4",
  8733. Upsilon: "\u03A5",
  8734. Phi: "\u03A6",
  8735. Chi: "\u03A7",
  8736. Psi: "\u03A8",
  8737. Omega: "\u03A9",
  8738. alpha: "\u03B1",
  8739. beta: "\u03B2",
  8740. gamma: "\u03B3",
  8741. delta: "\u03B4",
  8742. epsilon: "\u03B5",
  8743. zeta: "\u03B6",
  8744. eta: "\u03B7",
  8745. theta: "\u03B8",
  8746. iota: "\u03B9",
  8747. kappa: "\u03BA",
  8748. lambda: "\u03BB",
  8749. mu: "\u03BC",
  8750. nu: "\u03BD",
  8751. xi: "\u03BE",
  8752. omicron: "\u03BF",
  8753. pi: "\u03C0",
  8754. rho: "\u03C1",
  8755. sigmaf: "\u03C2",
  8756. sigma: "\u03C3",
  8757. tau: "\u03C4",
  8758. upsilon: "\u03C5",
  8759. phi: "\u03C6",
  8760. chi: "\u03C7",
  8761. psi: "\u03C8",
  8762. omega: "\u03C9",
  8763. thetasym: "\u03D1",
  8764. upsih: "\u03D2",
  8765. piv: "\u03D6",
  8766. ensp: "\u2002",
  8767. emsp: "\u2003",
  8768. thinsp: "\u2009",
  8769. zwnj: "\u200C",
  8770. zwj: "\u200D",
  8771. lrm: "\u200E",
  8772. rlm: "\u200F",
  8773. ndash: "\u2013",
  8774. mdash: "\u2014",
  8775. lsquo: "\u2018",
  8776. rsquo: "\u2019",
  8777. sbquo: "\u201A",
  8778. ldquo: "\u201C",
  8779. rdquo: "\u201D",
  8780. bdquo: "\u201E",
  8781. dagger: "\u2020",
  8782. Dagger: "\u2021",
  8783. bull: "\u2022",
  8784. hellip: "\u2026",
  8785. permil: "\u2030",
  8786. prime: "\u2032",
  8787. Prime: "\u2033",
  8788. lsaquo: "\u2039",
  8789. rsaquo: "\u203A",
  8790. oline: "\u203E",
  8791. frasl: "\u2044",
  8792. euro: "\u20AC",
  8793. image: "\u2111",
  8794. weierp: "\u2118",
  8795. real: "\u211C",
  8796. trade: "\u2122",
  8797. alefsym: "\u2135",
  8798. larr: "\u2190",
  8799. uarr: "\u2191",
  8800. rarr: "\u2192",
  8801. darr: "\u2193",
  8802. harr: "\u2194",
  8803. crarr: "\u21B5",
  8804. lArr: "\u21D0",
  8805. uArr: "\u21D1",
  8806. rArr: "\u21D2",
  8807. dArr: "\u21D3",
  8808. hArr: "\u21D4",
  8809. forall: "\u2200",
  8810. part: "\u2202",
  8811. exist: "\u2203",
  8812. empty: "\u2205",
  8813. nabla: "\u2207",
  8814. isin: "\u2208",
  8815. notin: "\u2209",
  8816. ni: "\u220B",
  8817. prod: "\u220F",
  8818. sum: "\u2211",
  8819. minus: "\u2212",
  8820. lowast: "\u2217",
  8821. radic: "\u221A",
  8822. prop: "\u221D",
  8823. infin: "\u221E",
  8824. ang: "\u2220",
  8825. and: "\u2227",
  8826. or: "\u2228",
  8827. cap: "\u2229",
  8828. cup: "\u222A",
  8829. int: "\u222B",
  8830. there4: "\u2234",
  8831. sim: "\u223C",
  8832. cong: "\u2245",
  8833. asymp: "\u2248",
  8834. ne: "\u2260",
  8835. equiv: "\u2261",
  8836. le: "\u2264",
  8837. ge: "\u2265",
  8838. sub: "\u2282",
  8839. sup: "\u2283",
  8840. nsub: "\u2284",
  8841. sube: "\u2286",
  8842. supe: "\u2287",
  8843. oplus: "\u2295",
  8844. otimes: "\u2297",
  8845. perp: "\u22A5",
  8846. sdot: "\u22C5",
  8847. lceil: "\u2308",
  8848. rceil: "\u2309",
  8849. lfloor: "\u230A",
  8850. rfloor: "\u230B",
  8851. lang: "\u2329",
  8852. rang: "\u232A",
  8853. loz: "\u25CA",
  8854. spades: "\u2660",
  8855. clubs: "\u2663",
  8856. hearts: "\u2665",
  8857. diams: "\u2666"
  8858. };
  8859. const JsxErrors = ParseErrorEnum`jsx`({
  8860. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  8861. MissingClosingTagElement: ({
  8862. openingTagName
  8863. }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
  8864. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  8865. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  8866. UnexpectedToken: ({
  8867. unexpected,
  8868. HTMLEntity
  8869. }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
  8870. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  8871. UnterminatedJsxContent: "Unterminated JSX contents.",
  8872. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  8873. });
  8874. function isFragment(object) {
  8875. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  8876. }
  8877. function getQualifiedJSXName(object) {
  8878. if (object.type === "JSXIdentifier") {
  8879. return object.name;
  8880. }
  8881. if (object.type === "JSXNamespacedName") {
  8882. return object.namespace.name + ":" + object.name.name;
  8883. }
  8884. if (object.type === "JSXMemberExpression") {
  8885. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  8886. }
  8887. throw new Error("Node had unexpected type: " + object.type);
  8888. }
  8889. var jsx = superClass => class JSXParserMixin extends superClass {
  8890. jsxReadToken() {
  8891. let out = "";
  8892. let chunkStart = this.state.pos;
  8893. for (;;) {
  8894. if (this.state.pos >= this.length) {
  8895. throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc);
  8896. }
  8897. const ch = this.input.charCodeAt(this.state.pos);
  8898. switch (ch) {
  8899. case 60:
  8900. case 123:
  8901. if (this.state.pos === this.state.start) {
  8902. if (ch === 60 && this.state.canStartJSXElement) {
  8903. ++this.state.pos;
  8904. this.finishToken(142);
  8905. } else {
  8906. super.getTokenFromCode(ch);
  8907. }
  8908. return;
  8909. }
  8910. out += this.input.slice(chunkStart, this.state.pos);
  8911. this.finishToken(141, out);
  8912. return;
  8913. case 38:
  8914. out += this.input.slice(chunkStart, this.state.pos);
  8915. out += this.jsxReadEntity();
  8916. chunkStart = this.state.pos;
  8917. break;
  8918. case 62:
  8919. case 125:
  8920. default:
  8921. if (isNewLine(ch)) {
  8922. out += this.input.slice(chunkStart, this.state.pos);
  8923. out += this.jsxReadNewLine(true);
  8924. chunkStart = this.state.pos;
  8925. } else {
  8926. ++this.state.pos;
  8927. }
  8928. }
  8929. }
  8930. }
  8931. jsxReadNewLine(normalizeCRLF) {
  8932. const ch = this.input.charCodeAt(this.state.pos);
  8933. let out;
  8934. ++this.state.pos;
  8935. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  8936. ++this.state.pos;
  8937. out = normalizeCRLF ? "\n" : "\r\n";
  8938. } else {
  8939. out = String.fromCharCode(ch);
  8940. }
  8941. ++this.state.curLine;
  8942. this.state.lineStart = this.state.pos;
  8943. return out;
  8944. }
  8945. jsxReadString(quote) {
  8946. let out = "";
  8947. let chunkStart = ++this.state.pos;
  8948. for (;;) {
  8949. if (this.state.pos >= this.length) {
  8950. throw this.raise(Errors.UnterminatedString, this.state.startLoc);
  8951. }
  8952. const ch = this.input.charCodeAt(this.state.pos);
  8953. if (ch === quote) break;
  8954. if (ch === 38) {
  8955. out += this.input.slice(chunkStart, this.state.pos);
  8956. out += this.jsxReadEntity();
  8957. chunkStart = this.state.pos;
  8958. } else if (isNewLine(ch)) {
  8959. out += this.input.slice(chunkStart, this.state.pos);
  8960. out += this.jsxReadNewLine(false);
  8961. chunkStart = this.state.pos;
  8962. } else {
  8963. ++this.state.pos;
  8964. }
  8965. }
  8966. out += this.input.slice(chunkStart, this.state.pos++);
  8967. this.finishToken(133, out);
  8968. }
  8969. jsxReadEntity() {
  8970. const startPos = ++this.state.pos;
  8971. if (this.codePointAtPos(this.state.pos) === 35) {
  8972. ++this.state.pos;
  8973. let radix = 10;
  8974. if (this.codePointAtPos(this.state.pos) === 120) {
  8975. radix = 16;
  8976. ++this.state.pos;
  8977. }
  8978. const codePoint = this.readInt(radix, undefined, false, "bail");
  8979. if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
  8980. ++this.state.pos;
  8981. return String.fromCodePoint(codePoint);
  8982. }
  8983. } else {
  8984. let count = 0;
  8985. let semi = false;
  8986. while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) === 59)) {
  8987. ++this.state.pos;
  8988. }
  8989. if (semi) {
  8990. const desc = this.input.slice(startPos, this.state.pos);
  8991. const entity = entities[desc];
  8992. ++this.state.pos;
  8993. if (entity) {
  8994. return entity;
  8995. }
  8996. }
  8997. }
  8998. this.state.pos = startPos;
  8999. return "&";
  9000. }
  9001. jsxReadWord() {
  9002. let ch;
  9003. const start = this.state.pos;
  9004. do {
  9005. ch = this.input.charCodeAt(++this.state.pos);
  9006. } while (isIdentifierChar(ch) || ch === 45);
  9007. this.finishToken(140, this.input.slice(start, this.state.pos));
  9008. }
  9009. jsxParseIdentifier() {
  9010. const node = this.startNode();
  9011. if (this.match(140)) {
  9012. node.name = this.state.value;
  9013. } else if (tokenIsKeyword(this.state.type)) {
  9014. node.name = tokenLabelName(this.state.type);
  9015. } else {
  9016. this.unexpected();
  9017. }
  9018. this.next();
  9019. return this.finishNode(node, "JSXIdentifier");
  9020. }
  9021. jsxParseNamespacedName() {
  9022. const startLoc = this.state.startLoc;
  9023. const name = this.jsxParseIdentifier();
  9024. if (!this.eat(14)) return name;
  9025. const node = this.startNodeAt(startLoc);
  9026. node.namespace = name;
  9027. node.name = this.jsxParseIdentifier();
  9028. return this.finishNode(node, "JSXNamespacedName");
  9029. }
  9030. jsxParseElementName() {
  9031. const startLoc = this.state.startLoc;
  9032. let node = this.jsxParseNamespacedName();
  9033. if (node.type === "JSXNamespacedName") {
  9034. return node;
  9035. }
  9036. while (this.eat(16)) {
  9037. const newNode = this.startNodeAt(startLoc);
  9038. newNode.object = node;
  9039. newNode.property = this.jsxParseIdentifier();
  9040. node = this.finishNode(newNode, "JSXMemberExpression");
  9041. }
  9042. return node;
  9043. }
  9044. jsxParseAttributeValue() {
  9045. let node;
  9046. switch (this.state.type) {
  9047. case 5:
  9048. node = this.startNode();
  9049. this.setContext(types.brace);
  9050. this.next();
  9051. node = this.jsxParseExpressionContainer(node, types.j_oTag);
  9052. if (node.expression.type === "JSXEmptyExpression") {
  9053. this.raise(JsxErrors.AttributeIsEmpty, node);
  9054. }
  9055. return node;
  9056. case 142:
  9057. case 133:
  9058. return this.parseExprAtom();
  9059. default:
  9060. throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
  9061. }
  9062. }
  9063. jsxParseEmptyExpression() {
  9064. const node = this.startNodeAt(this.state.lastTokEndLoc);
  9065. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
  9066. }
  9067. jsxParseSpreadChild(node) {
  9068. this.next();
  9069. node.expression = this.parseExpression();
  9070. this.setContext(types.j_expr);
  9071. this.state.canStartJSXElement = true;
  9072. this.expect(8);
  9073. return this.finishNode(node, "JSXSpreadChild");
  9074. }
  9075. jsxParseExpressionContainer(node, previousContext) {
  9076. if (this.match(8)) {
  9077. node.expression = this.jsxParseEmptyExpression();
  9078. } else {
  9079. const expression = this.parseExpression();
  9080. node.expression = expression;
  9081. }
  9082. this.setContext(previousContext);
  9083. this.state.canStartJSXElement = true;
  9084. this.expect(8);
  9085. return this.finishNode(node, "JSXExpressionContainer");
  9086. }
  9087. jsxParseAttribute() {
  9088. const node = this.startNode();
  9089. if (this.match(5)) {
  9090. this.setContext(types.brace);
  9091. this.next();
  9092. this.expect(21);
  9093. node.argument = this.parseMaybeAssignAllowIn();
  9094. this.setContext(types.j_oTag);
  9095. this.state.canStartJSXElement = true;
  9096. this.expect(8);
  9097. return this.finishNode(node, "JSXSpreadAttribute");
  9098. }
  9099. node.name = this.jsxParseNamespacedName();
  9100. node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
  9101. return this.finishNode(node, "JSXAttribute");
  9102. }
  9103. jsxParseOpeningElementAt(startLoc) {
  9104. const node = this.startNodeAt(startLoc);
  9105. if (this.eat(143)) {
  9106. return this.finishNode(node, "JSXOpeningFragment");
  9107. }
  9108. node.name = this.jsxParseElementName();
  9109. return this.jsxParseOpeningElementAfterName(node);
  9110. }
  9111. jsxParseOpeningElementAfterName(node) {
  9112. const attributes = [];
  9113. while (!this.match(56) && !this.match(143)) {
  9114. attributes.push(this.jsxParseAttribute());
  9115. }
  9116. node.attributes = attributes;
  9117. node.selfClosing = this.eat(56);
  9118. this.expect(143);
  9119. return this.finishNode(node, "JSXOpeningElement");
  9120. }
  9121. jsxParseClosingElementAt(startLoc) {
  9122. const node = this.startNodeAt(startLoc);
  9123. if (this.eat(143)) {
  9124. return this.finishNode(node, "JSXClosingFragment");
  9125. }
  9126. node.name = this.jsxParseElementName();
  9127. this.expect(143);
  9128. return this.finishNode(node, "JSXClosingElement");
  9129. }
  9130. jsxParseElementAt(startLoc) {
  9131. const node = this.startNodeAt(startLoc);
  9132. const children = [];
  9133. const openingElement = this.jsxParseOpeningElementAt(startLoc);
  9134. let closingElement = null;
  9135. if (!openingElement.selfClosing) {
  9136. contents: for (;;) {
  9137. switch (this.state.type) {
  9138. case 142:
  9139. startLoc = this.state.startLoc;
  9140. this.next();
  9141. if (this.eat(56)) {
  9142. closingElement = this.jsxParseClosingElementAt(startLoc);
  9143. break contents;
  9144. }
  9145. children.push(this.jsxParseElementAt(startLoc));
  9146. break;
  9147. case 141:
  9148. children.push(this.parseLiteral(this.state.value, "JSXText"));
  9149. break;
  9150. case 5:
  9151. {
  9152. const node = this.startNode();
  9153. this.setContext(types.brace);
  9154. this.next();
  9155. if (this.match(21)) {
  9156. children.push(this.jsxParseSpreadChild(node));
  9157. } else {
  9158. children.push(this.jsxParseExpressionContainer(node, types.j_expr));
  9159. }
  9160. break;
  9161. }
  9162. default:
  9163. this.unexpected();
  9164. }
  9165. }
  9166. if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
  9167. this.raise(JsxErrors.MissingClosingTagFragment, closingElement);
  9168. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  9169. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9170. openingTagName: getQualifiedJSXName(openingElement.name)
  9171. });
  9172. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  9173. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  9174. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9175. openingTagName: getQualifiedJSXName(openingElement.name)
  9176. });
  9177. }
  9178. }
  9179. }
  9180. if (isFragment(openingElement)) {
  9181. node.openingFragment = openingElement;
  9182. node.closingFragment = closingElement;
  9183. } else {
  9184. node.openingElement = openingElement;
  9185. node.closingElement = closingElement;
  9186. }
  9187. node.children = children;
  9188. if (this.match(47)) {
  9189. throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc);
  9190. }
  9191. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  9192. }
  9193. jsxParseElement() {
  9194. const startLoc = this.state.startLoc;
  9195. this.next();
  9196. return this.jsxParseElementAt(startLoc);
  9197. }
  9198. setContext(newContext) {
  9199. const {
  9200. context
  9201. } = this.state;
  9202. context[context.length - 1] = newContext;
  9203. }
  9204. parseExprAtom(refExpressionErrors) {
  9205. if (this.match(142)) {
  9206. return this.jsxParseElement();
  9207. } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
  9208. this.replaceToken(142);
  9209. return this.jsxParseElement();
  9210. } else {
  9211. return super.parseExprAtom(refExpressionErrors);
  9212. }
  9213. }
  9214. skipSpace() {
  9215. const curContext = this.curContext();
  9216. if (!curContext.preserveSpace) super.skipSpace();
  9217. }
  9218. getTokenFromCode(code) {
  9219. const context = this.curContext();
  9220. if (context === types.j_expr) {
  9221. this.jsxReadToken();
  9222. return;
  9223. }
  9224. if (context === types.j_oTag || context === types.j_cTag) {
  9225. if (isIdentifierStart(code)) {
  9226. this.jsxReadWord();
  9227. return;
  9228. }
  9229. if (code === 62) {
  9230. ++this.state.pos;
  9231. this.finishToken(143);
  9232. return;
  9233. }
  9234. if ((code === 34 || code === 39) && context === types.j_oTag) {
  9235. this.jsxReadString(code);
  9236. return;
  9237. }
  9238. }
  9239. if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  9240. ++this.state.pos;
  9241. this.finishToken(142);
  9242. return;
  9243. }
  9244. super.getTokenFromCode(code);
  9245. }
  9246. updateContext(prevType) {
  9247. const {
  9248. context,
  9249. type
  9250. } = this.state;
  9251. if (type === 56 && prevType === 142) {
  9252. context.splice(-2, 2, types.j_cTag);
  9253. this.state.canStartJSXElement = false;
  9254. } else if (type === 142) {
  9255. context.push(types.j_oTag);
  9256. } else if (type === 143) {
  9257. const out = context[context.length - 1];
  9258. if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) {
  9259. context.pop();
  9260. this.state.canStartJSXElement = context[context.length - 1] === types.j_expr;
  9261. } else {
  9262. this.setContext(types.j_expr);
  9263. this.state.canStartJSXElement = true;
  9264. }
  9265. } else {
  9266. this.state.canStartJSXElement = tokenComesBeforeExpression(type);
  9267. }
  9268. }
  9269. };
  9270. class TypeScriptScope extends Scope {
  9271. constructor(...args) {
  9272. super(...args);
  9273. this.tsNames = new Map();
  9274. }
  9275. }
  9276. class TypeScriptScopeHandler extends ScopeHandler {
  9277. constructor(...args) {
  9278. super(...args);
  9279. this.importsStack = [];
  9280. }
  9281. createScope(flags) {
  9282. this.importsStack.push(new Set());
  9283. return new TypeScriptScope(flags);
  9284. }
  9285. enter(flags) {
  9286. if (flags === 256) {
  9287. this.importsStack.push(new Set());
  9288. }
  9289. super.enter(flags);
  9290. }
  9291. exit() {
  9292. const flags = super.exit();
  9293. if (flags === 256) {
  9294. this.importsStack.pop();
  9295. }
  9296. return flags;
  9297. }
  9298. hasImport(name, allowShadow) {
  9299. const len = this.importsStack.length;
  9300. if (this.importsStack[len - 1].has(name)) {
  9301. return true;
  9302. }
  9303. if (!allowShadow && len > 1) {
  9304. for (let i = 0; i < len - 1; i++) {
  9305. if (this.importsStack[i].has(name)) return true;
  9306. }
  9307. }
  9308. return false;
  9309. }
  9310. declareName(name, bindingType, loc) {
  9311. if (bindingType & 4096) {
  9312. if (this.hasImport(name, true)) {
  9313. this.parser.raise(Errors.VarRedeclaration, loc, {
  9314. identifierName: name
  9315. });
  9316. }
  9317. this.importsStack[this.importsStack.length - 1].add(name);
  9318. return;
  9319. }
  9320. const scope = this.currentScope();
  9321. let type = scope.tsNames.get(name) || 0;
  9322. if (bindingType & 1024) {
  9323. this.maybeExportDefined(scope, name);
  9324. scope.tsNames.set(name, type | 16);
  9325. return;
  9326. }
  9327. super.declareName(name, bindingType, loc);
  9328. if (bindingType & 2) {
  9329. if (!(bindingType & 1)) {
  9330. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  9331. this.maybeExportDefined(scope, name);
  9332. }
  9333. type = type | 1;
  9334. }
  9335. if (bindingType & 256) {
  9336. type = type | 2;
  9337. }
  9338. if (bindingType & 512) {
  9339. type = type | 4;
  9340. }
  9341. if (bindingType & 128) {
  9342. type = type | 8;
  9343. }
  9344. if (type) scope.tsNames.set(name, type);
  9345. }
  9346. isRedeclaredInScope(scope, name, bindingType) {
  9347. const type = scope.tsNames.get(name);
  9348. if ((type & 2) > 0) {
  9349. if (bindingType & 256) {
  9350. const isConst = !!(bindingType & 512);
  9351. const wasConst = (type & 4) > 0;
  9352. return isConst !== wasConst;
  9353. }
  9354. return true;
  9355. }
  9356. if (bindingType & 128 && (type & 8) > 0) {
  9357. if (scope.names.get(name) & 2) {
  9358. return !!(bindingType & 1);
  9359. } else {
  9360. return false;
  9361. }
  9362. }
  9363. if (bindingType & 2 && (type & 1) > 0) {
  9364. return true;
  9365. }
  9366. return super.isRedeclaredInScope(scope, name, bindingType);
  9367. }
  9368. checkLocalExport(id) {
  9369. const {
  9370. name
  9371. } = id;
  9372. if (this.hasImport(name)) return;
  9373. const len = this.scopeStack.length;
  9374. for (let i = len - 1; i >= 0; i--) {
  9375. const scope = this.scopeStack[i];
  9376. const type = scope.tsNames.get(name);
  9377. if ((type & 1) > 0 || (type & 16) > 0) {
  9378. return;
  9379. }
  9380. }
  9381. super.checkLocalExport(id);
  9382. }
  9383. }
  9384. const unwrapParenthesizedExpression = node => {
  9385. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  9386. };
  9387. class LValParser extends NodeUtils {
  9388. toAssignable(node, isLHS = false) {
  9389. var _node$extra, _node$extra3;
  9390. let parenthesized = undefined;
  9391. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  9392. parenthesized = unwrapParenthesizedExpression(node);
  9393. if (isLHS) {
  9394. if (parenthesized.type === "Identifier") {
  9395. this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
  9396. } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
  9397. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9398. }
  9399. } else {
  9400. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9401. }
  9402. }
  9403. switch (node.type) {
  9404. case "Identifier":
  9405. case "ObjectPattern":
  9406. case "ArrayPattern":
  9407. case "AssignmentPattern":
  9408. case "RestElement":
  9409. break;
  9410. case "ObjectExpression":
  9411. node.type = "ObjectPattern";
  9412. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  9413. var _node$extra2;
  9414. const prop = node.properties[i];
  9415. const isLast = i === last;
  9416. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  9417. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
  9418. this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
  9419. }
  9420. }
  9421. break;
  9422. case "ObjectProperty":
  9423. {
  9424. const {
  9425. key,
  9426. value
  9427. } = node;
  9428. if (this.isPrivateName(key)) {
  9429. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  9430. }
  9431. this.toAssignable(value, isLHS);
  9432. break;
  9433. }
  9434. case "SpreadElement":
  9435. {
  9436. throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
  9437. }
  9438. case "ArrayExpression":
  9439. node.type = "ArrayPattern";
  9440. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
  9441. break;
  9442. case "AssignmentExpression":
  9443. if (node.operator !== "=") {
  9444. this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
  9445. }
  9446. node.type = "AssignmentPattern";
  9447. delete node.operator;
  9448. this.toAssignable(node.left, isLHS);
  9449. break;
  9450. case "ParenthesizedExpression":
  9451. this.toAssignable(parenthesized, isLHS);
  9452. break;
  9453. }
  9454. }
  9455. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  9456. if (prop.type === "ObjectMethod") {
  9457. this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
  9458. } else if (prop.type === "SpreadElement") {
  9459. prop.type = "RestElement";
  9460. const arg = prop.argument;
  9461. this.checkToRestConversion(arg, false);
  9462. this.toAssignable(arg, isLHS);
  9463. if (!isLast) {
  9464. this.raise(Errors.RestTrailingComma, prop);
  9465. }
  9466. } else {
  9467. this.toAssignable(prop, isLHS);
  9468. }
  9469. }
  9470. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  9471. const end = exprList.length - 1;
  9472. for (let i = 0; i <= end; i++) {
  9473. const elt = exprList[i];
  9474. if (!elt) continue;
  9475. if (elt.type === "SpreadElement") {
  9476. elt.type = "RestElement";
  9477. const arg = elt.argument;
  9478. this.checkToRestConversion(arg, true);
  9479. this.toAssignable(arg, isLHS);
  9480. } else {
  9481. this.toAssignable(elt, isLHS);
  9482. }
  9483. if (elt.type === "RestElement") {
  9484. if (i < end) {
  9485. this.raise(Errors.RestTrailingComma, elt);
  9486. } else if (trailingCommaLoc) {
  9487. this.raise(Errors.RestTrailingComma, trailingCommaLoc);
  9488. }
  9489. }
  9490. }
  9491. }
  9492. isAssignable(node, isBinding) {
  9493. switch (node.type) {
  9494. case "Identifier":
  9495. case "ObjectPattern":
  9496. case "ArrayPattern":
  9497. case "AssignmentPattern":
  9498. case "RestElement":
  9499. return true;
  9500. case "ObjectExpression":
  9501. {
  9502. const last = node.properties.length - 1;
  9503. return node.properties.every((prop, i) => {
  9504. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  9505. });
  9506. }
  9507. case "ObjectProperty":
  9508. return this.isAssignable(node.value);
  9509. case "SpreadElement":
  9510. return this.isAssignable(node.argument);
  9511. case "ArrayExpression":
  9512. return node.elements.every(element => element === null || this.isAssignable(element));
  9513. case "AssignmentExpression":
  9514. return node.operator === "=";
  9515. case "ParenthesizedExpression":
  9516. return this.isAssignable(node.expression);
  9517. case "MemberExpression":
  9518. case "OptionalMemberExpression":
  9519. return !isBinding;
  9520. default:
  9521. return false;
  9522. }
  9523. }
  9524. toReferencedList(exprList, isParenthesizedExpr) {
  9525. return exprList;
  9526. }
  9527. toReferencedListDeep(exprList, isParenthesizedExpr) {
  9528. this.toReferencedList(exprList, isParenthesizedExpr);
  9529. for (const expr of exprList) {
  9530. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  9531. this.toReferencedListDeep(expr.elements);
  9532. }
  9533. }
  9534. }
  9535. parseSpread(refExpressionErrors) {
  9536. const node = this.startNode();
  9537. this.next();
  9538. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined);
  9539. return this.finishNode(node, "SpreadElement");
  9540. }
  9541. parseRestBinding() {
  9542. const node = this.startNode();
  9543. this.next();
  9544. node.argument = this.parseBindingAtom();
  9545. return this.finishNode(node, "RestElement");
  9546. }
  9547. parseBindingAtom() {
  9548. switch (this.state.type) {
  9549. case 0:
  9550. {
  9551. const node = this.startNode();
  9552. this.next();
  9553. node.elements = this.parseBindingList(3, 93, 1);
  9554. return this.finishNode(node, "ArrayPattern");
  9555. }
  9556. case 5:
  9557. return this.parseObjectLike(8, true);
  9558. }
  9559. return this.parseIdentifier();
  9560. }
  9561. parseBindingList(close, closeCharCode, flags) {
  9562. const allowEmpty = flags & 1;
  9563. const elts = [];
  9564. let first = true;
  9565. while (!this.eat(close)) {
  9566. if (first) {
  9567. first = false;
  9568. } else {
  9569. this.expect(12);
  9570. }
  9571. if (allowEmpty && this.match(12)) {
  9572. elts.push(null);
  9573. } else if (this.eat(close)) {
  9574. break;
  9575. } else if (this.match(21)) {
  9576. elts.push(this.parseAssignableListItemTypes(this.parseRestBinding(), flags));
  9577. if (!this.checkCommaAfterRest(closeCharCode)) {
  9578. this.expect(close);
  9579. break;
  9580. }
  9581. } else {
  9582. const decorators = [];
  9583. if (this.match(26) && this.hasPlugin("decorators")) {
  9584. this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
  9585. }
  9586. while (this.match(26)) {
  9587. decorators.push(this.parseDecorator());
  9588. }
  9589. elts.push(this.parseAssignableListItem(flags, decorators));
  9590. }
  9591. }
  9592. return elts;
  9593. }
  9594. parseBindingRestProperty(prop) {
  9595. this.next();
  9596. prop.argument = this.parseIdentifier();
  9597. this.checkCommaAfterRest(125);
  9598. return this.finishNode(prop, "RestElement");
  9599. }
  9600. parseBindingProperty() {
  9601. const {
  9602. type,
  9603. startLoc
  9604. } = this.state;
  9605. if (type === 21) {
  9606. return this.parseBindingRestProperty(this.startNode());
  9607. }
  9608. const prop = this.startNode();
  9609. if (type === 138) {
  9610. this.expectPlugin("destructuringPrivate", startLoc);
  9611. this.classScope.usePrivateName(this.state.value, startLoc);
  9612. prop.key = this.parsePrivateName();
  9613. } else {
  9614. this.parsePropertyName(prop);
  9615. }
  9616. prop.method = false;
  9617. return this.parseObjPropValue(prop, startLoc, false, false, true, false);
  9618. }
  9619. parseAssignableListItem(flags, decorators) {
  9620. const left = this.parseMaybeDefault();
  9621. this.parseAssignableListItemTypes(left, flags);
  9622. const elt = this.parseMaybeDefault(left.loc.start, left);
  9623. if (decorators.length) {
  9624. left.decorators = decorators;
  9625. }
  9626. return elt;
  9627. }
  9628. parseAssignableListItemTypes(param, flags) {
  9629. return param;
  9630. }
  9631. parseMaybeDefault(startLoc, left) {
  9632. var _startLoc, _left;
  9633. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  9634. left = (_left = left) != null ? _left : this.parseBindingAtom();
  9635. if (!this.eat(29)) return left;
  9636. const node = this.startNodeAt(startLoc);
  9637. node.left = left;
  9638. node.right = this.parseMaybeAssignAllowIn();
  9639. return this.finishNode(node, "AssignmentPattern");
  9640. }
  9641. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  9642. switch (type) {
  9643. case "AssignmentPattern":
  9644. return "left";
  9645. case "RestElement":
  9646. return "argument";
  9647. case "ObjectProperty":
  9648. return "value";
  9649. case "ParenthesizedExpression":
  9650. return "expression";
  9651. case "ArrayPattern":
  9652. return "elements";
  9653. case "ObjectPattern":
  9654. return "properties";
  9655. }
  9656. return false;
  9657. }
  9658. isOptionalMemberExpression(expression) {
  9659. return expression.type === "OptionalMemberExpression";
  9660. }
  9661. checkLVal(expression, ancestor, binding = 64, checkClashes = false, strictModeChanged = false, hasParenthesizedAncestor = false) {
  9662. var _expression$extra;
  9663. const type = expression.type;
  9664. if (this.isObjectMethod(expression)) return;
  9665. const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
  9666. if (isOptionalMemberExpression || type === "MemberExpression") {
  9667. if (isOptionalMemberExpression) {
  9668. this.expectPlugin("optionalChainingAssign", expression.loc.start);
  9669. if (ancestor.type !== "AssignmentExpression") {
  9670. this.raise(Errors.InvalidLhsOptionalChaining, expression, {
  9671. ancestor
  9672. });
  9673. }
  9674. }
  9675. if (binding !== 64) {
  9676. this.raise(Errors.InvalidPropertyBindingPattern, expression);
  9677. }
  9678. return;
  9679. }
  9680. if (type === "Identifier") {
  9681. this.checkIdentifier(expression, binding, strictModeChanged);
  9682. const {
  9683. name
  9684. } = expression;
  9685. if (checkClashes) {
  9686. if (checkClashes.has(name)) {
  9687. this.raise(Errors.ParamDupe, expression);
  9688. } else {
  9689. checkClashes.add(name);
  9690. }
  9691. }
  9692. return;
  9693. }
  9694. const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
  9695. if (validity === true) return;
  9696. if (validity === false) {
  9697. const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
  9698. this.raise(ParseErrorClass, expression, {
  9699. ancestor
  9700. });
  9701. return;
  9702. }
  9703. let key, isParenthesizedExpression;
  9704. if (typeof validity === "string") {
  9705. key = validity;
  9706. isParenthesizedExpression = type === "ParenthesizedExpression";
  9707. } else {
  9708. [key, isParenthesizedExpression] = validity;
  9709. }
  9710. const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
  9711. type
  9712. } : ancestor;
  9713. const val = expression[key];
  9714. if (Array.isArray(val)) {
  9715. for (const child of val) {
  9716. if (child) {
  9717. this.checkLVal(child, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
  9718. }
  9719. }
  9720. } else if (val) {
  9721. this.checkLVal(val, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
  9722. }
  9723. }
  9724. checkIdentifier(at, bindingType, strictModeChanged = false) {
  9725. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
  9726. if (bindingType === 64) {
  9727. this.raise(Errors.StrictEvalArguments, at, {
  9728. referenceName: at.name
  9729. });
  9730. } else {
  9731. this.raise(Errors.StrictEvalArgumentsBinding, at, {
  9732. bindingName: at.name
  9733. });
  9734. }
  9735. }
  9736. if (bindingType & 8192 && at.name === "let") {
  9737. this.raise(Errors.LetInLexicalBinding, at);
  9738. }
  9739. if (!(bindingType & 64)) {
  9740. this.declareNameFromIdentifier(at, bindingType);
  9741. }
  9742. }
  9743. declareNameFromIdentifier(identifier, binding) {
  9744. this.scope.declareName(identifier.name, binding, identifier.loc.start);
  9745. }
  9746. checkToRestConversion(node, allowPattern) {
  9747. switch (node.type) {
  9748. case "ParenthesizedExpression":
  9749. this.checkToRestConversion(node.expression, allowPattern);
  9750. break;
  9751. case "Identifier":
  9752. case "MemberExpression":
  9753. break;
  9754. case "ArrayExpression":
  9755. case "ObjectExpression":
  9756. if (allowPattern) break;
  9757. default:
  9758. this.raise(Errors.InvalidRestAssignmentPattern, node);
  9759. }
  9760. }
  9761. checkCommaAfterRest(close) {
  9762. if (!this.match(12)) {
  9763. return false;
  9764. }
  9765. this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
  9766. return true;
  9767. }
  9768. }
  9769. function nonNull(x) {
  9770. if (x == null) {
  9771. throw new Error(`Unexpected ${x} value.`);
  9772. }
  9773. return x;
  9774. }
  9775. function assert(x) {
  9776. if (!x) {
  9777. throw new Error("Assert fail");
  9778. }
  9779. }
  9780. const TSErrors = ParseErrorEnum`typescript`({
  9781. AbstractMethodHasImplementation: ({
  9782. methodName
  9783. }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`,
  9784. AbstractPropertyHasInitializer: ({
  9785. propertyName
  9786. }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
  9787. AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  9788. AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  9789. AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
  9790. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  9791. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  9792. ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
  9793. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  9794. DeclareAccessor: ({
  9795. kind
  9796. }) => `'declare' is not allowed in ${kind}ters.`,
  9797. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  9798. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  9799. DuplicateAccessibilityModifier: ({
  9800. modifier
  9801. }) => `Accessibility modifier already seen.`,
  9802. DuplicateModifier: ({
  9803. modifier
  9804. }) => `Duplicate modifier: '${modifier}'.`,
  9805. EmptyHeritageClauseType: ({
  9806. token
  9807. }) => `'${token}' list cannot be empty.`,
  9808. EmptyTypeArguments: "Type argument list cannot be empty.",
  9809. EmptyTypeParameters: "Type parameter list cannot be empty.",
  9810. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  9811. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  9812. ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier",
  9813. IncompatibleModifiers: ({
  9814. modifiers
  9815. }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
  9816. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  9817. IndexSignatureHasAccessibility: ({
  9818. modifier
  9819. }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
  9820. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  9821. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  9822. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  9823. InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
  9824. InvalidModifierOnTypeMember: ({
  9825. modifier
  9826. }) => `'${modifier}' modifier cannot appear on a type member.`,
  9827. InvalidModifierOnTypeParameter: ({
  9828. modifier
  9829. }) => `'${modifier}' modifier cannot appear on a type parameter.`,
  9830. InvalidModifierOnTypeParameterPositions: ({
  9831. modifier
  9832. }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
  9833. InvalidModifiersOrder: ({
  9834. orderedModifiers
  9835. }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
  9836. InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
  9837. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  9838. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  9839. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  9840. NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
  9841. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  9842. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  9843. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  9844. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  9845. PrivateElementHasAccessibility: ({
  9846. modifier
  9847. }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
  9848. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  9849. ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
  9850. ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
  9851. SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  9852. SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  9853. SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  9854. SingleTypeParameterWithoutTrailingComma: ({
  9855. typeParameterName
  9856. }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
  9857. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  9858. TupleOptionalAfterType: "A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",
  9859. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  9860. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  9861. TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
  9862. TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
  9863. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  9864. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  9865. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  9866. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  9867. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  9868. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  9869. UnsupportedSignatureParameterKind: ({
  9870. type
  9871. }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`
  9872. });
  9873. function keywordTypeFromName(value) {
  9874. switch (value) {
  9875. case "any":
  9876. return "TSAnyKeyword";
  9877. case "boolean":
  9878. return "TSBooleanKeyword";
  9879. case "bigint":
  9880. return "TSBigIntKeyword";
  9881. case "never":
  9882. return "TSNeverKeyword";
  9883. case "number":
  9884. return "TSNumberKeyword";
  9885. case "object":
  9886. return "TSObjectKeyword";
  9887. case "string":
  9888. return "TSStringKeyword";
  9889. case "symbol":
  9890. return "TSSymbolKeyword";
  9891. case "undefined":
  9892. return "TSUndefinedKeyword";
  9893. case "unknown":
  9894. return "TSUnknownKeyword";
  9895. default:
  9896. return undefined;
  9897. }
  9898. }
  9899. function tsIsAccessModifier(modifier) {
  9900. return modifier === "private" || modifier === "public" || modifier === "protected";
  9901. }
  9902. function tsIsVarianceAnnotations(modifier) {
  9903. return modifier === "in" || modifier === "out";
  9904. }
  9905. var typescript = superClass => class TypeScriptParserMixin extends superClass {
  9906. constructor(...args) {
  9907. super(...args);
  9908. this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, {
  9909. allowedModifiers: ["in", "out"],
  9910. disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9911. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9912. });
  9913. this.tsParseConstModifier = this.tsParseModifiers.bind(this, {
  9914. allowedModifiers: ["const"],
  9915. disallowedModifiers: ["in", "out"],
  9916. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  9917. });
  9918. this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, {
  9919. allowedModifiers: ["in", "out", "const"],
  9920. disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9921. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9922. });
  9923. }
  9924. getScopeHandler() {
  9925. return TypeScriptScopeHandler;
  9926. }
  9927. tsIsIdentifier() {
  9928. return tokenIsIdentifier(this.state.type);
  9929. }
  9930. tsTokenCanFollowModifier() {
  9931. return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
  9932. }
  9933. tsNextTokenCanFollowModifier() {
  9934. this.next();
  9935. return this.tsTokenCanFollowModifier();
  9936. }
  9937. tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
  9938. if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) {
  9939. return undefined;
  9940. }
  9941. const modifier = this.state.value;
  9942. if (allowedModifiers.includes(modifier)) {
  9943. if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) {
  9944. return undefined;
  9945. }
  9946. if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  9947. return modifier;
  9948. }
  9949. }
  9950. return undefined;
  9951. }
  9952. tsParseModifiers({
  9953. allowedModifiers,
  9954. disallowedModifiers,
  9955. stopOnStartOfClassStaticBlock,
  9956. errorTemplate = TSErrors.InvalidModifierOnTypeMember
  9957. }, modified) {
  9958. const enforceOrder = (loc, modifier, before, after) => {
  9959. if (modifier === before && modified[after]) {
  9960. this.raise(TSErrors.InvalidModifiersOrder, loc, {
  9961. orderedModifiers: [before, after]
  9962. });
  9963. }
  9964. };
  9965. const incompatible = (loc, modifier, mod1, mod2) => {
  9966. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  9967. this.raise(TSErrors.IncompatibleModifiers, loc, {
  9968. modifiers: [mod1, mod2]
  9969. });
  9970. }
  9971. };
  9972. for (;;) {
  9973. const {
  9974. startLoc
  9975. } = this.state;
  9976. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
  9977. if (!modifier) break;
  9978. if (tsIsAccessModifier(modifier)) {
  9979. if (modified.accessibility) {
  9980. this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, {
  9981. modifier
  9982. });
  9983. } else {
  9984. enforceOrder(startLoc, modifier, modifier, "override");
  9985. enforceOrder(startLoc, modifier, modifier, "static");
  9986. enforceOrder(startLoc, modifier, modifier, "readonly");
  9987. modified.accessibility = modifier;
  9988. }
  9989. } else if (tsIsVarianceAnnotations(modifier)) {
  9990. if (modified[modifier]) {
  9991. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9992. modifier
  9993. });
  9994. }
  9995. modified[modifier] = true;
  9996. enforceOrder(startLoc, modifier, "in", "out");
  9997. } else {
  9998. if (hasOwnProperty.call(modified, modifier)) {
  9999. this.raise(TSErrors.DuplicateModifier, startLoc, {
  10000. modifier
  10001. });
  10002. } else {
  10003. enforceOrder(startLoc, modifier, "static", "readonly");
  10004. enforceOrder(startLoc, modifier, "static", "override");
  10005. enforceOrder(startLoc, modifier, "override", "readonly");
  10006. enforceOrder(startLoc, modifier, "abstract", "override");
  10007. incompatible(startLoc, modifier, "declare", "override");
  10008. incompatible(startLoc, modifier, "static", "abstract");
  10009. }
  10010. modified[modifier] = true;
  10011. }
  10012. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  10013. this.raise(errorTemplate, startLoc, {
  10014. modifier
  10015. });
  10016. }
  10017. }
  10018. }
  10019. tsIsListTerminator(kind) {
  10020. switch (kind) {
  10021. case "EnumMembers":
  10022. case "TypeMembers":
  10023. return this.match(8);
  10024. case "HeritageClauseElement":
  10025. return this.match(5);
  10026. case "TupleElementTypes":
  10027. return this.match(3);
  10028. case "TypeParametersOrArguments":
  10029. return this.match(48);
  10030. }
  10031. }
  10032. tsParseList(kind, parseElement) {
  10033. const result = [];
  10034. while (!this.tsIsListTerminator(kind)) {
  10035. result.push(parseElement());
  10036. }
  10037. return result;
  10038. }
  10039. tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) {
  10040. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos));
  10041. }
  10042. tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) {
  10043. const result = [];
  10044. let trailingCommaPos = -1;
  10045. for (;;) {
  10046. if (this.tsIsListTerminator(kind)) {
  10047. break;
  10048. }
  10049. trailingCommaPos = -1;
  10050. const element = parseElement();
  10051. if (element == null) {
  10052. return undefined;
  10053. }
  10054. result.push(element);
  10055. if (this.eat(12)) {
  10056. trailingCommaPos = this.state.lastTokStartLoc.index;
  10057. continue;
  10058. }
  10059. if (this.tsIsListTerminator(kind)) {
  10060. break;
  10061. }
  10062. if (expectSuccess) {
  10063. this.expect(12);
  10064. }
  10065. return undefined;
  10066. }
  10067. if (refTrailingCommaPos) {
  10068. refTrailingCommaPos.value = trailingCommaPos;
  10069. }
  10070. return result;
  10071. }
  10072. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) {
  10073. if (!skipFirstToken) {
  10074. if (bracket) {
  10075. this.expect(0);
  10076. } else {
  10077. this.expect(47);
  10078. }
  10079. }
  10080. const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos);
  10081. if (bracket) {
  10082. this.expect(3);
  10083. } else {
  10084. this.expect(48);
  10085. }
  10086. return result;
  10087. }
  10088. tsParseImportType() {
  10089. const node = this.startNode();
  10090. this.expect(83);
  10091. this.expect(10);
  10092. if (!this.match(133)) {
  10093. this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
  10094. }
  10095. node.argument = super.parseExprAtom();
  10096. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  10097. node.options = null;
  10098. }
  10099. if (this.eat(12)) {
  10100. this.expectImportAttributesPlugin();
  10101. if (!this.match(11)) {
  10102. node.options = super.parseMaybeAssignAllowIn();
  10103. this.eat(12);
  10104. }
  10105. }
  10106. this.expect(11);
  10107. if (this.eat(16)) {
  10108. node.qualifier = this.tsParseEntityName();
  10109. }
  10110. if (this.match(47)) {
  10111. node.typeParameters = this.tsParseTypeArguments();
  10112. }
  10113. return this.finishNode(node, "TSImportType");
  10114. }
  10115. tsParseEntityName(allowReservedWords = true) {
  10116. let entity = this.parseIdentifier(allowReservedWords);
  10117. while (this.eat(16)) {
  10118. const node = this.startNodeAtNode(entity);
  10119. node.left = entity;
  10120. node.right = this.parseIdentifier(allowReservedWords);
  10121. entity = this.finishNode(node, "TSQualifiedName");
  10122. }
  10123. return entity;
  10124. }
  10125. tsParseTypeReference() {
  10126. const node = this.startNode();
  10127. node.typeName = this.tsParseEntityName();
  10128. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10129. node.typeParameters = this.tsParseTypeArguments();
  10130. }
  10131. return this.finishNode(node, "TSTypeReference");
  10132. }
  10133. tsParseThisTypePredicate(lhs) {
  10134. this.next();
  10135. const node = this.startNodeAtNode(lhs);
  10136. node.parameterName = lhs;
  10137. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  10138. node.asserts = false;
  10139. return this.finishNode(node, "TSTypePredicate");
  10140. }
  10141. tsParseThisTypeNode() {
  10142. const node = this.startNode();
  10143. this.next();
  10144. return this.finishNode(node, "TSThisType");
  10145. }
  10146. tsParseTypeQuery() {
  10147. const node = this.startNode();
  10148. this.expect(87);
  10149. if (this.match(83)) {
  10150. node.exprName = this.tsParseImportType();
  10151. } else {
  10152. node.exprName = this.tsParseEntityName();
  10153. }
  10154. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10155. node.typeParameters = this.tsParseTypeArguments();
  10156. }
  10157. return this.finishNode(node, "TSTypeQuery");
  10158. }
  10159. tsParseTypeParameter(parseModifiers) {
  10160. const node = this.startNode();
  10161. parseModifiers(node);
  10162. node.name = this.tsParseTypeParameterName();
  10163. node.constraint = this.tsEatThenParseType(81);
  10164. node.default = this.tsEatThenParseType(29);
  10165. return this.finishNode(node, "TSTypeParameter");
  10166. }
  10167. tsTryParseTypeParameters(parseModifiers) {
  10168. if (this.match(47)) {
  10169. return this.tsParseTypeParameters(parseModifiers);
  10170. }
  10171. }
  10172. tsParseTypeParameters(parseModifiers) {
  10173. const node = this.startNode();
  10174. if (this.match(47) || this.match(142)) {
  10175. this.next();
  10176. } else {
  10177. this.unexpected();
  10178. }
  10179. const refTrailingCommaPos = {
  10180. value: -1
  10181. };
  10182. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
  10183. if (node.params.length === 0) {
  10184. this.raise(TSErrors.EmptyTypeParameters, node);
  10185. }
  10186. if (refTrailingCommaPos.value !== -1) {
  10187. this.addExtra(node, "trailingComma", refTrailingCommaPos.value);
  10188. }
  10189. return this.finishNode(node, "TSTypeParameterDeclaration");
  10190. }
  10191. tsFillSignature(returnToken, signature) {
  10192. const returnTokenRequired = returnToken === 19;
  10193. const paramsKey = "parameters";
  10194. const returnTypeKey = "typeAnnotation";
  10195. signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  10196. this.expect(10);
  10197. signature[paramsKey] = this.tsParseBindingListForSignature();
  10198. if (returnTokenRequired) {
  10199. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10200. } else if (this.match(returnToken)) {
  10201. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10202. }
  10203. }
  10204. tsParseBindingListForSignature() {
  10205. const list = super.parseBindingList(11, 41, 2);
  10206. for (const pattern of list) {
  10207. const {
  10208. type
  10209. } = pattern;
  10210. if (type === "AssignmentPattern" || type === "TSParameterProperty") {
  10211. this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, {
  10212. type
  10213. });
  10214. }
  10215. }
  10216. return list;
  10217. }
  10218. tsParseTypeMemberSemicolon() {
  10219. if (!this.eat(12) && !this.isLineTerminator()) {
  10220. this.expect(13);
  10221. }
  10222. }
  10223. tsParseSignatureMember(kind, node) {
  10224. this.tsFillSignature(14, node);
  10225. this.tsParseTypeMemberSemicolon();
  10226. return this.finishNode(node, kind);
  10227. }
  10228. tsIsUnambiguouslyIndexSignature() {
  10229. this.next();
  10230. if (tokenIsIdentifier(this.state.type)) {
  10231. this.next();
  10232. return this.match(14);
  10233. }
  10234. return false;
  10235. }
  10236. tsTryParseIndexSignature(node) {
  10237. if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  10238. return;
  10239. }
  10240. this.expect(0);
  10241. const id = this.parseIdentifier();
  10242. id.typeAnnotation = this.tsParseTypeAnnotation();
  10243. this.resetEndLocation(id);
  10244. this.expect(3);
  10245. node.parameters = [id];
  10246. const type = this.tsTryParseTypeAnnotation();
  10247. if (type) node.typeAnnotation = type;
  10248. this.tsParseTypeMemberSemicolon();
  10249. return this.finishNode(node, "TSIndexSignature");
  10250. }
  10251. tsParsePropertyOrMethodSignature(node, readonly) {
  10252. if (this.eat(17)) node.optional = true;
  10253. const nodeAny = node;
  10254. if (this.match(10) || this.match(47)) {
  10255. if (readonly) {
  10256. this.raise(TSErrors.ReadonlyForMethodSignature, node);
  10257. }
  10258. const method = nodeAny;
  10259. if (method.kind && this.match(47)) {
  10260. this.raise(TSErrors.AccesorCannotHaveTypeParameters, this.state.curPosition());
  10261. }
  10262. this.tsFillSignature(14, method);
  10263. this.tsParseTypeMemberSemicolon();
  10264. const paramsKey = "parameters";
  10265. const returnTypeKey = "typeAnnotation";
  10266. if (method.kind === "get") {
  10267. if (method[paramsKey].length > 0) {
  10268. this.raise(Errors.BadGetterArity, this.state.curPosition());
  10269. if (this.isThisParam(method[paramsKey][0])) {
  10270. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10271. }
  10272. }
  10273. } else if (method.kind === "set") {
  10274. if (method[paramsKey].length !== 1) {
  10275. this.raise(Errors.BadSetterArity, this.state.curPosition());
  10276. } else {
  10277. const firstParameter = method[paramsKey][0];
  10278. if (this.isThisParam(firstParameter)) {
  10279. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10280. }
  10281. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  10282. this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, this.state.curPosition());
  10283. }
  10284. if (firstParameter.type === "RestElement") {
  10285. this.raise(TSErrors.SetAccesorCannotHaveRestParameter, this.state.curPosition());
  10286. }
  10287. }
  10288. if (method[returnTypeKey]) {
  10289. this.raise(TSErrors.SetAccesorCannotHaveReturnType, method[returnTypeKey]);
  10290. }
  10291. } else {
  10292. method.kind = "method";
  10293. }
  10294. return this.finishNode(method, "TSMethodSignature");
  10295. } else {
  10296. const property = nodeAny;
  10297. if (readonly) property.readonly = true;
  10298. const type = this.tsTryParseTypeAnnotation();
  10299. if (type) property.typeAnnotation = type;
  10300. this.tsParseTypeMemberSemicolon();
  10301. return this.finishNode(property, "TSPropertySignature");
  10302. }
  10303. }
  10304. tsParseTypeMember() {
  10305. const node = this.startNode();
  10306. if (this.match(10) || this.match(47)) {
  10307. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  10308. }
  10309. if (this.match(77)) {
  10310. const id = this.startNode();
  10311. this.next();
  10312. if (this.match(10) || this.match(47)) {
  10313. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  10314. } else {
  10315. node.key = this.createIdentifier(id, "new");
  10316. return this.tsParsePropertyOrMethodSignature(node, false);
  10317. }
  10318. }
  10319. this.tsParseModifiers({
  10320. allowedModifiers: ["readonly"],
  10321. disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"]
  10322. }, node);
  10323. const idx = this.tsTryParseIndexSignature(node);
  10324. if (idx) {
  10325. return idx;
  10326. }
  10327. super.parsePropertyName(node);
  10328. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  10329. node.kind = node.key.name;
  10330. super.parsePropertyName(node);
  10331. }
  10332. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  10333. }
  10334. tsParseTypeLiteral() {
  10335. const node = this.startNode();
  10336. node.members = this.tsParseObjectTypeMembers();
  10337. return this.finishNode(node, "TSTypeLiteral");
  10338. }
  10339. tsParseObjectTypeMembers() {
  10340. this.expect(5);
  10341. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  10342. this.expect(8);
  10343. return members;
  10344. }
  10345. tsIsStartOfMappedType() {
  10346. this.next();
  10347. if (this.eat(53)) {
  10348. return this.isContextual(122);
  10349. }
  10350. if (this.isContextual(122)) {
  10351. this.next();
  10352. }
  10353. if (!this.match(0)) {
  10354. return false;
  10355. }
  10356. this.next();
  10357. if (!this.tsIsIdentifier()) {
  10358. return false;
  10359. }
  10360. this.next();
  10361. return this.match(58);
  10362. }
  10363. tsParseMappedTypeParameter() {
  10364. const node = this.startNode();
  10365. node.name = this.tsParseTypeParameterName();
  10366. node.constraint = this.tsExpectThenParseType(58);
  10367. return this.finishNode(node, "TSTypeParameter");
  10368. }
  10369. tsParseMappedType() {
  10370. const node = this.startNode();
  10371. this.expect(5);
  10372. if (this.match(53)) {
  10373. node.readonly = this.state.value;
  10374. this.next();
  10375. this.expectContextual(122);
  10376. } else if (this.eatContextual(122)) {
  10377. node.readonly = true;
  10378. }
  10379. this.expect(0);
  10380. node.typeParameter = this.tsParseMappedTypeParameter();
  10381. node.nameType = this.eatContextual(93) ? this.tsParseType() : null;
  10382. this.expect(3);
  10383. if (this.match(53)) {
  10384. node.optional = this.state.value;
  10385. this.next();
  10386. this.expect(17);
  10387. } else if (this.eat(17)) {
  10388. node.optional = true;
  10389. }
  10390. node.typeAnnotation = this.tsTryParseType();
  10391. this.semicolon();
  10392. this.expect(8);
  10393. return this.finishNode(node, "TSMappedType");
  10394. }
  10395. tsParseTupleType() {
  10396. const node = this.startNode();
  10397. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  10398. let seenOptionalElement = false;
  10399. node.elementTypes.forEach(elementNode => {
  10400. const {
  10401. type
  10402. } = elementNode;
  10403. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  10404. this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode);
  10405. }
  10406. seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType");
  10407. });
  10408. return this.finishNode(node, "TSTupleType");
  10409. }
  10410. tsParseTupleElementType() {
  10411. const {
  10412. startLoc
  10413. } = this.state;
  10414. const rest = this.eat(21);
  10415. let labeled;
  10416. let label;
  10417. let optional;
  10418. let type;
  10419. const isWord = tokenIsKeywordOrIdentifier(this.state.type);
  10420. const chAfterWord = isWord ? this.lookaheadCharCode() : null;
  10421. if (chAfterWord === 58) {
  10422. labeled = true;
  10423. optional = false;
  10424. label = this.parseIdentifier(true);
  10425. this.expect(14);
  10426. type = this.tsParseType();
  10427. } else if (chAfterWord === 63) {
  10428. optional = true;
  10429. const startLoc = this.state.startLoc;
  10430. const wordName = this.state.value;
  10431. const typeOrLabel = this.tsParseNonArrayType();
  10432. if (this.lookaheadCharCode() === 58) {
  10433. labeled = true;
  10434. label = this.createIdentifier(this.startNodeAt(startLoc), wordName);
  10435. this.expect(17);
  10436. this.expect(14);
  10437. type = this.tsParseType();
  10438. } else {
  10439. labeled = false;
  10440. type = typeOrLabel;
  10441. this.expect(17);
  10442. }
  10443. } else {
  10444. type = this.tsParseType();
  10445. optional = this.eat(17);
  10446. labeled = this.eat(14);
  10447. }
  10448. if (labeled) {
  10449. let labeledNode;
  10450. if (label) {
  10451. labeledNode = this.startNodeAtNode(label);
  10452. labeledNode.optional = optional;
  10453. labeledNode.label = label;
  10454. labeledNode.elementType = type;
  10455. if (this.eat(17)) {
  10456. labeledNode.optional = true;
  10457. this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc);
  10458. }
  10459. } else {
  10460. labeledNode = this.startNodeAtNode(type);
  10461. labeledNode.optional = optional;
  10462. this.raise(TSErrors.InvalidTupleMemberLabel, type);
  10463. labeledNode.label = type;
  10464. labeledNode.elementType = this.tsParseType();
  10465. }
  10466. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  10467. } else if (optional) {
  10468. const optionalTypeNode = this.startNodeAtNode(type);
  10469. optionalTypeNode.typeAnnotation = type;
  10470. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  10471. }
  10472. if (rest) {
  10473. const restNode = this.startNodeAt(startLoc);
  10474. restNode.typeAnnotation = type;
  10475. type = this.finishNode(restNode, "TSRestType");
  10476. }
  10477. return type;
  10478. }
  10479. tsParseParenthesizedType() {
  10480. const node = this.startNode();
  10481. this.expect(10);
  10482. node.typeAnnotation = this.tsParseType();
  10483. this.expect(11);
  10484. return this.finishNode(node, "TSParenthesizedType");
  10485. }
  10486. tsParseFunctionOrConstructorType(type, abstract) {
  10487. const node = this.startNode();
  10488. if (type === "TSConstructorType") {
  10489. node.abstract = !!abstract;
  10490. if (abstract) this.next();
  10491. this.next();
  10492. }
  10493. this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
  10494. return this.finishNode(node, type);
  10495. }
  10496. tsParseLiteralTypeNode() {
  10497. const node = this.startNode();
  10498. switch (this.state.type) {
  10499. case 134:
  10500. case 135:
  10501. case 133:
  10502. case 85:
  10503. case 86:
  10504. node.literal = super.parseExprAtom();
  10505. break;
  10506. default:
  10507. this.unexpected();
  10508. }
  10509. return this.finishNode(node, "TSLiteralType");
  10510. }
  10511. tsParseTemplateLiteralType() {
  10512. const node = this.startNode();
  10513. node.literal = super.parseTemplate(false);
  10514. return this.finishNode(node, "TSLiteralType");
  10515. }
  10516. parseTemplateSubstitution() {
  10517. if (this.state.inType) return this.tsParseType();
  10518. return super.parseTemplateSubstitution();
  10519. }
  10520. tsParseThisTypeOrThisTypePredicate() {
  10521. const thisKeyword = this.tsParseThisTypeNode();
  10522. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10523. return this.tsParseThisTypePredicate(thisKeyword);
  10524. } else {
  10525. return thisKeyword;
  10526. }
  10527. }
  10528. tsParseNonArrayType() {
  10529. switch (this.state.type) {
  10530. case 133:
  10531. case 134:
  10532. case 135:
  10533. case 85:
  10534. case 86:
  10535. return this.tsParseLiteralTypeNode();
  10536. case 53:
  10537. if (this.state.value === "-") {
  10538. const node = this.startNode();
  10539. const nextToken = this.lookahead();
  10540. if (nextToken.type !== 134 && nextToken.type !== 135) {
  10541. this.unexpected();
  10542. }
  10543. node.literal = this.parseMaybeUnary();
  10544. return this.finishNode(node, "TSLiteralType");
  10545. }
  10546. break;
  10547. case 78:
  10548. return this.tsParseThisTypeOrThisTypePredicate();
  10549. case 87:
  10550. return this.tsParseTypeQuery();
  10551. case 83:
  10552. return this.tsParseImportType();
  10553. case 5:
  10554. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  10555. case 0:
  10556. return this.tsParseTupleType();
  10557. case 10:
  10558. return this.tsParseParenthesizedType();
  10559. case 25:
  10560. case 24:
  10561. return this.tsParseTemplateLiteralType();
  10562. default:
  10563. {
  10564. const {
  10565. type
  10566. } = this.state;
  10567. if (tokenIsIdentifier(type) || type === 88 || type === 84) {
  10568. const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  10569. if (nodeType !== undefined && this.lookaheadCharCode() !== 46) {
  10570. const node = this.startNode();
  10571. this.next();
  10572. return this.finishNode(node, nodeType);
  10573. }
  10574. return this.tsParseTypeReference();
  10575. }
  10576. }
  10577. }
  10578. this.unexpected();
  10579. }
  10580. tsParseArrayTypeOrHigher() {
  10581. let type = this.tsParseNonArrayType();
  10582. while (!this.hasPrecedingLineBreak() && this.eat(0)) {
  10583. if (this.match(3)) {
  10584. const node = this.startNodeAtNode(type);
  10585. node.elementType = type;
  10586. this.expect(3);
  10587. type = this.finishNode(node, "TSArrayType");
  10588. } else {
  10589. const node = this.startNodeAtNode(type);
  10590. node.objectType = type;
  10591. node.indexType = this.tsParseType();
  10592. this.expect(3);
  10593. type = this.finishNode(node, "TSIndexedAccessType");
  10594. }
  10595. }
  10596. return type;
  10597. }
  10598. tsParseTypeOperator() {
  10599. const node = this.startNode();
  10600. const operator = this.state.value;
  10601. this.next();
  10602. node.operator = operator;
  10603. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  10604. if (operator === "readonly") {
  10605. this.tsCheckTypeAnnotationForReadOnly(node);
  10606. }
  10607. return this.finishNode(node, "TSTypeOperator");
  10608. }
  10609. tsCheckTypeAnnotationForReadOnly(node) {
  10610. switch (node.typeAnnotation.type) {
  10611. case "TSTupleType":
  10612. case "TSArrayType":
  10613. return;
  10614. default:
  10615. this.raise(TSErrors.UnexpectedReadonly, node);
  10616. }
  10617. }
  10618. tsParseInferType() {
  10619. const node = this.startNode();
  10620. this.expectContextual(115);
  10621. const typeParameter = this.startNode();
  10622. typeParameter.name = this.tsParseTypeParameterName();
  10623. typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
  10624. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10625. return this.finishNode(node, "TSInferType");
  10626. }
  10627. tsParseConstraintForInferType() {
  10628. if (this.eat(81)) {
  10629. const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
  10630. if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
  10631. return constraint;
  10632. }
  10633. }
  10634. }
  10635. tsParseTypeOperatorOrHigher() {
  10636. const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
  10637. return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
  10638. }
  10639. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  10640. const node = this.startNode();
  10641. const hasLeadingOperator = this.eat(operator);
  10642. const types = [];
  10643. do {
  10644. types.push(parseConstituentType());
  10645. } while (this.eat(operator));
  10646. if (types.length === 1 && !hasLeadingOperator) {
  10647. return types[0];
  10648. }
  10649. node.types = types;
  10650. return this.finishNode(node, kind);
  10651. }
  10652. tsParseIntersectionTypeOrHigher() {
  10653. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45);
  10654. }
  10655. tsParseUnionTypeOrHigher() {
  10656. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43);
  10657. }
  10658. tsIsStartOfFunctionType() {
  10659. if (this.match(47)) {
  10660. return true;
  10661. }
  10662. return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  10663. }
  10664. tsSkipParameterStart() {
  10665. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  10666. this.next();
  10667. return true;
  10668. }
  10669. if (this.match(5)) {
  10670. const {
  10671. errors
  10672. } = this.state;
  10673. const previousErrorCount = errors.length;
  10674. try {
  10675. this.parseObjectLike(8, true);
  10676. return errors.length === previousErrorCount;
  10677. } catch (_unused) {
  10678. return false;
  10679. }
  10680. }
  10681. if (this.match(0)) {
  10682. this.next();
  10683. const {
  10684. errors
  10685. } = this.state;
  10686. const previousErrorCount = errors.length;
  10687. try {
  10688. super.parseBindingList(3, 93, 1);
  10689. return errors.length === previousErrorCount;
  10690. } catch (_unused2) {
  10691. return false;
  10692. }
  10693. }
  10694. return false;
  10695. }
  10696. tsIsUnambiguouslyStartOfFunctionType() {
  10697. this.next();
  10698. if (this.match(11) || this.match(21)) {
  10699. return true;
  10700. }
  10701. if (this.tsSkipParameterStart()) {
  10702. if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) {
  10703. return true;
  10704. }
  10705. if (this.match(11)) {
  10706. this.next();
  10707. if (this.match(19)) {
  10708. return true;
  10709. }
  10710. }
  10711. }
  10712. return false;
  10713. }
  10714. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  10715. return this.tsInType(() => {
  10716. const t = this.startNode();
  10717. this.expect(returnToken);
  10718. const node = this.startNode();
  10719. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  10720. if (asserts && this.match(78)) {
  10721. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  10722. if (thisTypePredicate.type === "TSThisType") {
  10723. node.parameterName = thisTypePredicate;
  10724. node.asserts = true;
  10725. node.typeAnnotation = null;
  10726. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  10727. } else {
  10728. this.resetStartLocationFromNode(thisTypePredicate, node);
  10729. thisTypePredicate.asserts = true;
  10730. }
  10731. t.typeAnnotation = thisTypePredicate;
  10732. return this.finishNode(t, "TSTypeAnnotation");
  10733. }
  10734. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  10735. if (!typePredicateVariable) {
  10736. if (!asserts) {
  10737. return this.tsParseTypeAnnotation(false, t);
  10738. }
  10739. node.parameterName = this.parseIdentifier();
  10740. node.asserts = asserts;
  10741. node.typeAnnotation = null;
  10742. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10743. return this.finishNode(t, "TSTypeAnnotation");
  10744. }
  10745. const type = this.tsParseTypeAnnotation(false);
  10746. node.parameterName = typePredicateVariable;
  10747. node.typeAnnotation = type;
  10748. node.asserts = asserts;
  10749. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10750. return this.finishNode(t, "TSTypeAnnotation");
  10751. });
  10752. }
  10753. tsTryParseTypeOrTypePredicateAnnotation() {
  10754. if (this.match(14)) {
  10755. return this.tsParseTypeOrTypePredicateAnnotation(14);
  10756. }
  10757. }
  10758. tsTryParseTypeAnnotation() {
  10759. if (this.match(14)) {
  10760. return this.tsParseTypeAnnotation();
  10761. }
  10762. }
  10763. tsTryParseType() {
  10764. return this.tsEatThenParseType(14);
  10765. }
  10766. tsParseTypePredicatePrefix() {
  10767. const id = this.parseIdentifier();
  10768. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10769. this.next();
  10770. return id;
  10771. }
  10772. }
  10773. tsParseTypePredicateAsserts() {
  10774. if (this.state.type !== 109) {
  10775. return false;
  10776. }
  10777. const containsEsc = this.state.containsEsc;
  10778. this.next();
  10779. if (!tokenIsIdentifier(this.state.type) && !this.match(78)) {
  10780. return false;
  10781. }
  10782. if (containsEsc) {
  10783. this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, {
  10784. reservedWord: "asserts"
  10785. });
  10786. }
  10787. return true;
  10788. }
  10789. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  10790. this.tsInType(() => {
  10791. if (eatColon) this.expect(14);
  10792. t.typeAnnotation = this.tsParseType();
  10793. });
  10794. return this.finishNode(t, "TSTypeAnnotation");
  10795. }
  10796. tsParseType() {
  10797. assert(this.state.inType);
  10798. const type = this.tsParseNonConditionalType();
  10799. if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
  10800. return type;
  10801. }
  10802. const node = this.startNodeAtNode(type);
  10803. node.checkType = type;
  10804. node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
  10805. this.expect(17);
  10806. node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10807. this.expect(14);
  10808. node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10809. return this.finishNode(node, "TSConditionalType");
  10810. }
  10811. isAbstractConstructorSignature() {
  10812. return this.isContextual(124) && this.lookahead().type === 77;
  10813. }
  10814. tsParseNonConditionalType() {
  10815. if (this.tsIsStartOfFunctionType()) {
  10816. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  10817. }
  10818. if (this.match(77)) {
  10819. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  10820. } else if (this.isAbstractConstructorSignature()) {
  10821. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  10822. }
  10823. return this.tsParseUnionTypeOrHigher();
  10824. }
  10825. tsParseTypeAssertion() {
  10826. if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  10827. this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc);
  10828. }
  10829. const node = this.startNode();
  10830. node.typeAnnotation = this.tsInType(() => {
  10831. this.next();
  10832. return this.match(75) ? this.tsParseTypeReference() : this.tsParseType();
  10833. });
  10834. this.expect(48);
  10835. node.expression = this.parseMaybeUnary();
  10836. return this.finishNode(node, "TSTypeAssertion");
  10837. }
  10838. tsParseHeritageClause(token) {
  10839. const originalStartLoc = this.state.startLoc;
  10840. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
  10841. const node = this.startNode();
  10842. node.expression = this.tsParseEntityName();
  10843. if (this.match(47)) {
  10844. node.typeParameters = this.tsParseTypeArguments();
  10845. }
  10846. return this.finishNode(node, "TSExpressionWithTypeArguments");
  10847. });
  10848. if (!delimitedList.length) {
  10849. this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
  10850. token
  10851. });
  10852. }
  10853. return delimitedList;
  10854. }
  10855. tsParseInterfaceDeclaration(node, properties = {}) {
  10856. if (this.hasFollowingLineBreak()) return null;
  10857. this.expectContextual(129);
  10858. if (properties.declare) node.declare = true;
  10859. if (tokenIsIdentifier(this.state.type)) {
  10860. node.id = this.parseIdentifier();
  10861. this.checkIdentifier(node.id, 130);
  10862. } else {
  10863. node.id = null;
  10864. this.raise(TSErrors.MissingInterfaceName, this.state.startLoc);
  10865. }
  10866. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  10867. if (this.eat(81)) {
  10868. node.extends = this.tsParseHeritageClause("extends");
  10869. }
  10870. const body = this.startNode();
  10871. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  10872. node.body = this.finishNode(body, "TSInterfaceBody");
  10873. return this.finishNode(node, "TSInterfaceDeclaration");
  10874. }
  10875. tsParseTypeAliasDeclaration(node) {
  10876. node.id = this.parseIdentifier();
  10877. this.checkIdentifier(node.id, 2);
  10878. node.typeAnnotation = this.tsInType(() => {
  10879. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
  10880. this.expect(29);
  10881. if (this.isContextual(114) && this.lookahead().type !== 16) {
  10882. const node = this.startNode();
  10883. this.next();
  10884. return this.finishNode(node, "TSIntrinsicKeyword");
  10885. }
  10886. return this.tsParseType();
  10887. });
  10888. this.semicolon();
  10889. return this.finishNode(node, "TSTypeAliasDeclaration");
  10890. }
  10891. tsInNoContext(cb) {
  10892. const oldContext = this.state.context;
  10893. this.state.context = [oldContext[0]];
  10894. try {
  10895. return cb();
  10896. } finally {
  10897. this.state.context = oldContext;
  10898. }
  10899. }
  10900. tsInType(cb) {
  10901. const oldInType = this.state.inType;
  10902. this.state.inType = true;
  10903. try {
  10904. return cb();
  10905. } finally {
  10906. this.state.inType = oldInType;
  10907. }
  10908. }
  10909. tsInDisallowConditionalTypesContext(cb) {
  10910. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10911. this.state.inDisallowConditionalTypesContext = true;
  10912. try {
  10913. return cb();
  10914. } finally {
  10915. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10916. }
  10917. }
  10918. tsInAllowConditionalTypesContext(cb) {
  10919. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10920. this.state.inDisallowConditionalTypesContext = false;
  10921. try {
  10922. return cb();
  10923. } finally {
  10924. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10925. }
  10926. }
  10927. tsEatThenParseType(token) {
  10928. if (this.match(token)) {
  10929. return this.tsNextThenParseType();
  10930. }
  10931. }
  10932. tsExpectThenParseType(token) {
  10933. return this.tsInType(() => {
  10934. this.expect(token);
  10935. return this.tsParseType();
  10936. });
  10937. }
  10938. tsNextThenParseType() {
  10939. return this.tsInType(() => {
  10940. this.next();
  10941. return this.tsParseType();
  10942. });
  10943. }
  10944. tsParseEnumMember() {
  10945. const node = this.startNode();
  10946. node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
  10947. if (this.eat(29)) {
  10948. node.initializer = super.parseMaybeAssignAllowIn();
  10949. }
  10950. return this.finishNode(node, "TSEnumMember");
  10951. }
  10952. tsParseEnumDeclaration(node, properties = {}) {
  10953. if (properties.const) node.const = true;
  10954. if (properties.declare) node.declare = true;
  10955. this.expectContextual(126);
  10956. node.id = this.parseIdentifier();
  10957. this.checkIdentifier(node.id, node.const ? 8971 : 8459);
  10958. this.expect(5);
  10959. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  10960. this.expect(8);
  10961. return this.finishNode(node, "TSEnumDeclaration");
  10962. }
  10963. tsParseModuleBlock() {
  10964. const node = this.startNode();
  10965. this.scope.enter(0);
  10966. this.expect(5);
  10967. super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8);
  10968. this.scope.exit();
  10969. return this.finishNode(node, "TSModuleBlock");
  10970. }
  10971. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  10972. node.id = this.parseIdentifier();
  10973. if (!nested) {
  10974. this.checkIdentifier(node.id, 1024);
  10975. }
  10976. if (this.eat(16)) {
  10977. const inner = this.startNode();
  10978. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  10979. node.body = inner;
  10980. } else {
  10981. this.scope.enter(256);
  10982. this.prodParam.enter(0);
  10983. node.body = this.tsParseModuleBlock();
  10984. this.prodParam.exit();
  10985. this.scope.exit();
  10986. }
  10987. return this.finishNode(node, "TSModuleDeclaration");
  10988. }
  10989. tsParseAmbientExternalModuleDeclaration(node) {
  10990. if (this.isContextual(112)) {
  10991. node.global = true;
  10992. node.id = this.parseIdentifier();
  10993. } else if (this.match(133)) {
  10994. node.id = super.parseStringLiteral(this.state.value);
  10995. } else {
  10996. this.unexpected();
  10997. }
  10998. if (this.match(5)) {
  10999. this.scope.enter(256);
  11000. this.prodParam.enter(0);
  11001. node.body = this.tsParseModuleBlock();
  11002. this.prodParam.exit();
  11003. this.scope.exit();
  11004. } else {
  11005. this.semicolon();
  11006. }
  11007. return this.finishNode(node, "TSModuleDeclaration");
  11008. }
  11009. tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) {
  11010. node.isExport = isExport || false;
  11011. node.id = maybeDefaultIdentifier || this.parseIdentifier();
  11012. this.checkIdentifier(node.id, 4096);
  11013. this.expect(29);
  11014. const moduleReference = this.tsParseModuleReference();
  11015. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  11016. this.raise(TSErrors.ImportAliasHasImportType, moduleReference);
  11017. }
  11018. node.moduleReference = moduleReference;
  11019. this.semicolon();
  11020. return this.finishNode(node, "TSImportEqualsDeclaration");
  11021. }
  11022. tsIsExternalModuleReference() {
  11023. return this.isContextual(119) && this.lookaheadCharCode() === 40;
  11024. }
  11025. tsParseModuleReference() {
  11026. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
  11027. }
  11028. tsParseExternalModuleReference() {
  11029. const node = this.startNode();
  11030. this.expectContextual(119);
  11031. this.expect(10);
  11032. if (!this.match(133)) {
  11033. this.unexpected();
  11034. }
  11035. node.expression = super.parseExprAtom();
  11036. this.expect(11);
  11037. this.sawUnambiguousESM = true;
  11038. return this.finishNode(node, "TSExternalModuleReference");
  11039. }
  11040. tsLookAhead(f) {
  11041. const state = this.state.clone();
  11042. const res = f();
  11043. this.state = state;
  11044. return res;
  11045. }
  11046. tsTryParseAndCatch(f) {
  11047. const result = this.tryParse(abort => f() || abort());
  11048. if (result.aborted || !result.node) return;
  11049. if (result.error) this.state = result.failState;
  11050. return result.node;
  11051. }
  11052. tsTryParse(f) {
  11053. const state = this.state.clone();
  11054. const result = f();
  11055. if (result !== undefined && result !== false) {
  11056. return result;
  11057. }
  11058. this.state = state;
  11059. }
  11060. tsTryParseDeclare(nany) {
  11061. if (this.isLineTerminator()) {
  11062. return;
  11063. }
  11064. let startType = this.state.type;
  11065. let kind;
  11066. if (this.isContextual(100)) {
  11067. startType = 74;
  11068. kind = "let";
  11069. }
  11070. return this.tsInAmbientContext(() => {
  11071. switch (startType) {
  11072. case 68:
  11073. nany.declare = true;
  11074. return super.parseFunctionStatement(nany, false, false);
  11075. case 80:
  11076. nany.declare = true;
  11077. return this.parseClass(nany, true, false);
  11078. case 126:
  11079. return this.tsParseEnumDeclaration(nany, {
  11080. declare: true
  11081. });
  11082. case 112:
  11083. return this.tsParseAmbientExternalModuleDeclaration(nany);
  11084. case 75:
  11085. case 74:
  11086. if (!this.match(75) || !this.isLookaheadContextual("enum")) {
  11087. nany.declare = true;
  11088. return this.parseVarStatement(nany, kind || this.state.value, true);
  11089. }
  11090. this.expect(75);
  11091. return this.tsParseEnumDeclaration(nany, {
  11092. const: true,
  11093. declare: true
  11094. });
  11095. case 129:
  11096. {
  11097. const result = this.tsParseInterfaceDeclaration(nany, {
  11098. declare: true
  11099. });
  11100. if (result) return result;
  11101. }
  11102. default:
  11103. if (tokenIsIdentifier(startType)) {
  11104. return this.tsParseDeclaration(nany, this.state.value, true, null);
  11105. }
  11106. }
  11107. });
  11108. }
  11109. tsTryParseExportDeclaration() {
  11110. return this.tsParseDeclaration(this.startNode(), this.state.value, true, null);
  11111. }
  11112. tsParseExpressionStatement(node, expr, decorators) {
  11113. switch (expr.name) {
  11114. case "declare":
  11115. {
  11116. const declaration = this.tsTryParseDeclare(node);
  11117. if (declaration) {
  11118. declaration.declare = true;
  11119. }
  11120. return declaration;
  11121. }
  11122. case "global":
  11123. if (this.match(5)) {
  11124. this.scope.enter(256);
  11125. this.prodParam.enter(0);
  11126. const mod = node;
  11127. mod.global = true;
  11128. mod.id = expr;
  11129. mod.body = this.tsParseModuleBlock();
  11130. this.scope.exit();
  11131. this.prodParam.exit();
  11132. return this.finishNode(mod, "TSModuleDeclaration");
  11133. }
  11134. break;
  11135. default:
  11136. return this.tsParseDeclaration(node, expr.name, false, decorators);
  11137. }
  11138. }
  11139. tsParseDeclaration(node, value, next, decorators) {
  11140. switch (value) {
  11141. case "abstract":
  11142. if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
  11143. return this.tsParseAbstractDeclaration(node, decorators);
  11144. }
  11145. break;
  11146. case "module":
  11147. if (this.tsCheckLineTerminator(next)) {
  11148. if (this.match(133)) {
  11149. return this.tsParseAmbientExternalModuleDeclaration(node);
  11150. } else if (tokenIsIdentifier(this.state.type)) {
  11151. return this.tsParseModuleOrNamespaceDeclaration(node);
  11152. }
  11153. }
  11154. break;
  11155. case "namespace":
  11156. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11157. return this.tsParseModuleOrNamespaceDeclaration(node);
  11158. }
  11159. break;
  11160. case "type":
  11161. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11162. return this.tsParseTypeAliasDeclaration(node);
  11163. }
  11164. break;
  11165. }
  11166. }
  11167. tsCheckLineTerminator(next) {
  11168. if (next) {
  11169. if (this.hasFollowingLineBreak()) return false;
  11170. this.next();
  11171. return true;
  11172. }
  11173. return !this.isLineTerminator();
  11174. }
  11175. tsTryParseGenericAsyncArrowFunction(startLoc) {
  11176. if (!this.match(47)) return;
  11177. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  11178. this.state.maybeInArrowParameters = true;
  11179. const res = this.tsTryParseAndCatch(() => {
  11180. const node = this.startNodeAt(startLoc);
  11181. node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11182. super.parseFunctionParams(node);
  11183. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  11184. this.expect(19);
  11185. return node;
  11186. });
  11187. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  11188. if (!res) return;
  11189. return super.parseArrowExpression(res, null, true);
  11190. }
  11191. tsParseTypeArgumentsInExpression() {
  11192. if (this.reScan_lt() !== 47) return;
  11193. return this.tsParseTypeArguments();
  11194. }
  11195. tsParseTypeArguments() {
  11196. const node = this.startNode();
  11197. node.params = this.tsInType(() => this.tsInNoContext(() => {
  11198. this.expect(47);
  11199. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  11200. }));
  11201. if (node.params.length === 0) {
  11202. this.raise(TSErrors.EmptyTypeArguments, node);
  11203. } else if (!this.state.inType && this.curContext() === types.brace) {
  11204. this.reScan_lt_gt();
  11205. }
  11206. this.expect(48);
  11207. return this.finishNode(node, "TSTypeParameterInstantiation");
  11208. }
  11209. tsIsDeclarationStart() {
  11210. return tokenIsTSDeclarationStart(this.state.type);
  11211. }
  11212. isExportDefaultSpecifier() {
  11213. if (this.tsIsDeclarationStart()) return false;
  11214. return super.isExportDefaultSpecifier();
  11215. }
  11216. parseAssignableListItem(flags, decorators) {
  11217. const startLoc = this.state.startLoc;
  11218. const modified = {};
  11219. this.tsParseModifiers({
  11220. allowedModifiers: ["public", "private", "protected", "override", "readonly"]
  11221. }, modified);
  11222. const accessibility = modified.accessibility;
  11223. const override = modified.override;
  11224. const readonly = modified.readonly;
  11225. if (!(flags & 4) && (accessibility || readonly || override)) {
  11226. this.raise(TSErrors.UnexpectedParameterModifier, startLoc);
  11227. }
  11228. const left = this.parseMaybeDefault();
  11229. this.parseAssignableListItemTypes(left, flags);
  11230. const elt = this.parseMaybeDefault(left.loc.start, left);
  11231. if (accessibility || readonly || override) {
  11232. const pp = this.startNodeAt(startLoc);
  11233. if (decorators.length) {
  11234. pp.decorators = decorators;
  11235. }
  11236. if (accessibility) pp.accessibility = accessibility;
  11237. if (readonly) pp.readonly = readonly;
  11238. if (override) pp.override = override;
  11239. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  11240. this.raise(TSErrors.UnsupportedParameterPropertyKind, pp);
  11241. }
  11242. pp.parameter = elt;
  11243. return this.finishNode(pp, "TSParameterProperty");
  11244. }
  11245. if (decorators.length) {
  11246. left.decorators = decorators;
  11247. }
  11248. return elt;
  11249. }
  11250. isSimpleParameter(node) {
  11251. return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node);
  11252. }
  11253. tsDisallowOptionalPattern(node) {
  11254. for (const param of node.params) {
  11255. if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) {
  11256. this.raise(TSErrors.PatternIsOptional, param);
  11257. }
  11258. }
  11259. }
  11260. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  11261. super.setArrowFunctionParameters(node, params, trailingCommaLoc);
  11262. this.tsDisallowOptionalPattern(node);
  11263. }
  11264. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  11265. if (this.match(14)) {
  11266. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11267. }
  11268. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined;
  11269. if (bodilessType && !this.match(5) && this.isLineTerminator()) {
  11270. return this.finishNode(node, bodilessType);
  11271. }
  11272. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  11273. this.raise(TSErrors.DeclareFunctionHasImplementation, node);
  11274. if (node.declare) {
  11275. return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  11276. }
  11277. }
  11278. this.tsDisallowOptionalPattern(node);
  11279. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  11280. }
  11281. registerFunctionStatementId(node) {
  11282. if (!node.body && node.id) {
  11283. this.checkIdentifier(node.id, 1024);
  11284. } else {
  11285. super.registerFunctionStatementId(node);
  11286. }
  11287. }
  11288. tsCheckForInvalidTypeCasts(items) {
  11289. items.forEach(node => {
  11290. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  11291. this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation);
  11292. }
  11293. });
  11294. }
  11295. toReferencedList(exprList, isInParens) {
  11296. this.tsCheckForInvalidTypeCasts(exprList);
  11297. return exprList;
  11298. }
  11299. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  11300. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  11301. if (node.type === "ArrayExpression") {
  11302. this.tsCheckForInvalidTypeCasts(node.elements);
  11303. }
  11304. return node;
  11305. }
  11306. parseSubscript(base, startLoc, noCalls, state) {
  11307. if (!this.hasPrecedingLineBreak() && this.match(35)) {
  11308. this.state.canStartJSXElement = false;
  11309. this.next();
  11310. const nonNullExpression = this.startNodeAt(startLoc);
  11311. nonNullExpression.expression = base;
  11312. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  11313. }
  11314. let isOptionalCall = false;
  11315. if (this.match(18) && this.lookaheadCharCode() === 60) {
  11316. if (noCalls) {
  11317. state.stop = true;
  11318. return base;
  11319. }
  11320. state.optionalChainMember = isOptionalCall = true;
  11321. this.next();
  11322. }
  11323. if (this.match(47) || this.match(51)) {
  11324. let missingParenErrorLoc;
  11325. const result = this.tsTryParseAndCatch(() => {
  11326. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  11327. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
  11328. if (asyncArrowFn) {
  11329. return asyncArrowFn;
  11330. }
  11331. }
  11332. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11333. if (!typeArguments) return;
  11334. if (isOptionalCall && !this.match(10)) {
  11335. missingParenErrorLoc = this.state.curPosition();
  11336. return;
  11337. }
  11338. if (tokenIsTemplate(this.state.type)) {
  11339. const result = super.parseTaggedTemplateExpression(base, startLoc, state);
  11340. result.typeParameters = typeArguments;
  11341. return result;
  11342. }
  11343. if (!noCalls && this.eat(10)) {
  11344. const node = this.startNodeAt(startLoc);
  11345. node.callee = base;
  11346. node.arguments = this.parseCallExpressionArguments(11, false);
  11347. this.tsCheckForInvalidTypeCasts(node.arguments);
  11348. node.typeParameters = typeArguments;
  11349. if (state.optionalChainMember) {
  11350. node.optional = isOptionalCall;
  11351. }
  11352. return this.finishCallExpression(node, state.optionalChainMember);
  11353. }
  11354. const tokenType = this.state.type;
  11355. if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
  11356. return;
  11357. }
  11358. const node = this.startNodeAt(startLoc);
  11359. node.expression = base;
  11360. node.typeParameters = typeArguments;
  11361. return this.finishNode(node, "TSInstantiationExpression");
  11362. });
  11363. if (missingParenErrorLoc) {
  11364. this.unexpected(missingParenErrorLoc, 10);
  11365. }
  11366. if (result) {
  11367. if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) {
  11368. this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc);
  11369. }
  11370. return result;
  11371. }
  11372. }
  11373. return super.parseSubscript(base, startLoc, noCalls, state);
  11374. }
  11375. parseNewCallee(node) {
  11376. var _callee$extra;
  11377. super.parseNewCallee(node);
  11378. const {
  11379. callee
  11380. } = node;
  11381. if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
  11382. node.typeParameters = callee.typeParameters;
  11383. node.callee = callee.expression;
  11384. }
  11385. }
  11386. parseExprOp(left, leftStartLoc, minPrec) {
  11387. let isSatisfies;
  11388. if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) {
  11389. const node = this.startNodeAt(leftStartLoc);
  11390. node.expression = left;
  11391. node.typeAnnotation = this.tsInType(() => {
  11392. this.next();
  11393. if (this.match(75)) {
  11394. if (isSatisfies) {
  11395. this.raise(Errors.UnexpectedKeyword, this.state.startLoc, {
  11396. keyword: "const"
  11397. });
  11398. }
  11399. return this.tsParseTypeReference();
  11400. }
  11401. return this.tsParseType();
  11402. });
  11403. this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression");
  11404. this.reScan_lt_gt();
  11405. return this.parseExprOp(node, leftStartLoc, minPrec);
  11406. }
  11407. return super.parseExprOp(left, leftStartLoc, minPrec);
  11408. }
  11409. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  11410. if (!this.state.isAmbientContext) {
  11411. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  11412. }
  11413. }
  11414. checkImportReflection(node) {
  11415. super.checkImportReflection(node);
  11416. if (node.module && node.importKind !== "value") {
  11417. this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  11418. }
  11419. }
  11420. checkDuplicateExports() {}
  11421. isPotentialImportPhase(isExport) {
  11422. if (super.isPotentialImportPhase(isExport)) return true;
  11423. if (this.isContextual(130)) {
  11424. const ch = this.lookaheadCharCode();
  11425. return isExport ? ch === 123 || ch === 42 : ch !== 61;
  11426. }
  11427. return !isExport && this.isContextual(87);
  11428. }
  11429. applyImportPhase(node, isExport, phase, loc) {
  11430. super.applyImportPhase(node, isExport, phase, loc);
  11431. if (isExport) {
  11432. node.exportKind = phase === "type" ? "type" : "value";
  11433. } else {
  11434. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  11435. }
  11436. }
  11437. parseImport(node) {
  11438. if (this.match(133)) {
  11439. node.importKind = "value";
  11440. return super.parseImport(node);
  11441. }
  11442. let importNode;
  11443. if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) {
  11444. node.importKind = "value";
  11445. return this.tsParseImportEqualsDeclaration(node);
  11446. } else if (this.isContextual(130)) {
  11447. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11448. if (this.lookaheadCharCode() === 61) {
  11449. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier);
  11450. } else {
  11451. importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier);
  11452. }
  11453. } else {
  11454. importNode = super.parseImport(node);
  11455. }
  11456. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  11457. this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode);
  11458. }
  11459. return importNode;
  11460. }
  11461. parseExport(node, decorators) {
  11462. if (this.match(83)) {
  11463. this.next();
  11464. const nodeImportEquals = node;
  11465. let maybeDefaultIdentifier = null;
  11466. if (this.isContextual(130) && this.isPotentialImportPhase(false)) {
  11467. maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false);
  11468. } else {
  11469. nodeImportEquals.importKind = "value";
  11470. }
  11471. return this.tsParseImportEqualsDeclaration(nodeImportEquals, maybeDefaultIdentifier, true);
  11472. } else if (this.eat(29)) {
  11473. const assign = node;
  11474. assign.expression = super.parseExpression();
  11475. this.semicolon();
  11476. this.sawUnambiguousESM = true;
  11477. return this.finishNode(assign, "TSExportAssignment");
  11478. } else if (this.eatContextual(93)) {
  11479. const decl = node;
  11480. this.expectContextual(128);
  11481. decl.id = this.parseIdentifier();
  11482. this.semicolon();
  11483. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  11484. } else {
  11485. return super.parseExport(node, decorators);
  11486. }
  11487. }
  11488. isAbstractClass() {
  11489. return this.isContextual(124) && this.lookahead().type === 80;
  11490. }
  11491. parseExportDefaultExpression() {
  11492. if (this.isAbstractClass()) {
  11493. const cls = this.startNode();
  11494. this.next();
  11495. cls.abstract = true;
  11496. return this.parseClass(cls, true, true);
  11497. }
  11498. if (this.match(129)) {
  11499. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11500. if (result) return result;
  11501. }
  11502. return super.parseExportDefaultExpression();
  11503. }
  11504. parseVarStatement(node, kind, allowMissingInitializer = false) {
  11505. const {
  11506. isAmbientContext
  11507. } = this.state;
  11508. const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
  11509. if (!isAmbientContext) return declaration;
  11510. for (const {
  11511. id,
  11512. init
  11513. } of declaration.declarations) {
  11514. if (!init) continue;
  11515. if (kind !== "const" || !!id.typeAnnotation) {
  11516. this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init);
  11517. } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) {
  11518. this.raise(TSErrors.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, init);
  11519. }
  11520. }
  11521. return declaration;
  11522. }
  11523. parseStatementContent(flags, decorators) {
  11524. if (this.match(75) && this.isLookaheadContextual("enum")) {
  11525. const node = this.startNode();
  11526. this.expect(75);
  11527. return this.tsParseEnumDeclaration(node, {
  11528. const: true
  11529. });
  11530. }
  11531. if (this.isContextual(126)) {
  11532. return this.tsParseEnumDeclaration(this.startNode());
  11533. }
  11534. if (this.isContextual(129)) {
  11535. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11536. if (result) return result;
  11537. }
  11538. return super.parseStatementContent(flags, decorators);
  11539. }
  11540. parseAccessModifier() {
  11541. return this.tsParseModifier(["public", "protected", "private"]);
  11542. }
  11543. tsHasSomeModifiers(member, modifiers) {
  11544. return modifiers.some(modifier => {
  11545. if (tsIsAccessModifier(modifier)) {
  11546. return member.accessibility === modifier;
  11547. }
  11548. return !!member[modifier];
  11549. });
  11550. }
  11551. tsIsStartOfStaticBlocks() {
  11552. return this.isContextual(106) && this.lookaheadCharCode() === 123;
  11553. }
  11554. parseClassMember(classBody, member, state) {
  11555. const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"];
  11556. this.tsParseModifiers({
  11557. allowedModifiers: modifiers,
  11558. disallowedModifiers: ["in", "out"],
  11559. stopOnStartOfClassStaticBlock: true,
  11560. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  11561. }, member);
  11562. const callParseClassMemberWithIsStatic = () => {
  11563. if (this.tsIsStartOfStaticBlocks()) {
  11564. this.next();
  11565. this.next();
  11566. if (this.tsHasSomeModifiers(member, modifiers)) {
  11567. this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition());
  11568. }
  11569. super.parseClassStaticBlock(classBody, member);
  11570. } else {
  11571. this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static);
  11572. }
  11573. };
  11574. if (member.declare) {
  11575. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  11576. } else {
  11577. callParseClassMemberWithIsStatic();
  11578. }
  11579. }
  11580. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  11581. const idx = this.tsTryParseIndexSignature(member);
  11582. if (idx) {
  11583. classBody.body.push(idx);
  11584. if (member.abstract) {
  11585. this.raise(TSErrors.IndexSignatureHasAbstract, member);
  11586. }
  11587. if (member.accessibility) {
  11588. this.raise(TSErrors.IndexSignatureHasAccessibility, member, {
  11589. modifier: member.accessibility
  11590. });
  11591. }
  11592. if (member.declare) {
  11593. this.raise(TSErrors.IndexSignatureHasDeclare, member);
  11594. }
  11595. if (member.override) {
  11596. this.raise(TSErrors.IndexSignatureHasOverride, member);
  11597. }
  11598. return;
  11599. }
  11600. if (!this.state.inAbstractClass && member.abstract) {
  11601. this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member);
  11602. }
  11603. if (member.override) {
  11604. if (!state.hadSuperClass) {
  11605. this.raise(TSErrors.OverrideNotInSubClass, member);
  11606. }
  11607. }
  11608. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  11609. }
  11610. parsePostMemberNameModifiers(methodOrProp) {
  11611. const optional = this.eat(17);
  11612. if (optional) methodOrProp.optional = true;
  11613. if (methodOrProp.readonly && this.match(10)) {
  11614. this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp);
  11615. }
  11616. if (methodOrProp.declare && this.match(10)) {
  11617. this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
  11618. }
  11619. }
  11620. parseExpressionStatement(node, expr, decorators) {
  11621. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined;
  11622. return decl || super.parseExpressionStatement(node, expr, decorators);
  11623. }
  11624. shouldParseExportDeclaration() {
  11625. if (this.tsIsDeclarationStart()) return true;
  11626. return super.shouldParseExportDeclaration();
  11627. }
  11628. parseConditional(expr, startLoc, refExpressionErrors) {
  11629. if (!this.state.maybeInArrowParameters || !this.match(17)) {
  11630. return super.parseConditional(expr, startLoc, refExpressionErrors);
  11631. }
  11632. const result = this.tryParse(() => super.parseConditional(expr, startLoc));
  11633. if (!result.node) {
  11634. if (result.error) {
  11635. super.setOptionalParametersError(refExpressionErrors, result.error);
  11636. }
  11637. return expr;
  11638. }
  11639. if (result.error) this.state = result.failState;
  11640. return result.node;
  11641. }
  11642. parseParenItem(node, startLoc) {
  11643. const newNode = super.parseParenItem(node, startLoc);
  11644. if (this.eat(17)) {
  11645. newNode.optional = true;
  11646. this.resetEndLocation(node);
  11647. }
  11648. if (this.match(14)) {
  11649. const typeCastNode = this.startNodeAt(startLoc);
  11650. typeCastNode.expression = node;
  11651. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  11652. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  11653. }
  11654. return node;
  11655. }
  11656. parseExportDeclaration(node) {
  11657. if (!this.state.isAmbientContext && this.isContextual(125)) {
  11658. return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
  11659. }
  11660. const startLoc = this.state.startLoc;
  11661. const isDeclare = this.eatContextual(125);
  11662. if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) {
  11663. throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
  11664. }
  11665. const isIdentifier = tokenIsIdentifier(this.state.type);
  11666. const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
  11667. if (!declaration) return null;
  11668. if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) {
  11669. node.exportKind = "type";
  11670. }
  11671. if (isDeclare) {
  11672. this.resetStartLocation(declaration, startLoc);
  11673. declaration.declare = true;
  11674. }
  11675. return declaration;
  11676. }
  11677. parseClassId(node, isStatement, optionalId, bindingType) {
  11678. if ((!isStatement || optionalId) && this.isContextual(113)) {
  11679. return;
  11680. }
  11681. super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331);
  11682. const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  11683. if (typeParameters) node.typeParameters = typeParameters;
  11684. }
  11685. parseClassPropertyAnnotation(node) {
  11686. if (!node.optional) {
  11687. if (this.eat(35)) {
  11688. node.definite = true;
  11689. } else if (this.eat(17)) {
  11690. node.optional = true;
  11691. }
  11692. }
  11693. const type = this.tsTryParseTypeAnnotation();
  11694. if (type) node.typeAnnotation = type;
  11695. }
  11696. parseClassProperty(node) {
  11697. this.parseClassPropertyAnnotation(node);
  11698. if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) {
  11699. this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc);
  11700. }
  11701. if (node.abstract && this.match(29)) {
  11702. const {
  11703. key
  11704. } = node;
  11705. this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, {
  11706. propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  11707. });
  11708. }
  11709. return super.parseClassProperty(node);
  11710. }
  11711. parseClassPrivateProperty(node) {
  11712. if (node.abstract) {
  11713. this.raise(TSErrors.PrivateElementHasAbstract, node);
  11714. }
  11715. if (node.accessibility) {
  11716. this.raise(TSErrors.PrivateElementHasAccessibility, node, {
  11717. modifier: node.accessibility
  11718. });
  11719. }
  11720. this.parseClassPropertyAnnotation(node);
  11721. return super.parseClassPrivateProperty(node);
  11722. }
  11723. parseClassAccessorProperty(node) {
  11724. this.parseClassPropertyAnnotation(node);
  11725. if (node.optional) {
  11726. this.raise(TSErrors.AccessorCannotBeOptional, node);
  11727. }
  11728. return super.parseClassAccessorProperty(node);
  11729. }
  11730. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  11731. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11732. if (typeParameters && isConstructor) {
  11733. this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters);
  11734. }
  11735. const {
  11736. declare = false,
  11737. kind
  11738. } = method;
  11739. if (declare && (kind === "get" || kind === "set")) {
  11740. this.raise(TSErrors.DeclareAccessor, method, {
  11741. kind
  11742. });
  11743. }
  11744. if (typeParameters) method.typeParameters = typeParameters;
  11745. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  11746. }
  11747. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  11748. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11749. if (typeParameters) method.typeParameters = typeParameters;
  11750. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  11751. }
  11752. declareClassPrivateMethodInScope(node, kind) {
  11753. if (node.type === "TSDeclareMethod") return;
  11754. if (node.type === "MethodDefinition" && !hasOwnProperty.call(node.value, "body")) {
  11755. return;
  11756. }
  11757. super.declareClassPrivateMethodInScope(node, kind);
  11758. }
  11759. parseClassSuper(node) {
  11760. super.parseClassSuper(node);
  11761. if (node.superClass && (this.match(47) || this.match(51))) {
  11762. node.superTypeParameters = this.tsParseTypeArgumentsInExpression();
  11763. }
  11764. if (this.eatContextual(113)) {
  11765. node.implements = this.tsParseHeritageClause("implements");
  11766. }
  11767. }
  11768. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  11769. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11770. if (typeParameters) prop.typeParameters = typeParameters;
  11771. return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  11772. }
  11773. parseFunctionParams(node, isConstructor) {
  11774. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11775. if (typeParameters) node.typeParameters = typeParameters;
  11776. super.parseFunctionParams(node, isConstructor);
  11777. }
  11778. parseVarId(decl, kind) {
  11779. super.parseVarId(decl, kind);
  11780. if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
  11781. decl.definite = true;
  11782. }
  11783. const type = this.tsTryParseTypeAnnotation();
  11784. if (type) {
  11785. decl.id.typeAnnotation = type;
  11786. this.resetEndLocation(decl.id);
  11787. }
  11788. }
  11789. parseAsyncArrowFromCallExpression(node, call) {
  11790. if (this.match(14)) {
  11791. node.returnType = this.tsParseTypeAnnotation();
  11792. }
  11793. return super.parseAsyncArrowFromCallExpression(node, call);
  11794. }
  11795. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  11796. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
  11797. let state;
  11798. let jsx;
  11799. let typeCast;
  11800. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  11801. state = this.state.clone();
  11802. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11803. if (!jsx.error) return jsx.node;
  11804. const {
  11805. context
  11806. } = this.state;
  11807. const currentContext = context[context.length - 1];
  11808. if (currentContext === types.j_oTag || currentContext === types.j_expr) {
  11809. context.pop();
  11810. }
  11811. }
  11812. if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) {
  11813. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11814. }
  11815. if (!state || state === this.state) state = this.state.clone();
  11816. let typeParameters;
  11817. const arrow = this.tryParse(abort => {
  11818. var _expr$extra, _typeParameters;
  11819. typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11820. const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11821. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  11822. abort();
  11823. }
  11824. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  11825. this.resetStartLocationFromNode(expr, typeParameters);
  11826. }
  11827. expr.typeParameters = typeParameters;
  11828. return expr;
  11829. }, state);
  11830. if (!arrow.error && !arrow.aborted) {
  11831. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11832. return arrow.node;
  11833. }
  11834. if (!jsx) {
  11835. assert(!this.hasPlugin("jsx"));
  11836. typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11837. if (!typeCast.error) return typeCast.node;
  11838. }
  11839. if ((_jsx2 = jsx) != null && _jsx2.node) {
  11840. this.state = jsx.failState;
  11841. return jsx.node;
  11842. }
  11843. if (arrow.node) {
  11844. this.state = arrow.failState;
  11845. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11846. return arrow.node;
  11847. }
  11848. if ((_typeCast = typeCast) != null && _typeCast.node) {
  11849. this.state = typeCast.failState;
  11850. return typeCast.node;
  11851. }
  11852. throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
  11853. }
  11854. reportReservedArrowTypeParam(node) {
  11855. var _node$extra;
  11856. if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  11857. this.raise(TSErrors.ReservedArrowTypeParam, node);
  11858. }
  11859. }
  11860. parseMaybeUnary(refExpressionErrors, sawUnary) {
  11861. if (!this.hasPlugin("jsx") && this.match(47)) {
  11862. return this.tsParseTypeAssertion();
  11863. }
  11864. return super.parseMaybeUnary(refExpressionErrors, sawUnary);
  11865. }
  11866. parseArrow(node) {
  11867. if (this.match(14)) {
  11868. const result = this.tryParse(abort => {
  11869. const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11870. if (this.canInsertSemicolon() || !this.match(19)) abort();
  11871. return returnType;
  11872. });
  11873. if (result.aborted) return;
  11874. if (!result.thrown) {
  11875. if (result.error) this.state = result.failState;
  11876. node.returnType = result.node;
  11877. }
  11878. }
  11879. return super.parseArrow(node);
  11880. }
  11881. parseAssignableListItemTypes(param, flags) {
  11882. if (!(flags & 2)) return param;
  11883. if (this.eat(17)) {
  11884. param.optional = true;
  11885. }
  11886. const type = this.tsTryParseTypeAnnotation();
  11887. if (type) param.typeAnnotation = type;
  11888. this.resetEndLocation(param);
  11889. return param;
  11890. }
  11891. isAssignable(node, isBinding) {
  11892. switch (node.type) {
  11893. case "TSTypeCastExpression":
  11894. return this.isAssignable(node.expression, isBinding);
  11895. case "TSParameterProperty":
  11896. return true;
  11897. default:
  11898. return super.isAssignable(node, isBinding);
  11899. }
  11900. }
  11901. toAssignable(node, isLHS = false) {
  11902. switch (node.type) {
  11903. case "ParenthesizedExpression":
  11904. this.toAssignableParenthesizedExpression(node, isLHS);
  11905. break;
  11906. case "TSAsExpression":
  11907. case "TSSatisfiesExpression":
  11908. case "TSNonNullExpression":
  11909. case "TSTypeAssertion":
  11910. if (isLHS) {
  11911. this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
  11912. } else {
  11913. this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
  11914. }
  11915. this.toAssignable(node.expression, isLHS);
  11916. break;
  11917. case "AssignmentExpression":
  11918. if (!isLHS && node.left.type === "TSTypeCastExpression") {
  11919. node.left = this.typeCastToParameter(node.left);
  11920. }
  11921. default:
  11922. super.toAssignable(node, isLHS);
  11923. }
  11924. }
  11925. toAssignableParenthesizedExpression(node, isLHS) {
  11926. switch (node.expression.type) {
  11927. case "TSAsExpression":
  11928. case "TSSatisfiesExpression":
  11929. case "TSNonNullExpression":
  11930. case "TSTypeAssertion":
  11931. case "ParenthesizedExpression":
  11932. this.toAssignable(node.expression, isLHS);
  11933. break;
  11934. default:
  11935. super.toAssignable(node, isLHS);
  11936. }
  11937. }
  11938. checkToRestConversion(node, allowPattern) {
  11939. switch (node.type) {
  11940. case "TSAsExpression":
  11941. case "TSSatisfiesExpression":
  11942. case "TSTypeAssertion":
  11943. case "TSNonNullExpression":
  11944. this.checkToRestConversion(node.expression, false);
  11945. break;
  11946. default:
  11947. super.checkToRestConversion(node, allowPattern);
  11948. }
  11949. }
  11950. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  11951. switch (type) {
  11952. case "TSTypeCastExpression":
  11953. return true;
  11954. case "TSParameterProperty":
  11955. return "parameter";
  11956. case "TSNonNullExpression":
  11957. case "TSInstantiationExpression":
  11958. return "expression";
  11959. case "TSAsExpression":
  11960. case "TSSatisfiesExpression":
  11961. case "TSTypeAssertion":
  11962. return (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true];
  11963. default:
  11964. return super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  11965. }
  11966. }
  11967. parseBindingAtom() {
  11968. if (this.state.type === 78) {
  11969. return this.parseIdentifier(true);
  11970. }
  11971. return super.parseBindingAtom();
  11972. }
  11973. parseMaybeDecoratorArguments(expr) {
  11974. if (this.match(47) || this.match(51)) {
  11975. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11976. if (this.match(10)) {
  11977. const call = super.parseMaybeDecoratorArguments(expr);
  11978. call.typeParameters = typeArguments;
  11979. return call;
  11980. }
  11981. this.unexpected(null, 10);
  11982. }
  11983. return super.parseMaybeDecoratorArguments(expr);
  11984. }
  11985. checkCommaAfterRest(close) {
  11986. if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
  11987. this.next();
  11988. return false;
  11989. }
  11990. return super.checkCommaAfterRest(close);
  11991. }
  11992. isClassMethod() {
  11993. return this.match(47) || super.isClassMethod();
  11994. }
  11995. isClassProperty() {
  11996. return this.match(35) || this.match(14) || super.isClassProperty();
  11997. }
  11998. parseMaybeDefault(startLoc, left) {
  11999. const node = super.parseMaybeDefault(startLoc, left);
  12000. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  12001. this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation);
  12002. }
  12003. return node;
  12004. }
  12005. getTokenFromCode(code) {
  12006. if (this.state.inType) {
  12007. if (code === 62) {
  12008. this.finishOp(48, 1);
  12009. return;
  12010. }
  12011. if (code === 60) {
  12012. this.finishOp(47, 1);
  12013. return;
  12014. }
  12015. }
  12016. super.getTokenFromCode(code);
  12017. }
  12018. reScan_lt_gt() {
  12019. const {
  12020. type
  12021. } = this.state;
  12022. if (type === 47) {
  12023. this.state.pos -= 1;
  12024. this.readToken_lt();
  12025. } else if (type === 48) {
  12026. this.state.pos -= 1;
  12027. this.readToken_gt();
  12028. }
  12029. }
  12030. reScan_lt() {
  12031. const {
  12032. type
  12033. } = this.state;
  12034. if (type === 51) {
  12035. this.state.pos -= 2;
  12036. this.finishOp(47, 1);
  12037. return 47;
  12038. }
  12039. return type;
  12040. }
  12041. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  12042. for (let i = 0; i < exprList.length; i++) {
  12043. const expr = exprList[i];
  12044. if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
  12045. exprList[i] = this.typeCastToParameter(expr);
  12046. }
  12047. }
  12048. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  12049. }
  12050. typeCastToParameter(node) {
  12051. node.expression.typeAnnotation = node.typeAnnotation;
  12052. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  12053. return node.expression;
  12054. }
  12055. shouldParseArrow(params) {
  12056. if (this.match(14)) {
  12057. return params.every(expr => this.isAssignable(expr, true));
  12058. }
  12059. return super.shouldParseArrow(params);
  12060. }
  12061. shouldParseAsyncArrow() {
  12062. return this.match(14) || super.shouldParseAsyncArrow();
  12063. }
  12064. canHaveLeadingDecorator() {
  12065. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  12066. }
  12067. jsxParseOpeningElementAfterName(node) {
  12068. if (this.match(47) || this.match(51)) {
  12069. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression());
  12070. if (typeArguments) node.typeParameters = typeArguments;
  12071. }
  12072. return super.jsxParseOpeningElementAfterName(node);
  12073. }
  12074. getGetterSetterExpectedParamCount(method) {
  12075. const baseCount = super.getGetterSetterExpectedParamCount(method);
  12076. const params = this.getObjectOrClassMethodParams(method);
  12077. const firstParam = params[0];
  12078. const hasContextParam = firstParam && this.isThisParam(firstParam);
  12079. return hasContextParam ? baseCount + 1 : baseCount;
  12080. }
  12081. parseCatchClauseParam() {
  12082. const param = super.parseCatchClauseParam();
  12083. const type = this.tsTryParseTypeAnnotation();
  12084. if (type) {
  12085. param.typeAnnotation = type;
  12086. this.resetEndLocation(param);
  12087. }
  12088. return param;
  12089. }
  12090. tsInAmbientContext(cb) {
  12091. const {
  12092. isAmbientContext: oldIsAmbientContext,
  12093. strict: oldStrict
  12094. } = this.state;
  12095. this.state.isAmbientContext = true;
  12096. this.state.strict = false;
  12097. try {
  12098. return cb();
  12099. } finally {
  12100. this.state.isAmbientContext = oldIsAmbientContext;
  12101. this.state.strict = oldStrict;
  12102. }
  12103. }
  12104. parseClass(node, isStatement, optionalId) {
  12105. const oldInAbstractClass = this.state.inAbstractClass;
  12106. this.state.inAbstractClass = !!node.abstract;
  12107. try {
  12108. return super.parseClass(node, isStatement, optionalId);
  12109. } finally {
  12110. this.state.inAbstractClass = oldInAbstractClass;
  12111. }
  12112. }
  12113. tsParseAbstractDeclaration(node, decorators) {
  12114. if (this.match(80)) {
  12115. node.abstract = true;
  12116. return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
  12117. } else if (this.isContextual(129)) {
  12118. if (!this.hasFollowingLineBreak()) {
  12119. node.abstract = true;
  12120. this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, node);
  12121. return this.tsParseInterfaceDeclaration(node);
  12122. }
  12123. } else {
  12124. this.unexpected(null, 80);
  12125. }
  12126. }
  12127. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) {
  12128. const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  12129. if (method.abstract) {
  12130. const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body;
  12131. if (hasBody) {
  12132. const {
  12133. key
  12134. } = method;
  12135. this.raise(TSErrors.AbstractMethodHasImplementation, method, {
  12136. methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  12137. });
  12138. }
  12139. }
  12140. return method;
  12141. }
  12142. tsParseTypeParameterName() {
  12143. const typeName = this.parseIdentifier();
  12144. return typeName.name;
  12145. }
  12146. shouldParseAsAmbientContext() {
  12147. return !!this.getPluginOption("typescript", "dts");
  12148. }
  12149. parse() {
  12150. if (this.shouldParseAsAmbientContext()) {
  12151. this.state.isAmbientContext = true;
  12152. }
  12153. return super.parse();
  12154. }
  12155. getExpression() {
  12156. if (this.shouldParseAsAmbientContext()) {
  12157. this.state.isAmbientContext = true;
  12158. }
  12159. return super.getExpression();
  12160. }
  12161. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  12162. if (!isString && isMaybeTypeOnly) {
  12163. this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport);
  12164. return this.finishNode(node, "ExportSpecifier");
  12165. }
  12166. node.exportKind = "value";
  12167. return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
  12168. }
  12169. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  12170. if (!importedIsString && isMaybeTypeOnly) {
  12171. this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport);
  12172. return this.finishNode(specifier, "ImportSpecifier");
  12173. }
  12174. specifier.importKind = "value";
  12175. return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096);
  12176. }
  12177. parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) {
  12178. const leftOfAsKey = isImport ? "imported" : "local";
  12179. const rightOfAsKey = isImport ? "local" : "exported";
  12180. let leftOfAs = node[leftOfAsKey];
  12181. let rightOfAs;
  12182. let hasTypeSpecifier = false;
  12183. let canParseAsKeyword = true;
  12184. const loc = leftOfAs.loc.start;
  12185. if (this.isContextual(93)) {
  12186. const firstAs = this.parseIdentifier();
  12187. if (this.isContextual(93)) {
  12188. const secondAs = this.parseIdentifier();
  12189. if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12190. hasTypeSpecifier = true;
  12191. leftOfAs = firstAs;
  12192. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12193. canParseAsKeyword = false;
  12194. } else {
  12195. rightOfAs = secondAs;
  12196. canParseAsKeyword = false;
  12197. }
  12198. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12199. canParseAsKeyword = false;
  12200. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12201. } else {
  12202. hasTypeSpecifier = true;
  12203. leftOfAs = firstAs;
  12204. }
  12205. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12206. hasTypeSpecifier = true;
  12207. if (isImport) {
  12208. leftOfAs = this.parseIdentifier(true);
  12209. if (!this.isContextual(93)) {
  12210. this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
  12211. }
  12212. } else {
  12213. leftOfAs = this.parseModuleExportName();
  12214. }
  12215. }
  12216. if (hasTypeSpecifier && isInTypeOnlyImportExport) {
  12217. this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc);
  12218. }
  12219. node[leftOfAsKey] = leftOfAs;
  12220. node[rightOfAsKey] = rightOfAs;
  12221. const kindKey = isImport ? "importKind" : "exportKind";
  12222. node[kindKey] = hasTypeSpecifier ? "type" : "value";
  12223. if (canParseAsKeyword && this.eatContextual(93)) {
  12224. node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12225. }
  12226. if (!node[rightOfAsKey]) {
  12227. node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]);
  12228. }
  12229. if (isImport) {
  12230. this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
  12231. }
  12232. }
  12233. };
  12234. function isPossiblyLiteralEnum(expression) {
  12235. if (expression.type !== "MemberExpression") return false;
  12236. const {
  12237. computed,
  12238. property
  12239. } = expression;
  12240. if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) {
  12241. return false;
  12242. }
  12243. return isUncomputedMemberExpressionChain(expression.object);
  12244. }
  12245. function isValidAmbientConstInitializer(expression, estree) {
  12246. var _expression$extra;
  12247. const {
  12248. type
  12249. } = expression;
  12250. if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) {
  12251. return false;
  12252. }
  12253. if (estree) {
  12254. if (type === "Literal") {
  12255. const {
  12256. value
  12257. } = expression;
  12258. if (typeof value === "string" || typeof value === "boolean") {
  12259. return true;
  12260. }
  12261. }
  12262. } else {
  12263. if (type === "StringLiteral" || type === "BooleanLiteral") {
  12264. return true;
  12265. }
  12266. }
  12267. if (isNumber(expression, estree) || isNegativeNumber(expression, estree)) {
  12268. return true;
  12269. }
  12270. if (type === "TemplateLiteral" && expression.expressions.length === 0) {
  12271. return true;
  12272. }
  12273. if (isPossiblyLiteralEnum(expression)) {
  12274. return true;
  12275. }
  12276. return false;
  12277. }
  12278. function isNumber(expression, estree) {
  12279. if (estree) {
  12280. return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression);
  12281. }
  12282. return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral";
  12283. }
  12284. function isNegativeNumber(expression, estree) {
  12285. if (expression.type === "UnaryExpression") {
  12286. const {
  12287. operator,
  12288. argument
  12289. } = expression;
  12290. if (operator === "-" && isNumber(argument, estree)) {
  12291. return true;
  12292. }
  12293. }
  12294. return false;
  12295. }
  12296. function isUncomputedMemberExpressionChain(expression) {
  12297. if (expression.type === "Identifier") return true;
  12298. if (expression.type !== "MemberExpression" || expression.computed) {
  12299. return false;
  12300. }
  12301. return isUncomputedMemberExpressionChain(expression.object);
  12302. }
  12303. const PlaceholderErrors = ParseErrorEnum`placeholders`({
  12304. ClassNameIsRequired: "A class name is required.",
  12305. UnexpectedSpace: "Unexpected space in placeholder."
  12306. });
  12307. var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
  12308. parsePlaceholder(expectedNode) {
  12309. if (this.match(144)) {
  12310. const node = this.startNode();
  12311. this.next();
  12312. this.assertNoSpace();
  12313. node.name = super.parseIdentifier(true);
  12314. this.assertNoSpace();
  12315. this.expect(144);
  12316. return this.finishPlaceholder(node, expectedNode);
  12317. }
  12318. }
  12319. finishPlaceholder(node, expectedNode) {
  12320. let placeholder = node;
  12321. if (!placeholder.expectedNode || !placeholder.type) {
  12322. placeholder = this.finishNode(placeholder, "Placeholder");
  12323. }
  12324. placeholder.expectedNode = expectedNode;
  12325. return placeholder;
  12326. }
  12327. getTokenFromCode(code) {
  12328. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  12329. this.finishOp(144, 2);
  12330. } else {
  12331. super.getTokenFromCode(code);
  12332. }
  12333. }
  12334. parseExprAtom(refExpressionErrors) {
  12335. return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors);
  12336. }
  12337. parseIdentifier(liberal) {
  12338. return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal);
  12339. }
  12340. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  12341. if (word !== undefined) {
  12342. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  12343. }
  12344. }
  12345. parseBindingAtom() {
  12346. return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
  12347. }
  12348. isValidLVal(type, isParenthesized, binding) {
  12349. return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding);
  12350. }
  12351. toAssignable(node, isLHS) {
  12352. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  12353. node.expectedNode = "Pattern";
  12354. } else {
  12355. super.toAssignable(node, isLHS);
  12356. }
  12357. }
  12358. chStartsBindingIdentifier(ch, pos) {
  12359. if (super.chStartsBindingIdentifier(ch, pos)) {
  12360. return true;
  12361. }
  12362. const nextToken = this.lookahead();
  12363. if (nextToken.type === 144) {
  12364. return true;
  12365. }
  12366. return false;
  12367. }
  12368. verifyBreakContinue(node, isBreak) {
  12369. if (node.label && node.label.type === "Placeholder") return;
  12370. super.verifyBreakContinue(node, isBreak);
  12371. }
  12372. parseExpressionStatement(node, expr) {
  12373. var _expr$extra;
  12374. if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12375. return super.parseExpressionStatement(node, expr);
  12376. }
  12377. if (this.match(14)) {
  12378. const stmt = node;
  12379. stmt.label = this.finishPlaceholder(expr, "Identifier");
  12380. this.next();
  12381. stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration();
  12382. return this.finishNode(stmt, "LabeledStatement");
  12383. }
  12384. this.semicolon();
  12385. const stmtPlaceholder = node;
  12386. stmtPlaceholder.name = expr.name;
  12387. return this.finishPlaceholder(stmtPlaceholder, "Statement");
  12388. }
  12389. parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) {
  12390. return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse);
  12391. }
  12392. parseFunctionId(requireId) {
  12393. return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId);
  12394. }
  12395. parseClass(node, isStatement, optionalId) {
  12396. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  12397. this.next();
  12398. const oldStrict = this.state.strict;
  12399. const placeholder = this.parsePlaceholder("Identifier");
  12400. if (placeholder) {
  12401. if (this.match(81) || this.match(144) || this.match(5)) {
  12402. node.id = placeholder;
  12403. } else if (optionalId || !isStatement) {
  12404. node.id = null;
  12405. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  12406. return this.finishNode(node, type);
  12407. } else {
  12408. throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc);
  12409. }
  12410. } else {
  12411. this.parseClassId(node, isStatement, optionalId);
  12412. }
  12413. super.parseClassSuper(node);
  12414. node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict);
  12415. return this.finishNode(node, type);
  12416. }
  12417. parseExport(node, decorators) {
  12418. const placeholder = this.parsePlaceholder("Identifier");
  12419. if (!placeholder) return super.parseExport(node, decorators);
  12420. const node2 = node;
  12421. if (!this.isContextual(98) && !this.match(12)) {
  12422. node2.specifiers = [];
  12423. node2.source = null;
  12424. node2.declaration = this.finishPlaceholder(placeholder, "Declaration");
  12425. return this.finishNode(node2, "ExportNamedDeclaration");
  12426. }
  12427. this.expectPlugin("exportDefaultFrom");
  12428. const specifier = this.startNode();
  12429. specifier.exported = placeholder;
  12430. node2.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  12431. return super.parseExport(node2, decorators);
  12432. }
  12433. isExportDefaultSpecifier() {
  12434. if (this.match(65)) {
  12435. const next = this.nextTokenStart();
  12436. if (this.isUnparsedContextual(next, "from")) {
  12437. if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) {
  12438. return true;
  12439. }
  12440. }
  12441. }
  12442. return super.isExportDefaultSpecifier();
  12443. }
  12444. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  12445. var _specifiers;
  12446. if ((_specifiers = node.specifiers) != null && _specifiers.length) {
  12447. return true;
  12448. }
  12449. return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  12450. }
  12451. checkExport(node) {
  12452. const {
  12453. specifiers
  12454. } = node;
  12455. if (specifiers != null && specifiers.length) {
  12456. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  12457. }
  12458. super.checkExport(node);
  12459. node.specifiers = specifiers;
  12460. }
  12461. parseImport(node) {
  12462. const placeholder = this.parsePlaceholder("Identifier");
  12463. if (!placeholder) return super.parseImport(node);
  12464. node.specifiers = [];
  12465. if (!this.isContextual(98) && !this.match(12)) {
  12466. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  12467. this.semicolon();
  12468. return this.finishNode(node, "ImportDeclaration");
  12469. }
  12470. const specifier = this.startNodeAtNode(placeholder);
  12471. specifier.local = placeholder;
  12472. node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
  12473. if (this.eat(12)) {
  12474. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  12475. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  12476. }
  12477. this.expectContextual(98);
  12478. node.source = this.parseImportSource();
  12479. this.semicolon();
  12480. return this.finishNode(node, "ImportDeclaration");
  12481. }
  12482. parseImportSource() {
  12483. return this.parsePlaceholder("StringLiteral") || super.parseImportSource();
  12484. }
  12485. assertNoSpace() {
  12486. if (this.state.start > this.state.lastTokEndLoc.index) {
  12487. this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc);
  12488. }
  12489. }
  12490. };
  12491. var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
  12492. parseV8Intrinsic() {
  12493. if (this.match(54)) {
  12494. const v8IntrinsicStartLoc = this.state.startLoc;
  12495. const node = this.startNode();
  12496. this.next();
  12497. if (tokenIsIdentifier(this.state.type)) {
  12498. const name = this.parseIdentifierName();
  12499. const identifier = this.createIdentifier(node, name);
  12500. identifier.type = "V8IntrinsicIdentifier";
  12501. if (this.match(10)) {
  12502. return identifier;
  12503. }
  12504. }
  12505. this.unexpected(v8IntrinsicStartLoc);
  12506. }
  12507. }
  12508. parseExprAtom(refExpressionErrors) {
  12509. return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
  12510. }
  12511. };
  12512. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  12513. const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
  12514. function validatePlugins(pluginsMap) {
  12515. if (pluginsMap.has("decorators")) {
  12516. if (pluginsMap.has("decorators-legacy")) {
  12517. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  12518. }
  12519. const decoratorsBeforeExport = pluginsMap.get("decorators").decoratorsBeforeExport;
  12520. if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
  12521. throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");
  12522. }
  12523. const allowCallParenthesized = pluginsMap.get("decorators").allowCallParenthesized;
  12524. if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
  12525. throw new Error("'allowCallParenthesized' must be a boolean.");
  12526. }
  12527. }
  12528. if (pluginsMap.has("flow") && pluginsMap.has("typescript")) {
  12529. throw new Error("Cannot combine flow and typescript plugins.");
  12530. }
  12531. if (pluginsMap.has("placeholders") && pluginsMap.has("v8intrinsic")) {
  12532. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  12533. }
  12534. if (pluginsMap.has("pipelineOperator")) {
  12535. var _pluginsMap$get;
  12536. const proposal = pluginsMap.get("pipelineOperator").proposal;
  12537. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  12538. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  12539. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  12540. }
  12541. const tupleSyntaxIsHash = ((_pluginsMap$get = pluginsMap.get("recordAndTuple")) == null ? void 0 : _pluginsMap$get.syntaxType) === "hash";
  12542. if (proposal === "hack") {
  12543. if (pluginsMap.has("placeholders")) {
  12544. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  12545. }
  12546. if (pluginsMap.has("v8intrinsic")) {
  12547. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  12548. }
  12549. const topicToken = pluginsMap.get("pipelineOperator").topicToken;
  12550. if (!TOPIC_TOKENS.includes(topicToken)) {
  12551. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  12552. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  12553. }
  12554. if (topicToken === "#" && tupleSyntaxIsHash) {
  12555. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "hack", topicToken: "#" }]\` and \`${JSON.stringify(["recordAndTuple", pluginsMap.get("recordAndTuple")])}\`.`);
  12556. }
  12557. } else if (proposal === "smart" && tupleSyntaxIsHash) {
  12558. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "smart" }]\` and \`${JSON.stringify(["recordAndTuple", pluginsMap.get("recordAndTuple")])}\`.`);
  12559. }
  12560. }
  12561. if (pluginsMap.has("moduleAttributes")) {
  12562. {
  12563. if (pluginsMap.has("importAttributes") || pluginsMap.has("importAssertions")) {
  12564. throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");
  12565. }
  12566. const moduleAttributesVersionPluginOption = pluginsMap.get("moduleAttributes").version;
  12567. if (moduleAttributesVersionPluginOption !== "may-2020") {
  12568. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  12569. }
  12570. }
  12571. }
  12572. if (pluginsMap.has("importAttributes") && pluginsMap.has("importAssertions")) {
  12573. throw new Error("Cannot combine importAssertions and importAttributes plugins.");
  12574. }
  12575. if (pluginsMap.has("recordAndTuple")) {
  12576. const syntaxType = pluginsMap.get("recordAndTuple").syntaxType;
  12577. if (syntaxType != null) {
  12578. {
  12579. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  12580. if (!RECORD_AND_TUPLE_SYNTAX_TYPES.includes(syntaxType)) {
  12581. throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  12582. }
  12583. }
  12584. }
  12585. }
  12586. if (pluginsMap.has("asyncDoExpressions") && !pluginsMap.has("doExpressions")) {
  12587. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  12588. error.missingPlugins = "doExpressions";
  12589. throw error;
  12590. }
  12591. if (pluginsMap.has("optionalChainingAssign") && pluginsMap.get("optionalChainingAssign").version !== "2023-07") {
  12592. throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'.");
  12593. }
  12594. }
  12595. const mixinPlugins = {
  12596. estree,
  12597. jsx,
  12598. flow,
  12599. typescript,
  12600. v8intrinsic,
  12601. placeholders
  12602. };
  12603. const mixinPluginNames = Object.keys(mixinPlugins);
  12604. const defaultOptions = {
  12605. sourceType: "script",
  12606. sourceFilename: undefined,
  12607. startColumn: 0,
  12608. startLine: 1,
  12609. allowAwaitOutsideFunction: false,
  12610. allowReturnOutsideFunction: false,
  12611. allowNewTargetOutsideFunction: false,
  12612. allowImportExportEverywhere: false,
  12613. allowSuperOutsideMethod: false,
  12614. allowUndeclaredExports: false,
  12615. plugins: [],
  12616. strictMode: null,
  12617. ranges: false,
  12618. tokens: false,
  12619. createImportExpressions: false,
  12620. createParenthesizedExpressions: false,
  12621. errorRecovery: false,
  12622. attachComment: true,
  12623. annexB: true
  12624. };
  12625. function getOptions(opts) {
  12626. if (opts == null) {
  12627. return Object.assign({}, defaultOptions);
  12628. }
  12629. if (opts.annexB != null && opts.annexB !== false) {
  12630. throw new Error("The `annexB` option can only be set to `false`.");
  12631. }
  12632. const options = {};
  12633. for (const key of Object.keys(defaultOptions)) {
  12634. var _opts$key;
  12635. options[key] = (_opts$key = opts[key]) != null ? _opts$key : defaultOptions[key];
  12636. }
  12637. return options;
  12638. }
  12639. class ExpressionParser extends LValParser {
  12640. checkProto(prop, isRecord, protoRef, refExpressionErrors) {
  12641. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  12642. return;
  12643. }
  12644. const key = prop.key;
  12645. const name = key.type === "Identifier" ? key.name : key.value;
  12646. if (name === "__proto__") {
  12647. if (isRecord) {
  12648. this.raise(Errors.RecordNoProto, key);
  12649. return;
  12650. }
  12651. if (protoRef.used) {
  12652. if (refExpressionErrors) {
  12653. if (refExpressionErrors.doubleProtoLoc === null) {
  12654. refExpressionErrors.doubleProtoLoc = key.loc.start;
  12655. }
  12656. } else {
  12657. this.raise(Errors.DuplicateProto, key);
  12658. }
  12659. }
  12660. protoRef.used = true;
  12661. }
  12662. }
  12663. shouldExitDescending(expr, potentialArrowAt) {
  12664. return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
  12665. }
  12666. getExpression() {
  12667. this.enterInitialScopes();
  12668. this.nextToken();
  12669. const expr = this.parseExpression();
  12670. if (!this.match(139)) {
  12671. this.unexpected();
  12672. }
  12673. this.finalizeRemainingComments();
  12674. expr.comments = this.comments;
  12675. expr.errors = this.state.errors;
  12676. if (this.options.tokens) {
  12677. expr.tokens = this.tokens;
  12678. }
  12679. return expr;
  12680. }
  12681. parseExpression(disallowIn, refExpressionErrors) {
  12682. if (disallowIn) {
  12683. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12684. }
  12685. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12686. }
  12687. parseExpressionBase(refExpressionErrors) {
  12688. const startLoc = this.state.startLoc;
  12689. const expr = this.parseMaybeAssign(refExpressionErrors);
  12690. if (this.match(12)) {
  12691. const node = this.startNodeAt(startLoc);
  12692. node.expressions = [expr];
  12693. while (this.eat(12)) {
  12694. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  12695. }
  12696. this.toReferencedList(node.expressions);
  12697. return this.finishNode(node, "SequenceExpression");
  12698. }
  12699. return expr;
  12700. }
  12701. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  12702. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12703. }
  12704. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  12705. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12706. }
  12707. setOptionalParametersError(refExpressionErrors, resultError) {
  12708. var _resultError$loc;
  12709. refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
  12710. }
  12711. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  12712. const startLoc = this.state.startLoc;
  12713. if (this.isContextual(108)) {
  12714. if (this.prodParam.hasYield) {
  12715. let left = this.parseYield();
  12716. if (afterLeftParse) {
  12717. left = afterLeftParse.call(this, left, startLoc);
  12718. }
  12719. return left;
  12720. }
  12721. }
  12722. let ownExpressionErrors;
  12723. if (refExpressionErrors) {
  12724. ownExpressionErrors = false;
  12725. } else {
  12726. refExpressionErrors = new ExpressionErrors();
  12727. ownExpressionErrors = true;
  12728. }
  12729. const {
  12730. type
  12731. } = this.state;
  12732. if (type === 10 || tokenIsIdentifier(type)) {
  12733. this.state.potentialArrowAt = this.state.start;
  12734. }
  12735. let left = this.parseMaybeConditional(refExpressionErrors);
  12736. if (afterLeftParse) {
  12737. left = afterLeftParse.call(this, left, startLoc);
  12738. }
  12739. if (tokenIsAssignment(this.state.type)) {
  12740. const node = this.startNodeAt(startLoc);
  12741. const operator = this.state.value;
  12742. node.operator = operator;
  12743. if (this.match(29)) {
  12744. this.toAssignable(left, true);
  12745. node.left = left;
  12746. const startIndex = startLoc.index;
  12747. if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
  12748. refExpressionErrors.doubleProtoLoc = null;
  12749. }
  12750. if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
  12751. refExpressionErrors.shorthandAssignLoc = null;
  12752. }
  12753. if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
  12754. this.checkDestructuringPrivate(refExpressionErrors);
  12755. refExpressionErrors.privateKeyLoc = null;
  12756. }
  12757. } else {
  12758. node.left = left;
  12759. }
  12760. this.next();
  12761. node.right = this.parseMaybeAssign();
  12762. this.checkLVal(left, this.finishNode(node, "AssignmentExpression"));
  12763. return node;
  12764. } else if (ownExpressionErrors) {
  12765. this.checkExpressionErrors(refExpressionErrors, true);
  12766. }
  12767. return left;
  12768. }
  12769. parseMaybeConditional(refExpressionErrors) {
  12770. const startLoc = this.state.startLoc;
  12771. const potentialArrowAt = this.state.potentialArrowAt;
  12772. const expr = this.parseExprOps(refExpressionErrors);
  12773. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12774. return expr;
  12775. }
  12776. return this.parseConditional(expr, startLoc, refExpressionErrors);
  12777. }
  12778. parseConditional(expr, startLoc, refExpressionErrors) {
  12779. if (this.eat(17)) {
  12780. const node = this.startNodeAt(startLoc);
  12781. node.test = expr;
  12782. node.consequent = this.parseMaybeAssignAllowIn();
  12783. this.expect(14);
  12784. node.alternate = this.parseMaybeAssign();
  12785. return this.finishNode(node, "ConditionalExpression");
  12786. }
  12787. return expr;
  12788. }
  12789. parseMaybeUnaryOrPrivate(refExpressionErrors) {
  12790. return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
  12791. }
  12792. parseExprOps(refExpressionErrors) {
  12793. const startLoc = this.state.startLoc;
  12794. const potentialArrowAt = this.state.potentialArrowAt;
  12795. const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
  12796. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12797. return expr;
  12798. }
  12799. return this.parseExprOp(expr, startLoc, -1);
  12800. }
  12801. parseExprOp(left, leftStartLoc, minPrec) {
  12802. if (this.isPrivateName(left)) {
  12803. const value = this.getPrivateNameSV(left);
  12804. if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) {
  12805. this.raise(Errors.PrivateInExpectedIn, left, {
  12806. identifierName: value
  12807. });
  12808. }
  12809. this.classScope.usePrivateName(value, left.loc.start);
  12810. }
  12811. const op = this.state.type;
  12812. if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) {
  12813. let prec = tokenOperatorPrecedence(op);
  12814. if (prec > minPrec) {
  12815. if (op === 39) {
  12816. this.expectPlugin("pipelineOperator");
  12817. if (this.state.inFSharpPipelineDirectBody) {
  12818. return left;
  12819. }
  12820. this.checkPipelineAtInfixOperator(left, leftStartLoc);
  12821. }
  12822. const node = this.startNodeAt(leftStartLoc);
  12823. node.left = left;
  12824. node.operator = this.state.value;
  12825. const logical = op === 41 || op === 42;
  12826. const coalesce = op === 40;
  12827. if (coalesce) {
  12828. prec = tokenOperatorPrecedence(42);
  12829. }
  12830. this.next();
  12831. if (op === 39 && this.hasPlugin(["pipelineOperator", {
  12832. proposal: "minimal"
  12833. }])) {
  12834. if (this.state.type === 96 && this.prodParam.hasAwait) {
  12835. throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
  12836. }
  12837. }
  12838. node.right = this.parseExprOpRightExpr(op, prec);
  12839. const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  12840. const nextOp = this.state.type;
  12841. if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) {
  12842. throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
  12843. }
  12844. return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
  12845. }
  12846. }
  12847. return left;
  12848. }
  12849. parseExprOpRightExpr(op, prec) {
  12850. const startLoc = this.state.startLoc;
  12851. switch (op) {
  12852. case 39:
  12853. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  12854. case "hack":
  12855. return this.withTopicBindingContext(() => {
  12856. return this.parseHackPipeBody();
  12857. });
  12858. case "smart":
  12859. return this.withTopicBindingContext(() => {
  12860. if (this.prodParam.hasYield && this.isContextual(108)) {
  12861. throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
  12862. }
  12863. return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
  12864. });
  12865. case "fsharp":
  12866. return this.withSoloAwaitPermittingContext(() => {
  12867. return this.parseFSharpPipelineBody(prec);
  12868. });
  12869. }
  12870. default:
  12871. return this.parseExprOpBaseRightExpr(op, prec);
  12872. }
  12873. }
  12874. parseExprOpBaseRightExpr(op, prec) {
  12875. const startLoc = this.state.startLoc;
  12876. return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
  12877. }
  12878. parseHackPipeBody() {
  12879. var _body$extra;
  12880. const {
  12881. startLoc
  12882. } = this.state;
  12883. const body = this.parseMaybeAssign();
  12884. const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
  12885. if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
  12886. this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
  12887. type: body.type
  12888. });
  12889. }
  12890. if (!this.topicReferenceWasUsedInCurrentContext()) {
  12891. this.raise(Errors.PipeTopicUnused, startLoc);
  12892. }
  12893. return body;
  12894. }
  12895. checkExponentialAfterUnary(node) {
  12896. if (this.match(57)) {
  12897. this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
  12898. }
  12899. }
  12900. parseMaybeUnary(refExpressionErrors, sawUnary) {
  12901. const startLoc = this.state.startLoc;
  12902. const isAwait = this.isContextual(96);
  12903. if (isAwait && this.recordAwaitIfAllowed()) {
  12904. this.next();
  12905. const expr = this.parseAwait(startLoc);
  12906. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  12907. return expr;
  12908. }
  12909. const update = this.match(34);
  12910. const node = this.startNode();
  12911. if (tokenIsPrefix(this.state.type)) {
  12912. node.operator = this.state.value;
  12913. node.prefix = true;
  12914. if (this.match(72)) {
  12915. this.expectPlugin("throwExpressions");
  12916. }
  12917. const isDelete = this.match(89);
  12918. this.next();
  12919. node.argument = this.parseMaybeUnary(null, true);
  12920. this.checkExpressionErrors(refExpressionErrors, true);
  12921. if (this.state.strict && isDelete) {
  12922. const arg = node.argument;
  12923. if (arg.type === "Identifier") {
  12924. this.raise(Errors.StrictDelete, node);
  12925. } else if (this.hasPropertyAsPrivateName(arg)) {
  12926. this.raise(Errors.DeletePrivateField, node);
  12927. }
  12928. }
  12929. if (!update) {
  12930. if (!sawUnary) {
  12931. this.checkExponentialAfterUnary(node);
  12932. }
  12933. return this.finishNode(node, "UnaryExpression");
  12934. }
  12935. }
  12936. const expr = this.parseUpdate(node, update, refExpressionErrors);
  12937. if (isAwait) {
  12938. const {
  12939. type
  12940. } = this.state;
  12941. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  12942. if (startsExpr && !this.isAmbiguousAwait()) {
  12943. this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
  12944. return this.parseAwait(startLoc);
  12945. }
  12946. }
  12947. return expr;
  12948. }
  12949. parseUpdate(node, update, refExpressionErrors) {
  12950. if (update) {
  12951. const updateExpressionNode = node;
  12952. this.checkLVal(updateExpressionNode.argument, this.finishNode(updateExpressionNode, "UpdateExpression"));
  12953. return node;
  12954. }
  12955. const startLoc = this.state.startLoc;
  12956. let expr = this.parseExprSubscripts(refExpressionErrors);
  12957. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  12958. while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
  12959. const node = this.startNodeAt(startLoc);
  12960. node.operator = this.state.value;
  12961. node.prefix = false;
  12962. node.argument = expr;
  12963. this.next();
  12964. this.checkLVal(expr, expr = this.finishNode(node, "UpdateExpression"));
  12965. }
  12966. return expr;
  12967. }
  12968. parseExprSubscripts(refExpressionErrors) {
  12969. const startLoc = this.state.startLoc;
  12970. const potentialArrowAt = this.state.potentialArrowAt;
  12971. const expr = this.parseExprAtom(refExpressionErrors);
  12972. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12973. return expr;
  12974. }
  12975. return this.parseSubscripts(expr, startLoc);
  12976. }
  12977. parseSubscripts(base, startLoc, noCalls) {
  12978. const state = {
  12979. optionalChainMember: false,
  12980. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  12981. stop: false
  12982. };
  12983. do {
  12984. base = this.parseSubscript(base, startLoc, noCalls, state);
  12985. state.maybeAsyncArrow = false;
  12986. } while (!state.stop);
  12987. return base;
  12988. }
  12989. parseSubscript(base, startLoc, noCalls, state) {
  12990. const {
  12991. type
  12992. } = this.state;
  12993. if (!noCalls && type === 15) {
  12994. return this.parseBind(base, startLoc, noCalls, state);
  12995. } else if (tokenIsTemplate(type)) {
  12996. return this.parseTaggedTemplateExpression(base, startLoc, state);
  12997. }
  12998. let optional = false;
  12999. if (type === 18) {
  13000. if (noCalls) {
  13001. this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
  13002. if (this.lookaheadCharCode() === 40) {
  13003. state.stop = true;
  13004. return base;
  13005. }
  13006. }
  13007. state.optionalChainMember = optional = true;
  13008. this.next();
  13009. }
  13010. if (!noCalls && this.match(10)) {
  13011. return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
  13012. } else {
  13013. const computed = this.eat(0);
  13014. if (computed || optional || this.eat(16)) {
  13015. return this.parseMember(base, startLoc, state, computed, optional);
  13016. } else {
  13017. state.stop = true;
  13018. return base;
  13019. }
  13020. }
  13021. }
  13022. parseMember(base, startLoc, state, computed, optional) {
  13023. const node = this.startNodeAt(startLoc);
  13024. node.object = base;
  13025. node.computed = computed;
  13026. if (computed) {
  13027. node.property = this.parseExpression();
  13028. this.expect(3);
  13029. } else if (this.match(138)) {
  13030. if (base.type === "Super") {
  13031. this.raise(Errors.SuperPrivateField, startLoc);
  13032. }
  13033. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  13034. node.property = this.parsePrivateName();
  13035. } else {
  13036. node.property = this.parseIdentifier(true);
  13037. }
  13038. if (state.optionalChainMember) {
  13039. node.optional = optional;
  13040. return this.finishNode(node, "OptionalMemberExpression");
  13041. } else {
  13042. return this.finishNode(node, "MemberExpression");
  13043. }
  13044. }
  13045. parseBind(base, startLoc, noCalls, state) {
  13046. const node = this.startNodeAt(startLoc);
  13047. node.object = base;
  13048. this.next();
  13049. node.callee = this.parseNoCallExpr();
  13050. state.stop = true;
  13051. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls);
  13052. }
  13053. parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
  13054. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13055. let refExpressionErrors = null;
  13056. this.state.maybeInArrowParameters = true;
  13057. this.next();
  13058. const node = this.startNodeAt(startLoc);
  13059. node.callee = base;
  13060. const {
  13061. maybeAsyncArrow,
  13062. optionalChainMember
  13063. } = state;
  13064. if (maybeAsyncArrow) {
  13065. this.expressionScope.enter(newAsyncArrowScope());
  13066. refExpressionErrors = new ExpressionErrors();
  13067. }
  13068. if (optionalChainMember) {
  13069. node.optional = optional;
  13070. }
  13071. if (optional) {
  13072. node.arguments = this.parseCallExpressionArguments(11);
  13073. } else {
  13074. node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors);
  13075. }
  13076. let finishedNode = this.finishCallExpression(node, optionalChainMember);
  13077. if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  13078. state.stop = true;
  13079. this.checkDestructuringPrivate(refExpressionErrors);
  13080. this.expressionScope.validateAsPattern();
  13081. this.expressionScope.exit();
  13082. finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
  13083. } else {
  13084. if (maybeAsyncArrow) {
  13085. this.checkExpressionErrors(refExpressionErrors, true);
  13086. this.expressionScope.exit();
  13087. }
  13088. this.toReferencedArguments(finishedNode);
  13089. }
  13090. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13091. return finishedNode;
  13092. }
  13093. toReferencedArguments(node, isParenthesizedExpr) {
  13094. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  13095. }
  13096. parseTaggedTemplateExpression(base, startLoc, state) {
  13097. const node = this.startNodeAt(startLoc);
  13098. node.tag = base;
  13099. node.quasi = this.parseTemplate(true);
  13100. if (state.optionalChainMember) {
  13101. this.raise(Errors.OptionalChainingNoTemplate, startLoc);
  13102. }
  13103. return this.finishNode(node, "TaggedTemplateExpression");
  13104. }
  13105. atPossibleAsyncArrow(base) {
  13106. return base.type === "Identifier" && base.name === "async" && this.state.lastTokEndLoc.index === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
  13107. }
  13108. expectImportAttributesPlugin() {
  13109. if (!this.hasPlugin("importAssertions")) {
  13110. this.expectPlugin("importAttributes");
  13111. }
  13112. }
  13113. finishCallExpression(node, optional) {
  13114. if (node.callee.type === "Import") {
  13115. if (node.arguments.length === 2) {
  13116. {
  13117. if (!this.hasPlugin("moduleAttributes")) {
  13118. this.expectImportAttributesPlugin();
  13119. }
  13120. }
  13121. }
  13122. if (node.arguments.length === 0 || node.arguments.length > 2) {
  13123. this.raise(Errors.ImportCallArity, node, {
  13124. maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1
  13125. });
  13126. } else {
  13127. for (const arg of node.arguments) {
  13128. if (arg.type === "SpreadElement") {
  13129. this.raise(Errors.ImportCallSpreadArgument, arg);
  13130. }
  13131. }
  13132. }
  13133. }
  13134. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  13135. }
  13136. parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) {
  13137. const elts = [];
  13138. let first = true;
  13139. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13140. this.state.inFSharpPipelineDirectBody = false;
  13141. while (!this.eat(close)) {
  13142. if (first) {
  13143. first = false;
  13144. } else {
  13145. this.expect(12);
  13146. if (this.match(close)) {
  13147. if (dynamicImport && !this.hasPlugin("importAttributes") && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
  13148. this.raise(Errors.ImportCallArgumentTrailingComma, this.state.lastTokStartLoc);
  13149. }
  13150. if (nodeForExtra) {
  13151. this.addTrailingCommaExtraToNode(nodeForExtra);
  13152. }
  13153. this.next();
  13154. break;
  13155. }
  13156. }
  13157. elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
  13158. }
  13159. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13160. return elts;
  13161. }
  13162. shouldParseAsyncArrow() {
  13163. return this.match(19) && !this.canInsertSemicolon();
  13164. }
  13165. parseAsyncArrowFromCallExpression(node, call) {
  13166. var _call$extra;
  13167. this.resetPreviousNodeTrailingComments(call);
  13168. this.expect(19);
  13169. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
  13170. if (call.innerComments) {
  13171. setInnerComments(node, call.innerComments);
  13172. }
  13173. if (call.callee.trailingComments) {
  13174. setInnerComments(node, call.callee.trailingComments);
  13175. }
  13176. return node;
  13177. }
  13178. parseNoCallExpr() {
  13179. const startLoc = this.state.startLoc;
  13180. return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
  13181. }
  13182. parseExprAtom(refExpressionErrors) {
  13183. let node;
  13184. let decorators = null;
  13185. const {
  13186. type
  13187. } = this.state;
  13188. switch (type) {
  13189. case 79:
  13190. return this.parseSuper();
  13191. case 83:
  13192. node = this.startNode();
  13193. this.next();
  13194. if (this.match(16)) {
  13195. return this.parseImportMetaProperty(node);
  13196. }
  13197. if (this.match(10)) {
  13198. if (this.options.createImportExpressions) {
  13199. return this.parseImportCall(node);
  13200. } else {
  13201. return this.finishNode(node, "Import");
  13202. }
  13203. } else {
  13204. this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
  13205. return this.finishNode(node, "Import");
  13206. }
  13207. case 78:
  13208. node = this.startNode();
  13209. this.next();
  13210. return this.finishNode(node, "ThisExpression");
  13211. case 90:
  13212. {
  13213. return this.parseDo(this.startNode(), false);
  13214. }
  13215. case 56:
  13216. case 31:
  13217. {
  13218. this.readRegexp();
  13219. return this.parseRegExpLiteral(this.state.value);
  13220. }
  13221. case 134:
  13222. return this.parseNumericLiteral(this.state.value);
  13223. case 135:
  13224. return this.parseBigIntLiteral(this.state.value);
  13225. case 136:
  13226. return this.parseDecimalLiteral(this.state.value);
  13227. case 133:
  13228. return this.parseStringLiteral(this.state.value);
  13229. case 84:
  13230. return this.parseNullLiteral();
  13231. case 85:
  13232. return this.parseBooleanLiteral(true);
  13233. case 86:
  13234. return this.parseBooleanLiteral(false);
  13235. case 10:
  13236. {
  13237. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13238. return this.parseParenAndDistinguishExpression(canBeArrow);
  13239. }
  13240. case 2:
  13241. case 1:
  13242. {
  13243. return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true);
  13244. }
  13245. case 0:
  13246. {
  13247. return this.parseArrayLike(3, true, false, refExpressionErrors);
  13248. }
  13249. case 6:
  13250. case 7:
  13251. {
  13252. return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
  13253. }
  13254. case 5:
  13255. {
  13256. return this.parseObjectLike(8, false, false, refExpressionErrors);
  13257. }
  13258. case 68:
  13259. return this.parseFunctionOrFunctionSent();
  13260. case 26:
  13261. decorators = this.parseDecorators();
  13262. case 80:
  13263. return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
  13264. case 77:
  13265. return this.parseNewOrNewTarget();
  13266. case 25:
  13267. case 24:
  13268. return this.parseTemplate(false);
  13269. case 15:
  13270. {
  13271. node = this.startNode();
  13272. this.next();
  13273. node.object = null;
  13274. const callee = node.callee = this.parseNoCallExpr();
  13275. if (callee.type === "MemberExpression") {
  13276. return this.finishNode(node, "BindExpression");
  13277. } else {
  13278. throw this.raise(Errors.UnsupportedBind, callee);
  13279. }
  13280. }
  13281. case 138:
  13282. {
  13283. this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
  13284. identifierName: this.state.value
  13285. });
  13286. return this.parsePrivateName();
  13287. }
  13288. case 33:
  13289. {
  13290. return this.parseTopicReferenceThenEqualsSign(54, "%");
  13291. }
  13292. case 32:
  13293. {
  13294. return this.parseTopicReferenceThenEqualsSign(44, "^");
  13295. }
  13296. case 37:
  13297. case 38:
  13298. {
  13299. return this.parseTopicReference("hack");
  13300. }
  13301. case 44:
  13302. case 54:
  13303. case 27:
  13304. {
  13305. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13306. if (pipeProposal) {
  13307. return this.parseTopicReference(pipeProposal);
  13308. }
  13309. this.unexpected();
  13310. break;
  13311. }
  13312. case 47:
  13313. {
  13314. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  13315. if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
  13316. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  13317. } else {
  13318. this.unexpected();
  13319. }
  13320. break;
  13321. }
  13322. default:
  13323. if (tokenIsIdentifier(type)) {
  13324. if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) {
  13325. return this.parseModuleExpression();
  13326. }
  13327. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13328. const containsEsc = this.state.containsEsc;
  13329. const id = this.parseIdentifier();
  13330. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  13331. const {
  13332. type
  13333. } = this.state;
  13334. if (type === 68) {
  13335. this.resetPreviousNodeTrailingComments(id);
  13336. this.next();
  13337. return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
  13338. } else if (tokenIsIdentifier(type)) {
  13339. if (this.lookaheadCharCode() === 61) {
  13340. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  13341. } else {
  13342. return id;
  13343. }
  13344. } else if (type === 90) {
  13345. this.resetPreviousNodeTrailingComments(id);
  13346. return this.parseDo(this.startNodeAtNode(id), true);
  13347. }
  13348. }
  13349. if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) {
  13350. this.next();
  13351. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  13352. }
  13353. return id;
  13354. } else {
  13355. this.unexpected();
  13356. }
  13357. }
  13358. }
  13359. parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
  13360. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13361. if (pipeProposal) {
  13362. this.state.type = topicTokenType;
  13363. this.state.value = topicTokenValue;
  13364. this.state.pos--;
  13365. this.state.end--;
  13366. this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
  13367. return this.parseTopicReference(pipeProposal);
  13368. } else {
  13369. this.unexpected();
  13370. }
  13371. }
  13372. parseTopicReference(pipeProposal) {
  13373. const node = this.startNode();
  13374. const startLoc = this.state.startLoc;
  13375. const tokenType = this.state.type;
  13376. this.next();
  13377. return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
  13378. }
  13379. finishTopicReference(node, startLoc, pipeProposal, tokenType) {
  13380. if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
  13381. const nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
  13382. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13383. this.raise(pipeProposal === "smart" ? Errors.PrimaryTopicNotAllowed : Errors.PipeTopicUnbound, startLoc);
  13384. }
  13385. this.registerTopicReference();
  13386. return this.finishNode(node, nodeType);
  13387. } else {
  13388. throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
  13389. token: tokenLabelName(tokenType)
  13390. });
  13391. }
  13392. }
  13393. testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
  13394. switch (pipeProposal) {
  13395. case "hack":
  13396. {
  13397. return this.hasPlugin(["pipelineOperator", {
  13398. topicToken: tokenLabelName(tokenType)
  13399. }]);
  13400. }
  13401. case "smart":
  13402. return tokenType === 27;
  13403. default:
  13404. throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
  13405. }
  13406. }
  13407. parseAsyncArrowUnaryFunction(node) {
  13408. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  13409. const params = [this.parseIdentifier()];
  13410. this.prodParam.exit();
  13411. if (this.hasPrecedingLineBreak()) {
  13412. this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
  13413. }
  13414. this.expect(19);
  13415. return this.parseArrowExpression(node, params, true);
  13416. }
  13417. parseDo(node, isAsync) {
  13418. this.expectPlugin("doExpressions");
  13419. if (isAsync) {
  13420. this.expectPlugin("asyncDoExpressions");
  13421. }
  13422. node.async = isAsync;
  13423. this.next();
  13424. const oldLabels = this.state.labels;
  13425. this.state.labels = [];
  13426. if (isAsync) {
  13427. this.prodParam.enter(2);
  13428. node.body = this.parseBlock();
  13429. this.prodParam.exit();
  13430. } else {
  13431. node.body = this.parseBlock();
  13432. }
  13433. this.state.labels = oldLabels;
  13434. return this.finishNode(node, "DoExpression");
  13435. }
  13436. parseSuper() {
  13437. const node = this.startNode();
  13438. this.next();
  13439. if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
  13440. this.raise(Errors.SuperNotAllowed, node);
  13441. } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
  13442. this.raise(Errors.UnexpectedSuper, node);
  13443. }
  13444. if (!this.match(10) && !this.match(0) && !this.match(16)) {
  13445. this.raise(Errors.UnsupportedSuper, node);
  13446. }
  13447. return this.finishNode(node, "Super");
  13448. }
  13449. parsePrivateName() {
  13450. const node = this.startNode();
  13451. const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
  13452. const name = this.state.value;
  13453. this.next();
  13454. node.id = this.createIdentifier(id, name);
  13455. return this.finishNode(node, "PrivateName");
  13456. }
  13457. parseFunctionOrFunctionSent() {
  13458. const node = this.startNode();
  13459. this.next();
  13460. if (this.prodParam.hasYield && this.match(16)) {
  13461. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  13462. this.next();
  13463. if (this.match(103)) {
  13464. this.expectPlugin("functionSent");
  13465. } else if (!this.hasPlugin("functionSent")) {
  13466. this.unexpected();
  13467. }
  13468. return this.parseMetaProperty(node, meta, "sent");
  13469. }
  13470. return this.parseFunction(node);
  13471. }
  13472. parseMetaProperty(node, meta, propertyName) {
  13473. node.meta = meta;
  13474. const containsEsc = this.state.containsEsc;
  13475. node.property = this.parseIdentifier(true);
  13476. if (node.property.name !== propertyName || containsEsc) {
  13477. this.raise(Errors.UnsupportedMetaProperty, node.property, {
  13478. target: meta.name,
  13479. onlyValidPropertyName: propertyName
  13480. });
  13481. }
  13482. return this.finishNode(node, "MetaProperty");
  13483. }
  13484. parseImportMetaProperty(node) {
  13485. const id = this.createIdentifier(this.startNodeAtNode(node), "import");
  13486. this.next();
  13487. if (this.isContextual(101)) {
  13488. if (!this.inModule) {
  13489. this.raise(Errors.ImportMetaOutsideModule, id);
  13490. }
  13491. this.sawUnambiguousESM = true;
  13492. } else if (this.isContextual(105) || this.isContextual(97)) {
  13493. const isSource = this.isContextual(105);
  13494. if (!isSource) this.unexpected();
  13495. this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
  13496. if (!this.options.createImportExpressions) {
  13497. throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, {
  13498. phase: this.state.value
  13499. });
  13500. }
  13501. this.next();
  13502. node.phase = isSource ? "source" : "defer";
  13503. return this.parseImportCall(node);
  13504. }
  13505. return this.parseMetaProperty(node, id, "meta");
  13506. }
  13507. parseLiteralAtNode(value, type, node) {
  13508. this.addExtra(node, "rawValue", value);
  13509. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13510. node.value = value;
  13511. this.next();
  13512. return this.finishNode(node, type);
  13513. }
  13514. parseLiteral(value, type) {
  13515. const node = this.startNode();
  13516. return this.parseLiteralAtNode(value, type, node);
  13517. }
  13518. parseStringLiteral(value) {
  13519. return this.parseLiteral(value, "StringLiteral");
  13520. }
  13521. parseNumericLiteral(value) {
  13522. return this.parseLiteral(value, "NumericLiteral");
  13523. }
  13524. parseBigIntLiteral(value) {
  13525. return this.parseLiteral(value, "BigIntLiteral");
  13526. }
  13527. parseDecimalLiteral(value) {
  13528. return this.parseLiteral(value, "DecimalLiteral");
  13529. }
  13530. parseRegExpLiteral(value) {
  13531. const node = this.startNode();
  13532. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13533. node.pattern = value.pattern;
  13534. node.flags = value.flags;
  13535. this.next();
  13536. return this.finishNode(node, "RegExpLiteral");
  13537. }
  13538. parseBooleanLiteral(value) {
  13539. const node = this.startNode();
  13540. node.value = value;
  13541. this.next();
  13542. return this.finishNode(node, "BooleanLiteral");
  13543. }
  13544. parseNullLiteral() {
  13545. const node = this.startNode();
  13546. this.next();
  13547. return this.finishNode(node, "NullLiteral");
  13548. }
  13549. parseParenAndDistinguishExpression(canBeArrow) {
  13550. const startLoc = this.state.startLoc;
  13551. let val;
  13552. this.next();
  13553. this.expressionScope.enter(newArrowHeadScope());
  13554. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13555. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13556. this.state.maybeInArrowParameters = true;
  13557. this.state.inFSharpPipelineDirectBody = false;
  13558. const innerStartLoc = this.state.startLoc;
  13559. const exprList = [];
  13560. const refExpressionErrors = new ExpressionErrors();
  13561. let first = true;
  13562. let spreadStartLoc;
  13563. let optionalCommaStartLoc;
  13564. while (!this.match(11)) {
  13565. if (first) {
  13566. first = false;
  13567. } else {
  13568. this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
  13569. if (this.match(11)) {
  13570. optionalCommaStartLoc = this.state.startLoc;
  13571. break;
  13572. }
  13573. }
  13574. if (this.match(21)) {
  13575. const spreadNodeStartLoc = this.state.startLoc;
  13576. spreadStartLoc = this.state.startLoc;
  13577. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
  13578. if (!this.checkCommaAfterRest(41)) {
  13579. break;
  13580. }
  13581. } else {
  13582. exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
  13583. }
  13584. }
  13585. const innerEndLoc = this.state.lastTokEndLoc;
  13586. this.expect(11);
  13587. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13588. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13589. let arrowNode = this.startNodeAt(startLoc);
  13590. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  13591. this.checkDestructuringPrivate(refExpressionErrors);
  13592. this.expressionScope.validateAsPattern();
  13593. this.expressionScope.exit();
  13594. this.parseArrowExpression(arrowNode, exprList, false);
  13595. return arrowNode;
  13596. }
  13597. this.expressionScope.exit();
  13598. if (!exprList.length) {
  13599. this.unexpected(this.state.lastTokStartLoc);
  13600. }
  13601. if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
  13602. if (spreadStartLoc) this.unexpected(spreadStartLoc);
  13603. this.checkExpressionErrors(refExpressionErrors, true);
  13604. this.toReferencedListDeep(exprList, true);
  13605. if (exprList.length > 1) {
  13606. val = this.startNodeAt(innerStartLoc);
  13607. val.expressions = exprList;
  13608. this.finishNode(val, "SequenceExpression");
  13609. this.resetEndLocation(val, innerEndLoc);
  13610. } else {
  13611. val = exprList[0];
  13612. }
  13613. return this.wrapParenthesis(startLoc, val);
  13614. }
  13615. wrapParenthesis(startLoc, expression) {
  13616. if (!this.options.createParenthesizedExpressions) {
  13617. this.addExtra(expression, "parenthesized", true);
  13618. this.addExtra(expression, "parenStart", startLoc.index);
  13619. this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
  13620. return expression;
  13621. }
  13622. const parenExpression = this.startNodeAt(startLoc);
  13623. parenExpression.expression = expression;
  13624. return this.finishNode(parenExpression, "ParenthesizedExpression");
  13625. }
  13626. shouldParseArrow(params) {
  13627. return !this.canInsertSemicolon();
  13628. }
  13629. parseArrow(node) {
  13630. if (this.eat(19)) {
  13631. return node;
  13632. }
  13633. }
  13634. parseParenItem(node, startLoc) {
  13635. return node;
  13636. }
  13637. parseNewOrNewTarget() {
  13638. const node = this.startNode();
  13639. this.next();
  13640. if (this.match(16)) {
  13641. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  13642. this.next();
  13643. const metaProp = this.parseMetaProperty(node, meta, "target");
  13644. if (!this.scope.inNonArrowFunction && !this.scope.inClass && !this.options.allowNewTargetOutsideFunction) {
  13645. this.raise(Errors.UnexpectedNewTarget, metaProp);
  13646. }
  13647. return metaProp;
  13648. }
  13649. return this.parseNew(node);
  13650. }
  13651. parseNew(node) {
  13652. this.parseNewCallee(node);
  13653. if (this.eat(10)) {
  13654. const args = this.parseExprList(11);
  13655. this.toReferencedList(args);
  13656. node.arguments = args;
  13657. } else {
  13658. node.arguments = [];
  13659. }
  13660. return this.finishNode(node, "NewExpression");
  13661. }
  13662. parseNewCallee(node) {
  13663. const isImport = this.match(83);
  13664. const callee = this.parseNoCallExpr();
  13665. node.callee = callee;
  13666. if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) {
  13667. this.raise(Errors.ImportCallNotNewExpression, callee);
  13668. }
  13669. }
  13670. parseTemplateElement(isTagged) {
  13671. const {
  13672. start,
  13673. startLoc,
  13674. end,
  13675. value
  13676. } = this.state;
  13677. const elemStart = start + 1;
  13678. const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
  13679. if (value === null) {
  13680. if (!isTagged) {
  13681. this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
  13682. }
  13683. }
  13684. const isTail = this.match(24);
  13685. const endOffset = isTail ? -1 : -2;
  13686. const elemEnd = end + endOffset;
  13687. elem.value = {
  13688. raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
  13689. cooked: value === null ? null : value.slice(1, endOffset)
  13690. };
  13691. elem.tail = isTail;
  13692. this.next();
  13693. const finishedNode = this.finishNode(elem, "TemplateElement");
  13694. this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
  13695. return finishedNode;
  13696. }
  13697. parseTemplate(isTagged) {
  13698. const node = this.startNode();
  13699. let curElt = this.parseTemplateElement(isTagged);
  13700. const quasis = [curElt];
  13701. const substitutions = [];
  13702. while (!curElt.tail) {
  13703. substitutions.push(this.parseTemplateSubstitution());
  13704. this.readTemplateContinuation();
  13705. quasis.push(curElt = this.parseTemplateElement(isTagged));
  13706. }
  13707. node.expressions = substitutions;
  13708. node.quasis = quasis;
  13709. return this.finishNode(node, "TemplateLiteral");
  13710. }
  13711. parseTemplateSubstitution() {
  13712. return this.parseExpression();
  13713. }
  13714. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  13715. if (isRecord) {
  13716. this.expectPlugin("recordAndTuple");
  13717. }
  13718. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13719. this.state.inFSharpPipelineDirectBody = false;
  13720. const propHash = Object.create(null);
  13721. let first = true;
  13722. const node = this.startNode();
  13723. node.properties = [];
  13724. this.next();
  13725. while (!this.match(close)) {
  13726. if (first) {
  13727. first = false;
  13728. } else {
  13729. this.expect(12);
  13730. if (this.match(close)) {
  13731. this.addTrailingCommaExtraToNode(node);
  13732. break;
  13733. }
  13734. }
  13735. let prop;
  13736. if (isPattern) {
  13737. prop = this.parseBindingProperty();
  13738. } else {
  13739. prop = this.parsePropertyDefinition(refExpressionErrors);
  13740. this.checkProto(prop, isRecord, propHash, refExpressionErrors);
  13741. }
  13742. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  13743. this.raise(Errors.InvalidRecordProperty, prop);
  13744. }
  13745. {
  13746. if (prop.shorthand) {
  13747. this.addExtra(prop, "shorthand", true);
  13748. }
  13749. }
  13750. node.properties.push(prop);
  13751. }
  13752. this.next();
  13753. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13754. let type = "ObjectExpression";
  13755. if (isPattern) {
  13756. type = "ObjectPattern";
  13757. } else if (isRecord) {
  13758. type = "RecordExpression";
  13759. }
  13760. return this.finishNode(node, type);
  13761. }
  13762. addTrailingCommaExtraToNode(node) {
  13763. this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
  13764. this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
  13765. }
  13766. maybeAsyncOrAccessorProp(prop) {
  13767. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55));
  13768. }
  13769. parsePropertyDefinition(refExpressionErrors) {
  13770. let decorators = [];
  13771. if (this.match(26)) {
  13772. if (this.hasPlugin("decorators")) {
  13773. this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
  13774. }
  13775. while (this.match(26)) {
  13776. decorators.push(this.parseDecorator());
  13777. }
  13778. }
  13779. const prop = this.startNode();
  13780. let isAsync = false;
  13781. let isAccessor = false;
  13782. let startLoc;
  13783. if (this.match(21)) {
  13784. if (decorators.length) this.unexpected();
  13785. return this.parseSpread();
  13786. }
  13787. if (decorators.length) {
  13788. prop.decorators = decorators;
  13789. decorators = [];
  13790. }
  13791. prop.method = false;
  13792. if (refExpressionErrors) {
  13793. startLoc = this.state.startLoc;
  13794. }
  13795. let isGenerator = this.eat(55);
  13796. this.parsePropertyNamePrefixOperator(prop);
  13797. const containsEsc = this.state.containsEsc;
  13798. this.parsePropertyName(prop, refExpressionErrors);
  13799. if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  13800. const {
  13801. key
  13802. } = prop;
  13803. const keyName = key.name;
  13804. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  13805. isAsync = true;
  13806. this.resetPreviousNodeTrailingComments(key);
  13807. isGenerator = this.eat(55);
  13808. this.parsePropertyName(prop);
  13809. }
  13810. if (keyName === "get" || keyName === "set") {
  13811. isAccessor = true;
  13812. this.resetPreviousNodeTrailingComments(key);
  13813. prop.kind = keyName;
  13814. if (this.match(55)) {
  13815. isGenerator = true;
  13816. this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
  13817. kind: keyName
  13818. });
  13819. this.next();
  13820. }
  13821. this.parsePropertyName(prop);
  13822. }
  13823. }
  13824. return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
  13825. }
  13826. getGetterSetterExpectedParamCount(method) {
  13827. return method.kind === "get" ? 0 : 1;
  13828. }
  13829. getObjectOrClassMethodParams(method) {
  13830. return method.params;
  13831. }
  13832. checkGetterSetterParams(method) {
  13833. var _params;
  13834. const paramCount = this.getGetterSetterExpectedParamCount(method);
  13835. const params = this.getObjectOrClassMethodParams(method);
  13836. if (params.length !== paramCount) {
  13837. this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
  13838. }
  13839. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  13840. this.raise(Errors.BadSetterRestParameter, method);
  13841. }
  13842. }
  13843. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  13844. if (isAccessor) {
  13845. const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  13846. this.checkGetterSetterParams(finishedProp);
  13847. return finishedProp;
  13848. }
  13849. if (isAsync || isGenerator || this.match(10)) {
  13850. if (isPattern) this.unexpected();
  13851. prop.kind = "method";
  13852. prop.method = true;
  13853. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  13854. }
  13855. }
  13856. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  13857. prop.shorthand = false;
  13858. if (this.eat(14)) {
  13859. prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
  13860. return this.finishNode(prop, "ObjectProperty");
  13861. }
  13862. if (!prop.computed && prop.key.type === "Identifier") {
  13863. this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
  13864. if (isPattern) {
  13865. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13866. } else if (this.match(29)) {
  13867. const shorthandAssignLoc = this.state.startLoc;
  13868. if (refExpressionErrors != null) {
  13869. if (refExpressionErrors.shorthandAssignLoc === null) {
  13870. refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
  13871. }
  13872. } else {
  13873. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  13874. }
  13875. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13876. } else {
  13877. prop.value = cloneIdentifier(prop.key);
  13878. }
  13879. prop.shorthand = true;
  13880. return this.finishNode(prop, "ObjectProperty");
  13881. }
  13882. }
  13883. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  13884. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  13885. if (!node) this.unexpected();
  13886. return node;
  13887. }
  13888. parsePropertyName(prop, refExpressionErrors) {
  13889. if (this.eat(0)) {
  13890. prop.computed = true;
  13891. prop.key = this.parseMaybeAssignAllowIn();
  13892. this.expect(3);
  13893. } else {
  13894. const {
  13895. type,
  13896. value
  13897. } = this.state;
  13898. let key;
  13899. if (tokenIsKeywordOrIdentifier(type)) {
  13900. key = this.parseIdentifier(true);
  13901. } else {
  13902. switch (type) {
  13903. case 134:
  13904. key = this.parseNumericLiteral(value);
  13905. break;
  13906. case 133:
  13907. key = this.parseStringLiteral(value);
  13908. break;
  13909. case 135:
  13910. key = this.parseBigIntLiteral(value);
  13911. break;
  13912. case 136:
  13913. key = this.parseDecimalLiteral(value);
  13914. break;
  13915. case 138:
  13916. {
  13917. const privateKeyLoc = this.state.startLoc;
  13918. if (refExpressionErrors != null) {
  13919. if (refExpressionErrors.privateKeyLoc === null) {
  13920. refExpressionErrors.privateKeyLoc = privateKeyLoc;
  13921. }
  13922. } else {
  13923. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  13924. }
  13925. key = this.parsePrivateName();
  13926. break;
  13927. }
  13928. default:
  13929. this.unexpected();
  13930. }
  13931. }
  13932. prop.key = key;
  13933. if (type !== 138) {
  13934. prop.computed = false;
  13935. }
  13936. }
  13937. }
  13938. initFunction(node, isAsync) {
  13939. node.id = null;
  13940. node.generator = false;
  13941. node.async = isAsync;
  13942. }
  13943. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  13944. this.initFunction(node, isAsync);
  13945. node.generator = isGenerator;
  13946. this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0));
  13947. this.prodParam.enter(functionFlags(isAsync, node.generator));
  13948. this.parseFunctionParams(node, isConstructor);
  13949. const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
  13950. this.prodParam.exit();
  13951. this.scope.exit();
  13952. return finishedNode;
  13953. }
  13954. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  13955. if (isTuple) {
  13956. this.expectPlugin("recordAndTuple");
  13957. }
  13958. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13959. this.state.inFSharpPipelineDirectBody = false;
  13960. const node = this.startNode();
  13961. this.next();
  13962. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  13963. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13964. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  13965. }
  13966. parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
  13967. this.scope.enter(2 | 4);
  13968. let flags = functionFlags(isAsync, false);
  13969. if (!this.match(5) && this.prodParam.hasIn) {
  13970. flags |= 8;
  13971. }
  13972. this.prodParam.enter(flags);
  13973. this.initFunction(node, isAsync);
  13974. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13975. if (params) {
  13976. this.state.maybeInArrowParameters = true;
  13977. this.setArrowFunctionParameters(node, params, trailingCommaLoc);
  13978. }
  13979. this.state.maybeInArrowParameters = false;
  13980. this.parseFunctionBody(node, true);
  13981. this.prodParam.exit();
  13982. this.scope.exit();
  13983. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13984. return this.finishNode(node, "ArrowFunctionExpression");
  13985. }
  13986. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  13987. this.toAssignableList(params, trailingCommaLoc, false);
  13988. node.params = params;
  13989. }
  13990. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  13991. this.parseFunctionBody(node, false, isMethod);
  13992. return this.finishNode(node, type);
  13993. }
  13994. parseFunctionBody(node, allowExpression, isMethod = false) {
  13995. const isExpression = allowExpression && !this.match(5);
  13996. this.expressionScope.enter(newExpressionScope());
  13997. if (isExpression) {
  13998. node.body = this.parseMaybeAssign();
  13999. this.checkParams(node, false, allowExpression, false);
  14000. } else {
  14001. const oldStrict = this.state.strict;
  14002. const oldLabels = this.state.labels;
  14003. this.state.labels = [];
  14004. this.prodParam.enter(this.prodParam.currentFlags() | 4);
  14005. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  14006. const nonSimple = !this.isSimpleParamList(node.params);
  14007. if (hasStrictModeDirective && nonSimple) {
  14008. this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
  14009. }
  14010. const strictModeChanged = !oldStrict && this.state.strict;
  14011. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  14012. if (this.state.strict && node.id) {
  14013. this.checkIdentifier(node.id, 65, strictModeChanged);
  14014. }
  14015. });
  14016. this.prodParam.exit();
  14017. this.state.labels = oldLabels;
  14018. }
  14019. this.expressionScope.exit();
  14020. }
  14021. isSimpleParameter(node) {
  14022. return node.type === "Identifier";
  14023. }
  14024. isSimpleParamList(params) {
  14025. for (let i = 0, len = params.length; i < len; i++) {
  14026. if (!this.isSimpleParameter(params[i])) return false;
  14027. }
  14028. return true;
  14029. }
  14030. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  14031. const checkClashes = !allowDuplicates && new Set();
  14032. const formalParameters = {
  14033. type: "FormalParameters"
  14034. };
  14035. for (const param of node.params) {
  14036. this.checkLVal(param, formalParameters, 5, checkClashes, strictModeChanged);
  14037. }
  14038. }
  14039. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  14040. const elts = [];
  14041. let first = true;
  14042. while (!this.eat(close)) {
  14043. if (first) {
  14044. first = false;
  14045. } else {
  14046. this.expect(12);
  14047. if (this.match(close)) {
  14048. if (nodeForExtra) {
  14049. this.addTrailingCommaExtraToNode(nodeForExtra);
  14050. }
  14051. this.next();
  14052. break;
  14053. }
  14054. }
  14055. elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
  14056. }
  14057. return elts;
  14058. }
  14059. parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
  14060. let elt;
  14061. if (this.match(12)) {
  14062. if (!allowEmpty) {
  14063. this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
  14064. unexpected: ","
  14065. });
  14066. }
  14067. elt = null;
  14068. } else if (this.match(21)) {
  14069. const spreadNodeStartLoc = this.state.startLoc;
  14070. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
  14071. } else if (this.match(17)) {
  14072. this.expectPlugin("partialApplication");
  14073. if (!allowPlaceholder) {
  14074. this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
  14075. }
  14076. const node = this.startNode();
  14077. this.next();
  14078. elt = this.finishNode(node, "ArgumentPlaceholder");
  14079. } else {
  14080. elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
  14081. }
  14082. return elt;
  14083. }
  14084. parseIdentifier(liberal) {
  14085. const node = this.startNode();
  14086. const name = this.parseIdentifierName(liberal);
  14087. return this.createIdentifier(node, name);
  14088. }
  14089. createIdentifier(node, name) {
  14090. node.name = name;
  14091. node.loc.identifierName = name;
  14092. return this.finishNode(node, "Identifier");
  14093. }
  14094. parseIdentifierName(liberal) {
  14095. let name;
  14096. const {
  14097. startLoc,
  14098. type
  14099. } = this.state;
  14100. if (tokenIsKeywordOrIdentifier(type)) {
  14101. name = this.state.value;
  14102. } else {
  14103. this.unexpected();
  14104. }
  14105. const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
  14106. if (liberal) {
  14107. if (tokenIsKeyword) {
  14108. this.replaceToken(132);
  14109. }
  14110. } else {
  14111. this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
  14112. }
  14113. this.next();
  14114. return name;
  14115. }
  14116. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  14117. if (word.length > 10) {
  14118. return;
  14119. }
  14120. if (!canBeReservedWord(word)) {
  14121. return;
  14122. }
  14123. if (checkKeywords && isKeyword(word)) {
  14124. this.raise(Errors.UnexpectedKeyword, startLoc, {
  14125. keyword: word
  14126. });
  14127. return;
  14128. }
  14129. const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
  14130. if (reservedTest(word, this.inModule)) {
  14131. this.raise(Errors.UnexpectedReservedWord, startLoc, {
  14132. reservedWord: word
  14133. });
  14134. return;
  14135. } else if (word === "yield") {
  14136. if (this.prodParam.hasYield) {
  14137. this.raise(Errors.YieldBindingIdentifier, startLoc);
  14138. return;
  14139. }
  14140. } else if (word === "await") {
  14141. if (this.prodParam.hasAwait) {
  14142. this.raise(Errors.AwaitBindingIdentifier, startLoc);
  14143. return;
  14144. }
  14145. if (this.scope.inStaticBlock) {
  14146. this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
  14147. return;
  14148. }
  14149. this.expressionScope.recordAsyncArrowParametersError(startLoc);
  14150. } else if (word === "arguments") {
  14151. if (this.scope.inClassAndNotInNonArrowFunction) {
  14152. this.raise(Errors.ArgumentsInClass, startLoc);
  14153. return;
  14154. }
  14155. }
  14156. }
  14157. recordAwaitIfAllowed() {
  14158. const isAwaitAllowed = this.prodParam.hasAwait || this.options.allowAwaitOutsideFunction && !this.scope.inFunction;
  14159. if (isAwaitAllowed && !this.scope.inFunction) {
  14160. this.state.hasTopLevelAwait = true;
  14161. }
  14162. return isAwaitAllowed;
  14163. }
  14164. parseAwait(startLoc) {
  14165. const node = this.startNodeAt(startLoc);
  14166. this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
  14167. if (this.eat(55)) {
  14168. this.raise(Errors.ObsoleteAwaitStar, node);
  14169. }
  14170. if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
  14171. if (this.isAmbiguousAwait()) {
  14172. this.ambiguousScriptDifferentAst = true;
  14173. } else {
  14174. this.sawUnambiguousESM = true;
  14175. }
  14176. }
  14177. if (!this.state.soloAwait) {
  14178. node.argument = this.parseMaybeUnary(null, true);
  14179. }
  14180. return this.finishNode(node, "AwaitExpression");
  14181. }
  14182. isAmbiguousAwait() {
  14183. if (this.hasPrecedingLineBreak()) return true;
  14184. const {
  14185. type
  14186. } = this.state;
  14187. return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
  14188. }
  14189. parseYield() {
  14190. const node = this.startNode();
  14191. this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
  14192. this.next();
  14193. let delegating = false;
  14194. let argument = null;
  14195. if (!this.hasPrecedingLineBreak()) {
  14196. delegating = this.eat(55);
  14197. switch (this.state.type) {
  14198. case 13:
  14199. case 139:
  14200. case 8:
  14201. case 11:
  14202. case 3:
  14203. case 9:
  14204. case 14:
  14205. case 12:
  14206. if (!delegating) break;
  14207. default:
  14208. argument = this.parseMaybeAssign();
  14209. }
  14210. }
  14211. node.delegate = delegating;
  14212. node.argument = argument;
  14213. return this.finishNode(node, "YieldExpression");
  14214. }
  14215. parseImportCall(node) {
  14216. this.next();
  14217. node.source = this.parseMaybeAssignAllowIn();
  14218. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  14219. node.options = null;
  14220. }
  14221. if (this.eat(12)) {
  14222. this.expectImportAttributesPlugin();
  14223. if (!this.match(11)) {
  14224. node.options = this.parseMaybeAssignAllowIn();
  14225. this.eat(12);
  14226. }
  14227. }
  14228. this.expect(11);
  14229. return this.finishNode(node, "ImportExpression");
  14230. }
  14231. checkPipelineAtInfixOperator(left, leftStartLoc) {
  14232. if (this.hasPlugin(["pipelineOperator", {
  14233. proposal: "smart"
  14234. }])) {
  14235. if (left.type === "SequenceExpression") {
  14236. this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
  14237. }
  14238. }
  14239. }
  14240. parseSmartPipelineBodyInStyle(childExpr, startLoc) {
  14241. if (this.isSimpleReference(childExpr)) {
  14242. const bodyNode = this.startNodeAt(startLoc);
  14243. bodyNode.callee = childExpr;
  14244. return this.finishNode(bodyNode, "PipelineBareFunction");
  14245. } else {
  14246. const bodyNode = this.startNodeAt(startLoc);
  14247. this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
  14248. bodyNode.expression = childExpr;
  14249. return this.finishNode(bodyNode, "PipelineTopicExpression");
  14250. }
  14251. }
  14252. isSimpleReference(expression) {
  14253. switch (expression.type) {
  14254. case "MemberExpression":
  14255. return !expression.computed && this.isSimpleReference(expression.object);
  14256. case "Identifier":
  14257. return true;
  14258. default:
  14259. return false;
  14260. }
  14261. }
  14262. checkSmartPipeTopicBodyEarlyErrors(startLoc) {
  14263. if (this.match(19)) {
  14264. throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
  14265. }
  14266. if (!this.topicReferenceWasUsedInCurrentContext()) {
  14267. this.raise(Errors.PipelineTopicUnused, startLoc);
  14268. }
  14269. }
  14270. withTopicBindingContext(callback) {
  14271. const outerContextTopicState = this.state.topicContext;
  14272. this.state.topicContext = {
  14273. maxNumOfResolvableTopics: 1,
  14274. maxTopicIndex: null
  14275. };
  14276. try {
  14277. return callback();
  14278. } finally {
  14279. this.state.topicContext = outerContextTopicState;
  14280. }
  14281. }
  14282. withSmartMixTopicForbiddingContext(callback) {
  14283. if (this.hasPlugin(["pipelineOperator", {
  14284. proposal: "smart"
  14285. }])) {
  14286. const outerContextTopicState = this.state.topicContext;
  14287. this.state.topicContext = {
  14288. maxNumOfResolvableTopics: 0,
  14289. maxTopicIndex: null
  14290. };
  14291. try {
  14292. return callback();
  14293. } finally {
  14294. this.state.topicContext = outerContextTopicState;
  14295. }
  14296. } else {
  14297. return callback();
  14298. }
  14299. }
  14300. withSoloAwaitPermittingContext(callback) {
  14301. const outerContextSoloAwaitState = this.state.soloAwait;
  14302. this.state.soloAwait = true;
  14303. try {
  14304. return callback();
  14305. } finally {
  14306. this.state.soloAwait = outerContextSoloAwaitState;
  14307. }
  14308. }
  14309. allowInAnd(callback) {
  14310. const flags = this.prodParam.currentFlags();
  14311. const prodParamToSet = 8 & ~flags;
  14312. if (prodParamToSet) {
  14313. this.prodParam.enter(flags | 8);
  14314. try {
  14315. return callback();
  14316. } finally {
  14317. this.prodParam.exit();
  14318. }
  14319. }
  14320. return callback();
  14321. }
  14322. disallowInAnd(callback) {
  14323. const flags = this.prodParam.currentFlags();
  14324. const prodParamToClear = 8 & flags;
  14325. if (prodParamToClear) {
  14326. this.prodParam.enter(flags & ~8);
  14327. try {
  14328. return callback();
  14329. } finally {
  14330. this.prodParam.exit();
  14331. }
  14332. }
  14333. return callback();
  14334. }
  14335. registerTopicReference() {
  14336. this.state.topicContext.maxTopicIndex = 0;
  14337. }
  14338. topicReferenceIsAllowedInCurrentContext() {
  14339. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  14340. }
  14341. topicReferenceWasUsedInCurrentContext() {
  14342. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  14343. }
  14344. parseFSharpPipelineBody(prec) {
  14345. const startLoc = this.state.startLoc;
  14346. this.state.potentialArrowAt = this.state.start;
  14347. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14348. this.state.inFSharpPipelineDirectBody = true;
  14349. const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
  14350. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14351. return ret;
  14352. }
  14353. parseModuleExpression() {
  14354. this.expectPlugin("moduleBlocks");
  14355. const node = this.startNode();
  14356. this.next();
  14357. if (!this.match(5)) {
  14358. this.unexpected(null, 5);
  14359. }
  14360. const program = this.startNodeAt(this.state.endLoc);
  14361. this.next();
  14362. const revertScopes = this.initializeScopes(true);
  14363. this.enterInitialScopes();
  14364. try {
  14365. node.body = this.parseProgram(program, 8, "module");
  14366. } finally {
  14367. revertScopes();
  14368. }
  14369. return this.finishNode(node, "ModuleExpression");
  14370. }
  14371. parsePropertyNamePrefixOperator(prop) {}
  14372. }
  14373. const loopLabel = {
  14374. kind: 1
  14375. },
  14376. switchLabel = {
  14377. kind: 2
  14378. };
  14379. const loneSurrogate = /[\uD800-\uDFFF]/u;
  14380. const keywordRelationalOperator = /in(?:stanceof)?/y;
  14381. function babel7CompatTokens(tokens, input) {
  14382. for (let i = 0; i < tokens.length; i++) {
  14383. const token = tokens[i];
  14384. const {
  14385. type
  14386. } = token;
  14387. if (typeof type === "number") {
  14388. {
  14389. if (type === 138) {
  14390. const {
  14391. loc,
  14392. start,
  14393. value,
  14394. end
  14395. } = token;
  14396. const hashEndPos = start + 1;
  14397. const hashEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14398. tokens.splice(i, 1, new Token({
  14399. type: getExportedToken(27),
  14400. value: "#",
  14401. start: start,
  14402. end: hashEndPos,
  14403. startLoc: loc.start,
  14404. endLoc: hashEndLoc
  14405. }), new Token({
  14406. type: getExportedToken(132),
  14407. value: value,
  14408. start: hashEndPos,
  14409. end: end,
  14410. startLoc: hashEndLoc,
  14411. endLoc: loc.end
  14412. }));
  14413. i++;
  14414. continue;
  14415. }
  14416. if (tokenIsTemplate(type)) {
  14417. const {
  14418. loc,
  14419. start,
  14420. value,
  14421. end
  14422. } = token;
  14423. const backquoteEnd = start + 1;
  14424. const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14425. let startToken;
  14426. if (input.charCodeAt(start) === 96) {
  14427. startToken = new Token({
  14428. type: getExportedToken(22),
  14429. value: "`",
  14430. start: start,
  14431. end: backquoteEnd,
  14432. startLoc: loc.start,
  14433. endLoc: backquoteEndLoc
  14434. });
  14435. } else {
  14436. startToken = new Token({
  14437. type: getExportedToken(8),
  14438. value: "}",
  14439. start: start,
  14440. end: backquoteEnd,
  14441. startLoc: loc.start,
  14442. endLoc: backquoteEndLoc
  14443. });
  14444. }
  14445. let templateValue, templateElementEnd, templateElementEndLoc, endToken;
  14446. if (type === 24) {
  14447. templateElementEnd = end - 1;
  14448. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1);
  14449. templateValue = value === null ? null : value.slice(1, -1);
  14450. endToken = new Token({
  14451. type: getExportedToken(22),
  14452. value: "`",
  14453. start: templateElementEnd,
  14454. end: end,
  14455. startLoc: templateElementEndLoc,
  14456. endLoc: loc.end
  14457. });
  14458. } else {
  14459. templateElementEnd = end - 2;
  14460. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2);
  14461. templateValue = value === null ? null : value.slice(1, -2);
  14462. endToken = new Token({
  14463. type: getExportedToken(23),
  14464. value: "${",
  14465. start: templateElementEnd,
  14466. end: end,
  14467. startLoc: templateElementEndLoc,
  14468. endLoc: loc.end
  14469. });
  14470. }
  14471. tokens.splice(i, 1, startToken, new Token({
  14472. type: getExportedToken(20),
  14473. value: templateValue,
  14474. start: backquoteEnd,
  14475. end: templateElementEnd,
  14476. startLoc: backquoteEndLoc,
  14477. endLoc: templateElementEndLoc
  14478. }), endToken);
  14479. i += 2;
  14480. continue;
  14481. }
  14482. }
  14483. token.type = getExportedToken(type);
  14484. }
  14485. }
  14486. return tokens;
  14487. }
  14488. class StatementParser extends ExpressionParser {
  14489. parseTopLevel(file, program) {
  14490. file.program = this.parseProgram(program);
  14491. file.comments = this.comments;
  14492. if (this.options.tokens) {
  14493. file.tokens = babel7CompatTokens(this.tokens, this.input);
  14494. }
  14495. return this.finishNode(file, "File");
  14496. }
  14497. parseProgram(program, end = 139, sourceType = this.options.sourceType) {
  14498. program.sourceType = sourceType;
  14499. program.interpreter = this.parseInterpreterDirective();
  14500. this.parseBlockBody(program, true, true, end);
  14501. if (this.inModule) {
  14502. if (!this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
  14503. for (const [localName, at] of Array.from(this.scope.undefinedExports)) {
  14504. this.raise(Errors.ModuleExportUndefined, at, {
  14505. localName
  14506. });
  14507. }
  14508. }
  14509. this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait);
  14510. }
  14511. let finishedProgram;
  14512. if (end === 139) {
  14513. finishedProgram = this.finishNode(program, "Program");
  14514. } else {
  14515. finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
  14516. }
  14517. return finishedProgram;
  14518. }
  14519. stmtToDirective(stmt) {
  14520. const directive = stmt;
  14521. directive.type = "Directive";
  14522. directive.value = directive.expression;
  14523. delete directive.expression;
  14524. const directiveLiteral = directive.value;
  14525. const expressionValue = directiveLiteral.value;
  14526. const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end);
  14527. const val = directiveLiteral.value = raw.slice(1, -1);
  14528. this.addExtra(directiveLiteral, "raw", raw);
  14529. this.addExtra(directiveLiteral, "rawValue", val);
  14530. this.addExtra(directiveLiteral, "expressionValue", expressionValue);
  14531. directiveLiteral.type = "DirectiveLiteral";
  14532. return directive;
  14533. }
  14534. parseInterpreterDirective() {
  14535. if (!this.match(28)) {
  14536. return null;
  14537. }
  14538. const node = this.startNode();
  14539. node.value = this.state.value;
  14540. this.next();
  14541. return this.finishNode(node, "InterpreterDirective");
  14542. }
  14543. isLet() {
  14544. if (!this.isContextual(100)) {
  14545. return false;
  14546. }
  14547. return this.hasFollowingBindingAtom();
  14548. }
  14549. chStartsBindingIdentifier(ch, pos) {
  14550. if (isIdentifierStart(ch)) {
  14551. keywordRelationalOperator.lastIndex = pos;
  14552. if (keywordRelationalOperator.test(this.input)) {
  14553. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  14554. if (!isIdentifierChar(endCh) && endCh !== 92) {
  14555. return false;
  14556. }
  14557. }
  14558. return true;
  14559. } else if (ch === 92) {
  14560. return true;
  14561. } else {
  14562. return false;
  14563. }
  14564. }
  14565. chStartsBindingPattern(ch) {
  14566. return ch === 91 || ch === 123;
  14567. }
  14568. hasFollowingBindingAtom() {
  14569. const next = this.nextTokenStart();
  14570. const nextCh = this.codePointAtPos(next);
  14571. return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
  14572. }
  14573. hasInLineFollowingBindingIdentifierOrBrace() {
  14574. const next = this.nextTokenInLineStart();
  14575. const nextCh = this.codePointAtPos(next);
  14576. return nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next);
  14577. }
  14578. startsUsingForOf() {
  14579. const {
  14580. type,
  14581. containsEsc
  14582. } = this.lookahead();
  14583. if (type === 102 && !containsEsc) {
  14584. return false;
  14585. } else if (tokenIsIdentifier(type) && !this.hasFollowingLineBreak()) {
  14586. this.expectPlugin("explicitResourceManagement");
  14587. return true;
  14588. }
  14589. }
  14590. startsAwaitUsing() {
  14591. let next = this.nextTokenInLineStart();
  14592. if (this.isUnparsedContextual(next, "using")) {
  14593. next = this.nextTokenInLineStartSince(next + 5);
  14594. const nextCh = this.codePointAtPos(next);
  14595. if (this.chStartsBindingIdentifier(nextCh, next)) {
  14596. this.expectPlugin("explicitResourceManagement");
  14597. return true;
  14598. }
  14599. }
  14600. return false;
  14601. }
  14602. parseModuleItem() {
  14603. return this.parseStatementLike(1 | 2 | 4 | 8);
  14604. }
  14605. parseStatementListItem() {
  14606. return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8));
  14607. }
  14608. parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) {
  14609. let flags = 0;
  14610. if (this.options.annexB && !this.state.strict) {
  14611. flags |= 4;
  14612. if (allowLabeledFunction) {
  14613. flags |= 8;
  14614. }
  14615. }
  14616. return this.parseStatementLike(flags);
  14617. }
  14618. parseStatement() {
  14619. return this.parseStatementLike(0);
  14620. }
  14621. parseStatementLike(flags) {
  14622. let decorators = null;
  14623. if (this.match(26)) {
  14624. decorators = this.parseDecorators(true);
  14625. }
  14626. return this.parseStatementContent(flags, decorators);
  14627. }
  14628. parseStatementContent(flags, decorators) {
  14629. const startType = this.state.type;
  14630. const node = this.startNode();
  14631. const allowDeclaration = !!(flags & 2);
  14632. const allowFunctionDeclaration = !!(flags & 4);
  14633. const topLevel = flags & 1;
  14634. switch (startType) {
  14635. case 60:
  14636. return this.parseBreakContinueStatement(node, true);
  14637. case 63:
  14638. return this.parseBreakContinueStatement(node, false);
  14639. case 64:
  14640. return this.parseDebuggerStatement(node);
  14641. case 90:
  14642. return this.parseDoWhileStatement(node);
  14643. case 91:
  14644. return this.parseForStatement(node);
  14645. case 68:
  14646. if (this.lookaheadCharCode() === 46) break;
  14647. if (!allowFunctionDeclaration) {
  14648. this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc);
  14649. }
  14650. return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
  14651. case 80:
  14652. if (!allowDeclaration) this.unexpected();
  14653. return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
  14654. case 69:
  14655. return this.parseIfStatement(node);
  14656. case 70:
  14657. return this.parseReturnStatement(node);
  14658. case 71:
  14659. return this.parseSwitchStatement(node);
  14660. case 72:
  14661. return this.parseThrowStatement(node);
  14662. case 73:
  14663. return this.parseTryStatement(node);
  14664. case 96:
  14665. if (!this.state.containsEsc && this.startsAwaitUsing()) {
  14666. if (!this.recordAwaitIfAllowed()) {
  14667. this.raise(Errors.AwaitUsingNotInAsyncContext, node);
  14668. } else if (!allowDeclaration) {
  14669. this.raise(Errors.UnexpectedLexicalDeclaration, node);
  14670. }
  14671. this.next();
  14672. return this.parseVarStatement(node, "await using");
  14673. }
  14674. break;
  14675. case 107:
  14676. if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) {
  14677. break;
  14678. }
  14679. this.expectPlugin("explicitResourceManagement");
  14680. if (!this.scope.inModule && this.scope.inTopLevel) {
  14681. this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
  14682. } else if (!allowDeclaration) {
  14683. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14684. }
  14685. return this.parseVarStatement(node, "using");
  14686. case 100:
  14687. {
  14688. if (this.state.containsEsc) {
  14689. break;
  14690. }
  14691. const next = this.nextTokenStart();
  14692. const nextCh = this.codePointAtPos(next);
  14693. if (nextCh !== 91) {
  14694. if (!allowDeclaration && this.hasFollowingLineBreak()) break;
  14695. if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
  14696. break;
  14697. }
  14698. }
  14699. }
  14700. case 75:
  14701. {
  14702. if (!allowDeclaration) {
  14703. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14704. }
  14705. }
  14706. case 74:
  14707. {
  14708. const kind = this.state.value;
  14709. return this.parseVarStatement(node, kind);
  14710. }
  14711. case 92:
  14712. return this.parseWhileStatement(node);
  14713. case 76:
  14714. return this.parseWithStatement(node);
  14715. case 5:
  14716. return this.parseBlock();
  14717. case 13:
  14718. return this.parseEmptyStatement(node);
  14719. case 83:
  14720. {
  14721. const nextTokenCharCode = this.lookaheadCharCode();
  14722. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  14723. break;
  14724. }
  14725. }
  14726. case 82:
  14727. {
  14728. if (!this.options.allowImportExportEverywhere && !topLevel) {
  14729. this.raise(Errors.UnexpectedImportExport, this.state.startLoc);
  14730. }
  14731. this.next();
  14732. let result;
  14733. if (startType === 83) {
  14734. result = this.parseImport(node);
  14735. if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
  14736. this.sawUnambiguousESM = true;
  14737. }
  14738. } else {
  14739. result = this.parseExport(node, decorators);
  14740. if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
  14741. this.sawUnambiguousESM = true;
  14742. }
  14743. }
  14744. this.assertModuleNodeAllowed(result);
  14745. return result;
  14746. }
  14747. default:
  14748. {
  14749. if (this.isAsyncFunction()) {
  14750. if (!allowDeclaration) {
  14751. this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc);
  14752. }
  14753. this.next();
  14754. return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
  14755. }
  14756. }
  14757. }
  14758. const maybeName = this.state.value;
  14759. const expr = this.parseExpression();
  14760. if (tokenIsIdentifier(startType) && expr.type === "Identifier" && this.eat(14)) {
  14761. return this.parseLabeledStatement(node, maybeName, expr, flags);
  14762. } else {
  14763. return this.parseExpressionStatement(node, expr, decorators);
  14764. }
  14765. }
  14766. assertModuleNodeAllowed(node) {
  14767. if (!this.options.allowImportExportEverywhere && !this.inModule) {
  14768. this.raise(Errors.ImportOutsideModule, node);
  14769. }
  14770. }
  14771. decoratorsEnabledBeforeExport() {
  14772. if (this.hasPlugin("decorators-legacy")) return true;
  14773. return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false;
  14774. }
  14775. maybeTakeDecorators(maybeDecorators, classNode, exportNode) {
  14776. if (maybeDecorators) {
  14777. if (classNode.decorators && classNode.decorators.length > 0) {
  14778. if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") {
  14779. this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]);
  14780. }
  14781. classNode.decorators.unshift(...maybeDecorators);
  14782. } else {
  14783. classNode.decorators = maybeDecorators;
  14784. }
  14785. this.resetStartLocationFromNode(classNode, maybeDecorators[0]);
  14786. if (exportNode) this.resetStartLocationFromNode(exportNode, classNode);
  14787. }
  14788. return classNode;
  14789. }
  14790. canHaveLeadingDecorator() {
  14791. return this.match(80);
  14792. }
  14793. parseDecorators(allowExport) {
  14794. const decorators = [];
  14795. do {
  14796. decorators.push(this.parseDecorator());
  14797. } while (this.match(26));
  14798. if (this.match(82)) {
  14799. if (!allowExport) {
  14800. this.unexpected();
  14801. }
  14802. if (!this.decoratorsEnabledBeforeExport()) {
  14803. this.raise(Errors.DecoratorExportClass, this.state.startLoc);
  14804. }
  14805. } else if (!this.canHaveLeadingDecorator()) {
  14806. throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc);
  14807. }
  14808. return decorators;
  14809. }
  14810. parseDecorator() {
  14811. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  14812. const node = this.startNode();
  14813. this.next();
  14814. if (this.hasPlugin("decorators")) {
  14815. const startLoc = this.state.startLoc;
  14816. let expr;
  14817. if (this.match(10)) {
  14818. const startLoc = this.state.startLoc;
  14819. this.next();
  14820. expr = this.parseExpression();
  14821. this.expect(11);
  14822. expr = this.wrapParenthesis(startLoc, expr);
  14823. const paramsStartLoc = this.state.startLoc;
  14824. node.expression = this.parseMaybeDecoratorArguments(expr);
  14825. if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) {
  14826. this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc);
  14827. }
  14828. } else {
  14829. expr = this.parseIdentifier(false);
  14830. while (this.eat(16)) {
  14831. const node = this.startNodeAt(startLoc);
  14832. node.object = expr;
  14833. if (this.match(138)) {
  14834. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  14835. node.property = this.parsePrivateName();
  14836. } else {
  14837. node.property = this.parseIdentifier(true);
  14838. }
  14839. node.computed = false;
  14840. expr = this.finishNode(node, "MemberExpression");
  14841. }
  14842. node.expression = this.parseMaybeDecoratorArguments(expr);
  14843. }
  14844. } else {
  14845. node.expression = this.parseExprSubscripts();
  14846. }
  14847. return this.finishNode(node, "Decorator");
  14848. }
  14849. parseMaybeDecoratorArguments(expr) {
  14850. if (this.eat(10)) {
  14851. const node = this.startNodeAtNode(expr);
  14852. node.callee = expr;
  14853. node.arguments = this.parseCallExpressionArguments(11, false);
  14854. this.toReferencedList(node.arguments);
  14855. return this.finishNode(node, "CallExpression");
  14856. }
  14857. return expr;
  14858. }
  14859. parseBreakContinueStatement(node, isBreak) {
  14860. this.next();
  14861. if (this.isLineTerminator()) {
  14862. node.label = null;
  14863. } else {
  14864. node.label = this.parseIdentifier();
  14865. this.semicolon();
  14866. }
  14867. this.verifyBreakContinue(node, isBreak);
  14868. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  14869. }
  14870. verifyBreakContinue(node, isBreak) {
  14871. let i;
  14872. for (i = 0; i < this.state.labels.length; ++i) {
  14873. const lab = this.state.labels[i];
  14874. if (node.label == null || lab.name === node.label.name) {
  14875. if (lab.kind != null && (isBreak || lab.kind === 1)) {
  14876. break;
  14877. }
  14878. if (node.label && isBreak) break;
  14879. }
  14880. }
  14881. if (i === this.state.labels.length) {
  14882. const type = isBreak ? "BreakStatement" : "ContinueStatement";
  14883. this.raise(Errors.IllegalBreakContinue, node, {
  14884. type
  14885. });
  14886. }
  14887. }
  14888. parseDebuggerStatement(node) {
  14889. this.next();
  14890. this.semicolon();
  14891. return this.finishNode(node, "DebuggerStatement");
  14892. }
  14893. parseHeaderExpression() {
  14894. this.expect(10);
  14895. const val = this.parseExpression();
  14896. this.expect(11);
  14897. return val;
  14898. }
  14899. parseDoWhileStatement(node) {
  14900. this.next();
  14901. this.state.labels.push(loopLabel);
  14902. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  14903. this.state.labels.pop();
  14904. this.expect(92);
  14905. node.test = this.parseHeaderExpression();
  14906. this.eat(13);
  14907. return this.finishNode(node, "DoWhileStatement");
  14908. }
  14909. parseForStatement(node) {
  14910. this.next();
  14911. this.state.labels.push(loopLabel);
  14912. let awaitAt = null;
  14913. if (this.isContextual(96) && this.recordAwaitIfAllowed()) {
  14914. awaitAt = this.state.startLoc;
  14915. this.next();
  14916. }
  14917. this.scope.enter(0);
  14918. this.expect(10);
  14919. if (this.match(13)) {
  14920. if (awaitAt !== null) {
  14921. this.unexpected(awaitAt);
  14922. }
  14923. return this.parseFor(node, null);
  14924. }
  14925. const startsWithLet = this.isContextual(100);
  14926. {
  14927. const startsWithAwaitUsing = this.isContextual(96) && this.startsAwaitUsing();
  14928. const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.startsUsingForOf();
  14929. const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
  14930. if (this.match(74) || this.match(75) || isLetOrUsing) {
  14931. const initNode = this.startNode();
  14932. let kind;
  14933. if (startsWithAwaitUsing) {
  14934. kind = "await using";
  14935. if (!this.recordAwaitIfAllowed()) {
  14936. this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc);
  14937. }
  14938. this.next();
  14939. } else {
  14940. kind = this.state.value;
  14941. }
  14942. this.next();
  14943. this.parseVar(initNode, true, kind);
  14944. const init = this.finishNode(initNode, "VariableDeclaration");
  14945. const isForIn = this.match(58);
  14946. if (isForIn && starsWithUsingDeclaration) {
  14947. this.raise(Errors.ForInUsing, init);
  14948. }
  14949. if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) {
  14950. return this.parseForIn(node, init, awaitAt);
  14951. }
  14952. if (awaitAt !== null) {
  14953. this.unexpected(awaitAt);
  14954. }
  14955. return this.parseFor(node, init);
  14956. }
  14957. }
  14958. const startsWithAsync = this.isContextual(95);
  14959. const refExpressionErrors = new ExpressionErrors();
  14960. const init = this.parseExpression(true, refExpressionErrors);
  14961. const isForOf = this.isContextual(102);
  14962. if (isForOf) {
  14963. if (startsWithLet) {
  14964. this.raise(Errors.ForOfLet, init);
  14965. }
  14966. if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
  14967. this.raise(Errors.ForOfAsync, init);
  14968. }
  14969. }
  14970. if (isForOf || this.match(58)) {
  14971. this.checkDestructuringPrivate(refExpressionErrors);
  14972. this.toAssignable(init, true);
  14973. const type = isForOf ? "ForOfStatement" : "ForInStatement";
  14974. this.checkLVal(init, {
  14975. type
  14976. });
  14977. return this.parseForIn(node, init, awaitAt);
  14978. } else {
  14979. this.checkExpressionErrors(refExpressionErrors, true);
  14980. }
  14981. if (awaitAt !== null) {
  14982. this.unexpected(awaitAt);
  14983. }
  14984. return this.parseFor(node, init);
  14985. }
  14986. parseFunctionStatement(node, isAsync, isHangingDeclaration) {
  14987. this.next();
  14988. return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0));
  14989. }
  14990. parseIfStatement(node) {
  14991. this.next();
  14992. node.test = this.parseHeaderExpression();
  14993. node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration();
  14994. node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null;
  14995. return this.finishNode(node, "IfStatement");
  14996. }
  14997. parseReturnStatement(node) {
  14998. if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
  14999. this.raise(Errors.IllegalReturn, this.state.startLoc);
  15000. }
  15001. this.next();
  15002. if (this.isLineTerminator()) {
  15003. node.argument = null;
  15004. } else {
  15005. node.argument = this.parseExpression();
  15006. this.semicolon();
  15007. }
  15008. return this.finishNode(node, "ReturnStatement");
  15009. }
  15010. parseSwitchStatement(node) {
  15011. this.next();
  15012. node.discriminant = this.parseHeaderExpression();
  15013. const cases = node.cases = [];
  15014. this.expect(5);
  15015. this.state.labels.push(switchLabel);
  15016. this.scope.enter(0);
  15017. let cur;
  15018. for (let sawDefault; !this.match(8);) {
  15019. if (this.match(61) || this.match(65)) {
  15020. const isCase = this.match(61);
  15021. if (cur) this.finishNode(cur, "SwitchCase");
  15022. cases.push(cur = this.startNode());
  15023. cur.consequent = [];
  15024. this.next();
  15025. if (isCase) {
  15026. cur.test = this.parseExpression();
  15027. } else {
  15028. if (sawDefault) {
  15029. this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc);
  15030. }
  15031. sawDefault = true;
  15032. cur.test = null;
  15033. }
  15034. this.expect(14);
  15035. } else {
  15036. if (cur) {
  15037. cur.consequent.push(this.parseStatementListItem());
  15038. } else {
  15039. this.unexpected();
  15040. }
  15041. }
  15042. }
  15043. this.scope.exit();
  15044. if (cur) this.finishNode(cur, "SwitchCase");
  15045. this.next();
  15046. this.state.labels.pop();
  15047. return this.finishNode(node, "SwitchStatement");
  15048. }
  15049. parseThrowStatement(node) {
  15050. this.next();
  15051. if (this.hasPrecedingLineBreak()) {
  15052. this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc);
  15053. }
  15054. node.argument = this.parseExpression();
  15055. this.semicolon();
  15056. return this.finishNode(node, "ThrowStatement");
  15057. }
  15058. parseCatchClauseParam() {
  15059. const param = this.parseBindingAtom();
  15060. this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0);
  15061. this.checkLVal(param, {
  15062. type: "CatchClause"
  15063. }, 9);
  15064. return param;
  15065. }
  15066. parseTryStatement(node) {
  15067. this.next();
  15068. node.block = this.parseBlock();
  15069. node.handler = null;
  15070. if (this.match(62)) {
  15071. const clause = this.startNode();
  15072. this.next();
  15073. if (this.match(10)) {
  15074. this.expect(10);
  15075. clause.param = this.parseCatchClauseParam();
  15076. this.expect(11);
  15077. } else {
  15078. clause.param = null;
  15079. this.scope.enter(0);
  15080. }
  15081. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  15082. this.scope.exit();
  15083. node.handler = this.finishNode(clause, "CatchClause");
  15084. }
  15085. node.finalizer = this.eat(67) ? this.parseBlock() : null;
  15086. if (!node.handler && !node.finalizer) {
  15087. this.raise(Errors.NoCatchOrFinally, node);
  15088. }
  15089. return this.finishNode(node, "TryStatement");
  15090. }
  15091. parseVarStatement(node, kind, allowMissingInitializer = false) {
  15092. this.next();
  15093. this.parseVar(node, false, kind, allowMissingInitializer);
  15094. this.semicolon();
  15095. return this.finishNode(node, "VariableDeclaration");
  15096. }
  15097. parseWhileStatement(node) {
  15098. this.next();
  15099. node.test = this.parseHeaderExpression();
  15100. this.state.labels.push(loopLabel);
  15101. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15102. this.state.labels.pop();
  15103. return this.finishNode(node, "WhileStatement");
  15104. }
  15105. parseWithStatement(node) {
  15106. if (this.state.strict) {
  15107. this.raise(Errors.StrictWith, this.state.startLoc);
  15108. }
  15109. this.next();
  15110. node.object = this.parseHeaderExpression();
  15111. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15112. return this.finishNode(node, "WithStatement");
  15113. }
  15114. parseEmptyStatement(node) {
  15115. this.next();
  15116. return this.finishNode(node, "EmptyStatement");
  15117. }
  15118. parseLabeledStatement(node, maybeName, expr, flags) {
  15119. for (const label of this.state.labels) {
  15120. if (label.name === maybeName) {
  15121. this.raise(Errors.LabelRedeclaration, expr, {
  15122. labelName: maybeName
  15123. });
  15124. }
  15125. }
  15126. const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
  15127. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  15128. const label = this.state.labels[i];
  15129. if (label.statementStart === node.start) {
  15130. label.statementStart = this.state.start;
  15131. label.kind = kind;
  15132. } else {
  15133. break;
  15134. }
  15135. }
  15136. this.state.labels.push({
  15137. name: maybeName,
  15138. kind: kind,
  15139. statementStart: this.state.start
  15140. });
  15141. node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement();
  15142. this.state.labels.pop();
  15143. node.label = expr;
  15144. return this.finishNode(node, "LabeledStatement");
  15145. }
  15146. parseExpressionStatement(node, expr, decorators) {
  15147. node.expression = expr;
  15148. this.semicolon();
  15149. return this.finishNode(node, "ExpressionStatement");
  15150. }
  15151. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  15152. const node = this.startNode();
  15153. if (allowDirectives) {
  15154. this.state.strictErrors.clear();
  15155. }
  15156. this.expect(5);
  15157. if (createNewLexicalScope) {
  15158. this.scope.enter(0);
  15159. }
  15160. this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse);
  15161. if (createNewLexicalScope) {
  15162. this.scope.exit();
  15163. }
  15164. return this.finishNode(node, "BlockStatement");
  15165. }
  15166. isValidDirective(stmt) {
  15167. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  15168. }
  15169. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  15170. const body = node.body = [];
  15171. const directives = node.directives = [];
  15172. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  15173. }
  15174. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  15175. const oldStrict = this.state.strict;
  15176. let hasStrictModeDirective = false;
  15177. let parsedNonDirective = false;
  15178. while (!this.match(end)) {
  15179. const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
  15180. if (directives && !parsedNonDirective) {
  15181. if (this.isValidDirective(stmt)) {
  15182. const directive = this.stmtToDirective(stmt);
  15183. directives.push(directive);
  15184. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  15185. hasStrictModeDirective = true;
  15186. this.setStrict(true);
  15187. }
  15188. continue;
  15189. }
  15190. parsedNonDirective = true;
  15191. this.state.strictErrors.clear();
  15192. }
  15193. body.push(stmt);
  15194. }
  15195. afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
  15196. if (!oldStrict) {
  15197. this.setStrict(false);
  15198. }
  15199. this.next();
  15200. }
  15201. parseFor(node, init) {
  15202. node.init = init;
  15203. this.semicolon(false);
  15204. node.test = this.match(13) ? null : this.parseExpression();
  15205. this.semicolon(false);
  15206. node.update = this.match(11) ? null : this.parseExpression();
  15207. this.expect(11);
  15208. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15209. this.scope.exit();
  15210. this.state.labels.pop();
  15211. return this.finishNode(node, "ForStatement");
  15212. }
  15213. parseForIn(node, init, awaitAt) {
  15214. const isForIn = this.match(58);
  15215. this.next();
  15216. if (isForIn) {
  15217. if (awaitAt !== null) this.unexpected(awaitAt);
  15218. } else {
  15219. node.await = awaitAt !== null;
  15220. }
  15221. if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || !this.options.annexB || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
  15222. this.raise(Errors.ForInOfLoopInitializer, init, {
  15223. type: isForIn ? "ForInStatement" : "ForOfStatement"
  15224. });
  15225. }
  15226. if (init.type === "AssignmentPattern") {
  15227. this.raise(Errors.InvalidLhs, init, {
  15228. ancestor: {
  15229. type: "ForStatement"
  15230. }
  15231. });
  15232. }
  15233. node.left = init;
  15234. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  15235. this.expect(11);
  15236. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15237. this.scope.exit();
  15238. this.state.labels.pop();
  15239. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  15240. }
  15241. parseVar(node, isFor, kind, allowMissingInitializer = false) {
  15242. const declarations = node.declarations = [];
  15243. node.kind = kind;
  15244. for (;;) {
  15245. const decl = this.startNode();
  15246. this.parseVarId(decl, kind);
  15247. decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  15248. if (decl.init === null && !allowMissingInitializer) {
  15249. if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) {
  15250. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15251. kind: "destructuring"
  15252. });
  15253. } else if ((kind === "const" || kind === "using" || kind === "await using") && !(this.match(58) || this.isContextual(102))) {
  15254. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15255. kind
  15256. });
  15257. }
  15258. }
  15259. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  15260. if (!this.eat(12)) break;
  15261. }
  15262. return node;
  15263. }
  15264. parseVarId(decl, kind) {
  15265. const id = this.parseBindingAtom();
  15266. if (kind === "using" || kind === "await using") {
  15267. if (id.type === "ArrayPattern" || id.type === "ObjectPattern") {
  15268. this.raise(Errors.UsingDeclarationHasBindingPattern, id.loc.start);
  15269. }
  15270. }
  15271. this.checkLVal(id, {
  15272. type: "VariableDeclarator"
  15273. }, kind === "var" ? 5 : 8201);
  15274. decl.id = id;
  15275. }
  15276. parseAsyncFunctionExpression(node) {
  15277. return this.parseFunction(node, 8);
  15278. }
  15279. parseFunction(node, flags = 0) {
  15280. const hangingDeclaration = flags & 2;
  15281. const isDeclaration = !!(flags & 1);
  15282. const requireId = isDeclaration && !(flags & 4);
  15283. const isAsync = !!(flags & 8);
  15284. this.initFunction(node, isAsync);
  15285. if (this.match(55)) {
  15286. if (hangingDeclaration) {
  15287. this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc);
  15288. }
  15289. this.next();
  15290. node.generator = true;
  15291. }
  15292. if (isDeclaration) {
  15293. node.id = this.parseFunctionId(requireId);
  15294. }
  15295. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  15296. this.state.maybeInArrowParameters = false;
  15297. this.scope.enter(2);
  15298. this.prodParam.enter(functionFlags(isAsync, node.generator));
  15299. if (!isDeclaration) {
  15300. node.id = this.parseFunctionId();
  15301. }
  15302. this.parseFunctionParams(node, false);
  15303. this.withSmartMixTopicForbiddingContext(() => {
  15304. this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
  15305. });
  15306. this.prodParam.exit();
  15307. this.scope.exit();
  15308. if (isDeclaration && !hangingDeclaration) {
  15309. this.registerFunctionStatementId(node);
  15310. }
  15311. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  15312. return node;
  15313. }
  15314. parseFunctionId(requireId) {
  15315. return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null;
  15316. }
  15317. parseFunctionParams(node, isConstructor) {
  15318. this.expect(10);
  15319. this.expressionScope.enter(newParameterDeclarationScope());
  15320. node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0));
  15321. this.expressionScope.exit();
  15322. }
  15323. registerFunctionStatementId(node) {
  15324. if (!node.id) return;
  15325. this.scope.declareName(node.id.name, !this.options.annexB || this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? 5 : 8201 : 17, node.id.loc.start);
  15326. }
  15327. parseClass(node, isStatement, optionalId) {
  15328. this.next();
  15329. const oldStrict = this.state.strict;
  15330. this.state.strict = true;
  15331. this.parseClassId(node, isStatement, optionalId);
  15332. this.parseClassSuper(node);
  15333. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  15334. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  15335. }
  15336. isClassProperty() {
  15337. return this.match(29) || this.match(13) || this.match(8);
  15338. }
  15339. isClassMethod() {
  15340. return this.match(10);
  15341. }
  15342. nameIsConstructor(key) {
  15343. return key.type === "Identifier" && key.name === "constructor" || key.type === "StringLiteral" && key.value === "constructor";
  15344. }
  15345. isNonstaticConstructor(method) {
  15346. return !method.computed && !method.static && this.nameIsConstructor(method.key);
  15347. }
  15348. parseClassBody(hadSuperClass, oldStrict) {
  15349. this.classScope.enter();
  15350. const state = {
  15351. hadConstructor: false,
  15352. hadSuperClass
  15353. };
  15354. let decorators = [];
  15355. const classBody = this.startNode();
  15356. classBody.body = [];
  15357. this.expect(5);
  15358. this.withSmartMixTopicForbiddingContext(() => {
  15359. while (!this.match(8)) {
  15360. if (this.eat(13)) {
  15361. if (decorators.length > 0) {
  15362. throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc);
  15363. }
  15364. continue;
  15365. }
  15366. if (this.match(26)) {
  15367. decorators.push(this.parseDecorator());
  15368. continue;
  15369. }
  15370. const member = this.startNode();
  15371. if (decorators.length) {
  15372. member.decorators = decorators;
  15373. this.resetStartLocationFromNode(member, decorators[0]);
  15374. decorators = [];
  15375. }
  15376. this.parseClassMember(classBody, member, state);
  15377. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  15378. this.raise(Errors.DecoratorConstructor, member);
  15379. }
  15380. }
  15381. });
  15382. this.state.strict = oldStrict;
  15383. this.next();
  15384. if (decorators.length) {
  15385. throw this.raise(Errors.TrailingDecorator, this.state.startLoc);
  15386. }
  15387. this.classScope.exit();
  15388. return this.finishNode(classBody, "ClassBody");
  15389. }
  15390. parseClassMemberFromModifier(classBody, member) {
  15391. const key = this.parseIdentifier(true);
  15392. if (this.isClassMethod()) {
  15393. const method = member;
  15394. method.kind = "method";
  15395. method.computed = false;
  15396. method.key = key;
  15397. method.static = false;
  15398. this.pushClassMethod(classBody, method, false, false, false, false);
  15399. return true;
  15400. } else if (this.isClassProperty()) {
  15401. const prop = member;
  15402. prop.computed = false;
  15403. prop.key = key;
  15404. prop.static = false;
  15405. classBody.body.push(this.parseClassProperty(prop));
  15406. return true;
  15407. }
  15408. this.resetPreviousNodeTrailingComments(key);
  15409. return false;
  15410. }
  15411. parseClassMember(classBody, member, state) {
  15412. const isStatic = this.isContextual(106);
  15413. if (isStatic) {
  15414. if (this.parseClassMemberFromModifier(classBody, member)) {
  15415. return;
  15416. }
  15417. if (this.eat(5)) {
  15418. this.parseClassStaticBlock(classBody, member);
  15419. return;
  15420. }
  15421. }
  15422. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  15423. }
  15424. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  15425. const publicMethod = member;
  15426. const privateMethod = member;
  15427. const publicProp = member;
  15428. const privateProp = member;
  15429. const accessorProp = member;
  15430. const method = publicMethod;
  15431. const publicMember = publicMethod;
  15432. member.static = isStatic;
  15433. this.parsePropertyNamePrefixOperator(member);
  15434. if (this.eat(55)) {
  15435. method.kind = "method";
  15436. const isPrivateName = this.match(138);
  15437. this.parseClassElementName(method);
  15438. if (isPrivateName) {
  15439. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  15440. return;
  15441. }
  15442. if (this.isNonstaticConstructor(publicMethod)) {
  15443. this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
  15444. }
  15445. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  15446. return;
  15447. }
  15448. const isContextual = !this.state.containsEsc && tokenIsIdentifier(this.state.type);
  15449. const key = this.parseClassElementName(member);
  15450. const maybeContextualKw = isContextual ? key.name : null;
  15451. const isPrivate = this.isPrivateName(key);
  15452. const maybeQuestionTokenStartLoc = this.state.startLoc;
  15453. this.parsePostMemberNameModifiers(publicMember);
  15454. if (this.isClassMethod()) {
  15455. method.kind = "method";
  15456. if (isPrivate) {
  15457. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15458. return;
  15459. }
  15460. const isConstructor = this.isNonstaticConstructor(publicMethod);
  15461. let allowsDirectSuper = false;
  15462. if (isConstructor) {
  15463. publicMethod.kind = "constructor";
  15464. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  15465. this.raise(Errors.DuplicateConstructor, key);
  15466. }
  15467. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  15468. this.raise(Errors.OverrideOnConstructor, key);
  15469. }
  15470. state.hadConstructor = true;
  15471. allowsDirectSuper = state.hadSuperClass;
  15472. }
  15473. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  15474. } else if (this.isClassProperty()) {
  15475. if (isPrivate) {
  15476. this.pushClassPrivateProperty(classBody, privateProp);
  15477. } else {
  15478. this.pushClassProperty(classBody, publicProp);
  15479. }
  15480. } else if (maybeContextualKw === "async" && !this.isLineTerminator()) {
  15481. this.resetPreviousNodeTrailingComments(key);
  15482. const isGenerator = this.eat(55);
  15483. if (publicMember.optional) {
  15484. this.unexpected(maybeQuestionTokenStartLoc);
  15485. }
  15486. method.kind = "method";
  15487. const isPrivate = this.match(138);
  15488. this.parseClassElementName(method);
  15489. this.parsePostMemberNameModifiers(publicMember);
  15490. if (isPrivate) {
  15491. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  15492. } else {
  15493. if (this.isNonstaticConstructor(publicMethod)) {
  15494. this.raise(Errors.ConstructorIsAsync, publicMethod.key);
  15495. }
  15496. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  15497. }
  15498. } else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(55) && this.isLineTerminator())) {
  15499. this.resetPreviousNodeTrailingComments(key);
  15500. method.kind = maybeContextualKw;
  15501. const isPrivate = this.match(138);
  15502. this.parseClassElementName(publicMethod);
  15503. if (isPrivate) {
  15504. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15505. } else {
  15506. if (this.isNonstaticConstructor(publicMethod)) {
  15507. this.raise(Errors.ConstructorIsAccessor, publicMethod.key);
  15508. }
  15509. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  15510. }
  15511. this.checkGetterSetterParams(publicMethod);
  15512. } else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
  15513. this.expectPlugin("decoratorAutoAccessors");
  15514. this.resetPreviousNodeTrailingComments(key);
  15515. const isPrivate = this.match(138);
  15516. this.parseClassElementName(publicProp);
  15517. this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
  15518. } else if (this.isLineTerminator()) {
  15519. if (isPrivate) {
  15520. this.pushClassPrivateProperty(classBody, privateProp);
  15521. } else {
  15522. this.pushClassProperty(classBody, publicProp);
  15523. }
  15524. } else {
  15525. this.unexpected();
  15526. }
  15527. }
  15528. parseClassElementName(member) {
  15529. const {
  15530. type,
  15531. value
  15532. } = this.state;
  15533. if ((type === 132 || type === 133) && member.static && value === "prototype") {
  15534. this.raise(Errors.StaticPrototype, this.state.startLoc);
  15535. }
  15536. if (type === 138) {
  15537. if (value === "constructor") {
  15538. this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
  15539. }
  15540. const key = this.parsePrivateName();
  15541. member.key = key;
  15542. return key;
  15543. }
  15544. this.parsePropertyName(member);
  15545. return member.key;
  15546. }
  15547. parseClassStaticBlock(classBody, member) {
  15548. var _member$decorators;
  15549. this.scope.enter(64 | 128 | 16);
  15550. const oldLabels = this.state.labels;
  15551. this.state.labels = [];
  15552. this.prodParam.enter(0);
  15553. const body = member.body = [];
  15554. this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
  15555. this.prodParam.exit();
  15556. this.scope.exit();
  15557. this.state.labels = oldLabels;
  15558. classBody.body.push(this.finishNode(member, "StaticBlock"));
  15559. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  15560. this.raise(Errors.DecoratorStaticBlock, member);
  15561. }
  15562. }
  15563. pushClassProperty(classBody, prop) {
  15564. if (!prop.computed && this.nameIsConstructor(prop.key)) {
  15565. this.raise(Errors.ConstructorClassField, prop.key);
  15566. }
  15567. classBody.body.push(this.parseClassProperty(prop));
  15568. }
  15569. pushClassPrivateProperty(classBody, prop) {
  15570. const node = this.parseClassPrivateProperty(prop);
  15571. classBody.body.push(node);
  15572. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15573. }
  15574. pushClassAccessorProperty(classBody, prop, isPrivate) {
  15575. if (!isPrivate && !prop.computed && this.nameIsConstructor(prop.key)) {
  15576. this.raise(Errors.ConstructorClassField, prop.key);
  15577. }
  15578. const node = this.parseClassAccessorProperty(prop);
  15579. classBody.body.push(node);
  15580. if (isPrivate) {
  15581. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15582. }
  15583. }
  15584. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  15585. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  15586. }
  15587. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  15588. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  15589. classBody.body.push(node);
  15590. const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0;
  15591. this.declareClassPrivateMethodInScope(node, kind);
  15592. }
  15593. declareClassPrivateMethodInScope(node, kind) {
  15594. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
  15595. }
  15596. parsePostMemberNameModifiers(methodOrProp) {}
  15597. parseClassPrivateProperty(node) {
  15598. this.parseInitializer(node);
  15599. this.semicolon();
  15600. return this.finishNode(node, "ClassPrivateProperty");
  15601. }
  15602. parseClassProperty(node) {
  15603. this.parseInitializer(node);
  15604. this.semicolon();
  15605. return this.finishNode(node, "ClassProperty");
  15606. }
  15607. parseClassAccessorProperty(node) {
  15608. this.parseInitializer(node);
  15609. this.semicolon();
  15610. return this.finishNode(node, "ClassAccessorProperty");
  15611. }
  15612. parseInitializer(node) {
  15613. this.scope.enter(64 | 16);
  15614. this.expressionScope.enter(newExpressionScope());
  15615. this.prodParam.enter(0);
  15616. node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
  15617. this.expressionScope.exit();
  15618. this.prodParam.exit();
  15619. this.scope.exit();
  15620. }
  15621. parseClassId(node, isStatement, optionalId, bindingType = 8331) {
  15622. if (tokenIsIdentifier(this.state.type)) {
  15623. node.id = this.parseIdentifier();
  15624. if (isStatement) {
  15625. this.declareNameFromIdentifier(node.id, bindingType);
  15626. }
  15627. } else {
  15628. if (optionalId || !isStatement) {
  15629. node.id = null;
  15630. } else {
  15631. throw this.raise(Errors.MissingClassName, this.state.startLoc);
  15632. }
  15633. }
  15634. }
  15635. parseClassSuper(node) {
  15636. node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
  15637. }
  15638. parseExport(node, decorators) {
  15639. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
  15640. const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  15641. const parseAfterDefault = !hasDefault || this.eat(12);
  15642. const hasStar = parseAfterDefault && this.eatExportStar(node);
  15643. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  15644. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12));
  15645. const isFromRequired = hasDefault || hasStar;
  15646. if (hasStar && !hasNamespace) {
  15647. if (hasDefault) this.unexpected();
  15648. if (decorators) {
  15649. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15650. }
  15651. this.parseExportFrom(node, true);
  15652. return this.finishNode(node, "ExportAllDeclaration");
  15653. }
  15654. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  15655. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
  15656. this.unexpected(null, 5);
  15657. }
  15658. if (hasNamespace && parseAfterNamespace) {
  15659. this.unexpected(null, 98);
  15660. }
  15661. let hasDeclaration;
  15662. if (isFromRequired || hasSpecifiers) {
  15663. hasDeclaration = false;
  15664. if (decorators) {
  15665. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15666. }
  15667. this.parseExportFrom(node, isFromRequired);
  15668. } else {
  15669. hasDeclaration = this.maybeParseExportDeclaration(node);
  15670. }
  15671. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  15672. var _node2$declaration;
  15673. const node2 = node;
  15674. this.checkExport(node2, true, false, !!node2.source);
  15675. if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") {
  15676. this.maybeTakeDecorators(decorators, node2.declaration, node2);
  15677. } else if (decorators) {
  15678. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15679. }
  15680. return this.finishNode(node2, "ExportNamedDeclaration");
  15681. }
  15682. if (this.eat(65)) {
  15683. const node2 = node;
  15684. const decl = this.parseExportDefaultExpression();
  15685. node2.declaration = decl;
  15686. if (decl.type === "ClassDeclaration") {
  15687. this.maybeTakeDecorators(decorators, decl, node2);
  15688. } else if (decorators) {
  15689. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15690. }
  15691. this.checkExport(node2, true, true);
  15692. return this.finishNode(node2, "ExportDefaultDeclaration");
  15693. }
  15694. this.unexpected(null, 5);
  15695. }
  15696. eatExportStar(node) {
  15697. return this.eat(55);
  15698. }
  15699. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  15700. if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) {
  15701. this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start);
  15702. const id = maybeDefaultIdentifier || this.parseIdentifier(true);
  15703. const specifier = this.startNodeAtNode(id);
  15704. specifier.exported = id;
  15705. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  15706. return true;
  15707. }
  15708. return false;
  15709. }
  15710. maybeParseExportNamespaceSpecifier(node) {
  15711. if (this.isContextual(93)) {
  15712. var _ref, _ref$specifiers;
  15713. (_ref$specifiers = (_ref = node).specifiers) != null ? _ref$specifiers : _ref.specifiers = [];
  15714. const specifier = this.startNodeAt(this.state.lastTokStartLoc);
  15715. this.next();
  15716. specifier.exported = this.parseModuleExportName();
  15717. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  15718. return true;
  15719. }
  15720. return false;
  15721. }
  15722. maybeParseExportNamedSpecifiers(node) {
  15723. if (this.match(5)) {
  15724. const node2 = node;
  15725. if (!node2.specifiers) node2.specifiers = [];
  15726. const isTypeExport = node2.exportKind === "type";
  15727. node2.specifiers.push(...this.parseExportSpecifiers(isTypeExport));
  15728. node2.source = null;
  15729. node2.declaration = null;
  15730. if (this.hasPlugin("importAssertions")) {
  15731. node2.assertions = [];
  15732. }
  15733. return true;
  15734. }
  15735. return false;
  15736. }
  15737. maybeParseExportDeclaration(node) {
  15738. if (this.shouldParseExportDeclaration()) {
  15739. node.specifiers = [];
  15740. node.source = null;
  15741. if (this.hasPlugin("importAssertions")) {
  15742. node.assertions = [];
  15743. }
  15744. node.declaration = this.parseExportDeclaration(node);
  15745. return true;
  15746. }
  15747. return false;
  15748. }
  15749. isAsyncFunction() {
  15750. if (!this.isContextual(95)) return false;
  15751. const next = this.nextTokenInLineStart();
  15752. return this.isUnparsedContextual(next, "function");
  15753. }
  15754. parseExportDefaultExpression() {
  15755. const expr = this.startNode();
  15756. if (this.match(68)) {
  15757. this.next();
  15758. return this.parseFunction(expr, 1 | 4);
  15759. } else if (this.isAsyncFunction()) {
  15760. this.next();
  15761. this.next();
  15762. return this.parseFunction(expr, 1 | 4 | 8);
  15763. }
  15764. if (this.match(80)) {
  15765. return this.parseClass(expr, true, true);
  15766. }
  15767. if (this.match(26)) {
  15768. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15769. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15770. }
  15771. return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
  15772. }
  15773. if (this.match(75) || this.match(74) || this.isLet()) {
  15774. throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
  15775. }
  15776. const res = this.parseMaybeAssignAllowIn();
  15777. this.semicolon();
  15778. return res;
  15779. }
  15780. parseExportDeclaration(node) {
  15781. if (this.match(80)) {
  15782. const node = this.parseClass(this.startNode(), true, false);
  15783. return node;
  15784. }
  15785. return this.parseStatementListItem();
  15786. }
  15787. isExportDefaultSpecifier() {
  15788. const {
  15789. type
  15790. } = this.state;
  15791. if (tokenIsIdentifier(type)) {
  15792. if (type === 95 && !this.state.containsEsc || type === 100) {
  15793. return false;
  15794. }
  15795. if ((type === 130 || type === 129) && !this.state.containsEsc) {
  15796. const {
  15797. type: nextType
  15798. } = this.lookahead();
  15799. if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) {
  15800. this.expectOnePlugin(["flow", "typescript"]);
  15801. return false;
  15802. }
  15803. }
  15804. } else if (!this.match(65)) {
  15805. return false;
  15806. }
  15807. const next = this.nextTokenStart();
  15808. const hasFrom = this.isUnparsedContextual(next, "from");
  15809. if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) {
  15810. return true;
  15811. }
  15812. if (this.match(65) && hasFrom) {
  15813. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  15814. return nextAfterFrom === 34 || nextAfterFrom === 39;
  15815. }
  15816. return false;
  15817. }
  15818. parseExportFrom(node, expect) {
  15819. if (this.eatContextual(98)) {
  15820. node.source = this.parseImportSource();
  15821. this.checkExport(node);
  15822. this.maybeParseImportAttributes(node);
  15823. this.checkJSONModuleImport(node);
  15824. } else if (expect) {
  15825. this.unexpected();
  15826. }
  15827. this.semicolon();
  15828. }
  15829. shouldParseExportDeclaration() {
  15830. const {
  15831. type
  15832. } = this.state;
  15833. if (type === 26) {
  15834. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  15835. if (this.hasPlugin("decorators")) {
  15836. if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15837. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15838. }
  15839. return true;
  15840. }
  15841. }
  15842. if (this.isContextual(107)) {
  15843. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  15844. return true;
  15845. }
  15846. if (this.isContextual(96) && this.startsAwaitUsing()) {
  15847. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  15848. return true;
  15849. }
  15850. return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction();
  15851. }
  15852. checkExport(node, checkNames, isDefault, isFrom) {
  15853. if (checkNames) {
  15854. var _node$specifiers;
  15855. if (isDefault) {
  15856. this.checkDuplicateExports(node, "default");
  15857. if (this.hasPlugin("exportDefaultFrom")) {
  15858. var _declaration$extra;
  15859. const declaration = node.declaration;
  15860. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  15861. this.raise(Errors.ExportDefaultFromAsIdentifier, declaration);
  15862. }
  15863. }
  15864. } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) {
  15865. for (const specifier of node.specifiers) {
  15866. const {
  15867. exported
  15868. } = specifier;
  15869. const exportName = exported.type === "Identifier" ? exported.name : exported.value;
  15870. this.checkDuplicateExports(specifier, exportName);
  15871. if (!isFrom && specifier.local) {
  15872. const {
  15873. local
  15874. } = specifier;
  15875. if (local.type !== "Identifier") {
  15876. this.raise(Errors.ExportBindingIsString, specifier, {
  15877. localName: local.value,
  15878. exportName
  15879. });
  15880. } else {
  15881. this.checkReservedWord(local.name, local.loc.start, true, false);
  15882. this.scope.checkLocalExport(local);
  15883. }
  15884. }
  15885. }
  15886. } else if (node.declaration) {
  15887. const decl = node.declaration;
  15888. if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") {
  15889. const {
  15890. id
  15891. } = decl;
  15892. if (!id) throw new Error("Assertion failure");
  15893. this.checkDuplicateExports(node, id.name);
  15894. } else if (decl.type === "VariableDeclaration") {
  15895. for (const declaration of decl.declarations) {
  15896. this.checkDeclaration(declaration.id);
  15897. }
  15898. }
  15899. }
  15900. }
  15901. }
  15902. checkDeclaration(node) {
  15903. if (node.type === "Identifier") {
  15904. this.checkDuplicateExports(node, node.name);
  15905. } else if (node.type === "ObjectPattern") {
  15906. for (const prop of node.properties) {
  15907. this.checkDeclaration(prop);
  15908. }
  15909. } else if (node.type === "ArrayPattern") {
  15910. for (const elem of node.elements) {
  15911. if (elem) {
  15912. this.checkDeclaration(elem);
  15913. }
  15914. }
  15915. } else if (node.type === "ObjectProperty") {
  15916. this.checkDeclaration(node.value);
  15917. } else if (node.type === "RestElement") {
  15918. this.checkDeclaration(node.argument);
  15919. } else if (node.type === "AssignmentPattern") {
  15920. this.checkDeclaration(node.left);
  15921. }
  15922. }
  15923. checkDuplicateExports(node, exportName) {
  15924. if (this.exportedIdentifiers.has(exportName)) {
  15925. if (exportName === "default") {
  15926. this.raise(Errors.DuplicateDefaultExport, node);
  15927. } else {
  15928. this.raise(Errors.DuplicateExport, node, {
  15929. exportName
  15930. });
  15931. }
  15932. }
  15933. this.exportedIdentifiers.add(exportName);
  15934. }
  15935. parseExportSpecifiers(isInTypeExport) {
  15936. const nodes = [];
  15937. let first = true;
  15938. this.expect(5);
  15939. while (!this.eat(8)) {
  15940. if (first) {
  15941. first = false;
  15942. } else {
  15943. this.expect(12);
  15944. if (this.eat(8)) break;
  15945. }
  15946. const isMaybeTypeOnly = this.isContextual(130);
  15947. const isString = this.match(133);
  15948. const node = this.startNode();
  15949. node.local = this.parseModuleExportName();
  15950. nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
  15951. }
  15952. return nodes;
  15953. }
  15954. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  15955. if (this.eatContextual(93)) {
  15956. node.exported = this.parseModuleExportName();
  15957. } else if (isString) {
  15958. node.exported = cloneStringLiteral(node.local);
  15959. } else if (!node.exported) {
  15960. node.exported = cloneIdentifier(node.local);
  15961. }
  15962. return this.finishNode(node, "ExportSpecifier");
  15963. }
  15964. parseModuleExportName() {
  15965. if (this.match(133)) {
  15966. const result = this.parseStringLiteral(this.state.value);
  15967. const surrogate = loneSurrogate.exec(result.value);
  15968. if (surrogate) {
  15969. this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
  15970. surrogateCharCode: surrogate[0].charCodeAt(0)
  15971. });
  15972. }
  15973. return result;
  15974. }
  15975. return this.parseIdentifier(true);
  15976. }
  15977. isJSONModuleImport(node) {
  15978. if (node.assertions != null) {
  15979. return node.assertions.some(({
  15980. key,
  15981. value
  15982. }) => {
  15983. return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
  15984. });
  15985. }
  15986. return false;
  15987. }
  15988. checkImportReflection(node) {
  15989. const {
  15990. specifiers
  15991. } = node;
  15992. const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
  15993. if (node.phase === "source") {
  15994. if (singleBindingType !== "ImportDefaultSpecifier") {
  15995. this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start);
  15996. }
  15997. } else if (node.phase === "defer") {
  15998. if (singleBindingType !== "ImportNamespaceSpecifier") {
  15999. this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start);
  16000. }
  16001. } else if (node.module) {
  16002. var _node$assertions;
  16003. if (singleBindingType !== "ImportDefaultSpecifier") {
  16004. this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start);
  16005. }
  16006. if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) {
  16007. this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start);
  16008. }
  16009. }
  16010. }
  16011. checkJSONModuleImport(node) {
  16012. if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
  16013. const {
  16014. specifiers
  16015. } = node;
  16016. if (specifiers != null) {
  16017. const nonDefaultNamedSpecifier = specifiers.find(specifier => {
  16018. let imported;
  16019. if (specifier.type === "ExportSpecifier") {
  16020. imported = specifier.local;
  16021. } else if (specifier.type === "ImportSpecifier") {
  16022. imported = specifier.imported;
  16023. }
  16024. if (imported !== undefined) {
  16025. return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
  16026. }
  16027. });
  16028. if (nonDefaultNamedSpecifier !== undefined) {
  16029. this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start);
  16030. }
  16031. }
  16032. }
  16033. }
  16034. isPotentialImportPhase(isExport) {
  16035. if (isExport) return false;
  16036. return this.isContextual(105) || this.isContextual(97) || this.isContextual(127);
  16037. }
  16038. applyImportPhase(node, isExport, phase, loc) {
  16039. if (isExport) {
  16040. return;
  16041. }
  16042. if (phase === "module") {
  16043. this.expectPlugin("importReflection", loc);
  16044. node.module = true;
  16045. } else if (this.hasPlugin("importReflection")) {
  16046. node.module = false;
  16047. }
  16048. if (phase === "source") {
  16049. this.expectPlugin("sourcePhaseImports", loc);
  16050. node.phase = "source";
  16051. } else if (phase === "defer") {
  16052. this.expectPlugin("deferredImportEvaluation", loc);
  16053. node.phase = "defer";
  16054. } else if (this.hasPlugin("sourcePhaseImports")) {
  16055. node.phase = null;
  16056. }
  16057. }
  16058. parseMaybeImportPhase(node, isExport) {
  16059. if (!this.isPotentialImportPhase(isExport)) {
  16060. this.applyImportPhase(node, isExport, null);
  16061. return null;
  16062. }
  16063. const phaseIdentifier = this.parseIdentifier(true);
  16064. const {
  16065. type
  16066. } = this.state;
  16067. const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16068. if (isImportPhase) {
  16069. this.resetPreviousIdentifierLeadingComments(phaseIdentifier);
  16070. this.applyImportPhase(node, isExport, phaseIdentifier.name, phaseIdentifier.loc.start);
  16071. return null;
  16072. } else {
  16073. this.applyImportPhase(node, isExport, null);
  16074. return phaseIdentifier;
  16075. }
  16076. }
  16077. isPrecedingIdImportPhase(phase) {
  16078. const {
  16079. type
  16080. } = this.state;
  16081. return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16082. }
  16083. parseImport(node) {
  16084. if (this.match(133)) {
  16085. return this.parseImportSourceAndAttributes(node);
  16086. }
  16087. return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
  16088. }
  16089. parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
  16090. node.specifiers = [];
  16091. const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
  16092. const parseNext = !hasDefault || this.eat(12);
  16093. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  16094. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  16095. this.expectContextual(98);
  16096. return this.parseImportSourceAndAttributes(node);
  16097. }
  16098. parseImportSourceAndAttributes(node) {
  16099. var _node$specifiers2;
  16100. (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = [];
  16101. node.source = this.parseImportSource();
  16102. this.maybeParseImportAttributes(node);
  16103. this.checkImportReflection(node);
  16104. this.checkJSONModuleImport(node);
  16105. this.semicolon();
  16106. return this.finishNode(node, "ImportDeclaration");
  16107. }
  16108. parseImportSource() {
  16109. if (!this.match(133)) this.unexpected();
  16110. return this.parseExprAtom();
  16111. }
  16112. parseImportSpecifierLocal(node, specifier, type) {
  16113. specifier.local = this.parseIdentifier();
  16114. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  16115. }
  16116. finishImportSpecifier(specifier, type, bindingType = 8201) {
  16117. this.checkLVal(specifier.local, {
  16118. type
  16119. }, bindingType);
  16120. return this.finishNode(specifier, type);
  16121. }
  16122. parseImportAttributes() {
  16123. this.expect(5);
  16124. const attrs = [];
  16125. const attrNames = new Set();
  16126. do {
  16127. if (this.match(8)) {
  16128. break;
  16129. }
  16130. const node = this.startNode();
  16131. const keyName = this.state.value;
  16132. if (attrNames.has(keyName)) {
  16133. this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, {
  16134. key: keyName
  16135. });
  16136. }
  16137. attrNames.add(keyName);
  16138. if (this.match(133)) {
  16139. node.key = this.parseStringLiteral(keyName);
  16140. } else {
  16141. node.key = this.parseIdentifier(true);
  16142. }
  16143. this.expect(14);
  16144. if (!this.match(133)) {
  16145. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16146. }
  16147. node.value = this.parseStringLiteral(this.state.value);
  16148. attrs.push(this.finishNode(node, "ImportAttribute"));
  16149. } while (this.eat(12));
  16150. this.expect(8);
  16151. return attrs;
  16152. }
  16153. parseModuleAttributes() {
  16154. const attrs = [];
  16155. const attributes = new Set();
  16156. do {
  16157. const node = this.startNode();
  16158. node.key = this.parseIdentifier(true);
  16159. if (node.key.name !== "type") {
  16160. this.raise(Errors.ModuleAttributeDifferentFromType, node.key);
  16161. }
  16162. if (attributes.has(node.key.name)) {
  16163. this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, {
  16164. key: node.key.name
  16165. });
  16166. }
  16167. attributes.add(node.key.name);
  16168. this.expect(14);
  16169. if (!this.match(133)) {
  16170. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16171. }
  16172. node.value = this.parseStringLiteral(this.state.value);
  16173. attrs.push(this.finishNode(node, "ImportAttribute"));
  16174. } while (this.eat(12));
  16175. return attrs;
  16176. }
  16177. maybeParseImportAttributes(node) {
  16178. let attributes;
  16179. let useWith = false;
  16180. if (this.match(76)) {
  16181. if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) {
  16182. return;
  16183. }
  16184. this.next();
  16185. {
  16186. if (this.hasPlugin("moduleAttributes")) {
  16187. attributes = this.parseModuleAttributes();
  16188. } else {
  16189. this.expectImportAttributesPlugin();
  16190. attributes = this.parseImportAttributes();
  16191. }
  16192. }
  16193. useWith = true;
  16194. } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) {
  16195. if (this.hasPlugin("importAttributes")) {
  16196. if (this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== true) {
  16197. this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc);
  16198. }
  16199. this.addExtra(node, "deprecatedAssertSyntax", true);
  16200. } else {
  16201. this.expectOnePlugin(["importAttributes", "importAssertions"]);
  16202. }
  16203. this.next();
  16204. attributes = this.parseImportAttributes();
  16205. } else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  16206. attributes = [];
  16207. } else {
  16208. if (this.hasPlugin("moduleAttributes")) {
  16209. attributes = [];
  16210. } else return;
  16211. }
  16212. if (!useWith && this.hasPlugin("importAssertions")) {
  16213. node.assertions = attributes;
  16214. } else {
  16215. node.attributes = attributes;
  16216. }
  16217. }
  16218. maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) {
  16219. if (maybeDefaultIdentifier) {
  16220. const specifier = this.startNodeAtNode(maybeDefaultIdentifier);
  16221. specifier.local = maybeDefaultIdentifier;
  16222. node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier"));
  16223. return true;
  16224. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  16225. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier");
  16226. return true;
  16227. }
  16228. return false;
  16229. }
  16230. maybeParseStarImportSpecifier(node) {
  16231. if (this.match(55)) {
  16232. const specifier = this.startNode();
  16233. this.next();
  16234. this.expectContextual(93);
  16235. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
  16236. return true;
  16237. }
  16238. return false;
  16239. }
  16240. parseNamedImportSpecifiers(node) {
  16241. let first = true;
  16242. this.expect(5);
  16243. while (!this.eat(8)) {
  16244. if (first) {
  16245. first = false;
  16246. } else {
  16247. if (this.eat(14)) {
  16248. throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
  16249. }
  16250. this.expect(12);
  16251. if (this.eat(8)) break;
  16252. }
  16253. const specifier = this.startNode();
  16254. const importedIsString = this.match(133);
  16255. const isMaybeTypeOnly = this.isContextual(130);
  16256. specifier.imported = this.parseModuleExportName();
  16257. const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
  16258. node.specifiers.push(importSpecifier);
  16259. }
  16260. }
  16261. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  16262. if (this.eatContextual(93)) {
  16263. specifier.local = this.parseIdentifier();
  16264. } else {
  16265. const {
  16266. imported
  16267. } = specifier;
  16268. if (importedIsString) {
  16269. throw this.raise(Errors.ImportBindingIsString, specifier, {
  16270. importName: imported.value
  16271. });
  16272. }
  16273. this.checkReservedWord(imported.name, specifier.loc.start, true, true);
  16274. if (!specifier.local) {
  16275. specifier.local = cloneIdentifier(imported);
  16276. }
  16277. }
  16278. return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType);
  16279. }
  16280. isThisParam(param) {
  16281. return param.type === "Identifier" && param.name === "this";
  16282. }
  16283. }
  16284. class Parser extends StatementParser {
  16285. constructor(options, input, pluginsMap) {
  16286. options = getOptions(options);
  16287. super(options, input);
  16288. this.options = options;
  16289. this.initializeScopes();
  16290. this.plugins = pluginsMap;
  16291. this.filename = options.sourceFilename;
  16292. }
  16293. getScopeHandler() {
  16294. return ScopeHandler;
  16295. }
  16296. parse() {
  16297. this.enterInitialScopes();
  16298. const file = this.startNode();
  16299. const program = this.startNode();
  16300. this.nextToken();
  16301. file.errors = null;
  16302. this.parseTopLevel(file, program);
  16303. file.errors = this.state.errors;
  16304. file.comments.length = this.state.commentsLen;
  16305. return file;
  16306. }
  16307. }
  16308. function parse(input, options) {
  16309. var _options;
  16310. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  16311. options = Object.assign({}, options);
  16312. try {
  16313. options.sourceType = "module";
  16314. const parser = getParser(options, input);
  16315. const ast = parser.parse();
  16316. if (parser.sawUnambiguousESM) {
  16317. return ast;
  16318. }
  16319. if (parser.ambiguousScriptDifferentAst) {
  16320. try {
  16321. options.sourceType = "script";
  16322. return getParser(options, input).parse();
  16323. } catch (_unused) {}
  16324. } else {
  16325. ast.program.sourceType = "script";
  16326. }
  16327. return ast;
  16328. } catch (moduleError) {
  16329. try {
  16330. options.sourceType = "script";
  16331. return getParser(options, input).parse();
  16332. } catch (_unused2) {}
  16333. throw moduleError;
  16334. }
  16335. } else {
  16336. return getParser(options, input).parse();
  16337. }
  16338. }
  16339. function parseExpression(input, options) {
  16340. const parser = getParser(options, input);
  16341. if (parser.options.strictMode) {
  16342. parser.state.strict = true;
  16343. }
  16344. return parser.getExpression();
  16345. }
  16346. function generateExportedTokenTypes(internalTokenTypes) {
  16347. const tokenTypes = {};
  16348. for (const typeName of Object.keys(internalTokenTypes)) {
  16349. tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
  16350. }
  16351. return tokenTypes;
  16352. }
  16353. const tokTypes = generateExportedTokenTypes(tt);
  16354. function getParser(options, input) {
  16355. let cls = Parser;
  16356. const pluginsMap = new Map();
  16357. if (options != null && options.plugins) {
  16358. for (const plugin of options.plugins) {
  16359. let name, opts;
  16360. if (typeof plugin === "string") {
  16361. name = plugin;
  16362. } else {
  16363. [name, opts] = plugin;
  16364. }
  16365. if (!pluginsMap.has(name)) {
  16366. pluginsMap.set(name, opts || {});
  16367. }
  16368. }
  16369. validatePlugins(pluginsMap);
  16370. cls = getParserClass(pluginsMap);
  16371. }
  16372. return new cls(options, input, pluginsMap);
  16373. }
  16374. const parserClassCache = new Map();
  16375. function getParserClass(pluginsMap) {
  16376. const pluginList = [];
  16377. for (const name of mixinPluginNames) {
  16378. if (pluginsMap.has(name)) {
  16379. pluginList.push(name);
  16380. }
  16381. }
  16382. const key = pluginList.join("|");
  16383. let cls = parserClassCache.get(key);
  16384. if (!cls) {
  16385. cls = Parser;
  16386. for (const plugin of pluginList) {
  16387. cls = mixinPlugins[plugin](cls);
  16388. }
  16389. parserClassCache.set(key, cls);
  16390. }
  16391. return cls;
  16392. }
  16393. lib.parse = parse;
  16394. lib.parseExpression = parseExpression;
  16395. lib.tokTypes = tokTypes;
  16396. return lib;
  16397. }
  16398. var libExports = /*@__PURE__*/ requireLib();
  16399. // @ts-check
  16400. /** @typedef { import('estree').BaseNode} BaseNode */
  16401. /** @typedef {{
  16402. skip: () => void;
  16403. remove: () => void;
  16404. replace: (node: BaseNode) => void;
  16405. }} WalkerContext */
  16406. class WalkerBase {
  16407. constructor() {
  16408. /** @type {boolean} */
  16409. this.should_skip = false;
  16410. /** @type {boolean} */
  16411. this.should_remove = false;
  16412. /** @type {BaseNode | null} */
  16413. this.replacement = null;
  16414. /** @type {WalkerContext} */
  16415. this.context = {
  16416. skip: () => (this.should_skip = true),
  16417. remove: () => (this.should_remove = true),
  16418. replace: (node) => (this.replacement = node)
  16419. };
  16420. }
  16421. /**
  16422. *
  16423. * @param {any} parent
  16424. * @param {string} prop
  16425. * @param {number} index
  16426. * @param {BaseNode} node
  16427. */
  16428. replace(parent, prop, index, node) {
  16429. if (parent) {
  16430. if (index !== null) {
  16431. parent[prop][index] = node;
  16432. } else {
  16433. parent[prop] = node;
  16434. }
  16435. }
  16436. }
  16437. /**
  16438. *
  16439. * @param {any} parent
  16440. * @param {string} prop
  16441. * @param {number} index
  16442. */
  16443. remove(parent, prop, index) {
  16444. if (parent) {
  16445. if (index !== null) {
  16446. parent[prop].splice(index, 1);
  16447. } else {
  16448. delete parent[prop];
  16449. }
  16450. }
  16451. }
  16452. }
  16453. // @ts-check
  16454. /** @typedef { import('estree').BaseNode} BaseNode */
  16455. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  16456. /** @typedef {(
  16457. * this: WalkerContext,
  16458. * node: BaseNode,
  16459. * parent: BaseNode,
  16460. * key: string,
  16461. * index: number
  16462. * ) => void} SyncHandler */
  16463. class SyncWalker extends WalkerBase {
  16464. /**
  16465. *
  16466. * @param {SyncHandler} enter
  16467. * @param {SyncHandler} leave
  16468. */
  16469. constructor(enter, leave) {
  16470. super();
  16471. /** @type {SyncHandler} */
  16472. this.enter = enter;
  16473. /** @type {SyncHandler} */
  16474. this.leave = leave;
  16475. }
  16476. /**
  16477. *
  16478. * @param {BaseNode} node
  16479. * @param {BaseNode} parent
  16480. * @param {string} [prop]
  16481. * @param {number} [index]
  16482. * @returns {BaseNode}
  16483. */
  16484. visit(node, parent, prop, index) {
  16485. if (node) {
  16486. if (this.enter) {
  16487. const _should_skip = this.should_skip;
  16488. const _should_remove = this.should_remove;
  16489. const _replacement = this.replacement;
  16490. this.should_skip = false;
  16491. this.should_remove = false;
  16492. this.replacement = null;
  16493. this.enter.call(this.context, node, parent, prop, index);
  16494. if (this.replacement) {
  16495. node = this.replacement;
  16496. this.replace(parent, prop, index, node);
  16497. }
  16498. if (this.should_remove) {
  16499. this.remove(parent, prop, index);
  16500. }
  16501. const skipped = this.should_skip;
  16502. const removed = this.should_remove;
  16503. this.should_skip = _should_skip;
  16504. this.should_remove = _should_remove;
  16505. this.replacement = _replacement;
  16506. if (skipped) return node;
  16507. if (removed) return null;
  16508. }
  16509. for (const key in node) {
  16510. const value = node[key];
  16511. if (typeof value !== "object") {
  16512. continue;
  16513. } else if (Array.isArray(value)) {
  16514. for (let i = 0; i < value.length; i += 1) {
  16515. if (value[i] !== null && typeof value[i].type === 'string') {
  16516. if (!this.visit(value[i], node, key, i)) {
  16517. // removed
  16518. i--;
  16519. }
  16520. }
  16521. }
  16522. } else if (value !== null && typeof value.type === "string") {
  16523. this.visit(value, node, key, null);
  16524. }
  16525. }
  16526. if (this.leave) {
  16527. const _replacement = this.replacement;
  16528. const _should_remove = this.should_remove;
  16529. this.replacement = null;
  16530. this.should_remove = false;
  16531. this.leave.call(this.context, node, parent, prop, index);
  16532. if (this.replacement) {
  16533. node = this.replacement;
  16534. this.replace(parent, prop, index, node);
  16535. }
  16536. if (this.should_remove) {
  16537. this.remove(parent, prop, index);
  16538. }
  16539. const removed = this.should_remove;
  16540. this.replacement = _replacement;
  16541. this.should_remove = _should_remove;
  16542. if (removed) return null;
  16543. }
  16544. }
  16545. return node;
  16546. }
  16547. }
  16548. // @ts-check
  16549. /** @typedef { import('estree').BaseNode} BaseNode */
  16550. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  16551. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  16552. /**
  16553. *
  16554. * @param {BaseNode} ast
  16555. * @param {{
  16556. * enter?: SyncHandler
  16557. * leave?: SyncHandler
  16558. * }} walker
  16559. * @returns {BaseNode}
  16560. */
  16561. function walk$2(ast, { enter, leave }) {
  16562. const instance = new SyncWalker(enter, leave);
  16563. return instance.visit(ast, null);
  16564. }
  16565. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  16566. const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
  16567. walk$2(root, {
  16568. enter(node, parent) {
  16569. parent && parentStack.push(parent);
  16570. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  16571. return this.skip();
  16572. }
  16573. if (node.type === "Identifier") {
  16574. const isLocal = !!knownIds[node.name];
  16575. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  16576. if (includeAll || isRefed && !isLocal) {
  16577. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  16578. }
  16579. } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
  16580. (parent == null ? void 0 : parent.type) === "ObjectPattern") {
  16581. node.inPattern = true;
  16582. } else if (isFunctionType(node)) {
  16583. if (node.scopeIds) {
  16584. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16585. } else {
  16586. walkFunctionParams(
  16587. node,
  16588. (id) => markScopeIdentifier(node, id, knownIds)
  16589. );
  16590. }
  16591. } else if (node.type === "BlockStatement") {
  16592. if (node.scopeIds) {
  16593. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16594. } else {
  16595. walkBlockDeclarations(
  16596. node,
  16597. (id) => markScopeIdentifier(node, id, knownIds)
  16598. );
  16599. }
  16600. } else if (node.type === "CatchClause" && node.param) {
  16601. for (const id of extractIdentifiers$1(node.param)) {
  16602. markScopeIdentifier(node, id, knownIds);
  16603. }
  16604. } else if (isForStatement(node)) {
  16605. walkForStatement(
  16606. node,
  16607. false,
  16608. (id) => markScopeIdentifier(node, id, knownIds)
  16609. );
  16610. }
  16611. },
  16612. leave(node, parent) {
  16613. parent && parentStack.pop();
  16614. if (node !== rootExp && node.scopeIds) {
  16615. for (const id of node.scopeIds) {
  16616. knownIds[id]--;
  16617. if (knownIds[id] === 0) {
  16618. delete knownIds[id];
  16619. }
  16620. }
  16621. }
  16622. }
  16623. });
  16624. }
  16625. function isReferencedIdentifier(id, parent, parentStack) {
  16626. if (!parent) {
  16627. return true;
  16628. }
  16629. if (id.name === "arguments") {
  16630. return false;
  16631. }
  16632. if (isReferenced(id, parent)) {
  16633. return true;
  16634. }
  16635. switch (parent.type) {
  16636. case "AssignmentExpression":
  16637. case "AssignmentPattern":
  16638. return true;
  16639. case "ObjectPattern":
  16640. case "ArrayPattern":
  16641. return isInDestructureAssignment(parent, parentStack);
  16642. }
  16643. return false;
  16644. }
  16645. function isInDestructureAssignment(parent, parentStack) {
  16646. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  16647. let i = parentStack.length;
  16648. while (i--) {
  16649. const p = parentStack[i];
  16650. if (p.type === "AssignmentExpression") {
  16651. return true;
  16652. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  16653. break;
  16654. }
  16655. }
  16656. }
  16657. return false;
  16658. }
  16659. function isInNewExpression(parentStack) {
  16660. let i = parentStack.length;
  16661. while (i--) {
  16662. const p = parentStack[i];
  16663. if (p.type === "NewExpression") {
  16664. return true;
  16665. } else if (p.type !== "MemberExpression") {
  16666. break;
  16667. }
  16668. }
  16669. return false;
  16670. }
  16671. function walkFunctionParams(node, onIdent) {
  16672. for (const p of node.params) {
  16673. for (const id of extractIdentifiers$1(p)) {
  16674. onIdent(id);
  16675. }
  16676. }
  16677. }
  16678. function walkBlockDeclarations(block, onIdent) {
  16679. for (const stmt of block.body) {
  16680. if (stmt.type === "VariableDeclaration") {
  16681. if (stmt.declare) continue;
  16682. for (const decl of stmt.declarations) {
  16683. for (const id of extractIdentifiers$1(decl.id)) {
  16684. onIdent(id);
  16685. }
  16686. }
  16687. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  16688. if (stmt.declare || !stmt.id) continue;
  16689. onIdent(stmt.id);
  16690. } else if (isForStatement(stmt)) {
  16691. walkForStatement(stmt, true, onIdent);
  16692. }
  16693. }
  16694. }
  16695. function isForStatement(stmt) {
  16696. return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
  16697. }
  16698. function walkForStatement(stmt, isVar, onIdent) {
  16699. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  16700. if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) {
  16701. for (const decl of variable.declarations) {
  16702. for (const id of extractIdentifiers$1(decl.id)) {
  16703. onIdent(id);
  16704. }
  16705. }
  16706. }
  16707. }
  16708. function extractIdentifiers$1(param, nodes = []) {
  16709. switch (param.type) {
  16710. case "Identifier":
  16711. nodes.push(param);
  16712. break;
  16713. case "MemberExpression":
  16714. let object = param;
  16715. while (object.type === "MemberExpression") {
  16716. object = object.object;
  16717. }
  16718. nodes.push(object);
  16719. break;
  16720. case "ObjectPattern":
  16721. for (const prop of param.properties) {
  16722. if (prop.type === "RestElement") {
  16723. extractIdentifiers$1(prop.argument, nodes);
  16724. } else {
  16725. extractIdentifiers$1(prop.value, nodes);
  16726. }
  16727. }
  16728. break;
  16729. case "ArrayPattern":
  16730. param.elements.forEach((element) => {
  16731. if (element) extractIdentifiers$1(element, nodes);
  16732. });
  16733. break;
  16734. case "RestElement":
  16735. extractIdentifiers$1(param.argument, nodes);
  16736. break;
  16737. case "AssignmentPattern":
  16738. extractIdentifiers$1(param.left, nodes);
  16739. break;
  16740. }
  16741. return nodes;
  16742. }
  16743. function markKnownIds(name, knownIds) {
  16744. if (name in knownIds) {
  16745. knownIds[name]++;
  16746. } else {
  16747. knownIds[name] = 1;
  16748. }
  16749. }
  16750. function markScopeIdentifier(node, child, knownIds) {
  16751. const { name } = child;
  16752. if (node.scopeIds && node.scopeIds.has(name)) {
  16753. return;
  16754. }
  16755. markKnownIds(name, knownIds);
  16756. (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
  16757. }
  16758. const isFunctionType = (node) => {
  16759. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  16760. };
  16761. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  16762. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  16763. function isReferenced(node, parent, grandparent) {
  16764. switch (parent.type) {
  16765. // yes: PARENT[NODE]
  16766. // yes: NODE.child
  16767. // no: parent.NODE
  16768. case "MemberExpression":
  16769. case "OptionalMemberExpression":
  16770. if (parent.property === node) {
  16771. return !!parent.computed;
  16772. }
  16773. return parent.object === node;
  16774. case "JSXMemberExpression":
  16775. return parent.object === node;
  16776. // no: let NODE = init;
  16777. // yes: let id = NODE;
  16778. case "VariableDeclarator":
  16779. return parent.init === node;
  16780. // yes: () => NODE
  16781. // no: (NODE) => {}
  16782. case "ArrowFunctionExpression":
  16783. return parent.body === node;
  16784. // no: class { #NODE; }
  16785. // no: class { get #NODE() {} }
  16786. // no: class { #NODE() {} }
  16787. // no: class { fn() { return this.#NODE; } }
  16788. case "PrivateName":
  16789. return false;
  16790. // no: class { NODE() {} }
  16791. // yes: class { [NODE]() {} }
  16792. // no: class { foo(NODE) {} }
  16793. case "ClassMethod":
  16794. case "ClassPrivateMethod":
  16795. case "ObjectMethod":
  16796. if (parent.key === node) {
  16797. return !!parent.computed;
  16798. }
  16799. return false;
  16800. // yes: { [NODE]: "" }
  16801. // no: { NODE: "" }
  16802. // depends: { NODE }
  16803. // depends: { key: NODE }
  16804. case "ObjectProperty":
  16805. if (parent.key === node) {
  16806. return !!parent.computed;
  16807. }
  16808. return !grandparent;
  16809. // no: class { NODE = value; }
  16810. // yes: class { [NODE] = value; }
  16811. // yes: class { key = NODE; }
  16812. case "ClassProperty":
  16813. if (parent.key === node) {
  16814. return !!parent.computed;
  16815. }
  16816. return true;
  16817. case "ClassPrivateProperty":
  16818. return parent.key !== node;
  16819. // no: class NODE {}
  16820. // yes: class Foo extends NODE {}
  16821. case "ClassDeclaration":
  16822. case "ClassExpression":
  16823. return parent.superClass === node;
  16824. // yes: left = NODE;
  16825. // no: NODE = right;
  16826. case "AssignmentExpression":
  16827. return parent.right === node;
  16828. // no: [NODE = foo] = [];
  16829. // yes: [foo = NODE] = [];
  16830. case "AssignmentPattern":
  16831. return parent.right === node;
  16832. // no: NODE: for (;;) {}
  16833. case "LabeledStatement":
  16834. return false;
  16835. // no: try {} catch (NODE) {}
  16836. case "CatchClause":
  16837. return false;
  16838. // no: function foo(...NODE) {}
  16839. case "RestElement":
  16840. return false;
  16841. case "BreakStatement":
  16842. case "ContinueStatement":
  16843. return false;
  16844. // no: function NODE() {}
  16845. // no: function foo(NODE) {}
  16846. case "FunctionDeclaration":
  16847. case "FunctionExpression":
  16848. return false;
  16849. // no: export NODE from "foo";
  16850. // no: export * as NODE from "foo";
  16851. case "ExportNamespaceSpecifier":
  16852. case "ExportDefaultSpecifier":
  16853. return false;
  16854. // no: export { foo as NODE };
  16855. // yes: export { NODE as foo };
  16856. // no: export { NODE as foo } from "foo";
  16857. case "ExportSpecifier":
  16858. return parent.local === node;
  16859. // no: import NODE from "foo";
  16860. // no: import * as NODE from "foo";
  16861. // no: import { NODE as foo } from "foo";
  16862. // no: import { foo as NODE } from "foo";
  16863. // no: import NODE from "bar";
  16864. case "ImportDefaultSpecifier":
  16865. case "ImportNamespaceSpecifier":
  16866. case "ImportSpecifier":
  16867. return false;
  16868. // no: import "foo" assert { NODE: "json" }
  16869. case "ImportAttribute":
  16870. return false;
  16871. // no: <div NODE="foo" />
  16872. case "JSXAttribute":
  16873. return false;
  16874. // no: [NODE] = [];
  16875. // no: ({ NODE }) = [];
  16876. case "ObjectPattern":
  16877. case "ArrayPattern":
  16878. return false;
  16879. // no: new.NODE
  16880. // no: NODE.target
  16881. case "MetaProperty":
  16882. return false;
  16883. // yes: type X = { someProperty: NODE }
  16884. // no: type X = { NODE: OtherType }
  16885. case "ObjectTypeProperty":
  16886. return parent.key !== node;
  16887. // yes: enum X { Foo = NODE }
  16888. // no: enum X { NODE }
  16889. case "TSEnumMember":
  16890. return parent.id !== node;
  16891. // yes: { [NODE]: value }
  16892. // no: { NODE: value }
  16893. case "TSPropertySignature":
  16894. if (parent.key === node) {
  16895. return !!parent.computed;
  16896. }
  16897. return true;
  16898. }
  16899. return true;
  16900. }
  16901. const TS_NODE_TYPES = [
  16902. "TSAsExpression",
  16903. // foo as number
  16904. "TSTypeAssertion",
  16905. // (<number>foo)
  16906. "TSNonNullExpression",
  16907. // foo!
  16908. "TSInstantiationExpression",
  16909. // foo<string>
  16910. "TSSatisfiesExpression"
  16911. // foo satisfies T
  16912. ];
  16913. function unwrapTSNode(node) {
  16914. if (TS_NODE_TYPES.includes(node.type)) {
  16915. return unwrapTSNode(node.expression);
  16916. } else {
  16917. return node;
  16918. }
  16919. }
  16920. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  16921. function isCoreComponent(tag) {
  16922. switch (tag) {
  16923. case "Teleport":
  16924. case "teleport":
  16925. return TELEPORT;
  16926. case "Suspense":
  16927. case "suspense":
  16928. return SUSPENSE;
  16929. case "KeepAlive":
  16930. case "keep-alive":
  16931. return KEEP_ALIVE;
  16932. case "BaseTransition":
  16933. case "base-transition":
  16934. return BASE_TRANSITION;
  16935. }
  16936. }
  16937. const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
  16938. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  16939. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  16940. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  16941. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  16942. const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
  16943. const isMemberExpressionBrowser = (exp) => {
  16944. const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
  16945. let state = 0 /* inMemberExp */;
  16946. let stateStack = [];
  16947. let currentOpenBracketCount = 0;
  16948. let currentOpenParensCount = 0;
  16949. let currentStringType = null;
  16950. for (let i = 0; i < path.length; i++) {
  16951. const char = path.charAt(i);
  16952. switch (state) {
  16953. case 0 /* inMemberExp */:
  16954. if (char === "[") {
  16955. stateStack.push(state);
  16956. state = 1 /* inBrackets */;
  16957. currentOpenBracketCount++;
  16958. } else if (char === "(") {
  16959. stateStack.push(state);
  16960. state = 2 /* inParens */;
  16961. currentOpenParensCount++;
  16962. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  16963. return false;
  16964. }
  16965. break;
  16966. case 1 /* inBrackets */:
  16967. if (char === `'` || char === `"` || char === "`") {
  16968. stateStack.push(state);
  16969. state = 3 /* inString */;
  16970. currentStringType = char;
  16971. } else if (char === `[`) {
  16972. currentOpenBracketCount++;
  16973. } else if (char === `]`) {
  16974. if (!--currentOpenBracketCount) {
  16975. state = stateStack.pop();
  16976. }
  16977. }
  16978. break;
  16979. case 2 /* inParens */:
  16980. if (char === `'` || char === `"` || char === "`") {
  16981. stateStack.push(state);
  16982. state = 3 /* inString */;
  16983. currentStringType = char;
  16984. } else if (char === `(`) {
  16985. currentOpenParensCount++;
  16986. } else if (char === `)`) {
  16987. if (i === path.length - 1) {
  16988. return false;
  16989. }
  16990. if (!--currentOpenParensCount) {
  16991. state = stateStack.pop();
  16992. }
  16993. }
  16994. break;
  16995. case 3 /* inString */:
  16996. if (char === currentStringType) {
  16997. state = stateStack.pop();
  16998. currentStringType = null;
  16999. }
  17000. break;
  17001. }
  17002. }
  17003. return !currentOpenBracketCount && !currentOpenParensCount;
  17004. };
  17005. const isMemberExpressionNode = (exp, context) => {
  17006. try {
  17007. let ret = exp.ast || libExports.parseExpression(getExpSource(exp), {
  17008. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  17009. });
  17010. ret = unwrapTSNode(ret);
  17011. return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
  17012. } catch (e) {
  17013. return false;
  17014. }
  17015. };
  17016. const isMemberExpression = isMemberExpressionNode;
  17017. const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  17018. const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
  17019. const isFnExpressionNode = (exp, context) => {
  17020. try {
  17021. let ret = exp.ast || libExports.parseExpression(getExpSource(exp), {
  17022. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  17023. });
  17024. if (ret.type === "Program") {
  17025. ret = ret.body[0];
  17026. if (ret.type === "ExpressionStatement") {
  17027. ret = ret.expression;
  17028. }
  17029. }
  17030. ret = unwrapTSNode(ret);
  17031. return ret.type === "FunctionExpression" || ret.type === "ArrowFunctionExpression";
  17032. } catch (e) {
  17033. return false;
  17034. }
  17035. };
  17036. const isFnExpression = isFnExpressionNode;
  17037. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  17038. return advancePositionWithMutation(
  17039. {
  17040. offset: pos.offset,
  17041. line: pos.line,
  17042. column: pos.column
  17043. },
  17044. source,
  17045. numberOfCharacters
  17046. );
  17047. }
  17048. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  17049. let linesCount = 0;
  17050. let lastNewLinePos = -1;
  17051. for (let i = 0; i < numberOfCharacters; i++) {
  17052. if (source.charCodeAt(i) === 10) {
  17053. linesCount++;
  17054. lastNewLinePos = i;
  17055. }
  17056. }
  17057. pos.offset += numberOfCharacters;
  17058. pos.line += linesCount;
  17059. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  17060. return pos;
  17061. }
  17062. function assert(condition, msg) {
  17063. if (!condition) {
  17064. throw new Error(msg || `unexpected compiler condition`);
  17065. }
  17066. }
  17067. function findDir(node, name, allowEmpty = false) {
  17068. for (let i = 0; i < node.props.length; i++) {
  17069. const p = node.props[i];
  17070. if (p.type === 7 && (allowEmpty || p.exp) && (isString$1(name) ? p.name === name : name.test(p.name))) {
  17071. return p;
  17072. }
  17073. }
  17074. }
  17075. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  17076. for (let i = 0; i < node.props.length; i++) {
  17077. const p = node.props[i];
  17078. if (p.type === 6) {
  17079. if (dynamicOnly) continue;
  17080. if (p.name === name && (p.value || allowEmpty)) {
  17081. return p;
  17082. }
  17083. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  17084. return p;
  17085. }
  17086. }
  17087. }
  17088. function isStaticArgOf(arg, name) {
  17089. return !!(arg && isStaticExp(arg) && arg.content === name);
  17090. }
  17091. function hasDynamicKeyVBind(node) {
  17092. return node.props.some(
  17093. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  17094. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  17095. !p.arg.isStatic)
  17096. // v-bind:[foo]
  17097. );
  17098. }
  17099. function isText$1(node) {
  17100. return node.type === 5 || node.type === 2;
  17101. }
  17102. function isVSlot(p) {
  17103. return p.type === 7 && p.name === "slot";
  17104. }
  17105. function isTemplateNode(node) {
  17106. return node.type === 1 && node.tagType === 3;
  17107. }
  17108. function isSlotOutlet(node) {
  17109. return node.type === 1 && node.tagType === 2;
  17110. }
  17111. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  17112. function getUnnormalizedProps(props, callPath = []) {
  17113. if (props && !isString$1(props) && props.type === 14) {
  17114. const callee = props.callee;
  17115. if (!isString$1(callee) && propsHelperSet.has(callee)) {
  17116. return getUnnormalizedProps(
  17117. props.arguments[0],
  17118. callPath.concat(props)
  17119. );
  17120. }
  17121. }
  17122. return [props, callPath];
  17123. }
  17124. function injectProp(node, prop, context) {
  17125. let propsWithInjection;
  17126. let props = node.type === 13 ? node.props : node.arguments[2];
  17127. let callPath = [];
  17128. let parentCall;
  17129. if (props && !isString$1(props) && props.type === 14) {
  17130. const ret = getUnnormalizedProps(props);
  17131. props = ret[0];
  17132. callPath = ret[1];
  17133. parentCall = callPath[callPath.length - 1];
  17134. }
  17135. if (props == null || isString$1(props)) {
  17136. propsWithInjection = createObjectExpression([prop]);
  17137. } else if (props.type === 14) {
  17138. const first = props.arguments[0];
  17139. if (!isString$1(first) && first.type === 15) {
  17140. if (!hasProp(prop, first)) {
  17141. first.properties.unshift(prop);
  17142. }
  17143. } else {
  17144. if (props.callee === TO_HANDLERS) {
  17145. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17146. createObjectExpression([prop]),
  17147. props
  17148. ]);
  17149. } else {
  17150. props.arguments.unshift(createObjectExpression([prop]));
  17151. }
  17152. }
  17153. !propsWithInjection && (propsWithInjection = props);
  17154. } else if (props.type === 15) {
  17155. if (!hasProp(prop, props)) {
  17156. props.properties.unshift(prop);
  17157. }
  17158. propsWithInjection = props;
  17159. } else {
  17160. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17161. createObjectExpression([prop]),
  17162. props
  17163. ]);
  17164. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  17165. parentCall = callPath[callPath.length - 2];
  17166. }
  17167. }
  17168. if (node.type === 13) {
  17169. if (parentCall) {
  17170. parentCall.arguments[0] = propsWithInjection;
  17171. } else {
  17172. node.props = propsWithInjection;
  17173. }
  17174. } else {
  17175. if (parentCall) {
  17176. parentCall.arguments[0] = propsWithInjection;
  17177. } else {
  17178. node.arguments[2] = propsWithInjection;
  17179. }
  17180. }
  17181. }
  17182. function hasProp(prop, props) {
  17183. let result = false;
  17184. if (prop.key.type === 4) {
  17185. const propKeyName = prop.key.content;
  17186. result = props.properties.some(
  17187. (p) => p.key.type === 4 && p.key.content === propKeyName
  17188. );
  17189. }
  17190. return result;
  17191. }
  17192. function toValidAssetId(name, type) {
  17193. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  17194. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  17195. })}`;
  17196. }
  17197. function hasScopeRef(node, ids) {
  17198. if (!node || Object.keys(ids).length === 0) {
  17199. return false;
  17200. }
  17201. switch (node.type) {
  17202. case 1:
  17203. for (let i = 0; i < node.props.length; i++) {
  17204. const p = node.props[i];
  17205. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  17206. return true;
  17207. }
  17208. }
  17209. return node.children.some((c) => hasScopeRef(c, ids));
  17210. case 11:
  17211. if (hasScopeRef(node.source, ids)) {
  17212. return true;
  17213. }
  17214. return node.children.some((c) => hasScopeRef(c, ids));
  17215. case 9:
  17216. return node.branches.some((b) => hasScopeRef(b, ids));
  17217. case 10:
  17218. if (hasScopeRef(node.condition, ids)) {
  17219. return true;
  17220. }
  17221. return node.children.some((c) => hasScopeRef(c, ids));
  17222. case 4:
  17223. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  17224. case 8:
  17225. return node.children.some((c) => isObject$2(c) && hasScopeRef(c, ids));
  17226. case 5:
  17227. case 12:
  17228. return hasScopeRef(node.content, ids);
  17229. case 2:
  17230. case 3:
  17231. case 20:
  17232. return false;
  17233. default:
  17234. return false;
  17235. }
  17236. }
  17237. function getMemoedVNodeCall(node) {
  17238. if (node.type === 14 && node.callee === WITH_MEMO) {
  17239. return node.arguments[1].returns;
  17240. } else {
  17241. return node;
  17242. }
  17243. }
  17244. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
  17245. const defaultParserOptions = {
  17246. parseMode: "base",
  17247. ns: 0,
  17248. delimiters: [`{{`, `}}`],
  17249. getNamespace: () => 0,
  17250. isVoidTag: NO,
  17251. isPreTag: NO,
  17252. isIgnoreNewlineTag: NO,
  17253. isCustomElement: NO,
  17254. onError: defaultOnError,
  17255. onWarn: defaultOnWarn,
  17256. comments: true,
  17257. prefixIdentifiers: false
  17258. };
  17259. let currentOptions = defaultParserOptions;
  17260. let currentRoot = null;
  17261. let currentInput = "";
  17262. let currentOpenTag = null;
  17263. let currentProp = null;
  17264. let currentAttrValue = "";
  17265. let currentAttrStartIndex = -1;
  17266. let currentAttrEndIndex = -1;
  17267. let inPre = 0;
  17268. let inVPre = false;
  17269. let currentVPreBoundary = null;
  17270. const stack = [];
  17271. const tokenizer = new Tokenizer(stack, {
  17272. onerr: emitError,
  17273. ontext(start, end) {
  17274. onText(getSlice(start, end), start, end);
  17275. },
  17276. ontextentity(char, start, end) {
  17277. onText(char, start, end);
  17278. },
  17279. oninterpolation(start, end) {
  17280. if (inVPre) {
  17281. return onText(getSlice(start, end), start, end);
  17282. }
  17283. let innerStart = start + tokenizer.delimiterOpen.length;
  17284. let innerEnd = end - tokenizer.delimiterClose.length;
  17285. while (isWhitespace(currentInput.charCodeAt(innerStart))) {
  17286. innerStart++;
  17287. }
  17288. while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
  17289. innerEnd--;
  17290. }
  17291. let exp = getSlice(innerStart, innerEnd);
  17292. if (exp.includes("&")) {
  17293. {
  17294. exp = decodeHTML(exp);
  17295. }
  17296. }
  17297. addNode({
  17298. type: 5,
  17299. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  17300. loc: getLoc(start, end)
  17301. });
  17302. },
  17303. onopentagname(start, end) {
  17304. const name = getSlice(start, end);
  17305. currentOpenTag = {
  17306. type: 1,
  17307. tag: name,
  17308. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  17309. tagType: 0,
  17310. // will be refined on tag close
  17311. props: [],
  17312. children: [],
  17313. loc: getLoc(start - 1, end),
  17314. codegenNode: void 0
  17315. };
  17316. },
  17317. onopentagend(end) {
  17318. endOpenTag(end);
  17319. },
  17320. onclosetag(start, end) {
  17321. const name = getSlice(start, end);
  17322. if (!currentOptions.isVoidTag(name)) {
  17323. let found = false;
  17324. for (let i = 0; i < stack.length; i++) {
  17325. const e = stack[i];
  17326. if (e.tag.toLowerCase() === name.toLowerCase()) {
  17327. found = true;
  17328. if (i > 0) {
  17329. emitError(24, stack[0].loc.start.offset);
  17330. }
  17331. for (let j = 0; j <= i; j++) {
  17332. const el = stack.shift();
  17333. onCloseTag(el, end, j < i);
  17334. }
  17335. break;
  17336. }
  17337. }
  17338. if (!found) {
  17339. emitError(23, backTrack(start, 60));
  17340. }
  17341. }
  17342. },
  17343. onselfclosingtag(end) {
  17344. const name = currentOpenTag.tag;
  17345. currentOpenTag.isSelfClosing = true;
  17346. endOpenTag(end);
  17347. if (stack[0] && stack[0].tag === name) {
  17348. onCloseTag(stack.shift(), end);
  17349. }
  17350. },
  17351. onattribname(start, end) {
  17352. currentProp = {
  17353. type: 6,
  17354. name: getSlice(start, end),
  17355. nameLoc: getLoc(start, end),
  17356. value: void 0,
  17357. loc: getLoc(start)
  17358. };
  17359. },
  17360. ondirname(start, end) {
  17361. const raw = getSlice(start, end);
  17362. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  17363. if (!inVPre && name === "") {
  17364. emitError(26, start);
  17365. }
  17366. if (inVPre || name === "") {
  17367. currentProp = {
  17368. type: 6,
  17369. name: raw,
  17370. nameLoc: getLoc(start, end),
  17371. value: void 0,
  17372. loc: getLoc(start)
  17373. };
  17374. } else {
  17375. currentProp = {
  17376. type: 7,
  17377. name,
  17378. rawName: raw,
  17379. exp: void 0,
  17380. arg: void 0,
  17381. modifiers: raw === "." ? [createSimpleExpression("prop")] : [],
  17382. loc: getLoc(start)
  17383. };
  17384. if (name === "pre") {
  17385. inVPre = tokenizer.inVPre = true;
  17386. currentVPreBoundary = currentOpenTag;
  17387. const props = currentOpenTag.props;
  17388. for (let i = 0; i < props.length; i++) {
  17389. if (props[i].type === 7) {
  17390. props[i] = dirToAttr(props[i]);
  17391. }
  17392. }
  17393. }
  17394. }
  17395. },
  17396. ondirarg(start, end) {
  17397. if (start === end) return;
  17398. const arg = getSlice(start, end);
  17399. if (inVPre) {
  17400. currentProp.name += arg;
  17401. setLocEnd(currentProp.nameLoc, end);
  17402. } else {
  17403. const isStatic = arg[0] !== `[`;
  17404. currentProp.arg = createExp(
  17405. isStatic ? arg : arg.slice(1, -1),
  17406. isStatic,
  17407. getLoc(start, end),
  17408. isStatic ? 3 : 0
  17409. );
  17410. }
  17411. },
  17412. ondirmodifier(start, end) {
  17413. const mod = getSlice(start, end);
  17414. if (inVPre) {
  17415. currentProp.name += "." + mod;
  17416. setLocEnd(currentProp.nameLoc, end);
  17417. } else if (currentProp.name === "slot") {
  17418. const arg = currentProp.arg;
  17419. if (arg) {
  17420. arg.content += "." + mod;
  17421. setLocEnd(arg.loc, end);
  17422. }
  17423. } else {
  17424. const exp = createSimpleExpression(mod, true, getLoc(start, end));
  17425. currentProp.modifiers.push(exp);
  17426. }
  17427. },
  17428. onattribdata(start, end) {
  17429. currentAttrValue += getSlice(start, end);
  17430. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  17431. currentAttrEndIndex = end;
  17432. },
  17433. onattribentity(char, start, end) {
  17434. currentAttrValue += char;
  17435. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  17436. currentAttrEndIndex = end;
  17437. },
  17438. onattribnameend(end) {
  17439. const start = currentProp.loc.start.offset;
  17440. const name = getSlice(start, end);
  17441. if (currentProp.type === 7) {
  17442. currentProp.rawName = name;
  17443. }
  17444. if (currentOpenTag.props.some(
  17445. (p) => (p.type === 7 ? p.rawName : p.name) === name
  17446. )) {
  17447. emitError(2, start);
  17448. }
  17449. },
  17450. onattribend(quote, end) {
  17451. if (currentOpenTag && currentProp) {
  17452. setLocEnd(currentProp.loc, end);
  17453. if (quote !== 0) {
  17454. if (currentProp.type === 6) {
  17455. if (currentProp.name === "class") {
  17456. currentAttrValue = condense(currentAttrValue).trim();
  17457. }
  17458. if (quote === 1 && !currentAttrValue) {
  17459. emitError(13, end);
  17460. }
  17461. currentProp.value = {
  17462. type: 2,
  17463. content: currentAttrValue,
  17464. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  17465. };
  17466. if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  17467. tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
  17468. }
  17469. } else {
  17470. let expParseMode = 0 /* Normal */;
  17471. {
  17472. if (currentProp.name === "for") {
  17473. expParseMode = 3 /* Skip */;
  17474. } else if (currentProp.name === "slot") {
  17475. expParseMode = 1 /* Params */;
  17476. } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
  17477. expParseMode = 2 /* Statements */;
  17478. }
  17479. }
  17480. currentProp.exp = createExp(
  17481. currentAttrValue,
  17482. false,
  17483. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  17484. 0,
  17485. expParseMode
  17486. );
  17487. if (currentProp.name === "for") {
  17488. currentProp.forParseResult = parseForExpression(currentProp.exp);
  17489. }
  17490. }
  17491. }
  17492. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  17493. currentOpenTag.props.push(currentProp);
  17494. }
  17495. }
  17496. currentAttrValue = "";
  17497. currentAttrStartIndex = currentAttrEndIndex = -1;
  17498. },
  17499. oncomment(start, end) {
  17500. if (currentOptions.comments) {
  17501. addNode({
  17502. type: 3,
  17503. content: getSlice(start, end),
  17504. loc: getLoc(start - 4, end + 3)
  17505. });
  17506. }
  17507. },
  17508. onend() {
  17509. const end = currentInput.length;
  17510. if (tokenizer.state !== 1) {
  17511. switch (tokenizer.state) {
  17512. case 5:
  17513. case 8:
  17514. emitError(5, end);
  17515. break;
  17516. case 3:
  17517. case 4:
  17518. emitError(
  17519. 25,
  17520. tokenizer.sectionStart
  17521. );
  17522. break;
  17523. case 28:
  17524. if (tokenizer.currentSequence === Sequences.CdataEnd) {
  17525. emitError(6, end);
  17526. } else {
  17527. emitError(7, end);
  17528. }
  17529. break;
  17530. case 6:
  17531. case 7:
  17532. case 9:
  17533. case 11:
  17534. case 12:
  17535. case 13:
  17536. case 14:
  17537. case 15:
  17538. case 16:
  17539. case 17:
  17540. case 18:
  17541. case 19:
  17542. // "
  17543. case 20:
  17544. // '
  17545. case 21:
  17546. emitError(9, end);
  17547. break;
  17548. }
  17549. }
  17550. for (let index = 0; index < stack.length; index++) {
  17551. onCloseTag(stack[index], end - 1);
  17552. emitError(24, stack[index].loc.start.offset);
  17553. }
  17554. },
  17555. oncdata(start, end) {
  17556. if (stack[0].ns !== 0) {
  17557. onText(getSlice(start, end), start, end);
  17558. } else {
  17559. emitError(1, start - 9);
  17560. }
  17561. },
  17562. onprocessinginstruction(start) {
  17563. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17564. emitError(
  17565. 21,
  17566. start - 1
  17567. );
  17568. }
  17569. }
  17570. });
  17571. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  17572. const stripParensRE = /^\(|\)$/g;
  17573. function parseForExpression(input) {
  17574. const loc = input.loc;
  17575. const exp = input.content;
  17576. const inMatch = exp.match(forAliasRE);
  17577. if (!inMatch) return;
  17578. const [, LHS, RHS] = inMatch;
  17579. const createAliasExpression = (content, offset, asParam = false) => {
  17580. const start = loc.start.offset + offset;
  17581. const end = start + content.length;
  17582. return createExp(
  17583. content,
  17584. false,
  17585. getLoc(start, end),
  17586. 0,
  17587. asParam ? 1 /* Params */ : 0 /* Normal */
  17588. );
  17589. };
  17590. const result = {
  17591. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  17592. value: void 0,
  17593. key: void 0,
  17594. index: void 0,
  17595. finalized: false
  17596. };
  17597. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  17598. const trimmedOffset = LHS.indexOf(valueContent);
  17599. const iteratorMatch = valueContent.match(forIteratorRE);
  17600. if (iteratorMatch) {
  17601. valueContent = valueContent.replace(forIteratorRE, "").trim();
  17602. const keyContent = iteratorMatch[1].trim();
  17603. let keyOffset;
  17604. if (keyContent) {
  17605. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  17606. result.key = createAliasExpression(keyContent, keyOffset, true);
  17607. }
  17608. if (iteratorMatch[2]) {
  17609. const indexContent = iteratorMatch[2].trim();
  17610. if (indexContent) {
  17611. result.index = createAliasExpression(
  17612. indexContent,
  17613. exp.indexOf(
  17614. indexContent,
  17615. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  17616. ),
  17617. true
  17618. );
  17619. }
  17620. }
  17621. }
  17622. if (valueContent) {
  17623. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  17624. }
  17625. return result;
  17626. }
  17627. function getSlice(start, end) {
  17628. return currentInput.slice(start, end);
  17629. }
  17630. function endOpenTag(end) {
  17631. if (tokenizer.inSFCRoot) {
  17632. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  17633. }
  17634. addNode(currentOpenTag);
  17635. const { tag, ns } = currentOpenTag;
  17636. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17637. inPre++;
  17638. }
  17639. if (currentOptions.isVoidTag(tag)) {
  17640. onCloseTag(currentOpenTag, end);
  17641. } else {
  17642. stack.unshift(currentOpenTag);
  17643. if (ns === 1 || ns === 2) {
  17644. tokenizer.inXML = true;
  17645. }
  17646. }
  17647. currentOpenTag = null;
  17648. }
  17649. function onText(content, start, end) {
  17650. const parent = stack[0] || currentRoot;
  17651. const lastNode = parent.children[parent.children.length - 1];
  17652. if (lastNode && lastNode.type === 2) {
  17653. lastNode.content += content;
  17654. setLocEnd(lastNode.loc, end);
  17655. } else {
  17656. parent.children.push({
  17657. type: 2,
  17658. content,
  17659. loc: getLoc(start, end)
  17660. });
  17661. }
  17662. }
  17663. function onCloseTag(el, end, isImplied = false) {
  17664. if (isImplied) {
  17665. setLocEnd(el.loc, backTrack(end, 60));
  17666. } else {
  17667. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  17668. }
  17669. if (tokenizer.inSFCRoot) {
  17670. if (el.children.length) {
  17671. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  17672. } else {
  17673. el.innerLoc.end = extend({}, el.innerLoc.start);
  17674. }
  17675. el.innerLoc.source = getSlice(
  17676. el.innerLoc.start.offset,
  17677. el.innerLoc.end.offset
  17678. );
  17679. }
  17680. const { tag, ns, children } = el;
  17681. if (!inVPre) {
  17682. if (tag === "slot") {
  17683. el.tagType = 2;
  17684. } else if (isFragmentTemplate(el)) {
  17685. el.tagType = 3;
  17686. } else if (isComponent(el)) {
  17687. el.tagType = 1;
  17688. }
  17689. }
  17690. if (!tokenizer.inRCDATA) {
  17691. el.children = condenseWhitespace(children);
  17692. }
  17693. if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
  17694. const first = children[0];
  17695. if (first && first.type === 2) {
  17696. first.content = first.content.replace(/^\r?\n/, "");
  17697. }
  17698. }
  17699. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17700. inPre--;
  17701. }
  17702. if (currentVPreBoundary === el) {
  17703. inVPre = tokenizer.inVPre = false;
  17704. currentVPreBoundary = null;
  17705. }
  17706. if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17707. tokenizer.inXML = false;
  17708. }
  17709. }
  17710. function lookAhead(index, c) {
  17711. let i = index;
  17712. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
  17713. return i;
  17714. }
  17715. function backTrack(index, c) {
  17716. let i = index;
  17717. while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
  17718. return i;
  17719. }
  17720. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  17721. function isFragmentTemplate({ tag, props }) {
  17722. if (tag === "template") {
  17723. for (let i = 0; i < props.length; i++) {
  17724. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  17725. return true;
  17726. }
  17727. }
  17728. }
  17729. return false;
  17730. }
  17731. function isComponent({ tag, props }) {
  17732. if (currentOptions.isCustomElement(tag)) {
  17733. return false;
  17734. }
  17735. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  17736. return true;
  17737. }
  17738. for (let i = 0; i < props.length; i++) {
  17739. const p = props[i];
  17740. if (p.type === 6) {
  17741. if (p.name === "is" && p.value) {
  17742. if (p.value.content.startsWith("vue:")) {
  17743. return true;
  17744. }
  17745. }
  17746. }
  17747. }
  17748. return false;
  17749. }
  17750. function isUpperCase(c) {
  17751. return c > 64 && c < 91;
  17752. }
  17753. const windowsNewlineRE = /\r\n/g;
  17754. function condenseWhitespace(nodes, tag) {
  17755. const shouldCondense = currentOptions.whitespace !== "preserve";
  17756. let removedWhitespace = false;
  17757. for (let i = 0; i < nodes.length; i++) {
  17758. const node = nodes[i];
  17759. if (node.type === 2) {
  17760. if (!inPre) {
  17761. if (isAllWhitespace(node.content)) {
  17762. const prev = nodes[i - 1] && nodes[i - 1].type;
  17763. const next = nodes[i + 1] && nodes[i + 1].type;
  17764. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  17765. removedWhitespace = true;
  17766. nodes[i] = null;
  17767. } else {
  17768. node.content = " ";
  17769. }
  17770. } else if (shouldCondense) {
  17771. node.content = condense(node.content);
  17772. }
  17773. } else {
  17774. node.content = node.content.replace(windowsNewlineRE, "\n");
  17775. }
  17776. }
  17777. }
  17778. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  17779. }
  17780. function isAllWhitespace(str) {
  17781. for (let i = 0; i < str.length; i++) {
  17782. if (!isWhitespace(str.charCodeAt(i))) {
  17783. return false;
  17784. }
  17785. }
  17786. return true;
  17787. }
  17788. function hasNewlineChar(str) {
  17789. for (let i = 0; i < str.length; i++) {
  17790. const c = str.charCodeAt(i);
  17791. if (c === 10 || c === 13) {
  17792. return true;
  17793. }
  17794. }
  17795. return false;
  17796. }
  17797. function condense(str) {
  17798. let ret = "";
  17799. let prevCharIsWhitespace = false;
  17800. for (let i = 0; i < str.length; i++) {
  17801. if (isWhitespace(str.charCodeAt(i))) {
  17802. if (!prevCharIsWhitespace) {
  17803. ret += " ";
  17804. prevCharIsWhitespace = true;
  17805. }
  17806. } else {
  17807. ret += str[i];
  17808. prevCharIsWhitespace = false;
  17809. }
  17810. }
  17811. return ret;
  17812. }
  17813. function addNode(node) {
  17814. (stack[0] || currentRoot).children.push(node);
  17815. }
  17816. function getLoc(start, end) {
  17817. return {
  17818. start: tokenizer.getPos(start),
  17819. // @ts-expect-error allow late attachment
  17820. end: end == null ? end : tokenizer.getPos(end),
  17821. // @ts-expect-error allow late attachment
  17822. source: end == null ? end : getSlice(start, end)
  17823. };
  17824. }
  17825. function cloneLoc(loc) {
  17826. return getLoc(loc.start.offset, loc.end.offset);
  17827. }
  17828. function setLocEnd(loc, end) {
  17829. loc.end = tokenizer.getPos(end);
  17830. loc.source = getSlice(loc.start.offset, end);
  17831. }
  17832. function dirToAttr(dir) {
  17833. const attr = {
  17834. type: 6,
  17835. name: dir.rawName,
  17836. nameLoc: getLoc(
  17837. dir.loc.start.offset,
  17838. dir.loc.start.offset + dir.rawName.length
  17839. ),
  17840. value: void 0,
  17841. loc: dir.loc
  17842. };
  17843. if (dir.exp) {
  17844. const loc = dir.exp.loc;
  17845. if (loc.end.offset < dir.loc.end.offset) {
  17846. loc.start.offset--;
  17847. loc.start.column--;
  17848. loc.end.offset++;
  17849. loc.end.column++;
  17850. }
  17851. attr.value = {
  17852. type: 2,
  17853. content: dir.exp.content,
  17854. loc
  17855. };
  17856. }
  17857. return attr;
  17858. }
  17859. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  17860. const exp = createSimpleExpression(content, isStatic, loc, constType);
  17861. if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
  17862. if (isSimpleIdentifier(content)) {
  17863. exp.ast = null;
  17864. return exp;
  17865. }
  17866. try {
  17867. const plugins = currentOptions.expressionPlugins;
  17868. const options = {
  17869. plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
  17870. };
  17871. if (parseMode === 2 /* Statements */) {
  17872. exp.ast = libExports.parse(` ${content} `, options).program;
  17873. } else if (parseMode === 1 /* Params */) {
  17874. exp.ast = libExports.parseExpression(`(${content})=>{}`, options);
  17875. } else {
  17876. exp.ast = libExports.parseExpression(`(${content})`, options);
  17877. }
  17878. } catch (e) {
  17879. exp.ast = false;
  17880. emitError(45, loc.start.offset, e.message);
  17881. }
  17882. }
  17883. return exp;
  17884. }
  17885. function emitError(code, index, message) {
  17886. currentOptions.onError(
  17887. createCompilerError(code, getLoc(index, index), void 0, message)
  17888. );
  17889. }
  17890. function reset() {
  17891. tokenizer.reset();
  17892. currentOpenTag = null;
  17893. currentProp = null;
  17894. currentAttrValue = "";
  17895. currentAttrStartIndex = -1;
  17896. currentAttrEndIndex = -1;
  17897. stack.length = 0;
  17898. }
  17899. function baseParse(input, options) {
  17900. reset();
  17901. currentInput = input;
  17902. currentOptions = extend({}, defaultParserOptions);
  17903. if (options) {
  17904. let key;
  17905. for (key in options) {
  17906. if (options[key] != null) {
  17907. currentOptions[key] = options[key];
  17908. }
  17909. }
  17910. }
  17911. {
  17912. if (currentOptions.decodeEntities) {
  17913. console.warn(
  17914. `[@vue/compiler-core] decodeEntities option is passed but will be ignored in non-browser builds.`
  17915. );
  17916. }
  17917. }
  17918. tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  17919. tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  17920. const delimiters = options && options.delimiters;
  17921. if (delimiters) {
  17922. tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
  17923. tokenizer.delimiterClose = toCharCodes(delimiters[1]);
  17924. }
  17925. const root = currentRoot = createRoot([], input);
  17926. tokenizer.parse(currentInput);
  17927. root.loc = getLoc(0, input.length);
  17928. root.children = condenseWhitespace(root.children);
  17929. currentRoot = null;
  17930. return root;
  17931. }
  17932. function cacheStatic(root, context) {
  17933. walk$1(
  17934. root,
  17935. void 0,
  17936. context,
  17937. // Root node is unfortunately non-hoistable due to potential parent
  17938. // fallthrough attributes.
  17939. isSingleElementRoot(root, root.children[0])
  17940. );
  17941. }
  17942. function isSingleElementRoot(root, child) {
  17943. const { children } = root;
  17944. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  17945. }
  17946. function walk$1(node, parent, context, doNotHoistNode = false, inFor = false) {
  17947. const { children } = node;
  17948. const toCache = [];
  17949. for (let i = 0; i < children.length; i++) {
  17950. const child = children[i];
  17951. if (child.type === 1 && child.tagType === 0) {
  17952. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17953. if (constantType > 0) {
  17954. if (constantType >= 2) {
  17955. child.codegenNode.patchFlag = -1;
  17956. toCache.push(child);
  17957. continue;
  17958. }
  17959. } else {
  17960. const codegenNode = child.codegenNode;
  17961. if (codegenNode.type === 13) {
  17962. const flag = codegenNode.patchFlag;
  17963. if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  17964. const props = getNodeProps(child);
  17965. if (props) {
  17966. codegenNode.props = context.hoist(props);
  17967. }
  17968. }
  17969. if (codegenNode.dynamicProps) {
  17970. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  17971. }
  17972. }
  17973. }
  17974. } else if (child.type === 12) {
  17975. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17976. if (constantType >= 2) {
  17977. toCache.push(child);
  17978. continue;
  17979. }
  17980. }
  17981. if (child.type === 1) {
  17982. const isComponent = child.tagType === 1;
  17983. if (isComponent) {
  17984. context.scopes.vSlot++;
  17985. }
  17986. walk$1(child, node, context, false, inFor);
  17987. if (isComponent) {
  17988. context.scopes.vSlot--;
  17989. }
  17990. } else if (child.type === 11) {
  17991. walk$1(child, node, context, child.children.length === 1, true);
  17992. } else if (child.type === 9) {
  17993. for (let i2 = 0; i2 < child.branches.length; i2++) {
  17994. walk$1(
  17995. child.branches[i2],
  17996. node,
  17997. context,
  17998. child.branches[i2].children.length === 1,
  17999. inFor
  18000. );
  18001. }
  18002. }
  18003. }
  18004. let cachedAsArray = false;
  18005. if (toCache.length === children.length && node.type === 1) {
  18006. if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
  18007. node.codegenNode.children = getCacheExpression(
  18008. createArrayExpression(node.codegenNode.children)
  18009. );
  18010. cachedAsArray = true;
  18011. } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray$3(node.codegenNode.children) && node.codegenNode.children.type === 15) {
  18012. const slot = getSlotNode(node.codegenNode, "default");
  18013. if (slot) {
  18014. slot.returns = getCacheExpression(
  18015. createArrayExpression(slot.returns)
  18016. );
  18017. cachedAsArray = true;
  18018. }
  18019. } else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray$3(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
  18020. const slotName = findDir(node, "slot", true);
  18021. const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
  18022. if (slot) {
  18023. slot.returns = getCacheExpression(
  18024. createArrayExpression(slot.returns)
  18025. );
  18026. cachedAsArray = true;
  18027. }
  18028. }
  18029. }
  18030. if (!cachedAsArray) {
  18031. for (const child of toCache) {
  18032. child.codegenNode = context.cache(child.codegenNode);
  18033. }
  18034. }
  18035. function getCacheExpression(value) {
  18036. const exp = context.cache(value);
  18037. if (inFor && context.hmr) {
  18038. exp.needArraySpread = true;
  18039. }
  18040. return exp;
  18041. }
  18042. function getSlotNode(node2, name) {
  18043. if (node2.children && !isArray$3(node2.children) && node2.children.type === 15) {
  18044. const slot = node2.children.properties.find(
  18045. (p) => p.key === name || p.key.content === name
  18046. );
  18047. return slot && slot.value;
  18048. }
  18049. }
  18050. if (toCache.length && context.transformHoist) {
  18051. context.transformHoist(children, context, node);
  18052. }
  18053. }
  18054. function getConstantType(node, context) {
  18055. const { constantCache } = context;
  18056. switch (node.type) {
  18057. case 1:
  18058. if (node.tagType !== 0) {
  18059. return 0;
  18060. }
  18061. const cached = constantCache.get(node);
  18062. if (cached !== void 0) {
  18063. return cached;
  18064. }
  18065. const codegenNode = node.codegenNode;
  18066. if (codegenNode.type !== 13) {
  18067. return 0;
  18068. }
  18069. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
  18070. return 0;
  18071. }
  18072. if (codegenNode.patchFlag === void 0) {
  18073. let returnType2 = 3;
  18074. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  18075. if (generatedPropsType === 0) {
  18076. constantCache.set(node, 0);
  18077. return 0;
  18078. }
  18079. if (generatedPropsType < returnType2) {
  18080. returnType2 = generatedPropsType;
  18081. }
  18082. for (let i = 0; i < node.children.length; i++) {
  18083. const childType = getConstantType(node.children[i], context);
  18084. if (childType === 0) {
  18085. constantCache.set(node, 0);
  18086. return 0;
  18087. }
  18088. if (childType < returnType2) {
  18089. returnType2 = childType;
  18090. }
  18091. }
  18092. if (returnType2 > 1) {
  18093. for (let i = 0; i < node.props.length; i++) {
  18094. const p = node.props[i];
  18095. if (p.type === 7 && p.name === "bind" && p.exp) {
  18096. const expType = getConstantType(p.exp, context);
  18097. if (expType === 0) {
  18098. constantCache.set(node, 0);
  18099. return 0;
  18100. }
  18101. if (expType < returnType2) {
  18102. returnType2 = expType;
  18103. }
  18104. }
  18105. }
  18106. }
  18107. if (codegenNode.isBlock) {
  18108. for (let i = 0; i < node.props.length; i++) {
  18109. const p = node.props[i];
  18110. if (p.type === 7) {
  18111. constantCache.set(node, 0);
  18112. return 0;
  18113. }
  18114. }
  18115. context.removeHelper(OPEN_BLOCK);
  18116. context.removeHelper(
  18117. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  18118. );
  18119. codegenNode.isBlock = false;
  18120. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  18121. }
  18122. constantCache.set(node, returnType2);
  18123. return returnType2;
  18124. } else {
  18125. constantCache.set(node, 0);
  18126. return 0;
  18127. }
  18128. case 2:
  18129. case 3:
  18130. return 3;
  18131. case 9:
  18132. case 11:
  18133. case 10:
  18134. return 0;
  18135. case 5:
  18136. case 12:
  18137. return getConstantType(node.content, context);
  18138. case 4:
  18139. return node.constType;
  18140. case 8:
  18141. let returnType = 3;
  18142. for (let i = 0; i < node.children.length; i++) {
  18143. const child = node.children[i];
  18144. if (isString$1(child) || isSymbol$1(child)) {
  18145. continue;
  18146. }
  18147. const childType = getConstantType(child, context);
  18148. if (childType === 0) {
  18149. return 0;
  18150. } else if (childType < returnType) {
  18151. returnType = childType;
  18152. }
  18153. }
  18154. return returnType;
  18155. case 20:
  18156. return 2;
  18157. default:
  18158. return 0;
  18159. }
  18160. }
  18161. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  18162. NORMALIZE_CLASS,
  18163. NORMALIZE_STYLE,
  18164. NORMALIZE_PROPS,
  18165. GUARD_REACTIVE_PROPS
  18166. ]);
  18167. function getConstantTypeOfHelperCall(value, context) {
  18168. if (value.type === 14 && !isString$1(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  18169. const arg = value.arguments[0];
  18170. if (arg.type === 4) {
  18171. return getConstantType(arg, context);
  18172. } else if (arg.type === 14) {
  18173. return getConstantTypeOfHelperCall(arg, context);
  18174. }
  18175. }
  18176. return 0;
  18177. }
  18178. function getGeneratedPropsConstantType(node, context) {
  18179. let returnType = 3;
  18180. const props = getNodeProps(node);
  18181. if (props && props.type === 15) {
  18182. const { properties } = props;
  18183. for (let i = 0; i < properties.length; i++) {
  18184. const { key, value } = properties[i];
  18185. const keyType = getConstantType(key, context);
  18186. if (keyType === 0) {
  18187. return keyType;
  18188. }
  18189. if (keyType < returnType) {
  18190. returnType = keyType;
  18191. }
  18192. let valueType;
  18193. if (value.type === 4) {
  18194. valueType = getConstantType(value, context);
  18195. } else if (value.type === 14) {
  18196. valueType = getConstantTypeOfHelperCall(value, context);
  18197. } else {
  18198. valueType = 0;
  18199. }
  18200. if (valueType === 0) {
  18201. return valueType;
  18202. }
  18203. if (valueType < returnType) {
  18204. returnType = valueType;
  18205. }
  18206. }
  18207. }
  18208. return returnType;
  18209. }
  18210. function getNodeProps(node) {
  18211. const codegenNode = node.codegenNode;
  18212. if (codegenNode.type === 13) {
  18213. return codegenNode.props;
  18214. }
  18215. }
  18216. function createTransformContext(root, {
  18217. filename = "",
  18218. prefixIdentifiers = false,
  18219. hoistStatic = false,
  18220. hmr = false,
  18221. cacheHandlers = false,
  18222. nodeTransforms = [],
  18223. directiveTransforms = {},
  18224. transformHoist = null,
  18225. isBuiltInComponent = NOOP,
  18226. isCustomElement = NOOP,
  18227. expressionPlugins = [],
  18228. scopeId = null,
  18229. slotted = true,
  18230. ssr = false,
  18231. inSSR = false,
  18232. ssrCssVars = ``,
  18233. bindingMetadata = EMPTY_OBJ,
  18234. inline = false,
  18235. isTS = false,
  18236. onError = defaultOnError,
  18237. onWarn = defaultOnWarn,
  18238. compatConfig
  18239. }) {
  18240. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  18241. const context = {
  18242. // options
  18243. filename,
  18244. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  18245. prefixIdentifiers,
  18246. hoistStatic,
  18247. hmr,
  18248. cacheHandlers,
  18249. nodeTransforms,
  18250. directiveTransforms,
  18251. transformHoist,
  18252. isBuiltInComponent,
  18253. isCustomElement,
  18254. expressionPlugins,
  18255. scopeId,
  18256. slotted,
  18257. ssr,
  18258. inSSR,
  18259. ssrCssVars,
  18260. bindingMetadata,
  18261. inline,
  18262. isTS,
  18263. onError,
  18264. onWarn,
  18265. compatConfig,
  18266. // state
  18267. root,
  18268. helpers: /* @__PURE__ */ new Map(),
  18269. components: /* @__PURE__ */ new Set(),
  18270. directives: /* @__PURE__ */ new Set(),
  18271. hoists: [],
  18272. imports: [],
  18273. cached: [],
  18274. constantCache: /* @__PURE__ */ new WeakMap(),
  18275. temps: 0,
  18276. identifiers: /* @__PURE__ */ Object.create(null),
  18277. scopes: {
  18278. vFor: 0,
  18279. vSlot: 0,
  18280. vPre: 0,
  18281. vOnce: 0
  18282. },
  18283. parent: null,
  18284. grandParent: null,
  18285. currentNode: root,
  18286. childIndex: 0,
  18287. inVOnce: false,
  18288. // methods
  18289. helper(name) {
  18290. const count = context.helpers.get(name) || 0;
  18291. context.helpers.set(name, count + 1);
  18292. return name;
  18293. },
  18294. removeHelper(name) {
  18295. const count = context.helpers.get(name);
  18296. if (count) {
  18297. const currentCount = count - 1;
  18298. if (!currentCount) {
  18299. context.helpers.delete(name);
  18300. } else {
  18301. context.helpers.set(name, currentCount);
  18302. }
  18303. }
  18304. },
  18305. helperString(name) {
  18306. return `_${helperNameMap[context.helper(name)]}`;
  18307. },
  18308. replaceNode(node) {
  18309. {
  18310. if (!context.currentNode) {
  18311. throw new Error(`Node being replaced is already removed.`);
  18312. }
  18313. if (!context.parent) {
  18314. throw new Error(`Cannot replace root node.`);
  18315. }
  18316. }
  18317. context.parent.children[context.childIndex] = context.currentNode = node;
  18318. },
  18319. removeNode(node) {
  18320. if (!context.parent) {
  18321. throw new Error(`Cannot remove root node.`);
  18322. }
  18323. const list = context.parent.children;
  18324. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  18325. if (removalIndex < 0) {
  18326. throw new Error(`node being removed is not a child of current parent`);
  18327. }
  18328. if (!node || node === context.currentNode) {
  18329. context.currentNode = null;
  18330. context.onNodeRemoved();
  18331. } else {
  18332. if (context.childIndex > removalIndex) {
  18333. context.childIndex--;
  18334. context.onNodeRemoved();
  18335. }
  18336. }
  18337. context.parent.children.splice(removalIndex, 1);
  18338. },
  18339. onNodeRemoved: NOOP,
  18340. addIdentifiers(exp) {
  18341. {
  18342. if (isString$1(exp)) {
  18343. addId(exp);
  18344. } else if (exp.identifiers) {
  18345. exp.identifiers.forEach(addId);
  18346. } else if (exp.type === 4) {
  18347. addId(exp.content);
  18348. }
  18349. }
  18350. },
  18351. removeIdentifiers(exp) {
  18352. {
  18353. if (isString$1(exp)) {
  18354. removeId(exp);
  18355. } else if (exp.identifiers) {
  18356. exp.identifiers.forEach(removeId);
  18357. } else if (exp.type === 4) {
  18358. removeId(exp.content);
  18359. }
  18360. }
  18361. },
  18362. hoist(exp) {
  18363. if (isString$1(exp)) exp = createSimpleExpression(exp);
  18364. context.hoists.push(exp);
  18365. const identifier = createSimpleExpression(
  18366. `_hoisted_${context.hoists.length}`,
  18367. false,
  18368. exp.loc,
  18369. 2
  18370. );
  18371. identifier.hoisted = exp;
  18372. return identifier;
  18373. },
  18374. cache(exp, isVNode = false) {
  18375. const cacheExp = createCacheExpression(
  18376. context.cached.length,
  18377. exp,
  18378. isVNode
  18379. );
  18380. context.cached.push(cacheExp);
  18381. return cacheExp;
  18382. }
  18383. };
  18384. function addId(id) {
  18385. const { identifiers } = context;
  18386. if (identifiers[id] === void 0) {
  18387. identifiers[id] = 0;
  18388. }
  18389. identifiers[id]++;
  18390. }
  18391. function removeId(id) {
  18392. context.identifiers[id]--;
  18393. }
  18394. return context;
  18395. }
  18396. function transform(root, options) {
  18397. const context = createTransformContext(root, options);
  18398. traverseNode(root, context);
  18399. if (options.hoistStatic) {
  18400. cacheStatic(root, context);
  18401. }
  18402. if (!options.ssr) {
  18403. createRootCodegen(root, context);
  18404. }
  18405. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  18406. root.components = [...context.components];
  18407. root.directives = [...context.directives];
  18408. root.imports = context.imports;
  18409. root.hoists = context.hoists;
  18410. root.temps = context.temps;
  18411. root.cached = context.cached;
  18412. root.transformed = true;
  18413. }
  18414. function createRootCodegen(root, context) {
  18415. const { helper } = context;
  18416. const { children } = root;
  18417. if (children.length === 1) {
  18418. const child = children[0];
  18419. if (isSingleElementRoot(root, child) && child.codegenNode) {
  18420. const codegenNode = child.codegenNode;
  18421. if (codegenNode.type === 13) {
  18422. convertToBlock(codegenNode, context);
  18423. }
  18424. root.codegenNode = codegenNode;
  18425. } else {
  18426. root.codegenNode = child;
  18427. }
  18428. } else if (children.length > 1) {
  18429. let patchFlag = 64;
  18430. if (children.filter((c) => c.type !== 3).length === 1) {
  18431. patchFlag |= 2048;
  18432. }
  18433. root.codegenNode = createVNodeCall(
  18434. context,
  18435. helper(FRAGMENT),
  18436. void 0,
  18437. root.children,
  18438. patchFlag,
  18439. void 0,
  18440. void 0,
  18441. true,
  18442. void 0,
  18443. false
  18444. );
  18445. } else ;
  18446. }
  18447. function traverseChildren(parent, context) {
  18448. let i = 0;
  18449. const nodeRemoved = () => {
  18450. i--;
  18451. };
  18452. for (; i < parent.children.length; i++) {
  18453. const child = parent.children[i];
  18454. if (isString$1(child)) continue;
  18455. context.grandParent = context.parent;
  18456. context.parent = parent;
  18457. context.childIndex = i;
  18458. context.onNodeRemoved = nodeRemoved;
  18459. traverseNode(child, context);
  18460. }
  18461. }
  18462. function traverseNode(node, context) {
  18463. context.currentNode = node;
  18464. const { nodeTransforms } = context;
  18465. const exitFns = [];
  18466. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  18467. const onExit = nodeTransforms[i2](node, context);
  18468. if (onExit) {
  18469. if (isArray$3(onExit)) {
  18470. exitFns.push(...onExit);
  18471. } else {
  18472. exitFns.push(onExit);
  18473. }
  18474. }
  18475. if (!context.currentNode) {
  18476. return;
  18477. } else {
  18478. node = context.currentNode;
  18479. }
  18480. }
  18481. switch (node.type) {
  18482. case 3:
  18483. if (!context.ssr) {
  18484. context.helper(CREATE_COMMENT);
  18485. }
  18486. break;
  18487. case 5:
  18488. if (!context.ssr) {
  18489. context.helper(TO_DISPLAY_STRING);
  18490. }
  18491. break;
  18492. // for container types, further traverse downwards
  18493. case 9:
  18494. for (let i2 = 0; i2 < node.branches.length; i2++) {
  18495. traverseNode(node.branches[i2], context);
  18496. }
  18497. break;
  18498. case 10:
  18499. case 11:
  18500. case 1:
  18501. case 0:
  18502. traverseChildren(node, context);
  18503. break;
  18504. }
  18505. context.currentNode = node;
  18506. let i = exitFns.length;
  18507. while (i--) {
  18508. exitFns[i]();
  18509. }
  18510. }
  18511. function createStructuralDirectiveTransform(name, fn) {
  18512. const matches = isString$1(name) ? (n) => n === name : (n) => name.test(n);
  18513. return (node, context) => {
  18514. if (node.type === 1) {
  18515. const { props } = node;
  18516. if (node.tagType === 3 && props.some(isVSlot)) {
  18517. return;
  18518. }
  18519. const exitFns = [];
  18520. for (let i = 0; i < props.length; i++) {
  18521. const prop = props[i];
  18522. if (prop.type === 7 && matches(prop.name)) {
  18523. props.splice(i, 1);
  18524. i--;
  18525. const onExit = fn(node, prop, context);
  18526. if (onExit) exitFns.push(onExit);
  18527. }
  18528. }
  18529. return exitFns;
  18530. }
  18531. };
  18532. }
  18533. var sourceMap$2 = {};
  18534. var sourceMapGenerator$2 = {};
  18535. var base64Vlq$2 = {};
  18536. var base64$2 = {};
  18537. /* -*- Mode: js; js-indent-level: 2; -*- */
  18538. var hasRequiredBase64$2;
  18539. function requireBase64$2 () {
  18540. if (hasRequiredBase64$2) return base64$2;
  18541. hasRequiredBase64$2 = 1;
  18542. /*
  18543. * Copyright 2011 Mozilla Foundation and contributors
  18544. * Licensed under the New BSD license. See LICENSE or:
  18545. * http://opensource.org/licenses/BSD-3-Clause
  18546. */
  18547. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  18548. /**
  18549. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  18550. */
  18551. base64$2.encode = function (number) {
  18552. if (0 <= number && number < intToCharMap.length) {
  18553. return intToCharMap[number];
  18554. }
  18555. throw new TypeError("Must be between 0 and 63: " + number);
  18556. };
  18557. /**
  18558. * Decode a single base 64 character code digit to an integer. Returns -1 on
  18559. * failure.
  18560. */
  18561. base64$2.decode = function (charCode) {
  18562. var bigA = 65; // 'A'
  18563. var bigZ = 90; // 'Z'
  18564. var littleA = 97; // 'a'
  18565. var littleZ = 122; // 'z'
  18566. var zero = 48; // '0'
  18567. var nine = 57; // '9'
  18568. var plus = 43; // '+'
  18569. var slash = 47; // '/'
  18570. var littleOffset = 26;
  18571. var numberOffset = 52;
  18572. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  18573. if (bigA <= charCode && charCode <= bigZ) {
  18574. return (charCode - bigA);
  18575. }
  18576. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  18577. if (littleA <= charCode && charCode <= littleZ) {
  18578. return (charCode - littleA + littleOffset);
  18579. }
  18580. // 52 - 61: 0123456789
  18581. if (zero <= charCode && charCode <= nine) {
  18582. return (charCode - zero + numberOffset);
  18583. }
  18584. // 62: +
  18585. if (charCode == plus) {
  18586. return 62;
  18587. }
  18588. // 63: /
  18589. if (charCode == slash) {
  18590. return 63;
  18591. }
  18592. // Invalid base64 digit.
  18593. return -1;
  18594. };
  18595. return base64$2;
  18596. }
  18597. /* -*- Mode: js; js-indent-level: 2; -*- */
  18598. var hasRequiredBase64Vlq$2;
  18599. function requireBase64Vlq$2 () {
  18600. if (hasRequiredBase64Vlq$2) return base64Vlq$2;
  18601. hasRequiredBase64Vlq$2 = 1;
  18602. /*
  18603. * Copyright 2011 Mozilla Foundation and contributors
  18604. * Licensed under the New BSD license. See LICENSE or:
  18605. * http://opensource.org/licenses/BSD-3-Clause
  18606. *
  18607. * Based on the Base 64 VLQ implementation in Closure Compiler:
  18608. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  18609. *
  18610. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  18611. * Redistribution and use in source and binary forms, with or without
  18612. * modification, are permitted provided that the following conditions are
  18613. * met:
  18614. *
  18615. * * Redistributions of source code must retain the above copyright
  18616. * notice, this list of conditions and the following disclaimer.
  18617. * * Redistributions in binary form must reproduce the above
  18618. * copyright notice, this list of conditions and the following
  18619. * disclaimer in the documentation and/or other materials provided
  18620. * with the distribution.
  18621. * * Neither the name of Google Inc. nor the names of its
  18622. * contributors may be used to endorse or promote products derived
  18623. * from this software without specific prior written permission.
  18624. *
  18625. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18626. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18627. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18628. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18629. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18630. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18631. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18632. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18633. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18634. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18635. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18636. */
  18637. var base64 = /*@__PURE__*/ requireBase64$2();
  18638. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  18639. // length quantities we use in the source map spec, the first bit is the sign,
  18640. // the next four bits are the actual value, and the 6th bit is the
  18641. // continuation bit. The continuation bit tells us whether there are more
  18642. // digits in this value following this digit.
  18643. //
  18644. // Continuation
  18645. // | Sign
  18646. // | |
  18647. // V V
  18648. // 101011
  18649. var VLQ_BASE_SHIFT = 5;
  18650. // binary: 100000
  18651. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  18652. // binary: 011111
  18653. var VLQ_BASE_MASK = VLQ_BASE - 1;
  18654. // binary: 100000
  18655. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  18656. /**
  18657. * Converts from a two-complement value to a value where the sign bit is
  18658. * placed in the least significant bit. For example, as decimals:
  18659. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  18660. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  18661. */
  18662. function toVLQSigned(aValue) {
  18663. return aValue < 0
  18664. ? ((-aValue) << 1) + 1
  18665. : (aValue << 1) + 0;
  18666. }
  18667. /**
  18668. * Converts to a two-complement value from a value where the sign bit is
  18669. * placed in the least significant bit. For example, as decimals:
  18670. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  18671. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  18672. */
  18673. function fromVLQSigned(aValue) {
  18674. var isNegative = (aValue & 1) === 1;
  18675. var shifted = aValue >> 1;
  18676. return isNegative
  18677. ? -shifted
  18678. : shifted;
  18679. }
  18680. /**
  18681. * Returns the base 64 VLQ encoded value.
  18682. */
  18683. base64Vlq$2.encode = function base64VLQ_encode(aValue) {
  18684. var encoded = "";
  18685. var digit;
  18686. var vlq = toVLQSigned(aValue);
  18687. do {
  18688. digit = vlq & VLQ_BASE_MASK;
  18689. vlq >>>= VLQ_BASE_SHIFT;
  18690. if (vlq > 0) {
  18691. // There are still more digits in this value, so we must make sure the
  18692. // continuation bit is marked.
  18693. digit |= VLQ_CONTINUATION_BIT;
  18694. }
  18695. encoded += base64.encode(digit);
  18696. } while (vlq > 0);
  18697. return encoded;
  18698. };
  18699. /**
  18700. * Decodes the next base 64 VLQ value from the given string and returns the
  18701. * value and the rest of the string via the out parameter.
  18702. */
  18703. base64Vlq$2.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  18704. var strLen = aStr.length;
  18705. var result = 0;
  18706. var shift = 0;
  18707. var continuation, digit;
  18708. do {
  18709. if (aIndex >= strLen) {
  18710. throw new Error("Expected more digits in base 64 VLQ value.");
  18711. }
  18712. digit = base64.decode(aStr.charCodeAt(aIndex++));
  18713. if (digit === -1) {
  18714. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  18715. }
  18716. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  18717. digit &= VLQ_BASE_MASK;
  18718. result = result + (digit << shift);
  18719. shift += VLQ_BASE_SHIFT;
  18720. } while (continuation);
  18721. aOutParam.value = fromVLQSigned(result);
  18722. aOutParam.rest = aIndex;
  18723. };
  18724. return base64Vlq$2;
  18725. }
  18726. var util$3 = {};
  18727. /* -*- Mode: js; js-indent-level: 2; -*- */
  18728. var hasRequiredUtil$3;
  18729. function requireUtil$3 () {
  18730. if (hasRequiredUtil$3) return util$3;
  18731. hasRequiredUtil$3 = 1;
  18732. (function (exports) {
  18733. /*
  18734. * Copyright 2011 Mozilla Foundation and contributors
  18735. * Licensed under the New BSD license. See LICENSE or:
  18736. * http://opensource.org/licenses/BSD-3-Clause
  18737. */
  18738. /**
  18739. * This is a helper function for getting values from parameter/options
  18740. * objects.
  18741. *
  18742. * @param args The object we are extracting values from
  18743. * @param name The name of the property we are getting.
  18744. * @param defaultValue An optional value to return if the property is missing
  18745. * from the object. If this is not specified and the property is missing, an
  18746. * error will be thrown.
  18747. */
  18748. function getArg(aArgs, aName, aDefaultValue) {
  18749. if (aName in aArgs) {
  18750. return aArgs[aName];
  18751. } else if (arguments.length === 3) {
  18752. return aDefaultValue;
  18753. } else {
  18754. throw new Error('"' + aName + '" is a required argument.');
  18755. }
  18756. }
  18757. exports.getArg = getArg;
  18758. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  18759. var dataUrlRegexp = /^data:.+\,.+$/;
  18760. function urlParse(aUrl) {
  18761. var match = aUrl.match(urlRegexp);
  18762. if (!match) {
  18763. return null;
  18764. }
  18765. return {
  18766. scheme: match[1],
  18767. auth: match[2],
  18768. host: match[3],
  18769. port: match[4],
  18770. path: match[5]
  18771. };
  18772. }
  18773. exports.urlParse = urlParse;
  18774. function urlGenerate(aParsedUrl) {
  18775. var url = '';
  18776. if (aParsedUrl.scheme) {
  18777. url += aParsedUrl.scheme + ':';
  18778. }
  18779. url += '//';
  18780. if (aParsedUrl.auth) {
  18781. url += aParsedUrl.auth + '@';
  18782. }
  18783. if (aParsedUrl.host) {
  18784. url += aParsedUrl.host;
  18785. }
  18786. if (aParsedUrl.port) {
  18787. url += ":" + aParsedUrl.port;
  18788. }
  18789. if (aParsedUrl.path) {
  18790. url += aParsedUrl.path;
  18791. }
  18792. return url;
  18793. }
  18794. exports.urlGenerate = urlGenerate;
  18795. var MAX_CACHED_INPUTS = 32;
  18796. /**
  18797. * Takes some function `f(input) -> result` and returns a memoized version of
  18798. * `f`.
  18799. *
  18800. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  18801. * memoization is a dumb-simple, linear least-recently-used cache.
  18802. */
  18803. function lruMemoize(f) {
  18804. var cache = [];
  18805. return function(input) {
  18806. for (var i = 0; i < cache.length; i++) {
  18807. if (cache[i].input === input) {
  18808. var temp = cache[0];
  18809. cache[0] = cache[i];
  18810. cache[i] = temp;
  18811. return cache[0].result;
  18812. }
  18813. }
  18814. var result = f(input);
  18815. cache.unshift({
  18816. input,
  18817. result,
  18818. });
  18819. if (cache.length > MAX_CACHED_INPUTS) {
  18820. cache.pop();
  18821. }
  18822. return result;
  18823. };
  18824. }
  18825. /**
  18826. * Normalizes a path, or the path portion of a URL:
  18827. *
  18828. * - Replaces consecutive slashes with one slash.
  18829. * - Removes unnecessary '.' parts.
  18830. * - Removes unnecessary '<dir>/..' parts.
  18831. *
  18832. * Based on code in the Node.js 'path' core module.
  18833. *
  18834. * @param aPath The path or url to normalize.
  18835. */
  18836. var normalize = lruMemoize(function normalize(aPath) {
  18837. var path = aPath;
  18838. var url = urlParse(aPath);
  18839. if (url) {
  18840. if (!url.path) {
  18841. return aPath;
  18842. }
  18843. path = url.path;
  18844. }
  18845. var isAbsolute = exports.isAbsolute(path);
  18846. // Split the path into parts between `/` characters. This is much faster than
  18847. // using `.split(/\/+/g)`.
  18848. var parts = [];
  18849. var start = 0;
  18850. var i = 0;
  18851. while (true) {
  18852. start = i;
  18853. i = path.indexOf("/", start);
  18854. if (i === -1) {
  18855. parts.push(path.slice(start));
  18856. break;
  18857. } else {
  18858. parts.push(path.slice(start, i));
  18859. while (i < path.length && path[i] === "/") {
  18860. i++;
  18861. }
  18862. }
  18863. }
  18864. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  18865. part = parts[i];
  18866. if (part === '.') {
  18867. parts.splice(i, 1);
  18868. } else if (part === '..') {
  18869. up++;
  18870. } else if (up > 0) {
  18871. if (part === '') {
  18872. // The first part is blank if the path is absolute. Trying to go
  18873. // above the root is a no-op. Therefore we can remove all '..' parts
  18874. // directly after the root.
  18875. parts.splice(i + 1, up);
  18876. up = 0;
  18877. } else {
  18878. parts.splice(i, 2);
  18879. up--;
  18880. }
  18881. }
  18882. }
  18883. path = parts.join('/');
  18884. if (path === '') {
  18885. path = isAbsolute ? '/' : '.';
  18886. }
  18887. if (url) {
  18888. url.path = path;
  18889. return urlGenerate(url);
  18890. }
  18891. return path;
  18892. });
  18893. exports.normalize = normalize;
  18894. /**
  18895. * Joins two paths/URLs.
  18896. *
  18897. * @param aRoot The root path or URL.
  18898. * @param aPath The path or URL to be joined with the root.
  18899. *
  18900. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  18901. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  18902. * first.
  18903. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  18904. * is updated with the result and aRoot is returned. Otherwise the result
  18905. * is returned.
  18906. * - If aPath is absolute, the result is aPath.
  18907. * - Otherwise the two paths are joined with a slash.
  18908. * - Joining for example 'http://' and 'www.example.com' is also supported.
  18909. */
  18910. function join(aRoot, aPath) {
  18911. if (aRoot === "") {
  18912. aRoot = ".";
  18913. }
  18914. if (aPath === "") {
  18915. aPath = ".";
  18916. }
  18917. var aPathUrl = urlParse(aPath);
  18918. var aRootUrl = urlParse(aRoot);
  18919. if (aRootUrl) {
  18920. aRoot = aRootUrl.path || '/';
  18921. }
  18922. // `join(foo, '//www.example.org')`
  18923. if (aPathUrl && !aPathUrl.scheme) {
  18924. if (aRootUrl) {
  18925. aPathUrl.scheme = aRootUrl.scheme;
  18926. }
  18927. return urlGenerate(aPathUrl);
  18928. }
  18929. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  18930. return aPath;
  18931. }
  18932. // `join('http://', 'www.example.com')`
  18933. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  18934. aRootUrl.host = aPath;
  18935. return urlGenerate(aRootUrl);
  18936. }
  18937. var joined = aPath.charAt(0) === '/'
  18938. ? aPath
  18939. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  18940. if (aRootUrl) {
  18941. aRootUrl.path = joined;
  18942. return urlGenerate(aRootUrl);
  18943. }
  18944. return joined;
  18945. }
  18946. exports.join = join;
  18947. exports.isAbsolute = function (aPath) {
  18948. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  18949. };
  18950. /**
  18951. * Make a path relative to a URL or another path.
  18952. *
  18953. * @param aRoot The root path or URL.
  18954. * @param aPath The path or URL to be made relative to aRoot.
  18955. */
  18956. function relative(aRoot, aPath) {
  18957. if (aRoot === "") {
  18958. aRoot = ".";
  18959. }
  18960. aRoot = aRoot.replace(/\/$/, '');
  18961. // It is possible for the path to be above the root. In this case, simply
  18962. // checking whether the root is a prefix of the path won't work. Instead, we
  18963. // need to remove components from the root one by one, until either we find
  18964. // a prefix that fits, or we run out of components to remove.
  18965. var level = 0;
  18966. while (aPath.indexOf(aRoot + '/') !== 0) {
  18967. var index = aRoot.lastIndexOf("/");
  18968. if (index < 0) {
  18969. return aPath;
  18970. }
  18971. // If the only part of the root that is left is the scheme (i.e. http://,
  18972. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  18973. // have exhausted all components, so the path is not relative to the root.
  18974. aRoot = aRoot.slice(0, index);
  18975. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  18976. return aPath;
  18977. }
  18978. ++level;
  18979. }
  18980. // Make sure we add a "../" for each component we removed from the root.
  18981. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  18982. }
  18983. exports.relative = relative;
  18984. var supportsNullProto = (function () {
  18985. var obj = Object.create(null);
  18986. return !('__proto__' in obj);
  18987. }());
  18988. function identity (s) {
  18989. return s;
  18990. }
  18991. /**
  18992. * Because behavior goes wacky when you set `__proto__` on objects, we
  18993. * have to prefix all the strings in our set with an arbitrary character.
  18994. *
  18995. * See https://github.com/mozilla/source-map/pull/31 and
  18996. * https://github.com/mozilla/source-map/issues/30
  18997. *
  18998. * @param String aStr
  18999. */
  19000. function toSetString(aStr) {
  19001. if (isProtoString(aStr)) {
  19002. return '$' + aStr;
  19003. }
  19004. return aStr;
  19005. }
  19006. exports.toSetString = supportsNullProto ? identity : toSetString;
  19007. function fromSetString(aStr) {
  19008. if (isProtoString(aStr)) {
  19009. return aStr.slice(1);
  19010. }
  19011. return aStr;
  19012. }
  19013. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  19014. function isProtoString(s) {
  19015. if (!s) {
  19016. return false;
  19017. }
  19018. var length = s.length;
  19019. if (length < 9 /* "__proto__".length */) {
  19020. return false;
  19021. }
  19022. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  19023. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  19024. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  19025. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  19026. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  19027. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  19028. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  19029. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  19030. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  19031. return false;
  19032. }
  19033. for (var i = length - 10; i >= 0; i--) {
  19034. if (s.charCodeAt(i) !== 36 /* '$' */) {
  19035. return false;
  19036. }
  19037. }
  19038. return true;
  19039. }
  19040. /**
  19041. * Comparator between two mappings where the original positions are compared.
  19042. *
  19043. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  19044. * mappings with the same original source/line/column, but different generated
  19045. * line and column the same. Useful when searching for a mapping with a
  19046. * stubbed out mapping.
  19047. */
  19048. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  19049. var cmp = strcmp(mappingA.source, mappingB.source);
  19050. if (cmp !== 0) {
  19051. return cmp;
  19052. }
  19053. cmp = mappingA.originalLine - mappingB.originalLine;
  19054. if (cmp !== 0) {
  19055. return cmp;
  19056. }
  19057. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19058. if (cmp !== 0 || onlyCompareOriginal) {
  19059. return cmp;
  19060. }
  19061. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19062. if (cmp !== 0) {
  19063. return cmp;
  19064. }
  19065. cmp = mappingA.generatedLine - mappingB.generatedLine;
  19066. if (cmp !== 0) {
  19067. return cmp;
  19068. }
  19069. return strcmp(mappingA.name, mappingB.name);
  19070. }
  19071. exports.compareByOriginalPositions = compareByOriginalPositions;
  19072. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  19073. var cmp;
  19074. cmp = mappingA.originalLine - mappingB.originalLine;
  19075. if (cmp !== 0) {
  19076. return cmp;
  19077. }
  19078. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19079. if (cmp !== 0 || onlyCompareOriginal) {
  19080. return cmp;
  19081. }
  19082. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19083. if (cmp !== 0) {
  19084. return cmp;
  19085. }
  19086. cmp = mappingA.generatedLine - mappingB.generatedLine;
  19087. if (cmp !== 0) {
  19088. return cmp;
  19089. }
  19090. return strcmp(mappingA.name, mappingB.name);
  19091. }
  19092. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  19093. /**
  19094. * Comparator between two mappings with deflated source and name indices where
  19095. * the generated positions are compared.
  19096. *
  19097. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  19098. * mappings with the same generated line and column, but different
  19099. * source/name/original line and column the same. Useful when searching for a
  19100. * mapping with a stubbed out mapping.
  19101. */
  19102. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  19103. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  19104. if (cmp !== 0) {
  19105. return cmp;
  19106. }
  19107. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19108. if (cmp !== 0 || onlyCompareGenerated) {
  19109. return cmp;
  19110. }
  19111. cmp = strcmp(mappingA.source, mappingB.source);
  19112. if (cmp !== 0) {
  19113. return cmp;
  19114. }
  19115. cmp = mappingA.originalLine - mappingB.originalLine;
  19116. if (cmp !== 0) {
  19117. return cmp;
  19118. }
  19119. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19120. if (cmp !== 0) {
  19121. return cmp;
  19122. }
  19123. return strcmp(mappingA.name, mappingB.name);
  19124. }
  19125. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  19126. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  19127. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19128. if (cmp !== 0 || onlyCompareGenerated) {
  19129. return cmp;
  19130. }
  19131. cmp = strcmp(mappingA.source, mappingB.source);
  19132. if (cmp !== 0) {
  19133. return cmp;
  19134. }
  19135. cmp = mappingA.originalLine - mappingB.originalLine;
  19136. if (cmp !== 0) {
  19137. return cmp;
  19138. }
  19139. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19140. if (cmp !== 0) {
  19141. return cmp;
  19142. }
  19143. return strcmp(mappingA.name, mappingB.name);
  19144. }
  19145. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  19146. function strcmp(aStr1, aStr2) {
  19147. if (aStr1 === aStr2) {
  19148. return 0;
  19149. }
  19150. if (aStr1 === null) {
  19151. return 1; // aStr2 !== null
  19152. }
  19153. if (aStr2 === null) {
  19154. return -1; // aStr1 !== null
  19155. }
  19156. if (aStr1 > aStr2) {
  19157. return 1;
  19158. }
  19159. return -1;
  19160. }
  19161. /**
  19162. * Comparator between two mappings with inflated source and name strings where
  19163. * the generated positions are compared.
  19164. */
  19165. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  19166. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  19167. if (cmp !== 0) {
  19168. return cmp;
  19169. }
  19170. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  19171. if (cmp !== 0) {
  19172. return cmp;
  19173. }
  19174. cmp = strcmp(mappingA.source, mappingB.source);
  19175. if (cmp !== 0) {
  19176. return cmp;
  19177. }
  19178. cmp = mappingA.originalLine - mappingB.originalLine;
  19179. if (cmp !== 0) {
  19180. return cmp;
  19181. }
  19182. cmp = mappingA.originalColumn - mappingB.originalColumn;
  19183. if (cmp !== 0) {
  19184. return cmp;
  19185. }
  19186. return strcmp(mappingA.name, mappingB.name);
  19187. }
  19188. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  19189. /**
  19190. * Strip any JSON XSSI avoidance prefix from the string (as documented
  19191. * in the source maps specification), and then parse the string as
  19192. * JSON.
  19193. */
  19194. function parseSourceMapInput(str) {
  19195. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  19196. }
  19197. exports.parseSourceMapInput = parseSourceMapInput;
  19198. /**
  19199. * Compute the URL of a source given the the source root, the source's
  19200. * URL, and the source map's URL.
  19201. */
  19202. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  19203. sourceURL = sourceURL || '';
  19204. if (sourceRoot) {
  19205. // This follows what Chrome does.
  19206. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  19207. sourceRoot += '/';
  19208. }
  19209. // The spec says:
  19210. // Line 4: An optional source root, useful for relocating source
  19211. // files on a server or removing repeated values in the
  19212. // “sources” entry. This value is prepended to the individual
  19213. // entries in the “source” field.
  19214. sourceURL = sourceRoot + sourceURL;
  19215. }
  19216. // Historically, SourceMapConsumer did not take the sourceMapURL as
  19217. // a parameter. This mode is still somewhat supported, which is why
  19218. // this code block is conditional. However, it's preferable to pass
  19219. // the source map URL to SourceMapConsumer, so that this function
  19220. // can implement the source URL resolution algorithm as outlined in
  19221. // the spec. This block is basically the equivalent of:
  19222. // new URL(sourceURL, sourceMapURL).toString()
  19223. // ... except it avoids using URL, which wasn't available in the
  19224. // older releases of node still supported by this library.
  19225. //
  19226. // The spec says:
  19227. // If the sources are not absolute URLs after prepending of the
  19228. // “sourceRoot”, the sources are resolved relative to the
  19229. // SourceMap (like resolving script src in a html document).
  19230. if (sourceMapURL) {
  19231. var parsed = urlParse(sourceMapURL);
  19232. if (!parsed) {
  19233. throw new Error("sourceMapURL could not be parsed");
  19234. }
  19235. if (parsed.path) {
  19236. // Strip the last path component, but keep the "/".
  19237. var index = parsed.path.lastIndexOf('/');
  19238. if (index >= 0) {
  19239. parsed.path = parsed.path.substring(0, index + 1);
  19240. }
  19241. }
  19242. sourceURL = join(urlGenerate(parsed), sourceURL);
  19243. }
  19244. return normalize(sourceURL);
  19245. }
  19246. exports.computeSourceURL = computeSourceURL;
  19247. } (util$3));
  19248. return util$3;
  19249. }
  19250. var arraySet$2 = {};
  19251. /* -*- Mode: js; js-indent-level: 2; -*- */
  19252. var hasRequiredArraySet$2;
  19253. function requireArraySet$2 () {
  19254. if (hasRequiredArraySet$2) return arraySet$2;
  19255. hasRequiredArraySet$2 = 1;
  19256. /*
  19257. * Copyright 2011 Mozilla Foundation and contributors
  19258. * Licensed under the New BSD license. See LICENSE or:
  19259. * http://opensource.org/licenses/BSD-3-Clause
  19260. */
  19261. var util = /*@__PURE__*/ requireUtil$3();
  19262. var has = Object.prototype.hasOwnProperty;
  19263. var hasNativeMap = typeof Map !== "undefined";
  19264. /**
  19265. * A data structure which is a combination of an array and a set. Adding a new
  19266. * member is O(1), testing for membership is O(1), and finding the index of an
  19267. * element is O(1). Removing elements from the set is not supported. Only
  19268. * strings are supported for membership.
  19269. */
  19270. function ArraySet() {
  19271. this._array = [];
  19272. this._set = hasNativeMap ? new Map() : Object.create(null);
  19273. }
  19274. /**
  19275. * Static method for creating ArraySet instances from an existing array.
  19276. */
  19277. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  19278. var set = new ArraySet();
  19279. for (var i = 0, len = aArray.length; i < len; i++) {
  19280. set.add(aArray[i], aAllowDuplicates);
  19281. }
  19282. return set;
  19283. };
  19284. /**
  19285. * Return how many unique items are in this ArraySet. If duplicates have been
  19286. * added, than those do not count towards the size.
  19287. *
  19288. * @returns Number
  19289. */
  19290. ArraySet.prototype.size = function ArraySet_size() {
  19291. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  19292. };
  19293. /**
  19294. * Add the given string to this set.
  19295. *
  19296. * @param String aStr
  19297. */
  19298. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  19299. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  19300. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  19301. var idx = this._array.length;
  19302. if (!isDuplicate || aAllowDuplicates) {
  19303. this._array.push(aStr);
  19304. }
  19305. if (!isDuplicate) {
  19306. if (hasNativeMap) {
  19307. this._set.set(aStr, idx);
  19308. } else {
  19309. this._set[sStr] = idx;
  19310. }
  19311. }
  19312. };
  19313. /**
  19314. * Is the given string a member of this set?
  19315. *
  19316. * @param String aStr
  19317. */
  19318. ArraySet.prototype.has = function ArraySet_has(aStr) {
  19319. if (hasNativeMap) {
  19320. return this._set.has(aStr);
  19321. } else {
  19322. var sStr = util.toSetString(aStr);
  19323. return has.call(this._set, sStr);
  19324. }
  19325. };
  19326. /**
  19327. * What is the index of the given string in the array?
  19328. *
  19329. * @param String aStr
  19330. */
  19331. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  19332. if (hasNativeMap) {
  19333. var idx = this._set.get(aStr);
  19334. if (idx >= 0) {
  19335. return idx;
  19336. }
  19337. } else {
  19338. var sStr = util.toSetString(aStr);
  19339. if (has.call(this._set, sStr)) {
  19340. return this._set[sStr];
  19341. }
  19342. }
  19343. throw new Error('"' + aStr + '" is not in the set.');
  19344. };
  19345. /**
  19346. * What is the element at the given index?
  19347. *
  19348. * @param Number aIdx
  19349. */
  19350. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  19351. if (aIdx >= 0 && aIdx < this._array.length) {
  19352. return this._array[aIdx];
  19353. }
  19354. throw new Error('No element indexed by ' + aIdx);
  19355. };
  19356. /**
  19357. * Returns the array representation of this set (which has the proper indices
  19358. * indicated by indexOf). Note that this is a copy of the internal array used
  19359. * for storing the members so that no one can mess with internal state.
  19360. */
  19361. ArraySet.prototype.toArray = function ArraySet_toArray() {
  19362. return this._array.slice();
  19363. };
  19364. arraySet$2.ArraySet = ArraySet;
  19365. return arraySet$2;
  19366. }
  19367. var mappingList$2 = {};
  19368. /* -*- Mode: js; js-indent-level: 2; -*- */
  19369. var hasRequiredMappingList$2;
  19370. function requireMappingList$2 () {
  19371. if (hasRequiredMappingList$2) return mappingList$2;
  19372. hasRequiredMappingList$2 = 1;
  19373. /*
  19374. * Copyright 2014 Mozilla Foundation and contributors
  19375. * Licensed under the New BSD license. See LICENSE or:
  19376. * http://opensource.org/licenses/BSD-3-Clause
  19377. */
  19378. var util = /*@__PURE__*/ requireUtil$3();
  19379. /**
  19380. * Determine whether mappingB is after mappingA with respect to generated
  19381. * position.
  19382. */
  19383. function generatedPositionAfter(mappingA, mappingB) {
  19384. // Optimized for most common case
  19385. var lineA = mappingA.generatedLine;
  19386. var lineB = mappingB.generatedLine;
  19387. var columnA = mappingA.generatedColumn;
  19388. var columnB = mappingB.generatedColumn;
  19389. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  19390. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  19391. }
  19392. /**
  19393. * A data structure to provide a sorted view of accumulated mappings in a
  19394. * performance conscious manner. It trades a neglibable overhead in general
  19395. * case for a large speedup in case of mappings being added in order.
  19396. */
  19397. function MappingList() {
  19398. this._array = [];
  19399. this._sorted = true;
  19400. // Serves as infimum
  19401. this._last = {generatedLine: -1, generatedColumn: 0};
  19402. }
  19403. /**
  19404. * Iterate through internal items. This method takes the same arguments that
  19405. * `Array.prototype.forEach` takes.
  19406. *
  19407. * NOTE: The order of the mappings is NOT guaranteed.
  19408. */
  19409. MappingList.prototype.unsortedForEach =
  19410. function MappingList_forEach(aCallback, aThisArg) {
  19411. this._array.forEach(aCallback, aThisArg);
  19412. };
  19413. /**
  19414. * Add the given source mapping.
  19415. *
  19416. * @param Object aMapping
  19417. */
  19418. MappingList.prototype.add = function MappingList_add(aMapping) {
  19419. if (generatedPositionAfter(this._last, aMapping)) {
  19420. this._last = aMapping;
  19421. this._array.push(aMapping);
  19422. } else {
  19423. this._sorted = false;
  19424. this._array.push(aMapping);
  19425. }
  19426. };
  19427. /**
  19428. * Returns the flat, sorted array of mappings. The mappings are sorted by
  19429. * generated position.
  19430. *
  19431. * WARNING: This method returns internal data without copying, for
  19432. * performance. The return value must NOT be mutated, and should be treated as
  19433. * an immutable borrow. If you want to take ownership, you must make your own
  19434. * copy.
  19435. */
  19436. MappingList.prototype.toArray = function MappingList_toArray() {
  19437. if (!this._sorted) {
  19438. this._array.sort(util.compareByGeneratedPositionsInflated);
  19439. this._sorted = true;
  19440. }
  19441. return this._array;
  19442. };
  19443. mappingList$2.MappingList = MappingList;
  19444. return mappingList$2;
  19445. }
  19446. /* -*- Mode: js; js-indent-level: 2; -*- */
  19447. var hasRequiredSourceMapGenerator$2;
  19448. function requireSourceMapGenerator$2 () {
  19449. if (hasRequiredSourceMapGenerator$2) return sourceMapGenerator$2;
  19450. hasRequiredSourceMapGenerator$2 = 1;
  19451. /*
  19452. * Copyright 2011 Mozilla Foundation and contributors
  19453. * Licensed under the New BSD license. See LICENSE or:
  19454. * http://opensource.org/licenses/BSD-3-Clause
  19455. */
  19456. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$2();
  19457. var util = /*@__PURE__*/ requireUtil$3();
  19458. var ArraySet = /*@__PURE__*/ requireArraySet$2().ArraySet;
  19459. var MappingList = /*@__PURE__*/ requireMappingList$2().MappingList;
  19460. /**
  19461. * An instance of the SourceMapGenerator represents a source map which is
  19462. * being built incrementally. You may pass an object with the following
  19463. * properties:
  19464. *
  19465. * - file: The filename of the generated source.
  19466. * - sourceRoot: A root for all relative URLs in this source map.
  19467. */
  19468. function SourceMapGenerator(aArgs) {
  19469. if (!aArgs) {
  19470. aArgs = {};
  19471. }
  19472. this._file = util.getArg(aArgs, 'file', null);
  19473. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  19474. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  19475. this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
  19476. this._sources = new ArraySet();
  19477. this._names = new ArraySet();
  19478. this._mappings = new MappingList();
  19479. this._sourcesContents = null;
  19480. }
  19481. SourceMapGenerator.prototype._version = 3;
  19482. /**
  19483. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  19484. *
  19485. * @param aSourceMapConsumer The SourceMap.
  19486. */
  19487. SourceMapGenerator.fromSourceMap =
  19488. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  19489. var sourceRoot = aSourceMapConsumer.sourceRoot;
  19490. var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
  19491. file: aSourceMapConsumer.file,
  19492. sourceRoot: sourceRoot
  19493. }));
  19494. aSourceMapConsumer.eachMapping(function (mapping) {
  19495. var newMapping = {
  19496. generated: {
  19497. line: mapping.generatedLine,
  19498. column: mapping.generatedColumn
  19499. }
  19500. };
  19501. if (mapping.source != null) {
  19502. newMapping.source = mapping.source;
  19503. if (sourceRoot != null) {
  19504. newMapping.source = util.relative(sourceRoot, newMapping.source);
  19505. }
  19506. newMapping.original = {
  19507. line: mapping.originalLine,
  19508. column: mapping.originalColumn
  19509. };
  19510. if (mapping.name != null) {
  19511. newMapping.name = mapping.name;
  19512. }
  19513. }
  19514. generator.addMapping(newMapping);
  19515. });
  19516. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19517. var sourceRelative = sourceFile;
  19518. if (sourceRoot !== null) {
  19519. sourceRelative = util.relative(sourceRoot, sourceFile);
  19520. }
  19521. if (!generator._sources.has(sourceRelative)) {
  19522. generator._sources.add(sourceRelative);
  19523. }
  19524. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19525. if (content != null) {
  19526. generator.setSourceContent(sourceFile, content);
  19527. }
  19528. });
  19529. return generator;
  19530. };
  19531. /**
  19532. * Add a single mapping from original source line and column to the generated
  19533. * source's line and column for this source map being created. The mapping
  19534. * object should have the following properties:
  19535. *
  19536. * - generated: An object with the generated line and column positions.
  19537. * - original: An object with the original line and column positions.
  19538. * - source: The original source file (relative to the sourceRoot).
  19539. * - name: An optional original token name for this mapping.
  19540. */
  19541. SourceMapGenerator.prototype.addMapping =
  19542. function SourceMapGenerator_addMapping(aArgs) {
  19543. var generated = util.getArg(aArgs, 'generated');
  19544. var original = util.getArg(aArgs, 'original', null);
  19545. var source = util.getArg(aArgs, 'source', null);
  19546. var name = util.getArg(aArgs, 'name', null);
  19547. if (!this._skipValidation) {
  19548. if (this._validateMapping(generated, original, source, name) === false) {
  19549. return;
  19550. }
  19551. }
  19552. if (source != null) {
  19553. source = String(source);
  19554. if (!this._sources.has(source)) {
  19555. this._sources.add(source);
  19556. }
  19557. }
  19558. if (name != null) {
  19559. name = String(name);
  19560. if (!this._names.has(name)) {
  19561. this._names.add(name);
  19562. }
  19563. }
  19564. this._mappings.add({
  19565. generatedLine: generated.line,
  19566. generatedColumn: generated.column,
  19567. originalLine: original != null && original.line,
  19568. originalColumn: original != null && original.column,
  19569. source: source,
  19570. name: name
  19571. });
  19572. };
  19573. /**
  19574. * Set the source content for a source file.
  19575. */
  19576. SourceMapGenerator.prototype.setSourceContent =
  19577. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  19578. var source = aSourceFile;
  19579. if (this._sourceRoot != null) {
  19580. source = util.relative(this._sourceRoot, source);
  19581. }
  19582. if (aSourceContent != null) {
  19583. // Add the source content to the _sourcesContents map.
  19584. // Create a new _sourcesContents map if the property is null.
  19585. if (!this._sourcesContents) {
  19586. this._sourcesContents = Object.create(null);
  19587. }
  19588. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  19589. } else if (this._sourcesContents) {
  19590. // Remove the source file from the _sourcesContents map.
  19591. // If the _sourcesContents map is empty, set the property to null.
  19592. delete this._sourcesContents[util.toSetString(source)];
  19593. if (Object.keys(this._sourcesContents).length === 0) {
  19594. this._sourcesContents = null;
  19595. }
  19596. }
  19597. };
  19598. /**
  19599. * Applies the mappings of a sub-source-map for a specific source file to the
  19600. * source map being generated. Each mapping to the supplied source file is
  19601. * rewritten using the supplied source map. Note: The resolution for the
  19602. * resulting mappings is the minimium of this map and the supplied map.
  19603. *
  19604. * @param aSourceMapConsumer The source map to be applied.
  19605. * @param aSourceFile Optional. The filename of the source file.
  19606. * If omitted, SourceMapConsumer's file property will be used.
  19607. * @param aSourceMapPath Optional. The dirname of the path to the source map
  19608. * to be applied. If relative, it is relative to the SourceMapConsumer.
  19609. * This parameter is needed when the two source maps aren't in the same
  19610. * directory, and the source map to be applied contains relative source
  19611. * paths. If so, those relative source paths need to be rewritten
  19612. * relative to the SourceMapGenerator.
  19613. */
  19614. SourceMapGenerator.prototype.applySourceMap =
  19615. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  19616. var sourceFile = aSourceFile;
  19617. // If aSourceFile is omitted, we will use the file property of the SourceMap
  19618. if (aSourceFile == null) {
  19619. if (aSourceMapConsumer.file == null) {
  19620. throw new Error(
  19621. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  19622. 'or the source map\'s "file" property. Both were omitted.'
  19623. );
  19624. }
  19625. sourceFile = aSourceMapConsumer.file;
  19626. }
  19627. var sourceRoot = this._sourceRoot;
  19628. // Make "sourceFile" relative if an absolute Url is passed.
  19629. if (sourceRoot != null) {
  19630. sourceFile = util.relative(sourceRoot, sourceFile);
  19631. }
  19632. // Applying the SourceMap can add and remove items from the sources and
  19633. // the names array.
  19634. var newSources = new ArraySet();
  19635. var newNames = new ArraySet();
  19636. // Find mappings for the "sourceFile"
  19637. this._mappings.unsortedForEach(function (mapping) {
  19638. if (mapping.source === sourceFile && mapping.originalLine != null) {
  19639. // Check if it can be mapped by the source map, then update the mapping.
  19640. var original = aSourceMapConsumer.originalPositionFor({
  19641. line: mapping.originalLine,
  19642. column: mapping.originalColumn
  19643. });
  19644. if (original.source != null) {
  19645. // Copy mapping
  19646. mapping.source = original.source;
  19647. if (aSourceMapPath != null) {
  19648. mapping.source = util.join(aSourceMapPath, mapping.source);
  19649. }
  19650. if (sourceRoot != null) {
  19651. mapping.source = util.relative(sourceRoot, mapping.source);
  19652. }
  19653. mapping.originalLine = original.line;
  19654. mapping.originalColumn = original.column;
  19655. if (original.name != null) {
  19656. mapping.name = original.name;
  19657. }
  19658. }
  19659. }
  19660. var source = mapping.source;
  19661. if (source != null && !newSources.has(source)) {
  19662. newSources.add(source);
  19663. }
  19664. var name = mapping.name;
  19665. if (name != null && !newNames.has(name)) {
  19666. newNames.add(name);
  19667. }
  19668. }, this);
  19669. this._sources = newSources;
  19670. this._names = newNames;
  19671. // Copy sourcesContents of applied map.
  19672. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19673. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19674. if (content != null) {
  19675. if (aSourceMapPath != null) {
  19676. sourceFile = util.join(aSourceMapPath, sourceFile);
  19677. }
  19678. if (sourceRoot != null) {
  19679. sourceFile = util.relative(sourceRoot, sourceFile);
  19680. }
  19681. this.setSourceContent(sourceFile, content);
  19682. }
  19683. }, this);
  19684. };
  19685. /**
  19686. * A mapping can have one of the three levels of data:
  19687. *
  19688. * 1. Just the generated position.
  19689. * 2. The Generated position, original position, and original source.
  19690. * 3. Generated and original position, original source, as well as a name
  19691. * token.
  19692. *
  19693. * To maintain consistency, we validate that any new mapping being added falls
  19694. * in to one of these categories.
  19695. */
  19696. SourceMapGenerator.prototype._validateMapping =
  19697. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  19698. aName) {
  19699. // When aOriginal is truthy but has empty values for .line and .column,
  19700. // it is most likely a programmer error. In this case we throw a very
  19701. // specific error message to try to guide them the right way.
  19702. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  19703. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  19704. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  19705. 'the original mapping entirely and only map the generated position. If so, pass ' +
  19706. 'null for the original mapping instead of an object with empty or null values.';
  19707. if (this._ignoreInvalidMapping) {
  19708. if (typeof console !== 'undefined' && console.warn) {
  19709. console.warn(message);
  19710. }
  19711. return false;
  19712. } else {
  19713. throw new Error(message);
  19714. }
  19715. }
  19716. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19717. && aGenerated.line > 0 && aGenerated.column >= 0
  19718. && !aOriginal && !aSource && !aName) {
  19719. // Case 1.
  19720. return;
  19721. }
  19722. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19723. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  19724. && aGenerated.line > 0 && aGenerated.column >= 0
  19725. && aOriginal.line > 0 && aOriginal.column >= 0
  19726. && aSource) {
  19727. // Cases 2 and 3.
  19728. return;
  19729. }
  19730. else {
  19731. var message = 'Invalid mapping: ' + JSON.stringify({
  19732. generated: aGenerated,
  19733. source: aSource,
  19734. original: aOriginal,
  19735. name: aName
  19736. });
  19737. if (this._ignoreInvalidMapping) {
  19738. if (typeof console !== 'undefined' && console.warn) {
  19739. console.warn(message);
  19740. }
  19741. return false;
  19742. } else {
  19743. throw new Error(message)
  19744. }
  19745. }
  19746. };
  19747. /**
  19748. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  19749. * specified by the source map format.
  19750. */
  19751. SourceMapGenerator.prototype._serializeMappings =
  19752. function SourceMapGenerator_serializeMappings() {
  19753. var previousGeneratedColumn = 0;
  19754. var previousGeneratedLine = 1;
  19755. var previousOriginalColumn = 0;
  19756. var previousOriginalLine = 0;
  19757. var previousName = 0;
  19758. var previousSource = 0;
  19759. var result = '';
  19760. var next;
  19761. var mapping;
  19762. var nameIdx;
  19763. var sourceIdx;
  19764. var mappings = this._mappings.toArray();
  19765. for (var i = 0, len = mappings.length; i < len; i++) {
  19766. mapping = mappings[i];
  19767. next = '';
  19768. if (mapping.generatedLine !== previousGeneratedLine) {
  19769. previousGeneratedColumn = 0;
  19770. while (mapping.generatedLine !== previousGeneratedLine) {
  19771. next += ';';
  19772. previousGeneratedLine++;
  19773. }
  19774. }
  19775. else {
  19776. if (i > 0) {
  19777. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  19778. continue;
  19779. }
  19780. next += ',';
  19781. }
  19782. }
  19783. next += base64VLQ.encode(mapping.generatedColumn
  19784. - previousGeneratedColumn);
  19785. previousGeneratedColumn = mapping.generatedColumn;
  19786. if (mapping.source != null) {
  19787. sourceIdx = this._sources.indexOf(mapping.source);
  19788. next += base64VLQ.encode(sourceIdx - previousSource);
  19789. previousSource = sourceIdx;
  19790. // lines are stored 0-based in SourceMap spec version 3
  19791. next += base64VLQ.encode(mapping.originalLine - 1
  19792. - previousOriginalLine);
  19793. previousOriginalLine = mapping.originalLine - 1;
  19794. next += base64VLQ.encode(mapping.originalColumn
  19795. - previousOriginalColumn);
  19796. previousOriginalColumn = mapping.originalColumn;
  19797. if (mapping.name != null) {
  19798. nameIdx = this._names.indexOf(mapping.name);
  19799. next += base64VLQ.encode(nameIdx - previousName);
  19800. previousName = nameIdx;
  19801. }
  19802. }
  19803. result += next;
  19804. }
  19805. return result;
  19806. };
  19807. SourceMapGenerator.prototype._generateSourcesContent =
  19808. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  19809. return aSources.map(function (source) {
  19810. if (!this._sourcesContents) {
  19811. return null;
  19812. }
  19813. if (aSourceRoot != null) {
  19814. source = util.relative(aSourceRoot, source);
  19815. }
  19816. var key = util.toSetString(source);
  19817. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  19818. ? this._sourcesContents[key]
  19819. : null;
  19820. }, this);
  19821. };
  19822. /**
  19823. * Externalize the source map.
  19824. */
  19825. SourceMapGenerator.prototype.toJSON =
  19826. function SourceMapGenerator_toJSON() {
  19827. var map = {
  19828. version: this._version,
  19829. sources: this._sources.toArray(),
  19830. names: this._names.toArray(),
  19831. mappings: this._serializeMappings()
  19832. };
  19833. if (this._file != null) {
  19834. map.file = this._file;
  19835. }
  19836. if (this._sourceRoot != null) {
  19837. map.sourceRoot = this._sourceRoot;
  19838. }
  19839. if (this._sourcesContents) {
  19840. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  19841. }
  19842. return map;
  19843. };
  19844. /**
  19845. * Render the source map being generated to a string.
  19846. */
  19847. SourceMapGenerator.prototype.toString =
  19848. function SourceMapGenerator_toString() {
  19849. return JSON.stringify(this.toJSON());
  19850. };
  19851. sourceMapGenerator$2.SourceMapGenerator = SourceMapGenerator;
  19852. return sourceMapGenerator$2;
  19853. }
  19854. var sourceMapConsumer$2 = {};
  19855. var binarySearch$2 = {};
  19856. /* -*- Mode: js; js-indent-level: 2; -*- */
  19857. var hasRequiredBinarySearch$2;
  19858. function requireBinarySearch$2 () {
  19859. if (hasRequiredBinarySearch$2) return binarySearch$2;
  19860. hasRequiredBinarySearch$2 = 1;
  19861. (function (exports) {
  19862. /*
  19863. * Copyright 2011 Mozilla Foundation and contributors
  19864. * Licensed under the New BSD license. See LICENSE or:
  19865. * http://opensource.org/licenses/BSD-3-Clause
  19866. */
  19867. exports.GREATEST_LOWER_BOUND = 1;
  19868. exports.LEAST_UPPER_BOUND = 2;
  19869. /**
  19870. * Recursive implementation of binary search.
  19871. *
  19872. * @param aLow Indices here and lower do not contain the needle.
  19873. * @param aHigh Indices here and higher do not contain the needle.
  19874. * @param aNeedle The element being searched for.
  19875. * @param aHaystack The non-empty array being searched.
  19876. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  19877. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19878. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19879. * closest element that is smaller than or greater than the one we are
  19880. * searching for, respectively, if the exact element cannot be found.
  19881. */
  19882. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  19883. // This function terminates when one of the following is true:
  19884. //
  19885. // 1. We find the exact element we are looking for.
  19886. //
  19887. // 2. We did not find the exact element, but we can return the index of
  19888. // the next-closest element.
  19889. //
  19890. // 3. We did not find the exact element, and there is no next-closest
  19891. // element than the one we are searching for, so we return -1.
  19892. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  19893. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  19894. if (cmp === 0) {
  19895. // Found the element we are looking for.
  19896. return mid;
  19897. }
  19898. else if (cmp > 0) {
  19899. // Our needle is greater than aHaystack[mid].
  19900. if (aHigh - mid > 1) {
  19901. // The element is in the upper half.
  19902. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  19903. }
  19904. // The exact needle element was not found in this haystack. Determine if
  19905. // we are in termination case (3) or (2) and return the appropriate thing.
  19906. if (aBias == exports.LEAST_UPPER_BOUND) {
  19907. return aHigh < aHaystack.length ? aHigh : -1;
  19908. } else {
  19909. return mid;
  19910. }
  19911. }
  19912. else {
  19913. // Our needle is less than aHaystack[mid].
  19914. if (mid - aLow > 1) {
  19915. // The element is in the lower half.
  19916. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  19917. }
  19918. // we are in termination case (3) or (2) and return the appropriate thing.
  19919. if (aBias == exports.LEAST_UPPER_BOUND) {
  19920. return mid;
  19921. } else {
  19922. return aLow < 0 ? -1 : aLow;
  19923. }
  19924. }
  19925. }
  19926. /**
  19927. * This is an implementation of binary search which will always try and return
  19928. * the index of the closest element if there is no exact hit. This is because
  19929. * mappings between original and generated line/col pairs are single points,
  19930. * and there is an implicit region between each of them, so a miss just means
  19931. * that you aren't on the very start of a region.
  19932. *
  19933. * @param aNeedle The element you are looking for.
  19934. * @param aHaystack The array that is being searched.
  19935. * @param aCompare A function which takes the needle and an element in the
  19936. * array and returns -1, 0, or 1 depending on whether the needle is less
  19937. * than, equal to, or greater than the element, respectively.
  19938. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19939. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19940. * closest element that is smaller than or greater than the one we are
  19941. * searching for, respectively, if the exact element cannot be found.
  19942. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  19943. */
  19944. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  19945. if (aHaystack.length === 0) {
  19946. return -1;
  19947. }
  19948. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  19949. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  19950. if (index < 0) {
  19951. return -1;
  19952. }
  19953. // We have found either the exact element, or the next-closest element than
  19954. // the one we are searching for. However, there may be more than one such
  19955. // element. Make sure we always return the smallest of these.
  19956. while (index - 1 >= 0) {
  19957. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  19958. break;
  19959. }
  19960. --index;
  19961. }
  19962. return index;
  19963. };
  19964. } (binarySearch$2));
  19965. return binarySearch$2;
  19966. }
  19967. var quickSort$2 = {};
  19968. /* -*- Mode: js; js-indent-level: 2; -*- */
  19969. var hasRequiredQuickSort$2;
  19970. function requireQuickSort$2 () {
  19971. if (hasRequiredQuickSort$2) return quickSort$2;
  19972. hasRequiredQuickSort$2 = 1;
  19973. /*
  19974. * Copyright 2011 Mozilla Foundation and contributors
  19975. * Licensed under the New BSD license. See LICENSE or:
  19976. * http://opensource.org/licenses/BSD-3-Clause
  19977. */
  19978. // It turns out that some (most?) JavaScript engines don't self-host
  19979. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  19980. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  19981. // custom comparator function, calling back and forth between the VM's C++ and
  19982. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  19983. // worse generated code for the comparator function than would be optimal. In
  19984. // fact, when sorting with a comparator, these costs outweigh the benefits of
  19985. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  19986. // a ~3500ms mean speed-up in `bench/bench.html`.
  19987. function SortTemplate(comparator) {
  19988. /**
  19989. * Swap the elements indexed by `x` and `y` in the array `ary`.
  19990. *
  19991. * @param {Array} ary
  19992. * The array.
  19993. * @param {Number} x
  19994. * The index of the first item.
  19995. * @param {Number} y
  19996. * The index of the second item.
  19997. */
  19998. function swap(ary, x, y) {
  19999. var temp = ary[x];
  20000. ary[x] = ary[y];
  20001. ary[y] = temp;
  20002. }
  20003. /**
  20004. * Returns a random integer within the range `low .. high` inclusive.
  20005. *
  20006. * @param {Number} low
  20007. * The lower bound on the range.
  20008. * @param {Number} high
  20009. * The upper bound on the range.
  20010. */
  20011. function randomIntInRange(low, high) {
  20012. return Math.round(low + (Math.random() * (high - low)));
  20013. }
  20014. /**
  20015. * The Quick Sort algorithm.
  20016. *
  20017. * @param {Array} ary
  20018. * An array to sort.
  20019. * @param {function} comparator
  20020. * Function to use to compare two items.
  20021. * @param {Number} p
  20022. * Start index of the array
  20023. * @param {Number} r
  20024. * End index of the array
  20025. */
  20026. function doQuickSort(ary, comparator, p, r) {
  20027. // If our lower bound is less than our upper bound, we (1) partition the
  20028. // array into two pieces and (2) recurse on each half. If it is not, this is
  20029. // the empty array and our base case.
  20030. if (p < r) {
  20031. // (1) Partitioning.
  20032. //
  20033. // The partitioning chooses a pivot between `p` and `r` and moves all
  20034. // elements that are less than or equal to the pivot to the before it, and
  20035. // all the elements that are greater than it after it. The effect is that
  20036. // once partition is done, the pivot is in the exact place it will be when
  20037. // the array is put in sorted order, and it will not need to be moved
  20038. // again. This runs in O(n) time.
  20039. // Always choose a random pivot so that an input array which is reverse
  20040. // sorted does not cause O(n^2) running time.
  20041. var pivotIndex = randomIntInRange(p, r);
  20042. var i = p - 1;
  20043. swap(ary, pivotIndex, r);
  20044. var pivot = ary[r];
  20045. // Immediately after `j` is incremented in this loop, the following hold
  20046. // true:
  20047. //
  20048. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  20049. //
  20050. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  20051. for (var j = p; j < r; j++) {
  20052. if (comparator(ary[j], pivot, false) <= 0) {
  20053. i += 1;
  20054. swap(ary, i, j);
  20055. }
  20056. }
  20057. swap(ary, i + 1, j);
  20058. var q = i + 1;
  20059. // (2) Recurse on each half.
  20060. doQuickSort(ary, comparator, p, q - 1);
  20061. doQuickSort(ary, comparator, q + 1, r);
  20062. }
  20063. }
  20064. return doQuickSort;
  20065. }
  20066. function cloneSort(comparator) {
  20067. let template = SortTemplate.toString();
  20068. let templateFn = new Function(`return ${template}`)();
  20069. return templateFn(comparator);
  20070. }
  20071. /**
  20072. * Sort the given array in-place with the given comparator function.
  20073. *
  20074. * @param {Array} ary
  20075. * An array to sort.
  20076. * @param {function} comparator
  20077. * Function to use to compare two items.
  20078. */
  20079. let sortCache = new WeakMap();
  20080. quickSort$2.quickSort = function (ary, comparator, start = 0) {
  20081. let doQuickSort = sortCache.get(comparator);
  20082. if (doQuickSort === void 0) {
  20083. doQuickSort = cloneSort(comparator);
  20084. sortCache.set(comparator, doQuickSort);
  20085. }
  20086. doQuickSort(ary, comparator, start, ary.length - 1);
  20087. };
  20088. return quickSort$2;
  20089. }
  20090. /* -*- Mode: js; js-indent-level: 2; -*- */
  20091. var hasRequiredSourceMapConsumer$2;
  20092. function requireSourceMapConsumer$2 () {
  20093. if (hasRequiredSourceMapConsumer$2) return sourceMapConsumer$2;
  20094. hasRequiredSourceMapConsumer$2 = 1;
  20095. /*
  20096. * Copyright 2011 Mozilla Foundation and contributors
  20097. * Licensed under the New BSD license. See LICENSE or:
  20098. * http://opensource.org/licenses/BSD-3-Clause
  20099. */
  20100. var util = /*@__PURE__*/ requireUtil$3();
  20101. var binarySearch = /*@__PURE__*/ requireBinarySearch$2();
  20102. var ArraySet = /*@__PURE__*/ requireArraySet$2().ArraySet;
  20103. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$2();
  20104. var quickSort = /*@__PURE__*/ requireQuickSort$2().quickSort;
  20105. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  20106. var sourceMap = aSourceMap;
  20107. if (typeof aSourceMap === 'string') {
  20108. sourceMap = util.parseSourceMapInput(aSourceMap);
  20109. }
  20110. return sourceMap.sections != null
  20111. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  20112. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  20113. }
  20114. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  20115. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  20116. };
  20117. /**
  20118. * The version of the source mapping spec that we are consuming.
  20119. */
  20120. SourceMapConsumer.prototype._version = 3;
  20121. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  20122. // parsed mapping coordinates from the source map's "mappings" attribute. They
  20123. // are lazily instantiated, accessed via the `_generatedMappings` and
  20124. // `_originalMappings` getters respectively, and we only parse the mappings
  20125. // and create these arrays once queried for a source location. We jump through
  20126. // these hoops because there can be many thousands of mappings, and parsing
  20127. // them is expensive, so we only want to do it if we must.
  20128. //
  20129. // Each object in the arrays is of the form:
  20130. //
  20131. // {
  20132. // generatedLine: The line number in the generated code,
  20133. // generatedColumn: The column number in the generated code,
  20134. // source: The path to the original source file that generated this
  20135. // chunk of code,
  20136. // originalLine: The line number in the original source that
  20137. // corresponds to this chunk of generated code,
  20138. // originalColumn: The column number in the original source that
  20139. // corresponds to this chunk of generated code,
  20140. // name: The name of the original symbol which generated this chunk of
  20141. // code.
  20142. // }
  20143. //
  20144. // All properties except for `generatedLine` and `generatedColumn` can be
  20145. // `null`.
  20146. //
  20147. // `_generatedMappings` is ordered by the generated positions.
  20148. //
  20149. // `_originalMappings` is ordered by the original positions.
  20150. SourceMapConsumer.prototype.__generatedMappings = null;
  20151. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  20152. configurable: true,
  20153. enumerable: true,
  20154. get: function () {
  20155. if (!this.__generatedMappings) {
  20156. this._parseMappings(this._mappings, this.sourceRoot);
  20157. }
  20158. return this.__generatedMappings;
  20159. }
  20160. });
  20161. SourceMapConsumer.prototype.__originalMappings = null;
  20162. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  20163. configurable: true,
  20164. enumerable: true,
  20165. get: function () {
  20166. if (!this.__originalMappings) {
  20167. this._parseMappings(this._mappings, this.sourceRoot);
  20168. }
  20169. return this.__originalMappings;
  20170. }
  20171. });
  20172. SourceMapConsumer.prototype._charIsMappingSeparator =
  20173. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  20174. var c = aStr.charAt(index);
  20175. return c === ";" || c === ",";
  20176. };
  20177. /**
  20178. * Parse the mappings in a string in to a data structure which we can easily
  20179. * query (the ordered arrays in the `this.__generatedMappings` and
  20180. * `this.__originalMappings` properties).
  20181. */
  20182. SourceMapConsumer.prototype._parseMappings =
  20183. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20184. throw new Error("Subclasses must implement _parseMappings");
  20185. };
  20186. SourceMapConsumer.GENERATED_ORDER = 1;
  20187. SourceMapConsumer.ORIGINAL_ORDER = 2;
  20188. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  20189. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  20190. /**
  20191. * Iterate over each mapping between an original source/line/column and a
  20192. * generated line/column in this source map.
  20193. *
  20194. * @param Function aCallback
  20195. * The function that is called with each mapping.
  20196. * @param Object aContext
  20197. * Optional. If specified, this object will be the value of `this` every
  20198. * time that `aCallback` is called.
  20199. * @param aOrder
  20200. * Either `SourceMapConsumer.GENERATED_ORDER` or
  20201. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  20202. * iterate over the mappings sorted by the generated file's line/column
  20203. * order or the original's source/line/column order, respectively. Defaults to
  20204. * `SourceMapConsumer.GENERATED_ORDER`.
  20205. */
  20206. SourceMapConsumer.prototype.eachMapping =
  20207. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  20208. var context = aContext || null;
  20209. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  20210. var mappings;
  20211. switch (order) {
  20212. case SourceMapConsumer.GENERATED_ORDER:
  20213. mappings = this._generatedMappings;
  20214. break;
  20215. case SourceMapConsumer.ORIGINAL_ORDER:
  20216. mappings = this._originalMappings;
  20217. break;
  20218. default:
  20219. throw new Error("Unknown order of iteration.");
  20220. }
  20221. var sourceRoot = this.sourceRoot;
  20222. var boundCallback = aCallback.bind(context);
  20223. var names = this._names;
  20224. var sources = this._sources;
  20225. var sourceMapURL = this._sourceMapURL;
  20226. for (var i = 0, n = mappings.length; i < n; i++) {
  20227. var mapping = mappings[i];
  20228. var source = mapping.source === null ? null : sources.at(mapping.source);
  20229. source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
  20230. boundCallback({
  20231. source: source,
  20232. generatedLine: mapping.generatedLine,
  20233. generatedColumn: mapping.generatedColumn,
  20234. originalLine: mapping.originalLine,
  20235. originalColumn: mapping.originalColumn,
  20236. name: mapping.name === null ? null : names.at(mapping.name)
  20237. });
  20238. }
  20239. };
  20240. /**
  20241. * Returns all generated line and column information for the original source,
  20242. * line, and column provided. If no column is provided, returns all mappings
  20243. * corresponding to a either the line we are searching for or the next
  20244. * closest line that has any mappings. Otherwise, returns all mappings
  20245. * corresponding to the given line and either the column we are searching for
  20246. * or the next closest column that has any offsets.
  20247. *
  20248. * The only argument is an object with the following properties:
  20249. *
  20250. * - source: The filename of the original source.
  20251. * - line: The line number in the original source. The line number is 1-based.
  20252. * - column: Optional. the column number in the original source.
  20253. * The column number is 0-based.
  20254. *
  20255. * and an array of objects is returned, each with the following properties:
  20256. *
  20257. * - line: The line number in the generated source, or null. The
  20258. * line number is 1-based.
  20259. * - column: The column number in the generated source, or null.
  20260. * The column number is 0-based.
  20261. */
  20262. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  20263. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  20264. var line = util.getArg(aArgs, 'line');
  20265. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  20266. // returns the index of the closest mapping less than the needle. By
  20267. // setting needle.originalColumn to 0, we thus find the last mapping for
  20268. // the given line, provided such a mapping exists.
  20269. var needle = {
  20270. source: util.getArg(aArgs, 'source'),
  20271. originalLine: line,
  20272. originalColumn: util.getArg(aArgs, 'column', 0)
  20273. };
  20274. needle.source = this._findSourceIndex(needle.source);
  20275. if (needle.source < 0) {
  20276. return [];
  20277. }
  20278. var mappings = [];
  20279. var index = this._findMapping(needle,
  20280. this._originalMappings,
  20281. "originalLine",
  20282. "originalColumn",
  20283. util.compareByOriginalPositions,
  20284. binarySearch.LEAST_UPPER_BOUND);
  20285. if (index >= 0) {
  20286. var mapping = this._originalMappings[index];
  20287. if (aArgs.column === undefined) {
  20288. var originalLine = mapping.originalLine;
  20289. // Iterate until either we run out of mappings, or we run into
  20290. // a mapping for a different line than the one we found. Since
  20291. // mappings are sorted, this is guaranteed to find all mappings for
  20292. // the line we found.
  20293. while (mapping && mapping.originalLine === originalLine) {
  20294. mappings.push({
  20295. line: util.getArg(mapping, 'generatedLine', null),
  20296. column: util.getArg(mapping, 'generatedColumn', null),
  20297. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20298. });
  20299. mapping = this._originalMappings[++index];
  20300. }
  20301. } else {
  20302. var originalColumn = mapping.originalColumn;
  20303. // Iterate until either we run out of mappings, or we run into
  20304. // a mapping for a different line than the one we were searching for.
  20305. // Since mappings are sorted, this is guaranteed to find all mappings for
  20306. // the line we are searching for.
  20307. while (mapping &&
  20308. mapping.originalLine === line &&
  20309. mapping.originalColumn == originalColumn) {
  20310. mappings.push({
  20311. line: util.getArg(mapping, 'generatedLine', null),
  20312. column: util.getArg(mapping, 'generatedColumn', null),
  20313. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20314. });
  20315. mapping = this._originalMappings[++index];
  20316. }
  20317. }
  20318. }
  20319. return mappings;
  20320. };
  20321. sourceMapConsumer$2.SourceMapConsumer = SourceMapConsumer;
  20322. /**
  20323. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  20324. * query for information about the original file positions by giving it a file
  20325. * position in the generated source.
  20326. *
  20327. * The first parameter is the raw source map (either as a JSON string, or
  20328. * already parsed to an object). According to the spec, source maps have the
  20329. * following attributes:
  20330. *
  20331. * - version: Which version of the source map spec this map is following.
  20332. * - sources: An array of URLs to the original source files.
  20333. * - names: An array of identifiers which can be referrenced by individual mappings.
  20334. * - sourceRoot: Optional. The URL root from which all sources are relative.
  20335. * - sourcesContent: Optional. An array of contents of the original source files.
  20336. * - mappings: A string of base64 VLQs which contain the actual mappings.
  20337. * - file: Optional. The generated file this source map is associated with.
  20338. *
  20339. * Here is an example source map, taken from the source map spec[0]:
  20340. *
  20341. * {
  20342. * version : 3,
  20343. * file: "out.js",
  20344. * sourceRoot : "",
  20345. * sources: ["foo.js", "bar.js"],
  20346. * names: ["src", "maps", "are", "fun"],
  20347. * mappings: "AA,AB;;ABCDE;"
  20348. * }
  20349. *
  20350. * The second parameter, if given, is a string whose value is the URL
  20351. * at which the source map was found. This URL is used to compute the
  20352. * sources array.
  20353. *
  20354. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  20355. */
  20356. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  20357. var sourceMap = aSourceMap;
  20358. if (typeof aSourceMap === 'string') {
  20359. sourceMap = util.parseSourceMapInput(aSourceMap);
  20360. }
  20361. var version = util.getArg(sourceMap, 'version');
  20362. var sources = util.getArg(sourceMap, 'sources');
  20363. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  20364. // requires the array) to play nice here.
  20365. var names = util.getArg(sourceMap, 'names', []);
  20366. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  20367. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  20368. var mappings = util.getArg(sourceMap, 'mappings');
  20369. var file = util.getArg(sourceMap, 'file', null);
  20370. // Once again, Sass deviates from the spec and supplies the version as a
  20371. // string rather than a number, so we use loose equality checking here.
  20372. if (version != this._version) {
  20373. throw new Error('Unsupported version: ' + version);
  20374. }
  20375. if (sourceRoot) {
  20376. sourceRoot = util.normalize(sourceRoot);
  20377. }
  20378. sources = sources
  20379. .map(String)
  20380. // Some source maps produce relative source paths like "./foo.js" instead of
  20381. // "foo.js". Normalize these first so that future comparisons will succeed.
  20382. // See bugzil.la/1090768.
  20383. .map(util.normalize)
  20384. // Always ensure that absolute sources are internally stored relative to
  20385. // the source root, if the source root is absolute. Not doing this would
  20386. // be particularly problematic when the source root is a prefix of the
  20387. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  20388. .map(function (source) {
  20389. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  20390. ? util.relative(sourceRoot, source)
  20391. : source;
  20392. });
  20393. // Pass `true` below to allow duplicate names and sources. While source maps
  20394. // are intended to be compressed and deduplicated, the TypeScript compiler
  20395. // sometimes generates source maps with duplicates in them. See Github issue
  20396. // #72 and bugzil.la/889492.
  20397. this._names = ArraySet.fromArray(names.map(String), true);
  20398. this._sources = ArraySet.fromArray(sources, true);
  20399. this._absoluteSources = this._sources.toArray().map(function (s) {
  20400. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  20401. });
  20402. this.sourceRoot = sourceRoot;
  20403. this.sourcesContent = sourcesContent;
  20404. this._mappings = mappings;
  20405. this._sourceMapURL = aSourceMapURL;
  20406. this.file = file;
  20407. }
  20408. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  20409. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  20410. /**
  20411. * Utility function to find the index of a source. Returns -1 if not
  20412. * found.
  20413. */
  20414. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  20415. var relativeSource = aSource;
  20416. if (this.sourceRoot != null) {
  20417. relativeSource = util.relative(this.sourceRoot, relativeSource);
  20418. }
  20419. if (this._sources.has(relativeSource)) {
  20420. return this._sources.indexOf(relativeSource);
  20421. }
  20422. // Maybe aSource is an absolute URL as returned by |sources|. In
  20423. // this case we can't simply undo the transform.
  20424. var i;
  20425. for (i = 0; i < this._absoluteSources.length; ++i) {
  20426. if (this._absoluteSources[i] == aSource) {
  20427. return i;
  20428. }
  20429. }
  20430. return -1;
  20431. };
  20432. /**
  20433. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  20434. *
  20435. * @param SourceMapGenerator aSourceMap
  20436. * The source map that will be consumed.
  20437. * @param String aSourceMapURL
  20438. * The URL at which the source map can be found (optional)
  20439. * @returns BasicSourceMapConsumer
  20440. */
  20441. BasicSourceMapConsumer.fromSourceMap =
  20442. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  20443. var smc = Object.create(BasicSourceMapConsumer.prototype);
  20444. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  20445. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  20446. smc.sourceRoot = aSourceMap._sourceRoot;
  20447. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  20448. smc.sourceRoot);
  20449. smc.file = aSourceMap._file;
  20450. smc._sourceMapURL = aSourceMapURL;
  20451. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  20452. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  20453. });
  20454. // Because we are modifying the entries (by converting string sources and
  20455. // names to indices into the sources and names ArraySets), we have to make
  20456. // a copy of the entry or else bad things happen. Shared mutable state
  20457. // strikes again! See github issue #191.
  20458. var generatedMappings = aSourceMap._mappings.toArray().slice();
  20459. var destGeneratedMappings = smc.__generatedMappings = [];
  20460. var destOriginalMappings = smc.__originalMappings = [];
  20461. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  20462. var srcMapping = generatedMappings[i];
  20463. var destMapping = new Mapping;
  20464. destMapping.generatedLine = srcMapping.generatedLine;
  20465. destMapping.generatedColumn = srcMapping.generatedColumn;
  20466. if (srcMapping.source) {
  20467. destMapping.source = sources.indexOf(srcMapping.source);
  20468. destMapping.originalLine = srcMapping.originalLine;
  20469. destMapping.originalColumn = srcMapping.originalColumn;
  20470. if (srcMapping.name) {
  20471. destMapping.name = names.indexOf(srcMapping.name);
  20472. }
  20473. destOriginalMappings.push(destMapping);
  20474. }
  20475. destGeneratedMappings.push(destMapping);
  20476. }
  20477. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  20478. return smc;
  20479. };
  20480. /**
  20481. * The version of the source mapping spec that we are consuming.
  20482. */
  20483. BasicSourceMapConsumer.prototype._version = 3;
  20484. /**
  20485. * The list of original sources.
  20486. */
  20487. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  20488. get: function () {
  20489. return this._absoluteSources.slice();
  20490. }
  20491. });
  20492. /**
  20493. * Provide the JIT with a nice shape / hidden class.
  20494. */
  20495. function Mapping() {
  20496. this.generatedLine = 0;
  20497. this.generatedColumn = 0;
  20498. this.source = null;
  20499. this.originalLine = null;
  20500. this.originalColumn = null;
  20501. this.name = null;
  20502. }
  20503. /**
  20504. * Parse the mappings in a string in to a data structure which we can easily
  20505. * query (the ordered arrays in the `this.__generatedMappings` and
  20506. * `this.__originalMappings` properties).
  20507. */
  20508. const compareGenerated = util.compareByGeneratedPositionsDeflatedNoLine;
  20509. function sortGenerated(array, start) {
  20510. let l = array.length;
  20511. let n = array.length - start;
  20512. if (n <= 1) {
  20513. return;
  20514. } else if (n == 2) {
  20515. let a = array[start];
  20516. let b = array[start + 1];
  20517. if (compareGenerated(a, b) > 0) {
  20518. array[start] = b;
  20519. array[start + 1] = a;
  20520. }
  20521. } else if (n < 20) {
  20522. for (let i = start; i < l; i++) {
  20523. for (let j = i; j > start; j--) {
  20524. let a = array[j - 1];
  20525. let b = array[j];
  20526. if (compareGenerated(a, b) <= 0) {
  20527. break;
  20528. }
  20529. array[j - 1] = b;
  20530. array[j] = a;
  20531. }
  20532. }
  20533. } else {
  20534. quickSort(array, compareGenerated, start);
  20535. }
  20536. }
  20537. BasicSourceMapConsumer.prototype._parseMappings =
  20538. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20539. var generatedLine = 1;
  20540. var previousGeneratedColumn = 0;
  20541. var previousOriginalLine = 0;
  20542. var previousOriginalColumn = 0;
  20543. var previousSource = 0;
  20544. var previousName = 0;
  20545. var length = aStr.length;
  20546. var index = 0;
  20547. var temp = {};
  20548. var originalMappings = [];
  20549. var generatedMappings = [];
  20550. var mapping, segment, end, value;
  20551. let subarrayStart = 0;
  20552. while (index < length) {
  20553. if (aStr.charAt(index) === ';') {
  20554. generatedLine++;
  20555. index++;
  20556. previousGeneratedColumn = 0;
  20557. sortGenerated(generatedMappings, subarrayStart);
  20558. subarrayStart = generatedMappings.length;
  20559. }
  20560. else if (aStr.charAt(index) === ',') {
  20561. index++;
  20562. }
  20563. else {
  20564. mapping = new Mapping();
  20565. mapping.generatedLine = generatedLine;
  20566. for (end = index; end < length; end++) {
  20567. if (this._charIsMappingSeparator(aStr, end)) {
  20568. break;
  20569. }
  20570. }
  20571. aStr.slice(index, end);
  20572. segment = [];
  20573. while (index < end) {
  20574. base64VLQ.decode(aStr, index, temp);
  20575. value = temp.value;
  20576. index = temp.rest;
  20577. segment.push(value);
  20578. }
  20579. if (segment.length === 2) {
  20580. throw new Error('Found a source, but no line and column');
  20581. }
  20582. if (segment.length === 3) {
  20583. throw new Error('Found a source and line, but no column');
  20584. }
  20585. // Generated column.
  20586. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  20587. previousGeneratedColumn = mapping.generatedColumn;
  20588. if (segment.length > 1) {
  20589. // Original source.
  20590. mapping.source = previousSource + segment[1];
  20591. previousSource += segment[1];
  20592. // Original line.
  20593. mapping.originalLine = previousOriginalLine + segment[2];
  20594. previousOriginalLine = mapping.originalLine;
  20595. // Lines are stored 0-based
  20596. mapping.originalLine += 1;
  20597. // Original column.
  20598. mapping.originalColumn = previousOriginalColumn + segment[3];
  20599. previousOriginalColumn = mapping.originalColumn;
  20600. if (segment.length > 4) {
  20601. // Original name.
  20602. mapping.name = previousName + segment[4];
  20603. previousName += segment[4];
  20604. }
  20605. }
  20606. generatedMappings.push(mapping);
  20607. if (typeof mapping.originalLine === 'number') {
  20608. let currentSource = mapping.source;
  20609. while (originalMappings.length <= currentSource) {
  20610. originalMappings.push(null);
  20611. }
  20612. if (originalMappings[currentSource] === null) {
  20613. originalMappings[currentSource] = [];
  20614. }
  20615. originalMappings[currentSource].push(mapping);
  20616. }
  20617. }
  20618. }
  20619. sortGenerated(generatedMappings, subarrayStart);
  20620. this.__generatedMappings = generatedMappings;
  20621. for (var i = 0; i < originalMappings.length; i++) {
  20622. if (originalMappings[i] != null) {
  20623. quickSort(originalMappings[i], util.compareByOriginalPositionsNoSource);
  20624. }
  20625. }
  20626. this.__originalMappings = [].concat(...originalMappings);
  20627. };
  20628. /**
  20629. * Find the mapping that best matches the hypothetical "needle" mapping that
  20630. * we are searching for in the given "haystack" of mappings.
  20631. */
  20632. BasicSourceMapConsumer.prototype._findMapping =
  20633. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  20634. aColumnName, aComparator, aBias) {
  20635. // To return the position we are searching for, we must first find the
  20636. // mapping for the given position and then return the opposite position it
  20637. // points to. Because the mappings are sorted, we can use binary search to
  20638. // find the best mapping.
  20639. if (aNeedle[aLineName] <= 0) {
  20640. throw new TypeError('Line must be greater than or equal to 1, got '
  20641. + aNeedle[aLineName]);
  20642. }
  20643. if (aNeedle[aColumnName] < 0) {
  20644. throw new TypeError('Column must be greater than or equal to 0, got '
  20645. + aNeedle[aColumnName]);
  20646. }
  20647. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  20648. };
  20649. /**
  20650. * Compute the last column for each generated mapping. The last column is
  20651. * inclusive.
  20652. */
  20653. BasicSourceMapConsumer.prototype.computeColumnSpans =
  20654. function SourceMapConsumer_computeColumnSpans() {
  20655. for (var index = 0; index < this._generatedMappings.length; ++index) {
  20656. var mapping = this._generatedMappings[index];
  20657. // Mappings do not contain a field for the last generated columnt. We
  20658. // can come up with an optimistic estimate, however, by assuming that
  20659. // mappings are contiguous (i.e. given two consecutive mappings, the
  20660. // first mapping ends where the second one starts).
  20661. if (index + 1 < this._generatedMappings.length) {
  20662. var nextMapping = this._generatedMappings[index + 1];
  20663. if (mapping.generatedLine === nextMapping.generatedLine) {
  20664. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  20665. continue;
  20666. }
  20667. }
  20668. // The last mapping for each line spans the entire line.
  20669. mapping.lastGeneratedColumn = Infinity;
  20670. }
  20671. };
  20672. /**
  20673. * Returns the original source, line, and column information for the generated
  20674. * source's line and column positions provided. The only argument is an object
  20675. * with the following properties:
  20676. *
  20677. * - line: The line number in the generated source. The line number
  20678. * is 1-based.
  20679. * - column: The column number in the generated source. The column
  20680. * number is 0-based.
  20681. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20682. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20683. * closest element that is smaller than or greater than the one we are
  20684. * searching for, respectively, if the exact element cannot be found.
  20685. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20686. *
  20687. * and an object is returned with the following properties:
  20688. *
  20689. * - source: The original source file, or null.
  20690. * - line: The line number in the original source, or null. The
  20691. * line number is 1-based.
  20692. * - column: The column number in the original source, or null. The
  20693. * column number is 0-based.
  20694. * - name: The original identifier, or null.
  20695. */
  20696. BasicSourceMapConsumer.prototype.originalPositionFor =
  20697. function SourceMapConsumer_originalPositionFor(aArgs) {
  20698. var needle = {
  20699. generatedLine: util.getArg(aArgs, 'line'),
  20700. generatedColumn: util.getArg(aArgs, 'column')
  20701. };
  20702. var index = this._findMapping(
  20703. needle,
  20704. this._generatedMappings,
  20705. "generatedLine",
  20706. "generatedColumn",
  20707. util.compareByGeneratedPositionsDeflated,
  20708. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  20709. );
  20710. if (index >= 0) {
  20711. var mapping = this._generatedMappings[index];
  20712. if (mapping.generatedLine === needle.generatedLine) {
  20713. var source = util.getArg(mapping, 'source', null);
  20714. if (source !== null) {
  20715. source = this._sources.at(source);
  20716. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  20717. }
  20718. var name = util.getArg(mapping, 'name', null);
  20719. if (name !== null) {
  20720. name = this._names.at(name);
  20721. }
  20722. return {
  20723. source: source,
  20724. line: util.getArg(mapping, 'originalLine', null),
  20725. column: util.getArg(mapping, 'originalColumn', null),
  20726. name: name
  20727. };
  20728. }
  20729. }
  20730. return {
  20731. source: null,
  20732. line: null,
  20733. column: null,
  20734. name: null
  20735. };
  20736. };
  20737. /**
  20738. * Return true if we have the source content for every source in the source
  20739. * map, false otherwise.
  20740. */
  20741. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  20742. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  20743. if (!this.sourcesContent) {
  20744. return false;
  20745. }
  20746. return this.sourcesContent.length >= this._sources.size() &&
  20747. !this.sourcesContent.some(function (sc) { return sc == null; });
  20748. };
  20749. /**
  20750. * Returns the original source content. The only argument is the url of the
  20751. * original source file. Returns null if no original source content is
  20752. * available.
  20753. */
  20754. BasicSourceMapConsumer.prototype.sourceContentFor =
  20755. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20756. if (!this.sourcesContent) {
  20757. return null;
  20758. }
  20759. var index = this._findSourceIndex(aSource);
  20760. if (index >= 0) {
  20761. return this.sourcesContent[index];
  20762. }
  20763. var relativeSource = aSource;
  20764. if (this.sourceRoot != null) {
  20765. relativeSource = util.relative(this.sourceRoot, relativeSource);
  20766. }
  20767. var url;
  20768. if (this.sourceRoot != null
  20769. && (url = util.urlParse(this.sourceRoot))) {
  20770. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  20771. // many users. We can help them out when they expect file:// URIs to
  20772. // behave like it would if they were running a local HTTP server. See
  20773. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  20774. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  20775. if (url.scheme == "file"
  20776. && this._sources.has(fileUriAbsPath)) {
  20777. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  20778. }
  20779. if ((!url.path || url.path == "/")
  20780. && this._sources.has("/" + relativeSource)) {
  20781. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  20782. }
  20783. }
  20784. // This function is used recursively from
  20785. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  20786. // don't want to throw if we can't find the source - we just want to
  20787. // return null, so we provide a flag to exit gracefully.
  20788. if (nullOnMissing) {
  20789. return null;
  20790. }
  20791. else {
  20792. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  20793. }
  20794. };
  20795. /**
  20796. * Returns the generated line and column information for the original source,
  20797. * line, and column positions provided. The only argument is an object with
  20798. * the following properties:
  20799. *
  20800. * - source: The filename of the original source.
  20801. * - line: The line number in the original source. The line number
  20802. * is 1-based.
  20803. * - column: The column number in the original source. The column
  20804. * number is 0-based.
  20805. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20806. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20807. * closest element that is smaller than or greater than the one we are
  20808. * searching for, respectively, if the exact element cannot be found.
  20809. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20810. *
  20811. * and an object is returned with the following properties:
  20812. *
  20813. * - line: The line number in the generated source, or null. The
  20814. * line number is 1-based.
  20815. * - column: The column number in the generated source, or null.
  20816. * The column number is 0-based.
  20817. */
  20818. BasicSourceMapConsumer.prototype.generatedPositionFor =
  20819. function SourceMapConsumer_generatedPositionFor(aArgs) {
  20820. var source = util.getArg(aArgs, 'source');
  20821. source = this._findSourceIndex(source);
  20822. if (source < 0) {
  20823. return {
  20824. line: null,
  20825. column: null,
  20826. lastColumn: null
  20827. };
  20828. }
  20829. var needle = {
  20830. source: source,
  20831. originalLine: util.getArg(aArgs, 'line'),
  20832. originalColumn: util.getArg(aArgs, 'column')
  20833. };
  20834. var index = this._findMapping(
  20835. needle,
  20836. this._originalMappings,
  20837. "originalLine",
  20838. "originalColumn",
  20839. util.compareByOriginalPositions,
  20840. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  20841. );
  20842. if (index >= 0) {
  20843. var mapping = this._originalMappings[index];
  20844. if (mapping.source === needle.source) {
  20845. return {
  20846. line: util.getArg(mapping, 'generatedLine', null),
  20847. column: util.getArg(mapping, 'generatedColumn', null),
  20848. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  20849. };
  20850. }
  20851. }
  20852. return {
  20853. line: null,
  20854. column: null,
  20855. lastColumn: null
  20856. };
  20857. };
  20858. sourceMapConsumer$2.BasicSourceMapConsumer = BasicSourceMapConsumer;
  20859. /**
  20860. * An IndexedSourceMapConsumer instance represents a parsed source map which
  20861. * we can query for information. It differs from BasicSourceMapConsumer in
  20862. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  20863. * input.
  20864. *
  20865. * The first parameter is a raw source map (either as a JSON string, or already
  20866. * parsed to an object). According to the spec for indexed source maps, they
  20867. * have the following attributes:
  20868. *
  20869. * - version: Which version of the source map spec this map is following.
  20870. * - file: Optional. The generated file this source map is associated with.
  20871. * - sections: A list of section definitions.
  20872. *
  20873. * Each value under the "sections" field has two fields:
  20874. * - offset: The offset into the original specified at which this section
  20875. * begins to apply, defined as an object with a "line" and "column"
  20876. * field.
  20877. * - map: A source map definition. This source map could also be indexed,
  20878. * but doesn't have to be.
  20879. *
  20880. * Instead of the "map" field, it's also possible to have a "url" field
  20881. * specifying a URL to retrieve a source map from, but that's currently
  20882. * unsupported.
  20883. *
  20884. * Here's an example source map, taken from the source map spec[0], but
  20885. * modified to omit a section which uses the "url" field.
  20886. *
  20887. * {
  20888. * version : 3,
  20889. * file: "app.js",
  20890. * sections: [{
  20891. * offset: {line:100, column:10},
  20892. * map: {
  20893. * version : 3,
  20894. * file: "section.js",
  20895. * sources: ["foo.js", "bar.js"],
  20896. * names: ["src", "maps", "are", "fun"],
  20897. * mappings: "AAAA,E;;ABCDE;"
  20898. * }
  20899. * }],
  20900. * }
  20901. *
  20902. * The second parameter, if given, is a string whose value is the URL
  20903. * at which the source map was found. This URL is used to compute the
  20904. * sources array.
  20905. *
  20906. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  20907. */
  20908. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  20909. var sourceMap = aSourceMap;
  20910. if (typeof aSourceMap === 'string') {
  20911. sourceMap = util.parseSourceMapInput(aSourceMap);
  20912. }
  20913. var version = util.getArg(sourceMap, 'version');
  20914. var sections = util.getArg(sourceMap, 'sections');
  20915. if (version != this._version) {
  20916. throw new Error('Unsupported version: ' + version);
  20917. }
  20918. this._sources = new ArraySet();
  20919. this._names = new ArraySet();
  20920. var lastOffset = {
  20921. line: -1,
  20922. column: 0
  20923. };
  20924. this._sections = sections.map(function (s) {
  20925. if (s.url) {
  20926. // The url field will require support for asynchronicity.
  20927. // See https://github.com/mozilla/source-map/issues/16
  20928. throw new Error('Support for url field in sections not implemented.');
  20929. }
  20930. var offset = util.getArg(s, 'offset');
  20931. var offsetLine = util.getArg(offset, 'line');
  20932. var offsetColumn = util.getArg(offset, 'column');
  20933. if (offsetLine < lastOffset.line ||
  20934. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  20935. throw new Error('Section offsets must be ordered and non-overlapping.');
  20936. }
  20937. lastOffset = offset;
  20938. return {
  20939. generatedOffset: {
  20940. // The offset fields are 0-based, but we use 1-based indices when
  20941. // encoding/decoding from VLQ.
  20942. generatedLine: offsetLine + 1,
  20943. generatedColumn: offsetColumn + 1
  20944. },
  20945. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  20946. }
  20947. });
  20948. }
  20949. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  20950. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  20951. /**
  20952. * The version of the source mapping spec that we are consuming.
  20953. */
  20954. IndexedSourceMapConsumer.prototype._version = 3;
  20955. /**
  20956. * The list of original sources.
  20957. */
  20958. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  20959. get: function () {
  20960. var sources = [];
  20961. for (var i = 0; i < this._sections.length; i++) {
  20962. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  20963. sources.push(this._sections[i].consumer.sources[j]);
  20964. }
  20965. }
  20966. return sources;
  20967. }
  20968. });
  20969. /**
  20970. * Returns the original source, line, and column information for the generated
  20971. * source's line and column positions provided. The only argument is an object
  20972. * with the following properties:
  20973. *
  20974. * - line: The line number in the generated source. The line number
  20975. * is 1-based.
  20976. * - column: The column number in the generated source. The column
  20977. * number is 0-based.
  20978. *
  20979. * and an object is returned with the following properties:
  20980. *
  20981. * - source: The original source file, or null.
  20982. * - line: The line number in the original source, or null. The
  20983. * line number is 1-based.
  20984. * - column: The column number in the original source, or null. The
  20985. * column number is 0-based.
  20986. * - name: The original identifier, or null.
  20987. */
  20988. IndexedSourceMapConsumer.prototype.originalPositionFor =
  20989. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  20990. var needle = {
  20991. generatedLine: util.getArg(aArgs, 'line'),
  20992. generatedColumn: util.getArg(aArgs, 'column')
  20993. };
  20994. // Find the section containing the generated position we're trying to map
  20995. // to an original position.
  20996. var sectionIndex = binarySearch.search(needle, this._sections,
  20997. function(needle, section) {
  20998. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  20999. if (cmp) {
  21000. return cmp;
  21001. }
  21002. return (needle.generatedColumn -
  21003. section.generatedOffset.generatedColumn);
  21004. });
  21005. var section = this._sections[sectionIndex];
  21006. if (!section) {
  21007. return {
  21008. source: null,
  21009. line: null,
  21010. column: null,
  21011. name: null
  21012. };
  21013. }
  21014. return section.consumer.originalPositionFor({
  21015. line: needle.generatedLine -
  21016. (section.generatedOffset.generatedLine - 1),
  21017. column: needle.generatedColumn -
  21018. (section.generatedOffset.generatedLine === needle.generatedLine
  21019. ? section.generatedOffset.generatedColumn - 1
  21020. : 0),
  21021. bias: aArgs.bias
  21022. });
  21023. };
  21024. /**
  21025. * Return true if we have the source content for every source in the source
  21026. * map, false otherwise.
  21027. */
  21028. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  21029. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  21030. return this._sections.every(function (s) {
  21031. return s.consumer.hasContentsOfAllSources();
  21032. });
  21033. };
  21034. /**
  21035. * Returns the original source content. The only argument is the url of the
  21036. * original source file. Returns null if no original source content is
  21037. * available.
  21038. */
  21039. IndexedSourceMapConsumer.prototype.sourceContentFor =
  21040. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  21041. for (var i = 0; i < this._sections.length; i++) {
  21042. var section = this._sections[i];
  21043. var content = section.consumer.sourceContentFor(aSource, true);
  21044. if (content || content === '') {
  21045. return content;
  21046. }
  21047. }
  21048. if (nullOnMissing) {
  21049. return null;
  21050. }
  21051. else {
  21052. throw new Error('"' + aSource + '" is not in the SourceMap.');
  21053. }
  21054. };
  21055. /**
  21056. * Returns the generated line and column information for the original source,
  21057. * line, and column positions provided. The only argument is an object with
  21058. * the following properties:
  21059. *
  21060. * - source: The filename of the original source.
  21061. * - line: The line number in the original source. The line number
  21062. * is 1-based.
  21063. * - column: The column number in the original source. The column
  21064. * number is 0-based.
  21065. *
  21066. * and an object is returned with the following properties:
  21067. *
  21068. * - line: The line number in the generated source, or null. The
  21069. * line number is 1-based.
  21070. * - column: The column number in the generated source, or null.
  21071. * The column number is 0-based.
  21072. */
  21073. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  21074. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  21075. for (var i = 0; i < this._sections.length; i++) {
  21076. var section = this._sections[i];
  21077. // Only consider this section if the requested source is in the list of
  21078. // sources of the consumer.
  21079. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  21080. continue;
  21081. }
  21082. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  21083. if (generatedPosition) {
  21084. var ret = {
  21085. line: generatedPosition.line +
  21086. (section.generatedOffset.generatedLine - 1),
  21087. column: generatedPosition.column +
  21088. (section.generatedOffset.generatedLine === generatedPosition.line
  21089. ? section.generatedOffset.generatedColumn - 1
  21090. : 0)
  21091. };
  21092. return ret;
  21093. }
  21094. }
  21095. return {
  21096. line: null,
  21097. column: null
  21098. };
  21099. };
  21100. /**
  21101. * Parse the mappings in a string in to a data structure which we can easily
  21102. * query (the ordered arrays in the `this.__generatedMappings` and
  21103. * `this.__originalMappings` properties).
  21104. */
  21105. IndexedSourceMapConsumer.prototype._parseMappings =
  21106. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  21107. this.__generatedMappings = [];
  21108. this.__originalMappings = [];
  21109. for (var i = 0; i < this._sections.length; i++) {
  21110. var section = this._sections[i];
  21111. var sectionMappings = section.consumer._generatedMappings;
  21112. for (var j = 0; j < sectionMappings.length; j++) {
  21113. var mapping = sectionMappings[j];
  21114. var source = section.consumer._sources.at(mapping.source);
  21115. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  21116. this._sources.add(source);
  21117. source = this._sources.indexOf(source);
  21118. var name = null;
  21119. if (mapping.name) {
  21120. name = section.consumer._names.at(mapping.name);
  21121. this._names.add(name);
  21122. name = this._names.indexOf(name);
  21123. }
  21124. // The mappings coming from the consumer for the section have
  21125. // generated positions relative to the start of the section, so we
  21126. // need to offset them to be relative to the start of the concatenated
  21127. // generated file.
  21128. var adjustedMapping = {
  21129. source: source,
  21130. generatedLine: mapping.generatedLine +
  21131. (section.generatedOffset.generatedLine - 1),
  21132. generatedColumn: mapping.generatedColumn +
  21133. (section.generatedOffset.generatedLine === mapping.generatedLine
  21134. ? section.generatedOffset.generatedColumn - 1
  21135. : 0),
  21136. originalLine: mapping.originalLine,
  21137. originalColumn: mapping.originalColumn,
  21138. name: name
  21139. };
  21140. this.__generatedMappings.push(adjustedMapping);
  21141. if (typeof adjustedMapping.originalLine === 'number') {
  21142. this.__originalMappings.push(adjustedMapping);
  21143. }
  21144. }
  21145. }
  21146. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  21147. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  21148. };
  21149. sourceMapConsumer$2.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  21150. return sourceMapConsumer$2;
  21151. }
  21152. var sourceNode$2 = {};
  21153. /* -*- Mode: js; js-indent-level: 2; -*- */
  21154. var hasRequiredSourceNode$2;
  21155. function requireSourceNode$2 () {
  21156. if (hasRequiredSourceNode$2) return sourceNode$2;
  21157. hasRequiredSourceNode$2 = 1;
  21158. /*
  21159. * Copyright 2011 Mozilla Foundation and contributors
  21160. * Licensed under the New BSD license. See LICENSE or:
  21161. * http://opensource.org/licenses/BSD-3-Clause
  21162. */
  21163. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$2().SourceMapGenerator;
  21164. var util = /*@__PURE__*/ requireUtil$3();
  21165. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  21166. // operating systems these days (capturing the result).
  21167. var REGEX_NEWLINE = /(\r?\n)/;
  21168. // Newline character code for charCodeAt() comparisons
  21169. var NEWLINE_CODE = 10;
  21170. // Private symbol for identifying `SourceNode`s when multiple versions of
  21171. // the source-map library are loaded. This MUST NOT CHANGE across
  21172. // versions!
  21173. var isSourceNode = "$$$isSourceNode$$$";
  21174. /**
  21175. * SourceNodes provide a way to abstract over interpolating/concatenating
  21176. * snippets of generated JavaScript source code while maintaining the line and
  21177. * column information associated with the original source code.
  21178. *
  21179. * @param aLine The original line number.
  21180. * @param aColumn The original column number.
  21181. * @param aSource The original source's filename.
  21182. * @param aChunks Optional. An array of strings which are snippets of
  21183. * generated JS, or other SourceNodes.
  21184. * @param aName The original identifier.
  21185. */
  21186. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  21187. this.children = [];
  21188. this.sourceContents = {};
  21189. this.line = aLine == null ? null : aLine;
  21190. this.column = aColumn == null ? null : aColumn;
  21191. this.source = aSource == null ? null : aSource;
  21192. this.name = aName == null ? null : aName;
  21193. this[isSourceNode] = true;
  21194. if (aChunks != null) this.add(aChunks);
  21195. }
  21196. /**
  21197. * Creates a SourceNode from generated code and a SourceMapConsumer.
  21198. *
  21199. * @param aGeneratedCode The generated code
  21200. * @param aSourceMapConsumer The SourceMap for the generated code
  21201. * @param aRelativePath Optional. The path that relative sources in the
  21202. * SourceMapConsumer should be relative to.
  21203. */
  21204. SourceNode.fromStringWithSourceMap =
  21205. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  21206. // The SourceNode we want to fill with the generated code
  21207. // and the SourceMap
  21208. var node = new SourceNode();
  21209. // All even indices of this array are one line of the generated code,
  21210. // while all odd indices are the newlines between two adjacent lines
  21211. // (since `REGEX_NEWLINE` captures its match).
  21212. // Processed fragments are accessed by calling `shiftNextLine`.
  21213. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  21214. var remainingLinesIndex = 0;
  21215. var shiftNextLine = function() {
  21216. var lineContents = getNextLine();
  21217. // The last line of a file might not have a newline.
  21218. var newLine = getNextLine() || "";
  21219. return lineContents + newLine;
  21220. function getNextLine() {
  21221. return remainingLinesIndex < remainingLines.length ?
  21222. remainingLines[remainingLinesIndex++] : undefined;
  21223. }
  21224. };
  21225. // We need to remember the position of "remainingLines"
  21226. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  21227. // The generate SourceNodes we need a code range.
  21228. // To extract it current and last mapping is used.
  21229. // Here we store the last mapping.
  21230. var lastMapping = null;
  21231. aSourceMapConsumer.eachMapping(function (mapping) {
  21232. if (lastMapping !== null) {
  21233. // We add the code from "lastMapping" to "mapping":
  21234. // First check if there is a new line in between.
  21235. if (lastGeneratedLine < mapping.generatedLine) {
  21236. // Associate first line with "lastMapping"
  21237. addMappingWithCode(lastMapping, shiftNextLine());
  21238. lastGeneratedLine++;
  21239. lastGeneratedColumn = 0;
  21240. // The remaining code is added without mapping
  21241. } else {
  21242. // There is no new line in between.
  21243. // Associate the code between "lastGeneratedColumn" and
  21244. // "mapping.generatedColumn" with "lastMapping"
  21245. var nextLine = remainingLines[remainingLinesIndex] || '';
  21246. var code = nextLine.substr(0, mapping.generatedColumn -
  21247. lastGeneratedColumn);
  21248. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  21249. lastGeneratedColumn);
  21250. lastGeneratedColumn = mapping.generatedColumn;
  21251. addMappingWithCode(lastMapping, code);
  21252. // No more remaining code, continue
  21253. lastMapping = mapping;
  21254. return;
  21255. }
  21256. }
  21257. // We add the generated code until the first mapping
  21258. // to the SourceNode without any mapping.
  21259. // Each line is added as separate string.
  21260. while (lastGeneratedLine < mapping.generatedLine) {
  21261. node.add(shiftNextLine());
  21262. lastGeneratedLine++;
  21263. }
  21264. if (lastGeneratedColumn < mapping.generatedColumn) {
  21265. var nextLine = remainingLines[remainingLinesIndex] || '';
  21266. node.add(nextLine.substr(0, mapping.generatedColumn));
  21267. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  21268. lastGeneratedColumn = mapping.generatedColumn;
  21269. }
  21270. lastMapping = mapping;
  21271. }, this);
  21272. // We have processed all mappings.
  21273. if (remainingLinesIndex < remainingLines.length) {
  21274. if (lastMapping) {
  21275. // Associate the remaining code in the current line with "lastMapping"
  21276. addMappingWithCode(lastMapping, shiftNextLine());
  21277. }
  21278. // and add the remaining lines without any mapping
  21279. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  21280. }
  21281. // Copy sourcesContent into SourceNode
  21282. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  21283. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  21284. if (content != null) {
  21285. if (aRelativePath != null) {
  21286. sourceFile = util.join(aRelativePath, sourceFile);
  21287. }
  21288. node.setSourceContent(sourceFile, content);
  21289. }
  21290. });
  21291. return node;
  21292. function addMappingWithCode(mapping, code) {
  21293. if (mapping === null || mapping.source === undefined) {
  21294. node.add(code);
  21295. } else {
  21296. var source = aRelativePath
  21297. ? util.join(aRelativePath, mapping.source)
  21298. : mapping.source;
  21299. node.add(new SourceNode(mapping.originalLine,
  21300. mapping.originalColumn,
  21301. source,
  21302. code,
  21303. mapping.name));
  21304. }
  21305. }
  21306. };
  21307. /**
  21308. * Add a chunk of generated JS to this source node.
  21309. *
  21310. * @param aChunk A string snippet of generated JS code, another instance of
  21311. * SourceNode, or an array where each member is one of those things.
  21312. */
  21313. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  21314. if (Array.isArray(aChunk)) {
  21315. aChunk.forEach(function (chunk) {
  21316. this.add(chunk);
  21317. }, this);
  21318. }
  21319. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  21320. if (aChunk) {
  21321. this.children.push(aChunk);
  21322. }
  21323. }
  21324. else {
  21325. throw new TypeError(
  21326. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21327. );
  21328. }
  21329. return this;
  21330. };
  21331. /**
  21332. * Add a chunk of generated JS to the beginning of this source node.
  21333. *
  21334. * @param aChunk A string snippet of generated JS code, another instance of
  21335. * SourceNode, or an array where each member is one of those things.
  21336. */
  21337. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  21338. if (Array.isArray(aChunk)) {
  21339. for (var i = aChunk.length-1; i >= 0; i--) {
  21340. this.prepend(aChunk[i]);
  21341. }
  21342. }
  21343. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  21344. this.children.unshift(aChunk);
  21345. }
  21346. else {
  21347. throw new TypeError(
  21348. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21349. );
  21350. }
  21351. return this;
  21352. };
  21353. /**
  21354. * Walk over the tree of JS snippets in this node and its children. The
  21355. * walking function is called once for each snippet of JS and is passed that
  21356. * snippet and the its original associated source's line/column location.
  21357. *
  21358. * @param aFn The traversal function.
  21359. */
  21360. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  21361. var chunk;
  21362. for (var i = 0, len = this.children.length; i < len; i++) {
  21363. chunk = this.children[i];
  21364. if (chunk[isSourceNode]) {
  21365. chunk.walk(aFn);
  21366. }
  21367. else {
  21368. if (chunk !== '') {
  21369. aFn(chunk, { source: this.source,
  21370. line: this.line,
  21371. column: this.column,
  21372. name: this.name });
  21373. }
  21374. }
  21375. }
  21376. };
  21377. /**
  21378. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  21379. * each of `this.children`.
  21380. *
  21381. * @param aSep The separator.
  21382. */
  21383. SourceNode.prototype.join = function SourceNode_join(aSep) {
  21384. var newChildren;
  21385. var i;
  21386. var len = this.children.length;
  21387. if (len > 0) {
  21388. newChildren = [];
  21389. for (i = 0; i < len-1; i++) {
  21390. newChildren.push(this.children[i]);
  21391. newChildren.push(aSep);
  21392. }
  21393. newChildren.push(this.children[i]);
  21394. this.children = newChildren;
  21395. }
  21396. return this;
  21397. };
  21398. /**
  21399. * Call String.prototype.replace on the very right-most source snippet. Useful
  21400. * for trimming whitespace from the end of a source node, etc.
  21401. *
  21402. * @param aPattern The pattern to replace.
  21403. * @param aReplacement The thing to replace the pattern with.
  21404. */
  21405. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  21406. var lastChild = this.children[this.children.length - 1];
  21407. if (lastChild[isSourceNode]) {
  21408. lastChild.replaceRight(aPattern, aReplacement);
  21409. }
  21410. else if (typeof lastChild === 'string') {
  21411. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  21412. }
  21413. else {
  21414. this.children.push(''.replace(aPattern, aReplacement));
  21415. }
  21416. return this;
  21417. };
  21418. /**
  21419. * Set the source content for a source file. This will be added to the SourceMapGenerator
  21420. * in the sourcesContent field.
  21421. *
  21422. * @param aSourceFile The filename of the source file
  21423. * @param aSourceContent The content of the source file
  21424. */
  21425. SourceNode.prototype.setSourceContent =
  21426. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  21427. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  21428. };
  21429. /**
  21430. * Walk over the tree of SourceNodes. The walking function is called for each
  21431. * source file content and is passed the filename and source content.
  21432. *
  21433. * @param aFn The traversal function.
  21434. */
  21435. SourceNode.prototype.walkSourceContents =
  21436. function SourceNode_walkSourceContents(aFn) {
  21437. for (var i = 0, len = this.children.length; i < len; i++) {
  21438. if (this.children[i][isSourceNode]) {
  21439. this.children[i].walkSourceContents(aFn);
  21440. }
  21441. }
  21442. var sources = Object.keys(this.sourceContents);
  21443. for (var i = 0, len = sources.length; i < len; i++) {
  21444. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  21445. }
  21446. };
  21447. /**
  21448. * Return the string representation of this source node. Walks over the tree
  21449. * and concatenates all the various snippets together to one string.
  21450. */
  21451. SourceNode.prototype.toString = function SourceNode_toString() {
  21452. var str = "";
  21453. this.walk(function (chunk) {
  21454. str += chunk;
  21455. });
  21456. return str;
  21457. };
  21458. /**
  21459. * Returns the string representation of this source node along with a source
  21460. * map.
  21461. */
  21462. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  21463. var generated = {
  21464. code: "",
  21465. line: 1,
  21466. column: 0
  21467. };
  21468. var map = new SourceMapGenerator(aArgs);
  21469. var sourceMappingActive = false;
  21470. var lastOriginalSource = null;
  21471. var lastOriginalLine = null;
  21472. var lastOriginalColumn = null;
  21473. var lastOriginalName = null;
  21474. this.walk(function (chunk, original) {
  21475. generated.code += chunk;
  21476. if (original.source !== null
  21477. && original.line !== null
  21478. && original.column !== null) {
  21479. if(lastOriginalSource !== original.source
  21480. || lastOriginalLine !== original.line
  21481. || lastOriginalColumn !== original.column
  21482. || lastOriginalName !== original.name) {
  21483. map.addMapping({
  21484. source: original.source,
  21485. original: {
  21486. line: original.line,
  21487. column: original.column
  21488. },
  21489. generated: {
  21490. line: generated.line,
  21491. column: generated.column
  21492. },
  21493. name: original.name
  21494. });
  21495. }
  21496. lastOriginalSource = original.source;
  21497. lastOriginalLine = original.line;
  21498. lastOriginalColumn = original.column;
  21499. lastOriginalName = original.name;
  21500. sourceMappingActive = true;
  21501. } else if (sourceMappingActive) {
  21502. map.addMapping({
  21503. generated: {
  21504. line: generated.line,
  21505. column: generated.column
  21506. }
  21507. });
  21508. lastOriginalSource = null;
  21509. sourceMappingActive = false;
  21510. }
  21511. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  21512. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  21513. generated.line++;
  21514. generated.column = 0;
  21515. // Mappings end at eol
  21516. if (idx + 1 === length) {
  21517. lastOriginalSource = null;
  21518. sourceMappingActive = false;
  21519. } else if (sourceMappingActive) {
  21520. map.addMapping({
  21521. source: original.source,
  21522. original: {
  21523. line: original.line,
  21524. column: original.column
  21525. },
  21526. generated: {
  21527. line: generated.line,
  21528. column: generated.column
  21529. },
  21530. name: original.name
  21531. });
  21532. }
  21533. } else {
  21534. generated.column++;
  21535. }
  21536. }
  21537. });
  21538. this.walkSourceContents(function (sourceFile, sourceContent) {
  21539. map.setSourceContent(sourceFile, sourceContent);
  21540. });
  21541. return { code: generated.code, map: map };
  21542. };
  21543. sourceNode$2.SourceNode = SourceNode;
  21544. return sourceNode$2;
  21545. }
  21546. /*
  21547. * Copyright 2009-2011 Mozilla Foundation and contributors
  21548. * Licensed under the New BSD license. See LICENSE.txt or:
  21549. * http://opensource.org/licenses/BSD-3-Clause
  21550. */
  21551. var hasRequiredSourceMap$2;
  21552. function requireSourceMap$2 () {
  21553. if (hasRequiredSourceMap$2) return sourceMap$2;
  21554. hasRequiredSourceMap$2 = 1;
  21555. sourceMap$2.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$2().SourceMapGenerator;
  21556. sourceMap$2.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer$2().SourceMapConsumer;
  21557. sourceMap$2.SourceNode = /*@__PURE__*/ requireSourceNode$2().SourceNode;
  21558. return sourceMap$2;
  21559. }
  21560. var sourceMapExports = /*@__PURE__*/ requireSourceMap$2();
  21561. const PURE_ANNOTATION = `/*@__PURE__*/`;
  21562. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  21563. function createCodegenContext(ast, {
  21564. mode = "function",
  21565. prefixIdentifiers = mode === "module",
  21566. sourceMap = false,
  21567. filename = `template.vue.html`,
  21568. scopeId = null,
  21569. optimizeImports = false,
  21570. runtimeGlobalName = `Vue`,
  21571. runtimeModuleName = `vue`,
  21572. ssrRuntimeModuleName = "vue/server-renderer",
  21573. ssr = false,
  21574. isTS = false,
  21575. inSSR = false
  21576. }) {
  21577. const context = {
  21578. mode,
  21579. prefixIdentifiers,
  21580. sourceMap,
  21581. filename,
  21582. scopeId,
  21583. optimizeImports,
  21584. runtimeGlobalName,
  21585. runtimeModuleName,
  21586. ssrRuntimeModuleName,
  21587. ssr,
  21588. isTS,
  21589. inSSR,
  21590. source: ast.source,
  21591. code: ``,
  21592. column: 1,
  21593. line: 1,
  21594. offset: 0,
  21595. indentLevel: 0,
  21596. pure: false,
  21597. map: void 0,
  21598. helper(key) {
  21599. return `_${helperNameMap[key]}`;
  21600. },
  21601. push(code, newlineIndex = -2 /* None */, node) {
  21602. context.code += code;
  21603. if (context.map) {
  21604. if (node) {
  21605. let name;
  21606. if (node.type === 4 && !node.isStatic) {
  21607. const content = node.content.replace(/^_ctx\./, "");
  21608. if (content !== node.content && isSimpleIdentifier(content)) {
  21609. name = content;
  21610. }
  21611. }
  21612. addMapping(node.loc.start, name);
  21613. }
  21614. if (newlineIndex === -3 /* Unknown */) {
  21615. advancePositionWithMutation(context, code);
  21616. } else {
  21617. context.offset += code.length;
  21618. if (newlineIndex === -2 /* None */) {
  21619. context.column += code.length;
  21620. } else {
  21621. if (newlineIndex === -1 /* End */) {
  21622. newlineIndex = code.length - 1;
  21623. }
  21624. context.line++;
  21625. context.column = code.length - newlineIndex;
  21626. }
  21627. }
  21628. if (node && node.loc !== locStub) {
  21629. addMapping(node.loc.end);
  21630. }
  21631. }
  21632. },
  21633. indent() {
  21634. newline(++context.indentLevel);
  21635. },
  21636. deindent(withoutNewLine = false) {
  21637. if (withoutNewLine) {
  21638. --context.indentLevel;
  21639. } else {
  21640. newline(--context.indentLevel);
  21641. }
  21642. },
  21643. newline() {
  21644. newline(context.indentLevel);
  21645. }
  21646. };
  21647. function newline(n) {
  21648. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  21649. }
  21650. function addMapping(loc, name = null) {
  21651. const { _names, _mappings } = context.map;
  21652. if (name !== null && !_names.has(name)) _names.add(name);
  21653. _mappings.add({
  21654. originalLine: loc.line,
  21655. originalColumn: loc.column - 1,
  21656. // source-map column is 0 based
  21657. generatedLine: context.line,
  21658. generatedColumn: context.column - 1,
  21659. source: filename,
  21660. name
  21661. });
  21662. }
  21663. if (sourceMap) {
  21664. context.map = new sourceMapExports.SourceMapGenerator();
  21665. context.map.setSourceContent(filename, context.source);
  21666. context.map._sources.add(filename);
  21667. }
  21668. return context;
  21669. }
  21670. function generate(ast, options = {}) {
  21671. const context = createCodegenContext(ast, options);
  21672. if (options.onContextCreated) options.onContextCreated(context);
  21673. const {
  21674. mode,
  21675. push,
  21676. prefixIdentifiers,
  21677. indent,
  21678. deindent,
  21679. newline,
  21680. scopeId,
  21681. ssr
  21682. } = context;
  21683. const helpers = Array.from(ast.helpers);
  21684. const hasHelpers = helpers.length > 0;
  21685. const useWithBlock = !prefixIdentifiers && mode !== "module";
  21686. const genScopeId = scopeId != null && mode === "module";
  21687. const isSetupInlined = !!options.inline;
  21688. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  21689. if (mode === "module") {
  21690. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  21691. } else {
  21692. genFunctionPreamble(ast, preambleContext);
  21693. }
  21694. const functionName = ssr ? `ssrRender` : `render`;
  21695. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  21696. if (options.bindingMetadata && !options.inline) {
  21697. args.push("$props", "$setup", "$data", "$options");
  21698. }
  21699. const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
  21700. if (isSetupInlined) {
  21701. push(`(${signature}) => {`);
  21702. } else {
  21703. push(`function ${functionName}(${signature}) {`);
  21704. }
  21705. indent();
  21706. if (useWithBlock) {
  21707. push(`with (_ctx) {`);
  21708. indent();
  21709. if (hasHelpers) {
  21710. push(
  21711. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  21712. `,
  21713. -1 /* End */
  21714. );
  21715. newline();
  21716. }
  21717. }
  21718. if (ast.components.length) {
  21719. genAssets(ast.components, "component", context);
  21720. if (ast.directives.length || ast.temps > 0) {
  21721. newline();
  21722. }
  21723. }
  21724. if (ast.directives.length) {
  21725. genAssets(ast.directives, "directive", context);
  21726. if (ast.temps > 0) {
  21727. newline();
  21728. }
  21729. }
  21730. if (ast.temps > 0) {
  21731. push(`let `);
  21732. for (let i = 0; i < ast.temps; i++) {
  21733. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  21734. }
  21735. }
  21736. if (ast.components.length || ast.directives.length || ast.temps) {
  21737. push(`
  21738. `, 0 /* Start */);
  21739. newline();
  21740. }
  21741. if (!ssr) {
  21742. push(`return `);
  21743. }
  21744. if (ast.codegenNode) {
  21745. genNode(ast.codegenNode, context);
  21746. } else {
  21747. push(`null`);
  21748. }
  21749. if (useWithBlock) {
  21750. deindent();
  21751. push(`}`);
  21752. }
  21753. deindent();
  21754. push(`}`);
  21755. return {
  21756. ast,
  21757. code: context.code,
  21758. preamble: isSetupInlined ? preambleContext.code : ``,
  21759. map: context.map ? context.map.toJSON() : void 0
  21760. };
  21761. }
  21762. function genFunctionPreamble(ast, context) {
  21763. const {
  21764. ssr,
  21765. prefixIdentifiers,
  21766. push,
  21767. newline,
  21768. runtimeModuleName,
  21769. runtimeGlobalName,
  21770. ssrRuntimeModuleName
  21771. } = context;
  21772. const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
  21773. const helpers = Array.from(ast.helpers);
  21774. if (helpers.length > 0) {
  21775. if (prefixIdentifiers) {
  21776. push(
  21777. `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
  21778. `,
  21779. -1 /* End */
  21780. );
  21781. } else {
  21782. push(`const _Vue = ${VueBinding}
  21783. `, -1 /* End */);
  21784. if (ast.hoists.length) {
  21785. const staticHelpers = [
  21786. CREATE_VNODE,
  21787. CREATE_ELEMENT_VNODE,
  21788. CREATE_COMMENT,
  21789. CREATE_TEXT,
  21790. CREATE_STATIC
  21791. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  21792. push(`const { ${staticHelpers} } = _Vue
  21793. `, -1 /* End */);
  21794. }
  21795. }
  21796. }
  21797. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21798. push(
  21799. `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
  21800. `,
  21801. -1 /* End */
  21802. );
  21803. }
  21804. genHoists(ast.hoists, context);
  21805. newline();
  21806. push(`return `);
  21807. }
  21808. function genModulePreamble(ast, context, genScopeId, inline) {
  21809. const {
  21810. push,
  21811. newline,
  21812. optimizeImports,
  21813. runtimeModuleName,
  21814. ssrRuntimeModuleName
  21815. } = context;
  21816. if (ast.helpers.size) {
  21817. const helpers = Array.from(ast.helpers);
  21818. if (optimizeImports) {
  21819. push(
  21820. `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21821. `,
  21822. -1 /* End */
  21823. );
  21824. push(
  21825. `
  21826. // Binding optimization for webpack code-split
  21827. const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
  21828. `,
  21829. -1 /* End */
  21830. );
  21831. } else {
  21832. push(
  21833. `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21834. `,
  21835. -1 /* End */
  21836. );
  21837. }
  21838. }
  21839. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21840. push(
  21841. `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
  21842. `,
  21843. -1 /* End */
  21844. );
  21845. }
  21846. if (ast.imports.length) {
  21847. genImports(ast.imports, context);
  21848. newline();
  21849. }
  21850. genHoists(ast.hoists, context);
  21851. newline();
  21852. if (!inline) {
  21853. push(`export `);
  21854. }
  21855. }
  21856. function genAssets(assets, type, { helper, push, newline, isTS }) {
  21857. const resolver = helper(
  21858. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  21859. );
  21860. for (let i = 0; i < assets.length; i++) {
  21861. let id = assets[i];
  21862. const maybeSelfReference = id.endsWith("__self");
  21863. if (maybeSelfReference) {
  21864. id = id.slice(0, -6);
  21865. }
  21866. push(
  21867. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  21868. );
  21869. if (i < assets.length - 1) {
  21870. newline();
  21871. }
  21872. }
  21873. }
  21874. function genHoists(hoists, context) {
  21875. if (!hoists.length) {
  21876. return;
  21877. }
  21878. context.pure = true;
  21879. const { push, newline } = context;
  21880. newline();
  21881. for (let i = 0; i < hoists.length; i++) {
  21882. const exp = hoists[i];
  21883. if (exp) {
  21884. push(`const _hoisted_${i + 1} = `);
  21885. genNode(exp, context);
  21886. newline();
  21887. }
  21888. }
  21889. context.pure = false;
  21890. }
  21891. function genImports(importsOptions, context) {
  21892. if (!importsOptions.length) {
  21893. return;
  21894. }
  21895. importsOptions.forEach((imports) => {
  21896. context.push(`import `);
  21897. genNode(imports.exp, context);
  21898. context.push(` from '${imports.path}'`);
  21899. context.newline();
  21900. });
  21901. }
  21902. function isText(n) {
  21903. return isString$1(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  21904. }
  21905. function genNodeListAsArray(nodes, context) {
  21906. const multilines = nodes.length > 3 || nodes.some((n) => isArray$3(n) || !isText(n));
  21907. context.push(`[`);
  21908. multilines && context.indent();
  21909. genNodeList(nodes, context, multilines);
  21910. multilines && context.deindent();
  21911. context.push(`]`);
  21912. }
  21913. function genNodeList(nodes, context, multilines = false, comma = true) {
  21914. const { push, newline } = context;
  21915. for (let i = 0; i < nodes.length; i++) {
  21916. const node = nodes[i];
  21917. if (isString$1(node)) {
  21918. push(node, -3 /* Unknown */);
  21919. } else if (isArray$3(node)) {
  21920. genNodeListAsArray(node, context);
  21921. } else {
  21922. genNode(node, context);
  21923. }
  21924. if (i < nodes.length - 1) {
  21925. if (multilines) {
  21926. comma && push(",");
  21927. newline();
  21928. } else {
  21929. comma && push(", ");
  21930. }
  21931. }
  21932. }
  21933. }
  21934. function genNode(node, context) {
  21935. if (isString$1(node)) {
  21936. context.push(node, -3 /* Unknown */);
  21937. return;
  21938. }
  21939. if (isSymbol$1(node)) {
  21940. context.push(context.helper(node));
  21941. return;
  21942. }
  21943. switch (node.type) {
  21944. case 1:
  21945. case 9:
  21946. case 11:
  21947. assert(
  21948. node.codegenNode != null,
  21949. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  21950. );
  21951. genNode(node.codegenNode, context);
  21952. break;
  21953. case 2:
  21954. genText(node, context);
  21955. break;
  21956. case 4:
  21957. genExpression(node, context);
  21958. break;
  21959. case 5:
  21960. genInterpolation(node, context);
  21961. break;
  21962. case 12:
  21963. genNode(node.codegenNode, context);
  21964. break;
  21965. case 8:
  21966. genCompoundExpression(node, context);
  21967. break;
  21968. case 3:
  21969. genComment(node, context);
  21970. break;
  21971. case 13:
  21972. genVNodeCall(node, context);
  21973. break;
  21974. case 14:
  21975. genCallExpression(node, context);
  21976. break;
  21977. case 15:
  21978. genObjectExpression(node, context);
  21979. break;
  21980. case 17:
  21981. genArrayExpression(node, context);
  21982. break;
  21983. case 18:
  21984. genFunctionExpression(node, context);
  21985. break;
  21986. case 19:
  21987. genConditionalExpression(node, context);
  21988. break;
  21989. case 20:
  21990. genCacheExpression(node, context);
  21991. break;
  21992. case 21:
  21993. genNodeList(node.body, context, true, false);
  21994. break;
  21995. // SSR only types
  21996. case 22:
  21997. genTemplateLiteral(node, context);
  21998. break;
  21999. case 23:
  22000. genIfStatement(node, context);
  22001. break;
  22002. case 24:
  22003. genAssignmentExpression(node, context);
  22004. break;
  22005. case 25:
  22006. genSequenceExpression(node, context);
  22007. break;
  22008. case 26:
  22009. genReturnStatement(node, context);
  22010. break;
  22011. /* v8 ignore start */
  22012. case 10:
  22013. break;
  22014. default:
  22015. {
  22016. assert(false, `unhandled codegen node type: ${node.type}`);
  22017. const exhaustiveCheck = node;
  22018. return exhaustiveCheck;
  22019. }
  22020. }
  22021. }
  22022. function genText(node, context) {
  22023. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  22024. }
  22025. function genExpression(node, context) {
  22026. const { content, isStatic } = node;
  22027. context.push(
  22028. isStatic ? JSON.stringify(content) : content,
  22029. -3 /* Unknown */,
  22030. node
  22031. );
  22032. }
  22033. function genInterpolation(node, context) {
  22034. const { push, helper, pure } = context;
  22035. if (pure) push(PURE_ANNOTATION);
  22036. push(`${helper(TO_DISPLAY_STRING)}(`);
  22037. genNode(node.content, context);
  22038. push(`)`);
  22039. }
  22040. function genCompoundExpression(node, context) {
  22041. for (let i = 0; i < node.children.length; i++) {
  22042. const child = node.children[i];
  22043. if (isString$1(child)) {
  22044. context.push(child, -3 /* Unknown */);
  22045. } else {
  22046. genNode(child, context);
  22047. }
  22048. }
  22049. }
  22050. function genExpressionAsPropertyKey(node, context) {
  22051. const { push } = context;
  22052. if (node.type === 8) {
  22053. push(`[`);
  22054. genCompoundExpression(node, context);
  22055. push(`]`);
  22056. } else if (node.isStatic) {
  22057. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  22058. push(text, -2 /* None */, node);
  22059. } else {
  22060. push(`[${node.content}]`, -3 /* Unknown */, node);
  22061. }
  22062. }
  22063. function genComment(node, context) {
  22064. const { push, helper, pure } = context;
  22065. if (pure) {
  22066. push(PURE_ANNOTATION);
  22067. }
  22068. push(
  22069. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  22070. -3 /* Unknown */,
  22071. node
  22072. );
  22073. }
  22074. function genVNodeCall(node, context) {
  22075. const { push, helper, pure } = context;
  22076. const {
  22077. tag,
  22078. props,
  22079. children,
  22080. patchFlag,
  22081. dynamicProps,
  22082. directives,
  22083. isBlock,
  22084. disableTracking,
  22085. isComponent
  22086. } = node;
  22087. let patchFlagString;
  22088. if (patchFlag) {
  22089. {
  22090. if (patchFlag < 0) {
  22091. patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  22092. } else {
  22093. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  22094. patchFlagString = patchFlag + ` /* ${flagNames} */`;
  22095. }
  22096. }
  22097. }
  22098. if (directives) {
  22099. push(helper(WITH_DIRECTIVES) + `(`);
  22100. }
  22101. if (isBlock) {
  22102. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  22103. }
  22104. if (pure) {
  22105. push(PURE_ANNOTATION);
  22106. }
  22107. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  22108. push(helper(callHelper) + `(`, -2 /* None */, node);
  22109. genNodeList(
  22110. genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
  22111. context
  22112. );
  22113. push(`)`);
  22114. if (isBlock) {
  22115. push(`)`);
  22116. }
  22117. if (directives) {
  22118. push(`, `);
  22119. genNode(directives, context);
  22120. push(`)`);
  22121. }
  22122. }
  22123. function genNullableArgs(args) {
  22124. let i = args.length;
  22125. while (i--) {
  22126. if (args[i] != null) break;
  22127. }
  22128. return args.slice(0, i + 1).map((arg) => arg || `null`);
  22129. }
  22130. function genCallExpression(node, context) {
  22131. const { push, helper, pure } = context;
  22132. const callee = isString$1(node.callee) ? node.callee : helper(node.callee);
  22133. if (pure) {
  22134. push(PURE_ANNOTATION);
  22135. }
  22136. push(callee + `(`, -2 /* None */, node);
  22137. genNodeList(node.arguments, context);
  22138. push(`)`);
  22139. }
  22140. function genObjectExpression(node, context) {
  22141. const { push, indent, deindent, newline } = context;
  22142. const { properties } = node;
  22143. if (!properties.length) {
  22144. push(`{}`, -2 /* None */, node);
  22145. return;
  22146. }
  22147. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  22148. push(multilines ? `{` : `{ `);
  22149. multilines && indent();
  22150. for (let i = 0; i < properties.length; i++) {
  22151. const { key, value } = properties[i];
  22152. genExpressionAsPropertyKey(key, context);
  22153. push(`: `);
  22154. genNode(value, context);
  22155. if (i < properties.length - 1) {
  22156. push(`,`);
  22157. newline();
  22158. }
  22159. }
  22160. multilines && deindent();
  22161. push(multilines ? `}` : ` }`);
  22162. }
  22163. function genArrayExpression(node, context) {
  22164. genNodeListAsArray(node.elements, context);
  22165. }
  22166. function genFunctionExpression(node, context) {
  22167. const { push, indent, deindent } = context;
  22168. const { params, returns, body, newline, isSlot } = node;
  22169. if (isSlot) {
  22170. push(`_${helperNameMap[WITH_CTX]}(`);
  22171. }
  22172. push(`(`, -2 /* None */, node);
  22173. if (isArray$3(params)) {
  22174. genNodeList(params, context);
  22175. } else if (params) {
  22176. genNode(params, context);
  22177. }
  22178. push(`) => `);
  22179. if (newline || body) {
  22180. push(`{`);
  22181. indent();
  22182. }
  22183. if (returns) {
  22184. if (newline) {
  22185. push(`return `);
  22186. }
  22187. if (isArray$3(returns)) {
  22188. genNodeListAsArray(returns, context);
  22189. } else {
  22190. genNode(returns, context);
  22191. }
  22192. } else if (body) {
  22193. genNode(body, context);
  22194. }
  22195. if (newline || body) {
  22196. deindent();
  22197. push(`}`);
  22198. }
  22199. if (isSlot) {
  22200. push(`)`);
  22201. }
  22202. }
  22203. function genConditionalExpression(node, context) {
  22204. const { test, consequent, alternate, newline: needNewline } = node;
  22205. const { push, indent, deindent, newline } = context;
  22206. if (test.type === 4) {
  22207. const needsParens = !isSimpleIdentifier(test.content);
  22208. needsParens && push(`(`);
  22209. genExpression(test, context);
  22210. needsParens && push(`)`);
  22211. } else {
  22212. push(`(`);
  22213. genNode(test, context);
  22214. push(`)`);
  22215. }
  22216. needNewline && indent();
  22217. context.indentLevel++;
  22218. needNewline || push(` `);
  22219. push(`? `);
  22220. genNode(consequent, context);
  22221. context.indentLevel--;
  22222. needNewline && newline();
  22223. needNewline || push(` `);
  22224. push(`: `);
  22225. const isNested = alternate.type === 19;
  22226. if (!isNested) {
  22227. context.indentLevel++;
  22228. }
  22229. genNode(alternate, context);
  22230. if (!isNested) {
  22231. context.indentLevel--;
  22232. }
  22233. needNewline && deindent(
  22234. true
  22235. /* without newline */
  22236. );
  22237. }
  22238. function genCacheExpression(node, context) {
  22239. const { push, helper, indent, deindent, newline } = context;
  22240. const { needPauseTracking, needArraySpread } = node;
  22241. if (needArraySpread) {
  22242. push(`[...(`);
  22243. }
  22244. push(`_cache[${node.index}] || (`);
  22245. if (needPauseTracking) {
  22246. indent();
  22247. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  22248. newline();
  22249. push(`(`);
  22250. }
  22251. push(`_cache[${node.index}] = `);
  22252. genNode(node.value, context);
  22253. if (needPauseTracking) {
  22254. push(`).cacheIndex = ${node.index},`);
  22255. newline();
  22256. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  22257. newline();
  22258. push(`_cache[${node.index}]`);
  22259. deindent();
  22260. }
  22261. push(`)`);
  22262. if (needArraySpread) {
  22263. push(`)]`);
  22264. }
  22265. }
  22266. function genTemplateLiteral(node, context) {
  22267. const { push, indent, deindent } = context;
  22268. push("`");
  22269. const l = node.elements.length;
  22270. const multilines = l > 3;
  22271. for (let i = 0; i < l; i++) {
  22272. const e = node.elements[i];
  22273. if (isString$1(e)) {
  22274. push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
  22275. } else {
  22276. push("${");
  22277. if (multilines) indent();
  22278. genNode(e, context);
  22279. if (multilines) deindent();
  22280. push("}");
  22281. }
  22282. }
  22283. push("`");
  22284. }
  22285. function genIfStatement(node, context) {
  22286. const { push, indent, deindent } = context;
  22287. const { test, consequent, alternate } = node;
  22288. push(`if (`);
  22289. genNode(test, context);
  22290. push(`) {`);
  22291. indent();
  22292. genNode(consequent, context);
  22293. deindent();
  22294. push(`}`);
  22295. if (alternate) {
  22296. push(` else `);
  22297. if (alternate.type === 23) {
  22298. genIfStatement(alternate, context);
  22299. } else {
  22300. push(`{`);
  22301. indent();
  22302. genNode(alternate, context);
  22303. deindent();
  22304. push(`}`);
  22305. }
  22306. }
  22307. }
  22308. function genAssignmentExpression(node, context) {
  22309. genNode(node.left, context);
  22310. context.push(` = `);
  22311. genNode(node.right, context);
  22312. }
  22313. function genSequenceExpression(node, context) {
  22314. context.push(`(`);
  22315. genNodeList(node.expressions, context);
  22316. context.push(`)`);
  22317. }
  22318. function genReturnStatement({ returns }, context) {
  22319. context.push(`return `);
  22320. if (isArray$3(returns)) {
  22321. genNodeListAsArray(returns, context);
  22322. } else {
  22323. genNode(returns, context);
  22324. }
  22325. }
  22326. const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
  22327. const transformExpression = (node, context) => {
  22328. if (node.type === 5) {
  22329. node.content = processExpression(
  22330. node.content,
  22331. context
  22332. );
  22333. } else if (node.type === 1) {
  22334. for (let i = 0; i < node.props.length; i++) {
  22335. const dir = node.props[i];
  22336. if (dir.type === 7 && dir.name !== "for") {
  22337. const exp = dir.exp;
  22338. const arg = dir.arg;
  22339. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  22340. dir.exp = processExpression(
  22341. exp,
  22342. context,
  22343. // slot args must be processed as function params
  22344. dir.name === "slot"
  22345. );
  22346. }
  22347. if (arg && arg.type === 4 && !arg.isStatic) {
  22348. dir.arg = processExpression(arg, context);
  22349. }
  22350. }
  22351. }
  22352. }
  22353. };
  22354. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  22355. if (!context.prefixIdentifiers || !node.content.trim()) {
  22356. return node;
  22357. }
  22358. const { inline, bindingMetadata } = context;
  22359. const rewriteIdentifier = (raw, parent, id) => {
  22360. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  22361. if (inline) {
  22362. const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
  22363. const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
  22364. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  22365. const isNewExpression = parent && isInNewExpression(parentStack);
  22366. const wrapWithUnref = (raw2) => {
  22367. const wrapped = `${context.helperString(UNREF)}(${raw2})`;
  22368. return isNewExpression ? `(${wrapped})` : wrapped;
  22369. };
  22370. if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
  22371. return raw;
  22372. } else if (type === "setup-ref") {
  22373. return `${raw}.value`;
  22374. } else if (type === "setup-maybe-ref") {
  22375. return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
  22376. } else if (type === "setup-let") {
  22377. if (isAssignmentLVal) {
  22378. const { right: rVal, operator } = parent;
  22379. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  22380. const rExpString = stringifyExpression(
  22381. processExpression(
  22382. createSimpleExpression(rExp, false),
  22383. context,
  22384. false,
  22385. false,
  22386. knownIds
  22387. )
  22388. );
  22389. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22390. ` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  22391. } else if (isUpdateArg) {
  22392. id.start = parent.start;
  22393. id.end = parent.end;
  22394. const { prefix: isPrefix, operator } = parent;
  22395. const prefix = isPrefix ? operator : ``;
  22396. const postfix = isPrefix ? `` : operator;
  22397. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22398. ` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  22399. } else if (isDestructureAssignment) {
  22400. return raw;
  22401. } else {
  22402. return wrapWithUnref(raw);
  22403. }
  22404. } else if (type === "props") {
  22405. return genPropsAccessExp(raw);
  22406. } else if (type === "props-aliased") {
  22407. return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
  22408. }
  22409. } else {
  22410. if (type && type.startsWith("setup") || type === "literal-const") {
  22411. return `$setup.${raw}`;
  22412. } else if (type === "props-aliased") {
  22413. return `$props['${bindingMetadata.__propsAliases[raw]}']`;
  22414. } else if (type) {
  22415. return `$${type}.${raw}`;
  22416. }
  22417. }
  22418. return `_ctx.${raw}`;
  22419. };
  22420. const rawExp = node.content;
  22421. let ast = node.ast;
  22422. if (ast === false) {
  22423. return node;
  22424. }
  22425. if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
  22426. const isScopeVarReference = context.identifiers[rawExp];
  22427. const isAllowedGlobal = isGloballyAllowed(rawExp);
  22428. const isLiteral = isLiteralWhitelisted(rawExp);
  22429. if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
  22430. if (isConst(bindingMetadata[rawExp])) {
  22431. node.constType = 1;
  22432. }
  22433. node.content = rewriteIdentifier(rawExp);
  22434. } else if (!isScopeVarReference) {
  22435. if (isLiteral) {
  22436. node.constType = 3;
  22437. } else {
  22438. node.constType = 2;
  22439. }
  22440. }
  22441. return node;
  22442. }
  22443. if (!ast) {
  22444. const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
  22445. try {
  22446. ast = libExports.parseExpression(source, {
  22447. sourceType: "module",
  22448. plugins: context.expressionPlugins
  22449. });
  22450. } catch (e) {
  22451. context.onError(
  22452. createCompilerError(
  22453. 45,
  22454. node.loc,
  22455. void 0,
  22456. e.message
  22457. )
  22458. );
  22459. return node;
  22460. }
  22461. }
  22462. const ids = [];
  22463. const parentStack = [];
  22464. const knownIds = Object.create(context.identifiers);
  22465. walkIdentifiers(
  22466. ast,
  22467. (node2, parent, _, isReferenced, isLocal) => {
  22468. if (isStaticPropertyKey(node2, parent)) {
  22469. return;
  22470. }
  22471. const needPrefix = isReferenced && canPrefix(node2);
  22472. if (needPrefix && !isLocal) {
  22473. if (isStaticProperty(parent) && parent.shorthand) {
  22474. node2.prefix = `${node2.name}: `;
  22475. }
  22476. node2.name = rewriteIdentifier(node2.name, parent, node2);
  22477. ids.push(node2);
  22478. } else {
  22479. if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) {
  22480. node2.isConstant = true;
  22481. }
  22482. ids.push(node2);
  22483. }
  22484. },
  22485. true,
  22486. // invoke on ALL identifiers
  22487. parentStack,
  22488. knownIds
  22489. );
  22490. const children = [];
  22491. ids.sort((a, b) => a.start - b.start);
  22492. ids.forEach((id, i) => {
  22493. const start = id.start - 1;
  22494. const end = id.end - 1;
  22495. const last = ids[i - 1];
  22496. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  22497. if (leadingText.length || id.prefix) {
  22498. children.push(leadingText + (id.prefix || ``));
  22499. }
  22500. const source = rawExp.slice(start, end);
  22501. children.push(
  22502. createSimpleExpression(
  22503. id.name,
  22504. false,
  22505. {
  22506. start: advancePositionWithClone(node.loc.start, source, start),
  22507. end: advancePositionWithClone(node.loc.start, source, end),
  22508. source
  22509. },
  22510. id.isConstant ? 3 : 0
  22511. )
  22512. );
  22513. if (i === ids.length - 1 && end < rawExp.length) {
  22514. children.push(rawExp.slice(end));
  22515. }
  22516. });
  22517. let ret;
  22518. if (children.length) {
  22519. ret = createCompoundExpression(children, node.loc);
  22520. ret.ast = ast;
  22521. } else {
  22522. ret = node;
  22523. ret.constType = 3;
  22524. }
  22525. ret.identifiers = Object.keys(knownIds);
  22526. return ret;
  22527. }
  22528. function canPrefix(id) {
  22529. if (isGloballyAllowed(id.name)) {
  22530. return false;
  22531. }
  22532. if (id.name === "require") {
  22533. return false;
  22534. }
  22535. return true;
  22536. }
  22537. function stringifyExpression(exp) {
  22538. if (isString$1(exp)) {
  22539. return exp;
  22540. } else if (exp.type === 4) {
  22541. return exp.content;
  22542. } else {
  22543. return exp.children.map(stringifyExpression).join("");
  22544. }
  22545. }
  22546. function isConst(type) {
  22547. return type === "setup-const" || type === "literal-const";
  22548. }
  22549. const transformIf = createStructuralDirectiveTransform(
  22550. /^(if|else|else-if)$/,
  22551. (node, dir, context) => {
  22552. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  22553. const siblings = context.parent.children;
  22554. let i = siblings.indexOf(ifNode);
  22555. let key = 0;
  22556. while (i-- >= 0) {
  22557. const sibling = siblings[i];
  22558. if (sibling && sibling.type === 9) {
  22559. key += sibling.branches.length;
  22560. }
  22561. }
  22562. return () => {
  22563. if (isRoot) {
  22564. ifNode.codegenNode = createCodegenNodeForBranch(
  22565. branch,
  22566. key,
  22567. context
  22568. );
  22569. } else {
  22570. const parentCondition = getParentCondition(ifNode.codegenNode);
  22571. parentCondition.alternate = createCodegenNodeForBranch(
  22572. branch,
  22573. key + ifNode.branches.length - 1,
  22574. context
  22575. );
  22576. }
  22577. };
  22578. });
  22579. }
  22580. );
  22581. function processIf(node, dir, context, processCodegen) {
  22582. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  22583. const loc = dir.exp ? dir.exp.loc : node.loc;
  22584. context.onError(
  22585. createCompilerError(28, dir.loc)
  22586. );
  22587. dir.exp = createSimpleExpression(`true`, false, loc);
  22588. }
  22589. if (context.prefixIdentifiers && dir.exp) {
  22590. dir.exp = processExpression(dir.exp, context);
  22591. }
  22592. if (dir.name === "if") {
  22593. const branch = createIfBranch(node, dir);
  22594. const ifNode = {
  22595. type: 9,
  22596. loc: cloneLoc(node.loc),
  22597. branches: [branch]
  22598. };
  22599. context.replaceNode(ifNode);
  22600. if (processCodegen) {
  22601. return processCodegen(ifNode, branch, true);
  22602. }
  22603. } else {
  22604. const siblings = context.parent.children;
  22605. const comments = [];
  22606. let i = siblings.indexOf(node);
  22607. while (i-- >= -1) {
  22608. const sibling = siblings[i];
  22609. if (sibling && sibling.type === 3) {
  22610. context.removeNode(sibling);
  22611. comments.unshift(sibling);
  22612. continue;
  22613. }
  22614. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  22615. context.removeNode(sibling);
  22616. continue;
  22617. }
  22618. if (sibling && sibling.type === 9) {
  22619. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  22620. context.onError(
  22621. createCompilerError(30, node.loc)
  22622. );
  22623. }
  22624. context.removeNode();
  22625. const branch = createIfBranch(node, dir);
  22626. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  22627. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  22628. branch.children = [...comments, ...branch.children];
  22629. }
  22630. {
  22631. const key = branch.userKey;
  22632. if (key) {
  22633. sibling.branches.forEach(({ userKey }) => {
  22634. if (isSameKey(userKey, key)) {
  22635. context.onError(
  22636. createCompilerError(
  22637. 29,
  22638. branch.userKey.loc
  22639. )
  22640. );
  22641. }
  22642. });
  22643. }
  22644. }
  22645. sibling.branches.push(branch);
  22646. const onExit = processCodegen && processCodegen(sibling, branch, false);
  22647. traverseNode(branch, context);
  22648. if (onExit) onExit();
  22649. context.currentNode = null;
  22650. } else {
  22651. context.onError(
  22652. createCompilerError(30, node.loc)
  22653. );
  22654. }
  22655. break;
  22656. }
  22657. }
  22658. }
  22659. function createIfBranch(node, dir) {
  22660. const isTemplateIf = node.tagType === 3;
  22661. return {
  22662. type: 10,
  22663. loc: node.loc,
  22664. condition: dir.name === "else" ? void 0 : dir.exp,
  22665. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  22666. userKey: findProp(node, `key`),
  22667. isTemplateIf
  22668. };
  22669. }
  22670. function createCodegenNodeForBranch(branch, keyIndex, context) {
  22671. if (branch.condition) {
  22672. return createConditionalExpression(
  22673. branch.condition,
  22674. createChildrenCodegenNode(branch, keyIndex, context),
  22675. // make sure to pass in asBlock: true so that the comment node call
  22676. // closes the current block.
  22677. createCallExpression(context.helper(CREATE_COMMENT), [
  22678. '"v-if"' ,
  22679. "true"
  22680. ])
  22681. );
  22682. } else {
  22683. return createChildrenCodegenNode(branch, keyIndex, context);
  22684. }
  22685. }
  22686. function createChildrenCodegenNode(branch, keyIndex, context) {
  22687. const { helper } = context;
  22688. const keyProperty = createObjectProperty(
  22689. `key`,
  22690. createSimpleExpression(
  22691. `${keyIndex}`,
  22692. false,
  22693. locStub,
  22694. 2
  22695. )
  22696. );
  22697. const { children } = branch;
  22698. const firstChild = children[0];
  22699. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  22700. if (needFragmentWrapper) {
  22701. if (children.length === 1 && firstChild.type === 11) {
  22702. const vnodeCall = firstChild.codegenNode;
  22703. injectProp(vnodeCall, keyProperty, context);
  22704. return vnodeCall;
  22705. } else {
  22706. let patchFlag = 64;
  22707. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  22708. patchFlag |= 2048;
  22709. }
  22710. return createVNodeCall(
  22711. context,
  22712. helper(FRAGMENT),
  22713. createObjectExpression([keyProperty]),
  22714. children,
  22715. patchFlag,
  22716. void 0,
  22717. void 0,
  22718. true,
  22719. false,
  22720. false,
  22721. branch.loc
  22722. );
  22723. }
  22724. } else {
  22725. const ret = firstChild.codegenNode;
  22726. const vnodeCall = getMemoedVNodeCall(ret);
  22727. if (vnodeCall.type === 13) {
  22728. convertToBlock(vnodeCall, context);
  22729. }
  22730. injectProp(vnodeCall, keyProperty, context);
  22731. return ret;
  22732. }
  22733. }
  22734. function isSameKey(a, b) {
  22735. if (!a || a.type !== b.type) {
  22736. return false;
  22737. }
  22738. if (a.type === 6) {
  22739. if (a.value.content !== b.value.content) {
  22740. return false;
  22741. }
  22742. } else {
  22743. const exp = a.exp;
  22744. const branchExp = b.exp;
  22745. if (exp.type !== branchExp.type) {
  22746. return false;
  22747. }
  22748. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  22749. return false;
  22750. }
  22751. }
  22752. return true;
  22753. }
  22754. function getParentCondition(node) {
  22755. while (true) {
  22756. if (node.type === 19) {
  22757. if (node.alternate.type === 19) {
  22758. node = node.alternate;
  22759. } else {
  22760. return node;
  22761. }
  22762. } else if (node.type === 20) {
  22763. node = node.value;
  22764. }
  22765. }
  22766. }
  22767. const transformBind = (dir, _node, context) => {
  22768. const { modifiers, loc } = dir;
  22769. const arg = dir.arg;
  22770. let { exp } = dir;
  22771. if (exp && exp.type === 4 && !exp.content.trim()) {
  22772. {
  22773. context.onError(
  22774. createCompilerError(34, loc)
  22775. );
  22776. return {
  22777. props: [
  22778. createObjectProperty(arg, createSimpleExpression("", true, loc))
  22779. ]
  22780. };
  22781. }
  22782. }
  22783. if (!exp) {
  22784. if (arg.type !== 4 || !arg.isStatic) {
  22785. context.onError(
  22786. createCompilerError(
  22787. 52,
  22788. arg.loc
  22789. )
  22790. );
  22791. return {
  22792. props: [
  22793. createObjectProperty(arg, createSimpleExpression("", true, loc))
  22794. ]
  22795. };
  22796. }
  22797. transformBindShorthand(dir, context);
  22798. exp = dir.exp;
  22799. }
  22800. if (arg.type !== 4) {
  22801. arg.children.unshift(`(`);
  22802. arg.children.push(`) || ""`);
  22803. } else if (!arg.isStatic) {
  22804. arg.content = `${arg.content} || ""`;
  22805. }
  22806. if (modifiers.some((mod) => mod.content === "camel")) {
  22807. if (arg.type === 4) {
  22808. if (arg.isStatic) {
  22809. arg.content = camelize(arg.content);
  22810. } else {
  22811. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  22812. }
  22813. } else {
  22814. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  22815. arg.children.push(`)`);
  22816. }
  22817. }
  22818. if (!context.inSSR) {
  22819. if (modifiers.some((mod) => mod.content === "prop")) {
  22820. injectPrefix(arg, ".");
  22821. }
  22822. if (modifiers.some((mod) => mod.content === "attr")) {
  22823. injectPrefix(arg, "^");
  22824. }
  22825. }
  22826. return {
  22827. props: [createObjectProperty(arg, exp)]
  22828. };
  22829. };
  22830. const transformBindShorthand = (dir, context) => {
  22831. const arg = dir.arg;
  22832. const propName = camelize(arg.content);
  22833. dir.exp = createSimpleExpression(propName, false, arg.loc);
  22834. {
  22835. dir.exp = processExpression(dir.exp, context);
  22836. }
  22837. };
  22838. const injectPrefix = (arg, prefix) => {
  22839. if (arg.type === 4) {
  22840. if (arg.isStatic) {
  22841. arg.content = prefix + arg.content;
  22842. } else {
  22843. arg.content = `\`${prefix}\${${arg.content}}\``;
  22844. }
  22845. } else {
  22846. arg.children.unshift(`'${prefix}' + (`);
  22847. arg.children.push(`)`);
  22848. }
  22849. };
  22850. const transformFor = createStructuralDirectiveTransform(
  22851. "for",
  22852. (node, dir, context) => {
  22853. const { helper, removeHelper } = context;
  22854. return processFor(node, dir, context, (forNode) => {
  22855. const renderExp = createCallExpression(helper(RENDER_LIST), [
  22856. forNode.source
  22857. ]);
  22858. const isTemplate = isTemplateNode(node);
  22859. const memo = findDir(node, "memo");
  22860. const keyProp = findProp(node, `key`, false, true);
  22861. if (keyProp && keyProp.type === 7 && !keyProp.exp) {
  22862. transformBindShorthand(keyProp, context);
  22863. }
  22864. const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
  22865. const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
  22866. if (isTemplate) {
  22867. if (memo) {
  22868. memo.exp = processExpression(
  22869. memo.exp,
  22870. context
  22871. );
  22872. }
  22873. if (keyProperty && keyProp.type !== 6) {
  22874. keyProperty.value = processExpression(
  22875. keyProperty.value,
  22876. context
  22877. );
  22878. }
  22879. }
  22880. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  22881. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  22882. forNode.codegenNode = createVNodeCall(
  22883. context,
  22884. helper(FRAGMENT),
  22885. void 0,
  22886. renderExp,
  22887. fragmentFlag,
  22888. void 0,
  22889. void 0,
  22890. true,
  22891. !isStableFragment,
  22892. false,
  22893. node.loc
  22894. );
  22895. return () => {
  22896. let childBlock;
  22897. const { children } = forNode;
  22898. if (isTemplate) {
  22899. node.children.some((c) => {
  22900. if (c.type === 1) {
  22901. const key = findProp(c, "key");
  22902. if (key) {
  22903. context.onError(
  22904. createCompilerError(
  22905. 33,
  22906. key.loc
  22907. )
  22908. );
  22909. return true;
  22910. }
  22911. }
  22912. });
  22913. }
  22914. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  22915. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  22916. if (slotOutlet) {
  22917. childBlock = slotOutlet.codegenNode;
  22918. if (isTemplate && keyProperty) {
  22919. injectProp(childBlock, keyProperty, context);
  22920. }
  22921. } else if (needFragmentWrapper) {
  22922. childBlock = createVNodeCall(
  22923. context,
  22924. helper(FRAGMENT),
  22925. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  22926. node.children,
  22927. 64,
  22928. void 0,
  22929. void 0,
  22930. true,
  22931. void 0,
  22932. false
  22933. );
  22934. } else {
  22935. childBlock = children[0].codegenNode;
  22936. if (isTemplate && keyProperty) {
  22937. injectProp(childBlock, keyProperty, context);
  22938. }
  22939. if (childBlock.isBlock !== !isStableFragment) {
  22940. if (childBlock.isBlock) {
  22941. removeHelper(OPEN_BLOCK);
  22942. removeHelper(
  22943. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  22944. );
  22945. } else {
  22946. removeHelper(
  22947. getVNodeHelper(context.inSSR, childBlock.isComponent)
  22948. );
  22949. }
  22950. }
  22951. childBlock.isBlock = !isStableFragment;
  22952. if (childBlock.isBlock) {
  22953. helper(OPEN_BLOCK);
  22954. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  22955. } else {
  22956. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  22957. }
  22958. }
  22959. if (memo) {
  22960. const loop = createFunctionExpression(
  22961. createForLoopParams(forNode.parseResult, [
  22962. createSimpleExpression(`_cached`)
  22963. ])
  22964. );
  22965. loop.body = createBlockStatement([
  22966. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  22967. createCompoundExpression([
  22968. `if (_cached`,
  22969. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  22970. ` && ${context.helperString(
  22971. IS_MEMO_SAME
  22972. )}(_cached, _memo)) return _cached`
  22973. ]),
  22974. createCompoundExpression([`const _item = `, childBlock]),
  22975. createSimpleExpression(`_item.memo = _memo`),
  22976. createSimpleExpression(`return _item`)
  22977. ]);
  22978. renderExp.arguments.push(
  22979. loop,
  22980. createSimpleExpression(`_cache`),
  22981. createSimpleExpression(String(context.cached.length))
  22982. );
  22983. context.cached.push(null);
  22984. } else {
  22985. renderExp.arguments.push(
  22986. createFunctionExpression(
  22987. createForLoopParams(forNode.parseResult),
  22988. childBlock,
  22989. true
  22990. )
  22991. );
  22992. }
  22993. };
  22994. });
  22995. }
  22996. );
  22997. function processFor(node, dir, context, processCodegen) {
  22998. if (!dir.exp) {
  22999. context.onError(
  23000. createCompilerError(31, dir.loc)
  23001. );
  23002. return;
  23003. }
  23004. const parseResult = dir.forParseResult;
  23005. if (!parseResult) {
  23006. context.onError(
  23007. createCompilerError(32, dir.loc)
  23008. );
  23009. return;
  23010. }
  23011. finalizeForParseResult(parseResult, context);
  23012. const { addIdentifiers, removeIdentifiers, scopes } = context;
  23013. const { source, value, key, index } = parseResult;
  23014. const forNode = {
  23015. type: 11,
  23016. loc: dir.loc,
  23017. source,
  23018. valueAlias: value,
  23019. keyAlias: key,
  23020. objectIndexAlias: index,
  23021. parseResult,
  23022. children: isTemplateNode(node) ? node.children : [node]
  23023. };
  23024. context.replaceNode(forNode);
  23025. scopes.vFor++;
  23026. if (context.prefixIdentifiers) {
  23027. value && addIdentifiers(value);
  23028. key && addIdentifiers(key);
  23029. index && addIdentifiers(index);
  23030. }
  23031. const onExit = processCodegen && processCodegen(forNode);
  23032. return () => {
  23033. scopes.vFor--;
  23034. if (context.prefixIdentifiers) {
  23035. value && removeIdentifiers(value);
  23036. key && removeIdentifiers(key);
  23037. index && removeIdentifiers(index);
  23038. }
  23039. if (onExit) onExit();
  23040. };
  23041. }
  23042. function finalizeForParseResult(result, context) {
  23043. if (result.finalized) return;
  23044. if (context.prefixIdentifiers) {
  23045. result.source = processExpression(
  23046. result.source,
  23047. context
  23048. );
  23049. if (result.key) {
  23050. result.key = processExpression(
  23051. result.key,
  23052. context,
  23053. true
  23054. );
  23055. }
  23056. if (result.index) {
  23057. result.index = processExpression(
  23058. result.index,
  23059. context,
  23060. true
  23061. );
  23062. }
  23063. if (result.value) {
  23064. result.value = processExpression(
  23065. result.value,
  23066. context,
  23067. true
  23068. );
  23069. }
  23070. }
  23071. result.finalized = true;
  23072. }
  23073. function createForLoopParams({ value, key, index }, memoArgs = []) {
  23074. return createParamsList([value, key, index, ...memoArgs]);
  23075. }
  23076. function createParamsList(args) {
  23077. let i = args.length;
  23078. while (i--) {
  23079. if (args[i]) break;
  23080. }
  23081. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  23082. }
  23083. const defaultFallback = createSimpleExpression(`undefined`, false);
  23084. const trackSlotScopes = (node, context) => {
  23085. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  23086. const vSlot = findDir(node, "slot");
  23087. if (vSlot) {
  23088. const slotProps = vSlot.exp;
  23089. if (context.prefixIdentifiers) {
  23090. slotProps && context.addIdentifiers(slotProps);
  23091. }
  23092. context.scopes.vSlot++;
  23093. return () => {
  23094. if (context.prefixIdentifiers) {
  23095. slotProps && context.removeIdentifiers(slotProps);
  23096. }
  23097. context.scopes.vSlot--;
  23098. };
  23099. }
  23100. }
  23101. };
  23102. const trackVForSlotScopes = (node, context) => {
  23103. let vFor;
  23104. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  23105. const result = vFor.forParseResult;
  23106. if (result) {
  23107. finalizeForParseResult(result, context);
  23108. const { value, key, index } = result;
  23109. const { addIdentifiers, removeIdentifiers } = context;
  23110. value && addIdentifiers(value);
  23111. key && addIdentifiers(key);
  23112. index && addIdentifiers(index);
  23113. return () => {
  23114. value && removeIdentifiers(value);
  23115. key && removeIdentifiers(key);
  23116. index && removeIdentifiers(index);
  23117. };
  23118. }
  23119. }
  23120. };
  23121. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  23122. props,
  23123. children,
  23124. false,
  23125. true,
  23126. children.length ? children[0].loc : loc
  23127. );
  23128. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  23129. context.helper(WITH_CTX);
  23130. const { children, loc } = node;
  23131. const slotsProperties = [];
  23132. const dynamicSlots = [];
  23133. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  23134. if (!context.ssr && context.prefixIdentifiers) {
  23135. hasDynamicSlots = hasScopeRef(node, context.identifiers);
  23136. }
  23137. const onComponentSlot = findDir(node, "slot", true);
  23138. if (onComponentSlot) {
  23139. const { arg, exp } = onComponentSlot;
  23140. if (arg && !isStaticExp(arg)) {
  23141. hasDynamicSlots = true;
  23142. }
  23143. slotsProperties.push(
  23144. createObjectProperty(
  23145. arg || createSimpleExpression("default", true),
  23146. buildSlotFn(exp, void 0, children, loc)
  23147. )
  23148. );
  23149. }
  23150. let hasTemplateSlots = false;
  23151. let hasNamedDefaultSlot = false;
  23152. const implicitDefaultChildren = [];
  23153. const seenSlotNames = /* @__PURE__ */ new Set();
  23154. let conditionalBranchIndex = 0;
  23155. for (let i = 0; i < children.length; i++) {
  23156. const slotElement = children[i];
  23157. let slotDir;
  23158. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  23159. if (slotElement.type !== 3) {
  23160. implicitDefaultChildren.push(slotElement);
  23161. }
  23162. continue;
  23163. }
  23164. if (onComponentSlot) {
  23165. context.onError(
  23166. createCompilerError(37, slotDir.loc)
  23167. );
  23168. break;
  23169. }
  23170. hasTemplateSlots = true;
  23171. const { children: slotChildren, loc: slotLoc } = slotElement;
  23172. const {
  23173. arg: slotName = createSimpleExpression(`default`, true),
  23174. exp: slotProps,
  23175. loc: dirLoc
  23176. } = slotDir;
  23177. let staticSlotName;
  23178. if (isStaticExp(slotName)) {
  23179. staticSlotName = slotName ? slotName.content : `default`;
  23180. } else {
  23181. hasDynamicSlots = true;
  23182. }
  23183. const vFor = findDir(slotElement, "for");
  23184. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  23185. let vIf;
  23186. let vElse;
  23187. if (vIf = findDir(slotElement, "if")) {
  23188. hasDynamicSlots = true;
  23189. dynamicSlots.push(
  23190. createConditionalExpression(
  23191. vIf.exp,
  23192. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  23193. defaultFallback
  23194. )
  23195. );
  23196. } else if (vElse = findDir(
  23197. slotElement,
  23198. /^else(-if)?$/,
  23199. true
  23200. /* allowEmpty */
  23201. )) {
  23202. let j = i;
  23203. let prev;
  23204. while (j--) {
  23205. prev = children[j];
  23206. if (prev.type !== 3) {
  23207. break;
  23208. }
  23209. }
  23210. if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
  23211. let conditional = dynamicSlots[dynamicSlots.length - 1];
  23212. while (conditional.alternate.type === 19) {
  23213. conditional = conditional.alternate;
  23214. }
  23215. conditional.alternate = vElse.exp ? createConditionalExpression(
  23216. vElse.exp,
  23217. buildDynamicSlot(
  23218. slotName,
  23219. slotFunction,
  23220. conditionalBranchIndex++
  23221. ),
  23222. defaultFallback
  23223. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  23224. } else {
  23225. context.onError(
  23226. createCompilerError(30, vElse.loc)
  23227. );
  23228. }
  23229. } else if (vFor) {
  23230. hasDynamicSlots = true;
  23231. const parseResult = vFor.forParseResult;
  23232. if (parseResult) {
  23233. finalizeForParseResult(parseResult, context);
  23234. dynamicSlots.push(
  23235. createCallExpression(context.helper(RENDER_LIST), [
  23236. parseResult.source,
  23237. createFunctionExpression(
  23238. createForLoopParams(parseResult),
  23239. buildDynamicSlot(slotName, slotFunction),
  23240. true
  23241. )
  23242. ])
  23243. );
  23244. } else {
  23245. context.onError(
  23246. createCompilerError(
  23247. 32,
  23248. vFor.loc
  23249. )
  23250. );
  23251. }
  23252. } else {
  23253. if (staticSlotName) {
  23254. if (seenSlotNames.has(staticSlotName)) {
  23255. context.onError(
  23256. createCompilerError(
  23257. 38,
  23258. dirLoc
  23259. )
  23260. );
  23261. continue;
  23262. }
  23263. seenSlotNames.add(staticSlotName);
  23264. if (staticSlotName === "default") {
  23265. hasNamedDefaultSlot = true;
  23266. }
  23267. }
  23268. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  23269. }
  23270. }
  23271. if (!onComponentSlot) {
  23272. const buildDefaultSlotProperty = (props, children2) => {
  23273. const fn = buildSlotFn(props, void 0, children2, loc);
  23274. return createObjectProperty(`default`, fn);
  23275. };
  23276. if (!hasTemplateSlots) {
  23277. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  23278. } else if (implicitDefaultChildren.length && // #3766
  23279. // with whitespace: 'preserve', whitespaces between slots will end up in
  23280. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  23281. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  23282. if (hasNamedDefaultSlot) {
  23283. context.onError(
  23284. createCompilerError(
  23285. 39,
  23286. implicitDefaultChildren[0].loc
  23287. )
  23288. );
  23289. } else {
  23290. slotsProperties.push(
  23291. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  23292. );
  23293. }
  23294. }
  23295. }
  23296. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  23297. let slots = createObjectExpression(
  23298. slotsProperties.concat(
  23299. createObjectProperty(
  23300. `_`,
  23301. // 2 = compiled but dynamic = can skip normalization, but must run diff
  23302. // 1 = compiled and static = can skip normalization AND diff as optimized
  23303. createSimpleExpression(
  23304. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  23305. false
  23306. )
  23307. )
  23308. ),
  23309. loc
  23310. );
  23311. if (dynamicSlots.length) {
  23312. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  23313. slots,
  23314. createArrayExpression(dynamicSlots)
  23315. ]);
  23316. }
  23317. return {
  23318. slots,
  23319. hasDynamicSlots
  23320. };
  23321. }
  23322. function buildDynamicSlot(name, fn, index) {
  23323. const props = [
  23324. createObjectProperty(`name`, name),
  23325. createObjectProperty(`fn`, fn)
  23326. ];
  23327. if (index != null) {
  23328. props.push(
  23329. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  23330. );
  23331. }
  23332. return createObjectExpression(props);
  23333. }
  23334. function hasForwardedSlots(children) {
  23335. for (let i = 0; i < children.length; i++) {
  23336. const child = children[i];
  23337. switch (child.type) {
  23338. case 1:
  23339. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  23340. return true;
  23341. }
  23342. break;
  23343. case 9:
  23344. if (hasForwardedSlots(child.branches)) return true;
  23345. break;
  23346. case 10:
  23347. case 11:
  23348. if (hasForwardedSlots(child.children)) return true;
  23349. break;
  23350. }
  23351. }
  23352. return false;
  23353. }
  23354. function isNonWhitespaceContent(node) {
  23355. if (node.type !== 2 && node.type !== 12)
  23356. return true;
  23357. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  23358. }
  23359. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  23360. const transformElement = (node, context) => {
  23361. return function postTransformElement() {
  23362. node = context.currentNode;
  23363. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  23364. return;
  23365. }
  23366. const { tag, props } = node;
  23367. const isComponent = node.tagType === 1;
  23368. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  23369. const isDynamicComponent = isObject$2(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  23370. let vnodeProps;
  23371. let vnodeChildren;
  23372. let patchFlag = 0;
  23373. let vnodeDynamicProps;
  23374. let dynamicPropNames;
  23375. let vnodeDirectives;
  23376. let shouldUseBlock = (
  23377. // dynamic component may resolve to plain elements
  23378. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  23379. // updates inside get proper isSVG flag at runtime. (#639, #643)
  23380. // This is technically web-specific, but splitting the logic out of core
  23381. // leads to too much unnecessary complexity.
  23382. (tag === "svg" || tag === "foreignObject" || tag === "math")
  23383. );
  23384. if (props.length > 0) {
  23385. const propsBuildResult = buildProps(
  23386. node,
  23387. context,
  23388. void 0,
  23389. isComponent,
  23390. isDynamicComponent
  23391. );
  23392. vnodeProps = propsBuildResult.props;
  23393. patchFlag = propsBuildResult.patchFlag;
  23394. dynamicPropNames = propsBuildResult.dynamicPropNames;
  23395. const directives = propsBuildResult.directives;
  23396. vnodeDirectives = directives && directives.length ? createArrayExpression(
  23397. directives.map((dir) => buildDirectiveArgs(dir, context))
  23398. ) : void 0;
  23399. if (propsBuildResult.shouldUseBlock) {
  23400. shouldUseBlock = true;
  23401. }
  23402. }
  23403. if (node.children.length > 0) {
  23404. if (vnodeTag === KEEP_ALIVE) {
  23405. shouldUseBlock = true;
  23406. patchFlag |= 1024;
  23407. if (node.children.length > 1) {
  23408. context.onError(
  23409. createCompilerError(46, {
  23410. start: node.children[0].loc.start,
  23411. end: node.children[node.children.length - 1].loc.end,
  23412. source: ""
  23413. })
  23414. );
  23415. }
  23416. }
  23417. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  23418. vnodeTag !== TELEPORT && // explained above.
  23419. vnodeTag !== KEEP_ALIVE;
  23420. if (shouldBuildAsSlots) {
  23421. const { slots, hasDynamicSlots } = buildSlots(node, context);
  23422. vnodeChildren = slots;
  23423. if (hasDynamicSlots) {
  23424. patchFlag |= 1024;
  23425. }
  23426. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  23427. const child = node.children[0];
  23428. const type = child.type;
  23429. const hasDynamicTextChild = type === 5 || type === 8;
  23430. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  23431. patchFlag |= 1;
  23432. }
  23433. if (hasDynamicTextChild || type === 2) {
  23434. vnodeChildren = child;
  23435. } else {
  23436. vnodeChildren = node.children;
  23437. }
  23438. } else {
  23439. vnodeChildren = node.children;
  23440. }
  23441. }
  23442. if (dynamicPropNames && dynamicPropNames.length) {
  23443. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  23444. }
  23445. node.codegenNode = createVNodeCall(
  23446. context,
  23447. vnodeTag,
  23448. vnodeProps,
  23449. vnodeChildren,
  23450. patchFlag === 0 ? void 0 : patchFlag,
  23451. vnodeDynamicProps,
  23452. vnodeDirectives,
  23453. !!shouldUseBlock,
  23454. false,
  23455. isComponent,
  23456. node.loc
  23457. );
  23458. };
  23459. };
  23460. function resolveComponentType(node, context, ssr = false) {
  23461. let { tag } = node;
  23462. const isExplicitDynamic = isComponentTag(tag);
  23463. const isProp = findProp(
  23464. node,
  23465. "is",
  23466. false,
  23467. true
  23468. /* allow empty */
  23469. );
  23470. if (isProp) {
  23471. if (isExplicitDynamic || false) {
  23472. let exp;
  23473. if (isProp.type === 6) {
  23474. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  23475. } else {
  23476. exp = isProp.exp;
  23477. if (!exp) {
  23478. exp = createSimpleExpression(`is`, false, isProp.arg.loc);
  23479. {
  23480. exp = isProp.exp = processExpression(exp, context);
  23481. }
  23482. }
  23483. }
  23484. if (exp) {
  23485. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  23486. exp
  23487. ]);
  23488. }
  23489. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  23490. tag = isProp.value.content.slice(4);
  23491. }
  23492. }
  23493. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  23494. if (builtIn) {
  23495. if (!ssr) context.helper(builtIn);
  23496. return builtIn;
  23497. }
  23498. {
  23499. const fromSetup = resolveSetupReference(tag, context);
  23500. if (fromSetup) {
  23501. return fromSetup;
  23502. }
  23503. const dotIndex = tag.indexOf(".");
  23504. if (dotIndex > 0) {
  23505. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  23506. if (ns) {
  23507. return ns + tag.slice(dotIndex);
  23508. }
  23509. }
  23510. }
  23511. if (context.selfName && capitalize(camelize(tag)) === context.selfName) {
  23512. context.helper(RESOLVE_COMPONENT);
  23513. context.components.add(tag + `__self`);
  23514. return toValidAssetId(tag, `component`);
  23515. }
  23516. context.helper(RESOLVE_COMPONENT);
  23517. context.components.add(tag);
  23518. return toValidAssetId(tag, `component`);
  23519. }
  23520. function resolveSetupReference(name, context) {
  23521. const bindings = context.bindingMetadata;
  23522. if (!bindings || bindings.__isScriptSetup === false) {
  23523. return;
  23524. }
  23525. const camelName = camelize(name);
  23526. const PascalName = capitalize(camelName);
  23527. const checkType = (type) => {
  23528. if (bindings[name] === type) {
  23529. return name;
  23530. }
  23531. if (bindings[camelName] === type) {
  23532. return camelName;
  23533. }
  23534. if (bindings[PascalName] === type) {
  23535. return PascalName;
  23536. }
  23537. };
  23538. const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
  23539. if (fromConst) {
  23540. return context.inline ? (
  23541. // in inline mode, const setup bindings (e.g. imports) can be used as-is
  23542. fromConst
  23543. ) : `$setup[${JSON.stringify(fromConst)}]`;
  23544. }
  23545. const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
  23546. if (fromMaybeRef) {
  23547. return context.inline ? (
  23548. // setup scope bindings that may be refs need to be unrefed
  23549. `${context.helperString(UNREF)}(${fromMaybeRef})`
  23550. ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  23551. }
  23552. const fromProps = checkType("props");
  23553. if (fromProps) {
  23554. return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
  23555. }
  23556. }
  23557. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  23558. const { tag, loc: elementLoc, children } = node;
  23559. let properties = [];
  23560. const mergeArgs = [];
  23561. const runtimeDirectives = [];
  23562. const hasChildren = children.length > 0;
  23563. let shouldUseBlock = false;
  23564. let patchFlag = 0;
  23565. let hasRef = false;
  23566. let hasClassBinding = false;
  23567. let hasStyleBinding = false;
  23568. let hasHydrationEventBinding = false;
  23569. let hasDynamicKeys = false;
  23570. let hasVnodeHook = false;
  23571. const dynamicPropNames = [];
  23572. const pushMergeArg = (arg) => {
  23573. if (properties.length) {
  23574. mergeArgs.push(
  23575. createObjectExpression(dedupeProperties(properties), elementLoc)
  23576. );
  23577. properties = [];
  23578. }
  23579. if (arg) mergeArgs.push(arg);
  23580. };
  23581. const pushRefVForMarker = () => {
  23582. if (context.scopes.vFor > 0) {
  23583. properties.push(
  23584. createObjectProperty(
  23585. createSimpleExpression("ref_for", true),
  23586. createSimpleExpression("true")
  23587. )
  23588. );
  23589. }
  23590. };
  23591. const analyzePatchFlag = ({ key, value }) => {
  23592. if (isStaticExp(key)) {
  23593. const name = key.content;
  23594. const isEventHandler = isOn(name);
  23595. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  23596. // dedicated fast path.
  23597. name.toLowerCase() !== "onclick" && // omit v-model handlers
  23598. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  23599. !isReservedProp(name)) {
  23600. hasHydrationEventBinding = true;
  23601. }
  23602. if (isEventHandler && isReservedProp(name)) {
  23603. hasVnodeHook = true;
  23604. }
  23605. if (isEventHandler && value.type === 14) {
  23606. value = value.arguments[0];
  23607. }
  23608. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  23609. return;
  23610. }
  23611. if (name === "ref") {
  23612. hasRef = true;
  23613. } else if (name === "class") {
  23614. hasClassBinding = true;
  23615. } else if (name === "style") {
  23616. hasStyleBinding = true;
  23617. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  23618. dynamicPropNames.push(name);
  23619. }
  23620. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  23621. dynamicPropNames.push(name);
  23622. }
  23623. } else {
  23624. hasDynamicKeys = true;
  23625. }
  23626. };
  23627. for (let i = 0; i < props.length; i++) {
  23628. const prop = props[i];
  23629. if (prop.type === 6) {
  23630. const { loc, name, nameLoc, value } = prop;
  23631. let isStatic = true;
  23632. if (name === "ref") {
  23633. hasRef = true;
  23634. pushRefVForMarker();
  23635. if (value && context.inline) {
  23636. const binding = context.bindingMetadata[value.content];
  23637. if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
  23638. isStatic = false;
  23639. properties.push(
  23640. createObjectProperty(
  23641. createSimpleExpression("ref_key", true),
  23642. createSimpleExpression(value.content, true, value.loc)
  23643. )
  23644. );
  23645. }
  23646. }
  23647. }
  23648. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  23649. continue;
  23650. }
  23651. properties.push(
  23652. createObjectProperty(
  23653. createSimpleExpression(name, true, nameLoc),
  23654. createSimpleExpression(
  23655. value ? value.content : "",
  23656. isStatic,
  23657. value ? value.loc : loc
  23658. )
  23659. )
  23660. );
  23661. } else {
  23662. const { name, arg, exp, loc, modifiers } = prop;
  23663. const isVBind = name === "bind";
  23664. const isVOn = name === "on";
  23665. if (name === "slot") {
  23666. if (!isComponent) {
  23667. context.onError(
  23668. createCompilerError(40, loc)
  23669. );
  23670. }
  23671. continue;
  23672. }
  23673. if (name === "once" || name === "memo") {
  23674. continue;
  23675. }
  23676. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  23677. continue;
  23678. }
  23679. if (isVOn && ssr) {
  23680. continue;
  23681. }
  23682. if (
  23683. // #938: elements with dynamic keys should be forced into blocks
  23684. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  23685. // before children
  23686. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  23687. ) {
  23688. shouldUseBlock = true;
  23689. }
  23690. if (isVBind && isStaticArgOf(arg, "ref")) {
  23691. pushRefVForMarker();
  23692. }
  23693. if (!arg && (isVBind || isVOn)) {
  23694. hasDynamicKeys = true;
  23695. if (exp) {
  23696. if (isVBind) {
  23697. pushRefVForMarker();
  23698. pushMergeArg();
  23699. mergeArgs.push(exp);
  23700. } else {
  23701. pushMergeArg({
  23702. type: 14,
  23703. loc,
  23704. callee: context.helper(TO_HANDLERS),
  23705. arguments: isComponent ? [exp] : [exp, `true`]
  23706. });
  23707. }
  23708. } else {
  23709. context.onError(
  23710. createCompilerError(
  23711. isVBind ? 34 : 35,
  23712. loc
  23713. )
  23714. );
  23715. }
  23716. continue;
  23717. }
  23718. if (isVBind && modifiers.some((mod) => mod.content === "prop")) {
  23719. patchFlag |= 32;
  23720. }
  23721. const directiveTransform = context.directiveTransforms[name];
  23722. if (directiveTransform) {
  23723. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  23724. !ssr && props2.forEach(analyzePatchFlag);
  23725. if (isVOn && arg && !isStaticExp(arg)) {
  23726. pushMergeArg(createObjectExpression(props2, elementLoc));
  23727. } else {
  23728. properties.push(...props2);
  23729. }
  23730. if (needRuntime) {
  23731. runtimeDirectives.push(prop);
  23732. if (isSymbol$1(needRuntime)) {
  23733. directiveImportMap.set(prop, needRuntime);
  23734. }
  23735. }
  23736. } else if (!isBuiltInDirective(name)) {
  23737. runtimeDirectives.push(prop);
  23738. if (hasChildren) {
  23739. shouldUseBlock = true;
  23740. }
  23741. }
  23742. }
  23743. }
  23744. let propsExpression = void 0;
  23745. if (mergeArgs.length) {
  23746. pushMergeArg();
  23747. if (mergeArgs.length > 1) {
  23748. propsExpression = createCallExpression(
  23749. context.helper(MERGE_PROPS),
  23750. mergeArgs,
  23751. elementLoc
  23752. );
  23753. } else {
  23754. propsExpression = mergeArgs[0];
  23755. }
  23756. } else if (properties.length) {
  23757. propsExpression = createObjectExpression(
  23758. dedupeProperties(properties),
  23759. elementLoc
  23760. );
  23761. }
  23762. if (hasDynamicKeys) {
  23763. patchFlag |= 16;
  23764. } else {
  23765. if (hasClassBinding && !isComponent) {
  23766. patchFlag |= 2;
  23767. }
  23768. if (hasStyleBinding && !isComponent) {
  23769. patchFlag |= 4;
  23770. }
  23771. if (dynamicPropNames.length) {
  23772. patchFlag |= 8;
  23773. }
  23774. if (hasHydrationEventBinding) {
  23775. patchFlag |= 32;
  23776. }
  23777. }
  23778. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  23779. patchFlag |= 512;
  23780. }
  23781. if (!context.inSSR && propsExpression) {
  23782. switch (propsExpression.type) {
  23783. case 15:
  23784. let classKeyIndex = -1;
  23785. let styleKeyIndex = -1;
  23786. let hasDynamicKey = false;
  23787. for (let i = 0; i < propsExpression.properties.length; i++) {
  23788. const key = propsExpression.properties[i].key;
  23789. if (isStaticExp(key)) {
  23790. if (key.content === "class") {
  23791. classKeyIndex = i;
  23792. } else if (key.content === "style") {
  23793. styleKeyIndex = i;
  23794. }
  23795. } else if (!key.isHandlerKey) {
  23796. hasDynamicKey = true;
  23797. }
  23798. }
  23799. const classProp = propsExpression.properties[classKeyIndex];
  23800. const styleProp = propsExpression.properties[styleKeyIndex];
  23801. if (!hasDynamicKey) {
  23802. if (classProp && !isStaticExp(classProp.value)) {
  23803. classProp.value = createCallExpression(
  23804. context.helper(NORMALIZE_CLASS),
  23805. [classProp.value]
  23806. );
  23807. }
  23808. if (styleProp && // the static style is compiled into an object,
  23809. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  23810. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  23811. // v-bind:style with static literal object
  23812. styleProp.value.type === 17)) {
  23813. styleProp.value = createCallExpression(
  23814. context.helper(NORMALIZE_STYLE),
  23815. [styleProp.value]
  23816. );
  23817. }
  23818. } else {
  23819. propsExpression = createCallExpression(
  23820. context.helper(NORMALIZE_PROPS),
  23821. [propsExpression]
  23822. );
  23823. }
  23824. break;
  23825. case 14:
  23826. break;
  23827. default:
  23828. propsExpression = createCallExpression(
  23829. context.helper(NORMALIZE_PROPS),
  23830. [
  23831. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  23832. propsExpression
  23833. ])
  23834. ]
  23835. );
  23836. break;
  23837. }
  23838. }
  23839. return {
  23840. props: propsExpression,
  23841. directives: runtimeDirectives,
  23842. patchFlag,
  23843. dynamicPropNames,
  23844. shouldUseBlock
  23845. };
  23846. }
  23847. function dedupeProperties(properties) {
  23848. const knownProps = /* @__PURE__ */ new Map();
  23849. const deduped = [];
  23850. for (let i = 0; i < properties.length; i++) {
  23851. const prop = properties[i];
  23852. if (prop.key.type === 8 || !prop.key.isStatic) {
  23853. deduped.push(prop);
  23854. continue;
  23855. }
  23856. const name = prop.key.content;
  23857. const existing = knownProps.get(name);
  23858. if (existing) {
  23859. if (name === "style" || name === "class" || isOn(name)) {
  23860. mergeAsArray(existing, prop);
  23861. }
  23862. } else {
  23863. knownProps.set(name, prop);
  23864. deduped.push(prop);
  23865. }
  23866. }
  23867. return deduped;
  23868. }
  23869. function mergeAsArray(existing, incoming) {
  23870. if (existing.value.type === 17) {
  23871. existing.value.elements.push(incoming.value);
  23872. } else {
  23873. existing.value = createArrayExpression(
  23874. [existing.value, incoming.value],
  23875. existing.loc
  23876. );
  23877. }
  23878. }
  23879. function buildDirectiveArgs(dir, context) {
  23880. const dirArgs = [];
  23881. const runtime = directiveImportMap.get(dir);
  23882. if (runtime) {
  23883. dirArgs.push(context.helperString(runtime));
  23884. } else {
  23885. const fromSetup = resolveSetupReference("v-" + dir.name, context);
  23886. if (fromSetup) {
  23887. dirArgs.push(fromSetup);
  23888. } else {
  23889. context.helper(RESOLVE_DIRECTIVE);
  23890. context.directives.add(dir.name);
  23891. dirArgs.push(toValidAssetId(dir.name, `directive`));
  23892. }
  23893. }
  23894. const { loc } = dir;
  23895. if (dir.exp) dirArgs.push(dir.exp);
  23896. if (dir.arg) {
  23897. if (!dir.exp) {
  23898. dirArgs.push(`void 0`);
  23899. }
  23900. dirArgs.push(dir.arg);
  23901. }
  23902. if (Object.keys(dir.modifiers).length) {
  23903. if (!dir.arg) {
  23904. if (!dir.exp) {
  23905. dirArgs.push(`void 0`);
  23906. }
  23907. dirArgs.push(`void 0`);
  23908. }
  23909. const trueExpression = createSimpleExpression(`true`, false, loc);
  23910. dirArgs.push(
  23911. createObjectExpression(
  23912. dir.modifiers.map(
  23913. (modifier) => createObjectProperty(modifier, trueExpression)
  23914. ),
  23915. loc
  23916. )
  23917. );
  23918. }
  23919. return createArrayExpression(dirArgs, dir.loc);
  23920. }
  23921. function stringifyDynamicPropNames(props) {
  23922. let propsNamesString = `[`;
  23923. for (let i = 0, l = props.length; i < l; i++) {
  23924. propsNamesString += JSON.stringify(props[i]);
  23925. if (i < l - 1) propsNamesString += ", ";
  23926. }
  23927. return propsNamesString + `]`;
  23928. }
  23929. function isComponentTag(tag) {
  23930. return tag === "component" || tag === "Component";
  23931. }
  23932. const transformSlotOutlet = (node, context) => {
  23933. if (isSlotOutlet(node)) {
  23934. const { children, loc } = node;
  23935. const { slotName, slotProps } = processSlotOutlet(node, context);
  23936. const slotArgs = [
  23937. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  23938. slotName,
  23939. "{}",
  23940. "undefined",
  23941. "true"
  23942. ];
  23943. let expectedLen = 2;
  23944. if (slotProps) {
  23945. slotArgs[2] = slotProps;
  23946. expectedLen = 3;
  23947. }
  23948. if (children.length) {
  23949. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  23950. expectedLen = 4;
  23951. }
  23952. if (context.scopeId && !context.slotted) {
  23953. expectedLen = 5;
  23954. }
  23955. slotArgs.splice(expectedLen);
  23956. node.codegenNode = createCallExpression(
  23957. context.helper(RENDER_SLOT),
  23958. slotArgs,
  23959. loc
  23960. );
  23961. }
  23962. };
  23963. function processSlotOutlet(node, context) {
  23964. let slotName = `"default"`;
  23965. let slotProps = void 0;
  23966. const nonNameProps = [];
  23967. for (let i = 0; i < node.props.length; i++) {
  23968. const p = node.props[i];
  23969. if (p.type === 6) {
  23970. if (p.value) {
  23971. if (p.name === "name") {
  23972. slotName = JSON.stringify(p.value.content);
  23973. } else {
  23974. p.name = camelize(p.name);
  23975. nonNameProps.push(p);
  23976. }
  23977. }
  23978. } else {
  23979. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  23980. if (p.exp) {
  23981. slotName = p.exp;
  23982. } else if (p.arg && p.arg.type === 4) {
  23983. const name = camelize(p.arg.content);
  23984. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  23985. {
  23986. slotName = p.exp = processExpression(p.exp, context);
  23987. }
  23988. }
  23989. } else {
  23990. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  23991. p.arg.content = camelize(p.arg.content);
  23992. }
  23993. nonNameProps.push(p);
  23994. }
  23995. }
  23996. }
  23997. if (nonNameProps.length > 0) {
  23998. const { props, directives } = buildProps(
  23999. node,
  24000. context,
  24001. nonNameProps,
  24002. false,
  24003. false
  24004. );
  24005. slotProps = props;
  24006. if (directives.length) {
  24007. context.onError(
  24008. createCompilerError(
  24009. 36,
  24010. directives[0].loc
  24011. )
  24012. );
  24013. }
  24014. }
  24015. return {
  24016. slotName,
  24017. slotProps
  24018. };
  24019. }
  24020. const transformOn$1 = (dir, node, context, augmentor) => {
  24021. const { loc, modifiers, arg } = dir;
  24022. if (!dir.exp && !modifiers.length) {
  24023. context.onError(createCompilerError(35, loc));
  24024. }
  24025. let eventName;
  24026. if (arg.type === 4) {
  24027. if (arg.isStatic) {
  24028. let rawName = arg.content;
  24029. if (rawName.startsWith("vnode")) {
  24030. context.onError(createCompilerError(51, arg.loc));
  24031. }
  24032. if (rawName.startsWith("vue:")) {
  24033. rawName = `vnode-${rawName.slice(4)}`;
  24034. }
  24035. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  24036. // for non-element and vnode lifecycle event listeners, auto convert
  24037. // it to camelCase. See issue #2249
  24038. toHandlerKey(camelize(rawName))
  24039. ) : (
  24040. // preserve case for plain element listeners that have uppercase
  24041. // letters, as these may be custom elements' custom events
  24042. `on:${rawName}`
  24043. );
  24044. eventName = createSimpleExpression(eventString, true, arg.loc);
  24045. } else {
  24046. eventName = createCompoundExpression([
  24047. `${context.helperString(TO_HANDLER_KEY)}(`,
  24048. arg,
  24049. `)`
  24050. ]);
  24051. }
  24052. } else {
  24053. eventName = arg;
  24054. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  24055. eventName.children.push(`)`);
  24056. }
  24057. let exp = dir.exp;
  24058. if (exp && !exp.content.trim()) {
  24059. exp = void 0;
  24060. }
  24061. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  24062. if (exp) {
  24063. const isMemberExp = isMemberExpression(exp, context);
  24064. const isInlineStatement = !(isMemberExp || isFnExpression(exp, context));
  24065. const hasMultipleStatements = exp.content.includes(`;`);
  24066. if (context.prefixIdentifiers) {
  24067. isInlineStatement && context.addIdentifiers(`$event`);
  24068. exp = dir.exp = processExpression(
  24069. exp,
  24070. context,
  24071. false,
  24072. hasMultipleStatements
  24073. );
  24074. isInlineStatement && context.removeIdentifiers(`$event`);
  24075. shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
  24076. !context.inVOnce && // runtime constants don't need to be cached
  24077. // (this is analyzed by compileScript in SFC <script setup>)
  24078. !(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
  24079. // we need to use the original function to preserve arity,
  24080. // e.g. <transition> relies on checking cb.length to determine
  24081. // transition end handling. Inline function is ok since its arity
  24082. // is preserved even when cached.
  24083. !(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
  24084. // it must be passed fresh to avoid stale values.
  24085. !hasScopeRef(exp, context.identifiers);
  24086. if (shouldCache && isMemberExp) {
  24087. if (exp.type === 4) {
  24088. exp.content = `${exp.content} && ${exp.content}(...args)`;
  24089. } else {
  24090. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  24091. }
  24092. }
  24093. }
  24094. if (isInlineStatement || shouldCache && isMemberExp) {
  24095. exp = createCompoundExpression([
  24096. `${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
  24097. //@ts-ignore
  24098. ` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  24099. exp,
  24100. hasMultipleStatements ? `}` : `)`
  24101. ]);
  24102. }
  24103. }
  24104. let ret = {
  24105. props: [
  24106. createObjectProperty(
  24107. eventName,
  24108. exp || createSimpleExpression(`() => {}`, false, loc)
  24109. )
  24110. ]
  24111. };
  24112. if (augmentor) {
  24113. ret = augmentor(ret);
  24114. }
  24115. if (shouldCache) {
  24116. ret.props[0].value = context.cache(ret.props[0].value);
  24117. }
  24118. ret.props.forEach((p) => p.key.isHandlerKey = true);
  24119. return ret;
  24120. };
  24121. const transformText = (node, context) => {
  24122. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  24123. return () => {
  24124. const children = node.children;
  24125. let currentContainer = void 0;
  24126. let hasText = false;
  24127. for (let i = 0; i < children.length; i++) {
  24128. const child = children[i];
  24129. if (isText$1(child)) {
  24130. hasText = true;
  24131. for (let j = i + 1; j < children.length; j++) {
  24132. const next = children[j];
  24133. if (isText$1(next)) {
  24134. if (!currentContainer) {
  24135. currentContainer = children[i] = createCompoundExpression(
  24136. [child],
  24137. child.loc
  24138. );
  24139. }
  24140. currentContainer.children.push(` + `, next);
  24141. children.splice(j, 1);
  24142. j--;
  24143. } else {
  24144. currentContainer = void 0;
  24145. break;
  24146. }
  24147. }
  24148. }
  24149. }
  24150. if (!hasText || // if this is a plain element with a single text child, leave it
  24151. // as-is since the runtime has dedicated fast path for this by directly
  24152. // setting textContent of the element.
  24153. // for component root it's always normalized anyway.
  24154. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  24155. // custom directives can potentially add DOM elements arbitrarily,
  24156. // we need to avoid setting textContent of the element at runtime
  24157. // to avoid accidentally overwriting the DOM elements added
  24158. // by the user through custom directives.
  24159. !node.props.find(
  24160. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  24161. ) && // in compat mode, <template> tags with no special directives
  24162. // will be rendered as a fragment so its children must be
  24163. // converted into vnodes.
  24164. true)) {
  24165. return;
  24166. }
  24167. for (let i = 0; i < children.length; i++) {
  24168. const child = children[i];
  24169. if (isText$1(child) || child.type === 8) {
  24170. const callArgs = [];
  24171. if (child.type !== 2 || child.content !== " ") {
  24172. callArgs.push(child);
  24173. }
  24174. if (!context.ssr && getConstantType(child, context) === 0) {
  24175. callArgs.push(
  24176. 1 + (` /* ${PatchFlagNames[1]} */` )
  24177. );
  24178. }
  24179. children[i] = {
  24180. type: 12,
  24181. content: child,
  24182. loc: child.loc,
  24183. codegenNode: createCallExpression(
  24184. context.helper(CREATE_TEXT),
  24185. callArgs
  24186. )
  24187. };
  24188. }
  24189. }
  24190. };
  24191. }
  24192. };
  24193. const seen$1 = /* @__PURE__ */ new WeakSet();
  24194. const transformOnce = (node, context) => {
  24195. if (node.type === 1 && findDir(node, "once", true)) {
  24196. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  24197. return;
  24198. }
  24199. seen$1.add(node);
  24200. context.inVOnce = true;
  24201. context.helper(SET_BLOCK_TRACKING);
  24202. return () => {
  24203. context.inVOnce = false;
  24204. const cur = context.currentNode;
  24205. if (cur.codegenNode) {
  24206. cur.codegenNode = context.cache(
  24207. cur.codegenNode,
  24208. true
  24209. /* isVNode */
  24210. );
  24211. }
  24212. };
  24213. }
  24214. };
  24215. const transformModel$1 = (dir, node, context) => {
  24216. const { exp, arg } = dir;
  24217. if (!exp) {
  24218. context.onError(
  24219. createCompilerError(41, dir.loc)
  24220. );
  24221. return createTransformProps();
  24222. }
  24223. const rawExp = exp.loc.source.trim();
  24224. const expString = exp.type === 4 ? exp.content : rawExp;
  24225. const bindingType = context.bindingMetadata[rawExp];
  24226. if (bindingType === "props" || bindingType === "props-aliased") {
  24227. context.onError(createCompilerError(44, exp.loc));
  24228. return createTransformProps();
  24229. }
  24230. const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
  24231. if (!expString.trim() || !isMemberExpression(exp, context) && !maybeRef) {
  24232. context.onError(
  24233. createCompilerError(42, exp.loc)
  24234. );
  24235. return createTransformProps();
  24236. }
  24237. if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
  24238. context.onError(
  24239. createCompilerError(43, exp.loc)
  24240. );
  24241. return createTransformProps();
  24242. }
  24243. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  24244. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  24245. let assignmentExp;
  24246. const eventArg = context.isTS ? `($event: any)` : `$event`;
  24247. if (maybeRef) {
  24248. if (bindingType === "setup-ref") {
  24249. assignmentExp = createCompoundExpression([
  24250. `${eventArg} => ((`,
  24251. createSimpleExpression(rawExp, false, exp.loc),
  24252. `).value = $event)`
  24253. ]);
  24254. } else {
  24255. const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
  24256. assignmentExp = createCompoundExpression([
  24257. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
  24258. createSimpleExpression(rawExp, false, exp.loc),
  24259. `).value = $event : ${altAssignment})`
  24260. ]);
  24261. }
  24262. } else {
  24263. assignmentExp = createCompoundExpression([
  24264. `${eventArg} => ((`,
  24265. exp,
  24266. `) = $event)`
  24267. ]);
  24268. }
  24269. const props = [
  24270. // modelValue: foo
  24271. createObjectProperty(propName, dir.exp),
  24272. // "onUpdate:modelValue": $event => (foo = $event)
  24273. createObjectProperty(eventName, assignmentExp)
  24274. ];
  24275. if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
  24276. props[1].value = context.cache(props[1].value);
  24277. }
  24278. if (dir.modifiers.length && node.tagType === 1) {
  24279. const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  24280. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  24281. props.push(
  24282. createObjectProperty(
  24283. modifiersKey,
  24284. createSimpleExpression(
  24285. `{ ${modifiers} }`,
  24286. false,
  24287. dir.loc,
  24288. 2
  24289. )
  24290. )
  24291. );
  24292. }
  24293. return createTransformProps(props);
  24294. };
  24295. function createTransformProps(props = []) {
  24296. return { props };
  24297. }
  24298. const seen = /* @__PURE__ */ new WeakSet();
  24299. const transformMemo = (node, context) => {
  24300. if (node.type === 1) {
  24301. const dir = findDir(node, "memo");
  24302. if (!dir || seen.has(node)) {
  24303. return;
  24304. }
  24305. seen.add(node);
  24306. return () => {
  24307. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  24308. if (codegenNode && codegenNode.type === 13) {
  24309. if (node.tagType !== 1) {
  24310. convertToBlock(codegenNode, context);
  24311. }
  24312. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  24313. dir.exp,
  24314. createFunctionExpression(void 0, codegenNode),
  24315. `_cache`,
  24316. String(context.cached.length)
  24317. ]);
  24318. context.cached.push(null);
  24319. }
  24320. };
  24321. }
  24322. };
  24323. function getBaseTransformPreset(prefixIdentifiers) {
  24324. return [
  24325. [
  24326. transformOnce,
  24327. transformIf,
  24328. transformMemo,
  24329. transformFor,
  24330. ...[],
  24331. ...prefixIdentifiers ? [
  24332. // order is important
  24333. trackVForSlotScopes,
  24334. transformExpression
  24335. ] : [],
  24336. transformSlotOutlet,
  24337. transformElement,
  24338. trackSlotScopes,
  24339. transformText
  24340. ],
  24341. {
  24342. on: transformOn$1,
  24343. bind: transformBind,
  24344. model: transformModel$1
  24345. }
  24346. ];
  24347. }
  24348. function baseCompile(source, options = {}) {
  24349. const onError = options.onError || defaultOnError;
  24350. const isModuleMode = options.mode === "module";
  24351. const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
  24352. if (!prefixIdentifiers && options.cacheHandlers) {
  24353. onError(createCompilerError(49));
  24354. }
  24355. if (options.scopeId && !isModuleMode) {
  24356. onError(createCompilerError(50));
  24357. }
  24358. const resolvedOptions = extend({}, options, {
  24359. prefixIdentifiers
  24360. });
  24361. const ast = isString$1(source) ? baseParse(source, resolvedOptions) : source;
  24362. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  24363. if (options.isTS) {
  24364. const { expressionPlugins } = options;
  24365. if (!expressionPlugins || !expressionPlugins.includes("typescript")) {
  24366. options.expressionPlugins = [...expressionPlugins || [], "typescript"];
  24367. }
  24368. }
  24369. transform(
  24370. ast,
  24371. extend({}, resolvedOptions, {
  24372. nodeTransforms: [
  24373. ...nodeTransforms,
  24374. ...options.nodeTransforms || []
  24375. // user transforms
  24376. ],
  24377. directiveTransforms: extend(
  24378. {},
  24379. directiveTransforms,
  24380. options.directiveTransforms || {}
  24381. // user transforms
  24382. )
  24383. })
  24384. );
  24385. return generate(ast, resolvedOptions);
  24386. }
  24387. const BindingTypes = {
  24388. "DATA": "data",
  24389. "PROPS": "props",
  24390. "PROPS_ALIASED": "props-aliased",
  24391. "SETUP_LET": "setup-let",
  24392. "SETUP_CONST": "setup-const",
  24393. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  24394. "SETUP_MAYBE_REF": "setup-maybe-ref",
  24395. "SETUP_REF": "setup-ref",
  24396. "OPTIONS": "options",
  24397. "LITERAL_CONST": "literal-const"
  24398. };
  24399. const noopDirectiveTransform = () => ({ props: [] });
  24400. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  24401. const V_MODEL_CHECKBOX = Symbol(
  24402. `vModelCheckbox`
  24403. );
  24404. const V_MODEL_TEXT = Symbol(`vModelText` );
  24405. const V_MODEL_SELECT = Symbol(
  24406. `vModelSelect`
  24407. );
  24408. const V_MODEL_DYNAMIC = Symbol(
  24409. `vModelDynamic`
  24410. );
  24411. const V_ON_WITH_MODIFIERS = Symbol(
  24412. `vOnModifiersGuard`
  24413. );
  24414. const V_ON_WITH_KEYS = Symbol(
  24415. `vOnKeysGuard`
  24416. );
  24417. const V_SHOW = Symbol(`vShow` );
  24418. const TRANSITION = Symbol(`Transition` );
  24419. const TRANSITION_GROUP = Symbol(
  24420. `TransitionGroup`
  24421. );
  24422. registerRuntimeHelpers({
  24423. [V_MODEL_RADIO]: `vModelRadio`,
  24424. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  24425. [V_MODEL_TEXT]: `vModelText`,
  24426. [V_MODEL_SELECT]: `vModelSelect`,
  24427. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  24428. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  24429. [V_ON_WITH_KEYS]: `withKeys`,
  24430. [V_SHOW]: `vShow`,
  24431. [TRANSITION]: `Transition`,
  24432. [TRANSITION_GROUP]: `TransitionGroup`
  24433. });
  24434. const parserOptions = {
  24435. parseMode: "html",
  24436. isVoidTag,
  24437. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  24438. isPreTag: (tag) => tag === "pre",
  24439. isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
  24440. decodeEntities: void 0,
  24441. isBuiltInComponent: (tag) => {
  24442. if (tag === "Transition" || tag === "transition") {
  24443. return TRANSITION;
  24444. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  24445. return TRANSITION_GROUP;
  24446. }
  24447. },
  24448. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  24449. getNamespace(tag, parent, rootNamespace) {
  24450. let ns = parent ? parent.ns : rootNamespace;
  24451. if (parent && ns === 2) {
  24452. if (parent.tag === "annotation-xml") {
  24453. if (tag === "svg") {
  24454. return 1;
  24455. }
  24456. if (parent.props.some(
  24457. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  24458. )) {
  24459. ns = 0;
  24460. }
  24461. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  24462. ns = 0;
  24463. }
  24464. } else if (parent && ns === 1) {
  24465. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  24466. ns = 0;
  24467. }
  24468. }
  24469. if (ns === 0) {
  24470. if (tag === "svg") {
  24471. return 1;
  24472. }
  24473. if (tag === "math") {
  24474. return 2;
  24475. }
  24476. }
  24477. return ns;
  24478. }
  24479. };
  24480. const transformStyle = (node) => {
  24481. if (node.type === 1) {
  24482. node.props.forEach((p, i) => {
  24483. if (p.type === 6 && p.name === "style" && p.value) {
  24484. node.props[i] = {
  24485. type: 7,
  24486. name: `bind`,
  24487. arg: createSimpleExpression(`style`, true, p.loc),
  24488. exp: parseInlineCSS(p.value.content, p.loc),
  24489. modifiers: [],
  24490. loc: p.loc
  24491. };
  24492. }
  24493. });
  24494. }
  24495. };
  24496. const parseInlineCSS = (cssText, loc) => {
  24497. const normalized = parseStringStyle(cssText);
  24498. return createSimpleExpression(
  24499. JSON.stringify(normalized),
  24500. false,
  24501. loc,
  24502. 3
  24503. );
  24504. };
  24505. function createDOMCompilerError(code, loc) {
  24506. return createCompilerError(
  24507. code,
  24508. loc,
  24509. DOMErrorMessages
  24510. );
  24511. }
  24512. const DOMErrorCodes = {
  24513. "X_V_HTML_NO_EXPRESSION": 53,
  24514. "53": "X_V_HTML_NO_EXPRESSION",
  24515. "X_V_HTML_WITH_CHILDREN": 54,
  24516. "54": "X_V_HTML_WITH_CHILDREN",
  24517. "X_V_TEXT_NO_EXPRESSION": 55,
  24518. "55": "X_V_TEXT_NO_EXPRESSION",
  24519. "X_V_TEXT_WITH_CHILDREN": 56,
  24520. "56": "X_V_TEXT_WITH_CHILDREN",
  24521. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  24522. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  24523. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  24524. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  24525. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  24526. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  24527. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  24528. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  24529. "X_V_SHOW_NO_EXPRESSION": 61,
  24530. "61": "X_V_SHOW_NO_EXPRESSION",
  24531. "X_TRANSITION_INVALID_CHILDREN": 62,
  24532. "62": "X_TRANSITION_INVALID_CHILDREN",
  24533. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  24534. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  24535. "__EXTEND_POINT__": 64,
  24536. "64": "__EXTEND_POINT__"
  24537. };
  24538. const DOMErrorMessages = {
  24539. [53]: `v-html is missing expression.`,
  24540. [54]: `v-html will override element children.`,
  24541. [55]: `v-text is missing expression.`,
  24542. [56]: `v-text will override element children.`,
  24543. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  24544. [58]: `v-model argument is not supported on plain elements.`,
  24545. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  24546. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  24547. [61]: `v-show is missing expression.`,
  24548. [62]: `<Transition> expects exactly one child element or component.`,
  24549. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  24550. };
  24551. const transformVHtml = (dir, node, context) => {
  24552. const { exp, loc } = dir;
  24553. if (!exp) {
  24554. context.onError(
  24555. createDOMCompilerError(53, loc)
  24556. );
  24557. }
  24558. if (node.children.length) {
  24559. context.onError(
  24560. createDOMCompilerError(54, loc)
  24561. );
  24562. node.children.length = 0;
  24563. }
  24564. return {
  24565. props: [
  24566. createObjectProperty(
  24567. createSimpleExpression(`innerHTML`, true, loc),
  24568. exp || createSimpleExpression("", true)
  24569. )
  24570. ]
  24571. };
  24572. };
  24573. const transformVText = (dir, node, context) => {
  24574. const { exp, loc } = dir;
  24575. if (!exp) {
  24576. context.onError(
  24577. createDOMCompilerError(55, loc)
  24578. );
  24579. }
  24580. if (node.children.length) {
  24581. context.onError(
  24582. createDOMCompilerError(56, loc)
  24583. );
  24584. node.children.length = 0;
  24585. }
  24586. return {
  24587. props: [
  24588. createObjectProperty(
  24589. createSimpleExpression(`textContent`, true),
  24590. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  24591. context.helperString(TO_DISPLAY_STRING),
  24592. [exp],
  24593. loc
  24594. ) : createSimpleExpression("", true)
  24595. )
  24596. ]
  24597. };
  24598. };
  24599. const transformModel = (dir, node, context) => {
  24600. const baseResult = transformModel$1(dir, node, context);
  24601. if (!baseResult.props.length || node.tagType === 1) {
  24602. return baseResult;
  24603. }
  24604. if (dir.arg) {
  24605. context.onError(
  24606. createDOMCompilerError(
  24607. 58,
  24608. dir.arg.loc
  24609. )
  24610. );
  24611. }
  24612. function checkDuplicatedValue() {
  24613. const value = findDir(node, "bind");
  24614. if (value && isStaticArgOf(value.arg, "value")) {
  24615. context.onError(
  24616. createDOMCompilerError(
  24617. 60,
  24618. value.loc
  24619. )
  24620. );
  24621. }
  24622. }
  24623. const { tag } = node;
  24624. const isCustomElement = context.isCustomElement(tag);
  24625. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  24626. let directiveToUse = V_MODEL_TEXT;
  24627. let isInvalidType = false;
  24628. if (tag === "input" || isCustomElement) {
  24629. const type = findProp(node, `type`);
  24630. if (type) {
  24631. if (type.type === 7) {
  24632. directiveToUse = V_MODEL_DYNAMIC;
  24633. } else if (type.value) {
  24634. switch (type.value.content) {
  24635. case "radio":
  24636. directiveToUse = V_MODEL_RADIO;
  24637. break;
  24638. case "checkbox":
  24639. directiveToUse = V_MODEL_CHECKBOX;
  24640. break;
  24641. case "file":
  24642. isInvalidType = true;
  24643. context.onError(
  24644. createDOMCompilerError(
  24645. 59,
  24646. dir.loc
  24647. )
  24648. );
  24649. break;
  24650. default:
  24651. checkDuplicatedValue();
  24652. break;
  24653. }
  24654. }
  24655. } else if (hasDynamicKeyVBind(node)) {
  24656. directiveToUse = V_MODEL_DYNAMIC;
  24657. } else {
  24658. checkDuplicatedValue();
  24659. }
  24660. } else if (tag === "select") {
  24661. directiveToUse = V_MODEL_SELECT;
  24662. } else {
  24663. checkDuplicatedValue();
  24664. }
  24665. if (!isInvalidType) {
  24666. baseResult.needRuntime = context.helper(directiveToUse);
  24667. }
  24668. } else {
  24669. context.onError(
  24670. createDOMCompilerError(
  24671. 57,
  24672. dir.loc
  24673. )
  24674. );
  24675. }
  24676. baseResult.props = baseResult.props.filter(
  24677. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  24678. );
  24679. return baseResult;
  24680. };
  24681. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  24682. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  24683. // event propagation management
  24684. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  24685. );
  24686. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  24687. const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
  24688. const resolveModifiers = (key, modifiers, context, loc) => {
  24689. const keyModifiers = [];
  24690. const nonKeyModifiers = [];
  24691. const eventOptionModifiers = [];
  24692. for (let i = 0; i < modifiers.length; i++) {
  24693. const modifier = modifiers[i].content;
  24694. if (isEventOptionModifier(modifier)) {
  24695. eventOptionModifiers.push(modifier);
  24696. } else {
  24697. if (maybeKeyModifier(modifier)) {
  24698. if (isStaticExp(key)) {
  24699. if (isKeyboardEvent(key.content.toLowerCase())) {
  24700. keyModifiers.push(modifier);
  24701. } else {
  24702. nonKeyModifiers.push(modifier);
  24703. }
  24704. } else {
  24705. keyModifiers.push(modifier);
  24706. nonKeyModifiers.push(modifier);
  24707. }
  24708. } else {
  24709. if (isNonKeyModifier(modifier)) {
  24710. nonKeyModifiers.push(modifier);
  24711. } else {
  24712. keyModifiers.push(modifier);
  24713. }
  24714. }
  24715. }
  24716. }
  24717. return {
  24718. keyModifiers,
  24719. nonKeyModifiers,
  24720. eventOptionModifiers
  24721. };
  24722. };
  24723. const transformClick = (key, event) => {
  24724. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  24725. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  24726. `(`,
  24727. key,
  24728. `) === "onClick" ? "${event}" : (`,
  24729. key,
  24730. `)`
  24731. ]) : key;
  24732. };
  24733. const transformOn = (dir, node, context) => {
  24734. return transformOn$1(dir, node, context, (baseResult) => {
  24735. const { modifiers } = dir;
  24736. if (!modifiers.length) return baseResult;
  24737. let { key, value: handlerExp } = baseResult.props[0];
  24738. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  24739. if (nonKeyModifiers.includes("right")) {
  24740. key = transformClick(key, `onContextmenu`);
  24741. }
  24742. if (nonKeyModifiers.includes("middle")) {
  24743. key = transformClick(key, `onMouseup`);
  24744. }
  24745. if (nonKeyModifiers.length) {
  24746. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  24747. handlerExp,
  24748. JSON.stringify(nonKeyModifiers)
  24749. ]);
  24750. }
  24751. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  24752. (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
  24753. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  24754. handlerExp,
  24755. JSON.stringify(keyModifiers)
  24756. ]);
  24757. }
  24758. if (eventOptionModifiers.length) {
  24759. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  24760. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  24761. }
  24762. return {
  24763. props: [createObjectProperty(key, handlerExp)]
  24764. };
  24765. });
  24766. };
  24767. const transformShow = (dir, node, context) => {
  24768. const { exp, loc } = dir;
  24769. if (!exp) {
  24770. context.onError(
  24771. createDOMCompilerError(61, loc)
  24772. );
  24773. }
  24774. return {
  24775. props: [],
  24776. needRuntime: context.helper(V_SHOW)
  24777. };
  24778. };
  24779. const transformTransition = (node, context) => {
  24780. if (node.type === 1 && node.tagType === 1) {
  24781. const component = context.isBuiltInComponent(node.tag);
  24782. if (component === TRANSITION) {
  24783. return () => {
  24784. if (!node.children.length) {
  24785. return;
  24786. }
  24787. if (hasMultipleChildren(node)) {
  24788. context.onError(
  24789. createDOMCompilerError(
  24790. 62,
  24791. {
  24792. start: node.children[0].loc.start,
  24793. end: node.children[node.children.length - 1].loc.end,
  24794. source: ""
  24795. }
  24796. )
  24797. );
  24798. }
  24799. const child = node.children[0];
  24800. if (child.type === 1) {
  24801. for (const p of child.props) {
  24802. if (p.type === 7 && p.name === "show") {
  24803. node.props.push({
  24804. type: 6,
  24805. name: "persisted",
  24806. nameLoc: node.loc,
  24807. value: void 0,
  24808. loc: node.loc
  24809. });
  24810. }
  24811. }
  24812. }
  24813. };
  24814. }
  24815. }
  24816. };
  24817. function hasMultipleChildren(node) {
  24818. const children = node.children = node.children.filter(
  24819. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  24820. );
  24821. const child = children[0];
  24822. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  24823. }
  24824. const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
  24825. const stringifyStatic = (children, context, parent) => {
  24826. if (context.scopes.vSlot > 0) {
  24827. return;
  24828. }
  24829. const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray$3(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
  24830. let nc = 0;
  24831. let ec = 0;
  24832. const currentChunk = [];
  24833. const stringifyCurrentChunk = (currentIndex) => {
  24834. if (nc >= 20 || ec >= 5) {
  24835. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  24836. JSON.stringify(
  24837. currentChunk.map((node) => stringifyNode(node, context)).join("")
  24838. ).replace(expReplaceRE, `" + $1 + "`),
  24839. // the 2nd argument indicates the number of DOM nodes this static vnode
  24840. // will insert / hydrate
  24841. String(currentChunk.length)
  24842. ]);
  24843. const deleteCount = currentChunk.length - 1;
  24844. if (isParentCached) {
  24845. children.splice(
  24846. currentIndex - currentChunk.length,
  24847. currentChunk.length,
  24848. // @ts-expect-error
  24849. staticCall
  24850. );
  24851. } else {
  24852. currentChunk[0].codegenNode.value = staticCall;
  24853. if (currentChunk.length > 1) {
  24854. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  24855. const cacheIndex = context.cached.indexOf(
  24856. currentChunk[currentChunk.length - 1].codegenNode
  24857. );
  24858. if (cacheIndex > -1) {
  24859. for (let i2 = cacheIndex; i2 < context.cached.length; i2++) {
  24860. const c = context.cached[i2];
  24861. if (c) c.index -= deleteCount;
  24862. }
  24863. context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
  24864. }
  24865. }
  24866. }
  24867. return deleteCount;
  24868. }
  24869. return 0;
  24870. };
  24871. let i = 0;
  24872. for (; i < children.length; i++) {
  24873. const child = children[i];
  24874. const isCached = isParentCached || getCachedNode(child);
  24875. if (isCached) {
  24876. const result = analyzeNode(child);
  24877. if (result) {
  24878. nc += result[0];
  24879. ec += result[1];
  24880. currentChunk.push(child);
  24881. continue;
  24882. }
  24883. }
  24884. i -= stringifyCurrentChunk(i);
  24885. nc = 0;
  24886. ec = 0;
  24887. currentChunk.length = 0;
  24888. }
  24889. stringifyCurrentChunk(i);
  24890. };
  24891. const getCachedNode = (node) => {
  24892. if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) {
  24893. return node.codegenNode;
  24894. }
  24895. };
  24896. const dataAriaRE = /^(data|aria)-/;
  24897. const isStringifiableAttr = (name, ns) => {
  24898. return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : ns === 2 ? isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
  24899. };
  24900. const isNonStringifiable = /* @__PURE__ */ makeMap(
  24901. `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
  24902. );
  24903. function analyzeNode(node) {
  24904. if (node.type === 1 && isNonStringifiable(node.tag)) {
  24905. return false;
  24906. }
  24907. if (node.type === 12) {
  24908. return [1, 0];
  24909. }
  24910. let nc = 1;
  24911. let ec = node.props.length > 0 ? 1 : 0;
  24912. let bailed = false;
  24913. const bail = () => {
  24914. bailed = true;
  24915. return false;
  24916. };
  24917. function walk(node2) {
  24918. const isOptionTag = node2.tag === "option" && node2.ns === 0;
  24919. for (let i = 0; i < node2.props.length; i++) {
  24920. const p = node2.props[i];
  24921. if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
  24922. return bail();
  24923. }
  24924. if (p.type === 7 && p.name === "bind") {
  24925. if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
  24926. return bail();
  24927. }
  24928. if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
  24929. return bail();
  24930. }
  24931. if (isOptionTag && isStaticArgOf(p.arg, "value") && p.exp && !p.exp.isStatic) {
  24932. return bail();
  24933. }
  24934. }
  24935. }
  24936. for (let i = 0; i < node2.children.length; i++) {
  24937. nc++;
  24938. const child = node2.children[i];
  24939. if (child.type === 1) {
  24940. if (child.props.length > 0) {
  24941. ec++;
  24942. }
  24943. walk(child);
  24944. if (bailed) {
  24945. return false;
  24946. }
  24947. }
  24948. }
  24949. return true;
  24950. }
  24951. return walk(node) ? [nc, ec] : false;
  24952. }
  24953. function stringifyNode(node, context) {
  24954. if (isString$1(node)) {
  24955. return node;
  24956. }
  24957. if (isSymbol$1(node)) {
  24958. return ``;
  24959. }
  24960. switch (node.type) {
  24961. case 1:
  24962. return stringifyElement(node, context);
  24963. case 2:
  24964. return escapeHtml(node.content);
  24965. case 3:
  24966. return `<!--${escapeHtml(node.content)}-->`;
  24967. case 5:
  24968. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  24969. case 8:
  24970. return escapeHtml(evaluateConstant(node));
  24971. case 12:
  24972. return stringifyNode(node.content, context);
  24973. default:
  24974. return "";
  24975. }
  24976. }
  24977. function stringifyElement(node, context) {
  24978. let res = `<${node.tag}`;
  24979. let innerHTML = "";
  24980. for (let i = 0; i < node.props.length; i++) {
  24981. const p = node.props[i];
  24982. if (p.type === 6) {
  24983. res += ` ${p.name}`;
  24984. if (p.value) {
  24985. res += `="${escapeHtml(p.value.content)}"`;
  24986. }
  24987. } else if (p.type === 7) {
  24988. if (p.name === "bind") {
  24989. const exp = p.exp;
  24990. if (exp.content[0] === "_") {
  24991. res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
  24992. continue;
  24993. }
  24994. if (isBooleanAttr(p.arg.content) && exp.content === "false") {
  24995. continue;
  24996. }
  24997. let evaluated = evaluateConstant(exp);
  24998. if (evaluated != null) {
  24999. const arg = p.arg && p.arg.content;
  25000. if (arg === "class") {
  25001. evaluated = normalizeClass(evaluated);
  25002. } else if (arg === "style") {
  25003. evaluated = stringifyStyle(normalizeStyle(evaluated));
  25004. }
  25005. res += ` ${p.arg.content}="${escapeHtml(
  25006. evaluated
  25007. )}"`;
  25008. }
  25009. } else if (p.name === "html") {
  25010. innerHTML = evaluateConstant(p.exp);
  25011. } else if (p.name === "text") {
  25012. innerHTML = escapeHtml(
  25013. toDisplayString(evaluateConstant(p.exp))
  25014. );
  25015. }
  25016. }
  25017. }
  25018. if (context.scopeId) {
  25019. res += ` ${context.scopeId}`;
  25020. }
  25021. res += `>`;
  25022. if (innerHTML) {
  25023. res += innerHTML;
  25024. } else {
  25025. for (let i = 0; i < node.children.length; i++) {
  25026. res += stringifyNode(node.children[i], context);
  25027. }
  25028. }
  25029. if (!isVoidTag(node.tag)) {
  25030. res += `</${node.tag}>`;
  25031. }
  25032. return res;
  25033. }
  25034. function evaluateConstant(exp) {
  25035. if (exp.type === 4) {
  25036. return new Function(`return (${exp.content})`)();
  25037. } else {
  25038. let res = ``;
  25039. exp.children.forEach((c) => {
  25040. if (isString$1(c) || isSymbol$1(c)) {
  25041. return;
  25042. }
  25043. if (c.type === 2) {
  25044. res += c.content;
  25045. } else if (c.type === 5) {
  25046. res += toDisplayString(evaluateConstant(c.content));
  25047. } else {
  25048. res += evaluateConstant(c);
  25049. }
  25050. });
  25051. return res;
  25052. }
  25053. }
  25054. const ignoreSideEffectTags = (node, context) => {
  25055. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  25056. context.onError(
  25057. createDOMCompilerError(
  25058. 63,
  25059. node.loc
  25060. )
  25061. );
  25062. context.removeNode();
  25063. }
  25064. };
  25065. function isValidHTMLNesting(parent, child) {
  25066. if (parent in onlyValidChildren) {
  25067. return onlyValidChildren[parent].has(child);
  25068. }
  25069. if (child in onlyValidParents) {
  25070. return onlyValidParents[child].has(parent);
  25071. }
  25072. if (parent in knownInvalidChildren) {
  25073. if (knownInvalidChildren[parent].has(child)) return false;
  25074. }
  25075. if (child in knownInvalidParents) {
  25076. if (knownInvalidParents[child].has(parent)) return false;
  25077. }
  25078. return true;
  25079. }
  25080. const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
  25081. const emptySet = /* @__PURE__ */ new Set([]);
  25082. const onlyValidChildren = {
  25083. head: /* @__PURE__ */ new Set([
  25084. "base",
  25085. "basefront",
  25086. "bgsound",
  25087. "link",
  25088. "meta",
  25089. "title",
  25090. "noscript",
  25091. "noframes",
  25092. "style",
  25093. "script",
  25094. "template"
  25095. ]),
  25096. optgroup: /* @__PURE__ */ new Set(["option"]),
  25097. select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
  25098. // table
  25099. table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
  25100. tr: /* @__PURE__ */ new Set(["td", "th"]),
  25101. colgroup: /* @__PURE__ */ new Set(["col"]),
  25102. tbody: /* @__PURE__ */ new Set(["tr"]),
  25103. thead: /* @__PURE__ */ new Set(["tr"]),
  25104. tfoot: /* @__PURE__ */ new Set(["tr"]),
  25105. // these elements can not have any children elements
  25106. script: emptySet,
  25107. iframe: emptySet,
  25108. option: emptySet,
  25109. textarea: emptySet,
  25110. style: emptySet,
  25111. title: emptySet
  25112. };
  25113. const onlyValidParents = {
  25114. // sections
  25115. html: emptySet,
  25116. body: /* @__PURE__ */ new Set(["html"]),
  25117. head: /* @__PURE__ */ new Set(["html"]),
  25118. // table
  25119. td: /* @__PURE__ */ new Set(["tr"]),
  25120. colgroup: /* @__PURE__ */ new Set(["table"]),
  25121. caption: /* @__PURE__ */ new Set(["table"]),
  25122. tbody: /* @__PURE__ */ new Set(["table"]),
  25123. tfoot: /* @__PURE__ */ new Set(["table"]),
  25124. col: /* @__PURE__ */ new Set(["colgroup"]),
  25125. th: /* @__PURE__ */ new Set(["tr"]),
  25126. thead: /* @__PURE__ */ new Set(["table"]),
  25127. tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
  25128. // data list
  25129. dd: /* @__PURE__ */ new Set(["dl", "div"]),
  25130. dt: /* @__PURE__ */ new Set(["dl", "div"]),
  25131. // other
  25132. figcaption: /* @__PURE__ */ new Set(["figure"]),
  25133. // li: new Set(["ul", "ol"]),
  25134. summary: /* @__PURE__ */ new Set(["details"]),
  25135. area: /* @__PURE__ */ new Set(["map"])
  25136. };
  25137. const knownInvalidChildren = {
  25138. p: /* @__PURE__ */ new Set([
  25139. "address",
  25140. "article",
  25141. "aside",
  25142. "blockquote",
  25143. "center",
  25144. "details",
  25145. "dialog",
  25146. "dir",
  25147. "div",
  25148. "dl",
  25149. "fieldset",
  25150. "figure",
  25151. "footer",
  25152. "form",
  25153. "h1",
  25154. "h2",
  25155. "h3",
  25156. "h4",
  25157. "h5",
  25158. "h6",
  25159. "header",
  25160. "hgroup",
  25161. "hr",
  25162. "li",
  25163. "main",
  25164. "nav",
  25165. "menu",
  25166. "ol",
  25167. "p",
  25168. "pre",
  25169. "section",
  25170. "table",
  25171. "ul"
  25172. ]),
  25173. svg: /* @__PURE__ */ new Set([
  25174. "b",
  25175. "blockquote",
  25176. "br",
  25177. "code",
  25178. "dd",
  25179. "div",
  25180. "dl",
  25181. "dt",
  25182. "em",
  25183. "embed",
  25184. "h1",
  25185. "h2",
  25186. "h3",
  25187. "h4",
  25188. "h5",
  25189. "h6",
  25190. "hr",
  25191. "i",
  25192. "img",
  25193. "li",
  25194. "menu",
  25195. "meta",
  25196. "ol",
  25197. "p",
  25198. "pre",
  25199. "ruby",
  25200. "s",
  25201. "small",
  25202. "span",
  25203. "strong",
  25204. "sub",
  25205. "sup",
  25206. "table",
  25207. "u",
  25208. "ul",
  25209. "var"
  25210. ])
  25211. };
  25212. const knownInvalidParents = {
  25213. a: /* @__PURE__ */ new Set(["a"]),
  25214. button: /* @__PURE__ */ new Set(["button"]),
  25215. dd: /* @__PURE__ */ new Set(["dd", "dt"]),
  25216. dt: /* @__PURE__ */ new Set(["dd", "dt"]),
  25217. form: /* @__PURE__ */ new Set(["form"]),
  25218. li: /* @__PURE__ */ new Set(["li"]),
  25219. h1: headings,
  25220. h2: headings,
  25221. h3: headings,
  25222. h4: headings,
  25223. h5: headings,
  25224. h6: headings
  25225. };
  25226. const validateHtmlNesting = (node, context) => {
  25227. if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
  25228. const error = new SyntaxError(
  25229. `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
  25230. );
  25231. error.loc = node.loc;
  25232. context.onWarn(error);
  25233. }
  25234. };
  25235. const DOMNodeTransforms = [
  25236. transformStyle,
  25237. ...[transformTransition, validateHtmlNesting]
  25238. ];
  25239. const DOMDirectiveTransforms = {
  25240. cloak: noopDirectiveTransform,
  25241. html: transformVHtml,
  25242. text: transformVText,
  25243. model: transformModel,
  25244. // override compiler-core
  25245. on: transformOn,
  25246. // override compiler-core
  25247. show: transformShow
  25248. };
  25249. function compile$1(src, options = {}) {
  25250. return baseCompile(
  25251. src,
  25252. extend({}, parserOptions, options, {
  25253. nodeTransforms: [
  25254. // ignore <script> and <tag>
  25255. // this is not put inside DOMNodeTransforms because that list is used
  25256. // by compiler-ssr to generate vnode fallback branches
  25257. ignoreSideEffectTags,
  25258. ...DOMNodeTransforms,
  25259. ...options.nodeTransforms || []
  25260. ],
  25261. directiveTransforms: extend(
  25262. {},
  25263. DOMDirectiveTransforms,
  25264. options.directiveTransforms || {}
  25265. ),
  25266. transformHoist: stringifyStatic
  25267. })
  25268. );
  25269. }
  25270. function parse$3(template, options = {}) {
  25271. return baseParse(template, extend({}, parserOptions, options));
  25272. }
  25273. var CompilerDOM = /*#__PURE__*/Object.freeze({
  25274. __proto__: null,
  25275. BASE_TRANSITION: BASE_TRANSITION,
  25276. BindingTypes: BindingTypes,
  25277. CAMELIZE: CAMELIZE,
  25278. CAPITALIZE: CAPITALIZE,
  25279. CREATE_BLOCK: CREATE_BLOCK,
  25280. CREATE_COMMENT: CREATE_COMMENT,
  25281. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  25282. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  25283. CREATE_SLOTS: CREATE_SLOTS,
  25284. CREATE_STATIC: CREATE_STATIC,
  25285. CREATE_TEXT: CREATE_TEXT,
  25286. CREATE_VNODE: CREATE_VNODE,
  25287. CompilerDeprecationTypes: CompilerDeprecationTypes,
  25288. ConstantTypes: ConstantTypes,
  25289. DOMDirectiveTransforms: DOMDirectiveTransforms,
  25290. DOMErrorCodes: DOMErrorCodes,
  25291. DOMErrorMessages: DOMErrorMessages,
  25292. DOMNodeTransforms: DOMNodeTransforms,
  25293. ElementTypes: ElementTypes,
  25294. ErrorCodes: ErrorCodes,
  25295. FRAGMENT: FRAGMENT,
  25296. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  25297. IS_MEMO_SAME: IS_MEMO_SAME,
  25298. IS_REF: IS_REF,
  25299. KEEP_ALIVE: KEEP_ALIVE,
  25300. MERGE_PROPS: MERGE_PROPS,
  25301. NORMALIZE_CLASS: NORMALIZE_CLASS,
  25302. NORMALIZE_PROPS: NORMALIZE_PROPS,
  25303. NORMALIZE_STYLE: NORMALIZE_STYLE,
  25304. Namespaces: Namespaces,
  25305. NodeTypes: NodeTypes,
  25306. OPEN_BLOCK: OPEN_BLOCK,
  25307. POP_SCOPE_ID: POP_SCOPE_ID,
  25308. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  25309. RENDER_LIST: RENDER_LIST,
  25310. RENDER_SLOT: RENDER_SLOT,
  25311. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  25312. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  25313. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  25314. RESOLVE_FILTER: RESOLVE_FILTER,
  25315. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  25316. SUSPENSE: SUSPENSE,
  25317. TELEPORT: TELEPORT,
  25318. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  25319. TO_HANDLERS: TO_HANDLERS,
  25320. TO_HANDLER_KEY: TO_HANDLER_KEY,
  25321. TRANSITION: TRANSITION,
  25322. TRANSITION_GROUP: TRANSITION_GROUP,
  25323. TS_NODE_TYPES: TS_NODE_TYPES,
  25324. UNREF: UNREF,
  25325. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  25326. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  25327. V_MODEL_RADIO: V_MODEL_RADIO,
  25328. V_MODEL_SELECT: V_MODEL_SELECT,
  25329. V_MODEL_TEXT: V_MODEL_TEXT,
  25330. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  25331. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  25332. V_SHOW: V_SHOW,
  25333. WITH_CTX: WITH_CTX,
  25334. WITH_DIRECTIVES: WITH_DIRECTIVES,
  25335. WITH_MEMO: WITH_MEMO,
  25336. advancePositionWithClone: advancePositionWithClone,
  25337. advancePositionWithMutation: advancePositionWithMutation,
  25338. assert: assert,
  25339. baseCompile: baseCompile,
  25340. baseParse: baseParse,
  25341. buildDirectiveArgs: buildDirectiveArgs,
  25342. buildProps: buildProps,
  25343. buildSlots: buildSlots,
  25344. checkCompatEnabled: checkCompatEnabled,
  25345. compile: compile$1,
  25346. convertToBlock: convertToBlock,
  25347. createArrayExpression: createArrayExpression,
  25348. createAssignmentExpression: createAssignmentExpression,
  25349. createBlockStatement: createBlockStatement,
  25350. createCacheExpression: createCacheExpression,
  25351. createCallExpression: createCallExpression,
  25352. createCompilerError: createCompilerError,
  25353. createCompoundExpression: createCompoundExpression,
  25354. createConditionalExpression: createConditionalExpression,
  25355. createDOMCompilerError: createDOMCompilerError,
  25356. createForLoopParams: createForLoopParams,
  25357. createFunctionExpression: createFunctionExpression,
  25358. createIfStatement: createIfStatement,
  25359. createInterpolation: createInterpolation,
  25360. createObjectExpression: createObjectExpression,
  25361. createObjectProperty: createObjectProperty,
  25362. createReturnStatement: createReturnStatement,
  25363. createRoot: createRoot,
  25364. createSequenceExpression: createSequenceExpression,
  25365. createSimpleExpression: createSimpleExpression,
  25366. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  25367. createTemplateLiteral: createTemplateLiteral,
  25368. createTransformContext: createTransformContext,
  25369. createVNodeCall: createVNodeCall,
  25370. errorMessages: errorMessages$1,
  25371. extractIdentifiers: extractIdentifiers$1,
  25372. findDir: findDir,
  25373. findProp: findProp,
  25374. forAliasRE: forAliasRE,
  25375. generate: generate,
  25376. generateCodeFrame: generateCodeFrame,
  25377. getBaseTransformPreset: getBaseTransformPreset,
  25378. getConstantType: getConstantType,
  25379. getMemoedVNodeCall: getMemoedVNodeCall,
  25380. getVNodeBlockHelper: getVNodeBlockHelper,
  25381. getVNodeHelper: getVNodeHelper,
  25382. hasDynamicKeyVBind: hasDynamicKeyVBind,
  25383. hasScopeRef: hasScopeRef,
  25384. helperNameMap: helperNameMap,
  25385. injectProp: injectProp,
  25386. isCoreComponent: isCoreComponent,
  25387. isFnExpression: isFnExpression,
  25388. isFnExpressionBrowser: isFnExpressionBrowser,
  25389. isFnExpressionNode: isFnExpressionNode,
  25390. isFunctionType: isFunctionType,
  25391. isInDestructureAssignment: isInDestructureAssignment,
  25392. isInNewExpression: isInNewExpression,
  25393. isMemberExpression: isMemberExpression,
  25394. isMemberExpressionBrowser: isMemberExpressionBrowser,
  25395. isMemberExpressionNode: isMemberExpressionNode,
  25396. isReferencedIdentifier: isReferencedIdentifier,
  25397. isSimpleIdentifier: isSimpleIdentifier,
  25398. isSlotOutlet: isSlotOutlet,
  25399. isStaticArgOf: isStaticArgOf,
  25400. isStaticExp: isStaticExp,
  25401. isStaticProperty: isStaticProperty,
  25402. isStaticPropertyKey: isStaticPropertyKey,
  25403. isTemplateNode: isTemplateNode,
  25404. isText: isText$1,
  25405. isVSlot: isVSlot,
  25406. locStub: locStub,
  25407. noopDirectiveTransform: noopDirectiveTransform,
  25408. parse: parse$3,
  25409. parserOptions: parserOptions,
  25410. processExpression: processExpression,
  25411. processFor: processFor,
  25412. processIf: processIf,
  25413. processSlotOutlet: processSlotOutlet,
  25414. registerRuntimeHelpers: registerRuntimeHelpers,
  25415. resolveComponentType: resolveComponentType,
  25416. stringifyExpression: stringifyExpression,
  25417. toValidAssetId: toValidAssetId,
  25418. trackSlotScopes: trackSlotScopes,
  25419. trackVForSlotScopes: trackVForSlotScopes,
  25420. transform: transform,
  25421. transformBind: transformBind,
  25422. transformElement: transformElement,
  25423. transformExpression: transformExpression,
  25424. transformModel: transformModel$1,
  25425. transformOn: transformOn$1,
  25426. transformStyle: transformStyle,
  25427. traverseNode: traverseNode,
  25428. unwrapTSNode: unwrapTSNode,
  25429. walkBlockDeclarations: walkBlockDeclarations,
  25430. walkFunctionParams: walkFunctionParams,
  25431. walkIdentifiers: walkIdentifiers,
  25432. warnDeprecation: warnDeprecation
  25433. });
  25434. var hashSum;
  25435. var hasRequiredHashSum;
  25436. function requireHashSum () {
  25437. if (hasRequiredHashSum) return hashSum;
  25438. hasRequiredHashSum = 1;
  25439. function pad (hash, len) {
  25440. while (hash.length < len) {
  25441. hash = '0' + hash;
  25442. }
  25443. return hash;
  25444. }
  25445. function fold (hash, text) {
  25446. var i;
  25447. var chr;
  25448. var len;
  25449. if (text.length === 0) {
  25450. return hash;
  25451. }
  25452. for (i = 0, len = text.length; i < len; i++) {
  25453. chr = text.charCodeAt(i);
  25454. hash = ((hash << 5) - hash) + chr;
  25455. hash |= 0;
  25456. }
  25457. return hash < 0 ? hash * -2 : hash;
  25458. }
  25459. function foldObject (hash, o, seen) {
  25460. return Object.keys(o).sort().reduce(foldKey, hash);
  25461. function foldKey (hash, key) {
  25462. return foldValue(hash, o[key], key, seen);
  25463. }
  25464. }
  25465. function foldValue (input, value, key, seen) {
  25466. var hash = fold(fold(fold(input, key), toString(value)), typeof value);
  25467. if (value === null) {
  25468. return fold(hash, 'null');
  25469. }
  25470. if (value === undefined) {
  25471. return fold(hash, 'undefined');
  25472. }
  25473. if (typeof value === 'object' || typeof value === 'function') {
  25474. if (seen.indexOf(value) !== -1) {
  25475. return fold(hash, '[Circular]' + key);
  25476. }
  25477. seen.push(value);
  25478. var objHash = foldObject(hash, value, seen);
  25479. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  25480. return objHash;
  25481. }
  25482. try {
  25483. return fold(objHash, String(value.valueOf()))
  25484. } catch (err) {
  25485. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  25486. }
  25487. }
  25488. return fold(hash, value.toString());
  25489. }
  25490. function toString (o) {
  25491. return Object.prototype.toString.call(o);
  25492. }
  25493. function sum (o) {
  25494. return pad(foldValue(0, o, '', []).toString(16), 8);
  25495. }
  25496. hashSum = sum;
  25497. return hashSum;
  25498. }
  25499. var hashSumExports = /*@__PURE__*/ requireHashSum();
  25500. var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSumExports);
  25501. const CSS_VARS_HELPER = `useCssVars`;
  25502. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  25503. return `{
  25504. ${vars.map(
  25505. (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
  25506. ).join(",\n ")}
  25507. }`;
  25508. }
  25509. function genVarName(id, raw, isProd, isSSR = false) {
  25510. if (isProd) {
  25511. return hash(id + raw);
  25512. } else {
  25513. return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
  25514. }
  25515. }
  25516. function normalizeExpression(exp) {
  25517. exp = exp.trim();
  25518. if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) {
  25519. return exp.slice(1, -1);
  25520. }
  25521. return exp;
  25522. }
  25523. const vBindRE = /v-bind\s*\(/g;
  25524. function parseCssVars(sfc) {
  25525. const vars = [];
  25526. sfc.styles.forEach((style) => {
  25527. let match;
  25528. const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, "");
  25529. while (match = vBindRE.exec(content)) {
  25530. const start = match.index + match[0].length;
  25531. const end = lexBinding(content, start);
  25532. if (end !== null) {
  25533. const variable = normalizeExpression(content.slice(start, end));
  25534. if (!vars.includes(variable)) {
  25535. vars.push(variable);
  25536. }
  25537. }
  25538. }
  25539. });
  25540. return vars;
  25541. }
  25542. function lexBinding(content, start) {
  25543. let state = 0 /* inParens */;
  25544. let parenDepth = 0;
  25545. for (let i = start; i < content.length; i++) {
  25546. const char = content.charAt(i);
  25547. switch (state) {
  25548. case 0 /* inParens */:
  25549. if (char === `'`) {
  25550. state = 1 /* inSingleQuoteString */;
  25551. } else if (char === `"`) {
  25552. state = 2 /* inDoubleQuoteString */;
  25553. } else if (char === `(`) {
  25554. parenDepth++;
  25555. } else if (char === `)`) {
  25556. if (parenDepth > 0) {
  25557. parenDepth--;
  25558. } else {
  25559. return i;
  25560. }
  25561. }
  25562. break;
  25563. case 1 /* inSingleQuoteString */:
  25564. if (char === `'`) {
  25565. state = 0 /* inParens */;
  25566. }
  25567. break;
  25568. case 2 /* inDoubleQuoteString */:
  25569. if (char === `"`) {
  25570. state = 0 /* inParens */;
  25571. }
  25572. break;
  25573. }
  25574. }
  25575. return null;
  25576. }
  25577. const cssVarsPlugin = (opts) => {
  25578. const { id, isProd } = opts;
  25579. return {
  25580. postcssPlugin: "vue-sfc-vars",
  25581. Declaration(decl) {
  25582. const value = decl.value;
  25583. if (vBindRE.test(value)) {
  25584. vBindRE.lastIndex = 0;
  25585. let transformed = "";
  25586. let lastIndex = 0;
  25587. let match;
  25588. while (match = vBindRE.exec(value)) {
  25589. const start = match.index + match[0].length;
  25590. const end = lexBinding(value, start);
  25591. if (end !== null) {
  25592. const variable = normalizeExpression(value.slice(start, end));
  25593. transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`;
  25594. lastIndex = end + 1;
  25595. }
  25596. }
  25597. decl.value = transformed + value.slice(lastIndex);
  25598. }
  25599. }
  25600. };
  25601. };
  25602. cssVarsPlugin.postcss = true;
  25603. function genCssVarsCode(vars, bindings, id, isProd) {
  25604. const varsExp = genCssVarsFromList(vars, id, isProd);
  25605. const exp = createSimpleExpression(varsExp, false);
  25606. const context = createTransformContext(createRoot([]), {
  25607. prefixIdentifiers: true,
  25608. inline: true,
  25609. bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings
  25610. });
  25611. const transformed = processExpression(exp, context);
  25612. const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
  25613. return typeof c === "string" ? c : c.content;
  25614. }).join("");
  25615. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  25616. }
  25617. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
  25618. return `
  25619. import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
  25620. const __injectCSSVars__ = () => {
  25621. ${genCssVarsCode(
  25622. cssVars,
  25623. bindings,
  25624. id,
  25625. isProd
  25626. )}}
  25627. const __setup__ = ${defaultVar}.setup
  25628. ${defaultVar}.setup = __setup__
  25629. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  25630. : __injectCSSVars__
  25631. `;
  25632. }
  25633. var global$1 = (typeof global !== "undefined" ? global :
  25634. typeof self !== "undefined" ? self :
  25635. typeof window !== "undefined" ? window : {});
  25636. // shim for using process in browser
  25637. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  25638. function defaultSetTimout() {
  25639. throw new Error('setTimeout has not been defined');
  25640. }
  25641. function defaultClearTimeout () {
  25642. throw new Error('clearTimeout has not been defined');
  25643. }
  25644. var cachedSetTimeout = defaultSetTimout;
  25645. var cachedClearTimeout = defaultClearTimeout;
  25646. if (typeof global$1.setTimeout === 'function') {
  25647. cachedSetTimeout = setTimeout;
  25648. }
  25649. if (typeof global$1.clearTimeout === 'function') {
  25650. cachedClearTimeout = clearTimeout;
  25651. }
  25652. function runTimeout(fun) {
  25653. if (cachedSetTimeout === setTimeout) {
  25654. //normal enviroments in sane situations
  25655. return setTimeout(fun, 0);
  25656. }
  25657. // if setTimeout wasn't available but was latter defined
  25658. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  25659. cachedSetTimeout = setTimeout;
  25660. return setTimeout(fun, 0);
  25661. }
  25662. try {
  25663. // when when somebody has screwed with setTimeout but no I.E. maddness
  25664. return cachedSetTimeout(fun, 0);
  25665. } catch(e){
  25666. try {
  25667. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25668. return cachedSetTimeout.call(null, fun, 0);
  25669. } catch(e){
  25670. // 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
  25671. return cachedSetTimeout.call(this, fun, 0);
  25672. }
  25673. }
  25674. }
  25675. function runClearTimeout(marker) {
  25676. if (cachedClearTimeout === clearTimeout) {
  25677. //normal enviroments in sane situations
  25678. return clearTimeout(marker);
  25679. }
  25680. // if clearTimeout wasn't available but was latter defined
  25681. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  25682. cachedClearTimeout = clearTimeout;
  25683. return clearTimeout(marker);
  25684. }
  25685. try {
  25686. // when when somebody has screwed with setTimeout but no I.E. maddness
  25687. return cachedClearTimeout(marker);
  25688. } catch (e){
  25689. try {
  25690. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25691. return cachedClearTimeout.call(null, marker);
  25692. } catch (e){
  25693. // 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.
  25694. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  25695. return cachedClearTimeout.call(this, marker);
  25696. }
  25697. }
  25698. }
  25699. var queue = [];
  25700. var draining = false;
  25701. var currentQueue;
  25702. var queueIndex = -1;
  25703. function cleanUpNextTick() {
  25704. if (!draining || !currentQueue) {
  25705. return;
  25706. }
  25707. draining = false;
  25708. if (currentQueue.length) {
  25709. queue = currentQueue.concat(queue);
  25710. } else {
  25711. queueIndex = -1;
  25712. }
  25713. if (queue.length) {
  25714. drainQueue();
  25715. }
  25716. }
  25717. function drainQueue() {
  25718. if (draining) {
  25719. return;
  25720. }
  25721. var timeout = runTimeout(cleanUpNextTick);
  25722. draining = true;
  25723. var len = queue.length;
  25724. while(len) {
  25725. currentQueue = queue;
  25726. queue = [];
  25727. while (++queueIndex < len) {
  25728. if (currentQueue) {
  25729. currentQueue[queueIndex].run();
  25730. }
  25731. }
  25732. queueIndex = -1;
  25733. len = queue.length;
  25734. }
  25735. currentQueue = null;
  25736. draining = false;
  25737. runClearTimeout(timeout);
  25738. }
  25739. function nextTick(fun) {
  25740. var args = new Array(arguments.length - 1);
  25741. if (arguments.length > 1) {
  25742. for (var i = 1; i < arguments.length; i++) {
  25743. args[i - 1] = arguments[i];
  25744. }
  25745. }
  25746. queue.push(new Item(fun, args));
  25747. if (queue.length === 1 && !draining) {
  25748. runTimeout(drainQueue);
  25749. }
  25750. }
  25751. // v8 likes predictible objects
  25752. function Item(fun, array) {
  25753. this.fun = fun;
  25754. this.array = array;
  25755. }
  25756. Item.prototype.run = function () {
  25757. this.fun.apply(null, this.array);
  25758. };
  25759. var title = 'browser';
  25760. var platform = 'browser';
  25761. var browser = true;
  25762. var env = {};
  25763. var argv = [];
  25764. var version$1 = ''; // empty string to avoid regexp issues
  25765. var versions = {};
  25766. var release = {};
  25767. var config = {};
  25768. function noop() {}
  25769. var on = noop;
  25770. var addListener = noop;
  25771. var once = noop;
  25772. var off = noop;
  25773. var removeListener = noop;
  25774. var removeAllListeners = noop;
  25775. var emit = noop;
  25776. function binding(name) {
  25777. throw new Error('process.binding is not supported');
  25778. }
  25779. function cwd () { return '/' }
  25780. function chdir (dir) {
  25781. throw new Error('process.chdir is not supported');
  25782. }function umask() { return 0; }
  25783. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  25784. var performance = global$1.performance || {};
  25785. var performanceNow =
  25786. performance.now ||
  25787. performance.mozNow ||
  25788. performance.msNow ||
  25789. performance.oNow ||
  25790. performance.webkitNow ||
  25791. function(){ return (new Date()).getTime() };
  25792. // generate timestamp or delta
  25793. // see http://nodejs.org/api/process.html#process_process_hrtime
  25794. function hrtime(previousTimestamp){
  25795. var clocktime = performanceNow.call(performance)*1e-3;
  25796. var seconds = Math.floor(clocktime);
  25797. var nanoseconds = Math.floor((clocktime%1)*1e9);
  25798. if (previousTimestamp) {
  25799. seconds = seconds - previousTimestamp[0];
  25800. nanoseconds = nanoseconds - previousTimestamp[1];
  25801. if (nanoseconds<0) {
  25802. seconds--;
  25803. nanoseconds += 1e9;
  25804. }
  25805. }
  25806. return [seconds,nanoseconds]
  25807. }
  25808. var startTime = new Date();
  25809. function uptime() {
  25810. var currentTime = new Date();
  25811. var dif = currentTime - startTime;
  25812. return dif / 1000;
  25813. }
  25814. var browser$1 = {
  25815. nextTick: nextTick,
  25816. title: title,
  25817. browser: browser,
  25818. env: env,
  25819. argv: argv,
  25820. version: version$1,
  25821. versions: versions,
  25822. on: on,
  25823. addListener: addListener,
  25824. once: once,
  25825. off: off,
  25826. removeListener: removeListener,
  25827. removeAllListeners: removeAllListeners,
  25828. emit: emit,
  25829. binding: binding,
  25830. cwd: cwd,
  25831. chdir: chdir,
  25832. umask: umask,
  25833. hrtime: hrtime,
  25834. platform: platform,
  25835. release: release,
  25836. config: config,
  25837. uptime: uptime
  25838. };
  25839. function createCache(max = 500) {
  25840. {
  25841. return /* @__PURE__ */ new Map();
  25842. }
  25843. }
  25844. function isImportUsed(local, sfc) {
  25845. return resolveTemplateUsedIdentifiers(sfc).has(local);
  25846. }
  25847. const templateUsageCheckCache = createCache();
  25848. function resolveTemplateUsedIdentifiers(sfc) {
  25849. const { content, ast } = sfc.template;
  25850. const cached = templateUsageCheckCache.get(content);
  25851. if (cached) {
  25852. return cached;
  25853. }
  25854. const ids = /* @__PURE__ */ new Set();
  25855. ast.children.forEach(walk);
  25856. function walk(node) {
  25857. var _a;
  25858. switch (node.type) {
  25859. case 1:
  25860. let tag = node.tag;
  25861. if (tag.includes(".")) tag = tag.split(".")[0].trim();
  25862. if (!parserOptions.isNativeTag(tag) && !parserOptions.isBuiltInComponent(tag)) {
  25863. ids.add(camelize(tag));
  25864. ids.add(capitalize(camelize(tag)));
  25865. }
  25866. for (let i = 0; i < node.props.length; i++) {
  25867. const prop = node.props[i];
  25868. if (prop.type === 7) {
  25869. if (!isBuiltInDirective(prop.name)) {
  25870. ids.add(`v${capitalize(camelize(prop.name))}`);
  25871. }
  25872. if (prop.arg && !prop.arg.isStatic) {
  25873. extractIdentifiers(ids, prop.arg);
  25874. }
  25875. if (prop.name === "for") {
  25876. extractIdentifiers(ids, prop.forParseResult.source);
  25877. } else if (prop.exp) {
  25878. extractIdentifiers(ids, prop.exp);
  25879. } else if (prop.name === "bind" && !prop.exp) {
  25880. ids.add(camelize(prop.arg.content));
  25881. }
  25882. }
  25883. if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
  25884. ids.add(prop.value.content);
  25885. }
  25886. }
  25887. node.children.forEach(walk);
  25888. break;
  25889. case 5:
  25890. extractIdentifiers(ids, node.content);
  25891. break;
  25892. }
  25893. }
  25894. templateUsageCheckCache.set(content, ids);
  25895. return ids;
  25896. }
  25897. function extractIdentifiers(ids, node) {
  25898. if (node.ast) {
  25899. walkIdentifiers(node.ast, (n) => ids.add(n.name));
  25900. } else if (node.ast === null) {
  25901. ids.add(node.content);
  25902. }
  25903. }
  25904. var __defProp$a = Object.defineProperty;
  25905. var __defProps$9 = Object.defineProperties;
  25906. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  25907. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  25908. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  25909. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  25910. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  25911. var __spreadValues$a = (a, b) => {
  25912. for (var prop in b || (b = {}))
  25913. if (__hasOwnProp$a.call(b, prop))
  25914. __defNormalProp$a(a, prop, b[prop]);
  25915. if (__getOwnPropSymbols$a)
  25916. for (var prop of __getOwnPropSymbols$a(b)) {
  25917. if (__propIsEnum$a.call(b, prop))
  25918. __defNormalProp$a(a, prop, b[prop]);
  25919. }
  25920. return a;
  25921. };
  25922. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  25923. const DEFAULT_FILENAME = "anonymous.vue";
  25924. const parseCache$1 = createCache();
  25925. function parse$2(source, options = {}) {
  25926. var _a;
  25927. const sourceKey = genCacheKey(source, __spreadProps$9(__spreadValues$a({}, options), {
  25928. compiler: { parse: (_a = options.compiler) == null ? void 0 : _a.parse }
  25929. }));
  25930. const cache = parseCache$1.get(sourceKey);
  25931. if (cache) {
  25932. return cache;
  25933. }
  25934. const {
  25935. sourceMap = true,
  25936. filename = DEFAULT_FILENAME,
  25937. sourceRoot = "",
  25938. pad = false,
  25939. ignoreEmpty = true,
  25940. compiler = CompilerDOM,
  25941. templateParseOptions = {}
  25942. } = options;
  25943. const descriptor = {
  25944. filename,
  25945. source,
  25946. template: null,
  25947. script: null,
  25948. scriptSetup: null,
  25949. styles: [],
  25950. customBlocks: [],
  25951. cssVars: [],
  25952. slotted: false,
  25953. shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor)
  25954. };
  25955. const errors = [];
  25956. const ast = compiler.parse(source, __spreadProps$9(__spreadValues$a({
  25957. parseMode: "sfc",
  25958. prefixIdentifiers: true
  25959. }, templateParseOptions), {
  25960. onError: (e) => {
  25961. errors.push(e);
  25962. }
  25963. }));
  25964. ast.children.forEach((node) => {
  25965. if (node.type !== 1) {
  25966. return;
  25967. }
  25968. if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasSrc(node)) {
  25969. return;
  25970. }
  25971. switch (node.tag) {
  25972. case "template":
  25973. if (!descriptor.template) {
  25974. const templateBlock = descriptor.template = createBlock(
  25975. node,
  25976. source,
  25977. false
  25978. );
  25979. if (!templateBlock.attrs.src) {
  25980. templateBlock.ast = createRoot(node.children, source);
  25981. }
  25982. if (templateBlock.attrs.functional) {
  25983. const err = new SyntaxError(
  25984. `<template functional> is no longer supported in Vue 3, since functional components no longer have significant performance difference from stateful ones. Just use a normal <template> instead.`
  25985. );
  25986. err.loc = node.props.find(
  25987. (p) => p.type === 6 && p.name === "functional"
  25988. ).loc;
  25989. errors.push(err);
  25990. }
  25991. } else {
  25992. errors.push(createDuplicateBlockError(node));
  25993. }
  25994. break;
  25995. case "script":
  25996. const scriptBlock = createBlock(node, source, pad);
  25997. const isSetup = !!scriptBlock.attrs.setup;
  25998. if (isSetup && !descriptor.scriptSetup) {
  25999. descriptor.scriptSetup = scriptBlock;
  26000. break;
  26001. }
  26002. if (!isSetup && !descriptor.script) {
  26003. descriptor.script = scriptBlock;
  26004. break;
  26005. }
  26006. errors.push(createDuplicateBlockError(node, isSetup));
  26007. break;
  26008. case "style":
  26009. const styleBlock = createBlock(node, source, pad);
  26010. if (styleBlock.attrs.vars) {
  26011. errors.push(
  26012. new SyntaxError(
  26013. `<style vars> has been replaced by a new proposal: https://github.com/vuejs/rfcs/pull/231`
  26014. )
  26015. );
  26016. }
  26017. descriptor.styles.push(styleBlock);
  26018. break;
  26019. default:
  26020. descriptor.customBlocks.push(createBlock(node, source, pad));
  26021. break;
  26022. }
  26023. });
  26024. if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
  26025. errors.push(
  26026. new SyntaxError(
  26027. `At least one <template> or <script> is required in a single file component. ${descriptor.filename}`
  26028. )
  26029. );
  26030. }
  26031. if (descriptor.scriptSetup) {
  26032. if (descriptor.scriptSetup.src) {
  26033. errors.push(
  26034. new SyntaxError(
  26035. `<script setup> cannot use the "src" attribute because its syntax will be ambiguous outside of the component.`
  26036. )
  26037. );
  26038. descriptor.scriptSetup = null;
  26039. }
  26040. if (descriptor.script && descriptor.script.src) {
  26041. errors.push(
  26042. new SyntaxError(
  26043. `<script> cannot use the "src" attribute when <script setup> is also present because they must be processed together.`
  26044. )
  26045. );
  26046. descriptor.script = null;
  26047. }
  26048. }
  26049. let templateColumnOffset = 0;
  26050. if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
  26051. [descriptor.template.content, templateColumnOffset] = dedent(
  26052. descriptor.template.content
  26053. );
  26054. }
  26055. if (sourceMap) {
  26056. const genMap = (block, columnOffset = 0) => {
  26057. if (block && !block.src) {
  26058. block.map = generateSourceMap(
  26059. filename,
  26060. source,
  26061. block.content,
  26062. sourceRoot,
  26063. !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
  26064. columnOffset
  26065. );
  26066. }
  26067. };
  26068. genMap(descriptor.template, templateColumnOffset);
  26069. genMap(descriptor.script);
  26070. descriptor.styles.forEach((s) => genMap(s));
  26071. descriptor.customBlocks.forEach((s) => genMap(s));
  26072. }
  26073. descriptor.cssVars = parseCssVars(descriptor);
  26074. const slottedRE = /(?:::v-|:)slotted\(/;
  26075. descriptor.slotted = descriptor.styles.some(
  26076. (s) => s.scoped && slottedRE.test(s.content)
  26077. );
  26078. const result = {
  26079. descriptor,
  26080. errors
  26081. };
  26082. parseCache$1.set(sourceKey, result);
  26083. return result;
  26084. }
  26085. function createDuplicateBlockError(node, isScriptSetup = false) {
  26086. const err = new SyntaxError(
  26087. `Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`
  26088. );
  26089. err.loc = node.loc;
  26090. return err;
  26091. }
  26092. function createBlock(node, source, pad) {
  26093. const type = node.tag;
  26094. const loc = node.innerLoc;
  26095. const attrs = {};
  26096. const block = {
  26097. type,
  26098. content: source.slice(loc.start.offset, loc.end.offset),
  26099. loc,
  26100. attrs
  26101. };
  26102. if (pad) {
  26103. block.content = padContent(source, block, pad) + block.content;
  26104. }
  26105. node.props.forEach((p) => {
  26106. if (p.type === 6) {
  26107. const name = p.name;
  26108. attrs[name] = p.value ? p.value.content || true : true;
  26109. if (name === "lang") {
  26110. block.lang = p.value && p.value.content;
  26111. } else if (name === "src") {
  26112. block.src = p.value && p.value.content;
  26113. } else if (type === "style") {
  26114. if (name === "scoped") {
  26115. block.scoped = true;
  26116. } else if (name === "module") {
  26117. block.module = attrs[name];
  26118. }
  26119. } else if (type === "script" && name === "setup") {
  26120. block.setup = attrs.setup;
  26121. }
  26122. }
  26123. });
  26124. return block;
  26125. }
  26126. const splitRE = /\r?\n/g;
  26127. const emptyRE = /^(?:\/\/)?\s*$/;
  26128. const replaceRE = /./g;
  26129. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
  26130. const map = new sourceMapExports.SourceMapGenerator({
  26131. file: filename.replace(/\\/g, "/"),
  26132. sourceRoot: sourceRoot.replace(/\\/g, "/")
  26133. });
  26134. map.setSourceContent(filename, source);
  26135. map._sources.add(filename);
  26136. generated.split(splitRE).forEach((line, index) => {
  26137. if (!emptyRE.test(line)) {
  26138. const originalLine = index + 1 + lineOffset;
  26139. const generatedLine = index + 1;
  26140. for (let i = 0; i < line.length; i++) {
  26141. if (!/\s/.test(line[i])) {
  26142. map._mappings.add({
  26143. originalLine,
  26144. originalColumn: i + columnOffset,
  26145. generatedLine,
  26146. generatedColumn: i,
  26147. source: filename,
  26148. name: null
  26149. });
  26150. }
  26151. }
  26152. }
  26153. });
  26154. return map.toJSON();
  26155. }
  26156. function padContent(content, block, pad) {
  26157. content = content.slice(0, block.loc.start.offset);
  26158. if (pad === "space") {
  26159. return content.replace(replaceRE, " ");
  26160. } else {
  26161. const offset = content.split(splitRE).length;
  26162. const padChar = block.type === "script" && !block.lang ? "//\n" : "\n";
  26163. return Array(offset).join(padChar);
  26164. }
  26165. }
  26166. function hasSrc(node) {
  26167. return node.props.some((p) => {
  26168. if (p.type !== 6) {
  26169. return false;
  26170. }
  26171. return p.name === "src";
  26172. });
  26173. }
  26174. function isEmpty(node) {
  26175. for (let i = 0; i < node.children.length; i++) {
  26176. const child = node.children[i];
  26177. if (child.type !== 2 || child.content.trim() !== "") {
  26178. return false;
  26179. }
  26180. }
  26181. return true;
  26182. }
  26183. function hmrShouldReload(prevImports, next) {
  26184. if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
  26185. return false;
  26186. }
  26187. for (const key in prevImports) {
  26188. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) {
  26189. return true;
  26190. }
  26191. }
  26192. return false;
  26193. }
  26194. function dedent(s) {
  26195. const lines = s.split("\n");
  26196. const minIndent = lines.reduce(function(minIndent2, line) {
  26197. var _a, _b;
  26198. if (line.trim() === "") {
  26199. return minIndent2;
  26200. }
  26201. const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
  26202. return Math.min(indent, minIndent2);
  26203. }, Infinity);
  26204. if (minIndent === 0) {
  26205. return [s, minIndent];
  26206. }
  26207. return [
  26208. lines.map(function(line) {
  26209. return line.slice(minIndent);
  26210. }).join("\n"),
  26211. minIndent
  26212. ];
  26213. }
  26214. // Copyright Joyent, Inc. and other Node contributors.
  26215. //
  26216. // Permission is hereby granted, free of charge, to any person obtaining a
  26217. // copy of this software and associated documentation files (the
  26218. // "Software"), to deal in the Software without restriction, including
  26219. // without limitation the rights to use, copy, modify, merge, publish,
  26220. // distribute, sublicense, and/or sell copies of the Software, and to permit
  26221. // persons to whom the Software is furnished to do so, subject to the
  26222. // following conditions:
  26223. //
  26224. // The above copyright notice and this permission notice shall be included
  26225. // in all copies or substantial portions of the Software.
  26226. //
  26227. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  26228. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26229. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26230. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  26231. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  26232. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  26233. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  26234. // resolves . and .. elements in a path array with directory names there
  26235. // must be no slashes, empty elements, or device names (c:\) in the array
  26236. // (so also no leading and trailing slashes - it does not distinguish
  26237. // relative and absolute paths)
  26238. function normalizeArray(parts, allowAboveRoot) {
  26239. // if the path tries to go above the root, `up` ends up > 0
  26240. var up = 0;
  26241. for (var i = parts.length - 1; i >= 0; i--) {
  26242. var last = parts[i];
  26243. if (last === '.') {
  26244. parts.splice(i, 1);
  26245. } else if (last === '..') {
  26246. parts.splice(i, 1);
  26247. up++;
  26248. } else if (up) {
  26249. parts.splice(i, 1);
  26250. up--;
  26251. }
  26252. }
  26253. // if the path is allowed to go above the root, restore leading ..s
  26254. if (allowAboveRoot) {
  26255. for (; up--; up) {
  26256. parts.unshift('..');
  26257. }
  26258. }
  26259. return parts;
  26260. }
  26261. // Split a filename into [root, dir, basename, ext], unix version
  26262. // 'root' is just a slash, or nothing.
  26263. var splitPathRe =
  26264. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  26265. var splitPath = function(filename) {
  26266. return splitPathRe.exec(filename).slice(1);
  26267. };
  26268. // path.resolve([from ...], to)
  26269. // posix version
  26270. function resolve() {
  26271. var resolvedPath = '',
  26272. resolvedAbsolute = false;
  26273. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  26274. var path = (i >= 0) ? arguments[i] : '/';
  26275. // Skip empty and invalid entries
  26276. if (typeof path !== 'string') {
  26277. throw new TypeError('Arguments to path.resolve must be strings');
  26278. } else if (!path) {
  26279. continue;
  26280. }
  26281. resolvedPath = path + '/' + resolvedPath;
  26282. resolvedAbsolute = path.charAt(0) === '/';
  26283. }
  26284. // At this point the path should be resolved to a full absolute path, but
  26285. // handle relative paths to be safe (might happen when process.cwd() fails)
  26286. // Normalize the path
  26287. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  26288. return !!p;
  26289. }), !resolvedAbsolute).join('/');
  26290. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  26291. }
  26292. // path.normalize(path)
  26293. // posix version
  26294. function normalize$1(path) {
  26295. var isPathAbsolute = isAbsolute(path),
  26296. trailingSlash = substr(path, -1) === '/';
  26297. // Normalize the path
  26298. path = normalizeArray(filter(path.split('/'), function(p) {
  26299. return !!p;
  26300. }), !isPathAbsolute).join('/');
  26301. if (!path && !isPathAbsolute) {
  26302. path = '.';
  26303. }
  26304. if (path && trailingSlash) {
  26305. path += '/';
  26306. }
  26307. return (isPathAbsolute ? '/' : '') + path;
  26308. }
  26309. // posix version
  26310. function isAbsolute(path) {
  26311. return path.charAt(0) === '/';
  26312. }
  26313. // posix version
  26314. function join() {
  26315. var paths = Array.prototype.slice.call(arguments, 0);
  26316. return normalize$1(filter(paths, function(p, index) {
  26317. if (typeof p !== 'string') {
  26318. throw new TypeError('Arguments to path.join must be strings');
  26319. }
  26320. return p;
  26321. }).join('/'));
  26322. }
  26323. // path.relative(from, to)
  26324. // posix version
  26325. function relative(from, to) {
  26326. from = resolve(from).substr(1);
  26327. to = resolve(to).substr(1);
  26328. function trim(arr) {
  26329. var start = 0;
  26330. for (; start < arr.length; start++) {
  26331. if (arr[start] !== '') break;
  26332. }
  26333. var end = arr.length - 1;
  26334. for (; end >= 0; end--) {
  26335. if (arr[end] !== '') break;
  26336. }
  26337. if (start > end) return [];
  26338. return arr.slice(start, end - start + 1);
  26339. }
  26340. var fromParts = trim(from.split('/'));
  26341. var toParts = trim(to.split('/'));
  26342. var length = Math.min(fromParts.length, toParts.length);
  26343. var samePartsLength = length;
  26344. for (var i = 0; i < length; i++) {
  26345. if (fromParts[i] !== toParts[i]) {
  26346. samePartsLength = i;
  26347. break;
  26348. }
  26349. }
  26350. var outputParts = [];
  26351. for (var i = samePartsLength; i < fromParts.length; i++) {
  26352. outputParts.push('..');
  26353. }
  26354. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  26355. return outputParts.join('/');
  26356. }
  26357. var sep = '/';
  26358. var delimiter$1 = ':';
  26359. function dirname(path) {
  26360. var result = splitPath(path),
  26361. root = result[0],
  26362. dir = result[1];
  26363. if (!root && !dir) {
  26364. // No dirname whatsoever
  26365. return '.';
  26366. }
  26367. if (dir) {
  26368. // It has a dirname, strip trailing slash
  26369. dir = dir.substr(0, dir.length - 1);
  26370. }
  26371. return root + dir;
  26372. }
  26373. function basename(path, ext) {
  26374. var f = splitPath(path)[2];
  26375. // TODO: make this comparison case-insensitive on windows?
  26376. if (ext && f.substr(-1 * ext.length) === ext) {
  26377. f = f.substr(0, f.length - ext.length);
  26378. }
  26379. return f;
  26380. }
  26381. function extname(path) {
  26382. return splitPath(path)[3];
  26383. }
  26384. var path = {
  26385. extname: extname,
  26386. basename: basename,
  26387. dirname: dirname,
  26388. sep: sep,
  26389. delimiter: delimiter$1,
  26390. relative: relative,
  26391. join: join,
  26392. isAbsolute: isAbsolute,
  26393. normalize: normalize$1,
  26394. resolve: resolve
  26395. };
  26396. function filter (xs, f) {
  26397. if (xs.filter) return xs.filter(f);
  26398. var res = [];
  26399. for (var i = 0; i < xs.length; i++) {
  26400. if (f(xs[i], i, xs)) res.push(xs[i]);
  26401. }
  26402. return res;
  26403. }
  26404. // String.prototype.substr - negative index don't work in IE8
  26405. var substr = 'ab'.substr(-1) === 'b' ?
  26406. function (str, start, len) { return str.substr(start, len) } :
  26407. function (str, start, len) {
  26408. if (start < 0) start = str.length + start;
  26409. return str.substr(start, len);
  26410. }
  26411. ;
  26412. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  26413. __proto__: null,
  26414. basename: basename,
  26415. default: path,
  26416. delimiter: delimiter$1,
  26417. dirname: dirname,
  26418. extname: extname,
  26419. isAbsolute: isAbsolute,
  26420. join: join,
  26421. normalize: normalize$1,
  26422. relative: relative,
  26423. resolve: resolve,
  26424. sep: sep
  26425. });
  26426. /*! https://mths.be/punycode v1.4.1 by @mathias */
  26427. /** Highest positive signed 32-bit float value */
  26428. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  26429. /** Bootstring parameters */
  26430. var base = 36;
  26431. var tMin = 1;
  26432. var tMax = 26;
  26433. var skew = 38;
  26434. var damp = 700;
  26435. var initialBias = 72;
  26436. var initialN = 128; // 0x80
  26437. var delimiter = '-'; // '\x2D'
  26438. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  26439. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  26440. /** Error messages */
  26441. var errors = {
  26442. 'overflow': 'Overflow: input needs wider integers to process',
  26443. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  26444. 'invalid-input': 'Invalid input'
  26445. };
  26446. /** Convenience shortcuts */
  26447. var baseMinusTMin = base - tMin;
  26448. var floor = Math.floor;
  26449. var stringFromCharCode = String.fromCharCode;
  26450. /*--------------------------------------------------------------------------*/
  26451. /**
  26452. * A generic error utility function.
  26453. * @private
  26454. * @param {String} type The error type.
  26455. * @returns {Error} Throws a `RangeError` with the applicable error message.
  26456. */
  26457. function error(type) {
  26458. throw new RangeError(errors[type]);
  26459. }
  26460. /**
  26461. * A generic `Array#map` utility function.
  26462. * @private
  26463. * @param {Array} array The array to iterate over.
  26464. * @param {Function} callback The function that gets called for every array
  26465. * item.
  26466. * @returns {Array} A new array of values returned by the callback function.
  26467. */
  26468. function map$1(array, fn) {
  26469. var length = array.length;
  26470. var result = [];
  26471. while (length--) {
  26472. result[length] = fn(array[length]);
  26473. }
  26474. return result;
  26475. }
  26476. /**
  26477. * A simple `Array#map`-like wrapper to work with domain name strings or email
  26478. * addresses.
  26479. * @private
  26480. * @param {String} domain The domain name or email address.
  26481. * @param {Function} callback The function that gets called for every
  26482. * character.
  26483. * @returns {Array} A new string of characters returned by the callback
  26484. * function.
  26485. */
  26486. function mapDomain(string, fn) {
  26487. var parts = string.split('@');
  26488. var result = '';
  26489. if (parts.length > 1) {
  26490. // In email addresses, only the domain name should be punycoded. Leave
  26491. // the local part (i.e. everything up to `@`) intact.
  26492. result = parts[0] + '@';
  26493. string = parts[1];
  26494. }
  26495. // Avoid `split(regex)` for IE8 compatibility. See #17.
  26496. string = string.replace(regexSeparators, '\x2E');
  26497. var labels = string.split('.');
  26498. var encoded = map$1(labels, fn).join('.');
  26499. return result + encoded;
  26500. }
  26501. /**
  26502. * Creates an array containing the numeric code points of each Unicode
  26503. * character in the string. While JavaScript uses UCS-2 internally,
  26504. * this function will convert a pair of surrogate halves (each of which
  26505. * UCS-2 exposes as separate characters) into a single code point,
  26506. * matching UTF-16.
  26507. * @see `punycode.ucs2.encode`
  26508. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  26509. * @memberOf punycode.ucs2
  26510. * @name decode
  26511. * @param {String} string The Unicode input string (UCS-2).
  26512. * @returns {Array} The new array of code points.
  26513. */
  26514. function ucs2decode(string) {
  26515. var output = [],
  26516. counter = 0,
  26517. length = string.length,
  26518. value,
  26519. extra;
  26520. while (counter < length) {
  26521. value = string.charCodeAt(counter++);
  26522. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  26523. // high surrogate, and there is a next character
  26524. extra = string.charCodeAt(counter++);
  26525. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  26526. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  26527. } else {
  26528. // unmatched surrogate; only append this code unit, in case the next
  26529. // code unit is the high surrogate of a surrogate pair
  26530. output.push(value);
  26531. counter--;
  26532. }
  26533. } else {
  26534. output.push(value);
  26535. }
  26536. }
  26537. return output;
  26538. }
  26539. /**
  26540. * Converts a digit/integer into a basic code point.
  26541. * @see `basicToDigit()`
  26542. * @private
  26543. * @param {Number} digit The numeric value of a basic code point.
  26544. * @returns {Number} The basic code point whose value (when used for
  26545. * representing integers) is `digit`, which needs to be in the range
  26546. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  26547. * used; else, the lowercase form is used. The behavior is undefined
  26548. * if `flag` is non-zero and `digit` has no uppercase form.
  26549. */
  26550. function digitToBasic(digit, flag) {
  26551. // 0..25 map to ASCII a..z or A..Z
  26552. // 26..35 map to ASCII 0..9
  26553. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  26554. }
  26555. /**
  26556. * Bias adaptation function as per section 3.4 of RFC 3492.
  26557. * https://tools.ietf.org/html/rfc3492#section-3.4
  26558. * @private
  26559. */
  26560. function adapt(delta, numPoints, firstTime) {
  26561. var k = 0;
  26562. delta = firstTime ? floor(delta / damp) : delta >> 1;
  26563. delta += floor(delta / numPoints);
  26564. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  26565. delta = floor(delta / baseMinusTMin);
  26566. }
  26567. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  26568. }
  26569. /**
  26570. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  26571. * Punycode string of ASCII-only symbols.
  26572. * @memberOf punycode
  26573. * @param {String} input The string of Unicode symbols.
  26574. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  26575. */
  26576. function encode$1(input) {
  26577. var n,
  26578. delta,
  26579. handledCPCount,
  26580. basicLength,
  26581. bias,
  26582. j,
  26583. m,
  26584. q,
  26585. k,
  26586. t,
  26587. currentValue,
  26588. output = [],
  26589. /** `inputLength` will hold the number of code points in `input`. */
  26590. inputLength,
  26591. /** Cached calculation results */
  26592. handledCPCountPlusOne,
  26593. baseMinusT,
  26594. qMinusT;
  26595. // Convert the input in UCS-2 to Unicode
  26596. input = ucs2decode(input);
  26597. // Cache the length
  26598. inputLength = input.length;
  26599. // Initialize the state
  26600. n = initialN;
  26601. delta = 0;
  26602. bias = initialBias;
  26603. // Handle the basic code points
  26604. for (j = 0; j < inputLength; ++j) {
  26605. currentValue = input[j];
  26606. if (currentValue < 0x80) {
  26607. output.push(stringFromCharCode(currentValue));
  26608. }
  26609. }
  26610. handledCPCount = basicLength = output.length;
  26611. // `handledCPCount` is the number of code points that have been handled;
  26612. // `basicLength` is the number of basic code points.
  26613. // Finish the basic string - if it is not empty - with a delimiter
  26614. if (basicLength) {
  26615. output.push(delimiter);
  26616. }
  26617. // Main encoding loop:
  26618. while (handledCPCount < inputLength) {
  26619. // All non-basic code points < n have been handled already. Find the next
  26620. // larger one:
  26621. for (m = maxInt, j = 0; j < inputLength; ++j) {
  26622. currentValue = input[j];
  26623. if (currentValue >= n && currentValue < m) {
  26624. m = currentValue;
  26625. }
  26626. }
  26627. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  26628. // but guard against overflow
  26629. handledCPCountPlusOne = handledCPCount + 1;
  26630. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  26631. error('overflow');
  26632. }
  26633. delta += (m - n) * handledCPCountPlusOne;
  26634. n = m;
  26635. for (j = 0; j < inputLength; ++j) {
  26636. currentValue = input[j];
  26637. if (currentValue < n && ++delta > maxInt) {
  26638. error('overflow');
  26639. }
  26640. if (currentValue == n) {
  26641. // Represent delta as a generalized variable-length integer
  26642. for (q = delta, k = base; /* no condition */ ; k += base) {
  26643. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  26644. if (q < t) {
  26645. break;
  26646. }
  26647. qMinusT = q - t;
  26648. baseMinusT = base - t;
  26649. output.push(
  26650. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  26651. );
  26652. q = floor(qMinusT / baseMinusT);
  26653. }
  26654. output.push(stringFromCharCode(digitToBasic(q, 0)));
  26655. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  26656. delta = 0;
  26657. ++handledCPCount;
  26658. }
  26659. }
  26660. ++delta;
  26661. ++n;
  26662. }
  26663. return output.join('');
  26664. }
  26665. /**
  26666. * Converts a Unicode string representing a domain name or an email address to
  26667. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  26668. * i.e. it doesn't matter if you call it with a domain that's already in
  26669. * ASCII.
  26670. * @memberOf punycode
  26671. * @param {String} input The domain name or email address to convert, as a
  26672. * Unicode string.
  26673. * @returns {String} The Punycode representation of the given domain name or
  26674. * email address.
  26675. */
  26676. function toASCII(input) {
  26677. return mapDomain(input, function(string) {
  26678. return regexNonASCII.test(string) ?
  26679. 'xn--' + encode$1(string) :
  26680. string;
  26681. });
  26682. }
  26683. var lookup = [];
  26684. var revLookup = [];
  26685. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  26686. var inited = false;
  26687. function init () {
  26688. inited = true;
  26689. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  26690. for (var i = 0, len = code.length; i < len; ++i) {
  26691. lookup[i] = code[i];
  26692. revLookup[code.charCodeAt(i)] = i;
  26693. }
  26694. revLookup['-'.charCodeAt(0)] = 62;
  26695. revLookup['_'.charCodeAt(0)] = 63;
  26696. }
  26697. function toByteArray (b64) {
  26698. if (!inited) {
  26699. init();
  26700. }
  26701. var i, j, l, tmp, placeHolders, arr;
  26702. var len = b64.length;
  26703. if (len % 4 > 0) {
  26704. throw new Error('Invalid string. Length must be a multiple of 4')
  26705. }
  26706. // the number of equal signs (place holders)
  26707. // if there are two placeholders, than the two characters before it
  26708. // represent one byte
  26709. // if there is only one, then the three characters before it represent 2 bytes
  26710. // this is just a cheap hack to not do indexOf twice
  26711. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  26712. // base64 is 4/3 + up to two characters of the original data
  26713. arr = new Arr(len * 3 / 4 - placeHolders);
  26714. // if there are placeholders, only get up to the last complete 4 chars
  26715. l = placeHolders > 0 ? len - 4 : len;
  26716. var L = 0;
  26717. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  26718. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  26719. arr[L++] = (tmp >> 16) & 0xFF;
  26720. arr[L++] = (tmp >> 8) & 0xFF;
  26721. arr[L++] = tmp & 0xFF;
  26722. }
  26723. if (placeHolders === 2) {
  26724. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  26725. arr[L++] = tmp & 0xFF;
  26726. } else if (placeHolders === 1) {
  26727. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  26728. arr[L++] = (tmp >> 8) & 0xFF;
  26729. arr[L++] = tmp & 0xFF;
  26730. }
  26731. return arr
  26732. }
  26733. function tripletToBase64 (num) {
  26734. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  26735. }
  26736. function encodeChunk (uint8, start, end) {
  26737. var tmp;
  26738. var output = [];
  26739. for (var i = start; i < end; i += 3) {
  26740. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  26741. output.push(tripletToBase64(tmp));
  26742. }
  26743. return output.join('')
  26744. }
  26745. function fromByteArray (uint8) {
  26746. if (!inited) {
  26747. init();
  26748. }
  26749. var tmp;
  26750. var len = uint8.length;
  26751. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  26752. var output = '';
  26753. var parts = [];
  26754. var maxChunkLength = 16383; // must be multiple of 3
  26755. // go through the array every three bytes, we'll deal with trailing stuff later
  26756. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  26757. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  26758. }
  26759. // pad the end with zeros, but make sure to not forget the extra bytes
  26760. if (extraBytes === 1) {
  26761. tmp = uint8[len - 1];
  26762. output += lookup[tmp >> 2];
  26763. output += lookup[(tmp << 4) & 0x3F];
  26764. output += '==';
  26765. } else if (extraBytes === 2) {
  26766. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  26767. output += lookup[tmp >> 10];
  26768. output += lookup[(tmp >> 4) & 0x3F];
  26769. output += lookup[(tmp << 2) & 0x3F];
  26770. output += '=';
  26771. }
  26772. parts.push(output);
  26773. return parts.join('')
  26774. }
  26775. function read (buffer, offset, isLE, mLen, nBytes) {
  26776. var e, m;
  26777. var eLen = nBytes * 8 - mLen - 1;
  26778. var eMax = (1 << eLen) - 1;
  26779. var eBias = eMax >> 1;
  26780. var nBits = -7;
  26781. var i = isLE ? (nBytes - 1) : 0;
  26782. var d = isLE ? -1 : 1;
  26783. var s = buffer[offset + i];
  26784. i += d;
  26785. e = s & ((1 << (-nBits)) - 1);
  26786. s >>= (-nBits);
  26787. nBits += eLen;
  26788. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26789. m = e & ((1 << (-nBits)) - 1);
  26790. e >>= (-nBits);
  26791. nBits += mLen;
  26792. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26793. if (e === 0) {
  26794. e = 1 - eBias;
  26795. } else if (e === eMax) {
  26796. return m ? NaN : ((s ? -1 : 1) * Infinity)
  26797. } else {
  26798. m = m + Math.pow(2, mLen);
  26799. e = e - eBias;
  26800. }
  26801. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  26802. }
  26803. function write (buffer, value, offset, isLE, mLen, nBytes) {
  26804. var e, m, c;
  26805. var eLen = nBytes * 8 - mLen - 1;
  26806. var eMax = (1 << eLen) - 1;
  26807. var eBias = eMax >> 1;
  26808. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  26809. var i = isLE ? 0 : (nBytes - 1);
  26810. var d = isLE ? 1 : -1;
  26811. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  26812. value = Math.abs(value);
  26813. if (isNaN(value) || value === Infinity) {
  26814. m = isNaN(value) ? 1 : 0;
  26815. e = eMax;
  26816. } else {
  26817. e = Math.floor(Math.log(value) / Math.LN2);
  26818. if (value * (c = Math.pow(2, -e)) < 1) {
  26819. e--;
  26820. c *= 2;
  26821. }
  26822. if (e + eBias >= 1) {
  26823. value += rt / c;
  26824. } else {
  26825. value += rt * Math.pow(2, 1 - eBias);
  26826. }
  26827. if (value * c >= 2) {
  26828. e++;
  26829. c /= 2;
  26830. }
  26831. if (e + eBias >= eMax) {
  26832. m = 0;
  26833. e = eMax;
  26834. } else if (e + eBias >= 1) {
  26835. m = (value * c - 1) * Math.pow(2, mLen);
  26836. e = e + eBias;
  26837. } else {
  26838. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  26839. e = 0;
  26840. }
  26841. }
  26842. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  26843. e = (e << mLen) | m;
  26844. eLen += mLen;
  26845. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  26846. buffer[offset + i - d] |= s * 128;
  26847. }
  26848. var toString$1 = {}.toString;
  26849. var isArray$2 = Array.isArray || function (arr) {
  26850. return toString$1.call(arr) == '[object Array]';
  26851. };
  26852. /*!
  26853. * The buffer module from node.js, for the browser.
  26854. *
  26855. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  26856. * @license MIT
  26857. */
  26858. /* eslint-disable no-proto */
  26859. var INSPECT_MAX_BYTES = 50;
  26860. /**
  26861. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  26862. * === true Use Uint8Array implementation (fastest)
  26863. * === false Use Object implementation (most compatible, even IE6)
  26864. *
  26865. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  26866. * Opera 11.6+, iOS 4.2+.
  26867. *
  26868. * Due to various browser bugs, sometimes the Object implementation will be used even
  26869. * when the browser supports typed arrays.
  26870. *
  26871. * Note:
  26872. *
  26873. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  26874. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  26875. *
  26876. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  26877. *
  26878. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  26879. * incorrect length in some situations.
  26880. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  26881. * get the Object implementation, which is slower but behaves correctly.
  26882. */
  26883. Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
  26884. ? global$1.TYPED_ARRAY_SUPPORT
  26885. : true;
  26886. /*
  26887. * Export kMaxLength after typed array support is determined.
  26888. */
  26889. kMaxLength();
  26890. function kMaxLength () {
  26891. return Buffer$1.TYPED_ARRAY_SUPPORT
  26892. ? 0x7fffffff
  26893. : 0x3fffffff
  26894. }
  26895. function createBuffer (that, length) {
  26896. if (kMaxLength() < length) {
  26897. throw new RangeError('Invalid typed array length')
  26898. }
  26899. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26900. // Return an augmented `Uint8Array` instance, for best performance
  26901. that = new Uint8Array(length);
  26902. that.__proto__ = Buffer$1.prototype;
  26903. } else {
  26904. // Fallback: Return an object instance of the Buffer class
  26905. if (that === null) {
  26906. that = new Buffer$1(length);
  26907. }
  26908. that.length = length;
  26909. }
  26910. return that
  26911. }
  26912. /**
  26913. * The Buffer constructor returns instances of `Uint8Array` that have their
  26914. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  26915. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  26916. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  26917. * returns a single octet.
  26918. *
  26919. * The `Uint8Array` prototype remains unmodified.
  26920. */
  26921. function Buffer$1 (arg, encodingOrOffset, length) {
  26922. if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
  26923. return new Buffer$1(arg, encodingOrOffset, length)
  26924. }
  26925. // Common case.
  26926. if (typeof arg === 'number') {
  26927. if (typeof encodingOrOffset === 'string') {
  26928. throw new Error(
  26929. 'If encoding is specified then the first argument must be a string'
  26930. )
  26931. }
  26932. return allocUnsafe(this, arg)
  26933. }
  26934. return from(this, arg, encodingOrOffset, length)
  26935. }
  26936. Buffer$1.poolSize = 8192; // not used by this implementation
  26937. // TODO: Legacy, not needed anymore. Remove in next major version.
  26938. Buffer$1._augment = function (arr) {
  26939. arr.__proto__ = Buffer$1.prototype;
  26940. return arr
  26941. };
  26942. function from (that, value, encodingOrOffset, length) {
  26943. if (typeof value === 'number') {
  26944. throw new TypeError('"value" argument must not be a number')
  26945. }
  26946. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  26947. return fromArrayBuffer(that, value, encodingOrOffset, length)
  26948. }
  26949. if (typeof value === 'string') {
  26950. return fromString(that, value, encodingOrOffset)
  26951. }
  26952. return fromObject(that, value)
  26953. }
  26954. /**
  26955. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  26956. * if value is a number.
  26957. * Buffer.from(str[, encoding])
  26958. * Buffer.from(array)
  26959. * Buffer.from(buffer)
  26960. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  26961. **/
  26962. Buffer$1.from = function (value, encodingOrOffset, length) {
  26963. return from(null, value, encodingOrOffset, length)
  26964. };
  26965. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26966. Buffer$1.prototype.__proto__ = Uint8Array.prototype;
  26967. Buffer$1.__proto__ = Uint8Array;
  26968. if (typeof Symbol !== 'undefined' && Symbol.species &&
  26969. Buffer$1[Symbol.species] === Buffer$1) ;
  26970. }
  26971. function assertSize (size) {
  26972. if (typeof size !== 'number') {
  26973. throw new TypeError('"size" argument must be a number')
  26974. } else if (size < 0) {
  26975. throw new RangeError('"size" argument must not be negative')
  26976. }
  26977. }
  26978. function alloc (that, size, fill, encoding) {
  26979. assertSize(size);
  26980. if (size <= 0) {
  26981. return createBuffer(that, size)
  26982. }
  26983. if (fill !== undefined) {
  26984. // Only pay attention to encoding if it's a string. This
  26985. // prevents accidentally sending in a number that would
  26986. // be interpretted as a start offset.
  26987. return typeof encoding === 'string'
  26988. ? createBuffer(that, size).fill(fill, encoding)
  26989. : createBuffer(that, size).fill(fill)
  26990. }
  26991. return createBuffer(that, size)
  26992. }
  26993. /**
  26994. * Creates a new filled Buffer instance.
  26995. * alloc(size[, fill[, encoding]])
  26996. **/
  26997. Buffer$1.alloc = function (size, fill, encoding) {
  26998. return alloc(null, size, fill, encoding)
  26999. };
  27000. function allocUnsafe (that, size) {
  27001. assertSize(size);
  27002. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  27003. if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
  27004. for (var i = 0; i < size; ++i) {
  27005. that[i] = 0;
  27006. }
  27007. }
  27008. return that
  27009. }
  27010. /**
  27011. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  27012. * */
  27013. Buffer$1.allocUnsafe = function (size) {
  27014. return allocUnsafe(null, size)
  27015. };
  27016. /**
  27017. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  27018. */
  27019. Buffer$1.allocUnsafeSlow = function (size) {
  27020. return allocUnsafe(null, size)
  27021. };
  27022. function fromString (that, string, encoding) {
  27023. if (typeof encoding !== 'string' || encoding === '') {
  27024. encoding = 'utf8';
  27025. }
  27026. if (!Buffer$1.isEncoding(encoding)) {
  27027. throw new TypeError('"encoding" must be a valid string encoding')
  27028. }
  27029. var length = byteLength(string, encoding) | 0;
  27030. that = createBuffer(that, length);
  27031. var actual = that.write(string, encoding);
  27032. if (actual !== length) {
  27033. // Writing a hex string, for example, that contains invalid characters will
  27034. // cause everything after the first invalid character to be ignored. (e.g.
  27035. // 'abxxcd' will be treated as 'ab')
  27036. that = that.slice(0, actual);
  27037. }
  27038. return that
  27039. }
  27040. function fromArrayLike (that, array) {
  27041. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  27042. that = createBuffer(that, length);
  27043. for (var i = 0; i < length; i += 1) {
  27044. that[i] = array[i] & 255;
  27045. }
  27046. return that
  27047. }
  27048. function fromArrayBuffer (that, array, byteOffset, length) {
  27049. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  27050. if (byteOffset < 0 || array.byteLength < byteOffset) {
  27051. throw new RangeError('\'offset\' is out of bounds')
  27052. }
  27053. if (array.byteLength < byteOffset + (length || 0)) {
  27054. throw new RangeError('\'length\' is out of bounds')
  27055. }
  27056. if (byteOffset === undefined && length === undefined) {
  27057. array = new Uint8Array(array);
  27058. } else if (length === undefined) {
  27059. array = new Uint8Array(array, byteOffset);
  27060. } else {
  27061. array = new Uint8Array(array, byteOffset, length);
  27062. }
  27063. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27064. // Return an augmented `Uint8Array` instance, for best performance
  27065. that = array;
  27066. that.__proto__ = Buffer$1.prototype;
  27067. } else {
  27068. // Fallback: Return an object instance of the Buffer class
  27069. that = fromArrayLike(that, array);
  27070. }
  27071. return that
  27072. }
  27073. function fromObject (that, obj) {
  27074. if (internalIsBuffer(obj)) {
  27075. var len = checked(obj.length) | 0;
  27076. that = createBuffer(that, len);
  27077. if (that.length === 0) {
  27078. return that
  27079. }
  27080. obj.copy(that, 0, 0, len);
  27081. return that
  27082. }
  27083. if (obj) {
  27084. if ((typeof ArrayBuffer !== 'undefined' &&
  27085. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  27086. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  27087. return createBuffer(that, 0)
  27088. }
  27089. return fromArrayLike(that, obj)
  27090. }
  27091. if (obj.type === 'Buffer' && isArray$2(obj.data)) {
  27092. return fromArrayLike(that, obj.data)
  27093. }
  27094. }
  27095. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  27096. }
  27097. function checked (length) {
  27098. // Note: cannot use `length < kMaxLength()` here because that fails when
  27099. // length is NaN (which is otherwise coerced to zero.)
  27100. if (length >= kMaxLength()) {
  27101. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  27102. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  27103. }
  27104. return length | 0
  27105. }
  27106. Buffer$1.isBuffer = isBuffer$1;
  27107. function internalIsBuffer (b) {
  27108. return !!(b != null && b._isBuffer)
  27109. }
  27110. Buffer$1.compare = function compare (a, b) {
  27111. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  27112. throw new TypeError('Arguments must be Buffers')
  27113. }
  27114. if (a === b) return 0
  27115. var x = a.length;
  27116. var y = b.length;
  27117. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  27118. if (a[i] !== b[i]) {
  27119. x = a[i];
  27120. y = b[i];
  27121. break
  27122. }
  27123. }
  27124. if (x < y) return -1
  27125. if (y < x) return 1
  27126. return 0
  27127. };
  27128. Buffer$1.isEncoding = function isEncoding (encoding) {
  27129. switch (String(encoding).toLowerCase()) {
  27130. case 'hex':
  27131. case 'utf8':
  27132. case 'utf-8':
  27133. case 'ascii':
  27134. case 'latin1':
  27135. case 'binary':
  27136. case 'base64':
  27137. case 'ucs2':
  27138. case 'ucs-2':
  27139. case 'utf16le':
  27140. case 'utf-16le':
  27141. return true
  27142. default:
  27143. return false
  27144. }
  27145. };
  27146. Buffer$1.concat = function concat (list, length) {
  27147. if (!isArray$2(list)) {
  27148. throw new TypeError('"list" argument must be an Array of Buffers')
  27149. }
  27150. if (list.length === 0) {
  27151. return Buffer$1.alloc(0)
  27152. }
  27153. var i;
  27154. if (length === undefined) {
  27155. length = 0;
  27156. for (i = 0; i < list.length; ++i) {
  27157. length += list[i].length;
  27158. }
  27159. }
  27160. var buffer = Buffer$1.allocUnsafe(length);
  27161. var pos = 0;
  27162. for (i = 0; i < list.length; ++i) {
  27163. var buf = list[i];
  27164. if (!internalIsBuffer(buf)) {
  27165. throw new TypeError('"list" argument must be an Array of Buffers')
  27166. }
  27167. buf.copy(buffer, pos);
  27168. pos += buf.length;
  27169. }
  27170. return buffer
  27171. };
  27172. function byteLength (string, encoding) {
  27173. if (internalIsBuffer(string)) {
  27174. return string.length
  27175. }
  27176. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  27177. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  27178. return string.byteLength
  27179. }
  27180. if (typeof string !== 'string') {
  27181. string = '' + string;
  27182. }
  27183. var len = string.length;
  27184. if (len === 0) return 0
  27185. // Use a for loop to avoid recursion
  27186. var loweredCase = false;
  27187. for (;;) {
  27188. switch (encoding) {
  27189. case 'ascii':
  27190. case 'latin1':
  27191. case 'binary':
  27192. return len
  27193. case 'utf8':
  27194. case 'utf-8':
  27195. case undefined:
  27196. return utf8ToBytes(string).length
  27197. case 'ucs2':
  27198. case 'ucs-2':
  27199. case 'utf16le':
  27200. case 'utf-16le':
  27201. return len * 2
  27202. case 'hex':
  27203. return len >>> 1
  27204. case 'base64':
  27205. return base64ToBytes(string).length
  27206. default:
  27207. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  27208. encoding = ('' + encoding).toLowerCase();
  27209. loweredCase = true;
  27210. }
  27211. }
  27212. }
  27213. Buffer$1.byteLength = byteLength;
  27214. function slowToString (encoding, start, end) {
  27215. var loweredCase = false;
  27216. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  27217. // property of a typed array.
  27218. // This behaves neither like String nor Uint8Array in that we set start/end
  27219. // to their upper/lower bounds if the value passed is out of range.
  27220. // undefined is handled specially as per ECMA-262 6th Edition,
  27221. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  27222. if (start === undefined || start < 0) {
  27223. start = 0;
  27224. }
  27225. // Return early if start > this.length. Done here to prevent potential uint32
  27226. // coercion fail below.
  27227. if (start > this.length) {
  27228. return ''
  27229. }
  27230. if (end === undefined || end > this.length) {
  27231. end = this.length;
  27232. }
  27233. if (end <= 0) {
  27234. return ''
  27235. }
  27236. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  27237. end >>>= 0;
  27238. start >>>= 0;
  27239. if (end <= start) {
  27240. return ''
  27241. }
  27242. if (!encoding) encoding = 'utf8';
  27243. while (true) {
  27244. switch (encoding) {
  27245. case 'hex':
  27246. return hexSlice(this, start, end)
  27247. case 'utf8':
  27248. case 'utf-8':
  27249. return utf8Slice(this, start, end)
  27250. case 'ascii':
  27251. return asciiSlice(this, start, end)
  27252. case 'latin1':
  27253. case 'binary':
  27254. return latin1Slice(this, start, end)
  27255. case 'base64':
  27256. return base64Slice(this, start, end)
  27257. case 'ucs2':
  27258. case 'ucs-2':
  27259. case 'utf16le':
  27260. case 'utf-16le':
  27261. return utf16leSlice(this, start, end)
  27262. default:
  27263. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27264. encoding = (encoding + '').toLowerCase();
  27265. loweredCase = true;
  27266. }
  27267. }
  27268. }
  27269. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  27270. // Buffer instances.
  27271. Buffer$1.prototype._isBuffer = true;
  27272. function swap (b, n, m) {
  27273. var i = b[n];
  27274. b[n] = b[m];
  27275. b[m] = i;
  27276. }
  27277. Buffer$1.prototype.swap16 = function swap16 () {
  27278. var len = this.length;
  27279. if (len % 2 !== 0) {
  27280. throw new RangeError('Buffer size must be a multiple of 16-bits')
  27281. }
  27282. for (var i = 0; i < len; i += 2) {
  27283. swap(this, i, i + 1);
  27284. }
  27285. return this
  27286. };
  27287. Buffer$1.prototype.swap32 = function swap32 () {
  27288. var len = this.length;
  27289. if (len % 4 !== 0) {
  27290. throw new RangeError('Buffer size must be a multiple of 32-bits')
  27291. }
  27292. for (var i = 0; i < len; i += 4) {
  27293. swap(this, i, i + 3);
  27294. swap(this, i + 1, i + 2);
  27295. }
  27296. return this
  27297. };
  27298. Buffer$1.prototype.swap64 = function swap64 () {
  27299. var len = this.length;
  27300. if (len % 8 !== 0) {
  27301. throw new RangeError('Buffer size must be a multiple of 64-bits')
  27302. }
  27303. for (var i = 0; i < len; i += 8) {
  27304. swap(this, i, i + 7);
  27305. swap(this, i + 1, i + 6);
  27306. swap(this, i + 2, i + 5);
  27307. swap(this, i + 3, i + 4);
  27308. }
  27309. return this
  27310. };
  27311. Buffer$1.prototype.toString = function toString () {
  27312. var length = this.length | 0;
  27313. if (length === 0) return ''
  27314. if (arguments.length === 0) return utf8Slice(this, 0, length)
  27315. return slowToString.apply(this, arguments)
  27316. };
  27317. Buffer$1.prototype.equals = function equals (b) {
  27318. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  27319. if (this === b) return true
  27320. return Buffer$1.compare(this, b) === 0
  27321. };
  27322. Buffer$1.prototype.inspect = function inspect () {
  27323. var str = '';
  27324. var max = INSPECT_MAX_BYTES;
  27325. if (this.length > 0) {
  27326. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  27327. if (this.length > max) str += ' ... ';
  27328. }
  27329. return '<Buffer ' + str + '>'
  27330. };
  27331. Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  27332. if (!internalIsBuffer(target)) {
  27333. throw new TypeError('Argument must be a Buffer')
  27334. }
  27335. if (start === undefined) {
  27336. start = 0;
  27337. }
  27338. if (end === undefined) {
  27339. end = target ? target.length : 0;
  27340. }
  27341. if (thisStart === undefined) {
  27342. thisStart = 0;
  27343. }
  27344. if (thisEnd === undefined) {
  27345. thisEnd = this.length;
  27346. }
  27347. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  27348. throw new RangeError('out of range index')
  27349. }
  27350. if (thisStart >= thisEnd && start >= end) {
  27351. return 0
  27352. }
  27353. if (thisStart >= thisEnd) {
  27354. return -1
  27355. }
  27356. if (start >= end) {
  27357. return 1
  27358. }
  27359. start >>>= 0;
  27360. end >>>= 0;
  27361. thisStart >>>= 0;
  27362. thisEnd >>>= 0;
  27363. if (this === target) return 0
  27364. var x = thisEnd - thisStart;
  27365. var y = end - start;
  27366. var len = Math.min(x, y);
  27367. var thisCopy = this.slice(thisStart, thisEnd);
  27368. var targetCopy = target.slice(start, end);
  27369. for (var i = 0; i < len; ++i) {
  27370. if (thisCopy[i] !== targetCopy[i]) {
  27371. x = thisCopy[i];
  27372. y = targetCopy[i];
  27373. break
  27374. }
  27375. }
  27376. if (x < y) return -1
  27377. if (y < x) return 1
  27378. return 0
  27379. };
  27380. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  27381. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  27382. //
  27383. // Arguments:
  27384. // - buffer - a Buffer to search
  27385. // - val - a string, Buffer, or number
  27386. // - byteOffset - an index into `buffer`; will be clamped to an int32
  27387. // - encoding - an optional encoding, relevant is val is a string
  27388. // - dir - true for indexOf, false for lastIndexOf
  27389. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  27390. // Empty buffer means no match
  27391. if (buffer.length === 0) return -1
  27392. // Normalize byteOffset
  27393. if (typeof byteOffset === 'string') {
  27394. encoding = byteOffset;
  27395. byteOffset = 0;
  27396. } else if (byteOffset > 0x7fffffff) {
  27397. byteOffset = 0x7fffffff;
  27398. } else if (byteOffset < -0x80000000) {
  27399. byteOffset = -0x80000000;
  27400. }
  27401. byteOffset = +byteOffset; // Coerce to Number.
  27402. if (isNaN(byteOffset)) {
  27403. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  27404. byteOffset = dir ? 0 : (buffer.length - 1);
  27405. }
  27406. // Normalize byteOffset: negative offsets start from the end of the buffer
  27407. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  27408. if (byteOffset >= buffer.length) {
  27409. if (dir) return -1
  27410. else byteOffset = buffer.length - 1;
  27411. } else if (byteOffset < 0) {
  27412. if (dir) byteOffset = 0;
  27413. else return -1
  27414. }
  27415. // Normalize val
  27416. if (typeof val === 'string') {
  27417. val = Buffer$1.from(val, encoding);
  27418. }
  27419. // Finally, search either indexOf (if dir is true) or lastIndexOf
  27420. if (internalIsBuffer(val)) {
  27421. // Special case: looking for empty string/buffer always fails
  27422. if (val.length === 0) {
  27423. return -1
  27424. }
  27425. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  27426. } else if (typeof val === 'number') {
  27427. val = val & 0xFF; // Search for a byte value [0-255]
  27428. if (Buffer$1.TYPED_ARRAY_SUPPORT &&
  27429. typeof Uint8Array.prototype.indexOf === 'function') {
  27430. if (dir) {
  27431. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  27432. } else {
  27433. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  27434. }
  27435. }
  27436. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  27437. }
  27438. throw new TypeError('val must be string, number or Buffer')
  27439. }
  27440. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  27441. var indexSize = 1;
  27442. var arrLength = arr.length;
  27443. var valLength = val.length;
  27444. if (encoding !== undefined) {
  27445. encoding = String(encoding).toLowerCase();
  27446. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  27447. encoding === 'utf16le' || encoding === 'utf-16le') {
  27448. if (arr.length < 2 || val.length < 2) {
  27449. return -1
  27450. }
  27451. indexSize = 2;
  27452. arrLength /= 2;
  27453. valLength /= 2;
  27454. byteOffset /= 2;
  27455. }
  27456. }
  27457. function read (buf, i) {
  27458. if (indexSize === 1) {
  27459. return buf[i]
  27460. } else {
  27461. return buf.readUInt16BE(i * indexSize)
  27462. }
  27463. }
  27464. var i;
  27465. if (dir) {
  27466. var foundIndex = -1;
  27467. for (i = byteOffset; i < arrLength; i++) {
  27468. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  27469. if (foundIndex === -1) foundIndex = i;
  27470. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  27471. } else {
  27472. if (foundIndex !== -1) i -= i - foundIndex;
  27473. foundIndex = -1;
  27474. }
  27475. }
  27476. } else {
  27477. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  27478. for (i = byteOffset; i >= 0; i--) {
  27479. var found = true;
  27480. for (var j = 0; j < valLength; j++) {
  27481. if (read(arr, i + j) !== read(val, j)) {
  27482. found = false;
  27483. break
  27484. }
  27485. }
  27486. if (found) return i
  27487. }
  27488. }
  27489. return -1
  27490. }
  27491. Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
  27492. return this.indexOf(val, byteOffset, encoding) !== -1
  27493. };
  27494. Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  27495. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  27496. };
  27497. Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  27498. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  27499. };
  27500. function hexWrite (buf, string, offset, length) {
  27501. offset = Number(offset) || 0;
  27502. var remaining = buf.length - offset;
  27503. if (!length) {
  27504. length = remaining;
  27505. } else {
  27506. length = Number(length);
  27507. if (length > remaining) {
  27508. length = remaining;
  27509. }
  27510. }
  27511. // must be an even number of digits
  27512. var strLen = string.length;
  27513. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  27514. if (length > strLen / 2) {
  27515. length = strLen / 2;
  27516. }
  27517. for (var i = 0; i < length; ++i) {
  27518. var parsed = parseInt(string.substr(i * 2, 2), 16);
  27519. if (isNaN(parsed)) return i
  27520. buf[offset + i] = parsed;
  27521. }
  27522. return i
  27523. }
  27524. function utf8Write (buf, string, offset, length) {
  27525. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  27526. }
  27527. function asciiWrite (buf, string, offset, length) {
  27528. return blitBuffer(asciiToBytes(string), buf, offset, length)
  27529. }
  27530. function latin1Write (buf, string, offset, length) {
  27531. return asciiWrite(buf, string, offset, length)
  27532. }
  27533. function base64Write (buf, string, offset, length) {
  27534. return blitBuffer(base64ToBytes(string), buf, offset, length)
  27535. }
  27536. function ucs2Write (buf, string, offset, length) {
  27537. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  27538. }
  27539. Buffer$1.prototype.write = function write (string, offset, length, encoding) {
  27540. // Buffer#write(string)
  27541. if (offset === undefined) {
  27542. encoding = 'utf8';
  27543. length = this.length;
  27544. offset = 0;
  27545. // Buffer#write(string, encoding)
  27546. } else if (length === undefined && typeof offset === 'string') {
  27547. encoding = offset;
  27548. length = this.length;
  27549. offset = 0;
  27550. // Buffer#write(string, offset[, length][, encoding])
  27551. } else if (isFinite(offset)) {
  27552. offset = offset | 0;
  27553. if (isFinite(length)) {
  27554. length = length | 0;
  27555. if (encoding === undefined) encoding = 'utf8';
  27556. } else {
  27557. encoding = length;
  27558. length = undefined;
  27559. }
  27560. // legacy write(string, encoding, offset, length) - remove in v0.13
  27561. } else {
  27562. throw new Error(
  27563. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  27564. )
  27565. }
  27566. var remaining = this.length - offset;
  27567. if (length === undefined || length > remaining) length = remaining;
  27568. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  27569. throw new RangeError('Attempt to write outside buffer bounds')
  27570. }
  27571. if (!encoding) encoding = 'utf8';
  27572. var loweredCase = false;
  27573. for (;;) {
  27574. switch (encoding) {
  27575. case 'hex':
  27576. return hexWrite(this, string, offset, length)
  27577. case 'utf8':
  27578. case 'utf-8':
  27579. return utf8Write(this, string, offset, length)
  27580. case 'ascii':
  27581. return asciiWrite(this, string, offset, length)
  27582. case 'latin1':
  27583. case 'binary':
  27584. return latin1Write(this, string, offset, length)
  27585. case 'base64':
  27586. // Warning: maxLength not taken into account in base64Write
  27587. return base64Write(this, string, offset, length)
  27588. case 'ucs2':
  27589. case 'ucs-2':
  27590. case 'utf16le':
  27591. case 'utf-16le':
  27592. return ucs2Write(this, string, offset, length)
  27593. default:
  27594. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27595. encoding = ('' + encoding).toLowerCase();
  27596. loweredCase = true;
  27597. }
  27598. }
  27599. };
  27600. Buffer$1.prototype.toJSON = function toJSON () {
  27601. return {
  27602. type: 'Buffer',
  27603. data: Array.prototype.slice.call(this._arr || this, 0)
  27604. }
  27605. };
  27606. function base64Slice (buf, start, end) {
  27607. if (start === 0 && end === buf.length) {
  27608. return fromByteArray(buf)
  27609. } else {
  27610. return fromByteArray(buf.slice(start, end))
  27611. }
  27612. }
  27613. function utf8Slice (buf, start, end) {
  27614. end = Math.min(buf.length, end);
  27615. var res = [];
  27616. var i = start;
  27617. while (i < end) {
  27618. var firstByte = buf[i];
  27619. var codePoint = null;
  27620. var bytesPerSequence = (firstByte > 0xEF) ? 4
  27621. : (firstByte > 0xDF) ? 3
  27622. : (firstByte > 0xBF) ? 2
  27623. : 1;
  27624. if (i + bytesPerSequence <= end) {
  27625. var secondByte, thirdByte, fourthByte, tempCodePoint;
  27626. switch (bytesPerSequence) {
  27627. case 1:
  27628. if (firstByte < 0x80) {
  27629. codePoint = firstByte;
  27630. }
  27631. break
  27632. case 2:
  27633. secondByte = buf[i + 1];
  27634. if ((secondByte & 0xC0) === 0x80) {
  27635. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  27636. if (tempCodePoint > 0x7F) {
  27637. codePoint = tempCodePoint;
  27638. }
  27639. }
  27640. break
  27641. case 3:
  27642. secondByte = buf[i + 1];
  27643. thirdByte = buf[i + 2];
  27644. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  27645. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  27646. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  27647. codePoint = tempCodePoint;
  27648. }
  27649. }
  27650. break
  27651. case 4:
  27652. secondByte = buf[i + 1];
  27653. thirdByte = buf[i + 2];
  27654. fourthByte = buf[i + 3];
  27655. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  27656. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  27657. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  27658. codePoint = tempCodePoint;
  27659. }
  27660. }
  27661. }
  27662. }
  27663. if (codePoint === null) {
  27664. // we did not generate a valid codePoint so insert a
  27665. // replacement char (U+FFFD) and advance only 1 byte
  27666. codePoint = 0xFFFD;
  27667. bytesPerSequence = 1;
  27668. } else if (codePoint > 0xFFFF) {
  27669. // encode to utf16 (surrogate pair dance)
  27670. codePoint -= 0x10000;
  27671. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  27672. codePoint = 0xDC00 | codePoint & 0x3FF;
  27673. }
  27674. res.push(codePoint);
  27675. i += bytesPerSequence;
  27676. }
  27677. return decodeCodePointsArray(res)
  27678. }
  27679. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  27680. // the lowest limit is Chrome, with 0x10000 args.
  27681. // We go 1 magnitude less, for safety
  27682. var MAX_ARGUMENTS_LENGTH = 0x1000;
  27683. function decodeCodePointsArray (codePoints) {
  27684. var len = codePoints.length;
  27685. if (len <= MAX_ARGUMENTS_LENGTH) {
  27686. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  27687. }
  27688. // Decode in chunks to avoid "call stack size exceeded".
  27689. var res = '';
  27690. var i = 0;
  27691. while (i < len) {
  27692. res += String.fromCharCode.apply(
  27693. String,
  27694. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  27695. );
  27696. }
  27697. return res
  27698. }
  27699. function asciiSlice (buf, start, end) {
  27700. var ret = '';
  27701. end = Math.min(buf.length, end);
  27702. for (var i = start; i < end; ++i) {
  27703. ret += String.fromCharCode(buf[i] & 0x7F);
  27704. }
  27705. return ret
  27706. }
  27707. function latin1Slice (buf, start, end) {
  27708. var ret = '';
  27709. end = Math.min(buf.length, end);
  27710. for (var i = start; i < end; ++i) {
  27711. ret += String.fromCharCode(buf[i]);
  27712. }
  27713. return ret
  27714. }
  27715. function hexSlice (buf, start, end) {
  27716. var len = buf.length;
  27717. if (!start || start < 0) start = 0;
  27718. if (!end || end < 0 || end > len) end = len;
  27719. var out = '';
  27720. for (var i = start; i < end; ++i) {
  27721. out += toHex(buf[i]);
  27722. }
  27723. return out
  27724. }
  27725. function utf16leSlice (buf, start, end) {
  27726. var bytes = buf.slice(start, end);
  27727. var res = '';
  27728. for (var i = 0; i < bytes.length; i += 2) {
  27729. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  27730. }
  27731. return res
  27732. }
  27733. Buffer$1.prototype.slice = function slice (start, end) {
  27734. var len = this.length;
  27735. start = ~~start;
  27736. end = end === undefined ? len : ~~end;
  27737. if (start < 0) {
  27738. start += len;
  27739. if (start < 0) start = 0;
  27740. } else if (start > len) {
  27741. start = len;
  27742. }
  27743. if (end < 0) {
  27744. end += len;
  27745. if (end < 0) end = 0;
  27746. } else if (end > len) {
  27747. end = len;
  27748. }
  27749. if (end < start) end = start;
  27750. var newBuf;
  27751. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27752. newBuf = this.subarray(start, end);
  27753. newBuf.__proto__ = Buffer$1.prototype;
  27754. } else {
  27755. var sliceLen = end - start;
  27756. newBuf = new Buffer$1(sliceLen, undefined);
  27757. for (var i = 0; i < sliceLen; ++i) {
  27758. newBuf[i] = this[i + start];
  27759. }
  27760. }
  27761. return newBuf
  27762. };
  27763. /*
  27764. * Need to make sure that buffer isn't trying to write out of bounds.
  27765. */
  27766. function checkOffset (offset, ext, length) {
  27767. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  27768. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  27769. }
  27770. Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  27771. offset = offset | 0;
  27772. byteLength = byteLength | 0;
  27773. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27774. var val = this[offset];
  27775. var mul = 1;
  27776. var i = 0;
  27777. while (++i < byteLength && (mul *= 0x100)) {
  27778. val += this[offset + i] * mul;
  27779. }
  27780. return val
  27781. };
  27782. Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  27783. offset = offset | 0;
  27784. byteLength = byteLength | 0;
  27785. if (!noAssert) {
  27786. checkOffset(offset, byteLength, this.length);
  27787. }
  27788. var val = this[offset + --byteLength];
  27789. var mul = 1;
  27790. while (byteLength > 0 && (mul *= 0x100)) {
  27791. val += this[offset + --byteLength] * mul;
  27792. }
  27793. return val
  27794. };
  27795. Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  27796. if (!noAssert) checkOffset(offset, 1, this.length);
  27797. return this[offset]
  27798. };
  27799. Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  27800. if (!noAssert) checkOffset(offset, 2, this.length);
  27801. return this[offset] | (this[offset + 1] << 8)
  27802. };
  27803. Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  27804. if (!noAssert) checkOffset(offset, 2, this.length);
  27805. return (this[offset] << 8) | this[offset + 1]
  27806. };
  27807. Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  27808. if (!noAssert) checkOffset(offset, 4, this.length);
  27809. return ((this[offset]) |
  27810. (this[offset + 1] << 8) |
  27811. (this[offset + 2] << 16)) +
  27812. (this[offset + 3] * 0x1000000)
  27813. };
  27814. Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  27815. if (!noAssert) checkOffset(offset, 4, this.length);
  27816. return (this[offset] * 0x1000000) +
  27817. ((this[offset + 1] << 16) |
  27818. (this[offset + 2] << 8) |
  27819. this[offset + 3])
  27820. };
  27821. Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  27822. offset = offset | 0;
  27823. byteLength = byteLength | 0;
  27824. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27825. var val = this[offset];
  27826. var mul = 1;
  27827. var i = 0;
  27828. while (++i < byteLength && (mul *= 0x100)) {
  27829. val += this[offset + i] * mul;
  27830. }
  27831. mul *= 0x80;
  27832. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27833. return val
  27834. };
  27835. Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  27836. offset = offset | 0;
  27837. byteLength = byteLength | 0;
  27838. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27839. var i = byteLength;
  27840. var mul = 1;
  27841. var val = this[offset + --i];
  27842. while (i > 0 && (mul *= 0x100)) {
  27843. val += this[offset + --i] * mul;
  27844. }
  27845. mul *= 0x80;
  27846. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27847. return val
  27848. };
  27849. Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
  27850. if (!noAssert) checkOffset(offset, 1, this.length);
  27851. if (!(this[offset] & 0x80)) return (this[offset])
  27852. return ((0xff - this[offset] + 1) * -1)
  27853. };
  27854. Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  27855. if (!noAssert) checkOffset(offset, 2, this.length);
  27856. var val = this[offset] | (this[offset + 1] << 8);
  27857. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27858. };
  27859. Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  27860. if (!noAssert) checkOffset(offset, 2, this.length);
  27861. var val = this[offset + 1] | (this[offset] << 8);
  27862. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27863. };
  27864. Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  27865. if (!noAssert) checkOffset(offset, 4, this.length);
  27866. return (this[offset]) |
  27867. (this[offset + 1] << 8) |
  27868. (this[offset + 2] << 16) |
  27869. (this[offset + 3] << 24)
  27870. };
  27871. Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  27872. if (!noAssert) checkOffset(offset, 4, this.length);
  27873. return (this[offset] << 24) |
  27874. (this[offset + 1] << 16) |
  27875. (this[offset + 2] << 8) |
  27876. (this[offset + 3])
  27877. };
  27878. Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  27879. if (!noAssert) checkOffset(offset, 4, this.length);
  27880. return read(this, offset, true, 23, 4)
  27881. };
  27882. Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  27883. if (!noAssert) checkOffset(offset, 4, this.length);
  27884. return read(this, offset, false, 23, 4)
  27885. };
  27886. Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  27887. if (!noAssert) checkOffset(offset, 8, this.length);
  27888. return read(this, offset, true, 52, 8)
  27889. };
  27890. Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  27891. if (!noAssert) checkOffset(offset, 8, this.length);
  27892. return read(this, offset, false, 52, 8)
  27893. };
  27894. function checkInt (buf, value, offset, ext, max, min) {
  27895. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  27896. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  27897. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27898. }
  27899. Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  27900. value = +value;
  27901. offset = offset | 0;
  27902. byteLength = byteLength | 0;
  27903. if (!noAssert) {
  27904. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27905. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27906. }
  27907. var mul = 1;
  27908. var i = 0;
  27909. this[offset] = value & 0xFF;
  27910. while (++i < byteLength && (mul *= 0x100)) {
  27911. this[offset + i] = (value / mul) & 0xFF;
  27912. }
  27913. return offset + byteLength
  27914. };
  27915. Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  27916. value = +value;
  27917. offset = offset | 0;
  27918. byteLength = byteLength | 0;
  27919. if (!noAssert) {
  27920. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27921. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27922. }
  27923. var i = byteLength - 1;
  27924. var mul = 1;
  27925. this[offset + i] = value & 0xFF;
  27926. while (--i >= 0 && (mul *= 0x100)) {
  27927. this[offset + i] = (value / mul) & 0xFF;
  27928. }
  27929. return offset + byteLength
  27930. };
  27931. Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  27932. value = +value;
  27933. offset = offset | 0;
  27934. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  27935. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27936. this[offset] = (value & 0xff);
  27937. return offset + 1
  27938. };
  27939. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  27940. if (value < 0) value = 0xffff + value + 1;
  27941. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  27942. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  27943. (littleEndian ? i : 1 - i) * 8;
  27944. }
  27945. }
  27946. Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  27947. value = +value;
  27948. offset = offset | 0;
  27949. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27950. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27951. this[offset] = (value & 0xff);
  27952. this[offset + 1] = (value >>> 8);
  27953. } else {
  27954. objectWriteUInt16(this, value, offset, true);
  27955. }
  27956. return offset + 2
  27957. };
  27958. Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  27959. value = +value;
  27960. offset = offset | 0;
  27961. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27962. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27963. this[offset] = (value >>> 8);
  27964. this[offset + 1] = (value & 0xff);
  27965. } else {
  27966. objectWriteUInt16(this, value, offset, false);
  27967. }
  27968. return offset + 2
  27969. };
  27970. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  27971. if (value < 0) value = 0xffffffff + value + 1;
  27972. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  27973. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  27974. }
  27975. }
  27976. Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  27977. value = +value;
  27978. offset = offset | 0;
  27979. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27980. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27981. this[offset + 3] = (value >>> 24);
  27982. this[offset + 2] = (value >>> 16);
  27983. this[offset + 1] = (value >>> 8);
  27984. this[offset] = (value & 0xff);
  27985. } else {
  27986. objectWriteUInt32(this, value, offset, true);
  27987. }
  27988. return offset + 4
  27989. };
  27990. Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  27991. value = +value;
  27992. offset = offset | 0;
  27993. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27994. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27995. this[offset] = (value >>> 24);
  27996. this[offset + 1] = (value >>> 16);
  27997. this[offset + 2] = (value >>> 8);
  27998. this[offset + 3] = (value & 0xff);
  27999. } else {
  28000. objectWriteUInt32(this, value, offset, false);
  28001. }
  28002. return offset + 4
  28003. };
  28004. Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  28005. value = +value;
  28006. offset = offset | 0;
  28007. if (!noAssert) {
  28008. var limit = Math.pow(2, 8 * byteLength - 1);
  28009. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  28010. }
  28011. var i = 0;
  28012. var mul = 1;
  28013. var sub = 0;
  28014. this[offset] = value & 0xFF;
  28015. while (++i < byteLength && (mul *= 0x100)) {
  28016. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  28017. sub = 1;
  28018. }
  28019. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  28020. }
  28021. return offset + byteLength
  28022. };
  28023. Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  28024. value = +value;
  28025. offset = offset | 0;
  28026. if (!noAssert) {
  28027. var limit = Math.pow(2, 8 * byteLength - 1);
  28028. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  28029. }
  28030. var i = byteLength - 1;
  28031. var mul = 1;
  28032. var sub = 0;
  28033. this[offset + i] = value & 0xFF;
  28034. while (--i >= 0 && (mul *= 0x100)) {
  28035. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  28036. sub = 1;
  28037. }
  28038. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  28039. }
  28040. return offset + byteLength
  28041. };
  28042. Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  28043. value = +value;
  28044. offset = offset | 0;
  28045. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  28046. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  28047. if (value < 0) value = 0xff + value + 1;
  28048. this[offset] = (value & 0xff);
  28049. return offset + 1
  28050. };
  28051. Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  28052. value = +value;
  28053. offset = offset | 0;
  28054. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  28055. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28056. this[offset] = (value & 0xff);
  28057. this[offset + 1] = (value >>> 8);
  28058. } else {
  28059. objectWriteUInt16(this, value, offset, true);
  28060. }
  28061. return offset + 2
  28062. };
  28063. Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  28064. value = +value;
  28065. offset = offset | 0;
  28066. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  28067. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28068. this[offset] = (value >>> 8);
  28069. this[offset + 1] = (value & 0xff);
  28070. } else {
  28071. objectWriteUInt16(this, value, offset, false);
  28072. }
  28073. return offset + 2
  28074. };
  28075. Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  28076. value = +value;
  28077. offset = offset | 0;
  28078. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  28079. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28080. this[offset] = (value & 0xff);
  28081. this[offset + 1] = (value >>> 8);
  28082. this[offset + 2] = (value >>> 16);
  28083. this[offset + 3] = (value >>> 24);
  28084. } else {
  28085. objectWriteUInt32(this, value, offset, true);
  28086. }
  28087. return offset + 4
  28088. };
  28089. Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  28090. value = +value;
  28091. offset = offset | 0;
  28092. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  28093. if (value < 0) value = 0xffffffff + value + 1;
  28094. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  28095. this[offset] = (value >>> 24);
  28096. this[offset + 1] = (value >>> 16);
  28097. this[offset + 2] = (value >>> 8);
  28098. this[offset + 3] = (value & 0xff);
  28099. } else {
  28100. objectWriteUInt32(this, value, offset, false);
  28101. }
  28102. return offset + 4
  28103. };
  28104. function checkIEEE754 (buf, value, offset, ext, max, min) {
  28105. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  28106. if (offset < 0) throw new RangeError('Index out of range')
  28107. }
  28108. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  28109. if (!noAssert) {
  28110. checkIEEE754(buf, value, offset, 4);
  28111. }
  28112. write(buf, value, offset, littleEndian, 23, 4);
  28113. return offset + 4
  28114. }
  28115. Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  28116. return writeFloat(this, value, offset, true, noAssert)
  28117. };
  28118. Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  28119. return writeFloat(this, value, offset, false, noAssert)
  28120. };
  28121. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  28122. if (!noAssert) {
  28123. checkIEEE754(buf, value, offset, 8);
  28124. }
  28125. write(buf, value, offset, littleEndian, 52, 8);
  28126. return offset + 8
  28127. }
  28128. Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  28129. return writeDouble(this, value, offset, true, noAssert)
  28130. };
  28131. Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  28132. return writeDouble(this, value, offset, false, noAssert)
  28133. };
  28134. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  28135. Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
  28136. if (!start) start = 0;
  28137. if (!end && end !== 0) end = this.length;
  28138. if (targetStart >= target.length) targetStart = target.length;
  28139. if (!targetStart) targetStart = 0;
  28140. if (end > 0 && end < start) end = start;
  28141. // Copy 0 bytes; we're done
  28142. if (end === start) return 0
  28143. if (target.length === 0 || this.length === 0) return 0
  28144. // Fatal error conditions
  28145. if (targetStart < 0) {
  28146. throw new RangeError('targetStart out of bounds')
  28147. }
  28148. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  28149. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  28150. // Are we oob?
  28151. if (end > this.length) end = this.length;
  28152. if (target.length - targetStart < end - start) {
  28153. end = target.length - targetStart + start;
  28154. }
  28155. var len = end - start;
  28156. var i;
  28157. if (this === target && start < targetStart && targetStart < end) {
  28158. // descending copy from end
  28159. for (i = len - 1; i >= 0; --i) {
  28160. target[i + targetStart] = this[i + start];
  28161. }
  28162. } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
  28163. // ascending copy from start
  28164. for (i = 0; i < len; ++i) {
  28165. target[i + targetStart] = this[i + start];
  28166. }
  28167. } else {
  28168. Uint8Array.prototype.set.call(
  28169. target,
  28170. this.subarray(start, start + len),
  28171. targetStart
  28172. );
  28173. }
  28174. return len
  28175. };
  28176. // Usage:
  28177. // buffer.fill(number[, offset[, end]])
  28178. // buffer.fill(buffer[, offset[, end]])
  28179. // buffer.fill(string[, offset[, end]][, encoding])
  28180. Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
  28181. // Handle string cases:
  28182. if (typeof val === 'string') {
  28183. if (typeof start === 'string') {
  28184. encoding = start;
  28185. start = 0;
  28186. end = this.length;
  28187. } else if (typeof end === 'string') {
  28188. encoding = end;
  28189. end = this.length;
  28190. }
  28191. if (val.length === 1) {
  28192. var code = val.charCodeAt(0);
  28193. if (code < 256) {
  28194. val = code;
  28195. }
  28196. }
  28197. if (encoding !== undefined && typeof encoding !== 'string') {
  28198. throw new TypeError('encoding must be a string')
  28199. }
  28200. if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
  28201. throw new TypeError('Unknown encoding: ' + encoding)
  28202. }
  28203. } else if (typeof val === 'number') {
  28204. val = val & 255;
  28205. }
  28206. // Invalid ranges are not set to a default, so can range check early.
  28207. if (start < 0 || this.length < start || this.length < end) {
  28208. throw new RangeError('Out of range index')
  28209. }
  28210. if (end <= start) {
  28211. return this
  28212. }
  28213. start = start >>> 0;
  28214. end = end === undefined ? this.length : end >>> 0;
  28215. if (!val) val = 0;
  28216. var i;
  28217. if (typeof val === 'number') {
  28218. for (i = start; i < end; ++i) {
  28219. this[i] = val;
  28220. }
  28221. } else {
  28222. var bytes = internalIsBuffer(val)
  28223. ? val
  28224. : utf8ToBytes(new Buffer$1(val, encoding).toString());
  28225. var len = bytes.length;
  28226. for (i = 0; i < end - start; ++i) {
  28227. this[i + start] = bytes[i % len];
  28228. }
  28229. }
  28230. return this
  28231. };
  28232. // HELPER FUNCTIONS
  28233. // ================
  28234. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  28235. function base64clean (str) {
  28236. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  28237. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  28238. // Node converts strings with length < 2 to ''
  28239. if (str.length < 2) return ''
  28240. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  28241. while (str.length % 4 !== 0) {
  28242. str = str + '=';
  28243. }
  28244. return str
  28245. }
  28246. function stringtrim (str) {
  28247. if (str.trim) return str.trim()
  28248. return str.replace(/^\s+|\s+$/g, '')
  28249. }
  28250. function toHex (n) {
  28251. if (n < 16) return '0' + n.toString(16)
  28252. return n.toString(16)
  28253. }
  28254. function utf8ToBytes (string, units) {
  28255. units = units || Infinity;
  28256. var codePoint;
  28257. var length = string.length;
  28258. var leadSurrogate = null;
  28259. var bytes = [];
  28260. for (var i = 0; i < length; ++i) {
  28261. codePoint = string.charCodeAt(i);
  28262. // is surrogate component
  28263. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  28264. // last char was a lead
  28265. if (!leadSurrogate) {
  28266. // no lead yet
  28267. if (codePoint > 0xDBFF) {
  28268. // unexpected trail
  28269. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28270. continue
  28271. } else if (i + 1 === length) {
  28272. // unpaired lead
  28273. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28274. continue
  28275. }
  28276. // valid lead
  28277. leadSurrogate = codePoint;
  28278. continue
  28279. }
  28280. // 2 leads in a row
  28281. if (codePoint < 0xDC00) {
  28282. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28283. leadSurrogate = codePoint;
  28284. continue
  28285. }
  28286. // valid surrogate pair
  28287. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  28288. } else if (leadSurrogate) {
  28289. // valid bmp char, but last char was a lead
  28290. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  28291. }
  28292. leadSurrogate = null;
  28293. // encode utf8
  28294. if (codePoint < 0x80) {
  28295. if ((units -= 1) < 0) break
  28296. bytes.push(codePoint);
  28297. } else if (codePoint < 0x800) {
  28298. if ((units -= 2) < 0) break
  28299. bytes.push(
  28300. codePoint >> 0x6 | 0xC0,
  28301. codePoint & 0x3F | 0x80
  28302. );
  28303. } else if (codePoint < 0x10000) {
  28304. if ((units -= 3) < 0) break
  28305. bytes.push(
  28306. codePoint >> 0xC | 0xE0,
  28307. codePoint >> 0x6 & 0x3F | 0x80,
  28308. codePoint & 0x3F | 0x80
  28309. );
  28310. } else if (codePoint < 0x110000) {
  28311. if ((units -= 4) < 0) break
  28312. bytes.push(
  28313. codePoint >> 0x12 | 0xF0,
  28314. codePoint >> 0xC & 0x3F | 0x80,
  28315. codePoint >> 0x6 & 0x3F | 0x80,
  28316. codePoint & 0x3F | 0x80
  28317. );
  28318. } else {
  28319. throw new Error('Invalid code point')
  28320. }
  28321. }
  28322. return bytes
  28323. }
  28324. function asciiToBytes (str) {
  28325. var byteArray = [];
  28326. for (var i = 0; i < str.length; ++i) {
  28327. // Node's code seems to be doing this and not & 0x7F..
  28328. byteArray.push(str.charCodeAt(i) & 0xFF);
  28329. }
  28330. return byteArray
  28331. }
  28332. function utf16leToBytes (str, units) {
  28333. var c, hi, lo;
  28334. var byteArray = [];
  28335. for (var i = 0; i < str.length; ++i) {
  28336. if ((units -= 2) < 0) break
  28337. c = str.charCodeAt(i);
  28338. hi = c >> 8;
  28339. lo = c % 256;
  28340. byteArray.push(lo);
  28341. byteArray.push(hi);
  28342. }
  28343. return byteArray
  28344. }
  28345. function base64ToBytes (str) {
  28346. return toByteArray(base64clean(str))
  28347. }
  28348. function blitBuffer (src, dst, offset, length) {
  28349. for (var i = 0; i < length; ++i) {
  28350. if ((i + offset >= dst.length) || (i >= src.length)) break
  28351. dst[i + offset] = src[i];
  28352. }
  28353. return i
  28354. }
  28355. function isnan (val) {
  28356. return val !== val // eslint-disable-line no-self-compare
  28357. }
  28358. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  28359. // The _isBuffer check is for Safari 5-7 support, because it's missing
  28360. // Object.prototype.constructor. Remove this eventually
  28361. function isBuffer$1(obj) {
  28362. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  28363. }
  28364. function isFastBuffer (obj) {
  28365. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  28366. }
  28367. // For Node v0.10 support. Remove this eventually.
  28368. function isSlowBuffer (obj) {
  28369. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  28370. }
  28371. var inherits;
  28372. if (typeof Object.create === 'function'){
  28373. inherits = function inherits(ctor, superCtor) {
  28374. // implementation from standard node.js 'util' module
  28375. ctor.super_ = superCtor;
  28376. ctor.prototype = Object.create(superCtor.prototype, {
  28377. constructor: {
  28378. value: ctor,
  28379. enumerable: false,
  28380. writable: true,
  28381. configurable: true
  28382. }
  28383. });
  28384. };
  28385. } else {
  28386. inherits = function inherits(ctor, superCtor) {
  28387. ctor.super_ = superCtor;
  28388. var TempCtor = function () {};
  28389. TempCtor.prototype = superCtor.prototype;
  28390. ctor.prototype = new TempCtor();
  28391. ctor.prototype.constructor = ctor;
  28392. };
  28393. }
  28394. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  28395. function getOwnPropertyDescriptors(obj) {
  28396. var keys = Object.keys(obj);
  28397. var descriptors = {};
  28398. for (var i = 0; i < keys.length; i++) {
  28399. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  28400. }
  28401. return descriptors;
  28402. };
  28403. var formatRegExp = /%[sdj%]/g;
  28404. function format$1(f) {
  28405. if (!isString(f)) {
  28406. var objects = [];
  28407. for (var i = 0; i < arguments.length; i++) {
  28408. objects.push(inspect(arguments[i]));
  28409. }
  28410. return objects.join(' ');
  28411. }
  28412. var i = 1;
  28413. var args = arguments;
  28414. var len = args.length;
  28415. var str = String(f).replace(formatRegExp, function(x) {
  28416. if (x === '%%') return '%';
  28417. if (i >= len) return x;
  28418. switch (x) {
  28419. case '%s': return String(args[i++]);
  28420. case '%d': return Number(args[i++]);
  28421. case '%j':
  28422. try {
  28423. return JSON.stringify(args[i++]);
  28424. } catch (_) {
  28425. return '[Circular]';
  28426. }
  28427. default:
  28428. return x;
  28429. }
  28430. });
  28431. for (var x = args[i]; i < len; x = args[++i]) {
  28432. if (isNull(x) || !isObject$1(x)) {
  28433. str += ' ' + x;
  28434. } else {
  28435. str += ' ' + inspect(x);
  28436. }
  28437. }
  28438. return str;
  28439. }
  28440. // Mark that a method should not be used.
  28441. // Returns a modified function which warns once by default.
  28442. // If --no-deprecation is set, then it is a no-op.
  28443. function deprecate(fn, msg) {
  28444. // Allow for deprecating things in the process of starting up.
  28445. if (isUndefined(global$1.process)) {
  28446. return function() {
  28447. return deprecate(fn, msg).apply(this, arguments);
  28448. };
  28449. }
  28450. if (browser$1.noDeprecation === true) {
  28451. return fn;
  28452. }
  28453. var warned = false;
  28454. function deprecated() {
  28455. if (!warned) {
  28456. if (browser$1.throwDeprecation) {
  28457. throw new Error(msg);
  28458. } else if (browser$1.traceDeprecation) {
  28459. console.trace(msg);
  28460. } else {
  28461. console.error(msg);
  28462. }
  28463. warned = true;
  28464. }
  28465. return fn.apply(this, arguments);
  28466. }
  28467. return deprecated;
  28468. }
  28469. var debugs = {};
  28470. var debugEnviron;
  28471. function debuglog(set) {
  28472. if (isUndefined(debugEnviron))
  28473. debugEnviron = browser$1.env.NODE_DEBUG || '';
  28474. set = set.toUpperCase();
  28475. if (!debugs[set]) {
  28476. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  28477. var pid = 0;
  28478. debugs[set] = function() {
  28479. var msg = format$1.apply(null, arguments);
  28480. console.error('%s %d: %s', set, pid, msg);
  28481. };
  28482. } else {
  28483. debugs[set] = function() {};
  28484. }
  28485. }
  28486. return debugs[set];
  28487. }
  28488. /**
  28489. * Echos the value of a value. Trys to print the value out
  28490. * in the best way possible given the different types.
  28491. *
  28492. * @param {Object} obj The object to print out.
  28493. * @param {Object} opts Optional options object that alters the output.
  28494. */
  28495. /* legacy: obj, showHidden, depth, colors*/
  28496. function inspect(obj, opts) {
  28497. // default options
  28498. var ctx = {
  28499. seen: [],
  28500. stylize: stylizeNoColor
  28501. };
  28502. // legacy...
  28503. if (arguments.length >= 3) ctx.depth = arguments[2];
  28504. if (arguments.length >= 4) ctx.colors = arguments[3];
  28505. if (isBoolean(opts)) {
  28506. // legacy...
  28507. ctx.showHidden = opts;
  28508. } else if (opts) {
  28509. // got an "options" object
  28510. _extend(ctx, opts);
  28511. }
  28512. // set default options
  28513. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  28514. if (isUndefined(ctx.depth)) ctx.depth = 2;
  28515. if (isUndefined(ctx.colors)) ctx.colors = false;
  28516. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  28517. if (ctx.colors) ctx.stylize = stylizeWithColor;
  28518. return formatValue(ctx, obj, ctx.depth);
  28519. }
  28520. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  28521. inspect.colors = {
  28522. 'bold' : [1, 22],
  28523. 'italic' : [3, 23],
  28524. 'underline' : [4, 24],
  28525. 'inverse' : [7, 27],
  28526. 'white' : [37, 39],
  28527. 'grey' : [90, 39],
  28528. 'black' : [30, 39],
  28529. 'blue' : [34, 39],
  28530. 'cyan' : [36, 39],
  28531. 'green' : [32, 39],
  28532. 'magenta' : [35, 39],
  28533. 'red' : [31, 39],
  28534. 'yellow' : [33, 39]
  28535. };
  28536. // Don't use 'blue' not visible on cmd.exe
  28537. inspect.styles = {
  28538. 'special': 'cyan',
  28539. 'number': 'yellow',
  28540. 'boolean': 'yellow',
  28541. 'undefined': 'grey',
  28542. 'null': 'bold',
  28543. 'string': 'green',
  28544. 'date': 'magenta',
  28545. // "name": intentionally not styling
  28546. 'regexp': 'red'
  28547. };
  28548. function stylizeWithColor(str, styleType) {
  28549. var style = inspect.styles[styleType];
  28550. if (style) {
  28551. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  28552. '\u001b[' + inspect.colors[style][1] + 'm';
  28553. } else {
  28554. return str;
  28555. }
  28556. }
  28557. function stylizeNoColor(str, styleType) {
  28558. return str;
  28559. }
  28560. function arrayToHash(array) {
  28561. var hash = {};
  28562. array.forEach(function(val, idx) {
  28563. hash[val] = true;
  28564. });
  28565. return hash;
  28566. }
  28567. function formatValue(ctx, value, recurseTimes) {
  28568. // Provide a hook for user-specified inspect functions.
  28569. // Check that value is an object with an inspect function on it
  28570. if (ctx.customInspect &&
  28571. value &&
  28572. isFunction(value.inspect) &&
  28573. // Filter out the util module, it's inspect function is special
  28574. value.inspect !== inspect &&
  28575. // Also filter out any prototype objects using the circular check.
  28576. !(value.constructor && value.constructor.prototype === value)) {
  28577. var ret = value.inspect(recurseTimes, ctx);
  28578. if (!isString(ret)) {
  28579. ret = formatValue(ctx, ret, recurseTimes);
  28580. }
  28581. return ret;
  28582. }
  28583. // Primitive types cannot have properties
  28584. var primitive = formatPrimitive(ctx, value);
  28585. if (primitive) {
  28586. return primitive;
  28587. }
  28588. // Look up the keys of the object.
  28589. var keys = Object.keys(value);
  28590. var visibleKeys = arrayToHash(keys);
  28591. if (ctx.showHidden) {
  28592. keys = Object.getOwnPropertyNames(value);
  28593. }
  28594. // IE doesn't make error fields non-enumerable
  28595. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  28596. if (isError(value)
  28597. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  28598. return formatError(value);
  28599. }
  28600. // Some type of object without properties can be shortcutted.
  28601. if (keys.length === 0) {
  28602. if (isFunction(value)) {
  28603. var name = value.name ? ': ' + value.name : '';
  28604. return ctx.stylize('[Function' + name + ']', 'special');
  28605. }
  28606. if (isRegExp(value)) {
  28607. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28608. }
  28609. if (isDate(value)) {
  28610. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  28611. }
  28612. if (isError(value)) {
  28613. return formatError(value);
  28614. }
  28615. }
  28616. var base = '', array = false, braces = ['{', '}'];
  28617. // Make Array say that they are Array
  28618. if (isArray$1(value)) {
  28619. array = true;
  28620. braces = ['[', ']'];
  28621. }
  28622. // Make functions say that they are functions
  28623. if (isFunction(value)) {
  28624. var n = value.name ? ': ' + value.name : '';
  28625. base = ' [Function' + n + ']';
  28626. }
  28627. // Make RegExps say that they are RegExps
  28628. if (isRegExp(value)) {
  28629. base = ' ' + RegExp.prototype.toString.call(value);
  28630. }
  28631. // Make dates with properties first say the date
  28632. if (isDate(value)) {
  28633. base = ' ' + Date.prototype.toUTCString.call(value);
  28634. }
  28635. // Make error with message first say the error
  28636. if (isError(value)) {
  28637. base = ' ' + formatError(value);
  28638. }
  28639. if (keys.length === 0 && (!array || value.length == 0)) {
  28640. return braces[0] + base + braces[1];
  28641. }
  28642. if (recurseTimes < 0) {
  28643. if (isRegExp(value)) {
  28644. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28645. } else {
  28646. return ctx.stylize('[Object]', 'special');
  28647. }
  28648. }
  28649. ctx.seen.push(value);
  28650. var output;
  28651. if (array) {
  28652. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  28653. } else {
  28654. output = keys.map(function(key) {
  28655. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  28656. });
  28657. }
  28658. ctx.seen.pop();
  28659. return reduceToSingleString(output, base, braces);
  28660. }
  28661. function formatPrimitive(ctx, value) {
  28662. if (isUndefined(value))
  28663. return ctx.stylize('undefined', 'undefined');
  28664. if (isString(value)) {
  28665. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  28666. .replace(/'/g, "\\'")
  28667. .replace(/\\"/g, '"') + '\'';
  28668. return ctx.stylize(simple, 'string');
  28669. }
  28670. if (isNumber(value))
  28671. return ctx.stylize('' + value, 'number');
  28672. if (isBoolean(value))
  28673. return ctx.stylize('' + value, 'boolean');
  28674. // For some reason typeof null is "object", so special case here.
  28675. if (isNull(value))
  28676. return ctx.stylize('null', 'null');
  28677. }
  28678. function formatError(value) {
  28679. return '[' + Error.prototype.toString.call(value) + ']';
  28680. }
  28681. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  28682. var output = [];
  28683. for (var i = 0, l = value.length; i < l; ++i) {
  28684. if (hasOwnProperty$2(value, String(i))) {
  28685. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28686. String(i), true));
  28687. } else {
  28688. output.push('');
  28689. }
  28690. }
  28691. keys.forEach(function(key) {
  28692. if (!key.match(/^\d+$/)) {
  28693. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28694. key, true));
  28695. }
  28696. });
  28697. return output;
  28698. }
  28699. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  28700. var name, str, desc;
  28701. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  28702. if (desc.get) {
  28703. if (desc.set) {
  28704. str = ctx.stylize('[Getter/Setter]', 'special');
  28705. } else {
  28706. str = ctx.stylize('[Getter]', 'special');
  28707. }
  28708. } else {
  28709. if (desc.set) {
  28710. str = ctx.stylize('[Setter]', 'special');
  28711. }
  28712. }
  28713. if (!hasOwnProperty$2(visibleKeys, key)) {
  28714. name = '[' + key + ']';
  28715. }
  28716. if (!str) {
  28717. if (ctx.seen.indexOf(desc.value) < 0) {
  28718. if (isNull(recurseTimes)) {
  28719. str = formatValue(ctx, desc.value, null);
  28720. } else {
  28721. str = formatValue(ctx, desc.value, recurseTimes - 1);
  28722. }
  28723. if (str.indexOf('\n') > -1) {
  28724. if (array) {
  28725. str = str.split('\n').map(function(line) {
  28726. return ' ' + line;
  28727. }).join('\n').substr(2);
  28728. } else {
  28729. str = '\n' + str.split('\n').map(function(line) {
  28730. return ' ' + line;
  28731. }).join('\n');
  28732. }
  28733. }
  28734. } else {
  28735. str = ctx.stylize('[Circular]', 'special');
  28736. }
  28737. }
  28738. if (isUndefined(name)) {
  28739. if (array && key.match(/^\d+$/)) {
  28740. return str;
  28741. }
  28742. name = JSON.stringify('' + key);
  28743. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  28744. name = name.substr(1, name.length - 2);
  28745. name = ctx.stylize(name, 'name');
  28746. } else {
  28747. name = name.replace(/'/g, "\\'")
  28748. .replace(/\\"/g, '"')
  28749. .replace(/(^"|"$)/g, "'");
  28750. name = ctx.stylize(name, 'string');
  28751. }
  28752. }
  28753. return name + ': ' + str;
  28754. }
  28755. function reduceToSingleString(output, base, braces) {
  28756. var length = output.reduce(function(prev, cur) {
  28757. if (cur.indexOf('\n') >= 0) ;
  28758. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  28759. }, 0);
  28760. if (length > 60) {
  28761. return braces[0] +
  28762. (base === '' ? '' : base + '\n ') +
  28763. ' ' +
  28764. output.join(',\n ') +
  28765. ' ' +
  28766. braces[1];
  28767. }
  28768. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  28769. }
  28770. // NOTE: These type checking functions intentionally don't use `instanceof`
  28771. // because it is fragile and can be easily faked with `Object.create()`.
  28772. function isArray$1(ar) {
  28773. return Array.isArray(ar);
  28774. }
  28775. function isBoolean(arg) {
  28776. return typeof arg === 'boolean';
  28777. }
  28778. function isNull(arg) {
  28779. return arg === null;
  28780. }
  28781. function isNullOrUndefined(arg) {
  28782. return arg == null;
  28783. }
  28784. function isNumber(arg) {
  28785. return typeof arg === 'number';
  28786. }
  28787. function isString(arg) {
  28788. return typeof arg === 'string';
  28789. }
  28790. function isSymbol(arg) {
  28791. return typeof arg === 'symbol';
  28792. }
  28793. function isUndefined(arg) {
  28794. return arg === void 0;
  28795. }
  28796. function isRegExp(re) {
  28797. return isObject$1(re) && objectToString(re) === '[object RegExp]';
  28798. }
  28799. function isObject$1(arg) {
  28800. return typeof arg === 'object' && arg !== null;
  28801. }
  28802. function isDate(d) {
  28803. return isObject$1(d) && objectToString(d) === '[object Date]';
  28804. }
  28805. function isError(e) {
  28806. return isObject$1(e) &&
  28807. (objectToString(e) === '[object Error]' || e instanceof Error);
  28808. }
  28809. function isFunction(arg) {
  28810. return typeof arg === 'function';
  28811. }
  28812. function isPrimitive(arg) {
  28813. return arg === null ||
  28814. typeof arg === 'boolean' ||
  28815. typeof arg === 'number' ||
  28816. typeof arg === 'string' ||
  28817. typeof arg === 'symbol' || // ES6 symbol
  28818. typeof arg === 'undefined';
  28819. }
  28820. function isBuffer(maybeBuf) {
  28821. return Buffer$1.isBuffer(maybeBuf);
  28822. }
  28823. function objectToString(o) {
  28824. return Object.prototype.toString.call(o);
  28825. }
  28826. function pad(n) {
  28827. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  28828. }
  28829. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  28830. 'Oct', 'Nov', 'Dec'];
  28831. // 26 Feb 16:19:34
  28832. function timestamp() {
  28833. var d = new Date();
  28834. var time = [pad(d.getHours()),
  28835. pad(d.getMinutes()),
  28836. pad(d.getSeconds())].join(':');
  28837. return [d.getDate(), months[d.getMonth()], time].join(' ');
  28838. }
  28839. // log is just a thin wrapper to console.log that prepends a timestamp
  28840. function log() {
  28841. console.log('%s - %s', timestamp(), format$1.apply(null, arguments));
  28842. }
  28843. function _extend(origin, add) {
  28844. // Don't do anything if add isn't an object
  28845. if (!add || !isObject$1(add)) return origin;
  28846. var keys = Object.keys(add);
  28847. var i = keys.length;
  28848. while (i--) {
  28849. origin[keys[i]] = add[keys[i]];
  28850. }
  28851. return origin;
  28852. }
  28853. function hasOwnProperty$2(obj, prop) {
  28854. return Object.prototype.hasOwnProperty.call(obj, prop);
  28855. }
  28856. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  28857. function promisify(original) {
  28858. if (typeof original !== 'function')
  28859. throw new TypeError('The "original" argument must be of type Function');
  28860. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  28861. var fn = original[kCustomPromisifiedSymbol];
  28862. if (typeof fn !== 'function') {
  28863. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  28864. }
  28865. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28866. value: fn, enumerable: false, writable: false, configurable: true
  28867. });
  28868. return fn;
  28869. }
  28870. function fn() {
  28871. var promiseResolve, promiseReject;
  28872. var promise = new Promise(function (resolve, reject) {
  28873. promiseResolve = resolve;
  28874. promiseReject = reject;
  28875. });
  28876. var args = [];
  28877. for (var i = 0; i < arguments.length; i++) {
  28878. args.push(arguments[i]);
  28879. }
  28880. args.push(function (err, value) {
  28881. if (err) {
  28882. promiseReject(err);
  28883. } else {
  28884. promiseResolve(value);
  28885. }
  28886. });
  28887. try {
  28888. original.apply(this, args);
  28889. } catch (err) {
  28890. promiseReject(err);
  28891. }
  28892. return promise;
  28893. }
  28894. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  28895. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28896. value: fn, enumerable: false, writable: false, configurable: true
  28897. });
  28898. return Object.defineProperties(
  28899. fn,
  28900. getOwnPropertyDescriptors(original)
  28901. );
  28902. }
  28903. promisify.custom = kCustomPromisifiedSymbol;
  28904. function callbackifyOnRejected(reason, cb) {
  28905. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  28906. // Because `null` is a special error value in callbacks which means "no error
  28907. // occurred", we error-wrap so the callback consumer can distinguish between
  28908. // "the promise rejected with null" or "the promise fulfilled with undefined".
  28909. if (!reason) {
  28910. var newReason = new Error('Promise was rejected with a falsy value');
  28911. newReason.reason = reason;
  28912. reason = newReason;
  28913. }
  28914. return cb(reason);
  28915. }
  28916. function callbackify(original) {
  28917. if (typeof original !== 'function') {
  28918. throw new TypeError('The "original" argument must be of type Function');
  28919. }
  28920. // We DO NOT return the promise as it gives the user a false sense that
  28921. // the promise is actually somehow related to the callback's execution
  28922. // and that the callback throwing will reject the promise.
  28923. function callbackified() {
  28924. var args = [];
  28925. for (var i = 0; i < arguments.length; i++) {
  28926. args.push(arguments[i]);
  28927. }
  28928. var maybeCb = args.pop();
  28929. if (typeof maybeCb !== 'function') {
  28930. throw new TypeError('The last argument must be of type Function');
  28931. }
  28932. var self = this;
  28933. var cb = function() {
  28934. return maybeCb.apply(self, arguments);
  28935. };
  28936. // In true node style we process the callback on `nextTick` with all the
  28937. // implications (stack, `uncaughtException`, `async_hooks`)
  28938. original.apply(this, args)
  28939. .then(function(ret) { browser$1.nextTick(cb.bind(null, null, ret)); },
  28940. function(rej) { browser$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
  28941. }
  28942. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  28943. Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
  28944. return callbackified;
  28945. }
  28946. var _polyfillNode_util = {
  28947. inherits: inherits,
  28948. _extend: _extend,
  28949. log: log,
  28950. isBuffer: isBuffer,
  28951. isPrimitive: isPrimitive,
  28952. isFunction: isFunction,
  28953. isError: isError,
  28954. isDate: isDate,
  28955. isObject: isObject$1,
  28956. isRegExp: isRegExp,
  28957. isUndefined: isUndefined,
  28958. isSymbol: isSymbol,
  28959. isString: isString,
  28960. isNumber: isNumber,
  28961. isNullOrUndefined: isNullOrUndefined,
  28962. isNull: isNull,
  28963. isBoolean: isBoolean,
  28964. isArray: isArray$1,
  28965. inspect: inspect,
  28966. deprecate: deprecate,
  28967. format: format$1,
  28968. debuglog: debuglog,
  28969. promisify: promisify,
  28970. callbackify: callbackify,
  28971. };
  28972. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  28973. __proto__: null,
  28974. _extend: _extend,
  28975. callbackify: callbackify,
  28976. debuglog: debuglog,
  28977. default: _polyfillNode_util,
  28978. deprecate: deprecate,
  28979. format: format$1,
  28980. inherits: inherits,
  28981. inspect: inspect,
  28982. isArray: isArray$1,
  28983. isBoolean: isBoolean,
  28984. isBuffer: isBuffer,
  28985. isDate: isDate,
  28986. isError: isError,
  28987. isFunction: isFunction,
  28988. isNull: isNull,
  28989. isNullOrUndefined: isNullOrUndefined,
  28990. isNumber: isNumber,
  28991. isObject: isObject$1,
  28992. isPrimitive: isPrimitive,
  28993. isRegExp: isRegExp,
  28994. isString: isString,
  28995. isSymbol: isSymbol,
  28996. isUndefined: isUndefined,
  28997. log: log,
  28998. promisify: promisify
  28999. });
  29000. // Copyright Joyent, Inc. and other Node contributors.
  29001. //
  29002. // Permission is hereby granted, free of charge, to any person obtaining a
  29003. // copy of this software and associated documentation files (the
  29004. // "Software"), to deal in the Software without restriction, including
  29005. // without limitation the rights to use, copy, modify, merge, publish,
  29006. // distribute, sublicense, and/or sell copies of the Software, and to permit
  29007. // persons to whom the Software is furnished to do so, subject to the
  29008. // following conditions:
  29009. //
  29010. // The above copyright notice and this permission notice shall be included
  29011. // in all copies or substantial portions of the Software.
  29012. //
  29013. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  29014. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29015. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  29016. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  29017. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  29018. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  29019. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  29020. // If obj.hasOwnProperty has been overridden, then calling
  29021. // obj.hasOwnProperty(prop) will break.
  29022. // See: https://github.com/joyent/node/issues/1707
  29023. function hasOwnProperty$1(obj, prop) {
  29024. return Object.prototype.hasOwnProperty.call(obj, prop);
  29025. }
  29026. var isArray = Array.isArray || function (xs) {
  29027. return Object.prototype.toString.call(xs) === '[object Array]';
  29028. };
  29029. function stringifyPrimitive(v) {
  29030. switch (typeof v) {
  29031. case 'string':
  29032. return v;
  29033. case 'boolean':
  29034. return v ? 'true' : 'false';
  29035. case 'number':
  29036. return isFinite(v) ? v : '';
  29037. default:
  29038. return '';
  29039. }
  29040. }
  29041. function stringify (obj, sep, eq, name) {
  29042. sep = sep || '&';
  29043. eq = eq || '=';
  29044. if (obj === null) {
  29045. obj = undefined;
  29046. }
  29047. if (typeof obj === 'object') {
  29048. return map(objectKeys(obj), function(k) {
  29049. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  29050. if (isArray(obj[k])) {
  29051. return map(obj[k], function(v) {
  29052. return ks + encodeURIComponent(stringifyPrimitive(v));
  29053. }).join(sep);
  29054. } else {
  29055. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  29056. }
  29057. }).join(sep);
  29058. }
  29059. if (!name) return '';
  29060. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  29061. encodeURIComponent(stringifyPrimitive(obj));
  29062. }
  29063. function map (xs, f) {
  29064. if (xs.map) return xs.map(f);
  29065. var res = [];
  29066. for (var i = 0; i < xs.length; i++) {
  29067. res.push(f(xs[i], i));
  29068. }
  29069. return res;
  29070. }
  29071. var objectKeys = Object.keys || function (obj) {
  29072. var res = [];
  29073. for (var key in obj) {
  29074. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  29075. }
  29076. return res;
  29077. };
  29078. function parse$1(qs, sep, eq, options) {
  29079. sep = sep || '&';
  29080. eq = eq || '=';
  29081. var obj = {};
  29082. if (typeof qs !== 'string' || qs.length === 0) {
  29083. return obj;
  29084. }
  29085. var regexp = /\+/g;
  29086. qs = qs.split(sep);
  29087. var maxKeys = 1000;
  29088. if (options && typeof options.maxKeys === 'number') {
  29089. maxKeys = options.maxKeys;
  29090. }
  29091. var len = qs.length;
  29092. // maxKeys <= 0 means that we should not limit keys count
  29093. if (maxKeys > 0 && len > maxKeys) {
  29094. len = maxKeys;
  29095. }
  29096. for (var i = 0; i < len; ++i) {
  29097. var x = qs[i].replace(regexp, '%20'),
  29098. idx = x.indexOf(eq),
  29099. kstr, vstr, k, v;
  29100. if (idx >= 0) {
  29101. kstr = x.substr(0, idx);
  29102. vstr = x.substr(idx + 1);
  29103. } else {
  29104. kstr = x;
  29105. vstr = '';
  29106. }
  29107. k = decodeURIComponent(kstr);
  29108. v = decodeURIComponent(vstr);
  29109. if (!hasOwnProperty$1(obj, k)) {
  29110. obj[k] = v;
  29111. } else if (isArray(obj[k])) {
  29112. obj[k].push(v);
  29113. } else {
  29114. obj[k] = [obj[k], v];
  29115. }
  29116. }
  29117. return obj;
  29118. }
  29119. // WHATWG API
  29120. const URL$1 = global$1.URL;
  29121. const URLSearchParams = global$1.URLSearchParams;
  29122. var _polyfillNode_url = {
  29123. parse: urlParse,
  29124. resolve: urlResolve,
  29125. resolveObject: urlResolveObject,
  29126. fileURLToPath: urlFileURLToPath,
  29127. format: urlFormat,
  29128. Url: Url,
  29129. // WHATWG API
  29130. URL: URL$1,
  29131. URLSearchParams,
  29132. };
  29133. function Url() {
  29134. this.protocol = null;
  29135. this.slashes = null;
  29136. this.auth = null;
  29137. this.host = null;
  29138. this.port = null;
  29139. this.hostname = null;
  29140. this.hash = null;
  29141. this.search = null;
  29142. this.query = null;
  29143. this.pathname = null;
  29144. this.path = null;
  29145. this.href = null;
  29146. }
  29147. // Reference: RFC 3986, RFC 1808, RFC 2396
  29148. // define these here so at least they only have to be
  29149. // compiled once on the first module load.
  29150. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  29151. portPattern = /:[0-9]*$/,
  29152. // Special case for a simple path URL
  29153. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  29154. // RFC 2396: characters reserved for delimiting URLs.
  29155. // We actually just auto-escape these.
  29156. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  29157. // RFC 2396: characters not allowed for various reasons.
  29158. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  29159. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  29160. autoEscape = ['\''].concat(unwise),
  29161. // Characters that are never ever allowed in a hostname.
  29162. // Note that any invalid chars are also handled, but these
  29163. // are the ones that are *expected* to be seen, so we fast-path
  29164. // them.
  29165. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  29166. hostEndingChars = ['/', '?', '#'],
  29167. hostnameMaxLen = 255,
  29168. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  29169. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  29170. // protocols that can allow "unsafe" and "unwise" chars.
  29171. unsafeProtocol = {
  29172. 'javascript': true,
  29173. 'javascript:': true
  29174. },
  29175. // protocols that never have a hostname.
  29176. hostlessProtocol = {
  29177. 'javascript': true,
  29178. 'javascript:': true
  29179. },
  29180. // protocols that always contain a // bit.
  29181. slashedProtocol = {
  29182. 'http': true,
  29183. 'https': true,
  29184. 'ftp': true,
  29185. 'gopher': true,
  29186. 'file': true,
  29187. 'http:': true,
  29188. 'https:': true,
  29189. 'ftp:': true,
  29190. 'gopher:': true,
  29191. 'file:': true
  29192. };
  29193. function urlParse(url, parseQueryString, slashesDenoteHost) {
  29194. if (url && isObject$1(url) && url instanceof Url) return url;
  29195. var u = new Url;
  29196. u.parse(url, parseQueryString, slashesDenoteHost);
  29197. return u;
  29198. }
  29199. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  29200. return parse(this, url, parseQueryString, slashesDenoteHost);
  29201. };
  29202. function parse(self, url, parseQueryString, slashesDenoteHost) {
  29203. if (!isString(url)) {
  29204. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  29205. }
  29206. // Copy chrome, IE, opera backslash-handling behavior.
  29207. // Back slashes before the query string get converted to forward slashes
  29208. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  29209. var queryIndex = url.indexOf('?'),
  29210. splitter =
  29211. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  29212. uSplit = url.split(splitter),
  29213. slashRegex = /\\/g;
  29214. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  29215. url = uSplit.join(splitter);
  29216. var rest = url;
  29217. // trim before proceeding.
  29218. // This is to support parse stuff like " http://foo.com \n"
  29219. rest = rest.trim();
  29220. if (!slashesDenoteHost && url.split('#').length === 1) {
  29221. // Try fast path regexp
  29222. var simplePath = simplePathPattern.exec(rest);
  29223. if (simplePath) {
  29224. self.path = rest;
  29225. self.href = rest;
  29226. self.pathname = simplePath[1];
  29227. if (simplePath[2]) {
  29228. self.search = simplePath[2];
  29229. if (parseQueryString) {
  29230. self.query = parse$1(self.search.substr(1));
  29231. } else {
  29232. self.query = self.search.substr(1);
  29233. }
  29234. } else if (parseQueryString) {
  29235. self.search = '';
  29236. self.query = {};
  29237. }
  29238. return self;
  29239. }
  29240. }
  29241. var proto = protocolPattern.exec(rest);
  29242. if (proto) {
  29243. proto = proto[0];
  29244. var lowerProto = proto.toLowerCase();
  29245. self.protocol = lowerProto;
  29246. rest = rest.substr(proto.length);
  29247. }
  29248. // figure out if it's got a host
  29249. // user@server is *always* interpreted as a hostname, and url
  29250. // resolution will treat //foo/bar as host=foo,path=bar because that's
  29251. // how the browser resolves relative URLs.
  29252. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  29253. var slashes = rest.substr(0, 2) === '//';
  29254. if (slashes && !(proto && hostlessProtocol[proto])) {
  29255. rest = rest.substr(2);
  29256. self.slashes = true;
  29257. }
  29258. }
  29259. var i, hec, l, p;
  29260. if (!hostlessProtocol[proto] &&
  29261. (slashes || (proto && !slashedProtocol[proto]))) {
  29262. // there's a hostname.
  29263. // the first instance of /, ?, ;, or # ends the host.
  29264. //
  29265. // If there is an @ in the hostname, then non-host chars *are* allowed
  29266. // to the left of the last @ sign, unless some host-ending character
  29267. // comes *before* the @-sign.
  29268. // URLs are obnoxious.
  29269. //
  29270. // ex:
  29271. // http://a@b@c/ => user:a@b host:c
  29272. // http://a@b?@c => user:a host:c path:/?@c
  29273. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  29274. // Review our test case against browsers more comprehensively.
  29275. // find the first instance of any hostEndingChars
  29276. var hostEnd = -1;
  29277. for (i = 0; i < hostEndingChars.length; i++) {
  29278. hec = rest.indexOf(hostEndingChars[i]);
  29279. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  29280. hostEnd = hec;
  29281. }
  29282. // at this point, either we have an explicit point where the
  29283. // auth portion cannot go past, or the last @ char is the decider.
  29284. var auth, atSign;
  29285. if (hostEnd === -1) {
  29286. // atSign can be anywhere.
  29287. atSign = rest.lastIndexOf('@');
  29288. } else {
  29289. // atSign must be in auth portion.
  29290. // http://a@b/c@d => host:b auth:a path:/c@d
  29291. atSign = rest.lastIndexOf('@', hostEnd);
  29292. }
  29293. // Now we have a portion which is definitely the auth.
  29294. // Pull that off.
  29295. if (atSign !== -1) {
  29296. auth = rest.slice(0, atSign);
  29297. rest = rest.slice(atSign + 1);
  29298. self.auth = decodeURIComponent(auth);
  29299. }
  29300. // the host is the remaining to the left of the first non-host char
  29301. hostEnd = -1;
  29302. for (i = 0; i < nonHostChars.length; i++) {
  29303. hec = rest.indexOf(nonHostChars[i]);
  29304. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  29305. hostEnd = hec;
  29306. }
  29307. // if we still have not hit it, then the entire thing is a host.
  29308. if (hostEnd === -1)
  29309. hostEnd = rest.length;
  29310. self.host = rest.slice(0, hostEnd);
  29311. rest = rest.slice(hostEnd);
  29312. // pull out port.
  29313. parseHost(self);
  29314. // we've indicated that there is a hostname,
  29315. // so even if it's empty, it has to be present.
  29316. self.hostname = self.hostname || '';
  29317. // if hostname begins with [ and ends with ]
  29318. // assume that it's an IPv6 address.
  29319. var ipv6Hostname = self.hostname[0] === '[' &&
  29320. self.hostname[self.hostname.length - 1] === ']';
  29321. // validate a little.
  29322. if (!ipv6Hostname) {
  29323. var hostparts = self.hostname.split(/\./);
  29324. for (i = 0, l = hostparts.length; i < l; i++) {
  29325. var part = hostparts[i];
  29326. if (!part) continue;
  29327. if (!part.match(hostnamePartPattern)) {
  29328. var newpart = '';
  29329. for (var j = 0, k = part.length; j < k; j++) {
  29330. if (part.charCodeAt(j) > 127) {
  29331. // we replace non-ASCII char with a temporary placeholder
  29332. // we need this to make sure size of hostname is not
  29333. // broken by replacing non-ASCII by nothing
  29334. newpart += 'x';
  29335. } else {
  29336. newpart += part[j];
  29337. }
  29338. }
  29339. // we test again with ASCII char only
  29340. if (!newpart.match(hostnamePartPattern)) {
  29341. var validParts = hostparts.slice(0, i);
  29342. var notHost = hostparts.slice(i + 1);
  29343. var bit = part.match(hostnamePartStart);
  29344. if (bit) {
  29345. validParts.push(bit[1]);
  29346. notHost.unshift(bit[2]);
  29347. }
  29348. if (notHost.length) {
  29349. rest = '/' + notHost.join('.') + rest;
  29350. }
  29351. self.hostname = validParts.join('.');
  29352. break;
  29353. }
  29354. }
  29355. }
  29356. }
  29357. if (self.hostname.length > hostnameMaxLen) {
  29358. self.hostname = '';
  29359. } else {
  29360. // hostnames are always lower case.
  29361. self.hostname = self.hostname.toLowerCase();
  29362. }
  29363. if (!ipv6Hostname) {
  29364. // IDNA Support: Returns a punycoded representation of "domain".
  29365. // It only converts parts of the domain name that
  29366. // have non-ASCII characters, i.e. it doesn't matter if
  29367. // you call it with a domain that already is ASCII-only.
  29368. self.hostname = toASCII(self.hostname);
  29369. }
  29370. p = self.port ? ':' + self.port : '';
  29371. var h = self.hostname || '';
  29372. self.host = h + p;
  29373. self.href += self.host;
  29374. // strip [ and ] from the hostname
  29375. // the host field still retains them, though
  29376. if (ipv6Hostname) {
  29377. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  29378. if (rest[0] !== '/') {
  29379. rest = '/' + rest;
  29380. }
  29381. }
  29382. }
  29383. // now rest is set to the post-host stuff.
  29384. // chop off any delim chars.
  29385. if (!unsafeProtocol[lowerProto]) {
  29386. // First, make 100% sure that any "autoEscape" chars get
  29387. // escaped, even if encodeURIComponent doesn't think they
  29388. // need to be.
  29389. for (i = 0, l = autoEscape.length; i < l; i++) {
  29390. var ae = autoEscape[i];
  29391. if (rest.indexOf(ae) === -1)
  29392. continue;
  29393. var esc = encodeURIComponent(ae);
  29394. if (esc === ae) {
  29395. esc = escape(ae);
  29396. }
  29397. rest = rest.split(ae).join(esc);
  29398. }
  29399. }
  29400. // chop off from the tail first.
  29401. var hash = rest.indexOf('#');
  29402. if (hash !== -1) {
  29403. // got a fragment string.
  29404. self.hash = rest.substr(hash);
  29405. rest = rest.slice(0, hash);
  29406. }
  29407. var qm = rest.indexOf('?');
  29408. if (qm !== -1) {
  29409. self.search = rest.substr(qm);
  29410. self.query = rest.substr(qm + 1);
  29411. if (parseQueryString) {
  29412. self.query = parse$1(self.query);
  29413. }
  29414. rest = rest.slice(0, qm);
  29415. } else if (parseQueryString) {
  29416. // no query string, but parseQueryString still requested
  29417. self.search = '';
  29418. self.query = {};
  29419. }
  29420. if (rest) self.pathname = rest;
  29421. if (slashedProtocol[lowerProto] &&
  29422. self.hostname && !self.pathname) {
  29423. self.pathname = '/';
  29424. }
  29425. //to support http.request
  29426. if (self.pathname || self.search) {
  29427. p = self.pathname || '';
  29428. var s = self.search || '';
  29429. self.path = p + s;
  29430. }
  29431. // finally, reconstruct the href based on what has been validated.
  29432. self.href = format(self);
  29433. return self;
  29434. }
  29435. function urlFileURLToPath(path) {
  29436. if (typeof path === 'string')
  29437. path = new Url().parse(path);
  29438. else if (!(path instanceof Url))
  29439. throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type ' + (typeof path) + String(path));
  29440. if (path.protocol !== 'file:')
  29441. throw new TypeError('The URL must be of scheme file');
  29442. return getPathFromURLPosix(path);
  29443. }
  29444. function getPathFromURLPosix(url) {
  29445. const pathname = url.pathname;
  29446. for (let n = 0; n < pathname.length; n++) {
  29447. if (pathname[n] === '%') {
  29448. const third = pathname.codePointAt(n + 2) | 0x20;
  29449. if (pathname[n + 1] === '2' && third === 102) {
  29450. throw new TypeError(
  29451. 'must not include encoded / characters'
  29452. );
  29453. }
  29454. }
  29455. }
  29456. return decodeURIComponent(pathname);
  29457. }
  29458. // format a parsed object into a url string
  29459. function urlFormat(obj) {
  29460. // ensure it's an object, and not a string url.
  29461. // If it's an obj, this is a no-op.
  29462. // this way, you can call url_format() on strings
  29463. // to clean up potentially wonky urls.
  29464. if (isString(obj)) obj = parse({}, obj);
  29465. return format(obj);
  29466. }
  29467. function format(self) {
  29468. var auth = self.auth || '';
  29469. if (auth) {
  29470. auth = encodeURIComponent(auth);
  29471. auth = auth.replace(/%3A/i, ':');
  29472. auth += '@';
  29473. }
  29474. var protocol = self.protocol || '',
  29475. pathname = self.pathname || '',
  29476. hash = self.hash || '',
  29477. host = false,
  29478. query = '';
  29479. if (self.host) {
  29480. host = auth + self.host;
  29481. } else if (self.hostname) {
  29482. host = auth + (self.hostname.indexOf(':') === -1 ?
  29483. self.hostname :
  29484. '[' + this.hostname + ']');
  29485. if (self.port) {
  29486. host += ':' + self.port;
  29487. }
  29488. }
  29489. if (self.query &&
  29490. isObject$1(self.query) &&
  29491. Object.keys(self.query).length) {
  29492. query = stringify(self.query);
  29493. }
  29494. var search = self.search || (query && ('?' + query)) || '';
  29495. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  29496. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  29497. // unless they had them to begin with.
  29498. if (self.slashes ||
  29499. (!protocol || slashedProtocol[protocol]) && host !== false) {
  29500. host = '//' + (host || '');
  29501. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  29502. } else if (!host) {
  29503. host = '';
  29504. }
  29505. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  29506. if (search && search.charAt(0) !== '?') search = '?' + search;
  29507. pathname = pathname.replace(/[?#]/g, function(match) {
  29508. return encodeURIComponent(match);
  29509. });
  29510. search = search.replace('#', '%23');
  29511. return protocol + host + pathname + search + hash;
  29512. }
  29513. Url.prototype.format = function() {
  29514. return format(this);
  29515. };
  29516. function urlResolve(source, relative) {
  29517. return urlParse(source, false, true).resolve(relative);
  29518. }
  29519. Url.prototype.resolve = function(relative) {
  29520. return this.resolveObject(urlParse(relative, false, true)).format();
  29521. };
  29522. function urlResolveObject(source, relative) {
  29523. if (!source) return relative;
  29524. return urlParse(source, false, true).resolveObject(relative);
  29525. }
  29526. Url.prototype.resolveObject = function(relative) {
  29527. if (isString(relative)) {
  29528. var rel = new Url();
  29529. rel.parse(relative, false, true);
  29530. relative = rel;
  29531. }
  29532. var result = new Url();
  29533. var tkeys = Object.keys(this);
  29534. for (var tk = 0; tk < tkeys.length; tk++) {
  29535. var tkey = tkeys[tk];
  29536. result[tkey] = this[tkey];
  29537. }
  29538. // hash is always overridden, no matter what.
  29539. // even href="" will remove it.
  29540. result.hash = relative.hash;
  29541. // if the relative url is empty, then there's nothing left to do here.
  29542. if (relative.href === '') {
  29543. result.href = result.format();
  29544. return result;
  29545. }
  29546. // hrefs like //foo/bar always cut to the protocol.
  29547. if (relative.slashes && !relative.protocol) {
  29548. // take everything except the protocol from relative
  29549. var rkeys = Object.keys(relative);
  29550. for (var rk = 0; rk < rkeys.length; rk++) {
  29551. var rkey = rkeys[rk];
  29552. if (rkey !== 'protocol')
  29553. result[rkey] = relative[rkey];
  29554. }
  29555. //urlParse appends trailing / to urls like http://www.example.com
  29556. if (slashedProtocol[result.protocol] &&
  29557. result.hostname && !result.pathname) {
  29558. result.path = result.pathname = '/';
  29559. }
  29560. result.href = result.format();
  29561. return result;
  29562. }
  29563. var relPath;
  29564. if (relative.protocol && relative.protocol !== result.protocol) {
  29565. // if it's a known url protocol, then changing
  29566. // the protocol does weird things
  29567. // first, if it's not file:, then we MUST have a host,
  29568. // and if there was a path
  29569. // to begin with, then we MUST have a path.
  29570. // if it is file:, then the host is dropped,
  29571. // because that's known to be hostless.
  29572. // anything else is assumed to be absolute.
  29573. if (!slashedProtocol[relative.protocol]) {
  29574. var keys = Object.keys(relative);
  29575. for (var v = 0; v < keys.length; v++) {
  29576. var k = keys[v];
  29577. result[k] = relative[k];
  29578. }
  29579. result.href = result.format();
  29580. return result;
  29581. }
  29582. result.protocol = relative.protocol;
  29583. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  29584. relPath = (relative.pathname || '').split('/');
  29585. while (relPath.length && !(relative.host = relPath.shift()));
  29586. if (!relative.host) relative.host = '';
  29587. if (!relative.hostname) relative.hostname = '';
  29588. if (relPath[0] !== '') relPath.unshift('');
  29589. if (relPath.length < 2) relPath.unshift('');
  29590. result.pathname = relPath.join('/');
  29591. } else {
  29592. result.pathname = relative.pathname;
  29593. }
  29594. result.search = relative.search;
  29595. result.query = relative.query;
  29596. result.host = relative.host || '';
  29597. result.auth = relative.auth;
  29598. result.hostname = relative.hostname || relative.host;
  29599. result.port = relative.port;
  29600. // to support http.request
  29601. if (result.pathname || result.search) {
  29602. var p = result.pathname || '';
  29603. var s = result.search || '';
  29604. result.path = p + s;
  29605. }
  29606. result.slashes = result.slashes || relative.slashes;
  29607. result.href = result.format();
  29608. return result;
  29609. }
  29610. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  29611. isRelAbs = (
  29612. relative.host ||
  29613. relative.pathname && relative.pathname.charAt(0) === '/'
  29614. ),
  29615. mustEndAbs = (isRelAbs || isSourceAbs ||
  29616. (result.host && relative.pathname)),
  29617. removeAllDots = mustEndAbs,
  29618. srcPath = result.pathname && result.pathname.split('/') || [],
  29619. psychotic = result.protocol && !slashedProtocol[result.protocol];
  29620. relPath = relative.pathname && relative.pathname.split('/') || [];
  29621. // if the url is a non-slashed url, then relative
  29622. // links like ../.. should be able
  29623. // to crawl up to the hostname, as well. This is strange.
  29624. // result.protocol has already been set by now.
  29625. // Later on, put the first path part into the host field.
  29626. if (psychotic) {
  29627. result.hostname = '';
  29628. result.port = null;
  29629. if (result.host) {
  29630. if (srcPath[0] === '') srcPath[0] = result.host;
  29631. else srcPath.unshift(result.host);
  29632. }
  29633. result.host = '';
  29634. if (relative.protocol) {
  29635. relative.hostname = null;
  29636. relative.port = null;
  29637. if (relative.host) {
  29638. if (relPath[0] === '') relPath[0] = relative.host;
  29639. else relPath.unshift(relative.host);
  29640. }
  29641. relative.host = null;
  29642. }
  29643. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  29644. }
  29645. var authInHost;
  29646. if (isRelAbs) {
  29647. // it's absolute.
  29648. result.host = (relative.host || relative.host === '') ?
  29649. relative.host : result.host;
  29650. result.hostname = (relative.hostname || relative.hostname === '') ?
  29651. relative.hostname : result.hostname;
  29652. result.search = relative.search;
  29653. result.query = relative.query;
  29654. srcPath = relPath;
  29655. // fall through to the dot-handling below.
  29656. } else if (relPath.length) {
  29657. // it's relative
  29658. // throw away the existing file, and take the new path instead.
  29659. if (!srcPath) srcPath = [];
  29660. srcPath.pop();
  29661. srcPath = srcPath.concat(relPath);
  29662. result.search = relative.search;
  29663. result.query = relative.query;
  29664. } else if (!isNullOrUndefined(relative.search)) {
  29665. // just pull out the search.
  29666. // like href='?foo'.
  29667. // Put this after the other two cases because it simplifies the booleans
  29668. if (psychotic) {
  29669. result.hostname = result.host = srcPath.shift();
  29670. //occationaly the auth can get stuck only in host
  29671. //this especially happens in cases like
  29672. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29673. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29674. result.host.split('@') : false;
  29675. if (authInHost) {
  29676. result.auth = authInHost.shift();
  29677. result.host = result.hostname = authInHost.shift();
  29678. }
  29679. }
  29680. result.search = relative.search;
  29681. result.query = relative.query;
  29682. //to support http.request
  29683. if (!isNull(result.pathname) || !isNull(result.search)) {
  29684. result.path = (result.pathname ? result.pathname : '') +
  29685. (result.search ? result.search : '');
  29686. }
  29687. result.href = result.format();
  29688. return result;
  29689. }
  29690. if (!srcPath.length) {
  29691. // no path at all. easy.
  29692. // we've already handled the other stuff above.
  29693. result.pathname = null;
  29694. //to support http.request
  29695. if (result.search) {
  29696. result.path = '/' + result.search;
  29697. } else {
  29698. result.path = null;
  29699. }
  29700. result.href = result.format();
  29701. return result;
  29702. }
  29703. // if a url ENDs in . or .., then it must get a trailing slash.
  29704. // however, if it ends in anything else non-slashy,
  29705. // then it must NOT get a trailing slash.
  29706. var last = srcPath.slice(-1)[0];
  29707. var hasTrailingSlash = (
  29708. (result.host || relative.host || srcPath.length > 1) &&
  29709. (last === '.' || last === '..') || last === '');
  29710. // strip single dots, resolve double dots to parent dir
  29711. // if the path tries to go above the root, `up` ends up > 0
  29712. var up = 0;
  29713. for (var i = srcPath.length; i >= 0; i--) {
  29714. last = srcPath[i];
  29715. if (last === '.') {
  29716. srcPath.splice(i, 1);
  29717. } else if (last === '..') {
  29718. srcPath.splice(i, 1);
  29719. up++;
  29720. } else if (up) {
  29721. srcPath.splice(i, 1);
  29722. up--;
  29723. }
  29724. }
  29725. // if the path is allowed to go above the root, restore leading ..s
  29726. if (!mustEndAbs && !removeAllDots) {
  29727. for (; up--; up) {
  29728. srcPath.unshift('..');
  29729. }
  29730. }
  29731. if (mustEndAbs && srcPath[0] !== '' &&
  29732. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  29733. srcPath.unshift('');
  29734. }
  29735. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  29736. srcPath.push('');
  29737. }
  29738. var isAbsolute = srcPath[0] === '' ||
  29739. (srcPath[0] && srcPath[0].charAt(0) === '/');
  29740. // put the host back
  29741. if (psychotic) {
  29742. result.hostname = result.host = isAbsolute ? '' :
  29743. srcPath.length ? srcPath.shift() : '';
  29744. //occationaly the auth can get stuck only in host
  29745. //this especially happens in cases like
  29746. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29747. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29748. result.host.split('@') : false;
  29749. if (authInHost) {
  29750. result.auth = authInHost.shift();
  29751. result.host = result.hostname = authInHost.shift();
  29752. }
  29753. }
  29754. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  29755. if (mustEndAbs && !isAbsolute) {
  29756. srcPath.unshift('');
  29757. }
  29758. if (!srcPath.length) {
  29759. result.pathname = null;
  29760. result.path = null;
  29761. } else {
  29762. result.pathname = srcPath.join('/');
  29763. }
  29764. //to support request.http
  29765. if (!isNull(result.pathname) || !isNull(result.search)) {
  29766. result.path = (result.pathname ? result.pathname : '') +
  29767. (result.search ? result.search : '');
  29768. }
  29769. result.auth = relative.auth || result.auth;
  29770. result.slashes = result.slashes || relative.slashes;
  29771. result.href = result.format();
  29772. return result;
  29773. };
  29774. Url.prototype.parseHost = function() {
  29775. return parseHost(this);
  29776. };
  29777. function parseHost(self) {
  29778. var host = self.host;
  29779. var port = portPattern.exec(host);
  29780. if (port) {
  29781. port = port[0];
  29782. if (port !== ':') {
  29783. self.port = port.substr(1);
  29784. }
  29785. host = host.substr(0, host.length - port.length);
  29786. }
  29787. if (host) self.hostname = host;
  29788. }
  29789. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  29790. __proto__: null,
  29791. URL: URL$1,
  29792. URLSearchParams: URLSearchParams,
  29793. Url: Url,
  29794. default: _polyfillNode_url,
  29795. fileURLToPath: urlFileURLToPath,
  29796. format: urlFormat,
  29797. parse: urlParse,
  29798. resolve: urlResolve,
  29799. resolveObject: urlResolveObject
  29800. });
  29801. function isRelativeUrl(url) {
  29802. const firstChar = url.charAt(0);
  29803. return firstChar === "." || firstChar === "~" || firstChar === "@";
  29804. }
  29805. const externalRE = /^(https?:)?\/\//;
  29806. function isExternalUrl(url) {
  29807. return externalRE.test(url);
  29808. }
  29809. const dataUrlRE = /^\s*data:/i;
  29810. function isDataUrl(url) {
  29811. return dataUrlRE.test(url);
  29812. }
  29813. function parseUrl(url) {
  29814. const firstChar = url.charAt(0);
  29815. if (firstChar === "~") {
  29816. const secondChar = url.charAt(1);
  29817. url = url.slice(secondChar === "/" ? 2 : 1);
  29818. }
  29819. return parseUriParts(url);
  29820. }
  29821. function parseUriParts(urlString) {
  29822. return urlParse(isString$1(urlString) ? urlString : "", false, true);
  29823. }
  29824. var __defProp$9 = Object.defineProperty;
  29825. var __defProps$8 = Object.defineProperties;
  29826. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  29827. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  29828. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  29829. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  29830. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  29831. var __spreadValues$9 = (a, b) => {
  29832. for (var prop in b || (b = {}))
  29833. if (__hasOwnProp$9.call(b, prop))
  29834. __defNormalProp$9(a, prop, b[prop]);
  29835. if (__getOwnPropSymbols$9)
  29836. for (var prop of __getOwnPropSymbols$9(b)) {
  29837. if (__propIsEnum$9.call(b, prop))
  29838. __defNormalProp$9(a, prop, b[prop]);
  29839. }
  29840. return a;
  29841. };
  29842. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  29843. const defaultAssetUrlOptions = {
  29844. base: null,
  29845. includeAbsolute: false,
  29846. tags: {
  29847. video: ["src", "poster"],
  29848. source: ["src"],
  29849. img: ["src"],
  29850. image: ["xlink:href", "href"],
  29851. use: ["xlink:href", "href"]
  29852. }
  29853. };
  29854. const normalizeOptions = (options) => {
  29855. if (Object.keys(options).some((key) => isArray$3(options[key]))) {
  29856. return __spreadProps$8(__spreadValues$9({}, defaultAssetUrlOptions), {
  29857. tags: options
  29858. });
  29859. }
  29860. return __spreadValues$9(__spreadValues$9({}, defaultAssetUrlOptions), options);
  29861. };
  29862. const createAssetUrlTransformWithOptions = (options) => {
  29863. return (node, context) => transformAssetUrl(node, context, options);
  29864. };
  29865. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  29866. if (node.type === 1) {
  29867. if (!node.props.length) {
  29868. return;
  29869. }
  29870. const tags = options.tags || defaultAssetUrlOptions.tags;
  29871. const attrs = tags[node.tag];
  29872. const wildCardAttrs = tags["*"];
  29873. if (!attrs && !wildCardAttrs) {
  29874. return;
  29875. }
  29876. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  29877. node.props.forEach((attr, index) => {
  29878. if (attr.type !== 6 || !assetAttrs.includes(attr.name) || !attr.value || isExternalUrl(attr.value.content) || isDataUrl(attr.value.content) || attr.value.content[0] === "#" || !options.includeAbsolute && !isRelativeUrl(attr.value.content)) {
  29879. return;
  29880. }
  29881. const url = parseUrl(attr.value.content);
  29882. if (options.base && attr.value.content[0] === ".") {
  29883. const base = parseUrl(options.base);
  29884. const protocol = base.protocol || "";
  29885. const host = base.host ? protocol + "//" + base.host : "";
  29886. const basePath = base.path || "/";
  29887. attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
  29888. return;
  29889. }
  29890. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  29891. node.props[index] = {
  29892. type: 7,
  29893. name: "bind",
  29894. arg: createSimpleExpression(attr.name, true, attr.loc),
  29895. exp,
  29896. modifiers: [],
  29897. loc: attr.loc
  29898. };
  29899. });
  29900. }
  29901. };
  29902. function getImportsExpressionExp(path2, hash, loc, context) {
  29903. if (path2) {
  29904. let name;
  29905. let exp;
  29906. const existingIndex = context.imports.findIndex((i) => i.path === path2);
  29907. if (existingIndex > -1) {
  29908. name = `_imports_${existingIndex}`;
  29909. exp = context.imports[existingIndex].exp;
  29910. } else {
  29911. name = `_imports_${context.imports.length}`;
  29912. exp = createSimpleExpression(
  29913. name,
  29914. false,
  29915. loc,
  29916. 3
  29917. );
  29918. context.imports.push({
  29919. exp,
  29920. path: decodeURIComponent(path2)
  29921. });
  29922. }
  29923. if (!hash) {
  29924. return exp;
  29925. }
  29926. const hashExp = `${name} + '${hash}'`;
  29927. const finalExp = createSimpleExpression(
  29928. hashExp,
  29929. false,
  29930. loc,
  29931. 3
  29932. );
  29933. if (!context.hoistStatic) {
  29934. return finalExp;
  29935. }
  29936. const existingHoistIndex = context.hoists.findIndex((h) => {
  29937. return h && h.type === 4 && !h.isStatic && h.content === hashExp;
  29938. });
  29939. if (existingHoistIndex > -1) {
  29940. return createSimpleExpression(
  29941. `_hoisted_${existingHoistIndex + 1}`,
  29942. false,
  29943. loc,
  29944. 3
  29945. );
  29946. }
  29947. return context.hoist(finalExp);
  29948. } else {
  29949. return createSimpleExpression(`''`, false, loc, 3);
  29950. }
  29951. }
  29952. const srcsetTags = ["img", "source"];
  29953. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  29954. const createSrcsetTransformWithOptions = (options) => {
  29955. return (node, context) => transformSrcset(node, context, options);
  29956. };
  29957. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  29958. if (node.type === 1) {
  29959. if (srcsetTags.includes(node.tag) && node.props.length) {
  29960. node.props.forEach((attr, index) => {
  29961. if (attr.name === "srcset" && attr.type === 6) {
  29962. if (!attr.value) return;
  29963. const value = attr.value.content;
  29964. if (!value) return;
  29965. const imageCandidates = value.split(",").map((s) => {
  29966. const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
  29967. return { url, descriptor };
  29968. });
  29969. for (let i = 0; i < imageCandidates.length; i++) {
  29970. const { url } = imageCandidates[i];
  29971. if (isDataUrl(url)) {
  29972. imageCandidates[i + 1].url = url + "," + imageCandidates[i + 1].url;
  29973. imageCandidates.splice(i, 1);
  29974. }
  29975. }
  29976. const shouldProcessUrl = (url) => {
  29977. return !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
  29978. };
  29979. if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
  29980. return;
  29981. }
  29982. if (options.base) {
  29983. const base = options.base;
  29984. const set = [];
  29985. let needImportTransform = false;
  29986. imageCandidates.forEach((candidate) => {
  29987. let { url, descriptor } = candidate;
  29988. descriptor = descriptor ? ` ${descriptor}` : ``;
  29989. if (url[0] === ".") {
  29990. candidate.url = (path.posix || path).join(base, url);
  29991. set.push(candidate.url + descriptor);
  29992. } else if (shouldProcessUrl(url)) {
  29993. needImportTransform = true;
  29994. } else {
  29995. set.push(url + descriptor);
  29996. }
  29997. });
  29998. if (!needImportTransform) {
  29999. attr.value.content = set.join(", ");
  30000. return;
  30001. }
  30002. }
  30003. const compoundExpression = createCompoundExpression([], attr.loc);
  30004. imageCandidates.forEach(({ url, descriptor }, index2) => {
  30005. if (shouldProcessUrl(url)) {
  30006. const { path: path2 } = parseUrl(url);
  30007. let exp2;
  30008. if (path2) {
  30009. const existingImportsIndex = context.imports.findIndex(
  30010. (i) => i.path === path2
  30011. );
  30012. if (existingImportsIndex > -1) {
  30013. exp2 = createSimpleExpression(
  30014. `_imports_${existingImportsIndex}`,
  30015. false,
  30016. attr.loc,
  30017. 3
  30018. );
  30019. } else {
  30020. exp2 = createSimpleExpression(
  30021. `_imports_${context.imports.length}`,
  30022. false,
  30023. attr.loc,
  30024. 3
  30025. );
  30026. context.imports.push({ exp: exp2, path: path2 });
  30027. }
  30028. compoundExpression.children.push(exp2);
  30029. }
  30030. } else {
  30031. const exp2 = createSimpleExpression(
  30032. `"${url}"`,
  30033. false,
  30034. attr.loc,
  30035. 3
  30036. );
  30037. compoundExpression.children.push(exp2);
  30038. }
  30039. const isNotLast = imageCandidates.length - 1 > index2;
  30040. if (descriptor && isNotLast) {
  30041. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  30042. } else if (descriptor) {
  30043. compoundExpression.children.push(` + ' ${descriptor}'`);
  30044. } else if (isNotLast) {
  30045. compoundExpression.children.push(` + ', ' + `);
  30046. }
  30047. });
  30048. let exp = compoundExpression;
  30049. if (context.hoistStatic) {
  30050. exp = context.hoist(compoundExpression);
  30051. exp.constType = 3;
  30052. }
  30053. node.props[index] = {
  30054. type: 7,
  30055. name: "bind",
  30056. arg: createSimpleExpression("srcset", true, attr.loc),
  30057. exp,
  30058. modifiers: [],
  30059. loc: attr.loc
  30060. };
  30061. }
  30062. });
  30063. }
  30064. }
  30065. };
  30066. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  30067. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  30068. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  30069. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  30070. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  30071. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  30072. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  30073. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  30074. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  30075. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  30076. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  30077. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(
  30078. `ssrIncludeBooleanAttr`
  30079. );
  30080. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  30081. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  30082. const SSR_RENDER_DYNAMIC_MODEL = Symbol(
  30083. `ssrRenderDynamicModel`
  30084. );
  30085. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(
  30086. `ssrGetDynamicModelProps`
  30087. );
  30088. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  30089. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  30090. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  30091. const ssrHelpers = {
  30092. [SSR_INTERPOLATE]: `ssrInterpolate`,
  30093. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  30094. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  30095. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  30096. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  30097. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  30098. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  30099. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  30100. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  30101. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  30102. [SSR_RENDER_LIST]: `ssrRenderList`,
  30103. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  30104. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  30105. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  30106. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  30107. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  30108. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  30109. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  30110. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  30111. };
  30112. registerRuntimeHelpers(ssrHelpers);
  30113. const ssrTransformIf = createStructuralDirectiveTransform(
  30114. /^(if|else|else-if)$/,
  30115. processIf
  30116. );
  30117. function ssrProcessIf(node, context, disableNestedFragments = false, disableComment = false) {
  30118. const [rootBranch] = node.branches;
  30119. const ifStatement = createIfStatement(
  30120. rootBranch.condition,
  30121. processIfBranch(rootBranch, context, disableNestedFragments)
  30122. );
  30123. context.pushStatement(ifStatement);
  30124. let currentIf = ifStatement;
  30125. for (let i = 1; i < node.branches.length; i++) {
  30126. const branch = node.branches[i];
  30127. const branchBlockStatement = processIfBranch(
  30128. branch,
  30129. context,
  30130. disableNestedFragments
  30131. );
  30132. if (branch.condition) {
  30133. currentIf = currentIf.alternate = createIfStatement(
  30134. branch.condition,
  30135. branchBlockStatement
  30136. );
  30137. } else {
  30138. currentIf.alternate = branchBlockStatement;
  30139. }
  30140. }
  30141. if (!currentIf.alternate && !disableComment) {
  30142. currentIf.alternate = createBlockStatement([
  30143. createCallExpression(`_push`, ["`<!---->`"])
  30144. ]);
  30145. }
  30146. }
  30147. function processIfBranch(branch, context, disableNestedFragments = false) {
  30148. const { children } = branch;
  30149. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  30150. !(children.length === 1 && children[0].type === 11);
  30151. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  30152. }
  30153. const ssrTransformFor = createStructuralDirectiveTransform("for", processFor);
  30154. function ssrProcessFor(node, context, disableNestedFragments = false) {
  30155. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  30156. const renderLoop = createFunctionExpression(
  30157. createForLoopParams(node.parseResult)
  30158. );
  30159. renderLoop.body = processChildrenAsStatement(
  30160. node,
  30161. context,
  30162. needFragmentWrapper
  30163. );
  30164. if (!disableNestedFragments) {
  30165. context.pushStringPart(`<!--[-->`);
  30166. }
  30167. context.pushStatement(
  30168. createCallExpression(context.helper(SSR_RENDER_LIST), [
  30169. node.source,
  30170. renderLoop
  30171. ])
  30172. );
  30173. if (!disableNestedFragments) {
  30174. context.pushStringPart(`<!--]-->`);
  30175. }
  30176. }
  30177. const ssrTransformSlotOutlet = (node, context) => {
  30178. if (isSlotOutlet(node)) {
  30179. const { slotName, slotProps } = processSlotOutlet(node, context);
  30180. const args = [
  30181. `_ctx.$slots`,
  30182. slotName,
  30183. slotProps || `{}`,
  30184. // fallback content placeholder. will be replaced in the process phase
  30185. `null`,
  30186. `_push`,
  30187. `_parent`
  30188. ];
  30189. if (context.scopeId && context.slotted !== false) {
  30190. args.push(`"${context.scopeId}-s"`);
  30191. }
  30192. let method = SSR_RENDER_SLOT;
  30193. let parent = context.parent;
  30194. if (parent) {
  30195. const children = parent.children;
  30196. if (parent.type === 10) {
  30197. parent = context.grandParent;
  30198. }
  30199. let componentType;
  30200. if (parent.type === 1 && parent.tagType === 1 && ((componentType = resolveComponentType(parent, context, true)) === TRANSITION || componentType === TRANSITION_GROUP) && children.filter((c) => c.type === 1).length === 1) {
  30201. method = SSR_RENDER_SLOT_INNER;
  30202. if (!(context.scopeId && context.slotted !== false)) {
  30203. args.push("null");
  30204. }
  30205. args.push("true");
  30206. }
  30207. }
  30208. node.ssrCodegenNode = createCallExpression(context.helper(method), args);
  30209. }
  30210. };
  30211. function ssrProcessSlotOutlet(node, context) {
  30212. const renderCall = node.ssrCodegenNode;
  30213. if (node.children.length) {
  30214. const fallbackRenderFn = createFunctionExpression([]);
  30215. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  30216. renderCall.arguments[3] = fallbackRenderFn;
  30217. }
  30218. if (context.withSlotScopeId) {
  30219. const slotScopeId = renderCall.arguments[6];
  30220. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  30221. }
  30222. context.pushStatement(node.ssrCodegenNode);
  30223. }
  30224. function createSSRCompilerError(code, loc) {
  30225. return createCompilerError(code, loc, SSRErrorMessages);
  30226. }
  30227. const SSRErrorMessages = {
  30228. [65]: `Unsafe attribute name for SSR.`,
  30229. [66]: `Missing the 'to' prop on teleport element.`,
  30230. [67]: `Invalid AST node during SSR transform.`
  30231. };
  30232. function ssrProcessTeleport(node, context) {
  30233. const targetProp = findProp(node, "to");
  30234. if (!targetProp) {
  30235. context.onError(
  30236. createSSRCompilerError(66, node.loc)
  30237. );
  30238. return;
  30239. }
  30240. let target;
  30241. if (targetProp.type === 6) {
  30242. target = targetProp.value && createSimpleExpression(targetProp.value.content, true);
  30243. } else {
  30244. target = targetProp.exp;
  30245. }
  30246. if (!target) {
  30247. context.onError(
  30248. createSSRCompilerError(
  30249. 66,
  30250. targetProp.loc
  30251. )
  30252. );
  30253. return;
  30254. }
  30255. const disabledProp = findProp(
  30256. node,
  30257. "disabled",
  30258. false,
  30259. true
  30260. /* allow empty */
  30261. );
  30262. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  30263. const contentRenderFn = createFunctionExpression(
  30264. [`_push`],
  30265. void 0,
  30266. // Body is added later
  30267. true,
  30268. // newline
  30269. false,
  30270. // isSlot
  30271. node.loc
  30272. );
  30273. contentRenderFn.body = processChildrenAsStatement(node, context);
  30274. context.pushStatement(
  30275. createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  30276. `_push`,
  30277. contentRenderFn,
  30278. target,
  30279. disabled,
  30280. `_parent`
  30281. ])
  30282. );
  30283. }
  30284. const wipMap$3 = /* @__PURE__ */ new WeakMap();
  30285. function ssrTransformSuspense(node, context) {
  30286. return () => {
  30287. if (node.children.length) {
  30288. const wipEntry = {
  30289. slotsExp: null,
  30290. // to be immediately set
  30291. wipSlots: []
  30292. };
  30293. wipMap$3.set(node, wipEntry);
  30294. wipEntry.slotsExp = buildSlots(
  30295. node,
  30296. context,
  30297. (_props, _vForExp, children, loc) => {
  30298. const fn = createFunctionExpression(
  30299. [],
  30300. void 0,
  30301. // no return, assign body later
  30302. true,
  30303. // newline
  30304. false,
  30305. // suspense slots are not treated as normal slots
  30306. loc
  30307. );
  30308. wipEntry.wipSlots.push({
  30309. fn,
  30310. children
  30311. });
  30312. return fn;
  30313. }
  30314. ).slots;
  30315. }
  30316. };
  30317. }
  30318. function ssrProcessSuspense(node, context) {
  30319. const wipEntry = wipMap$3.get(node);
  30320. if (!wipEntry) {
  30321. return;
  30322. }
  30323. const { slotsExp, wipSlots } = wipEntry;
  30324. for (let i = 0; i < wipSlots.length; i++) {
  30325. const slot = wipSlots[i];
  30326. slot.fn.body = processChildrenAsStatement(slot, context);
  30327. }
  30328. context.pushStatement(
  30329. createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  30330. `_push`,
  30331. slotsExp
  30332. ])
  30333. );
  30334. }
  30335. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  30336. const ssrTransformElement = (node, context) => {
  30337. if (node.type !== 1 || node.tagType !== 0) {
  30338. return;
  30339. }
  30340. return function ssrPostTransformElement() {
  30341. const openTag = [`<${node.tag}`];
  30342. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  30343. const hasDynamicVBind = hasDynamicKeyVBind(node);
  30344. const hasCustomDir = node.props.some(
  30345. (p) => p.type === 7 && !isBuiltInDirective(p.name)
  30346. );
  30347. const needMergeProps = hasDynamicVBind || hasCustomDir;
  30348. if (needMergeProps) {
  30349. const { props, directives } = buildProps(
  30350. node,
  30351. context,
  30352. node.props,
  30353. false,
  30354. false,
  30355. true
  30356. );
  30357. if (props || directives.length) {
  30358. const mergedProps = buildSSRProps(props, directives, context);
  30359. const propsExp = createCallExpression(
  30360. context.helper(SSR_RENDER_ATTRS),
  30361. [mergedProps]
  30362. );
  30363. if (node.tag === "textarea") {
  30364. const existingText = node.children[0];
  30365. if (!existingText || existingText.type !== 5) {
  30366. const tempId = `_temp${context.temps++}`;
  30367. propsExp.arguments = [
  30368. createAssignmentExpression(
  30369. createSimpleExpression(tempId, false),
  30370. mergedProps
  30371. )
  30372. ];
  30373. rawChildrenMap.set(
  30374. node,
  30375. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30376. createConditionalExpression(
  30377. createSimpleExpression(`"value" in ${tempId}`, false),
  30378. createSimpleExpression(`${tempId}.value`, false),
  30379. createSimpleExpression(
  30380. existingText ? existingText.content : ``,
  30381. true
  30382. ),
  30383. false
  30384. )
  30385. ])
  30386. );
  30387. }
  30388. } else if (node.tag === "input") {
  30389. const vModel = findVModel(node);
  30390. if (vModel) {
  30391. const tempId = `_temp${context.temps++}`;
  30392. const tempExp = createSimpleExpression(tempId, false);
  30393. propsExp.arguments = [
  30394. createSequenceExpression([
  30395. createAssignmentExpression(tempExp, mergedProps),
  30396. createCallExpression(context.helper(MERGE_PROPS), [
  30397. tempExp,
  30398. createCallExpression(
  30399. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  30400. [
  30401. tempExp,
  30402. // existing props
  30403. vModel.exp
  30404. // model
  30405. ]
  30406. )
  30407. ])
  30408. ])
  30409. ];
  30410. }
  30411. } else if (directives.length && !node.children.length) {
  30412. const tempId = `_temp${context.temps++}`;
  30413. propsExp.arguments = [
  30414. createAssignmentExpression(
  30415. createSimpleExpression(tempId, false),
  30416. mergedProps
  30417. )
  30418. ];
  30419. rawChildrenMap.set(
  30420. node,
  30421. createConditionalExpression(
  30422. createSimpleExpression(`"textContent" in ${tempId}`, false),
  30423. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30424. createSimpleExpression(`${tempId}.textContent`, false)
  30425. ]),
  30426. createSimpleExpression(`${tempId}.innerHTML ?? ''`, false),
  30427. false
  30428. )
  30429. );
  30430. }
  30431. if (needTagForRuntime) {
  30432. propsExp.arguments.push(`"${node.tag}"`);
  30433. }
  30434. openTag.push(propsExp);
  30435. }
  30436. }
  30437. let dynamicClassBinding = void 0;
  30438. let staticClassBinding = void 0;
  30439. let dynamicStyleBinding = void 0;
  30440. for (let i = 0; i < node.props.length; i++) {
  30441. const prop = node.props[i];
  30442. if (node.tag === "input" && isTrueFalseValue(prop)) {
  30443. continue;
  30444. }
  30445. if (prop.type === 7) {
  30446. if (prop.name === "html" && prop.exp) {
  30447. rawChildrenMap.set(
  30448. node,
  30449. createCompoundExpression([`(`, prop.exp, `) ?? ''`])
  30450. );
  30451. } else if (prop.name === "text" && prop.exp) {
  30452. node.children = [createInterpolation(prop.exp, prop.loc)];
  30453. } else if (prop.name === "slot") {
  30454. context.onError(
  30455. createCompilerError(40, prop.loc)
  30456. );
  30457. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  30458. if (!needMergeProps) {
  30459. node.children = [createInterpolation(prop.exp, prop.loc)];
  30460. }
  30461. } else if (!needMergeProps && prop.name !== "on") {
  30462. const directiveTransform = context.directiveTransforms[prop.name];
  30463. if (directiveTransform) {
  30464. const { props, ssrTagParts } = directiveTransform(
  30465. prop,
  30466. node,
  30467. context
  30468. );
  30469. if (ssrTagParts) {
  30470. openTag.push(...ssrTagParts);
  30471. }
  30472. for (let j = 0; j < props.length; j++) {
  30473. const { key, value } = props[j];
  30474. if (isStaticExp(key)) {
  30475. let attrName = key.content;
  30476. if (attrName === "key" || attrName === "ref") {
  30477. continue;
  30478. }
  30479. if (attrName === "class") {
  30480. openTag.push(
  30481. ` class="`,
  30482. dynamicClassBinding = createCallExpression(
  30483. context.helper(SSR_RENDER_CLASS),
  30484. [value]
  30485. ),
  30486. `"`
  30487. );
  30488. } else if (attrName === "style") {
  30489. if (dynamicStyleBinding) {
  30490. mergeCall(dynamicStyleBinding, value);
  30491. } else {
  30492. openTag.push(
  30493. ` style="`,
  30494. dynamicStyleBinding = createCallExpression(
  30495. context.helper(SSR_RENDER_STYLE),
  30496. [value]
  30497. ),
  30498. `"`
  30499. );
  30500. }
  30501. } else {
  30502. attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
  30503. if (isBooleanAttr(attrName)) {
  30504. openTag.push(
  30505. createConditionalExpression(
  30506. createCallExpression(
  30507. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  30508. [value]
  30509. ),
  30510. createSimpleExpression(" " + attrName, true),
  30511. createSimpleExpression("", true),
  30512. false
  30513. )
  30514. );
  30515. } else if (isSSRSafeAttrName(attrName)) {
  30516. openTag.push(
  30517. createCallExpression(context.helper(SSR_RENDER_ATTR), [
  30518. key,
  30519. value
  30520. ])
  30521. );
  30522. } else {
  30523. context.onError(
  30524. createSSRCompilerError(
  30525. 65,
  30526. key.loc
  30527. )
  30528. );
  30529. }
  30530. }
  30531. } else {
  30532. const args = [key, value];
  30533. if (needTagForRuntime) {
  30534. args.push(`"${node.tag}"`);
  30535. }
  30536. openTag.push(
  30537. createCallExpression(
  30538. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  30539. args
  30540. )
  30541. );
  30542. }
  30543. }
  30544. }
  30545. }
  30546. } else {
  30547. const name = prop.name;
  30548. if (node.tag === "textarea" && name === "value" && prop.value) {
  30549. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  30550. } else if (!needMergeProps) {
  30551. if (name === "key" || name === "ref") {
  30552. continue;
  30553. }
  30554. if (name === "class" && prop.value) {
  30555. staticClassBinding = JSON.stringify(prop.value.content);
  30556. }
  30557. openTag.push(
  30558. ` ${prop.name}` + (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
  30559. );
  30560. }
  30561. }
  30562. }
  30563. if (dynamicClassBinding && staticClassBinding) {
  30564. mergeCall(dynamicClassBinding, staticClassBinding);
  30565. removeStaticBinding(openTag, "class");
  30566. }
  30567. if (context.scopeId) {
  30568. openTag.push(` ${context.scopeId}`);
  30569. }
  30570. node.ssrCodegenNode = createTemplateLiteral(openTag);
  30571. };
  30572. };
  30573. function buildSSRProps(props, directives, context) {
  30574. let mergePropsArgs = [];
  30575. if (props) {
  30576. if (props.type === 14) {
  30577. mergePropsArgs = props.arguments;
  30578. } else {
  30579. mergePropsArgs.push(props);
  30580. }
  30581. }
  30582. if (directives.length) {
  30583. for (const dir of directives) {
  30584. mergePropsArgs.push(
  30585. createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  30586. `_ctx`,
  30587. ...buildDirectiveArgs(dir, context).elements
  30588. ])
  30589. );
  30590. }
  30591. }
  30592. return mergePropsArgs.length > 1 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  30593. }
  30594. function isTrueFalseValue(prop) {
  30595. if (prop.type === 7) {
  30596. return prop.name === "bind" && prop.arg && isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  30597. } else {
  30598. return prop.name === "true-value" || prop.name === "false-value";
  30599. }
  30600. }
  30601. function isTextareaWithValue(node, prop) {
  30602. return !!(node.tag === "textarea" && prop.name === "bind" && isStaticArgOf(prop.arg, "value"));
  30603. }
  30604. function mergeCall(call, arg) {
  30605. const existing = call.arguments[0];
  30606. if (existing.type === 17) {
  30607. existing.elements.push(arg);
  30608. } else {
  30609. call.arguments[0] = createArrayExpression([existing, arg]);
  30610. }
  30611. }
  30612. function removeStaticBinding(tag, binding) {
  30613. const regExp = new RegExp(`^ ${binding}=".+"$`);
  30614. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  30615. if (i > -1) {
  30616. tag.splice(i, 1);
  30617. }
  30618. }
  30619. function findVModel(node) {
  30620. return node.props.find(
  30621. (p) => p.type === 7 && p.name === "model" && p.exp
  30622. );
  30623. }
  30624. function ssrProcessElement(node, context) {
  30625. const isVoidTag = context.options.isVoidTag || NO;
  30626. const elementsToAdd = node.ssrCodegenNode.elements;
  30627. for (let j = 0; j < elementsToAdd.length; j++) {
  30628. context.pushStringPart(elementsToAdd[j]);
  30629. }
  30630. if (context.withSlotScopeId) {
  30631. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  30632. }
  30633. context.pushStringPart(`>`);
  30634. const rawChildren = rawChildrenMap.get(node);
  30635. if (rawChildren) {
  30636. context.pushStringPart(rawChildren);
  30637. } else if (node.children.length) {
  30638. processChildren(node, context);
  30639. }
  30640. if (!isVoidTag(node.tag)) {
  30641. context.pushStringPart(`</${node.tag}>`);
  30642. }
  30643. }
  30644. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  30645. function ssrTransformTransitionGroup(node, context) {
  30646. return () => {
  30647. const tag = findProp(node, "tag");
  30648. if (tag) {
  30649. const otherProps = node.props.filter((p) => p !== tag);
  30650. const { props, directives } = buildProps(
  30651. node,
  30652. context,
  30653. otherProps,
  30654. true,
  30655. false,
  30656. true
  30657. );
  30658. let propsExp = null;
  30659. if (props || directives.length) {
  30660. propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  30661. buildSSRProps(props, directives, context)
  30662. ]);
  30663. }
  30664. wipMap$2.set(node, {
  30665. tag,
  30666. propsExp,
  30667. scopeId: context.scopeId || null
  30668. });
  30669. }
  30670. };
  30671. }
  30672. function ssrProcessTransitionGroup(node, context) {
  30673. const entry = wipMap$2.get(node);
  30674. if (entry) {
  30675. const { tag, propsExp, scopeId } = entry;
  30676. if (tag.type === 7) {
  30677. context.pushStringPart(`<`);
  30678. context.pushStringPart(tag.exp);
  30679. if (propsExp) {
  30680. context.pushStringPart(propsExp);
  30681. }
  30682. if (scopeId) {
  30683. context.pushStringPart(` ${scopeId}`);
  30684. }
  30685. context.pushStringPart(`>`);
  30686. processChildren(
  30687. node,
  30688. context,
  30689. false,
  30690. /**
  30691. * TransitionGroup has the special runtime behavior of flattening and
  30692. * concatenating all children into a single fragment (in order for them to
  30693. * be patched using the same key map) so we need to account for that here
  30694. * by disabling nested fragment wrappers from being generated.
  30695. */
  30696. true,
  30697. /**
  30698. * TransitionGroup filters out comment children at runtime and thus
  30699. * doesn't expect comments to be present during hydration. We need to
  30700. * account for that by disabling the empty comment that is otherwise
  30701. * rendered for a falsy v-if that has no v-else specified. (#6715)
  30702. */
  30703. true
  30704. );
  30705. context.pushStringPart(`</`);
  30706. context.pushStringPart(tag.exp);
  30707. context.pushStringPart(`>`);
  30708. } else {
  30709. context.pushStringPart(`<${tag.value.content}`);
  30710. if (propsExp) {
  30711. context.pushStringPart(propsExp);
  30712. }
  30713. if (scopeId) {
  30714. context.pushStringPart(` ${scopeId}`);
  30715. }
  30716. context.pushStringPart(`>`);
  30717. processChildren(node, context, false, true, true);
  30718. context.pushStringPart(`</${tag.value.content}>`);
  30719. }
  30720. } else {
  30721. processChildren(node, context, true, true, true);
  30722. }
  30723. }
  30724. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  30725. function ssrTransformTransition(node, context) {
  30726. return () => {
  30727. const appear = findProp(node, "appear", false, true);
  30728. wipMap$1.set(node, !!appear);
  30729. };
  30730. }
  30731. function ssrProcessTransition(node, context) {
  30732. node.children = node.children.filter((c) => c.type !== 3);
  30733. const appear = wipMap$1.get(node);
  30734. if (appear) {
  30735. context.pushStringPart(`<template>`);
  30736. processChildren(node, context, false, true);
  30737. context.pushStringPart(`</template>`);
  30738. } else {
  30739. processChildren(node, context, false, true);
  30740. }
  30741. }
  30742. var __defProp$8 = Object.defineProperty;
  30743. var __defProps$7 = Object.defineProperties;
  30744. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  30745. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  30746. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  30747. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  30748. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30749. var __spreadValues$8 = (a, b) => {
  30750. for (var prop in b || (b = {}))
  30751. if (__hasOwnProp$8.call(b, prop))
  30752. __defNormalProp$8(a, prop, b[prop]);
  30753. if (__getOwnPropSymbols$8)
  30754. for (var prop of __getOwnPropSymbols$8(b)) {
  30755. if (__propIsEnum$8.call(b, prop))
  30756. __defNormalProp$8(a, prop, b[prop]);
  30757. }
  30758. return a;
  30759. };
  30760. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  30761. const wipMap = /* @__PURE__ */ new WeakMap();
  30762. const WIP_SLOT = Symbol();
  30763. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  30764. const ssrTransformComponent = (node, context) => {
  30765. if (node.type !== 1 || node.tagType !== 1) {
  30766. return;
  30767. }
  30768. const component = resolveComponentType(
  30769. node,
  30770. context,
  30771. true
  30772. /* ssr */
  30773. );
  30774. const isDynamicComponent = isObject$2(component) && component.callee === RESOLVE_DYNAMIC_COMPONENT;
  30775. componentTypeMap.set(node, component);
  30776. if (isSymbol$1(component)) {
  30777. if (component === SUSPENSE) {
  30778. return ssrTransformSuspense(node, context);
  30779. } else if (component === TRANSITION_GROUP) {
  30780. return ssrTransformTransitionGroup(node, context);
  30781. } else if (component === TRANSITION) {
  30782. return ssrTransformTransition(node);
  30783. }
  30784. return;
  30785. }
  30786. const vnodeBranches = [];
  30787. const clonedNode = clone(node);
  30788. return function ssrPostTransformComponent() {
  30789. if (clonedNode.children.length) {
  30790. buildSlots(clonedNode, context, (props, vFor, children) => {
  30791. vnodeBranches.push(
  30792. createVNodeSlotBranch(props, vFor, children, context)
  30793. );
  30794. return createFunctionExpression(void 0);
  30795. });
  30796. }
  30797. let propsExp = `null`;
  30798. if (node.props.length) {
  30799. const { props, directives } = buildProps(
  30800. node,
  30801. context,
  30802. void 0,
  30803. true,
  30804. isDynamicComponent
  30805. );
  30806. if (props || directives.length) {
  30807. propsExp = buildSSRProps(props, directives, context);
  30808. }
  30809. }
  30810. const wipEntries = [];
  30811. wipMap.set(node, wipEntries);
  30812. const buildSSRSlotFn = (props, _vForExp, children, loc) => {
  30813. const param0 = props && stringifyExpression(props) || `_`;
  30814. const fn = createFunctionExpression(
  30815. [param0, `_push`, `_parent`, `_scopeId`],
  30816. void 0,
  30817. // no return, assign body later
  30818. true,
  30819. // newline
  30820. true,
  30821. // isSlot
  30822. loc
  30823. );
  30824. wipEntries.push({
  30825. type: WIP_SLOT,
  30826. fn,
  30827. children,
  30828. // also collect the corresponding vnode branch built earlier
  30829. vnodeBranch: vnodeBranches[wipEntries.length]
  30830. });
  30831. return fn;
  30832. };
  30833. const slots = node.children.length ? buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  30834. if (typeof component !== "string") {
  30835. node.ssrCodegenNode = createCallExpression(
  30836. context.helper(SSR_RENDER_VNODE),
  30837. [
  30838. `_push`,
  30839. createCallExpression(context.helper(CREATE_VNODE), [
  30840. component,
  30841. propsExp,
  30842. slots
  30843. ]),
  30844. `_parent`
  30845. ]
  30846. );
  30847. } else {
  30848. node.ssrCodegenNode = createCallExpression(
  30849. context.helper(SSR_RENDER_COMPONENT),
  30850. [component, propsExp, slots, `_parent`]
  30851. );
  30852. }
  30853. };
  30854. };
  30855. function ssrProcessComponent(node, context, parent) {
  30856. const component = componentTypeMap.get(node);
  30857. if (!node.ssrCodegenNode) {
  30858. if (component === TELEPORT) {
  30859. return ssrProcessTeleport(node, context);
  30860. } else if (component === SUSPENSE) {
  30861. return ssrProcessSuspense(node, context);
  30862. } else if (component === TRANSITION_GROUP) {
  30863. return ssrProcessTransitionGroup(node, context);
  30864. } else {
  30865. if (parent.type === WIP_SLOT) {
  30866. context.pushStringPart(``);
  30867. }
  30868. if (component === TRANSITION) {
  30869. return ssrProcessTransition(node, context);
  30870. }
  30871. processChildren(node, context);
  30872. }
  30873. } else {
  30874. const wipEntries = wipMap.get(node) || [];
  30875. for (let i = 0; i < wipEntries.length; i++) {
  30876. const { fn, vnodeBranch } = wipEntries[i];
  30877. fn.body = createIfStatement(
  30878. createSimpleExpression(`_push`, false),
  30879. processChildrenAsStatement(
  30880. wipEntries[i],
  30881. context,
  30882. false,
  30883. true
  30884. ),
  30885. vnodeBranch
  30886. );
  30887. }
  30888. if (context.withSlotScopeId) {
  30889. node.ssrCodegenNode.arguments.push(`_scopeId`);
  30890. }
  30891. if (typeof component === "string") {
  30892. context.pushStatement(
  30893. createCallExpression(`_push`, [node.ssrCodegenNode])
  30894. );
  30895. } else {
  30896. context.pushStatement(node.ssrCodegenNode);
  30897. }
  30898. }
  30899. }
  30900. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  30901. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  30902. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  30903. const vnodeDirectiveTransforms = __spreadValues$8(__spreadValues$8({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  30904. function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
  30905. const rawOptions = rawOptionsMap.get(parentContext.root);
  30906. const subOptions = __spreadProps$7(__spreadValues$8({}, rawOptions), {
  30907. // overwrite with vnode-based transforms
  30908. nodeTransforms: [
  30909. ...vnodeNodeTransforms,
  30910. ...rawOptions.nodeTransforms || []
  30911. ],
  30912. directiveTransforms: __spreadValues$8(__spreadValues$8({}, vnodeDirectiveTransforms), rawOptions.directiveTransforms || {})
  30913. });
  30914. const wrapperProps = [];
  30915. if (slotProps) {
  30916. wrapperProps.push({
  30917. type: 7,
  30918. name: "slot",
  30919. exp: slotProps,
  30920. arg: void 0,
  30921. modifiers: [],
  30922. loc: locStub
  30923. });
  30924. }
  30925. if (vFor) {
  30926. wrapperProps.push(extend({}, vFor));
  30927. }
  30928. const wrapperNode = {
  30929. type: 1,
  30930. ns: 0,
  30931. tag: "template",
  30932. tagType: 3,
  30933. props: wrapperProps,
  30934. children,
  30935. loc: locStub,
  30936. codegenNode: void 0
  30937. };
  30938. subTransform(wrapperNode, subOptions, parentContext);
  30939. return createReturnStatement(children);
  30940. }
  30941. function subTransform(node, options, parentContext) {
  30942. const childRoot = createRoot([node]);
  30943. const childContext = createTransformContext(childRoot, options);
  30944. childContext.ssr = false;
  30945. childContext.scopes = __spreadValues$8({}, parentContext.scopes);
  30946. childContext.identifiers = __spreadValues$8({}, parentContext.identifiers);
  30947. childContext.imports = parentContext.imports;
  30948. traverseNode(childRoot, childContext);
  30949. ["helpers", "components", "directives"].forEach((key) => {
  30950. childContext[key].forEach((value, helperKey) => {
  30951. if (key === "helpers") {
  30952. const parentCount = parentContext.helpers.get(helperKey);
  30953. if (parentCount === void 0) {
  30954. parentContext.helpers.set(helperKey, value);
  30955. } else {
  30956. parentContext.helpers.set(helperKey, value + parentCount);
  30957. }
  30958. } else {
  30959. parentContext[key].add(value);
  30960. }
  30961. });
  30962. });
  30963. }
  30964. function clone(v) {
  30965. if (isArray$3(v)) {
  30966. return v.map(clone);
  30967. } else if (isPlainObject(v)) {
  30968. const res = {};
  30969. for (const key in v) {
  30970. res[key] = clone(v[key]);
  30971. }
  30972. return res;
  30973. } else {
  30974. return v;
  30975. }
  30976. }
  30977. function ssrCodegenTransform(ast, options) {
  30978. const context = createSSRTransformContext(ast, options);
  30979. if (options.ssrCssVars) {
  30980. const cssContext = createTransformContext(createRoot([]), options);
  30981. const varsExp = processExpression(
  30982. createSimpleExpression(options.ssrCssVars, false),
  30983. cssContext
  30984. );
  30985. context.body.push(
  30986. createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  30987. );
  30988. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  30989. ast.helpers.add(helper);
  30990. });
  30991. }
  30992. const isFragment = ast.children.length > 1 && ast.children.some((c) => !isText$1(c));
  30993. processChildren(ast, context, isFragment);
  30994. ast.codegenNode = createBlockStatement(context.body);
  30995. ast.ssrHelpers = Array.from(
  30996. /* @__PURE__ */ new Set([
  30997. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  30998. ...context.helpers
  30999. ])
  31000. );
  31001. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  31002. }
  31003. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  31004. const body = [];
  31005. let currentString = null;
  31006. return {
  31007. root,
  31008. options,
  31009. body,
  31010. helpers,
  31011. withSlotScopeId,
  31012. onError: options.onError || ((e) => {
  31013. throw e;
  31014. }),
  31015. helper(name) {
  31016. helpers.add(name);
  31017. return name;
  31018. },
  31019. pushStringPart(part) {
  31020. if (!currentString) {
  31021. const currentCall = createCallExpression(`_push`);
  31022. body.push(currentCall);
  31023. currentString = createTemplateLiteral([]);
  31024. currentCall.arguments.push(currentString);
  31025. }
  31026. const bufferedElements = currentString.elements;
  31027. const lastItem = bufferedElements[bufferedElements.length - 1];
  31028. if (isString$1(part) && isString$1(lastItem)) {
  31029. bufferedElements[bufferedElements.length - 1] += part;
  31030. } else {
  31031. bufferedElements.push(part);
  31032. }
  31033. },
  31034. pushStatement(statement) {
  31035. currentString = null;
  31036. body.push(statement);
  31037. }
  31038. };
  31039. }
  31040. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  31041. return createSSRTransformContext(
  31042. parent.root,
  31043. parent.options,
  31044. parent.helpers,
  31045. withSlotScopeId
  31046. );
  31047. }
  31048. function processChildren(parent, context, asFragment = false, disableNestedFragments = false, disableComment = false) {
  31049. if (asFragment) {
  31050. context.pushStringPart(`<!--[-->`);
  31051. }
  31052. const { children } = parent;
  31053. for (let i = 0; i < children.length; i++) {
  31054. const child = children[i];
  31055. switch (child.type) {
  31056. case 1:
  31057. switch (child.tagType) {
  31058. case 0:
  31059. ssrProcessElement(child, context);
  31060. break;
  31061. case 1:
  31062. ssrProcessComponent(child, context, parent);
  31063. break;
  31064. case 2:
  31065. ssrProcessSlotOutlet(child, context);
  31066. break;
  31067. case 3:
  31068. break;
  31069. default:
  31070. context.onError(
  31071. createSSRCompilerError(
  31072. 67,
  31073. child.loc
  31074. )
  31075. );
  31076. const exhaustiveCheck2 = child;
  31077. return exhaustiveCheck2;
  31078. }
  31079. break;
  31080. case 2:
  31081. context.pushStringPart(escapeHtml(child.content));
  31082. break;
  31083. case 3:
  31084. if (!disableComment) {
  31085. context.pushStringPart(`<!--${child.content}-->`);
  31086. }
  31087. break;
  31088. case 5:
  31089. context.pushStringPart(
  31090. createCallExpression(context.helper(SSR_INTERPOLATE), [
  31091. child.content
  31092. ])
  31093. );
  31094. break;
  31095. case 9:
  31096. ssrProcessIf(child, context, disableNestedFragments, disableComment);
  31097. break;
  31098. case 11:
  31099. ssrProcessFor(child, context, disableNestedFragments);
  31100. break;
  31101. case 10:
  31102. break;
  31103. case 12:
  31104. case 8:
  31105. break;
  31106. default:
  31107. context.onError(
  31108. createSSRCompilerError(
  31109. 67,
  31110. child.loc
  31111. )
  31112. );
  31113. const exhaustiveCheck = child;
  31114. return exhaustiveCheck;
  31115. }
  31116. }
  31117. if (asFragment) {
  31118. context.pushStringPart(`<!--]-->`);
  31119. }
  31120. }
  31121. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  31122. const childContext = createChildContext(parentContext, withSlotScopeId);
  31123. processChildren(parent, childContext, asFragment);
  31124. return createBlockStatement(childContext.body);
  31125. }
  31126. const ssrTransformModel = (dir, node, context) => {
  31127. const model = dir.exp;
  31128. function checkDuplicatedValue() {
  31129. const value = findProp(node, "value");
  31130. if (value) {
  31131. context.onError(
  31132. createDOMCompilerError(
  31133. 60,
  31134. value.loc
  31135. )
  31136. );
  31137. }
  31138. }
  31139. function processOption(plainNode) {
  31140. if (plainNode.tag === "option") {
  31141. if (plainNode.props.findIndex((p) => p.name === "selected") === -1) {
  31142. const value = findValueBinding(plainNode);
  31143. plainNode.ssrCodegenNode.elements.push(
  31144. createConditionalExpression(
  31145. createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [
  31146. createConditionalExpression(
  31147. createCallExpression(`Array.isArray`, [model]),
  31148. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  31149. model,
  31150. value
  31151. ]),
  31152. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31153. model,
  31154. value
  31155. ])
  31156. )
  31157. ]),
  31158. createSimpleExpression(" selected", true),
  31159. createSimpleExpression("", true),
  31160. false
  31161. )
  31162. );
  31163. }
  31164. } else if (plainNode.tag === "optgroup") {
  31165. plainNode.children.forEach(
  31166. (option) => processOption(option)
  31167. );
  31168. }
  31169. }
  31170. if (node.tagType === 0) {
  31171. const res = { props: [] };
  31172. const defaultProps = [
  31173. // default value binding for text type inputs
  31174. createObjectProperty(`value`, model)
  31175. ];
  31176. if (node.tag === "input") {
  31177. const type = findProp(node, "type");
  31178. if (type) {
  31179. const value = findValueBinding(node);
  31180. if (type.type === 7) {
  31181. res.ssrTagParts = [
  31182. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  31183. type.exp,
  31184. model,
  31185. value
  31186. ])
  31187. ];
  31188. } else if (type.value) {
  31189. switch (type.value.content) {
  31190. case "radio":
  31191. res.props = [
  31192. createObjectProperty(
  31193. `checked`,
  31194. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31195. model,
  31196. value
  31197. ])
  31198. )
  31199. ];
  31200. break;
  31201. case "checkbox":
  31202. const trueValueBinding = findProp(node, "true-value");
  31203. if (trueValueBinding) {
  31204. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  31205. res.props = [
  31206. createObjectProperty(
  31207. `checked`,
  31208. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  31209. model,
  31210. trueValue
  31211. ])
  31212. )
  31213. ];
  31214. } else {
  31215. res.props = [
  31216. createObjectProperty(
  31217. `checked`,
  31218. createConditionalExpression(
  31219. createCallExpression(`Array.isArray`, [model]),
  31220. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  31221. model,
  31222. value
  31223. ]),
  31224. model
  31225. )
  31226. )
  31227. ];
  31228. }
  31229. break;
  31230. case "file":
  31231. context.onError(
  31232. createDOMCompilerError(
  31233. 59,
  31234. dir.loc
  31235. )
  31236. );
  31237. break;
  31238. default:
  31239. checkDuplicatedValue();
  31240. res.props = defaultProps;
  31241. break;
  31242. }
  31243. }
  31244. } else if (hasDynamicKeyVBind(node)) ; else {
  31245. checkDuplicatedValue();
  31246. res.props = defaultProps;
  31247. }
  31248. } else if (node.tag === "textarea") {
  31249. checkDuplicatedValue();
  31250. node.children = [createInterpolation(model, model.loc)];
  31251. } else if (node.tag === "select") {
  31252. node.children.forEach((child) => {
  31253. if (child.type === 1) {
  31254. processOption(child);
  31255. }
  31256. });
  31257. } else {
  31258. context.onError(
  31259. createDOMCompilerError(
  31260. 57,
  31261. dir.loc
  31262. )
  31263. );
  31264. }
  31265. return res;
  31266. } else {
  31267. return transformModel$1(dir, node, context);
  31268. }
  31269. };
  31270. function findValueBinding(node) {
  31271. const valueBinding = findProp(node, "value");
  31272. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : createSimpleExpression(valueBinding.value.content, true) : createSimpleExpression(`null`, false);
  31273. }
  31274. const ssrTransformShow = (dir, node, context) => {
  31275. if (!dir.exp) {
  31276. context.onError(
  31277. createDOMCompilerError(61)
  31278. );
  31279. }
  31280. return {
  31281. props: [
  31282. createObjectProperty(
  31283. `style`,
  31284. createConditionalExpression(
  31285. dir.exp,
  31286. createSimpleExpression(`null`, false),
  31287. createObjectExpression([
  31288. createObjectProperty(
  31289. `display`,
  31290. createSimpleExpression(`none`, true)
  31291. )
  31292. ]),
  31293. false
  31294. )
  31295. )
  31296. ]
  31297. };
  31298. };
  31299. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  31300. const hasSingleChild = (node) => filterChild(node).length === 1;
  31301. const ssrInjectFallthroughAttrs = (node, context) => {
  31302. if (node.type === 0) {
  31303. context.identifiers._attrs = 1;
  31304. }
  31305. if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
  31306. const rootChildren = filterChild(context.root);
  31307. if (rootChildren.length === 1 && rootChildren[0] === node) {
  31308. if (hasSingleChild(node)) {
  31309. injectFallthroughAttrs(node.children[0]);
  31310. }
  31311. return;
  31312. }
  31313. }
  31314. const parent = context.parent;
  31315. if (!parent || parent.type !== 0) {
  31316. return;
  31317. }
  31318. if (node.type === 10 && hasSingleChild(node)) {
  31319. let hasEncounteredIf = false;
  31320. for (const c of filterChild(parent)) {
  31321. if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
  31322. if (hasEncounteredIf) return;
  31323. hasEncounteredIf = true;
  31324. } else if (
  31325. // node before v-if
  31326. !hasEncounteredIf || // non else nodes
  31327. !(c.type === 1 && findDir(c, /else/, true))
  31328. ) {
  31329. return;
  31330. }
  31331. }
  31332. injectFallthroughAttrs(node.children[0]);
  31333. } else if (hasSingleChild(parent)) {
  31334. injectFallthroughAttrs(node);
  31335. }
  31336. };
  31337. function injectFallthroughAttrs(node) {
  31338. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  31339. node.props.push({
  31340. type: 7,
  31341. name: "bind",
  31342. arg: void 0,
  31343. exp: createSimpleExpression(`_attrs`, false),
  31344. modifiers: [],
  31345. loc: locStub
  31346. });
  31347. }
  31348. }
  31349. const ssrInjectCssVars = (node, context) => {
  31350. if (!context.ssrCssVars) {
  31351. return;
  31352. }
  31353. if (node.type === 0) {
  31354. context.identifiers._cssVars = 1;
  31355. }
  31356. const parent = context.parent;
  31357. if (!parent || parent.type !== 0) {
  31358. return;
  31359. }
  31360. if (node.type === 10) {
  31361. for (const child of node.children) {
  31362. injectCssVars(child);
  31363. }
  31364. } else {
  31365. injectCssVars(node);
  31366. }
  31367. };
  31368. function injectCssVars(node) {
  31369. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  31370. if (node.tag === "suspense" || node.tag === "Suspense") {
  31371. for (const child of node.children) {
  31372. if (child.type === 1 && child.tagType === 3) {
  31373. child.children.forEach(injectCssVars);
  31374. } else {
  31375. injectCssVars(child);
  31376. }
  31377. }
  31378. } else {
  31379. node.props.push({
  31380. type: 7,
  31381. name: "bind",
  31382. arg: void 0,
  31383. exp: createSimpleExpression(`_cssVars`, false),
  31384. modifiers: [],
  31385. loc: locStub
  31386. });
  31387. }
  31388. }
  31389. }
  31390. var __defProp$7 = Object.defineProperty;
  31391. var __defProps$6 = Object.defineProperties;
  31392. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  31393. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  31394. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  31395. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  31396. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31397. var __spreadValues$7 = (a, b) => {
  31398. for (var prop in b || (b = {}))
  31399. if (__hasOwnProp$7.call(b, prop))
  31400. __defNormalProp$7(a, prop, b[prop]);
  31401. if (__getOwnPropSymbols$7)
  31402. for (var prop of __getOwnPropSymbols$7(b)) {
  31403. if (__propIsEnum$7.call(b, prop))
  31404. __defNormalProp$7(a, prop, b[prop]);
  31405. }
  31406. return a;
  31407. };
  31408. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  31409. function compile(source, options = {}) {
  31410. options = __spreadProps$6(__spreadValues$7(__spreadValues$7({}, options), parserOptions), {
  31411. ssr: true,
  31412. inSSR: true,
  31413. scopeId: options.mode === "function" ? null : options.scopeId,
  31414. // always prefix since compiler-ssr doesn't have size concern
  31415. prefixIdentifiers: true,
  31416. // disable optimizations that are unnecessary for ssr
  31417. cacheHandlers: false,
  31418. hoistStatic: false
  31419. });
  31420. const ast = typeof source === "string" ? baseParse(source, options) : source;
  31421. rawOptionsMap.set(ast, options);
  31422. transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
  31423. hoistStatic: false,
  31424. nodeTransforms: [
  31425. ssrTransformIf,
  31426. ssrTransformFor,
  31427. trackVForSlotScopes,
  31428. transformExpression,
  31429. ssrTransformSlotOutlet,
  31430. ssrInjectFallthroughAttrs,
  31431. ssrInjectCssVars,
  31432. ssrTransformElement,
  31433. ssrTransformComponent,
  31434. trackSlotScopes,
  31435. transformStyle,
  31436. ...options.nodeTransforms || []
  31437. // user transforms
  31438. ],
  31439. directiveTransforms: __spreadValues$7({
  31440. // reusing core v-bind
  31441. bind: transformBind,
  31442. on: transformOn$1,
  31443. // model and show have dedicated SSR handling
  31444. model: ssrTransformModel,
  31445. show: ssrTransformShow,
  31446. // the following are ignored during SSR
  31447. // on: noopDirectiveTransform,
  31448. cloak: noopDirectiveTransform,
  31449. once: noopDirectiveTransform,
  31450. memo: noopDirectiveTransform
  31451. }, options.directiveTransforms || {})
  31452. }));
  31453. ssrCodegenTransform(ast, options);
  31454. return generate(ast, options);
  31455. }
  31456. var CompilerSSR = /*#__PURE__*/Object.freeze({
  31457. __proto__: null,
  31458. compile: compile
  31459. });
  31460. function commonjsRequire(path) {
  31461. throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
  31462. }
  31463. var _polyfillNode_fs = {};
  31464. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  31465. __proto__: null,
  31466. default: _polyfillNode_fs
  31467. });
  31468. var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  31469. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  31470. var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  31471. const hasWarned = {};
  31472. function warnOnce$1(msg) {
  31473. const isNodeProd = typeof process !== "undefined" && process.env.NODE_ENV === "production";
  31474. if (!isNodeProd && true && !hasWarned[msg]) {
  31475. hasWarned[msg] = true;
  31476. warn(msg);
  31477. }
  31478. }
  31479. function warn(msg) {
  31480. console.warn(
  31481. `\x1B[1m\x1B[33m[@vue/compiler-sfc]\x1B[0m\x1B[33m ${msg}\x1B[0m
  31482. `
  31483. );
  31484. }
  31485. var __defProp$6 = Object.defineProperty;
  31486. var __defProps$5 = Object.defineProperties;
  31487. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  31488. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  31489. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  31490. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  31491. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31492. var __spreadValues$6 = (a, b) => {
  31493. for (var prop in b || (b = {}))
  31494. if (__hasOwnProp$6.call(b, prop))
  31495. __defNormalProp$6(a, prop, b[prop]);
  31496. if (__getOwnPropSymbols$6)
  31497. for (var prop of __getOwnPropSymbols$6(b)) {
  31498. if (__propIsEnum$6.call(b, prop))
  31499. __defNormalProp$6(a, prop, b[prop]);
  31500. }
  31501. return a;
  31502. };
  31503. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  31504. function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
  31505. let res = "";
  31506. let err = null;
  31507. preprocessor.render(
  31508. source,
  31509. __spreadValues$6({ filename }, preprocessOptions),
  31510. (_err, _res) => {
  31511. if (_err) err = _err;
  31512. res = _res;
  31513. }
  31514. );
  31515. if (err) throw err;
  31516. return res;
  31517. }
  31518. function compileTemplate(options) {
  31519. const { preprocessLang, preprocessCustomRequire } = options;
  31520. if (preprocessLang && !preprocessCustomRequire) {
  31521. throw new Error(
  31522. `[@vue/compiler-sfc] Template preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor in the shape of { render(): string }.`
  31523. );
  31524. }
  31525. const preprocessor = preprocessLang ? preprocessCustomRequire ? preprocessCustomRequire(preprocessLang) : void 0 : false;
  31526. if (preprocessor) {
  31527. try {
  31528. return doCompileTemplate(__spreadProps$5(__spreadValues$6({}, options), {
  31529. source: preprocess$1(options, preprocessor),
  31530. ast: void 0
  31531. // invalidate AST if template goes through preprocessor
  31532. }));
  31533. } catch (e) {
  31534. return {
  31535. code: `export default function render() {}`,
  31536. source: options.source,
  31537. tips: [],
  31538. errors: [e]
  31539. };
  31540. }
  31541. } else if (preprocessLang) {
  31542. return {
  31543. code: `export default function render() {}`,
  31544. source: options.source,
  31545. tips: [
  31546. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  31547. ],
  31548. errors: [
  31549. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  31550. ]
  31551. };
  31552. } else {
  31553. return doCompileTemplate(options);
  31554. }
  31555. }
  31556. function doCompileTemplate({
  31557. filename,
  31558. id,
  31559. scoped,
  31560. slotted,
  31561. inMap,
  31562. source,
  31563. ast: inAST,
  31564. ssr = false,
  31565. ssrCssVars,
  31566. isProd = false,
  31567. compiler,
  31568. compilerOptions = {},
  31569. transformAssetUrls
  31570. }) {
  31571. const errors = [];
  31572. const warnings = [];
  31573. let nodeTransforms = [];
  31574. if (isObject$2(transformAssetUrls)) {
  31575. const assetOptions = normalizeOptions(transformAssetUrls);
  31576. nodeTransforms = [
  31577. createAssetUrlTransformWithOptions(assetOptions),
  31578. createSrcsetTransformWithOptions(assetOptions)
  31579. ];
  31580. } else if (transformAssetUrls !== false) {
  31581. nodeTransforms = [transformAssetUrl, transformSrcset];
  31582. }
  31583. if (ssr && !ssrCssVars) {
  31584. warnOnce$1(
  31585. `compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.`
  31586. );
  31587. }
  31588. if (!id) {
  31589. warnOnce$1(`compileTemplate now requires the \`id\` option.`);
  31590. id = "";
  31591. }
  31592. const shortId = id.replace(/^data-v-/, "");
  31593. const longId = `data-v-${shortId}`;
  31594. const defaultCompiler = ssr ? CompilerSSR : CompilerDOM;
  31595. compiler = compiler || defaultCompiler;
  31596. if (compiler !== defaultCompiler) {
  31597. inAST = void 0;
  31598. }
  31599. if (inAST == null ? void 0 : inAST.transformed) {
  31600. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
  31601. prefixIdentifiers: true
  31602. }, compilerOptions), {
  31603. parseMode: "sfc",
  31604. onError: (e) => errors.push(e)
  31605. }));
  31606. const template = newAST.children.find(
  31607. (node) => node.type === 1 && node.tag === "template"
  31608. );
  31609. inAST = createRoot(template.children, inAST.source);
  31610. }
  31611. let { code, ast, preamble, map } = compiler.compile(inAST || source, __spreadProps$5(__spreadValues$6({
  31612. mode: "module",
  31613. prefixIdentifiers: true,
  31614. hoistStatic: true,
  31615. cacheHandlers: true,
  31616. ssrCssVars: ssr && ssrCssVars && ssrCssVars.length ? genCssVarsFromList(ssrCssVars, shortId, isProd, true) : "",
  31617. scopeId: scoped ? longId : void 0,
  31618. slotted,
  31619. sourceMap: true
  31620. }, compilerOptions), {
  31621. hmr: !isProd,
  31622. nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
  31623. filename,
  31624. onError: (e) => errors.push(e),
  31625. onWarn: (w) => warnings.push(w)
  31626. }));
  31627. if (inMap && !inAST) {
  31628. if (map) {
  31629. map = mapLines(inMap, map);
  31630. }
  31631. if (errors.length) {
  31632. patchErrors(errors, source, inMap);
  31633. }
  31634. }
  31635. const tips = warnings.map((w) => {
  31636. let msg = w.message;
  31637. if (w.loc) {
  31638. msg += `
  31639. ${generateCodeFrame(
  31640. (inAST == null ? void 0 : inAST.source) || source,
  31641. w.loc.start.offset,
  31642. w.loc.end.offset
  31643. )}`;
  31644. }
  31645. return msg;
  31646. });
  31647. return { code, ast, preamble, source, errors, tips, map };
  31648. }
  31649. function mapLines(oldMap, newMap) {
  31650. if (!oldMap) return newMap;
  31651. if (!newMap) return oldMap;
  31652. const oldMapConsumer = new sourceMapExports.SourceMapConsumer(oldMap);
  31653. const newMapConsumer = new sourceMapExports.SourceMapConsumer(newMap);
  31654. const mergedMapGenerator = new sourceMapExports.SourceMapGenerator();
  31655. newMapConsumer.eachMapping((m) => {
  31656. if (m.originalLine == null) {
  31657. return;
  31658. }
  31659. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  31660. line: m.originalLine,
  31661. column: m.originalColumn
  31662. });
  31663. if (origPosInOldMap.source == null) {
  31664. return;
  31665. }
  31666. mergedMapGenerator.addMapping({
  31667. generated: {
  31668. line: m.generatedLine,
  31669. column: m.generatedColumn
  31670. },
  31671. original: {
  31672. line: origPosInOldMap.line,
  31673. // map line
  31674. // use current column, since the oldMap produced by @vue/compiler-sfc
  31675. // does not
  31676. column: m.originalColumn
  31677. },
  31678. source: origPosInOldMap.source,
  31679. name: origPosInOldMap.name
  31680. });
  31681. });
  31682. const generator = mergedMapGenerator;
  31683. oldMapConsumer.sources.forEach((sourceFile) => {
  31684. generator._sources.add(sourceFile);
  31685. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  31686. if (sourceContent != null) {
  31687. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  31688. }
  31689. });
  31690. generator._sourceRoot = oldMap.sourceRoot;
  31691. generator._file = oldMap.file;
  31692. return generator.toJSON();
  31693. }
  31694. function patchErrors(errors, source, inMap) {
  31695. const originalSource = inMap.sourcesContent[0];
  31696. const offset = originalSource.indexOf(source);
  31697. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  31698. errors.forEach((err) => {
  31699. if (err.loc) {
  31700. err.loc.start.line += lineOffset;
  31701. err.loc.start.offset += offset;
  31702. if (err.loc.end !== err.loc.start) {
  31703. err.loc.end.line += lineOffset;
  31704. err.loc.end.offset += offset;
  31705. }
  31706. }
  31707. });
  31708. }
  31709. var picocolors = {exports: {}};
  31710. // MIT lisence
  31711. // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
  31712. function isatty() {
  31713. return false;
  31714. }
  31715. function ReadStream() {
  31716. throw new Error('tty.ReadStream is not implemented');
  31717. }
  31718. function WriteStream() {
  31719. throw new Error('tty.ReadStream is not implemented');
  31720. }
  31721. var _polyfillNode_tty = {
  31722. isatty: isatty,
  31723. ReadStream: ReadStream,
  31724. WriteStream: WriteStream
  31725. };
  31726. var _polyfillNode_tty$1 = /*#__PURE__*/Object.freeze({
  31727. __proto__: null,
  31728. ReadStream: ReadStream,
  31729. WriteStream: WriteStream,
  31730. default: _polyfillNode_tty,
  31731. isatty: isatty
  31732. });
  31733. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_tty$1);
  31734. var hasRequiredPicocolors;
  31735. function requirePicocolors () {
  31736. if (hasRequiredPicocolors) return picocolors.exports;
  31737. hasRequiredPicocolors = 1;
  31738. let argv = browser$1.argv || [],
  31739. env = ({});
  31740. let isColorSupported =
  31741. !("NO_COLOR" in env || argv.includes("--no-color")) &&
  31742. ("FORCE_COLOR" in env ||
  31743. argv.includes("--color") ||
  31744. "" === "win32" ||
  31745. (commonjsRequire != null && require$$0.isatty(1) && env.TERM !== "dumb") ||
  31746. "CI" in env);
  31747. let formatter =
  31748. (open, close, replace = open) =>
  31749. input => {
  31750. let string = "" + input;
  31751. let index = string.indexOf(close, open.length);
  31752. return ~index
  31753. ? open + replaceClose(string, close, replace, index) + close
  31754. : open + string + close
  31755. };
  31756. let replaceClose = (string, close, replace, index) => {
  31757. let result = "";
  31758. let cursor = 0;
  31759. do {
  31760. result += string.substring(cursor, index) + replace;
  31761. cursor = index + close.length;
  31762. index = string.indexOf(close, cursor);
  31763. } while (~index)
  31764. return result + string.substring(cursor)
  31765. };
  31766. let createColors = (enabled = isColorSupported) => {
  31767. let init = enabled ? formatter : () => String;
  31768. return {
  31769. isColorSupported: enabled,
  31770. reset: init("\x1b[0m", "\x1b[0m"),
  31771. bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
  31772. dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
  31773. italic: init("\x1b[3m", "\x1b[23m"),
  31774. underline: init("\x1b[4m", "\x1b[24m"),
  31775. inverse: init("\x1b[7m", "\x1b[27m"),
  31776. hidden: init("\x1b[8m", "\x1b[28m"),
  31777. strikethrough: init("\x1b[9m", "\x1b[29m"),
  31778. black: init("\x1b[30m", "\x1b[39m"),
  31779. red: init("\x1b[31m", "\x1b[39m"),
  31780. green: init("\x1b[32m", "\x1b[39m"),
  31781. yellow: init("\x1b[33m", "\x1b[39m"),
  31782. blue: init("\x1b[34m", "\x1b[39m"),
  31783. magenta: init("\x1b[35m", "\x1b[39m"),
  31784. cyan: init("\x1b[36m", "\x1b[39m"),
  31785. white: init("\x1b[37m", "\x1b[39m"),
  31786. gray: init("\x1b[90m", "\x1b[39m"),
  31787. bgBlack: init("\x1b[40m", "\x1b[49m"),
  31788. bgRed: init("\x1b[41m", "\x1b[49m"),
  31789. bgGreen: init("\x1b[42m", "\x1b[49m"),
  31790. bgYellow: init("\x1b[43m", "\x1b[49m"),
  31791. bgBlue: init("\x1b[44m", "\x1b[49m"),
  31792. bgMagenta: init("\x1b[45m", "\x1b[49m"),
  31793. bgCyan: init("\x1b[46m", "\x1b[49m"),
  31794. bgWhite: init("\x1b[47m", "\x1b[49m"),
  31795. blackBright: init("\x1b[90m", "\x1b[39m"),
  31796. redBright: init("\x1b[91m", "\x1b[39m"),
  31797. greenBright: init("\x1b[92m", "\x1b[39m"),
  31798. yellowBright: init("\x1b[93m", "\x1b[39m"),
  31799. blueBright: init("\x1b[94m", "\x1b[39m"),
  31800. magentaBright: init("\x1b[95m", "\x1b[39m"),
  31801. cyanBright: init("\x1b[96m", "\x1b[39m"),
  31802. whiteBright: init("\x1b[97m", "\x1b[39m"),
  31803. bgBlackBright: init("\x1b[100m","\x1b[49m"),
  31804. bgRedBright: init("\x1b[101m","\x1b[49m"),
  31805. bgGreenBright: init("\x1b[102m","\x1b[49m"),
  31806. bgYellowBright: init("\x1b[103m","\x1b[49m"),
  31807. bgBlueBright: init("\x1b[104m","\x1b[49m"),
  31808. bgMagentaBright: init("\x1b[105m","\x1b[49m"),
  31809. bgCyanBright: init("\x1b[106m","\x1b[49m"),
  31810. bgWhiteBright: init("\x1b[107m","\x1b[49m"),
  31811. }
  31812. };
  31813. picocolors.exports = createColors();
  31814. picocolors.exports.createColors = createColors;
  31815. return picocolors.exports;
  31816. }
  31817. var tokenize$1;
  31818. var hasRequiredTokenize$1;
  31819. function requireTokenize$1 () {
  31820. if (hasRequiredTokenize$1) return tokenize$1;
  31821. hasRequiredTokenize$1 = 1;
  31822. const SINGLE_QUOTE = "'".charCodeAt(0);
  31823. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  31824. const BACKSLASH = '\\'.charCodeAt(0);
  31825. const SLASH = '/'.charCodeAt(0);
  31826. const NEWLINE = '\n'.charCodeAt(0);
  31827. const SPACE = ' '.charCodeAt(0);
  31828. const FEED = '\f'.charCodeAt(0);
  31829. const TAB = '\t'.charCodeAt(0);
  31830. const CR = '\r'.charCodeAt(0);
  31831. const OPEN_SQUARE = '['.charCodeAt(0);
  31832. const CLOSE_SQUARE = ']'.charCodeAt(0);
  31833. const OPEN_PARENTHESES = '('.charCodeAt(0);
  31834. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  31835. const OPEN_CURLY = '{'.charCodeAt(0);
  31836. const CLOSE_CURLY = '}'.charCodeAt(0);
  31837. const SEMICOLON = ';'.charCodeAt(0);
  31838. const ASTERISK = '*'.charCodeAt(0);
  31839. const COLON = ':'.charCodeAt(0);
  31840. const AT = '@'.charCodeAt(0);
  31841. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  31842. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  31843. const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
  31844. const RE_HEX_ESCAPE = /[\da-f]/i;
  31845. tokenize$1 = function tokenizer(input, options = {}) {
  31846. let css = input.css.valueOf();
  31847. let ignore = options.ignoreErrors;
  31848. let code, content, escape, next, quote;
  31849. let currentToken, escaped, escapePos, n, prev;
  31850. let length = css.length;
  31851. let pos = 0;
  31852. let buffer = [];
  31853. let returned = [];
  31854. function position() {
  31855. return pos
  31856. }
  31857. function unclosed(what) {
  31858. throw input.error('Unclosed ' + what, pos)
  31859. }
  31860. function endOfFile() {
  31861. return returned.length === 0 && pos >= length
  31862. }
  31863. function nextToken(opts) {
  31864. if (returned.length) return returned.pop()
  31865. if (pos >= length) return
  31866. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  31867. code = css.charCodeAt(pos);
  31868. switch (code) {
  31869. case NEWLINE:
  31870. case SPACE:
  31871. case TAB:
  31872. case CR:
  31873. case FEED: {
  31874. next = pos;
  31875. do {
  31876. next += 1;
  31877. code = css.charCodeAt(next);
  31878. } while (
  31879. code === SPACE ||
  31880. code === NEWLINE ||
  31881. code === TAB ||
  31882. code === CR ||
  31883. code === FEED
  31884. )
  31885. currentToken = ['space', css.slice(pos, next)];
  31886. pos = next - 1;
  31887. break
  31888. }
  31889. case OPEN_SQUARE:
  31890. case CLOSE_SQUARE:
  31891. case OPEN_CURLY:
  31892. case CLOSE_CURLY:
  31893. case COLON:
  31894. case SEMICOLON:
  31895. case CLOSE_PARENTHESES: {
  31896. let controlChar = String.fromCharCode(code);
  31897. currentToken = [controlChar, controlChar, pos];
  31898. break
  31899. }
  31900. case OPEN_PARENTHESES: {
  31901. prev = buffer.length ? buffer.pop()[1] : '';
  31902. n = css.charCodeAt(pos + 1);
  31903. if (
  31904. prev === 'url' &&
  31905. n !== SINGLE_QUOTE &&
  31906. n !== DOUBLE_QUOTE &&
  31907. n !== SPACE &&
  31908. n !== NEWLINE &&
  31909. n !== TAB &&
  31910. n !== FEED &&
  31911. n !== CR
  31912. ) {
  31913. next = pos;
  31914. do {
  31915. escaped = false;
  31916. next = css.indexOf(')', next + 1);
  31917. if (next === -1) {
  31918. if (ignore || ignoreUnclosed) {
  31919. next = pos;
  31920. break
  31921. } else {
  31922. unclosed('bracket');
  31923. }
  31924. }
  31925. escapePos = next;
  31926. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31927. escapePos -= 1;
  31928. escaped = !escaped;
  31929. }
  31930. } while (escaped)
  31931. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  31932. pos = next;
  31933. } else {
  31934. next = css.indexOf(')', pos + 1);
  31935. content = css.slice(pos, next + 1);
  31936. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  31937. currentToken = ['(', '(', pos];
  31938. } else {
  31939. currentToken = ['brackets', content, pos, next];
  31940. pos = next;
  31941. }
  31942. }
  31943. break
  31944. }
  31945. case SINGLE_QUOTE:
  31946. case DOUBLE_QUOTE: {
  31947. quote = code === SINGLE_QUOTE ? "'" : '"';
  31948. next = pos;
  31949. do {
  31950. escaped = false;
  31951. next = css.indexOf(quote, next + 1);
  31952. if (next === -1) {
  31953. if (ignore || ignoreUnclosed) {
  31954. next = pos + 1;
  31955. break
  31956. } else {
  31957. unclosed('string');
  31958. }
  31959. }
  31960. escapePos = next;
  31961. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31962. escapePos -= 1;
  31963. escaped = !escaped;
  31964. }
  31965. } while (escaped)
  31966. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  31967. pos = next;
  31968. break
  31969. }
  31970. case AT: {
  31971. RE_AT_END.lastIndex = pos + 1;
  31972. RE_AT_END.test(css);
  31973. if (RE_AT_END.lastIndex === 0) {
  31974. next = css.length - 1;
  31975. } else {
  31976. next = RE_AT_END.lastIndex - 2;
  31977. }
  31978. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  31979. pos = next;
  31980. break
  31981. }
  31982. case BACKSLASH: {
  31983. next = pos;
  31984. escape = true;
  31985. while (css.charCodeAt(next + 1) === BACKSLASH) {
  31986. next += 1;
  31987. escape = !escape;
  31988. }
  31989. code = css.charCodeAt(next + 1);
  31990. if (
  31991. escape &&
  31992. code !== SLASH &&
  31993. code !== SPACE &&
  31994. code !== NEWLINE &&
  31995. code !== TAB &&
  31996. code !== CR &&
  31997. code !== FEED
  31998. ) {
  31999. next += 1;
  32000. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  32001. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  32002. next += 1;
  32003. }
  32004. if (css.charCodeAt(next + 1) === SPACE) {
  32005. next += 1;
  32006. }
  32007. }
  32008. }
  32009. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  32010. pos = next;
  32011. break
  32012. }
  32013. default: {
  32014. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  32015. next = css.indexOf('*/', pos + 2) + 1;
  32016. if (next === 0) {
  32017. if (ignore || ignoreUnclosed) {
  32018. next = css.length;
  32019. } else {
  32020. unclosed('comment');
  32021. }
  32022. }
  32023. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  32024. pos = next;
  32025. } else {
  32026. RE_WORD_END.lastIndex = pos + 1;
  32027. RE_WORD_END.test(css);
  32028. if (RE_WORD_END.lastIndex === 0) {
  32029. next = css.length - 1;
  32030. } else {
  32031. next = RE_WORD_END.lastIndex - 2;
  32032. }
  32033. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  32034. buffer.push(currentToken);
  32035. pos = next;
  32036. }
  32037. break
  32038. }
  32039. }
  32040. pos++;
  32041. return currentToken
  32042. }
  32043. function back(token) {
  32044. returned.push(token);
  32045. }
  32046. return {
  32047. back,
  32048. endOfFile,
  32049. nextToken,
  32050. position
  32051. }
  32052. };
  32053. return tokenize$1;
  32054. }
  32055. var terminalHighlight_1;
  32056. var hasRequiredTerminalHighlight;
  32057. function requireTerminalHighlight () {
  32058. if (hasRequiredTerminalHighlight) return terminalHighlight_1;
  32059. hasRequiredTerminalHighlight = 1;
  32060. let pico = /*@__PURE__*/ requirePicocolors();
  32061. let tokenizer = /*@__PURE__*/ requireTokenize$1();
  32062. let Input;
  32063. function registerInput(dependant) {
  32064. Input = dependant;
  32065. }
  32066. const HIGHLIGHT_THEME = {
  32067. ';': pico.yellow,
  32068. ':': pico.yellow,
  32069. '(': pico.cyan,
  32070. ')': pico.cyan,
  32071. '[': pico.yellow,
  32072. ']': pico.yellow,
  32073. '{': pico.yellow,
  32074. '}': pico.yellow,
  32075. 'at-word': pico.cyan,
  32076. 'brackets': pico.cyan,
  32077. 'call': pico.cyan,
  32078. 'class': pico.yellow,
  32079. 'comment': pico.gray,
  32080. 'hash': pico.magenta,
  32081. 'string': pico.green
  32082. };
  32083. function getTokenType([type, value], processor) {
  32084. if (type === 'word') {
  32085. if (value[0] === '.') {
  32086. return 'class'
  32087. }
  32088. if (value[0] === '#') {
  32089. return 'hash'
  32090. }
  32091. }
  32092. if (!processor.endOfFile()) {
  32093. let next = processor.nextToken();
  32094. processor.back(next);
  32095. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  32096. }
  32097. return type
  32098. }
  32099. function terminalHighlight(css) {
  32100. let processor = tokenizer(new Input(css), { ignoreErrors: true });
  32101. let result = '';
  32102. while (!processor.endOfFile()) {
  32103. let token = processor.nextToken();
  32104. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  32105. if (color) {
  32106. result += token[1]
  32107. .split(/\r?\n/)
  32108. .map(i => color(i))
  32109. .join('\n');
  32110. } else {
  32111. result += token[1];
  32112. }
  32113. }
  32114. return result
  32115. }
  32116. terminalHighlight.registerInput = registerInput;
  32117. terminalHighlight_1 = terminalHighlight;
  32118. return terminalHighlight_1;
  32119. }
  32120. var cssSyntaxError;
  32121. var hasRequiredCssSyntaxError;
  32122. function requireCssSyntaxError () {
  32123. if (hasRequiredCssSyntaxError) return cssSyntaxError;
  32124. hasRequiredCssSyntaxError = 1;
  32125. let pico = /*@__PURE__*/ requirePicocolors();
  32126. let terminalHighlight = /*@__PURE__*/ requireTerminalHighlight();
  32127. class CssSyntaxError extends Error {
  32128. constructor(message, line, column, source, file, plugin) {
  32129. super(message);
  32130. this.name = 'CssSyntaxError';
  32131. this.reason = message;
  32132. if (file) {
  32133. this.file = file;
  32134. }
  32135. if (source) {
  32136. this.source = source;
  32137. }
  32138. if (plugin) {
  32139. this.plugin = plugin;
  32140. }
  32141. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  32142. if (typeof line === 'number') {
  32143. this.line = line;
  32144. this.column = column;
  32145. } else {
  32146. this.line = line.line;
  32147. this.column = line.column;
  32148. this.endLine = column.line;
  32149. this.endColumn = column.column;
  32150. }
  32151. }
  32152. this.setMessage();
  32153. if (Error.captureStackTrace) {
  32154. Error.captureStackTrace(this, CssSyntaxError);
  32155. }
  32156. }
  32157. setMessage() {
  32158. this.message = this.plugin ? this.plugin + ': ' : '';
  32159. this.message += this.file ? this.file : '<css input>';
  32160. if (typeof this.line !== 'undefined') {
  32161. this.message += ':' + this.line + ':' + this.column;
  32162. }
  32163. this.message += ': ' + this.reason;
  32164. }
  32165. showSourceCode(color) {
  32166. if (!this.source) return ''
  32167. let css = this.source;
  32168. if (color == null) color = pico.isColorSupported;
  32169. let aside = text => text;
  32170. let mark = text => text;
  32171. let highlight = text => text;
  32172. if (color) {
  32173. let { bold, gray, red } = pico.createColors(true);
  32174. mark = text => bold(red(text));
  32175. aside = text => gray(text);
  32176. if (terminalHighlight) {
  32177. highlight = text => terminalHighlight(text);
  32178. }
  32179. }
  32180. let lines = css.split(/\r?\n/);
  32181. let start = Math.max(this.line - 3, 0);
  32182. let end = Math.min(this.line + 2, lines.length);
  32183. let maxWidth = String(end).length;
  32184. return lines
  32185. .slice(start, end)
  32186. .map((line, index) => {
  32187. let number = start + 1 + index;
  32188. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  32189. if (number === this.line) {
  32190. if (line.length > 160) {
  32191. let padding = 20;
  32192. let subLineStart = Math.max(0, this.column - padding);
  32193. let subLineEnd = Math.max(
  32194. this.column + padding,
  32195. this.endColumn + padding
  32196. );
  32197. let subLine = line.slice(subLineStart, subLineEnd);
  32198. let spacing =
  32199. aside(gutter.replace(/\d/g, ' ')) +
  32200. line
  32201. .slice(0, Math.min(this.column - 1, padding - 1))
  32202. .replace(/[^\t]/g, ' ');
  32203. return (
  32204. mark('>') +
  32205. aside(gutter) +
  32206. highlight(subLine) +
  32207. '\n ' +
  32208. spacing +
  32209. mark('^')
  32210. )
  32211. }
  32212. let spacing =
  32213. aside(gutter.replace(/\d/g, ' ')) +
  32214. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  32215. return (
  32216. mark('>') +
  32217. aside(gutter) +
  32218. highlight(line) +
  32219. '\n ' +
  32220. spacing +
  32221. mark('^')
  32222. )
  32223. }
  32224. return ' ' + aside(gutter) + highlight(line)
  32225. })
  32226. .join('\n')
  32227. }
  32228. toString() {
  32229. let code = this.showSourceCode();
  32230. if (code) {
  32231. code = '\n\n' + code + '\n';
  32232. }
  32233. return this.name + ': ' + this.message + code
  32234. }
  32235. }
  32236. cssSyntaxError = CssSyntaxError;
  32237. CssSyntaxError.default = CssSyntaxError;
  32238. return cssSyntaxError;
  32239. }
  32240. var stringifier;
  32241. var hasRequiredStringifier;
  32242. function requireStringifier () {
  32243. if (hasRequiredStringifier) return stringifier;
  32244. hasRequiredStringifier = 1;
  32245. const DEFAULT_RAW = {
  32246. after: '\n',
  32247. beforeClose: '\n',
  32248. beforeComment: '\n',
  32249. beforeDecl: '\n',
  32250. beforeOpen: ' ',
  32251. beforeRule: '\n',
  32252. colon: ': ',
  32253. commentLeft: ' ',
  32254. commentRight: ' ',
  32255. emptyBody: '',
  32256. indent: ' ',
  32257. semicolon: false
  32258. };
  32259. function capitalize(str) {
  32260. return str[0].toUpperCase() + str.slice(1)
  32261. }
  32262. class Stringifier {
  32263. constructor(builder) {
  32264. this.builder = builder;
  32265. }
  32266. atrule(node, semicolon) {
  32267. let name = '@' + node.name;
  32268. let params = node.params ? this.rawValue(node, 'params') : '';
  32269. if (typeof node.raws.afterName !== 'undefined') {
  32270. name += node.raws.afterName;
  32271. } else if (params) {
  32272. name += ' ';
  32273. }
  32274. if (node.nodes) {
  32275. this.block(node, name + params);
  32276. } else {
  32277. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  32278. this.builder(name + params + end, node);
  32279. }
  32280. }
  32281. beforeAfter(node, detect) {
  32282. let value;
  32283. if (node.type === 'decl') {
  32284. value = this.raw(node, null, 'beforeDecl');
  32285. } else if (node.type === 'comment') {
  32286. value = this.raw(node, null, 'beforeComment');
  32287. } else if (detect === 'before') {
  32288. value = this.raw(node, null, 'beforeRule');
  32289. } else {
  32290. value = this.raw(node, null, 'beforeClose');
  32291. }
  32292. let buf = node.parent;
  32293. let depth = 0;
  32294. while (buf && buf.type !== 'root') {
  32295. depth += 1;
  32296. buf = buf.parent;
  32297. }
  32298. if (value.includes('\n')) {
  32299. let indent = this.raw(node, null, 'indent');
  32300. if (indent.length) {
  32301. for (let step = 0; step < depth; step++) value += indent;
  32302. }
  32303. }
  32304. return value
  32305. }
  32306. block(node, start) {
  32307. let between = this.raw(node, 'between', 'beforeOpen');
  32308. this.builder(start + between + '{', node, 'start');
  32309. let after;
  32310. if (node.nodes && node.nodes.length) {
  32311. this.body(node);
  32312. after = this.raw(node, 'after');
  32313. } else {
  32314. after = this.raw(node, 'after', 'emptyBody');
  32315. }
  32316. if (after) this.builder(after);
  32317. this.builder('}', node, 'end');
  32318. }
  32319. body(node) {
  32320. let last = node.nodes.length - 1;
  32321. while (last > 0) {
  32322. if (node.nodes[last].type !== 'comment') break
  32323. last -= 1;
  32324. }
  32325. let semicolon = this.raw(node, 'semicolon');
  32326. for (let i = 0; i < node.nodes.length; i++) {
  32327. let child = node.nodes[i];
  32328. let before = this.raw(child, 'before');
  32329. if (before) this.builder(before);
  32330. this.stringify(child, last !== i || semicolon);
  32331. }
  32332. }
  32333. comment(node) {
  32334. let left = this.raw(node, 'left', 'commentLeft');
  32335. let right = this.raw(node, 'right', 'commentRight');
  32336. this.builder('/*' + left + node.text + right + '*/', node);
  32337. }
  32338. decl(node, semicolon) {
  32339. let between = this.raw(node, 'between', 'colon');
  32340. let string = node.prop + between + this.rawValue(node, 'value');
  32341. if (node.important) {
  32342. string += node.raws.important || ' !important';
  32343. }
  32344. if (semicolon) string += ';';
  32345. this.builder(string, node);
  32346. }
  32347. document(node) {
  32348. this.body(node);
  32349. }
  32350. raw(node, own, detect) {
  32351. let value;
  32352. if (!detect) detect = own;
  32353. // Already had
  32354. if (own) {
  32355. value = node.raws[own];
  32356. if (typeof value !== 'undefined') return value
  32357. }
  32358. let parent = node.parent;
  32359. if (detect === 'before') {
  32360. // Hack for first rule in CSS
  32361. if (!parent || (parent.type === 'root' && parent.first === node)) {
  32362. return ''
  32363. }
  32364. // `root` nodes in `document` should use only their own raws
  32365. if (parent && parent.type === 'document') {
  32366. return ''
  32367. }
  32368. }
  32369. // Floating child without parent
  32370. if (!parent) return DEFAULT_RAW[detect]
  32371. // Detect style by other nodes
  32372. let root = node.root();
  32373. if (!root.rawCache) root.rawCache = {};
  32374. if (typeof root.rawCache[detect] !== 'undefined') {
  32375. return root.rawCache[detect]
  32376. }
  32377. if (detect === 'before' || detect === 'after') {
  32378. return this.beforeAfter(node, detect)
  32379. } else {
  32380. let method = 'raw' + capitalize(detect);
  32381. if (this[method]) {
  32382. value = this[method](root, node);
  32383. } else {
  32384. root.walk(i => {
  32385. value = i.raws[own];
  32386. if (typeof value !== 'undefined') return false
  32387. });
  32388. }
  32389. }
  32390. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  32391. root.rawCache[detect] = value;
  32392. return value
  32393. }
  32394. rawBeforeClose(root) {
  32395. let value;
  32396. root.walk(i => {
  32397. if (i.nodes && i.nodes.length > 0) {
  32398. if (typeof i.raws.after !== 'undefined') {
  32399. value = i.raws.after;
  32400. if (value.includes('\n')) {
  32401. value = value.replace(/[^\n]+$/, '');
  32402. }
  32403. return false
  32404. }
  32405. }
  32406. });
  32407. if (value) value = value.replace(/\S/g, '');
  32408. return value
  32409. }
  32410. rawBeforeComment(root, node) {
  32411. let value;
  32412. root.walkComments(i => {
  32413. if (typeof i.raws.before !== 'undefined') {
  32414. value = i.raws.before;
  32415. if (value.includes('\n')) {
  32416. value = value.replace(/[^\n]+$/, '');
  32417. }
  32418. return false
  32419. }
  32420. });
  32421. if (typeof value === 'undefined') {
  32422. value = this.raw(node, null, 'beforeDecl');
  32423. } else if (value) {
  32424. value = value.replace(/\S/g, '');
  32425. }
  32426. return value
  32427. }
  32428. rawBeforeDecl(root, node) {
  32429. let value;
  32430. root.walkDecls(i => {
  32431. if (typeof i.raws.before !== 'undefined') {
  32432. value = i.raws.before;
  32433. if (value.includes('\n')) {
  32434. value = value.replace(/[^\n]+$/, '');
  32435. }
  32436. return false
  32437. }
  32438. });
  32439. if (typeof value === 'undefined') {
  32440. value = this.raw(node, null, 'beforeRule');
  32441. } else if (value) {
  32442. value = value.replace(/\S/g, '');
  32443. }
  32444. return value
  32445. }
  32446. rawBeforeOpen(root) {
  32447. let value;
  32448. root.walk(i => {
  32449. if (i.type !== 'decl') {
  32450. value = i.raws.between;
  32451. if (typeof value !== 'undefined') return false
  32452. }
  32453. });
  32454. return value
  32455. }
  32456. rawBeforeRule(root) {
  32457. let value;
  32458. root.walk(i => {
  32459. if (i.nodes && (i.parent !== root || root.first !== i)) {
  32460. if (typeof i.raws.before !== 'undefined') {
  32461. value = i.raws.before;
  32462. if (value.includes('\n')) {
  32463. value = value.replace(/[^\n]+$/, '');
  32464. }
  32465. return false
  32466. }
  32467. }
  32468. });
  32469. if (value) value = value.replace(/\S/g, '');
  32470. return value
  32471. }
  32472. rawColon(root) {
  32473. let value;
  32474. root.walkDecls(i => {
  32475. if (typeof i.raws.between !== 'undefined') {
  32476. value = i.raws.between.replace(/[^\s:]/g, '');
  32477. return false
  32478. }
  32479. });
  32480. return value
  32481. }
  32482. rawEmptyBody(root) {
  32483. let value;
  32484. root.walk(i => {
  32485. if (i.nodes && i.nodes.length === 0) {
  32486. value = i.raws.after;
  32487. if (typeof value !== 'undefined') return false
  32488. }
  32489. });
  32490. return value
  32491. }
  32492. rawIndent(root) {
  32493. if (root.raws.indent) return root.raws.indent
  32494. let value;
  32495. root.walk(i => {
  32496. let p = i.parent;
  32497. if (p && p !== root && p.parent && p.parent === root) {
  32498. if (typeof i.raws.before !== 'undefined') {
  32499. let parts = i.raws.before.split('\n');
  32500. value = parts[parts.length - 1];
  32501. value = value.replace(/\S/g, '');
  32502. return false
  32503. }
  32504. }
  32505. });
  32506. return value
  32507. }
  32508. rawSemicolon(root) {
  32509. let value;
  32510. root.walk(i => {
  32511. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  32512. value = i.raws.semicolon;
  32513. if (typeof value !== 'undefined') return false
  32514. }
  32515. });
  32516. return value
  32517. }
  32518. rawValue(node, prop) {
  32519. let value = node[prop];
  32520. let raw = node.raws[prop];
  32521. if (raw && raw.value === value) {
  32522. return raw.raw
  32523. }
  32524. return value
  32525. }
  32526. root(node) {
  32527. this.body(node);
  32528. if (node.raws.after) this.builder(node.raws.after);
  32529. }
  32530. rule(node) {
  32531. this.block(node, this.rawValue(node, 'selector'));
  32532. if (node.raws.ownSemicolon) {
  32533. this.builder(node.raws.ownSemicolon, node, 'end');
  32534. }
  32535. }
  32536. stringify(node, semicolon) {
  32537. /* c8 ignore start */
  32538. if (!this[node.type]) {
  32539. throw new Error(
  32540. 'Unknown AST node type ' +
  32541. node.type +
  32542. '. ' +
  32543. 'Maybe you need to change PostCSS stringifier.'
  32544. )
  32545. }
  32546. /* c8 ignore stop */
  32547. this[node.type](node, semicolon);
  32548. }
  32549. }
  32550. stringifier = Stringifier;
  32551. Stringifier.default = Stringifier;
  32552. return stringifier;
  32553. }
  32554. var stringify_1;
  32555. var hasRequiredStringify;
  32556. function requireStringify () {
  32557. if (hasRequiredStringify) return stringify_1;
  32558. hasRequiredStringify = 1;
  32559. let Stringifier = /*@__PURE__*/ requireStringifier();
  32560. function stringify(node, builder) {
  32561. let str = new Stringifier(builder);
  32562. str.stringify(node);
  32563. }
  32564. stringify_1 = stringify;
  32565. stringify.default = stringify;
  32566. return stringify_1;
  32567. }
  32568. var symbols = {};
  32569. var hasRequiredSymbols;
  32570. function requireSymbols () {
  32571. if (hasRequiredSymbols) return symbols;
  32572. hasRequiredSymbols = 1;
  32573. symbols.isClean = Symbol('isClean');
  32574. symbols.my = Symbol('my');
  32575. return symbols;
  32576. }
  32577. var node$2;
  32578. var hasRequiredNode$2;
  32579. function requireNode$2 () {
  32580. if (hasRequiredNode$2) return node$2;
  32581. hasRequiredNode$2 = 1;
  32582. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  32583. let Stringifier = /*@__PURE__*/ requireStringifier();
  32584. let stringify = /*@__PURE__*/ requireStringify();
  32585. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  32586. function cloneNode(obj, parent) {
  32587. let cloned = new obj.constructor();
  32588. for (let i in obj) {
  32589. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  32590. /* c8 ignore next 2 */
  32591. continue
  32592. }
  32593. if (i === 'proxyCache') continue
  32594. let value = obj[i];
  32595. let type = typeof value;
  32596. if (i === 'parent' && type === 'object') {
  32597. if (parent) cloned[i] = parent;
  32598. } else if (i === 'source') {
  32599. cloned[i] = value;
  32600. } else if (Array.isArray(value)) {
  32601. cloned[i] = value.map(j => cloneNode(j, cloned));
  32602. } else {
  32603. if (type === 'object' && value !== null) value = cloneNode(value);
  32604. cloned[i] = value;
  32605. }
  32606. }
  32607. return cloned
  32608. }
  32609. class Node {
  32610. constructor(defaults = {}) {
  32611. this.raws = {};
  32612. this[isClean] = false;
  32613. this[my] = true;
  32614. for (let name in defaults) {
  32615. if (name === 'nodes') {
  32616. this.nodes = [];
  32617. for (let node of defaults[name]) {
  32618. if (typeof node.clone === 'function') {
  32619. this.append(node.clone());
  32620. } else {
  32621. this.append(node);
  32622. }
  32623. }
  32624. } else {
  32625. this[name] = defaults[name];
  32626. }
  32627. }
  32628. }
  32629. addToError(error) {
  32630. error.postcssNode = this;
  32631. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  32632. let s = this.source;
  32633. error.stack = error.stack.replace(
  32634. /\n\s{4}at /,
  32635. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  32636. );
  32637. }
  32638. return error
  32639. }
  32640. after(add) {
  32641. this.parent.insertAfter(this, add);
  32642. return this
  32643. }
  32644. assign(overrides = {}) {
  32645. for (let name in overrides) {
  32646. this[name] = overrides[name];
  32647. }
  32648. return this
  32649. }
  32650. before(add) {
  32651. this.parent.insertBefore(this, add);
  32652. return this
  32653. }
  32654. cleanRaws(keepBetween) {
  32655. delete this.raws.before;
  32656. delete this.raws.after;
  32657. if (!keepBetween) delete this.raws.between;
  32658. }
  32659. clone(overrides = {}) {
  32660. let cloned = cloneNode(this);
  32661. for (let name in overrides) {
  32662. cloned[name] = overrides[name];
  32663. }
  32664. return cloned
  32665. }
  32666. cloneAfter(overrides = {}) {
  32667. let cloned = this.clone(overrides);
  32668. this.parent.insertAfter(this, cloned);
  32669. return cloned
  32670. }
  32671. cloneBefore(overrides = {}) {
  32672. let cloned = this.clone(overrides);
  32673. this.parent.insertBefore(this, cloned);
  32674. return cloned
  32675. }
  32676. error(message, opts = {}) {
  32677. if (this.source) {
  32678. let { end, start } = this.rangeBy(opts);
  32679. return this.source.input.error(
  32680. message,
  32681. { column: start.column, line: start.line },
  32682. { column: end.column, line: end.line },
  32683. opts
  32684. )
  32685. }
  32686. return new CssSyntaxError(message)
  32687. }
  32688. getProxyProcessor() {
  32689. return {
  32690. get(node, prop) {
  32691. if (prop === 'proxyOf') {
  32692. return node
  32693. } else if (prop === 'root') {
  32694. return () => node.root().toProxy()
  32695. } else {
  32696. return node[prop]
  32697. }
  32698. },
  32699. set(node, prop, value) {
  32700. if (node[prop] === value) return true
  32701. node[prop] = value;
  32702. if (
  32703. prop === 'prop' ||
  32704. prop === 'value' ||
  32705. prop === 'name' ||
  32706. prop === 'params' ||
  32707. prop === 'important' ||
  32708. /* c8 ignore next */
  32709. prop === 'text'
  32710. ) {
  32711. node.markDirty();
  32712. }
  32713. return true
  32714. }
  32715. }
  32716. }
  32717. /* c8 ignore next 3 */
  32718. markClean() {
  32719. this[isClean] = true;
  32720. }
  32721. markDirty() {
  32722. if (this[isClean]) {
  32723. this[isClean] = false;
  32724. let next = this;
  32725. while ((next = next.parent)) {
  32726. next[isClean] = false;
  32727. }
  32728. }
  32729. }
  32730. next() {
  32731. if (!this.parent) return undefined
  32732. let index = this.parent.index(this);
  32733. return this.parent.nodes[index + 1]
  32734. }
  32735. positionBy(opts, stringRepresentation) {
  32736. let pos = this.source.start;
  32737. if (opts.index) {
  32738. pos = this.positionInside(opts.index, stringRepresentation);
  32739. } else if (opts.word) {
  32740. stringRepresentation = this.toString();
  32741. let index = stringRepresentation.indexOf(opts.word);
  32742. if (index !== -1) pos = this.positionInside(index, stringRepresentation);
  32743. }
  32744. return pos
  32745. }
  32746. positionInside(index, stringRepresentation) {
  32747. let string = stringRepresentation || this.toString();
  32748. let column = this.source.start.column;
  32749. let line = this.source.start.line;
  32750. for (let i = 0; i < index; i++) {
  32751. if (string[i] === '\n') {
  32752. column = 1;
  32753. line += 1;
  32754. } else {
  32755. column += 1;
  32756. }
  32757. }
  32758. return { column, line }
  32759. }
  32760. prev() {
  32761. if (!this.parent) return undefined
  32762. let index = this.parent.index(this);
  32763. return this.parent.nodes[index - 1]
  32764. }
  32765. rangeBy(opts) {
  32766. let start = {
  32767. column: this.source.start.column,
  32768. line: this.source.start.line
  32769. };
  32770. let end = this.source.end
  32771. ? {
  32772. column: this.source.end.column + 1,
  32773. line: this.source.end.line
  32774. }
  32775. : {
  32776. column: start.column + 1,
  32777. line: start.line
  32778. };
  32779. if (opts.word) {
  32780. let stringRepresentation = this.toString();
  32781. let index = stringRepresentation.indexOf(opts.word);
  32782. if (index !== -1) {
  32783. start = this.positionInside(index, stringRepresentation);
  32784. end = this.positionInside(
  32785. index + opts.word.length,
  32786. stringRepresentation
  32787. );
  32788. }
  32789. } else {
  32790. if (opts.start) {
  32791. start = {
  32792. column: opts.start.column,
  32793. line: opts.start.line
  32794. };
  32795. } else if (opts.index) {
  32796. start = this.positionInside(opts.index);
  32797. }
  32798. if (opts.end) {
  32799. end = {
  32800. column: opts.end.column,
  32801. line: opts.end.line
  32802. };
  32803. } else if (typeof opts.endIndex === 'number') {
  32804. end = this.positionInside(opts.endIndex);
  32805. } else if (opts.index) {
  32806. end = this.positionInside(opts.index + 1);
  32807. }
  32808. }
  32809. if (
  32810. end.line < start.line ||
  32811. (end.line === start.line && end.column <= start.column)
  32812. ) {
  32813. end = { column: start.column + 1, line: start.line };
  32814. }
  32815. return { end, start }
  32816. }
  32817. raw(prop, defaultType) {
  32818. let str = new Stringifier();
  32819. return str.raw(this, prop, defaultType)
  32820. }
  32821. remove() {
  32822. if (this.parent) {
  32823. this.parent.removeChild(this);
  32824. }
  32825. this.parent = undefined;
  32826. return this
  32827. }
  32828. replaceWith(...nodes) {
  32829. if (this.parent) {
  32830. let bookmark = this;
  32831. let foundSelf = false;
  32832. for (let node of nodes) {
  32833. if (node === this) {
  32834. foundSelf = true;
  32835. } else if (foundSelf) {
  32836. this.parent.insertAfter(bookmark, node);
  32837. bookmark = node;
  32838. } else {
  32839. this.parent.insertBefore(bookmark, node);
  32840. }
  32841. }
  32842. if (!foundSelf) {
  32843. this.remove();
  32844. }
  32845. }
  32846. return this
  32847. }
  32848. root() {
  32849. let result = this;
  32850. while (result.parent && result.parent.type !== 'document') {
  32851. result = result.parent;
  32852. }
  32853. return result
  32854. }
  32855. toJSON(_, inputs) {
  32856. let fixed = {};
  32857. let emitInputs = inputs == null;
  32858. inputs = inputs || new Map();
  32859. let inputsNextIndex = 0;
  32860. for (let name in this) {
  32861. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  32862. /* c8 ignore next 2 */
  32863. continue
  32864. }
  32865. if (name === 'parent' || name === 'proxyCache') continue
  32866. let value = this[name];
  32867. if (Array.isArray(value)) {
  32868. fixed[name] = value.map(i => {
  32869. if (typeof i === 'object' && i.toJSON) {
  32870. return i.toJSON(null, inputs)
  32871. } else {
  32872. return i
  32873. }
  32874. });
  32875. } else if (typeof value === 'object' && value.toJSON) {
  32876. fixed[name] = value.toJSON(null, inputs);
  32877. } else if (name === 'source') {
  32878. let inputId = inputs.get(value.input);
  32879. if (inputId == null) {
  32880. inputId = inputsNextIndex;
  32881. inputs.set(value.input, inputsNextIndex);
  32882. inputsNextIndex++;
  32883. }
  32884. fixed[name] = {
  32885. end: value.end,
  32886. inputId,
  32887. start: value.start
  32888. };
  32889. } else {
  32890. fixed[name] = value;
  32891. }
  32892. }
  32893. if (emitInputs) {
  32894. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  32895. }
  32896. return fixed
  32897. }
  32898. toProxy() {
  32899. if (!this.proxyCache) {
  32900. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  32901. }
  32902. return this.proxyCache
  32903. }
  32904. toString(stringifier = stringify) {
  32905. if (stringifier.stringify) stringifier = stringifier.stringify;
  32906. let result = '';
  32907. stringifier(this, i => {
  32908. result += i;
  32909. });
  32910. return result
  32911. }
  32912. warn(result, text, opts) {
  32913. let data = { node: this };
  32914. for (let i in opts) data[i] = opts[i];
  32915. return result.warn(text, data)
  32916. }
  32917. get proxyOf() {
  32918. return this
  32919. }
  32920. }
  32921. node$2 = Node;
  32922. Node.default = Node;
  32923. return node$2;
  32924. }
  32925. var comment$1;
  32926. var hasRequiredComment$1;
  32927. function requireComment$1 () {
  32928. if (hasRequiredComment$1) return comment$1;
  32929. hasRequiredComment$1 = 1;
  32930. let Node = /*@__PURE__*/ requireNode$2();
  32931. class Comment extends Node {
  32932. constructor(defaults) {
  32933. super(defaults);
  32934. this.type = 'comment';
  32935. }
  32936. }
  32937. comment$1 = Comment;
  32938. Comment.default = Comment;
  32939. return comment$1;
  32940. }
  32941. var declaration;
  32942. var hasRequiredDeclaration;
  32943. function requireDeclaration () {
  32944. if (hasRequiredDeclaration) return declaration;
  32945. hasRequiredDeclaration = 1;
  32946. let Node = /*@__PURE__*/ requireNode$2();
  32947. class Declaration extends Node {
  32948. constructor(defaults) {
  32949. if (
  32950. defaults &&
  32951. typeof defaults.value !== 'undefined' &&
  32952. typeof defaults.value !== 'string'
  32953. ) {
  32954. defaults = { ...defaults, value: String(defaults.value) };
  32955. }
  32956. super(defaults);
  32957. this.type = 'decl';
  32958. }
  32959. get variable() {
  32960. return this.prop.startsWith('--') || this.prop[0] === '$'
  32961. }
  32962. }
  32963. declaration = Declaration;
  32964. Declaration.default = Declaration;
  32965. return declaration;
  32966. }
  32967. var container$1;
  32968. var hasRequiredContainer$1;
  32969. function requireContainer$1 () {
  32970. if (hasRequiredContainer$1) return container$1;
  32971. hasRequiredContainer$1 = 1;
  32972. let Comment = /*@__PURE__*/ requireComment$1();
  32973. let Declaration = /*@__PURE__*/ requireDeclaration();
  32974. let Node = /*@__PURE__*/ requireNode$2();
  32975. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  32976. let AtRule, parse, Root, Rule;
  32977. function cleanSource(nodes) {
  32978. return nodes.map(i => {
  32979. if (i.nodes) i.nodes = cleanSource(i.nodes);
  32980. delete i.source;
  32981. return i
  32982. })
  32983. }
  32984. function markTreeDirty(node) {
  32985. node[isClean] = false;
  32986. if (node.proxyOf.nodes) {
  32987. for (let i of node.proxyOf.nodes) {
  32988. markTreeDirty(i);
  32989. }
  32990. }
  32991. }
  32992. class Container extends Node {
  32993. append(...children) {
  32994. for (let child of children) {
  32995. let nodes = this.normalize(child, this.last);
  32996. for (let node of nodes) this.proxyOf.nodes.push(node);
  32997. }
  32998. this.markDirty();
  32999. return this
  33000. }
  33001. cleanRaws(keepBetween) {
  33002. super.cleanRaws(keepBetween);
  33003. if (this.nodes) {
  33004. for (let node of this.nodes) node.cleanRaws(keepBetween);
  33005. }
  33006. }
  33007. each(callback) {
  33008. if (!this.proxyOf.nodes) return undefined
  33009. let iterator = this.getIterator();
  33010. let index, result;
  33011. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  33012. index = this.indexes[iterator];
  33013. result = callback(this.proxyOf.nodes[index], index);
  33014. if (result === false) break
  33015. this.indexes[iterator] += 1;
  33016. }
  33017. delete this.indexes[iterator];
  33018. return result
  33019. }
  33020. every(condition) {
  33021. return this.nodes.every(condition)
  33022. }
  33023. getIterator() {
  33024. if (!this.lastEach) this.lastEach = 0;
  33025. if (!this.indexes) this.indexes = {};
  33026. this.lastEach += 1;
  33027. let iterator = this.lastEach;
  33028. this.indexes[iterator] = 0;
  33029. return iterator
  33030. }
  33031. getProxyProcessor() {
  33032. return {
  33033. get(node, prop) {
  33034. if (prop === 'proxyOf') {
  33035. return node
  33036. } else if (!node[prop]) {
  33037. return node[prop]
  33038. } else if (
  33039. prop === 'each' ||
  33040. (typeof prop === 'string' && prop.startsWith('walk'))
  33041. ) {
  33042. return (...args) => {
  33043. return node[prop](
  33044. ...args.map(i => {
  33045. if (typeof i === 'function') {
  33046. return (child, index) => i(child.toProxy(), index)
  33047. } else {
  33048. return i
  33049. }
  33050. })
  33051. )
  33052. }
  33053. } else if (prop === 'every' || prop === 'some') {
  33054. return cb => {
  33055. return node[prop]((child, ...other) =>
  33056. cb(child.toProxy(), ...other)
  33057. )
  33058. }
  33059. } else if (prop === 'root') {
  33060. return () => node.root().toProxy()
  33061. } else if (prop === 'nodes') {
  33062. return node.nodes.map(i => i.toProxy())
  33063. } else if (prop === 'first' || prop === 'last') {
  33064. return node[prop].toProxy()
  33065. } else {
  33066. return node[prop]
  33067. }
  33068. },
  33069. set(node, prop, value) {
  33070. if (node[prop] === value) return true
  33071. node[prop] = value;
  33072. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  33073. node.markDirty();
  33074. }
  33075. return true
  33076. }
  33077. }
  33078. }
  33079. index(child) {
  33080. if (typeof child === 'number') return child
  33081. if (child.proxyOf) child = child.proxyOf;
  33082. return this.proxyOf.nodes.indexOf(child)
  33083. }
  33084. insertAfter(exist, add) {
  33085. let existIndex = this.index(exist);
  33086. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
  33087. existIndex = this.index(exist);
  33088. for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
  33089. let index;
  33090. for (let id in this.indexes) {
  33091. index = this.indexes[id];
  33092. if (existIndex < index) {
  33093. this.indexes[id] = index + nodes.length;
  33094. }
  33095. }
  33096. this.markDirty();
  33097. return this
  33098. }
  33099. insertBefore(exist, add) {
  33100. let existIndex = this.index(exist);
  33101. let type = existIndex === 0 ? 'prepend' : false;
  33102. let nodes = this.normalize(
  33103. add,
  33104. this.proxyOf.nodes[existIndex],
  33105. type
  33106. ).reverse();
  33107. existIndex = this.index(exist);
  33108. for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
  33109. let index;
  33110. for (let id in this.indexes) {
  33111. index = this.indexes[id];
  33112. if (existIndex <= index) {
  33113. this.indexes[id] = index + nodes.length;
  33114. }
  33115. }
  33116. this.markDirty();
  33117. return this
  33118. }
  33119. normalize(nodes, sample) {
  33120. if (typeof nodes === 'string') {
  33121. nodes = cleanSource(parse(nodes).nodes);
  33122. } else if (typeof nodes === 'undefined') {
  33123. nodes = [];
  33124. } else if (Array.isArray(nodes)) {
  33125. nodes = nodes.slice(0);
  33126. for (let i of nodes) {
  33127. if (i.parent) i.parent.removeChild(i, 'ignore');
  33128. }
  33129. } else if (nodes.type === 'root' && this.type !== 'document') {
  33130. nodes = nodes.nodes.slice(0);
  33131. for (let i of nodes) {
  33132. if (i.parent) i.parent.removeChild(i, 'ignore');
  33133. }
  33134. } else if (nodes.type) {
  33135. nodes = [nodes];
  33136. } else if (nodes.prop) {
  33137. if (typeof nodes.value === 'undefined') {
  33138. throw new Error('Value field is missed in node creation')
  33139. } else if (typeof nodes.value !== 'string') {
  33140. nodes.value = String(nodes.value);
  33141. }
  33142. nodes = [new Declaration(nodes)];
  33143. } else if (nodes.selector || nodes.selectors) {
  33144. nodes = [new Rule(nodes)];
  33145. } else if (nodes.name) {
  33146. nodes = [new AtRule(nodes)];
  33147. } else if (nodes.text) {
  33148. nodes = [new Comment(nodes)];
  33149. } else {
  33150. throw new Error('Unknown node type in node creation')
  33151. }
  33152. let processed = nodes.map(i => {
  33153. /* c8 ignore next */
  33154. if (!i[my]) Container.rebuild(i);
  33155. i = i.proxyOf;
  33156. if (i.parent) i.parent.removeChild(i);
  33157. if (i[isClean]) markTreeDirty(i);
  33158. if (!i.raws) i.raws = {};
  33159. if (typeof i.raws.before === 'undefined') {
  33160. if (sample && typeof sample.raws.before !== 'undefined') {
  33161. i.raws.before = sample.raws.before.replace(/\S/g, '');
  33162. }
  33163. }
  33164. i.parent = this.proxyOf;
  33165. return i
  33166. });
  33167. return processed
  33168. }
  33169. prepend(...children) {
  33170. children = children.reverse();
  33171. for (let child of children) {
  33172. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  33173. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  33174. for (let id in this.indexes) {
  33175. this.indexes[id] = this.indexes[id] + nodes.length;
  33176. }
  33177. }
  33178. this.markDirty();
  33179. return this
  33180. }
  33181. push(child) {
  33182. child.parent = this;
  33183. this.proxyOf.nodes.push(child);
  33184. return this
  33185. }
  33186. removeAll() {
  33187. for (let node of this.proxyOf.nodes) node.parent = undefined;
  33188. this.proxyOf.nodes = [];
  33189. this.markDirty();
  33190. return this
  33191. }
  33192. removeChild(child) {
  33193. child = this.index(child);
  33194. this.proxyOf.nodes[child].parent = undefined;
  33195. this.proxyOf.nodes.splice(child, 1);
  33196. let index;
  33197. for (let id in this.indexes) {
  33198. index = this.indexes[id];
  33199. if (index >= child) {
  33200. this.indexes[id] = index - 1;
  33201. }
  33202. }
  33203. this.markDirty();
  33204. return this
  33205. }
  33206. replaceValues(pattern, opts, callback) {
  33207. if (!callback) {
  33208. callback = opts;
  33209. opts = {};
  33210. }
  33211. this.walkDecls(decl => {
  33212. if (opts.props && !opts.props.includes(decl.prop)) return
  33213. if (opts.fast && !decl.value.includes(opts.fast)) return
  33214. decl.value = decl.value.replace(pattern, callback);
  33215. });
  33216. this.markDirty();
  33217. return this
  33218. }
  33219. some(condition) {
  33220. return this.nodes.some(condition)
  33221. }
  33222. walk(callback) {
  33223. return this.each((child, i) => {
  33224. let result;
  33225. try {
  33226. result = callback(child, i);
  33227. } catch (e) {
  33228. throw child.addToError(e)
  33229. }
  33230. if (result !== false && child.walk) {
  33231. result = child.walk(callback);
  33232. }
  33233. return result
  33234. })
  33235. }
  33236. walkAtRules(name, callback) {
  33237. if (!callback) {
  33238. callback = name;
  33239. return this.walk((child, i) => {
  33240. if (child.type === 'atrule') {
  33241. return callback(child, i)
  33242. }
  33243. })
  33244. }
  33245. if (name instanceof RegExp) {
  33246. return this.walk((child, i) => {
  33247. if (child.type === 'atrule' && name.test(child.name)) {
  33248. return callback(child, i)
  33249. }
  33250. })
  33251. }
  33252. return this.walk((child, i) => {
  33253. if (child.type === 'atrule' && child.name === name) {
  33254. return callback(child, i)
  33255. }
  33256. })
  33257. }
  33258. walkComments(callback) {
  33259. return this.walk((child, i) => {
  33260. if (child.type === 'comment') {
  33261. return callback(child, i)
  33262. }
  33263. })
  33264. }
  33265. walkDecls(prop, callback) {
  33266. if (!callback) {
  33267. callback = prop;
  33268. return this.walk((child, i) => {
  33269. if (child.type === 'decl') {
  33270. return callback(child, i)
  33271. }
  33272. })
  33273. }
  33274. if (prop instanceof RegExp) {
  33275. return this.walk((child, i) => {
  33276. if (child.type === 'decl' && prop.test(child.prop)) {
  33277. return callback(child, i)
  33278. }
  33279. })
  33280. }
  33281. return this.walk((child, i) => {
  33282. if (child.type === 'decl' && child.prop === prop) {
  33283. return callback(child, i)
  33284. }
  33285. })
  33286. }
  33287. walkRules(selector, callback) {
  33288. if (!callback) {
  33289. callback = selector;
  33290. return this.walk((child, i) => {
  33291. if (child.type === 'rule') {
  33292. return callback(child, i)
  33293. }
  33294. })
  33295. }
  33296. if (selector instanceof RegExp) {
  33297. return this.walk((child, i) => {
  33298. if (child.type === 'rule' && selector.test(child.selector)) {
  33299. return callback(child, i)
  33300. }
  33301. })
  33302. }
  33303. return this.walk((child, i) => {
  33304. if (child.type === 'rule' && child.selector === selector) {
  33305. return callback(child, i)
  33306. }
  33307. })
  33308. }
  33309. get first() {
  33310. if (!this.proxyOf.nodes) return undefined
  33311. return this.proxyOf.nodes[0]
  33312. }
  33313. get last() {
  33314. if (!this.proxyOf.nodes) return undefined
  33315. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  33316. }
  33317. }
  33318. Container.registerParse = dependant => {
  33319. parse = dependant;
  33320. };
  33321. Container.registerRule = dependant => {
  33322. Rule = dependant;
  33323. };
  33324. Container.registerAtRule = dependant => {
  33325. AtRule = dependant;
  33326. };
  33327. Container.registerRoot = dependant => {
  33328. Root = dependant;
  33329. };
  33330. container$1 = Container;
  33331. Container.default = Container;
  33332. /* c8 ignore start */
  33333. Container.rebuild = node => {
  33334. if (node.type === 'atrule') {
  33335. Object.setPrototypeOf(node, AtRule.prototype);
  33336. } else if (node.type === 'rule') {
  33337. Object.setPrototypeOf(node, Rule.prototype);
  33338. } else if (node.type === 'decl') {
  33339. Object.setPrototypeOf(node, Declaration.prototype);
  33340. } else if (node.type === 'comment') {
  33341. Object.setPrototypeOf(node, Comment.prototype);
  33342. } else if (node.type === 'root') {
  33343. Object.setPrototypeOf(node, Root.prototype);
  33344. }
  33345. node[my] = true;
  33346. if (node.nodes) {
  33347. node.nodes.forEach(child => {
  33348. Container.rebuild(child);
  33349. });
  33350. }
  33351. };
  33352. /* c8 ignore stop */
  33353. return container$1;
  33354. }
  33355. var atRule;
  33356. var hasRequiredAtRule;
  33357. function requireAtRule () {
  33358. if (hasRequiredAtRule) return atRule;
  33359. hasRequiredAtRule = 1;
  33360. let Container = /*@__PURE__*/ requireContainer$1();
  33361. class AtRule extends Container {
  33362. constructor(defaults) {
  33363. super(defaults);
  33364. this.type = 'atrule';
  33365. }
  33366. append(...children) {
  33367. if (!this.proxyOf.nodes) this.nodes = [];
  33368. return super.append(...children)
  33369. }
  33370. prepend(...children) {
  33371. if (!this.proxyOf.nodes) this.nodes = [];
  33372. return super.prepend(...children)
  33373. }
  33374. }
  33375. atRule = AtRule;
  33376. AtRule.default = AtRule;
  33377. Container.registerAtRule(AtRule);
  33378. return atRule;
  33379. }
  33380. var document;
  33381. var hasRequiredDocument;
  33382. function requireDocument () {
  33383. if (hasRequiredDocument) return document;
  33384. hasRequiredDocument = 1;
  33385. let Container = /*@__PURE__*/ requireContainer$1();
  33386. let LazyResult, Processor;
  33387. class Document extends Container {
  33388. constructor(defaults) {
  33389. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  33390. super({ type: 'document', ...defaults });
  33391. if (!this.nodes) {
  33392. this.nodes = [];
  33393. }
  33394. }
  33395. toResult(opts = {}) {
  33396. let lazy = new LazyResult(new Processor(), this, opts);
  33397. return lazy.stringify()
  33398. }
  33399. }
  33400. Document.registerLazyResult = dependant => {
  33401. LazyResult = dependant;
  33402. };
  33403. Document.registerProcessor = dependant => {
  33404. Processor = dependant;
  33405. };
  33406. document = Document;
  33407. Document.default = Document;
  33408. return document;
  33409. }
  33410. var nonSecure;
  33411. var hasRequiredNonSecure;
  33412. function requireNonSecure () {
  33413. if (hasRequiredNonSecure) return nonSecure;
  33414. hasRequiredNonSecure = 1;
  33415. let urlAlphabet =
  33416. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
  33417. let customAlphabet = (alphabet, defaultSize = 21) => {
  33418. return (size = defaultSize) => {
  33419. let id = '';
  33420. let i = size;
  33421. while (i--) {
  33422. id += alphabet[(Math.random() * alphabet.length) | 0];
  33423. }
  33424. return id
  33425. }
  33426. };
  33427. let nanoid = (size = 21) => {
  33428. let id = '';
  33429. let i = size;
  33430. while (i--) {
  33431. id += urlAlphabet[(Math.random() * 64) | 0];
  33432. }
  33433. return id
  33434. };
  33435. nonSecure = { nanoid, customAlphabet };
  33436. return nonSecure;
  33437. }
  33438. var sourceMap$1 = {};
  33439. var sourceMapGenerator$1 = {};
  33440. var base64Vlq$1 = {};
  33441. var base64$1 = {};
  33442. /* -*- Mode: js; js-indent-level: 2; -*- */
  33443. var hasRequiredBase64$1;
  33444. function requireBase64$1 () {
  33445. if (hasRequiredBase64$1) return base64$1;
  33446. hasRequiredBase64$1 = 1;
  33447. /*
  33448. * Copyright 2011 Mozilla Foundation and contributors
  33449. * Licensed under the New BSD license. See LICENSE or:
  33450. * http://opensource.org/licenses/BSD-3-Clause
  33451. */
  33452. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  33453. /**
  33454. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  33455. */
  33456. base64$1.encode = function (number) {
  33457. if (0 <= number && number < intToCharMap.length) {
  33458. return intToCharMap[number];
  33459. }
  33460. throw new TypeError("Must be between 0 and 63: " + number);
  33461. };
  33462. /**
  33463. * Decode a single base 64 character code digit to an integer. Returns -1 on
  33464. * failure.
  33465. */
  33466. base64$1.decode = function (charCode) {
  33467. var bigA = 65; // 'A'
  33468. var bigZ = 90; // 'Z'
  33469. var littleA = 97; // 'a'
  33470. var littleZ = 122; // 'z'
  33471. var zero = 48; // '0'
  33472. var nine = 57; // '9'
  33473. var plus = 43; // '+'
  33474. var slash = 47; // '/'
  33475. var littleOffset = 26;
  33476. var numberOffset = 52;
  33477. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  33478. if (bigA <= charCode && charCode <= bigZ) {
  33479. return (charCode - bigA);
  33480. }
  33481. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  33482. if (littleA <= charCode && charCode <= littleZ) {
  33483. return (charCode - littleA + littleOffset);
  33484. }
  33485. // 52 - 61: 0123456789
  33486. if (zero <= charCode && charCode <= nine) {
  33487. return (charCode - zero + numberOffset);
  33488. }
  33489. // 62: +
  33490. if (charCode == plus) {
  33491. return 62;
  33492. }
  33493. // 63: /
  33494. if (charCode == slash) {
  33495. return 63;
  33496. }
  33497. // Invalid base64 digit.
  33498. return -1;
  33499. };
  33500. return base64$1;
  33501. }
  33502. /* -*- Mode: js; js-indent-level: 2; -*- */
  33503. var hasRequiredBase64Vlq$1;
  33504. function requireBase64Vlq$1 () {
  33505. if (hasRequiredBase64Vlq$1) return base64Vlq$1;
  33506. hasRequiredBase64Vlq$1 = 1;
  33507. /*
  33508. * Copyright 2011 Mozilla Foundation and contributors
  33509. * Licensed under the New BSD license. See LICENSE or:
  33510. * http://opensource.org/licenses/BSD-3-Clause
  33511. *
  33512. * Based on the Base 64 VLQ implementation in Closure Compiler:
  33513. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  33514. *
  33515. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  33516. * Redistribution and use in source and binary forms, with or without
  33517. * modification, are permitted provided that the following conditions are
  33518. * met:
  33519. *
  33520. * * Redistributions of source code must retain the above copyright
  33521. * notice, this list of conditions and the following disclaimer.
  33522. * * Redistributions in binary form must reproduce the above
  33523. * copyright notice, this list of conditions and the following
  33524. * disclaimer in the documentation and/or other materials provided
  33525. * with the distribution.
  33526. * * Neither the name of Google Inc. nor the names of its
  33527. * contributors may be used to endorse or promote products derived
  33528. * from this software without specific prior written permission.
  33529. *
  33530. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33531. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33532. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  33533. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33534. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33535. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33536. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33537. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33538. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33539. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33540. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33541. */
  33542. var base64 = /*@__PURE__*/ requireBase64$1();
  33543. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  33544. // length quantities we use in the source map spec, the first bit is the sign,
  33545. // the next four bits are the actual value, and the 6th bit is the
  33546. // continuation bit. The continuation bit tells us whether there are more
  33547. // digits in this value following this digit.
  33548. //
  33549. // Continuation
  33550. // | Sign
  33551. // | |
  33552. // V V
  33553. // 101011
  33554. var VLQ_BASE_SHIFT = 5;
  33555. // binary: 100000
  33556. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  33557. // binary: 011111
  33558. var VLQ_BASE_MASK = VLQ_BASE - 1;
  33559. // binary: 100000
  33560. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  33561. /**
  33562. * Converts from a two-complement value to a value where the sign bit is
  33563. * placed in the least significant bit. For example, as decimals:
  33564. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  33565. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  33566. */
  33567. function toVLQSigned(aValue) {
  33568. return aValue < 0
  33569. ? ((-aValue) << 1) + 1
  33570. : (aValue << 1) + 0;
  33571. }
  33572. /**
  33573. * Converts to a two-complement value from a value where the sign bit is
  33574. * placed in the least significant bit. For example, as decimals:
  33575. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  33576. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  33577. */
  33578. function fromVLQSigned(aValue) {
  33579. var isNegative = (aValue & 1) === 1;
  33580. var shifted = aValue >> 1;
  33581. return isNegative
  33582. ? -shifted
  33583. : shifted;
  33584. }
  33585. /**
  33586. * Returns the base 64 VLQ encoded value.
  33587. */
  33588. base64Vlq$1.encode = function base64VLQ_encode(aValue) {
  33589. var encoded = "";
  33590. var digit;
  33591. var vlq = toVLQSigned(aValue);
  33592. do {
  33593. digit = vlq & VLQ_BASE_MASK;
  33594. vlq >>>= VLQ_BASE_SHIFT;
  33595. if (vlq > 0) {
  33596. // There are still more digits in this value, so we must make sure the
  33597. // continuation bit is marked.
  33598. digit |= VLQ_CONTINUATION_BIT;
  33599. }
  33600. encoded += base64.encode(digit);
  33601. } while (vlq > 0);
  33602. return encoded;
  33603. };
  33604. /**
  33605. * Decodes the next base 64 VLQ value from the given string and returns the
  33606. * value and the rest of the string via the out parameter.
  33607. */
  33608. base64Vlq$1.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  33609. var strLen = aStr.length;
  33610. var result = 0;
  33611. var shift = 0;
  33612. var continuation, digit;
  33613. do {
  33614. if (aIndex >= strLen) {
  33615. throw new Error("Expected more digits in base 64 VLQ value.");
  33616. }
  33617. digit = base64.decode(aStr.charCodeAt(aIndex++));
  33618. if (digit === -1) {
  33619. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  33620. }
  33621. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  33622. digit &= VLQ_BASE_MASK;
  33623. result = result + (digit << shift);
  33624. shift += VLQ_BASE_SHIFT;
  33625. } while (continuation);
  33626. aOutParam.value = fromVLQSigned(result);
  33627. aOutParam.rest = aIndex;
  33628. };
  33629. return base64Vlq$1;
  33630. }
  33631. var util$2 = {};
  33632. /* -*- Mode: js; js-indent-level: 2; -*- */
  33633. var hasRequiredUtil$2;
  33634. function requireUtil$2 () {
  33635. if (hasRequiredUtil$2) return util$2;
  33636. hasRequiredUtil$2 = 1;
  33637. (function (exports) {
  33638. /*
  33639. * Copyright 2011 Mozilla Foundation and contributors
  33640. * Licensed under the New BSD license. See LICENSE or:
  33641. * http://opensource.org/licenses/BSD-3-Clause
  33642. */
  33643. /**
  33644. * This is a helper function for getting values from parameter/options
  33645. * objects.
  33646. *
  33647. * @param args The object we are extracting values from
  33648. * @param name The name of the property we are getting.
  33649. * @param defaultValue An optional value to return if the property is missing
  33650. * from the object. If this is not specified and the property is missing, an
  33651. * error will be thrown.
  33652. */
  33653. function getArg(aArgs, aName, aDefaultValue) {
  33654. if (aName in aArgs) {
  33655. return aArgs[aName];
  33656. } else if (arguments.length === 3) {
  33657. return aDefaultValue;
  33658. } else {
  33659. throw new Error('"' + aName + '" is a required argument.');
  33660. }
  33661. }
  33662. exports.getArg = getArg;
  33663. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  33664. var dataUrlRegexp = /^data:.+\,.+$/;
  33665. function urlParse(aUrl) {
  33666. var match = aUrl.match(urlRegexp);
  33667. if (!match) {
  33668. return null;
  33669. }
  33670. return {
  33671. scheme: match[1],
  33672. auth: match[2],
  33673. host: match[3],
  33674. port: match[4],
  33675. path: match[5]
  33676. };
  33677. }
  33678. exports.urlParse = urlParse;
  33679. function urlGenerate(aParsedUrl) {
  33680. var url = '';
  33681. if (aParsedUrl.scheme) {
  33682. url += aParsedUrl.scheme + ':';
  33683. }
  33684. url += '//';
  33685. if (aParsedUrl.auth) {
  33686. url += aParsedUrl.auth + '@';
  33687. }
  33688. if (aParsedUrl.host) {
  33689. url += aParsedUrl.host;
  33690. }
  33691. if (aParsedUrl.port) {
  33692. url += ":" + aParsedUrl.port;
  33693. }
  33694. if (aParsedUrl.path) {
  33695. url += aParsedUrl.path;
  33696. }
  33697. return url;
  33698. }
  33699. exports.urlGenerate = urlGenerate;
  33700. var MAX_CACHED_INPUTS = 32;
  33701. /**
  33702. * Takes some function `f(input) -> result` and returns a memoized version of
  33703. * `f`.
  33704. *
  33705. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  33706. * memoization is a dumb-simple, linear least-recently-used cache.
  33707. */
  33708. function lruMemoize(f) {
  33709. var cache = [];
  33710. return function(input) {
  33711. for (var i = 0; i < cache.length; i++) {
  33712. if (cache[i].input === input) {
  33713. var temp = cache[0];
  33714. cache[0] = cache[i];
  33715. cache[i] = temp;
  33716. return cache[0].result;
  33717. }
  33718. }
  33719. var result = f(input);
  33720. cache.unshift({
  33721. input,
  33722. result,
  33723. });
  33724. if (cache.length > MAX_CACHED_INPUTS) {
  33725. cache.pop();
  33726. }
  33727. return result;
  33728. };
  33729. }
  33730. /**
  33731. * Normalizes a path, or the path portion of a URL:
  33732. *
  33733. * - Replaces consecutive slashes with one slash.
  33734. * - Removes unnecessary '.' parts.
  33735. * - Removes unnecessary '<dir>/..' parts.
  33736. *
  33737. * Based on code in the Node.js 'path' core module.
  33738. *
  33739. * @param aPath The path or url to normalize.
  33740. */
  33741. var normalize = lruMemoize(function normalize(aPath) {
  33742. var path = aPath;
  33743. var url = urlParse(aPath);
  33744. if (url) {
  33745. if (!url.path) {
  33746. return aPath;
  33747. }
  33748. path = url.path;
  33749. }
  33750. var isAbsolute = exports.isAbsolute(path);
  33751. // Split the path into parts between `/` characters. This is much faster than
  33752. // using `.split(/\/+/g)`.
  33753. var parts = [];
  33754. var start = 0;
  33755. var i = 0;
  33756. while (true) {
  33757. start = i;
  33758. i = path.indexOf("/", start);
  33759. if (i === -1) {
  33760. parts.push(path.slice(start));
  33761. break;
  33762. } else {
  33763. parts.push(path.slice(start, i));
  33764. while (i < path.length && path[i] === "/") {
  33765. i++;
  33766. }
  33767. }
  33768. }
  33769. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  33770. part = parts[i];
  33771. if (part === '.') {
  33772. parts.splice(i, 1);
  33773. } else if (part === '..') {
  33774. up++;
  33775. } else if (up > 0) {
  33776. if (part === '') {
  33777. // The first part is blank if the path is absolute. Trying to go
  33778. // above the root is a no-op. Therefore we can remove all '..' parts
  33779. // directly after the root.
  33780. parts.splice(i + 1, up);
  33781. up = 0;
  33782. } else {
  33783. parts.splice(i, 2);
  33784. up--;
  33785. }
  33786. }
  33787. }
  33788. path = parts.join('/');
  33789. if (path === '') {
  33790. path = isAbsolute ? '/' : '.';
  33791. }
  33792. if (url) {
  33793. url.path = path;
  33794. return urlGenerate(url);
  33795. }
  33796. return path;
  33797. });
  33798. exports.normalize = normalize;
  33799. /**
  33800. * Joins two paths/URLs.
  33801. *
  33802. * @param aRoot The root path or URL.
  33803. * @param aPath The path or URL to be joined with the root.
  33804. *
  33805. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  33806. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  33807. * first.
  33808. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  33809. * is updated with the result and aRoot is returned. Otherwise the result
  33810. * is returned.
  33811. * - If aPath is absolute, the result is aPath.
  33812. * - Otherwise the two paths are joined with a slash.
  33813. * - Joining for example 'http://' and 'www.example.com' is also supported.
  33814. */
  33815. function join(aRoot, aPath) {
  33816. if (aRoot === "") {
  33817. aRoot = ".";
  33818. }
  33819. if (aPath === "") {
  33820. aPath = ".";
  33821. }
  33822. var aPathUrl = urlParse(aPath);
  33823. var aRootUrl = urlParse(aRoot);
  33824. if (aRootUrl) {
  33825. aRoot = aRootUrl.path || '/';
  33826. }
  33827. // `join(foo, '//www.example.org')`
  33828. if (aPathUrl && !aPathUrl.scheme) {
  33829. if (aRootUrl) {
  33830. aPathUrl.scheme = aRootUrl.scheme;
  33831. }
  33832. return urlGenerate(aPathUrl);
  33833. }
  33834. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  33835. return aPath;
  33836. }
  33837. // `join('http://', 'www.example.com')`
  33838. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  33839. aRootUrl.host = aPath;
  33840. return urlGenerate(aRootUrl);
  33841. }
  33842. var joined = aPath.charAt(0) === '/'
  33843. ? aPath
  33844. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  33845. if (aRootUrl) {
  33846. aRootUrl.path = joined;
  33847. return urlGenerate(aRootUrl);
  33848. }
  33849. return joined;
  33850. }
  33851. exports.join = join;
  33852. exports.isAbsolute = function (aPath) {
  33853. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  33854. };
  33855. /**
  33856. * Make a path relative to a URL or another path.
  33857. *
  33858. * @param aRoot The root path or URL.
  33859. * @param aPath The path or URL to be made relative to aRoot.
  33860. */
  33861. function relative(aRoot, aPath) {
  33862. if (aRoot === "") {
  33863. aRoot = ".";
  33864. }
  33865. aRoot = aRoot.replace(/\/$/, '');
  33866. // It is possible for the path to be above the root. In this case, simply
  33867. // checking whether the root is a prefix of the path won't work. Instead, we
  33868. // need to remove components from the root one by one, until either we find
  33869. // a prefix that fits, or we run out of components to remove.
  33870. var level = 0;
  33871. while (aPath.indexOf(aRoot + '/') !== 0) {
  33872. var index = aRoot.lastIndexOf("/");
  33873. if (index < 0) {
  33874. return aPath;
  33875. }
  33876. // If the only part of the root that is left is the scheme (i.e. http://,
  33877. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  33878. // have exhausted all components, so the path is not relative to the root.
  33879. aRoot = aRoot.slice(0, index);
  33880. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  33881. return aPath;
  33882. }
  33883. ++level;
  33884. }
  33885. // Make sure we add a "../" for each component we removed from the root.
  33886. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  33887. }
  33888. exports.relative = relative;
  33889. var supportsNullProto = (function () {
  33890. var obj = Object.create(null);
  33891. return !('__proto__' in obj);
  33892. }());
  33893. function identity (s) {
  33894. return s;
  33895. }
  33896. /**
  33897. * Because behavior goes wacky when you set `__proto__` on objects, we
  33898. * have to prefix all the strings in our set with an arbitrary character.
  33899. *
  33900. * See https://github.com/mozilla/source-map/pull/31 and
  33901. * https://github.com/mozilla/source-map/issues/30
  33902. *
  33903. * @param String aStr
  33904. */
  33905. function toSetString(aStr) {
  33906. if (isProtoString(aStr)) {
  33907. return '$' + aStr;
  33908. }
  33909. return aStr;
  33910. }
  33911. exports.toSetString = supportsNullProto ? identity : toSetString;
  33912. function fromSetString(aStr) {
  33913. if (isProtoString(aStr)) {
  33914. return aStr.slice(1);
  33915. }
  33916. return aStr;
  33917. }
  33918. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  33919. function isProtoString(s) {
  33920. if (!s) {
  33921. return false;
  33922. }
  33923. var length = s.length;
  33924. if (length < 9 /* "__proto__".length */) {
  33925. return false;
  33926. }
  33927. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  33928. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  33929. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  33930. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  33931. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  33932. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  33933. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  33934. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  33935. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  33936. return false;
  33937. }
  33938. for (var i = length - 10; i >= 0; i--) {
  33939. if (s.charCodeAt(i) !== 36 /* '$' */) {
  33940. return false;
  33941. }
  33942. }
  33943. return true;
  33944. }
  33945. /**
  33946. * Comparator between two mappings where the original positions are compared.
  33947. *
  33948. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  33949. * mappings with the same original source/line/column, but different generated
  33950. * line and column the same. Useful when searching for a mapping with a
  33951. * stubbed out mapping.
  33952. */
  33953. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  33954. var cmp = strcmp(mappingA.source, mappingB.source);
  33955. if (cmp !== 0) {
  33956. return cmp;
  33957. }
  33958. cmp = mappingA.originalLine - mappingB.originalLine;
  33959. if (cmp !== 0) {
  33960. return cmp;
  33961. }
  33962. cmp = mappingA.originalColumn - mappingB.originalColumn;
  33963. if (cmp !== 0 || onlyCompareOriginal) {
  33964. return cmp;
  33965. }
  33966. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  33967. if (cmp !== 0) {
  33968. return cmp;
  33969. }
  33970. cmp = mappingA.generatedLine - mappingB.generatedLine;
  33971. if (cmp !== 0) {
  33972. return cmp;
  33973. }
  33974. return strcmp(mappingA.name, mappingB.name);
  33975. }
  33976. exports.compareByOriginalPositions = compareByOriginalPositions;
  33977. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  33978. var cmp;
  33979. cmp = mappingA.originalLine - mappingB.originalLine;
  33980. if (cmp !== 0) {
  33981. return cmp;
  33982. }
  33983. cmp = mappingA.originalColumn - mappingB.originalColumn;
  33984. if (cmp !== 0 || onlyCompareOriginal) {
  33985. return cmp;
  33986. }
  33987. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  33988. if (cmp !== 0) {
  33989. return cmp;
  33990. }
  33991. cmp = mappingA.generatedLine - mappingB.generatedLine;
  33992. if (cmp !== 0) {
  33993. return cmp;
  33994. }
  33995. return strcmp(mappingA.name, mappingB.name);
  33996. }
  33997. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  33998. /**
  33999. * Comparator between two mappings with deflated source and name indices where
  34000. * the generated positions are compared.
  34001. *
  34002. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  34003. * mappings with the same generated line and column, but different
  34004. * source/name/original line and column the same. Useful when searching for a
  34005. * mapping with a stubbed out mapping.
  34006. */
  34007. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  34008. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  34009. if (cmp !== 0) {
  34010. return cmp;
  34011. }
  34012. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  34013. if (cmp !== 0 || onlyCompareGenerated) {
  34014. return cmp;
  34015. }
  34016. cmp = strcmp(mappingA.source, mappingB.source);
  34017. if (cmp !== 0) {
  34018. return cmp;
  34019. }
  34020. cmp = mappingA.originalLine - mappingB.originalLine;
  34021. if (cmp !== 0) {
  34022. return cmp;
  34023. }
  34024. cmp = mappingA.originalColumn - mappingB.originalColumn;
  34025. if (cmp !== 0) {
  34026. return cmp;
  34027. }
  34028. return strcmp(mappingA.name, mappingB.name);
  34029. }
  34030. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  34031. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  34032. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  34033. if (cmp !== 0 || onlyCompareGenerated) {
  34034. return cmp;
  34035. }
  34036. cmp = strcmp(mappingA.source, mappingB.source);
  34037. if (cmp !== 0) {
  34038. return cmp;
  34039. }
  34040. cmp = mappingA.originalLine - mappingB.originalLine;
  34041. if (cmp !== 0) {
  34042. return cmp;
  34043. }
  34044. cmp = mappingA.originalColumn - mappingB.originalColumn;
  34045. if (cmp !== 0) {
  34046. return cmp;
  34047. }
  34048. return strcmp(mappingA.name, mappingB.name);
  34049. }
  34050. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  34051. function strcmp(aStr1, aStr2) {
  34052. if (aStr1 === aStr2) {
  34053. return 0;
  34054. }
  34055. if (aStr1 === null) {
  34056. return 1; // aStr2 !== null
  34057. }
  34058. if (aStr2 === null) {
  34059. return -1; // aStr1 !== null
  34060. }
  34061. if (aStr1 > aStr2) {
  34062. return 1;
  34063. }
  34064. return -1;
  34065. }
  34066. /**
  34067. * Comparator between two mappings with inflated source and name strings where
  34068. * the generated positions are compared.
  34069. */
  34070. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  34071. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  34072. if (cmp !== 0) {
  34073. return cmp;
  34074. }
  34075. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  34076. if (cmp !== 0) {
  34077. return cmp;
  34078. }
  34079. cmp = strcmp(mappingA.source, mappingB.source);
  34080. if (cmp !== 0) {
  34081. return cmp;
  34082. }
  34083. cmp = mappingA.originalLine - mappingB.originalLine;
  34084. if (cmp !== 0) {
  34085. return cmp;
  34086. }
  34087. cmp = mappingA.originalColumn - mappingB.originalColumn;
  34088. if (cmp !== 0) {
  34089. return cmp;
  34090. }
  34091. return strcmp(mappingA.name, mappingB.name);
  34092. }
  34093. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  34094. /**
  34095. * Strip any JSON XSSI avoidance prefix from the string (as documented
  34096. * in the source maps specification), and then parse the string as
  34097. * JSON.
  34098. */
  34099. function parseSourceMapInput(str) {
  34100. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  34101. }
  34102. exports.parseSourceMapInput = parseSourceMapInput;
  34103. /**
  34104. * Compute the URL of a source given the the source root, the source's
  34105. * URL, and the source map's URL.
  34106. */
  34107. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  34108. sourceURL = sourceURL || '';
  34109. if (sourceRoot) {
  34110. // This follows what Chrome does.
  34111. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  34112. sourceRoot += '/';
  34113. }
  34114. // The spec says:
  34115. // Line 4: An optional source root, useful for relocating source
  34116. // files on a server or removing repeated values in the
  34117. // “sources” entry. This value is prepended to the individual
  34118. // entries in the “source” field.
  34119. sourceURL = sourceRoot + sourceURL;
  34120. }
  34121. // Historically, SourceMapConsumer did not take the sourceMapURL as
  34122. // a parameter. This mode is still somewhat supported, which is why
  34123. // this code block is conditional. However, it's preferable to pass
  34124. // the source map URL to SourceMapConsumer, so that this function
  34125. // can implement the source URL resolution algorithm as outlined in
  34126. // the spec. This block is basically the equivalent of:
  34127. // new URL(sourceURL, sourceMapURL).toString()
  34128. // ... except it avoids using URL, which wasn't available in the
  34129. // older releases of node still supported by this library.
  34130. //
  34131. // The spec says:
  34132. // If the sources are not absolute URLs after prepending of the
  34133. // “sourceRoot”, the sources are resolved relative to the
  34134. // SourceMap (like resolving script src in a html document).
  34135. if (sourceMapURL) {
  34136. var parsed = urlParse(sourceMapURL);
  34137. if (!parsed) {
  34138. throw new Error("sourceMapURL could not be parsed");
  34139. }
  34140. if (parsed.path) {
  34141. // Strip the last path component, but keep the "/".
  34142. var index = parsed.path.lastIndexOf('/');
  34143. if (index >= 0) {
  34144. parsed.path = parsed.path.substring(0, index + 1);
  34145. }
  34146. }
  34147. sourceURL = join(urlGenerate(parsed), sourceURL);
  34148. }
  34149. return normalize(sourceURL);
  34150. }
  34151. exports.computeSourceURL = computeSourceURL;
  34152. } (util$2));
  34153. return util$2;
  34154. }
  34155. var arraySet$1 = {};
  34156. /* -*- Mode: js; js-indent-level: 2; -*- */
  34157. var hasRequiredArraySet$1;
  34158. function requireArraySet$1 () {
  34159. if (hasRequiredArraySet$1) return arraySet$1;
  34160. hasRequiredArraySet$1 = 1;
  34161. /*
  34162. * Copyright 2011 Mozilla Foundation and contributors
  34163. * Licensed under the New BSD license. See LICENSE or:
  34164. * http://opensource.org/licenses/BSD-3-Clause
  34165. */
  34166. var util = /*@__PURE__*/ requireUtil$2();
  34167. var has = Object.prototype.hasOwnProperty;
  34168. var hasNativeMap = typeof Map !== "undefined";
  34169. /**
  34170. * A data structure which is a combination of an array and a set. Adding a new
  34171. * member is O(1), testing for membership is O(1), and finding the index of an
  34172. * element is O(1). Removing elements from the set is not supported. Only
  34173. * strings are supported for membership.
  34174. */
  34175. function ArraySet() {
  34176. this._array = [];
  34177. this._set = hasNativeMap ? new Map() : Object.create(null);
  34178. }
  34179. /**
  34180. * Static method for creating ArraySet instances from an existing array.
  34181. */
  34182. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  34183. var set = new ArraySet();
  34184. for (var i = 0, len = aArray.length; i < len; i++) {
  34185. set.add(aArray[i], aAllowDuplicates);
  34186. }
  34187. return set;
  34188. };
  34189. /**
  34190. * Return how many unique items are in this ArraySet. If duplicates have been
  34191. * added, than those do not count towards the size.
  34192. *
  34193. * @returns Number
  34194. */
  34195. ArraySet.prototype.size = function ArraySet_size() {
  34196. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  34197. };
  34198. /**
  34199. * Add the given string to this set.
  34200. *
  34201. * @param String aStr
  34202. */
  34203. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  34204. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  34205. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  34206. var idx = this._array.length;
  34207. if (!isDuplicate || aAllowDuplicates) {
  34208. this._array.push(aStr);
  34209. }
  34210. if (!isDuplicate) {
  34211. if (hasNativeMap) {
  34212. this._set.set(aStr, idx);
  34213. } else {
  34214. this._set[sStr] = idx;
  34215. }
  34216. }
  34217. };
  34218. /**
  34219. * Is the given string a member of this set?
  34220. *
  34221. * @param String aStr
  34222. */
  34223. ArraySet.prototype.has = function ArraySet_has(aStr) {
  34224. if (hasNativeMap) {
  34225. return this._set.has(aStr);
  34226. } else {
  34227. var sStr = util.toSetString(aStr);
  34228. return has.call(this._set, sStr);
  34229. }
  34230. };
  34231. /**
  34232. * What is the index of the given string in the array?
  34233. *
  34234. * @param String aStr
  34235. */
  34236. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  34237. if (hasNativeMap) {
  34238. var idx = this._set.get(aStr);
  34239. if (idx >= 0) {
  34240. return idx;
  34241. }
  34242. } else {
  34243. var sStr = util.toSetString(aStr);
  34244. if (has.call(this._set, sStr)) {
  34245. return this._set[sStr];
  34246. }
  34247. }
  34248. throw new Error('"' + aStr + '" is not in the set.');
  34249. };
  34250. /**
  34251. * What is the element at the given index?
  34252. *
  34253. * @param Number aIdx
  34254. */
  34255. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  34256. if (aIdx >= 0 && aIdx < this._array.length) {
  34257. return this._array[aIdx];
  34258. }
  34259. throw new Error('No element indexed by ' + aIdx);
  34260. };
  34261. /**
  34262. * Returns the array representation of this set (which has the proper indices
  34263. * indicated by indexOf). Note that this is a copy of the internal array used
  34264. * for storing the members so that no one can mess with internal state.
  34265. */
  34266. ArraySet.prototype.toArray = function ArraySet_toArray() {
  34267. return this._array.slice();
  34268. };
  34269. arraySet$1.ArraySet = ArraySet;
  34270. return arraySet$1;
  34271. }
  34272. var mappingList$1 = {};
  34273. /* -*- Mode: js; js-indent-level: 2; -*- */
  34274. var hasRequiredMappingList$1;
  34275. function requireMappingList$1 () {
  34276. if (hasRequiredMappingList$1) return mappingList$1;
  34277. hasRequiredMappingList$1 = 1;
  34278. /*
  34279. * Copyright 2014 Mozilla Foundation and contributors
  34280. * Licensed under the New BSD license. See LICENSE or:
  34281. * http://opensource.org/licenses/BSD-3-Clause
  34282. */
  34283. var util = /*@__PURE__*/ requireUtil$2();
  34284. /**
  34285. * Determine whether mappingB is after mappingA with respect to generated
  34286. * position.
  34287. */
  34288. function generatedPositionAfter(mappingA, mappingB) {
  34289. // Optimized for most common case
  34290. var lineA = mappingA.generatedLine;
  34291. var lineB = mappingB.generatedLine;
  34292. var columnA = mappingA.generatedColumn;
  34293. var columnB = mappingB.generatedColumn;
  34294. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  34295. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  34296. }
  34297. /**
  34298. * A data structure to provide a sorted view of accumulated mappings in a
  34299. * performance conscious manner. It trades a neglibable overhead in general
  34300. * case for a large speedup in case of mappings being added in order.
  34301. */
  34302. function MappingList() {
  34303. this._array = [];
  34304. this._sorted = true;
  34305. // Serves as infimum
  34306. this._last = {generatedLine: -1, generatedColumn: 0};
  34307. }
  34308. /**
  34309. * Iterate through internal items. This method takes the same arguments that
  34310. * `Array.prototype.forEach` takes.
  34311. *
  34312. * NOTE: The order of the mappings is NOT guaranteed.
  34313. */
  34314. MappingList.prototype.unsortedForEach =
  34315. function MappingList_forEach(aCallback, aThisArg) {
  34316. this._array.forEach(aCallback, aThisArg);
  34317. };
  34318. /**
  34319. * Add the given source mapping.
  34320. *
  34321. * @param Object aMapping
  34322. */
  34323. MappingList.prototype.add = function MappingList_add(aMapping) {
  34324. if (generatedPositionAfter(this._last, aMapping)) {
  34325. this._last = aMapping;
  34326. this._array.push(aMapping);
  34327. } else {
  34328. this._sorted = false;
  34329. this._array.push(aMapping);
  34330. }
  34331. };
  34332. /**
  34333. * Returns the flat, sorted array of mappings. The mappings are sorted by
  34334. * generated position.
  34335. *
  34336. * WARNING: This method returns internal data without copying, for
  34337. * performance. The return value must NOT be mutated, and should be treated as
  34338. * an immutable borrow. If you want to take ownership, you must make your own
  34339. * copy.
  34340. */
  34341. MappingList.prototype.toArray = function MappingList_toArray() {
  34342. if (!this._sorted) {
  34343. this._array.sort(util.compareByGeneratedPositionsInflated);
  34344. this._sorted = true;
  34345. }
  34346. return this._array;
  34347. };
  34348. mappingList$1.MappingList = MappingList;
  34349. return mappingList$1;
  34350. }
  34351. /* -*- Mode: js; js-indent-level: 2; -*- */
  34352. var hasRequiredSourceMapGenerator$1;
  34353. function requireSourceMapGenerator$1 () {
  34354. if (hasRequiredSourceMapGenerator$1) return sourceMapGenerator$1;
  34355. hasRequiredSourceMapGenerator$1 = 1;
  34356. /*
  34357. * Copyright 2011 Mozilla Foundation and contributors
  34358. * Licensed under the New BSD license. See LICENSE or:
  34359. * http://opensource.org/licenses/BSD-3-Clause
  34360. */
  34361. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$1();
  34362. var util = /*@__PURE__*/ requireUtil$2();
  34363. var ArraySet = /*@__PURE__*/ requireArraySet$1().ArraySet;
  34364. var MappingList = /*@__PURE__*/ requireMappingList$1().MappingList;
  34365. /**
  34366. * An instance of the SourceMapGenerator represents a source map which is
  34367. * being built incrementally. You may pass an object with the following
  34368. * properties:
  34369. *
  34370. * - file: The filename of the generated source.
  34371. * - sourceRoot: A root for all relative URLs in this source map.
  34372. */
  34373. function SourceMapGenerator(aArgs) {
  34374. if (!aArgs) {
  34375. aArgs = {};
  34376. }
  34377. this._file = util.getArg(aArgs, 'file', null);
  34378. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  34379. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  34380. this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
  34381. this._sources = new ArraySet();
  34382. this._names = new ArraySet();
  34383. this._mappings = new MappingList();
  34384. this._sourcesContents = null;
  34385. }
  34386. SourceMapGenerator.prototype._version = 3;
  34387. /**
  34388. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  34389. *
  34390. * @param aSourceMapConsumer The SourceMap.
  34391. */
  34392. SourceMapGenerator.fromSourceMap =
  34393. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  34394. var sourceRoot = aSourceMapConsumer.sourceRoot;
  34395. var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
  34396. file: aSourceMapConsumer.file,
  34397. sourceRoot: sourceRoot
  34398. }));
  34399. aSourceMapConsumer.eachMapping(function (mapping) {
  34400. var newMapping = {
  34401. generated: {
  34402. line: mapping.generatedLine,
  34403. column: mapping.generatedColumn
  34404. }
  34405. };
  34406. if (mapping.source != null) {
  34407. newMapping.source = mapping.source;
  34408. if (sourceRoot != null) {
  34409. newMapping.source = util.relative(sourceRoot, newMapping.source);
  34410. }
  34411. newMapping.original = {
  34412. line: mapping.originalLine,
  34413. column: mapping.originalColumn
  34414. };
  34415. if (mapping.name != null) {
  34416. newMapping.name = mapping.name;
  34417. }
  34418. }
  34419. generator.addMapping(newMapping);
  34420. });
  34421. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  34422. var sourceRelative = sourceFile;
  34423. if (sourceRoot !== null) {
  34424. sourceRelative = util.relative(sourceRoot, sourceFile);
  34425. }
  34426. if (!generator._sources.has(sourceRelative)) {
  34427. generator._sources.add(sourceRelative);
  34428. }
  34429. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  34430. if (content != null) {
  34431. generator.setSourceContent(sourceFile, content);
  34432. }
  34433. });
  34434. return generator;
  34435. };
  34436. /**
  34437. * Add a single mapping from original source line and column to the generated
  34438. * source's line and column for this source map being created. The mapping
  34439. * object should have the following properties:
  34440. *
  34441. * - generated: An object with the generated line and column positions.
  34442. * - original: An object with the original line and column positions.
  34443. * - source: The original source file (relative to the sourceRoot).
  34444. * - name: An optional original token name for this mapping.
  34445. */
  34446. SourceMapGenerator.prototype.addMapping =
  34447. function SourceMapGenerator_addMapping(aArgs) {
  34448. var generated = util.getArg(aArgs, 'generated');
  34449. var original = util.getArg(aArgs, 'original', null);
  34450. var source = util.getArg(aArgs, 'source', null);
  34451. var name = util.getArg(aArgs, 'name', null);
  34452. if (!this._skipValidation) {
  34453. if (this._validateMapping(generated, original, source, name) === false) {
  34454. return;
  34455. }
  34456. }
  34457. if (source != null) {
  34458. source = String(source);
  34459. if (!this._sources.has(source)) {
  34460. this._sources.add(source);
  34461. }
  34462. }
  34463. if (name != null) {
  34464. name = String(name);
  34465. if (!this._names.has(name)) {
  34466. this._names.add(name);
  34467. }
  34468. }
  34469. this._mappings.add({
  34470. generatedLine: generated.line,
  34471. generatedColumn: generated.column,
  34472. originalLine: original != null && original.line,
  34473. originalColumn: original != null && original.column,
  34474. source: source,
  34475. name: name
  34476. });
  34477. };
  34478. /**
  34479. * Set the source content for a source file.
  34480. */
  34481. SourceMapGenerator.prototype.setSourceContent =
  34482. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  34483. var source = aSourceFile;
  34484. if (this._sourceRoot != null) {
  34485. source = util.relative(this._sourceRoot, source);
  34486. }
  34487. if (aSourceContent != null) {
  34488. // Add the source content to the _sourcesContents map.
  34489. // Create a new _sourcesContents map if the property is null.
  34490. if (!this._sourcesContents) {
  34491. this._sourcesContents = Object.create(null);
  34492. }
  34493. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  34494. } else if (this._sourcesContents) {
  34495. // Remove the source file from the _sourcesContents map.
  34496. // If the _sourcesContents map is empty, set the property to null.
  34497. delete this._sourcesContents[util.toSetString(source)];
  34498. if (Object.keys(this._sourcesContents).length === 0) {
  34499. this._sourcesContents = null;
  34500. }
  34501. }
  34502. };
  34503. /**
  34504. * Applies the mappings of a sub-source-map for a specific source file to the
  34505. * source map being generated. Each mapping to the supplied source file is
  34506. * rewritten using the supplied source map. Note: The resolution for the
  34507. * resulting mappings is the minimium of this map and the supplied map.
  34508. *
  34509. * @param aSourceMapConsumer The source map to be applied.
  34510. * @param aSourceFile Optional. The filename of the source file.
  34511. * If omitted, SourceMapConsumer's file property will be used.
  34512. * @param aSourceMapPath Optional. The dirname of the path to the source map
  34513. * to be applied. If relative, it is relative to the SourceMapConsumer.
  34514. * This parameter is needed when the two source maps aren't in the same
  34515. * directory, and the source map to be applied contains relative source
  34516. * paths. If so, those relative source paths need to be rewritten
  34517. * relative to the SourceMapGenerator.
  34518. */
  34519. SourceMapGenerator.prototype.applySourceMap =
  34520. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  34521. var sourceFile = aSourceFile;
  34522. // If aSourceFile is omitted, we will use the file property of the SourceMap
  34523. if (aSourceFile == null) {
  34524. if (aSourceMapConsumer.file == null) {
  34525. throw new Error(
  34526. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  34527. 'or the source map\'s "file" property. Both were omitted.'
  34528. );
  34529. }
  34530. sourceFile = aSourceMapConsumer.file;
  34531. }
  34532. var sourceRoot = this._sourceRoot;
  34533. // Make "sourceFile" relative if an absolute Url is passed.
  34534. if (sourceRoot != null) {
  34535. sourceFile = util.relative(sourceRoot, sourceFile);
  34536. }
  34537. // Applying the SourceMap can add and remove items from the sources and
  34538. // the names array.
  34539. var newSources = new ArraySet();
  34540. var newNames = new ArraySet();
  34541. // Find mappings for the "sourceFile"
  34542. this._mappings.unsortedForEach(function (mapping) {
  34543. if (mapping.source === sourceFile && mapping.originalLine != null) {
  34544. // Check if it can be mapped by the source map, then update the mapping.
  34545. var original = aSourceMapConsumer.originalPositionFor({
  34546. line: mapping.originalLine,
  34547. column: mapping.originalColumn
  34548. });
  34549. if (original.source != null) {
  34550. // Copy mapping
  34551. mapping.source = original.source;
  34552. if (aSourceMapPath != null) {
  34553. mapping.source = util.join(aSourceMapPath, mapping.source);
  34554. }
  34555. if (sourceRoot != null) {
  34556. mapping.source = util.relative(sourceRoot, mapping.source);
  34557. }
  34558. mapping.originalLine = original.line;
  34559. mapping.originalColumn = original.column;
  34560. if (original.name != null) {
  34561. mapping.name = original.name;
  34562. }
  34563. }
  34564. }
  34565. var source = mapping.source;
  34566. if (source != null && !newSources.has(source)) {
  34567. newSources.add(source);
  34568. }
  34569. var name = mapping.name;
  34570. if (name != null && !newNames.has(name)) {
  34571. newNames.add(name);
  34572. }
  34573. }, this);
  34574. this._sources = newSources;
  34575. this._names = newNames;
  34576. // Copy sourcesContents of applied map.
  34577. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  34578. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  34579. if (content != null) {
  34580. if (aSourceMapPath != null) {
  34581. sourceFile = util.join(aSourceMapPath, sourceFile);
  34582. }
  34583. if (sourceRoot != null) {
  34584. sourceFile = util.relative(sourceRoot, sourceFile);
  34585. }
  34586. this.setSourceContent(sourceFile, content);
  34587. }
  34588. }, this);
  34589. };
  34590. /**
  34591. * A mapping can have one of the three levels of data:
  34592. *
  34593. * 1. Just the generated position.
  34594. * 2. The Generated position, original position, and original source.
  34595. * 3. Generated and original position, original source, as well as a name
  34596. * token.
  34597. *
  34598. * To maintain consistency, we validate that any new mapping being added falls
  34599. * in to one of these categories.
  34600. */
  34601. SourceMapGenerator.prototype._validateMapping =
  34602. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  34603. aName) {
  34604. // When aOriginal is truthy but has empty values for .line and .column,
  34605. // it is most likely a programmer error. In this case we throw a very
  34606. // specific error message to try to guide them the right way.
  34607. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  34608. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  34609. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  34610. 'the original mapping entirely and only map the generated position. If so, pass ' +
  34611. 'null for the original mapping instead of an object with empty or null values.';
  34612. if (this._ignoreInvalidMapping) {
  34613. if (typeof console !== 'undefined' && console.warn) {
  34614. console.warn(message);
  34615. }
  34616. return false;
  34617. } else {
  34618. throw new Error(message);
  34619. }
  34620. }
  34621. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  34622. && aGenerated.line > 0 && aGenerated.column >= 0
  34623. && !aOriginal && !aSource && !aName) {
  34624. // Case 1.
  34625. return;
  34626. }
  34627. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  34628. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  34629. && aGenerated.line > 0 && aGenerated.column >= 0
  34630. && aOriginal.line > 0 && aOriginal.column >= 0
  34631. && aSource) {
  34632. // Cases 2 and 3.
  34633. return;
  34634. }
  34635. else {
  34636. var message = 'Invalid mapping: ' + JSON.stringify({
  34637. generated: aGenerated,
  34638. source: aSource,
  34639. original: aOriginal,
  34640. name: aName
  34641. });
  34642. if (this._ignoreInvalidMapping) {
  34643. if (typeof console !== 'undefined' && console.warn) {
  34644. console.warn(message);
  34645. }
  34646. return false;
  34647. } else {
  34648. throw new Error(message)
  34649. }
  34650. }
  34651. };
  34652. /**
  34653. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  34654. * specified by the source map format.
  34655. */
  34656. SourceMapGenerator.prototype._serializeMappings =
  34657. function SourceMapGenerator_serializeMappings() {
  34658. var previousGeneratedColumn = 0;
  34659. var previousGeneratedLine = 1;
  34660. var previousOriginalColumn = 0;
  34661. var previousOriginalLine = 0;
  34662. var previousName = 0;
  34663. var previousSource = 0;
  34664. var result = '';
  34665. var next;
  34666. var mapping;
  34667. var nameIdx;
  34668. var sourceIdx;
  34669. var mappings = this._mappings.toArray();
  34670. for (var i = 0, len = mappings.length; i < len; i++) {
  34671. mapping = mappings[i];
  34672. next = '';
  34673. if (mapping.generatedLine !== previousGeneratedLine) {
  34674. previousGeneratedColumn = 0;
  34675. while (mapping.generatedLine !== previousGeneratedLine) {
  34676. next += ';';
  34677. previousGeneratedLine++;
  34678. }
  34679. }
  34680. else {
  34681. if (i > 0) {
  34682. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  34683. continue;
  34684. }
  34685. next += ',';
  34686. }
  34687. }
  34688. next += base64VLQ.encode(mapping.generatedColumn
  34689. - previousGeneratedColumn);
  34690. previousGeneratedColumn = mapping.generatedColumn;
  34691. if (mapping.source != null) {
  34692. sourceIdx = this._sources.indexOf(mapping.source);
  34693. next += base64VLQ.encode(sourceIdx - previousSource);
  34694. previousSource = sourceIdx;
  34695. // lines are stored 0-based in SourceMap spec version 3
  34696. next += base64VLQ.encode(mapping.originalLine - 1
  34697. - previousOriginalLine);
  34698. previousOriginalLine = mapping.originalLine - 1;
  34699. next += base64VLQ.encode(mapping.originalColumn
  34700. - previousOriginalColumn);
  34701. previousOriginalColumn = mapping.originalColumn;
  34702. if (mapping.name != null) {
  34703. nameIdx = this._names.indexOf(mapping.name);
  34704. next += base64VLQ.encode(nameIdx - previousName);
  34705. previousName = nameIdx;
  34706. }
  34707. }
  34708. result += next;
  34709. }
  34710. return result;
  34711. };
  34712. SourceMapGenerator.prototype._generateSourcesContent =
  34713. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  34714. return aSources.map(function (source) {
  34715. if (!this._sourcesContents) {
  34716. return null;
  34717. }
  34718. if (aSourceRoot != null) {
  34719. source = util.relative(aSourceRoot, source);
  34720. }
  34721. var key = util.toSetString(source);
  34722. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  34723. ? this._sourcesContents[key]
  34724. : null;
  34725. }, this);
  34726. };
  34727. /**
  34728. * Externalize the source map.
  34729. */
  34730. SourceMapGenerator.prototype.toJSON =
  34731. function SourceMapGenerator_toJSON() {
  34732. var map = {
  34733. version: this._version,
  34734. sources: this._sources.toArray(),
  34735. names: this._names.toArray(),
  34736. mappings: this._serializeMappings()
  34737. };
  34738. if (this._file != null) {
  34739. map.file = this._file;
  34740. }
  34741. if (this._sourceRoot != null) {
  34742. map.sourceRoot = this._sourceRoot;
  34743. }
  34744. if (this._sourcesContents) {
  34745. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  34746. }
  34747. return map;
  34748. };
  34749. /**
  34750. * Render the source map being generated to a string.
  34751. */
  34752. SourceMapGenerator.prototype.toString =
  34753. function SourceMapGenerator_toString() {
  34754. return JSON.stringify(this.toJSON());
  34755. };
  34756. sourceMapGenerator$1.SourceMapGenerator = SourceMapGenerator;
  34757. return sourceMapGenerator$1;
  34758. }
  34759. var sourceMapConsumer$1 = {};
  34760. var binarySearch$1 = {};
  34761. /* -*- Mode: js; js-indent-level: 2; -*- */
  34762. var hasRequiredBinarySearch$1;
  34763. function requireBinarySearch$1 () {
  34764. if (hasRequiredBinarySearch$1) return binarySearch$1;
  34765. hasRequiredBinarySearch$1 = 1;
  34766. (function (exports) {
  34767. /*
  34768. * Copyright 2011 Mozilla Foundation and contributors
  34769. * Licensed under the New BSD license. See LICENSE or:
  34770. * http://opensource.org/licenses/BSD-3-Clause
  34771. */
  34772. exports.GREATEST_LOWER_BOUND = 1;
  34773. exports.LEAST_UPPER_BOUND = 2;
  34774. /**
  34775. * Recursive implementation of binary search.
  34776. *
  34777. * @param aLow Indices here and lower do not contain the needle.
  34778. * @param aHigh Indices here and higher do not contain the needle.
  34779. * @param aNeedle The element being searched for.
  34780. * @param aHaystack The non-empty array being searched.
  34781. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  34782. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  34783. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  34784. * closest element that is smaller than or greater than the one we are
  34785. * searching for, respectively, if the exact element cannot be found.
  34786. */
  34787. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  34788. // This function terminates when one of the following is true:
  34789. //
  34790. // 1. We find the exact element we are looking for.
  34791. //
  34792. // 2. We did not find the exact element, but we can return the index of
  34793. // the next-closest element.
  34794. //
  34795. // 3. We did not find the exact element, and there is no next-closest
  34796. // element than the one we are searching for, so we return -1.
  34797. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  34798. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  34799. if (cmp === 0) {
  34800. // Found the element we are looking for.
  34801. return mid;
  34802. }
  34803. else if (cmp > 0) {
  34804. // Our needle is greater than aHaystack[mid].
  34805. if (aHigh - mid > 1) {
  34806. // The element is in the upper half.
  34807. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  34808. }
  34809. // The exact needle element was not found in this haystack. Determine if
  34810. // we are in termination case (3) or (2) and return the appropriate thing.
  34811. if (aBias == exports.LEAST_UPPER_BOUND) {
  34812. return aHigh < aHaystack.length ? aHigh : -1;
  34813. } else {
  34814. return mid;
  34815. }
  34816. }
  34817. else {
  34818. // Our needle is less than aHaystack[mid].
  34819. if (mid - aLow > 1) {
  34820. // The element is in the lower half.
  34821. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  34822. }
  34823. // we are in termination case (3) or (2) and return the appropriate thing.
  34824. if (aBias == exports.LEAST_UPPER_BOUND) {
  34825. return mid;
  34826. } else {
  34827. return aLow < 0 ? -1 : aLow;
  34828. }
  34829. }
  34830. }
  34831. /**
  34832. * This is an implementation of binary search which will always try and return
  34833. * the index of the closest element if there is no exact hit. This is because
  34834. * mappings between original and generated line/col pairs are single points,
  34835. * and there is an implicit region between each of them, so a miss just means
  34836. * that you aren't on the very start of a region.
  34837. *
  34838. * @param aNeedle The element you are looking for.
  34839. * @param aHaystack The array that is being searched.
  34840. * @param aCompare A function which takes the needle and an element in the
  34841. * array and returns -1, 0, or 1 depending on whether the needle is less
  34842. * than, equal to, or greater than the element, respectively.
  34843. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  34844. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  34845. * closest element that is smaller than or greater than the one we are
  34846. * searching for, respectively, if the exact element cannot be found.
  34847. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  34848. */
  34849. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  34850. if (aHaystack.length === 0) {
  34851. return -1;
  34852. }
  34853. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  34854. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  34855. if (index < 0) {
  34856. return -1;
  34857. }
  34858. // We have found either the exact element, or the next-closest element than
  34859. // the one we are searching for. However, there may be more than one such
  34860. // element. Make sure we always return the smallest of these.
  34861. while (index - 1 >= 0) {
  34862. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  34863. break;
  34864. }
  34865. --index;
  34866. }
  34867. return index;
  34868. };
  34869. } (binarySearch$1));
  34870. return binarySearch$1;
  34871. }
  34872. var quickSort$1 = {};
  34873. /* -*- Mode: js; js-indent-level: 2; -*- */
  34874. var hasRequiredQuickSort$1;
  34875. function requireQuickSort$1 () {
  34876. if (hasRequiredQuickSort$1) return quickSort$1;
  34877. hasRequiredQuickSort$1 = 1;
  34878. /*
  34879. * Copyright 2011 Mozilla Foundation and contributors
  34880. * Licensed under the New BSD license. See LICENSE or:
  34881. * http://opensource.org/licenses/BSD-3-Clause
  34882. */
  34883. // It turns out that some (most?) JavaScript engines don't self-host
  34884. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  34885. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  34886. // custom comparator function, calling back and forth between the VM's C++ and
  34887. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  34888. // worse generated code for the comparator function than would be optimal. In
  34889. // fact, when sorting with a comparator, these costs outweigh the benefits of
  34890. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  34891. // a ~3500ms mean speed-up in `bench/bench.html`.
  34892. function SortTemplate(comparator) {
  34893. /**
  34894. * Swap the elements indexed by `x` and `y` in the array `ary`.
  34895. *
  34896. * @param {Array} ary
  34897. * The array.
  34898. * @param {Number} x
  34899. * The index of the first item.
  34900. * @param {Number} y
  34901. * The index of the second item.
  34902. */
  34903. function swap(ary, x, y) {
  34904. var temp = ary[x];
  34905. ary[x] = ary[y];
  34906. ary[y] = temp;
  34907. }
  34908. /**
  34909. * Returns a random integer within the range `low .. high` inclusive.
  34910. *
  34911. * @param {Number} low
  34912. * The lower bound on the range.
  34913. * @param {Number} high
  34914. * The upper bound on the range.
  34915. */
  34916. function randomIntInRange(low, high) {
  34917. return Math.round(low + (Math.random() * (high - low)));
  34918. }
  34919. /**
  34920. * The Quick Sort algorithm.
  34921. *
  34922. * @param {Array} ary
  34923. * An array to sort.
  34924. * @param {function} comparator
  34925. * Function to use to compare two items.
  34926. * @param {Number} p
  34927. * Start index of the array
  34928. * @param {Number} r
  34929. * End index of the array
  34930. */
  34931. function doQuickSort(ary, comparator, p, r) {
  34932. // If our lower bound is less than our upper bound, we (1) partition the
  34933. // array into two pieces and (2) recurse on each half. If it is not, this is
  34934. // the empty array and our base case.
  34935. if (p < r) {
  34936. // (1) Partitioning.
  34937. //
  34938. // The partitioning chooses a pivot between `p` and `r` and moves all
  34939. // elements that are less than or equal to the pivot to the before it, and
  34940. // all the elements that are greater than it after it. The effect is that
  34941. // once partition is done, the pivot is in the exact place it will be when
  34942. // the array is put in sorted order, and it will not need to be moved
  34943. // again. This runs in O(n) time.
  34944. // Always choose a random pivot so that an input array which is reverse
  34945. // sorted does not cause O(n^2) running time.
  34946. var pivotIndex = randomIntInRange(p, r);
  34947. var i = p - 1;
  34948. swap(ary, pivotIndex, r);
  34949. var pivot = ary[r];
  34950. // Immediately after `j` is incremented in this loop, the following hold
  34951. // true:
  34952. //
  34953. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  34954. //
  34955. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  34956. for (var j = p; j < r; j++) {
  34957. if (comparator(ary[j], pivot, false) <= 0) {
  34958. i += 1;
  34959. swap(ary, i, j);
  34960. }
  34961. }
  34962. swap(ary, i + 1, j);
  34963. var q = i + 1;
  34964. // (2) Recurse on each half.
  34965. doQuickSort(ary, comparator, p, q - 1);
  34966. doQuickSort(ary, comparator, q + 1, r);
  34967. }
  34968. }
  34969. return doQuickSort;
  34970. }
  34971. function cloneSort(comparator) {
  34972. let template = SortTemplate.toString();
  34973. let templateFn = new Function(`return ${template}`)();
  34974. return templateFn(comparator);
  34975. }
  34976. /**
  34977. * Sort the given array in-place with the given comparator function.
  34978. *
  34979. * @param {Array} ary
  34980. * An array to sort.
  34981. * @param {function} comparator
  34982. * Function to use to compare two items.
  34983. */
  34984. let sortCache = new WeakMap();
  34985. quickSort$1.quickSort = function (ary, comparator, start = 0) {
  34986. let doQuickSort = sortCache.get(comparator);
  34987. if (doQuickSort === void 0) {
  34988. doQuickSort = cloneSort(comparator);
  34989. sortCache.set(comparator, doQuickSort);
  34990. }
  34991. doQuickSort(ary, comparator, start, ary.length - 1);
  34992. };
  34993. return quickSort$1;
  34994. }
  34995. /* -*- Mode: js; js-indent-level: 2; -*- */
  34996. var hasRequiredSourceMapConsumer$1;
  34997. function requireSourceMapConsumer$1 () {
  34998. if (hasRequiredSourceMapConsumer$1) return sourceMapConsumer$1;
  34999. hasRequiredSourceMapConsumer$1 = 1;
  35000. /*
  35001. * Copyright 2011 Mozilla Foundation and contributors
  35002. * Licensed under the New BSD license. See LICENSE or:
  35003. * http://opensource.org/licenses/BSD-3-Clause
  35004. */
  35005. var util = /*@__PURE__*/ requireUtil$2();
  35006. var binarySearch = /*@__PURE__*/ requireBinarySearch$1();
  35007. var ArraySet = /*@__PURE__*/ requireArraySet$1().ArraySet;
  35008. var base64VLQ = /*@__PURE__*/ requireBase64Vlq$1();
  35009. var quickSort = /*@__PURE__*/ requireQuickSort$1().quickSort;
  35010. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  35011. var sourceMap = aSourceMap;
  35012. if (typeof aSourceMap === 'string') {
  35013. sourceMap = util.parseSourceMapInput(aSourceMap);
  35014. }
  35015. return sourceMap.sections != null
  35016. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  35017. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  35018. }
  35019. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  35020. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  35021. };
  35022. /**
  35023. * The version of the source mapping spec that we are consuming.
  35024. */
  35025. SourceMapConsumer.prototype._version = 3;
  35026. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  35027. // parsed mapping coordinates from the source map's "mappings" attribute. They
  35028. // are lazily instantiated, accessed via the `_generatedMappings` and
  35029. // `_originalMappings` getters respectively, and we only parse the mappings
  35030. // and create these arrays once queried for a source location. We jump through
  35031. // these hoops because there can be many thousands of mappings, and parsing
  35032. // them is expensive, so we only want to do it if we must.
  35033. //
  35034. // Each object in the arrays is of the form:
  35035. //
  35036. // {
  35037. // generatedLine: The line number in the generated code,
  35038. // generatedColumn: The column number in the generated code,
  35039. // source: The path to the original source file that generated this
  35040. // chunk of code,
  35041. // originalLine: The line number in the original source that
  35042. // corresponds to this chunk of generated code,
  35043. // originalColumn: The column number in the original source that
  35044. // corresponds to this chunk of generated code,
  35045. // name: The name of the original symbol which generated this chunk of
  35046. // code.
  35047. // }
  35048. //
  35049. // All properties except for `generatedLine` and `generatedColumn` can be
  35050. // `null`.
  35051. //
  35052. // `_generatedMappings` is ordered by the generated positions.
  35053. //
  35054. // `_originalMappings` is ordered by the original positions.
  35055. SourceMapConsumer.prototype.__generatedMappings = null;
  35056. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  35057. configurable: true,
  35058. enumerable: true,
  35059. get: function () {
  35060. if (!this.__generatedMappings) {
  35061. this._parseMappings(this._mappings, this.sourceRoot);
  35062. }
  35063. return this.__generatedMappings;
  35064. }
  35065. });
  35066. SourceMapConsumer.prototype.__originalMappings = null;
  35067. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  35068. configurable: true,
  35069. enumerable: true,
  35070. get: function () {
  35071. if (!this.__originalMappings) {
  35072. this._parseMappings(this._mappings, this.sourceRoot);
  35073. }
  35074. return this.__originalMappings;
  35075. }
  35076. });
  35077. SourceMapConsumer.prototype._charIsMappingSeparator =
  35078. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  35079. var c = aStr.charAt(index);
  35080. return c === ";" || c === ",";
  35081. };
  35082. /**
  35083. * Parse the mappings in a string in to a data structure which we can easily
  35084. * query (the ordered arrays in the `this.__generatedMappings` and
  35085. * `this.__originalMappings` properties).
  35086. */
  35087. SourceMapConsumer.prototype._parseMappings =
  35088. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  35089. throw new Error("Subclasses must implement _parseMappings");
  35090. };
  35091. SourceMapConsumer.GENERATED_ORDER = 1;
  35092. SourceMapConsumer.ORIGINAL_ORDER = 2;
  35093. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  35094. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  35095. /**
  35096. * Iterate over each mapping between an original source/line/column and a
  35097. * generated line/column in this source map.
  35098. *
  35099. * @param Function aCallback
  35100. * The function that is called with each mapping.
  35101. * @param Object aContext
  35102. * Optional. If specified, this object will be the value of `this` every
  35103. * time that `aCallback` is called.
  35104. * @param aOrder
  35105. * Either `SourceMapConsumer.GENERATED_ORDER` or
  35106. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  35107. * iterate over the mappings sorted by the generated file's line/column
  35108. * order or the original's source/line/column order, respectively. Defaults to
  35109. * `SourceMapConsumer.GENERATED_ORDER`.
  35110. */
  35111. SourceMapConsumer.prototype.eachMapping =
  35112. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  35113. var context = aContext || null;
  35114. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  35115. var mappings;
  35116. switch (order) {
  35117. case SourceMapConsumer.GENERATED_ORDER:
  35118. mappings = this._generatedMappings;
  35119. break;
  35120. case SourceMapConsumer.ORIGINAL_ORDER:
  35121. mappings = this._originalMappings;
  35122. break;
  35123. default:
  35124. throw new Error("Unknown order of iteration.");
  35125. }
  35126. var sourceRoot = this.sourceRoot;
  35127. var boundCallback = aCallback.bind(context);
  35128. var names = this._names;
  35129. var sources = this._sources;
  35130. var sourceMapURL = this._sourceMapURL;
  35131. for (var i = 0, n = mappings.length; i < n; i++) {
  35132. var mapping = mappings[i];
  35133. var source = mapping.source === null ? null : sources.at(mapping.source);
  35134. if(source !== null) {
  35135. source = util.computeSourceURL(sourceRoot, source, sourceMapURL);
  35136. }
  35137. boundCallback({
  35138. source: source,
  35139. generatedLine: mapping.generatedLine,
  35140. generatedColumn: mapping.generatedColumn,
  35141. originalLine: mapping.originalLine,
  35142. originalColumn: mapping.originalColumn,
  35143. name: mapping.name === null ? null : names.at(mapping.name)
  35144. });
  35145. }
  35146. };
  35147. /**
  35148. * Returns all generated line and column information for the original source,
  35149. * line, and column provided. If no column is provided, returns all mappings
  35150. * corresponding to a either the line we are searching for or the next
  35151. * closest line that has any mappings. Otherwise, returns all mappings
  35152. * corresponding to the given line and either the column we are searching for
  35153. * or the next closest column that has any offsets.
  35154. *
  35155. * The only argument is an object with the following properties:
  35156. *
  35157. * - source: The filename of the original source.
  35158. * - line: The line number in the original source. The line number is 1-based.
  35159. * - column: Optional. the column number in the original source.
  35160. * The column number is 0-based.
  35161. *
  35162. * and an array of objects is returned, each with the following properties:
  35163. *
  35164. * - line: The line number in the generated source, or null. The
  35165. * line number is 1-based.
  35166. * - column: The column number in the generated source, or null.
  35167. * The column number is 0-based.
  35168. */
  35169. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  35170. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  35171. var line = util.getArg(aArgs, 'line');
  35172. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  35173. // returns the index of the closest mapping less than the needle. By
  35174. // setting needle.originalColumn to 0, we thus find the last mapping for
  35175. // the given line, provided such a mapping exists.
  35176. var needle = {
  35177. source: util.getArg(aArgs, 'source'),
  35178. originalLine: line,
  35179. originalColumn: util.getArg(aArgs, 'column', 0)
  35180. };
  35181. needle.source = this._findSourceIndex(needle.source);
  35182. if (needle.source < 0) {
  35183. return [];
  35184. }
  35185. var mappings = [];
  35186. var index = this._findMapping(needle,
  35187. this._originalMappings,
  35188. "originalLine",
  35189. "originalColumn",
  35190. util.compareByOriginalPositions,
  35191. binarySearch.LEAST_UPPER_BOUND);
  35192. if (index >= 0) {
  35193. var mapping = this._originalMappings[index];
  35194. if (aArgs.column === undefined) {
  35195. var originalLine = mapping.originalLine;
  35196. // Iterate until either we run out of mappings, or we run into
  35197. // a mapping for a different line than the one we found. Since
  35198. // mappings are sorted, this is guaranteed to find all mappings for
  35199. // the line we found.
  35200. while (mapping && mapping.originalLine === originalLine) {
  35201. mappings.push({
  35202. line: util.getArg(mapping, 'generatedLine', null),
  35203. column: util.getArg(mapping, 'generatedColumn', null),
  35204. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  35205. });
  35206. mapping = this._originalMappings[++index];
  35207. }
  35208. } else {
  35209. var originalColumn = mapping.originalColumn;
  35210. // Iterate until either we run out of mappings, or we run into
  35211. // a mapping for a different line than the one we were searching for.
  35212. // Since mappings are sorted, this is guaranteed to find all mappings for
  35213. // the line we are searching for.
  35214. while (mapping &&
  35215. mapping.originalLine === line &&
  35216. mapping.originalColumn == originalColumn) {
  35217. mappings.push({
  35218. line: util.getArg(mapping, 'generatedLine', null),
  35219. column: util.getArg(mapping, 'generatedColumn', null),
  35220. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  35221. });
  35222. mapping = this._originalMappings[++index];
  35223. }
  35224. }
  35225. }
  35226. return mappings;
  35227. };
  35228. sourceMapConsumer$1.SourceMapConsumer = SourceMapConsumer;
  35229. /**
  35230. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  35231. * query for information about the original file positions by giving it a file
  35232. * position in the generated source.
  35233. *
  35234. * The first parameter is the raw source map (either as a JSON string, or
  35235. * already parsed to an object). According to the spec, source maps have the
  35236. * following attributes:
  35237. *
  35238. * - version: Which version of the source map spec this map is following.
  35239. * - sources: An array of URLs to the original source files.
  35240. * - names: An array of identifiers which can be referrenced by individual mappings.
  35241. * - sourceRoot: Optional. The URL root from which all sources are relative.
  35242. * - sourcesContent: Optional. An array of contents of the original source files.
  35243. * - mappings: A string of base64 VLQs which contain the actual mappings.
  35244. * - file: Optional. The generated file this source map is associated with.
  35245. *
  35246. * Here is an example source map, taken from the source map spec[0]:
  35247. *
  35248. * {
  35249. * version : 3,
  35250. * file: "out.js",
  35251. * sourceRoot : "",
  35252. * sources: ["foo.js", "bar.js"],
  35253. * names: ["src", "maps", "are", "fun"],
  35254. * mappings: "AA,AB;;ABCDE;"
  35255. * }
  35256. *
  35257. * The second parameter, if given, is a string whose value is the URL
  35258. * at which the source map was found. This URL is used to compute the
  35259. * sources array.
  35260. *
  35261. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  35262. */
  35263. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  35264. var sourceMap = aSourceMap;
  35265. if (typeof aSourceMap === 'string') {
  35266. sourceMap = util.parseSourceMapInput(aSourceMap);
  35267. }
  35268. var version = util.getArg(sourceMap, 'version');
  35269. var sources = util.getArg(sourceMap, 'sources');
  35270. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  35271. // requires the array) to play nice here.
  35272. var names = util.getArg(sourceMap, 'names', []);
  35273. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  35274. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  35275. var mappings = util.getArg(sourceMap, 'mappings');
  35276. var file = util.getArg(sourceMap, 'file', null);
  35277. // Once again, Sass deviates from the spec and supplies the version as a
  35278. // string rather than a number, so we use loose equality checking here.
  35279. if (version != this._version) {
  35280. throw new Error('Unsupported version: ' + version);
  35281. }
  35282. if (sourceRoot) {
  35283. sourceRoot = util.normalize(sourceRoot);
  35284. }
  35285. sources = sources
  35286. .map(String)
  35287. // Some source maps produce relative source paths like "./foo.js" instead of
  35288. // "foo.js". Normalize these first so that future comparisons will succeed.
  35289. // See bugzil.la/1090768.
  35290. .map(util.normalize)
  35291. // Always ensure that absolute sources are internally stored relative to
  35292. // the source root, if the source root is absolute. Not doing this would
  35293. // be particularly problematic when the source root is a prefix of the
  35294. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  35295. .map(function (source) {
  35296. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  35297. ? util.relative(sourceRoot, source)
  35298. : source;
  35299. });
  35300. // Pass `true` below to allow duplicate names and sources. While source maps
  35301. // are intended to be compressed and deduplicated, the TypeScript compiler
  35302. // sometimes generates source maps with duplicates in them. See Github issue
  35303. // #72 and bugzil.la/889492.
  35304. this._names = ArraySet.fromArray(names.map(String), true);
  35305. this._sources = ArraySet.fromArray(sources, true);
  35306. this._absoluteSources = this._sources.toArray().map(function (s) {
  35307. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  35308. });
  35309. this.sourceRoot = sourceRoot;
  35310. this.sourcesContent = sourcesContent;
  35311. this._mappings = mappings;
  35312. this._sourceMapURL = aSourceMapURL;
  35313. this.file = file;
  35314. }
  35315. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  35316. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  35317. /**
  35318. * Utility function to find the index of a source. Returns -1 if not
  35319. * found.
  35320. */
  35321. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  35322. var relativeSource = aSource;
  35323. if (this.sourceRoot != null) {
  35324. relativeSource = util.relative(this.sourceRoot, relativeSource);
  35325. }
  35326. if (this._sources.has(relativeSource)) {
  35327. return this._sources.indexOf(relativeSource);
  35328. }
  35329. // Maybe aSource is an absolute URL as returned by |sources|. In
  35330. // this case we can't simply undo the transform.
  35331. var i;
  35332. for (i = 0; i < this._absoluteSources.length; ++i) {
  35333. if (this._absoluteSources[i] == aSource) {
  35334. return i;
  35335. }
  35336. }
  35337. return -1;
  35338. };
  35339. /**
  35340. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  35341. *
  35342. * @param SourceMapGenerator aSourceMap
  35343. * The source map that will be consumed.
  35344. * @param String aSourceMapURL
  35345. * The URL at which the source map can be found (optional)
  35346. * @returns BasicSourceMapConsumer
  35347. */
  35348. BasicSourceMapConsumer.fromSourceMap =
  35349. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  35350. var smc = Object.create(BasicSourceMapConsumer.prototype);
  35351. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  35352. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  35353. smc.sourceRoot = aSourceMap._sourceRoot;
  35354. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  35355. smc.sourceRoot);
  35356. smc.file = aSourceMap._file;
  35357. smc._sourceMapURL = aSourceMapURL;
  35358. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  35359. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  35360. });
  35361. // Because we are modifying the entries (by converting string sources and
  35362. // names to indices into the sources and names ArraySets), we have to make
  35363. // a copy of the entry or else bad things happen. Shared mutable state
  35364. // strikes again! See github issue #191.
  35365. var generatedMappings = aSourceMap._mappings.toArray().slice();
  35366. var destGeneratedMappings = smc.__generatedMappings = [];
  35367. var destOriginalMappings = smc.__originalMappings = [];
  35368. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  35369. var srcMapping = generatedMappings[i];
  35370. var destMapping = new Mapping;
  35371. destMapping.generatedLine = srcMapping.generatedLine;
  35372. destMapping.generatedColumn = srcMapping.generatedColumn;
  35373. if (srcMapping.source) {
  35374. destMapping.source = sources.indexOf(srcMapping.source);
  35375. destMapping.originalLine = srcMapping.originalLine;
  35376. destMapping.originalColumn = srcMapping.originalColumn;
  35377. if (srcMapping.name) {
  35378. destMapping.name = names.indexOf(srcMapping.name);
  35379. }
  35380. destOriginalMappings.push(destMapping);
  35381. }
  35382. destGeneratedMappings.push(destMapping);
  35383. }
  35384. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  35385. return smc;
  35386. };
  35387. /**
  35388. * The version of the source mapping spec that we are consuming.
  35389. */
  35390. BasicSourceMapConsumer.prototype._version = 3;
  35391. /**
  35392. * The list of original sources.
  35393. */
  35394. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  35395. get: function () {
  35396. return this._absoluteSources.slice();
  35397. }
  35398. });
  35399. /**
  35400. * Provide the JIT with a nice shape / hidden class.
  35401. */
  35402. function Mapping() {
  35403. this.generatedLine = 0;
  35404. this.generatedColumn = 0;
  35405. this.source = null;
  35406. this.originalLine = null;
  35407. this.originalColumn = null;
  35408. this.name = null;
  35409. }
  35410. /**
  35411. * Parse the mappings in a string in to a data structure which we can easily
  35412. * query (the ordered arrays in the `this.__generatedMappings` and
  35413. * `this.__originalMappings` properties).
  35414. */
  35415. const compareGenerated = util.compareByGeneratedPositionsDeflatedNoLine;
  35416. function sortGenerated(array, start) {
  35417. let l = array.length;
  35418. let n = array.length - start;
  35419. if (n <= 1) {
  35420. return;
  35421. } else if (n == 2) {
  35422. let a = array[start];
  35423. let b = array[start + 1];
  35424. if (compareGenerated(a, b) > 0) {
  35425. array[start] = b;
  35426. array[start + 1] = a;
  35427. }
  35428. } else if (n < 20) {
  35429. for (let i = start; i < l; i++) {
  35430. for (let j = i; j > start; j--) {
  35431. let a = array[j - 1];
  35432. let b = array[j];
  35433. if (compareGenerated(a, b) <= 0) {
  35434. break;
  35435. }
  35436. array[j - 1] = b;
  35437. array[j] = a;
  35438. }
  35439. }
  35440. } else {
  35441. quickSort(array, compareGenerated, start);
  35442. }
  35443. }
  35444. BasicSourceMapConsumer.prototype._parseMappings =
  35445. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  35446. var generatedLine = 1;
  35447. var previousGeneratedColumn = 0;
  35448. var previousOriginalLine = 0;
  35449. var previousOriginalColumn = 0;
  35450. var previousSource = 0;
  35451. var previousName = 0;
  35452. var length = aStr.length;
  35453. var index = 0;
  35454. var temp = {};
  35455. var originalMappings = [];
  35456. var generatedMappings = [];
  35457. var mapping, segment, end, value;
  35458. let subarrayStart = 0;
  35459. while (index < length) {
  35460. if (aStr.charAt(index) === ';') {
  35461. generatedLine++;
  35462. index++;
  35463. previousGeneratedColumn = 0;
  35464. sortGenerated(generatedMappings, subarrayStart);
  35465. subarrayStart = generatedMappings.length;
  35466. }
  35467. else if (aStr.charAt(index) === ',') {
  35468. index++;
  35469. }
  35470. else {
  35471. mapping = new Mapping();
  35472. mapping.generatedLine = generatedLine;
  35473. for (end = index; end < length; end++) {
  35474. if (this._charIsMappingSeparator(aStr, end)) {
  35475. break;
  35476. }
  35477. }
  35478. aStr.slice(index, end);
  35479. segment = [];
  35480. while (index < end) {
  35481. base64VLQ.decode(aStr, index, temp);
  35482. value = temp.value;
  35483. index = temp.rest;
  35484. segment.push(value);
  35485. }
  35486. if (segment.length === 2) {
  35487. throw new Error('Found a source, but no line and column');
  35488. }
  35489. if (segment.length === 3) {
  35490. throw new Error('Found a source and line, but no column');
  35491. }
  35492. // Generated column.
  35493. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  35494. previousGeneratedColumn = mapping.generatedColumn;
  35495. if (segment.length > 1) {
  35496. // Original source.
  35497. mapping.source = previousSource + segment[1];
  35498. previousSource += segment[1];
  35499. // Original line.
  35500. mapping.originalLine = previousOriginalLine + segment[2];
  35501. previousOriginalLine = mapping.originalLine;
  35502. // Lines are stored 0-based
  35503. mapping.originalLine += 1;
  35504. // Original column.
  35505. mapping.originalColumn = previousOriginalColumn + segment[3];
  35506. previousOriginalColumn = mapping.originalColumn;
  35507. if (segment.length > 4) {
  35508. // Original name.
  35509. mapping.name = previousName + segment[4];
  35510. previousName += segment[4];
  35511. }
  35512. }
  35513. generatedMappings.push(mapping);
  35514. if (typeof mapping.originalLine === 'number') {
  35515. let currentSource = mapping.source;
  35516. while (originalMappings.length <= currentSource) {
  35517. originalMappings.push(null);
  35518. }
  35519. if (originalMappings[currentSource] === null) {
  35520. originalMappings[currentSource] = [];
  35521. }
  35522. originalMappings[currentSource].push(mapping);
  35523. }
  35524. }
  35525. }
  35526. sortGenerated(generatedMappings, subarrayStart);
  35527. this.__generatedMappings = generatedMappings;
  35528. for (var i = 0; i < originalMappings.length; i++) {
  35529. if (originalMappings[i] != null) {
  35530. quickSort(originalMappings[i], util.compareByOriginalPositionsNoSource);
  35531. }
  35532. }
  35533. this.__originalMappings = [].concat(...originalMappings);
  35534. };
  35535. /**
  35536. * Find the mapping that best matches the hypothetical "needle" mapping that
  35537. * we are searching for in the given "haystack" of mappings.
  35538. */
  35539. BasicSourceMapConsumer.prototype._findMapping =
  35540. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  35541. aColumnName, aComparator, aBias) {
  35542. // To return the position we are searching for, we must first find the
  35543. // mapping for the given position and then return the opposite position it
  35544. // points to. Because the mappings are sorted, we can use binary search to
  35545. // find the best mapping.
  35546. if (aNeedle[aLineName] <= 0) {
  35547. throw new TypeError('Line must be greater than or equal to 1, got '
  35548. + aNeedle[aLineName]);
  35549. }
  35550. if (aNeedle[aColumnName] < 0) {
  35551. throw new TypeError('Column must be greater than or equal to 0, got '
  35552. + aNeedle[aColumnName]);
  35553. }
  35554. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  35555. };
  35556. /**
  35557. * Compute the last column for each generated mapping. The last column is
  35558. * inclusive.
  35559. */
  35560. BasicSourceMapConsumer.prototype.computeColumnSpans =
  35561. function SourceMapConsumer_computeColumnSpans() {
  35562. for (var index = 0; index < this._generatedMappings.length; ++index) {
  35563. var mapping = this._generatedMappings[index];
  35564. // Mappings do not contain a field for the last generated columnt. We
  35565. // can come up with an optimistic estimate, however, by assuming that
  35566. // mappings are contiguous (i.e. given two consecutive mappings, the
  35567. // first mapping ends where the second one starts).
  35568. if (index + 1 < this._generatedMappings.length) {
  35569. var nextMapping = this._generatedMappings[index + 1];
  35570. if (mapping.generatedLine === nextMapping.generatedLine) {
  35571. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  35572. continue;
  35573. }
  35574. }
  35575. // The last mapping for each line spans the entire line.
  35576. mapping.lastGeneratedColumn = Infinity;
  35577. }
  35578. };
  35579. /**
  35580. * Returns the original source, line, and column information for the generated
  35581. * source's line and column positions provided. The only argument is an object
  35582. * with the following properties:
  35583. *
  35584. * - line: The line number in the generated source. The line number
  35585. * is 1-based.
  35586. * - column: The column number in the generated source. The column
  35587. * number is 0-based.
  35588. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  35589. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  35590. * closest element that is smaller than or greater than the one we are
  35591. * searching for, respectively, if the exact element cannot be found.
  35592. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  35593. *
  35594. * and an object is returned with the following properties:
  35595. *
  35596. * - source: The original source file, or null.
  35597. * - line: The line number in the original source, or null. The
  35598. * line number is 1-based.
  35599. * - column: The column number in the original source, or null. The
  35600. * column number is 0-based.
  35601. * - name: The original identifier, or null.
  35602. */
  35603. BasicSourceMapConsumer.prototype.originalPositionFor =
  35604. function SourceMapConsumer_originalPositionFor(aArgs) {
  35605. var needle = {
  35606. generatedLine: util.getArg(aArgs, 'line'),
  35607. generatedColumn: util.getArg(aArgs, 'column')
  35608. };
  35609. var index = this._findMapping(
  35610. needle,
  35611. this._generatedMappings,
  35612. "generatedLine",
  35613. "generatedColumn",
  35614. util.compareByGeneratedPositionsDeflated,
  35615. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  35616. );
  35617. if (index >= 0) {
  35618. var mapping = this._generatedMappings[index];
  35619. if (mapping.generatedLine === needle.generatedLine) {
  35620. var source = util.getArg(mapping, 'source', null);
  35621. if (source !== null) {
  35622. source = this._sources.at(source);
  35623. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  35624. }
  35625. var name = util.getArg(mapping, 'name', null);
  35626. if (name !== null) {
  35627. name = this._names.at(name);
  35628. }
  35629. return {
  35630. source: source,
  35631. line: util.getArg(mapping, 'originalLine', null),
  35632. column: util.getArg(mapping, 'originalColumn', null),
  35633. name: name
  35634. };
  35635. }
  35636. }
  35637. return {
  35638. source: null,
  35639. line: null,
  35640. column: null,
  35641. name: null
  35642. };
  35643. };
  35644. /**
  35645. * Return true if we have the source content for every source in the source
  35646. * map, false otherwise.
  35647. */
  35648. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  35649. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  35650. if (!this.sourcesContent) {
  35651. return false;
  35652. }
  35653. return this.sourcesContent.length >= this._sources.size() &&
  35654. !this.sourcesContent.some(function (sc) { return sc == null; });
  35655. };
  35656. /**
  35657. * Returns the original source content. The only argument is the url of the
  35658. * original source file. Returns null if no original source content is
  35659. * available.
  35660. */
  35661. BasicSourceMapConsumer.prototype.sourceContentFor =
  35662. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  35663. if (!this.sourcesContent) {
  35664. return null;
  35665. }
  35666. var index = this._findSourceIndex(aSource);
  35667. if (index >= 0) {
  35668. return this.sourcesContent[index];
  35669. }
  35670. var relativeSource = aSource;
  35671. if (this.sourceRoot != null) {
  35672. relativeSource = util.relative(this.sourceRoot, relativeSource);
  35673. }
  35674. var url;
  35675. if (this.sourceRoot != null
  35676. && (url = util.urlParse(this.sourceRoot))) {
  35677. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  35678. // many users. We can help them out when they expect file:// URIs to
  35679. // behave like it would if they were running a local HTTP server. See
  35680. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  35681. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  35682. if (url.scheme == "file"
  35683. && this._sources.has(fileUriAbsPath)) {
  35684. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  35685. }
  35686. if ((!url.path || url.path == "/")
  35687. && this._sources.has("/" + relativeSource)) {
  35688. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  35689. }
  35690. }
  35691. // This function is used recursively from
  35692. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  35693. // don't want to throw if we can't find the source - we just want to
  35694. // return null, so we provide a flag to exit gracefully.
  35695. if (nullOnMissing) {
  35696. return null;
  35697. }
  35698. else {
  35699. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  35700. }
  35701. };
  35702. /**
  35703. * Returns the generated line and column information for the original source,
  35704. * line, and column positions provided. The only argument is an object with
  35705. * the following properties:
  35706. *
  35707. * - source: The filename of the original source.
  35708. * - line: The line number in the original source. The line number
  35709. * is 1-based.
  35710. * - column: The column number in the original source. The column
  35711. * number is 0-based.
  35712. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  35713. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  35714. * closest element that is smaller than or greater than the one we are
  35715. * searching for, respectively, if the exact element cannot be found.
  35716. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  35717. *
  35718. * and an object is returned with the following properties:
  35719. *
  35720. * - line: The line number in the generated source, or null. The
  35721. * line number is 1-based.
  35722. * - column: The column number in the generated source, or null.
  35723. * The column number is 0-based.
  35724. */
  35725. BasicSourceMapConsumer.prototype.generatedPositionFor =
  35726. function SourceMapConsumer_generatedPositionFor(aArgs) {
  35727. var source = util.getArg(aArgs, 'source');
  35728. source = this._findSourceIndex(source);
  35729. if (source < 0) {
  35730. return {
  35731. line: null,
  35732. column: null,
  35733. lastColumn: null
  35734. };
  35735. }
  35736. var needle = {
  35737. source: source,
  35738. originalLine: util.getArg(aArgs, 'line'),
  35739. originalColumn: util.getArg(aArgs, 'column')
  35740. };
  35741. var index = this._findMapping(
  35742. needle,
  35743. this._originalMappings,
  35744. "originalLine",
  35745. "originalColumn",
  35746. util.compareByOriginalPositions,
  35747. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  35748. );
  35749. if (index >= 0) {
  35750. var mapping = this._originalMappings[index];
  35751. if (mapping.source === needle.source) {
  35752. return {
  35753. line: util.getArg(mapping, 'generatedLine', null),
  35754. column: util.getArg(mapping, 'generatedColumn', null),
  35755. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  35756. };
  35757. }
  35758. }
  35759. return {
  35760. line: null,
  35761. column: null,
  35762. lastColumn: null
  35763. };
  35764. };
  35765. sourceMapConsumer$1.BasicSourceMapConsumer = BasicSourceMapConsumer;
  35766. /**
  35767. * An IndexedSourceMapConsumer instance represents a parsed source map which
  35768. * we can query for information. It differs from BasicSourceMapConsumer in
  35769. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  35770. * input.
  35771. *
  35772. * The first parameter is a raw source map (either as a JSON string, or already
  35773. * parsed to an object). According to the spec for indexed source maps, they
  35774. * have the following attributes:
  35775. *
  35776. * - version: Which version of the source map spec this map is following.
  35777. * - file: Optional. The generated file this source map is associated with.
  35778. * - sections: A list of section definitions.
  35779. *
  35780. * Each value under the "sections" field has two fields:
  35781. * - offset: The offset into the original specified at which this section
  35782. * begins to apply, defined as an object with a "line" and "column"
  35783. * field.
  35784. * - map: A source map definition. This source map could also be indexed,
  35785. * but doesn't have to be.
  35786. *
  35787. * Instead of the "map" field, it's also possible to have a "url" field
  35788. * specifying a URL to retrieve a source map from, but that's currently
  35789. * unsupported.
  35790. *
  35791. * Here's an example source map, taken from the source map spec[0], but
  35792. * modified to omit a section which uses the "url" field.
  35793. *
  35794. * {
  35795. * version : 3,
  35796. * file: "app.js",
  35797. * sections: [{
  35798. * offset: {line:100, column:10},
  35799. * map: {
  35800. * version : 3,
  35801. * file: "section.js",
  35802. * sources: ["foo.js", "bar.js"],
  35803. * names: ["src", "maps", "are", "fun"],
  35804. * mappings: "AAAA,E;;ABCDE;"
  35805. * }
  35806. * }],
  35807. * }
  35808. *
  35809. * The second parameter, if given, is a string whose value is the URL
  35810. * at which the source map was found. This URL is used to compute the
  35811. * sources array.
  35812. *
  35813. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  35814. */
  35815. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  35816. var sourceMap = aSourceMap;
  35817. if (typeof aSourceMap === 'string') {
  35818. sourceMap = util.parseSourceMapInput(aSourceMap);
  35819. }
  35820. var version = util.getArg(sourceMap, 'version');
  35821. var sections = util.getArg(sourceMap, 'sections');
  35822. if (version != this._version) {
  35823. throw new Error('Unsupported version: ' + version);
  35824. }
  35825. this._sources = new ArraySet();
  35826. this._names = new ArraySet();
  35827. var lastOffset = {
  35828. line: -1,
  35829. column: 0
  35830. };
  35831. this._sections = sections.map(function (s) {
  35832. if (s.url) {
  35833. // The url field will require support for asynchronicity.
  35834. // See https://github.com/mozilla/source-map/issues/16
  35835. throw new Error('Support for url field in sections not implemented.');
  35836. }
  35837. var offset = util.getArg(s, 'offset');
  35838. var offsetLine = util.getArg(offset, 'line');
  35839. var offsetColumn = util.getArg(offset, 'column');
  35840. if (offsetLine < lastOffset.line ||
  35841. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  35842. throw new Error('Section offsets must be ordered and non-overlapping.');
  35843. }
  35844. lastOffset = offset;
  35845. return {
  35846. generatedOffset: {
  35847. // The offset fields are 0-based, but we use 1-based indices when
  35848. // encoding/decoding from VLQ.
  35849. generatedLine: offsetLine + 1,
  35850. generatedColumn: offsetColumn + 1
  35851. },
  35852. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  35853. }
  35854. });
  35855. }
  35856. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  35857. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  35858. /**
  35859. * The version of the source mapping spec that we are consuming.
  35860. */
  35861. IndexedSourceMapConsumer.prototype._version = 3;
  35862. /**
  35863. * The list of original sources.
  35864. */
  35865. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  35866. get: function () {
  35867. var sources = [];
  35868. for (var i = 0; i < this._sections.length; i++) {
  35869. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  35870. sources.push(this._sections[i].consumer.sources[j]);
  35871. }
  35872. }
  35873. return sources;
  35874. }
  35875. });
  35876. /**
  35877. * Returns the original source, line, and column information for the generated
  35878. * source's line and column positions provided. The only argument is an object
  35879. * with the following properties:
  35880. *
  35881. * - line: The line number in the generated source. The line number
  35882. * is 1-based.
  35883. * - column: The column number in the generated source. The column
  35884. * number is 0-based.
  35885. *
  35886. * and an object is returned with the following properties:
  35887. *
  35888. * - source: The original source file, or null.
  35889. * - line: The line number in the original source, or null. The
  35890. * line number is 1-based.
  35891. * - column: The column number in the original source, or null. The
  35892. * column number is 0-based.
  35893. * - name: The original identifier, or null.
  35894. */
  35895. IndexedSourceMapConsumer.prototype.originalPositionFor =
  35896. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  35897. var needle = {
  35898. generatedLine: util.getArg(aArgs, 'line'),
  35899. generatedColumn: util.getArg(aArgs, 'column')
  35900. };
  35901. // Find the section containing the generated position we're trying to map
  35902. // to an original position.
  35903. var sectionIndex = binarySearch.search(needle, this._sections,
  35904. function(needle, section) {
  35905. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  35906. if (cmp) {
  35907. return cmp;
  35908. }
  35909. return (needle.generatedColumn -
  35910. section.generatedOffset.generatedColumn);
  35911. });
  35912. var section = this._sections[sectionIndex];
  35913. if (!section) {
  35914. return {
  35915. source: null,
  35916. line: null,
  35917. column: null,
  35918. name: null
  35919. };
  35920. }
  35921. return section.consumer.originalPositionFor({
  35922. line: needle.generatedLine -
  35923. (section.generatedOffset.generatedLine - 1),
  35924. column: needle.generatedColumn -
  35925. (section.generatedOffset.generatedLine === needle.generatedLine
  35926. ? section.generatedOffset.generatedColumn - 1
  35927. : 0),
  35928. bias: aArgs.bias
  35929. });
  35930. };
  35931. /**
  35932. * Return true if we have the source content for every source in the source
  35933. * map, false otherwise.
  35934. */
  35935. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  35936. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  35937. return this._sections.every(function (s) {
  35938. return s.consumer.hasContentsOfAllSources();
  35939. });
  35940. };
  35941. /**
  35942. * Returns the original source content. The only argument is the url of the
  35943. * original source file. Returns null if no original source content is
  35944. * available.
  35945. */
  35946. IndexedSourceMapConsumer.prototype.sourceContentFor =
  35947. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  35948. for (var i = 0; i < this._sections.length; i++) {
  35949. var section = this._sections[i];
  35950. var content = section.consumer.sourceContentFor(aSource, true);
  35951. if (content || content === '') {
  35952. return content;
  35953. }
  35954. }
  35955. if (nullOnMissing) {
  35956. return null;
  35957. }
  35958. else {
  35959. throw new Error('"' + aSource + '" is not in the SourceMap.');
  35960. }
  35961. };
  35962. /**
  35963. * Returns the generated line and column information for the original source,
  35964. * line, and column positions provided. The only argument is an object with
  35965. * the following properties:
  35966. *
  35967. * - source: The filename of the original source.
  35968. * - line: The line number in the original source. The line number
  35969. * is 1-based.
  35970. * - column: The column number in the original source. The column
  35971. * number is 0-based.
  35972. *
  35973. * and an object is returned with the following properties:
  35974. *
  35975. * - line: The line number in the generated source, or null. The
  35976. * line number is 1-based.
  35977. * - column: The column number in the generated source, or null.
  35978. * The column number is 0-based.
  35979. */
  35980. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  35981. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  35982. for (var i = 0; i < this._sections.length; i++) {
  35983. var section = this._sections[i];
  35984. // Only consider this section if the requested source is in the list of
  35985. // sources of the consumer.
  35986. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  35987. continue;
  35988. }
  35989. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  35990. if (generatedPosition) {
  35991. var ret = {
  35992. line: generatedPosition.line +
  35993. (section.generatedOffset.generatedLine - 1),
  35994. column: generatedPosition.column +
  35995. (section.generatedOffset.generatedLine === generatedPosition.line
  35996. ? section.generatedOffset.generatedColumn - 1
  35997. : 0)
  35998. };
  35999. return ret;
  36000. }
  36001. }
  36002. return {
  36003. line: null,
  36004. column: null
  36005. };
  36006. };
  36007. /**
  36008. * Parse the mappings in a string in to a data structure which we can easily
  36009. * query (the ordered arrays in the `this.__generatedMappings` and
  36010. * `this.__originalMappings` properties).
  36011. */
  36012. IndexedSourceMapConsumer.prototype._parseMappings =
  36013. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  36014. this.__generatedMappings = [];
  36015. this.__originalMappings = [];
  36016. for (var i = 0; i < this._sections.length; i++) {
  36017. var section = this._sections[i];
  36018. var sectionMappings = section.consumer._generatedMappings;
  36019. for (var j = 0; j < sectionMappings.length; j++) {
  36020. var mapping = sectionMappings[j];
  36021. var source = section.consumer._sources.at(mapping.source);
  36022. if(source !== null) {
  36023. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  36024. }
  36025. this._sources.add(source);
  36026. source = this._sources.indexOf(source);
  36027. var name = null;
  36028. if (mapping.name) {
  36029. name = section.consumer._names.at(mapping.name);
  36030. this._names.add(name);
  36031. name = this._names.indexOf(name);
  36032. }
  36033. // The mappings coming from the consumer for the section have
  36034. // generated positions relative to the start of the section, so we
  36035. // need to offset them to be relative to the start of the concatenated
  36036. // generated file.
  36037. var adjustedMapping = {
  36038. source: source,
  36039. generatedLine: mapping.generatedLine +
  36040. (section.generatedOffset.generatedLine - 1),
  36041. generatedColumn: mapping.generatedColumn +
  36042. (section.generatedOffset.generatedLine === mapping.generatedLine
  36043. ? section.generatedOffset.generatedColumn - 1
  36044. : 0),
  36045. originalLine: mapping.originalLine,
  36046. originalColumn: mapping.originalColumn,
  36047. name: name
  36048. };
  36049. this.__generatedMappings.push(adjustedMapping);
  36050. if (typeof adjustedMapping.originalLine === 'number') {
  36051. this.__originalMappings.push(adjustedMapping);
  36052. }
  36053. }
  36054. }
  36055. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  36056. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  36057. };
  36058. sourceMapConsumer$1.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  36059. return sourceMapConsumer$1;
  36060. }
  36061. var sourceNode$1 = {};
  36062. /* -*- Mode: js; js-indent-level: 2; -*- */
  36063. var hasRequiredSourceNode$1;
  36064. function requireSourceNode$1 () {
  36065. if (hasRequiredSourceNode$1) return sourceNode$1;
  36066. hasRequiredSourceNode$1 = 1;
  36067. /*
  36068. * Copyright 2011 Mozilla Foundation and contributors
  36069. * Licensed under the New BSD license. See LICENSE or:
  36070. * http://opensource.org/licenses/BSD-3-Clause
  36071. */
  36072. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$1().SourceMapGenerator;
  36073. var util = /*@__PURE__*/ requireUtil$2();
  36074. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  36075. // operating systems these days (capturing the result).
  36076. var REGEX_NEWLINE = /(\r?\n)/;
  36077. // Newline character code for charCodeAt() comparisons
  36078. var NEWLINE_CODE = 10;
  36079. // Private symbol for identifying `SourceNode`s when multiple versions of
  36080. // the source-map library are loaded. This MUST NOT CHANGE across
  36081. // versions!
  36082. var isSourceNode = "$$$isSourceNode$$$";
  36083. /**
  36084. * SourceNodes provide a way to abstract over interpolating/concatenating
  36085. * snippets of generated JavaScript source code while maintaining the line and
  36086. * column information associated with the original source code.
  36087. *
  36088. * @param aLine The original line number.
  36089. * @param aColumn The original column number.
  36090. * @param aSource The original source's filename.
  36091. * @param aChunks Optional. An array of strings which are snippets of
  36092. * generated JS, or other SourceNodes.
  36093. * @param aName The original identifier.
  36094. */
  36095. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  36096. this.children = [];
  36097. this.sourceContents = {};
  36098. this.line = aLine == null ? null : aLine;
  36099. this.column = aColumn == null ? null : aColumn;
  36100. this.source = aSource == null ? null : aSource;
  36101. this.name = aName == null ? null : aName;
  36102. this[isSourceNode] = true;
  36103. if (aChunks != null) this.add(aChunks);
  36104. }
  36105. /**
  36106. * Creates a SourceNode from generated code and a SourceMapConsumer.
  36107. *
  36108. * @param aGeneratedCode The generated code
  36109. * @param aSourceMapConsumer The SourceMap for the generated code
  36110. * @param aRelativePath Optional. The path that relative sources in the
  36111. * SourceMapConsumer should be relative to.
  36112. */
  36113. SourceNode.fromStringWithSourceMap =
  36114. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  36115. // The SourceNode we want to fill with the generated code
  36116. // and the SourceMap
  36117. var node = new SourceNode();
  36118. // All even indices of this array are one line of the generated code,
  36119. // while all odd indices are the newlines between two adjacent lines
  36120. // (since `REGEX_NEWLINE` captures its match).
  36121. // Processed fragments are accessed by calling `shiftNextLine`.
  36122. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  36123. var remainingLinesIndex = 0;
  36124. var shiftNextLine = function() {
  36125. var lineContents = getNextLine();
  36126. // The last line of a file might not have a newline.
  36127. var newLine = getNextLine() || "";
  36128. return lineContents + newLine;
  36129. function getNextLine() {
  36130. return remainingLinesIndex < remainingLines.length ?
  36131. remainingLines[remainingLinesIndex++] : undefined;
  36132. }
  36133. };
  36134. // We need to remember the position of "remainingLines"
  36135. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  36136. // The generate SourceNodes we need a code range.
  36137. // To extract it current and last mapping is used.
  36138. // Here we store the last mapping.
  36139. var lastMapping = null;
  36140. aSourceMapConsumer.eachMapping(function (mapping) {
  36141. if (lastMapping !== null) {
  36142. // We add the code from "lastMapping" to "mapping":
  36143. // First check if there is a new line in between.
  36144. if (lastGeneratedLine < mapping.generatedLine) {
  36145. // Associate first line with "lastMapping"
  36146. addMappingWithCode(lastMapping, shiftNextLine());
  36147. lastGeneratedLine++;
  36148. lastGeneratedColumn = 0;
  36149. // The remaining code is added without mapping
  36150. } else {
  36151. // There is no new line in between.
  36152. // Associate the code between "lastGeneratedColumn" and
  36153. // "mapping.generatedColumn" with "lastMapping"
  36154. var nextLine = remainingLines[remainingLinesIndex] || '';
  36155. var code = nextLine.substr(0, mapping.generatedColumn -
  36156. lastGeneratedColumn);
  36157. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  36158. lastGeneratedColumn);
  36159. lastGeneratedColumn = mapping.generatedColumn;
  36160. addMappingWithCode(lastMapping, code);
  36161. // No more remaining code, continue
  36162. lastMapping = mapping;
  36163. return;
  36164. }
  36165. }
  36166. // We add the generated code until the first mapping
  36167. // to the SourceNode without any mapping.
  36168. // Each line is added as separate string.
  36169. while (lastGeneratedLine < mapping.generatedLine) {
  36170. node.add(shiftNextLine());
  36171. lastGeneratedLine++;
  36172. }
  36173. if (lastGeneratedColumn < mapping.generatedColumn) {
  36174. var nextLine = remainingLines[remainingLinesIndex] || '';
  36175. node.add(nextLine.substr(0, mapping.generatedColumn));
  36176. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  36177. lastGeneratedColumn = mapping.generatedColumn;
  36178. }
  36179. lastMapping = mapping;
  36180. }, this);
  36181. // We have processed all mappings.
  36182. if (remainingLinesIndex < remainingLines.length) {
  36183. if (lastMapping) {
  36184. // Associate the remaining code in the current line with "lastMapping"
  36185. addMappingWithCode(lastMapping, shiftNextLine());
  36186. }
  36187. // and add the remaining lines without any mapping
  36188. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  36189. }
  36190. // Copy sourcesContent into SourceNode
  36191. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  36192. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  36193. if (content != null) {
  36194. if (aRelativePath != null) {
  36195. sourceFile = util.join(aRelativePath, sourceFile);
  36196. }
  36197. node.setSourceContent(sourceFile, content);
  36198. }
  36199. });
  36200. return node;
  36201. function addMappingWithCode(mapping, code) {
  36202. if (mapping === null || mapping.source === undefined) {
  36203. node.add(code);
  36204. } else {
  36205. var source = aRelativePath
  36206. ? util.join(aRelativePath, mapping.source)
  36207. : mapping.source;
  36208. node.add(new SourceNode(mapping.originalLine,
  36209. mapping.originalColumn,
  36210. source,
  36211. code,
  36212. mapping.name));
  36213. }
  36214. }
  36215. };
  36216. /**
  36217. * Add a chunk of generated JS to this source node.
  36218. *
  36219. * @param aChunk A string snippet of generated JS code, another instance of
  36220. * SourceNode, or an array where each member is one of those things.
  36221. */
  36222. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  36223. if (Array.isArray(aChunk)) {
  36224. aChunk.forEach(function (chunk) {
  36225. this.add(chunk);
  36226. }, this);
  36227. }
  36228. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  36229. if (aChunk) {
  36230. this.children.push(aChunk);
  36231. }
  36232. }
  36233. else {
  36234. throw new TypeError(
  36235. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  36236. );
  36237. }
  36238. return this;
  36239. };
  36240. /**
  36241. * Add a chunk of generated JS to the beginning of this source node.
  36242. *
  36243. * @param aChunk A string snippet of generated JS code, another instance of
  36244. * SourceNode, or an array where each member is one of those things.
  36245. */
  36246. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  36247. if (Array.isArray(aChunk)) {
  36248. for (var i = aChunk.length-1; i >= 0; i--) {
  36249. this.prepend(aChunk[i]);
  36250. }
  36251. }
  36252. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  36253. this.children.unshift(aChunk);
  36254. }
  36255. else {
  36256. throw new TypeError(
  36257. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  36258. );
  36259. }
  36260. return this;
  36261. };
  36262. /**
  36263. * Walk over the tree of JS snippets in this node and its children. The
  36264. * walking function is called once for each snippet of JS and is passed that
  36265. * snippet and the its original associated source's line/column location.
  36266. *
  36267. * @param aFn The traversal function.
  36268. */
  36269. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  36270. var chunk;
  36271. for (var i = 0, len = this.children.length; i < len; i++) {
  36272. chunk = this.children[i];
  36273. if (chunk[isSourceNode]) {
  36274. chunk.walk(aFn);
  36275. }
  36276. else {
  36277. if (chunk !== '') {
  36278. aFn(chunk, { source: this.source,
  36279. line: this.line,
  36280. column: this.column,
  36281. name: this.name });
  36282. }
  36283. }
  36284. }
  36285. };
  36286. /**
  36287. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  36288. * each of `this.children`.
  36289. *
  36290. * @param aSep The separator.
  36291. */
  36292. SourceNode.prototype.join = function SourceNode_join(aSep) {
  36293. var newChildren;
  36294. var i;
  36295. var len = this.children.length;
  36296. if (len > 0) {
  36297. newChildren = [];
  36298. for (i = 0; i < len-1; i++) {
  36299. newChildren.push(this.children[i]);
  36300. newChildren.push(aSep);
  36301. }
  36302. newChildren.push(this.children[i]);
  36303. this.children = newChildren;
  36304. }
  36305. return this;
  36306. };
  36307. /**
  36308. * Call String.prototype.replace on the very right-most source snippet. Useful
  36309. * for trimming whitespace from the end of a source node, etc.
  36310. *
  36311. * @param aPattern The pattern to replace.
  36312. * @param aReplacement The thing to replace the pattern with.
  36313. */
  36314. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  36315. var lastChild = this.children[this.children.length - 1];
  36316. if (lastChild[isSourceNode]) {
  36317. lastChild.replaceRight(aPattern, aReplacement);
  36318. }
  36319. else if (typeof lastChild === 'string') {
  36320. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  36321. }
  36322. else {
  36323. this.children.push(''.replace(aPattern, aReplacement));
  36324. }
  36325. return this;
  36326. };
  36327. /**
  36328. * Set the source content for a source file. This will be added to the SourceMapGenerator
  36329. * in the sourcesContent field.
  36330. *
  36331. * @param aSourceFile The filename of the source file
  36332. * @param aSourceContent The content of the source file
  36333. */
  36334. SourceNode.prototype.setSourceContent =
  36335. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  36336. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  36337. };
  36338. /**
  36339. * Walk over the tree of SourceNodes. The walking function is called for each
  36340. * source file content and is passed the filename and source content.
  36341. *
  36342. * @param aFn The traversal function.
  36343. */
  36344. SourceNode.prototype.walkSourceContents =
  36345. function SourceNode_walkSourceContents(aFn) {
  36346. for (var i = 0, len = this.children.length; i < len; i++) {
  36347. if (this.children[i][isSourceNode]) {
  36348. this.children[i].walkSourceContents(aFn);
  36349. }
  36350. }
  36351. var sources = Object.keys(this.sourceContents);
  36352. for (var i = 0, len = sources.length; i < len; i++) {
  36353. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  36354. }
  36355. };
  36356. /**
  36357. * Return the string representation of this source node. Walks over the tree
  36358. * and concatenates all the various snippets together to one string.
  36359. */
  36360. SourceNode.prototype.toString = function SourceNode_toString() {
  36361. var str = "";
  36362. this.walk(function (chunk) {
  36363. str += chunk;
  36364. });
  36365. return str;
  36366. };
  36367. /**
  36368. * Returns the string representation of this source node along with a source
  36369. * map.
  36370. */
  36371. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  36372. var generated = {
  36373. code: "",
  36374. line: 1,
  36375. column: 0
  36376. };
  36377. var map = new SourceMapGenerator(aArgs);
  36378. var sourceMappingActive = false;
  36379. var lastOriginalSource = null;
  36380. var lastOriginalLine = null;
  36381. var lastOriginalColumn = null;
  36382. var lastOriginalName = null;
  36383. this.walk(function (chunk, original) {
  36384. generated.code += chunk;
  36385. if (original.source !== null
  36386. && original.line !== null
  36387. && original.column !== null) {
  36388. if(lastOriginalSource !== original.source
  36389. || lastOriginalLine !== original.line
  36390. || lastOriginalColumn !== original.column
  36391. || lastOriginalName !== original.name) {
  36392. map.addMapping({
  36393. source: original.source,
  36394. original: {
  36395. line: original.line,
  36396. column: original.column
  36397. },
  36398. generated: {
  36399. line: generated.line,
  36400. column: generated.column
  36401. },
  36402. name: original.name
  36403. });
  36404. }
  36405. lastOriginalSource = original.source;
  36406. lastOriginalLine = original.line;
  36407. lastOriginalColumn = original.column;
  36408. lastOriginalName = original.name;
  36409. sourceMappingActive = true;
  36410. } else if (sourceMappingActive) {
  36411. map.addMapping({
  36412. generated: {
  36413. line: generated.line,
  36414. column: generated.column
  36415. }
  36416. });
  36417. lastOriginalSource = null;
  36418. sourceMappingActive = false;
  36419. }
  36420. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  36421. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  36422. generated.line++;
  36423. generated.column = 0;
  36424. // Mappings end at eol
  36425. if (idx + 1 === length) {
  36426. lastOriginalSource = null;
  36427. sourceMappingActive = false;
  36428. } else if (sourceMappingActive) {
  36429. map.addMapping({
  36430. source: original.source,
  36431. original: {
  36432. line: original.line,
  36433. column: original.column
  36434. },
  36435. generated: {
  36436. line: generated.line,
  36437. column: generated.column
  36438. },
  36439. name: original.name
  36440. });
  36441. }
  36442. } else {
  36443. generated.column++;
  36444. }
  36445. }
  36446. });
  36447. this.walkSourceContents(function (sourceFile, sourceContent) {
  36448. map.setSourceContent(sourceFile, sourceContent);
  36449. });
  36450. return { code: generated.code, map: map };
  36451. };
  36452. sourceNode$1.SourceNode = SourceNode;
  36453. return sourceNode$1;
  36454. }
  36455. /*
  36456. * Copyright 2009-2011 Mozilla Foundation and contributors
  36457. * Licensed under the New BSD license. See LICENSE.txt or:
  36458. * http://opensource.org/licenses/BSD-3-Clause
  36459. */
  36460. var hasRequiredSourceMap$1;
  36461. function requireSourceMap$1 () {
  36462. if (hasRequiredSourceMap$1) return sourceMap$1;
  36463. hasRequiredSourceMap$1 = 1;
  36464. sourceMap$1.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator$1().SourceMapGenerator;
  36465. sourceMap$1.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer$1().SourceMapConsumer;
  36466. sourceMap$1.SourceNode = /*@__PURE__*/ requireSourceNode$1().SourceNode;
  36467. return sourceMap$1;
  36468. }
  36469. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  36470. var previousMap;
  36471. var hasRequiredPreviousMap;
  36472. function requirePreviousMap () {
  36473. if (hasRequiredPreviousMap) return previousMap;
  36474. hasRequiredPreviousMap = 1;
  36475. let { existsSync, readFileSync } = require$$0$2;
  36476. let { dirname, join } = require$$1;
  36477. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  36478. function fromBase64(str) {
  36479. if (Buffer$1) {
  36480. return Buffer$1.from(str, 'base64').toString()
  36481. } else {
  36482. /* c8 ignore next 2 */
  36483. return window.atob(str)
  36484. }
  36485. }
  36486. class PreviousMap {
  36487. constructor(css, opts) {
  36488. if (opts.map === false) return
  36489. this.loadAnnotation(css);
  36490. this.inline = this.startWith(this.annotation, 'data:');
  36491. let prev = opts.map ? opts.map.prev : undefined;
  36492. let text = this.loadMap(opts.from, prev);
  36493. if (!this.mapFile && opts.from) {
  36494. this.mapFile = opts.from;
  36495. }
  36496. if (this.mapFile) this.root = dirname(this.mapFile);
  36497. if (text) this.text = text;
  36498. }
  36499. consumer() {
  36500. if (!this.consumerCache) {
  36501. this.consumerCache = new SourceMapConsumer(this.text);
  36502. }
  36503. return this.consumerCache
  36504. }
  36505. decodeInline(text) {
  36506. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  36507. let baseUri = /^data:application\/json;base64,/;
  36508. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  36509. let uri = /^data:application\/json,/;
  36510. let uriMatch = text.match(charsetUri) || text.match(uri);
  36511. if (uriMatch) {
  36512. return decodeURIComponent(text.substr(uriMatch[0].length))
  36513. }
  36514. let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
  36515. if (baseUriMatch) {
  36516. return fromBase64(text.substr(baseUriMatch[0].length))
  36517. }
  36518. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  36519. throw new Error('Unsupported source map encoding ' + encoding)
  36520. }
  36521. getAnnotationURL(sourceMapString) {
  36522. return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
  36523. }
  36524. isMap(map) {
  36525. if (typeof map !== 'object') return false
  36526. return (
  36527. typeof map.mappings === 'string' ||
  36528. typeof map._mappings === 'string' ||
  36529. Array.isArray(map.sections)
  36530. )
  36531. }
  36532. loadAnnotation(css) {
  36533. let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
  36534. if (!comments) return
  36535. // sourceMappingURLs from comments, strings, etc.
  36536. let start = css.lastIndexOf(comments.pop());
  36537. let end = css.indexOf('*/', start);
  36538. if (start > -1 && end > -1) {
  36539. // Locate the last sourceMappingURL to avoid pickin
  36540. this.annotation = this.getAnnotationURL(css.substring(start, end));
  36541. }
  36542. }
  36543. loadFile(path) {
  36544. this.root = dirname(path);
  36545. if (existsSync(path)) {
  36546. this.mapFile = path;
  36547. return readFileSync(path, 'utf-8').toString().trim()
  36548. }
  36549. }
  36550. loadMap(file, prev) {
  36551. if (prev === false) return false
  36552. if (prev) {
  36553. if (typeof prev === 'string') {
  36554. return prev
  36555. } else if (typeof prev === 'function') {
  36556. let prevPath = prev(file);
  36557. if (prevPath) {
  36558. let map = this.loadFile(prevPath);
  36559. if (!map) {
  36560. throw new Error(
  36561. 'Unable to load previous source map: ' + prevPath.toString()
  36562. )
  36563. }
  36564. return map
  36565. }
  36566. } else if (prev instanceof SourceMapConsumer) {
  36567. return SourceMapGenerator.fromSourceMap(prev).toString()
  36568. } else if (prev instanceof SourceMapGenerator) {
  36569. return prev.toString()
  36570. } else if (this.isMap(prev)) {
  36571. return JSON.stringify(prev)
  36572. } else {
  36573. throw new Error(
  36574. 'Unsupported previous source map format: ' + prev.toString()
  36575. )
  36576. }
  36577. } else if (this.inline) {
  36578. return this.decodeInline(this.annotation)
  36579. } else if (this.annotation) {
  36580. let map = this.annotation;
  36581. if (file) map = join(dirname(file), map);
  36582. return this.loadFile(map)
  36583. }
  36584. }
  36585. startWith(string, start) {
  36586. if (!string) return false
  36587. return string.substr(0, start.length) === start
  36588. }
  36589. withContent() {
  36590. return !!(
  36591. this.consumer().sourcesContent &&
  36592. this.consumer().sourcesContent.length > 0
  36593. )
  36594. }
  36595. }
  36596. previousMap = PreviousMap;
  36597. PreviousMap.default = PreviousMap;
  36598. return previousMap;
  36599. }
  36600. var input;
  36601. var hasRequiredInput;
  36602. function requireInput () {
  36603. if (hasRequiredInput) return input;
  36604. hasRequiredInput = 1;
  36605. let { nanoid } = /*@__PURE__*/ requireNonSecure();
  36606. let { isAbsolute, resolve } = require$$1;
  36607. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  36608. let { fileURLToPath, pathToFileURL } = require$$2;
  36609. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  36610. let PreviousMap = /*@__PURE__*/ requirePreviousMap();
  36611. let terminalHighlight = /*@__PURE__*/ requireTerminalHighlight();
  36612. let fromOffsetCache = Symbol('fromOffsetCache');
  36613. let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
  36614. let pathAvailable = Boolean(resolve && isAbsolute);
  36615. class Input {
  36616. constructor(css, opts = {}) {
  36617. if (
  36618. css === null ||
  36619. typeof css === 'undefined' ||
  36620. (typeof css === 'object' && !css.toString)
  36621. ) {
  36622. throw new Error(`PostCSS received ${css} instead of CSS string`)
  36623. }
  36624. this.css = css.toString();
  36625. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  36626. this.hasBOM = true;
  36627. this.css = this.css.slice(1);
  36628. } else {
  36629. this.hasBOM = false;
  36630. }
  36631. if (opts.from) {
  36632. if (
  36633. !pathAvailable ||
  36634. /^\w+:\/\//.test(opts.from) ||
  36635. isAbsolute(opts.from)
  36636. ) {
  36637. this.file = opts.from;
  36638. } else {
  36639. this.file = resolve(opts.from);
  36640. }
  36641. }
  36642. if (pathAvailable && sourceMapAvailable) {
  36643. let map = new PreviousMap(this.css, opts);
  36644. if (map.text) {
  36645. this.map = map;
  36646. let file = map.consumer().file;
  36647. if (!this.file && file) this.file = this.mapResolve(file);
  36648. }
  36649. }
  36650. if (!this.file) {
  36651. this.id = '<input css ' + nanoid(6) + '>';
  36652. }
  36653. if (this.map) this.map.file = this.from;
  36654. }
  36655. error(message, line, column, opts = {}) {
  36656. let endColumn, endLine, result;
  36657. if (line && typeof line === 'object') {
  36658. let start = line;
  36659. let end = column;
  36660. if (typeof start.offset === 'number') {
  36661. let pos = this.fromOffset(start.offset);
  36662. line = pos.line;
  36663. column = pos.col;
  36664. } else {
  36665. line = start.line;
  36666. column = start.column;
  36667. }
  36668. if (typeof end.offset === 'number') {
  36669. let pos = this.fromOffset(end.offset);
  36670. endLine = pos.line;
  36671. endColumn = pos.col;
  36672. } else {
  36673. endLine = end.line;
  36674. endColumn = end.column;
  36675. }
  36676. } else if (!column) {
  36677. let pos = this.fromOffset(line);
  36678. line = pos.line;
  36679. column = pos.col;
  36680. }
  36681. let origin = this.origin(line, column, endLine, endColumn);
  36682. if (origin) {
  36683. result = new CssSyntaxError(
  36684. message,
  36685. origin.endLine === undefined
  36686. ? origin.line
  36687. : { column: origin.column, line: origin.line },
  36688. origin.endLine === undefined
  36689. ? origin.column
  36690. : { column: origin.endColumn, line: origin.endLine },
  36691. origin.source,
  36692. origin.file,
  36693. opts.plugin
  36694. );
  36695. } else {
  36696. result = new CssSyntaxError(
  36697. message,
  36698. endLine === undefined ? line : { column, line },
  36699. endLine === undefined ? column : { column: endColumn, line: endLine },
  36700. this.css,
  36701. this.file,
  36702. opts.plugin
  36703. );
  36704. }
  36705. result.input = { column, endColumn, endLine, line, source: this.css };
  36706. if (this.file) {
  36707. if (pathToFileURL) {
  36708. result.input.url = pathToFileURL(this.file).toString();
  36709. }
  36710. result.input.file = this.file;
  36711. }
  36712. return result
  36713. }
  36714. fromOffset(offset) {
  36715. let lastLine, lineToIndex;
  36716. if (!this[fromOffsetCache]) {
  36717. let lines = this.css.split('\n');
  36718. lineToIndex = new Array(lines.length);
  36719. let prevIndex = 0;
  36720. for (let i = 0, l = lines.length; i < l; i++) {
  36721. lineToIndex[i] = prevIndex;
  36722. prevIndex += lines[i].length + 1;
  36723. }
  36724. this[fromOffsetCache] = lineToIndex;
  36725. } else {
  36726. lineToIndex = this[fromOffsetCache];
  36727. }
  36728. lastLine = lineToIndex[lineToIndex.length - 1];
  36729. let min = 0;
  36730. if (offset >= lastLine) {
  36731. min = lineToIndex.length - 1;
  36732. } else {
  36733. let max = lineToIndex.length - 2;
  36734. let mid;
  36735. while (min < max) {
  36736. mid = min + ((max - min) >> 1);
  36737. if (offset < lineToIndex[mid]) {
  36738. max = mid - 1;
  36739. } else if (offset >= lineToIndex[mid + 1]) {
  36740. min = mid + 1;
  36741. } else {
  36742. min = mid;
  36743. break
  36744. }
  36745. }
  36746. }
  36747. return {
  36748. col: offset - lineToIndex[min] + 1,
  36749. line: min + 1
  36750. }
  36751. }
  36752. mapResolve(file) {
  36753. if (/^\w+:\/\//.test(file)) {
  36754. return file
  36755. }
  36756. return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
  36757. }
  36758. origin(line, column, endLine, endColumn) {
  36759. if (!this.map) return false
  36760. let consumer = this.map.consumer();
  36761. let from = consumer.originalPositionFor({ column, line });
  36762. if (!from.source) return false
  36763. let to;
  36764. if (typeof endLine === 'number') {
  36765. to = consumer.originalPositionFor({ column: endColumn, line: endLine });
  36766. }
  36767. let fromUrl;
  36768. if (isAbsolute(from.source)) {
  36769. fromUrl = pathToFileURL(from.source);
  36770. } else {
  36771. fromUrl = new URL(
  36772. from.source,
  36773. this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
  36774. );
  36775. }
  36776. let result = {
  36777. column: from.column,
  36778. endColumn: to && to.column,
  36779. endLine: to && to.line,
  36780. line: from.line,
  36781. url: fromUrl.toString()
  36782. };
  36783. if (fromUrl.protocol === 'file:') {
  36784. if (fileURLToPath) {
  36785. result.file = fileURLToPath(fromUrl);
  36786. } else {
  36787. /* c8 ignore next 2 */
  36788. throw new Error(`file: protocol is not available in this PostCSS build`)
  36789. }
  36790. }
  36791. let source = consumer.sourceContentFor(from.source);
  36792. if (source) result.source = source;
  36793. return result
  36794. }
  36795. toJSON() {
  36796. let json = {};
  36797. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  36798. if (this[name] != null) {
  36799. json[name] = this[name];
  36800. }
  36801. }
  36802. if (this.map) {
  36803. json.map = { ...this.map };
  36804. if (json.map.consumerCache) {
  36805. json.map.consumerCache = undefined;
  36806. }
  36807. }
  36808. return json
  36809. }
  36810. get from() {
  36811. return this.file || this.id
  36812. }
  36813. }
  36814. input = Input;
  36815. Input.default = Input;
  36816. if (terminalHighlight && terminalHighlight.registerInput) {
  36817. terminalHighlight.registerInput(Input);
  36818. }
  36819. return input;
  36820. }
  36821. var root$1;
  36822. var hasRequiredRoot$1;
  36823. function requireRoot$1 () {
  36824. if (hasRequiredRoot$1) return root$1;
  36825. hasRequiredRoot$1 = 1;
  36826. let Container = /*@__PURE__*/ requireContainer$1();
  36827. let LazyResult, Processor;
  36828. class Root extends Container {
  36829. constructor(defaults) {
  36830. super(defaults);
  36831. this.type = 'root';
  36832. if (!this.nodes) this.nodes = [];
  36833. }
  36834. normalize(child, sample, type) {
  36835. let nodes = super.normalize(child);
  36836. if (sample) {
  36837. if (type === 'prepend') {
  36838. if (this.nodes.length > 1) {
  36839. sample.raws.before = this.nodes[1].raws.before;
  36840. } else {
  36841. delete sample.raws.before;
  36842. }
  36843. } else if (this.first !== sample) {
  36844. for (let node of nodes) {
  36845. node.raws.before = sample.raws.before;
  36846. }
  36847. }
  36848. }
  36849. return nodes
  36850. }
  36851. removeChild(child, ignore) {
  36852. let index = this.index(child);
  36853. if (!ignore && index === 0 && this.nodes.length > 1) {
  36854. this.nodes[1].raws.before = this.nodes[index].raws.before;
  36855. }
  36856. return super.removeChild(child)
  36857. }
  36858. toResult(opts = {}) {
  36859. let lazy = new LazyResult(new Processor(), this, opts);
  36860. return lazy.stringify()
  36861. }
  36862. }
  36863. Root.registerLazyResult = dependant => {
  36864. LazyResult = dependant;
  36865. };
  36866. Root.registerProcessor = dependant => {
  36867. Processor = dependant;
  36868. };
  36869. root$1 = Root;
  36870. Root.default = Root;
  36871. Container.registerRoot(Root);
  36872. return root$1;
  36873. }
  36874. var list_1;
  36875. var hasRequiredList;
  36876. function requireList () {
  36877. if (hasRequiredList) return list_1;
  36878. hasRequiredList = 1;
  36879. let list = {
  36880. comma(string) {
  36881. return list.split(string, [','], true)
  36882. },
  36883. space(string) {
  36884. let spaces = [' ', '\n', '\t'];
  36885. return list.split(string, spaces)
  36886. },
  36887. split(string, separators, last) {
  36888. let array = [];
  36889. let current = '';
  36890. let split = false;
  36891. let func = 0;
  36892. let inQuote = false;
  36893. let prevQuote = '';
  36894. let escape = false;
  36895. for (let letter of string) {
  36896. if (escape) {
  36897. escape = false;
  36898. } else if (letter === '\\') {
  36899. escape = true;
  36900. } else if (inQuote) {
  36901. if (letter === prevQuote) {
  36902. inQuote = false;
  36903. }
  36904. } else if (letter === '"' || letter === "'") {
  36905. inQuote = true;
  36906. prevQuote = letter;
  36907. } else if (letter === '(') {
  36908. func += 1;
  36909. } else if (letter === ')') {
  36910. if (func > 0) func -= 1;
  36911. } else if (func === 0) {
  36912. if (separators.includes(letter)) split = true;
  36913. }
  36914. if (split) {
  36915. if (current !== '') array.push(current.trim());
  36916. current = '';
  36917. split = false;
  36918. } else {
  36919. current += letter;
  36920. }
  36921. }
  36922. if (last || current !== '') array.push(current.trim());
  36923. return array
  36924. }
  36925. };
  36926. list_1 = list;
  36927. list.default = list;
  36928. return list_1;
  36929. }
  36930. var rule;
  36931. var hasRequiredRule;
  36932. function requireRule () {
  36933. if (hasRequiredRule) return rule;
  36934. hasRequiredRule = 1;
  36935. let Container = /*@__PURE__*/ requireContainer$1();
  36936. let list = /*@__PURE__*/ requireList();
  36937. class Rule extends Container {
  36938. constructor(defaults) {
  36939. super(defaults);
  36940. this.type = 'rule';
  36941. if (!this.nodes) this.nodes = [];
  36942. }
  36943. get selectors() {
  36944. return list.comma(this.selector)
  36945. }
  36946. set selectors(values) {
  36947. let match = this.selector ? this.selector.match(/,\s*/) : null;
  36948. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  36949. this.selector = values.join(sep);
  36950. }
  36951. }
  36952. rule = Rule;
  36953. Rule.default = Rule;
  36954. Container.registerRule(Rule);
  36955. return rule;
  36956. }
  36957. var fromJSON_1;
  36958. var hasRequiredFromJSON;
  36959. function requireFromJSON () {
  36960. if (hasRequiredFromJSON) return fromJSON_1;
  36961. hasRequiredFromJSON = 1;
  36962. let AtRule = /*@__PURE__*/ requireAtRule();
  36963. let Comment = /*@__PURE__*/ requireComment$1();
  36964. let Declaration = /*@__PURE__*/ requireDeclaration();
  36965. let Input = /*@__PURE__*/ requireInput();
  36966. let PreviousMap = /*@__PURE__*/ requirePreviousMap();
  36967. let Root = /*@__PURE__*/ requireRoot$1();
  36968. let Rule = /*@__PURE__*/ requireRule();
  36969. function fromJSON(json, inputs) {
  36970. if (Array.isArray(json)) return json.map(n => fromJSON(n))
  36971. let { inputs: ownInputs, ...defaults } = json;
  36972. if (ownInputs) {
  36973. inputs = [];
  36974. for (let input of ownInputs) {
  36975. let inputHydrated = { ...input, __proto__: Input.prototype };
  36976. if (inputHydrated.map) {
  36977. inputHydrated.map = {
  36978. ...inputHydrated.map,
  36979. __proto__: PreviousMap.prototype
  36980. };
  36981. }
  36982. inputs.push(inputHydrated);
  36983. }
  36984. }
  36985. if (defaults.nodes) {
  36986. defaults.nodes = json.nodes.map(n => fromJSON(n, inputs));
  36987. }
  36988. if (defaults.source) {
  36989. let { inputId, ...source } = defaults.source;
  36990. defaults.source = source;
  36991. if (inputId != null) {
  36992. defaults.source.input = inputs[inputId];
  36993. }
  36994. }
  36995. if (defaults.type === 'root') {
  36996. return new Root(defaults)
  36997. } else if (defaults.type === 'decl') {
  36998. return new Declaration(defaults)
  36999. } else if (defaults.type === 'rule') {
  37000. return new Rule(defaults)
  37001. } else if (defaults.type === 'comment') {
  37002. return new Comment(defaults)
  37003. } else if (defaults.type === 'atrule') {
  37004. return new AtRule(defaults)
  37005. } else {
  37006. throw new Error('Unknown node type: ' + json.type)
  37007. }
  37008. }
  37009. fromJSON_1 = fromJSON;
  37010. fromJSON.default = fromJSON;
  37011. return fromJSON_1;
  37012. }
  37013. var mapGenerator;
  37014. var hasRequiredMapGenerator;
  37015. function requireMapGenerator () {
  37016. if (hasRequiredMapGenerator) return mapGenerator;
  37017. hasRequiredMapGenerator = 1;
  37018. let { dirname, relative, resolve, sep } = require$$1;
  37019. let { SourceMapConsumer, SourceMapGenerator } = /*@__PURE__*/ requireSourceMap$1();
  37020. let { pathToFileURL } = require$$2;
  37021. let Input = /*@__PURE__*/ requireInput();
  37022. let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
  37023. let pathAvailable = Boolean(dirname && resolve && relative && sep);
  37024. class MapGenerator {
  37025. constructor(stringify, root, opts, cssString) {
  37026. this.stringify = stringify;
  37027. this.mapOpts = opts.map || {};
  37028. this.root = root;
  37029. this.opts = opts;
  37030. this.css = cssString;
  37031. this.originalCSS = cssString;
  37032. this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
  37033. this.memoizedFileURLs = new Map();
  37034. this.memoizedPaths = new Map();
  37035. this.memoizedURLs = new Map();
  37036. }
  37037. addAnnotation() {
  37038. let content;
  37039. if (this.isInline()) {
  37040. content =
  37041. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  37042. } else if (typeof this.mapOpts.annotation === 'string') {
  37043. content = this.mapOpts.annotation;
  37044. } else if (typeof this.mapOpts.annotation === 'function') {
  37045. content = this.mapOpts.annotation(this.opts.to, this.root);
  37046. } else {
  37047. content = this.outputFile() + '.map';
  37048. }
  37049. let eol = '\n';
  37050. if (this.css.includes('\r\n')) eol = '\r\n';
  37051. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  37052. }
  37053. applyPrevMaps() {
  37054. for (let prev of this.previous()) {
  37055. let from = this.toUrl(this.path(prev.file));
  37056. let root = prev.root || dirname(prev.file);
  37057. let map;
  37058. if (this.mapOpts.sourcesContent === false) {
  37059. map = new SourceMapConsumer(prev.text);
  37060. if (map.sourcesContent) {
  37061. map.sourcesContent = null;
  37062. }
  37063. } else {
  37064. map = prev.consumer();
  37065. }
  37066. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  37067. }
  37068. }
  37069. clearAnnotation() {
  37070. if (this.mapOpts.annotation === false) return
  37071. if (this.root) {
  37072. let node;
  37073. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  37074. node = this.root.nodes[i];
  37075. if (node.type !== 'comment') continue
  37076. if (node.text.startsWith('# sourceMappingURL=')) {
  37077. this.root.removeChild(i);
  37078. }
  37079. }
  37080. } else if (this.css) {
  37081. this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
  37082. }
  37083. }
  37084. generate() {
  37085. this.clearAnnotation();
  37086. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  37087. return this.generateMap()
  37088. } else {
  37089. let result = '';
  37090. this.stringify(this.root, i => {
  37091. result += i;
  37092. });
  37093. return [result]
  37094. }
  37095. }
  37096. generateMap() {
  37097. if (this.root) {
  37098. this.generateString();
  37099. } else if (this.previous().length === 1) {
  37100. let prev = this.previous()[0].consumer();
  37101. prev.file = this.outputFile();
  37102. this.map = SourceMapGenerator.fromSourceMap(prev, {
  37103. ignoreInvalidMapping: true
  37104. });
  37105. } else {
  37106. this.map = new SourceMapGenerator({
  37107. file: this.outputFile(),
  37108. ignoreInvalidMapping: true
  37109. });
  37110. this.map.addMapping({
  37111. generated: { column: 0, line: 1 },
  37112. original: { column: 0, line: 1 },
  37113. source: this.opts.from
  37114. ? this.toUrl(this.path(this.opts.from))
  37115. : '<no source>'
  37116. });
  37117. }
  37118. if (this.isSourcesContent()) this.setSourcesContent();
  37119. if (this.root && this.previous().length > 0) this.applyPrevMaps();
  37120. if (this.isAnnotation()) this.addAnnotation();
  37121. if (this.isInline()) {
  37122. return [this.css]
  37123. } else {
  37124. return [this.css, this.map]
  37125. }
  37126. }
  37127. generateString() {
  37128. this.css = '';
  37129. this.map = new SourceMapGenerator({
  37130. file: this.outputFile(),
  37131. ignoreInvalidMapping: true
  37132. });
  37133. let line = 1;
  37134. let column = 1;
  37135. let noSource = '<no source>';
  37136. let mapping = {
  37137. generated: { column: 0, line: 0 },
  37138. original: { column: 0, line: 0 },
  37139. source: ''
  37140. };
  37141. let last, lines;
  37142. this.stringify(this.root, (str, node, type) => {
  37143. this.css += str;
  37144. if (node && type !== 'end') {
  37145. mapping.generated.line = line;
  37146. mapping.generated.column = column - 1;
  37147. if (node.source && node.source.start) {
  37148. mapping.source = this.sourcePath(node);
  37149. mapping.original.line = node.source.start.line;
  37150. mapping.original.column = node.source.start.column - 1;
  37151. this.map.addMapping(mapping);
  37152. } else {
  37153. mapping.source = noSource;
  37154. mapping.original.line = 1;
  37155. mapping.original.column = 0;
  37156. this.map.addMapping(mapping);
  37157. }
  37158. }
  37159. lines = str.match(/\n/g);
  37160. if (lines) {
  37161. line += lines.length;
  37162. last = str.lastIndexOf('\n');
  37163. column = str.length - last;
  37164. } else {
  37165. column += str.length;
  37166. }
  37167. if (node && type !== 'start') {
  37168. let p = node.parent || { raws: {} };
  37169. let childless =
  37170. node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
  37171. if (!childless || node !== p.last || p.raws.semicolon) {
  37172. if (node.source && node.source.end) {
  37173. mapping.source = this.sourcePath(node);
  37174. mapping.original.line = node.source.end.line;
  37175. mapping.original.column = node.source.end.column - 1;
  37176. mapping.generated.line = line;
  37177. mapping.generated.column = column - 2;
  37178. this.map.addMapping(mapping);
  37179. } else {
  37180. mapping.source = noSource;
  37181. mapping.original.line = 1;
  37182. mapping.original.column = 0;
  37183. mapping.generated.line = line;
  37184. mapping.generated.column = column - 1;
  37185. this.map.addMapping(mapping);
  37186. }
  37187. }
  37188. }
  37189. });
  37190. }
  37191. isAnnotation() {
  37192. if (this.isInline()) {
  37193. return true
  37194. }
  37195. if (typeof this.mapOpts.annotation !== 'undefined') {
  37196. return this.mapOpts.annotation
  37197. }
  37198. if (this.previous().length) {
  37199. return this.previous().some(i => i.annotation)
  37200. }
  37201. return true
  37202. }
  37203. isInline() {
  37204. if (typeof this.mapOpts.inline !== 'undefined') {
  37205. return this.mapOpts.inline
  37206. }
  37207. let annotation = this.mapOpts.annotation;
  37208. if (typeof annotation !== 'undefined' && annotation !== true) {
  37209. return false
  37210. }
  37211. if (this.previous().length) {
  37212. return this.previous().some(i => i.inline)
  37213. }
  37214. return true
  37215. }
  37216. isMap() {
  37217. if (typeof this.opts.map !== 'undefined') {
  37218. return !!this.opts.map
  37219. }
  37220. return this.previous().length > 0
  37221. }
  37222. isSourcesContent() {
  37223. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  37224. return this.mapOpts.sourcesContent
  37225. }
  37226. if (this.previous().length) {
  37227. return this.previous().some(i => i.withContent())
  37228. }
  37229. return true
  37230. }
  37231. outputFile() {
  37232. if (this.opts.to) {
  37233. return this.path(this.opts.to)
  37234. } else if (this.opts.from) {
  37235. return this.path(this.opts.from)
  37236. } else {
  37237. return 'to.css'
  37238. }
  37239. }
  37240. path(file) {
  37241. if (this.mapOpts.absolute) return file
  37242. if (file.charCodeAt(0) === 60 /* `<` */) return file
  37243. if (/^\w+:\/\//.test(file)) return file
  37244. let cached = this.memoizedPaths.get(file);
  37245. if (cached) return cached
  37246. let from = this.opts.to ? dirname(this.opts.to) : '.';
  37247. if (typeof this.mapOpts.annotation === 'string') {
  37248. from = dirname(resolve(from, this.mapOpts.annotation));
  37249. }
  37250. let path = relative(from, file);
  37251. this.memoizedPaths.set(file, path);
  37252. return path
  37253. }
  37254. previous() {
  37255. if (!this.previousMaps) {
  37256. this.previousMaps = [];
  37257. if (this.root) {
  37258. this.root.walk(node => {
  37259. if (node.source && node.source.input.map) {
  37260. let map = node.source.input.map;
  37261. if (!this.previousMaps.includes(map)) {
  37262. this.previousMaps.push(map);
  37263. }
  37264. }
  37265. });
  37266. } else {
  37267. let input = new Input(this.originalCSS, this.opts);
  37268. if (input.map) this.previousMaps.push(input.map);
  37269. }
  37270. }
  37271. return this.previousMaps
  37272. }
  37273. setSourcesContent() {
  37274. let already = {};
  37275. if (this.root) {
  37276. this.root.walk(node => {
  37277. if (node.source) {
  37278. let from = node.source.input.from;
  37279. if (from && !already[from]) {
  37280. already[from] = true;
  37281. let fromUrl = this.usesFileUrls
  37282. ? this.toFileUrl(from)
  37283. : this.toUrl(this.path(from));
  37284. this.map.setSourceContent(fromUrl, node.source.input.css);
  37285. }
  37286. }
  37287. });
  37288. } else if (this.css) {
  37289. let from = this.opts.from
  37290. ? this.toUrl(this.path(this.opts.from))
  37291. : '<no source>';
  37292. this.map.setSourceContent(from, this.css);
  37293. }
  37294. }
  37295. sourcePath(node) {
  37296. if (this.mapOpts.from) {
  37297. return this.toUrl(this.mapOpts.from)
  37298. } else if (this.usesFileUrls) {
  37299. return this.toFileUrl(node.source.input.from)
  37300. } else {
  37301. return this.toUrl(this.path(node.source.input.from))
  37302. }
  37303. }
  37304. toBase64(str) {
  37305. if (Buffer$1) {
  37306. return Buffer$1.from(str).toString('base64')
  37307. } else {
  37308. return window.btoa(unescape(encodeURIComponent(str)))
  37309. }
  37310. }
  37311. toFileUrl(path) {
  37312. let cached = this.memoizedFileURLs.get(path);
  37313. if (cached) return cached
  37314. if (pathToFileURL) {
  37315. let fileURL = pathToFileURL(path).toString();
  37316. this.memoizedFileURLs.set(path, fileURL);
  37317. return fileURL
  37318. } else {
  37319. throw new Error(
  37320. '`map.absolute` option is not available in this PostCSS build'
  37321. )
  37322. }
  37323. }
  37324. toUrl(path) {
  37325. let cached = this.memoizedURLs.get(path);
  37326. if (cached) return cached
  37327. if (sep === '\\') {
  37328. path = path.replace(/\\/g, '/');
  37329. }
  37330. let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
  37331. this.memoizedURLs.set(path, url);
  37332. return url
  37333. }
  37334. }
  37335. mapGenerator = MapGenerator;
  37336. return mapGenerator;
  37337. }
  37338. var parser$1;
  37339. var hasRequiredParser$1;
  37340. function requireParser$1 () {
  37341. if (hasRequiredParser$1) return parser$1;
  37342. hasRequiredParser$1 = 1;
  37343. let AtRule = /*@__PURE__*/ requireAtRule();
  37344. let Comment = /*@__PURE__*/ requireComment$1();
  37345. let Declaration = /*@__PURE__*/ requireDeclaration();
  37346. let Root = /*@__PURE__*/ requireRoot$1();
  37347. let Rule = /*@__PURE__*/ requireRule();
  37348. let tokenizer = /*@__PURE__*/ requireTokenize$1();
  37349. const SAFE_COMMENT_NEIGHBOR = {
  37350. empty: true,
  37351. space: true
  37352. };
  37353. function findLastWithPosition(tokens) {
  37354. for (let i = tokens.length - 1; i >= 0; i--) {
  37355. let token = tokens[i];
  37356. let pos = token[3] || token[2];
  37357. if (pos) return pos
  37358. }
  37359. }
  37360. class Parser {
  37361. constructor(input) {
  37362. this.input = input;
  37363. this.root = new Root();
  37364. this.current = this.root;
  37365. this.spaces = '';
  37366. this.semicolon = false;
  37367. this.createTokenizer();
  37368. this.root.source = { input, start: { column: 1, line: 1, offset: 0 } };
  37369. }
  37370. atrule(token) {
  37371. let node = new AtRule();
  37372. node.name = token[1].slice(1);
  37373. if (node.name === '') {
  37374. this.unnamedAtrule(node, token);
  37375. }
  37376. this.init(node, token[2]);
  37377. let type;
  37378. let prev;
  37379. let shift;
  37380. let last = false;
  37381. let open = false;
  37382. let params = [];
  37383. let brackets = [];
  37384. while (!this.tokenizer.endOfFile()) {
  37385. token = this.tokenizer.nextToken();
  37386. type = token[0];
  37387. if (type === '(' || type === '[') {
  37388. brackets.push(type === '(' ? ')' : ']');
  37389. } else if (type === '{' && brackets.length > 0) {
  37390. brackets.push('}');
  37391. } else if (type === brackets[brackets.length - 1]) {
  37392. brackets.pop();
  37393. }
  37394. if (brackets.length === 0) {
  37395. if (type === ';') {
  37396. node.source.end = this.getPosition(token[2]);
  37397. node.source.end.offset++;
  37398. this.semicolon = true;
  37399. break
  37400. } else if (type === '{') {
  37401. open = true;
  37402. break
  37403. } else if (type === '}') {
  37404. if (params.length > 0) {
  37405. shift = params.length - 1;
  37406. prev = params[shift];
  37407. while (prev && prev[0] === 'space') {
  37408. prev = params[--shift];
  37409. }
  37410. if (prev) {
  37411. node.source.end = this.getPosition(prev[3] || prev[2]);
  37412. node.source.end.offset++;
  37413. }
  37414. }
  37415. this.end(token);
  37416. break
  37417. } else {
  37418. params.push(token);
  37419. }
  37420. } else {
  37421. params.push(token);
  37422. }
  37423. if (this.tokenizer.endOfFile()) {
  37424. last = true;
  37425. break
  37426. }
  37427. }
  37428. node.raws.between = this.spacesAndCommentsFromEnd(params);
  37429. if (params.length) {
  37430. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  37431. this.raw(node, 'params', params);
  37432. if (last) {
  37433. token = params[params.length - 1];
  37434. node.source.end = this.getPosition(token[3] || token[2]);
  37435. node.source.end.offset++;
  37436. this.spaces = node.raws.between;
  37437. node.raws.between = '';
  37438. }
  37439. } else {
  37440. node.raws.afterName = '';
  37441. node.params = '';
  37442. }
  37443. if (open) {
  37444. node.nodes = [];
  37445. this.current = node;
  37446. }
  37447. }
  37448. checkMissedSemicolon(tokens) {
  37449. let colon = this.colon(tokens);
  37450. if (colon === false) return
  37451. let founded = 0;
  37452. let token;
  37453. for (let j = colon - 1; j >= 0; j--) {
  37454. token = tokens[j];
  37455. if (token[0] !== 'space') {
  37456. founded += 1;
  37457. if (founded === 2) break
  37458. }
  37459. }
  37460. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  37461. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  37462. // And because we need it after that one we do +1 to get the next one.
  37463. throw this.input.error(
  37464. 'Missed semicolon',
  37465. token[0] === 'word' ? token[3] + 1 : token[2]
  37466. )
  37467. }
  37468. colon(tokens) {
  37469. let brackets = 0;
  37470. let prev, token, type;
  37471. for (let [i, element] of tokens.entries()) {
  37472. token = element;
  37473. type = token[0];
  37474. if (type === '(') {
  37475. brackets += 1;
  37476. }
  37477. if (type === ')') {
  37478. brackets -= 1;
  37479. }
  37480. if (brackets === 0 && type === ':') {
  37481. if (!prev) {
  37482. this.doubleColon(token);
  37483. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  37484. continue
  37485. } else {
  37486. return i
  37487. }
  37488. }
  37489. prev = token;
  37490. }
  37491. return false
  37492. }
  37493. comment(token) {
  37494. let node = new Comment();
  37495. this.init(node, token[2]);
  37496. node.source.end = this.getPosition(token[3] || token[2]);
  37497. node.source.end.offset++;
  37498. let text = token[1].slice(2, -2);
  37499. if (/^\s*$/.test(text)) {
  37500. node.text = '';
  37501. node.raws.left = text;
  37502. node.raws.right = '';
  37503. } else {
  37504. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  37505. node.text = match[2];
  37506. node.raws.left = match[1];
  37507. node.raws.right = match[3];
  37508. }
  37509. }
  37510. createTokenizer() {
  37511. this.tokenizer = tokenizer(this.input);
  37512. }
  37513. decl(tokens, customProperty) {
  37514. let node = new Declaration();
  37515. this.init(node, tokens[0][2]);
  37516. let last = tokens[tokens.length - 1];
  37517. if (last[0] === ';') {
  37518. this.semicolon = true;
  37519. tokens.pop();
  37520. }
  37521. node.source.end = this.getPosition(
  37522. last[3] || last[2] || findLastWithPosition(tokens)
  37523. );
  37524. node.source.end.offset++;
  37525. while (tokens[0][0] !== 'word') {
  37526. if (tokens.length === 1) this.unknownWord(tokens);
  37527. node.raws.before += tokens.shift()[1];
  37528. }
  37529. node.source.start = this.getPosition(tokens[0][2]);
  37530. node.prop = '';
  37531. while (tokens.length) {
  37532. let type = tokens[0][0];
  37533. if (type === ':' || type === 'space' || type === 'comment') {
  37534. break
  37535. }
  37536. node.prop += tokens.shift()[1];
  37537. }
  37538. node.raws.between = '';
  37539. let token;
  37540. while (tokens.length) {
  37541. token = tokens.shift();
  37542. if (token[0] === ':') {
  37543. node.raws.between += token[1];
  37544. break
  37545. } else {
  37546. if (token[0] === 'word' && /\w/.test(token[1])) {
  37547. this.unknownWord([token]);
  37548. }
  37549. node.raws.between += token[1];
  37550. }
  37551. }
  37552. if (node.prop[0] === '_' || node.prop[0] === '*') {
  37553. node.raws.before += node.prop[0];
  37554. node.prop = node.prop.slice(1);
  37555. }
  37556. let firstSpaces = [];
  37557. let next;
  37558. while (tokens.length) {
  37559. next = tokens[0][0];
  37560. if (next !== 'space' && next !== 'comment') break
  37561. firstSpaces.push(tokens.shift());
  37562. }
  37563. this.precheckMissedSemicolon(tokens);
  37564. for (let i = tokens.length - 1; i >= 0; i--) {
  37565. token = tokens[i];
  37566. if (token[1].toLowerCase() === '!important') {
  37567. node.important = true;
  37568. let string = this.stringFrom(tokens, i);
  37569. string = this.spacesFromEnd(tokens) + string;
  37570. if (string !== ' !important') node.raws.important = string;
  37571. break
  37572. } else if (token[1].toLowerCase() === 'important') {
  37573. let cache = tokens.slice(0);
  37574. let str = '';
  37575. for (let j = i; j > 0; j--) {
  37576. let type = cache[j][0];
  37577. if (str.trim().startsWith('!') && type !== 'space') {
  37578. break
  37579. }
  37580. str = cache.pop()[1] + str;
  37581. }
  37582. if (str.trim().startsWith('!')) {
  37583. node.important = true;
  37584. node.raws.important = str;
  37585. tokens = cache;
  37586. }
  37587. }
  37588. if (token[0] !== 'space' && token[0] !== 'comment') {
  37589. break
  37590. }
  37591. }
  37592. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  37593. if (hasWord) {
  37594. node.raws.between += firstSpaces.map(i => i[1]).join('');
  37595. firstSpaces = [];
  37596. }
  37597. this.raw(node, 'value', firstSpaces.concat(tokens), customProperty);
  37598. if (node.value.includes(':') && !customProperty) {
  37599. this.checkMissedSemicolon(tokens);
  37600. }
  37601. }
  37602. doubleColon(token) {
  37603. throw this.input.error(
  37604. 'Double colon',
  37605. { offset: token[2] },
  37606. { offset: token[2] + token[1].length }
  37607. )
  37608. }
  37609. emptyRule(token) {
  37610. let node = new Rule();
  37611. this.init(node, token[2]);
  37612. node.selector = '';
  37613. node.raws.between = '';
  37614. this.current = node;
  37615. }
  37616. end(token) {
  37617. if (this.current.nodes && this.current.nodes.length) {
  37618. this.current.raws.semicolon = this.semicolon;
  37619. }
  37620. this.semicolon = false;
  37621. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  37622. this.spaces = '';
  37623. if (this.current.parent) {
  37624. this.current.source.end = this.getPosition(token[2]);
  37625. this.current.source.end.offset++;
  37626. this.current = this.current.parent;
  37627. } else {
  37628. this.unexpectedClose(token);
  37629. }
  37630. }
  37631. endFile() {
  37632. if (this.current.parent) this.unclosedBlock();
  37633. if (this.current.nodes && this.current.nodes.length) {
  37634. this.current.raws.semicolon = this.semicolon;
  37635. }
  37636. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  37637. this.root.source.end = this.getPosition(this.tokenizer.position());
  37638. }
  37639. freeSemicolon(token) {
  37640. this.spaces += token[1];
  37641. if (this.current.nodes) {
  37642. let prev = this.current.nodes[this.current.nodes.length - 1];
  37643. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  37644. prev.raws.ownSemicolon = this.spaces;
  37645. this.spaces = '';
  37646. }
  37647. }
  37648. }
  37649. // Helpers
  37650. getPosition(offset) {
  37651. let pos = this.input.fromOffset(offset);
  37652. return {
  37653. column: pos.col,
  37654. line: pos.line,
  37655. offset
  37656. }
  37657. }
  37658. init(node, offset) {
  37659. this.current.push(node);
  37660. node.source = {
  37661. input: this.input,
  37662. start: this.getPosition(offset)
  37663. };
  37664. node.raws.before = this.spaces;
  37665. this.spaces = '';
  37666. if (node.type !== 'comment') this.semicolon = false;
  37667. }
  37668. other(start) {
  37669. let end = false;
  37670. let type = null;
  37671. let colon = false;
  37672. let bracket = null;
  37673. let brackets = [];
  37674. let customProperty = start[1].startsWith('--');
  37675. let tokens = [];
  37676. let token = start;
  37677. while (token) {
  37678. type = token[0];
  37679. tokens.push(token);
  37680. if (type === '(' || type === '[') {
  37681. if (!bracket) bracket = token;
  37682. brackets.push(type === '(' ? ')' : ']');
  37683. } else if (customProperty && colon && type === '{') {
  37684. if (!bracket) bracket = token;
  37685. brackets.push('}');
  37686. } else if (brackets.length === 0) {
  37687. if (type === ';') {
  37688. if (colon) {
  37689. this.decl(tokens, customProperty);
  37690. return
  37691. } else {
  37692. break
  37693. }
  37694. } else if (type === '{') {
  37695. this.rule(tokens);
  37696. return
  37697. } else if (type === '}') {
  37698. this.tokenizer.back(tokens.pop());
  37699. end = true;
  37700. break
  37701. } else if (type === ':') {
  37702. colon = true;
  37703. }
  37704. } else if (type === brackets[brackets.length - 1]) {
  37705. brackets.pop();
  37706. if (brackets.length === 0) bracket = null;
  37707. }
  37708. token = this.tokenizer.nextToken();
  37709. }
  37710. if (this.tokenizer.endOfFile()) end = true;
  37711. if (brackets.length > 0) this.unclosedBracket(bracket);
  37712. if (end && colon) {
  37713. if (!customProperty) {
  37714. while (tokens.length) {
  37715. token = tokens[tokens.length - 1][0];
  37716. if (token !== 'space' && token !== 'comment') break
  37717. this.tokenizer.back(tokens.pop());
  37718. }
  37719. }
  37720. this.decl(tokens, customProperty);
  37721. } else {
  37722. this.unknownWord(tokens);
  37723. }
  37724. }
  37725. parse() {
  37726. let token;
  37727. while (!this.tokenizer.endOfFile()) {
  37728. token = this.tokenizer.nextToken();
  37729. switch (token[0]) {
  37730. case 'space':
  37731. this.spaces += token[1];
  37732. break
  37733. case ';':
  37734. this.freeSemicolon(token);
  37735. break
  37736. case '}':
  37737. this.end(token);
  37738. break
  37739. case 'comment':
  37740. this.comment(token);
  37741. break
  37742. case 'at-word':
  37743. this.atrule(token);
  37744. break
  37745. case '{':
  37746. this.emptyRule(token);
  37747. break
  37748. default:
  37749. this.other(token);
  37750. break
  37751. }
  37752. }
  37753. this.endFile();
  37754. }
  37755. precheckMissedSemicolon(/* tokens */) {
  37756. // Hook for Safe Parser
  37757. }
  37758. raw(node, prop, tokens, customProperty) {
  37759. let token, type;
  37760. let length = tokens.length;
  37761. let value = '';
  37762. let clean = true;
  37763. let next, prev;
  37764. for (let i = 0; i < length; i += 1) {
  37765. token = tokens[i];
  37766. type = token[0];
  37767. if (type === 'space' && i === length - 1 && !customProperty) {
  37768. clean = false;
  37769. } else if (type === 'comment') {
  37770. prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty';
  37771. next = tokens[i + 1] ? tokens[i + 1][0] : 'empty';
  37772. if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
  37773. if (value.slice(-1) === ',') {
  37774. clean = false;
  37775. } else {
  37776. value += token[1];
  37777. }
  37778. } else {
  37779. clean = false;
  37780. }
  37781. } else {
  37782. value += token[1];
  37783. }
  37784. }
  37785. if (!clean) {
  37786. let raw = tokens.reduce((all, i) => all + i[1], '');
  37787. node.raws[prop] = { raw, value };
  37788. }
  37789. node[prop] = value;
  37790. }
  37791. rule(tokens) {
  37792. tokens.pop();
  37793. let node = new Rule();
  37794. this.init(node, tokens[0][2]);
  37795. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  37796. this.raw(node, 'selector', tokens);
  37797. this.current = node;
  37798. }
  37799. spacesAndCommentsFromEnd(tokens) {
  37800. let lastTokenType;
  37801. let spaces = '';
  37802. while (tokens.length) {
  37803. lastTokenType = tokens[tokens.length - 1][0];
  37804. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  37805. spaces = tokens.pop()[1] + spaces;
  37806. }
  37807. return spaces
  37808. }
  37809. // Errors
  37810. spacesAndCommentsFromStart(tokens) {
  37811. let next;
  37812. let spaces = '';
  37813. while (tokens.length) {
  37814. next = tokens[0][0];
  37815. if (next !== 'space' && next !== 'comment') break
  37816. spaces += tokens.shift()[1];
  37817. }
  37818. return spaces
  37819. }
  37820. spacesFromEnd(tokens) {
  37821. let lastTokenType;
  37822. let spaces = '';
  37823. while (tokens.length) {
  37824. lastTokenType = tokens[tokens.length - 1][0];
  37825. if (lastTokenType !== 'space') break
  37826. spaces = tokens.pop()[1] + spaces;
  37827. }
  37828. return spaces
  37829. }
  37830. stringFrom(tokens, from) {
  37831. let result = '';
  37832. for (let i = from; i < tokens.length; i++) {
  37833. result += tokens[i][1];
  37834. }
  37835. tokens.splice(from, tokens.length - from);
  37836. return result
  37837. }
  37838. unclosedBlock() {
  37839. let pos = this.current.source.start;
  37840. throw this.input.error('Unclosed block', pos.line, pos.column)
  37841. }
  37842. unclosedBracket(bracket) {
  37843. throw this.input.error(
  37844. 'Unclosed bracket',
  37845. { offset: bracket[2] },
  37846. { offset: bracket[2] + 1 }
  37847. )
  37848. }
  37849. unexpectedClose(token) {
  37850. throw this.input.error(
  37851. 'Unexpected }',
  37852. { offset: token[2] },
  37853. { offset: token[2] + 1 }
  37854. )
  37855. }
  37856. unknownWord(tokens) {
  37857. throw this.input.error(
  37858. 'Unknown word',
  37859. { offset: tokens[0][2] },
  37860. { offset: tokens[0][2] + tokens[0][1].length }
  37861. )
  37862. }
  37863. unnamedAtrule(node, token) {
  37864. throw this.input.error(
  37865. 'At-rule without name',
  37866. { offset: token[2] },
  37867. { offset: token[2] + token[1].length }
  37868. )
  37869. }
  37870. }
  37871. parser$1 = Parser;
  37872. return parser$1;
  37873. }
  37874. var parse_1;
  37875. var hasRequiredParse;
  37876. function requireParse () {
  37877. if (hasRequiredParse) return parse_1;
  37878. hasRequiredParse = 1;
  37879. let Container = /*@__PURE__*/ requireContainer$1();
  37880. let Input = /*@__PURE__*/ requireInput();
  37881. let Parser = /*@__PURE__*/ requireParser$1();
  37882. function parse(css, opts) {
  37883. let input = new Input(css, opts);
  37884. let parser = new Parser(input);
  37885. try {
  37886. parser.parse();
  37887. } catch (e) {
  37888. if (browser$1.env.NODE_ENV !== 'production') {
  37889. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  37890. if (/\.scss$/i.test(opts.from)) {
  37891. e.message +=
  37892. '\nYou tried to parse SCSS with ' +
  37893. 'the standard CSS parser; ' +
  37894. 'try again with the postcss-scss parser';
  37895. } else if (/\.sass/i.test(opts.from)) {
  37896. e.message +=
  37897. '\nYou tried to parse Sass with ' +
  37898. 'the standard CSS parser; ' +
  37899. 'try again with the postcss-sass parser';
  37900. } else if (/\.less$/i.test(opts.from)) {
  37901. e.message +=
  37902. '\nYou tried to parse Less with ' +
  37903. 'the standard CSS parser; ' +
  37904. 'try again with the postcss-less parser';
  37905. }
  37906. }
  37907. }
  37908. throw e
  37909. }
  37910. return parser.root
  37911. }
  37912. parse_1 = parse;
  37913. parse.default = parse;
  37914. Container.registerParse(parse);
  37915. return parse_1;
  37916. }
  37917. var warning;
  37918. var hasRequiredWarning;
  37919. function requireWarning () {
  37920. if (hasRequiredWarning) return warning;
  37921. hasRequiredWarning = 1;
  37922. class Warning {
  37923. constructor(text, opts = {}) {
  37924. this.type = 'warning';
  37925. this.text = text;
  37926. if (opts.node && opts.node.source) {
  37927. let range = opts.node.rangeBy(opts);
  37928. this.line = range.start.line;
  37929. this.column = range.start.column;
  37930. this.endLine = range.end.line;
  37931. this.endColumn = range.end.column;
  37932. }
  37933. for (let opt in opts) this[opt] = opts[opt];
  37934. }
  37935. toString() {
  37936. if (this.node) {
  37937. return this.node.error(this.text, {
  37938. index: this.index,
  37939. plugin: this.plugin,
  37940. word: this.word
  37941. }).message
  37942. }
  37943. if (this.plugin) {
  37944. return this.plugin + ': ' + this.text
  37945. }
  37946. return this.text
  37947. }
  37948. }
  37949. warning = Warning;
  37950. Warning.default = Warning;
  37951. return warning;
  37952. }
  37953. var result;
  37954. var hasRequiredResult;
  37955. function requireResult () {
  37956. if (hasRequiredResult) return result;
  37957. hasRequiredResult = 1;
  37958. let Warning = /*@__PURE__*/ requireWarning();
  37959. class Result {
  37960. constructor(processor, root, opts) {
  37961. this.processor = processor;
  37962. this.messages = [];
  37963. this.root = root;
  37964. this.opts = opts;
  37965. this.css = undefined;
  37966. this.map = undefined;
  37967. }
  37968. toString() {
  37969. return this.css
  37970. }
  37971. warn(text, opts = {}) {
  37972. if (!opts.plugin) {
  37973. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  37974. opts.plugin = this.lastPlugin.postcssPlugin;
  37975. }
  37976. }
  37977. let warning = new Warning(text, opts);
  37978. this.messages.push(warning);
  37979. return warning
  37980. }
  37981. warnings() {
  37982. return this.messages.filter(i => i.type === 'warning')
  37983. }
  37984. get content() {
  37985. return this.css
  37986. }
  37987. }
  37988. result = Result;
  37989. Result.default = Result;
  37990. return result;
  37991. }
  37992. /* eslint-disable no-console */
  37993. var warnOnce;
  37994. var hasRequiredWarnOnce;
  37995. function requireWarnOnce () {
  37996. if (hasRequiredWarnOnce) return warnOnce;
  37997. hasRequiredWarnOnce = 1;
  37998. let printed = {};
  37999. warnOnce = function warnOnce(message) {
  38000. if (printed[message]) return
  38001. printed[message] = true;
  38002. if (typeof console !== 'undefined' && console.warn) {
  38003. console.warn(message);
  38004. }
  38005. };
  38006. return warnOnce;
  38007. }
  38008. var lazyResult;
  38009. var hasRequiredLazyResult;
  38010. function requireLazyResult () {
  38011. if (hasRequiredLazyResult) return lazyResult;
  38012. hasRequiredLazyResult = 1;
  38013. let Container = /*@__PURE__*/ requireContainer$1();
  38014. let Document = /*@__PURE__*/ requireDocument();
  38015. let MapGenerator = /*@__PURE__*/ requireMapGenerator();
  38016. let parse = /*@__PURE__*/ requireParse();
  38017. let Result = /*@__PURE__*/ requireResult();
  38018. let Root = /*@__PURE__*/ requireRoot$1();
  38019. let stringify = /*@__PURE__*/ requireStringify();
  38020. let { isClean, my } = /*@__PURE__*/ requireSymbols();
  38021. let warnOnce = /*@__PURE__*/ requireWarnOnce();
  38022. const TYPE_TO_CLASS_NAME = {
  38023. atrule: 'AtRule',
  38024. comment: 'Comment',
  38025. decl: 'Declaration',
  38026. document: 'Document',
  38027. root: 'Root',
  38028. rule: 'Rule'
  38029. };
  38030. const PLUGIN_PROPS = {
  38031. AtRule: true,
  38032. AtRuleExit: true,
  38033. Comment: true,
  38034. CommentExit: true,
  38035. Declaration: true,
  38036. DeclarationExit: true,
  38037. Document: true,
  38038. DocumentExit: true,
  38039. Once: true,
  38040. OnceExit: true,
  38041. postcssPlugin: true,
  38042. prepare: true,
  38043. Root: true,
  38044. RootExit: true,
  38045. Rule: true,
  38046. RuleExit: true
  38047. };
  38048. const NOT_VISITORS = {
  38049. Once: true,
  38050. postcssPlugin: true,
  38051. prepare: true
  38052. };
  38053. const CHILDREN = 0;
  38054. function isPromise(obj) {
  38055. return typeof obj === 'object' && typeof obj.then === 'function'
  38056. }
  38057. function getEvents(node) {
  38058. let key = false;
  38059. let type = TYPE_TO_CLASS_NAME[node.type];
  38060. if (node.type === 'decl') {
  38061. key = node.prop.toLowerCase();
  38062. } else if (node.type === 'atrule') {
  38063. key = node.name.toLowerCase();
  38064. }
  38065. if (key && node.append) {
  38066. return [
  38067. type,
  38068. type + '-' + key,
  38069. CHILDREN,
  38070. type + 'Exit',
  38071. type + 'Exit-' + key
  38072. ]
  38073. } else if (key) {
  38074. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  38075. } else if (node.append) {
  38076. return [type, CHILDREN, type + 'Exit']
  38077. } else {
  38078. return [type, type + 'Exit']
  38079. }
  38080. }
  38081. function toStack(node) {
  38082. let events;
  38083. if (node.type === 'document') {
  38084. events = ['Document', CHILDREN, 'DocumentExit'];
  38085. } else if (node.type === 'root') {
  38086. events = ['Root', CHILDREN, 'RootExit'];
  38087. } else {
  38088. events = getEvents(node);
  38089. }
  38090. return {
  38091. eventIndex: 0,
  38092. events,
  38093. iterator: 0,
  38094. node,
  38095. visitorIndex: 0,
  38096. visitors: []
  38097. }
  38098. }
  38099. function cleanMarks(node) {
  38100. node[isClean] = false;
  38101. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  38102. return node
  38103. }
  38104. let postcss = {};
  38105. class LazyResult {
  38106. constructor(processor, css, opts) {
  38107. this.stringified = false;
  38108. this.processed = false;
  38109. let root;
  38110. if (
  38111. typeof css === 'object' &&
  38112. css !== null &&
  38113. (css.type === 'root' || css.type === 'document')
  38114. ) {
  38115. root = cleanMarks(css);
  38116. } else if (css instanceof LazyResult || css instanceof Result) {
  38117. root = cleanMarks(css.root);
  38118. if (css.map) {
  38119. if (typeof opts.map === 'undefined') opts.map = {};
  38120. if (!opts.map.inline) opts.map.inline = false;
  38121. opts.map.prev = css.map;
  38122. }
  38123. } else {
  38124. let parser = parse;
  38125. if (opts.syntax) parser = opts.syntax.parse;
  38126. if (opts.parser) parser = opts.parser;
  38127. if (parser.parse) parser = parser.parse;
  38128. try {
  38129. root = parser(css, opts);
  38130. } catch (error) {
  38131. this.processed = true;
  38132. this.error = error;
  38133. }
  38134. if (root && !root[my]) {
  38135. /* c8 ignore next 2 */
  38136. Container.rebuild(root);
  38137. }
  38138. }
  38139. this.result = new Result(processor, root, opts);
  38140. this.helpers = { ...postcss, postcss, result: this.result };
  38141. this.plugins = this.processor.plugins.map(plugin => {
  38142. if (typeof plugin === 'object' && plugin.prepare) {
  38143. return { ...plugin, ...plugin.prepare(this.result) }
  38144. } else {
  38145. return plugin
  38146. }
  38147. });
  38148. }
  38149. async() {
  38150. if (this.error) return Promise.reject(this.error)
  38151. if (this.processed) return Promise.resolve(this.result)
  38152. if (!this.processing) {
  38153. this.processing = this.runAsync();
  38154. }
  38155. return this.processing
  38156. }
  38157. catch(onRejected) {
  38158. return this.async().catch(onRejected)
  38159. }
  38160. finally(onFinally) {
  38161. return this.async().then(onFinally, onFinally)
  38162. }
  38163. getAsyncError() {
  38164. throw new Error('Use process(css).then(cb) to work with async plugins')
  38165. }
  38166. handleError(error, node) {
  38167. let plugin = this.result.lastPlugin;
  38168. try {
  38169. if (node) node.addToError(error);
  38170. this.error = error;
  38171. if (error.name === 'CssSyntaxError' && !error.plugin) {
  38172. error.plugin = plugin.postcssPlugin;
  38173. error.setMessage();
  38174. } else if (plugin.postcssVersion) {
  38175. if (browser$1.env.NODE_ENV !== 'production') {
  38176. let pluginName = plugin.postcssPlugin;
  38177. let pluginVer = plugin.postcssVersion;
  38178. let runtimeVer = this.result.processor.version;
  38179. let a = pluginVer.split('.');
  38180. let b = runtimeVer.split('.');
  38181. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  38182. // eslint-disable-next-line no-console
  38183. console.error(
  38184. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  38185. 'version is ' +
  38186. runtimeVer +
  38187. ', but ' +
  38188. pluginName +
  38189. ' uses ' +
  38190. pluginVer +
  38191. '. Perhaps this is the source of the error below.'
  38192. );
  38193. }
  38194. }
  38195. }
  38196. } catch (err) {
  38197. /* c8 ignore next 3 */
  38198. // eslint-disable-next-line no-console
  38199. if (console && console.error) console.error(err);
  38200. }
  38201. return error
  38202. }
  38203. prepareVisitors() {
  38204. this.listeners = {};
  38205. let add = (plugin, type, cb) => {
  38206. if (!this.listeners[type]) this.listeners[type] = [];
  38207. this.listeners[type].push([plugin, cb]);
  38208. };
  38209. for (let plugin of this.plugins) {
  38210. if (typeof plugin === 'object') {
  38211. for (let event in plugin) {
  38212. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  38213. throw new Error(
  38214. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  38215. `Try to update PostCSS (${this.processor.version} now).`
  38216. )
  38217. }
  38218. if (!NOT_VISITORS[event]) {
  38219. if (typeof plugin[event] === 'object') {
  38220. for (let filter in plugin[event]) {
  38221. if (filter === '*') {
  38222. add(plugin, event, plugin[event][filter]);
  38223. } else {
  38224. add(
  38225. plugin,
  38226. event + '-' + filter.toLowerCase(),
  38227. plugin[event][filter]
  38228. );
  38229. }
  38230. }
  38231. } else if (typeof plugin[event] === 'function') {
  38232. add(plugin, event, plugin[event]);
  38233. }
  38234. }
  38235. }
  38236. }
  38237. }
  38238. this.hasListener = Object.keys(this.listeners).length > 0;
  38239. }
  38240. async runAsync() {
  38241. this.plugin = 0;
  38242. for (let i = 0; i < this.plugins.length; i++) {
  38243. let plugin = this.plugins[i];
  38244. let promise = this.runOnRoot(plugin);
  38245. if (isPromise(promise)) {
  38246. try {
  38247. await promise;
  38248. } catch (error) {
  38249. throw this.handleError(error)
  38250. }
  38251. }
  38252. }
  38253. this.prepareVisitors();
  38254. if (this.hasListener) {
  38255. let root = this.result.root;
  38256. while (!root[isClean]) {
  38257. root[isClean] = true;
  38258. let stack = [toStack(root)];
  38259. while (stack.length > 0) {
  38260. let promise = this.visitTick(stack);
  38261. if (isPromise(promise)) {
  38262. try {
  38263. await promise;
  38264. } catch (e) {
  38265. let node = stack[stack.length - 1].node;
  38266. throw this.handleError(e, node)
  38267. }
  38268. }
  38269. }
  38270. }
  38271. if (this.listeners.OnceExit) {
  38272. for (let [plugin, visitor] of this.listeners.OnceExit) {
  38273. this.result.lastPlugin = plugin;
  38274. try {
  38275. if (root.type === 'document') {
  38276. let roots = root.nodes.map(subRoot =>
  38277. visitor(subRoot, this.helpers)
  38278. );
  38279. await Promise.all(roots);
  38280. } else {
  38281. await visitor(root, this.helpers);
  38282. }
  38283. } catch (e) {
  38284. throw this.handleError(e)
  38285. }
  38286. }
  38287. }
  38288. }
  38289. this.processed = true;
  38290. return this.stringify()
  38291. }
  38292. runOnRoot(plugin) {
  38293. this.result.lastPlugin = plugin;
  38294. try {
  38295. if (typeof plugin === 'object' && plugin.Once) {
  38296. if (this.result.root.type === 'document') {
  38297. let roots = this.result.root.nodes.map(root =>
  38298. plugin.Once(root, this.helpers)
  38299. );
  38300. if (isPromise(roots[0])) {
  38301. return Promise.all(roots)
  38302. }
  38303. return roots
  38304. }
  38305. return plugin.Once(this.result.root, this.helpers)
  38306. } else if (typeof plugin === 'function') {
  38307. return plugin(this.result.root, this.result)
  38308. }
  38309. } catch (error) {
  38310. throw this.handleError(error)
  38311. }
  38312. }
  38313. stringify() {
  38314. if (this.error) throw this.error
  38315. if (this.stringified) return this.result
  38316. this.stringified = true;
  38317. this.sync();
  38318. let opts = this.result.opts;
  38319. let str = stringify;
  38320. if (opts.syntax) str = opts.syntax.stringify;
  38321. if (opts.stringifier) str = opts.stringifier;
  38322. if (str.stringify) str = str.stringify;
  38323. let map = new MapGenerator(str, this.result.root, this.result.opts);
  38324. let data = map.generate();
  38325. this.result.css = data[0];
  38326. this.result.map = data[1];
  38327. return this.result
  38328. }
  38329. sync() {
  38330. if (this.error) throw this.error
  38331. if (this.processed) return this.result
  38332. this.processed = true;
  38333. if (this.processing) {
  38334. throw this.getAsyncError()
  38335. }
  38336. for (let plugin of this.plugins) {
  38337. let promise = this.runOnRoot(plugin);
  38338. if (isPromise(promise)) {
  38339. throw this.getAsyncError()
  38340. }
  38341. }
  38342. this.prepareVisitors();
  38343. if (this.hasListener) {
  38344. let root = this.result.root;
  38345. while (!root[isClean]) {
  38346. root[isClean] = true;
  38347. this.walkSync(root);
  38348. }
  38349. if (this.listeners.OnceExit) {
  38350. if (root.type === 'document') {
  38351. for (let subRoot of root.nodes) {
  38352. this.visitSync(this.listeners.OnceExit, subRoot);
  38353. }
  38354. } else {
  38355. this.visitSync(this.listeners.OnceExit, root);
  38356. }
  38357. }
  38358. }
  38359. return this.result
  38360. }
  38361. then(onFulfilled, onRejected) {
  38362. if (browser$1.env.NODE_ENV !== 'production') {
  38363. if (!('from' in this.opts)) {
  38364. warnOnce(
  38365. 'Without `from` option PostCSS could generate wrong source map ' +
  38366. 'and will not find Browserslist config. Set it to CSS file path ' +
  38367. 'or to `undefined` to prevent this warning.'
  38368. );
  38369. }
  38370. }
  38371. return this.async().then(onFulfilled, onRejected)
  38372. }
  38373. toString() {
  38374. return this.css
  38375. }
  38376. visitSync(visitors, node) {
  38377. for (let [plugin, visitor] of visitors) {
  38378. this.result.lastPlugin = plugin;
  38379. let promise;
  38380. try {
  38381. promise = visitor(node, this.helpers);
  38382. } catch (e) {
  38383. throw this.handleError(e, node.proxyOf)
  38384. }
  38385. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  38386. return true
  38387. }
  38388. if (isPromise(promise)) {
  38389. throw this.getAsyncError()
  38390. }
  38391. }
  38392. }
  38393. visitTick(stack) {
  38394. let visit = stack[stack.length - 1];
  38395. let { node, visitors } = visit;
  38396. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  38397. stack.pop();
  38398. return
  38399. }
  38400. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  38401. let [plugin, visitor] = visitors[visit.visitorIndex];
  38402. visit.visitorIndex += 1;
  38403. if (visit.visitorIndex === visitors.length) {
  38404. visit.visitors = [];
  38405. visit.visitorIndex = 0;
  38406. }
  38407. this.result.lastPlugin = plugin;
  38408. try {
  38409. return visitor(node.toProxy(), this.helpers)
  38410. } catch (e) {
  38411. throw this.handleError(e, node)
  38412. }
  38413. }
  38414. if (visit.iterator !== 0) {
  38415. let iterator = visit.iterator;
  38416. let child;
  38417. while ((child = node.nodes[node.indexes[iterator]])) {
  38418. node.indexes[iterator] += 1;
  38419. if (!child[isClean]) {
  38420. child[isClean] = true;
  38421. stack.push(toStack(child));
  38422. return
  38423. }
  38424. }
  38425. visit.iterator = 0;
  38426. delete node.indexes[iterator];
  38427. }
  38428. let events = visit.events;
  38429. while (visit.eventIndex < events.length) {
  38430. let event = events[visit.eventIndex];
  38431. visit.eventIndex += 1;
  38432. if (event === CHILDREN) {
  38433. if (node.nodes && node.nodes.length) {
  38434. node[isClean] = true;
  38435. visit.iterator = node.getIterator();
  38436. }
  38437. return
  38438. } else if (this.listeners[event]) {
  38439. visit.visitors = this.listeners[event];
  38440. return
  38441. }
  38442. }
  38443. stack.pop();
  38444. }
  38445. walkSync(node) {
  38446. node[isClean] = true;
  38447. let events = getEvents(node);
  38448. for (let event of events) {
  38449. if (event === CHILDREN) {
  38450. if (node.nodes) {
  38451. node.each(child => {
  38452. if (!child[isClean]) this.walkSync(child);
  38453. });
  38454. }
  38455. } else {
  38456. let visitors = this.listeners[event];
  38457. if (visitors) {
  38458. if (this.visitSync(visitors, node.toProxy())) return
  38459. }
  38460. }
  38461. }
  38462. }
  38463. warnings() {
  38464. return this.sync().warnings()
  38465. }
  38466. get content() {
  38467. return this.stringify().content
  38468. }
  38469. get css() {
  38470. return this.stringify().css
  38471. }
  38472. get map() {
  38473. return this.stringify().map
  38474. }
  38475. get messages() {
  38476. return this.sync().messages
  38477. }
  38478. get opts() {
  38479. return this.result.opts
  38480. }
  38481. get processor() {
  38482. return this.result.processor
  38483. }
  38484. get root() {
  38485. return this.sync().root
  38486. }
  38487. get [Symbol.toStringTag]() {
  38488. return 'LazyResult'
  38489. }
  38490. }
  38491. LazyResult.registerPostcss = dependant => {
  38492. postcss = dependant;
  38493. };
  38494. lazyResult = LazyResult;
  38495. LazyResult.default = LazyResult;
  38496. Root.registerLazyResult(LazyResult);
  38497. Document.registerLazyResult(LazyResult);
  38498. return lazyResult;
  38499. }
  38500. var noWorkResult;
  38501. var hasRequiredNoWorkResult;
  38502. function requireNoWorkResult () {
  38503. if (hasRequiredNoWorkResult) return noWorkResult;
  38504. hasRequiredNoWorkResult = 1;
  38505. let MapGenerator = /*@__PURE__*/ requireMapGenerator();
  38506. let parse = /*@__PURE__*/ requireParse();
  38507. const Result = /*@__PURE__*/ requireResult();
  38508. let stringify = /*@__PURE__*/ requireStringify();
  38509. let warnOnce = /*@__PURE__*/ requireWarnOnce();
  38510. class NoWorkResult {
  38511. constructor(processor, css, opts) {
  38512. css = css.toString();
  38513. this.stringified = false;
  38514. this._processor = processor;
  38515. this._css = css;
  38516. this._opts = opts;
  38517. this._map = undefined;
  38518. let root;
  38519. let str = stringify;
  38520. this.result = new Result(this._processor, root, this._opts);
  38521. this.result.css = css;
  38522. let self = this;
  38523. Object.defineProperty(this.result, 'root', {
  38524. get() {
  38525. return self.root
  38526. }
  38527. });
  38528. let map = new MapGenerator(str, root, this._opts, css);
  38529. if (map.isMap()) {
  38530. let [generatedCSS, generatedMap] = map.generate();
  38531. if (generatedCSS) {
  38532. this.result.css = generatedCSS;
  38533. }
  38534. if (generatedMap) {
  38535. this.result.map = generatedMap;
  38536. }
  38537. } else {
  38538. map.clearAnnotation();
  38539. this.result.css = map.css;
  38540. }
  38541. }
  38542. async() {
  38543. if (this.error) return Promise.reject(this.error)
  38544. return Promise.resolve(this.result)
  38545. }
  38546. catch(onRejected) {
  38547. return this.async().catch(onRejected)
  38548. }
  38549. finally(onFinally) {
  38550. return this.async().then(onFinally, onFinally)
  38551. }
  38552. sync() {
  38553. if (this.error) throw this.error
  38554. return this.result
  38555. }
  38556. then(onFulfilled, onRejected) {
  38557. if (browser$1.env.NODE_ENV !== 'production') {
  38558. if (!('from' in this._opts)) {
  38559. warnOnce(
  38560. 'Without `from` option PostCSS could generate wrong source map ' +
  38561. 'and will not find Browserslist config. Set it to CSS file path ' +
  38562. 'or to `undefined` to prevent this warning.'
  38563. );
  38564. }
  38565. }
  38566. return this.async().then(onFulfilled, onRejected)
  38567. }
  38568. toString() {
  38569. return this._css
  38570. }
  38571. warnings() {
  38572. return []
  38573. }
  38574. get content() {
  38575. return this.result.css
  38576. }
  38577. get css() {
  38578. return this.result.css
  38579. }
  38580. get map() {
  38581. return this.result.map
  38582. }
  38583. get messages() {
  38584. return []
  38585. }
  38586. get opts() {
  38587. return this.result.opts
  38588. }
  38589. get processor() {
  38590. return this.result.processor
  38591. }
  38592. get root() {
  38593. if (this._root) {
  38594. return this._root
  38595. }
  38596. let root;
  38597. let parser = parse;
  38598. try {
  38599. root = parser(this._css, this._opts);
  38600. } catch (error) {
  38601. this.error = error;
  38602. }
  38603. if (this.error) {
  38604. throw this.error
  38605. } else {
  38606. this._root = root;
  38607. return root
  38608. }
  38609. }
  38610. get [Symbol.toStringTag]() {
  38611. return 'NoWorkResult'
  38612. }
  38613. }
  38614. noWorkResult = NoWorkResult;
  38615. NoWorkResult.default = NoWorkResult;
  38616. return noWorkResult;
  38617. }
  38618. var processor$1;
  38619. var hasRequiredProcessor$1;
  38620. function requireProcessor$1 () {
  38621. if (hasRequiredProcessor$1) return processor$1;
  38622. hasRequiredProcessor$1 = 1;
  38623. let Document = /*@__PURE__*/ requireDocument();
  38624. let LazyResult = /*@__PURE__*/ requireLazyResult();
  38625. let NoWorkResult = /*@__PURE__*/ requireNoWorkResult();
  38626. let Root = /*@__PURE__*/ requireRoot$1();
  38627. class Processor {
  38628. constructor(plugins = []) {
  38629. this.version = '8.4.47';
  38630. this.plugins = this.normalize(plugins);
  38631. }
  38632. normalize(plugins) {
  38633. let normalized = [];
  38634. for (let i of plugins) {
  38635. if (i.postcss === true) {
  38636. i = i();
  38637. } else if (i.postcss) {
  38638. i = i.postcss;
  38639. }
  38640. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  38641. normalized = normalized.concat(i.plugins);
  38642. } else if (typeof i === 'object' && i.postcssPlugin) {
  38643. normalized.push(i);
  38644. } else if (typeof i === 'function') {
  38645. normalized.push(i);
  38646. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  38647. if (browser$1.env.NODE_ENV !== 'production') {
  38648. throw new Error(
  38649. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  38650. 'one of the syntax/parser/stringifier options as outlined ' +
  38651. 'in your PostCSS runner documentation.'
  38652. )
  38653. }
  38654. } else {
  38655. throw new Error(i + ' is not a PostCSS plugin')
  38656. }
  38657. }
  38658. return normalized
  38659. }
  38660. process(css, opts = {}) {
  38661. if (
  38662. !this.plugins.length &&
  38663. !opts.parser &&
  38664. !opts.stringifier &&
  38665. !opts.syntax
  38666. ) {
  38667. return new NoWorkResult(this, css, opts)
  38668. } else {
  38669. return new LazyResult(this, css, opts)
  38670. }
  38671. }
  38672. use(plugin) {
  38673. this.plugins = this.plugins.concat(this.normalize([plugin]));
  38674. return this
  38675. }
  38676. }
  38677. processor$1 = Processor;
  38678. Processor.default = Processor;
  38679. Root.registerProcessor(Processor);
  38680. Document.registerProcessor(Processor);
  38681. return processor$1;
  38682. }
  38683. var postcss_1;
  38684. var hasRequiredPostcss;
  38685. function requirePostcss () {
  38686. if (hasRequiredPostcss) return postcss_1;
  38687. hasRequiredPostcss = 1;
  38688. let AtRule = /*@__PURE__*/ requireAtRule();
  38689. let Comment = /*@__PURE__*/ requireComment$1();
  38690. let Container = /*@__PURE__*/ requireContainer$1();
  38691. let CssSyntaxError = /*@__PURE__*/ requireCssSyntaxError();
  38692. let Declaration = /*@__PURE__*/ requireDeclaration();
  38693. let Document = /*@__PURE__*/ requireDocument();
  38694. let fromJSON = /*@__PURE__*/ requireFromJSON();
  38695. let Input = /*@__PURE__*/ requireInput();
  38696. let LazyResult = /*@__PURE__*/ requireLazyResult();
  38697. let list = /*@__PURE__*/ requireList();
  38698. let Node = /*@__PURE__*/ requireNode$2();
  38699. let parse = /*@__PURE__*/ requireParse();
  38700. let Processor = /*@__PURE__*/ requireProcessor$1();
  38701. let Result = /*@__PURE__*/ requireResult();
  38702. let Root = /*@__PURE__*/ requireRoot$1();
  38703. let Rule = /*@__PURE__*/ requireRule();
  38704. let stringify = /*@__PURE__*/ requireStringify();
  38705. let Warning = /*@__PURE__*/ requireWarning();
  38706. function postcss(...plugins) {
  38707. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  38708. plugins = plugins[0];
  38709. }
  38710. return new Processor(plugins)
  38711. }
  38712. postcss.plugin = function plugin(name, initializer) {
  38713. let warningPrinted = false;
  38714. function creator(...args) {
  38715. // eslint-disable-next-line no-console
  38716. if (console && console.warn && !warningPrinted) {
  38717. warningPrinted = true;
  38718. // eslint-disable-next-line no-console
  38719. console.warn(
  38720. name +
  38721. ': postcss.plugin was deprecated. Migration guide:\n' +
  38722. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  38723. );
  38724. if (browser$1.env.LANG && browser$1.env.LANG.startsWith('cn')) {
  38725. /* c8 ignore next 7 */
  38726. // eslint-disable-next-line no-console
  38727. console.warn(
  38728. name +
  38729. ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
  38730. 'https://www.w3ctech.com/topic/2226'
  38731. );
  38732. }
  38733. }
  38734. let transformer = initializer(...args);
  38735. transformer.postcssPlugin = name;
  38736. transformer.postcssVersion = new Processor().version;
  38737. return transformer
  38738. }
  38739. let cache;
  38740. Object.defineProperty(creator, 'postcss', {
  38741. get() {
  38742. if (!cache) cache = creator();
  38743. return cache
  38744. }
  38745. });
  38746. creator.process = function (css, processOpts, pluginOpts) {
  38747. return postcss([creator(pluginOpts)]).process(css, processOpts)
  38748. };
  38749. return creator
  38750. };
  38751. postcss.stringify = stringify;
  38752. postcss.parse = parse;
  38753. postcss.fromJSON = fromJSON;
  38754. postcss.list = list;
  38755. postcss.comment = defaults => new Comment(defaults);
  38756. postcss.atRule = defaults => new AtRule(defaults);
  38757. postcss.decl = defaults => new Declaration(defaults);
  38758. postcss.rule = defaults => new Rule(defaults);
  38759. postcss.root = defaults => new Root(defaults);
  38760. postcss.document = defaults => new Document(defaults);
  38761. postcss.CssSyntaxError = CssSyntaxError;
  38762. postcss.Declaration = Declaration;
  38763. postcss.Container = Container;
  38764. postcss.Processor = Processor;
  38765. postcss.Document = Document;
  38766. postcss.Comment = Comment;
  38767. postcss.Warning = Warning;
  38768. postcss.AtRule = AtRule;
  38769. postcss.Result = Result;
  38770. postcss.Input = Input;
  38771. postcss.Rule = Rule;
  38772. postcss.Root = Root;
  38773. postcss.Node = Node;
  38774. LazyResult.registerPostcss(postcss);
  38775. postcss_1 = postcss;
  38776. postcss.default = postcss;
  38777. return postcss_1;
  38778. }
  38779. var postcssExports = /*@__PURE__*/ requirePostcss();
  38780. var postcss = /*@__PURE__*/getDefaultExportFromCjs(postcssExports);
  38781. postcss.stringify;
  38782. postcss.fromJSON;
  38783. postcss.plugin;
  38784. postcss.parse;
  38785. postcss.list;
  38786. postcss.document;
  38787. postcss.comment;
  38788. postcss.atRule;
  38789. postcss.rule;
  38790. postcss.decl;
  38791. postcss.root;
  38792. postcss.CssSyntaxError;
  38793. postcss.Declaration;
  38794. postcss.Container;
  38795. postcss.Processor;
  38796. postcss.Document;
  38797. postcss.Comment;
  38798. postcss.Warning;
  38799. postcss.AtRule;
  38800. postcss.Result;
  38801. postcss.Input;
  38802. const Rule = postcss.Rule;
  38803. postcss.Root;
  38804. postcss.Node;
  38805. const trimPlugin = () => {
  38806. return {
  38807. postcssPlugin: "vue-sfc-trim",
  38808. Once(root) {
  38809. root.walk(({ type, raws }) => {
  38810. if (type === "rule" || type === "atrule") {
  38811. if (raws.before) raws.before = "\n";
  38812. if ("after" in raws && raws.after) raws.after = "\n";
  38813. }
  38814. });
  38815. }
  38816. };
  38817. };
  38818. trimPlugin.postcss = true;
  38819. var dist = {exports: {}};
  38820. var processor = {exports: {}};
  38821. var parser = {exports: {}};
  38822. var root = {exports: {}};
  38823. var container = {exports: {}};
  38824. var node$1 = {exports: {}};
  38825. var util$1 = {};
  38826. var unesc = {exports: {}};
  38827. var hasRequiredUnesc;
  38828. function requireUnesc () {
  38829. if (hasRequiredUnesc) return unesc.exports;
  38830. hasRequiredUnesc = 1;
  38831. (function (module, exports) {
  38832. exports.__esModule = true;
  38833. exports["default"] = unesc;
  38834. // Many thanks for this post which made this migration much easier.
  38835. // https://mathiasbynens.be/notes/css-escapes
  38836. /**
  38837. *
  38838. * @param {string} str
  38839. * @returns {[string, number]|undefined}
  38840. */
  38841. function gobbleHex(str) {
  38842. var lower = str.toLowerCase();
  38843. var hex = '';
  38844. var spaceTerminated = false;
  38845. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  38846. var code = lower.charCodeAt(i);
  38847. // check to see if we are dealing with a valid hex char [a-f|0-9]
  38848. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  38849. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  38850. spaceTerminated = code === 32;
  38851. if (!valid) {
  38852. break;
  38853. }
  38854. hex += lower[i];
  38855. }
  38856. if (hex.length === 0) {
  38857. return undefined;
  38858. }
  38859. var codePoint = parseInt(hex, 16);
  38860. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  38861. // Add special case for
  38862. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  38863. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  38864. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  38865. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  38866. }
  38867. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  38868. }
  38869. var CONTAINS_ESCAPE = /\\/;
  38870. function unesc(str) {
  38871. var needToProcess = CONTAINS_ESCAPE.test(str);
  38872. if (!needToProcess) {
  38873. return str;
  38874. }
  38875. var ret = "";
  38876. for (var i = 0; i < str.length; i++) {
  38877. if (str[i] === "\\") {
  38878. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  38879. if (gobbled !== undefined) {
  38880. ret += gobbled[0];
  38881. i += gobbled[1];
  38882. continue;
  38883. }
  38884. // Retain a pair of \\ if double escaped `\\\\`
  38885. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  38886. if (str[i + 1] === "\\") {
  38887. ret += "\\";
  38888. i++;
  38889. continue;
  38890. }
  38891. // if \\ is at the end of the string retain it
  38892. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  38893. if (str.length === i + 1) {
  38894. ret += str[i];
  38895. }
  38896. continue;
  38897. }
  38898. ret += str[i];
  38899. }
  38900. return ret;
  38901. }
  38902. module.exports = exports.default;
  38903. } (unesc, unesc.exports));
  38904. return unesc.exports;
  38905. }
  38906. var getProp = {exports: {}};
  38907. var hasRequiredGetProp;
  38908. function requireGetProp () {
  38909. if (hasRequiredGetProp) return getProp.exports;
  38910. hasRequiredGetProp = 1;
  38911. (function (module, exports) {
  38912. exports.__esModule = true;
  38913. exports["default"] = getProp;
  38914. function getProp(obj) {
  38915. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  38916. props[_key - 1] = arguments[_key];
  38917. }
  38918. while (props.length > 0) {
  38919. var prop = props.shift();
  38920. if (!obj[prop]) {
  38921. return undefined;
  38922. }
  38923. obj = obj[prop];
  38924. }
  38925. return obj;
  38926. }
  38927. module.exports = exports.default;
  38928. } (getProp, getProp.exports));
  38929. return getProp.exports;
  38930. }
  38931. var ensureObject = {exports: {}};
  38932. var hasRequiredEnsureObject;
  38933. function requireEnsureObject () {
  38934. if (hasRequiredEnsureObject) return ensureObject.exports;
  38935. hasRequiredEnsureObject = 1;
  38936. (function (module, exports) {
  38937. exports.__esModule = true;
  38938. exports["default"] = ensureObject;
  38939. function ensureObject(obj) {
  38940. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  38941. props[_key - 1] = arguments[_key];
  38942. }
  38943. while (props.length > 0) {
  38944. var prop = props.shift();
  38945. if (!obj[prop]) {
  38946. obj[prop] = {};
  38947. }
  38948. obj = obj[prop];
  38949. }
  38950. }
  38951. module.exports = exports.default;
  38952. } (ensureObject, ensureObject.exports));
  38953. return ensureObject.exports;
  38954. }
  38955. var stripComments = {exports: {}};
  38956. var hasRequiredStripComments;
  38957. function requireStripComments () {
  38958. if (hasRequiredStripComments) return stripComments.exports;
  38959. hasRequiredStripComments = 1;
  38960. (function (module, exports) {
  38961. exports.__esModule = true;
  38962. exports["default"] = stripComments;
  38963. function stripComments(str) {
  38964. var s = "";
  38965. var commentStart = str.indexOf("/*");
  38966. var lastEnd = 0;
  38967. while (commentStart >= 0) {
  38968. s = s + str.slice(lastEnd, commentStart);
  38969. var commentEnd = str.indexOf("*/", commentStart + 2);
  38970. if (commentEnd < 0) {
  38971. return s;
  38972. }
  38973. lastEnd = commentEnd + 2;
  38974. commentStart = str.indexOf("/*", lastEnd);
  38975. }
  38976. s = s + str.slice(lastEnd);
  38977. return s;
  38978. }
  38979. module.exports = exports.default;
  38980. } (stripComments, stripComments.exports));
  38981. return stripComments.exports;
  38982. }
  38983. var hasRequiredUtil$1;
  38984. function requireUtil$1 () {
  38985. if (hasRequiredUtil$1) return util$1;
  38986. hasRequiredUtil$1 = 1;
  38987. util$1.__esModule = true;
  38988. util$1.unesc = util$1.stripComments = util$1.getProp = util$1.ensureObject = void 0;
  38989. var _unesc = _interopRequireDefault(/*@__PURE__*/ requireUnesc());
  38990. util$1.unesc = _unesc["default"];
  38991. var _getProp = _interopRequireDefault(/*@__PURE__*/ requireGetProp());
  38992. util$1.getProp = _getProp["default"];
  38993. var _ensureObject = _interopRequireDefault(/*@__PURE__*/ requireEnsureObject());
  38994. util$1.ensureObject = _ensureObject["default"];
  38995. var _stripComments = _interopRequireDefault(/*@__PURE__*/ requireStripComments());
  38996. util$1.stripComments = _stripComments["default"];
  38997. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38998. return util$1;
  38999. }
  39000. var hasRequiredNode$1;
  39001. function requireNode$1 () {
  39002. if (hasRequiredNode$1) return node$1.exports;
  39003. hasRequiredNode$1 = 1;
  39004. (function (module, exports) {
  39005. exports.__esModule = true;
  39006. exports["default"] = void 0;
  39007. var _util = /*@__PURE__*/ requireUtil$1();
  39008. 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); } }
  39009. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39010. var cloneNode = function cloneNode(obj, parent) {
  39011. if (typeof obj !== 'object' || obj === null) {
  39012. return obj;
  39013. }
  39014. var cloned = new obj.constructor();
  39015. for (var i in obj) {
  39016. if (!obj.hasOwnProperty(i)) {
  39017. continue;
  39018. }
  39019. var value = obj[i];
  39020. var type = typeof value;
  39021. if (i === 'parent' && type === 'object') {
  39022. if (parent) {
  39023. cloned[i] = parent;
  39024. }
  39025. } else if (value instanceof Array) {
  39026. cloned[i] = value.map(function (j) {
  39027. return cloneNode(j, cloned);
  39028. });
  39029. } else {
  39030. cloned[i] = cloneNode(value, cloned);
  39031. }
  39032. }
  39033. return cloned;
  39034. };
  39035. var Node = /*#__PURE__*/function () {
  39036. function Node(opts) {
  39037. if (opts === void 0) {
  39038. opts = {};
  39039. }
  39040. Object.assign(this, opts);
  39041. this.spaces = this.spaces || {};
  39042. this.spaces.before = this.spaces.before || '';
  39043. this.spaces.after = this.spaces.after || '';
  39044. }
  39045. var _proto = Node.prototype;
  39046. _proto.remove = function remove() {
  39047. if (this.parent) {
  39048. this.parent.removeChild(this);
  39049. }
  39050. this.parent = undefined;
  39051. return this;
  39052. };
  39053. _proto.replaceWith = function replaceWith() {
  39054. if (this.parent) {
  39055. for (var index in arguments) {
  39056. this.parent.insertBefore(this, arguments[index]);
  39057. }
  39058. this.remove();
  39059. }
  39060. return this;
  39061. };
  39062. _proto.next = function next() {
  39063. return this.parent.at(this.parent.index(this) + 1);
  39064. };
  39065. _proto.prev = function prev() {
  39066. return this.parent.at(this.parent.index(this) - 1);
  39067. };
  39068. _proto.clone = function clone(overrides) {
  39069. if (overrides === void 0) {
  39070. overrides = {};
  39071. }
  39072. var cloned = cloneNode(this);
  39073. for (var name in overrides) {
  39074. cloned[name] = overrides[name];
  39075. }
  39076. return cloned;
  39077. }
  39078. /**
  39079. * Some non-standard syntax doesn't follow normal escaping rules for css.
  39080. * This allows non standard syntax to be appended to an existing property
  39081. * by specifying the escaped value. By specifying the escaped value,
  39082. * illegal characters are allowed to be directly inserted into css output.
  39083. * @param {string} name the property to set
  39084. * @param {any} value the unescaped value of the property
  39085. * @param {string} valueEscaped optional. the escaped value of the property.
  39086. */;
  39087. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  39088. if (!this.raws) {
  39089. this.raws = {};
  39090. }
  39091. var originalValue = this[name];
  39092. var originalEscaped = this.raws[name];
  39093. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  39094. if (originalEscaped || valueEscaped !== value) {
  39095. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  39096. } else {
  39097. delete this.raws[name]; // delete any escaped value that was created by the setter.
  39098. }
  39099. }
  39100. /**
  39101. * Some non-standard syntax doesn't follow normal escaping rules for css.
  39102. * This allows the escaped value to be specified directly, allowing illegal
  39103. * characters to be directly inserted into css output.
  39104. * @param {string} name the property to set
  39105. * @param {any} value the unescaped value of the property
  39106. * @param {string} valueEscaped the escaped value of the property.
  39107. */;
  39108. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  39109. if (!this.raws) {
  39110. this.raws = {};
  39111. }
  39112. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  39113. this.raws[name] = valueEscaped;
  39114. }
  39115. /**
  39116. * When you want a value to passed through to CSS directly. This method
  39117. * deletes the corresponding raw value causing the stringifier to fallback
  39118. * to the unescaped value.
  39119. * @param {string} name the property to set.
  39120. * @param {any} value The value that is both escaped and unescaped.
  39121. */;
  39122. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  39123. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  39124. if (this.raws) {
  39125. delete this.raws[name];
  39126. }
  39127. }
  39128. /**
  39129. *
  39130. * @param {number} line The number (starting with 1)
  39131. * @param {number} column The column number (starting with 1)
  39132. */;
  39133. _proto.isAtPosition = function isAtPosition(line, column) {
  39134. if (this.source && this.source.start && this.source.end) {
  39135. if (this.source.start.line > line) {
  39136. return false;
  39137. }
  39138. if (this.source.end.line < line) {
  39139. return false;
  39140. }
  39141. if (this.source.start.line === line && this.source.start.column > column) {
  39142. return false;
  39143. }
  39144. if (this.source.end.line === line && this.source.end.column < column) {
  39145. return false;
  39146. }
  39147. return true;
  39148. }
  39149. return undefined;
  39150. };
  39151. _proto.stringifyProperty = function stringifyProperty(name) {
  39152. return this.raws && this.raws[name] || this[name];
  39153. };
  39154. _proto.valueToString = function valueToString() {
  39155. return String(this.stringifyProperty("value"));
  39156. };
  39157. _proto.toString = function toString() {
  39158. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  39159. };
  39160. _createClass(Node, [{
  39161. key: "rawSpaceBefore",
  39162. get: function get() {
  39163. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  39164. if (rawSpace === undefined) {
  39165. rawSpace = this.spaces && this.spaces.before;
  39166. }
  39167. return rawSpace || "";
  39168. },
  39169. set: function set(raw) {
  39170. (0, _util.ensureObject)(this, "raws", "spaces");
  39171. this.raws.spaces.before = raw;
  39172. }
  39173. }, {
  39174. key: "rawSpaceAfter",
  39175. get: function get() {
  39176. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  39177. if (rawSpace === undefined) {
  39178. rawSpace = this.spaces.after;
  39179. }
  39180. return rawSpace || "";
  39181. },
  39182. set: function set(raw) {
  39183. (0, _util.ensureObject)(this, "raws", "spaces");
  39184. this.raws.spaces.after = raw;
  39185. }
  39186. }]);
  39187. return Node;
  39188. }();
  39189. exports["default"] = Node;
  39190. module.exports = exports.default;
  39191. } (node$1, node$1.exports));
  39192. return node$1.exports;
  39193. }
  39194. var types = {};
  39195. var hasRequiredTypes;
  39196. function requireTypes () {
  39197. if (hasRequiredTypes) return types;
  39198. hasRequiredTypes = 1;
  39199. types.__esModule = true;
  39200. types.UNIVERSAL = types.TAG = types.STRING = types.SELECTOR = types.ROOT = types.PSEUDO = types.NESTING = types.ID = types.COMMENT = types.COMBINATOR = types.CLASS = types.ATTRIBUTE = void 0;
  39201. var TAG = 'tag';
  39202. types.TAG = TAG;
  39203. var STRING = 'string';
  39204. types.STRING = STRING;
  39205. var SELECTOR = 'selector';
  39206. types.SELECTOR = SELECTOR;
  39207. var ROOT = 'root';
  39208. types.ROOT = ROOT;
  39209. var PSEUDO = 'pseudo';
  39210. types.PSEUDO = PSEUDO;
  39211. var NESTING = 'nesting';
  39212. types.NESTING = NESTING;
  39213. var ID = 'id';
  39214. types.ID = ID;
  39215. var COMMENT = 'comment';
  39216. types.COMMENT = COMMENT;
  39217. var COMBINATOR = 'combinator';
  39218. types.COMBINATOR = COMBINATOR;
  39219. var CLASS = 'class';
  39220. types.CLASS = CLASS;
  39221. var ATTRIBUTE = 'attribute';
  39222. types.ATTRIBUTE = ATTRIBUTE;
  39223. var UNIVERSAL = 'universal';
  39224. types.UNIVERSAL = UNIVERSAL;
  39225. return types;
  39226. }
  39227. var hasRequiredContainer;
  39228. function requireContainer () {
  39229. if (hasRequiredContainer) return container.exports;
  39230. hasRequiredContainer = 1;
  39231. (function (module, exports) {
  39232. exports.__esModule = true;
  39233. exports["default"] = void 0;
  39234. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39235. var types = _interopRequireWildcard(/*@__PURE__*/ requireTypes());
  39236. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  39237. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  39238. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39239. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  39240. 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); }
  39241. 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; }
  39242. 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); } }
  39243. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39244. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39245. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39246. var Container = /*#__PURE__*/function (_Node) {
  39247. _inheritsLoose(Container, _Node);
  39248. function Container(opts) {
  39249. var _this;
  39250. _this = _Node.call(this, opts) || this;
  39251. if (!_this.nodes) {
  39252. _this.nodes = [];
  39253. }
  39254. return _this;
  39255. }
  39256. var _proto = Container.prototype;
  39257. _proto.append = function append(selector) {
  39258. selector.parent = this;
  39259. this.nodes.push(selector);
  39260. return this;
  39261. };
  39262. _proto.prepend = function prepend(selector) {
  39263. selector.parent = this;
  39264. this.nodes.unshift(selector);
  39265. return this;
  39266. };
  39267. _proto.at = function at(index) {
  39268. return this.nodes[index];
  39269. };
  39270. _proto.index = function index(child) {
  39271. if (typeof child === 'number') {
  39272. return child;
  39273. }
  39274. return this.nodes.indexOf(child);
  39275. };
  39276. _proto.removeChild = function removeChild(child) {
  39277. child = this.index(child);
  39278. this.at(child).parent = undefined;
  39279. this.nodes.splice(child, 1);
  39280. var index;
  39281. for (var id in this.indexes) {
  39282. index = this.indexes[id];
  39283. if (index >= child) {
  39284. this.indexes[id] = index - 1;
  39285. }
  39286. }
  39287. return this;
  39288. };
  39289. _proto.removeAll = function removeAll() {
  39290. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  39291. var node = _step.value;
  39292. node.parent = undefined;
  39293. }
  39294. this.nodes = [];
  39295. return this;
  39296. };
  39297. _proto.empty = function empty() {
  39298. return this.removeAll();
  39299. };
  39300. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  39301. newNode.parent = this;
  39302. var oldIndex = this.index(oldNode);
  39303. this.nodes.splice(oldIndex + 1, 0, newNode);
  39304. newNode.parent = this;
  39305. var index;
  39306. for (var id in this.indexes) {
  39307. index = this.indexes[id];
  39308. if (oldIndex <= index) {
  39309. this.indexes[id] = index + 1;
  39310. }
  39311. }
  39312. return this;
  39313. };
  39314. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  39315. newNode.parent = this;
  39316. var oldIndex = this.index(oldNode);
  39317. this.nodes.splice(oldIndex, 0, newNode);
  39318. newNode.parent = this;
  39319. var index;
  39320. for (var id in this.indexes) {
  39321. index = this.indexes[id];
  39322. if (index <= oldIndex) {
  39323. this.indexes[id] = index + 1;
  39324. }
  39325. }
  39326. return this;
  39327. };
  39328. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  39329. var found = undefined;
  39330. this.each(function (node) {
  39331. if (node.atPosition) {
  39332. var foundChild = node.atPosition(line, col);
  39333. if (foundChild) {
  39334. found = foundChild;
  39335. return false;
  39336. }
  39337. } else if (node.isAtPosition(line, col)) {
  39338. found = node;
  39339. return false;
  39340. }
  39341. });
  39342. return found;
  39343. }
  39344. /**
  39345. * Return the most specific node at the line and column number given.
  39346. * The source location is based on the original parsed location, locations aren't
  39347. * updated as selector nodes are mutated.
  39348. *
  39349. * Note that this location is relative to the location of the first character
  39350. * of the selector, and not the location of the selector in the overall document
  39351. * when used in conjunction with postcss.
  39352. *
  39353. * If not found, returns undefined.
  39354. * @param {number} line The line number of the node to find. (1-based index)
  39355. * @param {number} col The column number of the node to find. (1-based index)
  39356. */;
  39357. _proto.atPosition = function atPosition(line, col) {
  39358. if (this.isAtPosition(line, col)) {
  39359. return this._findChildAtPosition(line, col) || this;
  39360. } else {
  39361. return undefined;
  39362. }
  39363. };
  39364. _proto._inferEndPosition = function _inferEndPosition() {
  39365. if (this.last && this.last.source && this.last.source.end) {
  39366. this.source = this.source || {};
  39367. this.source.end = this.source.end || {};
  39368. Object.assign(this.source.end, this.last.source.end);
  39369. }
  39370. };
  39371. _proto.each = function each(callback) {
  39372. if (!this.lastEach) {
  39373. this.lastEach = 0;
  39374. }
  39375. if (!this.indexes) {
  39376. this.indexes = {};
  39377. }
  39378. this.lastEach++;
  39379. var id = this.lastEach;
  39380. this.indexes[id] = 0;
  39381. if (!this.length) {
  39382. return undefined;
  39383. }
  39384. var index, result;
  39385. while (this.indexes[id] < this.length) {
  39386. index = this.indexes[id];
  39387. result = callback(this.at(index), index);
  39388. if (result === false) {
  39389. break;
  39390. }
  39391. this.indexes[id] += 1;
  39392. }
  39393. delete this.indexes[id];
  39394. if (result === false) {
  39395. return false;
  39396. }
  39397. };
  39398. _proto.walk = function walk(callback) {
  39399. return this.each(function (node, i) {
  39400. var result = callback(node, i);
  39401. if (result !== false && node.length) {
  39402. result = node.walk(callback);
  39403. }
  39404. if (result === false) {
  39405. return false;
  39406. }
  39407. });
  39408. };
  39409. _proto.walkAttributes = function walkAttributes(callback) {
  39410. var _this2 = this;
  39411. return this.walk(function (selector) {
  39412. if (selector.type === types.ATTRIBUTE) {
  39413. return callback.call(_this2, selector);
  39414. }
  39415. });
  39416. };
  39417. _proto.walkClasses = function walkClasses(callback) {
  39418. var _this3 = this;
  39419. return this.walk(function (selector) {
  39420. if (selector.type === types.CLASS) {
  39421. return callback.call(_this3, selector);
  39422. }
  39423. });
  39424. };
  39425. _proto.walkCombinators = function walkCombinators(callback) {
  39426. var _this4 = this;
  39427. return this.walk(function (selector) {
  39428. if (selector.type === types.COMBINATOR) {
  39429. return callback.call(_this4, selector);
  39430. }
  39431. });
  39432. };
  39433. _proto.walkComments = function walkComments(callback) {
  39434. var _this5 = this;
  39435. return this.walk(function (selector) {
  39436. if (selector.type === types.COMMENT) {
  39437. return callback.call(_this5, selector);
  39438. }
  39439. });
  39440. };
  39441. _proto.walkIds = function walkIds(callback) {
  39442. var _this6 = this;
  39443. return this.walk(function (selector) {
  39444. if (selector.type === types.ID) {
  39445. return callback.call(_this6, selector);
  39446. }
  39447. });
  39448. };
  39449. _proto.walkNesting = function walkNesting(callback) {
  39450. var _this7 = this;
  39451. return this.walk(function (selector) {
  39452. if (selector.type === types.NESTING) {
  39453. return callback.call(_this7, selector);
  39454. }
  39455. });
  39456. };
  39457. _proto.walkPseudos = function walkPseudos(callback) {
  39458. var _this8 = this;
  39459. return this.walk(function (selector) {
  39460. if (selector.type === types.PSEUDO) {
  39461. return callback.call(_this8, selector);
  39462. }
  39463. });
  39464. };
  39465. _proto.walkTags = function walkTags(callback) {
  39466. var _this9 = this;
  39467. return this.walk(function (selector) {
  39468. if (selector.type === types.TAG) {
  39469. return callback.call(_this9, selector);
  39470. }
  39471. });
  39472. };
  39473. _proto.walkUniversals = function walkUniversals(callback) {
  39474. var _this10 = this;
  39475. return this.walk(function (selector) {
  39476. if (selector.type === types.UNIVERSAL) {
  39477. return callback.call(_this10, selector);
  39478. }
  39479. });
  39480. };
  39481. _proto.split = function split(callback) {
  39482. var _this11 = this;
  39483. var current = [];
  39484. return this.reduce(function (memo, node, index) {
  39485. var split = callback.call(_this11, node);
  39486. current.push(node);
  39487. if (split) {
  39488. memo.push(current);
  39489. current = [];
  39490. } else if (index === _this11.length - 1) {
  39491. memo.push(current);
  39492. }
  39493. return memo;
  39494. }, []);
  39495. };
  39496. _proto.map = function map(callback) {
  39497. return this.nodes.map(callback);
  39498. };
  39499. _proto.reduce = function reduce(callback, memo) {
  39500. return this.nodes.reduce(callback, memo);
  39501. };
  39502. _proto.every = function every(callback) {
  39503. return this.nodes.every(callback);
  39504. };
  39505. _proto.some = function some(callback) {
  39506. return this.nodes.some(callback);
  39507. };
  39508. _proto.filter = function filter(callback) {
  39509. return this.nodes.filter(callback);
  39510. };
  39511. _proto.sort = function sort(callback) {
  39512. return this.nodes.sort(callback);
  39513. };
  39514. _proto.toString = function toString() {
  39515. return this.map(String).join('');
  39516. };
  39517. _createClass(Container, [{
  39518. key: "first",
  39519. get: function get() {
  39520. return this.at(0);
  39521. }
  39522. }, {
  39523. key: "last",
  39524. get: function get() {
  39525. return this.at(this.length - 1);
  39526. }
  39527. }, {
  39528. key: "length",
  39529. get: function get() {
  39530. return this.nodes.length;
  39531. }
  39532. }]);
  39533. return Container;
  39534. }(_node["default"]);
  39535. exports["default"] = Container;
  39536. module.exports = exports.default;
  39537. } (container, container.exports));
  39538. return container.exports;
  39539. }
  39540. var hasRequiredRoot;
  39541. function requireRoot () {
  39542. if (hasRequiredRoot) return root.exports;
  39543. hasRequiredRoot = 1;
  39544. (function (module, exports) {
  39545. exports.__esModule = true;
  39546. exports["default"] = void 0;
  39547. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  39548. var _types = /*@__PURE__*/ requireTypes();
  39549. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39550. 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); } }
  39551. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39552. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39553. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39554. var Root = /*#__PURE__*/function (_Container) {
  39555. _inheritsLoose(Root, _Container);
  39556. function Root(opts) {
  39557. var _this;
  39558. _this = _Container.call(this, opts) || this;
  39559. _this.type = _types.ROOT;
  39560. return _this;
  39561. }
  39562. var _proto = Root.prototype;
  39563. _proto.toString = function toString() {
  39564. var str = this.reduce(function (memo, selector) {
  39565. memo.push(String(selector));
  39566. return memo;
  39567. }, []).join(',');
  39568. return this.trailingComma ? str + ',' : str;
  39569. };
  39570. _proto.error = function error(message, options) {
  39571. if (this._error) {
  39572. return this._error(message, options);
  39573. } else {
  39574. return new Error(message);
  39575. }
  39576. };
  39577. _createClass(Root, [{
  39578. key: "errorGenerator",
  39579. set: function set(handler) {
  39580. this._error = handler;
  39581. }
  39582. }]);
  39583. return Root;
  39584. }(_container["default"]);
  39585. exports["default"] = Root;
  39586. module.exports = exports.default;
  39587. } (root, root.exports));
  39588. return root.exports;
  39589. }
  39590. var selector = {exports: {}};
  39591. var hasRequiredSelector;
  39592. function requireSelector () {
  39593. if (hasRequiredSelector) return selector.exports;
  39594. hasRequiredSelector = 1;
  39595. (function (module, exports) {
  39596. exports.__esModule = true;
  39597. exports["default"] = void 0;
  39598. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  39599. var _types = /*@__PURE__*/ requireTypes();
  39600. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39601. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39602. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39603. var Selector = /*#__PURE__*/function (_Container) {
  39604. _inheritsLoose(Selector, _Container);
  39605. function Selector(opts) {
  39606. var _this;
  39607. _this = _Container.call(this, opts) || this;
  39608. _this.type = _types.SELECTOR;
  39609. return _this;
  39610. }
  39611. return Selector;
  39612. }(_container["default"]);
  39613. exports["default"] = Selector;
  39614. module.exports = exports.default;
  39615. } (selector, selector.exports));
  39616. return selector.exports;
  39617. }
  39618. var className = {exports: {}};
  39619. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  39620. var cssesc_1;
  39621. var hasRequiredCssesc;
  39622. function requireCssesc () {
  39623. if (hasRequiredCssesc) return cssesc_1;
  39624. hasRequiredCssesc = 1;
  39625. var object = {};
  39626. var hasOwnProperty = object.hasOwnProperty;
  39627. var merge = function merge(options, defaults) {
  39628. if (!options) {
  39629. return defaults;
  39630. }
  39631. var result = {};
  39632. for (var key in defaults) {
  39633. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  39634. // only recognized option names are used.
  39635. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  39636. }
  39637. return result;
  39638. };
  39639. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  39640. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  39641. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  39642. // https://mathiasbynens.be/notes/css-escapes#css
  39643. var cssesc = function cssesc(string, options) {
  39644. options = merge(options, cssesc.options);
  39645. if (options.quotes != 'single' && options.quotes != 'double') {
  39646. options.quotes = 'single';
  39647. }
  39648. var quote = options.quotes == 'double' ? '"' : '\'';
  39649. var isIdentifier = options.isIdentifier;
  39650. var firstChar = string.charAt(0);
  39651. var output = '';
  39652. var counter = 0;
  39653. var length = string.length;
  39654. while (counter < length) {
  39655. var character = string.charAt(counter++);
  39656. var codePoint = character.charCodeAt();
  39657. var value = void 0;
  39658. // If it’s not a printable ASCII character…
  39659. if (codePoint < 0x20 || codePoint > 0x7E) {
  39660. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  39661. // It’s a high surrogate, and there is a next character.
  39662. var extra = string.charCodeAt(counter++);
  39663. if ((extra & 0xFC00) == 0xDC00) {
  39664. // next character is low surrogate
  39665. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  39666. } else {
  39667. // It’s an unmatched surrogate; only append this code unit, in case
  39668. // the next code unit is the high surrogate of a surrogate pair.
  39669. counter--;
  39670. }
  39671. }
  39672. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  39673. } else {
  39674. if (options.escapeEverything) {
  39675. if (regexAnySingleEscape.test(character)) {
  39676. value = '\\' + character;
  39677. } else {
  39678. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  39679. }
  39680. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  39681. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  39682. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  39683. value = '\\' + character;
  39684. } else {
  39685. value = character;
  39686. }
  39687. }
  39688. output += value;
  39689. }
  39690. if (isIdentifier) {
  39691. if (/^-[-\d]/.test(output)) {
  39692. output = '\\-' + output.slice(1);
  39693. } else if (/\d/.test(firstChar)) {
  39694. output = '\\3' + firstChar + ' ' + output.slice(1);
  39695. }
  39696. }
  39697. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  39698. // since they’re redundant. Note that this is only possible if the escape
  39699. // sequence isn’t preceded by an odd number of backslashes.
  39700. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  39701. if ($1 && $1.length % 2) {
  39702. // It’s not safe to remove the space, so don’t.
  39703. return $0;
  39704. }
  39705. // Strip the space.
  39706. return ($1 || '') + $2;
  39707. });
  39708. if (!isIdentifier && options.wrap) {
  39709. return quote + output + quote;
  39710. }
  39711. return output;
  39712. };
  39713. // Expose default options (so they can be overridden globally).
  39714. cssesc.options = {
  39715. 'escapeEverything': false,
  39716. 'isIdentifier': false,
  39717. 'quotes': 'single',
  39718. 'wrap': false
  39719. };
  39720. cssesc.version = '3.0.0';
  39721. cssesc_1 = cssesc;
  39722. return cssesc_1;
  39723. }
  39724. var hasRequiredClassName;
  39725. function requireClassName () {
  39726. if (hasRequiredClassName) return className.exports;
  39727. hasRequiredClassName = 1;
  39728. (function (module, exports) {
  39729. exports.__esModule = true;
  39730. exports["default"] = void 0;
  39731. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  39732. var _util = /*@__PURE__*/ requireUtil$1();
  39733. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39734. var _types = /*@__PURE__*/ requireTypes();
  39735. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39736. 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); } }
  39737. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39738. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39739. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39740. var ClassName = /*#__PURE__*/function (_Node) {
  39741. _inheritsLoose(ClassName, _Node);
  39742. function ClassName(opts) {
  39743. var _this;
  39744. _this = _Node.call(this, opts) || this;
  39745. _this.type = _types.CLASS;
  39746. _this._constructed = true;
  39747. return _this;
  39748. }
  39749. var _proto = ClassName.prototype;
  39750. _proto.valueToString = function valueToString() {
  39751. return '.' + _Node.prototype.valueToString.call(this);
  39752. };
  39753. _createClass(ClassName, [{
  39754. key: "value",
  39755. get: function get() {
  39756. return this._value;
  39757. },
  39758. set: function set(v) {
  39759. if (this._constructed) {
  39760. var escaped = (0, _cssesc["default"])(v, {
  39761. isIdentifier: true
  39762. });
  39763. if (escaped !== v) {
  39764. (0, _util.ensureObject)(this, "raws");
  39765. this.raws.value = escaped;
  39766. } else if (this.raws) {
  39767. delete this.raws.value;
  39768. }
  39769. }
  39770. this._value = v;
  39771. }
  39772. }]);
  39773. return ClassName;
  39774. }(_node["default"]);
  39775. exports["default"] = ClassName;
  39776. module.exports = exports.default;
  39777. } (className, className.exports));
  39778. return className.exports;
  39779. }
  39780. var comment = {exports: {}};
  39781. var hasRequiredComment;
  39782. function requireComment () {
  39783. if (hasRequiredComment) return comment.exports;
  39784. hasRequiredComment = 1;
  39785. (function (module, exports) {
  39786. exports.__esModule = true;
  39787. exports["default"] = void 0;
  39788. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39789. var _types = /*@__PURE__*/ requireTypes();
  39790. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39791. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39792. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39793. var Comment = /*#__PURE__*/function (_Node) {
  39794. _inheritsLoose(Comment, _Node);
  39795. function Comment(opts) {
  39796. var _this;
  39797. _this = _Node.call(this, opts) || this;
  39798. _this.type = _types.COMMENT;
  39799. return _this;
  39800. }
  39801. return Comment;
  39802. }(_node["default"]);
  39803. exports["default"] = Comment;
  39804. module.exports = exports.default;
  39805. } (comment, comment.exports));
  39806. return comment.exports;
  39807. }
  39808. var id = {exports: {}};
  39809. var hasRequiredId;
  39810. function requireId () {
  39811. if (hasRequiredId) return id.exports;
  39812. hasRequiredId = 1;
  39813. (function (module, exports) {
  39814. exports.__esModule = true;
  39815. exports["default"] = void 0;
  39816. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39817. var _types = /*@__PURE__*/ requireTypes();
  39818. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39819. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39820. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39821. var ID = /*#__PURE__*/function (_Node) {
  39822. _inheritsLoose(ID, _Node);
  39823. function ID(opts) {
  39824. var _this;
  39825. _this = _Node.call(this, opts) || this;
  39826. _this.type = _types.ID;
  39827. return _this;
  39828. }
  39829. var _proto = ID.prototype;
  39830. _proto.valueToString = function valueToString() {
  39831. return '#' + _Node.prototype.valueToString.call(this);
  39832. };
  39833. return ID;
  39834. }(_node["default"]);
  39835. exports["default"] = ID;
  39836. module.exports = exports.default;
  39837. } (id, id.exports));
  39838. return id.exports;
  39839. }
  39840. var tag = {exports: {}};
  39841. var namespace = {exports: {}};
  39842. var hasRequiredNamespace;
  39843. function requireNamespace () {
  39844. if (hasRequiredNamespace) return namespace.exports;
  39845. hasRequiredNamespace = 1;
  39846. (function (module, exports) {
  39847. exports.__esModule = true;
  39848. exports["default"] = void 0;
  39849. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  39850. var _util = /*@__PURE__*/ requireUtil$1();
  39851. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39852. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39853. 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); } }
  39854. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  39855. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39856. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39857. var Namespace = /*#__PURE__*/function (_Node) {
  39858. _inheritsLoose(Namespace, _Node);
  39859. function Namespace() {
  39860. return _Node.apply(this, arguments) || this;
  39861. }
  39862. var _proto = Namespace.prototype;
  39863. _proto.qualifiedName = function qualifiedName(value) {
  39864. if (this.namespace) {
  39865. return this.namespaceString + "|" + value;
  39866. } else {
  39867. return value;
  39868. }
  39869. };
  39870. _proto.valueToString = function valueToString() {
  39871. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  39872. };
  39873. _createClass(Namespace, [{
  39874. key: "namespace",
  39875. get: function get() {
  39876. return this._namespace;
  39877. },
  39878. set: function set(namespace) {
  39879. if (namespace === true || namespace === "*" || namespace === "&") {
  39880. this._namespace = namespace;
  39881. if (this.raws) {
  39882. delete this.raws.namespace;
  39883. }
  39884. return;
  39885. }
  39886. var escaped = (0, _cssesc["default"])(namespace, {
  39887. isIdentifier: true
  39888. });
  39889. this._namespace = namespace;
  39890. if (escaped !== namespace) {
  39891. (0, _util.ensureObject)(this, "raws");
  39892. this.raws.namespace = escaped;
  39893. } else if (this.raws) {
  39894. delete this.raws.namespace;
  39895. }
  39896. }
  39897. }, {
  39898. key: "ns",
  39899. get: function get() {
  39900. return this._namespace;
  39901. },
  39902. set: function set(namespace) {
  39903. this.namespace = namespace;
  39904. }
  39905. }, {
  39906. key: "namespaceString",
  39907. get: function get() {
  39908. if (this.namespace) {
  39909. var ns = this.stringifyProperty("namespace");
  39910. if (ns === true) {
  39911. return '';
  39912. } else {
  39913. return ns;
  39914. }
  39915. } else {
  39916. return '';
  39917. }
  39918. }
  39919. }]);
  39920. return Namespace;
  39921. }(_node["default"]);
  39922. exports["default"] = Namespace;
  39923. module.exports = exports.default;
  39924. } (namespace, namespace.exports));
  39925. return namespace.exports;
  39926. }
  39927. var hasRequiredTag;
  39928. function requireTag () {
  39929. if (hasRequiredTag) return tag.exports;
  39930. hasRequiredTag = 1;
  39931. (function (module, exports) {
  39932. exports.__esModule = true;
  39933. exports["default"] = void 0;
  39934. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  39935. var _types = /*@__PURE__*/ requireTypes();
  39936. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39937. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39938. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39939. var Tag = /*#__PURE__*/function (_Namespace) {
  39940. _inheritsLoose(Tag, _Namespace);
  39941. function Tag(opts) {
  39942. var _this;
  39943. _this = _Namespace.call(this, opts) || this;
  39944. _this.type = _types.TAG;
  39945. return _this;
  39946. }
  39947. return Tag;
  39948. }(_namespace["default"]);
  39949. exports["default"] = Tag;
  39950. module.exports = exports.default;
  39951. } (tag, tag.exports));
  39952. return tag.exports;
  39953. }
  39954. var string = {exports: {}};
  39955. var hasRequiredString;
  39956. function requireString () {
  39957. if (hasRequiredString) return string.exports;
  39958. hasRequiredString = 1;
  39959. (function (module, exports) {
  39960. exports.__esModule = true;
  39961. exports["default"] = void 0;
  39962. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  39963. var _types = /*@__PURE__*/ requireTypes();
  39964. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39965. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39966. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39967. var String = /*#__PURE__*/function (_Node) {
  39968. _inheritsLoose(String, _Node);
  39969. function String(opts) {
  39970. var _this;
  39971. _this = _Node.call(this, opts) || this;
  39972. _this.type = _types.STRING;
  39973. return _this;
  39974. }
  39975. return String;
  39976. }(_node["default"]);
  39977. exports["default"] = String;
  39978. module.exports = exports.default;
  39979. } (string, string.exports));
  39980. return string.exports;
  39981. }
  39982. var pseudo = {exports: {}};
  39983. var hasRequiredPseudo;
  39984. function requirePseudo () {
  39985. if (hasRequiredPseudo) return pseudo.exports;
  39986. hasRequiredPseudo = 1;
  39987. (function (module, exports) {
  39988. exports.__esModule = true;
  39989. exports["default"] = void 0;
  39990. var _container = _interopRequireDefault(/*@__PURE__*/ requireContainer());
  39991. var _types = /*@__PURE__*/ requireTypes();
  39992. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  39993. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  39994. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39995. var Pseudo = /*#__PURE__*/function (_Container) {
  39996. _inheritsLoose(Pseudo, _Container);
  39997. function Pseudo(opts) {
  39998. var _this;
  39999. _this = _Container.call(this, opts) || this;
  40000. _this.type = _types.PSEUDO;
  40001. return _this;
  40002. }
  40003. var _proto = Pseudo.prototype;
  40004. _proto.toString = function toString() {
  40005. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  40006. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  40007. };
  40008. return Pseudo;
  40009. }(_container["default"]);
  40010. exports["default"] = Pseudo;
  40011. module.exports = exports.default;
  40012. } (pseudo, pseudo.exports));
  40013. return pseudo.exports;
  40014. }
  40015. var attribute = {};
  40016. var node;
  40017. var hasRequiredNode;
  40018. function requireNode () {
  40019. if (hasRequiredNode) return node;
  40020. hasRequiredNode = 1;
  40021. /**
  40022. * For Node.js, simply re-export the core `util.deprecate` function.
  40023. */
  40024. node = require$$0$1.deprecate;
  40025. return node;
  40026. }
  40027. var hasRequiredAttribute;
  40028. function requireAttribute () {
  40029. if (hasRequiredAttribute) return attribute;
  40030. hasRequiredAttribute = 1;
  40031. (function (exports) {
  40032. exports.__esModule = true;
  40033. exports["default"] = void 0;
  40034. exports.unescapeValue = unescapeValue;
  40035. var _cssesc = _interopRequireDefault(/*@__PURE__*/ requireCssesc());
  40036. var _unesc = _interopRequireDefault(/*@__PURE__*/ requireUnesc());
  40037. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  40038. var _types = /*@__PURE__*/ requireTypes();
  40039. var _CSSESC_QUOTE_OPTIONS;
  40040. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40041. 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); } }
  40042. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  40043. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40044. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40045. var deprecate = /*@__PURE__*/ requireNode();
  40046. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  40047. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  40048. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  40049. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  40050. function unescapeValue(value) {
  40051. var deprecatedUsage = false;
  40052. var quoteMark = null;
  40053. var unescaped = value;
  40054. var m = unescaped.match(WRAPPED_IN_QUOTES);
  40055. if (m) {
  40056. quoteMark = m[1];
  40057. unescaped = m[2];
  40058. }
  40059. unescaped = (0, _unesc["default"])(unescaped);
  40060. if (unescaped !== value) {
  40061. deprecatedUsage = true;
  40062. }
  40063. return {
  40064. deprecatedUsage: deprecatedUsage,
  40065. unescaped: unescaped,
  40066. quoteMark: quoteMark
  40067. };
  40068. }
  40069. function handleDeprecatedContructorOpts(opts) {
  40070. if (opts.quoteMark !== undefined) {
  40071. return opts;
  40072. }
  40073. if (opts.value === undefined) {
  40074. return opts;
  40075. }
  40076. warnOfDeprecatedConstructor();
  40077. var _unescapeValue = unescapeValue(opts.value),
  40078. quoteMark = _unescapeValue.quoteMark,
  40079. unescaped = _unescapeValue.unescaped;
  40080. if (!opts.raws) {
  40081. opts.raws = {};
  40082. }
  40083. if (opts.raws.value === undefined) {
  40084. opts.raws.value = opts.value;
  40085. }
  40086. opts.value = unescaped;
  40087. opts.quoteMark = quoteMark;
  40088. return opts;
  40089. }
  40090. var Attribute = /*#__PURE__*/function (_Namespace) {
  40091. _inheritsLoose(Attribute, _Namespace);
  40092. function Attribute(opts) {
  40093. var _this;
  40094. if (opts === void 0) {
  40095. opts = {};
  40096. }
  40097. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  40098. _this.type = _types.ATTRIBUTE;
  40099. _this.raws = _this.raws || {};
  40100. Object.defineProperty(_this.raws, 'unquoted', {
  40101. get: deprecate(function () {
  40102. return _this.value;
  40103. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  40104. set: deprecate(function () {
  40105. return _this.value;
  40106. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  40107. });
  40108. _this._constructed = true;
  40109. return _this;
  40110. }
  40111. /**
  40112. * Returns the Attribute's value quoted such that it would be legal to use
  40113. * in the value of a css file. The original value's quotation setting
  40114. * used for stringification is left unchanged. See `setValue(value, options)`
  40115. * if you want to control the quote settings of a new value for the attribute.
  40116. *
  40117. * You can also change the quotation used for the current value by setting quoteMark.
  40118. *
  40119. * Options:
  40120. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  40121. * option is not set, the original value for quoteMark will be used. If
  40122. * indeterminate, a double quote is used. The legal values are:
  40123. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  40124. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  40125. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  40126. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  40127. * over the quoteMark option value.
  40128. * * smart {boolean} - if true, will select a quote mark based on the value
  40129. * and the other options specified here. See the `smartQuoteMark()`
  40130. * method.
  40131. **/
  40132. var _proto = Attribute.prototype;
  40133. _proto.getQuotedValue = function getQuotedValue(options) {
  40134. if (options === void 0) {
  40135. options = {};
  40136. }
  40137. var quoteMark = this._determineQuoteMark(options);
  40138. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  40139. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  40140. return escaped;
  40141. };
  40142. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  40143. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  40144. }
  40145. /**
  40146. * Set the unescaped value with the specified quotation options. The value
  40147. * provided must not include any wrapping quote marks -- those quotes will
  40148. * be interpreted as part of the value and escaped accordingly.
  40149. */;
  40150. _proto.setValue = function setValue(value, options) {
  40151. if (options === void 0) {
  40152. options = {};
  40153. }
  40154. this._value = value;
  40155. this._quoteMark = this._determineQuoteMark(options);
  40156. this._syncRawValue();
  40157. }
  40158. /**
  40159. * Intelligently select a quoteMark value based on the value's contents. If
  40160. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  40161. * mark will be picked that minimizes the number of escapes.
  40162. *
  40163. * If there's no clear winner, the quote mark from these options is used,
  40164. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  40165. * true). If the quoteMark is unspecified, a double quote is used.
  40166. *
  40167. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  40168. * from the quoteValue method.
  40169. */;
  40170. _proto.smartQuoteMark = function smartQuoteMark(options) {
  40171. var v = this.value;
  40172. var numSingleQuotes = v.replace(/[^']/g, '').length;
  40173. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  40174. if (numSingleQuotes + numDoubleQuotes === 0) {
  40175. var escaped = (0, _cssesc["default"])(v, {
  40176. isIdentifier: true
  40177. });
  40178. if (escaped === v) {
  40179. return Attribute.NO_QUOTE;
  40180. } else {
  40181. var pref = this.preferredQuoteMark(options);
  40182. if (pref === Attribute.NO_QUOTE) {
  40183. // pick a quote mark that isn't none and see if it's smaller
  40184. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  40185. var opts = CSSESC_QUOTE_OPTIONS[quote];
  40186. var quoteValue = (0, _cssesc["default"])(v, opts);
  40187. if (quoteValue.length < escaped.length) {
  40188. return quote;
  40189. }
  40190. }
  40191. return pref;
  40192. }
  40193. } else if (numDoubleQuotes === numSingleQuotes) {
  40194. return this.preferredQuoteMark(options);
  40195. } else if (numDoubleQuotes < numSingleQuotes) {
  40196. return Attribute.DOUBLE_QUOTE;
  40197. } else {
  40198. return Attribute.SINGLE_QUOTE;
  40199. }
  40200. }
  40201. /**
  40202. * Selects the preferred quote mark based on the options and the current quote mark value.
  40203. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  40204. * instead.
  40205. */;
  40206. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  40207. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  40208. if (quoteMark === undefined) {
  40209. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  40210. }
  40211. if (quoteMark === undefined) {
  40212. quoteMark = Attribute.DOUBLE_QUOTE;
  40213. }
  40214. return quoteMark;
  40215. };
  40216. _proto._syncRawValue = function _syncRawValue() {
  40217. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  40218. if (rawValue === this._value) {
  40219. if (this.raws) {
  40220. delete this.raws.value;
  40221. }
  40222. } else {
  40223. this.raws.value = rawValue;
  40224. }
  40225. };
  40226. _proto._handleEscapes = function _handleEscapes(prop, value) {
  40227. if (this._constructed) {
  40228. var escaped = (0, _cssesc["default"])(value, {
  40229. isIdentifier: true
  40230. });
  40231. if (escaped !== value) {
  40232. this.raws[prop] = escaped;
  40233. } else {
  40234. delete this.raws[prop];
  40235. }
  40236. }
  40237. };
  40238. _proto._spacesFor = function _spacesFor(name) {
  40239. var attrSpaces = {
  40240. before: '',
  40241. after: ''
  40242. };
  40243. var spaces = this.spaces[name] || {};
  40244. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  40245. return Object.assign(attrSpaces, spaces, rawSpaces);
  40246. };
  40247. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  40248. if (spaceName === void 0) {
  40249. spaceName = name;
  40250. }
  40251. if (concat === void 0) {
  40252. concat = defaultAttrConcat;
  40253. }
  40254. var attrSpaces = this._spacesFor(spaceName);
  40255. return concat(this.stringifyProperty(name), attrSpaces);
  40256. }
  40257. /**
  40258. * returns the offset of the attribute part specified relative to the
  40259. * start of the node of the output string.
  40260. *
  40261. * * "ns" - alias for "namespace"
  40262. * * "namespace" - the namespace if it exists.
  40263. * * "attribute" - the attribute name
  40264. * * "attributeNS" - the start of the attribute or its namespace
  40265. * * "operator" - the match operator of the attribute
  40266. * * "value" - The value (string or identifier)
  40267. * * "insensitive" - the case insensitivity flag;
  40268. * @param part One of the possible values inside an attribute.
  40269. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  40270. */;
  40271. _proto.offsetOf = function offsetOf(name) {
  40272. var count = 1;
  40273. var attributeSpaces = this._spacesFor("attribute");
  40274. count += attributeSpaces.before.length;
  40275. if (name === "namespace" || name === "ns") {
  40276. return this.namespace ? count : -1;
  40277. }
  40278. if (name === "attributeNS") {
  40279. return count;
  40280. }
  40281. count += this.namespaceString.length;
  40282. if (this.namespace) {
  40283. count += 1;
  40284. }
  40285. if (name === "attribute") {
  40286. return count;
  40287. }
  40288. count += this.stringifyProperty("attribute").length;
  40289. count += attributeSpaces.after.length;
  40290. var operatorSpaces = this._spacesFor("operator");
  40291. count += operatorSpaces.before.length;
  40292. var operator = this.stringifyProperty("operator");
  40293. if (name === "operator") {
  40294. return operator ? count : -1;
  40295. }
  40296. count += operator.length;
  40297. count += operatorSpaces.after.length;
  40298. var valueSpaces = this._spacesFor("value");
  40299. count += valueSpaces.before.length;
  40300. var value = this.stringifyProperty("value");
  40301. if (name === "value") {
  40302. return value ? count : -1;
  40303. }
  40304. count += value.length;
  40305. count += valueSpaces.after.length;
  40306. var insensitiveSpaces = this._spacesFor("insensitive");
  40307. count += insensitiveSpaces.before.length;
  40308. if (name === "insensitive") {
  40309. return this.insensitive ? count : -1;
  40310. }
  40311. return -1;
  40312. };
  40313. _proto.toString = function toString() {
  40314. var _this2 = this;
  40315. var selector = [this.rawSpaceBefore, '['];
  40316. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  40317. if (this.operator && (this.value || this.value === '')) {
  40318. selector.push(this._stringFor('operator'));
  40319. selector.push(this._stringFor('value'));
  40320. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  40321. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  40322. attrSpaces.before = " ";
  40323. }
  40324. return defaultAttrConcat(attrValue, attrSpaces);
  40325. }));
  40326. }
  40327. selector.push(']');
  40328. selector.push(this.rawSpaceAfter);
  40329. return selector.join('');
  40330. };
  40331. _createClass(Attribute, [{
  40332. key: "quoted",
  40333. get: function get() {
  40334. var qm = this.quoteMark;
  40335. return qm === "'" || qm === '"';
  40336. },
  40337. set: function set(value) {
  40338. warnOfDeprecatedQuotedAssignment();
  40339. }
  40340. /**
  40341. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  40342. * returns `null` if the value is not quoted.
  40343. * returns `undefined` if the quotation state is unknown (this can happen when
  40344. * the attribute is constructed without specifying a quote mark.)
  40345. */
  40346. }, {
  40347. key: "quoteMark",
  40348. get: function get() {
  40349. return this._quoteMark;
  40350. }
  40351. /**
  40352. * Set the quote mark to be used by this attribute's value.
  40353. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  40354. * value is updated accordingly.
  40355. *
  40356. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  40357. */,
  40358. set: function set(quoteMark) {
  40359. if (!this._constructed) {
  40360. this._quoteMark = quoteMark;
  40361. return;
  40362. }
  40363. if (this._quoteMark !== quoteMark) {
  40364. this._quoteMark = quoteMark;
  40365. this._syncRawValue();
  40366. }
  40367. }
  40368. }, {
  40369. key: "qualifiedAttribute",
  40370. get: function get() {
  40371. return this.qualifiedName(this.raws.attribute || this.attribute);
  40372. }
  40373. }, {
  40374. key: "insensitiveFlag",
  40375. get: function get() {
  40376. return this.insensitive ? 'i' : '';
  40377. }
  40378. }, {
  40379. key: "value",
  40380. get: function get() {
  40381. return this._value;
  40382. },
  40383. set:
  40384. /**
  40385. * Before 3.0, the value had to be set to an escaped value including any wrapped
  40386. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  40387. * is unescaped during parsing and any quote marks are removed.
  40388. *
  40389. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  40390. * a deprecation warning is raised when the new value contains any characters that would
  40391. * require escaping (including if it contains wrapped quotes).
  40392. *
  40393. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  40394. * how the new value is quoted.
  40395. */
  40396. function set(v) {
  40397. if (this._constructed) {
  40398. var _unescapeValue2 = unescapeValue(v),
  40399. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  40400. unescaped = _unescapeValue2.unescaped,
  40401. quoteMark = _unescapeValue2.quoteMark;
  40402. if (deprecatedUsage) {
  40403. warnOfDeprecatedValueAssignment();
  40404. }
  40405. if (unescaped === this._value && quoteMark === this._quoteMark) {
  40406. return;
  40407. }
  40408. this._value = unescaped;
  40409. this._quoteMark = quoteMark;
  40410. this._syncRawValue();
  40411. } else {
  40412. this._value = v;
  40413. }
  40414. }
  40415. }, {
  40416. key: "insensitive",
  40417. get: function get() {
  40418. return this._insensitive;
  40419. }
  40420. /**
  40421. * Set the case insensitive flag.
  40422. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  40423. * of the attribute is updated accordingly.
  40424. *
  40425. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  40426. */,
  40427. set: function set(insensitive) {
  40428. if (!insensitive) {
  40429. this._insensitive = false;
  40430. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  40431. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  40432. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  40433. this.raws.insensitiveFlag = undefined;
  40434. }
  40435. }
  40436. this._insensitive = insensitive;
  40437. }
  40438. }, {
  40439. key: "attribute",
  40440. get: function get() {
  40441. return this._attribute;
  40442. },
  40443. set: function set(name) {
  40444. this._handleEscapes("attribute", name);
  40445. this._attribute = name;
  40446. }
  40447. }]);
  40448. return Attribute;
  40449. }(_namespace["default"]);
  40450. exports["default"] = Attribute;
  40451. Attribute.NO_QUOTE = null;
  40452. Attribute.SINGLE_QUOTE = "'";
  40453. Attribute.DOUBLE_QUOTE = '"';
  40454. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  40455. "'": {
  40456. quotes: 'single',
  40457. wrap: true
  40458. },
  40459. '"': {
  40460. quotes: 'double',
  40461. wrap: true
  40462. }
  40463. }, _CSSESC_QUOTE_OPTIONS[null] = {
  40464. isIdentifier: true
  40465. }, _CSSESC_QUOTE_OPTIONS);
  40466. function defaultAttrConcat(attrValue, attrSpaces) {
  40467. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  40468. }
  40469. } (attribute));
  40470. return attribute;
  40471. }
  40472. var universal = {exports: {}};
  40473. var hasRequiredUniversal;
  40474. function requireUniversal () {
  40475. if (hasRequiredUniversal) return universal.exports;
  40476. hasRequiredUniversal = 1;
  40477. (function (module, exports) {
  40478. exports.__esModule = true;
  40479. exports["default"] = void 0;
  40480. var _namespace = _interopRequireDefault(/*@__PURE__*/ requireNamespace());
  40481. var _types = /*@__PURE__*/ requireTypes();
  40482. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40483. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40484. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40485. var Universal = /*#__PURE__*/function (_Namespace) {
  40486. _inheritsLoose(Universal, _Namespace);
  40487. function Universal(opts) {
  40488. var _this;
  40489. _this = _Namespace.call(this, opts) || this;
  40490. _this.type = _types.UNIVERSAL;
  40491. _this.value = '*';
  40492. return _this;
  40493. }
  40494. return Universal;
  40495. }(_namespace["default"]);
  40496. exports["default"] = Universal;
  40497. module.exports = exports.default;
  40498. } (universal, universal.exports));
  40499. return universal.exports;
  40500. }
  40501. var combinator = {exports: {}};
  40502. var hasRequiredCombinator;
  40503. function requireCombinator () {
  40504. if (hasRequiredCombinator) return combinator.exports;
  40505. hasRequiredCombinator = 1;
  40506. (function (module, exports) {
  40507. exports.__esModule = true;
  40508. exports["default"] = void 0;
  40509. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  40510. var _types = /*@__PURE__*/ requireTypes();
  40511. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40512. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40513. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40514. var Combinator = /*#__PURE__*/function (_Node) {
  40515. _inheritsLoose(Combinator, _Node);
  40516. function Combinator(opts) {
  40517. var _this;
  40518. _this = _Node.call(this, opts) || this;
  40519. _this.type = _types.COMBINATOR;
  40520. return _this;
  40521. }
  40522. return Combinator;
  40523. }(_node["default"]);
  40524. exports["default"] = Combinator;
  40525. module.exports = exports.default;
  40526. } (combinator, combinator.exports));
  40527. return combinator.exports;
  40528. }
  40529. var nesting = {exports: {}};
  40530. var hasRequiredNesting;
  40531. function requireNesting () {
  40532. if (hasRequiredNesting) return nesting.exports;
  40533. hasRequiredNesting = 1;
  40534. (function (module, exports) {
  40535. exports.__esModule = true;
  40536. exports["default"] = void 0;
  40537. var _node = _interopRequireDefault(/*@__PURE__*/ requireNode$1());
  40538. var _types = /*@__PURE__*/ requireTypes();
  40539. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40540. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  40541. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40542. var Nesting = /*#__PURE__*/function (_Node) {
  40543. _inheritsLoose(Nesting, _Node);
  40544. function Nesting(opts) {
  40545. var _this;
  40546. _this = _Node.call(this, opts) || this;
  40547. _this.type = _types.NESTING;
  40548. _this.value = '&';
  40549. return _this;
  40550. }
  40551. return Nesting;
  40552. }(_node["default"]);
  40553. exports["default"] = Nesting;
  40554. module.exports = exports.default;
  40555. } (nesting, nesting.exports));
  40556. return nesting.exports;
  40557. }
  40558. var sortAscending = {exports: {}};
  40559. var hasRequiredSortAscending;
  40560. function requireSortAscending () {
  40561. if (hasRequiredSortAscending) return sortAscending.exports;
  40562. hasRequiredSortAscending = 1;
  40563. (function (module, exports) {
  40564. exports.__esModule = true;
  40565. exports["default"] = sortAscending;
  40566. function sortAscending(list) {
  40567. return list.sort(function (a, b) {
  40568. return a - b;
  40569. });
  40570. }
  40571. module.exports = exports.default;
  40572. } (sortAscending, sortAscending.exports));
  40573. return sortAscending.exports;
  40574. }
  40575. var tokenize = {};
  40576. var tokenTypes = {};
  40577. var hasRequiredTokenTypes;
  40578. function requireTokenTypes () {
  40579. if (hasRequiredTokenTypes) return tokenTypes;
  40580. hasRequiredTokenTypes = 1;
  40581. tokenTypes.__esModule = true;
  40582. tokenTypes.word = tokenTypes.tilde = tokenTypes.tab = tokenTypes.str = tokenTypes.space = tokenTypes.slash = tokenTypes.singleQuote = tokenTypes.semicolon = tokenTypes.plus = tokenTypes.pipe = tokenTypes.openSquare = tokenTypes.openParenthesis = tokenTypes.newline = tokenTypes.greaterThan = tokenTypes.feed = tokenTypes.equals = tokenTypes.doubleQuote = tokenTypes.dollar = tokenTypes.cr = tokenTypes.comment = tokenTypes.comma = tokenTypes.combinator = tokenTypes.colon = tokenTypes.closeSquare = tokenTypes.closeParenthesis = tokenTypes.caret = tokenTypes.bang = tokenTypes.backslash = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  40583. var ampersand = 38; // `&`.charCodeAt(0);
  40584. tokenTypes.ampersand = ampersand;
  40585. var asterisk = 42; // `*`.charCodeAt(0);
  40586. tokenTypes.asterisk = asterisk;
  40587. var at = 64; // `@`.charCodeAt(0);
  40588. tokenTypes.at = at;
  40589. var comma = 44; // `,`.charCodeAt(0);
  40590. tokenTypes.comma = comma;
  40591. var colon = 58; // `:`.charCodeAt(0);
  40592. tokenTypes.colon = colon;
  40593. var semicolon = 59; // `;`.charCodeAt(0);
  40594. tokenTypes.semicolon = semicolon;
  40595. var openParenthesis = 40; // `(`.charCodeAt(0);
  40596. tokenTypes.openParenthesis = openParenthesis;
  40597. var closeParenthesis = 41; // `)`.charCodeAt(0);
  40598. tokenTypes.closeParenthesis = closeParenthesis;
  40599. var openSquare = 91; // `[`.charCodeAt(0);
  40600. tokenTypes.openSquare = openSquare;
  40601. var closeSquare = 93; // `]`.charCodeAt(0);
  40602. tokenTypes.closeSquare = closeSquare;
  40603. var dollar = 36; // `$`.charCodeAt(0);
  40604. tokenTypes.dollar = dollar;
  40605. var tilde = 126; // `~`.charCodeAt(0);
  40606. tokenTypes.tilde = tilde;
  40607. var caret = 94; // `^`.charCodeAt(0);
  40608. tokenTypes.caret = caret;
  40609. var plus = 43; // `+`.charCodeAt(0);
  40610. tokenTypes.plus = plus;
  40611. var equals = 61; // `=`.charCodeAt(0);
  40612. tokenTypes.equals = equals;
  40613. var pipe = 124; // `|`.charCodeAt(0);
  40614. tokenTypes.pipe = pipe;
  40615. var greaterThan = 62; // `>`.charCodeAt(0);
  40616. tokenTypes.greaterThan = greaterThan;
  40617. var space = 32; // ` `.charCodeAt(0);
  40618. tokenTypes.space = space;
  40619. var singleQuote = 39; // `'`.charCodeAt(0);
  40620. tokenTypes.singleQuote = singleQuote;
  40621. var doubleQuote = 34; // `"`.charCodeAt(0);
  40622. tokenTypes.doubleQuote = doubleQuote;
  40623. var slash = 47; // `/`.charCodeAt(0);
  40624. tokenTypes.slash = slash;
  40625. var bang = 33; // `!`.charCodeAt(0);
  40626. tokenTypes.bang = bang;
  40627. var backslash = 92; // '\\'.charCodeAt(0);
  40628. tokenTypes.backslash = backslash;
  40629. var cr = 13; // '\r'.charCodeAt(0);
  40630. tokenTypes.cr = cr;
  40631. var feed = 12; // '\f'.charCodeAt(0);
  40632. tokenTypes.feed = feed;
  40633. var newline = 10; // '\n'.charCodeAt(0);
  40634. tokenTypes.newline = newline;
  40635. var tab = 9; // '\t'.charCodeAt(0);
  40636. // Expose aliases primarily for readability.
  40637. tokenTypes.tab = tab;
  40638. var str = singleQuote;
  40639. // No good single character representation!
  40640. tokenTypes.str = str;
  40641. var comment = -1;
  40642. tokenTypes.comment = comment;
  40643. var word = -2;
  40644. tokenTypes.word = word;
  40645. var combinator = -3;
  40646. tokenTypes.combinator = combinator;
  40647. return tokenTypes;
  40648. }
  40649. var hasRequiredTokenize;
  40650. function requireTokenize () {
  40651. if (hasRequiredTokenize) return tokenize;
  40652. hasRequiredTokenize = 1;
  40653. (function (exports) {
  40654. exports.__esModule = true;
  40655. exports.FIELDS = void 0;
  40656. exports["default"] = tokenize;
  40657. var t = _interopRequireWildcard(/*@__PURE__*/ requireTokenTypes());
  40658. var _unescapable, _wordDelimiters;
  40659. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  40660. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  40661. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  40662. 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);
  40663. var hex = {};
  40664. var hexChars = "0123456789abcdefABCDEF";
  40665. for (var i = 0; i < hexChars.length; i++) {
  40666. hex[hexChars.charCodeAt(i)] = true;
  40667. }
  40668. /**
  40669. * Returns the last index of the bar css word
  40670. * @param {string} css The string in which the word begins
  40671. * @param {number} start The index into the string where word's first letter occurs
  40672. */
  40673. function consumeWord(css, start) {
  40674. var next = start;
  40675. var code;
  40676. do {
  40677. code = css.charCodeAt(next);
  40678. if (wordDelimiters[code]) {
  40679. return next - 1;
  40680. } else if (code === t.backslash) {
  40681. next = consumeEscape(css, next) + 1;
  40682. } else {
  40683. // All other characters are part of the word
  40684. next++;
  40685. }
  40686. } while (next < css.length);
  40687. return next - 1;
  40688. }
  40689. /**
  40690. * Returns the last index of the escape sequence
  40691. * @param {string} css The string in which the sequence begins
  40692. * @param {number} start The index into the string where escape character (`\`) occurs.
  40693. */
  40694. function consumeEscape(css, start) {
  40695. var next = start;
  40696. var code = css.charCodeAt(next + 1);
  40697. if (unescapable[code]) ; else if (hex[code]) {
  40698. var hexDigits = 0;
  40699. // consume up to 6 hex chars
  40700. do {
  40701. next++;
  40702. hexDigits++;
  40703. code = css.charCodeAt(next + 1);
  40704. } while (hex[code] && hexDigits < 6);
  40705. // if fewer than 6 hex chars, a trailing space ends the escape
  40706. if (hexDigits < 6 && code === t.space) {
  40707. next++;
  40708. }
  40709. } else {
  40710. // the next char is part of the current word
  40711. next++;
  40712. }
  40713. return next;
  40714. }
  40715. var FIELDS = {
  40716. TYPE: 0,
  40717. START_LINE: 1,
  40718. START_COL: 2,
  40719. END_LINE: 3,
  40720. END_COL: 4,
  40721. START_POS: 5,
  40722. END_POS: 6
  40723. };
  40724. exports.FIELDS = FIELDS;
  40725. function tokenize(input) {
  40726. var tokens = [];
  40727. var css = input.css.valueOf();
  40728. var _css = css,
  40729. length = _css.length;
  40730. var offset = -1;
  40731. var line = 1;
  40732. var start = 0;
  40733. var end = 0;
  40734. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  40735. function unclosed(what, fix) {
  40736. if (input.safe) {
  40737. // fyi: this is never set to true.
  40738. css += fix;
  40739. next = css.length - 1;
  40740. } else {
  40741. throw input.error('Unclosed ' + what, line, start - offset, start);
  40742. }
  40743. }
  40744. while (start < length) {
  40745. code = css.charCodeAt(start);
  40746. if (code === t.newline) {
  40747. offset = start;
  40748. line += 1;
  40749. }
  40750. switch (code) {
  40751. case t.space:
  40752. case t.tab:
  40753. case t.newline:
  40754. case t.cr:
  40755. case t.feed:
  40756. next = start;
  40757. do {
  40758. next += 1;
  40759. code = css.charCodeAt(next);
  40760. if (code === t.newline) {
  40761. offset = next;
  40762. line += 1;
  40763. }
  40764. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  40765. tokenType = t.space;
  40766. endLine = line;
  40767. endColumn = next - offset - 1;
  40768. end = next;
  40769. break;
  40770. case t.plus:
  40771. case t.greaterThan:
  40772. case t.tilde:
  40773. case t.pipe:
  40774. next = start;
  40775. do {
  40776. next += 1;
  40777. code = css.charCodeAt(next);
  40778. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  40779. tokenType = t.combinator;
  40780. endLine = line;
  40781. endColumn = start - offset;
  40782. end = next;
  40783. break;
  40784. // Consume these characters as single tokens.
  40785. case t.asterisk:
  40786. case t.ampersand:
  40787. case t.bang:
  40788. case t.comma:
  40789. case t.equals:
  40790. case t.dollar:
  40791. case t.caret:
  40792. case t.openSquare:
  40793. case t.closeSquare:
  40794. case t.colon:
  40795. case t.semicolon:
  40796. case t.openParenthesis:
  40797. case t.closeParenthesis:
  40798. next = start;
  40799. tokenType = code;
  40800. endLine = line;
  40801. endColumn = start - offset;
  40802. end = next + 1;
  40803. break;
  40804. case t.singleQuote:
  40805. case t.doubleQuote:
  40806. quote = code === t.singleQuote ? "'" : '"';
  40807. next = start;
  40808. do {
  40809. escaped = false;
  40810. next = css.indexOf(quote, next + 1);
  40811. if (next === -1) {
  40812. unclosed('quote', quote);
  40813. }
  40814. escapePos = next;
  40815. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  40816. escapePos -= 1;
  40817. escaped = !escaped;
  40818. }
  40819. } while (escaped);
  40820. tokenType = t.str;
  40821. endLine = line;
  40822. endColumn = start - offset;
  40823. end = next + 1;
  40824. break;
  40825. default:
  40826. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  40827. next = css.indexOf('*/', start + 2) + 1;
  40828. if (next === 0) {
  40829. unclosed('comment', '*/');
  40830. }
  40831. content = css.slice(start, next + 1);
  40832. lines = content.split('\n');
  40833. last = lines.length - 1;
  40834. if (last > 0) {
  40835. nextLine = line + last;
  40836. nextOffset = next - lines[last].length;
  40837. } else {
  40838. nextLine = line;
  40839. nextOffset = offset;
  40840. }
  40841. tokenType = t.comment;
  40842. line = nextLine;
  40843. endLine = nextLine;
  40844. endColumn = next - nextOffset;
  40845. } else if (code === t.slash) {
  40846. next = start;
  40847. tokenType = code;
  40848. endLine = line;
  40849. endColumn = start - offset;
  40850. end = next + 1;
  40851. } else {
  40852. next = consumeWord(css, start);
  40853. tokenType = t.word;
  40854. endLine = line;
  40855. endColumn = next - offset;
  40856. }
  40857. end = next + 1;
  40858. break;
  40859. }
  40860. // Ensure that the token structure remains consistent
  40861. tokens.push([tokenType,
  40862. // [0] Token type
  40863. line,
  40864. // [1] Starting line
  40865. start - offset,
  40866. // [2] Starting column
  40867. endLine,
  40868. // [3] Ending line
  40869. endColumn,
  40870. // [4] Ending column
  40871. start,
  40872. // [5] Start position / Source index
  40873. end // [6] End position
  40874. ]);
  40875. // Reset offset for the next token
  40876. if (nextOffset) {
  40877. offset = nextOffset;
  40878. nextOffset = null;
  40879. }
  40880. start = end;
  40881. }
  40882. return tokens;
  40883. }
  40884. } (tokenize));
  40885. return tokenize;
  40886. }
  40887. var hasRequiredParser;
  40888. function requireParser () {
  40889. if (hasRequiredParser) return parser.exports;
  40890. hasRequiredParser = 1;
  40891. (function (module, exports) {
  40892. exports.__esModule = true;
  40893. exports["default"] = void 0;
  40894. var _root = _interopRequireDefault(/*@__PURE__*/ requireRoot());
  40895. var _selector = _interopRequireDefault(/*@__PURE__*/ requireSelector());
  40896. var _className = _interopRequireDefault(/*@__PURE__*/ requireClassName());
  40897. var _comment = _interopRequireDefault(/*@__PURE__*/ requireComment());
  40898. var _id = _interopRequireDefault(/*@__PURE__*/ requireId());
  40899. var _tag = _interopRequireDefault(/*@__PURE__*/ requireTag());
  40900. var _string = _interopRequireDefault(/*@__PURE__*/ requireString());
  40901. var _pseudo = _interopRequireDefault(/*@__PURE__*/ requirePseudo());
  40902. var _attribute = _interopRequireWildcard(/*@__PURE__*/ requireAttribute());
  40903. var _universal = _interopRequireDefault(/*@__PURE__*/ requireUniversal());
  40904. var _combinator = _interopRequireDefault(/*@__PURE__*/ requireCombinator());
  40905. var _nesting = _interopRequireDefault(/*@__PURE__*/ requireNesting());
  40906. var _sortAscending = _interopRequireDefault(/*@__PURE__*/ requireSortAscending());
  40907. var _tokenize = _interopRequireWildcard(/*@__PURE__*/ requireTokenize());
  40908. var tokens = _interopRequireWildcard(/*@__PURE__*/ requireTokenTypes());
  40909. var types = _interopRequireWildcard(/*@__PURE__*/ requireTypes());
  40910. var _util = /*@__PURE__*/ requireUtil$1();
  40911. var _WHITESPACE_TOKENS, _Object$assign;
  40912. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  40913. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  40914. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40915. 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); } }
  40916. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  40917. 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);
  40918. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  40919. function tokenStart(token) {
  40920. return {
  40921. line: token[_tokenize.FIELDS.START_LINE],
  40922. column: token[_tokenize.FIELDS.START_COL]
  40923. };
  40924. }
  40925. function tokenEnd(token) {
  40926. return {
  40927. line: token[_tokenize.FIELDS.END_LINE],
  40928. column: token[_tokenize.FIELDS.END_COL]
  40929. };
  40930. }
  40931. function getSource(startLine, startColumn, endLine, endColumn) {
  40932. return {
  40933. start: {
  40934. line: startLine,
  40935. column: startColumn
  40936. },
  40937. end: {
  40938. line: endLine,
  40939. column: endColumn
  40940. }
  40941. };
  40942. }
  40943. function getTokenSource(token) {
  40944. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  40945. }
  40946. function getTokenSourceSpan(startToken, endToken) {
  40947. if (!startToken) {
  40948. return undefined;
  40949. }
  40950. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  40951. }
  40952. function unescapeProp(node, prop) {
  40953. var value = node[prop];
  40954. if (typeof value !== "string") {
  40955. return;
  40956. }
  40957. if (value.indexOf("\\") !== -1) {
  40958. (0, _util.ensureObject)(node, 'raws');
  40959. node[prop] = (0, _util.unesc)(value);
  40960. if (node.raws[prop] === undefined) {
  40961. node.raws[prop] = value;
  40962. }
  40963. }
  40964. return node;
  40965. }
  40966. function indexesOf(array, item) {
  40967. var i = -1;
  40968. var indexes = [];
  40969. while ((i = array.indexOf(item, i + 1)) !== -1) {
  40970. indexes.push(i);
  40971. }
  40972. return indexes;
  40973. }
  40974. function uniqs() {
  40975. var list = Array.prototype.concat.apply([], arguments);
  40976. return list.filter(function (item, i) {
  40977. return i === list.indexOf(item);
  40978. });
  40979. }
  40980. var Parser = /*#__PURE__*/function () {
  40981. function Parser(rule, options) {
  40982. if (options === void 0) {
  40983. options = {};
  40984. }
  40985. this.rule = rule;
  40986. this.options = Object.assign({
  40987. lossy: false,
  40988. safe: false
  40989. }, options);
  40990. this.position = 0;
  40991. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  40992. this.tokens = (0, _tokenize["default"])({
  40993. css: this.css,
  40994. error: this._errorGenerator(),
  40995. safe: this.options.safe
  40996. });
  40997. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  40998. this.root = new _root["default"]({
  40999. source: rootSource
  41000. });
  41001. this.root.errorGenerator = this._errorGenerator();
  41002. var selector = new _selector["default"]({
  41003. source: {
  41004. start: {
  41005. line: 1,
  41006. column: 1
  41007. }
  41008. },
  41009. sourceIndex: 0
  41010. });
  41011. this.root.append(selector);
  41012. this.current = selector;
  41013. this.loop();
  41014. }
  41015. var _proto = Parser.prototype;
  41016. _proto._errorGenerator = function _errorGenerator() {
  41017. var _this = this;
  41018. return function (message, errorOptions) {
  41019. if (typeof _this.rule === 'string') {
  41020. return new Error(message);
  41021. }
  41022. return _this.rule.error(message, errorOptions);
  41023. };
  41024. };
  41025. _proto.attribute = function attribute() {
  41026. var attr = [];
  41027. var startingToken = this.currToken;
  41028. this.position++;
  41029. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  41030. attr.push(this.currToken);
  41031. this.position++;
  41032. }
  41033. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  41034. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  41035. }
  41036. var len = attr.length;
  41037. var node = {
  41038. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  41039. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  41040. };
  41041. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  41042. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  41043. }
  41044. var pos = 0;
  41045. var spaceBefore = '';
  41046. var commentBefore = '';
  41047. var lastAdded = null;
  41048. var spaceAfterMeaningfulToken = false;
  41049. while (pos < len) {
  41050. var token = attr[pos];
  41051. var content = this.content(token);
  41052. var next = attr[pos + 1];
  41053. switch (token[_tokenize.FIELDS.TYPE]) {
  41054. case tokens.space:
  41055. // if (
  41056. // len === 1 ||
  41057. // pos === 0 && this.content(next) === '|'
  41058. // ) {
  41059. // return this.expected('attribute', token[TOKEN.START_POS], content);
  41060. // }
  41061. spaceAfterMeaningfulToken = true;
  41062. if (this.options.lossy) {
  41063. break;
  41064. }
  41065. if (lastAdded) {
  41066. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  41067. var prevContent = node.spaces[lastAdded].after || '';
  41068. node.spaces[lastAdded].after = prevContent + content;
  41069. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  41070. if (existingComment) {
  41071. node.raws.spaces[lastAdded].after = existingComment + content;
  41072. }
  41073. } else {
  41074. spaceBefore = spaceBefore + content;
  41075. commentBefore = commentBefore + content;
  41076. }
  41077. break;
  41078. case tokens.asterisk:
  41079. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41080. node.operator = content;
  41081. lastAdded = 'operator';
  41082. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  41083. if (spaceBefore) {
  41084. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  41085. node.spaces.attribute.before = spaceBefore;
  41086. spaceBefore = '';
  41087. }
  41088. if (commentBefore) {
  41089. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  41090. node.raws.spaces.attribute.before = spaceBefore;
  41091. commentBefore = '';
  41092. }
  41093. node.namespace = (node.namespace || "") + content;
  41094. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  41095. if (rawValue) {
  41096. node.raws.namespace += content;
  41097. }
  41098. lastAdded = 'namespace';
  41099. }
  41100. spaceAfterMeaningfulToken = false;
  41101. break;
  41102. case tokens.dollar:
  41103. if (lastAdded === "value") {
  41104. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  41105. node.value += "$";
  41106. if (oldRawValue) {
  41107. node.raws.value = oldRawValue + "$";
  41108. }
  41109. break;
  41110. }
  41111. // Falls through
  41112. case tokens.caret:
  41113. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41114. node.operator = content;
  41115. lastAdded = 'operator';
  41116. }
  41117. spaceAfterMeaningfulToken = false;
  41118. break;
  41119. case tokens.combinator:
  41120. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41121. node.operator = content;
  41122. lastAdded = 'operator';
  41123. }
  41124. if (content !== '|') {
  41125. spaceAfterMeaningfulToken = false;
  41126. break;
  41127. }
  41128. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  41129. node.operator = content;
  41130. lastAdded = 'operator';
  41131. } else if (!node.namespace && !node.attribute) {
  41132. node.namespace = true;
  41133. }
  41134. spaceAfterMeaningfulToken = false;
  41135. break;
  41136. case tokens.word:
  41137. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  41138. // this look-ahead probably fails with comment nodes involved.
  41139. !node.operator && !node.namespace) {
  41140. node.namespace = content;
  41141. lastAdded = 'namespace';
  41142. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  41143. if (spaceBefore) {
  41144. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  41145. node.spaces.attribute.before = spaceBefore;
  41146. spaceBefore = '';
  41147. }
  41148. if (commentBefore) {
  41149. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  41150. node.raws.spaces.attribute.before = commentBefore;
  41151. commentBefore = '';
  41152. }
  41153. node.attribute = (node.attribute || "") + content;
  41154. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  41155. if (_rawValue) {
  41156. node.raws.attribute += content;
  41157. }
  41158. lastAdded = 'attribute';
  41159. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  41160. var _unescaped = (0, _util.unesc)(content);
  41161. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  41162. var oldValue = node.value || '';
  41163. node.value = oldValue + _unescaped;
  41164. node.quoteMark = null;
  41165. if (_unescaped !== content || _oldRawValue) {
  41166. (0, _util.ensureObject)(node, 'raws');
  41167. node.raws.value = (_oldRawValue || oldValue) + content;
  41168. }
  41169. lastAdded = 'value';
  41170. } else {
  41171. var insensitive = content === 'i' || content === "I";
  41172. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  41173. node.insensitive = insensitive;
  41174. if (!insensitive || content === "I") {
  41175. (0, _util.ensureObject)(node, 'raws');
  41176. node.raws.insensitiveFlag = content;
  41177. }
  41178. lastAdded = 'insensitive';
  41179. if (spaceBefore) {
  41180. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  41181. node.spaces.insensitive.before = spaceBefore;
  41182. spaceBefore = '';
  41183. }
  41184. if (commentBefore) {
  41185. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  41186. node.raws.spaces.insensitive.before = commentBefore;
  41187. commentBefore = '';
  41188. }
  41189. } else if (node.value || node.value === '') {
  41190. lastAdded = 'value';
  41191. node.value += content;
  41192. if (node.raws.value) {
  41193. node.raws.value += content;
  41194. }
  41195. }
  41196. }
  41197. spaceAfterMeaningfulToken = false;
  41198. break;
  41199. case tokens.str:
  41200. if (!node.attribute || !node.operator) {
  41201. return this.error("Expected an attribute followed by an operator preceding the string.", {
  41202. index: token[_tokenize.FIELDS.START_POS]
  41203. });
  41204. }
  41205. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  41206. unescaped = _unescapeValue.unescaped,
  41207. quoteMark = _unescapeValue.quoteMark;
  41208. node.value = unescaped;
  41209. node.quoteMark = quoteMark;
  41210. lastAdded = 'value';
  41211. (0, _util.ensureObject)(node, 'raws');
  41212. node.raws.value = content;
  41213. spaceAfterMeaningfulToken = false;
  41214. break;
  41215. case tokens.equals:
  41216. if (!node.attribute) {
  41217. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  41218. }
  41219. if (node.value) {
  41220. return this.error('Unexpected "=" found; an operator was already defined.', {
  41221. index: token[_tokenize.FIELDS.START_POS]
  41222. });
  41223. }
  41224. node.operator = node.operator ? node.operator + content : content;
  41225. lastAdded = 'operator';
  41226. spaceAfterMeaningfulToken = false;
  41227. break;
  41228. case tokens.comment:
  41229. if (lastAdded) {
  41230. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  41231. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  41232. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  41233. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  41234. node.raws.spaces[lastAdded].after = rawLastComment + content;
  41235. } else {
  41236. var lastValue = node[lastAdded] || '';
  41237. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  41238. (0, _util.ensureObject)(node, 'raws');
  41239. node.raws[lastAdded] = rawLastValue + content;
  41240. }
  41241. } else {
  41242. commentBefore = commentBefore + content;
  41243. }
  41244. break;
  41245. default:
  41246. return this.error("Unexpected \"" + content + "\" found.", {
  41247. index: token[_tokenize.FIELDS.START_POS]
  41248. });
  41249. }
  41250. pos++;
  41251. }
  41252. unescapeProp(node, "attribute");
  41253. unescapeProp(node, "namespace");
  41254. this.newNode(new _attribute["default"](node));
  41255. this.position++;
  41256. }
  41257. /**
  41258. * return a node containing meaningless garbage up to (but not including) the specified token position.
  41259. * if the token position is negative, all remaining tokens are consumed.
  41260. *
  41261. * This returns an array containing a single string node if all whitespace,
  41262. * otherwise an array of comment nodes with space before and after.
  41263. *
  41264. * These tokens are not added to the current selector, the caller can add them or use them to amend
  41265. * a previous node's space metadata.
  41266. *
  41267. * In lossy mode, this returns only comments.
  41268. */;
  41269. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  41270. if (stopPosition < 0) {
  41271. stopPosition = this.tokens.length;
  41272. }
  41273. var startPosition = this.position;
  41274. var nodes = [];
  41275. var space = "";
  41276. var lastComment = undefined;
  41277. do {
  41278. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  41279. if (!this.options.lossy) {
  41280. space += this.content();
  41281. }
  41282. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  41283. var spaces = {};
  41284. if (space) {
  41285. spaces.before = space;
  41286. space = "";
  41287. }
  41288. lastComment = new _comment["default"]({
  41289. value: this.content(),
  41290. source: getTokenSource(this.currToken),
  41291. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  41292. spaces: spaces
  41293. });
  41294. nodes.push(lastComment);
  41295. }
  41296. } while (++this.position < stopPosition);
  41297. if (space) {
  41298. if (lastComment) {
  41299. lastComment.spaces.after = space;
  41300. } else if (!this.options.lossy) {
  41301. var firstToken = this.tokens[startPosition];
  41302. var lastToken = this.tokens[this.position - 1];
  41303. nodes.push(new _string["default"]({
  41304. value: '',
  41305. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  41306. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  41307. spaces: {
  41308. before: space,
  41309. after: ''
  41310. }
  41311. }));
  41312. }
  41313. }
  41314. return nodes;
  41315. }
  41316. /**
  41317. *
  41318. * @param {*} nodes
  41319. */;
  41320. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  41321. var _this2 = this;
  41322. if (requiredSpace === void 0) {
  41323. requiredSpace = false;
  41324. }
  41325. var space = "";
  41326. var rawSpace = "";
  41327. nodes.forEach(function (n) {
  41328. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  41329. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  41330. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  41331. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  41332. });
  41333. if (rawSpace === space) {
  41334. rawSpace = undefined;
  41335. }
  41336. var result = {
  41337. space: space,
  41338. rawSpace: rawSpace
  41339. };
  41340. return result;
  41341. };
  41342. _proto.isNamedCombinator = function isNamedCombinator(position) {
  41343. if (position === void 0) {
  41344. position = this.position;
  41345. }
  41346. 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;
  41347. };
  41348. _proto.namedCombinator = function namedCombinator() {
  41349. if (this.isNamedCombinator()) {
  41350. var nameRaw = this.content(this.tokens[this.position + 1]);
  41351. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  41352. var raws = {};
  41353. if (name !== nameRaw) {
  41354. raws.value = "/" + nameRaw + "/";
  41355. }
  41356. var node = new _combinator["default"]({
  41357. value: "/" + name + "/",
  41358. 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]),
  41359. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  41360. raws: raws
  41361. });
  41362. this.position = this.position + 3;
  41363. return node;
  41364. } else {
  41365. this.unexpected();
  41366. }
  41367. };
  41368. _proto.combinator = function combinator() {
  41369. var _this3 = this;
  41370. if (this.content() === '|') {
  41371. return this.namespace();
  41372. }
  41373. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  41374. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  41375. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41376. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  41377. if (nodes.length > 0) {
  41378. var last = this.current.last;
  41379. if (last) {
  41380. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  41381. space = _this$convertWhitespa.space,
  41382. rawSpace = _this$convertWhitespa.rawSpace;
  41383. if (rawSpace !== undefined) {
  41384. last.rawSpaceAfter += rawSpace;
  41385. }
  41386. last.spaces.after += space;
  41387. } else {
  41388. nodes.forEach(function (n) {
  41389. return _this3.newNode(n);
  41390. });
  41391. }
  41392. }
  41393. return;
  41394. }
  41395. var firstToken = this.currToken;
  41396. var spaceOrDescendantSelectorNodes = undefined;
  41397. if (nextSigTokenPos > this.position) {
  41398. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  41399. }
  41400. var node;
  41401. if (this.isNamedCombinator()) {
  41402. node = this.namedCombinator();
  41403. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  41404. node = new _combinator["default"]({
  41405. value: this.content(),
  41406. source: getTokenSource(this.currToken),
  41407. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  41408. });
  41409. this.position++;
  41410. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  41411. this.unexpected();
  41412. }
  41413. if (node) {
  41414. if (spaceOrDescendantSelectorNodes) {
  41415. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  41416. _space = _this$convertWhitespa2.space,
  41417. _rawSpace = _this$convertWhitespa2.rawSpace;
  41418. node.spaces.before = _space;
  41419. node.rawSpaceBefore = _rawSpace;
  41420. }
  41421. } else {
  41422. // descendant combinator
  41423. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  41424. _space2 = _this$convertWhitespa3.space,
  41425. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  41426. if (!_rawSpace2) {
  41427. _rawSpace2 = _space2;
  41428. }
  41429. var spaces = {};
  41430. var raws = {
  41431. spaces: {}
  41432. };
  41433. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  41434. spaces.before = _space2.slice(0, _space2.length - 1);
  41435. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  41436. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  41437. spaces.after = _space2.slice(1);
  41438. raws.spaces.after = _rawSpace2.slice(1);
  41439. } else {
  41440. raws.value = _rawSpace2;
  41441. }
  41442. node = new _combinator["default"]({
  41443. value: ' ',
  41444. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  41445. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  41446. spaces: spaces,
  41447. raws: raws
  41448. });
  41449. }
  41450. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  41451. node.spaces.after = this.optionalSpace(this.content());
  41452. this.position++;
  41453. }
  41454. return this.newNode(node);
  41455. };
  41456. _proto.comma = function comma() {
  41457. if (this.position === this.tokens.length - 1) {
  41458. this.root.trailingComma = true;
  41459. this.position++;
  41460. return;
  41461. }
  41462. this.current._inferEndPosition();
  41463. var selector = new _selector["default"]({
  41464. source: {
  41465. start: tokenStart(this.tokens[this.position + 1])
  41466. },
  41467. sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS]
  41468. });
  41469. this.current.parent.append(selector);
  41470. this.current = selector;
  41471. this.position++;
  41472. };
  41473. _proto.comment = function comment() {
  41474. var current = this.currToken;
  41475. this.newNode(new _comment["default"]({
  41476. value: this.content(),
  41477. source: getTokenSource(current),
  41478. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41479. }));
  41480. this.position++;
  41481. };
  41482. _proto.error = function error(message, opts) {
  41483. throw this.root.error(message, opts);
  41484. };
  41485. _proto.missingBackslash = function missingBackslash() {
  41486. return this.error('Expected a backslash preceding the semicolon.', {
  41487. index: this.currToken[_tokenize.FIELDS.START_POS]
  41488. });
  41489. };
  41490. _proto.missingParenthesis = function missingParenthesis() {
  41491. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  41492. };
  41493. _proto.missingSquareBracket = function missingSquareBracket() {
  41494. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  41495. };
  41496. _proto.unexpected = function unexpected() {
  41497. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  41498. };
  41499. _proto.unexpectedPipe = function unexpectedPipe() {
  41500. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  41501. };
  41502. _proto.namespace = function namespace() {
  41503. var before = this.prevToken && this.content(this.prevToken) || true;
  41504. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  41505. this.position++;
  41506. return this.word(before);
  41507. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  41508. this.position++;
  41509. return this.universal(before);
  41510. }
  41511. this.unexpectedPipe();
  41512. };
  41513. _proto.nesting = function nesting() {
  41514. if (this.nextToken) {
  41515. var nextContent = this.content(this.nextToken);
  41516. if (nextContent === "|") {
  41517. this.position++;
  41518. return;
  41519. }
  41520. }
  41521. var current = this.currToken;
  41522. this.newNode(new _nesting["default"]({
  41523. value: this.content(),
  41524. source: getTokenSource(current),
  41525. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41526. }));
  41527. this.position++;
  41528. };
  41529. _proto.parentheses = function parentheses() {
  41530. var last = this.current.last;
  41531. var unbalanced = 1;
  41532. this.position++;
  41533. if (last && last.type === types.PSEUDO) {
  41534. var selector = new _selector["default"]({
  41535. source: {
  41536. start: tokenStart(this.tokens[this.position])
  41537. },
  41538. sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS]
  41539. });
  41540. var cache = this.current;
  41541. last.append(selector);
  41542. this.current = selector;
  41543. while (this.position < this.tokens.length && unbalanced) {
  41544. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  41545. unbalanced++;
  41546. }
  41547. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41548. unbalanced--;
  41549. }
  41550. if (unbalanced) {
  41551. this.parse();
  41552. } else {
  41553. this.current.source.end = tokenEnd(this.currToken);
  41554. this.current.parent.source.end = tokenEnd(this.currToken);
  41555. this.position++;
  41556. }
  41557. }
  41558. this.current = cache;
  41559. } else {
  41560. // I think this case should be an error. It's used to implement a basic parse of media queries
  41561. // but I don't think it's a good idea.
  41562. var parenStart = this.currToken;
  41563. var parenValue = "(";
  41564. var parenEnd;
  41565. while (this.position < this.tokens.length && unbalanced) {
  41566. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  41567. unbalanced++;
  41568. }
  41569. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41570. unbalanced--;
  41571. }
  41572. parenEnd = this.currToken;
  41573. parenValue += this.parseParenthesisToken(this.currToken);
  41574. this.position++;
  41575. }
  41576. if (last) {
  41577. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  41578. } else {
  41579. this.newNode(new _string["default"]({
  41580. value: parenValue,
  41581. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  41582. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  41583. }));
  41584. }
  41585. }
  41586. if (unbalanced) {
  41587. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  41588. }
  41589. };
  41590. _proto.pseudo = function pseudo() {
  41591. var _this4 = this;
  41592. var pseudoStr = '';
  41593. var startingToken = this.currToken;
  41594. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  41595. pseudoStr += this.content();
  41596. this.position++;
  41597. }
  41598. if (!this.currToken) {
  41599. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  41600. }
  41601. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  41602. this.splitWord(false, function (first, length) {
  41603. pseudoStr += first;
  41604. _this4.newNode(new _pseudo["default"]({
  41605. value: pseudoStr,
  41606. source: getTokenSourceSpan(startingToken, _this4.currToken),
  41607. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  41608. }));
  41609. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  41610. _this4.error('Misplaced parenthesis.', {
  41611. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  41612. });
  41613. }
  41614. });
  41615. } else {
  41616. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  41617. }
  41618. };
  41619. _proto.space = function space() {
  41620. var content = this.content();
  41621. // Handle space before and after the selector
  41622. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  41623. return node.type === 'comment';
  41624. })) {
  41625. this.spaces = this.optionalSpace(content);
  41626. this.position++;
  41627. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  41628. this.current.last.spaces.after = this.optionalSpace(content);
  41629. this.position++;
  41630. } else {
  41631. this.combinator();
  41632. }
  41633. };
  41634. _proto.string = function string() {
  41635. var current = this.currToken;
  41636. this.newNode(new _string["default"]({
  41637. value: this.content(),
  41638. source: getTokenSource(current),
  41639. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41640. }));
  41641. this.position++;
  41642. };
  41643. _proto.universal = function universal(namespace) {
  41644. var nextToken = this.nextToken;
  41645. if (nextToken && this.content(nextToken) === '|') {
  41646. this.position++;
  41647. return this.namespace();
  41648. }
  41649. var current = this.currToken;
  41650. this.newNode(new _universal["default"]({
  41651. value: this.content(),
  41652. source: getTokenSource(current),
  41653. sourceIndex: current[_tokenize.FIELDS.START_POS]
  41654. }), namespace);
  41655. this.position++;
  41656. };
  41657. _proto.splitWord = function splitWord(namespace, firstCallback) {
  41658. var _this5 = this;
  41659. var nextToken = this.nextToken;
  41660. var word = this.content();
  41661. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  41662. this.position++;
  41663. var current = this.content();
  41664. word += current;
  41665. if (current.lastIndexOf('\\') === current.length - 1) {
  41666. var next = this.nextToken;
  41667. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  41668. word += this.requiredSpace(this.content(next));
  41669. this.position++;
  41670. }
  41671. }
  41672. nextToken = this.nextToken;
  41673. }
  41674. var hasClass = indexesOf(word, '.').filter(function (i) {
  41675. // Allow escaped dot within class name
  41676. var escapedDot = word[i - 1] === '\\';
  41677. // Allow decimal numbers percent in @keyframes
  41678. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  41679. return !escapedDot && !isKeyframesPercent;
  41680. });
  41681. var hasId = indexesOf(word, '#').filter(function (i) {
  41682. return word[i - 1] !== '\\';
  41683. });
  41684. // Eliminate Sass interpolations from the list of id indexes
  41685. var interpolations = indexesOf(word, '#{');
  41686. if (interpolations.length) {
  41687. hasId = hasId.filter(function (hashIndex) {
  41688. return !~interpolations.indexOf(hashIndex);
  41689. });
  41690. }
  41691. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  41692. indices.forEach(function (ind, i) {
  41693. var index = indices[i + 1] || word.length;
  41694. var value = word.slice(ind, index);
  41695. if (i === 0 && firstCallback) {
  41696. return firstCallback.call(_this5, value, indices.length);
  41697. }
  41698. var node;
  41699. var current = _this5.currToken;
  41700. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  41701. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  41702. if (~hasClass.indexOf(ind)) {
  41703. var classNameOpts = {
  41704. value: value.slice(1),
  41705. source: source,
  41706. sourceIndex: sourceIndex
  41707. };
  41708. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  41709. } else if (~hasId.indexOf(ind)) {
  41710. var idOpts = {
  41711. value: value.slice(1),
  41712. source: source,
  41713. sourceIndex: sourceIndex
  41714. };
  41715. node = new _id["default"](unescapeProp(idOpts, "value"));
  41716. } else {
  41717. var tagOpts = {
  41718. value: value,
  41719. source: source,
  41720. sourceIndex: sourceIndex
  41721. };
  41722. unescapeProp(tagOpts, "value");
  41723. node = new _tag["default"](tagOpts);
  41724. }
  41725. _this5.newNode(node, namespace);
  41726. // Ensure that the namespace is used only once
  41727. namespace = null;
  41728. });
  41729. this.position++;
  41730. };
  41731. _proto.word = function word(namespace) {
  41732. var nextToken = this.nextToken;
  41733. if (nextToken && this.content(nextToken) === '|') {
  41734. this.position++;
  41735. return this.namespace();
  41736. }
  41737. return this.splitWord(namespace);
  41738. };
  41739. _proto.loop = function loop() {
  41740. while (this.position < this.tokens.length) {
  41741. this.parse(true);
  41742. }
  41743. this.current._inferEndPosition();
  41744. return this.root;
  41745. };
  41746. _proto.parse = function parse(throwOnParenthesis) {
  41747. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  41748. case tokens.space:
  41749. this.space();
  41750. break;
  41751. case tokens.comment:
  41752. this.comment();
  41753. break;
  41754. case tokens.openParenthesis:
  41755. this.parentheses();
  41756. break;
  41757. case tokens.closeParenthesis:
  41758. if (throwOnParenthesis) {
  41759. this.missingParenthesis();
  41760. }
  41761. break;
  41762. case tokens.openSquare:
  41763. this.attribute();
  41764. break;
  41765. case tokens.dollar:
  41766. case tokens.caret:
  41767. case tokens.equals:
  41768. case tokens.word:
  41769. this.word();
  41770. break;
  41771. case tokens.colon:
  41772. this.pseudo();
  41773. break;
  41774. case tokens.comma:
  41775. this.comma();
  41776. break;
  41777. case tokens.asterisk:
  41778. this.universal();
  41779. break;
  41780. case tokens.ampersand:
  41781. this.nesting();
  41782. break;
  41783. case tokens.slash:
  41784. case tokens.combinator:
  41785. this.combinator();
  41786. break;
  41787. case tokens.str:
  41788. this.string();
  41789. break;
  41790. // These cases throw; no break needed.
  41791. case tokens.closeSquare:
  41792. this.missingSquareBracket();
  41793. case tokens.semicolon:
  41794. this.missingBackslash();
  41795. default:
  41796. this.unexpected();
  41797. }
  41798. }
  41799. /**
  41800. * Helpers
  41801. */;
  41802. _proto.expected = function expected(description, index, found) {
  41803. if (Array.isArray(description)) {
  41804. var last = description.pop();
  41805. description = description.join(', ') + " or " + last;
  41806. }
  41807. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  41808. if (!found) {
  41809. return this.error("Expected " + an + " " + description + ".", {
  41810. index: index
  41811. });
  41812. }
  41813. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  41814. index: index
  41815. });
  41816. };
  41817. _proto.requiredSpace = function requiredSpace(space) {
  41818. return this.options.lossy ? ' ' : space;
  41819. };
  41820. _proto.optionalSpace = function optionalSpace(space) {
  41821. return this.options.lossy ? '' : space;
  41822. };
  41823. _proto.lossySpace = function lossySpace(space, required) {
  41824. if (this.options.lossy) {
  41825. return required ? ' ' : '';
  41826. } else {
  41827. return space;
  41828. }
  41829. };
  41830. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  41831. var content = this.content(token);
  41832. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  41833. return this.requiredSpace(content);
  41834. } else {
  41835. return content;
  41836. }
  41837. };
  41838. _proto.newNode = function newNode(node, namespace) {
  41839. if (namespace) {
  41840. if (/^ +$/.test(namespace)) {
  41841. if (!this.options.lossy) {
  41842. this.spaces = (this.spaces || '') + namespace;
  41843. }
  41844. namespace = true;
  41845. }
  41846. node.namespace = namespace;
  41847. unescapeProp(node, "namespace");
  41848. }
  41849. if (this.spaces) {
  41850. node.spaces.before = this.spaces;
  41851. this.spaces = '';
  41852. }
  41853. return this.current.append(node);
  41854. };
  41855. _proto.content = function content(token) {
  41856. if (token === void 0) {
  41857. token = this.currToken;
  41858. }
  41859. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  41860. };
  41861. /**
  41862. * returns the index of the next non-whitespace, non-comment token.
  41863. * returns -1 if no meaningful token is found.
  41864. */
  41865. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  41866. if (startPosition === void 0) {
  41867. startPosition = this.position + 1;
  41868. }
  41869. var searchPosition = startPosition;
  41870. while (searchPosition < this.tokens.length) {
  41871. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  41872. searchPosition++;
  41873. continue;
  41874. } else {
  41875. return searchPosition;
  41876. }
  41877. }
  41878. return -1;
  41879. };
  41880. _createClass(Parser, [{
  41881. key: "currToken",
  41882. get: function get() {
  41883. return this.tokens[this.position];
  41884. }
  41885. }, {
  41886. key: "nextToken",
  41887. get: function get() {
  41888. return this.tokens[this.position + 1];
  41889. }
  41890. }, {
  41891. key: "prevToken",
  41892. get: function get() {
  41893. return this.tokens[this.position - 1];
  41894. }
  41895. }]);
  41896. return Parser;
  41897. }();
  41898. exports["default"] = Parser;
  41899. module.exports = exports.default;
  41900. } (parser, parser.exports));
  41901. return parser.exports;
  41902. }
  41903. var hasRequiredProcessor;
  41904. function requireProcessor () {
  41905. if (hasRequiredProcessor) return processor.exports;
  41906. hasRequiredProcessor = 1;
  41907. (function (module, exports) {
  41908. exports.__esModule = true;
  41909. exports["default"] = void 0;
  41910. var _parser = _interopRequireDefault(/*@__PURE__*/ requireParser());
  41911. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  41912. var Processor = /*#__PURE__*/function () {
  41913. function Processor(func, options) {
  41914. this.func = func || function noop() {};
  41915. this.funcRes = null;
  41916. this.options = options;
  41917. }
  41918. var _proto = Processor.prototype;
  41919. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  41920. if (options === void 0) {
  41921. options = {};
  41922. }
  41923. var merged = Object.assign({}, this.options, options);
  41924. if (merged.updateSelector === false) {
  41925. return false;
  41926. } else {
  41927. return typeof rule !== "string";
  41928. }
  41929. };
  41930. _proto._isLossy = function _isLossy(options) {
  41931. if (options === void 0) {
  41932. options = {};
  41933. }
  41934. var merged = Object.assign({}, this.options, options);
  41935. if (merged.lossless === false) {
  41936. return true;
  41937. } else {
  41938. return false;
  41939. }
  41940. };
  41941. _proto._root = function _root(rule, options) {
  41942. if (options === void 0) {
  41943. options = {};
  41944. }
  41945. var parser = new _parser["default"](rule, this._parseOptions(options));
  41946. return parser.root;
  41947. };
  41948. _proto._parseOptions = function _parseOptions(options) {
  41949. return {
  41950. lossy: this._isLossy(options)
  41951. };
  41952. };
  41953. _proto._run = function _run(rule, options) {
  41954. var _this = this;
  41955. if (options === void 0) {
  41956. options = {};
  41957. }
  41958. return new Promise(function (resolve, reject) {
  41959. try {
  41960. var root = _this._root(rule, options);
  41961. Promise.resolve(_this.func(root)).then(function (transform) {
  41962. var string = undefined;
  41963. if (_this._shouldUpdateSelector(rule, options)) {
  41964. string = root.toString();
  41965. rule.selector = string;
  41966. }
  41967. return {
  41968. transform: transform,
  41969. root: root,
  41970. string: string
  41971. };
  41972. }).then(resolve, reject);
  41973. } catch (e) {
  41974. reject(e);
  41975. return;
  41976. }
  41977. });
  41978. };
  41979. _proto._runSync = function _runSync(rule, options) {
  41980. if (options === void 0) {
  41981. options = {};
  41982. }
  41983. var root = this._root(rule, options);
  41984. var transform = this.func(root);
  41985. if (transform && typeof transform.then === "function") {
  41986. throw new Error("Selector processor returned a promise to a synchronous call.");
  41987. }
  41988. var string = undefined;
  41989. if (options.updateSelector && typeof rule !== "string") {
  41990. string = root.toString();
  41991. rule.selector = string;
  41992. }
  41993. return {
  41994. transform: transform,
  41995. root: root,
  41996. string: string
  41997. };
  41998. }
  41999. /**
  42000. * Process rule into a selector AST.
  42001. *
  42002. * @param rule {postcss.Rule | string} The css selector to be processed
  42003. * @param options The options for processing
  42004. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  42005. */;
  42006. _proto.ast = function ast(rule, options) {
  42007. return this._run(rule, options).then(function (result) {
  42008. return result.root;
  42009. });
  42010. }
  42011. /**
  42012. * Process rule into a selector AST synchronously.
  42013. *
  42014. * @param rule {postcss.Rule | string} The css selector to be processed
  42015. * @param options The options for processing
  42016. * @returns {parser.Root} The AST of the selector after processing it.
  42017. */;
  42018. _proto.astSync = function astSync(rule, options) {
  42019. return this._runSync(rule, options).root;
  42020. }
  42021. /**
  42022. * Process a selector into a transformed value asynchronously
  42023. *
  42024. * @param rule {postcss.Rule | string} The css selector to be processed
  42025. * @param options The options for processing
  42026. * @returns {Promise<any>} The value returned by the processor.
  42027. */;
  42028. _proto.transform = function transform(rule, options) {
  42029. return this._run(rule, options).then(function (result) {
  42030. return result.transform;
  42031. });
  42032. }
  42033. /**
  42034. * Process a selector into a transformed value synchronously.
  42035. *
  42036. * @param rule {postcss.Rule | string} The css selector to be processed
  42037. * @param options The options for processing
  42038. * @returns {any} The value returned by the processor.
  42039. */;
  42040. _proto.transformSync = function transformSync(rule, options) {
  42041. return this._runSync(rule, options).transform;
  42042. }
  42043. /**
  42044. * Process a selector into a new selector string asynchronously.
  42045. *
  42046. * @param rule {postcss.Rule | string} The css selector to be processed
  42047. * @param options The options for processing
  42048. * @returns {string} the selector after processing.
  42049. */;
  42050. _proto.process = function process(rule, options) {
  42051. return this._run(rule, options).then(function (result) {
  42052. return result.string || result.root.toString();
  42053. });
  42054. }
  42055. /**
  42056. * Process a selector into a new selector string synchronously.
  42057. *
  42058. * @param rule {postcss.Rule | string} The css selector to be processed
  42059. * @param options The options for processing
  42060. * @returns {string} the selector after processing.
  42061. */;
  42062. _proto.processSync = function processSync(rule, options) {
  42063. var result = this._runSync(rule, options);
  42064. return result.string || result.root.toString();
  42065. };
  42066. return Processor;
  42067. }();
  42068. exports["default"] = Processor;
  42069. module.exports = exports.default;
  42070. } (processor, processor.exports));
  42071. return processor.exports;
  42072. }
  42073. var selectors = {};
  42074. var constructors = {};
  42075. var hasRequiredConstructors;
  42076. function requireConstructors () {
  42077. if (hasRequiredConstructors) return constructors;
  42078. hasRequiredConstructors = 1;
  42079. constructors.__esModule = true;
  42080. constructors.universal = constructors.tag = constructors.string = constructors.selector = constructors.root = constructors.pseudo = constructors.nesting = constructors.id = constructors.comment = constructors.combinator = constructors.className = constructors.attribute = void 0;
  42081. var _attribute = _interopRequireDefault(/*@__PURE__*/ requireAttribute());
  42082. var _className = _interopRequireDefault(/*@__PURE__*/ requireClassName());
  42083. var _combinator = _interopRequireDefault(/*@__PURE__*/ requireCombinator());
  42084. var _comment = _interopRequireDefault(/*@__PURE__*/ requireComment());
  42085. var _id = _interopRequireDefault(/*@__PURE__*/ requireId());
  42086. var _nesting = _interopRequireDefault(/*@__PURE__*/ requireNesting());
  42087. var _pseudo = _interopRequireDefault(/*@__PURE__*/ requirePseudo());
  42088. var _root = _interopRequireDefault(/*@__PURE__*/ requireRoot());
  42089. var _selector = _interopRequireDefault(/*@__PURE__*/ requireSelector());
  42090. var _string = _interopRequireDefault(/*@__PURE__*/ requireString());
  42091. var _tag = _interopRequireDefault(/*@__PURE__*/ requireTag());
  42092. var _universal = _interopRequireDefault(/*@__PURE__*/ requireUniversal());
  42093. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  42094. var attribute = function attribute(opts) {
  42095. return new _attribute["default"](opts);
  42096. };
  42097. constructors.attribute = attribute;
  42098. var className = function className(opts) {
  42099. return new _className["default"](opts);
  42100. };
  42101. constructors.className = className;
  42102. var combinator = function combinator(opts) {
  42103. return new _combinator["default"](opts);
  42104. };
  42105. constructors.combinator = combinator;
  42106. var comment = function comment(opts) {
  42107. return new _comment["default"](opts);
  42108. };
  42109. constructors.comment = comment;
  42110. var id = function id(opts) {
  42111. return new _id["default"](opts);
  42112. };
  42113. constructors.id = id;
  42114. var nesting = function nesting(opts) {
  42115. return new _nesting["default"](opts);
  42116. };
  42117. constructors.nesting = nesting;
  42118. var pseudo = function pseudo(opts) {
  42119. return new _pseudo["default"](opts);
  42120. };
  42121. constructors.pseudo = pseudo;
  42122. var root = function root(opts) {
  42123. return new _root["default"](opts);
  42124. };
  42125. constructors.root = root;
  42126. var selector = function selector(opts) {
  42127. return new _selector["default"](opts);
  42128. };
  42129. constructors.selector = selector;
  42130. var string = function string(opts) {
  42131. return new _string["default"](opts);
  42132. };
  42133. constructors.string = string;
  42134. var tag = function tag(opts) {
  42135. return new _tag["default"](opts);
  42136. };
  42137. constructors.tag = tag;
  42138. var universal = function universal(opts) {
  42139. return new _universal["default"](opts);
  42140. };
  42141. constructors.universal = universal;
  42142. return constructors;
  42143. }
  42144. var guards = {};
  42145. var hasRequiredGuards;
  42146. function requireGuards () {
  42147. if (hasRequiredGuards) return guards;
  42148. hasRequiredGuards = 1;
  42149. guards.__esModule = true;
  42150. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  42151. guards.isContainer = isContainer;
  42152. guards.isIdentifier = void 0;
  42153. guards.isNamespace = isNamespace;
  42154. guards.isNesting = void 0;
  42155. guards.isNode = isNode;
  42156. guards.isPseudo = void 0;
  42157. guards.isPseudoClass = isPseudoClass;
  42158. guards.isPseudoElement = isPseudoElement;
  42159. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  42160. var _types = /*@__PURE__*/ requireTypes();
  42161. var _IS_TYPE;
  42162. var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE);
  42163. function isNode(node) {
  42164. return typeof node === "object" && IS_TYPE[node.type];
  42165. }
  42166. function isNodeType(type, node) {
  42167. return isNode(node) && node.type === type;
  42168. }
  42169. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  42170. guards.isAttribute = isAttribute;
  42171. var isClassName = isNodeType.bind(null, _types.CLASS);
  42172. guards.isClassName = isClassName;
  42173. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  42174. guards.isCombinator = isCombinator;
  42175. var isComment = isNodeType.bind(null, _types.COMMENT);
  42176. guards.isComment = isComment;
  42177. var isIdentifier = isNodeType.bind(null, _types.ID);
  42178. guards.isIdentifier = isIdentifier;
  42179. var isNesting = isNodeType.bind(null, _types.NESTING);
  42180. guards.isNesting = isNesting;
  42181. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  42182. guards.isPseudo = isPseudo;
  42183. var isRoot = isNodeType.bind(null, _types.ROOT);
  42184. guards.isRoot = isRoot;
  42185. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  42186. guards.isSelector = isSelector;
  42187. var isString = isNodeType.bind(null, _types.STRING);
  42188. guards.isString = isString;
  42189. var isTag = isNodeType.bind(null, _types.TAG);
  42190. guards.isTag = isTag;
  42191. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  42192. guards.isUniversal = isUniversal;
  42193. function isPseudoElement(node) {
  42194. return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
  42195. }
  42196. function isPseudoClass(node) {
  42197. return isPseudo(node) && !isPseudoElement(node);
  42198. }
  42199. function isContainer(node) {
  42200. return !!(isNode(node) && node.walk);
  42201. }
  42202. function isNamespace(node) {
  42203. return isAttribute(node) || isTag(node);
  42204. }
  42205. return guards;
  42206. }
  42207. var hasRequiredSelectors;
  42208. function requireSelectors () {
  42209. if (hasRequiredSelectors) return selectors;
  42210. hasRequiredSelectors = 1;
  42211. (function (exports) {
  42212. exports.__esModule = true;
  42213. var _types = /*@__PURE__*/ requireTypes();
  42214. Object.keys(_types).forEach(function (key) {
  42215. if (key === "default" || key === "__esModule") return;
  42216. if (key in exports && exports[key] === _types[key]) return;
  42217. exports[key] = _types[key];
  42218. });
  42219. var _constructors = /*@__PURE__*/ requireConstructors();
  42220. Object.keys(_constructors).forEach(function (key) {
  42221. if (key === "default" || key === "__esModule") return;
  42222. if (key in exports && exports[key] === _constructors[key]) return;
  42223. exports[key] = _constructors[key];
  42224. });
  42225. var _guards = /*@__PURE__*/ requireGuards();
  42226. Object.keys(_guards).forEach(function (key) {
  42227. if (key === "default" || key === "__esModule") return;
  42228. if (key in exports && exports[key] === _guards[key]) return;
  42229. exports[key] = _guards[key];
  42230. });
  42231. } (selectors));
  42232. return selectors;
  42233. }
  42234. var hasRequiredDist;
  42235. function requireDist () {
  42236. if (hasRequiredDist) return dist.exports;
  42237. hasRequiredDist = 1;
  42238. (function (module, exports) {
  42239. exports.__esModule = true;
  42240. exports["default"] = void 0;
  42241. var _processor = _interopRequireDefault(/*@__PURE__*/ requireProcessor());
  42242. var selectors = _interopRequireWildcard(/*@__PURE__*/ requireSelectors());
  42243. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  42244. function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  42245. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  42246. var parser = function parser(processor) {
  42247. return new _processor["default"](processor);
  42248. };
  42249. Object.assign(parser, selectors);
  42250. delete parser.__esModule;
  42251. var _default = parser;
  42252. exports["default"] = _default;
  42253. module.exports = exports.default;
  42254. } (dist, dist.exports));
  42255. return dist.exports;
  42256. }
  42257. var distExports = /*@__PURE__*/ requireDist();
  42258. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
  42259. const animationNameRE = /^(-\w+-)?animation-name$/;
  42260. const animationRE = /^(-\w+-)?animation$/;
  42261. const scopedPlugin = (id = "") => {
  42262. const keyframes = /* @__PURE__ */ Object.create(null);
  42263. const shortId = id.replace(/^data-v-/, "");
  42264. return {
  42265. postcssPlugin: "vue-sfc-scoped",
  42266. Rule(rule) {
  42267. processRule(id, rule);
  42268. },
  42269. AtRule(node) {
  42270. if (/-?keyframes$/.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
  42271. keyframes[node.params] = node.params = node.params + "-" + shortId;
  42272. }
  42273. },
  42274. OnceExit(root) {
  42275. if (Object.keys(keyframes).length) {
  42276. root.walkDecls((decl) => {
  42277. if (animationNameRE.test(decl.prop)) {
  42278. decl.value = decl.value.split(",").map((v) => keyframes[v.trim()] || v.trim()).join(",");
  42279. }
  42280. if (animationRE.test(decl.prop)) {
  42281. decl.value = decl.value.split(",").map((v) => {
  42282. const vals = v.trim().split(/\s+/);
  42283. const i = vals.findIndex((val) => keyframes[val]);
  42284. if (i !== -1) {
  42285. vals.splice(i, 1, keyframes[vals[i]]);
  42286. return vals.join(" ");
  42287. } else {
  42288. return v;
  42289. }
  42290. }).join(",");
  42291. }
  42292. });
  42293. }
  42294. }
  42295. };
  42296. };
  42297. const processedRules = /* @__PURE__ */ new WeakSet();
  42298. function processRule(id, rule) {
  42299. if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && /-?keyframes$/.test(rule.parent.name)) {
  42300. return;
  42301. }
  42302. processedRules.add(rule);
  42303. let deep = false;
  42304. let parent = rule.parent;
  42305. while (parent && parent.type !== "root") {
  42306. if (parent.__deep) {
  42307. deep = true;
  42308. break;
  42309. }
  42310. parent = parent.parent;
  42311. }
  42312. rule.selector = selectorParser((selectorRoot) => {
  42313. selectorRoot.each((selector) => {
  42314. rewriteSelector(id, rule, selector, selectorRoot, deep);
  42315. });
  42316. }).processSync(rule.selector);
  42317. }
  42318. function rewriteSelector(id, rule, selector, selectorRoot, deep, slotted = false) {
  42319. let node = null;
  42320. let shouldInject = !deep;
  42321. selector.each((n) => {
  42322. if (n.type === "combinator" && (n.value === ">>>" || n.value === "/deep/")) {
  42323. n.value = " ";
  42324. n.spaces.before = n.spaces.after = "";
  42325. warn(
  42326. `the >>> and /deep/ combinators have been deprecated. Use :deep() instead.`
  42327. );
  42328. return false;
  42329. }
  42330. if (n.type === "pseudo") {
  42331. const { value } = n;
  42332. if (value === ":deep" || value === "::v-deep") {
  42333. rule.__deep = true;
  42334. if (n.nodes.length) {
  42335. let last = n;
  42336. n.nodes[0].each((ss) => {
  42337. selector.insertAfter(last, ss);
  42338. last = ss;
  42339. });
  42340. const prev = selector.at(selector.index(n) - 1);
  42341. if (!prev || !isSpaceCombinator(prev)) {
  42342. selector.insertAfter(
  42343. n,
  42344. selectorParser.combinator({
  42345. value: " "
  42346. })
  42347. );
  42348. }
  42349. selector.removeChild(n);
  42350. } else {
  42351. warn(
  42352. `${value} usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
  42353. );
  42354. const prev = selector.at(selector.index(n) - 1);
  42355. if (prev && isSpaceCombinator(prev)) {
  42356. selector.removeChild(prev);
  42357. }
  42358. selector.removeChild(n);
  42359. }
  42360. return false;
  42361. }
  42362. if (value === ":slotted" || value === "::v-slotted") {
  42363. rewriteSelector(
  42364. id,
  42365. rule,
  42366. n.nodes[0],
  42367. selectorRoot,
  42368. deep,
  42369. true
  42370. );
  42371. let last = n;
  42372. n.nodes[0].each((ss) => {
  42373. selector.insertAfter(last, ss);
  42374. last = ss;
  42375. });
  42376. selector.removeChild(n);
  42377. shouldInject = false;
  42378. return false;
  42379. }
  42380. if (value === ":global" || value === "::v-global") {
  42381. selectorRoot.insertAfter(selector, n.nodes[0]);
  42382. selectorRoot.removeChild(selector);
  42383. return false;
  42384. }
  42385. }
  42386. if (n.type === "universal") {
  42387. const prev = selector.at(selector.index(n) - 1);
  42388. const next = selector.at(selector.index(n) + 1);
  42389. if (!prev) {
  42390. if (next) {
  42391. if (next.type === "combinator" && next.value === " ") {
  42392. selector.removeChild(next);
  42393. }
  42394. selector.removeChild(n);
  42395. return;
  42396. } else {
  42397. node = selectorParser.combinator({
  42398. value: ""
  42399. });
  42400. selector.insertBefore(n, node);
  42401. selector.removeChild(n);
  42402. return false;
  42403. }
  42404. }
  42405. if (node) return;
  42406. }
  42407. if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where") && !node) {
  42408. node = n;
  42409. }
  42410. });
  42411. if (rule.nodes.some((node2) => node2.type === "rule")) {
  42412. const deep2 = rule.__deep;
  42413. if (!deep2) {
  42414. extractAndWrapNodes(rule);
  42415. const atruleNodes = rule.nodes.filter((node2) => node2.type === "atrule");
  42416. for (const atnode of atruleNodes) {
  42417. extractAndWrapNodes(atnode);
  42418. }
  42419. }
  42420. shouldInject = deep2;
  42421. }
  42422. if (node) {
  42423. const { type, value } = node;
  42424. if (type === "pseudo" && (value === ":is" || value === ":where")) {
  42425. node.nodes.forEach(
  42426. (value2) => rewriteSelector(id, rule, value2, selectorRoot, deep, slotted)
  42427. );
  42428. shouldInject = false;
  42429. }
  42430. }
  42431. if (node) {
  42432. node.spaces.after = "";
  42433. } else {
  42434. selector.first.spaces.before = "";
  42435. }
  42436. if (shouldInject) {
  42437. const idToAdd = slotted ? id + "-s" : id;
  42438. selector.insertAfter(
  42439. // If node is null it means we need to inject [id] at the start
  42440. // insertAfter can handle `null` here
  42441. node,
  42442. selectorParser.attribute({
  42443. attribute: idToAdd,
  42444. value: idToAdd,
  42445. raws: {},
  42446. quoteMark: `"`
  42447. })
  42448. );
  42449. }
  42450. }
  42451. function isSpaceCombinator(node) {
  42452. return node.type === "combinator" && /^\s+$/.test(node.value);
  42453. }
  42454. function extractAndWrapNodes(parentNode) {
  42455. if (!parentNode.nodes) return;
  42456. const nodes = parentNode.nodes.filter(
  42457. (node) => node.type === "decl" || node.type === "comment"
  42458. );
  42459. if (nodes.length) {
  42460. for (const node of nodes) {
  42461. parentNode.removeChild(node);
  42462. }
  42463. const wrappedRule = new Rule({
  42464. nodes,
  42465. selector: "&"
  42466. });
  42467. parentNode.prepend(wrappedRule);
  42468. }
  42469. }
  42470. scopedPlugin.postcss = true;
  42471. var sourceMap = {};
  42472. var sourceMapGenerator = {};
  42473. var base64Vlq = {};
  42474. var base64 = {};
  42475. /* -*- Mode: js; js-indent-level: 2; -*- */
  42476. var hasRequiredBase64;
  42477. function requireBase64 () {
  42478. if (hasRequiredBase64) return base64;
  42479. hasRequiredBase64 = 1;
  42480. /*
  42481. * Copyright 2011 Mozilla Foundation and contributors
  42482. * Licensed under the New BSD license. See LICENSE or:
  42483. * http://opensource.org/licenses/BSD-3-Clause
  42484. */
  42485. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  42486. /**
  42487. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  42488. */
  42489. base64.encode = function (number) {
  42490. if (0 <= number && number < intToCharMap.length) {
  42491. return intToCharMap[number];
  42492. }
  42493. throw new TypeError("Must be between 0 and 63: " + number);
  42494. };
  42495. /**
  42496. * Decode a single base 64 character code digit to an integer. Returns -1 on
  42497. * failure.
  42498. */
  42499. base64.decode = function (charCode) {
  42500. var bigA = 65; // 'A'
  42501. var bigZ = 90; // 'Z'
  42502. var littleA = 97; // 'a'
  42503. var littleZ = 122; // 'z'
  42504. var zero = 48; // '0'
  42505. var nine = 57; // '9'
  42506. var plus = 43; // '+'
  42507. var slash = 47; // '/'
  42508. var littleOffset = 26;
  42509. var numberOffset = 52;
  42510. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  42511. if (bigA <= charCode && charCode <= bigZ) {
  42512. return (charCode - bigA);
  42513. }
  42514. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  42515. if (littleA <= charCode && charCode <= littleZ) {
  42516. return (charCode - littleA + littleOffset);
  42517. }
  42518. // 52 - 61: 0123456789
  42519. if (zero <= charCode && charCode <= nine) {
  42520. return (charCode - zero + numberOffset);
  42521. }
  42522. // 62: +
  42523. if (charCode == plus) {
  42524. return 62;
  42525. }
  42526. // 63: /
  42527. if (charCode == slash) {
  42528. return 63;
  42529. }
  42530. // Invalid base64 digit.
  42531. return -1;
  42532. };
  42533. return base64;
  42534. }
  42535. /* -*- Mode: js; js-indent-level: 2; -*- */
  42536. var hasRequiredBase64Vlq;
  42537. function requireBase64Vlq () {
  42538. if (hasRequiredBase64Vlq) return base64Vlq;
  42539. hasRequiredBase64Vlq = 1;
  42540. /*
  42541. * Copyright 2011 Mozilla Foundation and contributors
  42542. * Licensed under the New BSD license. See LICENSE or:
  42543. * http://opensource.org/licenses/BSD-3-Clause
  42544. *
  42545. * Based on the Base 64 VLQ implementation in Closure Compiler:
  42546. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  42547. *
  42548. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  42549. * Redistribution and use in source and binary forms, with or without
  42550. * modification, are permitted provided that the following conditions are
  42551. * met:
  42552. *
  42553. * * Redistributions of source code must retain the above copyright
  42554. * notice, this list of conditions and the following disclaimer.
  42555. * * Redistributions in binary form must reproduce the above
  42556. * copyright notice, this list of conditions and the following
  42557. * disclaimer in the documentation and/or other materials provided
  42558. * with the distribution.
  42559. * * Neither the name of Google Inc. nor the names of its
  42560. * contributors may be used to endorse or promote products derived
  42561. * from this software without specific prior written permission.
  42562. *
  42563. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  42564. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  42565. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  42566. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  42567. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42568. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42569. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  42570. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  42571. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42572. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  42573. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42574. */
  42575. var base64 = /*@__PURE__*/ requireBase64();
  42576. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  42577. // length quantities we use in the source map spec, the first bit is the sign,
  42578. // the next four bits are the actual value, and the 6th bit is the
  42579. // continuation bit. The continuation bit tells us whether there are more
  42580. // digits in this value following this digit.
  42581. //
  42582. // Continuation
  42583. // | Sign
  42584. // | |
  42585. // V V
  42586. // 101011
  42587. var VLQ_BASE_SHIFT = 5;
  42588. // binary: 100000
  42589. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  42590. // binary: 011111
  42591. var VLQ_BASE_MASK = VLQ_BASE - 1;
  42592. // binary: 100000
  42593. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  42594. /**
  42595. * Converts from a two-complement value to a value where the sign bit is
  42596. * placed in the least significant bit. For example, as decimals:
  42597. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  42598. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  42599. */
  42600. function toVLQSigned(aValue) {
  42601. return aValue < 0
  42602. ? ((-aValue) << 1) + 1
  42603. : (aValue << 1) + 0;
  42604. }
  42605. /**
  42606. * Converts to a two-complement value from a value where the sign bit is
  42607. * placed in the least significant bit. For example, as decimals:
  42608. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  42609. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  42610. */
  42611. function fromVLQSigned(aValue) {
  42612. var isNegative = (aValue & 1) === 1;
  42613. var shifted = aValue >> 1;
  42614. return isNegative
  42615. ? -shifted
  42616. : shifted;
  42617. }
  42618. /**
  42619. * Returns the base 64 VLQ encoded value.
  42620. */
  42621. base64Vlq.encode = function base64VLQ_encode(aValue) {
  42622. var encoded = "";
  42623. var digit;
  42624. var vlq = toVLQSigned(aValue);
  42625. do {
  42626. digit = vlq & VLQ_BASE_MASK;
  42627. vlq >>>= VLQ_BASE_SHIFT;
  42628. if (vlq > 0) {
  42629. // There are still more digits in this value, so we must make sure the
  42630. // continuation bit is marked.
  42631. digit |= VLQ_CONTINUATION_BIT;
  42632. }
  42633. encoded += base64.encode(digit);
  42634. } while (vlq > 0);
  42635. return encoded;
  42636. };
  42637. /**
  42638. * Decodes the next base 64 VLQ value from the given string and returns the
  42639. * value and the rest of the string via the out parameter.
  42640. */
  42641. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  42642. var strLen = aStr.length;
  42643. var result = 0;
  42644. var shift = 0;
  42645. var continuation, digit;
  42646. do {
  42647. if (aIndex >= strLen) {
  42648. throw new Error("Expected more digits in base 64 VLQ value.");
  42649. }
  42650. digit = base64.decode(aStr.charCodeAt(aIndex++));
  42651. if (digit === -1) {
  42652. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  42653. }
  42654. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  42655. digit &= VLQ_BASE_MASK;
  42656. result = result + (digit << shift);
  42657. shift += VLQ_BASE_SHIFT;
  42658. } while (continuation);
  42659. aOutParam.value = fromVLQSigned(result);
  42660. aOutParam.rest = aIndex;
  42661. };
  42662. return base64Vlq;
  42663. }
  42664. var util = {};
  42665. /* -*- Mode: js; js-indent-level: 2; -*- */
  42666. var hasRequiredUtil;
  42667. function requireUtil () {
  42668. if (hasRequiredUtil) return util;
  42669. hasRequiredUtil = 1;
  42670. (function (exports) {
  42671. /*
  42672. * Copyright 2011 Mozilla Foundation and contributors
  42673. * Licensed under the New BSD license. See LICENSE or:
  42674. * http://opensource.org/licenses/BSD-3-Clause
  42675. */
  42676. /**
  42677. * This is a helper function for getting values from parameter/options
  42678. * objects.
  42679. *
  42680. * @param args The object we are extracting values from
  42681. * @param name The name of the property we are getting.
  42682. * @param defaultValue An optional value to return if the property is missing
  42683. * from the object. If this is not specified and the property is missing, an
  42684. * error will be thrown.
  42685. */
  42686. function getArg(aArgs, aName, aDefaultValue) {
  42687. if (aName in aArgs) {
  42688. return aArgs[aName];
  42689. } else if (arguments.length === 3) {
  42690. return aDefaultValue;
  42691. } else {
  42692. throw new Error('"' + aName + '" is a required argument.');
  42693. }
  42694. }
  42695. exports.getArg = getArg;
  42696. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  42697. var dataUrlRegexp = /^data:.+\,.+$/;
  42698. function urlParse(aUrl) {
  42699. var match = aUrl.match(urlRegexp);
  42700. if (!match) {
  42701. return null;
  42702. }
  42703. return {
  42704. scheme: match[1],
  42705. auth: match[2],
  42706. host: match[3],
  42707. port: match[4],
  42708. path: match[5]
  42709. };
  42710. }
  42711. exports.urlParse = urlParse;
  42712. function urlGenerate(aParsedUrl) {
  42713. var url = '';
  42714. if (aParsedUrl.scheme) {
  42715. url += aParsedUrl.scheme + ':';
  42716. }
  42717. url += '//';
  42718. if (aParsedUrl.auth) {
  42719. url += aParsedUrl.auth + '@';
  42720. }
  42721. if (aParsedUrl.host) {
  42722. url += aParsedUrl.host;
  42723. }
  42724. if (aParsedUrl.port) {
  42725. url += ":" + aParsedUrl.port;
  42726. }
  42727. if (aParsedUrl.path) {
  42728. url += aParsedUrl.path;
  42729. }
  42730. return url;
  42731. }
  42732. exports.urlGenerate = urlGenerate;
  42733. /**
  42734. * Normalizes a path, or the path portion of a URL:
  42735. *
  42736. * - Replaces consecutive slashes with one slash.
  42737. * - Removes unnecessary '.' parts.
  42738. * - Removes unnecessary '<dir>/..' parts.
  42739. *
  42740. * Based on code in the Node.js 'path' core module.
  42741. *
  42742. * @param aPath The path or url to normalize.
  42743. */
  42744. function normalize(aPath) {
  42745. var path = aPath;
  42746. var url = urlParse(aPath);
  42747. if (url) {
  42748. if (!url.path) {
  42749. return aPath;
  42750. }
  42751. path = url.path;
  42752. }
  42753. var isAbsolute = exports.isAbsolute(path);
  42754. var parts = path.split(/\/+/);
  42755. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  42756. part = parts[i];
  42757. if (part === '.') {
  42758. parts.splice(i, 1);
  42759. } else if (part === '..') {
  42760. up++;
  42761. } else if (up > 0) {
  42762. if (part === '') {
  42763. // The first part is blank if the path is absolute. Trying to go
  42764. // above the root is a no-op. Therefore we can remove all '..' parts
  42765. // directly after the root.
  42766. parts.splice(i + 1, up);
  42767. up = 0;
  42768. } else {
  42769. parts.splice(i, 2);
  42770. up--;
  42771. }
  42772. }
  42773. }
  42774. path = parts.join('/');
  42775. if (path === '') {
  42776. path = isAbsolute ? '/' : '.';
  42777. }
  42778. if (url) {
  42779. url.path = path;
  42780. return urlGenerate(url);
  42781. }
  42782. return path;
  42783. }
  42784. exports.normalize = normalize;
  42785. /**
  42786. * Joins two paths/URLs.
  42787. *
  42788. * @param aRoot The root path or URL.
  42789. * @param aPath The path or URL to be joined with the root.
  42790. *
  42791. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  42792. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  42793. * first.
  42794. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  42795. * is updated with the result and aRoot is returned. Otherwise the result
  42796. * is returned.
  42797. * - If aPath is absolute, the result is aPath.
  42798. * - Otherwise the two paths are joined with a slash.
  42799. * - Joining for example 'http://' and 'www.example.com' is also supported.
  42800. */
  42801. function join(aRoot, aPath) {
  42802. if (aRoot === "") {
  42803. aRoot = ".";
  42804. }
  42805. if (aPath === "") {
  42806. aPath = ".";
  42807. }
  42808. var aPathUrl = urlParse(aPath);
  42809. var aRootUrl = urlParse(aRoot);
  42810. if (aRootUrl) {
  42811. aRoot = aRootUrl.path || '/';
  42812. }
  42813. // `join(foo, '//www.example.org')`
  42814. if (aPathUrl && !aPathUrl.scheme) {
  42815. if (aRootUrl) {
  42816. aPathUrl.scheme = aRootUrl.scheme;
  42817. }
  42818. return urlGenerate(aPathUrl);
  42819. }
  42820. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  42821. return aPath;
  42822. }
  42823. // `join('http://', 'www.example.com')`
  42824. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  42825. aRootUrl.host = aPath;
  42826. return urlGenerate(aRootUrl);
  42827. }
  42828. var joined = aPath.charAt(0) === '/'
  42829. ? aPath
  42830. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  42831. if (aRootUrl) {
  42832. aRootUrl.path = joined;
  42833. return urlGenerate(aRootUrl);
  42834. }
  42835. return joined;
  42836. }
  42837. exports.join = join;
  42838. exports.isAbsolute = function (aPath) {
  42839. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  42840. };
  42841. /**
  42842. * Make a path relative to a URL or another path.
  42843. *
  42844. * @param aRoot The root path or URL.
  42845. * @param aPath The path or URL to be made relative to aRoot.
  42846. */
  42847. function relative(aRoot, aPath) {
  42848. if (aRoot === "") {
  42849. aRoot = ".";
  42850. }
  42851. aRoot = aRoot.replace(/\/$/, '');
  42852. // It is possible for the path to be above the root. In this case, simply
  42853. // checking whether the root is a prefix of the path won't work. Instead, we
  42854. // need to remove components from the root one by one, until either we find
  42855. // a prefix that fits, or we run out of components to remove.
  42856. var level = 0;
  42857. while (aPath.indexOf(aRoot + '/') !== 0) {
  42858. var index = aRoot.lastIndexOf("/");
  42859. if (index < 0) {
  42860. return aPath;
  42861. }
  42862. // If the only part of the root that is left is the scheme (i.e. http://,
  42863. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  42864. // have exhausted all components, so the path is not relative to the root.
  42865. aRoot = aRoot.slice(0, index);
  42866. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  42867. return aPath;
  42868. }
  42869. ++level;
  42870. }
  42871. // Make sure we add a "../" for each component we removed from the root.
  42872. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  42873. }
  42874. exports.relative = relative;
  42875. var supportsNullProto = (function () {
  42876. var obj = Object.create(null);
  42877. return !('__proto__' in obj);
  42878. }());
  42879. function identity (s) {
  42880. return s;
  42881. }
  42882. /**
  42883. * Because behavior goes wacky when you set `__proto__` on objects, we
  42884. * have to prefix all the strings in our set with an arbitrary character.
  42885. *
  42886. * See https://github.com/mozilla/source-map/pull/31 and
  42887. * https://github.com/mozilla/source-map/issues/30
  42888. *
  42889. * @param String aStr
  42890. */
  42891. function toSetString(aStr) {
  42892. if (isProtoString(aStr)) {
  42893. return '$' + aStr;
  42894. }
  42895. return aStr;
  42896. }
  42897. exports.toSetString = supportsNullProto ? identity : toSetString;
  42898. function fromSetString(aStr) {
  42899. if (isProtoString(aStr)) {
  42900. return aStr.slice(1);
  42901. }
  42902. return aStr;
  42903. }
  42904. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  42905. function isProtoString(s) {
  42906. if (!s) {
  42907. return false;
  42908. }
  42909. var length = s.length;
  42910. if (length < 9 /* "__proto__".length */) {
  42911. return false;
  42912. }
  42913. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  42914. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  42915. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  42916. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  42917. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  42918. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  42919. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  42920. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  42921. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  42922. return false;
  42923. }
  42924. for (var i = length - 10; i >= 0; i--) {
  42925. if (s.charCodeAt(i) !== 36 /* '$' */) {
  42926. return false;
  42927. }
  42928. }
  42929. return true;
  42930. }
  42931. /**
  42932. * Comparator between two mappings where the original positions are compared.
  42933. *
  42934. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  42935. * mappings with the same original source/line/column, but different generated
  42936. * line and column the same. Useful when searching for a mapping with a
  42937. * stubbed out mapping.
  42938. */
  42939. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  42940. var cmp = strcmp(mappingA.source, mappingB.source);
  42941. if (cmp !== 0) {
  42942. return cmp;
  42943. }
  42944. cmp = mappingA.originalLine - mappingB.originalLine;
  42945. if (cmp !== 0) {
  42946. return cmp;
  42947. }
  42948. cmp = mappingA.originalColumn - mappingB.originalColumn;
  42949. if (cmp !== 0 || onlyCompareOriginal) {
  42950. return cmp;
  42951. }
  42952. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  42953. if (cmp !== 0) {
  42954. return cmp;
  42955. }
  42956. cmp = mappingA.generatedLine - mappingB.generatedLine;
  42957. if (cmp !== 0) {
  42958. return cmp;
  42959. }
  42960. return strcmp(mappingA.name, mappingB.name);
  42961. }
  42962. exports.compareByOriginalPositions = compareByOriginalPositions;
  42963. /**
  42964. * Comparator between two mappings with deflated source and name indices where
  42965. * the generated positions are compared.
  42966. *
  42967. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  42968. * mappings with the same generated line and column, but different
  42969. * source/name/original line and column the same. Useful when searching for a
  42970. * mapping with a stubbed out mapping.
  42971. */
  42972. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  42973. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  42974. if (cmp !== 0) {
  42975. return cmp;
  42976. }
  42977. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  42978. if (cmp !== 0 || onlyCompareGenerated) {
  42979. return cmp;
  42980. }
  42981. cmp = strcmp(mappingA.source, mappingB.source);
  42982. if (cmp !== 0) {
  42983. return cmp;
  42984. }
  42985. cmp = mappingA.originalLine - mappingB.originalLine;
  42986. if (cmp !== 0) {
  42987. return cmp;
  42988. }
  42989. cmp = mappingA.originalColumn - mappingB.originalColumn;
  42990. if (cmp !== 0) {
  42991. return cmp;
  42992. }
  42993. return strcmp(mappingA.name, mappingB.name);
  42994. }
  42995. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  42996. function strcmp(aStr1, aStr2) {
  42997. if (aStr1 === aStr2) {
  42998. return 0;
  42999. }
  43000. if (aStr1 === null) {
  43001. return 1; // aStr2 !== null
  43002. }
  43003. if (aStr2 === null) {
  43004. return -1; // aStr1 !== null
  43005. }
  43006. if (aStr1 > aStr2) {
  43007. return 1;
  43008. }
  43009. return -1;
  43010. }
  43011. /**
  43012. * Comparator between two mappings with inflated source and name strings where
  43013. * the generated positions are compared.
  43014. */
  43015. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  43016. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  43017. if (cmp !== 0) {
  43018. return cmp;
  43019. }
  43020. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  43021. if (cmp !== 0) {
  43022. return cmp;
  43023. }
  43024. cmp = strcmp(mappingA.source, mappingB.source);
  43025. if (cmp !== 0) {
  43026. return cmp;
  43027. }
  43028. cmp = mappingA.originalLine - mappingB.originalLine;
  43029. if (cmp !== 0) {
  43030. return cmp;
  43031. }
  43032. cmp = mappingA.originalColumn - mappingB.originalColumn;
  43033. if (cmp !== 0) {
  43034. return cmp;
  43035. }
  43036. return strcmp(mappingA.name, mappingB.name);
  43037. }
  43038. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  43039. /**
  43040. * Strip any JSON XSSI avoidance prefix from the string (as documented
  43041. * in the source maps specification), and then parse the string as
  43042. * JSON.
  43043. */
  43044. function parseSourceMapInput(str) {
  43045. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  43046. }
  43047. exports.parseSourceMapInput = parseSourceMapInput;
  43048. /**
  43049. * Compute the URL of a source given the the source root, the source's
  43050. * URL, and the source map's URL.
  43051. */
  43052. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  43053. sourceURL = sourceURL || '';
  43054. if (sourceRoot) {
  43055. // This follows what Chrome does.
  43056. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  43057. sourceRoot += '/';
  43058. }
  43059. // The spec says:
  43060. // Line 4: An optional source root, useful for relocating source
  43061. // files on a server or removing repeated values in the
  43062. // “sources” entry. This value is prepended to the individual
  43063. // entries in the “source” field.
  43064. sourceURL = sourceRoot + sourceURL;
  43065. }
  43066. // Historically, SourceMapConsumer did not take the sourceMapURL as
  43067. // a parameter. This mode is still somewhat supported, which is why
  43068. // this code block is conditional. However, it's preferable to pass
  43069. // the source map URL to SourceMapConsumer, so that this function
  43070. // can implement the source URL resolution algorithm as outlined in
  43071. // the spec. This block is basically the equivalent of:
  43072. // new URL(sourceURL, sourceMapURL).toString()
  43073. // ... except it avoids using URL, which wasn't available in the
  43074. // older releases of node still supported by this library.
  43075. //
  43076. // The spec says:
  43077. // If the sources are not absolute URLs after prepending of the
  43078. // “sourceRoot”, the sources are resolved relative to the
  43079. // SourceMap (like resolving script src in a html document).
  43080. if (sourceMapURL) {
  43081. var parsed = urlParse(sourceMapURL);
  43082. if (!parsed) {
  43083. throw new Error("sourceMapURL could not be parsed");
  43084. }
  43085. if (parsed.path) {
  43086. // Strip the last path component, but keep the "/".
  43087. var index = parsed.path.lastIndexOf('/');
  43088. if (index >= 0) {
  43089. parsed.path = parsed.path.substring(0, index + 1);
  43090. }
  43091. }
  43092. sourceURL = join(urlGenerate(parsed), sourceURL);
  43093. }
  43094. return normalize(sourceURL);
  43095. }
  43096. exports.computeSourceURL = computeSourceURL;
  43097. } (util));
  43098. return util;
  43099. }
  43100. var arraySet = {};
  43101. /* -*- Mode: js; js-indent-level: 2; -*- */
  43102. var hasRequiredArraySet;
  43103. function requireArraySet () {
  43104. if (hasRequiredArraySet) return arraySet;
  43105. hasRequiredArraySet = 1;
  43106. /*
  43107. * Copyright 2011 Mozilla Foundation and contributors
  43108. * Licensed under the New BSD license. See LICENSE or:
  43109. * http://opensource.org/licenses/BSD-3-Clause
  43110. */
  43111. var util = /*@__PURE__*/ requireUtil();
  43112. var has = Object.prototype.hasOwnProperty;
  43113. var hasNativeMap = typeof Map !== "undefined";
  43114. /**
  43115. * A data structure which is a combination of an array and a set. Adding a new
  43116. * member is O(1), testing for membership is O(1), and finding the index of an
  43117. * element is O(1). Removing elements from the set is not supported. Only
  43118. * strings are supported for membership.
  43119. */
  43120. function ArraySet() {
  43121. this._array = [];
  43122. this._set = hasNativeMap ? new Map() : Object.create(null);
  43123. }
  43124. /**
  43125. * Static method for creating ArraySet instances from an existing array.
  43126. */
  43127. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  43128. var set = new ArraySet();
  43129. for (var i = 0, len = aArray.length; i < len; i++) {
  43130. set.add(aArray[i], aAllowDuplicates);
  43131. }
  43132. return set;
  43133. };
  43134. /**
  43135. * Return how many unique items are in this ArraySet. If duplicates have been
  43136. * added, than those do not count towards the size.
  43137. *
  43138. * @returns Number
  43139. */
  43140. ArraySet.prototype.size = function ArraySet_size() {
  43141. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  43142. };
  43143. /**
  43144. * Add the given string to this set.
  43145. *
  43146. * @param String aStr
  43147. */
  43148. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  43149. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  43150. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  43151. var idx = this._array.length;
  43152. if (!isDuplicate || aAllowDuplicates) {
  43153. this._array.push(aStr);
  43154. }
  43155. if (!isDuplicate) {
  43156. if (hasNativeMap) {
  43157. this._set.set(aStr, idx);
  43158. } else {
  43159. this._set[sStr] = idx;
  43160. }
  43161. }
  43162. };
  43163. /**
  43164. * Is the given string a member of this set?
  43165. *
  43166. * @param String aStr
  43167. */
  43168. ArraySet.prototype.has = function ArraySet_has(aStr) {
  43169. if (hasNativeMap) {
  43170. return this._set.has(aStr);
  43171. } else {
  43172. var sStr = util.toSetString(aStr);
  43173. return has.call(this._set, sStr);
  43174. }
  43175. };
  43176. /**
  43177. * What is the index of the given string in the array?
  43178. *
  43179. * @param String aStr
  43180. */
  43181. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  43182. if (hasNativeMap) {
  43183. var idx = this._set.get(aStr);
  43184. if (idx >= 0) {
  43185. return idx;
  43186. }
  43187. } else {
  43188. var sStr = util.toSetString(aStr);
  43189. if (has.call(this._set, sStr)) {
  43190. return this._set[sStr];
  43191. }
  43192. }
  43193. throw new Error('"' + aStr + '" is not in the set.');
  43194. };
  43195. /**
  43196. * What is the element at the given index?
  43197. *
  43198. * @param Number aIdx
  43199. */
  43200. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  43201. if (aIdx >= 0 && aIdx < this._array.length) {
  43202. return this._array[aIdx];
  43203. }
  43204. throw new Error('No element indexed by ' + aIdx);
  43205. };
  43206. /**
  43207. * Returns the array representation of this set (which has the proper indices
  43208. * indicated by indexOf). Note that this is a copy of the internal array used
  43209. * for storing the members so that no one can mess with internal state.
  43210. */
  43211. ArraySet.prototype.toArray = function ArraySet_toArray() {
  43212. return this._array.slice();
  43213. };
  43214. arraySet.ArraySet = ArraySet;
  43215. return arraySet;
  43216. }
  43217. var mappingList = {};
  43218. /* -*- Mode: js; js-indent-level: 2; -*- */
  43219. var hasRequiredMappingList;
  43220. function requireMappingList () {
  43221. if (hasRequiredMappingList) return mappingList;
  43222. hasRequiredMappingList = 1;
  43223. /*
  43224. * Copyright 2014 Mozilla Foundation and contributors
  43225. * Licensed under the New BSD license. See LICENSE or:
  43226. * http://opensource.org/licenses/BSD-3-Clause
  43227. */
  43228. var util = /*@__PURE__*/ requireUtil();
  43229. /**
  43230. * Determine whether mappingB is after mappingA with respect to generated
  43231. * position.
  43232. */
  43233. function generatedPositionAfter(mappingA, mappingB) {
  43234. // Optimized for most common case
  43235. var lineA = mappingA.generatedLine;
  43236. var lineB = mappingB.generatedLine;
  43237. var columnA = mappingA.generatedColumn;
  43238. var columnB = mappingB.generatedColumn;
  43239. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  43240. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  43241. }
  43242. /**
  43243. * A data structure to provide a sorted view of accumulated mappings in a
  43244. * performance conscious manner. It trades a neglibable overhead in general
  43245. * case for a large speedup in case of mappings being added in order.
  43246. */
  43247. function MappingList() {
  43248. this._array = [];
  43249. this._sorted = true;
  43250. // Serves as infimum
  43251. this._last = {generatedLine: -1, generatedColumn: 0};
  43252. }
  43253. /**
  43254. * Iterate through internal items. This method takes the same arguments that
  43255. * `Array.prototype.forEach` takes.
  43256. *
  43257. * NOTE: The order of the mappings is NOT guaranteed.
  43258. */
  43259. MappingList.prototype.unsortedForEach =
  43260. function MappingList_forEach(aCallback, aThisArg) {
  43261. this._array.forEach(aCallback, aThisArg);
  43262. };
  43263. /**
  43264. * Add the given source mapping.
  43265. *
  43266. * @param Object aMapping
  43267. */
  43268. MappingList.prototype.add = function MappingList_add(aMapping) {
  43269. if (generatedPositionAfter(this._last, aMapping)) {
  43270. this._last = aMapping;
  43271. this._array.push(aMapping);
  43272. } else {
  43273. this._sorted = false;
  43274. this._array.push(aMapping);
  43275. }
  43276. };
  43277. /**
  43278. * Returns the flat, sorted array of mappings. The mappings are sorted by
  43279. * generated position.
  43280. *
  43281. * WARNING: This method returns internal data without copying, for
  43282. * performance. The return value must NOT be mutated, and should be treated as
  43283. * an immutable borrow. If you want to take ownership, you must make your own
  43284. * copy.
  43285. */
  43286. MappingList.prototype.toArray = function MappingList_toArray() {
  43287. if (!this._sorted) {
  43288. this._array.sort(util.compareByGeneratedPositionsInflated);
  43289. this._sorted = true;
  43290. }
  43291. return this._array;
  43292. };
  43293. mappingList.MappingList = MappingList;
  43294. return mappingList;
  43295. }
  43296. /* -*- Mode: js; js-indent-level: 2; -*- */
  43297. var hasRequiredSourceMapGenerator;
  43298. function requireSourceMapGenerator () {
  43299. if (hasRequiredSourceMapGenerator) return sourceMapGenerator;
  43300. hasRequiredSourceMapGenerator = 1;
  43301. /*
  43302. * Copyright 2011 Mozilla Foundation and contributors
  43303. * Licensed under the New BSD license. See LICENSE or:
  43304. * http://opensource.org/licenses/BSD-3-Clause
  43305. */
  43306. var base64VLQ = /*@__PURE__*/ requireBase64Vlq();
  43307. var util = /*@__PURE__*/ requireUtil();
  43308. var ArraySet = /*@__PURE__*/ requireArraySet().ArraySet;
  43309. var MappingList = /*@__PURE__*/ requireMappingList().MappingList;
  43310. /**
  43311. * An instance of the SourceMapGenerator represents a source map which is
  43312. * being built incrementally. You may pass an object with the following
  43313. * properties:
  43314. *
  43315. * - file: The filename of the generated source.
  43316. * - sourceRoot: A root for all relative URLs in this source map.
  43317. */
  43318. function SourceMapGenerator(aArgs) {
  43319. if (!aArgs) {
  43320. aArgs = {};
  43321. }
  43322. this._file = util.getArg(aArgs, 'file', null);
  43323. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  43324. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  43325. this._sources = new ArraySet();
  43326. this._names = new ArraySet();
  43327. this._mappings = new MappingList();
  43328. this._sourcesContents = null;
  43329. }
  43330. SourceMapGenerator.prototype._version = 3;
  43331. /**
  43332. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  43333. *
  43334. * @param aSourceMapConsumer The SourceMap.
  43335. */
  43336. SourceMapGenerator.fromSourceMap =
  43337. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  43338. var sourceRoot = aSourceMapConsumer.sourceRoot;
  43339. var generator = new SourceMapGenerator({
  43340. file: aSourceMapConsumer.file,
  43341. sourceRoot: sourceRoot
  43342. });
  43343. aSourceMapConsumer.eachMapping(function (mapping) {
  43344. var newMapping = {
  43345. generated: {
  43346. line: mapping.generatedLine,
  43347. column: mapping.generatedColumn
  43348. }
  43349. };
  43350. if (mapping.source != null) {
  43351. newMapping.source = mapping.source;
  43352. if (sourceRoot != null) {
  43353. newMapping.source = util.relative(sourceRoot, newMapping.source);
  43354. }
  43355. newMapping.original = {
  43356. line: mapping.originalLine,
  43357. column: mapping.originalColumn
  43358. };
  43359. if (mapping.name != null) {
  43360. newMapping.name = mapping.name;
  43361. }
  43362. }
  43363. generator.addMapping(newMapping);
  43364. });
  43365. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  43366. var sourceRelative = sourceFile;
  43367. if (sourceRoot !== null) {
  43368. sourceRelative = util.relative(sourceRoot, sourceFile);
  43369. }
  43370. if (!generator._sources.has(sourceRelative)) {
  43371. generator._sources.add(sourceRelative);
  43372. }
  43373. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  43374. if (content != null) {
  43375. generator.setSourceContent(sourceFile, content);
  43376. }
  43377. });
  43378. return generator;
  43379. };
  43380. /**
  43381. * Add a single mapping from original source line and column to the generated
  43382. * source's line and column for this source map being created. The mapping
  43383. * object should have the following properties:
  43384. *
  43385. * - generated: An object with the generated line and column positions.
  43386. * - original: An object with the original line and column positions.
  43387. * - source: The original source file (relative to the sourceRoot).
  43388. * - name: An optional original token name for this mapping.
  43389. */
  43390. SourceMapGenerator.prototype.addMapping =
  43391. function SourceMapGenerator_addMapping(aArgs) {
  43392. var generated = util.getArg(aArgs, 'generated');
  43393. var original = util.getArg(aArgs, 'original', null);
  43394. var source = util.getArg(aArgs, 'source', null);
  43395. var name = util.getArg(aArgs, 'name', null);
  43396. if (!this._skipValidation) {
  43397. this._validateMapping(generated, original, source, name);
  43398. }
  43399. if (source != null) {
  43400. source = String(source);
  43401. if (!this._sources.has(source)) {
  43402. this._sources.add(source);
  43403. }
  43404. }
  43405. if (name != null) {
  43406. name = String(name);
  43407. if (!this._names.has(name)) {
  43408. this._names.add(name);
  43409. }
  43410. }
  43411. this._mappings.add({
  43412. generatedLine: generated.line,
  43413. generatedColumn: generated.column,
  43414. originalLine: original != null && original.line,
  43415. originalColumn: original != null && original.column,
  43416. source: source,
  43417. name: name
  43418. });
  43419. };
  43420. /**
  43421. * Set the source content for a source file.
  43422. */
  43423. SourceMapGenerator.prototype.setSourceContent =
  43424. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  43425. var source = aSourceFile;
  43426. if (this._sourceRoot != null) {
  43427. source = util.relative(this._sourceRoot, source);
  43428. }
  43429. if (aSourceContent != null) {
  43430. // Add the source content to the _sourcesContents map.
  43431. // Create a new _sourcesContents map if the property is null.
  43432. if (!this._sourcesContents) {
  43433. this._sourcesContents = Object.create(null);
  43434. }
  43435. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  43436. } else if (this._sourcesContents) {
  43437. // Remove the source file from the _sourcesContents map.
  43438. // If the _sourcesContents map is empty, set the property to null.
  43439. delete this._sourcesContents[util.toSetString(source)];
  43440. if (Object.keys(this._sourcesContents).length === 0) {
  43441. this._sourcesContents = null;
  43442. }
  43443. }
  43444. };
  43445. /**
  43446. * Applies the mappings of a sub-source-map for a specific source file to the
  43447. * source map being generated. Each mapping to the supplied source file is
  43448. * rewritten using the supplied source map. Note: The resolution for the
  43449. * resulting mappings is the minimium of this map and the supplied map.
  43450. *
  43451. * @param aSourceMapConsumer The source map to be applied.
  43452. * @param aSourceFile Optional. The filename of the source file.
  43453. * If omitted, SourceMapConsumer's file property will be used.
  43454. * @param aSourceMapPath Optional. The dirname of the path to the source map
  43455. * to be applied. If relative, it is relative to the SourceMapConsumer.
  43456. * This parameter is needed when the two source maps aren't in the same
  43457. * directory, and the source map to be applied contains relative source
  43458. * paths. If so, those relative source paths need to be rewritten
  43459. * relative to the SourceMapGenerator.
  43460. */
  43461. SourceMapGenerator.prototype.applySourceMap =
  43462. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  43463. var sourceFile = aSourceFile;
  43464. // If aSourceFile is omitted, we will use the file property of the SourceMap
  43465. if (aSourceFile == null) {
  43466. if (aSourceMapConsumer.file == null) {
  43467. throw new Error(
  43468. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  43469. 'or the source map\'s "file" property. Both were omitted.'
  43470. );
  43471. }
  43472. sourceFile = aSourceMapConsumer.file;
  43473. }
  43474. var sourceRoot = this._sourceRoot;
  43475. // Make "sourceFile" relative if an absolute Url is passed.
  43476. if (sourceRoot != null) {
  43477. sourceFile = util.relative(sourceRoot, sourceFile);
  43478. }
  43479. // Applying the SourceMap can add and remove items from the sources and
  43480. // the names array.
  43481. var newSources = new ArraySet();
  43482. var newNames = new ArraySet();
  43483. // Find mappings for the "sourceFile"
  43484. this._mappings.unsortedForEach(function (mapping) {
  43485. if (mapping.source === sourceFile && mapping.originalLine != null) {
  43486. // Check if it can be mapped by the source map, then update the mapping.
  43487. var original = aSourceMapConsumer.originalPositionFor({
  43488. line: mapping.originalLine,
  43489. column: mapping.originalColumn
  43490. });
  43491. if (original.source != null) {
  43492. // Copy mapping
  43493. mapping.source = original.source;
  43494. if (aSourceMapPath != null) {
  43495. mapping.source = util.join(aSourceMapPath, mapping.source);
  43496. }
  43497. if (sourceRoot != null) {
  43498. mapping.source = util.relative(sourceRoot, mapping.source);
  43499. }
  43500. mapping.originalLine = original.line;
  43501. mapping.originalColumn = original.column;
  43502. if (original.name != null) {
  43503. mapping.name = original.name;
  43504. }
  43505. }
  43506. }
  43507. var source = mapping.source;
  43508. if (source != null && !newSources.has(source)) {
  43509. newSources.add(source);
  43510. }
  43511. var name = mapping.name;
  43512. if (name != null && !newNames.has(name)) {
  43513. newNames.add(name);
  43514. }
  43515. }, this);
  43516. this._sources = newSources;
  43517. this._names = newNames;
  43518. // Copy sourcesContents of applied map.
  43519. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  43520. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  43521. if (content != null) {
  43522. if (aSourceMapPath != null) {
  43523. sourceFile = util.join(aSourceMapPath, sourceFile);
  43524. }
  43525. if (sourceRoot != null) {
  43526. sourceFile = util.relative(sourceRoot, sourceFile);
  43527. }
  43528. this.setSourceContent(sourceFile, content);
  43529. }
  43530. }, this);
  43531. };
  43532. /**
  43533. * A mapping can have one of the three levels of data:
  43534. *
  43535. * 1. Just the generated position.
  43536. * 2. The Generated position, original position, and original source.
  43537. * 3. Generated and original position, original source, as well as a name
  43538. * token.
  43539. *
  43540. * To maintain consistency, we validate that any new mapping being added falls
  43541. * in to one of these categories.
  43542. */
  43543. SourceMapGenerator.prototype._validateMapping =
  43544. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  43545. aName) {
  43546. // When aOriginal is truthy but has empty values for .line and .column,
  43547. // it is most likely a programmer error. In this case we throw a very
  43548. // specific error message to try to guide them the right way.
  43549. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  43550. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  43551. throw new Error(
  43552. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  43553. 'the original mapping entirely and only map the generated position. If so, pass ' +
  43554. 'null for the original mapping instead of an object with empty or null values.'
  43555. );
  43556. }
  43557. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  43558. && aGenerated.line > 0 && aGenerated.column >= 0
  43559. && !aOriginal && !aSource && !aName) {
  43560. // Case 1.
  43561. return;
  43562. }
  43563. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  43564. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  43565. && aGenerated.line > 0 && aGenerated.column >= 0
  43566. && aOriginal.line > 0 && aOriginal.column >= 0
  43567. && aSource) {
  43568. // Cases 2 and 3.
  43569. return;
  43570. }
  43571. else {
  43572. throw new Error('Invalid mapping: ' + JSON.stringify({
  43573. generated: aGenerated,
  43574. source: aSource,
  43575. original: aOriginal,
  43576. name: aName
  43577. }));
  43578. }
  43579. };
  43580. /**
  43581. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  43582. * specified by the source map format.
  43583. */
  43584. SourceMapGenerator.prototype._serializeMappings =
  43585. function SourceMapGenerator_serializeMappings() {
  43586. var previousGeneratedColumn = 0;
  43587. var previousGeneratedLine = 1;
  43588. var previousOriginalColumn = 0;
  43589. var previousOriginalLine = 0;
  43590. var previousName = 0;
  43591. var previousSource = 0;
  43592. var result = '';
  43593. var next;
  43594. var mapping;
  43595. var nameIdx;
  43596. var sourceIdx;
  43597. var mappings = this._mappings.toArray();
  43598. for (var i = 0, len = mappings.length; i < len; i++) {
  43599. mapping = mappings[i];
  43600. next = '';
  43601. if (mapping.generatedLine !== previousGeneratedLine) {
  43602. previousGeneratedColumn = 0;
  43603. while (mapping.generatedLine !== previousGeneratedLine) {
  43604. next += ';';
  43605. previousGeneratedLine++;
  43606. }
  43607. }
  43608. else {
  43609. if (i > 0) {
  43610. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  43611. continue;
  43612. }
  43613. next += ',';
  43614. }
  43615. }
  43616. next += base64VLQ.encode(mapping.generatedColumn
  43617. - previousGeneratedColumn);
  43618. previousGeneratedColumn = mapping.generatedColumn;
  43619. if (mapping.source != null) {
  43620. sourceIdx = this._sources.indexOf(mapping.source);
  43621. next += base64VLQ.encode(sourceIdx - previousSource);
  43622. previousSource = sourceIdx;
  43623. // lines are stored 0-based in SourceMap spec version 3
  43624. next += base64VLQ.encode(mapping.originalLine - 1
  43625. - previousOriginalLine);
  43626. previousOriginalLine = mapping.originalLine - 1;
  43627. next += base64VLQ.encode(mapping.originalColumn
  43628. - previousOriginalColumn);
  43629. previousOriginalColumn = mapping.originalColumn;
  43630. if (mapping.name != null) {
  43631. nameIdx = this._names.indexOf(mapping.name);
  43632. next += base64VLQ.encode(nameIdx - previousName);
  43633. previousName = nameIdx;
  43634. }
  43635. }
  43636. result += next;
  43637. }
  43638. return result;
  43639. };
  43640. SourceMapGenerator.prototype._generateSourcesContent =
  43641. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  43642. return aSources.map(function (source) {
  43643. if (!this._sourcesContents) {
  43644. return null;
  43645. }
  43646. if (aSourceRoot != null) {
  43647. source = util.relative(aSourceRoot, source);
  43648. }
  43649. var key = util.toSetString(source);
  43650. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  43651. ? this._sourcesContents[key]
  43652. : null;
  43653. }, this);
  43654. };
  43655. /**
  43656. * Externalize the source map.
  43657. */
  43658. SourceMapGenerator.prototype.toJSON =
  43659. function SourceMapGenerator_toJSON() {
  43660. var map = {
  43661. version: this._version,
  43662. sources: this._sources.toArray(),
  43663. names: this._names.toArray(),
  43664. mappings: this._serializeMappings()
  43665. };
  43666. if (this._file != null) {
  43667. map.file = this._file;
  43668. }
  43669. if (this._sourceRoot != null) {
  43670. map.sourceRoot = this._sourceRoot;
  43671. }
  43672. if (this._sourcesContents) {
  43673. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  43674. }
  43675. return map;
  43676. };
  43677. /**
  43678. * Render the source map being generated to a string.
  43679. */
  43680. SourceMapGenerator.prototype.toString =
  43681. function SourceMapGenerator_toString() {
  43682. return JSON.stringify(this.toJSON());
  43683. };
  43684. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator;
  43685. return sourceMapGenerator;
  43686. }
  43687. var sourceMapConsumer = {};
  43688. var binarySearch = {};
  43689. /* -*- Mode: js; js-indent-level: 2; -*- */
  43690. var hasRequiredBinarySearch;
  43691. function requireBinarySearch () {
  43692. if (hasRequiredBinarySearch) return binarySearch;
  43693. hasRequiredBinarySearch = 1;
  43694. (function (exports) {
  43695. /*
  43696. * Copyright 2011 Mozilla Foundation and contributors
  43697. * Licensed under the New BSD license. See LICENSE or:
  43698. * http://opensource.org/licenses/BSD-3-Clause
  43699. */
  43700. exports.GREATEST_LOWER_BOUND = 1;
  43701. exports.LEAST_UPPER_BOUND = 2;
  43702. /**
  43703. * Recursive implementation of binary search.
  43704. *
  43705. * @param aLow Indices here and lower do not contain the needle.
  43706. * @param aHigh Indices here and higher do not contain the needle.
  43707. * @param aNeedle The element being searched for.
  43708. * @param aHaystack The non-empty array being searched.
  43709. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  43710. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  43711. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  43712. * closest element that is smaller than or greater than the one we are
  43713. * searching for, respectively, if the exact element cannot be found.
  43714. */
  43715. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  43716. // This function terminates when one of the following is true:
  43717. //
  43718. // 1. We find the exact element we are looking for.
  43719. //
  43720. // 2. We did not find the exact element, but we can return the index of
  43721. // the next-closest element.
  43722. //
  43723. // 3. We did not find the exact element, and there is no next-closest
  43724. // element than the one we are searching for, so we return -1.
  43725. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  43726. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  43727. if (cmp === 0) {
  43728. // Found the element we are looking for.
  43729. return mid;
  43730. }
  43731. else if (cmp > 0) {
  43732. // Our needle is greater than aHaystack[mid].
  43733. if (aHigh - mid > 1) {
  43734. // The element is in the upper half.
  43735. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  43736. }
  43737. // The exact needle element was not found in this haystack. Determine if
  43738. // we are in termination case (3) or (2) and return the appropriate thing.
  43739. if (aBias == exports.LEAST_UPPER_BOUND) {
  43740. return aHigh < aHaystack.length ? aHigh : -1;
  43741. } else {
  43742. return mid;
  43743. }
  43744. }
  43745. else {
  43746. // Our needle is less than aHaystack[mid].
  43747. if (mid - aLow > 1) {
  43748. // The element is in the lower half.
  43749. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  43750. }
  43751. // we are in termination case (3) or (2) and return the appropriate thing.
  43752. if (aBias == exports.LEAST_UPPER_BOUND) {
  43753. return mid;
  43754. } else {
  43755. return aLow < 0 ? -1 : aLow;
  43756. }
  43757. }
  43758. }
  43759. /**
  43760. * This is an implementation of binary search which will always try and return
  43761. * the index of the closest element if there is no exact hit. This is because
  43762. * mappings between original and generated line/col pairs are single points,
  43763. * and there is an implicit region between each of them, so a miss just means
  43764. * that you aren't on the very start of a region.
  43765. *
  43766. * @param aNeedle The element you are looking for.
  43767. * @param aHaystack The array that is being searched.
  43768. * @param aCompare A function which takes the needle and an element in the
  43769. * array and returns -1, 0, or 1 depending on whether the needle is less
  43770. * than, equal to, or greater than the element, respectively.
  43771. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  43772. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  43773. * closest element that is smaller than or greater than the one we are
  43774. * searching for, respectively, if the exact element cannot be found.
  43775. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  43776. */
  43777. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  43778. if (aHaystack.length === 0) {
  43779. return -1;
  43780. }
  43781. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  43782. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  43783. if (index < 0) {
  43784. return -1;
  43785. }
  43786. // We have found either the exact element, or the next-closest element than
  43787. // the one we are searching for. However, there may be more than one such
  43788. // element. Make sure we always return the smallest of these.
  43789. while (index - 1 >= 0) {
  43790. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  43791. break;
  43792. }
  43793. --index;
  43794. }
  43795. return index;
  43796. };
  43797. } (binarySearch));
  43798. return binarySearch;
  43799. }
  43800. var quickSort = {};
  43801. /* -*- Mode: js; js-indent-level: 2; -*- */
  43802. var hasRequiredQuickSort;
  43803. function requireQuickSort () {
  43804. if (hasRequiredQuickSort) return quickSort;
  43805. hasRequiredQuickSort = 1;
  43806. /*
  43807. * Copyright 2011 Mozilla Foundation and contributors
  43808. * Licensed under the New BSD license. See LICENSE or:
  43809. * http://opensource.org/licenses/BSD-3-Clause
  43810. */
  43811. // It turns out that some (most?) JavaScript engines don't self-host
  43812. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  43813. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  43814. // custom comparator function, calling back and forth between the VM's C++ and
  43815. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  43816. // worse generated code for the comparator function than would be optimal. In
  43817. // fact, when sorting with a comparator, these costs outweigh the benefits of
  43818. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  43819. // a ~3500ms mean speed-up in `bench/bench.html`.
  43820. /**
  43821. * Swap the elements indexed by `x` and `y` in the array `ary`.
  43822. *
  43823. * @param {Array} ary
  43824. * The array.
  43825. * @param {Number} x
  43826. * The index of the first item.
  43827. * @param {Number} y
  43828. * The index of the second item.
  43829. */
  43830. function swap(ary, x, y) {
  43831. var temp = ary[x];
  43832. ary[x] = ary[y];
  43833. ary[y] = temp;
  43834. }
  43835. /**
  43836. * Returns a random integer within the range `low .. high` inclusive.
  43837. *
  43838. * @param {Number} low
  43839. * The lower bound on the range.
  43840. * @param {Number} high
  43841. * The upper bound on the range.
  43842. */
  43843. function randomIntInRange(low, high) {
  43844. return Math.round(low + (Math.random() * (high - low)));
  43845. }
  43846. /**
  43847. * The Quick Sort algorithm.
  43848. *
  43849. * @param {Array} ary
  43850. * An array to sort.
  43851. * @param {function} comparator
  43852. * Function to use to compare two items.
  43853. * @param {Number} p
  43854. * Start index of the array
  43855. * @param {Number} r
  43856. * End index of the array
  43857. */
  43858. function doQuickSort(ary, comparator, p, r) {
  43859. // If our lower bound is less than our upper bound, we (1) partition the
  43860. // array into two pieces and (2) recurse on each half. If it is not, this is
  43861. // the empty array and our base case.
  43862. if (p < r) {
  43863. // (1) Partitioning.
  43864. //
  43865. // The partitioning chooses a pivot between `p` and `r` and moves all
  43866. // elements that are less than or equal to the pivot to the before it, and
  43867. // all the elements that are greater than it after it. The effect is that
  43868. // once partition is done, the pivot is in the exact place it will be when
  43869. // the array is put in sorted order, and it will not need to be moved
  43870. // again. This runs in O(n) time.
  43871. // Always choose a random pivot so that an input array which is reverse
  43872. // sorted does not cause O(n^2) running time.
  43873. var pivotIndex = randomIntInRange(p, r);
  43874. var i = p - 1;
  43875. swap(ary, pivotIndex, r);
  43876. var pivot = ary[r];
  43877. // Immediately after `j` is incremented in this loop, the following hold
  43878. // true:
  43879. //
  43880. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  43881. //
  43882. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  43883. for (var j = p; j < r; j++) {
  43884. if (comparator(ary[j], pivot) <= 0) {
  43885. i += 1;
  43886. swap(ary, i, j);
  43887. }
  43888. }
  43889. swap(ary, i + 1, j);
  43890. var q = i + 1;
  43891. // (2) Recurse on each half.
  43892. doQuickSort(ary, comparator, p, q - 1);
  43893. doQuickSort(ary, comparator, q + 1, r);
  43894. }
  43895. }
  43896. /**
  43897. * Sort the given array in-place with the given comparator function.
  43898. *
  43899. * @param {Array} ary
  43900. * An array to sort.
  43901. * @param {function} comparator
  43902. * Function to use to compare two items.
  43903. */
  43904. quickSort.quickSort = function (ary, comparator) {
  43905. doQuickSort(ary, comparator, 0, ary.length - 1);
  43906. };
  43907. return quickSort;
  43908. }
  43909. /* -*- Mode: js; js-indent-level: 2; -*- */
  43910. var hasRequiredSourceMapConsumer;
  43911. function requireSourceMapConsumer () {
  43912. if (hasRequiredSourceMapConsumer) return sourceMapConsumer;
  43913. hasRequiredSourceMapConsumer = 1;
  43914. /*
  43915. * Copyright 2011 Mozilla Foundation and contributors
  43916. * Licensed under the New BSD license. See LICENSE or:
  43917. * http://opensource.org/licenses/BSD-3-Clause
  43918. */
  43919. var util = /*@__PURE__*/ requireUtil();
  43920. var binarySearch = /*@__PURE__*/ requireBinarySearch();
  43921. var ArraySet = /*@__PURE__*/ requireArraySet().ArraySet;
  43922. var base64VLQ = /*@__PURE__*/ requireBase64Vlq();
  43923. var quickSort = /*@__PURE__*/ requireQuickSort().quickSort;
  43924. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  43925. var sourceMap = aSourceMap;
  43926. if (typeof aSourceMap === 'string') {
  43927. sourceMap = util.parseSourceMapInput(aSourceMap);
  43928. }
  43929. return sourceMap.sections != null
  43930. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  43931. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  43932. }
  43933. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  43934. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  43935. };
  43936. /**
  43937. * The version of the source mapping spec that we are consuming.
  43938. */
  43939. SourceMapConsumer.prototype._version = 3;
  43940. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  43941. // parsed mapping coordinates from the source map's "mappings" attribute. They
  43942. // are lazily instantiated, accessed via the `_generatedMappings` and
  43943. // `_originalMappings` getters respectively, and we only parse the mappings
  43944. // and create these arrays once queried for a source location. We jump through
  43945. // these hoops because there can be many thousands of mappings, and parsing
  43946. // them is expensive, so we only want to do it if we must.
  43947. //
  43948. // Each object in the arrays is of the form:
  43949. //
  43950. // {
  43951. // generatedLine: The line number in the generated code,
  43952. // generatedColumn: The column number in the generated code,
  43953. // source: The path to the original source file that generated this
  43954. // chunk of code,
  43955. // originalLine: The line number in the original source that
  43956. // corresponds to this chunk of generated code,
  43957. // originalColumn: The column number in the original source that
  43958. // corresponds to this chunk of generated code,
  43959. // name: The name of the original symbol which generated this chunk of
  43960. // code.
  43961. // }
  43962. //
  43963. // All properties except for `generatedLine` and `generatedColumn` can be
  43964. // `null`.
  43965. //
  43966. // `_generatedMappings` is ordered by the generated positions.
  43967. //
  43968. // `_originalMappings` is ordered by the original positions.
  43969. SourceMapConsumer.prototype.__generatedMappings = null;
  43970. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  43971. configurable: true,
  43972. enumerable: true,
  43973. get: function () {
  43974. if (!this.__generatedMappings) {
  43975. this._parseMappings(this._mappings, this.sourceRoot);
  43976. }
  43977. return this.__generatedMappings;
  43978. }
  43979. });
  43980. SourceMapConsumer.prototype.__originalMappings = null;
  43981. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  43982. configurable: true,
  43983. enumerable: true,
  43984. get: function () {
  43985. if (!this.__originalMappings) {
  43986. this._parseMappings(this._mappings, this.sourceRoot);
  43987. }
  43988. return this.__originalMappings;
  43989. }
  43990. });
  43991. SourceMapConsumer.prototype._charIsMappingSeparator =
  43992. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  43993. var c = aStr.charAt(index);
  43994. return c === ";" || c === ",";
  43995. };
  43996. /**
  43997. * Parse the mappings in a string in to a data structure which we can easily
  43998. * query (the ordered arrays in the `this.__generatedMappings` and
  43999. * `this.__originalMappings` properties).
  44000. */
  44001. SourceMapConsumer.prototype._parseMappings =
  44002. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  44003. throw new Error("Subclasses must implement _parseMappings");
  44004. };
  44005. SourceMapConsumer.GENERATED_ORDER = 1;
  44006. SourceMapConsumer.ORIGINAL_ORDER = 2;
  44007. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  44008. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  44009. /**
  44010. * Iterate over each mapping between an original source/line/column and a
  44011. * generated line/column in this source map.
  44012. *
  44013. * @param Function aCallback
  44014. * The function that is called with each mapping.
  44015. * @param Object aContext
  44016. * Optional. If specified, this object will be the value of `this` every
  44017. * time that `aCallback` is called.
  44018. * @param aOrder
  44019. * Either `SourceMapConsumer.GENERATED_ORDER` or
  44020. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  44021. * iterate over the mappings sorted by the generated file's line/column
  44022. * order or the original's source/line/column order, respectively. Defaults to
  44023. * `SourceMapConsumer.GENERATED_ORDER`.
  44024. */
  44025. SourceMapConsumer.prototype.eachMapping =
  44026. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  44027. var context = aContext || null;
  44028. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  44029. var mappings;
  44030. switch (order) {
  44031. case SourceMapConsumer.GENERATED_ORDER:
  44032. mappings = this._generatedMappings;
  44033. break;
  44034. case SourceMapConsumer.ORIGINAL_ORDER:
  44035. mappings = this._originalMappings;
  44036. break;
  44037. default:
  44038. throw new Error("Unknown order of iteration.");
  44039. }
  44040. var sourceRoot = this.sourceRoot;
  44041. mappings.map(function (mapping) {
  44042. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  44043. source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  44044. return {
  44045. source: source,
  44046. generatedLine: mapping.generatedLine,
  44047. generatedColumn: mapping.generatedColumn,
  44048. originalLine: mapping.originalLine,
  44049. originalColumn: mapping.originalColumn,
  44050. name: mapping.name === null ? null : this._names.at(mapping.name)
  44051. };
  44052. }, this).forEach(aCallback, context);
  44053. };
  44054. /**
  44055. * Returns all generated line and column information for the original source,
  44056. * line, and column provided. If no column is provided, returns all mappings
  44057. * corresponding to a either the line we are searching for or the next
  44058. * closest line that has any mappings. Otherwise, returns all mappings
  44059. * corresponding to the given line and either the column we are searching for
  44060. * or the next closest column that has any offsets.
  44061. *
  44062. * The only argument is an object with the following properties:
  44063. *
  44064. * - source: The filename of the original source.
  44065. * - line: The line number in the original source. The line number is 1-based.
  44066. * - column: Optional. the column number in the original source.
  44067. * The column number is 0-based.
  44068. *
  44069. * and an array of objects is returned, each with the following properties:
  44070. *
  44071. * - line: The line number in the generated source, or null. The
  44072. * line number is 1-based.
  44073. * - column: The column number in the generated source, or null.
  44074. * The column number is 0-based.
  44075. */
  44076. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  44077. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  44078. var line = util.getArg(aArgs, 'line');
  44079. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  44080. // returns the index of the closest mapping less than the needle. By
  44081. // setting needle.originalColumn to 0, we thus find the last mapping for
  44082. // the given line, provided such a mapping exists.
  44083. var needle = {
  44084. source: util.getArg(aArgs, 'source'),
  44085. originalLine: line,
  44086. originalColumn: util.getArg(aArgs, 'column', 0)
  44087. };
  44088. needle.source = this._findSourceIndex(needle.source);
  44089. if (needle.source < 0) {
  44090. return [];
  44091. }
  44092. var mappings = [];
  44093. var index = this._findMapping(needle,
  44094. this._originalMappings,
  44095. "originalLine",
  44096. "originalColumn",
  44097. util.compareByOriginalPositions,
  44098. binarySearch.LEAST_UPPER_BOUND);
  44099. if (index >= 0) {
  44100. var mapping = this._originalMappings[index];
  44101. if (aArgs.column === undefined) {
  44102. var originalLine = mapping.originalLine;
  44103. // Iterate until either we run out of mappings, or we run into
  44104. // a mapping for a different line than the one we found. Since
  44105. // mappings are sorted, this is guaranteed to find all mappings for
  44106. // the line we found.
  44107. while (mapping && mapping.originalLine === originalLine) {
  44108. mappings.push({
  44109. line: util.getArg(mapping, 'generatedLine', null),
  44110. column: util.getArg(mapping, 'generatedColumn', null),
  44111. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  44112. });
  44113. mapping = this._originalMappings[++index];
  44114. }
  44115. } else {
  44116. var originalColumn = mapping.originalColumn;
  44117. // Iterate until either we run out of mappings, or we run into
  44118. // a mapping for a different line than the one we were searching for.
  44119. // Since mappings are sorted, this is guaranteed to find all mappings for
  44120. // the line we are searching for.
  44121. while (mapping &&
  44122. mapping.originalLine === line &&
  44123. mapping.originalColumn == originalColumn) {
  44124. mappings.push({
  44125. line: util.getArg(mapping, 'generatedLine', null),
  44126. column: util.getArg(mapping, 'generatedColumn', null),
  44127. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  44128. });
  44129. mapping = this._originalMappings[++index];
  44130. }
  44131. }
  44132. }
  44133. return mappings;
  44134. };
  44135. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer;
  44136. /**
  44137. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  44138. * query for information about the original file positions by giving it a file
  44139. * position in the generated source.
  44140. *
  44141. * The first parameter is the raw source map (either as a JSON string, or
  44142. * already parsed to an object). According to the spec, source maps have the
  44143. * following attributes:
  44144. *
  44145. * - version: Which version of the source map spec this map is following.
  44146. * - sources: An array of URLs to the original source files.
  44147. * - names: An array of identifiers which can be referrenced by individual mappings.
  44148. * - sourceRoot: Optional. The URL root from which all sources are relative.
  44149. * - sourcesContent: Optional. An array of contents of the original source files.
  44150. * - mappings: A string of base64 VLQs which contain the actual mappings.
  44151. * - file: Optional. The generated file this source map is associated with.
  44152. *
  44153. * Here is an example source map, taken from the source map spec[0]:
  44154. *
  44155. * {
  44156. * version : 3,
  44157. * file: "out.js",
  44158. * sourceRoot : "",
  44159. * sources: ["foo.js", "bar.js"],
  44160. * names: ["src", "maps", "are", "fun"],
  44161. * mappings: "AA,AB;;ABCDE;"
  44162. * }
  44163. *
  44164. * The second parameter, if given, is a string whose value is the URL
  44165. * at which the source map was found. This URL is used to compute the
  44166. * sources array.
  44167. *
  44168. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  44169. */
  44170. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  44171. var sourceMap = aSourceMap;
  44172. if (typeof aSourceMap === 'string') {
  44173. sourceMap = util.parseSourceMapInput(aSourceMap);
  44174. }
  44175. var version = util.getArg(sourceMap, 'version');
  44176. var sources = util.getArg(sourceMap, 'sources');
  44177. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  44178. // requires the array) to play nice here.
  44179. var names = util.getArg(sourceMap, 'names', []);
  44180. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  44181. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  44182. var mappings = util.getArg(sourceMap, 'mappings');
  44183. var file = util.getArg(sourceMap, 'file', null);
  44184. // Once again, Sass deviates from the spec and supplies the version as a
  44185. // string rather than a number, so we use loose equality checking here.
  44186. if (version != this._version) {
  44187. throw new Error('Unsupported version: ' + version);
  44188. }
  44189. if (sourceRoot) {
  44190. sourceRoot = util.normalize(sourceRoot);
  44191. }
  44192. sources = sources
  44193. .map(String)
  44194. // Some source maps produce relative source paths like "./foo.js" instead of
  44195. // "foo.js". Normalize these first so that future comparisons will succeed.
  44196. // See bugzil.la/1090768.
  44197. .map(util.normalize)
  44198. // Always ensure that absolute sources are internally stored relative to
  44199. // the source root, if the source root is absolute. Not doing this would
  44200. // be particularly problematic when the source root is a prefix of the
  44201. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  44202. .map(function (source) {
  44203. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  44204. ? util.relative(sourceRoot, source)
  44205. : source;
  44206. });
  44207. // Pass `true` below to allow duplicate names and sources. While source maps
  44208. // are intended to be compressed and deduplicated, the TypeScript compiler
  44209. // sometimes generates source maps with duplicates in them. See Github issue
  44210. // #72 and bugzil.la/889492.
  44211. this._names = ArraySet.fromArray(names.map(String), true);
  44212. this._sources = ArraySet.fromArray(sources, true);
  44213. this._absoluteSources = this._sources.toArray().map(function (s) {
  44214. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  44215. });
  44216. this.sourceRoot = sourceRoot;
  44217. this.sourcesContent = sourcesContent;
  44218. this._mappings = mappings;
  44219. this._sourceMapURL = aSourceMapURL;
  44220. this.file = file;
  44221. }
  44222. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  44223. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  44224. /**
  44225. * Utility function to find the index of a source. Returns -1 if not
  44226. * found.
  44227. */
  44228. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  44229. var relativeSource = aSource;
  44230. if (this.sourceRoot != null) {
  44231. relativeSource = util.relative(this.sourceRoot, relativeSource);
  44232. }
  44233. if (this._sources.has(relativeSource)) {
  44234. return this._sources.indexOf(relativeSource);
  44235. }
  44236. // Maybe aSource is an absolute URL as returned by |sources|. In
  44237. // this case we can't simply undo the transform.
  44238. var i;
  44239. for (i = 0; i < this._absoluteSources.length; ++i) {
  44240. if (this._absoluteSources[i] == aSource) {
  44241. return i;
  44242. }
  44243. }
  44244. return -1;
  44245. };
  44246. /**
  44247. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  44248. *
  44249. * @param SourceMapGenerator aSourceMap
  44250. * The source map that will be consumed.
  44251. * @param String aSourceMapURL
  44252. * The URL at which the source map can be found (optional)
  44253. * @returns BasicSourceMapConsumer
  44254. */
  44255. BasicSourceMapConsumer.fromSourceMap =
  44256. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  44257. var smc = Object.create(BasicSourceMapConsumer.prototype);
  44258. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  44259. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  44260. smc.sourceRoot = aSourceMap._sourceRoot;
  44261. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  44262. smc.sourceRoot);
  44263. smc.file = aSourceMap._file;
  44264. smc._sourceMapURL = aSourceMapURL;
  44265. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  44266. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  44267. });
  44268. // Because we are modifying the entries (by converting string sources and
  44269. // names to indices into the sources and names ArraySets), we have to make
  44270. // a copy of the entry or else bad things happen. Shared mutable state
  44271. // strikes again! See github issue #191.
  44272. var generatedMappings = aSourceMap._mappings.toArray().slice();
  44273. var destGeneratedMappings = smc.__generatedMappings = [];
  44274. var destOriginalMappings = smc.__originalMappings = [];
  44275. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  44276. var srcMapping = generatedMappings[i];
  44277. var destMapping = new Mapping;
  44278. destMapping.generatedLine = srcMapping.generatedLine;
  44279. destMapping.generatedColumn = srcMapping.generatedColumn;
  44280. if (srcMapping.source) {
  44281. destMapping.source = sources.indexOf(srcMapping.source);
  44282. destMapping.originalLine = srcMapping.originalLine;
  44283. destMapping.originalColumn = srcMapping.originalColumn;
  44284. if (srcMapping.name) {
  44285. destMapping.name = names.indexOf(srcMapping.name);
  44286. }
  44287. destOriginalMappings.push(destMapping);
  44288. }
  44289. destGeneratedMappings.push(destMapping);
  44290. }
  44291. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  44292. return smc;
  44293. };
  44294. /**
  44295. * The version of the source mapping spec that we are consuming.
  44296. */
  44297. BasicSourceMapConsumer.prototype._version = 3;
  44298. /**
  44299. * The list of original sources.
  44300. */
  44301. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  44302. get: function () {
  44303. return this._absoluteSources.slice();
  44304. }
  44305. });
  44306. /**
  44307. * Provide the JIT with a nice shape / hidden class.
  44308. */
  44309. function Mapping() {
  44310. this.generatedLine = 0;
  44311. this.generatedColumn = 0;
  44312. this.source = null;
  44313. this.originalLine = null;
  44314. this.originalColumn = null;
  44315. this.name = null;
  44316. }
  44317. /**
  44318. * Parse the mappings in a string in to a data structure which we can easily
  44319. * query (the ordered arrays in the `this.__generatedMappings` and
  44320. * `this.__originalMappings` properties).
  44321. */
  44322. BasicSourceMapConsumer.prototype._parseMappings =
  44323. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  44324. var generatedLine = 1;
  44325. var previousGeneratedColumn = 0;
  44326. var previousOriginalLine = 0;
  44327. var previousOriginalColumn = 0;
  44328. var previousSource = 0;
  44329. var previousName = 0;
  44330. var length = aStr.length;
  44331. var index = 0;
  44332. var cachedSegments = {};
  44333. var temp = {};
  44334. var originalMappings = [];
  44335. var generatedMappings = [];
  44336. var mapping, str, segment, end, value;
  44337. while (index < length) {
  44338. if (aStr.charAt(index) === ';') {
  44339. generatedLine++;
  44340. index++;
  44341. previousGeneratedColumn = 0;
  44342. }
  44343. else if (aStr.charAt(index) === ',') {
  44344. index++;
  44345. }
  44346. else {
  44347. mapping = new Mapping();
  44348. mapping.generatedLine = generatedLine;
  44349. // Because each offset is encoded relative to the previous one,
  44350. // many segments often have the same encoding. We can exploit this
  44351. // fact by caching the parsed variable length fields of each segment,
  44352. // allowing us to avoid a second parse if we encounter the same
  44353. // segment again.
  44354. for (end = index; end < length; end++) {
  44355. if (this._charIsMappingSeparator(aStr, end)) {
  44356. break;
  44357. }
  44358. }
  44359. str = aStr.slice(index, end);
  44360. segment = cachedSegments[str];
  44361. if (segment) {
  44362. index += str.length;
  44363. } else {
  44364. segment = [];
  44365. while (index < end) {
  44366. base64VLQ.decode(aStr, index, temp);
  44367. value = temp.value;
  44368. index = temp.rest;
  44369. segment.push(value);
  44370. }
  44371. if (segment.length === 2) {
  44372. throw new Error('Found a source, but no line and column');
  44373. }
  44374. if (segment.length === 3) {
  44375. throw new Error('Found a source and line, but no column');
  44376. }
  44377. cachedSegments[str] = segment;
  44378. }
  44379. // Generated column.
  44380. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  44381. previousGeneratedColumn = mapping.generatedColumn;
  44382. if (segment.length > 1) {
  44383. // Original source.
  44384. mapping.source = previousSource + segment[1];
  44385. previousSource += segment[1];
  44386. // Original line.
  44387. mapping.originalLine = previousOriginalLine + segment[2];
  44388. previousOriginalLine = mapping.originalLine;
  44389. // Lines are stored 0-based
  44390. mapping.originalLine += 1;
  44391. // Original column.
  44392. mapping.originalColumn = previousOriginalColumn + segment[3];
  44393. previousOriginalColumn = mapping.originalColumn;
  44394. if (segment.length > 4) {
  44395. // Original name.
  44396. mapping.name = previousName + segment[4];
  44397. previousName += segment[4];
  44398. }
  44399. }
  44400. generatedMappings.push(mapping);
  44401. if (typeof mapping.originalLine === 'number') {
  44402. originalMappings.push(mapping);
  44403. }
  44404. }
  44405. }
  44406. quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
  44407. this.__generatedMappings = generatedMappings;
  44408. quickSort(originalMappings, util.compareByOriginalPositions);
  44409. this.__originalMappings = originalMappings;
  44410. };
  44411. /**
  44412. * Find the mapping that best matches the hypothetical "needle" mapping that
  44413. * we are searching for in the given "haystack" of mappings.
  44414. */
  44415. BasicSourceMapConsumer.prototype._findMapping =
  44416. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  44417. aColumnName, aComparator, aBias) {
  44418. // To return the position we are searching for, we must first find the
  44419. // mapping for the given position and then return the opposite position it
  44420. // points to. Because the mappings are sorted, we can use binary search to
  44421. // find the best mapping.
  44422. if (aNeedle[aLineName] <= 0) {
  44423. throw new TypeError('Line must be greater than or equal to 1, got '
  44424. + aNeedle[aLineName]);
  44425. }
  44426. if (aNeedle[aColumnName] < 0) {
  44427. throw new TypeError('Column must be greater than or equal to 0, got '
  44428. + aNeedle[aColumnName]);
  44429. }
  44430. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  44431. };
  44432. /**
  44433. * Compute the last column for each generated mapping. The last column is
  44434. * inclusive.
  44435. */
  44436. BasicSourceMapConsumer.prototype.computeColumnSpans =
  44437. function SourceMapConsumer_computeColumnSpans() {
  44438. for (var index = 0; index < this._generatedMappings.length; ++index) {
  44439. var mapping = this._generatedMappings[index];
  44440. // Mappings do not contain a field for the last generated columnt. We
  44441. // can come up with an optimistic estimate, however, by assuming that
  44442. // mappings are contiguous (i.e. given two consecutive mappings, the
  44443. // first mapping ends where the second one starts).
  44444. if (index + 1 < this._generatedMappings.length) {
  44445. var nextMapping = this._generatedMappings[index + 1];
  44446. if (mapping.generatedLine === nextMapping.generatedLine) {
  44447. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  44448. continue;
  44449. }
  44450. }
  44451. // The last mapping for each line spans the entire line.
  44452. mapping.lastGeneratedColumn = Infinity;
  44453. }
  44454. };
  44455. /**
  44456. * Returns the original source, line, and column information for the generated
  44457. * source's line and column positions provided. The only argument is an object
  44458. * with the following properties:
  44459. *
  44460. * - line: The line number in the generated source. The line number
  44461. * is 1-based.
  44462. * - column: The column number in the generated source. The column
  44463. * number is 0-based.
  44464. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  44465. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  44466. * closest element that is smaller than or greater than the one we are
  44467. * searching for, respectively, if the exact element cannot be found.
  44468. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  44469. *
  44470. * and an object is returned with the following properties:
  44471. *
  44472. * - source: The original source file, or null.
  44473. * - line: The line number in the original source, or null. The
  44474. * line number is 1-based.
  44475. * - column: The column number in the original source, or null. The
  44476. * column number is 0-based.
  44477. * - name: The original identifier, or null.
  44478. */
  44479. BasicSourceMapConsumer.prototype.originalPositionFor =
  44480. function SourceMapConsumer_originalPositionFor(aArgs) {
  44481. var needle = {
  44482. generatedLine: util.getArg(aArgs, 'line'),
  44483. generatedColumn: util.getArg(aArgs, 'column')
  44484. };
  44485. var index = this._findMapping(
  44486. needle,
  44487. this._generatedMappings,
  44488. "generatedLine",
  44489. "generatedColumn",
  44490. util.compareByGeneratedPositionsDeflated,
  44491. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  44492. );
  44493. if (index >= 0) {
  44494. var mapping = this._generatedMappings[index];
  44495. if (mapping.generatedLine === needle.generatedLine) {
  44496. var source = util.getArg(mapping, 'source', null);
  44497. if (source !== null) {
  44498. source = this._sources.at(source);
  44499. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  44500. }
  44501. var name = util.getArg(mapping, 'name', null);
  44502. if (name !== null) {
  44503. name = this._names.at(name);
  44504. }
  44505. return {
  44506. source: source,
  44507. line: util.getArg(mapping, 'originalLine', null),
  44508. column: util.getArg(mapping, 'originalColumn', null),
  44509. name: name
  44510. };
  44511. }
  44512. }
  44513. return {
  44514. source: null,
  44515. line: null,
  44516. column: null,
  44517. name: null
  44518. };
  44519. };
  44520. /**
  44521. * Return true if we have the source content for every source in the source
  44522. * map, false otherwise.
  44523. */
  44524. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  44525. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  44526. if (!this.sourcesContent) {
  44527. return false;
  44528. }
  44529. return this.sourcesContent.length >= this._sources.size() &&
  44530. !this.sourcesContent.some(function (sc) { return sc == null; });
  44531. };
  44532. /**
  44533. * Returns the original source content. The only argument is the url of the
  44534. * original source file. Returns null if no original source content is
  44535. * available.
  44536. */
  44537. BasicSourceMapConsumer.prototype.sourceContentFor =
  44538. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  44539. if (!this.sourcesContent) {
  44540. return null;
  44541. }
  44542. var index = this._findSourceIndex(aSource);
  44543. if (index >= 0) {
  44544. return this.sourcesContent[index];
  44545. }
  44546. var relativeSource = aSource;
  44547. if (this.sourceRoot != null) {
  44548. relativeSource = util.relative(this.sourceRoot, relativeSource);
  44549. }
  44550. var url;
  44551. if (this.sourceRoot != null
  44552. && (url = util.urlParse(this.sourceRoot))) {
  44553. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  44554. // many users. We can help them out when they expect file:// URIs to
  44555. // behave like it would if they were running a local HTTP server. See
  44556. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  44557. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  44558. if (url.scheme == "file"
  44559. && this._sources.has(fileUriAbsPath)) {
  44560. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  44561. }
  44562. if ((!url.path || url.path == "/")
  44563. && this._sources.has("/" + relativeSource)) {
  44564. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  44565. }
  44566. }
  44567. // This function is used recursively from
  44568. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  44569. // don't want to throw if we can't find the source - we just want to
  44570. // return null, so we provide a flag to exit gracefully.
  44571. if (nullOnMissing) {
  44572. return null;
  44573. }
  44574. else {
  44575. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  44576. }
  44577. };
  44578. /**
  44579. * Returns the generated line and column information for the original source,
  44580. * line, and column positions provided. The only argument is an object with
  44581. * the following properties:
  44582. *
  44583. * - source: The filename of the original source.
  44584. * - line: The line number in the original source. The line number
  44585. * is 1-based.
  44586. * - column: The column number in the original source. The column
  44587. * number is 0-based.
  44588. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  44589. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  44590. * closest element that is smaller than or greater than the one we are
  44591. * searching for, respectively, if the exact element cannot be found.
  44592. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  44593. *
  44594. * and an object is returned with the following properties:
  44595. *
  44596. * - line: The line number in the generated source, or null. The
  44597. * line number is 1-based.
  44598. * - column: The column number in the generated source, or null.
  44599. * The column number is 0-based.
  44600. */
  44601. BasicSourceMapConsumer.prototype.generatedPositionFor =
  44602. function SourceMapConsumer_generatedPositionFor(aArgs) {
  44603. var source = util.getArg(aArgs, 'source');
  44604. source = this._findSourceIndex(source);
  44605. if (source < 0) {
  44606. return {
  44607. line: null,
  44608. column: null,
  44609. lastColumn: null
  44610. };
  44611. }
  44612. var needle = {
  44613. source: source,
  44614. originalLine: util.getArg(aArgs, 'line'),
  44615. originalColumn: util.getArg(aArgs, 'column')
  44616. };
  44617. var index = this._findMapping(
  44618. needle,
  44619. this._originalMappings,
  44620. "originalLine",
  44621. "originalColumn",
  44622. util.compareByOriginalPositions,
  44623. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  44624. );
  44625. if (index >= 0) {
  44626. var mapping = this._originalMappings[index];
  44627. if (mapping.source === needle.source) {
  44628. return {
  44629. line: util.getArg(mapping, 'generatedLine', null),
  44630. column: util.getArg(mapping, 'generatedColumn', null),
  44631. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  44632. };
  44633. }
  44634. }
  44635. return {
  44636. line: null,
  44637. column: null,
  44638. lastColumn: null
  44639. };
  44640. };
  44641. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  44642. /**
  44643. * An IndexedSourceMapConsumer instance represents a parsed source map which
  44644. * we can query for information. It differs from BasicSourceMapConsumer in
  44645. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  44646. * input.
  44647. *
  44648. * The first parameter is a raw source map (either as a JSON string, or already
  44649. * parsed to an object). According to the spec for indexed source maps, they
  44650. * have the following attributes:
  44651. *
  44652. * - version: Which version of the source map spec this map is following.
  44653. * - file: Optional. The generated file this source map is associated with.
  44654. * - sections: A list of section definitions.
  44655. *
  44656. * Each value under the "sections" field has two fields:
  44657. * - offset: The offset into the original specified at which this section
  44658. * begins to apply, defined as an object with a "line" and "column"
  44659. * field.
  44660. * - map: A source map definition. This source map could also be indexed,
  44661. * but doesn't have to be.
  44662. *
  44663. * Instead of the "map" field, it's also possible to have a "url" field
  44664. * specifying a URL to retrieve a source map from, but that's currently
  44665. * unsupported.
  44666. *
  44667. * Here's an example source map, taken from the source map spec[0], but
  44668. * modified to omit a section which uses the "url" field.
  44669. *
  44670. * {
  44671. * version : 3,
  44672. * file: "app.js",
  44673. * sections: [{
  44674. * offset: {line:100, column:10},
  44675. * map: {
  44676. * version : 3,
  44677. * file: "section.js",
  44678. * sources: ["foo.js", "bar.js"],
  44679. * names: ["src", "maps", "are", "fun"],
  44680. * mappings: "AAAA,E;;ABCDE;"
  44681. * }
  44682. * }],
  44683. * }
  44684. *
  44685. * The second parameter, if given, is a string whose value is the URL
  44686. * at which the source map was found. This URL is used to compute the
  44687. * sources array.
  44688. *
  44689. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  44690. */
  44691. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  44692. var sourceMap = aSourceMap;
  44693. if (typeof aSourceMap === 'string') {
  44694. sourceMap = util.parseSourceMapInput(aSourceMap);
  44695. }
  44696. var version = util.getArg(sourceMap, 'version');
  44697. var sections = util.getArg(sourceMap, 'sections');
  44698. if (version != this._version) {
  44699. throw new Error('Unsupported version: ' + version);
  44700. }
  44701. this._sources = new ArraySet();
  44702. this._names = new ArraySet();
  44703. var lastOffset = {
  44704. line: -1,
  44705. column: 0
  44706. };
  44707. this._sections = sections.map(function (s) {
  44708. if (s.url) {
  44709. // The url field will require support for asynchronicity.
  44710. // See https://github.com/mozilla/source-map/issues/16
  44711. throw new Error('Support for url field in sections not implemented.');
  44712. }
  44713. var offset = util.getArg(s, 'offset');
  44714. var offsetLine = util.getArg(offset, 'line');
  44715. var offsetColumn = util.getArg(offset, 'column');
  44716. if (offsetLine < lastOffset.line ||
  44717. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  44718. throw new Error('Section offsets must be ordered and non-overlapping.');
  44719. }
  44720. lastOffset = offset;
  44721. return {
  44722. generatedOffset: {
  44723. // The offset fields are 0-based, but we use 1-based indices when
  44724. // encoding/decoding from VLQ.
  44725. generatedLine: offsetLine + 1,
  44726. generatedColumn: offsetColumn + 1
  44727. },
  44728. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  44729. }
  44730. });
  44731. }
  44732. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  44733. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  44734. /**
  44735. * The version of the source mapping spec that we are consuming.
  44736. */
  44737. IndexedSourceMapConsumer.prototype._version = 3;
  44738. /**
  44739. * The list of original sources.
  44740. */
  44741. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  44742. get: function () {
  44743. var sources = [];
  44744. for (var i = 0; i < this._sections.length; i++) {
  44745. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  44746. sources.push(this._sections[i].consumer.sources[j]);
  44747. }
  44748. }
  44749. return sources;
  44750. }
  44751. });
  44752. /**
  44753. * Returns the original source, line, and column information for the generated
  44754. * source's line and column positions provided. The only argument is an object
  44755. * with the following properties:
  44756. *
  44757. * - line: The line number in the generated source. The line number
  44758. * is 1-based.
  44759. * - column: The column number in the generated source. The column
  44760. * number is 0-based.
  44761. *
  44762. * and an object is returned with the following properties:
  44763. *
  44764. * - source: The original source file, or null.
  44765. * - line: The line number in the original source, or null. The
  44766. * line number is 1-based.
  44767. * - column: The column number in the original source, or null. The
  44768. * column number is 0-based.
  44769. * - name: The original identifier, or null.
  44770. */
  44771. IndexedSourceMapConsumer.prototype.originalPositionFor =
  44772. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  44773. var needle = {
  44774. generatedLine: util.getArg(aArgs, 'line'),
  44775. generatedColumn: util.getArg(aArgs, 'column')
  44776. };
  44777. // Find the section containing the generated position we're trying to map
  44778. // to an original position.
  44779. var sectionIndex = binarySearch.search(needle, this._sections,
  44780. function(needle, section) {
  44781. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  44782. if (cmp) {
  44783. return cmp;
  44784. }
  44785. return (needle.generatedColumn -
  44786. section.generatedOffset.generatedColumn);
  44787. });
  44788. var section = this._sections[sectionIndex];
  44789. if (!section) {
  44790. return {
  44791. source: null,
  44792. line: null,
  44793. column: null,
  44794. name: null
  44795. };
  44796. }
  44797. return section.consumer.originalPositionFor({
  44798. line: needle.generatedLine -
  44799. (section.generatedOffset.generatedLine - 1),
  44800. column: needle.generatedColumn -
  44801. (section.generatedOffset.generatedLine === needle.generatedLine
  44802. ? section.generatedOffset.generatedColumn - 1
  44803. : 0),
  44804. bias: aArgs.bias
  44805. });
  44806. };
  44807. /**
  44808. * Return true if we have the source content for every source in the source
  44809. * map, false otherwise.
  44810. */
  44811. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  44812. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  44813. return this._sections.every(function (s) {
  44814. return s.consumer.hasContentsOfAllSources();
  44815. });
  44816. };
  44817. /**
  44818. * Returns the original source content. The only argument is the url of the
  44819. * original source file. Returns null if no original source content is
  44820. * available.
  44821. */
  44822. IndexedSourceMapConsumer.prototype.sourceContentFor =
  44823. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  44824. for (var i = 0; i < this._sections.length; i++) {
  44825. var section = this._sections[i];
  44826. var content = section.consumer.sourceContentFor(aSource, true);
  44827. if (content) {
  44828. return content;
  44829. }
  44830. }
  44831. if (nullOnMissing) {
  44832. return null;
  44833. }
  44834. else {
  44835. throw new Error('"' + aSource + '" is not in the SourceMap.');
  44836. }
  44837. };
  44838. /**
  44839. * Returns the generated line and column information for the original source,
  44840. * line, and column positions provided. The only argument is an object with
  44841. * the following properties:
  44842. *
  44843. * - source: The filename of the original source.
  44844. * - line: The line number in the original source. The line number
  44845. * is 1-based.
  44846. * - column: The column number in the original source. The column
  44847. * number is 0-based.
  44848. *
  44849. * and an object is returned with the following properties:
  44850. *
  44851. * - line: The line number in the generated source, or null. The
  44852. * line number is 1-based.
  44853. * - column: The column number in the generated source, or null.
  44854. * The column number is 0-based.
  44855. */
  44856. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  44857. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  44858. for (var i = 0; i < this._sections.length; i++) {
  44859. var section = this._sections[i];
  44860. // Only consider this section if the requested source is in the list of
  44861. // sources of the consumer.
  44862. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  44863. continue;
  44864. }
  44865. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  44866. if (generatedPosition) {
  44867. var ret = {
  44868. line: generatedPosition.line +
  44869. (section.generatedOffset.generatedLine - 1),
  44870. column: generatedPosition.column +
  44871. (section.generatedOffset.generatedLine === generatedPosition.line
  44872. ? section.generatedOffset.generatedColumn - 1
  44873. : 0)
  44874. };
  44875. return ret;
  44876. }
  44877. }
  44878. return {
  44879. line: null,
  44880. column: null
  44881. };
  44882. };
  44883. /**
  44884. * Parse the mappings in a string in to a data structure which we can easily
  44885. * query (the ordered arrays in the `this.__generatedMappings` and
  44886. * `this.__originalMappings` properties).
  44887. */
  44888. IndexedSourceMapConsumer.prototype._parseMappings =
  44889. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  44890. this.__generatedMappings = [];
  44891. this.__originalMappings = [];
  44892. for (var i = 0; i < this._sections.length; i++) {
  44893. var section = this._sections[i];
  44894. var sectionMappings = section.consumer._generatedMappings;
  44895. for (var j = 0; j < sectionMappings.length; j++) {
  44896. var mapping = sectionMappings[j];
  44897. var source = section.consumer._sources.at(mapping.source);
  44898. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  44899. this._sources.add(source);
  44900. source = this._sources.indexOf(source);
  44901. var name = null;
  44902. if (mapping.name) {
  44903. name = section.consumer._names.at(mapping.name);
  44904. this._names.add(name);
  44905. name = this._names.indexOf(name);
  44906. }
  44907. // The mappings coming from the consumer for the section have
  44908. // generated positions relative to the start of the section, so we
  44909. // need to offset them to be relative to the start of the concatenated
  44910. // generated file.
  44911. var adjustedMapping = {
  44912. source: source,
  44913. generatedLine: mapping.generatedLine +
  44914. (section.generatedOffset.generatedLine - 1),
  44915. generatedColumn: mapping.generatedColumn +
  44916. (section.generatedOffset.generatedLine === mapping.generatedLine
  44917. ? section.generatedOffset.generatedColumn - 1
  44918. : 0),
  44919. originalLine: mapping.originalLine,
  44920. originalColumn: mapping.originalColumn,
  44921. name: name
  44922. };
  44923. this.__generatedMappings.push(adjustedMapping);
  44924. if (typeof adjustedMapping.originalLine === 'number') {
  44925. this.__originalMappings.push(adjustedMapping);
  44926. }
  44927. }
  44928. }
  44929. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  44930. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  44931. };
  44932. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  44933. return sourceMapConsumer;
  44934. }
  44935. var sourceNode = {};
  44936. /* -*- Mode: js; js-indent-level: 2; -*- */
  44937. var hasRequiredSourceNode;
  44938. function requireSourceNode () {
  44939. if (hasRequiredSourceNode) return sourceNode;
  44940. hasRequiredSourceNode = 1;
  44941. /*
  44942. * Copyright 2011 Mozilla Foundation and contributors
  44943. * Licensed under the New BSD license. See LICENSE or:
  44944. * http://opensource.org/licenses/BSD-3-Clause
  44945. */
  44946. var SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator().SourceMapGenerator;
  44947. var util = /*@__PURE__*/ requireUtil();
  44948. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  44949. // operating systems these days (capturing the result).
  44950. var REGEX_NEWLINE = /(\r?\n)/;
  44951. // Newline character code for charCodeAt() comparisons
  44952. var NEWLINE_CODE = 10;
  44953. // Private symbol for identifying `SourceNode`s when multiple versions of
  44954. // the source-map library are loaded. This MUST NOT CHANGE across
  44955. // versions!
  44956. var isSourceNode = "$$$isSourceNode$$$";
  44957. /**
  44958. * SourceNodes provide a way to abstract over interpolating/concatenating
  44959. * snippets of generated JavaScript source code while maintaining the line and
  44960. * column information associated with the original source code.
  44961. *
  44962. * @param aLine The original line number.
  44963. * @param aColumn The original column number.
  44964. * @param aSource The original source's filename.
  44965. * @param aChunks Optional. An array of strings which are snippets of
  44966. * generated JS, or other SourceNodes.
  44967. * @param aName The original identifier.
  44968. */
  44969. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  44970. this.children = [];
  44971. this.sourceContents = {};
  44972. this.line = aLine == null ? null : aLine;
  44973. this.column = aColumn == null ? null : aColumn;
  44974. this.source = aSource == null ? null : aSource;
  44975. this.name = aName == null ? null : aName;
  44976. this[isSourceNode] = true;
  44977. if (aChunks != null) this.add(aChunks);
  44978. }
  44979. /**
  44980. * Creates a SourceNode from generated code and a SourceMapConsumer.
  44981. *
  44982. * @param aGeneratedCode The generated code
  44983. * @param aSourceMapConsumer The SourceMap for the generated code
  44984. * @param aRelativePath Optional. The path that relative sources in the
  44985. * SourceMapConsumer should be relative to.
  44986. */
  44987. SourceNode.fromStringWithSourceMap =
  44988. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  44989. // The SourceNode we want to fill with the generated code
  44990. // and the SourceMap
  44991. var node = new SourceNode();
  44992. // All even indices of this array are one line of the generated code,
  44993. // while all odd indices are the newlines between two adjacent lines
  44994. // (since `REGEX_NEWLINE` captures its match).
  44995. // Processed fragments are accessed by calling `shiftNextLine`.
  44996. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  44997. var remainingLinesIndex = 0;
  44998. var shiftNextLine = function() {
  44999. var lineContents = getNextLine();
  45000. // The last line of a file might not have a newline.
  45001. var newLine = getNextLine() || "";
  45002. return lineContents + newLine;
  45003. function getNextLine() {
  45004. return remainingLinesIndex < remainingLines.length ?
  45005. remainingLines[remainingLinesIndex++] : undefined;
  45006. }
  45007. };
  45008. // We need to remember the position of "remainingLines"
  45009. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  45010. // The generate SourceNodes we need a code range.
  45011. // To extract it current and last mapping is used.
  45012. // Here we store the last mapping.
  45013. var lastMapping = null;
  45014. aSourceMapConsumer.eachMapping(function (mapping) {
  45015. if (lastMapping !== null) {
  45016. // We add the code from "lastMapping" to "mapping":
  45017. // First check if there is a new line in between.
  45018. if (lastGeneratedLine < mapping.generatedLine) {
  45019. // Associate first line with "lastMapping"
  45020. addMappingWithCode(lastMapping, shiftNextLine());
  45021. lastGeneratedLine++;
  45022. lastGeneratedColumn = 0;
  45023. // The remaining code is added without mapping
  45024. } else {
  45025. // There is no new line in between.
  45026. // Associate the code between "lastGeneratedColumn" and
  45027. // "mapping.generatedColumn" with "lastMapping"
  45028. var nextLine = remainingLines[remainingLinesIndex] || '';
  45029. var code = nextLine.substr(0, mapping.generatedColumn -
  45030. lastGeneratedColumn);
  45031. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  45032. lastGeneratedColumn);
  45033. lastGeneratedColumn = mapping.generatedColumn;
  45034. addMappingWithCode(lastMapping, code);
  45035. // No more remaining code, continue
  45036. lastMapping = mapping;
  45037. return;
  45038. }
  45039. }
  45040. // We add the generated code until the first mapping
  45041. // to the SourceNode without any mapping.
  45042. // Each line is added as separate string.
  45043. while (lastGeneratedLine < mapping.generatedLine) {
  45044. node.add(shiftNextLine());
  45045. lastGeneratedLine++;
  45046. }
  45047. if (lastGeneratedColumn < mapping.generatedColumn) {
  45048. var nextLine = remainingLines[remainingLinesIndex] || '';
  45049. node.add(nextLine.substr(0, mapping.generatedColumn));
  45050. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  45051. lastGeneratedColumn = mapping.generatedColumn;
  45052. }
  45053. lastMapping = mapping;
  45054. }, this);
  45055. // We have processed all mappings.
  45056. if (remainingLinesIndex < remainingLines.length) {
  45057. if (lastMapping) {
  45058. // Associate the remaining code in the current line with "lastMapping"
  45059. addMappingWithCode(lastMapping, shiftNextLine());
  45060. }
  45061. // and add the remaining lines without any mapping
  45062. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  45063. }
  45064. // Copy sourcesContent into SourceNode
  45065. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  45066. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  45067. if (content != null) {
  45068. if (aRelativePath != null) {
  45069. sourceFile = util.join(aRelativePath, sourceFile);
  45070. }
  45071. node.setSourceContent(sourceFile, content);
  45072. }
  45073. });
  45074. return node;
  45075. function addMappingWithCode(mapping, code) {
  45076. if (mapping === null || mapping.source === undefined) {
  45077. node.add(code);
  45078. } else {
  45079. var source = aRelativePath
  45080. ? util.join(aRelativePath, mapping.source)
  45081. : mapping.source;
  45082. node.add(new SourceNode(mapping.originalLine,
  45083. mapping.originalColumn,
  45084. source,
  45085. code,
  45086. mapping.name));
  45087. }
  45088. }
  45089. };
  45090. /**
  45091. * Add a chunk of generated JS to this source node.
  45092. *
  45093. * @param aChunk A string snippet of generated JS code, another instance of
  45094. * SourceNode, or an array where each member is one of those things.
  45095. */
  45096. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  45097. if (Array.isArray(aChunk)) {
  45098. aChunk.forEach(function (chunk) {
  45099. this.add(chunk);
  45100. }, this);
  45101. }
  45102. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  45103. if (aChunk) {
  45104. this.children.push(aChunk);
  45105. }
  45106. }
  45107. else {
  45108. throw new TypeError(
  45109. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  45110. );
  45111. }
  45112. return this;
  45113. };
  45114. /**
  45115. * Add a chunk of generated JS to the beginning of this source node.
  45116. *
  45117. * @param aChunk A string snippet of generated JS code, another instance of
  45118. * SourceNode, or an array where each member is one of those things.
  45119. */
  45120. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  45121. if (Array.isArray(aChunk)) {
  45122. for (var i = aChunk.length-1; i >= 0; i--) {
  45123. this.prepend(aChunk[i]);
  45124. }
  45125. }
  45126. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  45127. this.children.unshift(aChunk);
  45128. }
  45129. else {
  45130. throw new TypeError(
  45131. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  45132. );
  45133. }
  45134. return this;
  45135. };
  45136. /**
  45137. * Walk over the tree of JS snippets in this node and its children. The
  45138. * walking function is called once for each snippet of JS and is passed that
  45139. * snippet and the its original associated source's line/column location.
  45140. *
  45141. * @param aFn The traversal function.
  45142. */
  45143. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  45144. var chunk;
  45145. for (var i = 0, len = this.children.length; i < len; i++) {
  45146. chunk = this.children[i];
  45147. if (chunk[isSourceNode]) {
  45148. chunk.walk(aFn);
  45149. }
  45150. else {
  45151. if (chunk !== '') {
  45152. aFn(chunk, { source: this.source,
  45153. line: this.line,
  45154. column: this.column,
  45155. name: this.name });
  45156. }
  45157. }
  45158. }
  45159. };
  45160. /**
  45161. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  45162. * each of `this.children`.
  45163. *
  45164. * @param aSep The separator.
  45165. */
  45166. SourceNode.prototype.join = function SourceNode_join(aSep) {
  45167. var newChildren;
  45168. var i;
  45169. var len = this.children.length;
  45170. if (len > 0) {
  45171. newChildren = [];
  45172. for (i = 0; i < len-1; i++) {
  45173. newChildren.push(this.children[i]);
  45174. newChildren.push(aSep);
  45175. }
  45176. newChildren.push(this.children[i]);
  45177. this.children = newChildren;
  45178. }
  45179. return this;
  45180. };
  45181. /**
  45182. * Call String.prototype.replace on the very right-most source snippet. Useful
  45183. * for trimming whitespace from the end of a source node, etc.
  45184. *
  45185. * @param aPattern The pattern to replace.
  45186. * @param aReplacement The thing to replace the pattern with.
  45187. */
  45188. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  45189. var lastChild = this.children[this.children.length - 1];
  45190. if (lastChild[isSourceNode]) {
  45191. lastChild.replaceRight(aPattern, aReplacement);
  45192. }
  45193. else if (typeof lastChild === 'string') {
  45194. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  45195. }
  45196. else {
  45197. this.children.push(''.replace(aPattern, aReplacement));
  45198. }
  45199. return this;
  45200. };
  45201. /**
  45202. * Set the source content for a source file. This will be added to the SourceMapGenerator
  45203. * in the sourcesContent field.
  45204. *
  45205. * @param aSourceFile The filename of the source file
  45206. * @param aSourceContent The content of the source file
  45207. */
  45208. SourceNode.prototype.setSourceContent =
  45209. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  45210. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  45211. };
  45212. /**
  45213. * Walk over the tree of SourceNodes. The walking function is called for each
  45214. * source file content and is passed the filename and source content.
  45215. *
  45216. * @param aFn The traversal function.
  45217. */
  45218. SourceNode.prototype.walkSourceContents =
  45219. function SourceNode_walkSourceContents(aFn) {
  45220. for (var i = 0, len = this.children.length; i < len; i++) {
  45221. if (this.children[i][isSourceNode]) {
  45222. this.children[i].walkSourceContents(aFn);
  45223. }
  45224. }
  45225. var sources = Object.keys(this.sourceContents);
  45226. for (var i = 0, len = sources.length; i < len; i++) {
  45227. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  45228. }
  45229. };
  45230. /**
  45231. * Return the string representation of this source node. Walks over the tree
  45232. * and concatenates all the various snippets together to one string.
  45233. */
  45234. SourceNode.prototype.toString = function SourceNode_toString() {
  45235. var str = "";
  45236. this.walk(function (chunk) {
  45237. str += chunk;
  45238. });
  45239. return str;
  45240. };
  45241. /**
  45242. * Returns the string representation of this source node along with a source
  45243. * map.
  45244. */
  45245. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  45246. var generated = {
  45247. code: "",
  45248. line: 1,
  45249. column: 0
  45250. };
  45251. var map = new SourceMapGenerator(aArgs);
  45252. var sourceMappingActive = false;
  45253. var lastOriginalSource = null;
  45254. var lastOriginalLine = null;
  45255. var lastOriginalColumn = null;
  45256. var lastOriginalName = null;
  45257. this.walk(function (chunk, original) {
  45258. generated.code += chunk;
  45259. if (original.source !== null
  45260. && original.line !== null
  45261. && original.column !== null) {
  45262. if(lastOriginalSource !== original.source
  45263. || lastOriginalLine !== original.line
  45264. || lastOriginalColumn !== original.column
  45265. || lastOriginalName !== original.name) {
  45266. map.addMapping({
  45267. source: original.source,
  45268. original: {
  45269. line: original.line,
  45270. column: original.column
  45271. },
  45272. generated: {
  45273. line: generated.line,
  45274. column: generated.column
  45275. },
  45276. name: original.name
  45277. });
  45278. }
  45279. lastOriginalSource = original.source;
  45280. lastOriginalLine = original.line;
  45281. lastOriginalColumn = original.column;
  45282. lastOriginalName = original.name;
  45283. sourceMappingActive = true;
  45284. } else if (sourceMappingActive) {
  45285. map.addMapping({
  45286. generated: {
  45287. line: generated.line,
  45288. column: generated.column
  45289. }
  45290. });
  45291. lastOriginalSource = null;
  45292. sourceMappingActive = false;
  45293. }
  45294. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  45295. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  45296. generated.line++;
  45297. generated.column = 0;
  45298. // Mappings end at eol
  45299. if (idx + 1 === length) {
  45300. lastOriginalSource = null;
  45301. sourceMappingActive = false;
  45302. } else if (sourceMappingActive) {
  45303. map.addMapping({
  45304. source: original.source,
  45305. original: {
  45306. line: original.line,
  45307. column: original.column
  45308. },
  45309. generated: {
  45310. line: generated.line,
  45311. column: generated.column
  45312. },
  45313. name: original.name
  45314. });
  45315. }
  45316. } else {
  45317. generated.column++;
  45318. }
  45319. }
  45320. });
  45321. this.walkSourceContents(function (sourceFile, sourceContent) {
  45322. map.setSourceContent(sourceFile, sourceContent);
  45323. });
  45324. return { code: generated.code, map: map };
  45325. };
  45326. sourceNode.SourceNode = SourceNode;
  45327. return sourceNode;
  45328. }
  45329. /*
  45330. * Copyright 2009-2011 Mozilla Foundation and contributors
  45331. * Licensed under the New BSD license. See LICENSE.txt or:
  45332. * http://opensource.org/licenses/BSD-3-Clause
  45333. */
  45334. var hasRequiredSourceMap;
  45335. function requireSourceMap () {
  45336. if (hasRequiredSourceMap) return sourceMap;
  45337. hasRequiredSourceMap = 1;
  45338. sourceMap.SourceMapGenerator = /*@__PURE__*/ requireSourceMapGenerator().SourceMapGenerator;
  45339. sourceMap.SourceMapConsumer = /*@__PURE__*/ requireSourceMapConsumer().SourceMapConsumer;
  45340. sourceMap.SourceNode = /*@__PURE__*/ requireSourceNode().SourceNode;
  45341. return sourceMap;
  45342. }
  45343. var mergeSourceMap;
  45344. var hasRequiredMergeSourceMap;
  45345. function requireMergeSourceMap () {
  45346. if (hasRequiredMergeSourceMap) return mergeSourceMap;
  45347. hasRequiredMergeSourceMap = 1;
  45348. var sourceMap = /*@__PURE__*/ requireSourceMap();
  45349. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  45350. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  45351. mergeSourceMap = merge;
  45352. /**
  45353. * Merge old source map and new source map and return merged.
  45354. * If old or new source map value is falsy, return another one as it is.
  45355. *
  45356. * @param {object|string} [oldMap] old source map object
  45357. * @param {object|string} [newmap] new source map object
  45358. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  45359. */
  45360. function merge(oldMap, newMap) {
  45361. if (!oldMap) return newMap
  45362. if (!newMap) return oldMap
  45363. var oldMapConsumer = new SourceMapConsumer(oldMap);
  45364. var newMapConsumer = new SourceMapConsumer(newMap);
  45365. var mergedMapGenerator = new SourceMapGenerator();
  45366. // iterate on new map and overwrite original position of new map with one of old map
  45367. newMapConsumer.eachMapping(function(m) {
  45368. // pass when `originalLine` is null.
  45369. // It occurs in case that the node does not have origin in original code.
  45370. if (m.originalLine == null) return
  45371. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  45372. line: m.originalLine,
  45373. column: m.originalColumn
  45374. });
  45375. if (origPosInOldMap.source == null) return
  45376. mergedMapGenerator.addMapping({
  45377. original: {
  45378. line: origPosInOldMap.line,
  45379. column: origPosInOldMap.column
  45380. },
  45381. generated: {
  45382. line: m.generatedLine,
  45383. column: m.generatedColumn
  45384. },
  45385. source: origPosInOldMap.source,
  45386. name: origPosInOldMap.name
  45387. });
  45388. });
  45389. var consumers = [oldMapConsumer, newMapConsumer];
  45390. consumers.forEach(function(consumer) {
  45391. consumer.sources.forEach(function(sourceFile) {
  45392. mergedMapGenerator._sources.add(sourceFile);
  45393. var sourceContent = consumer.sourceContentFor(sourceFile);
  45394. if (sourceContent != null) {
  45395. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  45396. }
  45397. });
  45398. });
  45399. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  45400. mergedMapGenerator._file = oldMap.file;
  45401. return JSON.parse(mergedMapGenerator.toString())
  45402. }
  45403. return mergeSourceMap;
  45404. }
  45405. var mergeSourceMapExports = /*@__PURE__*/ requireMergeSourceMap();
  45406. var merge = /*@__PURE__*/getDefaultExportFromCjs(mergeSourceMapExports);
  45407. var __defProp$5 = Object.defineProperty;
  45408. var __defProps$4 = Object.defineProperties;
  45409. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  45410. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  45411. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  45412. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  45413. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45414. var __spreadValues$5 = (a, b) => {
  45415. for (var prop in b || (b = {}))
  45416. if (__hasOwnProp$5.call(b, prop))
  45417. __defNormalProp$5(a, prop, b[prop]);
  45418. if (__getOwnPropSymbols$5)
  45419. for (var prop of __getOwnPropSymbols$5(b)) {
  45420. if (__propIsEnum$5.call(b, prop))
  45421. __defNormalProp$5(a, prop, b[prop]);
  45422. }
  45423. return a;
  45424. };
  45425. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  45426. const scss = (source, map, options, load = require) => {
  45427. const nodeSass = load("sass");
  45428. const { compileString, renderSync } = nodeSass;
  45429. const data = getSource(source, options.filename, options.additionalData);
  45430. let css;
  45431. let dependencies;
  45432. let sourceMap;
  45433. try {
  45434. if (compileString) {
  45435. const { pathToFileURL, fileURLToPath } = load("url");
  45436. const result = compileString(data, __spreadProps$4(__spreadValues$5({}, options), {
  45437. url: pathToFileURL(options.filename),
  45438. sourceMap: !!map
  45439. }));
  45440. css = result.css;
  45441. dependencies = result.loadedUrls.map((url) => fileURLToPath(url));
  45442. sourceMap = map ? result.sourceMap : void 0;
  45443. } else {
  45444. const result = renderSync(__spreadProps$4(__spreadValues$5({}, options), {
  45445. data,
  45446. file: options.filename,
  45447. outFile: options.filename,
  45448. sourceMap: !!map
  45449. }));
  45450. css = result.css.toString();
  45451. dependencies = result.stats.includedFiles;
  45452. sourceMap = map ? JSON.parse(result.map.toString()) : void 0;
  45453. }
  45454. if (map) {
  45455. return {
  45456. code: css,
  45457. errors: [],
  45458. dependencies,
  45459. map: merge(map, sourceMap)
  45460. };
  45461. }
  45462. return { code: css, errors: [], dependencies };
  45463. } catch (e) {
  45464. return { code: "", errors: [e], dependencies: [] };
  45465. }
  45466. };
  45467. const sass = (source, map, options, load) => scss(
  45468. source,
  45469. map,
  45470. __spreadProps$4(__spreadValues$5({}, options), {
  45471. indentedSyntax: true
  45472. }),
  45473. load
  45474. );
  45475. const less = (source, map, options, load = require) => {
  45476. const nodeLess = load("less");
  45477. let result;
  45478. let error = null;
  45479. nodeLess.render(
  45480. getSource(source, options.filename, options.additionalData),
  45481. __spreadProps$4(__spreadValues$5({}, options), { syncImport: true }),
  45482. (err, output) => {
  45483. error = err;
  45484. result = output;
  45485. }
  45486. );
  45487. if (error) return { code: "", errors: [error], dependencies: [] };
  45488. const dependencies = result.imports;
  45489. if (map) {
  45490. return {
  45491. code: result.css.toString(),
  45492. map: merge(map, result.map),
  45493. errors: [],
  45494. dependencies
  45495. };
  45496. }
  45497. return {
  45498. code: result.css.toString(),
  45499. errors: [],
  45500. dependencies
  45501. };
  45502. };
  45503. const styl = (source, map, options, load = require) => {
  45504. const nodeStylus = load("stylus");
  45505. try {
  45506. const ref = nodeStylus(source, options);
  45507. if (map) ref.set("sourcemap", { inline: false, comment: false });
  45508. const result = ref.render();
  45509. const dependencies = ref.deps();
  45510. if (map) {
  45511. return {
  45512. code: result,
  45513. map: merge(map, ref.sourcemap),
  45514. errors: [],
  45515. dependencies
  45516. };
  45517. }
  45518. return { code: result, errors: [], dependencies };
  45519. } catch (e) {
  45520. return { code: "", errors: [e], dependencies: [] };
  45521. }
  45522. };
  45523. function getSource(source, filename, additionalData) {
  45524. if (!additionalData) return source;
  45525. if (isFunction$1(additionalData)) {
  45526. return additionalData(source, filename);
  45527. }
  45528. return additionalData + source;
  45529. }
  45530. const processors = {
  45531. less,
  45532. sass,
  45533. scss,
  45534. styl,
  45535. stylus: styl
  45536. };
  45537. var __defProp$4 = Object.defineProperty;
  45538. var __defProps$3 = Object.defineProperties;
  45539. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  45540. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  45541. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  45542. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  45543. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45544. var __spreadValues$4 = (a, b) => {
  45545. for (var prop in b || (b = {}))
  45546. if (__hasOwnProp$4.call(b, prop))
  45547. __defNormalProp$4(a, prop, b[prop]);
  45548. if (__getOwnPropSymbols$4)
  45549. for (var prop of __getOwnPropSymbols$4(b)) {
  45550. if (__propIsEnum$4.call(b, prop))
  45551. __defNormalProp$4(a, prop, b[prop]);
  45552. }
  45553. return a;
  45554. };
  45555. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  45556. function compileStyle(options) {
  45557. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  45558. isAsync: false
  45559. }));
  45560. }
  45561. function compileStyleAsync(options) {
  45562. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  45563. isAsync: true
  45564. }));
  45565. }
  45566. function doCompileStyle(options) {
  45567. const {
  45568. filename,
  45569. id,
  45570. scoped = false,
  45571. trim = true,
  45572. isProd = false,
  45573. modules = false,
  45574. modulesOptions = {},
  45575. preprocessLang,
  45576. postcssOptions,
  45577. postcssPlugins
  45578. } = options;
  45579. const preprocessor = preprocessLang && processors[preprocessLang];
  45580. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  45581. const map = preProcessedSource ? preProcessedSource.map : options.inMap || options.map;
  45582. const source = preProcessedSource ? preProcessedSource.code : options.source;
  45583. const shortId = id.replace(/^data-v-/, "");
  45584. const longId = `data-v-${shortId}`;
  45585. const plugins = (postcssPlugins || []).slice();
  45586. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  45587. if (trim) {
  45588. plugins.push(trimPlugin());
  45589. }
  45590. if (scoped) {
  45591. plugins.push(scopedPlugin(longId));
  45592. }
  45593. let cssModules;
  45594. if (modules) {
  45595. {
  45596. throw new Error(
  45597. "[@vue/compiler-sfc] `modules` option is not supported in the browser build."
  45598. );
  45599. }
  45600. }
  45601. const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
  45602. to: filename,
  45603. from: filename
  45604. });
  45605. if (map) {
  45606. postCSSOptions.map = {
  45607. inline: false,
  45608. annotation: false,
  45609. prev: map
  45610. };
  45611. }
  45612. let result;
  45613. let code;
  45614. let outMap;
  45615. const dependencies = new Set(
  45616. preProcessedSource ? preProcessedSource.dependencies : []
  45617. );
  45618. dependencies.delete(filename);
  45619. const errors = [];
  45620. if (preProcessedSource && preProcessedSource.errors.length) {
  45621. errors.push(...preProcessedSource.errors);
  45622. }
  45623. const recordPlainCssDependencies = (messages) => {
  45624. messages.forEach((msg) => {
  45625. if (msg.type === "dependency") {
  45626. dependencies.add(msg.file);
  45627. }
  45628. });
  45629. return dependencies;
  45630. };
  45631. try {
  45632. result = postcss(plugins).process(source, postCSSOptions);
  45633. if (options.isAsync) {
  45634. return result.then((result2) => ({
  45635. code: result2.css || "",
  45636. map: result2.map && result2.map.toJSON(),
  45637. errors,
  45638. modules: cssModules,
  45639. rawResult: result2,
  45640. dependencies: recordPlainCssDependencies(result2.messages)
  45641. })).catch((error) => ({
  45642. code: "",
  45643. map: void 0,
  45644. errors: [...errors, error],
  45645. rawResult: void 0,
  45646. dependencies
  45647. }));
  45648. }
  45649. recordPlainCssDependencies(result.messages);
  45650. code = result.css;
  45651. outMap = result.map;
  45652. } catch (e) {
  45653. errors.push(e);
  45654. }
  45655. return {
  45656. code: code || ``,
  45657. map: outMap && outMap.toJSON(),
  45658. errors,
  45659. rawResult: result,
  45660. dependencies
  45661. };
  45662. }
  45663. function preprocess(options, preprocessor) {
  45664. if (!options.preprocessCustomRequire) {
  45665. throw new Error(
  45666. `[@vue/compiler-sfc] Style preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor.`
  45667. );
  45668. }
  45669. return preprocessor(
  45670. options.source,
  45671. options.inMap || options.map,
  45672. __spreadValues$4({
  45673. filename: options.filename
  45674. }, options.preprocessOptions),
  45675. options.preprocessCustomRequire
  45676. );
  45677. }
  45678. const UNKNOWN_TYPE = "Unknown";
  45679. function resolveObjectKey(node, computed) {
  45680. switch (node.type) {
  45681. case "StringLiteral":
  45682. case "NumericLiteral":
  45683. return String(node.value);
  45684. case "Identifier":
  45685. if (!computed) return node.name;
  45686. }
  45687. return void 0;
  45688. }
  45689. function concatStrings(strs) {
  45690. return strs.filter((s) => !!s).join(", ");
  45691. }
  45692. function isLiteralNode(node) {
  45693. return node.type.endsWith("Literal");
  45694. }
  45695. function isCallOf(node, test) {
  45696. return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
  45697. }
  45698. function toRuntimeTypeString(types) {
  45699. return types.length > 1 ? `[${types.join(", ")}]` : types[0];
  45700. }
  45701. function getImportedName(specifier) {
  45702. if (specifier.type === "ImportSpecifier")
  45703. return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
  45704. else if (specifier.type === "ImportNamespaceSpecifier") return "*";
  45705. return "default";
  45706. }
  45707. function getId(node) {
  45708. return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
  45709. }
  45710. const normalize = (path.posix || path).normalize;
  45711. const windowsSlashRE = /\\/g;
  45712. function normalizePath(p) {
  45713. return normalize(p.replace(windowsSlashRE, "/"));
  45714. }
  45715. const joinPaths = (path.posix || path).join;
  45716. const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
  45717. function getEscapedPropName(key) {
  45718. return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
  45719. }
  45720. function analyzeScriptBindings(ast) {
  45721. for (const node of ast) {
  45722. if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
  45723. return analyzeBindingsFromOptions(node.declaration);
  45724. }
  45725. }
  45726. return {};
  45727. }
  45728. function analyzeBindingsFromOptions(node) {
  45729. const bindings = {};
  45730. Object.defineProperty(bindings, "__isScriptSetup", {
  45731. enumerable: false,
  45732. value: false
  45733. });
  45734. for (const property of node.properties) {
  45735. if (property.type === "ObjectProperty" && !property.computed && property.key.type === "Identifier") {
  45736. if (property.key.name === "props") {
  45737. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  45738. bindings[key] = "props";
  45739. }
  45740. } else if (property.key.name === "inject") {
  45741. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  45742. bindings[key] = "options";
  45743. }
  45744. } else if (property.value.type === "ObjectExpression" && (property.key.name === "computed" || property.key.name === "methods")) {
  45745. for (const key of getObjectExpressionKeys(property.value)) {
  45746. bindings[key] = "options";
  45747. }
  45748. }
  45749. } else if (property.type === "ObjectMethod" && property.key.type === "Identifier" && (property.key.name === "setup" || property.key.name === "data")) {
  45750. for (const bodyItem of property.body.body) {
  45751. if (bodyItem.type === "ReturnStatement" && bodyItem.argument && bodyItem.argument.type === "ObjectExpression") {
  45752. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  45753. bindings[key] = property.key.name === "setup" ? "setup-maybe-ref" : "data";
  45754. }
  45755. }
  45756. }
  45757. }
  45758. }
  45759. return bindings;
  45760. }
  45761. function getObjectExpressionKeys(node) {
  45762. const keys = [];
  45763. for (const prop of node.properties) {
  45764. if (prop.type === "SpreadElement") continue;
  45765. const key = resolveObjectKey(prop.key, prop.computed);
  45766. if (key) keys.push(String(key));
  45767. }
  45768. return keys;
  45769. }
  45770. function getArrayExpressionKeys(node) {
  45771. const keys = [];
  45772. for (const element of node.elements) {
  45773. if (element && element.type === "StringLiteral") {
  45774. keys.push(element.value);
  45775. }
  45776. }
  45777. return keys;
  45778. }
  45779. function getObjectOrArrayExpressionKeys(value) {
  45780. if (value.type === "ArrayExpression") {
  45781. return getArrayExpressionKeys(value);
  45782. }
  45783. if (value.type === "ObjectExpression") {
  45784. return getObjectExpressionKeys(value);
  45785. }
  45786. return [];
  45787. }
  45788. const comma = ','.charCodeAt(0);
  45789. const semicolon = ';'.charCodeAt(0);
  45790. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  45791. const intToChar = new Uint8Array(64); // 64 possible chars.
  45792. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  45793. for (let i = 0; i < chars.length; i++) {
  45794. const c = chars.charCodeAt(i);
  45795. intToChar[i] = c;
  45796. charToInt[c] = i;
  45797. }
  45798. function encodeInteger(builder, num, relative) {
  45799. let delta = num - relative;
  45800. delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
  45801. do {
  45802. let clamped = delta & 0b011111;
  45803. delta >>>= 5;
  45804. if (delta > 0)
  45805. clamped |= 0b100000;
  45806. builder.write(intToChar[clamped]);
  45807. } while (delta > 0);
  45808. return num;
  45809. }
  45810. const bufLength = 1024 * 16;
  45811. // Provide a fallback for older environments.
  45812. const td = typeof TextDecoder !== 'undefined'
  45813. ? /* #__PURE__ */ new TextDecoder()
  45814. : typeof Buffer !== 'undefined'
  45815. ? {
  45816. decode(buf) {
  45817. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  45818. return out.toString();
  45819. },
  45820. }
  45821. : {
  45822. decode(buf) {
  45823. let out = '';
  45824. for (let i = 0; i < buf.length; i++) {
  45825. out += String.fromCharCode(buf[i]);
  45826. }
  45827. return out;
  45828. },
  45829. };
  45830. class StringWriter {
  45831. constructor() {
  45832. this.pos = 0;
  45833. this.out = '';
  45834. this.buffer = new Uint8Array(bufLength);
  45835. }
  45836. write(v) {
  45837. const { buffer } = this;
  45838. buffer[this.pos++] = v;
  45839. if (this.pos === bufLength) {
  45840. this.out += td.decode(buffer);
  45841. this.pos = 0;
  45842. }
  45843. }
  45844. flush() {
  45845. const { buffer, out, pos } = this;
  45846. return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
  45847. }
  45848. }
  45849. function encode(decoded) {
  45850. const writer = new StringWriter();
  45851. let sourcesIndex = 0;
  45852. let sourceLine = 0;
  45853. let sourceColumn = 0;
  45854. let namesIndex = 0;
  45855. for (let i = 0; i < decoded.length; i++) {
  45856. const line = decoded[i];
  45857. if (i > 0)
  45858. writer.write(semicolon);
  45859. if (line.length === 0)
  45860. continue;
  45861. let genColumn = 0;
  45862. for (let j = 0; j < line.length; j++) {
  45863. const segment = line[j];
  45864. if (j > 0)
  45865. writer.write(comma);
  45866. genColumn = encodeInteger(writer, segment[0], genColumn);
  45867. if (segment.length === 1)
  45868. continue;
  45869. sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
  45870. sourceLine = encodeInteger(writer, segment[2], sourceLine);
  45871. sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
  45872. if (segment.length === 4)
  45873. continue;
  45874. namesIndex = encodeInteger(writer, segment[4], namesIndex);
  45875. }
  45876. }
  45877. return writer.flush();
  45878. }
  45879. class BitSet {
  45880. constructor(arg) {
  45881. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  45882. }
  45883. add(n) {
  45884. this.bits[n >> 5] |= 1 << (n & 31);
  45885. }
  45886. has(n) {
  45887. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  45888. }
  45889. }
  45890. class Chunk {
  45891. constructor(start, end, content) {
  45892. this.start = start;
  45893. this.end = end;
  45894. this.original = content;
  45895. this.intro = '';
  45896. this.outro = '';
  45897. this.content = content;
  45898. this.storeName = false;
  45899. this.edited = false;
  45900. {
  45901. this.previous = null;
  45902. this.next = null;
  45903. }
  45904. }
  45905. appendLeft(content) {
  45906. this.outro += content;
  45907. }
  45908. appendRight(content) {
  45909. this.intro = this.intro + content;
  45910. }
  45911. clone() {
  45912. const chunk = new Chunk(this.start, this.end, this.original);
  45913. chunk.intro = this.intro;
  45914. chunk.outro = this.outro;
  45915. chunk.content = this.content;
  45916. chunk.storeName = this.storeName;
  45917. chunk.edited = this.edited;
  45918. return chunk;
  45919. }
  45920. contains(index) {
  45921. return this.start < index && index < this.end;
  45922. }
  45923. eachNext(fn) {
  45924. let chunk = this;
  45925. while (chunk) {
  45926. fn(chunk);
  45927. chunk = chunk.next;
  45928. }
  45929. }
  45930. eachPrevious(fn) {
  45931. let chunk = this;
  45932. while (chunk) {
  45933. fn(chunk);
  45934. chunk = chunk.previous;
  45935. }
  45936. }
  45937. edit(content, storeName, contentOnly) {
  45938. this.content = content;
  45939. if (!contentOnly) {
  45940. this.intro = '';
  45941. this.outro = '';
  45942. }
  45943. this.storeName = storeName;
  45944. this.edited = true;
  45945. return this;
  45946. }
  45947. prependLeft(content) {
  45948. this.outro = content + this.outro;
  45949. }
  45950. prependRight(content) {
  45951. this.intro = content + this.intro;
  45952. }
  45953. reset() {
  45954. this.intro = '';
  45955. this.outro = '';
  45956. if (this.edited) {
  45957. this.content = this.original;
  45958. this.storeName = false;
  45959. this.edited = false;
  45960. }
  45961. }
  45962. split(index) {
  45963. const sliceIndex = index - this.start;
  45964. const originalBefore = this.original.slice(0, sliceIndex);
  45965. const originalAfter = this.original.slice(sliceIndex);
  45966. this.original = originalBefore;
  45967. const newChunk = new Chunk(index, this.end, originalAfter);
  45968. newChunk.outro = this.outro;
  45969. this.outro = '';
  45970. this.end = index;
  45971. if (this.edited) {
  45972. // after split we should save the edit content record into the correct chunk
  45973. // to make sure sourcemap correct
  45974. // For example:
  45975. // ' test'.trim()
  45976. // split -> ' ' + 'test'
  45977. // ✔️ edit -> '' + 'test'
  45978. // ✖️ edit -> 'test' + ''
  45979. // TODO is this block necessary?...
  45980. newChunk.edit('', false);
  45981. this.content = '';
  45982. } else {
  45983. this.content = originalBefore;
  45984. }
  45985. newChunk.next = this.next;
  45986. if (newChunk.next) newChunk.next.previous = newChunk;
  45987. newChunk.previous = this;
  45988. this.next = newChunk;
  45989. return newChunk;
  45990. }
  45991. toString() {
  45992. return this.intro + this.content + this.outro;
  45993. }
  45994. trimEnd(rx) {
  45995. this.outro = this.outro.replace(rx, '');
  45996. if (this.outro.length) return true;
  45997. const trimmed = this.content.replace(rx, '');
  45998. if (trimmed.length) {
  45999. if (trimmed !== this.content) {
  46000. this.split(this.start + trimmed.length).edit('', undefined, true);
  46001. if (this.edited) {
  46002. // save the change, if it has been edited
  46003. this.edit(trimmed, this.storeName, true);
  46004. }
  46005. }
  46006. return true;
  46007. } else {
  46008. this.edit('', undefined, true);
  46009. this.intro = this.intro.replace(rx, '');
  46010. if (this.intro.length) return true;
  46011. }
  46012. }
  46013. trimStart(rx) {
  46014. this.intro = this.intro.replace(rx, '');
  46015. if (this.intro.length) return true;
  46016. const trimmed = this.content.replace(rx, '');
  46017. if (trimmed.length) {
  46018. if (trimmed !== this.content) {
  46019. const newChunk = this.split(this.end - trimmed.length);
  46020. if (this.edited) {
  46021. // save the change, if it has been edited
  46022. newChunk.edit(trimmed, this.storeName, true);
  46023. }
  46024. this.edit('', undefined, true);
  46025. }
  46026. return true;
  46027. } else {
  46028. this.edit('', undefined, true);
  46029. this.outro = this.outro.replace(rx, '');
  46030. if (this.outro.length) return true;
  46031. }
  46032. }
  46033. }
  46034. function getBtoa() {
  46035. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  46036. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  46037. } else if (typeof Buffer === 'function') {
  46038. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  46039. } else {
  46040. return () => {
  46041. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  46042. };
  46043. }
  46044. }
  46045. const btoa = /*#__PURE__*/ getBtoa();
  46046. class SourceMap {
  46047. constructor(properties) {
  46048. this.version = 3;
  46049. this.file = properties.file;
  46050. this.sources = properties.sources;
  46051. this.sourcesContent = properties.sourcesContent;
  46052. this.names = properties.names;
  46053. this.mappings = encode(properties.mappings);
  46054. if (typeof properties.x_google_ignoreList !== 'undefined') {
  46055. this.x_google_ignoreList = properties.x_google_ignoreList;
  46056. }
  46057. }
  46058. toString() {
  46059. return JSON.stringify(this);
  46060. }
  46061. toUrl() {
  46062. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  46063. }
  46064. }
  46065. function guessIndent(code) {
  46066. const lines = code.split('\n');
  46067. const tabbed = lines.filter((line) => /^\t+/.test(line));
  46068. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  46069. if (tabbed.length === 0 && spaced.length === 0) {
  46070. return null;
  46071. }
  46072. // More lines tabbed than spaced? Assume tabs, and
  46073. // default to tabs in the case of a tie (or nothing
  46074. // to go on)
  46075. if (tabbed.length >= spaced.length) {
  46076. return '\t';
  46077. }
  46078. // Otherwise, we need to guess the multiple
  46079. const min = spaced.reduce((previous, current) => {
  46080. const numSpaces = /^ +/.exec(current)[0].length;
  46081. return Math.min(numSpaces, previous);
  46082. }, Infinity);
  46083. return new Array(min + 1).join(' ');
  46084. }
  46085. function getRelativePath(from, to) {
  46086. const fromParts = from.split(/[/\\]/);
  46087. const toParts = to.split(/[/\\]/);
  46088. fromParts.pop(); // get dirname
  46089. while (fromParts[0] === toParts[0]) {
  46090. fromParts.shift();
  46091. toParts.shift();
  46092. }
  46093. if (fromParts.length) {
  46094. let i = fromParts.length;
  46095. while (i--) fromParts[i] = '..';
  46096. }
  46097. return fromParts.concat(toParts).join('/');
  46098. }
  46099. const toString = Object.prototype.toString;
  46100. function isObject(thing) {
  46101. return toString.call(thing) === '[object Object]';
  46102. }
  46103. function getLocator(source) {
  46104. const originalLines = source.split('\n');
  46105. const lineOffsets = [];
  46106. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  46107. lineOffsets.push(pos);
  46108. pos += originalLines[i].length + 1;
  46109. }
  46110. return function locate(index) {
  46111. let i = 0;
  46112. let j = lineOffsets.length;
  46113. while (i < j) {
  46114. const m = (i + j) >> 1;
  46115. if (index < lineOffsets[m]) {
  46116. j = m;
  46117. } else {
  46118. i = m + 1;
  46119. }
  46120. }
  46121. const line = i - 1;
  46122. const column = index - lineOffsets[line];
  46123. return { line, column };
  46124. };
  46125. }
  46126. const wordRegex = /\w/;
  46127. class Mappings {
  46128. constructor(hires) {
  46129. this.hires = hires;
  46130. this.generatedCodeLine = 0;
  46131. this.generatedCodeColumn = 0;
  46132. this.raw = [];
  46133. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  46134. this.pending = null;
  46135. }
  46136. addEdit(sourceIndex, content, loc, nameIndex) {
  46137. if (content.length) {
  46138. const contentLengthMinusOne = content.length - 1;
  46139. let contentLineEnd = content.indexOf('\n', 0);
  46140. let previousContentLineEnd = -1;
  46141. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  46142. // else code afterwards would fill one line too many
  46143. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  46144. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  46145. if (nameIndex >= 0) {
  46146. segment.push(nameIndex);
  46147. }
  46148. this.rawSegments.push(segment);
  46149. this.generatedCodeLine += 1;
  46150. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  46151. this.generatedCodeColumn = 0;
  46152. previousContentLineEnd = contentLineEnd;
  46153. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  46154. }
  46155. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  46156. if (nameIndex >= 0) {
  46157. segment.push(nameIndex);
  46158. }
  46159. this.rawSegments.push(segment);
  46160. this.advance(content.slice(previousContentLineEnd + 1));
  46161. } else if (this.pending) {
  46162. this.rawSegments.push(this.pending);
  46163. this.advance(content);
  46164. }
  46165. this.pending = null;
  46166. }
  46167. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  46168. let originalCharIndex = chunk.start;
  46169. let first = true;
  46170. // when iterating each char, check if it's in a word boundary
  46171. let charInHiresBoundary = false;
  46172. while (originalCharIndex < chunk.end) {
  46173. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  46174. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  46175. if (this.hires === 'boundary') {
  46176. // in hires "boundary", group segments per word boundary than per char
  46177. if (wordRegex.test(original[originalCharIndex])) {
  46178. // for first char in the boundary found, start the boundary by pushing a segment
  46179. if (!charInHiresBoundary) {
  46180. this.rawSegments.push(segment);
  46181. charInHiresBoundary = true;
  46182. }
  46183. } else {
  46184. // for non-word char, end the boundary by pushing a segment
  46185. this.rawSegments.push(segment);
  46186. charInHiresBoundary = false;
  46187. }
  46188. } else {
  46189. this.rawSegments.push(segment);
  46190. }
  46191. }
  46192. if (original[originalCharIndex] === '\n') {
  46193. loc.line += 1;
  46194. loc.column = 0;
  46195. this.generatedCodeLine += 1;
  46196. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  46197. this.generatedCodeColumn = 0;
  46198. first = true;
  46199. } else {
  46200. loc.column += 1;
  46201. this.generatedCodeColumn += 1;
  46202. first = false;
  46203. }
  46204. originalCharIndex += 1;
  46205. }
  46206. this.pending = null;
  46207. }
  46208. advance(str) {
  46209. if (!str) return;
  46210. const lines = str.split('\n');
  46211. if (lines.length > 1) {
  46212. for (let i = 0; i < lines.length - 1; i++) {
  46213. this.generatedCodeLine++;
  46214. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  46215. }
  46216. this.generatedCodeColumn = 0;
  46217. }
  46218. this.generatedCodeColumn += lines[lines.length - 1].length;
  46219. }
  46220. }
  46221. const n = '\n';
  46222. const warned = {
  46223. insertLeft: false,
  46224. insertRight: false,
  46225. storeName: false,
  46226. };
  46227. class MagicString {
  46228. constructor(string, options = {}) {
  46229. const chunk = new Chunk(0, string.length, string);
  46230. Object.defineProperties(this, {
  46231. original: { writable: true, value: string },
  46232. outro: { writable: true, value: '' },
  46233. intro: { writable: true, value: '' },
  46234. firstChunk: { writable: true, value: chunk },
  46235. lastChunk: { writable: true, value: chunk },
  46236. lastSearchedChunk: { writable: true, value: chunk },
  46237. byStart: { writable: true, value: {} },
  46238. byEnd: { writable: true, value: {} },
  46239. filename: { writable: true, value: options.filename },
  46240. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  46241. sourcemapLocations: { writable: true, value: new BitSet() },
  46242. storedNames: { writable: true, value: {} },
  46243. indentStr: { writable: true, value: undefined },
  46244. ignoreList: { writable: true, value: options.ignoreList },
  46245. });
  46246. this.byStart[0] = chunk;
  46247. this.byEnd[string.length] = chunk;
  46248. }
  46249. addSourcemapLocation(char) {
  46250. this.sourcemapLocations.add(char);
  46251. }
  46252. append(content) {
  46253. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  46254. this.outro += content;
  46255. return this;
  46256. }
  46257. appendLeft(index, content) {
  46258. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46259. this._split(index);
  46260. const chunk = this.byEnd[index];
  46261. if (chunk) {
  46262. chunk.appendLeft(content);
  46263. } else {
  46264. this.intro += content;
  46265. }
  46266. return this;
  46267. }
  46268. appendRight(index, content) {
  46269. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46270. this._split(index);
  46271. const chunk = this.byStart[index];
  46272. if (chunk) {
  46273. chunk.appendRight(content);
  46274. } else {
  46275. this.outro += content;
  46276. }
  46277. return this;
  46278. }
  46279. clone() {
  46280. const cloned = new MagicString(this.original, { filename: this.filename });
  46281. let originalChunk = this.firstChunk;
  46282. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  46283. while (originalChunk) {
  46284. cloned.byStart[clonedChunk.start] = clonedChunk;
  46285. cloned.byEnd[clonedChunk.end] = clonedChunk;
  46286. const nextOriginalChunk = originalChunk.next;
  46287. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  46288. if (nextClonedChunk) {
  46289. clonedChunk.next = nextClonedChunk;
  46290. nextClonedChunk.previous = clonedChunk;
  46291. clonedChunk = nextClonedChunk;
  46292. }
  46293. originalChunk = nextOriginalChunk;
  46294. }
  46295. cloned.lastChunk = clonedChunk;
  46296. if (this.indentExclusionRanges) {
  46297. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  46298. }
  46299. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  46300. cloned.intro = this.intro;
  46301. cloned.outro = this.outro;
  46302. return cloned;
  46303. }
  46304. generateDecodedMap(options) {
  46305. options = options || {};
  46306. const sourceIndex = 0;
  46307. const names = Object.keys(this.storedNames);
  46308. const mappings = new Mappings(options.hires);
  46309. const locate = getLocator(this.original);
  46310. if (this.intro) {
  46311. mappings.advance(this.intro);
  46312. }
  46313. this.firstChunk.eachNext((chunk) => {
  46314. const loc = locate(chunk.start);
  46315. if (chunk.intro.length) mappings.advance(chunk.intro);
  46316. if (chunk.edited) {
  46317. mappings.addEdit(
  46318. sourceIndex,
  46319. chunk.content,
  46320. loc,
  46321. chunk.storeName ? names.indexOf(chunk.original) : -1,
  46322. );
  46323. } else {
  46324. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  46325. }
  46326. if (chunk.outro.length) mappings.advance(chunk.outro);
  46327. });
  46328. return {
  46329. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  46330. sources: [
  46331. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  46332. ],
  46333. sourcesContent: options.includeContent ? [this.original] : undefined,
  46334. names,
  46335. mappings: mappings.raw,
  46336. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  46337. };
  46338. }
  46339. generateMap(options) {
  46340. return new SourceMap(this.generateDecodedMap(options));
  46341. }
  46342. _ensureindentStr() {
  46343. if (this.indentStr === undefined) {
  46344. this.indentStr = guessIndent(this.original);
  46345. }
  46346. }
  46347. _getRawIndentString() {
  46348. this._ensureindentStr();
  46349. return this.indentStr;
  46350. }
  46351. getIndentString() {
  46352. this._ensureindentStr();
  46353. return this.indentStr === null ? '\t' : this.indentStr;
  46354. }
  46355. indent(indentStr, options) {
  46356. const pattern = /^[^\r\n]/gm;
  46357. if (isObject(indentStr)) {
  46358. options = indentStr;
  46359. indentStr = undefined;
  46360. }
  46361. if (indentStr === undefined) {
  46362. this._ensureindentStr();
  46363. indentStr = this.indentStr || '\t';
  46364. }
  46365. if (indentStr === '') return this; // noop
  46366. options = options || {};
  46367. // Process exclusion ranges
  46368. const isExcluded = {};
  46369. if (options.exclude) {
  46370. const exclusions =
  46371. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  46372. exclusions.forEach((exclusion) => {
  46373. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  46374. isExcluded[i] = true;
  46375. }
  46376. });
  46377. }
  46378. let shouldIndentNextCharacter = options.indentStart !== false;
  46379. const replacer = (match) => {
  46380. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  46381. shouldIndentNextCharacter = true;
  46382. return match;
  46383. };
  46384. this.intro = this.intro.replace(pattern, replacer);
  46385. let charIndex = 0;
  46386. let chunk = this.firstChunk;
  46387. while (chunk) {
  46388. const end = chunk.end;
  46389. if (chunk.edited) {
  46390. if (!isExcluded[charIndex]) {
  46391. chunk.content = chunk.content.replace(pattern, replacer);
  46392. if (chunk.content.length) {
  46393. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  46394. }
  46395. }
  46396. } else {
  46397. charIndex = chunk.start;
  46398. while (charIndex < end) {
  46399. if (!isExcluded[charIndex]) {
  46400. const char = this.original[charIndex];
  46401. if (char === '\n') {
  46402. shouldIndentNextCharacter = true;
  46403. } else if (char !== '\r' && shouldIndentNextCharacter) {
  46404. shouldIndentNextCharacter = false;
  46405. if (charIndex === chunk.start) {
  46406. chunk.prependRight(indentStr);
  46407. } else {
  46408. this._splitChunk(chunk, charIndex);
  46409. chunk = chunk.next;
  46410. chunk.prependRight(indentStr);
  46411. }
  46412. }
  46413. }
  46414. charIndex += 1;
  46415. }
  46416. }
  46417. charIndex = chunk.end;
  46418. chunk = chunk.next;
  46419. }
  46420. this.outro = this.outro.replace(pattern, replacer);
  46421. return this;
  46422. }
  46423. insert() {
  46424. throw new Error(
  46425. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  46426. );
  46427. }
  46428. insertLeft(index, content) {
  46429. if (!warned.insertLeft) {
  46430. console.warn(
  46431. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  46432. ); // eslint-disable-line no-console
  46433. warned.insertLeft = true;
  46434. }
  46435. return this.appendLeft(index, content);
  46436. }
  46437. insertRight(index, content) {
  46438. if (!warned.insertRight) {
  46439. console.warn(
  46440. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  46441. ); // eslint-disable-line no-console
  46442. warned.insertRight = true;
  46443. }
  46444. return this.prependRight(index, content);
  46445. }
  46446. move(start, end, index) {
  46447. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  46448. this._split(start);
  46449. this._split(end);
  46450. this._split(index);
  46451. const first = this.byStart[start];
  46452. const last = this.byEnd[end];
  46453. const oldLeft = first.previous;
  46454. const oldRight = last.next;
  46455. const newRight = this.byStart[index];
  46456. if (!newRight && last === this.lastChunk) return this;
  46457. const newLeft = newRight ? newRight.previous : this.lastChunk;
  46458. if (oldLeft) oldLeft.next = oldRight;
  46459. if (oldRight) oldRight.previous = oldLeft;
  46460. if (newLeft) newLeft.next = first;
  46461. if (newRight) newRight.previous = last;
  46462. if (!first.previous) this.firstChunk = last.next;
  46463. if (!last.next) {
  46464. this.lastChunk = first.previous;
  46465. this.lastChunk.next = null;
  46466. }
  46467. first.previous = newLeft;
  46468. last.next = newRight || null;
  46469. if (!newLeft) this.firstChunk = first;
  46470. if (!newRight) this.lastChunk = last;
  46471. return this;
  46472. }
  46473. overwrite(start, end, content, options) {
  46474. options = options || {};
  46475. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  46476. }
  46477. update(start, end, content, options) {
  46478. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  46479. if (this.original.length !== 0) {
  46480. while (start < 0) start += this.original.length;
  46481. while (end < 0) end += this.original.length;
  46482. }
  46483. if (end > this.original.length) throw new Error('end is out of bounds');
  46484. if (start === end)
  46485. throw new Error(
  46486. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  46487. );
  46488. this._split(start);
  46489. this._split(end);
  46490. if (options === true) {
  46491. if (!warned.storeName) {
  46492. console.warn(
  46493. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  46494. ); // eslint-disable-line no-console
  46495. warned.storeName = true;
  46496. }
  46497. options = { storeName: true };
  46498. }
  46499. const storeName = options !== undefined ? options.storeName : false;
  46500. const overwrite = options !== undefined ? options.overwrite : false;
  46501. if (storeName) {
  46502. const original = this.original.slice(start, end);
  46503. Object.defineProperty(this.storedNames, original, {
  46504. writable: true,
  46505. value: true,
  46506. enumerable: true,
  46507. });
  46508. }
  46509. const first = this.byStart[start];
  46510. const last = this.byEnd[end];
  46511. if (first) {
  46512. let chunk = first;
  46513. while (chunk !== last) {
  46514. if (chunk.next !== this.byStart[chunk.end]) {
  46515. throw new Error('Cannot overwrite across a split point');
  46516. }
  46517. chunk = chunk.next;
  46518. chunk.edit('', false);
  46519. }
  46520. first.edit(content, storeName, !overwrite);
  46521. } else {
  46522. // must be inserting at the end
  46523. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  46524. // TODO last chunk in the array may not be the last chunk, if it's moved...
  46525. last.next = newChunk;
  46526. newChunk.previous = last;
  46527. }
  46528. return this;
  46529. }
  46530. prepend(content) {
  46531. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  46532. this.intro = content + this.intro;
  46533. return this;
  46534. }
  46535. prependLeft(index, content) {
  46536. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46537. this._split(index);
  46538. const chunk = this.byEnd[index];
  46539. if (chunk) {
  46540. chunk.prependLeft(content);
  46541. } else {
  46542. this.intro = content + this.intro;
  46543. }
  46544. return this;
  46545. }
  46546. prependRight(index, content) {
  46547. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  46548. this._split(index);
  46549. const chunk = this.byStart[index];
  46550. if (chunk) {
  46551. chunk.prependRight(content);
  46552. } else {
  46553. this.outro = content + this.outro;
  46554. }
  46555. return this;
  46556. }
  46557. remove(start, end) {
  46558. if (this.original.length !== 0) {
  46559. while (start < 0) start += this.original.length;
  46560. while (end < 0) end += this.original.length;
  46561. }
  46562. if (start === end) return this;
  46563. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  46564. if (start > end) throw new Error('end must be greater than start');
  46565. this._split(start);
  46566. this._split(end);
  46567. let chunk = this.byStart[start];
  46568. while (chunk) {
  46569. chunk.intro = '';
  46570. chunk.outro = '';
  46571. chunk.edit('');
  46572. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  46573. }
  46574. return this;
  46575. }
  46576. reset(start, end) {
  46577. if (this.original.length !== 0) {
  46578. while (start < 0) start += this.original.length;
  46579. while (end < 0) end += this.original.length;
  46580. }
  46581. if (start === end) return this;
  46582. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  46583. if (start > end) throw new Error('end must be greater than start');
  46584. this._split(start);
  46585. this._split(end);
  46586. let chunk = this.byStart[start];
  46587. while (chunk) {
  46588. chunk.reset();
  46589. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  46590. }
  46591. return this;
  46592. }
  46593. lastChar() {
  46594. if (this.outro.length) return this.outro[this.outro.length - 1];
  46595. let chunk = this.lastChunk;
  46596. do {
  46597. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  46598. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  46599. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  46600. } while ((chunk = chunk.previous));
  46601. if (this.intro.length) return this.intro[this.intro.length - 1];
  46602. return '';
  46603. }
  46604. lastLine() {
  46605. let lineIndex = this.outro.lastIndexOf(n);
  46606. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  46607. let lineStr = this.outro;
  46608. let chunk = this.lastChunk;
  46609. do {
  46610. if (chunk.outro.length > 0) {
  46611. lineIndex = chunk.outro.lastIndexOf(n);
  46612. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  46613. lineStr = chunk.outro + lineStr;
  46614. }
  46615. if (chunk.content.length > 0) {
  46616. lineIndex = chunk.content.lastIndexOf(n);
  46617. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  46618. lineStr = chunk.content + lineStr;
  46619. }
  46620. if (chunk.intro.length > 0) {
  46621. lineIndex = chunk.intro.lastIndexOf(n);
  46622. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  46623. lineStr = chunk.intro + lineStr;
  46624. }
  46625. } while ((chunk = chunk.previous));
  46626. lineIndex = this.intro.lastIndexOf(n);
  46627. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  46628. return this.intro + lineStr;
  46629. }
  46630. slice(start = 0, end = this.original.length) {
  46631. if (this.original.length !== 0) {
  46632. while (start < 0) start += this.original.length;
  46633. while (end < 0) end += this.original.length;
  46634. }
  46635. let result = '';
  46636. // find start chunk
  46637. let chunk = this.firstChunk;
  46638. while (chunk && (chunk.start > start || chunk.end <= start)) {
  46639. // found end chunk before start
  46640. if (chunk.start < end && chunk.end >= end) {
  46641. return result;
  46642. }
  46643. chunk = chunk.next;
  46644. }
  46645. if (chunk && chunk.edited && chunk.start !== start)
  46646. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  46647. const startChunk = chunk;
  46648. while (chunk) {
  46649. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  46650. result += chunk.intro;
  46651. }
  46652. const containsEnd = chunk.start < end && chunk.end >= end;
  46653. if (containsEnd && chunk.edited && chunk.end !== end)
  46654. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  46655. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  46656. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  46657. result += chunk.content.slice(sliceStart, sliceEnd);
  46658. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  46659. result += chunk.outro;
  46660. }
  46661. if (containsEnd) {
  46662. break;
  46663. }
  46664. chunk = chunk.next;
  46665. }
  46666. return result;
  46667. }
  46668. // TODO deprecate this? not really very useful
  46669. snip(start, end) {
  46670. const clone = this.clone();
  46671. clone.remove(0, start);
  46672. clone.remove(end, clone.original.length);
  46673. return clone;
  46674. }
  46675. _split(index) {
  46676. if (this.byStart[index] || this.byEnd[index]) return;
  46677. let chunk = this.lastSearchedChunk;
  46678. const searchForward = index > chunk.end;
  46679. while (chunk) {
  46680. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  46681. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  46682. }
  46683. }
  46684. _splitChunk(chunk, index) {
  46685. if (chunk.edited && chunk.content.length) {
  46686. // zero-length edited chunks are a special case (overlapping replacements)
  46687. const loc = getLocator(this.original)(index);
  46688. throw new Error(
  46689. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  46690. );
  46691. }
  46692. const newChunk = chunk.split(index);
  46693. this.byEnd[index] = chunk;
  46694. this.byStart[index] = newChunk;
  46695. this.byEnd[newChunk.end] = newChunk;
  46696. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  46697. this.lastSearchedChunk = chunk;
  46698. return true;
  46699. }
  46700. toString() {
  46701. let str = this.intro;
  46702. let chunk = this.firstChunk;
  46703. while (chunk) {
  46704. str += chunk.toString();
  46705. chunk = chunk.next;
  46706. }
  46707. return str + this.outro;
  46708. }
  46709. isEmpty() {
  46710. let chunk = this.firstChunk;
  46711. do {
  46712. if (
  46713. (chunk.intro.length && chunk.intro.trim()) ||
  46714. (chunk.content.length && chunk.content.trim()) ||
  46715. (chunk.outro.length && chunk.outro.trim())
  46716. )
  46717. return false;
  46718. } while ((chunk = chunk.next));
  46719. return true;
  46720. }
  46721. length() {
  46722. let chunk = this.firstChunk;
  46723. let length = 0;
  46724. do {
  46725. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  46726. } while ((chunk = chunk.next));
  46727. return length;
  46728. }
  46729. trimLines() {
  46730. return this.trim('[\\r\\n]');
  46731. }
  46732. trim(charType) {
  46733. return this.trimStart(charType).trimEnd(charType);
  46734. }
  46735. trimEndAborted(charType) {
  46736. const rx = new RegExp((charType || '\\s') + '+$');
  46737. this.outro = this.outro.replace(rx, '');
  46738. if (this.outro.length) return true;
  46739. let chunk = this.lastChunk;
  46740. do {
  46741. const end = chunk.end;
  46742. const aborted = chunk.trimEnd(rx);
  46743. // if chunk was trimmed, we have a new lastChunk
  46744. if (chunk.end !== end) {
  46745. if (this.lastChunk === chunk) {
  46746. this.lastChunk = chunk.next;
  46747. }
  46748. this.byEnd[chunk.end] = chunk;
  46749. this.byStart[chunk.next.start] = chunk.next;
  46750. this.byEnd[chunk.next.end] = chunk.next;
  46751. }
  46752. if (aborted) return true;
  46753. chunk = chunk.previous;
  46754. } while (chunk);
  46755. return false;
  46756. }
  46757. trimEnd(charType) {
  46758. this.trimEndAborted(charType);
  46759. return this;
  46760. }
  46761. trimStartAborted(charType) {
  46762. const rx = new RegExp('^' + (charType || '\\s') + '+');
  46763. this.intro = this.intro.replace(rx, '');
  46764. if (this.intro.length) return true;
  46765. let chunk = this.firstChunk;
  46766. do {
  46767. const end = chunk.end;
  46768. const aborted = chunk.trimStart(rx);
  46769. if (chunk.end !== end) {
  46770. // special case...
  46771. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  46772. this.byEnd[chunk.end] = chunk;
  46773. this.byStart[chunk.next.start] = chunk.next;
  46774. this.byEnd[chunk.next.end] = chunk.next;
  46775. }
  46776. if (aborted) return true;
  46777. chunk = chunk.next;
  46778. } while (chunk);
  46779. return false;
  46780. }
  46781. trimStart(charType) {
  46782. this.trimStartAborted(charType);
  46783. return this;
  46784. }
  46785. hasChanged() {
  46786. return this.original !== this.toString();
  46787. }
  46788. _replaceRegexp(searchValue, replacement) {
  46789. function getReplacement(match, str) {
  46790. if (typeof replacement === 'string') {
  46791. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  46792. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  46793. if (i === '$') return '$';
  46794. if (i === '&') return match[0];
  46795. const num = +i;
  46796. if (num < match.length) return match[+i];
  46797. return `$${i}`;
  46798. });
  46799. } else {
  46800. return replacement(...match, match.index, str, match.groups);
  46801. }
  46802. }
  46803. function matchAll(re, str) {
  46804. let match;
  46805. const matches = [];
  46806. while ((match = re.exec(str))) {
  46807. matches.push(match);
  46808. }
  46809. return matches;
  46810. }
  46811. if (searchValue.global) {
  46812. const matches = matchAll(searchValue, this.original);
  46813. matches.forEach((match) => {
  46814. if (match.index != null) {
  46815. const replacement = getReplacement(match, this.original);
  46816. if (replacement !== match[0]) {
  46817. this.overwrite(
  46818. match.index,
  46819. match.index + match[0].length,
  46820. replacement
  46821. );
  46822. }
  46823. }
  46824. });
  46825. } else {
  46826. const match = this.original.match(searchValue);
  46827. if (match && match.index != null) {
  46828. const replacement = getReplacement(match, this.original);
  46829. if (replacement !== match[0]) {
  46830. this.overwrite(
  46831. match.index,
  46832. match.index + match[0].length,
  46833. replacement
  46834. );
  46835. }
  46836. }
  46837. }
  46838. return this;
  46839. }
  46840. _replaceString(string, replacement) {
  46841. const { original } = this;
  46842. const index = original.indexOf(string);
  46843. if (index !== -1) {
  46844. this.overwrite(index, index + string.length, replacement);
  46845. }
  46846. return this;
  46847. }
  46848. replace(searchValue, replacement) {
  46849. if (typeof searchValue === 'string') {
  46850. return this._replaceString(searchValue, replacement);
  46851. }
  46852. return this._replaceRegexp(searchValue, replacement);
  46853. }
  46854. _replaceAllString(string, replacement) {
  46855. const { original } = this;
  46856. const stringLength = string.length;
  46857. for (
  46858. let index = original.indexOf(string);
  46859. index !== -1;
  46860. index = original.indexOf(string, index + stringLength)
  46861. ) {
  46862. const previous = original.slice(index, index + stringLength);
  46863. if (previous !== replacement)
  46864. this.overwrite(index, index + stringLength, replacement);
  46865. }
  46866. return this;
  46867. }
  46868. replaceAll(searchValue, replacement) {
  46869. if (typeof searchValue === 'string') {
  46870. return this._replaceAllString(searchValue, replacement);
  46871. }
  46872. if (!searchValue.global) {
  46873. throw new TypeError(
  46874. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  46875. );
  46876. }
  46877. return this._replaceRegexp(searchValue, replacement);
  46878. }
  46879. }
  46880. var _a, _b;
  46881. class ScriptCompileContext {
  46882. constructor(descriptor, options) {
  46883. this.descriptor = descriptor;
  46884. this.options = options;
  46885. this.isCE = false;
  46886. this.source = this.descriptor.source;
  46887. this.filename = this.descriptor.filename;
  46888. this.s = new MagicString(this.source);
  46889. this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
  46890. this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
  46891. this.userImports = /* @__PURE__ */ Object.create(null);
  46892. // macros presence check
  46893. this.hasDefinePropsCall = false;
  46894. this.hasDefineEmitCall = false;
  46895. this.hasDefineExposeCall = false;
  46896. this.hasDefaultExportName = false;
  46897. this.hasDefaultExportRender = false;
  46898. this.hasDefineOptionsCall = false;
  46899. this.hasDefineSlotsCall = false;
  46900. this.hasDefineModelCall = false;
  46901. this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
  46902. // defineModel
  46903. this.modelDecls = /* @__PURE__ */ Object.create(null);
  46904. // codegen
  46905. this.bindingMetadata = {};
  46906. this.helperImports = /* @__PURE__ */ new Set();
  46907. const { script, scriptSetup } = descriptor;
  46908. const scriptLang = script && script.lang;
  46909. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  46910. this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
  46911. this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
  46912. const customElement = options.customElement;
  46913. const filename = this.descriptor.filename;
  46914. if (customElement) {
  46915. this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
  46916. }
  46917. const plugins = resolveParserPlugins(
  46918. scriptLang || scriptSetupLang,
  46919. options.babelParserPlugins
  46920. );
  46921. function parse(input, offset) {
  46922. try {
  46923. return libExports.parse(input, {
  46924. plugins,
  46925. sourceType: "module"
  46926. }).program;
  46927. } catch (e) {
  46928. e.message = `[vue/compiler-sfc] ${e.message}
  46929. ${descriptor.filename}
  46930. ${generateCodeFrame(
  46931. descriptor.source,
  46932. e.pos + offset,
  46933. e.pos + offset + 1
  46934. )}`;
  46935. throw e;
  46936. }
  46937. }
  46938. this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
  46939. this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
  46940. }
  46941. helper(key) {
  46942. this.helperImports.add(key);
  46943. return `_${key}`;
  46944. }
  46945. getString(node, scriptSetup = true) {
  46946. const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
  46947. return block.content.slice(node.start, node.end);
  46948. }
  46949. warn(msg, node, scope) {
  46950. warn(generateError(msg, node, this, scope));
  46951. }
  46952. error(msg, node, scope) {
  46953. throw new Error(
  46954. `[@vue/compiler-sfc] ${generateError(msg, node, this, scope)}`
  46955. );
  46956. }
  46957. }
  46958. function generateError(msg, node, ctx, scope) {
  46959. const offset = scope ? scope.offset : ctx.startOffset;
  46960. return `${msg}
  46961. ${(scope || ctx.descriptor).filename}
  46962. ${generateCodeFrame(
  46963. (scope || ctx.descriptor).source,
  46964. node.start + offset,
  46965. node.end + offset
  46966. )}`;
  46967. }
  46968. function resolveParserPlugins(lang, userPlugins, dts = false) {
  46969. const plugins = [];
  46970. if (!userPlugins || !userPlugins.some(
  46971. (p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
  46972. )) {
  46973. plugins.push("importAttributes");
  46974. }
  46975. if (lang === "jsx" || lang === "tsx" || lang === "mtsx") {
  46976. plugins.push("jsx");
  46977. } else if (userPlugins) {
  46978. userPlugins = userPlugins.filter((p) => p !== "jsx");
  46979. }
  46980. if (lang === "ts" || lang === "mts" || lang === "tsx" || lang === "mtsx") {
  46981. plugins.push(["typescript", { dts }], "explicitResourceManagement");
  46982. if (!userPlugins || !userPlugins.includes("decorators")) {
  46983. plugins.push("decorators-legacy");
  46984. }
  46985. }
  46986. if (userPlugins) {
  46987. plugins.push(...userPlugins);
  46988. }
  46989. return plugins;
  46990. }
  46991. function rewriteDefault(input, as, parserPlugins) {
  46992. const ast = libExports.parse(input, {
  46993. sourceType: "module",
  46994. plugins: resolveParserPlugins("js", parserPlugins)
  46995. }).program.body;
  46996. const s = new MagicString(input);
  46997. rewriteDefaultAST(ast, s, as);
  46998. return s.toString();
  46999. }
  47000. function rewriteDefaultAST(ast, s, as) {
  47001. if (!hasDefaultExport(ast)) {
  47002. s.append(`
  47003. const ${as} = {}`);
  47004. return;
  47005. }
  47006. ast.forEach((node) => {
  47007. if (node.type === "ExportDefaultDeclaration") {
  47008. if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
  47009. let start = node.declaration.decorators && node.declaration.decorators.length > 0 ? node.declaration.decorators[node.declaration.decorators.length - 1].end : node.start;
  47010. s.overwrite(start, node.declaration.id.start, ` class `);
  47011. s.append(`
  47012. const ${as} = ${node.declaration.id.name}`);
  47013. } else {
  47014. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  47015. }
  47016. } else if (node.type === "ExportNamedDeclaration") {
  47017. for (const specifier of node.specifiers) {
  47018. if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.exported.name === "default") {
  47019. if (node.source) {
  47020. if (specifier.local.name === "default") {
  47021. s.prepend(
  47022. `import { default as __VUE_DEFAULT__ } from '${node.source.value}'
  47023. `
  47024. );
  47025. const end2 = specifierEnd(s, specifier.local.end, node.end);
  47026. s.remove(specifier.start, end2);
  47027. s.append(`
  47028. const ${as} = __VUE_DEFAULT__`);
  47029. continue;
  47030. } else {
  47031. s.prepend(
  47032. `import { ${s.slice(
  47033. specifier.local.start,
  47034. specifier.local.end
  47035. )} as __VUE_DEFAULT__ } from '${node.source.value}'
  47036. `
  47037. );
  47038. const end2 = specifierEnd(s, specifier.exported.end, node.end);
  47039. s.remove(specifier.start, end2);
  47040. s.append(`
  47041. const ${as} = __VUE_DEFAULT__`);
  47042. continue;
  47043. }
  47044. }
  47045. const end = specifierEnd(s, specifier.end, node.end);
  47046. s.remove(specifier.start, end);
  47047. s.append(`
  47048. const ${as} = ${specifier.local.name}`);
  47049. }
  47050. }
  47051. }
  47052. });
  47053. }
  47054. function hasDefaultExport(ast) {
  47055. for (const stmt of ast) {
  47056. if (stmt.type === "ExportDefaultDeclaration") {
  47057. return true;
  47058. } else if (stmt.type === "ExportNamedDeclaration" && stmt.specifiers.some(
  47059. (spec) => spec.exported.name === "default"
  47060. )) {
  47061. return true;
  47062. }
  47063. }
  47064. return false;
  47065. }
  47066. function specifierEnd(s, end, nodeEnd) {
  47067. let hasCommas = false;
  47068. let oldEnd = end;
  47069. while (end < nodeEnd) {
  47070. if (/\s/.test(s.slice(end, end + 1))) {
  47071. end++;
  47072. } else if (s.slice(end, end + 1) === ",") {
  47073. end++;
  47074. hasCommas = true;
  47075. break;
  47076. } else if (s.slice(end, end + 1) === "}") {
  47077. break;
  47078. }
  47079. }
  47080. return hasCommas ? end : oldEnd;
  47081. }
  47082. var __defProp$3 = Object.defineProperty;
  47083. var __defProps$2 = Object.defineProperties;
  47084. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  47085. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  47086. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  47087. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  47088. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  47089. var __spreadValues$3 = (a, b) => {
  47090. for (var prop in b || (b = {}))
  47091. if (__hasOwnProp$3.call(b, prop))
  47092. __defNormalProp$3(a, prop, b[prop]);
  47093. if (__getOwnPropSymbols$3)
  47094. for (var prop of __getOwnPropSymbols$3(b)) {
  47095. if (__propIsEnum$3.call(b, prop))
  47096. __defNormalProp$3(a, prop, b[prop]);
  47097. }
  47098. return a;
  47099. };
  47100. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  47101. const normalScriptDefaultVar = `__default__`;
  47102. function processNormalScript(ctx, scopeId) {
  47103. var _a;
  47104. const script = ctx.descriptor.script;
  47105. if (script.lang && !ctx.isJS && !ctx.isTS) {
  47106. return script;
  47107. }
  47108. try {
  47109. let content = script.content;
  47110. let map = script.map;
  47111. const scriptAst = ctx.scriptAst;
  47112. const bindings = analyzeScriptBindings(scriptAst.body);
  47113. const { cssVars } = ctx.descriptor;
  47114. const { genDefaultAs, isProd } = ctx.options;
  47115. if (cssVars.length || genDefaultAs) {
  47116. const defaultVar = genDefaultAs || normalScriptDefaultVar;
  47117. const s = new MagicString(content);
  47118. rewriteDefaultAST(scriptAst.body, s, defaultVar);
  47119. content = s.toString();
  47120. if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
  47121. content += genNormalScriptCssVarsCode(
  47122. cssVars,
  47123. bindings,
  47124. scopeId,
  47125. !!isProd,
  47126. defaultVar
  47127. );
  47128. }
  47129. if (!genDefaultAs) {
  47130. content += `
  47131. export default ${defaultVar}`;
  47132. }
  47133. }
  47134. return __spreadProps$2(__spreadValues$3({}, script), {
  47135. content,
  47136. map,
  47137. bindings,
  47138. scriptAst: scriptAst.body
  47139. });
  47140. } catch (e) {
  47141. return script;
  47142. }
  47143. }
  47144. var __defProp$2 = Object.defineProperty;
  47145. var __defProps$1 = Object.defineProperties;
  47146. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  47147. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  47148. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  47149. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  47150. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  47151. var __spreadValues$2 = (a, b) => {
  47152. for (var prop in b || (b = {}))
  47153. if (__hasOwnProp$2.call(b, prop))
  47154. __defNormalProp$2(a, prop, b[prop]);
  47155. if (__getOwnPropSymbols$2)
  47156. for (var prop of __getOwnPropSymbols$2(b)) {
  47157. if (__propIsEnum$2.call(b, prop))
  47158. __defNormalProp$2(a, prop, b[prop]);
  47159. }
  47160. return a;
  47161. };
  47162. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  47163. class TypeScope {
  47164. constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
  47165. this.filename = filename;
  47166. this.source = source;
  47167. this.offset = offset;
  47168. this.imports = imports;
  47169. this.types = types;
  47170. this.declares = declares;
  47171. this.isGenericScope = false;
  47172. this.resolvedImportSources = /* @__PURE__ */ Object.create(null);
  47173. this.exportedTypes = /* @__PURE__ */ Object.create(null);
  47174. this.exportedDeclares = /* @__PURE__ */ Object.create(null);
  47175. }
  47176. }
  47177. function resolveTypeElements(ctx, node, scope, typeParameters) {
  47178. const canCache = !typeParameters;
  47179. if (canCache && node._resolvedElements) {
  47180. return node._resolvedElements;
  47181. }
  47182. const resolved = innerResolveTypeElements(
  47183. ctx,
  47184. node,
  47185. node._ownerScope || scope || ctxToScope(ctx),
  47186. typeParameters
  47187. );
  47188. return canCache ? node._resolvedElements = resolved : resolved;
  47189. }
  47190. function innerResolveTypeElements(ctx, node, scope, typeParameters) {
  47191. var _a, _b;
  47192. if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  47193. return { props: {} };
  47194. }
  47195. switch (node.type) {
  47196. case "TSTypeLiteral":
  47197. return typeElementsToMap(ctx, node.members, scope, typeParameters);
  47198. case "TSInterfaceDeclaration":
  47199. return resolveInterfaceMembers(ctx, node, scope, typeParameters);
  47200. case "TSTypeAliasDeclaration":
  47201. case "TSTypeAnnotation":
  47202. case "TSParenthesizedType":
  47203. return resolveTypeElements(
  47204. ctx,
  47205. node.typeAnnotation,
  47206. scope,
  47207. typeParameters
  47208. );
  47209. case "TSFunctionType": {
  47210. return { props: {}, calls: [node] };
  47211. }
  47212. case "TSUnionType":
  47213. case "TSIntersectionType":
  47214. return mergeElements(
  47215. node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
  47216. node.type
  47217. );
  47218. case "TSMappedType":
  47219. return resolveMappedType(ctx, node, scope, typeParameters);
  47220. case "TSIndexedAccessType": {
  47221. const types = resolveIndexType(ctx, node, scope);
  47222. return mergeElements(
  47223. types.map((t) => resolveTypeElements(ctx, t, t._ownerScope)),
  47224. "TSUnionType"
  47225. );
  47226. }
  47227. case "TSExpressionWithTypeArguments":
  47228. // referenced by interface extends
  47229. case "TSTypeReference": {
  47230. const typeName = getReferenceName(node);
  47231. if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
  47232. return resolveExtractPropTypes(
  47233. resolveTypeElements(
  47234. ctx,
  47235. node.typeParameters.params[0],
  47236. scope,
  47237. typeParameters
  47238. ),
  47239. scope
  47240. );
  47241. }
  47242. const resolved = resolveTypeReference(ctx, node, scope);
  47243. if (resolved) {
  47244. let typeParams;
  47245. if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
  47246. typeParams = /* @__PURE__ */ Object.create(null);
  47247. resolved.typeParameters.params.forEach((p, i) => {
  47248. let param = typeParameters && typeParameters[p.name];
  47249. if (!param) param = node.typeParameters.params[i];
  47250. typeParams[p.name] = param;
  47251. });
  47252. }
  47253. return resolveTypeElements(
  47254. ctx,
  47255. resolved,
  47256. resolved._ownerScope,
  47257. typeParams
  47258. );
  47259. } else {
  47260. if (typeof typeName === "string") {
  47261. if (typeParameters && typeParameters[typeName]) {
  47262. return resolveTypeElements(
  47263. ctx,
  47264. typeParameters[typeName],
  47265. scope,
  47266. typeParameters
  47267. );
  47268. }
  47269. if (
  47270. // @ts-expect-error
  47271. SupportedBuiltinsSet.has(typeName)
  47272. ) {
  47273. return resolveBuiltin(
  47274. ctx,
  47275. node,
  47276. typeName,
  47277. scope,
  47278. typeParameters
  47279. );
  47280. } else if (typeName === "ReturnType" && node.typeParameters) {
  47281. const ret = resolveReturnType(
  47282. ctx,
  47283. node.typeParameters.params[0],
  47284. scope
  47285. );
  47286. if (ret) {
  47287. return resolveTypeElements(ctx, ret, scope);
  47288. }
  47289. }
  47290. }
  47291. return ctx.error(
  47292. `Unresolvable type reference or unsupported built-in utility type`,
  47293. node,
  47294. scope
  47295. );
  47296. }
  47297. }
  47298. case "TSImportType": {
  47299. if (getId(node.argument) === "vue" && ((_b = node.qualifier) == null ? void 0 : _b.type) === "Identifier" && node.qualifier.name === "ExtractPropTypes" && node.typeParameters) {
  47300. return resolveExtractPropTypes(
  47301. resolveTypeElements(ctx, node.typeParameters.params[0], scope),
  47302. scope
  47303. );
  47304. }
  47305. const sourceScope = importSourceToScope(
  47306. ctx,
  47307. node.argument,
  47308. scope,
  47309. node.argument.value
  47310. );
  47311. const resolved = resolveTypeReference(ctx, node, sourceScope);
  47312. if (resolved) {
  47313. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  47314. }
  47315. break;
  47316. }
  47317. case "TSTypeQuery":
  47318. {
  47319. const resolved = resolveTypeReference(ctx, node, scope);
  47320. if (resolved) {
  47321. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  47322. }
  47323. }
  47324. break;
  47325. }
  47326. return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
  47327. }
  47328. function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
  47329. const res = { props: {} };
  47330. for (const e of elements) {
  47331. if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
  47332. if (typeParameters) {
  47333. scope = createChildScope(scope);
  47334. scope.isGenericScope = true;
  47335. Object.assign(scope.types, typeParameters);
  47336. }
  47337. e._ownerScope = scope;
  47338. const name = getId(e.key);
  47339. if (name && !e.computed) {
  47340. res.props[name] = e;
  47341. } else if (e.key.type === "TemplateLiteral") {
  47342. for (const key of resolveTemplateKeys(ctx, e.key, scope)) {
  47343. res.props[key] = e;
  47344. }
  47345. } else {
  47346. ctx.error(
  47347. `Unsupported computed key in type referenced by a macro`,
  47348. e.key,
  47349. scope
  47350. );
  47351. }
  47352. } else if (e.type === "TSCallSignatureDeclaration") {
  47353. (res.calls || (res.calls = [])).push(e);
  47354. }
  47355. }
  47356. return res;
  47357. }
  47358. function mergeElements(maps, type) {
  47359. if (maps.length === 1) return maps[0];
  47360. const res = { props: {} };
  47361. const { props: baseProps } = res;
  47362. for (const { props, calls } of maps) {
  47363. for (const key in props) {
  47364. if (!hasOwn(baseProps, key)) {
  47365. baseProps[key] = props[key];
  47366. } else {
  47367. baseProps[key] = createProperty(
  47368. baseProps[key].key,
  47369. {
  47370. type,
  47371. // @ts-expect-error
  47372. types: [baseProps[key], props[key]]
  47373. },
  47374. baseProps[key]._ownerScope,
  47375. baseProps[key].optional || props[key].optional
  47376. );
  47377. }
  47378. }
  47379. if (calls) {
  47380. (res.calls || (res.calls = [])).push(...calls);
  47381. }
  47382. }
  47383. return res;
  47384. }
  47385. function createProperty(key, typeAnnotation, scope, optional) {
  47386. return {
  47387. type: "TSPropertySignature",
  47388. key,
  47389. kind: "get",
  47390. optional,
  47391. typeAnnotation: {
  47392. type: "TSTypeAnnotation",
  47393. typeAnnotation
  47394. },
  47395. _ownerScope: scope
  47396. };
  47397. }
  47398. function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
  47399. const base = typeElementsToMap(
  47400. ctx,
  47401. node.body.body,
  47402. node._ownerScope,
  47403. typeParameters
  47404. );
  47405. if (node.extends) {
  47406. for (const ext of node.extends) {
  47407. try {
  47408. const { props, calls } = resolveTypeElements(ctx, ext, scope);
  47409. for (const key in props) {
  47410. if (!hasOwn(base.props, key)) {
  47411. base.props[key] = props[key];
  47412. }
  47413. }
  47414. if (calls) {
  47415. ;
  47416. (base.calls || (base.calls = [])).push(...calls);
  47417. }
  47418. } catch (e) {
  47419. ctx.error(
  47420. `Failed to resolve extends base type.
  47421. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
  47422. interface Props extends /* @vue-ignore */ Base {}
  47423. Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
  47424. ext,
  47425. scope
  47426. );
  47427. }
  47428. }
  47429. }
  47430. return base;
  47431. }
  47432. function resolveMappedType(ctx, node, scope, typeParameters) {
  47433. const res = { props: {} };
  47434. let keys;
  47435. if (node.nameType) {
  47436. const { name, constraint } = node.typeParameter;
  47437. scope = createChildScope(scope);
  47438. Object.assign(scope.types, __spreadProps$1(__spreadValues$2({}, typeParameters), { [name]: constraint }));
  47439. keys = resolveStringType(ctx, node.nameType, scope);
  47440. } else {
  47441. keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
  47442. }
  47443. for (const key of keys) {
  47444. res.props[key] = createProperty(
  47445. {
  47446. type: "Identifier",
  47447. name: key
  47448. },
  47449. node.typeAnnotation,
  47450. scope,
  47451. !!node.optional
  47452. );
  47453. }
  47454. return res;
  47455. }
  47456. function resolveIndexType(ctx, node, scope) {
  47457. var _a, _b;
  47458. if (node.indexType.type === "TSNumberKeyword") {
  47459. return resolveArrayElementType(ctx, node.objectType, scope);
  47460. }
  47461. const { indexType, objectType } = node;
  47462. const types = [];
  47463. let keys;
  47464. let resolved;
  47465. if (indexType.type === "TSStringKeyword") {
  47466. resolved = resolveTypeElements(ctx, objectType, scope);
  47467. keys = Object.keys(resolved.props);
  47468. } else {
  47469. keys = resolveStringType(ctx, indexType, scope);
  47470. resolved = resolveTypeElements(ctx, objectType, scope);
  47471. }
  47472. for (const key of keys) {
  47473. const targetType = (_b = (_a = resolved.props[key]) == null ? void 0 : _a.typeAnnotation) == null ? void 0 : _b.typeAnnotation;
  47474. if (targetType) {
  47475. targetType._ownerScope = resolved.props[key]._ownerScope;
  47476. types.push(targetType);
  47477. }
  47478. }
  47479. return types;
  47480. }
  47481. function resolveArrayElementType(ctx, node, scope) {
  47482. if (node.type === "TSArrayType") {
  47483. return [node.elementType];
  47484. }
  47485. if (node.type === "TSTupleType") {
  47486. return node.elementTypes.map(
  47487. (t) => t.type === "TSNamedTupleMember" ? t.elementType : t
  47488. );
  47489. }
  47490. if (node.type === "TSTypeReference") {
  47491. if (getReferenceName(node) === "Array" && node.typeParameters) {
  47492. return node.typeParameters.params;
  47493. } else {
  47494. const resolved = resolveTypeReference(ctx, node, scope);
  47495. if (resolved) {
  47496. return resolveArrayElementType(ctx, resolved, scope);
  47497. }
  47498. }
  47499. }
  47500. return ctx.error(
  47501. "Failed to resolve element type from target type",
  47502. node,
  47503. scope
  47504. );
  47505. }
  47506. function resolveStringType(ctx, node, scope) {
  47507. switch (node.type) {
  47508. case "StringLiteral":
  47509. return [node.value];
  47510. case "TSLiteralType":
  47511. return resolveStringType(ctx, node.literal, scope);
  47512. case "TSUnionType":
  47513. return node.types.map((t) => resolveStringType(ctx, t, scope)).flat();
  47514. case "TemplateLiteral": {
  47515. return resolveTemplateKeys(ctx, node, scope);
  47516. }
  47517. case "TSTypeReference": {
  47518. const resolved = resolveTypeReference(ctx, node, scope);
  47519. if (resolved) {
  47520. return resolveStringType(ctx, resolved, scope);
  47521. }
  47522. if (node.typeName.type === "Identifier") {
  47523. const getParam = (index = 0) => resolveStringType(ctx, node.typeParameters.params[index], scope);
  47524. switch (node.typeName.name) {
  47525. case "Extract":
  47526. return getParam(1);
  47527. case "Exclude": {
  47528. const excluded = getParam(1);
  47529. return getParam().filter((s) => !excluded.includes(s));
  47530. }
  47531. case "Uppercase":
  47532. return getParam().map((s) => s.toUpperCase());
  47533. case "Lowercase":
  47534. return getParam().map((s) => s.toLowerCase());
  47535. case "Capitalize":
  47536. return getParam().map(capitalize);
  47537. case "Uncapitalize":
  47538. return getParam().map((s) => s[0].toLowerCase() + s.slice(1));
  47539. default:
  47540. ctx.error(
  47541. "Unsupported type when resolving index type",
  47542. node.typeName,
  47543. scope
  47544. );
  47545. }
  47546. }
  47547. }
  47548. }
  47549. return ctx.error("Failed to resolve index type into finite keys", node, scope);
  47550. }
  47551. function resolveTemplateKeys(ctx, node, scope) {
  47552. if (!node.expressions.length) {
  47553. return [node.quasis[0].value.raw];
  47554. }
  47555. const res = [];
  47556. const e = node.expressions[0];
  47557. const q = node.quasis[0];
  47558. const leading = q ? q.value.raw : ``;
  47559. const resolved = resolveStringType(ctx, e, scope);
  47560. const restResolved = resolveTemplateKeys(
  47561. ctx,
  47562. __spreadProps$1(__spreadValues$2({}, node), {
  47563. expressions: node.expressions.slice(1),
  47564. quasis: q ? node.quasis.slice(1) : node.quasis
  47565. }),
  47566. scope
  47567. );
  47568. for (const r of resolved) {
  47569. for (const rr of restResolved) {
  47570. res.push(leading + r + rr);
  47571. }
  47572. }
  47573. return res;
  47574. }
  47575. const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
  47576. "Partial",
  47577. "Required",
  47578. "Readonly",
  47579. "Pick",
  47580. "Omit"
  47581. ]);
  47582. function resolveBuiltin(ctx, node, name, scope, typeParameters) {
  47583. const t = resolveTypeElements(
  47584. ctx,
  47585. node.typeParameters.params[0],
  47586. scope,
  47587. typeParameters
  47588. );
  47589. switch (name) {
  47590. case "Partial": {
  47591. const res2 = { props: {}, calls: t.calls };
  47592. Object.keys(t.props).forEach((key) => {
  47593. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: true });
  47594. });
  47595. return res2;
  47596. }
  47597. case "Required": {
  47598. const res2 = { props: {}, calls: t.calls };
  47599. Object.keys(t.props).forEach((key) => {
  47600. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: false });
  47601. });
  47602. return res2;
  47603. }
  47604. case "Readonly":
  47605. return t;
  47606. case "Pick": {
  47607. const picked = resolveStringType(
  47608. ctx,
  47609. node.typeParameters.params[1],
  47610. scope
  47611. );
  47612. const res2 = { props: {}, calls: t.calls };
  47613. for (const key of picked) {
  47614. res2.props[key] = t.props[key];
  47615. }
  47616. return res2;
  47617. }
  47618. case "Omit":
  47619. const omitted = resolveStringType(
  47620. ctx,
  47621. node.typeParameters.params[1],
  47622. scope
  47623. );
  47624. const res = { props: {}, calls: t.calls };
  47625. for (const key in t.props) {
  47626. if (!omitted.includes(key)) {
  47627. res.props[key] = t.props[key];
  47628. }
  47629. }
  47630. return res;
  47631. }
  47632. }
  47633. function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
  47634. const canCache = !(scope == null ? void 0 : scope.isGenericScope);
  47635. if (canCache && node._resolvedReference) {
  47636. return node._resolvedReference;
  47637. }
  47638. const resolved = innerResolveTypeReference(
  47639. ctx,
  47640. scope || ctxToScope(ctx),
  47641. name || getReferenceName(node),
  47642. node,
  47643. onlyExported
  47644. );
  47645. return canCache ? node._resolvedReference = resolved : resolved;
  47646. }
  47647. function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
  47648. if (typeof name === "string") {
  47649. if (scope.imports[name]) {
  47650. return resolveTypeFromImport(ctx, node, name, scope);
  47651. } else {
  47652. const lookupSource = node.type === "TSTypeQuery" ? onlyExported ? scope.exportedDeclares : scope.declares : onlyExported ? scope.exportedTypes : scope.types;
  47653. if (lookupSource[name]) {
  47654. return lookupSource[name];
  47655. } else {
  47656. const globalScopes = resolveGlobalScope(ctx);
  47657. if (globalScopes) {
  47658. for (const s of globalScopes) {
  47659. const src = node.type === "TSTypeQuery" ? s.declares : s.types;
  47660. if (src[name]) {
  47661. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(s.filename);
  47662. return src[name];
  47663. }
  47664. }
  47665. }
  47666. }
  47667. }
  47668. } else {
  47669. let ns = innerResolveTypeReference(ctx, scope, name[0], node, onlyExported);
  47670. if (ns) {
  47671. if (ns.type !== "TSModuleDeclaration") {
  47672. ns = ns._ns;
  47673. }
  47674. if (ns) {
  47675. const childScope = moduleDeclToScope(ctx, ns, ns._ownerScope || scope);
  47676. return innerResolveTypeReference(
  47677. ctx,
  47678. childScope,
  47679. name.length > 2 ? name.slice(1) : name[name.length - 1],
  47680. node,
  47681. !ns.declare
  47682. );
  47683. }
  47684. }
  47685. }
  47686. }
  47687. function getReferenceName(node) {
  47688. const ref = node.type === "TSTypeReference" ? node.typeName : node.type === "TSExpressionWithTypeArguments" ? node.expression : node.type === "TSImportType" ? node.qualifier : node.exprName;
  47689. if ((ref == null ? void 0 : ref.type) === "Identifier") {
  47690. return ref.name;
  47691. } else if ((ref == null ? void 0 : ref.type) === "TSQualifiedName") {
  47692. return qualifiedNameToPath(ref);
  47693. } else {
  47694. return "default";
  47695. }
  47696. }
  47697. function qualifiedNameToPath(node) {
  47698. if (node.type === "Identifier") {
  47699. return [node.name];
  47700. } else {
  47701. return [...qualifiedNameToPath(node.left), node.right.name];
  47702. }
  47703. }
  47704. function resolveGlobalScope(ctx) {
  47705. if (ctx.options.globalTypeFiles) {
  47706. const fs = resolveFS(ctx);
  47707. if (!fs) {
  47708. throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
  47709. }
  47710. return ctx.options.globalTypeFiles.map(
  47711. (file) => fileToScope(ctx, normalizePath(file), true)
  47712. );
  47713. }
  47714. }
  47715. let ts;
  47716. let loadTS;
  47717. function registerTS(_loadTS) {
  47718. loadTS = () => {
  47719. try {
  47720. return _loadTS();
  47721. } catch (err) {
  47722. if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
  47723. throw new Error(
  47724. 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
  47725. );
  47726. } else {
  47727. throw new Error(
  47728. "Failed to load TypeScript for resolving imported types."
  47729. );
  47730. }
  47731. }
  47732. };
  47733. }
  47734. function resolveFS(ctx) {
  47735. if (ctx.fs) {
  47736. return ctx.fs;
  47737. }
  47738. if (!ts && loadTS) {
  47739. ts = loadTS();
  47740. }
  47741. const fs = ctx.options.fs || (ts == null ? void 0 : ts.sys);
  47742. if (!fs) {
  47743. return;
  47744. }
  47745. return ctx.fs = {
  47746. fileExists(file) {
  47747. if (file.endsWith(".vue.ts")) {
  47748. file = file.replace(/\.ts$/, "");
  47749. }
  47750. return fs.fileExists(file);
  47751. },
  47752. readFile(file) {
  47753. if (file.endsWith(".vue.ts")) {
  47754. file = file.replace(/\.ts$/, "");
  47755. }
  47756. return fs.readFile(file);
  47757. },
  47758. realpath: fs.realpath
  47759. };
  47760. }
  47761. function resolveTypeFromImport(ctx, node, name, scope) {
  47762. const { source, imported } = scope.imports[name];
  47763. const sourceScope = importSourceToScope(ctx, node, scope, source);
  47764. return resolveTypeReference(ctx, node, sourceScope, imported, true);
  47765. }
  47766. function importSourceToScope(ctx, node, scope, source) {
  47767. let fs;
  47768. try {
  47769. fs = resolveFS(ctx);
  47770. } catch (err) {
  47771. return ctx.error(err.message, node, scope);
  47772. }
  47773. if (!fs) {
  47774. return ctx.error(
  47775. `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
  47776. node,
  47777. scope
  47778. );
  47779. }
  47780. let resolved = scope.resolvedImportSources[source];
  47781. if (!resolved) {
  47782. if (source.startsWith("..")) {
  47783. const osSpecificJoinFn = joinPaths;
  47784. const filename = osSpecificJoinFn(dirname(scope.filename), source);
  47785. resolved = resolveExt(filename, fs);
  47786. } else if (source[0] === ".") {
  47787. const filename = joinPaths(dirname(scope.filename), source);
  47788. resolved = resolveExt(filename, fs);
  47789. } else {
  47790. {
  47791. return ctx.error(
  47792. `Type import from non-relative sources is not supported in the browser build.`,
  47793. node,
  47794. scope
  47795. );
  47796. }
  47797. }
  47798. if (resolved) {
  47799. resolved = scope.resolvedImportSources[source] = normalizePath(resolved);
  47800. }
  47801. }
  47802. if (resolved) {
  47803. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(resolved);
  47804. return fileToScope(ctx, resolved);
  47805. } else {
  47806. return ctx.error(
  47807. `Failed to resolve import source ${JSON.stringify(source)}.`,
  47808. node,
  47809. scope
  47810. );
  47811. }
  47812. }
  47813. function resolveExt(filename, fs) {
  47814. filename = filename.replace(/\.js$/, "");
  47815. const tryResolve = (filename2) => {
  47816. if (fs.fileExists(filename2)) return filename2;
  47817. };
  47818. return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.tsx`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.tsx`)) || tryResolve(joinPaths(filename, `index.d.ts`));
  47819. }
  47820. const tsConfigCache = createCache();
  47821. const tsConfigRefMap = /* @__PURE__ */ new Map();
  47822. const fileToScopeCache = createCache();
  47823. function invalidateTypeCache(filename) {
  47824. filename = normalizePath(filename);
  47825. fileToScopeCache.delete(filename);
  47826. tsConfigCache.delete(filename);
  47827. const affectedConfig = tsConfigRefMap.get(filename);
  47828. if (affectedConfig) tsConfigCache.delete(affectedConfig);
  47829. }
  47830. function fileToScope(ctx, filename, asGlobal = false) {
  47831. const cached = fileToScopeCache.get(filename);
  47832. if (cached) {
  47833. return cached;
  47834. }
  47835. const fs = resolveFS(ctx);
  47836. const source = fs.readFile(filename) || "";
  47837. const body = parseFile(filename, source, ctx.options.babelParserPlugins);
  47838. const scope = new TypeScope(filename, source, 0, recordImports(body));
  47839. recordTypes(ctx, body, scope, asGlobal);
  47840. fileToScopeCache.set(filename, scope);
  47841. return scope;
  47842. }
  47843. function parseFile(filename, content, parserPlugins) {
  47844. const ext = extname(filename);
  47845. if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
  47846. return libExports.parse(content, {
  47847. plugins: resolveParserPlugins(
  47848. ext.slice(1),
  47849. parserPlugins,
  47850. /\.d\.m?ts$/.test(filename)
  47851. ),
  47852. sourceType: "module"
  47853. }).program.body;
  47854. } else if (ext === ".vue") {
  47855. const {
  47856. descriptor: { script, scriptSetup }
  47857. } = parse$2(content);
  47858. if (!script && !scriptSetup) {
  47859. return [];
  47860. }
  47861. const scriptOffset = script ? script.loc.start.offset : Infinity;
  47862. const scriptSetupOffset = scriptSetup ? scriptSetup.loc.start.offset : Infinity;
  47863. const firstBlock = scriptOffset < scriptSetupOffset ? script : scriptSetup;
  47864. const secondBlock = scriptOffset < scriptSetupOffset ? scriptSetup : script;
  47865. let scriptContent = " ".repeat(Math.min(scriptOffset, scriptSetupOffset)) + firstBlock.content;
  47866. if (secondBlock) {
  47867. scriptContent += " ".repeat(secondBlock.loc.start.offset - script.loc.end.offset) + secondBlock.content;
  47868. }
  47869. const lang = (script == null ? void 0 : script.lang) || (scriptSetup == null ? void 0 : scriptSetup.lang);
  47870. return libExports.parse(scriptContent, {
  47871. plugins: resolveParserPlugins(lang, parserPlugins),
  47872. sourceType: "module"
  47873. }).program.body;
  47874. }
  47875. return [];
  47876. }
  47877. function ctxToScope(ctx) {
  47878. if (ctx.scope) {
  47879. return ctx.scope;
  47880. }
  47881. const body = "ast" in ctx ? ctx.ast : ctx.scriptAst ? [...ctx.scriptAst.body, ...ctx.scriptSetupAst.body] : ctx.scriptSetupAst.body;
  47882. const scope = new TypeScope(
  47883. ctx.filename,
  47884. ctx.source,
  47885. "startOffset" in ctx ? ctx.startOffset : 0,
  47886. "userImports" in ctx ? Object.create(ctx.userImports) : recordImports(body)
  47887. );
  47888. recordTypes(ctx, body, scope);
  47889. return ctx.scope = scope;
  47890. }
  47891. function moduleDeclToScope(ctx, node, parentScope) {
  47892. if (node._resolvedChildScope) {
  47893. return node._resolvedChildScope;
  47894. }
  47895. const scope = createChildScope(parentScope);
  47896. if (node.body.type === "TSModuleDeclaration") {
  47897. const decl = node.body;
  47898. decl._ownerScope = scope;
  47899. const id = getId(decl.id);
  47900. scope.types[id] = scope.exportedTypes[id] = decl;
  47901. } else {
  47902. recordTypes(ctx, node.body.body, scope);
  47903. }
  47904. return node._resolvedChildScope = scope;
  47905. }
  47906. function createChildScope(parentScope) {
  47907. return new TypeScope(
  47908. parentScope.filename,
  47909. parentScope.source,
  47910. parentScope.offset,
  47911. Object.create(parentScope.imports),
  47912. Object.create(parentScope.types),
  47913. Object.create(parentScope.declares)
  47914. );
  47915. }
  47916. const importExportRE = /^Import|^Export/;
  47917. function recordTypes(ctx, body, scope, asGlobal = false) {
  47918. const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
  47919. const isAmbient = asGlobal ? !body.some((s) => importExportRE.test(s.type)) : false;
  47920. for (const stmt of body) {
  47921. if (asGlobal) {
  47922. if (isAmbient) {
  47923. if (stmt.declare) {
  47924. recordType(stmt, types, declares);
  47925. }
  47926. } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
  47927. for (const s of stmt.body.body) {
  47928. recordType(s, types, declares);
  47929. }
  47930. }
  47931. } else {
  47932. recordType(stmt, types, declares);
  47933. }
  47934. }
  47935. if (!asGlobal) {
  47936. for (const stmt of body) {
  47937. if (stmt.type === "ExportNamedDeclaration") {
  47938. if (stmt.declaration) {
  47939. recordType(stmt.declaration, types, declares);
  47940. recordType(stmt.declaration, exportedTypes, exportedDeclares);
  47941. } else {
  47942. for (const spec of stmt.specifiers) {
  47943. if (spec.type === "ExportSpecifier") {
  47944. const local = spec.local.name;
  47945. const exported = getId(spec.exported);
  47946. if (stmt.source) {
  47947. imports[exported] = {
  47948. source: stmt.source.value,
  47949. imported: local
  47950. };
  47951. exportedTypes[exported] = {
  47952. type: "TSTypeReference",
  47953. typeName: {
  47954. type: "Identifier",
  47955. name: local
  47956. },
  47957. _ownerScope: scope
  47958. };
  47959. } else if (types[local]) {
  47960. exportedTypes[exported] = types[local];
  47961. }
  47962. }
  47963. }
  47964. }
  47965. } else if (stmt.type === "ExportAllDeclaration") {
  47966. const sourceScope = importSourceToScope(
  47967. ctx,
  47968. stmt.source,
  47969. scope,
  47970. stmt.source.value
  47971. );
  47972. Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
  47973. } else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
  47974. if (stmt.declaration.type !== "Identifier") {
  47975. recordType(stmt.declaration, types, declares, "default");
  47976. recordType(
  47977. stmt.declaration,
  47978. exportedTypes,
  47979. exportedDeclares,
  47980. "default"
  47981. );
  47982. } else if (types[stmt.declaration.name]) {
  47983. exportedTypes["default"] = types[stmt.declaration.name];
  47984. }
  47985. }
  47986. }
  47987. }
  47988. for (const key of Object.keys(types)) {
  47989. const node = types[key];
  47990. node._ownerScope = scope;
  47991. if (node._ns) node._ns._ownerScope = scope;
  47992. }
  47993. for (const key of Object.keys(declares)) {
  47994. declares[key]._ownerScope = scope;
  47995. }
  47996. }
  47997. function recordType(node, types, declares, overwriteId) {
  47998. switch (node.type) {
  47999. case "TSInterfaceDeclaration":
  48000. case "TSEnumDeclaration":
  48001. case "TSModuleDeclaration": {
  48002. const id = overwriteId || getId(node.id);
  48003. let existing = types[id];
  48004. if (existing) {
  48005. if (node.type === "TSModuleDeclaration") {
  48006. if (existing.type === "TSModuleDeclaration") {
  48007. mergeNamespaces(existing, node);
  48008. } else {
  48009. attachNamespace(existing, node);
  48010. }
  48011. break;
  48012. }
  48013. if (existing.type === "TSModuleDeclaration") {
  48014. types[id] = node;
  48015. attachNamespace(node, existing);
  48016. break;
  48017. }
  48018. if (existing.type !== node.type) {
  48019. break;
  48020. }
  48021. if (node.type === "TSInterfaceDeclaration") {
  48022. existing.body.body.push(...node.body.body);
  48023. } else {
  48024. existing.members.push(...node.members);
  48025. }
  48026. } else {
  48027. types[id] = node;
  48028. }
  48029. break;
  48030. }
  48031. case "ClassDeclaration":
  48032. if (overwriteId || node.id) types[overwriteId || getId(node.id)] = node;
  48033. break;
  48034. case "TSTypeAliasDeclaration":
  48035. types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
  48036. break;
  48037. case "TSDeclareFunction":
  48038. if (node.id) declares[node.id.name] = node;
  48039. break;
  48040. case "VariableDeclaration": {
  48041. if (node.declare) {
  48042. for (const decl of node.declarations) {
  48043. if (decl.id.type === "Identifier" && decl.id.typeAnnotation) {
  48044. declares[decl.id.name] = decl.id.typeAnnotation.typeAnnotation;
  48045. }
  48046. }
  48047. }
  48048. break;
  48049. }
  48050. }
  48051. }
  48052. function mergeNamespaces(to, from) {
  48053. const toBody = to.body;
  48054. const fromBody = from.body;
  48055. if (toBody.type === "TSModuleDeclaration") {
  48056. if (fromBody.type === "TSModuleDeclaration") {
  48057. mergeNamespaces(toBody, fromBody);
  48058. } else {
  48059. fromBody.body.push({
  48060. type: "ExportNamedDeclaration",
  48061. declaration: toBody,
  48062. exportKind: "type",
  48063. specifiers: []
  48064. });
  48065. }
  48066. } else if (fromBody.type === "TSModuleDeclaration") {
  48067. toBody.body.push({
  48068. type: "ExportNamedDeclaration",
  48069. declaration: fromBody,
  48070. exportKind: "type",
  48071. specifiers: []
  48072. });
  48073. } else {
  48074. toBody.body.push(...fromBody.body);
  48075. }
  48076. }
  48077. function attachNamespace(to, ns) {
  48078. if (!to._ns) {
  48079. to._ns = ns;
  48080. } else {
  48081. mergeNamespaces(to._ns, ns);
  48082. }
  48083. }
  48084. function recordImports(body) {
  48085. const imports = /* @__PURE__ */ Object.create(null);
  48086. for (const s of body) {
  48087. recordImport(s, imports);
  48088. }
  48089. return imports;
  48090. }
  48091. function recordImport(node, imports) {
  48092. if (node.type !== "ImportDeclaration") {
  48093. return;
  48094. }
  48095. for (const s of node.specifiers) {
  48096. imports[s.local.name] = {
  48097. imported: getImportedName(s),
  48098. source: node.source.value
  48099. };
  48100. }
  48101. }
  48102. function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
  48103. try {
  48104. switch (node.type) {
  48105. case "TSStringKeyword":
  48106. return ["String"];
  48107. case "TSNumberKeyword":
  48108. return ["Number"];
  48109. case "TSBooleanKeyword":
  48110. return ["Boolean"];
  48111. case "TSObjectKeyword":
  48112. return ["Object"];
  48113. case "TSNullKeyword":
  48114. return ["null"];
  48115. case "TSTypeLiteral":
  48116. case "TSInterfaceDeclaration": {
  48117. const types = /* @__PURE__ */ new Set();
  48118. const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
  48119. for (const m of members) {
  48120. if (isKeyOf) {
  48121. if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
  48122. types.add("Number");
  48123. } else if (m.type === "TSIndexSignature") {
  48124. const annotation = m.parameters[0].typeAnnotation;
  48125. if (annotation && annotation.type !== "Noop") {
  48126. const type = inferRuntimeType(
  48127. ctx,
  48128. annotation.typeAnnotation,
  48129. scope
  48130. )[0];
  48131. if (type === UNKNOWN_TYPE) return [UNKNOWN_TYPE];
  48132. types.add(type);
  48133. }
  48134. } else {
  48135. types.add("String");
  48136. }
  48137. } else if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
  48138. types.add("Function");
  48139. } else {
  48140. types.add("Object");
  48141. }
  48142. }
  48143. return types.size ? Array.from(types) : [isKeyOf ? UNKNOWN_TYPE : "Object"];
  48144. }
  48145. case "TSPropertySignature":
  48146. if (node.typeAnnotation) {
  48147. return inferRuntimeType(
  48148. ctx,
  48149. node.typeAnnotation.typeAnnotation,
  48150. scope
  48151. );
  48152. }
  48153. break;
  48154. case "TSMethodSignature":
  48155. case "TSFunctionType":
  48156. return ["Function"];
  48157. case "TSArrayType":
  48158. case "TSTupleType":
  48159. return ["Array"];
  48160. case "TSLiteralType":
  48161. switch (node.literal.type) {
  48162. case "StringLiteral":
  48163. return ["String"];
  48164. case "BooleanLiteral":
  48165. return ["Boolean"];
  48166. case "NumericLiteral":
  48167. case "BigIntLiteral":
  48168. return ["Number"];
  48169. default:
  48170. return [UNKNOWN_TYPE];
  48171. }
  48172. case "TSTypeReference": {
  48173. const resolved = resolveTypeReference(ctx, node, scope);
  48174. if (resolved) {
  48175. return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
  48176. }
  48177. if (node.typeName.type === "Identifier") {
  48178. if (isKeyOf) {
  48179. switch (node.typeName.name) {
  48180. case "String":
  48181. case "Array":
  48182. case "ArrayLike":
  48183. case "Parameters":
  48184. case "ConstructorParameters":
  48185. case "ReadonlyArray":
  48186. return ["String", "Number"];
  48187. // TS built-in utility types
  48188. case "Record":
  48189. case "Partial":
  48190. case "Required":
  48191. case "Readonly":
  48192. if (node.typeParameters && node.typeParameters.params[0]) {
  48193. return inferRuntimeType(
  48194. ctx,
  48195. node.typeParameters.params[0],
  48196. scope,
  48197. true
  48198. );
  48199. }
  48200. break;
  48201. case "Pick":
  48202. case "Extract":
  48203. if (node.typeParameters && node.typeParameters.params[1]) {
  48204. return inferRuntimeType(
  48205. ctx,
  48206. node.typeParameters.params[1],
  48207. scope
  48208. );
  48209. }
  48210. break;
  48211. case "Function":
  48212. case "Object":
  48213. case "Set":
  48214. case "Map":
  48215. case "WeakSet":
  48216. case "WeakMap":
  48217. case "Date":
  48218. case "Promise":
  48219. case "Error":
  48220. case "Uppercase":
  48221. case "Lowercase":
  48222. case "Capitalize":
  48223. case "Uncapitalize":
  48224. case "ReadonlyMap":
  48225. case "ReadonlySet":
  48226. return ["String"];
  48227. }
  48228. } else {
  48229. switch (node.typeName.name) {
  48230. case "Array":
  48231. case "Function":
  48232. case "Object":
  48233. case "Set":
  48234. case "Map":
  48235. case "WeakSet":
  48236. case "WeakMap":
  48237. case "Date":
  48238. case "Promise":
  48239. case "Error":
  48240. return [node.typeName.name];
  48241. // TS built-in utility types
  48242. // https://www.typescriptlang.org/docs/handbook/utility-types.html
  48243. case "Partial":
  48244. case "Required":
  48245. case "Readonly":
  48246. case "Record":
  48247. case "Pick":
  48248. case "Omit":
  48249. case "InstanceType":
  48250. return ["Object"];
  48251. case "Uppercase":
  48252. case "Lowercase":
  48253. case "Capitalize":
  48254. case "Uncapitalize":
  48255. return ["String"];
  48256. case "Parameters":
  48257. case "ConstructorParameters":
  48258. case "ReadonlyArray":
  48259. return ["Array"];
  48260. case "ReadonlyMap":
  48261. return ["Map"];
  48262. case "ReadonlySet":
  48263. return ["Set"];
  48264. case "NonNullable":
  48265. if (node.typeParameters && node.typeParameters.params[0]) {
  48266. return inferRuntimeType(
  48267. ctx,
  48268. node.typeParameters.params[0],
  48269. scope
  48270. ).filter((t) => t !== "null");
  48271. }
  48272. break;
  48273. case "Extract":
  48274. if (node.typeParameters && node.typeParameters.params[1]) {
  48275. return inferRuntimeType(
  48276. ctx,
  48277. node.typeParameters.params[1],
  48278. scope
  48279. );
  48280. }
  48281. break;
  48282. case "Exclude":
  48283. case "OmitThisParameter":
  48284. if (node.typeParameters && node.typeParameters.params[0]) {
  48285. return inferRuntimeType(
  48286. ctx,
  48287. node.typeParameters.params[0],
  48288. scope
  48289. );
  48290. }
  48291. break;
  48292. }
  48293. }
  48294. }
  48295. break;
  48296. }
  48297. case "TSParenthesizedType":
  48298. return inferRuntimeType(ctx, node.typeAnnotation, scope);
  48299. case "TSUnionType":
  48300. return flattenTypes(ctx, node.types, scope, isKeyOf);
  48301. case "TSIntersectionType": {
  48302. return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
  48303. (t) => t !== UNKNOWN_TYPE
  48304. );
  48305. }
  48306. case "TSEnumDeclaration":
  48307. return inferEnumType(node);
  48308. case "TSSymbolKeyword":
  48309. return ["Symbol"];
  48310. case "TSIndexedAccessType": {
  48311. const types = resolveIndexType(ctx, node, scope);
  48312. return flattenTypes(ctx, types, scope, isKeyOf);
  48313. }
  48314. case "ClassDeclaration":
  48315. return ["Object"];
  48316. case "TSImportType": {
  48317. const sourceScope = importSourceToScope(
  48318. ctx,
  48319. node.argument,
  48320. scope,
  48321. node.argument.value
  48322. );
  48323. const resolved = resolveTypeReference(ctx, node, sourceScope);
  48324. if (resolved) {
  48325. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  48326. }
  48327. break;
  48328. }
  48329. case "TSTypeQuery": {
  48330. const id = node.exprName;
  48331. if (id.type === "Identifier") {
  48332. const matched = scope.declares[id.name];
  48333. if (matched) {
  48334. return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf);
  48335. }
  48336. }
  48337. break;
  48338. }
  48339. // e.g. readonly
  48340. case "TSTypeOperator": {
  48341. return inferRuntimeType(
  48342. ctx,
  48343. node.typeAnnotation,
  48344. scope,
  48345. node.operator === "keyof"
  48346. );
  48347. }
  48348. case "TSAnyKeyword": {
  48349. if (isKeyOf) {
  48350. return ["String", "Number", "Symbol"];
  48351. }
  48352. break;
  48353. }
  48354. }
  48355. } catch (e) {
  48356. }
  48357. return [UNKNOWN_TYPE];
  48358. }
  48359. function flattenTypes(ctx, types, scope, isKeyOf = false) {
  48360. if (types.length === 1) {
  48361. return inferRuntimeType(ctx, types[0], scope, isKeyOf);
  48362. }
  48363. return [
  48364. ...new Set(
  48365. [].concat(
  48366. ...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
  48367. )
  48368. )
  48369. ];
  48370. }
  48371. function inferEnumType(node) {
  48372. const types = /* @__PURE__ */ new Set();
  48373. for (const m of node.members) {
  48374. if (m.initializer) {
  48375. switch (m.initializer.type) {
  48376. case "StringLiteral":
  48377. types.add("String");
  48378. break;
  48379. case "NumericLiteral":
  48380. types.add("Number");
  48381. break;
  48382. }
  48383. }
  48384. }
  48385. return types.size ? [...types] : ["Number"];
  48386. }
  48387. function resolveExtractPropTypes({ props }, scope) {
  48388. const res = { props: {} };
  48389. for (const key in props) {
  48390. const raw = props[key];
  48391. res.props[key] = reverseInferType(
  48392. raw.key,
  48393. raw.typeAnnotation.typeAnnotation,
  48394. scope
  48395. );
  48396. }
  48397. return res;
  48398. }
  48399. function reverseInferType(key, node, scope, optional = true, checkObjectSyntax = true) {
  48400. if (checkObjectSyntax && node.type === "TSTypeLiteral") {
  48401. const typeType = findStaticPropertyType(node, "type");
  48402. if (typeType) {
  48403. const requiredType = findStaticPropertyType(node, "required");
  48404. const optional2 = requiredType && requiredType.type === "TSLiteralType" && requiredType.literal.type === "BooleanLiteral" ? !requiredType.literal.value : true;
  48405. return reverseInferType(key, typeType, scope, optional2, false);
  48406. }
  48407. } else if (node.type === "TSTypeReference" && node.typeName.type === "Identifier") {
  48408. if (node.typeName.name.endsWith("Constructor")) {
  48409. return createProperty(
  48410. key,
  48411. ctorToType(node.typeName.name),
  48412. scope,
  48413. optional
  48414. );
  48415. } else if (node.typeName.name === "PropType" && node.typeParameters) {
  48416. return createProperty(key, node.typeParameters.params[0], scope, optional);
  48417. }
  48418. }
  48419. if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
  48420. for (const t of node.typeParameters.params) {
  48421. const inferred = reverseInferType(key, t, scope, optional);
  48422. if (inferred) return inferred;
  48423. }
  48424. }
  48425. return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
  48426. }
  48427. function ctorToType(ctorType) {
  48428. const ctor = ctorType.slice(0, -11);
  48429. switch (ctor) {
  48430. case "String":
  48431. case "Number":
  48432. case "Boolean":
  48433. return { type: `TS${ctor}Keyword` };
  48434. case "Array":
  48435. case "Function":
  48436. case "Object":
  48437. case "Set":
  48438. case "Map":
  48439. case "WeakSet":
  48440. case "WeakMap":
  48441. case "Date":
  48442. case "Promise":
  48443. return {
  48444. type: "TSTypeReference",
  48445. typeName: { type: "Identifier", name: ctor }
  48446. };
  48447. }
  48448. return { type: `TSNullKeyword` };
  48449. }
  48450. function findStaticPropertyType(node, key) {
  48451. const prop = node.members.find(
  48452. (m) => m.type === "TSPropertySignature" && !m.computed && getId(m.key) === key && m.typeAnnotation
  48453. );
  48454. return prop && prop.typeAnnotation.typeAnnotation;
  48455. }
  48456. function resolveReturnType(ctx, arg, scope) {
  48457. var _a;
  48458. let resolved = arg;
  48459. if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
  48460. resolved = resolveTypeReference(ctx, arg, scope);
  48461. }
  48462. if (!resolved) return;
  48463. if (resolved.type === "TSFunctionType") {
  48464. return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
  48465. }
  48466. if (resolved.type === "TSDeclareFunction") {
  48467. return resolved.returnType;
  48468. }
  48469. }
  48470. function resolveUnionType(ctx, node, scope) {
  48471. if (node.type === "TSTypeReference") {
  48472. const resolved = resolveTypeReference(ctx, node, scope);
  48473. if (resolved) node = resolved;
  48474. }
  48475. let types;
  48476. if (node.type === "TSUnionType") {
  48477. types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
  48478. } else {
  48479. types = [node];
  48480. }
  48481. return types;
  48482. }
  48483. const DEFINE_MODEL = "defineModel";
  48484. function processDefineModel(ctx, node, declId) {
  48485. if (!isCallOf(node, DEFINE_MODEL)) {
  48486. return false;
  48487. }
  48488. ctx.hasDefineModelCall = true;
  48489. const type = node.typeParameters && node.typeParameters.params[0] || void 0;
  48490. let modelName;
  48491. let options;
  48492. const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
  48493. const hasName = arg0 && arg0.type === "StringLiteral";
  48494. if (hasName) {
  48495. modelName = arg0.value;
  48496. options = node.arguments[1];
  48497. } else {
  48498. modelName = "modelValue";
  48499. options = arg0;
  48500. }
  48501. if (ctx.modelDecls[modelName]) {
  48502. ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
  48503. }
  48504. let optionsString = options && ctx.getString(options);
  48505. let optionsRemoved = !options;
  48506. const runtimeOptionNodes = [];
  48507. if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
  48508. let removed = 0;
  48509. for (let i = options.properties.length - 1; i >= 0; i--) {
  48510. const p = options.properties[i];
  48511. const next = options.properties[i + 1];
  48512. const start = p.start;
  48513. const end = next ? next.start : options.end - 1;
  48514. if ((p.type === "ObjectProperty" || p.type === "ObjectMethod") && (p.key.type === "Identifier" && (p.key.name === "get" || p.key.name === "set") || p.key.type === "StringLiteral" && (p.key.value === "get" || p.key.value === "set"))) {
  48515. optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
  48516. } else {
  48517. removed++;
  48518. ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
  48519. runtimeOptionNodes.push(p);
  48520. }
  48521. }
  48522. if (removed === options.properties.length) {
  48523. optionsRemoved = true;
  48524. ctx.s.remove(
  48525. ctx.startOffset + (hasName ? arg0.end : options.start),
  48526. ctx.startOffset + options.end
  48527. );
  48528. }
  48529. }
  48530. ctx.modelDecls[modelName] = {
  48531. type,
  48532. options: optionsString,
  48533. runtimeOptionNodes,
  48534. identifier: declId && declId.type === "Identifier" ? declId.name : void 0
  48535. };
  48536. ctx.bindingMetadata[modelName] = "props";
  48537. ctx.s.overwrite(
  48538. ctx.startOffset + node.callee.start,
  48539. ctx.startOffset + node.callee.end,
  48540. ctx.helper("useModel")
  48541. );
  48542. ctx.s.appendLeft(
  48543. ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
  48544. `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
  48545. );
  48546. return true;
  48547. }
  48548. function genModelProps(ctx) {
  48549. if (!ctx.hasDefineModelCall) return;
  48550. const isProd = !!ctx.options.isProd;
  48551. let modelPropsDecl = "";
  48552. for (const [name, { type, options: runtimeOptions }] of Object.entries(
  48553. ctx.modelDecls
  48554. )) {
  48555. let skipCheck = false;
  48556. let codegenOptions = ``;
  48557. let runtimeTypes = type && inferRuntimeType(ctx, type);
  48558. if (runtimeTypes) {
  48559. const hasBoolean = runtimeTypes.includes("Boolean");
  48560. const hasFunction = runtimeTypes.includes("Function");
  48561. const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
  48562. if (hasUnknownType) {
  48563. if (hasBoolean || hasFunction) {
  48564. runtimeTypes = runtimeTypes.filter((t) => t !== UNKNOWN_TYPE);
  48565. skipCheck = true;
  48566. } else {
  48567. runtimeTypes = ["null"];
  48568. }
  48569. }
  48570. if (!isProd) {
  48571. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}` + (skipCheck ? ", skipCheck: true" : "");
  48572. } else if (hasBoolean || runtimeOptions && hasFunction) {
  48573. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`;
  48574. } else ;
  48575. }
  48576. let decl;
  48577. if (codegenOptions && runtimeOptions) {
  48578. decl = ctx.isTS ? `{ ${codegenOptions}, ...${runtimeOptions} }` : `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`;
  48579. } else if (codegenOptions) {
  48580. decl = `{ ${codegenOptions} }`;
  48581. } else if (runtimeOptions) {
  48582. decl = runtimeOptions;
  48583. } else {
  48584. decl = `{}`;
  48585. }
  48586. modelPropsDecl += `
  48587. ${JSON.stringify(name)}: ${decl},`;
  48588. const modifierPropName = JSON.stringify(
  48589. name === "modelValue" ? `modelModifiers` : `${name}Modifiers`
  48590. );
  48591. modelPropsDecl += `
  48592. ${modifierPropName}: {},`;
  48593. }
  48594. return `{${modelPropsDecl}
  48595. }`;
  48596. }
  48597. const DEFINE_PROPS = "defineProps";
  48598. const WITH_DEFAULTS = "withDefaults";
  48599. function processDefineProps(ctx, node, declId, isWithDefaults = false) {
  48600. if (!isCallOf(node, DEFINE_PROPS)) {
  48601. return processWithDefaults(ctx, node, declId);
  48602. }
  48603. if (ctx.hasDefinePropsCall) {
  48604. ctx.error(`duplicate ${DEFINE_PROPS}() call`, node);
  48605. }
  48606. ctx.hasDefinePropsCall = true;
  48607. ctx.propsRuntimeDecl = node.arguments[0];
  48608. if (ctx.propsRuntimeDecl) {
  48609. for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
  48610. if (!(key in ctx.bindingMetadata)) {
  48611. ctx.bindingMetadata[key] = "props";
  48612. }
  48613. }
  48614. }
  48615. if (node.typeParameters) {
  48616. if (ctx.propsRuntimeDecl) {
  48617. ctx.error(
  48618. `${DEFINE_PROPS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  48619. node
  48620. );
  48621. }
  48622. ctx.propsTypeDecl = node.typeParameters.params[0];
  48623. }
  48624. if (!isWithDefaults && declId && declId.type === "ObjectPattern") {
  48625. processPropsDestructure(ctx, declId);
  48626. }
  48627. ctx.propsCall = node;
  48628. ctx.propsDecl = declId;
  48629. return true;
  48630. }
  48631. function processWithDefaults(ctx, node, declId) {
  48632. if (!isCallOf(node, WITH_DEFAULTS)) {
  48633. return false;
  48634. }
  48635. if (!processDefineProps(
  48636. ctx,
  48637. node.arguments[0],
  48638. declId,
  48639. true
  48640. )) {
  48641. ctx.error(
  48642. `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
  48643. node.arguments[0] || node
  48644. );
  48645. }
  48646. if (ctx.propsRuntimeDecl) {
  48647. ctx.error(
  48648. `${WITH_DEFAULTS} can only be used with type-based ${DEFINE_PROPS} declaration.`,
  48649. node
  48650. );
  48651. }
  48652. if (declId && declId.type === "ObjectPattern") {
  48653. ctx.warn(
  48654. `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
  48655. Reactive destructure will be disabled when using withDefaults().
  48656. Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...). `,
  48657. node.callee
  48658. );
  48659. }
  48660. ctx.propsRuntimeDefaults = node.arguments[1];
  48661. if (!ctx.propsRuntimeDefaults) {
  48662. ctx.error(`The 2nd argument of ${WITH_DEFAULTS} is required.`, node);
  48663. }
  48664. ctx.propsCall = node;
  48665. return true;
  48666. }
  48667. function genRuntimeProps(ctx) {
  48668. let propsDecls;
  48669. if (ctx.propsRuntimeDecl) {
  48670. propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim();
  48671. if (ctx.propsDestructureDecl) {
  48672. const defaults = [];
  48673. for (const key in ctx.propsDestructuredBindings) {
  48674. const d = genDestructuredDefaultValue(ctx, key);
  48675. const finalKey = getEscapedPropName(key);
  48676. if (d)
  48677. defaults.push(
  48678. `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
  48679. );
  48680. }
  48681. if (defaults.length) {
  48682. propsDecls = `/*@__PURE__*/${ctx.helper(
  48683. `mergeDefaults`
  48684. )}(${propsDecls}, {
  48685. ${defaults.join(",\n ")}
  48686. })`;
  48687. }
  48688. }
  48689. } else if (ctx.propsTypeDecl) {
  48690. propsDecls = extractRuntimeProps(ctx);
  48691. }
  48692. const modelsDecls = genModelProps(ctx);
  48693. if (propsDecls && modelsDecls) {
  48694. return `/*@__PURE__*/${ctx.helper(
  48695. "mergeModels"
  48696. )}(${propsDecls}, ${modelsDecls})`;
  48697. } else {
  48698. return modelsDecls || propsDecls;
  48699. }
  48700. }
  48701. function extractRuntimeProps(ctx) {
  48702. const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
  48703. if (!props.length) {
  48704. return;
  48705. }
  48706. const propStrings = [];
  48707. const hasStaticDefaults = hasStaticWithDefaults(ctx);
  48708. for (const prop of props) {
  48709. propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
  48710. if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
  48711. ctx.bindingMetadata[prop.key] = "props";
  48712. }
  48713. }
  48714. let propsDecls = `{
  48715. ${propStrings.join(",\n ")}
  48716. }`;
  48717. if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
  48718. propsDecls = `/*@__PURE__*/${ctx.helper(
  48719. "mergeDefaults"
  48720. )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
  48721. }
  48722. return propsDecls;
  48723. }
  48724. function resolveRuntimePropsFromType(ctx, node) {
  48725. const props = [];
  48726. const elements = resolveTypeElements(ctx, node);
  48727. for (const key in elements.props) {
  48728. const e = elements.props[key];
  48729. let type = inferRuntimeType(ctx, e);
  48730. let skipCheck = false;
  48731. if (type.includes(UNKNOWN_TYPE)) {
  48732. if (type.includes("Boolean") || type.includes("Function")) {
  48733. type = type.filter((t) => t !== UNKNOWN_TYPE);
  48734. skipCheck = true;
  48735. } else {
  48736. type = ["null"];
  48737. }
  48738. }
  48739. props.push({
  48740. key,
  48741. required: !e.optional,
  48742. type: type || [`null`],
  48743. skipCheck
  48744. });
  48745. }
  48746. return props;
  48747. }
  48748. function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStaticDefaults) {
  48749. let defaultString;
  48750. const destructured = genDestructuredDefaultValue(ctx, key, type);
  48751. if (destructured) {
  48752. defaultString = `default: ${destructured.valueString}${destructured.needSkipFactory ? `, skipFactory: true` : ``}`;
  48753. } else if (hasStaticDefaults) {
  48754. const prop = ctx.propsRuntimeDefaults.properties.find(
  48755. (node) => {
  48756. if (node.type === "SpreadElement") return false;
  48757. return resolveObjectKey(node.key, node.computed) === key;
  48758. }
  48759. );
  48760. if (prop) {
  48761. if (prop.type === "ObjectProperty") {
  48762. defaultString = `default: ${ctx.getString(prop.value)}`;
  48763. } else {
  48764. defaultString = `${prop.async ? "async " : ""}${prop.kind !== "method" ? `${prop.kind} ` : ""}default() ${ctx.getString(prop.body)}`;
  48765. }
  48766. }
  48767. }
  48768. const finalKey = getEscapedPropName(key);
  48769. if (!ctx.options.isProd) {
  48770. return `${finalKey}: { ${concatStrings([
  48771. `type: ${toRuntimeTypeString(type)}`,
  48772. `required: ${required}`,
  48773. skipCheck && "skipCheck: true",
  48774. defaultString
  48775. ])} }`;
  48776. } else if (type.some(
  48777. (el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
  48778. )) {
  48779. return `${finalKey}: { ${concatStrings([
  48780. `type: ${toRuntimeTypeString(type)}`,
  48781. defaultString
  48782. ])} }`;
  48783. } else {
  48784. if (ctx.isCE) {
  48785. if (defaultString) {
  48786. return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
  48787. type
  48788. )} }`}`;
  48789. } else {
  48790. return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
  48791. }
  48792. }
  48793. return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
  48794. }
  48795. }
  48796. function hasStaticWithDefaults(ctx) {
  48797. return !!(ctx.propsRuntimeDefaults && ctx.propsRuntimeDefaults.type === "ObjectExpression" && ctx.propsRuntimeDefaults.properties.every(
  48798. (node) => node.type !== "SpreadElement" && (!node.computed || node.key.type.endsWith("Literal"))
  48799. ));
  48800. }
  48801. function genDestructuredDefaultValue(ctx, key, inferredType) {
  48802. const destructured = ctx.propsDestructuredBindings[key];
  48803. const defaultVal = destructured && destructured.default;
  48804. if (defaultVal) {
  48805. const value = ctx.getString(defaultVal);
  48806. const unwrapped = unwrapTSNode(defaultVal);
  48807. if (inferredType && inferredType.length && !inferredType.includes("null")) {
  48808. const valueType = inferValueType(unwrapped);
  48809. if (valueType && !inferredType.includes(valueType)) {
  48810. ctx.error(
  48811. `Default value of prop "${key}" does not match declared type.`,
  48812. unwrapped
  48813. );
  48814. }
  48815. }
  48816. const needSkipFactory = !inferredType && (isFunctionType(unwrapped) || unwrapped.type === "Identifier");
  48817. const needFactoryWrap = !needSkipFactory && !isLiteralNode(unwrapped) && !(inferredType == null ? void 0 : inferredType.includes("Function"));
  48818. return {
  48819. valueString: needFactoryWrap ? `() => (${value})` : value,
  48820. needSkipFactory
  48821. };
  48822. }
  48823. }
  48824. function inferValueType(node) {
  48825. switch (node.type) {
  48826. case "StringLiteral":
  48827. return "String";
  48828. case "NumericLiteral":
  48829. return "Number";
  48830. case "BooleanLiteral":
  48831. return "Boolean";
  48832. case "ObjectExpression":
  48833. return "Object";
  48834. case "ArrayExpression":
  48835. return "Array";
  48836. case "FunctionExpression":
  48837. case "ArrowFunctionExpression":
  48838. return "Function";
  48839. }
  48840. }
  48841. function processPropsDestructure(ctx, declId) {
  48842. if (ctx.options.propsDestructure === "error") {
  48843. ctx.error(`Props destructure is explicitly prohibited via config.`, declId);
  48844. } else if (ctx.options.propsDestructure === false) {
  48845. return;
  48846. }
  48847. ctx.propsDestructureDecl = declId;
  48848. const registerBinding = (key, local, defaultValue) => {
  48849. ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
  48850. if (local !== key) {
  48851. ctx.bindingMetadata[local] = "props-aliased";
  48852. (ctx.bindingMetadata.__propsAliases || (ctx.bindingMetadata.__propsAliases = {}))[local] = key;
  48853. }
  48854. };
  48855. for (const prop of declId.properties) {
  48856. if (prop.type === "ObjectProperty") {
  48857. const propKey = resolveObjectKey(prop.key, prop.computed);
  48858. if (!propKey) {
  48859. ctx.error(
  48860. `${DEFINE_PROPS}() destructure cannot use computed key.`,
  48861. prop.key
  48862. );
  48863. }
  48864. if (prop.value.type === "AssignmentPattern") {
  48865. const { left, right } = prop.value;
  48866. if (left.type !== "Identifier") {
  48867. ctx.error(
  48868. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  48869. left
  48870. );
  48871. }
  48872. registerBinding(propKey, left.name, right);
  48873. } else if (prop.value.type === "Identifier") {
  48874. registerBinding(propKey, prop.value.name);
  48875. } else {
  48876. ctx.error(
  48877. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  48878. prop.value
  48879. );
  48880. }
  48881. } else {
  48882. ctx.propsDestructureRestId = prop.argument.name;
  48883. ctx.bindingMetadata[ctx.propsDestructureRestId] = "setup-reactive-const";
  48884. }
  48885. }
  48886. }
  48887. function transformDestructuredProps(ctx, vueImportAliases) {
  48888. if (ctx.options.propsDestructure === false) {
  48889. return;
  48890. }
  48891. const rootScope = /* @__PURE__ */ Object.create(null);
  48892. const scopeStack = [rootScope];
  48893. let currentScope = rootScope;
  48894. const excludedIds = /* @__PURE__ */ new WeakSet();
  48895. const parentStack = [];
  48896. const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
  48897. for (const key in ctx.propsDestructuredBindings) {
  48898. const { local } = ctx.propsDestructuredBindings[key];
  48899. rootScope[local] = true;
  48900. propsLocalToPublicMap[local] = key;
  48901. }
  48902. function pushScope() {
  48903. scopeStack.push(currentScope = Object.create(currentScope));
  48904. }
  48905. function popScope() {
  48906. scopeStack.pop();
  48907. currentScope = scopeStack[scopeStack.length - 1] || null;
  48908. }
  48909. function registerLocalBinding(id) {
  48910. excludedIds.add(id);
  48911. if (currentScope) {
  48912. currentScope[id.name] = false;
  48913. } else {
  48914. ctx.error(
  48915. "registerBinding called without active scope, something is wrong.",
  48916. id
  48917. );
  48918. }
  48919. }
  48920. function walkScope(node, isRoot = false) {
  48921. for (const stmt of node.body) {
  48922. if (stmt.type === "VariableDeclaration") {
  48923. walkVariableDeclaration(stmt, isRoot);
  48924. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  48925. if (stmt.declare || !stmt.id) continue;
  48926. registerLocalBinding(stmt.id);
  48927. } else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
  48928. walkVariableDeclaration(stmt.left);
  48929. } else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration && stmt.declaration.type === "VariableDeclaration") {
  48930. walkVariableDeclaration(stmt.declaration, isRoot);
  48931. } else if (stmt.type === "LabeledStatement" && stmt.body.type === "VariableDeclaration") {
  48932. walkVariableDeclaration(stmt.body, isRoot);
  48933. }
  48934. }
  48935. }
  48936. function walkVariableDeclaration(stmt, isRoot = false) {
  48937. if (stmt.declare) {
  48938. return;
  48939. }
  48940. for (const decl of stmt.declarations) {
  48941. const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
  48942. for (const id of extractIdentifiers$1(decl.id)) {
  48943. if (isDefineProps) {
  48944. excludedIds.add(id);
  48945. } else {
  48946. registerLocalBinding(id);
  48947. }
  48948. }
  48949. }
  48950. }
  48951. function rewriteId(id, parent, parentStack2) {
  48952. if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
  48953. ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
  48954. }
  48955. if (isStaticProperty(parent) && parent.shorthand) {
  48956. if (!parent.inPattern || isInDestructureAssignment(parent, parentStack2)) {
  48957. ctx.s.appendLeft(
  48958. id.end + ctx.startOffset,
  48959. `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
  48960. );
  48961. }
  48962. } else {
  48963. ctx.s.overwrite(
  48964. id.start + ctx.startOffset,
  48965. id.end + ctx.startOffset,
  48966. genPropsAccessExp(propsLocalToPublicMap[id.name])
  48967. );
  48968. }
  48969. }
  48970. function checkUsage(node, method, alias = method) {
  48971. if (isCallOf(node, alias)) {
  48972. const arg = unwrapTSNode(node.arguments[0]);
  48973. if (arg.type === "Identifier" && currentScope[arg.name]) {
  48974. ctx.error(
  48975. `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). Pass a getter () => ${arg.name} instead.`,
  48976. arg
  48977. );
  48978. }
  48979. }
  48980. }
  48981. const ast = ctx.scriptSetupAst;
  48982. walkScope(ast, true);
  48983. walk$2(ast, {
  48984. enter(node, parent) {
  48985. parent && parentStack.push(parent);
  48986. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  48987. return this.skip();
  48988. }
  48989. checkUsage(node, "watch", vueImportAliases.watch);
  48990. checkUsage(node, "toRef", vueImportAliases.toRef);
  48991. if (isFunctionType(node)) {
  48992. pushScope();
  48993. walkFunctionParams(node, registerLocalBinding);
  48994. if (node.body.type === "BlockStatement") {
  48995. walkScope(node.body);
  48996. }
  48997. return;
  48998. }
  48999. if (node.type === "CatchClause") {
  49000. pushScope();
  49001. if (node.param && node.param.type === "Identifier") {
  49002. registerLocalBinding(node.param);
  49003. }
  49004. walkScope(node.body);
  49005. return;
  49006. }
  49007. if (node.type === "BlockStatement" && !isFunctionType(parent)) {
  49008. pushScope();
  49009. walkScope(node);
  49010. return;
  49011. }
  49012. if (node.type === "Identifier") {
  49013. if (isReferencedIdentifier(node, parent, parentStack) && !excludedIds.has(node)) {
  49014. if (currentScope[node.name]) {
  49015. rewriteId(node, parent, parentStack);
  49016. }
  49017. }
  49018. }
  49019. },
  49020. leave(node, parent) {
  49021. parent && parentStack.pop();
  49022. if (node.type === "BlockStatement" && !isFunctionType(parent) || isFunctionType(node)) {
  49023. popScope();
  49024. }
  49025. }
  49026. });
  49027. }
  49028. const DEFINE_EMITS = "defineEmits";
  49029. function processDefineEmits(ctx, node, declId) {
  49030. if (!isCallOf(node, DEFINE_EMITS)) {
  49031. return false;
  49032. }
  49033. if (ctx.hasDefineEmitCall) {
  49034. ctx.error(`duplicate ${DEFINE_EMITS}() call`, node);
  49035. }
  49036. ctx.hasDefineEmitCall = true;
  49037. ctx.emitsRuntimeDecl = node.arguments[0];
  49038. if (node.typeParameters) {
  49039. if (ctx.emitsRuntimeDecl) {
  49040. ctx.error(
  49041. `${DEFINE_EMITS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  49042. node
  49043. );
  49044. }
  49045. ctx.emitsTypeDecl = node.typeParameters.params[0];
  49046. }
  49047. ctx.emitDecl = declId;
  49048. return true;
  49049. }
  49050. function genRuntimeEmits(ctx) {
  49051. let emitsDecl = "";
  49052. if (ctx.emitsRuntimeDecl) {
  49053. emitsDecl = ctx.getString(ctx.emitsRuntimeDecl).trim();
  49054. } else if (ctx.emitsTypeDecl) {
  49055. const typeDeclaredEmits = extractRuntimeEmits(ctx);
  49056. emitsDecl = typeDeclaredEmits.size ? `[${Array.from(typeDeclaredEmits).map((k) => JSON.stringify(k)).join(", ")}]` : ``;
  49057. }
  49058. if (ctx.hasDefineModelCall) {
  49059. let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
  49060. emitsDecl = emitsDecl ? `/*@__PURE__*/${ctx.helper(
  49061. "mergeModels"
  49062. )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
  49063. }
  49064. return emitsDecl;
  49065. }
  49066. function extractRuntimeEmits(ctx) {
  49067. const emits = /* @__PURE__ */ new Set();
  49068. const node = ctx.emitsTypeDecl;
  49069. if (node.type === "TSFunctionType") {
  49070. extractEventNames(ctx, node.parameters[0], emits);
  49071. return emits;
  49072. }
  49073. const { props, calls } = resolveTypeElements(ctx, node);
  49074. let hasProperty = false;
  49075. for (const key in props) {
  49076. emits.add(key);
  49077. hasProperty = true;
  49078. }
  49079. if (calls) {
  49080. if (hasProperty) {
  49081. ctx.error(
  49082. `defineEmits() type cannot mixed call signature and property syntax.`,
  49083. node
  49084. );
  49085. }
  49086. for (const call of calls) {
  49087. extractEventNames(ctx, call.parameters[0], emits);
  49088. }
  49089. }
  49090. return emits;
  49091. }
  49092. function extractEventNames(ctx, eventName, emits) {
  49093. if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
  49094. const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
  49095. for (const type of types) {
  49096. if (type.type === "TSLiteralType") {
  49097. if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
  49098. emits.add(String(type.literal.value));
  49099. }
  49100. }
  49101. }
  49102. }
  49103. }
  49104. const DEFINE_EXPOSE = "defineExpose";
  49105. function processDefineExpose(ctx, node) {
  49106. if (isCallOf(node, DEFINE_EXPOSE)) {
  49107. if (ctx.hasDefineExposeCall) {
  49108. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  49109. }
  49110. ctx.hasDefineExposeCall = true;
  49111. return true;
  49112. }
  49113. return false;
  49114. }
  49115. const DEFINE_SLOTS = "defineSlots";
  49116. function processDefineSlots(ctx, node, declId) {
  49117. if (!isCallOf(node, DEFINE_SLOTS)) {
  49118. return false;
  49119. }
  49120. if (ctx.hasDefineSlotsCall) {
  49121. ctx.error(`duplicate ${DEFINE_SLOTS}() call`, node);
  49122. }
  49123. ctx.hasDefineSlotsCall = true;
  49124. if (node.arguments.length > 0) {
  49125. ctx.error(`${DEFINE_SLOTS}() cannot accept arguments`, node);
  49126. }
  49127. if (declId) {
  49128. ctx.s.overwrite(
  49129. ctx.startOffset + node.start,
  49130. ctx.startOffset + node.end,
  49131. `${ctx.helper("useSlots")}()`
  49132. );
  49133. }
  49134. return true;
  49135. }
  49136. const DEFINE_OPTIONS = "defineOptions";
  49137. function processDefineOptions(ctx, node) {
  49138. if (!isCallOf(node, DEFINE_OPTIONS)) {
  49139. return false;
  49140. }
  49141. if (ctx.hasDefineOptionsCall) {
  49142. ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
  49143. }
  49144. if (node.typeParameters) {
  49145. ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
  49146. }
  49147. if (!node.arguments[0]) return true;
  49148. ctx.hasDefineOptionsCall = true;
  49149. ctx.optionsRuntimeDecl = unwrapTSNode(node.arguments[0]);
  49150. let propsOption = void 0;
  49151. let emitsOption = void 0;
  49152. let exposeOption = void 0;
  49153. let slotsOption = void 0;
  49154. if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
  49155. for (const prop of ctx.optionsRuntimeDecl.properties) {
  49156. if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
  49157. switch (prop.key.name) {
  49158. case "props":
  49159. propsOption = prop;
  49160. break;
  49161. case "emits":
  49162. emitsOption = prop;
  49163. break;
  49164. case "expose":
  49165. exposeOption = prop;
  49166. break;
  49167. case "slots":
  49168. slotsOption = prop;
  49169. break;
  49170. }
  49171. }
  49172. }
  49173. }
  49174. if (propsOption) {
  49175. ctx.error(
  49176. `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
  49177. propsOption
  49178. );
  49179. }
  49180. if (emitsOption) {
  49181. ctx.error(
  49182. `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
  49183. emitsOption
  49184. );
  49185. }
  49186. if (exposeOption) {
  49187. ctx.error(
  49188. `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
  49189. exposeOption
  49190. );
  49191. }
  49192. if (slotsOption) {
  49193. ctx.error(
  49194. `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
  49195. slotsOption
  49196. );
  49197. }
  49198. return true;
  49199. }
  49200. function processAwait(ctx, node, needSemi, isStatement) {
  49201. const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
  49202. const startOffset = ctx.startOffset;
  49203. const argumentStr = ctx.descriptor.source.slice(
  49204. argumentStart + startOffset,
  49205. node.argument.end + startOffset
  49206. );
  49207. const containsNestedAwait = /\bawait\b/.test(argumentStr);
  49208. ctx.s.overwrite(
  49209. node.start + startOffset,
  49210. argumentStart + startOffset,
  49211. `${needSemi ? `;` : ``}(
  49212. ([__temp,__restore] = ${ctx.helper(
  49213. `withAsyncContext`
  49214. )}(${containsNestedAwait ? `async ` : ``}() => `
  49215. );
  49216. ctx.s.appendLeft(
  49217. node.end + startOffset,
  49218. `)),
  49219. ${isStatement ? `` : `__temp = `}await __temp,
  49220. __restore()${isStatement ? `` : `,
  49221. __temp`}
  49222. )`
  49223. );
  49224. }
  49225. var __defProp$1 = Object.defineProperty;
  49226. var __defProps = Object.defineProperties;
  49227. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  49228. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  49229. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  49230. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  49231. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  49232. var __spreadValues$1 = (a, b) => {
  49233. for (var prop in b || (b = {}))
  49234. if (__hasOwnProp$1.call(b, prop))
  49235. __defNormalProp$1(a, prop, b[prop]);
  49236. if (__getOwnPropSymbols$1)
  49237. for (var prop of __getOwnPropSymbols$1(b)) {
  49238. if (__propIsEnum$1.call(b, prop))
  49239. __defNormalProp$1(a, prop, b[prop]);
  49240. }
  49241. return a;
  49242. };
  49243. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  49244. const MACROS = [
  49245. DEFINE_PROPS,
  49246. DEFINE_EMITS,
  49247. DEFINE_EXPOSE,
  49248. DEFINE_OPTIONS,
  49249. DEFINE_SLOTS,
  49250. DEFINE_MODEL,
  49251. WITH_DEFAULTS
  49252. ];
  49253. function compileScript(sfc, options) {
  49254. var _a, _b, _c;
  49255. if (!options.id) {
  49256. warnOnce$1(
  49257. `compileScript now requires passing the \`id\` option.
  49258. Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
  49259. );
  49260. }
  49261. const ctx = new ScriptCompileContext(sfc, options);
  49262. const { script, scriptSetup, source, filename } = sfc;
  49263. const hoistStatic = options.hoistStatic !== false && !script;
  49264. const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
  49265. const scriptLang = script && script.lang;
  49266. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  49267. if (!scriptSetup) {
  49268. if (!script) {
  49269. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  49270. }
  49271. return processNormalScript(ctx, scopeId);
  49272. }
  49273. if (script && scriptLang !== scriptSetupLang) {
  49274. throw new Error(
  49275. `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
  49276. );
  49277. }
  49278. if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
  49279. return scriptSetup;
  49280. }
  49281. const scriptBindings = /* @__PURE__ */ Object.create(null);
  49282. const setupBindings = /* @__PURE__ */ Object.create(null);
  49283. let defaultExport;
  49284. let hasAwait = false;
  49285. let hasInlinedSsrRenderFn = false;
  49286. const startOffset = ctx.startOffset;
  49287. const endOffset = ctx.endOffset;
  49288. const scriptStartOffset = script && script.loc.start.offset;
  49289. const scriptEndOffset = script && script.loc.end.offset;
  49290. function hoistNode(node) {
  49291. const start = node.start + startOffset;
  49292. let end = node.end + startOffset;
  49293. if (node.trailingComments && node.trailingComments.length > 0) {
  49294. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  49295. end = lastCommentNode.end + startOffset;
  49296. }
  49297. while (end <= source.length) {
  49298. if (!/\s/.test(source.charAt(end))) {
  49299. break;
  49300. }
  49301. end++;
  49302. }
  49303. ctx.s.move(start, end, 0);
  49304. }
  49305. function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
  49306. let isUsedInTemplate = needTemplateUsageCheck;
  49307. if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  49308. isUsedInTemplate = isImportUsed(local, sfc);
  49309. }
  49310. ctx.userImports[local] = {
  49311. isType,
  49312. imported,
  49313. local,
  49314. source: source2,
  49315. isFromSetup,
  49316. isUsedInTemplate
  49317. };
  49318. }
  49319. function checkInvalidScopeReference(node, method) {
  49320. if (!node) return;
  49321. walkIdentifiers(node, (id) => {
  49322. const binding = setupBindings[id.name];
  49323. if (binding && binding !== "literal-const") {
  49324. ctx.error(
  49325. `\`${method}()\` in <script setup> cannot reference locally declared variables because it will be hoisted outside of the setup() function. If your component options require initialization in the module scope, use a separate normal <script> to export the options instead.`,
  49326. id
  49327. );
  49328. }
  49329. });
  49330. }
  49331. const scriptAst = ctx.scriptAst;
  49332. const scriptSetupAst = ctx.scriptSetupAst;
  49333. if (scriptAst) {
  49334. for (const node of scriptAst.body) {
  49335. if (node.type === "ImportDeclaration") {
  49336. for (const specifier of node.specifiers) {
  49337. const imported = getImportedName(specifier);
  49338. registerUserImport(
  49339. node.source.value,
  49340. specifier.local.name,
  49341. imported,
  49342. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  49343. false,
  49344. !options.inlineTemplate
  49345. );
  49346. }
  49347. }
  49348. }
  49349. }
  49350. for (const node of scriptSetupAst.body) {
  49351. if (node.type === "ImportDeclaration") {
  49352. hoistNode(node);
  49353. let removed = 0;
  49354. const removeSpecifier = (i) => {
  49355. const removeLeft = i > removed;
  49356. removed++;
  49357. const current = node.specifiers[i];
  49358. const next = node.specifiers[i + 1];
  49359. ctx.s.remove(
  49360. removeLeft ? node.specifiers[i - 1].end + startOffset : current.start + startOffset,
  49361. next && !removeLeft ? next.start + startOffset : current.end + startOffset
  49362. );
  49363. };
  49364. for (let i = 0; i < node.specifiers.length; i++) {
  49365. const specifier = node.specifiers[i];
  49366. const local = specifier.local.name;
  49367. const imported = getImportedName(specifier);
  49368. const source2 = node.source.value;
  49369. const existing = ctx.userImports[local];
  49370. if (source2 === "vue" && MACROS.includes(imported)) {
  49371. if (local === imported) {
  49372. warnOnce$1(
  49373. `\`${imported}\` is a compiler macro and no longer needs to be imported.`
  49374. );
  49375. } else {
  49376. ctx.error(
  49377. `\`${imported}\` is a compiler macro and cannot be aliased to a different name.`,
  49378. specifier
  49379. );
  49380. }
  49381. removeSpecifier(i);
  49382. } else if (existing) {
  49383. if (existing.source === source2 && existing.imported === imported) {
  49384. removeSpecifier(i);
  49385. } else {
  49386. ctx.error(
  49387. `different imports aliased to same local name.`,
  49388. specifier
  49389. );
  49390. }
  49391. } else {
  49392. registerUserImport(
  49393. source2,
  49394. local,
  49395. imported,
  49396. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  49397. true,
  49398. !options.inlineTemplate
  49399. );
  49400. }
  49401. }
  49402. if (node.specifiers.length && removed === node.specifiers.length) {
  49403. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  49404. }
  49405. }
  49406. }
  49407. const vueImportAliases = {};
  49408. for (const key in ctx.userImports) {
  49409. const { source: source2, imported, local } = ctx.userImports[key];
  49410. if (source2 === "vue") vueImportAliases[imported] = local;
  49411. }
  49412. if (script && scriptAst) {
  49413. for (const node of scriptAst.body) {
  49414. if (node.type === "ExportDefaultDeclaration") {
  49415. defaultExport = node;
  49416. let optionProperties;
  49417. if (defaultExport.declaration.type === "ObjectExpression") {
  49418. optionProperties = defaultExport.declaration.properties;
  49419. } else if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
  49420. optionProperties = defaultExport.declaration.arguments[0].properties;
  49421. }
  49422. if (optionProperties) {
  49423. for (const p of optionProperties) {
  49424. if (p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name") {
  49425. ctx.hasDefaultExportName = true;
  49426. }
  49427. if ((p.type === "ObjectMethod" || p.type === "ObjectProperty") && p.key.type === "Identifier" && p.key.name === "render") {
  49428. ctx.hasDefaultExportRender = true;
  49429. }
  49430. }
  49431. }
  49432. const start = node.start + scriptStartOffset;
  49433. const end = node.declaration.start + scriptStartOffset;
  49434. ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `);
  49435. } else if (node.type === "ExportNamedDeclaration") {
  49436. const defaultSpecifier = node.specifiers.find(
  49437. (s) => s.exported.type === "Identifier" && s.exported.name === "default"
  49438. );
  49439. if (defaultSpecifier) {
  49440. defaultExport = node;
  49441. if (node.specifiers.length > 1) {
  49442. ctx.s.remove(
  49443. defaultSpecifier.start + scriptStartOffset,
  49444. defaultSpecifier.end + scriptStartOffset
  49445. );
  49446. } else {
  49447. ctx.s.remove(
  49448. node.start + scriptStartOffset,
  49449. node.end + scriptStartOffset
  49450. );
  49451. }
  49452. if (node.source) {
  49453. ctx.s.prepend(
  49454. `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'
  49455. `
  49456. );
  49457. } else {
  49458. ctx.s.appendLeft(
  49459. scriptEndOffset,
  49460. `
  49461. const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
  49462. `
  49463. );
  49464. }
  49465. }
  49466. if (node.declaration) {
  49467. walkDeclaration(
  49468. "script",
  49469. node.declaration,
  49470. scriptBindings,
  49471. vueImportAliases,
  49472. hoistStatic
  49473. );
  49474. }
  49475. } else if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  49476. walkDeclaration(
  49477. "script",
  49478. node,
  49479. scriptBindings,
  49480. vueImportAliases,
  49481. hoistStatic
  49482. );
  49483. }
  49484. }
  49485. if (scriptStartOffset > startOffset) {
  49486. if (!/\n$/.test(script.content.trim())) {
  49487. ctx.s.appendLeft(scriptEndOffset, `
  49488. `);
  49489. }
  49490. ctx.s.move(scriptStartOffset, scriptEndOffset, 0);
  49491. }
  49492. }
  49493. for (const node of scriptSetupAst.body) {
  49494. if (node.type === "ExpressionStatement") {
  49495. const expr = unwrapTSNode(node.expression);
  49496. if (processDefineProps(ctx, expr) || processDefineEmits(ctx, expr) || processDefineOptions(ctx, expr) || processDefineSlots(ctx, expr)) {
  49497. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  49498. } else if (processDefineExpose(ctx, expr)) {
  49499. const callee = expr.callee;
  49500. ctx.s.overwrite(
  49501. callee.start + startOffset,
  49502. callee.end + startOffset,
  49503. "__expose"
  49504. );
  49505. } else {
  49506. processDefineModel(ctx, expr);
  49507. }
  49508. }
  49509. if (node.type === "VariableDeclaration" && !node.declare) {
  49510. const total = node.declarations.length;
  49511. let left = total;
  49512. let lastNonRemoved;
  49513. for (let i = 0; i < total; i++) {
  49514. const decl = node.declarations[i];
  49515. const init = decl.init && unwrapTSNode(decl.init);
  49516. if (init) {
  49517. if (processDefineOptions(ctx, init)) {
  49518. ctx.error(
  49519. `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
  49520. node
  49521. );
  49522. }
  49523. const isDefineProps = processDefineProps(ctx, init, decl.id);
  49524. if (ctx.propsDestructureRestId) {
  49525. setupBindings[ctx.propsDestructureRestId] = "setup-reactive-const";
  49526. }
  49527. const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
  49528. !isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
  49529. if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
  49530. if (left === 1) {
  49531. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  49532. } else {
  49533. let start = decl.start + startOffset;
  49534. let end = decl.end + startOffset;
  49535. if (i === total - 1) {
  49536. start = node.declarations[lastNonRemoved].end + startOffset;
  49537. } else {
  49538. end = node.declarations[i + 1].start + startOffset;
  49539. }
  49540. ctx.s.remove(start, end);
  49541. left--;
  49542. }
  49543. } else if (isDefineEmits) {
  49544. ctx.s.overwrite(
  49545. startOffset + init.start,
  49546. startOffset + init.end,
  49547. "__emit"
  49548. );
  49549. } else {
  49550. lastNonRemoved = i;
  49551. }
  49552. }
  49553. }
  49554. }
  49555. let isAllLiteral = false;
  49556. if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  49557. isAllLiteral = walkDeclaration(
  49558. "scriptSetup",
  49559. node,
  49560. setupBindings,
  49561. vueImportAliases,
  49562. hoistStatic,
  49563. !!ctx.propsDestructureDecl
  49564. );
  49565. }
  49566. if (hoistStatic && isAllLiteral) {
  49567. hoistNode(node);
  49568. }
  49569. if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
  49570. const scope = [scriptSetupAst.body];
  49571. walk$2(node, {
  49572. enter(child, parent) {
  49573. if (isFunctionType(child)) {
  49574. this.skip();
  49575. }
  49576. if (child.type === "BlockStatement") {
  49577. scope.push(child.body);
  49578. }
  49579. if (child.type === "AwaitExpression") {
  49580. hasAwait = true;
  49581. const currentScope = scope[scope.length - 1];
  49582. const needsSemi = currentScope.some((n, i) => {
  49583. return (scope.length === 1 || i > 0) && n.type === "ExpressionStatement" && n.start === child.start;
  49584. });
  49585. processAwait(
  49586. ctx,
  49587. child,
  49588. needsSemi,
  49589. parent.type === "ExpressionStatement"
  49590. );
  49591. }
  49592. },
  49593. exit(node2) {
  49594. if (node2.type === "BlockStatement") scope.pop();
  49595. }
  49596. });
  49597. }
  49598. if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration") {
  49599. ctx.error(
  49600. `<script setup> cannot contain ES module exports. If you are using a previous version of <script setup>, please consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`,
  49601. node
  49602. );
  49603. }
  49604. if (ctx.isTS) {
  49605. if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
  49606. if (node.type !== "TSEnumDeclaration") {
  49607. hoistNode(node);
  49608. }
  49609. }
  49610. }
  49611. }
  49612. if (ctx.propsDestructureDecl) {
  49613. transformDestructuredProps(ctx, vueImportAliases);
  49614. }
  49615. checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
  49616. checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
  49617. checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
  49618. checkInvalidScopeReference(ctx.emitsRuntimeDecl, DEFINE_EMITS);
  49619. checkInvalidScopeReference(ctx.optionsRuntimeDecl, DEFINE_OPTIONS);
  49620. for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
  49621. for (const node of runtimeOptionNodes) {
  49622. checkInvalidScopeReference(node, DEFINE_MODEL);
  49623. }
  49624. }
  49625. if (script) {
  49626. if (startOffset < scriptStartOffset) {
  49627. ctx.s.remove(0, startOffset);
  49628. ctx.s.remove(endOffset, scriptStartOffset);
  49629. ctx.s.remove(scriptEndOffset, source.length);
  49630. } else {
  49631. ctx.s.remove(0, scriptStartOffset);
  49632. ctx.s.remove(scriptEndOffset, startOffset);
  49633. ctx.s.remove(endOffset, source.length);
  49634. }
  49635. } else {
  49636. ctx.s.remove(0, startOffset);
  49637. ctx.s.remove(endOffset, source.length);
  49638. }
  49639. if (scriptAst) {
  49640. Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body));
  49641. }
  49642. for (const [key, { isType, imported, source: source2 }] of Object.entries(
  49643. ctx.userImports
  49644. )) {
  49645. if (isType) continue;
  49646. ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
  49647. }
  49648. for (const key in scriptBindings) {
  49649. ctx.bindingMetadata[key] = scriptBindings[key];
  49650. }
  49651. for (const key in setupBindings) {
  49652. ctx.bindingMetadata[key] = setupBindings[key];
  49653. }
  49654. if (sfc.cssVars.length && // no need to do this when targeting SSR
  49655. !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
  49656. ctx.helperImports.add(CSS_VARS_HELPER);
  49657. ctx.helperImports.add("unref");
  49658. ctx.s.prependLeft(
  49659. startOffset,
  49660. `
  49661. ${genCssVarsCode(
  49662. sfc.cssVars,
  49663. ctx.bindingMetadata,
  49664. scopeId,
  49665. !!options.isProd
  49666. )}
  49667. `
  49668. );
  49669. }
  49670. let args = `__props`;
  49671. if (ctx.propsTypeDecl) {
  49672. args += `: any`;
  49673. }
  49674. if (ctx.propsDecl) {
  49675. if (ctx.propsDestructureRestId) {
  49676. ctx.s.overwrite(
  49677. startOffset + ctx.propsCall.start,
  49678. startOffset + ctx.propsCall.end,
  49679. `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
  49680. Object.keys(ctx.propsDestructuredBindings)
  49681. )})`
  49682. );
  49683. ctx.s.overwrite(
  49684. startOffset + ctx.propsDestructureDecl.start,
  49685. startOffset + ctx.propsDestructureDecl.end,
  49686. ctx.propsDestructureRestId
  49687. );
  49688. } else if (!ctx.propsDestructureDecl) {
  49689. ctx.s.overwrite(
  49690. startOffset + ctx.propsCall.start,
  49691. startOffset + ctx.propsCall.end,
  49692. "__props"
  49693. );
  49694. }
  49695. }
  49696. if (hasAwait) {
  49697. const any = ctx.isTS ? `: any` : ``;
  49698. ctx.s.prependLeft(startOffset, `
  49699. let __temp${any}, __restore${any}
  49700. `);
  49701. }
  49702. const destructureElements = ctx.hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [];
  49703. if (ctx.emitDecl) {
  49704. destructureElements.push(`emit: __emit`);
  49705. }
  49706. if (destructureElements.length) {
  49707. args += `, { ${destructureElements.join(", ")} }`;
  49708. }
  49709. let returned;
  49710. if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
  49711. const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
  49712. for (const key in ctx.userImports) {
  49713. if (!ctx.userImports[key].isType && ctx.userImports[key].isUsedInTemplate) {
  49714. allBindings[key] = true;
  49715. }
  49716. }
  49717. returned = `{ `;
  49718. for (const key in allBindings) {
  49719. if (allBindings[key] === true && ctx.userImports[key].source !== "vue" && !ctx.userImports[key].source.endsWith(".vue")) {
  49720. returned += `get ${key}() { return ${key} }, `;
  49721. } else if (ctx.bindingMetadata[key] === "setup-let") {
  49722. const setArg = key === "v" ? `_v` : `v`;
  49723. returned += `get ${key}() { return ${key} }, set ${key}(${setArg}) { ${key} = ${setArg} }, `;
  49724. } else {
  49725. returned += `${key}, `;
  49726. }
  49727. }
  49728. returned = returned.replace(/, $/, "") + ` }`;
  49729. } else {
  49730. if (sfc.template && !sfc.template.src) {
  49731. if (options.templateOptions && options.templateOptions.ssr) {
  49732. hasInlinedSsrRenderFn = true;
  49733. }
  49734. const { code, ast, preamble, tips, errors } = compileTemplate(__spreadProps(__spreadValues$1({
  49735. filename,
  49736. ast: sfc.template.ast,
  49737. source: sfc.template.content,
  49738. inMap: sfc.template.map
  49739. }, options.templateOptions), {
  49740. id: scopeId,
  49741. scoped: sfc.styles.some((s) => s.scoped),
  49742. isProd: options.isProd,
  49743. ssrCssVars: sfc.cssVars,
  49744. compilerOptions: __spreadProps(__spreadValues$1({}, options.templateOptions && options.templateOptions.compilerOptions), {
  49745. inline: true,
  49746. isTS: ctx.isTS,
  49747. bindingMetadata: ctx.bindingMetadata
  49748. })
  49749. }));
  49750. if (tips.length) {
  49751. tips.forEach(warnOnce$1);
  49752. }
  49753. const err = errors[0];
  49754. if (typeof err === "string") {
  49755. throw new Error(err);
  49756. } else if (err) {
  49757. if (err.loc) {
  49758. err.message += `
  49759. ` + sfc.filename + "\n" + generateCodeFrame(
  49760. source,
  49761. err.loc.start.offset,
  49762. err.loc.end.offset
  49763. ) + `
  49764. `;
  49765. }
  49766. throw err;
  49767. }
  49768. if (preamble) {
  49769. ctx.s.prepend(preamble);
  49770. }
  49771. if (ast && ast.helpers.has(UNREF)) {
  49772. ctx.helperImports.delete("unref");
  49773. }
  49774. returned = code;
  49775. } else {
  49776. returned = `() => {}`;
  49777. }
  49778. }
  49779. if (!options.inlineTemplate && true) {
  49780. ctx.s.appendRight(
  49781. endOffset,
  49782. `
  49783. const __returned__ = ${returned}
  49784. Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
  49785. return __returned__
  49786. }
  49787. `
  49788. );
  49789. } else {
  49790. ctx.s.appendRight(endOffset, `
  49791. return ${returned}
  49792. }
  49793. `);
  49794. }
  49795. const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
  49796. let runtimeOptions = ``;
  49797. if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  49798. const match = filename.match(/([^/\\]+)\.\w+$/);
  49799. if (match) {
  49800. runtimeOptions += `
  49801. __name: '${match[1]}',`;
  49802. }
  49803. }
  49804. if (hasInlinedSsrRenderFn) {
  49805. runtimeOptions += `
  49806. __ssrInlineRender: true,`;
  49807. }
  49808. const propsDecl = genRuntimeProps(ctx);
  49809. if (propsDecl) runtimeOptions += `
  49810. props: ${propsDecl},`;
  49811. const emitsDecl = genRuntimeEmits(ctx);
  49812. if (emitsDecl) runtimeOptions += `
  49813. emits: ${emitsDecl},`;
  49814. let definedOptions = "";
  49815. if (ctx.optionsRuntimeDecl) {
  49816. definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
  49817. }
  49818. const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
  49819. `;
  49820. if (ctx.isTS) {
  49821. const def = (defaultExport ? `
  49822. ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
  49823. ...${definedOptions},` : "");
  49824. ctx.s.prependLeft(
  49825. startOffset,
  49826. `
  49827. ${genDefaultAs} /*@__PURE__*/${ctx.helper(
  49828. `defineComponent`
  49829. )}({${def}${runtimeOptions}
  49830. ${hasAwait ? `async ` : ``}setup(${args}) {
  49831. ${exposeCall}`
  49832. );
  49833. ctx.s.appendRight(endOffset, `})`);
  49834. } else {
  49835. if (defaultExport || definedOptions) {
  49836. ctx.s.prependLeft(
  49837. startOffset,
  49838. `
  49839. ${genDefaultAs} /*@__PURE__*/Object.assign(${defaultExport ? `${normalScriptDefaultVar}, ` : ""}${definedOptions ? `${definedOptions}, ` : ""}{${runtimeOptions}
  49840. ${hasAwait ? `async ` : ``}setup(${args}) {
  49841. ${exposeCall}`
  49842. );
  49843. ctx.s.appendRight(endOffset, `})`);
  49844. } else {
  49845. ctx.s.prependLeft(
  49846. startOffset,
  49847. `
  49848. ${genDefaultAs} {${runtimeOptions}
  49849. ${hasAwait ? `async ` : ``}setup(${args}) {
  49850. ${exposeCall}`
  49851. );
  49852. ctx.s.appendRight(endOffset, `}`);
  49853. }
  49854. }
  49855. if (ctx.helperImports.size > 0) {
  49856. const runtimeModuleName = (_c = (_b = options.templateOptions) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.runtimeModuleName;
  49857. const importSrc = runtimeModuleName ? JSON.stringify(runtimeModuleName) : `'vue'`;
  49858. ctx.s.prepend(
  49859. `import { ${[...ctx.helperImports].map((h) => `${h} as _${h}`).join(", ")} } from ${importSrc}
  49860. `
  49861. );
  49862. }
  49863. return __spreadProps(__spreadValues$1({}, scriptSetup), {
  49864. bindings: ctx.bindingMetadata,
  49865. imports: ctx.userImports,
  49866. content: ctx.s.toString(),
  49867. map: options.sourceMap !== false ? ctx.s.generateMap({
  49868. source: filename,
  49869. hires: true,
  49870. includeContent: true
  49871. }) : void 0,
  49872. scriptAst: scriptAst == null ? void 0 : scriptAst.body,
  49873. scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
  49874. deps: ctx.deps ? [...ctx.deps] : void 0
  49875. });
  49876. }
  49877. function registerBinding(bindings, node, type) {
  49878. bindings[node.name] = type;
  49879. }
  49880. function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic, isPropsDestructureEnabled = false) {
  49881. let isAllLiteral = false;
  49882. if (node.type === "VariableDeclaration") {
  49883. const isConst = node.kind === "const";
  49884. isAllLiteral = isConst && node.declarations.every(
  49885. (decl) => decl.id.type === "Identifier" && isStaticNode(decl.init)
  49886. );
  49887. for (const { id, init: _init } of node.declarations) {
  49888. const init = _init && unwrapTSNode(_init);
  49889. const isConstMacroCall = isConst && isCallOf(
  49890. init,
  49891. (c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS || c === DEFINE_SLOTS
  49892. );
  49893. if (id.type === "Identifier") {
  49894. let bindingType;
  49895. const userReactiveBinding = userImportAliases["reactive"];
  49896. if ((hoistStatic || from === "script") && (isAllLiteral || isConst && isStaticNode(init))) {
  49897. bindingType = "literal-const";
  49898. } else if (isCallOf(init, userReactiveBinding)) {
  49899. bindingType = isConst ? "setup-reactive-const" : "setup-let";
  49900. } else if (
  49901. // if a declaration is a const literal, we can mark it so that
  49902. // the generated render fn code doesn't need to unref() it
  49903. isConstMacroCall || isConst && canNeverBeRef(init, userReactiveBinding)
  49904. ) {
  49905. bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
  49906. } else if (isConst) {
  49907. if (isCallOf(
  49908. init,
  49909. (m) => m === userImportAliases["ref"] || m === userImportAliases["computed"] || m === userImportAliases["shallowRef"] || m === userImportAliases["customRef"] || m === userImportAliases["toRef"] || m === DEFINE_MODEL
  49910. )) {
  49911. bindingType = "setup-ref";
  49912. } else {
  49913. bindingType = "setup-maybe-ref";
  49914. }
  49915. } else {
  49916. bindingType = "setup-let";
  49917. }
  49918. registerBinding(bindings, id, bindingType);
  49919. } else {
  49920. if (isCallOf(init, DEFINE_PROPS) && isPropsDestructureEnabled) {
  49921. continue;
  49922. }
  49923. if (id.type === "ObjectPattern") {
  49924. walkObjectPattern(id, bindings, isConst, isConstMacroCall);
  49925. } else if (id.type === "ArrayPattern") {
  49926. walkArrayPattern(id, bindings, isConst, isConstMacroCall);
  49927. }
  49928. }
  49929. }
  49930. } else if (node.type === "TSEnumDeclaration") {
  49931. isAllLiteral = node.members.every(
  49932. (member) => !member.initializer || isStaticNode(member.initializer)
  49933. );
  49934. bindings[node.id.name] = isAllLiteral ? "literal-const" : "setup-const";
  49935. } else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
  49936. bindings[node.id.name] = "setup-const";
  49937. }
  49938. return isAllLiteral;
  49939. }
  49940. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  49941. for (const p of node.properties) {
  49942. if (p.type === "ObjectProperty") {
  49943. if (p.key.type === "Identifier" && p.key === p.value) {
  49944. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  49945. registerBinding(bindings, p.key, type);
  49946. } else {
  49947. walkPattern(p.value, bindings, isConst, isDefineCall);
  49948. }
  49949. } else {
  49950. const type = isConst ? "setup-const" : "setup-let";
  49951. registerBinding(bindings, p.argument, type);
  49952. }
  49953. }
  49954. }
  49955. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  49956. for (const e of node.elements) {
  49957. e && walkPattern(e, bindings, isConst, isDefineCall);
  49958. }
  49959. }
  49960. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  49961. if (node.type === "Identifier") {
  49962. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  49963. registerBinding(bindings, node, type);
  49964. } else if (node.type === "RestElement") {
  49965. const type = isConst ? "setup-const" : "setup-let";
  49966. registerBinding(bindings, node.argument, type);
  49967. } else if (node.type === "ObjectPattern") {
  49968. walkObjectPattern(node, bindings, isConst);
  49969. } else if (node.type === "ArrayPattern") {
  49970. walkArrayPattern(node, bindings, isConst);
  49971. } else if (node.type === "AssignmentPattern") {
  49972. if (node.left.type === "Identifier") {
  49973. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  49974. registerBinding(bindings, node.left, type);
  49975. } else {
  49976. walkPattern(node.left, bindings, isConst);
  49977. }
  49978. }
  49979. }
  49980. function canNeverBeRef(node, userReactiveImport) {
  49981. if (isCallOf(node, userReactiveImport)) {
  49982. return true;
  49983. }
  49984. switch (node.type) {
  49985. case "UnaryExpression":
  49986. case "BinaryExpression":
  49987. case "ArrayExpression":
  49988. case "ObjectExpression":
  49989. case "FunctionExpression":
  49990. case "ArrowFunctionExpression":
  49991. case "UpdateExpression":
  49992. case "ClassExpression":
  49993. case "TaggedTemplateExpression":
  49994. return true;
  49995. case "SequenceExpression":
  49996. return canNeverBeRef(
  49997. node.expressions[node.expressions.length - 1],
  49998. userReactiveImport
  49999. );
  50000. default:
  50001. if (isLiteralNode(node)) {
  50002. return true;
  50003. }
  50004. return false;
  50005. }
  50006. }
  50007. function isStaticNode(node) {
  50008. node = unwrapTSNode(node);
  50009. switch (node.type) {
  50010. case "UnaryExpression":
  50011. return isStaticNode(node.argument);
  50012. case "LogicalExpression":
  50013. // 1 > 2
  50014. case "BinaryExpression":
  50015. return isStaticNode(node.left) && isStaticNode(node.right);
  50016. case "ConditionalExpression": {
  50017. return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
  50018. }
  50019. case "SequenceExpression":
  50020. // (1, 2)
  50021. case "TemplateLiteral":
  50022. return node.expressions.every((expr) => isStaticNode(expr));
  50023. case "ParenthesizedExpression":
  50024. return isStaticNode(node.expression);
  50025. case "StringLiteral":
  50026. case "NumericLiteral":
  50027. case "BooleanLiteral":
  50028. case "NullLiteral":
  50029. case "BigIntLiteral":
  50030. return true;
  50031. }
  50032. return false;
  50033. }
  50034. var __defProp = Object.defineProperty;
  50035. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  50036. var __hasOwnProp = Object.prototype.hasOwnProperty;
  50037. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  50038. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  50039. var __spreadValues = (a, b) => {
  50040. for (var prop in b || (b = {}))
  50041. if (__hasOwnProp.call(b, prop))
  50042. __defNormalProp(a, prop, b[prop]);
  50043. if (__getOwnPropSymbols)
  50044. for (var prop of __getOwnPropSymbols(b)) {
  50045. if (__propIsEnum.call(b, prop))
  50046. __defNormalProp(a, prop, b[prop]);
  50047. }
  50048. return a;
  50049. };
  50050. const version = "3.5.12";
  50051. const parseCache = parseCache$1;
  50052. const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
  50053. const walk = walk$2;
  50054. const shouldTransformRef = () => false;
  50055. var parse$4 = libExports.parse;
  50056. export { MagicString, parse$4 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, errorMessages, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$2 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };