Node-Red configuration
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

compiler-sfc.esm-browser.js 1.5MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519
  1. /**
  2. * @vue/compiler-sfc v3.4.38
  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, expectsLowerCase) {
  9. const set = new Set(str.split(","));
  10. return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
  11. }
  12. const EMPTY_OBJ = Object.freeze({}) ;
  13. const NOOP = () => {
  14. };
  15. const NO = () => false;
  16. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  17. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  18. const extend = Object.assign;
  19. const hasOwnProperty$4 = Object.prototype.hasOwnProperty;
  20. const hasOwn = (val, key) => hasOwnProperty$4.call(val, key);
  21. const isArray$3 = Array.isArray;
  22. const isMap = (val) => toTypeString(val) === "[object Map]";
  23. const isSet = (val) => toTypeString(val) === "[object Set]";
  24. const isFunction$1 = (val) => typeof val === "function";
  25. const isString$2 = (val) => typeof val === "string";
  26. const isSymbol$1 = (val) => typeof val === "symbol";
  27. const isObject$2 = (val) => val !== null && typeof val === "object";
  28. const objectToString$1 = Object.prototype.toString;
  29. const toTypeString = (value) => objectToString$1.call(value);
  30. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  31. const isReservedProp = /* @__PURE__ */ makeMap(
  32. // the leading comma is intentional so empty string "" is also included
  33. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  34. );
  35. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  36. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  37. );
  38. const cacheStringFunction = (fn) => {
  39. const cache = /* @__PURE__ */ Object.create(null);
  40. return (str) => {
  41. const hit = cache[str];
  42. return hit || (cache[str] = fn(str));
  43. };
  44. };
  45. const camelizeRE = /-(\w)/g;
  46. const camelize = cacheStringFunction((str) => {
  47. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  48. });
  49. const hyphenateRE = /\B([A-Z])/g;
  50. const hyphenate = cacheStringFunction(
  51. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  52. );
  53. const capitalize$1 = cacheStringFunction((str) => {
  54. return str.charAt(0).toUpperCase() + str.slice(1);
  55. });
  56. const toHandlerKey = cacheStringFunction((str) => {
  57. const s = str ? `on${capitalize$1(str)}` : ``;
  58. return s;
  59. });
  60. const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
  61. function genPropsAccessExp(name) {
  62. return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
  63. }
  64. const PatchFlagNames = {
  65. [1]: `TEXT`,
  66. [2]: `CLASS`,
  67. [4]: `STYLE`,
  68. [8]: `PROPS`,
  69. [16]: `FULL_PROPS`,
  70. [32]: `NEED_HYDRATION`,
  71. [64]: `STABLE_FRAGMENT`,
  72. [128]: `KEYED_FRAGMENT`,
  73. [256]: `UNKEYED_FRAGMENT`,
  74. [512]: `NEED_PATCH`,
  75. [1024]: `DYNAMIC_SLOTS`,
  76. [2048]: `DEV_ROOT_FRAGMENT`,
  77. [-1]: `HOISTED`,
  78. [-2]: `BAIL`
  79. };
  80. const slotFlagsText = {
  81. [1]: "STABLE",
  82. [2]: "DYNAMIC",
  83. [3]: "FORWARDED"
  84. };
  85. 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";
  86. const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
  87. const range = 2;
  88. function generateCodeFrame(source, start = 0, end = source.length) {
  89. start = Math.max(0, Math.min(start, source.length));
  90. end = Math.max(0, Math.min(end, source.length));
  91. if (start > end) return "";
  92. let lines = source.split(/(\r?\n)/);
  93. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  94. lines = lines.filter((_, idx) => idx % 2 === 0);
  95. let count = 0;
  96. const res = [];
  97. for (let i = 0; i < lines.length; i++) {
  98. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  99. if (count >= start) {
  100. for (let j = i - range; j <= i + range || end > count; j++) {
  101. if (j < 0 || j >= lines.length) continue;
  102. const line = j + 1;
  103. res.push(
  104. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  105. );
  106. const lineLength = lines[j].length;
  107. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  108. if (j === i) {
  109. const pad = start - (count - (lineLength + newLineSeqLength));
  110. const length = Math.max(
  111. 1,
  112. end > count ? lineLength - pad : end - start
  113. );
  114. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  115. } else if (j > i) {
  116. if (end > count) {
  117. const length = Math.max(Math.min(end - count, lineLength), 1);
  118. res.push(` | ` + "^".repeat(length));
  119. }
  120. count += lineLength + newLineSeqLength;
  121. }
  122. }
  123. break;
  124. }
  125. }
  126. return res.join("\n");
  127. }
  128. function normalizeStyle(value) {
  129. if (isArray$3(value)) {
  130. const res = {};
  131. for (let i = 0; i < value.length; i++) {
  132. const item = value[i];
  133. const normalized = isString$2(item) ? parseStringStyle(item) : normalizeStyle(item);
  134. if (normalized) {
  135. for (const key in normalized) {
  136. res[key] = normalized[key];
  137. }
  138. }
  139. }
  140. return res;
  141. } else if (isString$2(value) || isObject$2(value)) {
  142. return value;
  143. }
  144. }
  145. const listDelimiterRE = /;(?![^(]*\))/g;
  146. const propertyDelimiterRE = /:([^]+)/;
  147. const styleCommentRE = /\/\*[^]*?\*\//g;
  148. function parseStringStyle(cssText) {
  149. const ret = {};
  150. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  151. if (item) {
  152. const tmp = item.split(propertyDelimiterRE);
  153. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  154. }
  155. });
  156. return ret;
  157. }
  158. function stringifyStyle(styles) {
  159. let ret = "";
  160. if (!styles || isString$2(styles)) {
  161. return ret;
  162. }
  163. for (const key in styles) {
  164. const value = styles[key];
  165. if (isString$2(value) || typeof value === "number") {
  166. const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
  167. ret += `${normalizedKey}:${value};`;
  168. }
  169. }
  170. return ret;
  171. }
  172. function normalizeClass(value) {
  173. let res = "";
  174. if (isString$2(value)) {
  175. res = value;
  176. } else if (isArray$3(value)) {
  177. for (let i = 0; i < value.length; i++) {
  178. const normalized = normalizeClass(value[i]);
  179. if (normalized) {
  180. res += normalized + " ";
  181. }
  182. }
  183. } else if (isObject$2(value)) {
  184. for (const name in value) {
  185. if (value[name]) {
  186. res += name + " ";
  187. }
  188. }
  189. }
  190. return res.trim();
  191. }
  192. 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";
  193. 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";
  194. 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";
  195. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  196. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  197. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  198. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  199. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  200. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  201. const isBooleanAttr = /* @__PURE__ */ makeMap(
  202. specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
  203. );
  204. const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
  205. const attrValidationCache = {};
  206. function isSSRSafeAttrName(name) {
  207. if (attrValidationCache.hasOwnProperty(name)) {
  208. return attrValidationCache[name];
  209. }
  210. const isUnsafe = unsafeAttrCharRE.test(name);
  211. if (isUnsafe) {
  212. console.error(`unsafe attribute name: ${name}`);
  213. }
  214. return attrValidationCache[name] = !isUnsafe;
  215. }
  216. const propsToAttrMap = {
  217. acceptCharset: "accept-charset",
  218. className: "class",
  219. htmlFor: "for",
  220. httpEquiv: "http-equiv"
  221. };
  222. const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
  223. `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`
  224. );
  225. const isKnownSvgAttr = /* @__PURE__ */ makeMap(
  226. `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`
  227. );
  228. const escapeRE = /["'&<>]/;
  229. function escapeHtml(string) {
  230. const str = "" + string;
  231. const match = escapeRE.exec(str);
  232. if (!match) {
  233. return str;
  234. }
  235. let html = "";
  236. let escaped;
  237. let index;
  238. let lastIndex = 0;
  239. for (index = match.index; index < str.length; index++) {
  240. switch (str.charCodeAt(index)) {
  241. case 34:
  242. escaped = "&quot;";
  243. break;
  244. case 38:
  245. escaped = "&amp;";
  246. break;
  247. case 39:
  248. escaped = "&#39;";
  249. break;
  250. case 60:
  251. escaped = "&lt;";
  252. break;
  253. case 62:
  254. escaped = "&gt;";
  255. break;
  256. default:
  257. continue;
  258. }
  259. if (lastIndex !== index) {
  260. html += str.slice(lastIndex, index);
  261. }
  262. lastIndex = index + 1;
  263. html += escaped;
  264. }
  265. return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
  266. }
  267. const isRef = (val) => {
  268. return !!(val && val.__v_isRef === true);
  269. };
  270. const toDisplayString = (val) => {
  271. return isString$2(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);
  272. };
  273. const replacer = (_key, val) => {
  274. if (isRef(val)) {
  275. return replacer(_key, val.value);
  276. } else if (isMap(val)) {
  277. return {
  278. [`Map(${val.size})`]: [...val.entries()].reduce(
  279. (entries, [key, val2], i) => {
  280. entries[stringifySymbol(key, i) + " =>"] = val2;
  281. return entries;
  282. },
  283. {}
  284. )
  285. };
  286. } else if (isSet(val)) {
  287. return {
  288. [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
  289. };
  290. } else if (isSymbol$1(val)) {
  291. return stringifySymbol(val);
  292. } else if (isObject$2(val) && !isArray$3(val) && !isPlainObject(val)) {
  293. return String(val);
  294. }
  295. return val;
  296. };
  297. const stringifySymbol = (v, i = "") => {
  298. var _a;
  299. return (
  300. // Symbol.description in es2019+ so we need to cast here to pass
  301. // the lib: es2016 check
  302. isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
  303. );
  304. };
  305. const FRAGMENT = Symbol(`Fragment` );
  306. const TELEPORT = Symbol(`Teleport` );
  307. const SUSPENSE = Symbol(`Suspense` );
  308. const KEEP_ALIVE = Symbol(`KeepAlive` );
  309. const BASE_TRANSITION = Symbol(`BaseTransition` );
  310. const OPEN_BLOCK = Symbol(`openBlock` );
  311. const CREATE_BLOCK = Symbol(`createBlock` );
  312. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  313. const CREATE_VNODE = Symbol(`createVNode` );
  314. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  315. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  316. const CREATE_TEXT = Symbol(`createTextVNode` );
  317. const CREATE_STATIC = Symbol(`createStaticVNode` );
  318. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  319. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  320. `resolveDynamicComponent`
  321. );
  322. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  323. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  324. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  325. const RENDER_LIST = Symbol(`renderList` );
  326. const RENDER_SLOT = Symbol(`renderSlot` );
  327. const CREATE_SLOTS = Symbol(`createSlots` );
  328. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  329. const MERGE_PROPS = Symbol(`mergeProps` );
  330. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  331. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  332. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  333. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  334. const TO_HANDLERS = Symbol(`toHandlers` );
  335. const CAMELIZE = Symbol(`camelize` );
  336. const CAPITALIZE = Symbol(`capitalize` );
  337. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  338. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  339. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  340. const POP_SCOPE_ID = Symbol(`popScopeId` );
  341. const WITH_CTX = Symbol(`withCtx` );
  342. const UNREF = Symbol(`unref` );
  343. const IS_REF = Symbol(`isRef` );
  344. const WITH_MEMO = Symbol(`withMemo` );
  345. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  346. const helperNameMap = {
  347. [FRAGMENT]: `Fragment`,
  348. [TELEPORT]: `Teleport`,
  349. [SUSPENSE]: `Suspense`,
  350. [KEEP_ALIVE]: `KeepAlive`,
  351. [BASE_TRANSITION]: `BaseTransition`,
  352. [OPEN_BLOCK]: `openBlock`,
  353. [CREATE_BLOCK]: `createBlock`,
  354. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  355. [CREATE_VNODE]: `createVNode`,
  356. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  357. [CREATE_COMMENT]: `createCommentVNode`,
  358. [CREATE_TEXT]: `createTextVNode`,
  359. [CREATE_STATIC]: `createStaticVNode`,
  360. [RESOLVE_COMPONENT]: `resolveComponent`,
  361. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  362. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  363. [RESOLVE_FILTER]: `resolveFilter`,
  364. [WITH_DIRECTIVES]: `withDirectives`,
  365. [RENDER_LIST]: `renderList`,
  366. [RENDER_SLOT]: `renderSlot`,
  367. [CREATE_SLOTS]: `createSlots`,
  368. [TO_DISPLAY_STRING]: `toDisplayString`,
  369. [MERGE_PROPS]: `mergeProps`,
  370. [NORMALIZE_CLASS]: `normalizeClass`,
  371. [NORMALIZE_STYLE]: `normalizeStyle`,
  372. [NORMALIZE_PROPS]: `normalizeProps`,
  373. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  374. [TO_HANDLERS]: `toHandlers`,
  375. [CAMELIZE]: `camelize`,
  376. [CAPITALIZE]: `capitalize`,
  377. [TO_HANDLER_KEY]: `toHandlerKey`,
  378. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  379. [PUSH_SCOPE_ID]: `pushScopeId`,
  380. [POP_SCOPE_ID]: `popScopeId`,
  381. [WITH_CTX]: `withCtx`,
  382. [UNREF]: `unref`,
  383. [IS_REF]: `isRef`,
  384. [WITH_MEMO]: `withMemo`,
  385. [IS_MEMO_SAME]: `isMemoSame`
  386. };
  387. function registerRuntimeHelpers(helpers) {
  388. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  389. helperNameMap[s] = helpers[s];
  390. });
  391. }
  392. const Namespaces = {
  393. "HTML": 0,
  394. "0": "HTML",
  395. "SVG": 1,
  396. "1": "SVG",
  397. "MATH_ML": 2,
  398. "2": "MATH_ML"
  399. };
  400. const NodeTypes = {
  401. "ROOT": 0,
  402. "0": "ROOT",
  403. "ELEMENT": 1,
  404. "1": "ELEMENT",
  405. "TEXT": 2,
  406. "2": "TEXT",
  407. "COMMENT": 3,
  408. "3": "COMMENT",
  409. "SIMPLE_EXPRESSION": 4,
  410. "4": "SIMPLE_EXPRESSION",
  411. "INTERPOLATION": 5,
  412. "5": "INTERPOLATION",
  413. "ATTRIBUTE": 6,
  414. "6": "ATTRIBUTE",
  415. "DIRECTIVE": 7,
  416. "7": "DIRECTIVE",
  417. "COMPOUND_EXPRESSION": 8,
  418. "8": "COMPOUND_EXPRESSION",
  419. "IF": 9,
  420. "9": "IF",
  421. "IF_BRANCH": 10,
  422. "10": "IF_BRANCH",
  423. "FOR": 11,
  424. "11": "FOR",
  425. "TEXT_CALL": 12,
  426. "12": "TEXT_CALL",
  427. "VNODE_CALL": 13,
  428. "13": "VNODE_CALL",
  429. "JS_CALL_EXPRESSION": 14,
  430. "14": "JS_CALL_EXPRESSION",
  431. "JS_OBJECT_EXPRESSION": 15,
  432. "15": "JS_OBJECT_EXPRESSION",
  433. "JS_PROPERTY": 16,
  434. "16": "JS_PROPERTY",
  435. "JS_ARRAY_EXPRESSION": 17,
  436. "17": "JS_ARRAY_EXPRESSION",
  437. "JS_FUNCTION_EXPRESSION": 18,
  438. "18": "JS_FUNCTION_EXPRESSION",
  439. "JS_CONDITIONAL_EXPRESSION": 19,
  440. "19": "JS_CONDITIONAL_EXPRESSION",
  441. "JS_CACHE_EXPRESSION": 20,
  442. "20": "JS_CACHE_EXPRESSION",
  443. "JS_BLOCK_STATEMENT": 21,
  444. "21": "JS_BLOCK_STATEMENT",
  445. "JS_TEMPLATE_LITERAL": 22,
  446. "22": "JS_TEMPLATE_LITERAL",
  447. "JS_IF_STATEMENT": 23,
  448. "23": "JS_IF_STATEMENT",
  449. "JS_ASSIGNMENT_EXPRESSION": 24,
  450. "24": "JS_ASSIGNMENT_EXPRESSION",
  451. "JS_SEQUENCE_EXPRESSION": 25,
  452. "25": "JS_SEQUENCE_EXPRESSION",
  453. "JS_RETURN_STATEMENT": 26,
  454. "26": "JS_RETURN_STATEMENT"
  455. };
  456. const ElementTypes = {
  457. "ELEMENT": 0,
  458. "0": "ELEMENT",
  459. "COMPONENT": 1,
  460. "1": "COMPONENT",
  461. "SLOT": 2,
  462. "2": "SLOT",
  463. "TEMPLATE": 3,
  464. "3": "TEMPLATE"
  465. };
  466. const ConstantTypes = {
  467. "NOT_CONSTANT": 0,
  468. "0": "NOT_CONSTANT",
  469. "CAN_SKIP_PATCH": 1,
  470. "1": "CAN_SKIP_PATCH",
  471. "CAN_HOIST": 2,
  472. "2": "CAN_HOIST",
  473. "CAN_STRINGIFY": 3,
  474. "3": "CAN_STRINGIFY"
  475. };
  476. const locStub = {
  477. start: { line: 1, column: 1, offset: 0 },
  478. end: { line: 1, column: 1, offset: 0 },
  479. source: ""
  480. };
  481. function createRoot(children, source = "") {
  482. return {
  483. type: 0,
  484. source,
  485. children,
  486. helpers: /* @__PURE__ */ new Set(),
  487. components: [],
  488. directives: [],
  489. hoists: [],
  490. imports: [],
  491. cached: 0,
  492. temps: 0,
  493. codegenNode: void 0,
  494. loc: locStub
  495. };
  496. }
  497. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  498. if (context) {
  499. if (isBlock) {
  500. context.helper(OPEN_BLOCK);
  501. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  502. } else {
  503. context.helper(getVNodeHelper(context.inSSR, isComponent));
  504. }
  505. if (directives) {
  506. context.helper(WITH_DIRECTIVES);
  507. }
  508. }
  509. return {
  510. type: 13,
  511. tag,
  512. props,
  513. children,
  514. patchFlag,
  515. dynamicProps,
  516. directives,
  517. isBlock,
  518. disableTracking,
  519. isComponent,
  520. loc
  521. };
  522. }
  523. function createArrayExpression(elements, loc = locStub) {
  524. return {
  525. type: 17,
  526. loc,
  527. elements
  528. };
  529. }
  530. function createObjectExpression(properties, loc = locStub) {
  531. return {
  532. type: 15,
  533. loc,
  534. properties
  535. };
  536. }
  537. function createObjectProperty(key, value) {
  538. return {
  539. type: 16,
  540. loc: locStub,
  541. key: isString$2(key) ? createSimpleExpression(key, true) : key,
  542. value
  543. };
  544. }
  545. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  546. return {
  547. type: 4,
  548. loc,
  549. content,
  550. isStatic,
  551. constType: isStatic ? 3 : constType
  552. };
  553. }
  554. function createInterpolation(content, loc) {
  555. return {
  556. type: 5,
  557. loc,
  558. content: isString$2(content) ? createSimpleExpression(content, false, loc) : content
  559. };
  560. }
  561. function createCompoundExpression(children, loc = locStub) {
  562. return {
  563. type: 8,
  564. loc,
  565. children
  566. };
  567. }
  568. function createCallExpression(callee, args = [], loc = locStub) {
  569. return {
  570. type: 14,
  571. loc,
  572. callee,
  573. arguments: args
  574. };
  575. }
  576. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  577. return {
  578. type: 18,
  579. params,
  580. returns,
  581. newline,
  582. isSlot,
  583. loc
  584. };
  585. }
  586. function createConditionalExpression(test, consequent, alternate, newline = true) {
  587. return {
  588. type: 19,
  589. test,
  590. consequent,
  591. alternate,
  592. newline,
  593. loc: locStub
  594. };
  595. }
  596. function createCacheExpression(index, value, isVOnce = false) {
  597. return {
  598. type: 20,
  599. index,
  600. value,
  601. isVOnce,
  602. loc: locStub
  603. };
  604. }
  605. function createBlockStatement(body) {
  606. return {
  607. type: 21,
  608. body,
  609. loc: locStub
  610. };
  611. }
  612. function createTemplateLiteral(elements) {
  613. return {
  614. type: 22,
  615. elements,
  616. loc: locStub
  617. };
  618. }
  619. function createIfStatement(test, consequent, alternate) {
  620. return {
  621. type: 23,
  622. test,
  623. consequent,
  624. alternate,
  625. loc: locStub
  626. };
  627. }
  628. function createAssignmentExpression(left, right) {
  629. return {
  630. type: 24,
  631. left,
  632. right,
  633. loc: locStub
  634. };
  635. }
  636. function createSequenceExpression(expressions) {
  637. return {
  638. type: 25,
  639. expressions,
  640. loc: locStub
  641. };
  642. }
  643. function createReturnStatement(returns) {
  644. return {
  645. type: 26,
  646. returns,
  647. loc: locStub
  648. };
  649. }
  650. function getVNodeHelper(ssr, isComponent) {
  651. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  652. }
  653. function getVNodeBlockHelper(ssr, isComponent) {
  654. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  655. }
  656. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  657. if (!node.isBlock) {
  658. node.isBlock = true;
  659. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  660. helper(OPEN_BLOCK);
  661. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  662. }
  663. }
  664. // Generated using scripts/write-decode-map.ts
  665. var htmlDecodeTree = new Uint16Array(
  666. // prettier-ignore
  667. "\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"
  668. .split("")
  669. .map((c) => c.charCodeAt(0)));
  670. // Generated using scripts/write-decode-map.ts
  671. var xmlDecodeTree = new Uint16Array(
  672. // prettier-ignore
  673. "\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022"
  674. .split("")
  675. .map((c) => c.charCodeAt(0)));
  676. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  677. var _a$1;
  678. const decodeMap = new Map([
  679. [0, 65533],
  680. // C1 Unicode control character reference replacements
  681. [128, 8364],
  682. [130, 8218],
  683. [131, 402],
  684. [132, 8222],
  685. [133, 8230],
  686. [134, 8224],
  687. [135, 8225],
  688. [136, 710],
  689. [137, 8240],
  690. [138, 352],
  691. [139, 8249],
  692. [140, 338],
  693. [142, 381],
  694. [145, 8216],
  695. [146, 8217],
  696. [147, 8220],
  697. [148, 8221],
  698. [149, 8226],
  699. [150, 8211],
  700. [151, 8212],
  701. [152, 732],
  702. [153, 8482],
  703. [154, 353],
  704. [155, 8250],
  705. [156, 339],
  706. [158, 382],
  707. [159, 376],
  708. ]);
  709. /**
  710. * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
  711. */
  712. const fromCodePoint =
  713. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  714. (_a$1 = String.fromCodePoint) !== null && _a$1 !== void 0 ? _a$1 : function (codePoint) {
  715. let output = "";
  716. if (codePoint > 0xffff) {
  717. codePoint -= 0x10000;
  718. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  719. codePoint = 0xdc00 | (codePoint & 0x3ff);
  720. }
  721. output += String.fromCharCode(codePoint);
  722. return output;
  723. };
  724. /**
  725. * Replace the given code point with a replacement character if it is a
  726. * surrogate or is outside the valid range. Otherwise return the code
  727. * point unchanged.
  728. */
  729. function replaceCodePoint(codePoint) {
  730. var _a;
  731. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  732. return 0xfffd;
  733. }
  734. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  735. }
  736. var CharCodes;
  737. (function (CharCodes) {
  738. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  739. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  740. CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
  741. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  742. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  743. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  744. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  745. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  746. CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
  747. CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
  748. CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
  749. CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
  750. })(CharCodes || (CharCodes = {}));
  751. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  752. const TO_LOWER_BIT = 0b100000;
  753. var BinTrieFlags;
  754. (function (BinTrieFlags) {
  755. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  756. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  757. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  758. })(BinTrieFlags || (BinTrieFlags = {}));
  759. function isNumber$2(code) {
  760. return code >= CharCodes.ZERO && code <= CharCodes.NINE;
  761. }
  762. function isHexadecimalCharacter(code) {
  763. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
  764. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
  765. }
  766. function isAsciiAlphaNumeric(code) {
  767. return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
  768. (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
  769. isNumber$2(code));
  770. }
  771. /**
  772. * Checks if the given character is a valid end character for an entity in an attribute.
  773. *
  774. * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  775. * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  776. */
  777. function isEntityInAttributeInvalidEnd(code) {
  778. return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
  779. }
  780. var EntityDecoderState;
  781. (function (EntityDecoderState) {
  782. EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
  783. EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
  784. EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
  785. EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
  786. EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
  787. })(EntityDecoderState || (EntityDecoderState = {}));
  788. var DecodingMode;
  789. (function (DecodingMode) {
  790. /** Entities in text nodes that can end with any character. */
  791. DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
  792. /** Only allow entities terminated with a semicolon. */
  793. DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
  794. /** Entities in attributes have limitations on ending characters. */
  795. DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
  796. })(DecodingMode || (DecodingMode = {}));
  797. /**
  798. * Token decoder with support of writing partial entities.
  799. */
  800. class EntityDecoder {
  801. constructor(
  802. /** The tree used to decode entities. */
  803. decodeTree,
  804. /**
  805. * The function that is called when a codepoint is decoded.
  806. *
  807. * For multi-byte named entities, this will be called multiple times,
  808. * with the second codepoint, and the same `consumed` value.
  809. *
  810. * @param codepoint The decoded codepoint.
  811. * @param consumed The number of bytes consumed by the decoder.
  812. */
  813. emitCodePoint,
  814. /** An object that is used to produce errors. */
  815. errors) {
  816. this.decodeTree = decodeTree;
  817. this.emitCodePoint = emitCodePoint;
  818. this.errors = errors;
  819. /** The current state of the decoder. */
  820. this.state = EntityDecoderState.EntityStart;
  821. /** Characters that were consumed while parsing an entity. */
  822. this.consumed = 1;
  823. /**
  824. * The result of the entity.
  825. *
  826. * Either the result index of a numeric entity, or the codepoint of a
  827. * numeric entity.
  828. */
  829. this.result = 0;
  830. /** The current index in the decode tree. */
  831. this.treeIndex = 0;
  832. /** The number of characters that were consumed in excess. */
  833. this.excess = 1;
  834. /** The mode in which the decoder is operating. */
  835. this.decodeMode = DecodingMode.Strict;
  836. }
  837. /** Resets the instance to make it reusable. */
  838. startEntity(decodeMode) {
  839. this.decodeMode = decodeMode;
  840. this.state = EntityDecoderState.EntityStart;
  841. this.result = 0;
  842. this.treeIndex = 0;
  843. this.excess = 1;
  844. this.consumed = 1;
  845. }
  846. /**
  847. * Write an entity to the decoder. This can be called multiple times with partial entities.
  848. * If the entity is incomplete, the decoder will return -1.
  849. *
  850. * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
  851. * entity is incomplete, and resume when the next string is written.
  852. *
  853. * @param string The string containing the entity (or a continuation of the entity).
  854. * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
  855. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  856. */
  857. write(str, offset) {
  858. switch (this.state) {
  859. case EntityDecoderState.EntityStart: {
  860. if (str.charCodeAt(offset) === CharCodes.NUM) {
  861. this.state = EntityDecoderState.NumericStart;
  862. this.consumed += 1;
  863. return this.stateNumericStart(str, offset + 1);
  864. }
  865. this.state = EntityDecoderState.NamedEntity;
  866. return this.stateNamedEntity(str, offset);
  867. }
  868. case EntityDecoderState.NumericStart: {
  869. return this.stateNumericStart(str, offset);
  870. }
  871. case EntityDecoderState.NumericDecimal: {
  872. return this.stateNumericDecimal(str, offset);
  873. }
  874. case EntityDecoderState.NumericHex: {
  875. return this.stateNumericHex(str, offset);
  876. }
  877. case EntityDecoderState.NamedEntity: {
  878. return this.stateNamedEntity(str, offset);
  879. }
  880. }
  881. }
  882. /**
  883. * Switches between the numeric decimal and hexadecimal states.
  884. *
  885. * Equivalent to the `Numeric character reference state` in the HTML spec.
  886. *
  887. * @param str The string containing the entity (or a continuation of the entity).
  888. * @param offset The current offset.
  889. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  890. */
  891. stateNumericStart(str, offset) {
  892. if (offset >= str.length) {
  893. return -1;
  894. }
  895. if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
  896. this.state = EntityDecoderState.NumericHex;
  897. this.consumed += 1;
  898. return this.stateNumericHex(str, offset + 1);
  899. }
  900. this.state = EntityDecoderState.NumericDecimal;
  901. return this.stateNumericDecimal(str, offset);
  902. }
  903. addToNumericResult(str, start, end, base) {
  904. if (start !== end) {
  905. const digitCount = end - start;
  906. this.result =
  907. this.result * Math.pow(base, digitCount) +
  908. parseInt(str.substr(start, digitCount), base);
  909. this.consumed += digitCount;
  910. }
  911. }
  912. /**
  913. * Parses a hexadecimal numeric entity.
  914. *
  915. * Equivalent to the `Hexademical character reference state` in the HTML spec.
  916. *
  917. * @param str The string containing the entity (or a continuation of the entity).
  918. * @param offset The current offset.
  919. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  920. */
  921. stateNumericHex(str, offset) {
  922. const startIdx = offset;
  923. while (offset < str.length) {
  924. const char = str.charCodeAt(offset);
  925. if (isNumber$2(char) || isHexadecimalCharacter(char)) {
  926. offset += 1;
  927. }
  928. else {
  929. this.addToNumericResult(str, startIdx, offset, 16);
  930. return this.emitNumericEntity(char, 3);
  931. }
  932. }
  933. this.addToNumericResult(str, startIdx, offset, 16);
  934. return -1;
  935. }
  936. /**
  937. * Parses a decimal numeric entity.
  938. *
  939. * Equivalent to the `Decimal character reference state` in the HTML spec.
  940. *
  941. * @param str The string containing the entity (or a continuation of the entity).
  942. * @param offset The current offset.
  943. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  944. */
  945. stateNumericDecimal(str, offset) {
  946. const startIdx = offset;
  947. while (offset < str.length) {
  948. const char = str.charCodeAt(offset);
  949. if (isNumber$2(char)) {
  950. offset += 1;
  951. }
  952. else {
  953. this.addToNumericResult(str, startIdx, offset, 10);
  954. return this.emitNumericEntity(char, 2);
  955. }
  956. }
  957. this.addToNumericResult(str, startIdx, offset, 10);
  958. return -1;
  959. }
  960. /**
  961. * Validate and emit a numeric entity.
  962. *
  963. * Implements the logic from the `Hexademical character reference start
  964. * state` and `Numeric character reference end state` in the HTML spec.
  965. *
  966. * @param lastCp The last code point of the entity. Used to see if the
  967. * entity was terminated with a semicolon.
  968. * @param expectedLength The minimum number of characters that should be
  969. * consumed. Used to validate that at least one digit
  970. * was consumed.
  971. * @returns The number of characters that were consumed.
  972. */
  973. emitNumericEntity(lastCp, expectedLength) {
  974. var _a;
  975. // Ensure we consumed at least one digit.
  976. if (this.consumed <= expectedLength) {
  977. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  978. return 0;
  979. }
  980. // Figure out if this is a legit end of the entity
  981. if (lastCp === CharCodes.SEMI) {
  982. this.consumed += 1;
  983. }
  984. else if (this.decodeMode === DecodingMode.Strict) {
  985. return 0;
  986. }
  987. this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
  988. if (this.errors) {
  989. if (lastCp !== CharCodes.SEMI) {
  990. this.errors.missingSemicolonAfterCharacterReference();
  991. }
  992. this.errors.validateNumericCharacterReference(this.result);
  993. }
  994. return this.consumed;
  995. }
  996. /**
  997. * Parses a named entity.
  998. *
  999. * Equivalent to the `Named character reference state` in the HTML spec.
  1000. *
  1001. * @param str The string containing the entity (or a continuation of the entity).
  1002. * @param offset The current offset.
  1003. * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
  1004. */
  1005. stateNamedEntity(str, offset) {
  1006. const { decodeTree } = this;
  1007. let current = decodeTree[this.treeIndex];
  1008. // The mask is the number of bytes of the value, including the current byte.
  1009. let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1010. for (; offset < str.length; offset++, this.excess++) {
  1011. const char = str.charCodeAt(offset);
  1012. this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
  1013. if (this.treeIndex < 0) {
  1014. return this.result === 0 ||
  1015. // If we are parsing an attribute
  1016. (this.decodeMode === DecodingMode.Attribute &&
  1017. // We shouldn't have consumed any characters after the entity,
  1018. (valueLength === 0 ||
  1019. // And there should be no invalid characters.
  1020. isEntityInAttributeInvalidEnd(char)))
  1021. ? 0
  1022. : this.emitNotTerminatedNamedEntity();
  1023. }
  1024. current = decodeTree[this.treeIndex];
  1025. valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
  1026. // If the branch is a value, store it and continue
  1027. if (valueLength !== 0) {
  1028. // If the entity is terminated by a semicolon, we are done.
  1029. if (char === CharCodes.SEMI) {
  1030. return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
  1031. }
  1032. // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
  1033. if (this.decodeMode !== DecodingMode.Strict) {
  1034. this.result = this.treeIndex;
  1035. this.consumed += this.excess;
  1036. this.excess = 0;
  1037. }
  1038. }
  1039. }
  1040. return -1;
  1041. }
  1042. /**
  1043. * Emit a named entity that was not terminated with a semicolon.
  1044. *
  1045. * @returns The number of characters consumed.
  1046. */
  1047. emitNotTerminatedNamedEntity() {
  1048. var _a;
  1049. const { result, decodeTree } = this;
  1050. const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
  1051. this.emitNamedEntityData(result, valueLength, this.consumed);
  1052. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
  1053. return this.consumed;
  1054. }
  1055. /**
  1056. * Emit a named entity.
  1057. *
  1058. * @param result The index of the entity in the decode tree.
  1059. * @param valueLength The number of bytes in the entity.
  1060. * @param consumed The number of characters consumed.
  1061. *
  1062. * @returns The number of characters consumed.
  1063. */
  1064. emitNamedEntityData(result, valueLength, consumed) {
  1065. const { decodeTree } = this;
  1066. this.emitCodePoint(valueLength === 1
  1067. ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
  1068. : decodeTree[result + 1], consumed);
  1069. if (valueLength === 3) {
  1070. // For multi-byte values, we need to emit the second byte.
  1071. this.emitCodePoint(decodeTree[result + 2], consumed);
  1072. }
  1073. return consumed;
  1074. }
  1075. /**
  1076. * Signal to the parser that the end of the input was reached.
  1077. *
  1078. * Remaining data will be emitted and relevant errors will be produced.
  1079. *
  1080. * @returns The number of characters consumed.
  1081. */
  1082. end() {
  1083. var _a;
  1084. switch (this.state) {
  1085. case EntityDecoderState.NamedEntity: {
  1086. // Emit a named entity if we have one.
  1087. return this.result !== 0 &&
  1088. (this.decodeMode !== DecodingMode.Attribute ||
  1089. this.result === this.treeIndex)
  1090. ? this.emitNotTerminatedNamedEntity()
  1091. : 0;
  1092. }
  1093. // Otherwise, emit a numeric entity if we have one.
  1094. case EntityDecoderState.NumericDecimal: {
  1095. return this.emitNumericEntity(0, 2);
  1096. }
  1097. case EntityDecoderState.NumericHex: {
  1098. return this.emitNumericEntity(0, 3);
  1099. }
  1100. case EntityDecoderState.NumericStart: {
  1101. (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
  1102. return 0;
  1103. }
  1104. case EntityDecoderState.EntityStart: {
  1105. // Return 0 if we have no entity.
  1106. return 0;
  1107. }
  1108. }
  1109. }
  1110. }
  1111. /**
  1112. * Creates a function that decodes entities in a string.
  1113. *
  1114. * @param decodeTree The decode tree.
  1115. * @returns A function that decodes entities in a string.
  1116. */
  1117. function getDecoder(decodeTree) {
  1118. let ret = "";
  1119. const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));
  1120. return function decodeWithTrie(str, decodeMode) {
  1121. let lastIndex = 0;
  1122. let offset = 0;
  1123. while ((offset = str.indexOf("&", offset)) >= 0) {
  1124. ret += str.slice(lastIndex, offset);
  1125. decoder.startEntity(decodeMode);
  1126. const len = decoder.write(str,
  1127. // Skip the "&"
  1128. offset + 1);
  1129. if (len < 0) {
  1130. lastIndex = offset + decoder.end();
  1131. break;
  1132. }
  1133. lastIndex = offset + len;
  1134. // If `len` is 0, skip the current `&` and continue.
  1135. offset = len === 0 ? lastIndex + 1 : lastIndex;
  1136. }
  1137. const result = ret + str.slice(lastIndex);
  1138. // Make sure we don't keep a reference to the final string.
  1139. ret = "";
  1140. return result;
  1141. };
  1142. }
  1143. /**
  1144. * Determines the branch of the current node that is taken given the current
  1145. * character. This function is used to traverse the trie.
  1146. *
  1147. * @param decodeTree The trie.
  1148. * @param current The current node.
  1149. * @param nodeIdx The index right after the current node and its value.
  1150. * @param char The current character.
  1151. * @returns The index of the next node, or -1 if no branch is taken.
  1152. */
  1153. function determineBranch(decodeTree, current, nodeIdx, char) {
  1154. const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  1155. const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  1156. // Case 1: Single branch encoded in jump offset
  1157. if (branchCount === 0) {
  1158. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  1159. }
  1160. // Case 2: Multiple branches encoded in jump table
  1161. if (jumpOffset) {
  1162. const value = char - jumpOffset;
  1163. return value < 0 || value >= branchCount
  1164. ? -1
  1165. : decodeTree[nodeIdx + value] - 1;
  1166. }
  1167. // Case 3: Multiple branches encoded in dictionary
  1168. // Binary search for the character.
  1169. let lo = nodeIdx;
  1170. let hi = lo + branchCount - 1;
  1171. while (lo <= hi) {
  1172. const mid = (lo + hi) >>> 1;
  1173. const midVal = decodeTree[mid];
  1174. if (midVal < char) {
  1175. lo = mid + 1;
  1176. }
  1177. else if (midVal > char) {
  1178. hi = mid - 1;
  1179. }
  1180. else {
  1181. return decodeTree[mid + branchCount];
  1182. }
  1183. }
  1184. return -1;
  1185. }
  1186. const htmlDecoder = getDecoder(htmlDecodeTree);
  1187. getDecoder(xmlDecodeTree);
  1188. /**
  1189. * Decodes an HTML string.
  1190. *
  1191. * @param str The string to decode.
  1192. * @param mode The decoding mode.
  1193. * @returns The decoded string.
  1194. */
  1195. function decodeHTML(str, mode = DecodingMode.Legacy) {
  1196. return htmlDecoder(str, mode);
  1197. }
  1198. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  1199. const defaultDelimitersClose = new Uint8Array([125, 125]);
  1200. function isTagStartChar(c) {
  1201. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  1202. }
  1203. function isWhitespace$1(c) {
  1204. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  1205. }
  1206. function isEndOfTagSection(c) {
  1207. return c === 47 || c === 62 || isWhitespace$1(c);
  1208. }
  1209. function toCharCodes(str) {
  1210. const ret = new Uint8Array(str.length);
  1211. for (let i = 0; i < str.length; i++) {
  1212. ret[i] = str.charCodeAt(i);
  1213. }
  1214. return ret;
  1215. }
  1216. const Sequences = {
  1217. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  1218. // CDATA[
  1219. CdataEnd: new Uint8Array([93, 93, 62]),
  1220. // ]]>
  1221. CommentEnd: new Uint8Array([45, 45, 62]),
  1222. // `-->`
  1223. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  1224. // `<\/script`
  1225. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  1226. // `</style`
  1227. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  1228. // `</title`
  1229. TextareaEnd: new Uint8Array([
  1230. 60,
  1231. 47,
  1232. 116,
  1233. 101,
  1234. 120,
  1235. 116,
  1236. 97,
  1237. 114,
  1238. 101,
  1239. 97
  1240. ])
  1241. // `</textarea
  1242. };
  1243. let Tokenizer$1 = class Tokenizer {
  1244. constructor(stack, cbs) {
  1245. this.stack = stack;
  1246. this.cbs = cbs;
  1247. /** The current state the tokenizer is in. */
  1248. this.state = 1;
  1249. /** The read buffer. */
  1250. this.buffer = "";
  1251. /** The beginning of the section that is currently being read. */
  1252. this.sectionStart = 0;
  1253. /** The index within the buffer that we are currently looking at. */
  1254. this.index = 0;
  1255. /** The start of the last entity. */
  1256. this.entityStart = 0;
  1257. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  1258. this.baseState = 1;
  1259. /** For special parsing behavior inside of script and style tags. */
  1260. this.inRCDATA = false;
  1261. /** For disabling RCDATA tags handling */
  1262. this.inXML = false;
  1263. /** For disabling interpolation parsing in v-pre */
  1264. this.inVPre = false;
  1265. /** Record newline positions for fast line / column calculation */
  1266. this.newlines = [];
  1267. this.mode = 0;
  1268. this.delimiterOpen = defaultDelimitersOpen;
  1269. this.delimiterClose = defaultDelimitersClose;
  1270. this.delimiterIndex = -1;
  1271. this.currentSequence = void 0;
  1272. this.sequenceIndex = 0;
  1273. {
  1274. this.entityDecoder = new EntityDecoder(
  1275. htmlDecodeTree,
  1276. (cp, consumed) => this.emitCodePoint(cp, consumed)
  1277. );
  1278. }
  1279. }
  1280. get inSFCRoot() {
  1281. return this.mode === 2 && this.stack.length === 0;
  1282. }
  1283. reset() {
  1284. this.state = 1;
  1285. this.mode = 0;
  1286. this.buffer = "";
  1287. this.sectionStart = 0;
  1288. this.index = 0;
  1289. this.baseState = 1;
  1290. this.inRCDATA = false;
  1291. this.currentSequence = void 0;
  1292. this.newlines.length = 0;
  1293. this.delimiterOpen = defaultDelimitersOpen;
  1294. this.delimiterClose = defaultDelimitersClose;
  1295. }
  1296. /**
  1297. * Generate Position object with line / column information using recorded
  1298. * newline positions. We know the index is always going to be an already
  1299. * processed index, so all the newlines up to this index should have been
  1300. * recorded.
  1301. */
  1302. getPos(index) {
  1303. let line = 1;
  1304. let column = index + 1;
  1305. for (let i = this.newlines.length - 1; i >= 0; i--) {
  1306. const newlineIndex = this.newlines[i];
  1307. if (index > newlineIndex) {
  1308. line = i + 2;
  1309. column = index - newlineIndex;
  1310. break;
  1311. }
  1312. }
  1313. return {
  1314. column,
  1315. line,
  1316. offset: index
  1317. };
  1318. }
  1319. peek() {
  1320. return this.buffer.charCodeAt(this.index + 1);
  1321. }
  1322. stateText(c) {
  1323. if (c === 60) {
  1324. if (this.index > this.sectionStart) {
  1325. this.cbs.ontext(this.sectionStart, this.index);
  1326. }
  1327. this.state = 5;
  1328. this.sectionStart = this.index;
  1329. } else if (c === 38) {
  1330. this.startEntity();
  1331. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  1332. this.state = 2;
  1333. this.delimiterIndex = 0;
  1334. this.stateInterpolationOpen(c);
  1335. }
  1336. }
  1337. stateInterpolationOpen(c) {
  1338. if (c === this.delimiterOpen[this.delimiterIndex]) {
  1339. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  1340. const start = this.index + 1 - this.delimiterOpen.length;
  1341. if (start > this.sectionStart) {
  1342. this.cbs.ontext(this.sectionStart, start);
  1343. }
  1344. this.state = 3;
  1345. this.sectionStart = start;
  1346. } else {
  1347. this.delimiterIndex++;
  1348. }
  1349. } else if (this.inRCDATA) {
  1350. this.state = 32;
  1351. this.stateInRCDATA(c);
  1352. } else {
  1353. this.state = 1;
  1354. this.stateText(c);
  1355. }
  1356. }
  1357. stateInterpolation(c) {
  1358. if (c === this.delimiterClose[0]) {
  1359. this.state = 4;
  1360. this.delimiterIndex = 0;
  1361. this.stateInterpolationClose(c);
  1362. }
  1363. }
  1364. stateInterpolationClose(c) {
  1365. if (c === this.delimiterClose[this.delimiterIndex]) {
  1366. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  1367. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  1368. if (this.inRCDATA) {
  1369. this.state = 32;
  1370. } else {
  1371. this.state = 1;
  1372. }
  1373. this.sectionStart = this.index + 1;
  1374. } else {
  1375. this.delimiterIndex++;
  1376. }
  1377. } else {
  1378. this.state = 3;
  1379. this.stateInterpolation(c);
  1380. }
  1381. }
  1382. stateSpecialStartSequence(c) {
  1383. const isEnd = this.sequenceIndex === this.currentSequence.length;
  1384. const isMatch = isEnd ? (
  1385. // If we are at the end of the sequence, make sure the tag name has ended
  1386. isEndOfTagSection(c)
  1387. ) : (
  1388. // Otherwise, do a case-insensitive comparison
  1389. (c | 32) === this.currentSequence[this.sequenceIndex]
  1390. );
  1391. if (!isMatch) {
  1392. this.inRCDATA = false;
  1393. } else if (!isEnd) {
  1394. this.sequenceIndex++;
  1395. return;
  1396. }
  1397. this.sequenceIndex = 0;
  1398. this.state = 6;
  1399. this.stateInTagName(c);
  1400. }
  1401. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  1402. stateInRCDATA(c) {
  1403. if (this.sequenceIndex === this.currentSequence.length) {
  1404. if (c === 62 || isWhitespace$1(c)) {
  1405. const endOfText = this.index - this.currentSequence.length;
  1406. if (this.sectionStart < endOfText) {
  1407. const actualIndex = this.index;
  1408. this.index = endOfText;
  1409. this.cbs.ontext(this.sectionStart, endOfText);
  1410. this.index = actualIndex;
  1411. }
  1412. this.sectionStart = endOfText + 2;
  1413. this.stateInClosingTagName(c);
  1414. this.inRCDATA = false;
  1415. return;
  1416. }
  1417. this.sequenceIndex = 0;
  1418. }
  1419. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  1420. this.sequenceIndex += 1;
  1421. } else if (this.sequenceIndex === 0) {
  1422. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  1423. if (c === 38) {
  1424. this.startEntity();
  1425. } else if (c === this.delimiterOpen[0]) {
  1426. this.state = 2;
  1427. this.delimiterIndex = 0;
  1428. this.stateInterpolationOpen(c);
  1429. }
  1430. } else if (this.fastForwardTo(60)) {
  1431. this.sequenceIndex = 1;
  1432. }
  1433. } else {
  1434. this.sequenceIndex = Number(c === 60);
  1435. }
  1436. }
  1437. stateCDATASequence(c) {
  1438. if (c === Sequences.Cdata[this.sequenceIndex]) {
  1439. if (++this.sequenceIndex === Sequences.Cdata.length) {
  1440. this.state = 28;
  1441. this.currentSequence = Sequences.CdataEnd;
  1442. this.sequenceIndex = 0;
  1443. this.sectionStart = this.index + 1;
  1444. }
  1445. } else {
  1446. this.sequenceIndex = 0;
  1447. this.state = 23;
  1448. this.stateInDeclaration(c);
  1449. }
  1450. }
  1451. /**
  1452. * When we wait for one specific character, we can speed things up
  1453. * by skipping through the buffer until we find it.
  1454. *
  1455. * @returns Whether the character was found.
  1456. */
  1457. fastForwardTo(c) {
  1458. while (++this.index < this.buffer.length) {
  1459. const cc = this.buffer.charCodeAt(this.index);
  1460. if (cc === 10) {
  1461. this.newlines.push(this.index);
  1462. }
  1463. if (cc === c) {
  1464. return true;
  1465. }
  1466. }
  1467. this.index = this.buffer.length - 1;
  1468. return false;
  1469. }
  1470. /**
  1471. * Comments and CDATA end with `-->` and `]]>`.
  1472. *
  1473. * Their common qualities are:
  1474. * - Their end sequences have a distinct character they start with.
  1475. * - That character is then repeated, so we have to check multiple repeats.
  1476. * - All characters but the start character of the sequence can be skipped.
  1477. */
  1478. stateInCommentLike(c) {
  1479. if (c === this.currentSequence[this.sequenceIndex]) {
  1480. if (++this.sequenceIndex === this.currentSequence.length) {
  1481. if (this.currentSequence === Sequences.CdataEnd) {
  1482. this.cbs.oncdata(this.sectionStart, this.index - 2);
  1483. } else {
  1484. this.cbs.oncomment(this.sectionStart, this.index - 2);
  1485. }
  1486. this.sequenceIndex = 0;
  1487. this.sectionStart = this.index + 1;
  1488. this.state = 1;
  1489. }
  1490. } else if (this.sequenceIndex === 0) {
  1491. if (this.fastForwardTo(this.currentSequence[0])) {
  1492. this.sequenceIndex = 1;
  1493. }
  1494. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  1495. this.sequenceIndex = 0;
  1496. }
  1497. }
  1498. startSpecial(sequence, offset) {
  1499. this.enterRCDATA(sequence, offset);
  1500. this.state = 31;
  1501. }
  1502. enterRCDATA(sequence, offset) {
  1503. this.inRCDATA = true;
  1504. this.currentSequence = sequence;
  1505. this.sequenceIndex = offset;
  1506. }
  1507. stateBeforeTagName(c) {
  1508. if (c === 33) {
  1509. this.state = 22;
  1510. this.sectionStart = this.index + 1;
  1511. } else if (c === 63) {
  1512. this.state = 24;
  1513. this.sectionStart = this.index + 1;
  1514. } else if (isTagStartChar(c)) {
  1515. this.sectionStart = this.index;
  1516. if (this.mode === 0) {
  1517. this.state = 6;
  1518. } else if (this.inSFCRoot) {
  1519. this.state = 34;
  1520. } else if (!this.inXML) {
  1521. if (c === 116) {
  1522. this.state = 30;
  1523. } else {
  1524. this.state = c === 115 ? 29 : 6;
  1525. }
  1526. } else {
  1527. this.state = 6;
  1528. }
  1529. } else if (c === 47) {
  1530. this.state = 8;
  1531. } else {
  1532. this.state = 1;
  1533. this.stateText(c);
  1534. }
  1535. }
  1536. stateInTagName(c) {
  1537. if (isEndOfTagSection(c)) {
  1538. this.handleTagName(c);
  1539. }
  1540. }
  1541. stateInSFCRootTagName(c) {
  1542. if (isEndOfTagSection(c)) {
  1543. const tag = this.buffer.slice(this.sectionStart, this.index);
  1544. if (tag !== "template") {
  1545. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  1546. }
  1547. this.handleTagName(c);
  1548. }
  1549. }
  1550. handleTagName(c) {
  1551. this.cbs.onopentagname(this.sectionStart, this.index);
  1552. this.sectionStart = -1;
  1553. this.state = 11;
  1554. this.stateBeforeAttrName(c);
  1555. }
  1556. stateBeforeClosingTagName(c) {
  1557. if (isWhitespace$1(c)) ; else if (c === 62) {
  1558. {
  1559. this.cbs.onerr(14, this.index);
  1560. }
  1561. this.state = 1;
  1562. this.sectionStart = this.index + 1;
  1563. } else {
  1564. this.state = isTagStartChar(c) ? 9 : 27;
  1565. this.sectionStart = this.index;
  1566. }
  1567. }
  1568. stateInClosingTagName(c) {
  1569. if (c === 62 || isWhitespace$1(c)) {
  1570. this.cbs.onclosetag(this.sectionStart, this.index);
  1571. this.sectionStart = -1;
  1572. this.state = 10;
  1573. this.stateAfterClosingTagName(c);
  1574. }
  1575. }
  1576. stateAfterClosingTagName(c) {
  1577. if (c === 62) {
  1578. this.state = 1;
  1579. this.sectionStart = this.index + 1;
  1580. }
  1581. }
  1582. stateBeforeAttrName(c) {
  1583. if (c === 62) {
  1584. this.cbs.onopentagend(this.index);
  1585. if (this.inRCDATA) {
  1586. this.state = 32;
  1587. } else {
  1588. this.state = 1;
  1589. }
  1590. this.sectionStart = this.index + 1;
  1591. } else if (c === 47) {
  1592. this.state = 7;
  1593. if (this.peek() !== 62) {
  1594. this.cbs.onerr(22, this.index);
  1595. }
  1596. } else if (c === 60 && this.peek() === 47) {
  1597. this.cbs.onopentagend(this.index);
  1598. this.state = 5;
  1599. this.sectionStart = this.index;
  1600. } else if (!isWhitespace$1(c)) {
  1601. if (c === 61) {
  1602. this.cbs.onerr(
  1603. 19,
  1604. this.index
  1605. );
  1606. }
  1607. this.handleAttrStart(c);
  1608. }
  1609. }
  1610. handleAttrStart(c) {
  1611. if (c === 118 && this.peek() === 45) {
  1612. this.state = 13;
  1613. this.sectionStart = this.index;
  1614. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  1615. this.cbs.ondirname(this.index, this.index + 1);
  1616. this.state = 14;
  1617. this.sectionStart = this.index + 1;
  1618. } else {
  1619. this.state = 12;
  1620. this.sectionStart = this.index;
  1621. }
  1622. }
  1623. stateInSelfClosingTag(c) {
  1624. if (c === 62) {
  1625. this.cbs.onselfclosingtag(this.index);
  1626. this.state = 1;
  1627. this.sectionStart = this.index + 1;
  1628. this.inRCDATA = false;
  1629. } else if (!isWhitespace$1(c)) {
  1630. this.state = 11;
  1631. this.stateBeforeAttrName(c);
  1632. }
  1633. }
  1634. stateInAttrName(c) {
  1635. if (c === 61 || isEndOfTagSection(c)) {
  1636. this.cbs.onattribname(this.sectionStart, this.index);
  1637. this.handleAttrNameEnd(c);
  1638. } else if (c === 34 || c === 39 || c === 60) {
  1639. this.cbs.onerr(
  1640. 17,
  1641. this.index
  1642. );
  1643. }
  1644. }
  1645. stateInDirName(c) {
  1646. if (c === 61 || isEndOfTagSection(c)) {
  1647. this.cbs.ondirname(this.sectionStart, this.index);
  1648. this.handleAttrNameEnd(c);
  1649. } else if (c === 58) {
  1650. this.cbs.ondirname(this.sectionStart, this.index);
  1651. this.state = 14;
  1652. this.sectionStart = this.index + 1;
  1653. } else if (c === 46) {
  1654. this.cbs.ondirname(this.sectionStart, this.index);
  1655. this.state = 16;
  1656. this.sectionStart = this.index + 1;
  1657. }
  1658. }
  1659. stateInDirArg(c) {
  1660. if (c === 61 || isEndOfTagSection(c)) {
  1661. this.cbs.ondirarg(this.sectionStart, this.index);
  1662. this.handleAttrNameEnd(c);
  1663. } else if (c === 91) {
  1664. this.state = 15;
  1665. } else if (c === 46) {
  1666. this.cbs.ondirarg(this.sectionStart, this.index);
  1667. this.state = 16;
  1668. this.sectionStart = this.index + 1;
  1669. }
  1670. }
  1671. stateInDynamicDirArg(c) {
  1672. if (c === 93) {
  1673. this.state = 14;
  1674. } else if (c === 61 || isEndOfTagSection(c)) {
  1675. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  1676. this.handleAttrNameEnd(c);
  1677. {
  1678. this.cbs.onerr(
  1679. 27,
  1680. this.index
  1681. );
  1682. }
  1683. }
  1684. }
  1685. stateInDirModifier(c) {
  1686. if (c === 61 || isEndOfTagSection(c)) {
  1687. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1688. this.handleAttrNameEnd(c);
  1689. } else if (c === 46) {
  1690. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1691. this.sectionStart = this.index + 1;
  1692. }
  1693. }
  1694. handleAttrNameEnd(c) {
  1695. this.sectionStart = this.index;
  1696. this.state = 17;
  1697. this.cbs.onattribnameend(this.index);
  1698. this.stateAfterAttrName(c);
  1699. }
  1700. stateAfterAttrName(c) {
  1701. if (c === 61) {
  1702. this.state = 18;
  1703. } else if (c === 47 || c === 62) {
  1704. this.cbs.onattribend(0, this.sectionStart);
  1705. this.sectionStart = -1;
  1706. this.state = 11;
  1707. this.stateBeforeAttrName(c);
  1708. } else if (!isWhitespace$1(c)) {
  1709. this.cbs.onattribend(0, this.sectionStart);
  1710. this.handleAttrStart(c);
  1711. }
  1712. }
  1713. stateBeforeAttrValue(c) {
  1714. if (c === 34) {
  1715. this.state = 19;
  1716. this.sectionStart = this.index + 1;
  1717. } else if (c === 39) {
  1718. this.state = 20;
  1719. this.sectionStart = this.index + 1;
  1720. } else if (!isWhitespace$1(c)) {
  1721. this.sectionStart = this.index;
  1722. this.state = 21;
  1723. this.stateInAttrValueNoQuotes(c);
  1724. }
  1725. }
  1726. handleInAttrValue(c, quote) {
  1727. if (c === quote || false) {
  1728. this.cbs.onattribdata(this.sectionStart, this.index);
  1729. this.sectionStart = -1;
  1730. this.cbs.onattribend(
  1731. quote === 34 ? 3 : 2,
  1732. this.index + 1
  1733. );
  1734. this.state = 11;
  1735. } else if (c === 38) {
  1736. this.startEntity();
  1737. }
  1738. }
  1739. stateInAttrValueDoubleQuotes(c) {
  1740. this.handleInAttrValue(c, 34);
  1741. }
  1742. stateInAttrValueSingleQuotes(c) {
  1743. this.handleInAttrValue(c, 39);
  1744. }
  1745. stateInAttrValueNoQuotes(c) {
  1746. if (isWhitespace$1(c) || c === 62) {
  1747. this.cbs.onattribdata(this.sectionStart, this.index);
  1748. this.sectionStart = -1;
  1749. this.cbs.onattribend(1, this.index);
  1750. this.state = 11;
  1751. this.stateBeforeAttrName(c);
  1752. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1753. this.cbs.onerr(
  1754. 18,
  1755. this.index
  1756. );
  1757. } else if (c === 38) {
  1758. this.startEntity();
  1759. }
  1760. }
  1761. stateBeforeDeclaration(c) {
  1762. if (c === 91) {
  1763. this.state = 26;
  1764. this.sequenceIndex = 0;
  1765. } else {
  1766. this.state = c === 45 ? 25 : 23;
  1767. }
  1768. }
  1769. stateInDeclaration(c) {
  1770. if (c === 62 || this.fastForwardTo(62)) {
  1771. this.state = 1;
  1772. this.sectionStart = this.index + 1;
  1773. }
  1774. }
  1775. stateInProcessingInstruction(c) {
  1776. if (c === 62 || this.fastForwardTo(62)) {
  1777. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1778. this.state = 1;
  1779. this.sectionStart = this.index + 1;
  1780. }
  1781. }
  1782. stateBeforeComment(c) {
  1783. if (c === 45) {
  1784. this.state = 28;
  1785. this.currentSequence = Sequences.CommentEnd;
  1786. this.sequenceIndex = 2;
  1787. this.sectionStart = this.index + 1;
  1788. } else {
  1789. this.state = 23;
  1790. }
  1791. }
  1792. stateInSpecialComment(c) {
  1793. if (c === 62 || this.fastForwardTo(62)) {
  1794. this.cbs.oncomment(this.sectionStart, this.index);
  1795. this.state = 1;
  1796. this.sectionStart = this.index + 1;
  1797. }
  1798. }
  1799. stateBeforeSpecialS(c) {
  1800. if (c === Sequences.ScriptEnd[3]) {
  1801. this.startSpecial(Sequences.ScriptEnd, 4);
  1802. } else if (c === Sequences.StyleEnd[3]) {
  1803. this.startSpecial(Sequences.StyleEnd, 4);
  1804. } else {
  1805. this.state = 6;
  1806. this.stateInTagName(c);
  1807. }
  1808. }
  1809. stateBeforeSpecialT(c) {
  1810. if (c === Sequences.TitleEnd[3]) {
  1811. this.startSpecial(Sequences.TitleEnd, 4);
  1812. } else if (c === Sequences.TextareaEnd[3]) {
  1813. this.startSpecial(Sequences.TextareaEnd, 4);
  1814. } else {
  1815. this.state = 6;
  1816. this.stateInTagName(c);
  1817. }
  1818. }
  1819. startEntity() {
  1820. {
  1821. this.baseState = this.state;
  1822. this.state = 33;
  1823. this.entityStart = this.index;
  1824. this.entityDecoder.startEntity(
  1825. this.baseState === 1 || this.baseState === 32 ? DecodingMode.Legacy : DecodingMode.Attribute
  1826. );
  1827. }
  1828. }
  1829. stateInEntity() {
  1830. {
  1831. const length = this.entityDecoder.write(this.buffer, this.index);
  1832. if (length >= 0) {
  1833. this.state = this.baseState;
  1834. if (length === 0) {
  1835. this.index = this.entityStart;
  1836. }
  1837. } else {
  1838. this.index = this.buffer.length - 1;
  1839. }
  1840. }
  1841. }
  1842. /**
  1843. * Iterates through the buffer, calling the function corresponding to the current state.
  1844. *
  1845. * States that are more likely to be hit are higher up, as a performance improvement.
  1846. */
  1847. parse(input) {
  1848. this.buffer = input;
  1849. while (this.index < this.buffer.length) {
  1850. const c = this.buffer.charCodeAt(this.index);
  1851. if (c === 10) {
  1852. this.newlines.push(this.index);
  1853. }
  1854. switch (this.state) {
  1855. case 1: {
  1856. this.stateText(c);
  1857. break;
  1858. }
  1859. case 2: {
  1860. this.stateInterpolationOpen(c);
  1861. break;
  1862. }
  1863. case 3: {
  1864. this.stateInterpolation(c);
  1865. break;
  1866. }
  1867. case 4: {
  1868. this.stateInterpolationClose(c);
  1869. break;
  1870. }
  1871. case 31: {
  1872. this.stateSpecialStartSequence(c);
  1873. break;
  1874. }
  1875. case 32: {
  1876. this.stateInRCDATA(c);
  1877. break;
  1878. }
  1879. case 26: {
  1880. this.stateCDATASequence(c);
  1881. break;
  1882. }
  1883. case 19: {
  1884. this.stateInAttrValueDoubleQuotes(c);
  1885. break;
  1886. }
  1887. case 12: {
  1888. this.stateInAttrName(c);
  1889. break;
  1890. }
  1891. case 13: {
  1892. this.stateInDirName(c);
  1893. break;
  1894. }
  1895. case 14: {
  1896. this.stateInDirArg(c);
  1897. break;
  1898. }
  1899. case 15: {
  1900. this.stateInDynamicDirArg(c);
  1901. break;
  1902. }
  1903. case 16: {
  1904. this.stateInDirModifier(c);
  1905. break;
  1906. }
  1907. case 28: {
  1908. this.stateInCommentLike(c);
  1909. break;
  1910. }
  1911. case 27: {
  1912. this.stateInSpecialComment(c);
  1913. break;
  1914. }
  1915. case 11: {
  1916. this.stateBeforeAttrName(c);
  1917. break;
  1918. }
  1919. case 6: {
  1920. this.stateInTagName(c);
  1921. break;
  1922. }
  1923. case 34: {
  1924. this.stateInSFCRootTagName(c);
  1925. break;
  1926. }
  1927. case 9: {
  1928. this.stateInClosingTagName(c);
  1929. break;
  1930. }
  1931. case 5: {
  1932. this.stateBeforeTagName(c);
  1933. break;
  1934. }
  1935. case 17: {
  1936. this.stateAfterAttrName(c);
  1937. break;
  1938. }
  1939. case 20: {
  1940. this.stateInAttrValueSingleQuotes(c);
  1941. break;
  1942. }
  1943. case 18: {
  1944. this.stateBeforeAttrValue(c);
  1945. break;
  1946. }
  1947. case 8: {
  1948. this.stateBeforeClosingTagName(c);
  1949. break;
  1950. }
  1951. case 10: {
  1952. this.stateAfterClosingTagName(c);
  1953. break;
  1954. }
  1955. case 29: {
  1956. this.stateBeforeSpecialS(c);
  1957. break;
  1958. }
  1959. case 30: {
  1960. this.stateBeforeSpecialT(c);
  1961. break;
  1962. }
  1963. case 21: {
  1964. this.stateInAttrValueNoQuotes(c);
  1965. break;
  1966. }
  1967. case 7: {
  1968. this.stateInSelfClosingTag(c);
  1969. break;
  1970. }
  1971. case 23: {
  1972. this.stateInDeclaration(c);
  1973. break;
  1974. }
  1975. case 22: {
  1976. this.stateBeforeDeclaration(c);
  1977. break;
  1978. }
  1979. case 25: {
  1980. this.stateBeforeComment(c);
  1981. break;
  1982. }
  1983. case 24: {
  1984. this.stateInProcessingInstruction(c);
  1985. break;
  1986. }
  1987. case 33: {
  1988. this.stateInEntity();
  1989. break;
  1990. }
  1991. }
  1992. this.index++;
  1993. }
  1994. this.cleanup();
  1995. this.finish();
  1996. }
  1997. /**
  1998. * Remove data that has already been consumed from the buffer.
  1999. */
  2000. cleanup() {
  2001. if (this.sectionStart !== this.index) {
  2002. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  2003. this.cbs.ontext(this.sectionStart, this.index);
  2004. this.sectionStart = this.index;
  2005. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  2006. this.cbs.onattribdata(this.sectionStart, this.index);
  2007. this.sectionStart = this.index;
  2008. }
  2009. }
  2010. }
  2011. finish() {
  2012. if (this.state === 33) {
  2013. this.entityDecoder.end();
  2014. this.state = this.baseState;
  2015. }
  2016. this.handleTrailingData();
  2017. this.cbs.onend();
  2018. }
  2019. /** Handle any trailing data. */
  2020. handleTrailingData() {
  2021. const endIndex = this.buffer.length;
  2022. if (this.sectionStart >= endIndex) {
  2023. return;
  2024. }
  2025. if (this.state === 28) {
  2026. if (this.currentSequence === Sequences.CdataEnd) {
  2027. this.cbs.oncdata(this.sectionStart, endIndex);
  2028. } else {
  2029. this.cbs.oncomment(this.sectionStart, endIndex);
  2030. }
  2031. } 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 {
  2032. this.cbs.ontext(this.sectionStart, endIndex);
  2033. }
  2034. }
  2035. emitCodePoint(cp, consumed) {
  2036. {
  2037. if (this.baseState !== 1 && this.baseState !== 32) {
  2038. if (this.sectionStart < this.entityStart) {
  2039. this.cbs.onattribdata(this.sectionStart, this.entityStart);
  2040. }
  2041. this.sectionStart = this.entityStart + consumed;
  2042. this.index = this.sectionStart - 1;
  2043. this.cbs.onattribentity(
  2044. fromCodePoint(cp),
  2045. this.entityStart,
  2046. this.sectionStart
  2047. );
  2048. } else {
  2049. if (this.sectionStart < this.entityStart) {
  2050. this.cbs.ontext(this.sectionStart, this.entityStart);
  2051. }
  2052. this.sectionStart = this.entityStart + consumed;
  2053. this.index = this.sectionStart - 1;
  2054. this.cbs.ontextentity(
  2055. fromCodePoint(cp),
  2056. this.entityStart,
  2057. this.sectionStart
  2058. );
  2059. }
  2060. }
  2061. }
  2062. };
  2063. const CompilerDeprecationTypes = {
  2064. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  2065. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  2066. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  2067. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  2068. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2069. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  2070. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  2071. "COMPILER_FILTERS": "COMPILER_FILTERS"
  2072. };
  2073. const deprecationData = {
  2074. ["COMPILER_IS_ON_ELEMENT"]: {
  2075. 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:".`,
  2076. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  2077. },
  2078. ["COMPILER_V_BIND_SYNC"]: {
  2079. 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}\`.`,
  2080. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  2081. },
  2082. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  2083. 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.`,
  2084. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  2085. },
  2086. ["COMPILER_V_ON_NATIVE"]: {
  2087. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  2088. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  2089. },
  2090. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  2091. 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.`,
  2092. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  2093. },
  2094. ["COMPILER_NATIVE_TEMPLATE"]: {
  2095. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  2096. },
  2097. ["COMPILER_INLINE_TEMPLATE"]: {
  2098. message: `"inline-template" has been removed in Vue 3.`,
  2099. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  2100. },
  2101. ["COMPILER_FILTERS"]: {
  2102. 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.`,
  2103. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  2104. }
  2105. };
  2106. function getCompatValue(key, { compatConfig }) {
  2107. const value = compatConfig && compatConfig[key];
  2108. if (key === "MODE") {
  2109. return value || 3;
  2110. } else {
  2111. return value;
  2112. }
  2113. }
  2114. function isCompatEnabled(key, context) {
  2115. const mode = getCompatValue("MODE", context);
  2116. const value = getCompatValue(key, context);
  2117. return mode === 3 ? value === true : value !== false;
  2118. }
  2119. function checkCompatEnabled(key, context, loc, ...args) {
  2120. const enabled = isCompatEnabled(key, context);
  2121. if (enabled) {
  2122. warnDeprecation(key, context, loc, ...args);
  2123. }
  2124. return enabled;
  2125. }
  2126. function warnDeprecation(key, context, loc, ...args) {
  2127. const val = getCompatValue(key, context);
  2128. if (val === "suppress-warning") {
  2129. return;
  2130. }
  2131. const { message, link } = deprecationData[key];
  2132. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  2133. Details: ${link}` : ``}`;
  2134. const err = new SyntaxError(msg);
  2135. err.code = key;
  2136. if (loc) err.loc = loc;
  2137. context.onWarn(err);
  2138. }
  2139. function defaultOnError(error) {
  2140. throw error;
  2141. }
  2142. function defaultOnWarn(msg) {
  2143. console.warn(`[Vue warn] ${msg.message}`);
  2144. }
  2145. function createCompilerError(code, loc, messages, additionalMessage) {
  2146. const msg = (messages || errorMessages$1)[code] + (additionalMessage || ``) ;
  2147. const error = new SyntaxError(String(msg));
  2148. error.code = code;
  2149. error.loc = loc;
  2150. return error;
  2151. }
  2152. const ErrorCodes = {
  2153. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  2154. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  2155. "CDATA_IN_HTML_CONTENT": 1,
  2156. "1": "CDATA_IN_HTML_CONTENT",
  2157. "DUPLICATE_ATTRIBUTE": 2,
  2158. "2": "DUPLICATE_ATTRIBUTE",
  2159. "END_TAG_WITH_ATTRIBUTES": 3,
  2160. "3": "END_TAG_WITH_ATTRIBUTES",
  2161. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  2162. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  2163. "EOF_BEFORE_TAG_NAME": 5,
  2164. "5": "EOF_BEFORE_TAG_NAME",
  2165. "EOF_IN_CDATA": 6,
  2166. "6": "EOF_IN_CDATA",
  2167. "EOF_IN_COMMENT": 7,
  2168. "7": "EOF_IN_COMMENT",
  2169. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  2170. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  2171. "EOF_IN_TAG": 9,
  2172. "9": "EOF_IN_TAG",
  2173. "INCORRECTLY_CLOSED_COMMENT": 10,
  2174. "10": "INCORRECTLY_CLOSED_COMMENT",
  2175. "INCORRECTLY_OPENED_COMMENT": 11,
  2176. "11": "INCORRECTLY_OPENED_COMMENT",
  2177. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  2178. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  2179. "MISSING_ATTRIBUTE_VALUE": 13,
  2180. "13": "MISSING_ATTRIBUTE_VALUE",
  2181. "MISSING_END_TAG_NAME": 14,
  2182. "14": "MISSING_END_TAG_NAME",
  2183. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  2184. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  2185. "NESTED_COMMENT": 16,
  2186. "16": "NESTED_COMMENT",
  2187. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  2188. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  2189. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  2190. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  2191. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  2192. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  2193. "UNEXPECTED_NULL_CHARACTER": 20,
  2194. "20": "UNEXPECTED_NULL_CHARACTER",
  2195. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  2196. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  2197. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  2198. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  2199. "X_INVALID_END_TAG": 23,
  2200. "23": "X_INVALID_END_TAG",
  2201. "X_MISSING_END_TAG": 24,
  2202. "24": "X_MISSING_END_TAG",
  2203. "X_MISSING_INTERPOLATION_END": 25,
  2204. "25": "X_MISSING_INTERPOLATION_END",
  2205. "X_MISSING_DIRECTIVE_NAME": 26,
  2206. "26": "X_MISSING_DIRECTIVE_NAME",
  2207. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  2208. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  2209. "X_V_IF_NO_EXPRESSION": 28,
  2210. "28": "X_V_IF_NO_EXPRESSION",
  2211. "X_V_IF_SAME_KEY": 29,
  2212. "29": "X_V_IF_SAME_KEY",
  2213. "X_V_ELSE_NO_ADJACENT_IF": 30,
  2214. "30": "X_V_ELSE_NO_ADJACENT_IF",
  2215. "X_V_FOR_NO_EXPRESSION": 31,
  2216. "31": "X_V_FOR_NO_EXPRESSION",
  2217. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  2218. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  2219. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  2220. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  2221. "X_V_BIND_NO_EXPRESSION": 34,
  2222. "34": "X_V_BIND_NO_EXPRESSION",
  2223. "X_V_ON_NO_EXPRESSION": 35,
  2224. "35": "X_V_ON_NO_EXPRESSION",
  2225. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  2226. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  2227. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  2228. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  2229. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  2230. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  2231. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  2232. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  2233. "X_V_SLOT_MISPLACED": 40,
  2234. "40": "X_V_SLOT_MISPLACED",
  2235. "X_V_MODEL_NO_EXPRESSION": 41,
  2236. "41": "X_V_MODEL_NO_EXPRESSION",
  2237. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  2238. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  2239. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  2240. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  2241. "X_V_MODEL_ON_PROPS": 44,
  2242. "44": "X_V_MODEL_ON_PROPS",
  2243. "X_INVALID_EXPRESSION": 45,
  2244. "45": "X_INVALID_EXPRESSION",
  2245. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  2246. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  2247. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  2248. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  2249. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  2250. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  2251. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  2252. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  2253. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  2254. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  2255. "X_VNODE_HOOKS": 51,
  2256. "51": "X_VNODE_HOOKS",
  2257. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  2258. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  2259. "__EXTEND_POINT__": 53,
  2260. "53": "__EXTEND_POINT__"
  2261. };
  2262. const errorMessages$1 = {
  2263. // parse errors
  2264. [0]: "Illegal comment.",
  2265. [1]: "CDATA section is allowed only in XML context.",
  2266. [2]: "Duplicate attribute.",
  2267. [3]: "End tag cannot have attributes.",
  2268. [4]: "Illegal '/' in tags.",
  2269. [5]: "Unexpected EOF in tag.",
  2270. [6]: "Unexpected EOF in CDATA section.",
  2271. [7]: "Unexpected EOF in comment.",
  2272. [8]: "Unexpected EOF in script.",
  2273. [9]: "Unexpected EOF in tag.",
  2274. [10]: "Incorrectly closed comment.",
  2275. [11]: "Incorrectly opened comment.",
  2276. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  2277. [13]: "Attribute value was expected.",
  2278. [14]: "End tag name was expected.",
  2279. [15]: "Whitespace was expected.",
  2280. [16]: "Unexpected '<!--' in comment.",
  2281. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  2282. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  2283. [19]: "Attribute name cannot start with '='.",
  2284. [21]: "'<?' is allowed only in XML context.",
  2285. [20]: `Unexpected null character.`,
  2286. [22]: "Illegal '/' in tags.",
  2287. // Vue-specific parse errors
  2288. [23]: "Invalid end tag.",
  2289. [24]: "Element is missing end tag.",
  2290. [25]: "Interpolation end sign was not found.",
  2291. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  2292. [26]: "Legal directive name was expected.",
  2293. // transform errors
  2294. [28]: `v-if/v-else-if is missing expression.`,
  2295. [29]: `v-if/else branches must use unique keys.`,
  2296. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  2297. [31]: `v-for is missing expression.`,
  2298. [32]: `v-for has invalid expression.`,
  2299. [33]: `<template v-for> key should be placed on the <template> tag.`,
  2300. [34]: `v-bind is missing expression.`,
  2301. [52]: `v-bind with same-name shorthand only allows static argument.`,
  2302. [35]: `v-on is missing expression.`,
  2303. [36]: `Unexpected custom directive on <slot> outlet.`,
  2304. [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.`,
  2305. [38]: `Duplicate slot names found. `,
  2306. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  2307. [40]: `v-slot can only be used on components or <template> tags.`,
  2308. [41]: `v-model is missing expression.`,
  2309. [42]: `v-model value must be a valid JavaScript member expression.`,
  2310. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  2311. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  2312. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  2313. [45]: `Error parsing JavaScript expression: `,
  2314. [46]: `<KeepAlive> expects exactly one child component.`,
  2315. [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.`,
  2316. // generic errors
  2317. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  2318. [48]: `ES module mode is not supported in this build of compiler.`,
  2319. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  2320. [50]: `"scopeId" option is only supported in module mode.`,
  2321. // just to fulfill types
  2322. [53]: ``
  2323. };
  2324. function getDefaultExportFromCjs (x) {
  2325. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  2326. }
  2327. function getAugmentedNamespace(n) {
  2328. if (n.__esModule) return n;
  2329. var f = n.default;
  2330. if (typeof f == "function") {
  2331. var a = function a () {
  2332. if (this instanceof a) {
  2333. return Reflect.construct(f, arguments, this.constructor);
  2334. }
  2335. return f.apply(this, arguments);
  2336. };
  2337. a.prototype = f.prototype;
  2338. } else a = {};
  2339. Object.defineProperty(a, '__esModule', {value: true});
  2340. Object.keys(n).forEach(function (k) {
  2341. var d = Object.getOwnPropertyDescriptor(n, k);
  2342. Object.defineProperty(a, k, d.get ? d : {
  2343. enumerable: true,
  2344. get: function () {
  2345. return n[k];
  2346. }
  2347. });
  2348. });
  2349. return a;
  2350. }
  2351. var lib = {};
  2352. Object.defineProperty(lib, '__esModule', {
  2353. value: true
  2354. });
  2355. function _objectWithoutPropertiesLoose(source, excluded) {
  2356. if (source == null) return {};
  2357. var target = {};
  2358. var sourceKeys = Object.keys(source);
  2359. var key, i;
  2360. for (i = 0; i < sourceKeys.length; i++) {
  2361. key = sourceKeys[i];
  2362. if (excluded.indexOf(key) >= 0) continue;
  2363. target[key] = source[key];
  2364. }
  2365. return target;
  2366. }
  2367. class Position {
  2368. constructor(line, col, index) {
  2369. this.line = void 0;
  2370. this.column = void 0;
  2371. this.index = void 0;
  2372. this.line = line;
  2373. this.column = col;
  2374. this.index = index;
  2375. }
  2376. }
  2377. class SourceLocation {
  2378. constructor(start, end) {
  2379. this.start = void 0;
  2380. this.end = void 0;
  2381. this.filename = void 0;
  2382. this.identifierName = void 0;
  2383. this.start = start;
  2384. this.end = end;
  2385. }
  2386. }
  2387. function createPositionWithColumnOffset(position, columnOffset) {
  2388. const {
  2389. line,
  2390. column,
  2391. index
  2392. } = position;
  2393. return new Position(line, column + columnOffset, index + columnOffset);
  2394. }
  2395. const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
  2396. var ModuleErrors = {
  2397. ImportMetaOutsideModule: {
  2398. message: `import.meta may appear only with 'sourceType: "module"'`,
  2399. code
  2400. },
  2401. ImportOutsideModule: {
  2402. message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
  2403. code
  2404. }
  2405. };
  2406. const NodeDescriptions = {
  2407. ArrayPattern: "array destructuring pattern",
  2408. AssignmentExpression: "assignment expression",
  2409. AssignmentPattern: "assignment expression",
  2410. ArrowFunctionExpression: "arrow function expression",
  2411. ConditionalExpression: "conditional expression",
  2412. CatchClause: "catch clause",
  2413. ForOfStatement: "for-of statement",
  2414. ForInStatement: "for-in statement",
  2415. ForStatement: "for-loop",
  2416. FormalParameters: "function parameter list",
  2417. Identifier: "identifier",
  2418. ImportSpecifier: "import specifier",
  2419. ImportDefaultSpecifier: "import default specifier",
  2420. ImportNamespaceSpecifier: "import namespace specifier",
  2421. ObjectPattern: "object destructuring pattern",
  2422. ParenthesizedExpression: "parenthesized expression",
  2423. RestElement: "rest element",
  2424. UpdateExpression: {
  2425. true: "prefix operation",
  2426. false: "postfix operation"
  2427. },
  2428. VariableDeclarator: "variable declaration",
  2429. YieldExpression: "yield expression"
  2430. };
  2431. const toNodeDescription = node => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type];
  2432. var StandardErrors = {
  2433. AccessorIsGenerator: ({
  2434. kind
  2435. }) => `A ${kind}ter cannot be a generator.`,
  2436. ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
  2437. AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
  2438. AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
  2439. AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
  2440. AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
  2441. AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
  2442. AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
  2443. AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
  2444. BadGetterArity: "A 'get' accessor must not have any formal parameters.",
  2445. BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
  2446. BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
  2447. ConstructorClassField: "Classes may not have a field named 'constructor'.",
  2448. ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
  2449. ConstructorIsAccessor: "Class constructor may not be an accessor.",
  2450. ConstructorIsAsync: "Constructor can't be an async function.",
  2451. ConstructorIsGenerator: "Constructor can't be a generator.",
  2452. DeclarationMissingInitializer: ({
  2453. kind
  2454. }) => `Missing initializer in ${kind} declaration.`,
  2455. DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
  2456. DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
  2457. DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
  2458. DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
  2459. DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
  2460. DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
  2461. DecoratorStaticBlock: "Decorators can't be used with a static block.",
  2462. DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
  2463. DeletePrivateField: "Deleting a private field is not allowed.",
  2464. DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  2465. DuplicateConstructor: "Duplicate constructor in the same class.",
  2466. DuplicateDefaultExport: "Only one default export allowed per module.",
  2467. DuplicateExport: ({
  2468. exportName
  2469. }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
  2470. DuplicateProto: "Redefinition of __proto__ property.",
  2471. DuplicateRegExpFlags: "Duplicate regular expression flag.",
  2472. DynamicImportPhaseRequiresImportExpressions: ({
  2473. phase
  2474. }) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`,
  2475. ElementAfterRest: "Rest element must be last element.",
  2476. EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
  2477. ExportBindingIsString: ({
  2478. localName,
  2479. exportName
  2480. }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
  2481. ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
  2482. ForInOfLoopInitializer: ({
  2483. type
  2484. }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
  2485. ForInUsing: "For-in loop may not start with 'using' declaration.",
  2486. ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
  2487. ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
  2488. GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
  2489. IllegalBreakContinue: ({
  2490. type
  2491. }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
  2492. IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
  2493. IllegalReturn: "'return' outside of function.",
  2494. 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.",
  2495. ImportBindingIsString: ({
  2496. importName
  2497. }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
  2498. ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.",
  2499. ImportCallArity: ({
  2500. maxArgumentCount
  2501. }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`,
  2502. ImportCallNotNewExpression: "Cannot use new with import(...).",
  2503. ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
  2504. ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
  2505. ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
  2506. ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.',
  2507. IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
  2508. InvalidBigIntLiteral: "Invalid BigIntLiteral.",
  2509. InvalidCodePoint: "Code point out of bounds.",
  2510. InvalidCoverInitializedName: "Invalid shorthand property initializer.",
  2511. InvalidDecimal: "Invalid decimal.",
  2512. InvalidDigit: ({
  2513. radix
  2514. }) => `Expected number in radix ${radix}.`,
  2515. InvalidEscapeSequence: "Bad character escape sequence.",
  2516. InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
  2517. InvalidEscapedReservedWord: ({
  2518. reservedWord
  2519. }) => `Escape sequence in keyword ${reservedWord}.`,
  2520. InvalidIdentifier: ({
  2521. identifierName
  2522. }) => `Invalid identifier ${identifierName}.`,
  2523. InvalidLhs: ({
  2524. ancestor
  2525. }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2526. InvalidLhsBinding: ({
  2527. ancestor
  2528. }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
  2529. InvalidLhsOptionalChaining: ({
  2530. ancestor
  2531. }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
  2532. InvalidNumber: "Invalid number.",
  2533. InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
  2534. InvalidOrUnexpectedToken: ({
  2535. unexpected
  2536. }) => `Unexpected character '${unexpected}'.`,
  2537. InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
  2538. InvalidPrivateFieldResolution: ({
  2539. identifierName
  2540. }) => `Private name #${identifierName} is not defined.`,
  2541. InvalidPropertyBindingPattern: "Binding member expression.",
  2542. InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
  2543. InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
  2544. LabelRedeclaration: ({
  2545. labelName
  2546. }) => `Label '${labelName}' is already declared.`,
  2547. LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
  2548. LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
  2549. MalformedRegExpFlags: "Invalid regular expression flag.",
  2550. MissingClassName: "A class name is required.",
  2551. MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
  2552. MissingSemicolon: "Missing semicolon.",
  2553. MissingPlugin: ({
  2554. missingPlugin
  2555. }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2556. MissingOneOfPlugins: ({
  2557. missingPlugin
  2558. }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`,
  2559. MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
  2560. MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
  2561. ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
  2562. ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
  2563. ModuleAttributesWithDuplicateKeys: ({
  2564. key
  2565. }) => `Duplicate key "${key}" is not allowed in module attributes.`,
  2566. ModuleExportNameHasLoneSurrogate: ({
  2567. surrogateCharCode
  2568. }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
  2569. ModuleExportUndefined: ({
  2570. localName
  2571. }) => `Export '${localName}' is not defined.`,
  2572. MultipleDefaultsInSwitch: "Multiple default clauses.",
  2573. NewlineAfterThrow: "Illegal newline after throw.",
  2574. NoCatchOrFinally: "Missing catch or finally clause.",
  2575. NumberIdentifier: "Identifier directly after number.",
  2576. NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
  2577. ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
  2578. OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
  2579. OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
  2580. OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
  2581. ParamDupe: "Argument name clash.",
  2582. PatternHasAccessor: "Object pattern can't contain getter or setter.",
  2583. PatternHasMethod: "Object pattern can't contain methods.",
  2584. PrivateInExpectedIn: ({
  2585. identifierName
  2586. }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
  2587. PrivateNameRedeclaration: ({
  2588. identifierName
  2589. }) => `Duplicate private name #${identifierName}.`,
  2590. RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2591. RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2592. RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2593. RecordNoProto: "'__proto__' is not allowed in Record expressions.",
  2594. RestTrailingComma: "Unexpected trailing comma after rest element.",
  2595. SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
  2596. 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.",
  2597. SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.',
  2598. StaticPrototype: "Classes may not have static property named prototype.",
  2599. 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?",
  2600. SuperPrivateField: "Private fields can't be accessed on super.",
  2601. TrailingDecorator: "Decorators must be attached to a class element.",
  2602. TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2603. TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
  2604. TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
  2605. UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
  2606. UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',
  2607. UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
  2608. UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
  2609. UnexpectedKeyword: ({
  2610. keyword
  2611. }) => `Unexpected keyword '${keyword}'.`,
  2612. UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
  2613. UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
  2614. UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
  2615. UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
  2616. UnexpectedPrivateField: "Unexpected private name.",
  2617. UnexpectedReservedWord: ({
  2618. reservedWord
  2619. }) => `Unexpected reserved word '${reservedWord}'.`,
  2620. UnexpectedSuper: "'super' is only allowed in object methods and classes.",
  2621. UnexpectedToken: ({
  2622. expected,
  2623. unexpected
  2624. }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
  2625. UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
  2626. UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.",
  2627. UnsupportedBind: "Binding should be performed on object property.",
  2628. UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
  2629. UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
  2630. UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
  2631. UnsupportedMetaProperty: ({
  2632. target,
  2633. onlyValidPropertyName
  2634. }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
  2635. UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
  2636. UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
  2637. UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
  2638. UnterminatedComment: "Unterminated comment.",
  2639. UnterminatedRegExp: "Unterminated regular expression.",
  2640. UnterminatedString: "Unterminated string constant.",
  2641. UnterminatedTemplate: "Unterminated template.",
  2642. UsingDeclarationExport: "Using declaration cannot be exported.",
  2643. UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
  2644. VarRedeclaration: ({
  2645. identifierName
  2646. }) => `Identifier '${identifierName}' has already been declared.`,
  2647. YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
  2648. YieldInParameter: "Yield expression is not allowed in formal parameters.",
  2649. ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
  2650. };
  2651. var StrictModeErrors = {
  2652. StrictDelete: "Deleting local variable in strict mode.",
  2653. StrictEvalArguments: ({
  2654. referenceName
  2655. }) => `Assigning to '${referenceName}' in strict mode.`,
  2656. StrictEvalArgumentsBinding: ({
  2657. bindingName
  2658. }) => `Binding '${bindingName}' in strict mode.`,
  2659. StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
  2660. StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
  2661. StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
  2662. StrictWith: "'with' in strict mode."
  2663. };
  2664. const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
  2665. var PipelineOperatorErrors = {
  2666. PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
  2667. PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
  2668. PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
  2669. PipeTopicUnconfiguredToken: ({
  2670. token
  2671. }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
  2672. PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
  2673. PipeUnparenthesizedBody: ({
  2674. type
  2675. }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
  2676. type
  2677. })}; please wrap it in parentheses.`,
  2678. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
  2679. PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
  2680. PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
  2681. PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
  2682. PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
  2683. PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
  2684. };
  2685. const _excluded = ["toMessage"],
  2686. _excluded2 = ["message"];
  2687. function defineHidden(obj, key, value) {
  2688. Object.defineProperty(obj, key, {
  2689. enumerable: false,
  2690. configurable: true,
  2691. value
  2692. });
  2693. }
  2694. function toParseErrorConstructor(_ref) {
  2695. let {
  2696. toMessage
  2697. } = _ref,
  2698. properties = _objectWithoutPropertiesLoose(_ref, _excluded);
  2699. return function constructor(loc, details) {
  2700. const error = new SyntaxError();
  2701. Object.assign(error, properties, {
  2702. loc,
  2703. pos: loc.index
  2704. });
  2705. if ("missingPlugin" in details) {
  2706. Object.assign(error, {
  2707. missingPlugin: details.missingPlugin
  2708. });
  2709. }
  2710. defineHidden(error, "clone", function clone(overrides = {}) {
  2711. var _overrides$loc;
  2712. const {
  2713. line,
  2714. column,
  2715. index
  2716. } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
  2717. return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
  2718. });
  2719. defineHidden(error, "details", details);
  2720. Object.defineProperty(error, "message", {
  2721. configurable: true,
  2722. get() {
  2723. const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
  2724. this.message = message;
  2725. return message;
  2726. },
  2727. set(value) {
  2728. Object.defineProperty(this, "message", {
  2729. value,
  2730. writable: true
  2731. });
  2732. }
  2733. });
  2734. return error;
  2735. };
  2736. }
  2737. function ParseErrorEnum(argument, syntaxPlugin) {
  2738. if (Array.isArray(argument)) {
  2739. return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]);
  2740. }
  2741. const ParseErrorConstructors = {};
  2742. for (const reasonCode of Object.keys(argument)) {
  2743. const template = argument[reasonCode];
  2744. const _ref2 = typeof template === "string" ? {
  2745. message: () => template
  2746. } : typeof template === "function" ? {
  2747. message: template
  2748. } : template,
  2749. {
  2750. message
  2751. } = _ref2,
  2752. rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
  2753. const toMessage = typeof message === "string" ? () => message : message;
  2754. ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
  2755. code: "BABEL_PARSER_SYNTAX_ERROR",
  2756. reasonCode,
  2757. toMessage
  2758. }, syntaxPlugin ? {
  2759. syntaxPlugin
  2760. } : {}, rest));
  2761. }
  2762. return ParseErrorConstructors;
  2763. }
  2764. const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
  2765. const {
  2766. defineProperty
  2767. } = Object;
  2768. const toUnenumerable = (object, key) => defineProperty(object, key, {
  2769. enumerable: false,
  2770. value: object[key]
  2771. });
  2772. function toESTreeLocation(node) {
  2773. node.loc.start && toUnenumerable(node.loc.start, "index");
  2774. node.loc.end && toUnenumerable(node.loc.end, "index");
  2775. return node;
  2776. }
  2777. var estree = superClass => class ESTreeParserMixin extends superClass {
  2778. parse() {
  2779. const file = toESTreeLocation(super.parse());
  2780. if (this.options.tokens) {
  2781. file.tokens = file.tokens.map(toESTreeLocation);
  2782. }
  2783. return file;
  2784. }
  2785. parseRegExpLiteral({
  2786. pattern,
  2787. flags
  2788. }) {
  2789. let regex = null;
  2790. try {
  2791. regex = new RegExp(pattern, flags);
  2792. } catch (e) {}
  2793. const node = this.estreeParseLiteral(regex);
  2794. node.regex = {
  2795. pattern,
  2796. flags
  2797. };
  2798. return node;
  2799. }
  2800. parseBigIntLiteral(value) {
  2801. let bigInt;
  2802. try {
  2803. bigInt = BigInt(value);
  2804. } catch (_unused) {
  2805. bigInt = null;
  2806. }
  2807. const node = this.estreeParseLiteral(bigInt);
  2808. node.bigint = String(node.value || value);
  2809. return node;
  2810. }
  2811. parseDecimalLiteral(value) {
  2812. const decimal = null;
  2813. const node = this.estreeParseLiteral(decimal);
  2814. node.decimal = String(node.value || value);
  2815. return node;
  2816. }
  2817. estreeParseLiteral(value) {
  2818. return this.parseLiteral(value, "Literal");
  2819. }
  2820. parseStringLiteral(value) {
  2821. return this.estreeParseLiteral(value);
  2822. }
  2823. parseNumericLiteral(value) {
  2824. return this.estreeParseLiteral(value);
  2825. }
  2826. parseNullLiteral() {
  2827. return this.estreeParseLiteral(null);
  2828. }
  2829. parseBooleanLiteral(value) {
  2830. return this.estreeParseLiteral(value);
  2831. }
  2832. directiveToStmt(directive) {
  2833. const expression = directive.value;
  2834. delete directive.value;
  2835. expression.type = "Literal";
  2836. expression.raw = expression.extra.raw;
  2837. expression.value = expression.extra.expressionValue;
  2838. const stmt = directive;
  2839. stmt.type = "ExpressionStatement";
  2840. stmt.expression = expression;
  2841. stmt.directive = expression.extra.rawValue;
  2842. delete expression.extra;
  2843. return stmt;
  2844. }
  2845. initFunction(node, isAsync) {
  2846. super.initFunction(node, isAsync);
  2847. node.expression = false;
  2848. }
  2849. checkDeclaration(node) {
  2850. if (node != null && this.isObjectProperty(node)) {
  2851. this.checkDeclaration(node.value);
  2852. } else {
  2853. super.checkDeclaration(node);
  2854. }
  2855. }
  2856. getObjectOrClassMethodParams(method) {
  2857. return method.value.params;
  2858. }
  2859. isValidDirective(stmt) {
  2860. var _stmt$expression$extr;
  2861. return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
  2862. }
  2863. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  2864. super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
  2865. const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
  2866. node.body = directiveStatements.concat(node.body);
  2867. delete node.directives;
  2868. }
  2869. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  2870. this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
  2871. if (method.typeParameters) {
  2872. method.value.typeParameters = method.typeParameters;
  2873. delete method.typeParameters;
  2874. }
  2875. classBody.body.push(method);
  2876. }
  2877. parsePrivateName() {
  2878. const node = super.parsePrivateName();
  2879. {
  2880. if (!this.getPluginOption("estree", "classFeatures")) {
  2881. return node;
  2882. }
  2883. }
  2884. return this.convertPrivateNameToPrivateIdentifier(node);
  2885. }
  2886. convertPrivateNameToPrivateIdentifier(node) {
  2887. const name = super.getPrivateNameSV(node);
  2888. node = node;
  2889. delete node.id;
  2890. node.name = name;
  2891. node.type = "PrivateIdentifier";
  2892. return node;
  2893. }
  2894. isPrivateName(node) {
  2895. {
  2896. if (!this.getPluginOption("estree", "classFeatures")) {
  2897. return super.isPrivateName(node);
  2898. }
  2899. }
  2900. return node.type === "PrivateIdentifier";
  2901. }
  2902. getPrivateNameSV(node) {
  2903. {
  2904. if (!this.getPluginOption("estree", "classFeatures")) {
  2905. return super.getPrivateNameSV(node);
  2906. }
  2907. }
  2908. return node.name;
  2909. }
  2910. parseLiteral(value, type) {
  2911. const node = super.parseLiteral(value, type);
  2912. node.raw = node.extra.raw;
  2913. delete node.extra;
  2914. return node;
  2915. }
  2916. parseFunctionBody(node, allowExpression, isMethod = false) {
  2917. super.parseFunctionBody(node, allowExpression, isMethod);
  2918. node.expression = node.body.type !== "BlockStatement";
  2919. }
  2920. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  2921. let funcNode = this.startNode();
  2922. funcNode.kind = node.kind;
  2923. funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  2924. funcNode.type = "FunctionExpression";
  2925. delete funcNode.kind;
  2926. node.value = funcNode;
  2927. if (type === "ClassPrivateMethod") {
  2928. node.computed = false;
  2929. }
  2930. return this.finishNode(node, "MethodDefinition");
  2931. }
  2932. nameIsConstructor(key) {
  2933. if (key.type === "Literal") return key.value === "constructor";
  2934. return super.nameIsConstructor(key);
  2935. }
  2936. parseClassProperty(...args) {
  2937. const propertyNode = super.parseClassProperty(...args);
  2938. {
  2939. if (!this.getPluginOption("estree", "classFeatures")) {
  2940. return propertyNode;
  2941. }
  2942. }
  2943. propertyNode.type = "PropertyDefinition";
  2944. return propertyNode;
  2945. }
  2946. parseClassPrivateProperty(...args) {
  2947. const propertyNode = super.parseClassPrivateProperty(...args);
  2948. {
  2949. if (!this.getPluginOption("estree", "classFeatures")) {
  2950. return propertyNode;
  2951. }
  2952. }
  2953. propertyNode.type = "PropertyDefinition";
  2954. propertyNode.computed = false;
  2955. return propertyNode;
  2956. }
  2957. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  2958. const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
  2959. if (node) {
  2960. node.type = "Property";
  2961. if (node.kind === "method") {
  2962. node.kind = "init";
  2963. }
  2964. node.shorthand = false;
  2965. }
  2966. return node;
  2967. }
  2968. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  2969. const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  2970. if (node) {
  2971. node.kind = "init";
  2972. node.type = "Property";
  2973. }
  2974. return node;
  2975. }
  2976. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  2977. return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  2978. }
  2979. isAssignable(node, isBinding) {
  2980. if (node != null && this.isObjectProperty(node)) {
  2981. return this.isAssignable(node.value, isBinding);
  2982. }
  2983. return super.isAssignable(node, isBinding);
  2984. }
  2985. toAssignable(node, isLHS = false) {
  2986. if (node != null && this.isObjectProperty(node)) {
  2987. const {
  2988. key,
  2989. value
  2990. } = node;
  2991. if (this.isPrivateName(key)) {
  2992. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  2993. }
  2994. this.toAssignable(value, isLHS);
  2995. } else {
  2996. super.toAssignable(node, isLHS);
  2997. }
  2998. }
  2999. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  3000. if (prop.type === "Property" && (prop.kind === "get" || prop.kind === "set")) {
  3001. this.raise(Errors.PatternHasAccessor, prop.key);
  3002. } else if (prop.type === "Property" && prop.method) {
  3003. this.raise(Errors.PatternHasMethod, prop.key);
  3004. } else {
  3005. super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  3006. }
  3007. }
  3008. finishCallExpression(unfinished, optional) {
  3009. const node = super.finishCallExpression(unfinished, optional);
  3010. if (node.callee.type === "Import") {
  3011. node.type = "ImportExpression";
  3012. node.source = node.arguments[0];
  3013. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  3014. var _ref, _ref2;
  3015. node.options = (_ref = node.arguments[1]) != null ? _ref : null;
  3016. node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
  3017. }
  3018. delete node.arguments;
  3019. delete node.callee;
  3020. }
  3021. return node;
  3022. }
  3023. toReferencedArguments(node) {
  3024. if (node.type === "ImportExpression") {
  3025. return;
  3026. }
  3027. super.toReferencedArguments(node);
  3028. }
  3029. parseExport(unfinished, decorators) {
  3030. const exportStartLoc = this.state.lastTokStartLoc;
  3031. const node = super.parseExport(unfinished, decorators);
  3032. switch (node.type) {
  3033. case "ExportAllDeclaration":
  3034. node.exported = null;
  3035. break;
  3036. case "ExportNamedDeclaration":
  3037. if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
  3038. node.type = "ExportAllDeclaration";
  3039. node.exported = node.specifiers[0].exported;
  3040. delete node.specifiers;
  3041. }
  3042. case "ExportDefaultDeclaration":
  3043. {
  3044. var _declaration$decorato;
  3045. const {
  3046. declaration
  3047. } = node;
  3048. if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) {
  3049. this.resetStartLocation(node, exportStartLoc);
  3050. }
  3051. }
  3052. break;
  3053. }
  3054. return node;
  3055. }
  3056. parseSubscript(base, startLoc, noCalls, state) {
  3057. const node = super.parseSubscript(base, startLoc, noCalls, state);
  3058. if (state.optionalChainMember) {
  3059. if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
  3060. node.type = node.type.substring(8);
  3061. }
  3062. if (state.stop) {
  3063. const chain = this.startNodeAtNode(node);
  3064. chain.expression = node;
  3065. return this.finishNode(chain, "ChainExpression");
  3066. }
  3067. } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
  3068. node.optional = false;
  3069. }
  3070. return node;
  3071. }
  3072. isOptionalMemberExpression(node) {
  3073. if (node.type === "ChainExpression") {
  3074. return node.expression.type === "MemberExpression";
  3075. }
  3076. return super.isOptionalMemberExpression(node);
  3077. }
  3078. hasPropertyAsPrivateName(node) {
  3079. if (node.type === "ChainExpression") {
  3080. node = node.expression;
  3081. }
  3082. return super.hasPropertyAsPrivateName(node);
  3083. }
  3084. isObjectProperty(node) {
  3085. return node.type === "Property" && node.kind === "init" && !node.method;
  3086. }
  3087. isObjectMethod(node) {
  3088. return node.type === "Property" && (node.method || node.kind === "get" || node.kind === "set");
  3089. }
  3090. finishNodeAt(node, type, endLoc) {
  3091. return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
  3092. }
  3093. resetStartLocation(node, startLoc) {
  3094. super.resetStartLocation(node, startLoc);
  3095. toESTreeLocation(node);
  3096. }
  3097. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  3098. super.resetEndLocation(node, endLoc);
  3099. toESTreeLocation(node);
  3100. }
  3101. };
  3102. class TokContext {
  3103. constructor(token, preserveSpace) {
  3104. this.token = void 0;
  3105. this.preserveSpace = void 0;
  3106. this.token = token;
  3107. this.preserveSpace = !!preserveSpace;
  3108. }
  3109. }
  3110. const types$1 = {
  3111. brace: new TokContext("{"),
  3112. j_oTag: new TokContext("<tag"),
  3113. j_cTag: new TokContext("</tag"),
  3114. j_expr: new TokContext("<tag>...</tag>", true)
  3115. };
  3116. {
  3117. types$1.template = new TokContext("`", true);
  3118. }
  3119. const beforeExpr = true;
  3120. const startsExpr = true;
  3121. const isLoop = true;
  3122. const isAssign = true;
  3123. const prefix = true;
  3124. const postfix = true;
  3125. class ExportedTokenType {
  3126. constructor(label, conf = {}) {
  3127. this.label = void 0;
  3128. this.keyword = void 0;
  3129. this.beforeExpr = void 0;
  3130. this.startsExpr = void 0;
  3131. this.rightAssociative = void 0;
  3132. this.isLoop = void 0;
  3133. this.isAssign = void 0;
  3134. this.prefix = void 0;
  3135. this.postfix = void 0;
  3136. this.binop = void 0;
  3137. this.label = label;
  3138. this.keyword = conf.keyword;
  3139. this.beforeExpr = !!conf.beforeExpr;
  3140. this.startsExpr = !!conf.startsExpr;
  3141. this.rightAssociative = !!conf.rightAssociative;
  3142. this.isLoop = !!conf.isLoop;
  3143. this.isAssign = !!conf.isAssign;
  3144. this.prefix = !!conf.prefix;
  3145. this.postfix = !!conf.postfix;
  3146. this.binop = conf.binop != null ? conf.binop : null;
  3147. {
  3148. this.updateContext = null;
  3149. }
  3150. }
  3151. }
  3152. const keywords$1 = new Map();
  3153. function createKeyword(name, options = {}) {
  3154. options.keyword = name;
  3155. const token = createToken(name, options);
  3156. keywords$1.set(name, token);
  3157. return token;
  3158. }
  3159. function createBinop(name, binop) {
  3160. return createToken(name, {
  3161. beforeExpr,
  3162. binop
  3163. });
  3164. }
  3165. let tokenTypeCounter = -1;
  3166. const tokenTypes$1 = [];
  3167. const tokenLabels = [];
  3168. const tokenBinops = [];
  3169. const tokenBeforeExprs = [];
  3170. const tokenStartsExprs = [];
  3171. const tokenPrefixes = [];
  3172. function createToken(name, options = {}) {
  3173. var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
  3174. ++tokenTypeCounter;
  3175. tokenLabels.push(name);
  3176. tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
  3177. tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
  3178. tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
  3179. tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
  3180. tokenTypes$1.push(new ExportedTokenType(name, options));
  3181. return tokenTypeCounter;
  3182. }
  3183. function createKeywordLike(name, options = {}) {
  3184. var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
  3185. ++tokenTypeCounter;
  3186. keywords$1.set(name, tokenTypeCounter);
  3187. tokenLabels.push(name);
  3188. tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
  3189. tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
  3190. tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
  3191. tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
  3192. tokenTypes$1.push(new ExportedTokenType("name", options));
  3193. return tokenTypeCounter;
  3194. }
  3195. const tt = {
  3196. bracketL: createToken("[", {
  3197. beforeExpr,
  3198. startsExpr
  3199. }),
  3200. bracketHashL: createToken("#[", {
  3201. beforeExpr,
  3202. startsExpr
  3203. }),
  3204. bracketBarL: createToken("[|", {
  3205. beforeExpr,
  3206. startsExpr
  3207. }),
  3208. bracketR: createToken("]"),
  3209. bracketBarR: createToken("|]"),
  3210. braceL: createToken("{", {
  3211. beforeExpr,
  3212. startsExpr
  3213. }),
  3214. braceBarL: createToken("{|", {
  3215. beforeExpr,
  3216. startsExpr
  3217. }),
  3218. braceHashL: createToken("#{", {
  3219. beforeExpr,
  3220. startsExpr
  3221. }),
  3222. braceR: createToken("}"),
  3223. braceBarR: createToken("|}"),
  3224. parenL: createToken("(", {
  3225. beforeExpr,
  3226. startsExpr
  3227. }),
  3228. parenR: createToken(")"),
  3229. comma: createToken(",", {
  3230. beforeExpr
  3231. }),
  3232. semi: createToken(";", {
  3233. beforeExpr
  3234. }),
  3235. colon: createToken(":", {
  3236. beforeExpr
  3237. }),
  3238. doubleColon: createToken("::", {
  3239. beforeExpr
  3240. }),
  3241. dot: createToken("."),
  3242. question: createToken("?", {
  3243. beforeExpr
  3244. }),
  3245. questionDot: createToken("?."),
  3246. arrow: createToken("=>", {
  3247. beforeExpr
  3248. }),
  3249. template: createToken("template"),
  3250. ellipsis: createToken("...", {
  3251. beforeExpr
  3252. }),
  3253. backQuote: createToken("`", {
  3254. startsExpr
  3255. }),
  3256. dollarBraceL: createToken("${", {
  3257. beforeExpr,
  3258. startsExpr
  3259. }),
  3260. templateTail: createToken("...`", {
  3261. startsExpr
  3262. }),
  3263. templateNonTail: createToken("...${", {
  3264. beforeExpr,
  3265. startsExpr
  3266. }),
  3267. at: createToken("@"),
  3268. hash: createToken("#", {
  3269. startsExpr
  3270. }),
  3271. interpreterDirective: createToken("#!..."),
  3272. eq: createToken("=", {
  3273. beforeExpr,
  3274. isAssign
  3275. }),
  3276. assign: createToken("_=", {
  3277. beforeExpr,
  3278. isAssign
  3279. }),
  3280. slashAssign: createToken("_=", {
  3281. beforeExpr,
  3282. isAssign
  3283. }),
  3284. xorAssign: createToken("_=", {
  3285. beforeExpr,
  3286. isAssign
  3287. }),
  3288. moduloAssign: createToken("_=", {
  3289. beforeExpr,
  3290. isAssign
  3291. }),
  3292. incDec: createToken("++/--", {
  3293. prefix,
  3294. postfix,
  3295. startsExpr
  3296. }),
  3297. bang: createToken("!", {
  3298. beforeExpr,
  3299. prefix,
  3300. startsExpr
  3301. }),
  3302. tilde: createToken("~", {
  3303. beforeExpr,
  3304. prefix,
  3305. startsExpr
  3306. }),
  3307. doubleCaret: createToken("^^", {
  3308. startsExpr
  3309. }),
  3310. doubleAt: createToken("@@", {
  3311. startsExpr
  3312. }),
  3313. pipeline: createBinop("|>", 0),
  3314. nullishCoalescing: createBinop("??", 1),
  3315. logicalOR: createBinop("||", 1),
  3316. logicalAND: createBinop("&&", 2),
  3317. bitwiseOR: createBinop("|", 3),
  3318. bitwiseXOR: createBinop("^", 4),
  3319. bitwiseAND: createBinop("&", 5),
  3320. equality: createBinop("==/!=/===/!==", 6),
  3321. lt: createBinop("</>/<=/>=", 7),
  3322. gt: createBinop("</>/<=/>=", 7),
  3323. relational: createBinop("</>/<=/>=", 7),
  3324. bitShift: createBinop("<</>>/>>>", 8),
  3325. bitShiftL: createBinop("<</>>/>>>", 8),
  3326. bitShiftR: createBinop("<</>>/>>>", 8),
  3327. plusMin: createToken("+/-", {
  3328. beforeExpr,
  3329. binop: 9,
  3330. prefix,
  3331. startsExpr
  3332. }),
  3333. modulo: createToken("%", {
  3334. binop: 10,
  3335. startsExpr
  3336. }),
  3337. star: createToken("*", {
  3338. binop: 10
  3339. }),
  3340. slash: createBinop("/", 10),
  3341. exponent: createToken("**", {
  3342. beforeExpr,
  3343. binop: 11,
  3344. rightAssociative: true
  3345. }),
  3346. _in: createKeyword("in", {
  3347. beforeExpr,
  3348. binop: 7
  3349. }),
  3350. _instanceof: createKeyword("instanceof", {
  3351. beforeExpr,
  3352. binop: 7
  3353. }),
  3354. _break: createKeyword("break"),
  3355. _case: createKeyword("case", {
  3356. beforeExpr
  3357. }),
  3358. _catch: createKeyword("catch"),
  3359. _continue: createKeyword("continue"),
  3360. _debugger: createKeyword("debugger"),
  3361. _default: createKeyword("default", {
  3362. beforeExpr
  3363. }),
  3364. _else: createKeyword("else", {
  3365. beforeExpr
  3366. }),
  3367. _finally: createKeyword("finally"),
  3368. _function: createKeyword("function", {
  3369. startsExpr
  3370. }),
  3371. _if: createKeyword("if"),
  3372. _return: createKeyword("return", {
  3373. beforeExpr
  3374. }),
  3375. _switch: createKeyword("switch"),
  3376. _throw: createKeyword("throw", {
  3377. beforeExpr,
  3378. prefix,
  3379. startsExpr
  3380. }),
  3381. _try: createKeyword("try"),
  3382. _var: createKeyword("var"),
  3383. _const: createKeyword("const"),
  3384. _with: createKeyword("with"),
  3385. _new: createKeyword("new", {
  3386. beforeExpr,
  3387. startsExpr
  3388. }),
  3389. _this: createKeyword("this", {
  3390. startsExpr
  3391. }),
  3392. _super: createKeyword("super", {
  3393. startsExpr
  3394. }),
  3395. _class: createKeyword("class", {
  3396. startsExpr
  3397. }),
  3398. _extends: createKeyword("extends", {
  3399. beforeExpr
  3400. }),
  3401. _export: createKeyword("export"),
  3402. _import: createKeyword("import", {
  3403. startsExpr
  3404. }),
  3405. _null: createKeyword("null", {
  3406. startsExpr
  3407. }),
  3408. _true: createKeyword("true", {
  3409. startsExpr
  3410. }),
  3411. _false: createKeyword("false", {
  3412. startsExpr
  3413. }),
  3414. _typeof: createKeyword("typeof", {
  3415. beforeExpr,
  3416. prefix,
  3417. startsExpr
  3418. }),
  3419. _void: createKeyword("void", {
  3420. beforeExpr,
  3421. prefix,
  3422. startsExpr
  3423. }),
  3424. _delete: createKeyword("delete", {
  3425. beforeExpr,
  3426. prefix,
  3427. startsExpr
  3428. }),
  3429. _do: createKeyword("do", {
  3430. isLoop,
  3431. beforeExpr
  3432. }),
  3433. _for: createKeyword("for", {
  3434. isLoop
  3435. }),
  3436. _while: createKeyword("while", {
  3437. isLoop
  3438. }),
  3439. _as: createKeywordLike("as", {
  3440. startsExpr
  3441. }),
  3442. _assert: createKeywordLike("assert", {
  3443. startsExpr
  3444. }),
  3445. _async: createKeywordLike("async", {
  3446. startsExpr
  3447. }),
  3448. _await: createKeywordLike("await", {
  3449. startsExpr
  3450. }),
  3451. _defer: createKeywordLike("defer", {
  3452. startsExpr
  3453. }),
  3454. _from: createKeywordLike("from", {
  3455. startsExpr
  3456. }),
  3457. _get: createKeywordLike("get", {
  3458. startsExpr
  3459. }),
  3460. _let: createKeywordLike("let", {
  3461. startsExpr
  3462. }),
  3463. _meta: createKeywordLike("meta", {
  3464. startsExpr
  3465. }),
  3466. _of: createKeywordLike("of", {
  3467. startsExpr
  3468. }),
  3469. _sent: createKeywordLike("sent", {
  3470. startsExpr
  3471. }),
  3472. _set: createKeywordLike("set", {
  3473. startsExpr
  3474. }),
  3475. _source: createKeywordLike("source", {
  3476. startsExpr
  3477. }),
  3478. _static: createKeywordLike("static", {
  3479. startsExpr
  3480. }),
  3481. _using: createKeywordLike("using", {
  3482. startsExpr
  3483. }),
  3484. _yield: createKeywordLike("yield", {
  3485. startsExpr
  3486. }),
  3487. _asserts: createKeywordLike("asserts", {
  3488. startsExpr
  3489. }),
  3490. _checks: createKeywordLike("checks", {
  3491. startsExpr
  3492. }),
  3493. _exports: createKeywordLike("exports", {
  3494. startsExpr
  3495. }),
  3496. _global: createKeywordLike("global", {
  3497. startsExpr
  3498. }),
  3499. _implements: createKeywordLike("implements", {
  3500. startsExpr
  3501. }),
  3502. _intrinsic: createKeywordLike("intrinsic", {
  3503. startsExpr
  3504. }),
  3505. _infer: createKeywordLike("infer", {
  3506. startsExpr
  3507. }),
  3508. _is: createKeywordLike("is", {
  3509. startsExpr
  3510. }),
  3511. _mixins: createKeywordLike("mixins", {
  3512. startsExpr
  3513. }),
  3514. _proto: createKeywordLike("proto", {
  3515. startsExpr
  3516. }),
  3517. _require: createKeywordLike("require", {
  3518. startsExpr
  3519. }),
  3520. _satisfies: createKeywordLike("satisfies", {
  3521. startsExpr
  3522. }),
  3523. _keyof: createKeywordLike("keyof", {
  3524. startsExpr
  3525. }),
  3526. _readonly: createKeywordLike("readonly", {
  3527. startsExpr
  3528. }),
  3529. _unique: createKeywordLike("unique", {
  3530. startsExpr
  3531. }),
  3532. _abstract: createKeywordLike("abstract", {
  3533. startsExpr
  3534. }),
  3535. _declare: createKeywordLike("declare", {
  3536. startsExpr
  3537. }),
  3538. _enum: createKeywordLike("enum", {
  3539. startsExpr
  3540. }),
  3541. _module: createKeywordLike("module", {
  3542. startsExpr
  3543. }),
  3544. _namespace: createKeywordLike("namespace", {
  3545. startsExpr
  3546. }),
  3547. _interface: createKeywordLike("interface", {
  3548. startsExpr
  3549. }),
  3550. _type: createKeywordLike("type", {
  3551. startsExpr
  3552. }),
  3553. _opaque: createKeywordLike("opaque", {
  3554. startsExpr
  3555. }),
  3556. name: createToken("name", {
  3557. startsExpr
  3558. }),
  3559. string: createToken("string", {
  3560. startsExpr
  3561. }),
  3562. num: createToken("num", {
  3563. startsExpr
  3564. }),
  3565. bigint: createToken("bigint", {
  3566. startsExpr
  3567. }),
  3568. decimal: createToken("decimal", {
  3569. startsExpr
  3570. }),
  3571. regexp: createToken("regexp", {
  3572. startsExpr
  3573. }),
  3574. privateName: createToken("#name", {
  3575. startsExpr
  3576. }),
  3577. eof: createToken("eof"),
  3578. jsxName: createToken("jsxName"),
  3579. jsxText: createToken("jsxText", {
  3580. beforeExpr: true
  3581. }),
  3582. jsxTagStart: createToken("jsxTagStart", {
  3583. startsExpr: true
  3584. }),
  3585. jsxTagEnd: createToken("jsxTagEnd"),
  3586. placeholder: createToken("%%", {
  3587. startsExpr: true
  3588. })
  3589. };
  3590. function tokenIsIdentifier(token) {
  3591. return token >= 93 && token <= 132;
  3592. }
  3593. function tokenKeywordOrIdentifierIsKeyword(token) {
  3594. return token <= 92;
  3595. }
  3596. function tokenIsKeywordOrIdentifier(token) {
  3597. return token >= 58 && token <= 132;
  3598. }
  3599. function tokenIsLiteralPropertyName(token) {
  3600. return token >= 58 && token <= 136;
  3601. }
  3602. function tokenComesBeforeExpression(token) {
  3603. return tokenBeforeExprs[token];
  3604. }
  3605. function tokenCanStartExpression(token) {
  3606. return tokenStartsExprs[token];
  3607. }
  3608. function tokenIsAssignment(token) {
  3609. return token >= 29 && token <= 33;
  3610. }
  3611. function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
  3612. return token >= 129 && token <= 131;
  3613. }
  3614. function tokenIsLoop(token) {
  3615. return token >= 90 && token <= 92;
  3616. }
  3617. function tokenIsKeyword(token) {
  3618. return token >= 58 && token <= 92;
  3619. }
  3620. function tokenIsOperator(token) {
  3621. return token >= 39 && token <= 59;
  3622. }
  3623. function tokenIsPostfix(token) {
  3624. return token === 34;
  3625. }
  3626. function tokenIsPrefix(token) {
  3627. return tokenPrefixes[token];
  3628. }
  3629. function tokenIsTSTypeOperator(token) {
  3630. return token >= 121 && token <= 123;
  3631. }
  3632. function tokenIsTSDeclarationStart(token) {
  3633. return token >= 124 && token <= 130;
  3634. }
  3635. function tokenLabelName(token) {
  3636. return tokenLabels[token];
  3637. }
  3638. function tokenOperatorPrecedence(token) {
  3639. return tokenBinops[token];
  3640. }
  3641. function tokenIsRightAssociative(token) {
  3642. return token === 57;
  3643. }
  3644. function tokenIsTemplate(token) {
  3645. return token >= 24 && token <= 25;
  3646. }
  3647. function getExportedToken(token) {
  3648. return tokenTypes$1[token];
  3649. }
  3650. {
  3651. tokenTypes$1[8].updateContext = context => {
  3652. context.pop();
  3653. };
  3654. tokenTypes$1[5].updateContext = tokenTypes$1[7].updateContext = tokenTypes$1[23].updateContext = context => {
  3655. context.push(types$1.brace);
  3656. };
  3657. tokenTypes$1[22].updateContext = context => {
  3658. if (context[context.length - 1] === types$1.template) {
  3659. context.pop();
  3660. } else {
  3661. context.push(types$1.template);
  3662. }
  3663. };
  3664. tokenTypes$1[142].updateContext = context => {
  3665. context.push(types$1.j_expr, types$1.j_oTag);
  3666. };
  3667. }
  3668. 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";
  3669. 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";
  3670. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
  3671. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
  3672. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
  3673. 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];
  3674. 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];
  3675. function isInAstralSet(code, set) {
  3676. let pos = 0x10000;
  3677. for (let i = 0, length = set.length; i < length; i += 2) {
  3678. pos += set[i];
  3679. if (pos > code) return false;
  3680. pos += set[i + 1];
  3681. if (pos >= code) return true;
  3682. }
  3683. return false;
  3684. }
  3685. function isIdentifierStart(code) {
  3686. if (code < 65) return code === 36;
  3687. if (code <= 90) return true;
  3688. if (code < 97) return code === 95;
  3689. if (code <= 122) return true;
  3690. if (code <= 0xffff) {
  3691. return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
  3692. }
  3693. return isInAstralSet(code, astralIdentifierStartCodes);
  3694. }
  3695. function isIdentifierChar(code) {
  3696. if (code < 48) return code === 36;
  3697. if (code < 58) return true;
  3698. if (code < 65) return false;
  3699. if (code <= 90) return true;
  3700. if (code < 97) return code === 95;
  3701. if (code <= 122) return true;
  3702. if (code <= 0xffff) {
  3703. return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
  3704. }
  3705. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
  3706. }
  3707. const reservedWords = {
  3708. 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"],
  3709. strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
  3710. strictBind: ["eval", "arguments"]
  3711. };
  3712. const keywords = new Set(reservedWords.keyword);
  3713. const reservedWordsStrictSet = new Set(reservedWords.strict);
  3714. const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
  3715. function isReservedWord(word, inModule) {
  3716. return inModule && word === "await" || word === "enum";
  3717. }
  3718. function isStrictReservedWord(word, inModule) {
  3719. return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
  3720. }
  3721. function isStrictBindOnlyReservedWord(word) {
  3722. return reservedWordsStrictBindSet.has(word);
  3723. }
  3724. function isStrictBindReservedWord(word, inModule) {
  3725. return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
  3726. }
  3727. function isKeyword(word) {
  3728. return keywords.has(word);
  3729. }
  3730. function isIteratorStart(current, next, next2) {
  3731. return current === 64 && next === 64 && isIdentifierStart(next2);
  3732. }
  3733. 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"]);
  3734. function canBeReservedWord(word) {
  3735. return reservedWordLikeSet.has(word);
  3736. }
  3737. class Scope {
  3738. constructor(flags) {
  3739. this.flags = 0;
  3740. this.names = new Map();
  3741. this.firstLexicalName = "";
  3742. this.flags = flags;
  3743. }
  3744. }
  3745. class ScopeHandler {
  3746. constructor(parser, inModule) {
  3747. this.parser = void 0;
  3748. this.scopeStack = [];
  3749. this.inModule = void 0;
  3750. this.undefinedExports = new Map();
  3751. this.parser = parser;
  3752. this.inModule = inModule;
  3753. }
  3754. get inTopLevel() {
  3755. return (this.currentScope().flags & 1) > 0;
  3756. }
  3757. get inFunction() {
  3758. return (this.currentVarScopeFlags() & 2) > 0;
  3759. }
  3760. get allowSuper() {
  3761. return (this.currentThisScopeFlags() & 16) > 0;
  3762. }
  3763. get allowDirectSuper() {
  3764. return (this.currentThisScopeFlags() & 32) > 0;
  3765. }
  3766. get inClass() {
  3767. return (this.currentThisScopeFlags() & 64) > 0;
  3768. }
  3769. get inClassAndNotInNonArrowFunction() {
  3770. const flags = this.currentThisScopeFlags();
  3771. return (flags & 64) > 0 && (flags & 2) === 0;
  3772. }
  3773. get inStaticBlock() {
  3774. for (let i = this.scopeStack.length - 1;; i--) {
  3775. const {
  3776. flags
  3777. } = this.scopeStack[i];
  3778. if (flags & 128) {
  3779. return true;
  3780. }
  3781. if (flags & (387 | 64)) {
  3782. return false;
  3783. }
  3784. }
  3785. }
  3786. get inNonArrowFunction() {
  3787. return (this.currentThisScopeFlags() & 2) > 0;
  3788. }
  3789. get treatFunctionsAsVar() {
  3790. return this.treatFunctionsAsVarInScope(this.currentScope());
  3791. }
  3792. createScope(flags) {
  3793. return new Scope(flags);
  3794. }
  3795. enter(flags) {
  3796. this.scopeStack.push(this.createScope(flags));
  3797. }
  3798. exit() {
  3799. const scope = this.scopeStack.pop();
  3800. return scope.flags;
  3801. }
  3802. treatFunctionsAsVarInScope(scope) {
  3803. return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1);
  3804. }
  3805. declareName(name, bindingType, loc) {
  3806. let scope = this.currentScope();
  3807. if (bindingType & 8 || bindingType & 16) {
  3808. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3809. let type = scope.names.get(name) || 0;
  3810. if (bindingType & 16) {
  3811. type = type | 4;
  3812. } else {
  3813. if (!scope.firstLexicalName) {
  3814. scope.firstLexicalName = name;
  3815. }
  3816. type = type | 2;
  3817. }
  3818. scope.names.set(name, type);
  3819. if (bindingType & 8) {
  3820. this.maybeExportDefined(scope, name);
  3821. }
  3822. } else if (bindingType & 4) {
  3823. for (let i = this.scopeStack.length - 1; i >= 0; --i) {
  3824. scope = this.scopeStack[i];
  3825. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3826. scope.names.set(name, (scope.names.get(name) || 0) | 1);
  3827. this.maybeExportDefined(scope, name);
  3828. if (scope.flags & 387) break;
  3829. }
  3830. }
  3831. if (this.parser.inModule && scope.flags & 1) {
  3832. this.undefinedExports.delete(name);
  3833. }
  3834. }
  3835. maybeExportDefined(scope, name) {
  3836. if (this.parser.inModule && scope.flags & 1) {
  3837. this.undefinedExports.delete(name);
  3838. }
  3839. }
  3840. checkRedeclarationInScope(scope, name, bindingType, loc) {
  3841. if (this.isRedeclaredInScope(scope, name, bindingType)) {
  3842. this.parser.raise(Errors.VarRedeclaration, loc, {
  3843. identifierName: name
  3844. });
  3845. }
  3846. }
  3847. isRedeclaredInScope(scope, name, bindingType) {
  3848. if (!(bindingType & 1)) return false;
  3849. if (bindingType & 8) {
  3850. return scope.names.has(name);
  3851. }
  3852. const type = scope.names.get(name);
  3853. if (bindingType & 16) {
  3854. return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0;
  3855. }
  3856. return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0;
  3857. }
  3858. checkLocalExport(id) {
  3859. const {
  3860. name
  3861. } = id;
  3862. const topLevelScope = this.scopeStack[0];
  3863. if (!topLevelScope.names.has(name)) {
  3864. this.undefinedExports.set(name, id.loc.start);
  3865. }
  3866. }
  3867. currentScope() {
  3868. return this.scopeStack[this.scopeStack.length - 1];
  3869. }
  3870. currentVarScopeFlags() {
  3871. for (let i = this.scopeStack.length - 1;; i--) {
  3872. const {
  3873. flags
  3874. } = this.scopeStack[i];
  3875. if (flags & 387) {
  3876. return flags;
  3877. }
  3878. }
  3879. }
  3880. currentThisScopeFlags() {
  3881. for (let i = this.scopeStack.length - 1;; i--) {
  3882. const {
  3883. flags
  3884. } = this.scopeStack[i];
  3885. if (flags & (387 | 64) && !(flags & 4)) {
  3886. return flags;
  3887. }
  3888. }
  3889. }
  3890. }
  3891. class FlowScope extends Scope {
  3892. constructor(...args) {
  3893. super(...args);
  3894. this.declareFunctions = new Set();
  3895. }
  3896. }
  3897. class FlowScopeHandler extends ScopeHandler {
  3898. createScope(flags) {
  3899. return new FlowScope(flags);
  3900. }
  3901. declareName(name, bindingType, loc) {
  3902. const scope = this.currentScope();
  3903. if (bindingType & 2048) {
  3904. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  3905. this.maybeExportDefined(scope, name);
  3906. scope.declareFunctions.add(name);
  3907. return;
  3908. }
  3909. super.declareName(name, bindingType, loc);
  3910. }
  3911. isRedeclaredInScope(scope, name, bindingType) {
  3912. if (super.isRedeclaredInScope(scope, name, bindingType)) return true;
  3913. if (bindingType & 2048 && !scope.declareFunctions.has(name)) {
  3914. const type = scope.names.get(name);
  3915. return (type & 4) > 0 || (type & 2) > 0;
  3916. }
  3917. return false;
  3918. }
  3919. checkLocalExport(id) {
  3920. if (!this.scopeStack[0].declareFunctions.has(id.name)) {
  3921. super.checkLocalExport(id);
  3922. }
  3923. }
  3924. }
  3925. class BaseParser {
  3926. constructor() {
  3927. this.sawUnambiguousESM = false;
  3928. this.ambiguousScriptDifferentAst = false;
  3929. }
  3930. hasPlugin(pluginConfig) {
  3931. if (typeof pluginConfig === "string") {
  3932. return this.plugins.has(pluginConfig);
  3933. } else {
  3934. const [pluginName, pluginOptions] = pluginConfig;
  3935. if (!this.hasPlugin(pluginName)) {
  3936. return false;
  3937. }
  3938. const actualOptions = this.plugins.get(pluginName);
  3939. for (const key of Object.keys(pluginOptions)) {
  3940. if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) {
  3941. return false;
  3942. }
  3943. }
  3944. return true;
  3945. }
  3946. }
  3947. getPluginOption(plugin, name) {
  3948. var _this$plugins$get;
  3949. return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name];
  3950. }
  3951. }
  3952. function setTrailingComments(node, comments) {
  3953. if (node.trailingComments === undefined) {
  3954. node.trailingComments = comments;
  3955. } else {
  3956. node.trailingComments.unshift(...comments);
  3957. }
  3958. }
  3959. function setLeadingComments(node, comments) {
  3960. if (node.leadingComments === undefined) {
  3961. node.leadingComments = comments;
  3962. } else {
  3963. node.leadingComments.unshift(...comments);
  3964. }
  3965. }
  3966. function setInnerComments(node, comments) {
  3967. if (node.innerComments === undefined) {
  3968. node.innerComments = comments;
  3969. } else {
  3970. node.innerComments.unshift(...comments);
  3971. }
  3972. }
  3973. function adjustInnerComments(node, elements, commentWS) {
  3974. let lastElement = null;
  3975. let i = elements.length;
  3976. while (lastElement === null && i > 0) {
  3977. lastElement = elements[--i];
  3978. }
  3979. if (lastElement === null || lastElement.start > commentWS.start) {
  3980. setInnerComments(node, commentWS.comments);
  3981. } else {
  3982. setTrailingComments(lastElement, commentWS.comments);
  3983. }
  3984. }
  3985. class CommentsParser extends BaseParser {
  3986. addComment(comment) {
  3987. if (this.filename) comment.loc.filename = this.filename;
  3988. const {
  3989. commentsLen
  3990. } = this.state;
  3991. if (this.comments.length !== commentsLen) {
  3992. this.comments.length = commentsLen;
  3993. }
  3994. this.comments.push(comment);
  3995. this.state.commentsLen++;
  3996. }
  3997. processComment(node) {
  3998. const {
  3999. commentStack
  4000. } = this.state;
  4001. const commentStackLength = commentStack.length;
  4002. if (commentStackLength === 0) return;
  4003. let i = commentStackLength - 1;
  4004. const lastCommentWS = commentStack[i];
  4005. if (lastCommentWS.start === node.end) {
  4006. lastCommentWS.leadingNode = node;
  4007. i--;
  4008. }
  4009. const {
  4010. start: nodeStart
  4011. } = node;
  4012. for (; i >= 0; i--) {
  4013. const commentWS = commentStack[i];
  4014. const commentEnd = commentWS.end;
  4015. if (commentEnd > nodeStart) {
  4016. commentWS.containingNode = node;
  4017. this.finalizeComment(commentWS);
  4018. commentStack.splice(i, 1);
  4019. } else {
  4020. if (commentEnd === nodeStart) {
  4021. commentWS.trailingNode = node;
  4022. }
  4023. break;
  4024. }
  4025. }
  4026. }
  4027. finalizeComment(commentWS) {
  4028. const {
  4029. comments
  4030. } = commentWS;
  4031. if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) {
  4032. if (commentWS.leadingNode !== null) {
  4033. setTrailingComments(commentWS.leadingNode, comments);
  4034. }
  4035. if (commentWS.trailingNode !== null) {
  4036. setLeadingComments(commentWS.trailingNode, comments);
  4037. }
  4038. } else {
  4039. const {
  4040. containingNode: node,
  4041. start: commentStart
  4042. } = commentWS;
  4043. if (this.input.charCodeAt(commentStart - 1) === 44) {
  4044. switch (node.type) {
  4045. case "ObjectExpression":
  4046. case "ObjectPattern":
  4047. case "RecordExpression":
  4048. adjustInnerComments(node, node.properties, commentWS);
  4049. break;
  4050. case "CallExpression":
  4051. case "OptionalCallExpression":
  4052. adjustInnerComments(node, node.arguments, commentWS);
  4053. break;
  4054. case "FunctionDeclaration":
  4055. case "FunctionExpression":
  4056. case "ArrowFunctionExpression":
  4057. case "ObjectMethod":
  4058. case "ClassMethod":
  4059. case "ClassPrivateMethod":
  4060. adjustInnerComments(node, node.params, commentWS);
  4061. break;
  4062. case "ArrayExpression":
  4063. case "ArrayPattern":
  4064. case "TupleExpression":
  4065. adjustInnerComments(node, node.elements, commentWS);
  4066. break;
  4067. case "ExportNamedDeclaration":
  4068. case "ImportDeclaration":
  4069. adjustInnerComments(node, node.specifiers, commentWS);
  4070. break;
  4071. default:
  4072. {
  4073. setInnerComments(node, comments);
  4074. }
  4075. }
  4076. } else {
  4077. setInnerComments(node, comments);
  4078. }
  4079. }
  4080. }
  4081. finalizeRemainingComments() {
  4082. const {
  4083. commentStack
  4084. } = this.state;
  4085. for (let i = commentStack.length - 1; i >= 0; i--) {
  4086. this.finalizeComment(commentStack[i]);
  4087. }
  4088. this.state.commentStack = [];
  4089. }
  4090. resetPreviousNodeTrailingComments(node) {
  4091. const {
  4092. commentStack
  4093. } = this.state;
  4094. const {
  4095. length
  4096. } = commentStack;
  4097. if (length === 0) return;
  4098. const commentWS = commentStack[length - 1];
  4099. if (commentWS.leadingNode === node) {
  4100. commentWS.leadingNode = null;
  4101. }
  4102. }
  4103. resetPreviousIdentifierLeadingComments(node) {
  4104. const {
  4105. commentStack
  4106. } = this.state;
  4107. const {
  4108. length
  4109. } = commentStack;
  4110. if (length === 0) return;
  4111. if (commentStack[length - 1].trailingNode === node) {
  4112. commentStack[length - 1].trailingNode = null;
  4113. } else if (length >= 2 && commentStack[length - 2].trailingNode === node) {
  4114. commentStack[length - 2].trailingNode = null;
  4115. }
  4116. }
  4117. takeSurroundingComments(node, start, end) {
  4118. const {
  4119. commentStack
  4120. } = this.state;
  4121. const commentStackLength = commentStack.length;
  4122. if (commentStackLength === 0) return;
  4123. let i = commentStackLength - 1;
  4124. for (; i >= 0; i--) {
  4125. const commentWS = commentStack[i];
  4126. const commentEnd = commentWS.end;
  4127. const commentStart = commentWS.start;
  4128. if (commentStart === end) {
  4129. commentWS.leadingNode = node;
  4130. } else if (commentEnd === start) {
  4131. commentWS.trailingNode = node;
  4132. } else if (commentEnd < start) {
  4133. break;
  4134. }
  4135. }
  4136. }
  4137. }
  4138. const lineBreak = /\r\n?|[\n\u2028\u2029]/;
  4139. const lineBreakG = new RegExp(lineBreak.source, "g");
  4140. function isNewLine(code) {
  4141. switch (code) {
  4142. case 10:
  4143. case 13:
  4144. case 8232:
  4145. case 8233:
  4146. return true;
  4147. default:
  4148. return false;
  4149. }
  4150. }
  4151. const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
  4152. const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;
  4153. const skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
  4154. function isWhitespace(code) {
  4155. switch (code) {
  4156. case 0x0009:
  4157. case 0x000b:
  4158. case 0x000c:
  4159. case 32:
  4160. case 160:
  4161. case 5760:
  4162. case 0x2000:
  4163. case 0x2001:
  4164. case 0x2002:
  4165. case 0x2003:
  4166. case 0x2004:
  4167. case 0x2005:
  4168. case 0x2006:
  4169. case 0x2007:
  4170. case 0x2008:
  4171. case 0x2009:
  4172. case 0x200a:
  4173. case 0x202f:
  4174. case 0x205f:
  4175. case 0x3000:
  4176. case 0xfeff:
  4177. return true;
  4178. default:
  4179. return false;
  4180. }
  4181. }
  4182. class State {
  4183. constructor() {
  4184. this.flags = 1024;
  4185. this.curLine = void 0;
  4186. this.lineStart = void 0;
  4187. this.startLoc = void 0;
  4188. this.endLoc = void 0;
  4189. this.errors = [];
  4190. this.potentialArrowAt = -1;
  4191. this.noArrowAt = [];
  4192. this.noArrowParamsConversionAt = [];
  4193. this.topicContext = {
  4194. maxNumOfResolvableTopics: 0,
  4195. maxTopicIndex: null
  4196. };
  4197. this.labels = [];
  4198. this.commentsLen = 0;
  4199. this.commentStack = [];
  4200. this.pos = 0;
  4201. this.type = 139;
  4202. this.value = null;
  4203. this.start = 0;
  4204. this.end = 0;
  4205. this.lastTokEndLoc = null;
  4206. this.lastTokStartLoc = null;
  4207. this.context = [types$1.brace];
  4208. this.firstInvalidTemplateEscapePos = null;
  4209. this.strictErrors = new Map();
  4210. this.tokensLength = 0;
  4211. }
  4212. get strict() {
  4213. return (this.flags & 1) > 0;
  4214. }
  4215. set strict(v) {
  4216. if (v) this.flags |= 1;else this.flags &= -2;
  4217. }
  4218. init({
  4219. strictMode,
  4220. sourceType,
  4221. startLine,
  4222. startColumn
  4223. }) {
  4224. this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
  4225. this.curLine = startLine;
  4226. this.lineStart = -startColumn;
  4227. this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
  4228. }
  4229. get maybeInArrowParameters() {
  4230. return (this.flags & 2) > 0;
  4231. }
  4232. set maybeInArrowParameters(v) {
  4233. if (v) this.flags |= 2;else this.flags &= -3;
  4234. }
  4235. get inType() {
  4236. return (this.flags & 4) > 0;
  4237. }
  4238. set inType(v) {
  4239. if (v) this.flags |= 4;else this.flags &= -5;
  4240. }
  4241. get noAnonFunctionType() {
  4242. return (this.flags & 8) > 0;
  4243. }
  4244. set noAnonFunctionType(v) {
  4245. if (v) this.flags |= 8;else this.flags &= -9;
  4246. }
  4247. get hasFlowComment() {
  4248. return (this.flags & 16) > 0;
  4249. }
  4250. set hasFlowComment(v) {
  4251. if (v) this.flags |= 16;else this.flags &= -17;
  4252. }
  4253. get isAmbientContext() {
  4254. return (this.flags & 32) > 0;
  4255. }
  4256. set isAmbientContext(v) {
  4257. if (v) this.flags |= 32;else this.flags &= -33;
  4258. }
  4259. get inAbstractClass() {
  4260. return (this.flags & 64) > 0;
  4261. }
  4262. set inAbstractClass(v) {
  4263. if (v) this.flags |= 64;else this.flags &= -65;
  4264. }
  4265. get inDisallowConditionalTypesContext() {
  4266. return (this.flags & 128) > 0;
  4267. }
  4268. set inDisallowConditionalTypesContext(v) {
  4269. if (v) this.flags |= 128;else this.flags &= -129;
  4270. }
  4271. get soloAwait() {
  4272. return (this.flags & 256) > 0;
  4273. }
  4274. set soloAwait(v) {
  4275. if (v) this.flags |= 256;else this.flags &= -257;
  4276. }
  4277. get inFSharpPipelineDirectBody() {
  4278. return (this.flags & 512) > 0;
  4279. }
  4280. set inFSharpPipelineDirectBody(v) {
  4281. if (v) this.flags |= 512;else this.flags &= -513;
  4282. }
  4283. get canStartJSXElement() {
  4284. return (this.flags & 1024) > 0;
  4285. }
  4286. set canStartJSXElement(v) {
  4287. if (v) this.flags |= 1024;else this.flags &= -1025;
  4288. }
  4289. get containsEsc() {
  4290. return (this.flags & 2048) > 0;
  4291. }
  4292. set containsEsc(v) {
  4293. if (v) this.flags |= 2048;else this.flags &= -2049;
  4294. }
  4295. curPosition() {
  4296. return new Position(this.curLine, this.pos - this.lineStart, this.pos);
  4297. }
  4298. clone() {
  4299. const state = new State();
  4300. state.flags = this.flags;
  4301. state.curLine = this.curLine;
  4302. state.lineStart = this.lineStart;
  4303. state.startLoc = this.startLoc;
  4304. state.endLoc = this.endLoc;
  4305. state.errors = this.errors.slice();
  4306. state.potentialArrowAt = this.potentialArrowAt;
  4307. state.noArrowAt = this.noArrowAt.slice();
  4308. state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
  4309. state.topicContext = this.topicContext;
  4310. state.labels = this.labels.slice();
  4311. state.commentsLen = this.commentsLen;
  4312. state.commentStack = this.commentStack.slice();
  4313. state.pos = this.pos;
  4314. state.type = this.type;
  4315. state.value = this.value;
  4316. state.start = this.start;
  4317. state.end = this.end;
  4318. state.lastTokEndLoc = this.lastTokEndLoc;
  4319. state.lastTokStartLoc = this.lastTokStartLoc;
  4320. state.context = this.context.slice();
  4321. state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos;
  4322. state.strictErrors = this.strictErrors;
  4323. state.tokensLength = this.tokensLength;
  4324. return state;
  4325. }
  4326. }
  4327. var _isDigit = function isDigit(code) {
  4328. return code >= 48 && code <= 57;
  4329. };
  4330. const forbiddenNumericSeparatorSiblings = {
  4331. decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
  4332. hex: new Set([46, 88, 95, 120])
  4333. };
  4334. const isAllowedNumericSeparatorSibling = {
  4335. bin: ch => ch === 48 || ch === 49,
  4336. oct: ch => ch >= 48 && ch <= 55,
  4337. dec: ch => ch >= 48 && ch <= 57,
  4338. hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
  4339. };
  4340. function readStringContents(type, input, pos, lineStart, curLine, errors) {
  4341. const initialPos = pos;
  4342. const initialLineStart = lineStart;
  4343. const initialCurLine = curLine;
  4344. let out = "";
  4345. let firstInvalidLoc = null;
  4346. let chunkStart = pos;
  4347. const {
  4348. length
  4349. } = input;
  4350. for (;;) {
  4351. if (pos >= length) {
  4352. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4353. out += input.slice(chunkStart, pos);
  4354. break;
  4355. }
  4356. const ch = input.charCodeAt(pos);
  4357. if (isStringEnd(type, ch, input, pos)) {
  4358. out += input.slice(chunkStart, pos);
  4359. break;
  4360. }
  4361. if (ch === 92) {
  4362. out += input.slice(chunkStart, pos);
  4363. const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
  4364. if (res.ch === null && !firstInvalidLoc) {
  4365. firstInvalidLoc = {
  4366. pos,
  4367. lineStart,
  4368. curLine
  4369. };
  4370. } else {
  4371. out += res.ch;
  4372. }
  4373. ({
  4374. pos,
  4375. lineStart,
  4376. curLine
  4377. } = res);
  4378. chunkStart = pos;
  4379. } else if (ch === 8232 || ch === 8233) {
  4380. ++pos;
  4381. ++curLine;
  4382. lineStart = pos;
  4383. } else if (ch === 10 || ch === 13) {
  4384. if (type === "template") {
  4385. out += input.slice(chunkStart, pos) + "\n";
  4386. ++pos;
  4387. if (ch === 13 && input.charCodeAt(pos) === 10) {
  4388. ++pos;
  4389. }
  4390. ++curLine;
  4391. chunkStart = lineStart = pos;
  4392. } else {
  4393. errors.unterminated(initialPos, initialLineStart, initialCurLine);
  4394. }
  4395. } else {
  4396. ++pos;
  4397. }
  4398. }
  4399. return {
  4400. pos,
  4401. str: out,
  4402. firstInvalidLoc,
  4403. lineStart,
  4404. curLine,
  4405. containsInvalid: !!firstInvalidLoc
  4406. };
  4407. }
  4408. function isStringEnd(type, ch, input, pos) {
  4409. if (type === "template") {
  4410. return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
  4411. }
  4412. return ch === (type === "double" ? 34 : 39);
  4413. }
  4414. function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
  4415. const throwOnInvalid = !inTemplate;
  4416. pos++;
  4417. const res = ch => ({
  4418. pos,
  4419. ch,
  4420. lineStart,
  4421. curLine
  4422. });
  4423. const ch = input.charCodeAt(pos++);
  4424. switch (ch) {
  4425. case 110:
  4426. return res("\n");
  4427. case 114:
  4428. return res("\r");
  4429. case 120:
  4430. {
  4431. let code;
  4432. ({
  4433. code,
  4434. pos
  4435. } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
  4436. return res(code === null ? null : String.fromCharCode(code));
  4437. }
  4438. case 117:
  4439. {
  4440. let code;
  4441. ({
  4442. code,
  4443. pos
  4444. } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
  4445. return res(code === null ? null : String.fromCodePoint(code));
  4446. }
  4447. case 116:
  4448. return res("\t");
  4449. case 98:
  4450. return res("\b");
  4451. case 118:
  4452. return res("\u000b");
  4453. case 102:
  4454. return res("\f");
  4455. case 13:
  4456. if (input.charCodeAt(pos) === 10) {
  4457. ++pos;
  4458. }
  4459. case 10:
  4460. lineStart = pos;
  4461. ++curLine;
  4462. case 8232:
  4463. case 8233:
  4464. return res("");
  4465. case 56:
  4466. case 57:
  4467. if (inTemplate) {
  4468. return res(null);
  4469. } else {
  4470. errors.strictNumericEscape(pos - 1, lineStart, curLine);
  4471. }
  4472. default:
  4473. if (ch >= 48 && ch <= 55) {
  4474. const startPos = pos - 1;
  4475. const match = input.slice(startPos, pos + 2).match(/^[0-7]+/);
  4476. let octalStr = match[0];
  4477. let octal = parseInt(octalStr, 8);
  4478. if (octal > 255) {
  4479. octalStr = octalStr.slice(0, -1);
  4480. octal = parseInt(octalStr, 8);
  4481. }
  4482. pos += octalStr.length - 1;
  4483. const next = input.charCodeAt(pos);
  4484. if (octalStr !== "0" || next === 56 || next === 57) {
  4485. if (inTemplate) {
  4486. return res(null);
  4487. } else {
  4488. errors.strictNumericEscape(startPos, lineStart, curLine);
  4489. }
  4490. }
  4491. return res(String.fromCharCode(octal));
  4492. }
  4493. return res(String.fromCharCode(ch));
  4494. }
  4495. }
  4496. function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
  4497. const initialPos = pos;
  4498. let n;
  4499. ({
  4500. n,
  4501. pos
  4502. } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
  4503. if (n === null) {
  4504. if (throwOnInvalid) {
  4505. errors.invalidEscapeSequence(initialPos, lineStart, curLine);
  4506. } else {
  4507. pos = initialPos - 1;
  4508. }
  4509. }
  4510. return {
  4511. code: n,
  4512. pos
  4513. };
  4514. }
  4515. function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
  4516. const start = pos;
  4517. const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
  4518. const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
  4519. let invalid = false;
  4520. let total = 0;
  4521. for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
  4522. const code = input.charCodeAt(pos);
  4523. let val;
  4524. if (code === 95 && allowNumSeparator !== "bail") {
  4525. const prev = input.charCodeAt(pos - 1);
  4526. const next = input.charCodeAt(pos + 1);
  4527. if (!allowNumSeparator) {
  4528. if (bailOnError) return {
  4529. n: null,
  4530. pos
  4531. };
  4532. errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
  4533. } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) {
  4534. if (bailOnError) return {
  4535. n: null,
  4536. pos
  4537. };
  4538. errors.unexpectedNumericSeparator(pos, lineStart, curLine);
  4539. }
  4540. ++pos;
  4541. continue;
  4542. }
  4543. if (code >= 97) {
  4544. val = code - 97 + 10;
  4545. } else if (code >= 65) {
  4546. val = code - 65 + 10;
  4547. } else if (_isDigit(code)) {
  4548. val = code - 48;
  4549. } else {
  4550. val = Infinity;
  4551. }
  4552. if (val >= radix) {
  4553. if (val <= 9 && bailOnError) {
  4554. return {
  4555. n: null,
  4556. pos
  4557. };
  4558. } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) {
  4559. val = 0;
  4560. } else if (forceLen) {
  4561. val = 0;
  4562. invalid = true;
  4563. } else {
  4564. break;
  4565. }
  4566. }
  4567. ++pos;
  4568. total = total * radix + val;
  4569. }
  4570. if (pos === start || len != null && pos - start !== len || invalid) {
  4571. return {
  4572. n: null,
  4573. pos
  4574. };
  4575. }
  4576. return {
  4577. n: total,
  4578. pos
  4579. };
  4580. }
  4581. function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
  4582. const ch = input.charCodeAt(pos);
  4583. let code;
  4584. if (ch === 123) {
  4585. ++pos;
  4586. ({
  4587. code,
  4588. pos
  4589. } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
  4590. ++pos;
  4591. if (code !== null && code > 0x10ffff) {
  4592. if (throwOnInvalid) {
  4593. errors.invalidCodePoint(pos, lineStart, curLine);
  4594. } else {
  4595. return {
  4596. code: null,
  4597. pos
  4598. };
  4599. }
  4600. }
  4601. } else {
  4602. ({
  4603. code,
  4604. pos
  4605. } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
  4606. }
  4607. return {
  4608. code,
  4609. pos
  4610. };
  4611. }
  4612. function buildPosition(pos, lineStart, curLine) {
  4613. return new Position(curLine, pos - lineStart, pos);
  4614. }
  4615. const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
  4616. class Token {
  4617. constructor(state) {
  4618. this.type = state.type;
  4619. this.value = state.value;
  4620. this.start = state.start;
  4621. this.end = state.end;
  4622. this.loc = new SourceLocation(state.startLoc, state.endLoc);
  4623. }
  4624. }
  4625. class Tokenizer extends CommentsParser {
  4626. constructor(options, input) {
  4627. super();
  4628. this.isLookahead = void 0;
  4629. this.tokens = [];
  4630. this.errorHandlers_readInt = {
  4631. invalidDigit: (pos, lineStart, curLine, radix) => {
  4632. if (!this.options.errorRecovery) return false;
  4633. this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
  4634. radix
  4635. });
  4636. return true;
  4637. },
  4638. numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
  4639. unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
  4640. };
  4641. this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, {
  4642. invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
  4643. invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
  4644. });
  4645. this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, {
  4646. strictNumericEscape: (pos, lineStart, curLine) => {
  4647. this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
  4648. },
  4649. unterminated: (pos, lineStart, curLine) => {
  4650. throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
  4651. }
  4652. });
  4653. this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, {
  4654. strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
  4655. unterminated: (pos, lineStart, curLine) => {
  4656. throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
  4657. }
  4658. });
  4659. this.state = new State();
  4660. this.state.init(options);
  4661. this.input = input;
  4662. this.length = input.length;
  4663. this.comments = [];
  4664. this.isLookahead = false;
  4665. }
  4666. pushToken(token) {
  4667. this.tokens.length = this.state.tokensLength;
  4668. this.tokens.push(token);
  4669. ++this.state.tokensLength;
  4670. }
  4671. next() {
  4672. this.checkKeywordEscapes();
  4673. if (this.options.tokens) {
  4674. this.pushToken(new Token(this.state));
  4675. }
  4676. this.state.lastTokEndLoc = this.state.endLoc;
  4677. this.state.lastTokStartLoc = this.state.startLoc;
  4678. this.nextToken();
  4679. }
  4680. eat(type) {
  4681. if (this.match(type)) {
  4682. this.next();
  4683. return true;
  4684. } else {
  4685. return false;
  4686. }
  4687. }
  4688. match(type) {
  4689. return this.state.type === type;
  4690. }
  4691. createLookaheadState(state) {
  4692. return {
  4693. pos: state.pos,
  4694. value: null,
  4695. type: state.type,
  4696. start: state.start,
  4697. end: state.end,
  4698. context: [this.curContext()],
  4699. inType: state.inType,
  4700. startLoc: state.startLoc,
  4701. lastTokEndLoc: state.lastTokEndLoc,
  4702. curLine: state.curLine,
  4703. lineStart: state.lineStart,
  4704. curPosition: state.curPosition
  4705. };
  4706. }
  4707. lookahead() {
  4708. const old = this.state;
  4709. this.state = this.createLookaheadState(old);
  4710. this.isLookahead = true;
  4711. this.nextToken();
  4712. this.isLookahead = false;
  4713. const curr = this.state;
  4714. this.state = old;
  4715. return curr;
  4716. }
  4717. nextTokenStart() {
  4718. return this.nextTokenStartSince(this.state.pos);
  4719. }
  4720. nextTokenStartSince(pos) {
  4721. skipWhiteSpace.lastIndex = pos;
  4722. return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
  4723. }
  4724. lookaheadCharCode() {
  4725. return this.input.charCodeAt(this.nextTokenStart());
  4726. }
  4727. nextTokenInLineStart() {
  4728. return this.nextTokenInLineStartSince(this.state.pos);
  4729. }
  4730. nextTokenInLineStartSince(pos) {
  4731. skipWhiteSpaceInLine.lastIndex = pos;
  4732. return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
  4733. }
  4734. lookaheadInLineCharCode() {
  4735. return this.input.charCodeAt(this.nextTokenInLineStart());
  4736. }
  4737. codePointAtPos(pos) {
  4738. let cp = this.input.charCodeAt(pos);
  4739. if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) {
  4740. const trail = this.input.charCodeAt(pos);
  4741. if ((trail & 0xfc00) === 0xdc00) {
  4742. cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff);
  4743. }
  4744. }
  4745. return cp;
  4746. }
  4747. setStrict(strict) {
  4748. this.state.strict = strict;
  4749. if (strict) {
  4750. this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
  4751. this.state.strictErrors.clear();
  4752. }
  4753. }
  4754. curContext() {
  4755. return this.state.context[this.state.context.length - 1];
  4756. }
  4757. nextToken() {
  4758. this.skipSpace();
  4759. this.state.start = this.state.pos;
  4760. if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
  4761. if (this.state.pos >= this.length) {
  4762. this.finishToken(139);
  4763. return;
  4764. }
  4765. this.getTokenFromCode(this.codePointAtPos(this.state.pos));
  4766. }
  4767. skipBlockComment(commentEnd) {
  4768. let startLoc;
  4769. if (!this.isLookahead) startLoc = this.state.curPosition();
  4770. const start = this.state.pos;
  4771. const end = this.input.indexOf(commentEnd, start + 2);
  4772. if (end === -1) {
  4773. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  4774. }
  4775. this.state.pos = end + commentEnd.length;
  4776. lineBreakG.lastIndex = start + 2;
  4777. while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
  4778. ++this.state.curLine;
  4779. this.state.lineStart = lineBreakG.lastIndex;
  4780. }
  4781. if (this.isLookahead) return;
  4782. const comment = {
  4783. type: "CommentBlock",
  4784. value: this.input.slice(start + 2, end),
  4785. start,
  4786. end: end + commentEnd.length,
  4787. loc: new SourceLocation(startLoc, this.state.curPosition())
  4788. };
  4789. if (this.options.tokens) this.pushToken(comment);
  4790. return comment;
  4791. }
  4792. skipLineComment(startSkip) {
  4793. const start = this.state.pos;
  4794. let startLoc;
  4795. if (!this.isLookahead) startLoc = this.state.curPosition();
  4796. let ch = this.input.charCodeAt(this.state.pos += startSkip);
  4797. if (this.state.pos < this.length) {
  4798. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  4799. ch = this.input.charCodeAt(this.state.pos);
  4800. }
  4801. }
  4802. if (this.isLookahead) return;
  4803. const end = this.state.pos;
  4804. const value = this.input.slice(start + startSkip, end);
  4805. const comment = {
  4806. type: "CommentLine",
  4807. value,
  4808. start,
  4809. end,
  4810. loc: new SourceLocation(startLoc, this.state.curPosition())
  4811. };
  4812. if (this.options.tokens) this.pushToken(comment);
  4813. return comment;
  4814. }
  4815. skipSpace() {
  4816. const spaceStart = this.state.pos;
  4817. const comments = [];
  4818. loop: while (this.state.pos < this.length) {
  4819. const ch = this.input.charCodeAt(this.state.pos);
  4820. switch (ch) {
  4821. case 32:
  4822. case 160:
  4823. case 9:
  4824. ++this.state.pos;
  4825. break;
  4826. case 13:
  4827. if (this.input.charCodeAt(this.state.pos + 1) === 10) {
  4828. ++this.state.pos;
  4829. }
  4830. case 10:
  4831. case 8232:
  4832. case 8233:
  4833. ++this.state.pos;
  4834. ++this.state.curLine;
  4835. this.state.lineStart = this.state.pos;
  4836. break;
  4837. case 47:
  4838. switch (this.input.charCodeAt(this.state.pos + 1)) {
  4839. case 42:
  4840. {
  4841. const comment = this.skipBlockComment("*/");
  4842. if (comment !== undefined) {
  4843. this.addComment(comment);
  4844. if (this.options.attachComment) comments.push(comment);
  4845. }
  4846. break;
  4847. }
  4848. case 47:
  4849. {
  4850. const comment = this.skipLineComment(2);
  4851. if (comment !== undefined) {
  4852. this.addComment(comment);
  4853. if (this.options.attachComment) comments.push(comment);
  4854. }
  4855. break;
  4856. }
  4857. default:
  4858. break loop;
  4859. }
  4860. break;
  4861. default:
  4862. if (isWhitespace(ch)) {
  4863. ++this.state.pos;
  4864. } else if (ch === 45 && !this.inModule && this.options.annexB) {
  4865. const pos = this.state.pos;
  4866. if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
  4867. const comment = this.skipLineComment(3);
  4868. if (comment !== undefined) {
  4869. this.addComment(comment);
  4870. if (this.options.attachComment) comments.push(comment);
  4871. }
  4872. } else {
  4873. break loop;
  4874. }
  4875. } else if (ch === 60 && !this.inModule && this.options.annexB) {
  4876. const pos = this.state.pos;
  4877. if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
  4878. const comment = this.skipLineComment(4);
  4879. if (comment !== undefined) {
  4880. this.addComment(comment);
  4881. if (this.options.attachComment) comments.push(comment);
  4882. }
  4883. } else {
  4884. break loop;
  4885. }
  4886. } else {
  4887. break loop;
  4888. }
  4889. }
  4890. }
  4891. if (comments.length > 0) {
  4892. const end = this.state.pos;
  4893. const commentWhitespace = {
  4894. start: spaceStart,
  4895. end,
  4896. comments,
  4897. leadingNode: null,
  4898. trailingNode: null,
  4899. containingNode: null
  4900. };
  4901. this.state.commentStack.push(commentWhitespace);
  4902. }
  4903. }
  4904. finishToken(type, val) {
  4905. this.state.end = this.state.pos;
  4906. this.state.endLoc = this.state.curPosition();
  4907. const prevType = this.state.type;
  4908. this.state.type = type;
  4909. this.state.value = val;
  4910. if (!this.isLookahead) {
  4911. this.updateContext(prevType);
  4912. }
  4913. }
  4914. replaceToken(type) {
  4915. this.state.type = type;
  4916. this.updateContext();
  4917. }
  4918. readToken_numberSign() {
  4919. if (this.state.pos === 0 && this.readToken_interpreter()) {
  4920. return;
  4921. }
  4922. const nextPos = this.state.pos + 1;
  4923. const next = this.codePointAtPos(nextPos);
  4924. if (next >= 48 && next <= 57) {
  4925. throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
  4926. }
  4927. if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
  4928. this.expectPlugin("recordAndTuple");
  4929. if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
  4930. throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
  4931. }
  4932. this.state.pos += 2;
  4933. if (next === 123) {
  4934. this.finishToken(7);
  4935. } else {
  4936. this.finishToken(1);
  4937. }
  4938. } else if (isIdentifierStart(next)) {
  4939. ++this.state.pos;
  4940. this.finishToken(138, this.readWord1(next));
  4941. } else if (next === 92) {
  4942. ++this.state.pos;
  4943. this.finishToken(138, this.readWord1());
  4944. } else {
  4945. this.finishOp(27, 1);
  4946. }
  4947. }
  4948. readToken_dot() {
  4949. const next = this.input.charCodeAt(this.state.pos + 1);
  4950. if (next >= 48 && next <= 57) {
  4951. this.readNumber(true);
  4952. return;
  4953. }
  4954. if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
  4955. this.state.pos += 3;
  4956. this.finishToken(21);
  4957. } else {
  4958. ++this.state.pos;
  4959. this.finishToken(16);
  4960. }
  4961. }
  4962. readToken_slash() {
  4963. const next = this.input.charCodeAt(this.state.pos + 1);
  4964. if (next === 61) {
  4965. this.finishOp(31, 2);
  4966. } else {
  4967. this.finishOp(56, 1);
  4968. }
  4969. }
  4970. readToken_interpreter() {
  4971. if (this.state.pos !== 0 || this.length < 2) return false;
  4972. let ch = this.input.charCodeAt(this.state.pos + 1);
  4973. if (ch !== 33) return false;
  4974. const start = this.state.pos;
  4975. this.state.pos += 1;
  4976. while (!isNewLine(ch) && ++this.state.pos < this.length) {
  4977. ch = this.input.charCodeAt(this.state.pos);
  4978. }
  4979. const value = this.input.slice(start + 2, this.state.pos);
  4980. this.finishToken(28, value);
  4981. return true;
  4982. }
  4983. readToken_mult_modulo(code) {
  4984. let type = code === 42 ? 55 : 54;
  4985. let width = 1;
  4986. let next = this.input.charCodeAt(this.state.pos + 1);
  4987. if (code === 42 && next === 42) {
  4988. width++;
  4989. next = this.input.charCodeAt(this.state.pos + 2);
  4990. type = 57;
  4991. }
  4992. if (next === 61 && !this.state.inType) {
  4993. width++;
  4994. type = code === 37 ? 33 : 30;
  4995. }
  4996. this.finishOp(type, width);
  4997. }
  4998. readToken_pipe_amp(code) {
  4999. const next = this.input.charCodeAt(this.state.pos + 1);
  5000. if (next === code) {
  5001. if (this.input.charCodeAt(this.state.pos + 2) === 61) {
  5002. this.finishOp(30, 3);
  5003. } else {
  5004. this.finishOp(code === 124 ? 41 : 42, 2);
  5005. }
  5006. return;
  5007. }
  5008. if (code === 124) {
  5009. if (next === 62) {
  5010. this.finishOp(39, 2);
  5011. return;
  5012. }
  5013. if (this.hasPlugin("recordAndTuple") && next === 125) {
  5014. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5015. throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5016. }
  5017. this.state.pos += 2;
  5018. this.finishToken(9);
  5019. return;
  5020. }
  5021. if (this.hasPlugin("recordAndTuple") && next === 93) {
  5022. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5023. throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
  5024. }
  5025. this.state.pos += 2;
  5026. this.finishToken(4);
  5027. return;
  5028. }
  5029. }
  5030. if (next === 61) {
  5031. this.finishOp(30, 2);
  5032. return;
  5033. }
  5034. this.finishOp(code === 124 ? 43 : 45, 1);
  5035. }
  5036. readToken_caret() {
  5037. const next = this.input.charCodeAt(this.state.pos + 1);
  5038. if (next === 61 && !this.state.inType) {
  5039. this.finishOp(32, 2);
  5040. } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
  5041. proposal: "hack",
  5042. topicToken: "^^"
  5043. }])) {
  5044. this.finishOp(37, 2);
  5045. const lookaheadCh = this.input.codePointAt(this.state.pos);
  5046. if (lookaheadCh === 94) {
  5047. this.unexpected();
  5048. }
  5049. } else {
  5050. this.finishOp(44, 1);
  5051. }
  5052. }
  5053. readToken_atSign() {
  5054. const next = this.input.charCodeAt(this.state.pos + 1);
  5055. if (next === 64 && this.hasPlugin(["pipelineOperator", {
  5056. proposal: "hack",
  5057. topicToken: "@@"
  5058. }])) {
  5059. this.finishOp(38, 2);
  5060. } else {
  5061. this.finishOp(26, 1);
  5062. }
  5063. }
  5064. readToken_plus_min(code) {
  5065. const next = this.input.charCodeAt(this.state.pos + 1);
  5066. if (next === code) {
  5067. this.finishOp(34, 2);
  5068. return;
  5069. }
  5070. if (next === 61) {
  5071. this.finishOp(30, 2);
  5072. } else {
  5073. this.finishOp(53, 1);
  5074. }
  5075. }
  5076. readToken_lt() {
  5077. const {
  5078. pos
  5079. } = this.state;
  5080. const next = this.input.charCodeAt(pos + 1);
  5081. if (next === 60) {
  5082. if (this.input.charCodeAt(pos + 2) === 61) {
  5083. this.finishOp(30, 3);
  5084. return;
  5085. }
  5086. this.finishOp(51, 2);
  5087. return;
  5088. }
  5089. if (next === 61) {
  5090. this.finishOp(49, 2);
  5091. return;
  5092. }
  5093. this.finishOp(47, 1);
  5094. }
  5095. readToken_gt() {
  5096. const {
  5097. pos
  5098. } = this.state;
  5099. const next = this.input.charCodeAt(pos + 1);
  5100. if (next === 62) {
  5101. const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
  5102. if (this.input.charCodeAt(pos + size) === 61) {
  5103. this.finishOp(30, size + 1);
  5104. return;
  5105. }
  5106. this.finishOp(52, size);
  5107. return;
  5108. }
  5109. if (next === 61) {
  5110. this.finishOp(49, 2);
  5111. return;
  5112. }
  5113. this.finishOp(48, 1);
  5114. }
  5115. readToken_eq_excl(code) {
  5116. const next = this.input.charCodeAt(this.state.pos + 1);
  5117. if (next === 61) {
  5118. this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
  5119. return;
  5120. }
  5121. if (code === 61 && next === 62) {
  5122. this.state.pos += 2;
  5123. this.finishToken(19);
  5124. return;
  5125. }
  5126. this.finishOp(code === 61 ? 29 : 35, 1);
  5127. }
  5128. readToken_question() {
  5129. const next = this.input.charCodeAt(this.state.pos + 1);
  5130. const next2 = this.input.charCodeAt(this.state.pos + 2);
  5131. if (next === 63) {
  5132. if (next2 === 61) {
  5133. this.finishOp(30, 3);
  5134. } else {
  5135. this.finishOp(40, 2);
  5136. }
  5137. } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
  5138. this.state.pos += 2;
  5139. this.finishToken(18);
  5140. } else {
  5141. ++this.state.pos;
  5142. this.finishToken(17);
  5143. }
  5144. }
  5145. getTokenFromCode(code) {
  5146. switch (code) {
  5147. case 46:
  5148. this.readToken_dot();
  5149. return;
  5150. case 40:
  5151. ++this.state.pos;
  5152. this.finishToken(10);
  5153. return;
  5154. case 41:
  5155. ++this.state.pos;
  5156. this.finishToken(11);
  5157. return;
  5158. case 59:
  5159. ++this.state.pos;
  5160. this.finishToken(13);
  5161. return;
  5162. case 44:
  5163. ++this.state.pos;
  5164. this.finishToken(12);
  5165. return;
  5166. case 91:
  5167. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5168. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5169. throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5170. }
  5171. this.state.pos += 2;
  5172. this.finishToken(2);
  5173. } else {
  5174. ++this.state.pos;
  5175. this.finishToken(0);
  5176. }
  5177. return;
  5178. case 93:
  5179. ++this.state.pos;
  5180. this.finishToken(3);
  5181. return;
  5182. case 123:
  5183. if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
  5184. if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
  5185. throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
  5186. }
  5187. this.state.pos += 2;
  5188. this.finishToken(6);
  5189. } else {
  5190. ++this.state.pos;
  5191. this.finishToken(5);
  5192. }
  5193. return;
  5194. case 125:
  5195. ++this.state.pos;
  5196. this.finishToken(8);
  5197. return;
  5198. case 58:
  5199. if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
  5200. this.finishOp(15, 2);
  5201. } else {
  5202. ++this.state.pos;
  5203. this.finishToken(14);
  5204. }
  5205. return;
  5206. case 63:
  5207. this.readToken_question();
  5208. return;
  5209. case 96:
  5210. this.readTemplateToken();
  5211. return;
  5212. case 48:
  5213. {
  5214. const next = this.input.charCodeAt(this.state.pos + 1);
  5215. if (next === 120 || next === 88) {
  5216. this.readRadixNumber(16);
  5217. return;
  5218. }
  5219. if (next === 111 || next === 79) {
  5220. this.readRadixNumber(8);
  5221. return;
  5222. }
  5223. if (next === 98 || next === 66) {
  5224. this.readRadixNumber(2);
  5225. return;
  5226. }
  5227. }
  5228. case 49:
  5229. case 50:
  5230. case 51:
  5231. case 52:
  5232. case 53:
  5233. case 54:
  5234. case 55:
  5235. case 56:
  5236. case 57:
  5237. this.readNumber(false);
  5238. return;
  5239. case 34:
  5240. case 39:
  5241. this.readString(code);
  5242. return;
  5243. case 47:
  5244. this.readToken_slash();
  5245. return;
  5246. case 37:
  5247. case 42:
  5248. this.readToken_mult_modulo(code);
  5249. return;
  5250. case 124:
  5251. case 38:
  5252. this.readToken_pipe_amp(code);
  5253. return;
  5254. case 94:
  5255. this.readToken_caret();
  5256. return;
  5257. case 43:
  5258. case 45:
  5259. this.readToken_plus_min(code);
  5260. return;
  5261. case 60:
  5262. this.readToken_lt();
  5263. return;
  5264. case 62:
  5265. this.readToken_gt();
  5266. return;
  5267. case 61:
  5268. case 33:
  5269. this.readToken_eq_excl(code);
  5270. return;
  5271. case 126:
  5272. this.finishOp(36, 1);
  5273. return;
  5274. case 64:
  5275. this.readToken_atSign();
  5276. return;
  5277. case 35:
  5278. this.readToken_numberSign();
  5279. return;
  5280. case 92:
  5281. this.readWord();
  5282. return;
  5283. default:
  5284. if (isIdentifierStart(code)) {
  5285. this.readWord(code);
  5286. return;
  5287. }
  5288. }
  5289. throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
  5290. unexpected: String.fromCodePoint(code)
  5291. });
  5292. }
  5293. finishOp(type, size) {
  5294. const str = this.input.slice(this.state.pos, this.state.pos + size);
  5295. this.state.pos += size;
  5296. this.finishToken(type, str);
  5297. }
  5298. readRegexp() {
  5299. const startLoc = this.state.startLoc;
  5300. const start = this.state.start + 1;
  5301. let escaped, inClass;
  5302. let {
  5303. pos
  5304. } = this.state;
  5305. for (;; ++pos) {
  5306. if (pos >= this.length) {
  5307. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5308. }
  5309. const ch = this.input.charCodeAt(pos);
  5310. if (isNewLine(ch)) {
  5311. throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
  5312. }
  5313. if (escaped) {
  5314. escaped = false;
  5315. } else {
  5316. if (ch === 91) {
  5317. inClass = true;
  5318. } else if (ch === 93 && inClass) {
  5319. inClass = false;
  5320. } else if (ch === 47 && !inClass) {
  5321. break;
  5322. }
  5323. escaped = ch === 92;
  5324. }
  5325. }
  5326. const content = this.input.slice(start, pos);
  5327. ++pos;
  5328. let mods = "";
  5329. const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
  5330. while (pos < this.length) {
  5331. const cp = this.codePointAtPos(pos);
  5332. const char = String.fromCharCode(cp);
  5333. if (VALID_REGEX_FLAGS.has(cp)) {
  5334. if (cp === 118) {
  5335. if (mods.includes("u")) {
  5336. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5337. }
  5338. } else if (cp === 117) {
  5339. if (mods.includes("v")) {
  5340. this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
  5341. }
  5342. }
  5343. if (mods.includes(char)) {
  5344. this.raise(Errors.DuplicateRegExpFlags, nextPos());
  5345. }
  5346. } else if (isIdentifierChar(cp) || cp === 92) {
  5347. this.raise(Errors.MalformedRegExpFlags, nextPos());
  5348. } else {
  5349. break;
  5350. }
  5351. ++pos;
  5352. mods += char;
  5353. }
  5354. this.state.pos = pos;
  5355. this.finishToken(137, {
  5356. pattern: content,
  5357. flags: mods
  5358. });
  5359. }
  5360. readInt(radix, len, forceLen = false, allowNumSeparator = true) {
  5361. const {
  5362. n,
  5363. pos
  5364. } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
  5365. this.state.pos = pos;
  5366. return n;
  5367. }
  5368. readRadixNumber(radix) {
  5369. const startLoc = this.state.curPosition();
  5370. let isBigInt = false;
  5371. this.state.pos += 2;
  5372. const val = this.readInt(radix);
  5373. if (val == null) {
  5374. this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
  5375. radix
  5376. });
  5377. }
  5378. const next = this.input.charCodeAt(this.state.pos);
  5379. if (next === 110) {
  5380. ++this.state.pos;
  5381. isBigInt = true;
  5382. } else if (next === 109) {
  5383. throw this.raise(Errors.InvalidDecimal, startLoc);
  5384. }
  5385. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5386. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5387. }
  5388. if (isBigInt) {
  5389. const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, "");
  5390. this.finishToken(135, str);
  5391. return;
  5392. }
  5393. this.finishToken(134, val);
  5394. }
  5395. readNumber(startsWithDot) {
  5396. const start = this.state.pos;
  5397. const startLoc = this.state.curPosition();
  5398. let isFloat = false;
  5399. let isBigInt = false;
  5400. let isDecimal = false;
  5401. let hasExponent = false;
  5402. let isOctal = false;
  5403. if (!startsWithDot && this.readInt(10) === null) {
  5404. this.raise(Errors.InvalidNumber, this.state.curPosition());
  5405. }
  5406. const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
  5407. if (hasLeadingZero) {
  5408. const integer = this.input.slice(start, this.state.pos);
  5409. this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
  5410. if (!this.state.strict) {
  5411. const underscorePos = integer.indexOf("_");
  5412. if (underscorePos > 0) {
  5413. this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
  5414. }
  5415. }
  5416. isOctal = hasLeadingZero && !/[89]/.test(integer);
  5417. }
  5418. let next = this.input.charCodeAt(this.state.pos);
  5419. if (next === 46 && !isOctal) {
  5420. ++this.state.pos;
  5421. this.readInt(10);
  5422. isFloat = true;
  5423. next = this.input.charCodeAt(this.state.pos);
  5424. }
  5425. if ((next === 69 || next === 101) && !isOctal) {
  5426. next = this.input.charCodeAt(++this.state.pos);
  5427. if (next === 43 || next === 45) {
  5428. ++this.state.pos;
  5429. }
  5430. if (this.readInt(10) === null) {
  5431. this.raise(Errors.InvalidOrMissingExponent, startLoc);
  5432. }
  5433. isFloat = true;
  5434. hasExponent = true;
  5435. next = this.input.charCodeAt(this.state.pos);
  5436. }
  5437. if (next === 110) {
  5438. if (isFloat || hasLeadingZero) {
  5439. this.raise(Errors.InvalidBigIntLiteral, startLoc);
  5440. }
  5441. ++this.state.pos;
  5442. isBigInt = true;
  5443. }
  5444. if (next === 109) {
  5445. this.expectPlugin("decimal", this.state.curPosition());
  5446. if (hasExponent || hasLeadingZero) {
  5447. this.raise(Errors.InvalidDecimal, startLoc);
  5448. }
  5449. ++this.state.pos;
  5450. isDecimal = true;
  5451. }
  5452. if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
  5453. throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
  5454. }
  5455. const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
  5456. if (isBigInt) {
  5457. this.finishToken(135, str);
  5458. return;
  5459. }
  5460. if (isDecimal) {
  5461. this.finishToken(136, str);
  5462. return;
  5463. }
  5464. const val = isOctal ? parseInt(str, 8) : parseFloat(str);
  5465. this.finishToken(134, val);
  5466. }
  5467. readCodePoint(throwOnInvalid) {
  5468. const {
  5469. code,
  5470. pos
  5471. } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
  5472. this.state.pos = pos;
  5473. return code;
  5474. }
  5475. readString(quote) {
  5476. const {
  5477. str,
  5478. pos,
  5479. curLine,
  5480. lineStart
  5481. } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
  5482. this.state.pos = pos + 1;
  5483. this.state.lineStart = lineStart;
  5484. this.state.curLine = curLine;
  5485. this.finishToken(133, str);
  5486. }
  5487. readTemplateContinuation() {
  5488. if (!this.match(8)) {
  5489. this.unexpected(null, 8);
  5490. }
  5491. this.state.pos--;
  5492. this.readTemplateToken();
  5493. }
  5494. readTemplateToken() {
  5495. const opening = this.input[this.state.pos];
  5496. const {
  5497. str,
  5498. firstInvalidLoc,
  5499. pos,
  5500. curLine,
  5501. lineStart
  5502. } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
  5503. this.state.pos = pos + 1;
  5504. this.state.lineStart = lineStart;
  5505. this.state.curLine = curLine;
  5506. if (firstInvalidLoc) {
  5507. this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos);
  5508. }
  5509. if (this.input.codePointAt(pos) === 96) {
  5510. this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
  5511. } else {
  5512. this.state.pos++;
  5513. this.finishToken(25, firstInvalidLoc ? null : opening + str + "${");
  5514. }
  5515. }
  5516. recordStrictModeErrors(toParseError, at) {
  5517. const index = at.index;
  5518. if (this.state.strict && !this.state.strictErrors.has(index)) {
  5519. this.raise(toParseError, at);
  5520. } else {
  5521. this.state.strictErrors.set(index, [toParseError, at]);
  5522. }
  5523. }
  5524. readWord1(firstCode) {
  5525. this.state.containsEsc = false;
  5526. let word = "";
  5527. const start = this.state.pos;
  5528. let chunkStart = this.state.pos;
  5529. if (firstCode !== undefined) {
  5530. this.state.pos += firstCode <= 0xffff ? 1 : 2;
  5531. }
  5532. while (this.state.pos < this.length) {
  5533. const ch = this.codePointAtPos(this.state.pos);
  5534. if (isIdentifierChar(ch)) {
  5535. this.state.pos += ch <= 0xffff ? 1 : 2;
  5536. } else if (ch === 92) {
  5537. this.state.containsEsc = true;
  5538. word += this.input.slice(chunkStart, this.state.pos);
  5539. const escStart = this.state.curPosition();
  5540. const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
  5541. if (this.input.charCodeAt(++this.state.pos) !== 117) {
  5542. this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
  5543. chunkStart = this.state.pos - 1;
  5544. continue;
  5545. }
  5546. ++this.state.pos;
  5547. const esc = this.readCodePoint(true);
  5548. if (esc !== null) {
  5549. if (!identifierCheck(esc)) {
  5550. this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
  5551. }
  5552. word += String.fromCodePoint(esc);
  5553. }
  5554. chunkStart = this.state.pos;
  5555. } else {
  5556. break;
  5557. }
  5558. }
  5559. return word + this.input.slice(chunkStart, this.state.pos);
  5560. }
  5561. readWord(firstCode) {
  5562. const word = this.readWord1(firstCode);
  5563. const type = keywords$1.get(word);
  5564. if (type !== undefined) {
  5565. this.finishToken(type, tokenLabelName(type));
  5566. } else {
  5567. this.finishToken(132, word);
  5568. }
  5569. }
  5570. checkKeywordEscapes() {
  5571. const {
  5572. type
  5573. } = this.state;
  5574. if (tokenIsKeyword(type) && this.state.containsEsc) {
  5575. this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
  5576. reservedWord: tokenLabelName(type)
  5577. });
  5578. }
  5579. }
  5580. raise(toParseError, at, details = {}) {
  5581. const loc = at instanceof Position ? at : at.loc.start;
  5582. const error = toParseError(loc, details);
  5583. if (!this.options.errorRecovery) throw error;
  5584. if (!this.isLookahead) this.state.errors.push(error);
  5585. return error;
  5586. }
  5587. raiseOverwrite(toParseError, at, details = {}) {
  5588. const loc = at instanceof Position ? at : at.loc.start;
  5589. const pos = loc.index;
  5590. const errors = this.state.errors;
  5591. for (let i = errors.length - 1; i >= 0; i--) {
  5592. const error = errors[i];
  5593. if (error.loc.index === pos) {
  5594. return errors[i] = toParseError(loc, details);
  5595. }
  5596. if (error.loc.index < pos) break;
  5597. }
  5598. return this.raise(toParseError, at, details);
  5599. }
  5600. updateContext(prevType) {}
  5601. unexpected(loc, type) {
  5602. throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
  5603. expected: type ? tokenLabelName(type) : null
  5604. });
  5605. }
  5606. expectPlugin(pluginName, loc) {
  5607. if (this.hasPlugin(pluginName)) {
  5608. return true;
  5609. }
  5610. throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
  5611. missingPlugin: [pluginName]
  5612. });
  5613. }
  5614. expectOnePlugin(pluginNames) {
  5615. if (!pluginNames.some(name => this.hasPlugin(name))) {
  5616. throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
  5617. missingPlugin: pluginNames
  5618. });
  5619. }
  5620. }
  5621. errorBuilder(error) {
  5622. return (pos, lineStart, curLine) => {
  5623. this.raise(error, buildPosition(pos, lineStart, curLine));
  5624. };
  5625. }
  5626. }
  5627. class ClassScope {
  5628. constructor() {
  5629. this.privateNames = new Set();
  5630. this.loneAccessors = new Map();
  5631. this.undefinedPrivateNames = new Map();
  5632. }
  5633. }
  5634. class ClassScopeHandler {
  5635. constructor(parser) {
  5636. this.parser = void 0;
  5637. this.stack = [];
  5638. this.undefinedPrivateNames = new Map();
  5639. this.parser = parser;
  5640. }
  5641. current() {
  5642. return this.stack[this.stack.length - 1];
  5643. }
  5644. enter() {
  5645. this.stack.push(new ClassScope());
  5646. }
  5647. exit() {
  5648. const oldClassScope = this.stack.pop();
  5649. const current = this.current();
  5650. for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
  5651. if (current) {
  5652. if (!current.undefinedPrivateNames.has(name)) {
  5653. current.undefinedPrivateNames.set(name, loc);
  5654. }
  5655. } else {
  5656. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5657. identifierName: name
  5658. });
  5659. }
  5660. }
  5661. }
  5662. declarePrivateName(name, elementType, loc) {
  5663. const {
  5664. privateNames,
  5665. loneAccessors,
  5666. undefinedPrivateNames
  5667. } = this.current();
  5668. let redefined = privateNames.has(name);
  5669. if (elementType & 3) {
  5670. const accessor = redefined && loneAccessors.get(name);
  5671. if (accessor) {
  5672. const oldStatic = accessor & 4;
  5673. const newStatic = elementType & 4;
  5674. const oldKind = accessor & 3;
  5675. const newKind = elementType & 3;
  5676. redefined = oldKind === newKind || oldStatic !== newStatic;
  5677. if (!redefined) loneAccessors.delete(name);
  5678. } else if (!redefined) {
  5679. loneAccessors.set(name, elementType);
  5680. }
  5681. }
  5682. if (redefined) {
  5683. this.parser.raise(Errors.PrivateNameRedeclaration, loc, {
  5684. identifierName: name
  5685. });
  5686. }
  5687. privateNames.add(name);
  5688. undefinedPrivateNames.delete(name);
  5689. }
  5690. usePrivateName(name, loc) {
  5691. let classScope;
  5692. for (classScope of this.stack) {
  5693. if (classScope.privateNames.has(name)) return;
  5694. }
  5695. if (classScope) {
  5696. classScope.undefinedPrivateNames.set(name, loc);
  5697. } else {
  5698. this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, {
  5699. identifierName: name
  5700. });
  5701. }
  5702. }
  5703. }
  5704. class ExpressionScope {
  5705. constructor(type = 0) {
  5706. this.type = type;
  5707. }
  5708. canBeArrowParameterDeclaration() {
  5709. return this.type === 2 || this.type === 1;
  5710. }
  5711. isCertainlyParameterDeclaration() {
  5712. return this.type === 3;
  5713. }
  5714. }
  5715. class ArrowHeadParsingScope extends ExpressionScope {
  5716. constructor(type) {
  5717. super(type);
  5718. this.declarationErrors = new Map();
  5719. }
  5720. recordDeclarationError(ParsingErrorClass, at) {
  5721. const index = at.index;
  5722. this.declarationErrors.set(index, [ParsingErrorClass, at]);
  5723. }
  5724. clearDeclarationError(index) {
  5725. this.declarationErrors.delete(index);
  5726. }
  5727. iterateErrors(iterator) {
  5728. this.declarationErrors.forEach(iterator);
  5729. }
  5730. }
  5731. class ExpressionScopeHandler {
  5732. constructor(parser) {
  5733. this.parser = void 0;
  5734. this.stack = [new ExpressionScope()];
  5735. this.parser = parser;
  5736. }
  5737. enter(scope) {
  5738. this.stack.push(scope);
  5739. }
  5740. exit() {
  5741. this.stack.pop();
  5742. }
  5743. recordParameterInitializerError(toParseError, node) {
  5744. const origin = node.loc.start;
  5745. const {
  5746. stack
  5747. } = this;
  5748. let i = stack.length - 1;
  5749. let scope = stack[i];
  5750. while (!scope.isCertainlyParameterDeclaration()) {
  5751. if (scope.canBeArrowParameterDeclaration()) {
  5752. scope.recordDeclarationError(toParseError, origin);
  5753. } else {
  5754. return;
  5755. }
  5756. scope = stack[--i];
  5757. }
  5758. this.parser.raise(toParseError, origin);
  5759. }
  5760. recordArrowParameterBindingError(error, node) {
  5761. const {
  5762. stack
  5763. } = this;
  5764. const scope = stack[stack.length - 1];
  5765. const origin = node.loc.start;
  5766. if (scope.isCertainlyParameterDeclaration()) {
  5767. this.parser.raise(error, origin);
  5768. } else if (scope.canBeArrowParameterDeclaration()) {
  5769. scope.recordDeclarationError(error, origin);
  5770. } else {
  5771. return;
  5772. }
  5773. }
  5774. recordAsyncArrowParametersError(at) {
  5775. const {
  5776. stack
  5777. } = this;
  5778. let i = stack.length - 1;
  5779. let scope = stack[i];
  5780. while (scope.canBeArrowParameterDeclaration()) {
  5781. if (scope.type === 2) {
  5782. scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
  5783. }
  5784. scope = stack[--i];
  5785. }
  5786. }
  5787. validateAsPattern() {
  5788. const {
  5789. stack
  5790. } = this;
  5791. const currentScope = stack[stack.length - 1];
  5792. if (!currentScope.canBeArrowParameterDeclaration()) return;
  5793. currentScope.iterateErrors(([toParseError, loc]) => {
  5794. this.parser.raise(toParseError, loc);
  5795. let i = stack.length - 2;
  5796. let scope = stack[i];
  5797. while (scope.canBeArrowParameterDeclaration()) {
  5798. scope.clearDeclarationError(loc.index);
  5799. scope = stack[--i];
  5800. }
  5801. });
  5802. }
  5803. }
  5804. function newParameterDeclarationScope() {
  5805. return new ExpressionScope(3);
  5806. }
  5807. function newArrowHeadScope() {
  5808. return new ArrowHeadParsingScope(1);
  5809. }
  5810. function newAsyncArrowScope() {
  5811. return new ArrowHeadParsingScope(2);
  5812. }
  5813. function newExpressionScope() {
  5814. return new ExpressionScope();
  5815. }
  5816. class ProductionParameterHandler {
  5817. constructor() {
  5818. this.stacks = [];
  5819. }
  5820. enter(flags) {
  5821. this.stacks.push(flags);
  5822. }
  5823. exit() {
  5824. this.stacks.pop();
  5825. }
  5826. currentFlags() {
  5827. return this.stacks[this.stacks.length - 1];
  5828. }
  5829. get hasAwait() {
  5830. return (this.currentFlags() & 2) > 0;
  5831. }
  5832. get hasYield() {
  5833. return (this.currentFlags() & 1) > 0;
  5834. }
  5835. get hasReturn() {
  5836. return (this.currentFlags() & 4) > 0;
  5837. }
  5838. get hasIn() {
  5839. return (this.currentFlags() & 8) > 0;
  5840. }
  5841. }
  5842. function functionFlags(isAsync, isGenerator) {
  5843. return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0);
  5844. }
  5845. class UtilParser extends Tokenizer {
  5846. addExtra(node, key, value, enumerable = true) {
  5847. if (!node) return;
  5848. const extra = node.extra = node.extra || {};
  5849. if (enumerable) {
  5850. extra[key] = value;
  5851. } else {
  5852. Object.defineProperty(extra, key, {
  5853. enumerable,
  5854. value
  5855. });
  5856. }
  5857. }
  5858. isContextual(token) {
  5859. return this.state.type === token && !this.state.containsEsc;
  5860. }
  5861. isUnparsedContextual(nameStart, name) {
  5862. const nameEnd = nameStart + name.length;
  5863. if (this.input.slice(nameStart, nameEnd) === name) {
  5864. const nextCh = this.input.charCodeAt(nameEnd);
  5865. return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
  5866. }
  5867. return false;
  5868. }
  5869. isLookaheadContextual(name) {
  5870. const next = this.nextTokenStart();
  5871. return this.isUnparsedContextual(next, name);
  5872. }
  5873. eatContextual(token) {
  5874. if (this.isContextual(token)) {
  5875. this.next();
  5876. return true;
  5877. }
  5878. return false;
  5879. }
  5880. expectContextual(token, toParseError) {
  5881. if (!this.eatContextual(token)) {
  5882. if (toParseError != null) {
  5883. throw this.raise(toParseError, this.state.startLoc);
  5884. }
  5885. this.unexpected(null, token);
  5886. }
  5887. }
  5888. canInsertSemicolon() {
  5889. return this.match(139) || this.match(8) || this.hasPrecedingLineBreak();
  5890. }
  5891. hasPrecedingLineBreak() {
  5892. return lineBreak.test(this.input.slice(this.state.lastTokEndLoc.index, this.state.start));
  5893. }
  5894. hasFollowingLineBreak() {
  5895. skipWhiteSpaceToLineBreak.lastIndex = this.state.end;
  5896. return skipWhiteSpaceToLineBreak.test(this.input);
  5897. }
  5898. isLineTerminator() {
  5899. return this.eat(13) || this.canInsertSemicolon();
  5900. }
  5901. semicolon(allowAsi = true) {
  5902. if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
  5903. this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc);
  5904. }
  5905. expect(type, loc) {
  5906. this.eat(type) || this.unexpected(loc, type);
  5907. }
  5908. tryParse(fn, oldState = this.state.clone()) {
  5909. const abortSignal = {
  5910. node: null
  5911. };
  5912. try {
  5913. const node = fn((node = null) => {
  5914. abortSignal.node = node;
  5915. throw abortSignal;
  5916. });
  5917. if (this.state.errors.length > oldState.errors.length) {
  5918. const failState = this.state;
  5919. this.state = oldState;
  5920. this.state.tokensLength = failState.tokensLength;
  5921. return {
  5922. node,
  5923. error: failState.errors[oldState.errors.length],
  5924. thrown: false,
  5925. aborted: false,
  5926. failState
  5927. };
  5928. }
  5929. return {
  5930. node,
  5931. error: null,
  5932. thrown: false,
  5933. aborted: false,
  5934. failState: null
  5935. };
  5936. } catch (error) {
  5937. const failState = this.state;
  5938. this.state = oldState;
  5939. if (error instanceof SyntaxError) {
  5940. return {
  5941. node: null,
  5942. error,
  5943. thrown: true,
  5944. aborted: false,
  5945. failState
  5946. };
  5947. }
  5948. if (error === abortSignal) {
  5949. return {
  5950. node: abortSignal.node,
  5951. error: null,
  5952. thrown: false,
  5953. aborted: true,
  5954. failState
  5955. };
  5956. }
  5957. throw error;
  5958. }
  5959. }
  5960. checkExpressionErrors(refExpressionErrors, andThrow) {
  5961. if (!refExpressionErrors) return false;
  5962. const {
  5963. shorthandAssignLoc,
  5964. doubleProtoLoc,
  5965. privateKeyLoc,
  5966. optionalParametersLoc
  5967. } = refExpressionErrors;
  5968. const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc;
  5969. if (!andThrow) {
  5970. return hasErrors;
  5971. }
  5972. if (shorthandAssignLoc != null) {
  5973. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  5974. }
  5975. if (doubleProtoLoc != null) {
  5976. this.raise(Errors.DuplicateProto, doubleProtoLoc);
  5977. }
  5978. if (privateKeyLoc != null) {
  5979. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  5980. }
  5981. if (optionalParametersLoc != null) {
  5982. this.unexpected(optionalParametersLoc);
  5983. }
  5984. }
  5985. isLiteralPropertyName() {
  5986. return tokenIsLiteralPropertyName(this.state.type);
  5987. }
  5988. isPrivateName(node) {
  5989. return node.type === "PrivateName";
  5990. }
  5991. getPrivateNameSV(node) {
  5992. return node.id.name;
  5993. }
  5994. hasPropertyAsPrivateName(node) {
  5995. return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
  5996. }
  5997. isObjectProperty(node) {
  5998. return node.type === "ObjectProperty";
  5999. }
  6000. isObjectMethod(node) {
  6001. return node.type === "ObjectMethod";
  6002. }
  6003. initializeScopes(inModule = this.options.sourceType === "module") {
  6004. const oldLabels = this.state.labels;
  6005. this.state.labels = [];
  6006. const oldExportedIdentifiers = this.exportedIdentifiers;
  6007. this.exportedIdentifiers = new Set();
  6008. const oldInModule = this.inModule;
  6009. this.inModule = inModule;
  6010. const oldScope = this.scope;
  6011. const ScopeHandler = this.getScopeHandler();
  6012. this.scope = new ScopeHandler(this, inModule);
  6013. const oldProdParam = this.prodParam;
  6014. this.prodParam = new ProductionParameterHandler();
  6015. const oldClassScope = this.classScope;
  6016. this.classScope = new ClassScopeHandler(this);
  6017. const oldExpressionScope = this.expressionScope;
  6018. this.expressionScope = new ExpressionScopeHandler(this);
  6019. return () => {
  6020. this.state.labels = oldLabels;
  6021. this.exportedIdentifiers = oldExportedIdentifiers;
  6022. this.inModule = oldInModule;
  6023. this.scope = oldScope;
  6024. this.prodParam = oldProdParam;
  6025. this.classScope = oldClassScope;
  6026. this.expressionScope = oldExpressionScope;
  6027. };
  6028. }
  6029. enterInitialScopes() {
  6030. let paramFlags = 0;
  6031. if (this.inModule) {
  6032. paramFlags |= 2;
  6033. }
  6034. this.scope.enter(1);
  6035. this.prodParam.enter(paramFlags);
  6036. }
  6037. checkDestructuringPrivate(refExpressionErrors) {
  6038. const {
  6039. privateKeyLoc
  6040. } = refExpressionErrors;
  6041. if (privateKeyLoc !== null) {
  6042. this.expectPlugin("destructuringPrivate", privateKeyLoc);
  6043. }
  6044. }
  6045. }
  6046. class ExpressionErrors {
  6047. constructor() {
  6048. this.shorthandAssignLoc = null;
  6049. this.doubleProtoLoc = null;
  6050. this.privateKeyLoc = null;
  6051. this.optionalParametersLoc = null;
  6052. }
  6053. }
  6054. let Node$5 = class Node {
  6055. constructor(parser, pos, loc) {
  6056. this.type = "";
  6057. this.start = pos;
  6058. this.end = 0;
  6059. this.loc = new SourceLocation(loc);
  6060. if (parser != null && parser.options.ranges) this.range = [pos, 0];
  6061. if (parser != null && parser.filename) this.loc.filename = parser.filename;
  6062. }
  6063. };
  6064. const NodePrototype = Node$5.prototype;
  6065. {
  6066. NodePrototype.__clone = function () {
  6067. const newNode = new Node$5(undefined, this.start, this.loc.start);
  6068. const keys = Object.keys(this);
  6069. for (let i = 0, length = keys.length; i < length; i++) {
  6070. const key = keys[i];
  6071. if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
  6072. newNode[key] = this[key];
  6073. }
  6074. }
  6075. return newNode;
  6076. };
  6077. }
  6078. function clonePlaceholder(node) {
  6079. return cloneIdentifier(node);
  6080. }
  6081. function cloneIdentifier(node) {
  6082. const {
  6083. type,
  6084. start,
  6085. end,
  6086. loc,
  6087. range,
  6088. extra,
  6089. name
  6090. } = node;
  6091. const cloned = Object.create(NodePrototype);
  6092. cloned.type = type;
  6093. cloned.start = start;
  6094. cloned.end = end;
  6095. cloned.loc = loc;
  6096. cloned.range = range;
  6097. cloned.extra = extra;
  6098. cloned.name = name;
  6099. if (type === "Placeholder") {
  6100. cloned.expectedNode = node.expectedNode;
  6101. }
  6102. return cloned;
  6103. }
  6104. function cloneStringLiteral(node) {
  6105. const {
  6106. type,
  6107. start,
  6108. end,
  6109. loc,
  6110. range,
  6111. extra
  6112. } = node;
  6113. if (type === "Placeholder") {
  6114. return clonePlaceholder(node);
  6115. }
  6116. const cloned = Object.create(NodePrototype);
  6117. cloned.type = type;
  6118. cloned.start = start;
  6119. cloned.end = end;
  6120. cloned.loc = loc;
  6121. cloned.range = range;
  6122. if (node.raw !== undefined) {
  6123. cloned.raw = node.raw;
  6124. } else {
  6125. cloned.extra = extra;
  6126. }
  6127. cloned.value = node.value;
  6128. return cloned;
  6129. }
  6130. class NodeUtils extends UtilParser {
  6131. startNode() {
  6132. const loc = this.state.startLoc;
  6133. return new Node$5(this, loc.index, loc);
  6134. }
  6135. startNodeAt(loc) {
  6136. return new Node$5(this, loc.index, loc);
  6137. }
  6138. startNodeAtNode(type) {
  6139. return this.startNodeAt(type.loc.start);
  6140. }
  6141. finishNode(node, type) {
  6142. return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
  6143. }
  6144. finishNodeAt(node, type, endLoc) {
  6145. node.type = type;
  6146. node.end = endLoc.index;
  6147. node.loc.end = endLoc;
  6148. if (this.options.ranges) node.range[1] = endLoc.index;
  6149. if (this.options.attachComment) this.processComment(node);
  6150. return node;
  6151. }
  6152. resetStartLocation(node, startLoc) {
  6153. node.start = startLoc.index;
  6154. node.loc.start = startLoc;
  6155. if (this.options.ranges) node.range[0] = startLoc.index;
  6156. }
  6157. resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
  6158. node.end = endLoc.index;
  6159. node.loc.end = endLoc;
  6160. if (this.options.ranges) node.range[1] = endLoc.index;
  6161. }
  6162. resetStartLocationFromNode(node, locationNode) {
  6163. this.resetStartLocation(node, locationNode.loc.start);
  6164. }
  6165. }
  6166. const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
  6167. const FlowErrors = ParseErrorEnum`flow`({
  6168. AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
  6169. 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.",
  6170. AssignReservedType: ({
  6171. reservedType
  6172. }) => `Cannot overwrite reserved type ${reservedType}.`,
  6173. DeclareClassElement: "The `declare` modifier can only appear on class fields.",
  6174. DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
  6175. DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.",
  6176. EnumBooleanMemberNotInitialized: ({
  6177. memberName,
  6178. enumName
  6179. }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`,
  6180. EnumDuplicateMemberName: ({
  6181. memberName,
  6182. enumName
  6183. }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`,
  6184. EnumInconsistentMemberValues: ({
  6185. enumName
  6186. }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,
  6187. EnumInvalidExplicitType: ({
  6188. invalidEnumType,
  6189. enumName
  6190. }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6191. EnumInvalidExplicitTypeUnknownSupplied: ({
  6192. enumName
  6193. }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`,
  6194. EnumInvalidMemberInitializerPrimaryType: ({
  6195. enumName,
  6196. memberName,
  6197. explicitType
  6198. }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`,
  6199. EnumInvalidMemberInitializerSymbolType: ({
  6200. enumName,
  6201. memberName
  6202. }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`,
  6203. EnumInvalidMemberInitializerUnknownType: ({
  6204. enumName,
  6205. memberName
  6206. }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`,
  6207. EnumInvalidMemberName: ({
  6208. enumName,
  6209. memberName,
  6210. suggestion
  6211. }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`,
  6212. EnumNumberMemberNotInitialized: ({
  6213. enumName,
  6214. memberName
  6215. }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`,
  6216. EnumStringMemberInconsistentlyInitialized: ({
  6217. enumName
  6218. }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`,
  6219. GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
  6220. ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.",
  6221. 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.",
  6222. InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.",
  6223. InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.",
  6224. InexactVariance: "Explicit inexact syntax cannot have variance.",
  6225. InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.",
  6226. MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
  6227. NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.",
  6228. NestedFlowComment: "Cannot have a flow comment inside another flow comment.",
  6229. PatternIsOptional: Object.assign({
  6230. message: "A binding pattern parameter cannot be optional in an implementation signature."
  6231. }, {
  6232. reasonCode: "OptionalBindingPattern"
  6233. }),
  6234. SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
  6235. SpreadVariance: "Spread properties cannot have variance.",
  6236. ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
  6237. ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
  6238. ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
  6239. ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
  6240. ThisParamNoDefault: "The `this` parameter may not have a default value.",
  6241. TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  6242. TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.",
  6243. UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.",
  6244. UnexpectedReservedType: ({
  6245. reservedType
  6246. }) => `Unexpected reserved type ${reservedType}.`,
  6247. UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.",
  6248. UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
  6249. UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.",
  6250. UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".',
  6251. UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.",
  6252. UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",
  6253. UnsupportedDeclareExportKind: ({
  6254. unsupportedExportKind,
  6255. suggestion
  6256. }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`,
  6257. UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.",
  6258. UnterminatedFlowComment: "Unterminated flow-comment."
  6259. });
  6260. function isEsModuleType(bodyElement) {
  6261. return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
  6262. }
  6263. function hasTypeImportKind(node) {
  6264. return node.importKind === "type" || node.importKind === "typeof";
  6265. }
  6266. const exportSuggestions = {
  6267. const: "declare export var",
  6268. let: "declare export var",
  6269. type: "export type",
  6270. interface: "export interface"
  6271. };
  6272. function partition(list, test) {
  6273. const list1 = [];
  6274. const list2 = [];
  6275. for (let i = 0; i < list.length; i++) {
  6276. (test(list[i], i, list) ? list1 : list2).push(list[i]);
  6277. }
  6278. return [list1, list2];
  6279. }
  6280. const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
  6281. var flow = superClass => class FlowParserMixin extends superClass {
  6282. constructor(...args) {
  6283. super(...args);
  6284. this.flowPragma = undefined;
  6285. }
  6286. getScopeHandler() {
  6287. return FlowScopeHandler;
  6288. }
  6289. shouldParseTypes() {
  6290. return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
  6291. }
  6292. shouldParseEnums() {
  6293. return !!this.getPluginOption("flow", "enums");
  6294. }
  6295. finishToken(type, val) {
  6296. if (type !== 133 && type !== 13 && type !== 28) {
  6297. if (this.flowPragma === undefined) {
  6298. this.flowPragma = null;
  6299. }
  6300. }
  6301. super.finishToken(type, val);
  6302. }
  6303. addComment(comment) {
  6304. if (this.flowPragma === undefined) {
  6305. const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
  6306. if (!matches) ;else if (matches[1] === "flow") {
  6307. this.flowPragma = "flow";
  6308. } else if (matches[1] === "noflow") {
  6309. this.flowPragma = "noflow";
  6310. } else {
  6311. throw new Error("Unexpected flow pragma");
  6312. }
  6313. }
  6314. super.addComment(comment);
  6315. }
  6316. flowParseTypeInitialiser(tok) {
  6317. const oldInType = this.state.inType;
  6318. this.state.inType = true;
  6319. this.expect(tok || 14);
  6320. const type = this.flowParseType();
  6321. this.state.inType = oldInType;
  6322. return type;
  6323. }
  6324. flowParsePredicate() {
  6325. const node = this.startNode();
  6326. const moduloLoc = this.state.startLoc;
  6327. this.next();
  6328. this.expectContextual(110);
  6329. if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
  6330. this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
  6331. }
  6332. if (this.eat(10)) {
  6333. node.value = super.parseExpression();
  6334. this.expect(11);
  6335. return this.finishNode(node, "DeclaredPredicate");
  6336. } else {
  6337. return this.finishNode(node, "InferredPredicate");
  6338. }
  6339. }
  6340. flowParseTypeAndPredicateInitialiser() {
  6341. const oldInType = this.state.inType;
  6342. this.state.inType = true;
  6343. this.expect(14);
  6344. let type = null;
  6345. let predicate = null;
  6346. if (this.match(54)) {
  6347. this.state.inType = oldInType;
  6348. predicate = this.flowParsePredicate();
  6349. } else {
  6350. type = this.flowParseType();
  6351. this.state.inType = oldInType;
  6352. if (this.match(54)) {
  6353. predicate = this.flowParsePredicate();
  6354. }
  6355. }
  6356. return [type, predicate];
  6357. }
  6358. flowParseDeclareClass(node) {
  6359. this.next();
  6360. this.flowParseInterfaceish(node, true);
  6361. return this.finishNode(node, "DeclareClass");
  6362. }
  6363. flowParseDeclareFunction(node) {
  6364. this.next();
  6365. const id = node.id = this.parseIdentifier();
  6366. const typeNode = this.startNode();
  6367. const typeContainer = this.startNode();
  6368. if (this.match(47)) {
  6369. typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
  6370. } else {
  6371. typeNode.typeParameters = null;
  6372. }
  6373. this.expect(10);
  6374. const tmp = this.flowParseFunctionTypeParams();
  6375. typeNode.params = tmp.params;
  6376. typeNode.rest = tmp.rest;
  6377. typeNode.this = tmp._this;
  6378. this.expect(11);
  6379. [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  6380. typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
  6381. id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
  6382. this.resetEndLocation(id);
  6383. this.semicolon();
  6384. this.scope.declareName(node.id.name, 2048, node.id.loc.start);
  6385. return this.finishNode(node, "DeclareFunction");
  6386. }
  6387. flowParseDeclare(node, insideModule) {
  6388. if (this.match(80)) {
  6389. return this.flowParseDeclareClass(node);
  6390. } else if (this.match(68)) {
  6391. return this.flowParseDeclareFunction(node);
  6392. } else if (this.match(74)) {
  6393. return this.flowParseDeclareVariable(node);
  6394. } else if (this.eatContextual(127)) {
  6395. if (this.match(16)) {
  6396. return this.flowParseDeclareModuleExports(node);
  6397. } else {
  6398. if (insideModule) {
  6399. this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc);
  6400. }
  6401. return this.flowParseDeclareModule(node);
  6402. }
  6403. } else if (this.isContextual(130)) {
  6404. return this.flowParseDeclareTypeAlias(node);
  6405. } else if (this.isContextual(131)) {
  6406. return this.flowParseDeclareOpaqueType(node);
  6407. } else if (this.isContextual(129)) {
  6408. return this.flowParseDeclareInterface(node);
  6409. } else if (this.match(82)) {
  6410. return this.flowParseDeclareExportDeclaration(node, insideModule);
  6411. } else {
  6412. this.unexpected();
  6413. }
  6414. }
  6415. flowParseDeclareVariable(node) {
  6416. this.next();
  6417. node.id = this.flowParseTypeAnnotatableIdentifier(true);
  6418. this.scope.declareName(node.id.name, 5, node.id.loc.start);
  6419. this.semicolon();
  6420. return this.finishNode(node, "DeclareVariable");
  6421. }
  6422. flowParseDeclareModule(node) {
  6423. this.scope.enter(0);
  6424. if (this.match(133)) {
  6425. node.id = super.parseExprAtom();
  6426. } else {
  6427. node.id = this.parseIdentifier();
  6428. }
  6429. const bodyNode = node.body = this.startNode();
  6430. const body = bodyNode.body = [];
  6431. this.expect(5);
  6432. while (!this.match(8)) {
  6433. let bodyNode = this.startNode();
  6434. if (this.match(83)) {
  6435. this.next();
  6436. if (!this.isContextual(130) && !this.match(87)) {
  6437. this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
  6438. }
  6439. super.parseImport(bodyNode);
  6440. } else {
  6441. this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
  6442. bodyNode = this.flowParseDeclare(bodyNode, true);
  6443. }
  6444. body.push(bodyNode);
  6445. }
  6446. this.scope.exit();
  6447. this.expect(8);
  6448. this.finishNode(bodyNode, "BlockStatement");
  6449. let kind = null;
  6450. let hasModuleExport = false;
  6451. body.forEach(bodyElement => {
  6452. if (isEsModuleType(bodyElement)) {
  6453. if (kind === "CommonJS") {
  6454. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6455. }
  6456. kind = "ES";
  6457. } else if (bodyElement.type === "DeclareModuleExports") {
  6458. if (hasModuleExport) {
  6459. this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement);
  6460. }
  6461. if (kind === "ES") {
  6462. this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement);
  6463. }
  6464. kind = "CommonJS";
  6465. hasModuleExport = true;
  6466. }
  6467. });
  6468. node.kind = kind || "CommonJS";
  6469. return this.finishNode(node, "DeclareModule");
  6470. }
  6471. flowParseDeclareExportDeclaration(node, insideModule) {
  6472. this.expect(82);
  6473. if (this.eat(65)) {
  6474. if (this.match(68) || this.match(80)) {
  6475. node.declaration = this.flowParseDeclare(this.startNode());
  6476. } else {
  6477. node.declaration = this.flowParseType();
  6478. this.semicolon();
  6479. }
  6480. node.default = true;
  6481. return this.finishNode(node, "DeclareExportDeclaration");
  6482. } else {
  6483. if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) {
  6484. const label = this.state.value;
  6485. throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
  6486. unsupportedExportKind: label,
  6487. suggestion: exportSuggestions[label]
  6488. });
  6489. }
  6490. if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) {
  6491. node.declaration = this.flowParseDeclare(this.startNode());
  6492. node.default = false;
  6493. return this.finishNode(node, "DeclareExportDeclaration");
  6494. } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) {
  6495. node = this.parseExport(node, null);
  6496. if (node.type === "ExportNamedDeclaration") {
  6497. node.type = "ExportDeclaration";
  6498. node.default = false;
  6499. delete node.exportKind;
  6500. }
  6501. node.type = "Declare" + node.type;
  6502. return node;
  6503. }
  6504. }
  6505. this.unexpected();
  6506. }
  6507. flowParseDeclareModuleExports(node) {
  6508. this.next();
  6509. this.expectContextual(111);
  6510. node.typeAnnotation = this.flowParseTypeAnnotation();
  6511. this.semicolon();
  6512. return this.finishNode(node, "DeclareModuleExports");
  6513. }
  6514. flowParseDeclareTypeAlias(node) {
  6515. this.next();
  6516. const finished = this.flowParseTypeAlias(node);
  6517. finished.type = "DeclareTypeAlias";
  6518. return finished;
  6519. }
  6520. flowParseDeclareOpaqueType(node) {
  6521. this.next();
  6522. const finished = this.flowParseOpaqueType(node, true);
  6523. finished.type = "DeclareOpaqueType";
  6524. return finished;
  6525. }
  6526. flowParseDeclareInterface(node) {
  6527. this.next();
  6528. this.flowParseInterfaceish(node, false);
  6529. return this.finishNode(node, "DeclareInterface");
  6530. }
  6531. flowParseInterfaceish(node, isClass) {
  6532. node.id = this.flowParseRestrictedIdentifier(!isClass, true);
  6533. this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start);
  6534. if (this.match(47)) {
  6535. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6536. } else {
  6537. node.typeParameters = null;
  6538. }
  6539. node.extends = [];
  6540. if (this.eat(81)) {
  6541. do {
  6542. node.extends.push(this.flowParseInterfaceExtends());
  6543. } while (!isClass && this.eat(12));
  6544. }
  6545. if (isClass) {
  6546. node.implements = [];
  6547. node.mixins = [];
  6548. if (this.eatContextual(117)) {
  6549. do {
  6550. node.mixins.push(this.flowParseInterfaceExtends());
  6551. } while (this.eat(12));
  6552. }
  6553. if (this.eatContextual(113)) {
  6554. do {
  6555. node.implements.push(this.flowParseInterfaceExtends());
  6556. } while (this.eat(12));
  6557. }
  6558. }
  6559. node.body = this.flowParseObjectType({
  6560. allowStatic: isClass,
  6561. allowExact: false,
  6562. allowSpread: false,
  6563. allowProto: isClass,
  6564. allowInexact: false
  6565. });
  6566. }
  6567. flowParseInterfaceExtends() {
  6568. const node = this.startNode();
  6569. node.id = this.flowParseQualifiedTypeIdentifier();
  6570. if (this.match(47)) {
  6571. node.typeParameters = this.flowParseTypeParameterInstantiation();
  6572. } else {
  6573. node.typeParameters = null;
  6574. }
  6575. return this.finishNode(node, "InterfaceExtends");
  6576. }
  6577. flowParseInterface(node) {
  6578. this.flowParseInterfaceish(node, false);
  6579. return this.finishNode(node, "InterfaceDeclaration");
  6580. }
  6581. checkNotUnderscore(word) {
  6582. if (word === "_") {
  6583. this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc);
  6584. }
  6585. }
  6586. checkReservedType(word, startLoc, declaration) {
  6587. if (!reservedTypes.has(word)) return;
  6588. this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, {
  6589. reservedType: word
  6590. });
  6591. }
  6592. flowParseRestrictedIdentifier(liberal, declaration) {
  6593. this.checkReservedType(this.state.value, this.state.startLoc, declaration);
  6594. return this.parseIdentifier(liberal);
  6595. }
  6596. flowParseTypeAlias(node) {
  6597. node.id = this.flowParseRestrictedIdentifier(false, true);
  6598. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6599. if (this.match(47)) {
  6600. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6601. } else {
  6602. node.typeParameters = null;
  6603. }
  6604. node.right = this.flowParseTypeInitialiser(29);
  6605. this.semicolon();
  6606. return this.finishNode(node, "TypeAlias");
  6607. }
  6608. flowParseOpaqueType(node, declare) {
  6609. this.expectContextual(130);
  6610. node.id = this.flowParseRestrictedIdentifier(true, true);
  6611. this.scope.declareName(node.id.name, 8201, node.id.loc.start);
  6612. if (this.match(47)) {
  6613. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6614. } else {
  6615. node.typeParameters = null;
  6616. }
  6617. node.supertype = null;
  6618. if (this.match(14)) {
  6619. node.supertype = this.flowParseTypeInitialiser(14);
  6620. }
  6621. node.impltype = null;
  6622. if (!declare) {
  6623. node.impltype = this.flowParseTypeInitialiser(29);
  6624. }
  6625. this.semicolon();
  6626. return this.finishNode(node, "OpaqueType");
  6627. }
  6628. flowParseTypeParameter(requireDefault = false) {
  6629. const nodeStartLoc = this.state.startLoc;
  6630. const node = this.startNode();
  6631. const variance = this.flowParseVariance();
  6632. const ident = this.flowParseTypeAnnotatableIdentifier();
  6633. node.name = ident.name;
  6634. node.variance = variance;
  6635. node.bound = ident.typeAnnotation;
  6636. if (this.match(29)) {
  6637. this.eat(29);
  6638. node.default = this.flowParseType();
  6639. } else {
  6640. if (requireDefault) {
  6641. this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc);
  6642. }
  6643. }
  6644. return this.finishNode(node, "TypeParameter");
  6645. }
  6646. flowParseTypeParameterDeclaration() {
  6647. const oldInType = this.state.inType;
  6648. const node = this.startNode();
  6649. node.params = [];
  6650. this.state.inType = true;
  6651. if (this.match(47) || this.match(142)) {
  6652. this.next();
  6653. } else {
  6654. this.unexpected();
  6655. }
  6656. let defaultRequired = false;
  6657. do {
  6658. const typeParameter = this.flowParseTypeParameter(defaultRequired);
  6659. node.params.push(typeParameter);
  6660. if (typeParameter.default) {
  6661. defaultRequired = true;
  6662. }
  6663. if (!this.match(48)) {
  6664. this.expect(12);
  6665. }
  6666. } while (!this.match(48));
  6667. this.expect(48);
  6668. this.state.inType = oldInType;
  6669. return this.finishNode(node, "TypeParameterDeclaration");
  6670. }
  6671. flowParseTypeParameterInstantiation() {
  6672. const node = this.startNode();
  6673. const oldInType = this.state.inType;
  6674. node.params = [];
  6675. this.state.inType = true;
  6676. this.expect(47);
  6677. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  6678. this.state.noAnonFunctionType = false;
  6679. while (!this.match(48)) {
  6680. node.params.push(this.flowParseType());
  6681. if (!this.match(48)) {
  6682. this.expect(12);
  6683. }
  6684. }
  6685. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  6686. this.expect(48);
  6687. this.state.inType = oldInType;
  6688. return this.finishNode(node, "TypeParameterInstantiation");
  6689. }
  6690. flowParseTypeParameterInstantiationCallOrNew() {
  6691. const node = this.startNode();
  6692. const oldInType = this.state.inType;
  6693. node.params = [];
  6694. this.state.inType = true;
  6695. this.expect(47);
  6696. while (!this.match(48)) {
  6697. node.params.push(this.flowParseTypeOrImplicitInstantiation());
  6698. if (!this.match(48)) {
  6699. this.expect(12);
  6700. }
  6701. }
  6702. this.expect(48);
  6703. this.state.inType = oldInType;
  6704. return this.finishNode(node, "TypeParameterInstantiation");
  6705. }
  6706. flowParseInterfaceType() {
  6707. const node = this.startNode();
  6708. this.expectContextual(129);
  6709. node.extends = [];
  6710. if (this.eat(81)) {
  6711. do {
  6712. node.extends.push(this.flowParseInterfaceExtends());
  6713. } while (this.eat(12));
  6714. }
  6715. node.body = this.flowParseObjectType({
  6716. allowStatic: false,
  6717. allowExact: false,
  6718. allowSpread: false,
  6719. allowProto: false,
  6720. allowInexact: false
  6721. });
  6722. return this.finishNode(node, "InterfaceTypeAnnotation");
  6723. }
  6724. flowParseObjectPropertyKey() {
  6725. return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
  6726. }
  6727. flowParseObjectTypeIndexer(node, isStatic, variance) {
  6728. node.static = isStatic;
  6729. if (this.lookahead().type === 14) {
  6730. node.id = this.flowParseObjectPropertyKey();
  6731. node.key = this.flowParseTypeInitialiser();
  6732. } else {
  6733. node.id = null;
  6734. node.key = this.flowParseType();
  6735. }
  6736. this.expect(3);
  6737. node.value = this.flowParseTypeInitialiser();
  6738. node.variance = variance;
  6739. return this.finishNode(node, "ObjectTypeIndexer");
  6740. }
  6741. flowParseObjectTypeInternalSlot(node, isStatic) {
  6742. node.static = isStatic;
  6743. node.id = this.flowParseObjectPropertyKey();
  6744. this.expect(3);
  6745. this.expect(3);
  6746. if (this.match(47) || this.match(10)) {
  6747. node.method = true;
  6748. node.optional = false;
  6749. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6750. } else {
  6751. node.method = false;
  6752. if (this.eat(17)) {
  6753. node.optional = true;
  6754. }
  6755. node.value = this.flowParseTypeInitialiser();
  6756. }
  6757. return this.finishNode(node, "ObjectTypeInternalSlot");
  6758. }
  6759. flowParseObjectTypeMethodish(node) {
  6760. node.params = [];
  6761. node.rest = null;
  6762. node.typeParameters = null;
  6763. node.this = null;
  6764. if (this.match(47)) {
  6765. node.typeParameters = this.flowParseTypeParameterDeclaration();
  6766. }
  6767. this.expect(10);
  6768. if (this.match(78)) {
  6769. node.this = this.flowParseFunctionTypeParam(true);
  6770. node.this.name = null;
  6771. if (!this.match(11)) {
  6772. this.expect(12);
  6773. }
  6774. }
  6775. while (!this.match(11) && !this.match(21)) {
  6776. node.params.push(this.flowParseFunctionTypeParam(false));
  6777. if (!this.match(11)) {
  6778. this.expect(12);
  6779. }
  6780. }
  6781. if (this.eat(21)) {
  6782. node.rest = this.flowParseFunctionTypeParam(false);
  6783. }
  6784. this.expect(11);
  6785. node.returnType = this.flowParseTypeInitialiser();
  6786. return this.finishNode(node, "FunctionTypeAnnotation");
  6787. }
  6788. flowParseObjectTypeCallProperty(node, isStatic) {
  6789. const valueNode = this.startNode();
  6790. node.static = isStatic;
  6791. node.value = this.flowParseObjectTypeMethodish(valueNode);
  6792. return this.finishNode(node, "ObjectTypeCallProperty");
  6793. }
  6794. flowParseObjectType({
  6795. allowStatic,
  6796. allowExact,
  6797. allowSpread,
  6798. allowProto,
  6799. allowInexact
  6800. }) {
  6801. const oldInType = this.state.inType;
  6802. this.state.inType = true;
  6803. const nodeStart = this.startNode();
  6804. nodeStart.callProperties = [];
  6805. nodeStart.properties = [];
  6806. nodeStart.indexers = [];
  6807. nodeStart.internalSlots = [];
  6808. let endDelim;
  6809. let exact;
  6810. let inexact = false;
  6811. if (allowExact && this.match(6)) {
  6812. this.expect(6);
  6813. endDelim = 9;
  6814. exact = true;
  6815. } else {
  6816. this.expect(5);
  6817. endDelim = 8;
  6818. exact = false;
  6819. }
  6820. nodeStart.exact = exact;
  6821. while (!this.match(endDelim)) {
  6822. let isStatic = false;
  6823. let protoStartLoc = null;
  6824. let inexactStartLoc = null;
  6825. const node = this.startNode();
  6826. if (allowProto && this.isContextual(118)) {
  6827. const lookahead = this.lookahead();
  6828. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6829. this.next();
  6830. protoStartLoc = this.state.startLoc;
  6831. allowStatic = false;
  6832. }
  6833. }
  6834. if (allowStatic && this.isContextual(106)) {
  6835. const lookahead = this.lookahead();
  6836. if (lookahead.type !== 14 && lookahead.type !== 17) {
  6837. this.next();
  6838. isStatic = true;
  6839. }
  6840. }
  6841. const variance = this.flowParseVariance();
  6842. if (this.eat(0)) {
  6843. if (protoStartLoc != null) {
  6844. this.unexpected(protoStartLoc);
  6845. }
  6846. if (this.eat(0)) {
  6847. if (variance) {
  6848. this.unexpected(variance.loc.start);
  6849. }
  6850. nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
  6851. } else {
  6852. nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
  6853. }
  6854. } else if (this.match(10) || this.match(47)) {
  6855. if (protoStartLoc != null) {
  6856. this.unexpected(protoStartLoc);
  6857. }
  6858. if (variance) {
  6859. this.unexpected(variance.loc.start);
  6860. }
  6861. nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
  6862. } else {
  6863. let kind = "init";
  6864. if (this.isContextual(99) || this.isContextual(104)) {
  6865. const lookahead = this.lookahead();
  6866. if (tokenIsLiteralPropertyName(lookahead.type)) {
  6867. kind = this.state.value;
  6868. this.next();
  6869. }
  6870. }
  6871. const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
  6872. if (propOrInexact === null) {
  6873. inexact = true;
  6874. inexactStartLoc = this.state.lastTokStartLoc;
  6875. } else {
  6876. nodeStart.properties.push(propOrInexact);
  6877. }
  6878. }
  6879. this.flowObjectTypeSemicolon();
  6880. if (inexactStartLoc && !this.match(8) && !this.match(9)) {
  6881. this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc);
  6882. }
  6883. }
  6884. this.expect(endDelim);
  6885. if (allowSpread) {
  6886. nodeStart.inexact = inexact;
  6887. }
  6888. const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
  6889. this.state.inType = oldInType;
  6890. return out;
  6891. }
  6892. flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
  6893. if (this.eat(21)) {
  6894. const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
  6895. if (isInexactToken) {
  6896. if (!allowSpread) {
  6897. this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc);
  6898. } else if (!allowInexact) {
  6899. this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc);
  6900. }
  6901. if (variance) {
  6902. this.raise(FlowErrors.InexactVariance, variance);
  6903. }
  6904. return null;
  6905. }
  6906. if (!allowSpread) {
  6907. this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc);
  6908. }
  6909. if (protoStartLoc != null) {
  6910. this.unexpected(protoStartLoc);
  6911. }
  6912. if (variance) {
  6913. this.raise(FlowErrors.SpreadVariance, variance);
  6914. }
  6915. node.argument = this.flowParseType();
  6916. return this.finishNode(node, "ObjectTypeSpreadProperty");
  6917. } else {
  6918. node.key = this.flowParseObjectPropertyKey();
  6919. node.static = isStatic;
  6920. node.proto = protoStartLoc != null;
  6921. node.kind = kind;
  6922. let optional = false;
  6923. if (this.match(47) || this.match(10)) {
  6924. node.method = true;
  6925. if (protoStartLoc != null) {
  6926. this.unexpected(protoStartLoc);
  6927. }
  6928. if (variance) {
  6929. this.unexpected(variance.loc.start);
  6930. }
  6931. node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start));
  6932. if (kind === "get" || kind === "set") {
  6933. this.flowCheckGetterSetterParams(node);
  6934. }
  6935. if (!allowSpread && node.key.name === "constructor" && node.value.this) {
  6936. this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this);
  6937. }
  6938. } else {
  6939. if (kind !== "init") this.unexpected();
  6940. node.method = false;
  6941. if (this.eat(17)) {
  6942. optional = true;
  6943. }
  6944. node.value = this.flowParseTypeInitialiser();
  6945. node.variance = variance;
  6946. }
  6947. node.optional = optional;
  6948. return this.finishNode(node, "ObjectTypeProperty");
  6949. }
  6950. }
  6951. flowCheckGetterSetterParams(property) {
  6952. const paramCount = property.kind === "get" ? 0 : 1;
  6953. const length = property.value.params.length + (property.value.rest ? 1 : 0);
  6954. if (property.value.this) {
  6955. this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this);
  6956. }
  6957. if (length !== paramCount) {
  6958. this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property);
  6959. }
  6960. if (property.kind === "set" && property.value.rest) {
  6961. this.raise(Errors.BadSetterRestParameter, property);
  6962. }
  6963. }
  6964. flowObjectTypeSemicolon() {
  6965. if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) {
  6966. this.unexpected();
  6967. }
  6968. }
  6969. flowParseQualifiedTypeIdentifier(startLoc, id) {
  6970. var _startLoc;
  6971. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  6972. let node = id || this.flowParseRestrictedIdentifier(true);
  6973. while (this.eat(16)) {
  6974. const node2 = this.startNodeAt(startLoc);
  6975. node2.qualification = node;
  6976. node2.id = this.flowParseRestrictedIdentifier(true);
  6977. node = this.finishNode(node2, "QualifiedTypeIdentifier");
  6978. }
  6979. return node;
  6980. }
  6981. flowParseGenericType(startLoc, id) {
  6982. const node = this.startNodeAt(startLoc);
  6983. node.typeParameters = null;
  6984. node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id);
  6985. if (this.match(47)) {
  6986. node.typeParameters = this.flowParseTypeParameterInstantiation();
  6987. }
  6988. return this.finishNode(node, "GenericTypeAnnotation");
  6989. }
  6990. flowParseTypeofType() {
  6991. const node = this.startNode();
  6992. this.expect(87);
  6993. node.argument = this.flowParsePrimaryType();
  6994. return this.finishNode(node, "TypeofTypeAnnotation");
  6995. }
  6996. flowParseTupleType() {
  6997. const node = this.startNode();
  6998. node.types = [];
  6999. this.expect(0);
  7000. while (this.state.pos < this.length && !this.match(3)) {
  7001. node.types.push(this.flowParseType());
  7002. if (this.match(3)) break;
  7003. this.expect(12);
  7004. }
  7005. this.expect(3);
  7006. return this.finishNode(node, "TupleTypeAnnotation");
  7007. }
  7008. flowParseFunctionTypeParam(first) {
  7009. let name = null;
  7010. let optional = false;
  7011. let typeAnnotation = null;
  7012. const node = this.startNode();
  7013. const lh = this.lookahead();
  7014. const isThis = this.state.type === 78;
  7015. if (lh.type === 14 || lh.type === 17) {
  7016. if (isThis && !first) {
  7017. this.raise(FlowErrors.ThisParamMustBeFirst, node);
  7018. }
  7019. name = this.parseIdentifier(isThis);
  7020. if (this.eat(17)) {
  7021. optional = true;
  7022. if (isThis) {
  7023. this.raise(FlowErrors.ThisParamMayNotBeOptional, node);
  7024. }
  7025. }
  7026. typeAnnotation = this.flowParseTypeInitialiser();
  7027. } else {
  7028. typeAnnotation = this.flowParseType();
  7029. }
  7030. node.name = name;
  7031. node.optional = optional;
  7032. node.typeAnnotation = typeAnnotation;
  7033. return this.finishNode(node, "FunctionTypeParam");
  7034. }
  7035. reinterpretTypeAsFunctionTypeParam(type) {
  7036. const node = this.startNodeAt(type.loc.start);
  7037. node.name = null;
  7038. node.optional = false;
  7039. node.typeAnnotation = type;
  7040. return this.finishNode(node, "FunctionTypeParam");
  7041. }
  7042. flowParseFunctionTypeParams(params = []) {
  7043. let rest = null;
  7044. let _this = null;
  7045. if (this.match(78)) {
  7046. _this = this.flowParseFunctionTypeParam(true);
  7047. _this.name = null;
  7048. if (!this.match(11)) {
  7049. this.expect(12);
  7050. }
  7051. }
  7052. while (!this.match(11) && !this.match(21)) {
  7053. params.push(this.flowParseFunctionTypeParam(false));
  7054. if (!this.match(11)) {
  7055. this.expect(12);
  7056. }
  7057. }
  7058. if (this.eat(21)) {
  7059. rest = this.flowParseFunctionTypeParam(false);
  7060. }
  7061. return {
  7062. params,
  7063. rest,
  7064. _this
  7065. };
  7066. }
  7067. flowIdentToTypeAnnotation(startLoc, node, id) {
  7068. switch (id.name) {
  7069. case "any":
  7070. return this.finishNode(node, "AnyTypeAnnotation");
  7071. case "bool":
  7072. case "boolean":
  7073. return this.finishNode(node, "BooleanTypeAnnotation");
  7074. case "mixed":
  7075. return this.finishNode(node, "MixedTypeAnnotation");
  7076. case "empty":
  7077. return this.finishNode(node, "EmptyTypeAnnotation");
  7078. case "number":
  7079. return this.finishNode(node, "NumberTypeAnnotation");
  7080. case "string":
  7081. return this.finishNode(node, "StringTypeAnnotation");
  7082. case "symbol":
  7083. return this.finishNode(node, "SymbolTypeAnnotation");
  7084. default:
  7085. this.checkNotUnderscore(id.name);
  7086. return this.flowParseGenericType(startLoc, id);
  7087. }
  7088. }
  7089. flowParsePrimaryType() {
  7090. const startLoc = this.state.startLoc;
  7091. const node = this.startNode();
  7092. let tmp;
  7093. let type;
  7094. let isGroupedType = false;
  7095. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7096. switch (this.state.type) {
  7097. case 5:
  7098. return this.flowParseObjectType({
  7099. allowStatic: false,
  7100. allowExact: false,
  7101. allowSpread: true,
  7102. allowProto: false,
  7103. allowInexact: true
  7104. });
  7105. case 6:
  7106. return this.flowParseObjectType({
  7107. allowStatic: false,
  7108. allowExact: true,
  7109. allowSpread: true,
  7110. allowProto: false,
  7111. allowInexact: false
  7112. });
  7113. case 0:
  7114. this.state.noAnonFunctionType = false;
  7115. type = this.flowParseTupleType();
  7116. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7117. return type;
  7118. case 47:
  7119. {
  7120. const node = this.startNode();
  7121. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7122. this.expect(10);
  7123. tmp = this.flowParseFunctionTypeParams();
  7124. node.params = tmp.params;
  7125. node.rest = tmp.rest;
  7126. node.this = tmp._this;
  7127. this.expect(11);
  7128. this.expect(19);
  7129. node.returnType = this.flowParseType();
  7130. return this.finishNode(node, "FunctionTypeAnnotation");
  7131. }
  7132. case 10:
  7133. {
  7134. const node = this.startNode();
  7135. this.next();
  7136. if (!this.match(11) && !this.match(21)) {
  7137. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  7138. const token = this.lookahead().type;
  7139. isGroupedType = token !== 17 && token !== 14;
  7140. } else {
  7141. isGroupedType = true;
  7142. }
  7143. }
  7144. if (isGroupedType) {
  7145. this.state.noAnonFunctionType = false;
  7146. type = this.flowParseType();
  7147. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7148. if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) {
  7149. this.expect(11);
  7150. return type;
  7151. } else {
  7152. this.eat(12);
  7153. }
  7154. }
  7155. if (type) {
  7156. tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
  7157. } else {
  7158. tmp = this.flowParseFunctionTypeParams();
  7159. }
  7160. node.params = tmp.params;
  7161. node.rest = tmp.rest;
  7162. node.this = tmp._this;
  7163. this.expect(11);
  7164. this.expect(19);
  7165. node.returnType = this.flowParseType();
  7166. node.typeParameters = null;
  7167. return this.finishNode(node, "FunctionTypeAnnotation");
  7168. }
  7169. case 133:
  7170. return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
  7171. case 85:
  7172. case 86:
  7173. node.value = this.match(85);
  7174. this.next();
  7175. return this.finishNode(node, "BooleanLiteralTypeAnnotation");
  7176. case 53:
  7177. if (this.state.value === "-") {
  7178. this.next();
  7179. if (this.match(134)) {
  7180. return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
  7181. }
  7182. if (this.match(135)) {
  7183. return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
  7184. }
  7185. throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
  7186. }
  7187. this.unexpected();
  7188. return;
  7189. case 134:
  7190. return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
  7191. case 135:
  7192. return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
  7193. case 88:
  7194. this.next();
  7195. return this.finishNode(node, "VoidTypeAnnotation");
  7196. case 84:
  7197. this.next();
  7198. return this.finishNode(node, "NullLiteralTypeAnnotation");
  7199. case 78:
  7200. this.next();
  7201. return this.finishNode(node, "ThisTypeAnnotation");
  7202. case 55:
  7203. this.next();
  7204. return this.finishNode(node, "ExistsTypeAnnotation");
  7205. case 87:
  7206. return this.flowParseTypeofType();
  7207. default:
  7208. if (tokenIsKeyword(this.state.type)) {
  7209. const label = tokenLabelName(this.state.type);
  7210. this.next();
  7211. return super.createIdentifier(node, label);
  7212. } else if (tokenIsIdentifier(this.state.type)) {
  7213. if (this.isContextual(129)) {
  7214. return this.flowParseInterfaceType();
  7215. }
  7216. return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
  7217. }
  7218. }
  7219. this.unexpected();
  7220. }
  7221. flowParsePostfixType() {
  7222. const startLoc = this.state.startLoc;
  7223. let type = this.flowParsePrimaryType();
  7224. let seenOptionalIndexedAccess = false;
  7225. while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) {
  7226. const node = this.startNodeAt(startLoc);
  7227. const optional = this.eat(18);
  7228. seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional;
  7229. this.expect(0);
  7230. if (!optional && this.match(3)) {
  7231. node.elementType = type;
  7232. this.next();
  7233. type = this.finishNode(node, "ArrayTypeAnnotation");
  7234. } else {
  7235. node.objectType = type;
  7236. node.indexType = this.flowParseType();
  7237. this.expect(3);
  7238. if (seenOptionalIndexedAccess) {
  7239. node.optional = optional;
  7240. type = this.finishNode(node, "OptionalIndexedAccessType");
  7241. } else {
  7242. type = this.finishNode(node, "IndexedAccessType");
  7243. }
  7244. }
  7245. }
  7246. return type;
  7247. }
  7248. flowParsePrefixType() {
  7249. const node = this.startNode();
  7250. if (this.eat(17)) {
  7251. node.typeAnnotation = this.flowParsePrefixType();
  7252. return this.finishNode(node, "NullableTypeAnnotation");
  7253. } else {
  7254. return this.flowParsePostfixType();
  7255. }
  7256. }
  7257. flowParseAnonFunctionWithoutParens() {
  7258. const param = this.flowParsePrefixType();
  7259. if (!this.state.noAnonFunctionType && this.eat(19)) {
  7260. const node = this.startNodeAt(param.loc.start);
  7261. node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
  7262. node.rest = null;
  7263. node.this = null;
  7264. node.returnType = this.flowParseType();
  7265. node.typeParameters = null;
  7266. return this.finishNode(node, "FunctionTypeAnnotation");
  7267. }
  7268. return param;
  7269. }
  7270. flowParseIntersectionType() {
  7271. const node = this.startNode();
  7272. this.eat(45);
  7273. const type = this.flowParseAnonFunctionWithoutParens();
  7274. node.types = [type];
  7275. while (this.eat(45)) {
  7276. node.types.push(this.flowParseAnonFunctionWithoutParens());
  7277. }
  7278. return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
  7279. }
  7280. flowParseUnionType() {
  7281. const node = this.startNode();
  7282. this.eat(43);
  7283. const type = this.flowParseIntersectionType();
  7284. node.types = [type];
  7285. while (this.eat(43)) {
  7286. node.types.push(this.flowParseIntersectionType());
  7287. }
  7288. return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
  7289. }
  7290. flowParseType() {
  7291. const oldInType = this.state.inType;
  7292. this.state.inType = true;
  7293. const type = this.flowParseUnionType();
  7294. this.state.inType = oldInType;
  7295. return type;
  7296. }
  7297. flowParseTypeOrImplicitInstantiation() {
  7298. if (this.state.type === 132 && this.state.value === "_") {
  7299. const startLoc = this.state.startLoc;
  7300. const node = this.parseIdentifier();
  7301. return this.flowParseGenericType(startLoc, node);
  7302. } else {
  7303. return this.flowParseType();
  7304. }
  7305. }
  7306. flowParseTypeAnnotation() {
  7307. const node = this.startNode();
  7308. node.typeAnnotation = this.flowParseTypeInitialiser();
  7309. return this.finishNode(node, "TypeAnnotation");
  7310. }
  7311. flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
  7312. const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
  7313. if (this.match(14)) {
  7314. ident.typeAnnotation = this.flowParseTypeAnnotation();
  7315. this.resetEndLocation(ident);
  7316. }
  7317. return ident;
  7318. }
  7319. typeCastToParameter(node) {
  7320. node.expression.typeAnnotation = node.typeAnnotation;
  7321. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  7322. return node.expression;
  7323. }
  7324. flowParseVariance() {
  7325. let variance = null;
  7326. if (this.match(53)) {
  7327. variance = this.startNode();
  7328. if (this.state.value === "+") {
  7329. variance.kind = "plus";
  7330. } else {
  7331. variance.kind = "minus";
  7332. }
  7333. this.next();
  7334. return this.finishNode(variance, "Variance");
  7335. }
  7336. return variance;
  7337. }
  7338. parseFunctionBody(node, allowExpressionBody, isMethod = false) {
  7339. if (allowExpressionBody) {
  7340. this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
  7341. return;
  7342. }
  7343. super.parseFunctionBody(node, false, isMethod);
  7344. }
  7345. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  7346. if (this.match(14)) {
  7347. const typeNode = this.startNode();
  7348. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  7349. node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
  7350. }
  7351. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  7352. }
  7353. parseStatementLike(flags) {
  7354. if (this.state.strict && this.isContextual(129)) {
  7355. const lookahead = this.lookahead();
  7356. if (tokenIsKeywordOrIdentifier(lookahead.type)) {
  7357. const node = this.startNode();
  7358. this.next();
  7359. return this.flowParseInterface(node);
  7360. }
  7361. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7362. const node = this.startNode();
  7363. this.next();
  7364. return this.flowParseEnumDeclaration(node);
  7365. }
  7366. const stmt = super.parseStatementLike(flags);
  7367. if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
  7368. this.flowPragma = null;
  7369. }
  7370. return stmt;
  7371. }
  7372. parseExpressionStatement(node, expr, decorators) {
  7373. if (expr.type === "Identifier") {
  7374. if (expr.name === "declare") {
  7375. if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) {
  7376. return this.flowParseDeclare(node);
  7377. }
  7378. } else if (tokenIsIdentifier(this.state.type)) {
  7379. if (expr.name === "interface") {
  7380. return this.flowParseInterface(node);
  7381. } else if (expr.name === "type") {
  7382. return this.flowParseTypeAlias(node);
  7383. } else if (expr.name === "opaque") {
  7384. return this.flowParseOpaqueType(node, false);
  7385. }
  7386. }
  7387. }
  7388. return super.parseExpressionStatement(node, expr, decorators);
  7389. }
  7390. shouldParseExportDeclaration() {
  7391. const {
  7392. type
  7393. } = this.state;
  7394. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7395. return !this.state.containsEsc;
  7396. }
  7397. return super.shouldParseExportDeclaration();
  7398. }
  7399. isExportDefaultSpecifier() {
  7400. const {
  7401. type
  7402. } = this.state;
  7403. if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) {
  7404. return this.state.containsEsc;
  7405. }
  7406. return super.isExportDefaultSpecifier();
  7407. }
  7408. parseExportDefaultExpression() {
  7409. if (this.shouldParseEnums() && this.isContextual(126)) {
  7410. const node = this.startNode();
  7411. this.next();
  7412. return this.flowParseEnumDeclaration(node);
  7413. }
  7414. return super.parseExportDefaultExpression();
  7415. }
  7416. parseConditional(expr, startLoc, refExpressionErrors) {
  7417. if (!this.match(17)) return expr;
  7418. if (this.state.maybeInArrowParameters) {
  7419. const nextCh = this.lookaheadCharCode();
  7420. if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
  7421. this.setOptionalParametersError(refExpressionErrors);
  7422. return expr;
  7423. }
  7424. }
  7425. this.expect(17);
  7426. const state = this.state.clone();
  7427. const originalNoArrowAt = this.state.noArrowAt;
  7428. const node = this.startNodeAt(startLoc);
  7429. let {
  7430. consequent,
  7431. failed
  7432. } = this.tryParseConditionalConsequent();
  7433. let [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7434. if (failed || invalid.length > 0) {
  7435. const noArrowAt = [...originalNoArrowAt];
  7436. if (invalid.length > 0) {
  7437. this.state = state;
  7438. this.state.noArrowAt = noArrowAt;
  7439. for (let i = 0; i < invalid.length; i++) {
  7440. noArrowAt.push(invalid[i].start);
  7441. }
  7442. ({
  7443. consequent,
  7444. failed
  7445. } = this.tryParseConditionalConsequent());
  7446. [valid, invalid] = this.getArrowLikeExpressions(consequent);
  7447. }
  7448. if (failed && valid.length > 1) {
  7449. this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc);
  7450. }
  7451. if (failed && valid.length === 1) {
  7452. this.state = state;
  7453. noArrowAt.push(valid[0].start);
  7454. this.state.noArrowAt = noArrowAt;
  7455. ({
  7456. consequent,
  7457. failed
  7458. } = this.tryParseConditionalConsequent());
  7459. }
  7460. }
  7461. this.getArrowLikeExpressions(consequent, true);
  7462. this.state.noArrowAt = originalNoArrowAt;
  7463. this.expect(14);
  7464. node.test = expr;
  7465. node.consequent = consequent;
  7466. node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined));
  7467. return this.finishNode(node, "ConditionalExpression");
  7468. }
  7469. tryParseConditionalConsequent() {
  7470. this.state.noArrowParamsConversionAt.push(this.state.start);
  7471. const consequent = this.parseMaybeAssignAllowIn();
  7472. const failed = !this.match(14);
  7473. this.state.noArrowParamsConversionAt.pop();
  7474. return {
  7475. consequent,
  7476. failed
  7477. };
  7478. }
  7479. getArrowLikeExpressions(node, disallowInvalid) {
  7480. const stack = [node];
  7481. const arrows = [];
  7482. while (stack.length !== 0) {
  7483. const node = stack.pop();
  7484. if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
  7485. if (node.typeParameters || !node.returnType) {
  7486. this.finishArrowValidation(node);
  7487. } else {
  7488. arrows.push(node);
  7489. }
  7490. stack.push(node.body);
  7491. } else if (node.type === "ConditionalExpression") {
  7492. stack.push(node.consequent);
  7493. stack.push(node.alternate);
  7494. }
  7495. }
  7496. if (disallowInvalid) {
  7497. arrows.forEach(node => this.finishArrowValidation(node));
  7498. return [arrows, []];
  7499. }
  7500. return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
  7501. }
  7502. finishArrowValidation(node) {
  7503. var _node$extra;
  7504. this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
  7505. this.scope.enter(2 | 4);
  7506. super.checkParams(node, false, true);
  7507. this.scope.exit();
  7508. }
  7509. forwardNoArrowParamsConversionAt(node, parse) {
  7510. let result;
  7511. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  7512. this.state.noArrowParamsConversionAt.push(this.state.start);
  7513. result = parse();
  7514. this.state.noArrowParamsConversionAt.pop();
  7515. } else {
  7516. result = parse();
  7517. }
  7518. return result;
  7519. }
  7520. parseParenItem(node, startLoc) {
  7521. const newNode = super.parseParenItem(node, startLoc);
  7522. if (this.eat(17)) {
  7523. newNode.optional = true;
  7524. this.resetEndLocation(node);
  7525. }
  7526. if (this.match(14)) {
  7527. const typeCastNode = this.startNodeAt(startLoc);
  7528. typeCastNode.expression = newNode;
  7529. typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
  7530. return this.finishNode(typeCastNode, "TypeCastExpression");
  7531. }
  7532. return newNode;
  7533. }
  7534. assertModuleNodeAllowed(node) {
  7535. if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
  7536. return;
  7537. }
  7538. super.assertModuleNodeAllowed(node);
  7539. }
  7540. parseExportDeclaration(node) {
  7541. if (this.isContextual(130)) {
  7542. node.exportKind = "type";
  7543. const declarationNode = this.startNode();
  7544. this.next();
  7545. if (this.match(5)) {
  7546. node.specifiers = this.parseExportSpecifiers(true);
  7547. super.parseExportFrom(node);
  7548. return null;
  7549. } else {
  7550. return this.flowParseTypeAlias(declarationNode);
  7551. }
  7552. } else if (this.isContextual(131)) {
  7553. node.exportKind = "type";
  7554. const declarationNode = this.startNode();
  7555. this.next();
  7556. return this.flowParseOpaqueType(declarationNode, false);
  7557. } else if (this.isContextual(129)) {
  7558. node.exportKind = "type";
  7559. const declarationNode = this.startNode();
  7560. this.next();
  7561. return this.flowParseInterface(declarationNode);
  7562. } else if (this.shouldParseEnums() && this.isContextual(126)) {
  7563. node.exportKind = "value";
  7564. const declarationNode = this.startNode();
  7565. this.next();
  7566. return this.flowParseEnumDeclaration(declarationNode);
  7567. } else {
  7568. return super.parseExportDeclaration(node);
  7569. }
  7570. }
  7571. eatExportStar(node) {
  7572. if (super.eatExportStar(node)) return true;
  7573. if (this.isContextual(130) && this.lookahead().type === 55) {
  7574. node.exportKind = "type";
  7575. this.next();
  7576. this.next();
  7577. return true;
  7578. }
  7579. return false;
  7580. }
  7581. maybeParseExportNamespaceSpecifier(node) {
  7582. const {
  7583. startLoc
  7584. } = this.state;
  7585. const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
  7586. if (hasNamespace && node.exportKind === "type") {
  7587. this.unexpected(startLoc);
  7588. }
  7589. return hasNamespace;
  7590. }
  7591. parseClassId(node, isStatement, optionalId) {
  7592. super.parseClassId(node, isStatement, optionalId);
  7593. if (this.match(47)) {
  7594. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7595. }
  7596. }
  7597. parseClassMember(classBody, member, state) {
  7598. const {
  7599. startLoc
  7600. } = this.state;
  7601. if (this.isContextual(125)) {
  7602. if (super.parseClassMemberFromModifier(classBody, member)) {
  7603. return;
  7604. }
  7605. member.declare = true;
  7606. }
  7607. super.parseClassMember(classBody, member, state);
  7608. if (member.declare) {
  7609. if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
  7610. this.raise(FlowErrors.DeclareClassElement, startLoc);
  7611. } else if (member.value) {
  7612. this.raise(FlowErrors.DeclareClassFieldInitializer, member.value);
  7613. }
  7614. }
  7615. }
  7616. isIterator(word) {
  7617. return word === "iterator" || word === "asyncIterator";
  7618. }
  7619. readIterator() {
  7620. const word = super.readWord1();
  7621. const fullWord = "@@" + word;
  7622. if (!this.isIterator(word) || !this.state.inType) {
  7623. this.raise(Errors.InvalidIdentifier, this.state.curPosition(), {
  7624. identifierName: fullWord
  7625. });
  7626. }
  7627. this.finishToken(132, fullWord);
  7628. }
  7629. getTokenFromCode(code) {
  7630. const next = this.input.charCodeAt(this.state.pos + 1);
  7631. if (code === 123 && next === 124) {
  7632. this.finishOp(6, 2);
  7633. } else if (this.state.inType && (code === 62 || code === 60)) {
  7634. this.finishOp(code === 62 ? 48 : 47, 1);
  7635. } else if (this.state.inType && code === 63) {
  7636. if (next === 46) {
  7637. this.finishOp(18, 2);
  7638. } else {
  7639. this.finishOp(17, 1);
  7640. }
  7641. } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) {
  7642. this.state.pos += 2;
  7643. this.readIterator();
  7644. } else {
  7645. super.getTokenFromCode(code);
  7646. }
  7647. }
  7648. isAssignable(node, isBinding) {
  7649. if (node.type === "TypeCastExpression") {
  7650. return this.isAssignable(node.expression, isBinding);
  7651. } else {
  7652. return super.isAssignable(node, isBinding);
  7653. }
  7654. }
  7655. toAssignable(node, isLHS = false) {
  7656. if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
  7657. node.left = this.typeCastToParameter(node.left);
  7658. }
  7659. super.toAssignable(node, isLHS);
  7660. }
  7661. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  7662. for (let i = 0; i < exprList.length; i++) {
  7663. const expr = exprList[i];
  7664. if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
  7665. exprList[i] = this.typeCastToParameter(expr);
  7666. }
  7667. }
  7668. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  7669. }
  7670. toReferencedList(exprList, isParenthesizedExpr) {
  7671. for (let i = 0; i < exprList.length; i++) {
  7672. var _expr$extra;
  7673. const expr = exprList[i];
  7674. if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
  7675. this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation);
  7676. }
  7677. }
  7678. return exprList;
  7679. }
  7680. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  7681. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  7682. if (canBePattern && !this.state.maybeInArrowParameters) {
  7683. this.toReferencedList(node.elements);
  7684. }
  7685. return node;
  7686. }
  7687. isValidLVal(type, isParenthesized, binding) {
  7688. return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding);
  7689. }
  7690. parseClassProperty(node) {
  7691. if (this.match(14)) {
  7692. node.typeAnnotation = this.flowParseTypeAnnotation();
  7693. }
  7694. return super.parseClassProperty(node);
  7695. }
  7696. parseClassPrivateProperty(node) {
  7697. if (this.match(14)) {
  7698. node.typeAnnotation = this.flowParseTypeAnnotation();
  7699. }
  7700. return super.parseClassPrivateProperty(node);
  7701. }
  7702. isClassMethod() {
  7703. return this.match(47) || super.isClassMethod();
  7704. }
  7705. isClassProperty() {
  7706. return this.match(14) || super.isClassProperty();
  7707. }
  7708. isNonstaticConstructor(method) {
  7709. return !this.match(14) && super.isNonstaticConstructor(method);
  7710. }
  7711. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  7712. if (method.variance) {
  7713. this.unexpected(method.variance.loc.start);
  7714. }
  7715. delete method.variance;
  7716. if (this.match(47)) {
  7717. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7718. }
  7719. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  7720. if (method.params && isConstructor) {
  7721. const params = method.params;
  7722. if (params.length > 0 && this.isThisParam(params[0])) {
  7723. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7724. }
  7725. } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
  7726. const params = method.value.params;
  7727. if (params.length > 0 && this.isThisParam(params[0])) {
  7728. this.raise(FlowErrors.ThisParamBannedInConstructor, method);
  7729. }
  7730. }
  7731. }
  7732. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  7733. if (method.variance) {
  7734. this.unexpected(method.variance.loc.start);
  7735. }
  7736. delete method.variance;
  7737. if (this.match(47)) {
  7738. method.typeParameters = this.flowParseTypeParameterDeclaration();
  7739. }
  7740. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  7741. }
  7742. parseClassSuper(node) {
  7743. super.parseClassSuper(node);
  7744. if (node.superClass && this.match(47)) {
  7745. node.superTypeParameters = this.flowParseTypeParameterInstantiation();
  7746. }
  7747. if (this.isContextual(113)) {
  7748. this.next();
  7749. const implemented = node.implements = [];
  7750. do {
  7751. const node = this.startNode();
  7752. node.id = this.flowParseRestrictedIdentifier(true);
  7753. if (this.match(47)) {
  7754. node.typeParameters = this.flowParseTypeParameterInstantiation();
  7755. } else {
  7756. node.typeParameters = null;
  7757. }
  7758. implemented.push(this.finishNode(node, "ClassImplements"));
  7759. } while (this.eat(12));
  7760. }
  7761. }
  7762. checkGetterSetterParams(method) {
  7763. super.checkGetterSetterParams(method);
  7764. const params = this.getObjectOrClassMethodParams(method);
  7765. if (params.length > 0) {
  7766. const param = params[0];
  7767. if (this.isThisParam(param) && method.kind === "get") {
  7768. this.raise(FlowErrors.GetterMayNotHaveThisParam, param);
  7769. } else if (this.isThisParam(param)) {
  7770. this.raise(FlowErrors.SetterMayNotHaveThisParam, param);
  7771. }
  7772. }
  7773. }
  7774. parsePropertyNamePrefixOperator(node) {
  7775. node.variance = this.flowParseVariance();
  7776. }
  7777. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  7778. if (prop.variance) {
  7779. this.unexpected(prop.variance.loc.start);
  7780. }
  7781. delete prop.variance;
  7782. let typeParameters;
  7783. if (this.match(47) && !isAccessor) {
  7784. typeParameters = this.flowParseTypeParameterDeclaration();
  7785. if (!this.match(10)) this.unexpected();
  7786. }
  7787. const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  7788. if (typeParameters) {
  7789. (result.value || result).typeParameters = typeParameters;
  7790. }
  7791. return result;
  7792. }
  7793. parseAssignableListItemTypes(param) {
  7794. if (this.eat(17)) {
  7795. if (param.type !== "Identifier") {
  7796. this.raise(FlowErrors.PatternIsOptional, param);
  7797. }
  7798. if (this.isThisParam(param)) {
  7799. this.raise(FlowErrors.ThisParamMayNotBeOptional, param);
  7800. }
  7801. param.optional = true;
  7802. }
  7803. if (this.match(14)) {
  7804. param.typeAnnotation = this.flowParseTypeAnnotation();
  7805. } else if (this.isThisParam(param)) {
  7806. this.raise(FlowErrors.ThisParamAnnotationRequired, param);
  7807. }
  7808. if (this.match(29) && this.isThisParam(param)) {
  7809. this.raise(FlowErrors.ThisParamNoDefault, param);
  7810. }
  7811. this.resetEndLocation(param);
  7812. return param;
  7813. }
  7814. parseMaybeDefault(startLoc, left) {
  7815. const node = super.parseMaybeDefault(startLoc, left);
  7816. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  7817. this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation);
  7818. }
  7819. return node;
  7820. }
  7821. checkImportReflection(node) {
  7822. super.checkImportReflection(node);
  7823. if (node.module && node.importKind !== "value") {
  7824. this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  7825. }
  7826. }
  7827. parseImportSpecifierLocal(node, specifier, type) {
  7828. specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
  7829. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  7830. }
  7831. isPotentialImportPhase(isExport) {
  7832. if (super.isPotentialImportPhase(isExport)) return true;
  7833. if (this.isContextual(130)) {
  7834. if (!isExport) return true;
  7835. const ch = this.lookaheadCharCode();
  7836. return ch === 123 || ch === 42;
  7837. }
  7838. return !isExport && this.isContextual(87);
  7839. }
  7840. applyImportPhase(node, isExport, phase, loc) {
  7841. super.applyImportPhase(node, isExport, phase, loc);
  7842. if (isExport) {
  7843. if (!phase && this.match(65)) {
  7844. return;
  7845. }
  7846. node.exportKind = phase === "type" ? phase : "value";
  7847. } else {
  7848. if (phase === "type" && this.match(55)) this.unexpected();
  7849. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  7850. }
  7851. }
  7852. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  7853. const firstIdent = specifier.imported;
  7854. let specifierTypeKind = null;
  7855. if (firstIdent.type === "Identifier") {
  7856. if (firstIdent.name === "type") {
  7857. specifierTypeKind = "type";
  7858. } else if (firstIdent.name === "typeof") {
  7859. specifierTypeKind = "typeof";
  7860. }
  7861. }
  7862. let isBinding = false;
  7863. if (this.isContextual(93) && !this.isLookaheadContextual("as")) {
  7864. const as_ident = this.parseIdentifier(true);
  7865. if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
  7866. specifier.imported = as_ident;
  7867. specifier.importKind = specifierTypeKind;
  7868. specifier.local = cloneIdentifier(as_ident);
  7869. } else {
  7870. specifier.imported = firstIdent;
  7871. specifier.importKind = null;
  7872. specifier.local = this.parseIdentifier();
  7873. }
  7874. } else {
  7875. if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) {
  7876. specifier.imported = this.parseIdentifier(true);
  7877. specifier.importKind = specifierTypeKind;
  7878. } else {
  7879. if (importedIsString) {
  7880. throw this.raise(Errors.ImportBindingIsString, specifier, {
  7881. importName: firstIdent.value
  7882. });
  7883. }
  7884. specifier.imported = firstIdent;
  7885. specifier.importKind = null;
  7886. }
  7887. if (this.eatContextual(93)) {
  7888. specifier.local = this.parseIdentifier();
  7889. } else {
  7890. isBinding = true;
  7891. specifier.local = cloneIdentifier(specifier.imported);
  7892. }
  7893. }
  7894. const specifierIsTypeImport = hasTypeImportKind(specifier);
  7895. if (isInTypeOnlyImport && specifierIsTypeImport) {
  7896. this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
  7897. }
  7898. if (isInTypeOnlyImport || specifierIsTypeImport) {
  7899. this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
  7900. }
  7901. if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
  7902. this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
  7903. }
  7904. return this.finishImportSpecifier(specifier, "ImportSpecifier");
  7905. }
  7906. parseBindingAtom() {
  7907. switch (this.state.type) {
  7908. case 78:
  7909. return this.parseIdentifier(true);
  7910. default:
  7911. return super.parseBindingAtom();
  7912. }
  7913. }
  7914. parseFunctionParams(node, isConstructor) {
  7915. const kind = node.kind;
  7916. if (kind !== "get" && kind !== "set" && this.match(47)) {
  7917. node.typeParameters = this.flowParseTypeParameterDeclaration();
  7918. }
  7919. super.parseFunctionParams(node, isConstructor);
  7920. }
  7921. parseVarId(decl, kind) {
  7922. super.parseVarId(decl, kind);
  7923. if (this.match(14)) {
  7924. decl.id.typeAnnotation = this.flowParseTypeAnnotation();
  7925. this.resetEndLocation(decl.id);
  7926. }
  7927. }
  7928. parseAsyncArrowFromCallExpression(node, call) {
  7929. if (this.match(14)) {
  7930. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  7931. this.state.noAnonFunctionType = true;
  7932. node.returnType = this.flowParseTypeAnnotation();
  7933. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  7934. }
  7935. return super.parseAsyncArrowFromCallExpression(node, call);
  7936. }
  7937. shouldParseAsyncArrow() {
  7938. return this.match(14) || super.shouldParseAsyncArrow();
  7939. }
  7940. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  7941. var _jsx;
  7942. let state = null;
  7943. let jsx;
  7944. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  7945. state = this.state.clone();
  7946. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  7947. if (!jsx.error) return jsx.node;
  7948. const {
  7949. context
  7950. } = this.state;
  7951. const currentContext = context[context.length - 1];
  7952. if (currentContext === types$1.j_oTag || currentContext === types$1.j_expr) {
  7953. context.pop();
  7954. }
  7955. }
  7956. if ((_jsx = jsx) != null && _jsx.error || this.match(47)) {
  7957. var _jsx2, _jsx3;
  7958. state = state || this.state.clone();
  7959. let typeParameters;
  7960. const arrow = this.tryParse(abort => {
  7961. var _arrowExpression$extr;
  7962. typeParameters = this.flowParseTypeParameterDeclaration();
  7963. const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
  7964. const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  7965. this.resetStartLocationFromNode(result, typeParameters);
  7966. return result;
  7967. });
  7968. if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort();
  7969. const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
  7970. if (expr.type !== "ArrowFunctionExpression") abort();
  7971. expr.typeParameters = typeParameters;
  7972. this.resetStartLocationFromNode(expr, typeParameters);
  7973. return arrowExpression;
  7974. }, state);
  7975. let arrowExpression = null;
  7976. if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
  7977. if (!arrow.error && !arrow.aborted) {
  7978. if (arrow.node.async) {
  7979. this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters);
  7980. }
  7981. return arrow.node;
  7982. }
  7983. arrowExpression = arrow.node;
  7984. }
  7985. if ((_jsx2 = jsx) != null && _jsx2.node) {
  7986. this.state = jsx.failState;
  7987. return jsx.node;
  7988. }
  7989. if (arrowExpression) {
  7990. this.state = arrow.failState;
  7991. return arrowExpression;
  7992. }
  7993. if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
  7994. if (arrow.thrown) throw arrow.error;
  7995. throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters);
  7996. }
  7997. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  7998. }
  7999. parseArrow(node) {
  8000. if (this.match(14)) {
  8001. const result = this.tryParse(() => {
  8002. const oldNoAnonFunctionType = this.state.noAnonFunctionType;
  8003. this.state.noAnonFunctionType = true;
  8004. const typeNode = this.startNode();
  8005. [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
  8006. this.state.noAnonFunctionType = oldNoAnonFunctionType;
  8007. if (this.canInsertSemicolon()) this.unexpected();
  8008. if (!this.match(19)) this.unexpected();
  8009. return typeNode;
  8010. });
  8011. if (result.thrown) return null;
  8012. if (result.error) this.state = result.failState;
  8013. node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
  8014. }
  8015. return super.parseArrow(node);
  8016. }
  8017. shouldParseArrow(params) {
  8018. return this.match(14) || super.shouldParseArrow(params);
  8019. }
  8020. setArrowFunctionParameters(node, params) {
  8021. if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  8022. node.params = params;
  8023. } else {
  8024. super.setArrowFunctionParameters(node, params);
  8025. }
  8026. }
  8027. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  8028. if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
  8029. return;
  8030. }
  8031. for (let i = 0; i < node.params.length; i++) {
  8032. if (this.isThisParam(node.params[i]) && i > 0) {
  8033. this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
  8034. }
  8035. }
  8036. super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
  8037. }
  8038. parseParenAndDistinguishExpression(canBeArrow) {
  8039. return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
  8040. }
  8041. parseSubscripts(base, startLoc, noCalls) {
  8042. if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startLoc.index) !== -1) {
  8043. this.next();
  8044. const node = this.startNodeAt(startLoc);
  8045. node.callee = base;
  8046. node.arguments = super.parseCallExpressionArguments(11, false);
  8047. base = this.finishNode(node, "CallExpression");
  8048. } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
  8049. const state = this.state.clone();
  8050. const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
  8051. if (!arrow.error && !arrow.aborted) return arrow.node;
  8052. const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state);
  8053. if (result.node && !result.error) return result.node;
  8054. if (arrow.node) {
  8055. this.state = arrow.failState;
  8056. return arrow.node;
  8057. }
  8058. if (result.node) {
  8059. this.state = result.failState;
  8060. return result.node;
  8061. }
  8062. throw arrow.error || result.error;
  8063. }
  8064. return super.parseSubscripts(base, startLoc, noCalls);
  8065. }
  8066. parseSubscript(base, startLoc, noCalls, subscriptState) {
  8067. if (this.match(18) && this.isLookaheadToken_lt()) {
  8068. subscriptState.optionalChainMember = true;
  8069. if (noCalls) {
  8070. subscriptState.stop = true;
  8071. return base;
  8072. }
  8073. this.next();
  8074. const node = this.startNodeAt(startLoc);
  8075. node.callee = base;
  8076. node.typeArguments = this.flowParseTypeParameterInstantiation();
  8077. this.expect(10);
  8078. node.arguments = this.parseCallExpressionArguments(11, false);
  8079. node.optional = true;
  8080. return this.finishCallExpression(node, true);
  8081. } else if (!noCalls && this.shouldParseTypes() && this.match(47)) {
  8082. const node = this.startNodeAt(startLoc);
  8083. node.callee = base;
  8084. const result = this.tryParse(() => {
  8085. node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
  8086. this.expect(10);
  8087. node.arguments = super.parseCallExpressionArguments(11, false);
  8088. if (subscriptState.optionalChainMember) {
  8089. node.optional = false;
  8090. }
  8091. return this.finishCallExpression(node, subscriptState.optionalChainMember);
  8092. });
  8093. if (result.node) {
  8094. if (result.error) this.state = result.failState;
  8095. return result.node;
  8096. }
  8097. }
  8098. return super.parseSubscript(base, startLoc, noCalls, subscriptState);
  8099. }
  8100. parseNewCallee(node) {
  8101. super.parseNewCallee(node);
  8102. let targs = null;
  8103. if (this.shouldParseTypes() && this.match(47)) {
  8104. targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
  8105. }
  8106. node.typeArguments = targs;
  8107. }
  8108. parseAsyncArrowWithTypeParameters(startLoc) {
  8109. const node = this.startNodeAt(startLoc);
  8110. this.parseFunctionParams(node, false);
  8111. if (!this.parseArrow(node)) return;
  8112. return super.parseArrowExpression(node, undefined, true);
  8113. }
  8114. readToken_mult_modulo(code) {
  8115. const next = this.input.charCodeAt(this.state.pos + 1);
  8116. if (code === 42 && next === 47 && this.state.hasFlowComment) {
  8117. this.state.hasFlowComment = false;
  8118. this.state.pos += 2;
  8119. this.nextToken();
  8120. return;
  8121. }
  8122. super.readToken_mult_modulo(code);
  8123. }
  8124. readToken_pipe_amp(code) {
  8125. const next = this.input.charCodeAt(this.state.pos + 1);
  8126. if (code === 124 && next === 125) {
  8127. this.finishOp(9, 2);
  8128. return;
  8129. }
  8130. super.readToken_pipe_amp(code);
  8131. }
  8132. parseTopLevel(file, program) {
  8133. const fileNode = super.parseTopLevel(file, program);
  8134. if (this.state.hasFlowComment) {
  8135. this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition());
  8136. }
  8137. return fileNode;
  8138. }
  8139. skipBlockComment() {
  8140. if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
  8141. if (this.state.hasFlowComment) {
  8142. throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc);
  8143. }
  8144. this.hasFlowCommentCompletion();
  8145. const commentSkip = this.skipFlowComment();
  8146. if (commentSkip) {
  8147. this.state.pos += commentSkip;
  8148. this.state.hasFlowComment = true;
  8149. }
  8150. return;
  8151. }
  8152. return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/");
  8153. }
  8154. skipFlowComment() {
  8155. const {
  8156. pos
  8157. } = this.state;
  8158. let shiftToFirstNonWhiteSpace = 2;
  8159. while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
  8160. shiftToFirstNonWhiteSpace++;
  8161. }
  8162. const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
  8163. const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
  8164. if (ch2 === 58 && ch3 === 58) {
  8165. return shiftToFirstNonWhiteSpace + 2;
  8166. }
  8167. if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
  8168. return shiftToFirstNonWhiteSpace + 12;
  8169. }
  8170. if (ch2 === 58 && ch3 !== 58) {
  8171. return shiftToFirstNonWhiteSpace;
  8172. }
  8173. return false;
  8174. }
  8175. hasFlowCommentCompletion() {
  8176. const end = this.input.indexOf("*/", this.state.pos);
  8177. if (end === -1) {
  8178. throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
  8179. }
  8180. }
  8181. flowEnumErrorBooleanMemberNotInitialized(loc, {
  8182. enumName,
  8183. memberName
  8184. }) {
  8185. this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, {
  8186. memberName,
  8187. enumName
  8188. });
  8189. }
  8190. flowEnumErrorInvalidMemberInitializer(loc, enumContext) {
  8191. return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext);
  8192. }
  8193. flowEnumErrorNumberMemberNotInitialized(loc, details) {
  8194. this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details);
  8195. }
  8196. flowEnumErrorStringMemberInconsistentlyInitialized(node, details) {
  8197. this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details);
  8198. }
  8199. flowEnumMemberInit() {
  8200. const startLoc = this.state.startLoc;
  8201. const endOfInit = () => this.match(12) || this.match(8);
  8202. switch (this.state.type) {
  8203. case 134:
  8204. {
  8205. const literal = this.parseNumericLiteral(this.state.value);
  8206. if (endOfInit()) {
  8207. return {
  8208. type: "number",
  8209. loc: literal.loc.start,
  8210. value: literal
  8211. };
  8212. }
  8213. return {
  8214. type: "invalid",
  8215. loc: startLoc
  8216. };
  8217. }
  8218. case 133:
  8219. {
  8220. const literal = this.parseStringLiteral(this.state.value);
  8221. if (endOfInit()) {
  8222. return {
  8223. type: "string",
  8224. loc: literal.loc.start,
  8225. value: literal
  8226. };
  8227. }
  8228. return {
  8229. type: "invalid",
  8230. loc: startLoc
  8231. };
  8232. }
  8233. case 85:
  8234. case 86:
  8235. {
  8236. const literal = this.parseBooleanLiteral(this.match(85));
  8237. if (endOfInit()) {
  8238. return {
  8239. type: "boolean",
  8240. loc: literal.loc.start,
  8241. value: literal
  8242. };
  8243. }
  8244. return {
  8245. type: "invalid",
  8246. loc: startLoc
  8247. };
  8248. }
  8249. default:
  8250. return {
  8251. type: "invalid",
  8252. loc: startLoc
  8253. };
  8254. }
  8255. }
  8256. flowEnumMemberRaw() {
  8257. const loc = this.state.startLoc;
  8258. const id = this.parseIdentifier(true);
  8259. const init = this.eat(29) ? this.flowEnumMemberInit() : {
  8260. type: "none",
  8261. loc
  8262. };
  8263. return {
  8264. id,
  8265. init
  8266. };
  8267. }
  8268. flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
  8269. const {
  8270. explicitType
  8271. } = context;
  8272. if (explicitType === null) {
  8273. return;
  8274. }
  8275. if (explicitType !== expectedType) {
  8276. this.flowEnumErrorInvalidMemberInitializer(loc, context);
  8277. }
  8278. }
  8279. flowEnumMembers({
  8280. enumName,
  8281. explicitType
  8282. }) {
  8283. const seenNames = new Set();
  8284. const members = {
  8285. booleanMembers: [],
  8286. numberMembers: [],
  8287. stringMembers: [],
  8288. defaultedMembers: []
  8289. };
  8290. let hasUnknownMembers = false;
  8291. while (!this.match(8)) {
  8292. if (this.eat(21)) {
  8293. hasUnknownMembers = true;
  8294. break;
  8295. }
  8296. const memberNode = this.startNode();
  8297. const {
  8298. id,
  8299. init
  8300. } = this.flowEnumMemberRaw();
  8301. const memberName = id.name;
  8302. if (memberName === "") {
  8303. continue;
  8304. }
  8305. if (/^[a-z]/.test(memberName)) {
  8306. this.raise(FlowErrors.EnumInvalidMemberName, id, {
  8307. memberName,
  8308. suggestion: memberName[0].toUpperCase() + memberName.slice(1),
  8309. enumName
  8310. });
  8311. }
  8312. if (seenNames.has(memberName)) {
  8313. this.raise(FlowErrors.EnumDuplicateMemberName, id, {
  8314. memberName,
  8315. enumName
  8316. });
  8317. }
  8318. seenNames.add(memberName);
  8319. const context = {
  8320. enumName,
  8321. explicitType,
  8322. memberName
  8323. };
  8324. memberNode.id = id;
  8325. switch (init.type) {
  8326. case "boolean":
  8327. {
  8328. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
  8329. memberNode.init = init.value;
  8330. members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
  8331. break;
  8332. }
  8333. case "number":
  8334. {
  8335. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
  8336. memberNode.init = init.value;
  8337. members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
  8338. break;
  8339. }
  8340. case "string":
  8341. {
  8342. this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
  8343. memberNode.init = init.value;
  8344. members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
  8345. break;
  8346. }
  8347. case "invalid":
  8348. {
  8349. throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
  8350. }
  8351. case "none":
  8352. {
  8353. switch (explicitType) {
  8354. case "boolean":
  8355. this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
  8356. break;
  8357. case "number":
  8358. this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
  8359. break;
  8360. default:
  8361. members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
  8362. }
  8363. }
  8364. }
  8365. if (!this.match(8)) {
  8366. this.expect(12);
  8367. }
  8368. }
  8369. return {
  8370. members,
  8371. hasUnknownMembers
  8372. };
  8373. }
  8374. flowEnumStringMembers(initializedMembers, defaultedMembers, {
  8375. enumName
  8376. }) {
  8377. if (initializedMembers.length === 0) {
  8378. return defaultedMembers;
  8379. } else if (defaultedMembers.length === 0) {
  8380. return initializedMembers;
  8381. } else if (defaultedMembers.length > initializedMembers.length) {
  8382. for (const member of initializedMembers) {
  8383. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8384. enumName
  8385. });
  8386. }
  8387. return defaultedMembers;
  8388. } else {
  8389. for (const member of defaultedMembers) {
  8390. this.flowEnumErrorStringMemberInconsistentlyInitialized(member, {
  8391. enumName
  8392. });
  8393. }
  8394. return initializedMembers;
  8395. }
  8396. }
  8397. flowEnumParseExplicitType({
  8398. enumName
  8399. }) {
  8400. if (!this.eatContextual(102)) return null;
  8401. if (!tokenIsIdentifier(this.state.type)) {
  8402. throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, {
  8403. enumName
  8404. });
  8405. }
  8406. const {
  8407. value
  8408. } = this.state;
  8409. this.next();
  8410. if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
  8411. this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, {
  8412. enumName,
  8413. invalidEnumType: value
  8414. });
  8415. }
  8416. return value;
  8417. }
  8418. flowEnumBody(node, id) {
  8419. const enumName = id.name;
  8420. const nameLoc = id.loc.start;
  8421. const explicitType = this.flowEnumParseExplicitType({
  8422. enumName
  8423. });
  8424. this.expect(5);
  8425. const {
  8426. members,
  8427. hasUnknownMembers
  8428. } = this.flowEnumMembers({
  8429. enumName,
  8430. explicitType
  8431. });
  8432. node.hasUnknownMembers = hasUnknownMembers;
  8433. switch (explicitType) {
  8434. case "boolean":
  8435. node.explicitType = true;
  8436. node.members = members.booleanMembers;
  8437. this.expect(8);
  8438. return this.finishNode(node, "EnumBooleanBody");
  8439. case "number":
  8440. node.explicitType = true;
  8441. node.members = members.numberMembers;
  8442. this.expect(8);
  8443. return this.finishNode(node, "EnumNumberBody");
  8444. case "string":
  8445. node.explicitType = true;
  8446. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8447. enumName
  8448. });
  8449. this.expect(8);
  8450. return this.finishNode(node, "EnumStringBody");
  8451. case "symbol":
  8452. node.members = members.defaultedMembers;
  8453. this.expect(8);
  8454. return this.finishNode(node, "EnumSymbolBody");
  8455. default:
  8456. {
  8457. const empty = () => {
  8458. node.members = [];
  8459. this.expect(8);
  8460. return this.finishNode(node, "EnumStringBody");
  8461. };
  8462. node.explicitType = false;
  8463. const boolsLen = members.booleanMembers.length;
  8464. const numsLen = members.numberMembers.length;
  8465. const strsLen = members.stringMembers.length;
  8466. const defaultedLen = members.defaultedMembers.length;
  8467. if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
  8468. return empty();
  8469. } else if (!boolsLen && !numsLen) {
  8470. node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
  8471. enumName
  8472. });
  8473. this.expect(8);
  8474. return this.finishNode(node, "EnumStringBody");
  8475. } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
  8476. for (const member of members.defaultedMembers) {
  8477. this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
  8478. enumName,
  8479. memberName: member.id.name
  8480. });
  8481. }
  8482. node.members = members.booleanMembers;
  8483. this.expect(8);
  8484. return this.finishNode(node, "EnumBooleanBody");
  8485. } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
  8486. for (const member of members.defaultedMembers) {
  8487. this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, {
  8488. enumName,
  8489. memberName: member.id.name
  8490. });
  8491. }
  8492. node.members = members.numberMembers;
  8493. this.expect(8);
  8494. return this.finishNode(node, "EnumNumberBody");
  8495. } else {
  8496. this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, {
  8497. enumName
  8498. });
  8499. return empty();
  8500. }
  8501. }
  8502. }
  8503. }
  8504. flowParseEnumDeclaration(node) {
  8505. const id = this.parseIdentifier();
  8506. node.id = id;
  8507. node.body = this.flowEnumBody(this.startNode(), id);
  8508. return this.finishNode(node, "EnumDeclaration");
  8509. }
  8510. isLookaheadToken_lt() {
  8511. const next = this.nextTokenStart();
  8512. if (this.input.charCodeAt(next) === 60) {
  8513. const afterNext = this.input.charCodeAt(next + 1);
  8514. return afterNext !== 60 && afterNext !== 61;
  8515. }
  8516. return false;
  8517. }
  8518. maybeUnwrapTypeCastExpression(node) {
  8519. return node.type === "TypeCastExpression" ? node.expression : node;
  8520. }
  8521. };
  8522. const entities = {
  8523. __proto__: null,
  8524. quot: "\u0022",
  8525. amp: "&",
  8526. apos: "\u0027",
  8527. lt: "<",
  8528. gt: ">",
  8529. nbsp: "\u00A0",
  8530. iexcl: "\u00A1",
  8531. cent: "\u00A2",
  8532. pound: "\u00A3",
  8533. curren: "\u00A4",
  8534. yen: "\u00A5",
  8535. brvbar: "\u00A6",
  8536. sect: "\u00A7",
  8537. uml: "\u00A8",
  8538. copy: "\u00A9",
  8539. ordf: "\u00AA",
  8540. laquo: "\u00AB",
  8541. not: "\u00AC",
  8542. shy: "\u00AD",
  8543. reg: "\u00AE",
  8544. macr: "\u00AF",
  8545. deg: "\u00B0",
  8546. plusmn: "\u00B1",
  8547. sup2: "\u00B2",
  8548. sup3: "\u00B3",
  8549. acute: "\u00B4",
  8550. micro: "\u00B5",
  8551. para: "\u00B6",
  8552. middot: "\u00B7",
  8553. cedil: "\u00B8",
  8554. sup1: "\u00B9",
  8555. ordm: "\u00BA",
  8556. raquo: "\u00BB",
  8557. frac14: "\u00BC",
  8558. frac12: "\u00BD",
  8559. frac34: "\u00BE",
  8560. iquest: "\u00BF",
  8561. Agrave: "\u00C0",
  8562. Aacute: "\u00C1",
  8563. Acirc: "\u00C2",
  8564. Atilde: "\u00C3",
  8565. Auml: "\u00C4",
  8566. Aring: "\u00C5",
  8567. AElig: "\u00C6",
  8568. Ccedil: "\u00C7",
  8569. Egrave: "\u00C8",
  8570. Eacute: "\u00C9",
  8571. Ecirc: "\u00CA",
  8572. Euml: "\u00CB",
  8573. Igrave: "\u00CC",
  8574. Iacute: "\u00CD",
  8575. Icirc: "\u00CE",
  8576. Iuml: "\u00CF",
  8577. ETH: "\u00D0",
  8578. Ntilde: "\u00D1",
  8579. Ograve: "\u00D2",
  8580. Oacute: "\u00D3",
  8581. Ocirc: "\u00D4",
  8582. Otilde: "\u00D5",
  8583. Ouml: "\u00D6",
  8584. times: "\u00D7",
  8585. Oslash: "\u00D8",
  8586. Ugrave: "\u00D9",
  8587. Uacute: "\u00DA",
  8588. Ucirc: "\u00DB",
  8589. Uuml: "\u00DC",
  8590. Yacute: "\u00DD",
  8591. THORN: "\u00DE",
  8592. szlig: "\u00DF",
  8593. agrave: "\u00E0",
  8594. aacute: "\u00E1",
  8595. acirc: "\u00E2",
  8596. atilde: "\u00E3",
  8597. auml: "\u00E4",
  8598. aring: "\u00E5",
  8599. aelig: "\u00E6",
  8600. ccedil: "\u00E7",
  8601. egrave: "\u00E8",
  8602. eacute: "\u00E9",
  8603. ecirc: "\u00EA",
  8604. euml: "\u00EB",
  8605. igrave: "\u00EC",
  8606. iacute: "\u00ED",
  8607. icirc: "\u00EE",
  8608. iuml: "\u00EF",
  8609. eth: "\u00F0",
  8610. ntilde: "\u00F1",
  8611. ograve: "\u00F2",
  8612. oacute: "\u00F3",
  8613. ocirc: "\u00F4",
  8614. otilde: "\u00F5",
  8615. ouml: "\u00F6",
  8616. divide: "\u00F7",
  8617. oslash: "\u00F8",
  8618. ugrave: "\u00F9",
  8619. uacute: "\u00FA",
  8620. ucirc: "\u00FB",
  8621. uuml: "\u00FC",
  8622. yacute: "\u00FD",
  8623. thorn: "\u00FE",
  8624. yuml: "\u00FF",
  8625. OElig: "\u0152",
  8626. oelig: "\u0153",
  8627. Scaron: "\u0160",
  8628. scaron: "\u0161",
  8629. Yuml: "\u0178",
  8630. fnof: "\u0192",
  8631. circ: "\u02C6",
  8632. tilde: "\u02DC",
  8633. Alpha: "\u0391",
  8634. Beta: "\u0392",
  8635. Gamma: "\u0393",
  8636. Delta: "\u0394",
  8637. Epsilon: "\u0395",
  8638. Zeta: "\u0396",
  8639. Eta: "\u0397",
  8640. Theta: "\u0398",
  8641. Iota: "\u0399",
  8642. Kappa: "\u039A",
  8643. Lambda: "\u039B",
  8644. Mu: "\u039C",
  8645. Nu: "\u039D",
  8646. Xi: "\u039E",
  8647. Omicron: "\u039F",
  8648. Pi: "\u03A0",
  8649. Rho: "\u03A1",
  8650. Sigma: "\u03A3",
  8651. Tau: "\u03A4",
  8652. Upsilon: "\u03A5",
  8653. Phi: "\u03A6",
  8654. Chi: "\u03A7",
  8655. Psi: "\u03A8",
  8656. Omega: "\u03A9",
  8657. alpha: "\u03B1",
  8658. beta: "\u03B2",
  8659. gamma: "\u03B3",
  8660. delta: "\u03B4",
  8661. epsilon: "\u03B5",
  8662. zeta: "\u03B6",
  8663. eta: "\u03B7",
  8664. theta: "\u03B8",
  8665. iota: "\u03B9",
  8666. kappa: "\u03BA",
  8667. lambda: "\u03BB",
  8668. mu: "\u03BC",
  8669. nu: "\u03BD",
  8670. xi: "\u03BE",
  8671. omicron: "\u03BF",
  8672. pi: "\u03C0",
  8673. rho: "\u03C1",
  8674. sigmaf: "\u03C2",
  8675. sigma: "\u03C3",
  8676. tau: "\u03C4",
  8677. upsilon: "\u03C5",
  8678. phi: "\u03C6",
  8679. chi: "\u03C7",
  8680. psi: "\u03C8",
  8681. omega: "\u03C9",
  8682. thetasym: "\u03D1",
  8683. upsih: "\u03D2",
  8684. piv: "\u03D6",
  8685. ensp: "\u2002",
  8686. emsp: "\u2003",
  8687. thinsp: "\u2009",
  8688. zwnj: "\u200C",
  8689. zwj: "\u200D",
  8690. lrm: "\u200E",
  8691. rlm: "\u200F",
  8692. ndash: "\u2013",
  8693. mdash: "\u2014",
  8694. lsquo: "\u2018",
  8695. rsquo: "\u2019",
  8696. sbquo: "\u201A",
  8697. ldquo: "\u201C",
  8698. rdquo: "\u201D",
  8699. bdquo: "\u201E",
  8700. dagger: "\u2020",
  8701. Dagger: "\u2021",
  8702. bull: "\u2022",
  8703. hellip: "\u2026",
  8704. permil: "\u2030",
  8705. prime: "\u2032",
  8706. Prime: "\u2033",
  8707. lsaquo: "\u2039",
  8708. rsaquo: "\u203A",
  8709. oline: "\u203E",
  8710. frasl: "\u2044",
  8711. euro: "\u20AC",
  8712. image: "\u2111",
  8713. weierp: "\u2118",
  8714. real: "\u211C",
  8715. trade: "\u2122",
  8716. alefsym: "\u2135",
  8717. larr: "\u2190",
  8718. uarr: "\u2191",
  8719. rarr: "\u2192",
  8720. darr: "\u2193",
  8721. harr: "\u2194",
  8722. crarr: "\u21B5",
  8723. lArr: "\u21D0",
  8724. uArr: "\u21D1",
  8725. rArr: "\u21D2",
  8726. dArr: "\u21D3",
  8727. hArr: "\u21D4",
  8728. forall: "\u2200",
  8729. part: "\u2202",
  8730. exist: "\u2203",
  8731. empty: "\u2205",
  8732. nabla: "\u2207",
  8733. isin: "\u2208",
  8734. notin: "\u2209",
  8735. ni: "\u220B",
  8736. prod: "\u220F",
  8737. sum: "\u2211",
  8738. minus: "\u2212",
  8739. lowast: "\u2217",
  8740. radic: "\u221A",
  8741. prop: "\u221D",
  8742. infin: "\u221E",
  8743. ang: "\u2220",
  8744. and: "\u2227",
  8745. or: "\u2228",
  8746. cap: "\u2229",
  8747. cup: "\u222A",
  8748. int: "\u222B",
  8749. there4: "\u2234",
  8750. sim: "\u223C",
  8751. cong: "\u2245",
  8752. asymp: "\u2248",
  8753. ne: "\u2260",
  8754. equiv: "\u2261",
  8755. le: "\u2264",
  8756. ge: "\u2265",
  8757. sub: "\u2282",
  8758. sup: "\u2283",
  8759. nsub: "\u2284",
  8760. sube: "\u2286",
  8761. supe: "\u2287",
  8762. oplus: "\u2295",
  8763. otimes: "\u2297",
  8764. perp: "\u22A5",
  8765. sdot: "\u22C5",
  8766. lceil: "\u2308",
  8767. rceil: "\u2309",
  8768. lfloor: "\u230A",
  8769. rfloor: "\u230B",
  8770. lang: "\u2329",
  8771. rang: "\u232A",
  8772. loz: "\u25CA",
  8773. spades: "\u2660",
  8774. clubs: "\u2663",
  8775. hearts: "\u2665",
  8776. diams: "\u2666"
  8777. };
  8778. const JsxErrors = ParseErrorEnum`jsx`({
  8779. AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.",
  8780. MissingClosingTagElement: ({
  8781. openingTagName
  8782. }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`,
  8783. MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.",
  8784. UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
  8785. UnexpectedToken: ({
  8786. unexpected,
  8787. HTMLEntity
  8788. }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`,
  8789. UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.",
  8790. UnterminatedJsxContent: "Unterminated JSX contents.",
  8791. UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"
  8792. });
  8793. function isFragment(object) {
  8794. return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
  8795. }
  8796. function getQualifiedJSXName(object) {
  8797. if (object.type === "JSXIdentifier") {
  8798. return object.name;
  8799. }
  8800. if (object.type === "JSXNamespacedName") {
  8801. return object.namespace.name + ":" + object.name.name;
  8802. }
  8803. if (object.type === "JSXMemberExpression") {
  8804. return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
  8805. }
  8806. throw new Error("Node had unexpected type: " + object.type);
  8807. }
  8808. var jsx = superClass => class JSXParserMixin extends superClass {
  8809. jsxReadToken() {
  8810. let out = "";
  8811. let chunkStart = this.state.pos;
  8812. for (;;) {
  8813. if (this.state.pos >= this.length) {
  8814. throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc);
  8815. }
  8816. const ch = this.input.charCodeAt(this.state.pos);
  8817. switch (ch) {
  8818. case 60:
  8819. case 123:
  8820. if (this.state.pos === this.state.start) {
  8821. if (ch === 60 && this.state.canStartJSXElement) {
  8822. ++this.state.pos;
  8823. this.finishToken(142);
  8824. } else {
  8825. super.getTokenFromCode(ch);
  8826. }
  8827. return;
  8828. }
  8829. out += this.input.slice(chunkStart, this.state.pos);
  8830. this.finishToken(141, out);
  8831. return;
  8832. case 38:
  8833. out += this.input.slice(chunkStart, this.state.pos);
  8834. out += this.jsxReadEntity();
  8835. chunkStart = this.state.pos;
  8836. break;
  8837. case 62:
  8838. case 125:
  8839. default:
  8840. if (isNewLine(ch)) {
  8841. out += this.input.slice(chunkStart, this.state.pos);
  8842. out += this.jsxReadNewLine(true);
  8843. chunkStart = this.state.pos;
  8844. } else {
  8845. ++this.state.pos;
  8846. }
  8847. }
  8848. }
  8849. }
  8850. jsxReadNewLine(normalizeCRLF) {
  8851. const ch = this.input.charCodeAt(this.state.pos);
  8852. let out;
  8853. ++this.state.pos;
  8854. if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
  8855. ++this.state.pos;
  8856. out = normalizeCRLF ? "\n" : "\r\n";
  8857. } else {
  8858. out = String.fromCharCode(ch);
  8859. }
  8860. ++this.state.curLine;
  8861. this.state.lineStart = this.state.pos;
  8862. return out;
  8863. }
  8864. jsxReadString(quote) {
  8865. let out = "";
  8866. let chunkStart = ++this.state.pos;
  8867. for (;;) {
  8868. if (this.state.pos >= this.length) {
  8869. throw this.raise(Errors.UnterminatedString, this.state.startLoc);
  8870. }
  8871. const ch = this.input.charCodeAt(this.state.pos);
  8872. if (ch === quote) break;
  8873. if (ch === 38) {
  8874. out += this.input.slice(chunkStart, this.state.pos);
  8875. out += this.jsxReadEntity();
  8876. chunkStart = this.state.pos;
  8877. } else if (isNewLine(ch)) {
  8878. out += this.input.slice(chunkStart, this.state.pos);
  8879. out += this.jsxReadNewLine(false);
  8880. chunkStart = this.state.pos;
  8881. } else {
  8882. ++this.state.pos;
  8883. }
  8884. }
  8885. out += this.input.slice(chunkStart, this.state.pos++);
  8886. this.finishToken(133, out);
  8887. }
  8888. jsxReadEntity() {
  8889. const startPos = ++this.state.pos;
  8890. if (this.codePointAtPos(this.state.pos) === 35) {
  8891. ++this.state.pos;
  8892. let radix = 10;
  8893. if (this.codePointAtPos(this.state.pos) === 120) {
  8894. radix = 16;
  8895. ++this.state.pos;
  8896. }
  8897. const codePoint = this.readInt(radix, undefined, false, "bail");
  8898. if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) {
  8899. ++this.state.pos;
  8900. return String.fromCodePoint(codePoint);
  8901. }
  8902. } else {
  8903. let count = 0;
  8904. let semi = false;
  8905. while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) === 59)) {
  8906. ++this.state.pos;
  8907. }
  8908. if (semi) {
  8909. const desc = this.input.slice(startPos, this.state.pos);
  8910. const entity = entities[desc];
  8911. ++this.state.pos;
  8912. if (entity) {
  8913. return entity;
  8914. }
  8915. }
  8916. }
  8917. this.state.pos = startPos;
  8918. return "&";
  8919. }
  8920. jsxReadWord() {
  8921. let ch;
  8922. const start = this.state.pos;
  8923. do {
  8924. ch = this.input.charCodeAt(++this.state.pos);
  8925. } while (isIdentifierChar(ch) || ch === 45);
  8926. this.finishToken(140, this.input.slice(start, this.state.pos));
  8927. }
  8928. jsxParseIdentifier() {
  8929. const node = this.startNode();
  8930. if (this.match(140)) {
  8931. node.name = this.state.value;
  8932. } else if (tokenIsKeyword(this.state.type)) {
  8933. node.name = tokenLabelName(this.state.type);
  8934. } else {
  8935. this.unexpected();
  8936. }
  8937. this.next();
  8938. return this.finishNode(node, "JSXIdentifier");
  8939. }
  8940. jsxParseNamespacedName() {
  8941. const startLoc = this.state.startLoc;
  8942. const name = this.jsxParseIdentifier();
  8943. if (!this.eat(14)) return name;
  8944. const node = this.startNodeAt(startLoc);
  8945. node.namespace = name;
  8946. node.name = this.jsxParseIdentifier();
  8947. return this.finishNode(node, "JSXNamespacedName");
  8948. }
  8949. jsxParseElementName() {
  8950. const startLoc = this.state.startLoc;
  8951. let node = this.jsxParseNamespacedName();
  8952. if (node.type === "JSXNamespacedName") {
  8953. return node;
  8954. }
  8955. while (this.eat(16)) {
  8956. const newNode = this.startNodeAt(startLoc);
  8957. newNode.object = node;
  8958. newNode.property = this.jsxParseIdentifier();
  8959. node = this.finishNode(newNode, "JSXMemberExpression");
  8960. }
  8961. return node;
  8962. }
  8963. jsxParseAttributeValue() {
  8964. let node;
  8965. switch (this.state.type) {
  8966. case 5:
  8967. node = this.startNode();
  8968. this.setContext(types$1.brace);
  8969. this.next();
  8970. node = this.jsxParseExpressionContainer(node, types$1.j_oTag);
  8971. if (node.expression.type === "JSXEmptyExpression") {
  8972. this.raise(JsxErrors.AttributeIsEmpty, node);
  8973. }
  8974. return node;
  8975. case 142:
  8976. case 133:
  8977. return this.parseExprAtom();
  8978. default:
  8979. throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
  8980. }
  8981. }
  8982. jsxParseEmptyExpression() {
  8983. const node = this.startNodeAt(this.state.lastTokEndLoc);
  8984. return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
  8985. }
  8986. jsxParseSpreadChild(node) {
  8987. this.next();
  8988. node.expression = this.parseExpression();
  8989. this.setContext(types$1.j_expr);
  8990. this.state.canStartJSXElement = true;
  8991. this.expect(8);
  8992. return this.finishNode(node, "JSXSpreadChild");
  8993. }
  8994. jsxParseExpressionContainer(node, previousContext) {
  8995. if (this.match(8)) {
  8996. node.expression = this.jsxParseEmptyExpression();
  8997. } else {
  8998. const expression = this.parseExpression();
  8999. node.expression = expression;
  9000. }
  9001. this.setContext(previousContext);
  9002. this.state.canStartJSXElement = true;
  9003. this.expect(8);
  9004. return this.finishNode(node, "JSXExpressionContainer");
  9005. }
  9006. jsxParseAttribute() {
  9007. const node = this.startNode();
  9008. if (this.match(5)) {
  9009. this.setContext(types$1.brace);
  9010. this.next();
  9011. this.expect(21);
  9012. node.argument = this.parseMaybeAssignAllowIn();
  9013. this.setContext(types$1.j_oTag);
  9014. this.state.canStartJSXElement = true;
  9015. this.expect(8);
  9016. return this.finishNode(node, "JSXSpreadAttribute");
  9017. }
  9018. node.name = this.jsxParseNamespacedName();
  9019. node.value = this.eat(29) ? this.jsxParseAttributeValue() : null;
  9020. return this.finishNode(node, "JSXAttribute");
  9021. }
  9022. jsxParseOpeningElementAt(startLoc) {
  9023. const node = this.startNodeAt(startLoc);
  9024. if (this.eat(143)) {
  9025. return this.finishNode(node, "JSXOpeningFragment");
  9026. }
  9027. node.name = this.jsxParseElementName();
  9028. return this.jsxParseOpeningElementAfterName(node);
  9029. }
  9030. jsxParseOpeningElementAfterName(node) {
  9031. const attributes = [];
  9032. while (!this.match(56) && !this.match(143)) {
  9033. attributes.push(this.jsxParseAttribute());
  9034. }
  9035. node.attributes = attributes;
  9036. node.selfClosing = this.eat(56);
  9037. this.expect(143);
  9038. return this.finishNode(node, "JSXOpeningElement");
  9039. }
  9040. jsxParseClosingElementAt(startLoc) {
  9041. const node = this.startNodeAt(startLoc);
  9042. if (this.eat(143)) {
  9043. return this.finishNode(node, "JSXClosingFragment");
  9044. }
  9045. node.name = this.jsxParseElementName();
  9046. this.expect(143);
  9047. return this.finishNode(node, "JSXClosingElement");
  9048. }
  9049. jsxParseElementAt(startLoc) {
  9050. const node = this.startNodeAt(startLoc);
  9051. const children = [];
  9052. const openingElement = this.jsxParseOpeningElementAt(startLoc);
  9053. let closingElement = null;
  9054. if (!openingElement.selfClosing) {
  9055. contents: for (;;) {
  9056. switch (this.state.type) {
  9057. case 142:
  9058. startLoc = this.state.startLoc;
  9059. this.next();
  9060. if (this.eat(56)) {
  9061. closingElement = this.jsxParseClosingElementAt(startLoc);
  9062. break contents;
  9063. }
  9064. children.push(this.jsxParseElementAt(startLoc));
  9065. break;
  9066. case 141:
  9067. children.push(this.parseLiteral(this.state.value, "JSXText"));
  9068. break;
  9069. case 5:
  9070. {
  9071. const node = this.startNode();
  9072. this.setContext(types$1.brace);
  9073. this.next();
  9074. if (this.match(21)) {
  9075. children.push(this.jsxParseSpreadChild(node));
  9076. } else {
  9077. children.push(this.jsxParseExpressionContainer(node, types$1.j_expr));
  9078. }
  9079. break;
  9080. }
  9081. default:
  9082. this.unexpected();
  9083. }
  9084. }
  9085. if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
  9086. this.raise(JsxErrors.MissingClosingTagFragment, closingElement);
  9087. } else if (!isFragment(openingElement) && isFragment(closingElement)) {
  9088. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9089. openingTagName: getQualifiedJSXName(openingElement.name)
  9090. });
  9091. } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
  9092. if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
  9093. this.raise(JsxErrors.MissingClosingTagElement, closingElement, {
  9094. openingTagName: getQualifiedJSXName(openingElement.name)
  9095. });
  9096. }
  9097. }
  9098. }
  9099. if (isFragment(openingElement)) {
  9100. node.openingFragment = openingElement;
  9101. node.closingFragment = closingElement;
  9102. } else {
  9103. node.openingElement = openingElement;
  9104. node.closingElement = closingElement;
  9105. }
  9106. node.children = children;
  9107. if (this.match(47)) {
  9108. throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc);
  9109. }
  9110. return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
  9111. }
  9112. jsxParseElement() {
  9113. const startLoc = this.state.startLoc;
  9114. this.next();
  9115. return this.jsxParseElementAt(startLoc);
  9116. }
  9117. setContext(newContext) {
  9118. const {
  9119. context
  9120. } = this.state;
  9121. context[context.length - 1] = newContext;
  9122. }
  9123. parseExprAtom(refExpressionErrors) {
  9124. if (this.match(142)) {
  9125. return this.jsxParseElement();
  9126. } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
  9127. this.replaceToken(142);
  9128. return this.jsxParseElement();
  9129. } else {
  9130. return super.parseExprAtom(refExpressionErrors);
  9131. }
  9132. }
  9133. skipSpace() {
  9134. const curContext = this.curContext();
  9135. if (!curContext.preserveSpace) super.skipSpace();
  9136. }
  9137. getTokenFromCode(code) {
  9138. const context = this.curContext();
  9139. if (context === types$1.j_expr) {
  9140. this.jsxReadToken();
  9141. return;
  9142. }
  9143. if (context === types$1.j_oTag || context === types$1.j_cTag) {
  9144. if (isIdentifierStart(code)) {
  9145. this.jsxReadWord();
  9146. return;
  9147. }
  9148. if (code === 62) {
  9149. ++this.state.pos;
  9150. this.finishToken(143);
  9151. return;
  9152. }
  9153. if ((code === 34 || code === 39) && context === types$1.j_oTag) {
  9154. this.jsxReadString(code);
  9155. return;
  9156. }
  9157. }
  9158. if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
  9159. ++this.state.pos;
  9160. this.finishToken(142);
  9161. return;
  9162. }
  9163. super.getTokenFromCode(code);
  9164. }
  9165. updateContext(prevType) {
  9166. const {
  9167. context,
  9168. type
  9169. } = this.state;
  9170. if (type === 56 && prevType === 142) {
  9171. context.splice(-2, 2, types$1.j_cTag);
  9172. this.state.canStartJSXElement = false;
  9173. } else if (type === 142) {
  9174. context.push(types$1.j_oTag);
  9175. } else if (type === 143) {
  9176. const out = context[context.length - 1];
  9177. if (out === types$1.j_oTag && prevType === 56 || out === types$1.j_cTag) {
  9178. context.pop();
  9179. this.state.canStartJSXElement = context[context.length - 1] === types$1.j_expr;
  9180. } else {
  9181. this.setContext(types$1.j_expr);
  9182. this.state.canStartJSXElement = true;
  9183. }
  9184. } else {
  9185. this.state.canStartJSXElement = tokenComesBeforeExpression(type);
  9186. }
  9187. }
  9188. };
  9189. class TypeScriptScope extends Scope {
  9190. constructor(...args) {
  9191. super(...args);
  9192. this.tsNames = new Map();
  9193. }
  9194. }
  9195. class TypeScriptScopeHandler extends ScopeHandler {
  9196. constructor(...args) {
  9197. super(...args);
  9198. this.importsStack = [];
  9199. }
  9200. createScope(flags) {
  9201. this.importsStack.push(new Set());
  9202. return new TypeScriptScope(flags);
  9203. }
  9204. enter(flags) {
  9205. if (flags === 256) {
  9206. this.importsStack.push(new Set());
  9207. }
  9208. super.enter(flags);
  9209. }
  9210. exit() {
  9211. const flags = super.exit();
  9212. if (flags === 256) {
  9213. this.importsStack.pop();
  9214. }
  9215. return flags;
  9216. }
  9217. hasImport(name, allowShadow) {
  9218. const len = this.importsStack.length;
  9219. if (this.importsStack[len - 1].has(name)) {
  9220. return true;
  9221. }
  9222. if (!allowShadow && len > 1) {
  9223. for (let i = 0; i < len - 1; i++) {
  9224. if (this.importsStack[i].has(name)) return true;
  9225. }
  9226. }
  9227. return false;
  9228. }
  9229. declareName(name, bindingType, loc) {
  9230. if (bindingType & 4096) {
  9231. if (this.hasImport(name, true)) {
  9232. this.parser.raise(Errors.VarRedeclaration, loc, {
  9233. identifierName: name
  9234. });
  9235. }
  9236. this.importsStack[this.importsStack.length - 1].add(name);
  9237. return;
  9238. }
  9239. const scope = this.currentScope();
  9240. let type = scope.tsNames.get(name) || 0;
  9241. if (bindingType & 1024) {
  9242. this.maybeExportDefined(scope, name);
  9243. scope.tsNames.set(name, type | 16);
  9244. return;
  9245. }
  9246. super.declareName(name, bindingType, loc);
  9247. if (bindingType & 2) {
  9248. if (!(bindingType & 1)) {
  9249. this.checkRedeclarationInScope(scope, name, bindingType, loc);
  9250. this.maybeExportDefined(scope, name);
  9251. }
  9252. type = type | 1;
  9253. }
  9254. if (bindingType & 256) {
  9255. type = type | 2;
  9256. }
  9257. if (bindingType & 512) {
  9258. type = type | 4;
  9259. }
  9260. if (bindingType & 128) {
  9261. type = type | 8;
  9262. }
  9263. if (type) scope.tsNames.set(name, type);
  9264. }
  9265. isRedeclaredInScope(scope, name, bindingType) {
  9266. const type = scope.tsNames.get(name);
  9267. if ((type & 2) > 0) {
  9268. if (bindingType & 256) {
  9269. const isConst = !!(bindingType & 512);
  9270. const wasConst = (type & 4) > 0;
  9271. return isConst !== wasConst;
  9272. }
  9273. return true;
  9274. }
  9275. if (bindingType & 128 && (type & 8) > 0) {
  9276. if (scope.names.get(name) & 2) {
  9277. return !!(bindingType & 1);
  9278. } else {
  9279. return false;
  9280. }
  9281. }
  9282. if (bindingType & 2 && (type & 1) > 0) {
  9283. return true;
  9284. }
  9285. return super.isRedeclaredInScope(scope, name, bindingType);
  9286. }
  9287. checkLocalExport(id) {
  9288. const {
  9289. name
  9290. } = id;
  9291. if (this.hasImport(name)) return;
  9292. const len = this.scopeStack.length;
  9293. for (let i = len - 1; i >= 0; i--) {
  9294. const scope = this.scopeStack[i];
  9295. const type = scope.tsNames.get(name);
  9296. if ((type & 1) > 0 || (type & 16) > 0) {
  9297. return;
  9298. }
  9299. }
  9300. super.checkLocalExport(id);
  9301. }
  9302. }
  9303. const getOwn$1 = (object, key) => hasOwnProperty.call(object, key) && object[key];
  9304. const unwrapParenthesizedExpression = node => {
  9305. return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
  9306. };
  9307. class LValParser extends NodeUtils {
  9308. toAssignable(node, isLHS = false) {
  9309. var _node$extra, _node$extra3;
  9310. let parenthesized = undefined;
  9311. if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
  9312. parenthesized = unwrapParenthesizedExpression(node);
  9313. if (isLHS) {
  9314. if (parenthesized.type === "Identifier") {
  9315. this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
  9316. } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
  9317. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9318. }
  9319. } else {
  9320. this.raise(Errors.InvalidParenthesizedAssignment, node);
  9321. }
  9322. }
  9323. switch (node.type) {
  9324. case "Identifier":
  9325. case "ObjectPattern":
  9326. case "ArrayPattern":
  9327. case "AssignmentPattern":
  9328. case "RestElement":
  9329. break;
  9330. case "ObjectExpression":
  9331. node.type = "ObjectPattern";
  9332. for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
  9333. var _node$extra2;
  9334. const prop = node.properties[i];
  9335. const isLast = i === last;
  9336. this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
  9337. if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
  9338. this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc);
  9339. }
  9340. }
  9341. break;
  9342. case "ObjectProperty":
  9343. {
  9344. const {
  9345. key,
  9346. value
  9347. } = node;
  9348. if (this.isPrivateName(key)) {
  9349. this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
  9350. }
  9351. this.toAssignable(value, isLHS);
  9352. break;
  9353. }
  9354. case "SpreadElement":
  9355. {
  9356. throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
  9357. }
  9358. case "ArrayExpression":
  9359. node.type = "ArrayPattern";
  9360. this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
  9361. break;
  9362. case "AssignmentExpression":
  9363. if (node.operator !== "=") {
  9364. this.raise(Errors.MissingEqInAssignment, node.left.loc.end);
  9365. }
  9366. node.type = "AssignmentPattern";
  9367. delete node.operator;
  9368. this.toAssignable(node.left, isLHS);
  9369. break;
  9370. case "ParenthesizedExpression":
  9371. this.toAssignable(parenthesized, isLHS);
  9372. break;
  9373. }
  9374. }
  9375. toAssignableObjectExpressionProp(prop, isLast, isLHS) {
  9376. if (prop.type === "ObjectMethod") {
  9377. this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key);
  9378. } else if (prop.type === "SpreadElement") {
  9379. prop.type = "RestElement";
  9380. const arg = prop.argument;
  9381. this.checkToRestConversion(arg, false);
  9382. this.toAssignable(arg, isLHS);
  9383. if (!isLast) {
  9384. this.raise(Errors.RestTrailingComma, prop);
  9385. }
  9386. } else {
  9387. this.toAssignable(prop, isLHS);
  9388. }
  9389. }
  9390. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  9391. const end = exprList.length - 1;
  9392. for (let i = 0; i <= end; i++) {
  9393. const elt = exprList[i];
  9394. if (!elt) continue;
  9395. if (elt.type === "SpreadElement") {
  9396. elt.type = "RestElement";
  9397. const arg = elt.argument;
  9398. this.checkToRestConversion(arg, true);
  9399. this.toAssignable(arg, isLHS);
  9400. } else {
  9401. this.toAssignable(elt, isLHS);
  9402. }
  9403. if (elt.type === "RestElement") {
  9404. if (i < end) {
  9405. this.raise(Errors.RestTrailingComma, elt);
  9406. } else if (trailingCommaLoc) {
  9407. this.raise(Errors.RestTrailingComma, trailingCommaLoc);
  9408. }
  9409. }
  9410. }
  9411. }
  9412. isAssignable(node, isBinding) {
  9413. switch (node.type) {
  9414. case "Identifier":
  9415. case "ObjectPattern":
  9416. case "ArrayPattern":
  9417. case "AssignmentPattern":
  9418. case "RestElement":
  9419. return true;
  9420. case "ObjectExpression":
  9421. {
  9422. const last = node.properties.length - 1;
  9423. return node.properties.every((prop, i) => {
  9424. return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop);
  9425. });
  9426. }
  9427. case "ObjectProperty":
  9428. return this.isAssignable(node.value);
  9429. case "SpreadElement":
  9430. return this.isAssignable(node.argument);
  9431. case "ArrayExpression":
  9432. return node.elements.every(element => element === null || this.isAssignable(element));
  9433. case "AssignmentExpression":
  9434. return node.operator === "=";
  9435. case "ParenthesizedExpression":
  9436. return this.isAssignable(node.expression);
  9437. case "MemberExpression":
  9438. case "OptionalMemberExpression":
  9439. return !isBinding;
  9440. default:
  9441. return false;
  9442. }
  9443. }
  9444. toReferencedList(exprList, isParenthesizedExpr) {
  9445. return exprList;
  9446. }
  9447. toReferencedListDeep(exprList, isParenthesizedExpr) {
  9448. this.toReferencedList(exprList, isParenthesizedExpr);
  9449. for (const expr of exprList) {
  9450. if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
  9451. this.toReferencedListDeep(expr.elements);
  9452. }
  9453. }
  9454. }
  9455. parseSpread(refExpressionErrors) {
  9456. const node = this.startNode();
  9457. this.next();
  9458. node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined);
  9459. return this.finishNode(node, "SpreadElement");
  9460. }
  9461. parseRestBinding() {
  9462. const node = this.startNode();
  9463. this.next();
  9464. node.argument = this.parseBindingAtom();
  9465. return this.finishNode(node, "RestElement");
  9466. }
  9467. parseBindingAtom() {
  9468. switch (this.state.type) {
  9469. case 0:
  9470. {
  9471. const node = this.startNode();
  9472. this.next();
  9473. node.elements = this.parseBindingList(3, 93, 1);
  9474. return this.finishNode(node, "ArrayPattern");
  9475. }
  9476. case 5:
  9477. return this.parseObjectLike(8, true);
  9478. }
  9479. return this.parseIdentifier();
  9480. }
  9481. parseBindingList(close, closeCharCode, flags) {
  9482. const allowEmpty = flags & 1;
  9483. const elts = [];
  9484. let first = true;
  9485. while (!this.eat(close)) {
  9486. if (first) {
  9487. first = false;
  9488. } else {
  9489. this.expect(12);
  9490. }
  9491. if (allowEmpty && this.match(12)) {
  9492. elts.push(null);
  9493. } else if (this.eat(close)) {
  9494. break;
  9495. } else if (this.match(21)) {
  9496. elts.push(this.parseAssignableListItemTypes(this.parseRestBinding(), flags));
  9497. if (!this.checkCommaAfterRest(closeCharCode)) {
  9498. this.expect(close);
  9499. break;
  9500. }
  9501. } else {
  9502. const decorators = [];
  9503. if (this.match(26) && this.hasPlugin("decorators")) {
  9504. this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc);
  9505. }
  9506. while (this.match(26)) {
  9507. decorators.push(this.parseDecorator());
  9508. }
  9509. elts.push(this.parseAssignableListItem(flags, decorators));
  9510. }
  9511. }
  9512. return elts;
  9513. }
  9514. parseBindingRestProperty(prop) {
  9515. this.next();
  9516. prop.argument = this.parseIdentifier();
  9517. this.checkCommaAfterRest(125);
  9518. return this.finishNode(prop, "RestElement");
  9519. }
  9520. parseBindingProperty() {
  9521. const {
  9522. type,
  9523. startLoc
  9524. } = this.state;
  9525. if (type === 21) {
  9526. return this.parseBindingRestProperty(this.startNode());
  9527. }
  9528. const prop = this.startNode();
  9529. if (type === 138) {
  9530. this.expectPlugin("destructuringPrivate", startLoc);
  9531. this.classScope.usePrivateName(this.state.value, startLoc);
  9532. prop.key = this.parsePrivateName();
  9533. } else {
  9534. this.parsePropertyName(prop);
  9535. }
  9536. prop.method = false;
  9537. return this.parseObjPropValue(prop, startLoc, false, false, true, false);
  9538. }
  9539. parseAssignableListItem(flags, decorators) {
  9540. const left = this.parseMaybeDefault();
  9541. this.parseAssignableListItemTypes(left, flags);
  9542. const elt = this.parseMaybeDefault(left.loc.start, left);
  9543. if (decorators.length) {
  9544. left.decorators = decorators;
  9545. }
  9546. return elt;
  9547. }
  9548. parseAssignableListItemTypes(param, flags) {
  9549. return param;
  9550. }
  9551. parseMaybeDefault(startLoc, left) {
  9552. var _startLoc, _left;
  9553. (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc;
  9554. left = (_left = left) != null ? _left : this.parseBindingAtom();
  9555. if (!this.eat(29)) return left;
  9556. const node = this.startNodeAt(startLoc);
  9557. node.left = left;
  9558. node.right = this.parseMaybeAssignAllowIn();
  9559. return this.finishNode(node, "AssignmentPattern");
  9560. }
  9561. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  9562. return getOwn$1({
  9563. AssignmentPattern: "left",
  9564. RestElement: "argument",
  9565. ObjectProperty: "value",
  9566. ParenthesizedExpression: "expression",
  9567. ArrayPattern: "elements",
  9568. ObjectPattern: "properties"
  9569. }, type);
  9570. }
  9571. isOptionalMemberExpression(expression) {
  9572. return expression.type === "OptionalMemberExpression";
  9573. }
  9574. checkLVal(expression, {
  9575. in: ancestor,
  9576. binding = 64,
  9577. checkClashes = false,
  9578. strictModeChanged = false,
  9579. hasParenthesizedAncestor = false
  9580. }) {
  9581. var _expression$extra;
  9582. const type = expression.type;
  9583. if (this.isObjectMethod(expression)) return;
  9584. const isOptionalMemberExpression = this.isOptionalMemberExpression(expression);
  9585. if (isOptionalMemberExpression || type === "MemberExpression") {
  9586. if (isOptionalMemberExpression) {
  9587. this.expectPlugin("optionalChainingAssign", expression.loc.start);
  9588. if (ancestor.type !== "AssignmentExpression") {
  9589. this.raise(Errors.InvalidLhsOptionalChaining, expression, {
  9590. ancestor
  9591. });
  9592. }
  9593. }
  9594. if (binding !== 64) {
  9595. this.raise(Errors.InvalidPropertyBindingPattern, expression);
  9596. }
  9597. return;
  9598. }
  9599. if (type === "Identifier") {
  9600. this.checkIdentifier(expression, binding, strictModeChanged);
  9601. const {
  9602. name
  9603. } = expression;
  9604. if (checkClashes) {
  9605. if (checkClashes.has(name)) {
  9606. this.raise(Errors.ParamDupe, expression);
  9607. } else {
  9608. checkClashes.add(name);
  9609. }
  9610. }
  9611. return;
  9612. }
  9613. const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
  9614. if (validity === true) return;
  9615. if (validity === false) {
  9616. const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
  9617. this.raise(ParseErrorClass, expression, {
  9618. ancestor
  9619. });
  9620. return;
  9621. }
  9622. const [key, isParenthesizedExpression] = Array.isArray(validity) ? validity : [validity, type === "ParenthesizedExpression"];
  9623. const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? {
  9624. type
  9625. } : ancestor;
  9626. for (const child of [].concat(expression[key])) {
  9627. if (child) {
  9628. this.checkLVal(child, {
  9629. in: nextAncestor,
  9630. binding,
  9631. checkClashes,
  9632. strictModeChanged,
  9633. hasParenthesizedAncestor: isParenthesizedExpression
  9634. });
  9635. }
  9636. }
  9637. }
  9638. checkIdentifier(at, bindingType, strictModeChanged = false) {
  9639. if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) {
  9640. if (bindingType === 64) {
  9641. this.raise(Errors.StrictEvalArguments, at, {
  9642. referenceName: at.name
  9643. });
  9644. } else {
  9645. this.raise(Errors.StrictEvalArgumentsBinding, at, {
  9646. bindingName: at.name
  9647. });
  9648. }
  9649. }
  9650. if (bindingType & 8192 && at.name === "let") {
  9651. this.raise(Errors.LetInLexicalBinding, at);
  9652. }
  9653. if (!(bindingType & 64)) {
  9654. this.declareNameFromIdentifier(at, bindingType);
  9655. }
  9656. }
  9657. declareNameFromIdentifier(identifier, binding) {
  9658. this.scope.declareName(identifier.name, binding, identifier.loc.start);
  9659. }
  9660. checkToRestConversion(node, allowPattern) {
  9661. switch (node.type) {
  9662. case "ParenthesizedExpression":
  9663. this.checkToRestConversion(node.expression, allowPattern);
  9664. break;
  9665. case "Identifier":
  9666. case "MemberExpression":
  9667. break;
  9668. case "ArrayExpression":
  9669. case "ObjectExpression":
  9670. if (allowPattern) break;
  9671. default:
  9672. this.raise(Errors.InvalidRestAssignmentPattern, node);
  9673. }
  9674. }
  9675. checkCommaAfterRest(close) {
  9676. if (!this.match(12)) {
  9677. return false;
  9678. }
  9679. this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc);
  9680. return true;
  9681. }
  9682. }
  9683. const getOwn = (object, key) => hasOwnProperty.call(object, key) && object[key];
  9684. function nonNull(x) {
  9685. if (x == null) {
  9686. throw new Error(`Unexpected ${x} value.`);
  9687. }
  9688. return x;
  9689. }
  9690. function assert$1(x) {
  9691. if (!x) {
  9692. throw new Error("Assert fail");
  9693. }
  9694. }
  9695. const TSErrors = ParseErrorEnum`typescript`({
  9696. AbstractMethodHasImplementation: ({
  9697. methodName
  9698. }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`,
  9699. AbstractPropertyHasInitializer: ({
  9700. propertyName
  9701. }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`,
  9702. AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.",
  9703. AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.",
  9704. AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.",
  9705. ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.",
  9706. ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.",
  9707. ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",
  9708. ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
  9709. DeclareAccessor: ({
  9710. kind
  9711. }) => `'declare' is not allowed in ${kind}ters.`,
  9712. DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
  9713. DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
  9714. DuplicateAccessibilityModifier: ({
  9715. modifier
  9716. }) => `Accessibility modifier already seen.`,
  9717. DuplicateModifier: ({
  9718. modifier
  9719. }) => `Duplicate modifier: '${modifier}'.`,
  9720. EmptyHeritageClauseType: ({
  9721. token
  9722. }) => `'${token}' list cannot be empty.`,
  9723. EmptyTypeArguments: "Type argument list cannot be empty.",
  9724. EmptyTypeParameters: "Type parameter list cannot be empty.",
  9725. ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
  9726. ImportAliasHasImportType: "An import alias can not use 'import type'.",
  9727. ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier",
  9728. IncompatibleModifiers: ({
  9729. modifiers
  9730. }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
  9731. IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
  9732. IndexSignatureHasAccessibility: ({
  9733. modifier
  9734. }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
  9735. IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
  9736. IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
  9737. IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
  9738. InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
  9739. InvalidModifierOnTypeMember: ({
  9740. modifier
  9741. }) => `'${modifier}' modifier cannot appear on a type member.`,
  9742. InvalidModifierOnTypeParameter: ({
  9743. modifier
  9744. }) => `'${modifier}' modifier cannot appear on a type parameter.`,
  9745. InvalidModifierOnTypeParameterPositions: ({
  9746. modifier
  9747. }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
  9748. InvalidModifiersOrder: ({
  9749. orderedModifiers
  9750. }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
  9751. InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
  9752. InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
  9753. MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
  9754. NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
  9755. NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
  9756. OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
  9757. OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
  9758. PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
  9759. PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
  9760. PrivateElementHasAccessibility: ({
  9761. modifier
  9762. }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
  9763. ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
  9764. ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
  9765. ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
  9766. SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
  9767. SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
  9768. SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
  9769. SingleTypeParameterWithoutTrailingComma: ({
  9770. typeParameterName
  9771. }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
  9772. StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
  9773. 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?`).",
  9774. TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
  9775. TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
  9776. TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
  9777. TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
  9778. UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
  9779. UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
  9780. UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
  9781. UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
  9782. UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
  9783. UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
  9784. UnsupportedSignatureParameterKind: ({
  9785. type
  9786. }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`
  9787. });
  9788. function keywordTypeFromName(value) {
  9789. switch (value) {
  9790. case "any":
  9791. return "TSAnyKeyword";
  9792. case "boolean":
  9793. return "TSBooleanKeyword";
  9794. case "bigint":
  9795. return "TSBigIntKeyword";
  9796. case "never":
  9797. return "TSNeverKeyword";
  9798. case "number":
  9799. return "TSNumberKeyword";
  9800. case "object":
  9801. return "TSObjectKeyword";
  9802. case "string":
  9803. return "TSStringKeyword";
  9804. case "symbol":
  9805. return "TSSymbolKeyword";
  9806. case "undefined":
  9807. return "TSUndefinedKeyword";
  9808. case "unknown":
  9809. return "TSUnknownKeyword";
  9810. default:
  9811. return undefined;
  9812. }
  9813. }
  9814. function tsIsAccessModifier(modifier) {
  9815. return modifier === "private" || modifier === "public" || modifier === "protected";
  9816. }
  9817. function tsIsVarianceAnnotations(modifier) {
  9818. return modifier === "in" || modifier === "out";
  9819. }
  9820. var typescript = superClass => class TypeScriptParserMixin extends superClass {
  9821. constructor(...args) {
  9822. super(...args);
  9823. this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, {
  9824. allowedModifiers: ["in", "out"],
  9825. disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9826. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9827. });
  9828. this.tsParseConstModifier = this.tsParseModifiers.bind(this, {
  9829. allowedModifiers: ["const"],
  9830. disallowedModifiers: ["in", "out"],
  9831. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  9832. });
  9833. this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, {
  9834. allowedModifiers: ["in", "out", "const"],
  9835. disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
  9836. errorTemplate: TSErrors.InvalidModifierOnTypeParameter
  9837. });
  9838. }
  9839. getScopeHandler() {
  9840. return TypeScriptScopeHandler;
  9841. }
  9842. tsIsIdentifier() {
  9843. return tokenIsIdentifier(this.state.type);
  9844. }
  9845. tsTokenCanFollowModifier() {
  9846. return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
  9847. }
  9848. tsNextTokenCanFollowModifier() {
  9849. this.next();
  9850. return this.tsTokenCanFollowModifier();
  9851. }
  9852. tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
  9853. if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) {
  9854. return undefined;
  9855. }
  9856. const modifier = this.state.value;
  9857. if (allowedModifiers.indexOf(modifier) !== -1) {
  9858. if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) {
  9859. return undefined;
  9860. }
  9861. if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
  9862. return modifier;
  9863. }
  9864. }
  9865. return undefined;
  9866. }
  9867. tsParseModifiers({
  9868. allowedModifiers,
  9869. disallowedModifiers,
  9870. stopOnStartOfClassStaticBlock,
  9871. errorTemplate = TSErrors.InvalidModifierOnTypeMember
  9872. }, modified) {
  9873. const enforceOrder = (loc, modifier, before, after) => {
  9874. if (modifier === before && modified[after]) {
  9875. this.raise(TSErrors.InvalidModifiersOrder, loc, {
  9876. orderedModifiers: [before, after]
  9877. });
  9878. }
  9879. };
  9880. const incompatible = (loc, modifier, mod1, mod2) => {
  9881. if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
  9882. this.raise(TSErrors.IncompatibleModifiers, loc, {
  9883. modifiers: [mod1, mod2]
  9884. });
  9885. }
  9886. };
  9887. for (;;) {
  9888. const {
  9889. startLoc
  9890. } = this.state;
  9891. const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
  9892. if (!modifier) break;
  9893. if (tsIsAccessModifier(modifier)) {
  9894. if (modified.accessibility) {
  9895. this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, {
  9896. modifier
  9897. });
  9898. } else {
  9899. enforceOrder(startLoc, modifier, modifier, "override");
  9900. enforceOrder(startLoc, modifier, modifier, "static");
  9901. enforceOrder(startLoc, modifier, modifier, "readonly");
  9902. modified.accessibility = modifier;
  9903. }
  9904. } else if (tsIsVarianceAnnotations(modifier)) {
  9905. if (modified[modifier]) {
  9906. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9907. modifier
  9908. });
  9909. }
  9910. modified[modifier] = true;
  9911. enforceOrder(startLoc, modifier, "in", "out");
  9912. } else {
  9913. if (hasOwnProperty.call(modified, modifier)) {
  9914. this.raise(TSErrors.DuplicateModifier, startLoc, {
  9915. modifier
  9916. });
  9917. } else {
  9918. enforceOrder(startLoc, modifier, "static", "readonly");
  9919. enforceOrder(startLoc, modifier, "static", "override");
  9920. enforceOrder(startLoc, modifier, "override", "readonly");
  9921. enforceOrder(startLoc, modifier, "abstract", "override");
  9922. incompatible(startLoc, modifier, "declare", "override");
  9923. incompatible(startLoc, modifier, "static", "abstract");
  9924. }
  9925. modified[modifier] = true;
  9926. }
  9927. if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
  9928. this.raise(errorTemplate, startLoc, {
  9929. modifier
  9930. });
  9931. }
  9932. }
  9933. }
  9934. tsIsListTerminator(kind) {
  9935. switch (kind) {
  9936. case "EnumMembers":
  9937. case "TypeMembers":
  9938. return this.match(8);
  9939. case "HeritageClauseElement":
  9940. return this.match(5);
  9941. case "TupleElementTypes":
  9942. return this.match(3);
  9943. case "TypeParametersOrArguments":
  9944. return this.match(48);
  9945. }
  9946. }
  9947. tsParseList(kind, parseElement) {
  9948. const result = [];
  9949. while (!this.tsIsListTerminator(kind)) {
  9950. result.push(parseElement());
  9951. }
  9952. return result;
  9953. }
  9954. tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) {
  9955. return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos));
  9956. }
  9957. tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) {
  9958. const result = [];
  9959. let trailingCommaPos = -1;
  9960. for (;;) {
  9961. if (this.tsIsListTerminator(kind)) {
  9962. break;
  9963. }
  9964. trailingCommaPos = -1;
  9965. const element = parseElement();
  9966. if (element == null) {
  9967. return undefined;
  9968. }
  9969. result.push(element);
  9970. if (this.eat(12)) {
  9971. trailingCommaPos = this.state.lastTokStartLoc.index;
  9972. continue;
  9973. }
  9974. if (this.tsIsListTerminator(kind)) {
  9975. break;
  9976. }
  9977. if (expectSuccess) {
  9978. this.expect(12);
  9979. }
  9980. return undefined;
  9981. }
  9982. if (refTrailingCommaPos) {
  9983. refTrailingCommaPos.value = trailingCommaPos;
  9984. }
  9985. return result;
  9986. }
  9987. tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) {
  9988. if (!skipFirstToken) {
  9989. if (bracket) {
  9990. this.expect(0);
  9991. } else {
  9992. this.expect(47);
  9993. }
  9994. }
  9995. const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos);
  9996. if (bracket) {
  9997. this.expect(3);
  9998. } else {
  9999. this.expect(48);
  10000. }
  10001. return result;
  10002. }
  10003. tsParseImportType() {
  10004. const node = this.startNode();
  10005. this.expect(83);
  10006. this.expect(10);
  10007. if (!this.match(133)) {
  10008. this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
  10009. }
  10010. node.argument = super.parseExprAtom();
  10011. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  10012. node.options = null;
  10013. }
  10014. if (this.eat(12)) {
  10015. this.expectImportAttributesPlugin();
  10016. if (!this.match(11)) {
  10017. node.options = super.parseMaybeAssignAllowIn();
  10018. this.eat(12);
  10019. }
  10020. }
  10021. this.expect(11);
  10022. if (this.eat(16)) {
  10023. node.qualifier = this.tsParseEntityName();
  10024. }
  10025. if (this.match(47)) {
  10026. node.typeParameters = this.tsParseTypeArguments();
  10027. }
  10028. return this.finishNode(node, "TSImportType");
  10029. }
  10030. tsParseEntityName(allowReservedWords = true) {
  10031. let entity = this.parseIdentifier(allowReservedWords);
  10032. while (this.eat(16)) {
  10033. const node = this.startNodeAtNode(entity);
  10034. node.left = entity;
  10035. node.right = this.parseIdentifier(allowReservedWords);
  10036. entity = this.finishNode(node, "TSQualifiedName");
  10037. }
  10038. return entity;
  10039. }
  10040. tsParseTypeReference() {
  10041. const node = this.startNode();
  10042. node.typeName = this.tsParseEntityName();
  10043. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10044. node.typeParameters = this.tsParseTypeArguments();
  10045. }
  10046. return this.finishNode(node, "TSTypeReference");
  10047. }
  10048. tsParseThisTypePredicate(lhs) {
  10049. this.next();
  10050. const node = this.startNodeAtNode(lhs);
  10051. node.parameterName = lhs;
  10052. node.typeAnnotation = this.tsParseTypeAnnotation(false);
  10053. node.asserts = false;
  10054. return this.finishNode(node, "TSTypePredicate");
  10055. }
  10056. tsParseThisTypeNode() {
  10057. const node = this.startNode();
  10058. this.next();
  10059. return this.finishNode(node, "TSThisType");
  10060. }
  10061. tsParseTypeQuery() {
  10062. const node = this.startNode();
  10063. this.expect(87);
  10064. if (this.match(83)) {
  10065. node.exprName = this.tsParseImportType();
  10066. } else {
  10067. node.exprName = this.tsParseEntityName();
  10068. }
  10069. if (!this.hasPrecedingLineBreak() && this.match(47)) {
  10070. node.typeParameters = this.tsParseTypeArguments();
  10071. }
  10072. return this.finishNode(node, "TSTypeQuery");
  10073. }
  10074. tsParseTypeParameter(parseModifiers) {
  10075. const node = this.startNode();
  10076. parseModifiers(node);
  10077. node.name = this.tsParseTypeParameterName();
  10078. node.constraint = this.tsEatThenParseType(81);
  10079. node.default = this.tsEatThenParseType(29);
  10080. return this.finishNode(node, "TSTypeParameter");
  10081. }
  10082. tsTryParseTypeParameters(parseModifiers) {
  10083. if (this.match(47)) {
  10084. return this.tsParseTypeParameters(parseModifiers);
  10085. }
  10086. }
  10087. tsParseTypeParameters(parseModifiers) {
  10088. const node = this.startNode();
  10089. if (this.match(47) || this.match(142)) {
  10090. this.next();
  10091. } else {
  10092. this.unexpected();
  10093. }
  10094. const refTrailingCommaPos = {
  10095. value: -1
  10096. };
  10097. node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
  10098. if (node.params.length === 0) {
  10099. this.raise(TSErrors.EmptyTypeParameters, node);
  10100. }
  10101. if (refTrailingCommaPos.value !== -1) {
  10102. this.addExtra(node, "trailingComma", refTrailingCommaPos.value);
  10103. }
  10104. return this.finishNode(node, "TSTypeParameterDeclaration");
  10105. }
  10106. tsFillSignature(returnToken, signature) {
  10107. const returnTokenRequired = returnToken === 19;
  10108. const paramsKey = "parameters";
  10109. const returnTypeKey = "typeAnnotation";
  10110. signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  10111. this.expect(10);
  10112. signature[paramsKey] = this.tsParseBindingListForSignature();
  10113. if (returnTokenRequired) {
  10114. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10115. } else if (this.match(returnToken)) {
  10116. signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
  10117. }
  10118. }
  10119. tsParseBindingListForSignature() {
  10120. const list = super.parseBindingList(11, 41, 2);
  10121. for (const pattern of list) {
  10122. const {
  10123. type
  10124. } = pattern;
  10125. if (type === "AssignmentPattern" || type === "TSParameterProperty") {
  10126. this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, {
  10127. type
  10128. });
  10129. }
  10130. }
  10131. return list;
  10132. }
  10133. tsParseTypeMemberSemicolon() {
  10134. if (!this.eat(12) && !this.isLineTerminator()) {
  10135. this.expect(13);
  10136. }
  10137. }
  10138. tsParseSignatureMember(kind, node) {
  10139. this.tsFillSignature(14, node);
  10140. this.tsParseTypeMemberSemicolon();
  10141. return this.finishNode(node, kind);
  10142. }
  10143. tsIsUnambiguouslyIndexSignature() {
  10144. this.next();
  10145. if (tokenIsIdentifier(this.state.type)) {
  10146. this.next();
  10147. return this.match(14);
  10148. }
  10149. return false;
  10150. }
  10151. tsTryParseIndexSignature(node) {
  10152. if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
  10153. return;
  10154. }
  10155. this.expect(0);
  10156. const id = this.parseIdentifier();
  10157. id.typeAnnotation = this.tsParseTypeAnnotation();
  10158. this.resetEndLocation(id);
  10159. this.expect(3);
  10160. node.parameters = [id];
  10161. const type = this.tsTryParseTypeAnnotation();
  10162. if (type) node.typeAnnotation = type;
  10163. this.tsParseTypeMemberSemicolon();
  10164. return this.finishNode(node, "TSIndexSignature");
  10165. }
  10166. tsParsePropertyOrMethodSignature(node, readonly) {
  10167. if (this.eat(17)) node.optional = true;
  10168. const nodeAny = node;
  10169. if (this.match(10) || this.match(47)) {
  10170. if (readonly) {
  10171. this.raise(TSErrors.ReadonlyForMethodSignature, node);
  10172. }
  10173. const method = nodeAny;
  10174. if (method.kind && this.match(47)) {
  10175. this.raise(TSErrors.AccesorCannotHaveTypeParameters, this.state.curPosition());
  10176. }
  10177. this.tsFillSignature(14, method);
  10178. this.tsParseTypeMemberSemicolon();
  10179. const paramsKey = "parameters";
  10180. const returnTypeKey = "typeAnnotation";
  10181. if (method.kind === "get") {
  10182. if (method[paramsKey].length > 0) {
  10183. this.raise(Errors.BadGetterArity, this.state.curPosition());
  10184. if (this.isThisParam(method[paramsKey][0])) {
  10185. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10186. }
  10187. }
  10188. } else if (method.kind === "set") {
  10189. if (method[paramsKey].length !== 1) {
  10190. this.raise(Errors.BadSetterArity, this.state.curPosition());
  10191. } else {
  10192. const firstParameter = method[paramsKey][0];
  10193. if (this.isThisParam(firstParameter)) {
  10194. this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition());
  10195. }
  10196. if (firstParameter.type === "Identifier" && firstParameter.optional) {
  10197. this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, this.state.curPosition());
  10198. }
  10199. if (firstParameter.type === "RestElement") {
  10200. this.raise(TSErrors.SetAccesorCannotHaveRestParameter, this.state.curPosition());
  10201. }
  10202. }
  10203. if (method[returnTypeKey]) {
  10204. this.raise(TSErrors.SetAccesorCannotHaveReturnType, method[returnTypeKey]);
  10205. }
  10206. } else {
  10207. method.kind = "method";
  10208. }
  10209. return this.finishNode(method, "TSMethodSignature");
  10210. } else {
  10211. const property = nodeAny;
  10212. if (readonly) property.readonly = true;
  10213. const type = this.tsTryParseTypeAnnotation();
  10214. if (type) property.typeAnnotation = type;
  10215. this.tsParseTypeMemberSemicolon();
  10216. return this.finishNode(property, "TSPropertySignature");
  10217. }
  10218. }
  10219. tsParseTypeMember() {
  10220. const node = this.startNode();
  10221. if (this.match(10) || this.match(47)) {
  10222. return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
  10223. }
  10224. if (this.match(77)) {
  10225. const id = this.startNode();
  10226. this.next();
  10227. if (this.match(10) || this.match(47)) {
  10228. return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
  10229. } else {
  10230. node.key = this.createIdentifier(id, "new");
  10231. return this.tsParsePropertyOrMethodSignature(node, false);
  10232. }
  10233. }
  10234. this.tsParseModifiers({
  10235. allowedModifiers: ["readonly"],
  10236. disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"]
  10237. }, node);
  10238. const idx = this.tsTryParseIndexSignature(node);
  10239. if (idx) {
  10240. return idx;
  10241. }
  10242. super.parsePropertyName(node);
  10243. if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) {
  10244. node.kind = node.key.name;
  10245. super.parsePropertyName(node);
  10246. }
  10247. return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
  10248. }
  10249. tsParseTypeLiteral() {
  10250. const node = this.startNode();
  10251. node.members = this.tsParseObjectTypeMembers();
  10252. return this.finishNode(node, "TSTypeLiteral");
  10253. }
  10254. tsParseObjectTypeMembers() {
  10255. this.expect(5);
  10256. const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
  10257. this.expect(8);
  10258. return members;
  10259. }
  10260. tsIsStartOfMappedType() {
  10261. this.next();
  10262. if (this.eat(53)) {
  10263. return this.isContextual(122);
  10264. }
  10265. if (this.isContextual(122)) {
  10266. this.next();
  10267. }
  10268. if (!this.match(0)) {
  10269. return false;
  10270. }
  10271. this.next();
  10272. if (!this.tsIsIdentifier()) {
  10273. return false;
  10274. }
  10275. this.next();
  10276. return this.match(58);
  10277. }
  10278. tsParseMappedTypeParameter() {
  10279. const node = this.startNode();
  10280. node.name = this.tsParseTypeParameterName();
  10281. node.constraint = this.tsExpectThenParseType(58);
  10282. return this.finishNode(node, "TSTypeParameter");
  10283. }
  10284. tsParseMappedType() {
  10285. const node = this.startNode();
  10286. this.expect(5);
  10287. if (this.match(53)) {
  10288. node.readonly = this.state.value;
  10289. this.next();
  10290. this.expectContextual(122);
  10291. } else if (this.eatContextual(122)) {
  10292. node.readonly = true;
  10293. }
  10294. this.expect(0);
  10295. node.typeParameter = this.tsParseMappedTypeParameter();
  10296. node.nameType = this.eatContextual(93) ? this.tsParseType() : null;
  10297. this.expect(3);
  10298. if (this.match(53)) {
  10299. node.optional = this.state.value;
  10300. this.next();
  10301. this.expect(17);
  10302. } else if (this.eat(17)) {
  10303. node.optional = true;
  10304. }
  10305. node.typeAnnotation = this.tsTryParseType();
  10306. this.semicolon();
  10307. this.expect(8);
  10308. return this.finishNode(node, "TSMappedType");
  10309. }
  10310. tsParseTupleType() {
  10311. const node = this.startNode();
  10312. node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
  10313. let seenOptionalElement = false;
  10314. node.elementTypes.forEach(elementNode => {
  10315. const {
  10316. type
  10317. } = elementNode;
  10318. if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
  10319. this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode);
  10320. }
  10321. seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType");
  10322. });
  10323. return this.finishNode(node, "TSTupleType");
  10324. }
  10325. tsParseTupleElementType() {
  10326. const {
  10327. startLoc
  10328. } = this.state;
  10329. const rest = this.eat(21);
  10330. let labeled;
  10331. let label;
  10332. let optional;
  10333. let type;
  10334. const isWord = tokenIsKeywordOrIdentifier(this.state.type);
  10335. const chAfterWord = isWord ? this.lookaheadCharCode() : null;
  10336. if (chAfterWord === 58) {
  10337. labeled = true;
  10338. optional = false;
  10339. label = this.parseIdentifier(true);
  10340. this.expect(14);
  10341. type = this.tsParseType();
  10342. } else if (chAfterWord === 63) {
  10343. optional = true;
  10344. const startLoc = this.state.startLoc;
  10345. const wordName = this.state.value;
  10346. const typeOrLabel = this.tsParseNonArrayType();
  10347. if (this.lookaheadCharCode() === 58) {
  10348. labeled = true;
  10349. label = this.createIdentifier(this.startNodeAt(startLoc), wordName);
  10350. this.expect(17);
  10351. this.expect(14);
  10352. type = this.tsParseType();
  10353. } else {
  10354. labeled = false;
  10355. type = typeOrLabel;
  10356. this.expect(17);
  10357. }
  10358. } else {
  10359. type = this.tsParseType();
  10360. optional = this.eat(17);
  10361. labeled = this.eat(14);
  10362. }
  10363. if (labeled) {
  10364. let labeledNode;
  10365. if (label) {
  10366. labeledNode = this.startNodeAtNode(label);
  10367. labeledNode.optional = optional;
  10368. labeledNode.label = label;
  10369. labeledNode.elementType = type;
  10370. if (this.eat(17)) {
  10371. labeledNode.optional = true;
  10372. this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc);
  10373. }
  10374. } else {
  10375. labeledNode = this.startNodeAtNode(type);
  10376. labeledNode.optional = optional;
  10377. this.raise(TSErrors.InvalidTupleMemberLabel, type);
  10378. labeledNode.label = type;
  10379. labeledNode.elementType = this.tsParseType();
  10380. }
  10381. type = this.finishNode(labeledNode, "TSNamedTupleMember");
  10382. } else if (optional) {
  10383. const optionalTypeNode = this.startNodeAtNode(type);
  10384. optionalTypeNode.typeAnnotation = type;
  10385. type = this.finishNode(optionalTypeNode, "TSOptionalType");
  10386. }
  10387. if (rest) {
  10388. const restNode = this.startNodeAt(startLoc);
  10389. restNode.typeAnnotation = type;
  10390. type = this.finishNode(restNode, "TSRestType");
  10391. }
  10392. return type;
  10393. }
  10394. tsParseParenthesizedType() {
  10395. const node = this.startNode();
  10396. this.expect(10);
  10397. node.typeAnnotation = this.tsParseType();
  10398. this.expect(11);
  10399. return this.finishNode(node, "TSParenthesizedType");
  10400. }
  10401. tsParseFunctionOrConstructorType(type, abstract) {
  10402. const node = this.startNode();
  10403. if (type === "TSConstructorType") {
  10404. node.abstract = !!abstract;
  10405. if (abstract) this.next();
  10406. this.next();
  10407. }
  10408. this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
  10409. return this.finishNode(node, type);
  10410. }
  10411. tsParseLiteralTypeNode() {
  10412. const node = this.startNode();
  10413. switch (this.state.type) {
  10414. case 134:
  10415. case 135:
  10416. case 133:
  10417. case 85:
  10418. case 86:
  10419. node.literal = super.parseExprAtom();
  10420. break;
  10421. default:
  10422. this.unexpected();
  10423. }
  10424. return this.finishNode(node, "TSLiteralType");
  10425. }
  10426. tsParseTemplateLiteralType() {
  10427. const node = this.startNode();
  10428. node.literal = super.parseTemplate(false);
  10429. return this.finishNode(node, "TSLiteralType");
  10430. }
  10431. parseTemplateSubstitution() {
  10432. if (this.state.inType) return this.tsParseType();
  10433. return super.parseTemplateSubstitution();
  10434. }
  10435. tsParseThisTypeOrThisTypePredicate() {
  10436. const thisKeyword = this.tsParseThisTypeNode();
  10437. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10438. return this.tsParseThisTypePredicate(thisKeyword);
  10439. } else {
  10440. return thisKeyword;
  10441. }
  10442. }
  10443. tsParseNonArrayType() {
  10444. switch (this.state.type) {
  10445. case 133:
  10446. case 134:
  10447. case 135:
  10448. case 85:
  10449. case 86:
  10450. return this.tsParseLiteralTypeNode();
  10451. case 53:
  10452. if (this.state.value === "-") {
  10453. const node = this.startNode();
  10454. const nextToken = this.lookahead();
  10455. if (nextToken.type !== 134 && nextToken.type !== 135) {
  10456. this.unexpected();
  10457. }
  10458. node.literal = this.parseMaybeUnary();
  10459. return this.finishNode(node, "TSLiteralType");
  10460. }
  10461. break;
  10462. case 78:
  10463. return this.tsParseThisTypeOrThisTypePredicate();
  10464. case 87:
  10465. return this.tsParseTypeQuery();
  10466. case 83:
  10467. return this.tsParseImportType();
  10468. case 5:
  10469. return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
  10470. case 0:
  10471. return this.tsParseTupleType();
  10472. case 10:
  10473. return this.tsParseParenthesizedType();
  10474. case 25:
  10475. case 24:
  10476. return this.tsParseTemplateLiteralType();
  10477. default:
  10478. {
  10479. const {
  10480. type
  10481. } = this.state;
  10482. if (tokenIsIdentifier(type) || type === 88 || type === 84) {
  10483. const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
  10484. if (nodeType !== undefined && this.lookaheadCharCode() !== 46) {
  10485. const node = this.startNode();
  10486. this.next();
  10487. return this.finishNode(node, nodeType);
  10488. }
  10489. return this.tsParseTypeReference();
  10490. }
  10491. }
  10492. }
  10493. this.unexpected();
  10494. }
  10495. tsParseArrayTypeOrHigher() {
  10496. let type = this.tsParseNonArrayType();
  10497. while (!this.hasPrecedingLineBreak() && this.eat(0)) {
  10498. if (this.match(3)) {
  10499. const node = this.startNodeAtNode(type);
  10500. node.elementType = type;
  10501. this.expect(3);
  10502. type = this.finishNode(node, "TSArrayType");
  10503. } else {
  10504. const node = this.startNodeAtNode(type);
  10505. node.objectType = type;
  10506. node.indexType = this.tsParseType();
  10507. this.expect(3);
  10508. type = this.finishNode(node, "TSIndexedAccessType");
  10509. }
  10510. }
  10511. return type;
  10512. }
  10513. tsParseTypeOperator() {
  10514. const node = this.startNode();
  10515. const operator = this.state.value;
  10516. this.next();
  10517. node.operator = operator;
  10518. node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
  10519. if (operator === "readonly") {
  10520. this.tsCheckTypeAnnotationForReadOnly(node);
  10521. }
  10522. return this.finishNode(node, "TSTypeOperator");
  10523. }
  10524. tsCheckTypeAnnotationForReadOnly(node) {
  10525. switch (node.typeAnnotation.type) {
  10526. case "TSTupleType":
  10527. case "TSArrayType":
  10528. return;
  10529. default:
  10530. this.raise(TSErrors.UnexpectedReadonly, node);
  10531. }
  10532. }
  10533. tsParseInferType() {
  10534. const node = this.startNode();
  10535. this.expectContextual(115);
  10536. const typeParameter = this.startNode();
  10537. typeParameter.name = this.tsParseTypeParameterName();
  10538. typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
  10539. node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
  10540. return this.finishNode(node, "TSInferType");
  10541. }
  10542. tsParseConstraintForInferType() {
  10543. if (this.eat(81)) {
  10544. const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
  10545. if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
  10546. return constraint;
  10547. }
  10548. }
  10549. }
  10550. tsParseTypeOperatorOrHigher() {
  10551. const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
  10552. return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
  10553. }
  10554. tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
  10555. const node = this.startNode();
  10556. const hasLeadingOperator = this.eat(operator);
  10557. const types = [];
  10558. do {
  10559. types.push(parseConstituentType());
  10560. } while (this.eat(operator));
  10561. if (types.length === 1 && !hasLeadingOperator) {
  10562. return types[0];
  10563. }
  10564. node.types = types;
  10565. return this.finishNode(node, kind);
  10566. }
  10567. tsParseIntersectionTypeOrHigher() {
  10568. return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45);
  10569. }
  10570. tsParseUnionTypeOrHigher() {
  10571. return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43);
  10572. }
  10573. tsIsStartOfFunctionType() {
  10574. if (this.match(47)) {
  10575. return true;
  10576. }
  10577. return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
  10578. }
  10579. tsSkipParameterStart() {
  10580. if (tokenIsIdentifier(this.state.type) || this.match(78)) {
  10581. this.next();
  10582. return true;
  10583. }
  10584. if (this.match(5)) {
  10585. const {
  10586. errors
  10587. } = this.state;
  10588. const previousErrorCount = errors.length;
  10589. try {
  10590. this.parseObjectLike(8, true);
  10591. return errors.length === previousErrorCount;
  10592. } catch (_unused) {
  10593. return false;
  10594. }
  10595. }
  10596. if (this.match(0)) {
  10597. this.next();
  10598. const {
  10599. errors
  10600. } = this.state;
  10601. const previousErrorCount = errors.length;
  10602. try {
  10603. super.parseBindingList(3, 93, 1);
  10604. return errors.length === previousErrorCount;
  10605. } catch (_unused2) {
  10606. return false;
  10607. }
  10608. }
  10609. return false;
  10610. }
  10611. tsIsUnambiguouslyStartOfFunctionType() {
  10612. this.next();
  10613. if (this.match(11) || this.match(21)) {
  10614. return true;
  10615. }
  10616. if (this.tsSkipParameterStart()) {
  10617. if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) {
  10618. return true;
  10619. }
  10620. if (this.match(11)) {
  10621. this.next();
  10622. if (this.match(19)) {
  10623. return true;
  10624. }
  10625. }
  10626. }
  10627. return false;
  10628. }
  10629. tsParseTypeOrTypePredicateAnnotation(returnToken) {
  10630. return this.tsInType(() => {
  10631. const t = this.startNode();
  10632. this.expect(returnToken);
  10633. const node = this.startNode();
  10634. const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
  10635. if (asserts && this.match(78)) {
  10636. let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
  10637. if (thisTypePredicate.type === "TSThisType") {
  10638. node.parameterName = thisTypePredicate;
  10639. node.asserts = true;
  10640. node.typeAnnotation = null;
  10641. thisTypePredicate = this.finishNode(node, "TSTypePredicate");
  10642. } else {
  10643. this.resetStartLocationFromNode(thisTypePredicate, node);
  10644. thisTypePredicate.asserts = true;
  10645. }
  10646. t.typeAnnotation = thisTypePredicate;
  10647. return this.finishNode(t, "TSTypeAnnotation");
  10648. }
  10649. const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
  10650. if (!typePredicateVariable) {
  10651. if (!asserts) {
  10652. return this.tsParseTypeAnnotation(false, t);
  10653. }
  10654. node.parameterName = this.parseIdentifier();
  10655. node.asserts = asserts;
  10656. node.typeAnnotation = null;
  10657. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10658. return this.finishNode(t, "TSTypeAnnotation");
  10659. }
  10660. const type = this.tsParseTypeAnnotation(false);
  10661. node.parameterName = typePredicateVariable;
  10662. node.typeAnnotation = type;
  10663. node.asserts = asserts;
  10664. t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
  10665. return this.finishNode(t, "TSTypeAnnotation");
  10666. });
  10667. }
  10668. tsTryParseTypeOrTypePredicateAnnotation() {
  10669. if (this.match(14)) {
  10670. return this.tsParseTypeOrTypePredicateAnnotation(14);
  10671. }
  10672. }
  10673. tsTryParseTypeAnnotation() {
  10674. if (this.match(14)) {
  10675. return this.tsParseTypeAnnotation();
  10676. }
  10677. }
  10678. tsTryParseType() {
  10679. return this.tsEatThenParseType(14);
  10680. }
  10681. tsParseTypePredicatePrefix() {
  10682. const id = this.parseIdentifier();
  10683. if (this.isContextual(116) && !this.hasPrecedingLineBreak()) {
  10684. this.next();
  10685. return id;
  10686. }
  10687. }
  10688. tsParseTypePredicateAsserts() {
  10689. if (this.state.type !== 109) {
  10690. return false;
  10691. }
  10692. const containsEsc = this.state.containsEsc;
  10693. this.next();
  10694. if (!tokenIsIdentifier(this.state.type) && !this.match(78)) {
  10695. return false;
  10696. }
  10697. if (containsEsc) {
  10698. this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, {
  10699. reservedWord: "asserts"
  10700. });
  10701. }
  10702. return true;
  10703. }
  10704. tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
  10705. this.tsInType(() => {
  10706. if (eatColon) this.expect(14);
  10707. t.typeAnnotation = this.tsParseType();
  10708. });
  10709. return this.finishNode(t, "TSTypeAnnotation");
  10710. }
  10711. tsParseType() {
  10712. assert$1(this.state.inType);
  10713. const type = this.tsParseNonConditionalType();
  10714. if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
  10715. return type;
  10716. }
  10717. const node = this.startNodeAtNode(type);
  10718. node.checkType = type;
  10719. node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
  10720. this.expect(17);
  10721. node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10722. this.expect(14);
  10723. node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
  10724. return this.finishNode(node, "TSConditionalType");
  10725. }
  10726. isAbstractConstructorSignature() {
  10727. return this.isContextual(124) && this.lookahead().type === 77;
  10728. }
  10729. tsParseNonConditionalType() {
  10730. if (this.tsIsStartOfFunctionType()) {
  10731. return this.tsParseFunctionOrConstructorType("TSFunctionType");
  10732. }
  10733. if (this.match(77)) {
  10734. return this.tsParseFunctionOrConstructorType("TSConstructorType");
  10735. } else if (this.isAbstractConstructorSignature()) {
  10736. return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
  10737. }
  10738. return this.tsParseUnionTypeOrHigher();
  10739. }
  10740. tsParseTypeAssertion() {
  10741. if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  10742. this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc);
  10743. }
  10744. const node = this.startNode();
  10745. node.typeAnnotation = this.tsInType(() => {
  10746. this.next();
  10747. return this.match(75) ? this.tsParseTypeReference() : this.tsParseType();
  10748. });
  10749. this.expect(48);
  10750. node.expression = this.parseMaybeUnary();
  10751. return this.finishNode(node, "TSTypeAssertion");
  10752. }
  10753. tsParseHeritageClause(token) {
  10754. const originalStartLoc = this.state.startLoc;
  10755. const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
  10756. const node = this.startNode();
  10757. node.expression = this.tsParseEntityName();
  10758. if (this.match(47)) {
  10759. node.typeParameters = this.tsParseTypeArguments();
  10760. }
  10761. return this.finishNode(node, "TSExpressionWithTypeArguments");
  10762. });
  10763. if (!delimitedList.length) {
  10764. this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
  10765. token
  10766. });
  10767. }
  10768. return delimitedList;
  10769. }
  10770. tsParseInterfaceDeclaration(node, properties = {}) {
  10771. if (this.hasFollowingLineBreak()) return null;
  10772. this.expectContextual(129);
  10773. if (properties.declare) node.declare = true;
  10774. if (tokenIsIdentifier(this.state.type)) {
  10775. node.id = this.parseIdentifier();
  10776. this.checkIdentifier(node.id, 130);
  10777. } else {
  10778. node.id = null;
  10779. this.raise(TSErrors.MissingInterfaceName, this.state.startLoc);
  10780. }
  10781. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  10782. if (this.eat(81)) {
  10783. node.extends = this.tsParseHeritageClause("extends");
  10784. }
  10785. const body = this.startNode();
  10786. body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
  10787. node.body = this.finishNode(body, "TSInterfaceBody");
  10788. return this.finishNode(node, "TSInterfaceDeclaration");
  10789. }
  10790. tsParseTypeAliasDeclaration(node) {
  10791. node.id = this.parseIdentifier();
  10792. this.checkIdentifier(node.id, 2);
  10793. node.typeAnnotation = this.tsInType(() => {
  10794. node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
  10795. this.expect(29);
  10796. if (this.isContextual(114) && this.lookahead().type !== 16) {
  10797. const node = this.startNode();
  10798. this.next();
  10799. return this.finishNode(node, "TSIntrinsicKeyword");
  10800. }
  10801. return this.tsParseType();
  10802. });
  10803. this.semicolon();
  10804. return this.finishNode(node, "TSTypeAliasDeclaration");
  10805. }
  10806. tsInNoContext(cb) {
  10807. const oldContext = this.state.context;
  10808. this.state.context = [oldContext[0]];
  10809. try {
  10810. return cb();
  10811. } finally {
  10812. this.state.context = oldContext;
  10813. }
  10814. }
  10815. tsInType(cb) {
  10816. const oldInType = this.state.inType;
  10817. this.state.inType = true;
  10818. try {
  10819. return cb();
  10820. } finally {
  10821. this.state.inType = oldInType;
  10822. }
  10823. }
  10824. tsInDisallowConditionalTypesContext(cb) {
  10825. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10826. this.state.inDisallowConditionalTypesContext = true;
  10827. try {
  10828. return cb();
  10829. } finally {
  10830. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10831. }
  10832. }
  10833. tsInAllowConditionalTypesContext(cb) {
  10834. const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
  10835. this.state.inDisallowConditionalTypesContext = false;
  10836. try {
  10837. return cb();
  10838. } finally {
  10839. this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
  10840. }
  10841. }
  10842. tsEatThenParseType(token) {
  10843. if (this.match(token)) {
  10844. return this.tsNextThenParseType();
  10845. }
  10846. }
  10847. tsExpectThenParseType(token) {
  10848. return this.tsInType(() => {
  10849. this.expect(token);
  10850. return this.tsParseType();
  10851. });
  10852. }
  10853. tsNextThenParseType() {
  10854. return this.tsInType(() => {
  10855. this.next();
  10856. return this.tsParseType();
  10857. });
  10858. }
  10859. tsParseEnumMember() {
  10860. const node = this.startNode();
  10861. node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
  10862. if (this.eat(29)) {
  10863. node.initializer = super.parseMaybeAssignAllowIn();
  10864. }
  10865. return this.finishNode(node, "TSEnumMember");
  10866. }
  10867. tsParseEnumDeclaration(node, properties = {}) {
  10868. if (properties.const) node.const = true;
  10869. if (properties.declare) node.declare = true;
  10870. this.expectContextual(126);
  10871. node.id = this.parseIdentifier();
  10872. this.checkIdentifier(node.id, node.const ? 8971 : 8459);
  10873. this.expect(5);
  10874. node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
  10875. this.expect(8);
  10876. return this.finishNode(node, "TSEnumDeclaration");
  10877. }
  10878. tsParseModuleBlock() {
  10879. const node = this.startNode();
  10880. this.scope.enter(0);
  10881. this.expect(5);
  10882. super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8);
  10883. this.scope.exit();
  10884. return this.finishNode(node, "TSModuleBlock");
  10885. }
  10886. tsParseModuleOrNamespaceDeclaration(node, nested = false) {
  10887. node.id = this.parseIdentifier();
  10888. if (!nested) {
  10889. this.checkIdentifier(node.id, 1024);
  10890. }
  10891. if (this.eat(16)) {
  10892. const inner = this.startNode();
  10893. this.tsParseModuleOrNamespaceDeclaration(inner, true);
  10894. node.body = inner;
  10895. } else {
  10896. this.scope.enter(256);
  10897. this.prodParam.enter(0);
  10898. node.body = this.tsParseModuleBlock();
  10899. this.prodParam.exit();
  10900. this.scope.exit();
  10901. }
  10902. return this.finishNode(node, "TSModuleDeclaration");
  10903. }
  10904. tsParseAmbientExternalModuleDeclaration(node) {
  10905. if (this.isContextual(112)) {
  10906. node.global = true;
  10907. node.id = this.parseIdentifier();
  10908. } else if (this.match(133)) {
  10909. node.id = super.parseStringLiteral(this.state.value);
  10910. } else {
  10911. this.unexpected();
  10912. }
  10913. if (this.match(5)) {
  10914. this.scope.enter(256);
  10915. this.prodParam.enter(0);
  10916. node.body = this.tsParseModuleBlock();
  10917. this.prodParam.exit();
  10918. this.scope.exit();
  10919. } else {
  10920. this.semicolon();
  10921. }
  10922. return this.finishNode(node, "TSModuleDeclaration");
  10923. }
  10924. tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) {
  10925. node.isExport = isExport || false;
  10926. node.id = maybeDefaultIdentifier || this.parseIdentifier();
  10927. this.checkIdentifier(node.id, 4096);
  10928. this.expect(29);
  10929. const moduleReference = this.tsParseModuleReference();
  10930. if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
  10931. this.raise(TSErrors.ImportAliasHasImportType, moduleReference);
  10932. }
  10933. node.moduleReference = moduleReference;
  10934. this.semicolon();
  10935. return this.finishNode(node, "TSImportEqualsDeclaration");
  10936. }
  10937. tsIsExternalModuleReference() {
  10938. return this.isContextual(119) && this.lookaheadCharCode() === 40;
  10939. }
  10940. tsParseModuleReference() {
  10941. return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
  10942. }
  10943. tsParseExternalModuleReference() {
  10944. const node = this.startNode();
  10945. this.expectContextual(119);
  10946. this.expect(10);
  10947. if (!this.match(133)) {
  10948. this.unexpected();
  10949. }
  10950. node.expression = super.parseExprAtom();
  10951. this.expect(11);
  10952. this.sawUnambiguousESM = true;
  10953. return this.finishNode(node, "TSExternalModuleReference");
  10954. }
  10955. tsLookAhead(f) {
  10956. const state = this.state.clone();
  10957. const res = f();
  10958. this.state = state;
  10959. return res;
  10960. }
  10961. tsTryParseAndCatch(f) {
  10962. const result = this.tryParse(abort => f() || abort());
  10963. if (result.aborted || !result.node) return;
  10964. if (result.error) this.state = result.failState;
  10965. return result.node;
  10966. }
  10967. tsTryParse(f) {
  10968. const state = this.state.clone();
  10969. const result = f();
  10970. if (result !== undefined && result !== false) {
  10971. return result;
  10972. }
  10973. this.state = state;
  10974. }
  10975. tsTryParseDeclare(nany) {
  10976. if (this.isLineTerminator()) {
  10977. return;
  10978. }
  10979. let startType = this.state.type;
  10980. let kind;
  10981. if (this.isContextual(100)) {
  10982. startType = 74;
  10983. kind = "let";
  10984. }
  10985. return this.tsInAmbientContext(() => {
  10986. switch (startType) {
  10987. case 68:
  10988. nany.declare = true;
  10989. return super.parseFunctionStatement(nany, false, false);
  10990. case 80:
  10991. nany.declare = true;
  10992. return this.parseClass(nany, true, false);
  10993. case 126:
  10994. return this.tsParseEnumDeclaration(nany, {
  10995. declare: true
  10996. });
  10997. case 112:
  10998. return this.tsParseAmbientExternalModuleDeclaration(nany);
  10999. case 75:
  11000. case 74:
  11001. if (!this.match(75) || !this.isLookaheadContextual("enum")) {
  11002. nany.declare = true;
  11003. return this.parseVarStatement(nany, kind || this.state.value, true);
  11004. }
  11005. this.expect(75);
  11006. return this.tsParseEnumDeclaration(nany, {
  11007. const: true,
  11008. declare: true
  11009. });
  11010. case 129:
  11011. {
  11012. const result = this.tsParseInterfaceDeclaration(nany, {
  11013. declare: true
  11014. });
  11015. if (result) return result;
  11016. }
  11017. default:
  11018. if (tokenIsIdentifier(startType)) {
  11019. return this.tsParseDeclaration(nany, this.state.value, true, null);
  11020. }
  11021. }
  11022. });
  11023. }
  11024. tsTryParseExportDeclaration() {
  11025. return this.tsParseDeclaration(this.startNode(), this.state.value, true, null);
  11026. }
  11027. tsParseExpressionStatement(node, expr, decorators) {
  11028. switch (expr.name) {
  11029. case "declare":
  11030. {
  11031. const declaration = this.tsTryParseDeclare(node);
  11032. if (declaration) {
  11033. declaration.declare = true;
  11034. }
  11035. return declaration;
  11036. }
  11037. case "global":
  11038. if (this.match(5)) {
  11039. this.scope.enter(256);
  11040. this.prodParam.enter(0);
  11041. const mod = node;
  11042. mod.global = true;
  11043. mod.id = expr;
  11044. mod.body = this.tsParseModuleBlock();
  11045. this.scope.exit();
  11046. this.prodParam.exit();
  11047. return this.finishNode(mod, "TSModuleDeclaration");
  11048. }
  11049. break;
  11050. default:
  11051. return this.tsParseDeclaration(node, expr.name, false, decorators);
  11052. }
  11053. }
  11054. tsParseDeclaration(node, value, next, decorators) {
  11055. switch (value) {
  11056. case "abstract":
  11057. if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
  11058. return this.tsParseAbstractDeclaration(node, decorators);
  11059. }
  11060. break;
  11061. case "module":
  11062. if (this.tsCheckLineTerminator(next)) {
  11063. if (this.match(133)) {
  11064. return this.tsParseAmbientExternalModuleDeclaration(node);
  11065. } else if (tokenIsIdentifier(this.state.type)) {
  11066. return this.tsParseModuleOrNamespaceDeclaration(node);
  11067. }
  11068. }
  11069. break;
  11070. case "namespace":
  11071. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11072. return this.tsParseModuleOrNamespaceDeclaration(node);
  11073. }
  11074. break;
  11075. case "type":
  11076. if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
  11077. return this.tsParseTypeAliasDeclaration(node);
  11078. }
  11079. break;
  11080. }
  11081. }
  11082. tsCheckLineTerminator(next) {
  11083. if (next) {
  11084. if (this.hasFollowingLineBreak()) return false;
  11085. this.next();
  11086. return true;
  11087. }
  11088. return !this.isLineTerminator();
  11089. }
  11090. tsTryParseGenericAsyncArrowFunction(startLoc) {
  11091. if (!this.match(47)) return;
  11092. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  11093. this.state.maybeInArrowParameters = true;
  11094. const res = this.tsTryParseAndCatch(() => {
  11095. const node = this.startNodeAt(startLoc);
  11096. node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11097. super.parseFunctionParams(node);
  11098. node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
  11099. this.expect(19);
  11100. return node;
  11101. });
  11102. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  11103. if (!res) return;
  11104. return super.parseArrowExpression(res, null, true);
  11105. }
  11106. tsParseTypeArgumentsInExpression() {
  11107. if (this.reScan_lt() !== 47) return;
  11108. return this.tsParseTypeArguments();
  11109. }
  11110. tsParseTypeArguments() {
  11111. const node = this.startNode();
  11112. node.params = this.tsInType(() => this.tsInNoContext(() => {
  11113. this.expect(47);
  11114. return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
  11115. }));
  11116. if (node.params.length === 0) {
  11117. this.raise(TSErrors.EmptyTypeArguments, node);
  11118. } else if (!this.state.inType && this.curContext() === types$1.brace) {
  11119. this.reScan_lt_gt();
  11120. }
  11121. this.expect(48);
  11122. return this.finishNode(node, "TSTypeParameterInstantiation");
  11123. }
  11124. tsIsDeclarationStart() {
  11125. return tokenIsTSDeclarationStart(this.state.type);
  11126. }
  11127. isExportDefaultSpecifier() {
  11128. if (this.tsIsDeclarationStart()) return false;
  11129. return super.isExportDefaultSpecifier();
  11130. }
  11131. parseAssignableListItem(flags, decorators) {
  11132. const startLoc = this.state.startLoc;
  11133. const modified = {};
  11134. this.tsParseModifiers({
  11135. allowedModifiers: ["public", "private", "protected", "override", "readonly"]
  11136. }, modified);
  11137. const accessibility = modified.accessibility;
  11138. const override = modified.override;
  11139. const readonly = modified.readonly;
  11140. if (!(flags & 4) && (accessibility || readonly || override)) {
  11141. this.raise(TSErrors.UnexpectedParameterModifier, startLoc);
  11142. }
  11143. const left = this.parseMaybeDefault();
  11144. this.parseAssignableListItemTypes(left, flags);
  11145. const elt = this.parseMaybeDefault(left.loc.start, left);
  11146. if (accessibility || readonly || override) {
  11147. const pp = this.startNodeAt(startLoc);
  11148. if (decorators.length) {
  11149. pp.decorators = decorators;
  11150. }
  11151. if (accessibility) pp.accessibility = accessibility;
  11152. if (readonly) pp.readonly = readonly;
  11153. if (override) pp.override = override;
  11154. if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
  11155. this.raise(TSErrors.UnsupportedParameterPropertyKind, pp);
  11156. }
  11157. pp.parameter = elt;
  11158. return this.finishNode(pp, "TSParameterProperty");
  11159. }
  11160. if (decorators.length) {
  11161. left.decorators = decorators;
  11162. }
  11163. return elt;
  11164. }
  11165. isSimpleParameter(node) {
  11166. return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node);
  11167. }
  11168. tsDisallowOptionalPattern(node) {
  11169. for (const param of node.params) {
  11170. if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) {
  11171. this.raise(TSErrors.PatternIsOptional, param);
  11172. }
  11173. }
  11174. }
  11175. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  11176. super.setArrowFunctionParameters(node, params, trailingCommaLoc);
  11177. this.tsDisallowOptionalPattern(node);
  11178. }
  11179. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  11180. if (this.match(14)) {
  11181. node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11182. }
  11183. const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined;
  11184. if (bodilessType && !this.match(5) && this.isLineTerminator()) {
  11185. return this.finishNode(node, bodilessType);
  11186. }
  11187. if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
  11188. this.raise(TSErrors.DeclareFunctionHasImplementation, node);
  11189. if (node.declare) {
  11190. return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
  11191. }
  11192. }
  11193. this.tsDisallowOptionalPattern(node);
  11194. return super.parseFunctionBodyAndFinish(node, type, isMethod);
  11195. }
  11196. registerFunctionStatementId(node) {
  11197. if (!node.body && node.id) {
  11198. this.checkIdentifier(node.id, 1024);
  11199. } else {
  11200. super.registerFunctionStatementId(node);
  11201. }
  11202. }
  11203. tsCheckForInvalidTypeCasts(items) {
  11204. items.forEach(node => {
  11205. if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
  11206. this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation);
  11207. }
  11208. });
  11209. }
  11210. toReferencedList(exprList, isInParens) {
  11211. this.tsCheckForInvalidTypeCasts(exprList);
  11212. return exprList;
  11213. }
  11214. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  11215. const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
  11216. if (node.type === "ArrayExpression") {
  11217. this.tsCheckForInvalidTypeCasts(node.elements);
  11218. }
  11219. return node;
  11220. }
  11221. parseSubscript(base, startLoc, noCalls, state) {
  11222. if (!this.hasPrecedingLineBreak() && this.match(35)) {
  11223. this.state.canStartJSXElement = false;
  11224. this.next();
  11225. const nonNullExpression = this.startNodeAt(startLoc);
  11226. nonNullExpression.expression = base;
  11227. return this.finishNode(nonNullExpression, "TSNonNullExpression");
  11228. }
  11229. let isOptionalCall = false;
  11230. if (this.match(18) && this.lookaheadCharCode() === 60) {
  11231. if (noCalls) {
  11232. state.stop = true;
  11233. return base;
  11234. }
  11235. state.optionalChainMember = isOptionalCall = true;
  11236. this.next();
  11237. }
  11238. if (this.match(47) || this.match(51)) {
  11239. let missingParenErrorLoc;
  11240. const result = this.tsTryParseAndCatch(() => {
  11241. if (!noCalls && this.atPossibleAsyncArrow(base)) {
  11242. const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
  11243. if (asyncArrowFn) {
  11244. return asyncArrowFn;
  11245. }
  11246. }
  11247. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11248. if (!typeArguments) return;
  11249. if (isOptionalCall && !this.match(10)) {
  11250. missingParenErrorLoc = this.state.curPosition();
  11251. return;
  11252. }
  11253. if (tokenIsTemplate(this.state.type)) {
  11254. const result = super.parseTaggedTemplateExpression(base, startLoc, state);
  11255. result.typeParameters = typeArguments;
  11256. return result;
  11257. }
  11258. if (!noCalls && this.eat(10)) {
  11259. const node = this.startNodeAt(startLoc);
  11260. node.callee = base;
  11261. node.arguments = this.parseCallExpressionArguments(11, false);
  11262. this.tsCheckForInvalidTypeCasts(node.arguments);
  11263. node.typeParameters = typeArguments;
  11264. if (state.optionalChainMember) {
  11265. node.optional = isOptionalCall;
  11266. }
  11267. return this.finishCallExpression(node, state.optionalChainMember);
  11268. }
  11269. const tokenType = this.state.type;
  11270. if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
  11271. return;
  11272. }
  11273. const node = this.startNodeAt(startLoc);
  11274. node.expression = base;
  11275. node.typeParameters = typeArguments;
  11276. return this.finishNode(node, "TSInstantiationExpression");
  11277. });
  11278. if (missingParenErrorLoc) {
  11279. this.unexpected(missingParenErrorLoc, 10);
  11280. }
  11281. if (result) {
  11282. if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) {
  11283. this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc);
  11284. }
  11285. return result;
  11286. }
  11287. }
  11288. return super.parseSubscript(base, startLoc, noCalls, state);
  11289. }
  11290. parseNewCallee(node) {
  11291. var _callee$extra;
  11292. super.parseNewCallee(node);
  11293. const {
  11294. callee
  11295. } = node;
  11296. if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
  11297. node.typeParameters = callee.typeParameters;
  11298. node.callee = callee.expression;
  11299. }
  11300. }
  11301. parseExprOp(left, leftStartLoc, minPrec) {
  11302. let isSatisfies;
  11303. if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) {
  11304. const node = this.startNodeAt(leftStartLoc);
  11305. node.expression = left;
  11306. node.typeAnnotation = this.tsInType(() => {
  11307. this.next();
  11308. if (this.match(75)) {
  11309. if (isSatisfies) {
  11310. this.raise(Errors.UnexpectedKeyword, this.state.startLoc, {
  11311. keyword: "const"
  11312. });
  11313. }
  11314. return this.tsParseTypeReference();
  11315. }
  11316. return this.tsParseType();
  11317. });
  11318. this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression");
  11319. this.reScan_lt_gt();
  11320. return this.parseExprOp(node, leftStartLoc, minPrec);
  11321. }
  11322. return super.parseExprOp(left, leftStartLoc, minPrec);
  11323. }
  11324. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  11325. if (!this.state.isAmbientContext) {
  11326. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  11327. }
  11328. }
  11329. checkImportReflection(node) {
  11330. super.checkImportReflection(node);
  11331. if (node.module && node.importKind !== "value") {
  11332. this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start);
  11333. }
  11334. }
  11335. checkDuplicateExports() {}
  11336. isPotentialImportPhase(isExport) {
  11337. if (super.isPotentialImportPhase(isExport)) return true;
  11338. if (this.isContextual(130)) {
  11339. const ch = this.lookaheadCharCode();
  11340. return isExport ? ch === 123 || ch === 42 : ch !== 61;
  11341. }
  11342. return !isExport && this.isContextual(87);
  11343. }
  11344. applyImportPhase(node, isExport, phase, loc) {
  11345. super.applyImportPhase(node, isExport, phase, loc);
  11346. if (isExport) {
  11347. node.exportKind = phase === "type" ? "type" : "value";
  11348. } else {
  11349. node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
  11350. }
  11351. }
  11352. parseImport(node) {
  11353. if (this.match(133)) {
  11354. node.importKind = "value";
  11355. return super.parseImport(node);
  11356. }
  11357. let importNode;
  11358. if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) {
  11359. node.importKind = "value";
  11360. return this.tsParseImportEqualsDeclaration(node);
  11361. } else if (this.isContextual(130)) {
  11362. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
  11363. if (this.lookaheadCharCode() === 61) {
  11364. return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier);
  11365. } else {
  11366. importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier);
  11367. }
  11368. } else {
  11369. importNode = super.parseImport(node);
  11370. }
  11371. if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
  11372. this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode);
  11373. }
  11374. return importNode;
  11375. }
  11376. parseExport(node, decorators) {
  11377. if (this.match(83)) {
  11378. this.next();
  11379. const nodeImportEquals = node;
  11380. let maybeDefaultIdentifier = null;
  11381. if (this.isContextual(130) && this.isPotentialImportPhase(false)) {
  11382. maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false);
  11383. } else {
  11384. nodeImportEquals.importKind = "value";
  11385. }
  11386. return this.tsParseImportEqualsDeclaration(nodeImportEquals, maybeDefaultIdentifier, true);
  11387. } else if (this.eat(29)) {
  11388. const assign = node;
  11389. assign.expression = super.parseExpression();
  11390. this.semicolon();
  11391. this.sawUnambiguousESM = true;
  11392. return this.finishNode(assign, "TSExportAssignment");
  11393. } else if (this.eatContextual(93)) {
  11394. const decl = node;
  11395. this.expectContextual(128);
  11396. decl.id = this.parseIdentifier();
  11397. this.semicolon();
  11398. return this.finishNode(decl, "TSNamespaceExportDeclaration");
  11399. } else {
  11400. return super.parseExport(node, decorators);
  11401. }
  11402. }
  11403. isAbstractClass() {
  11404. return this.isContextual(124) && this.lookahead().type === 80;
  11405. }
  11406. parseExportDefaultExpression() {
  11407. if (this.isAbstractClass()) {
  11408. const cls = this.startNode();
  11409. this.next();
  11410. cls.abstract = true;
  11411. return this.parseClass(cls, true, true);
  11412. }
  11413. if (this.match(129)) {
  11414. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11415. if (result) return result;
  11416. }
  11417. return super.parseExportDefaultExpression();
  11418. }
  11419. parseVarStatement(node, kind, allowMissingInitializer = false) {
  11420. const {
  11421. isAmbientContext
  11422. } = this.state;
  11423. const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext);
  11424. if (!isAmbientContext) return declaration;
  11425. for (const {
  11426. id,
  11427. init
  11428. } of declaration.declarations) {
  11429. if (!init) continue;
  11430. if (kind !== "const" || !!id.typeAnnotation) {
  11431. this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init);
  11432. } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) {
  11433. this.raise(TSErrors.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, init);
  11434. }
  11435. }
  11436. return declaration;
  11437. }
  11438. parseStatementContent(flags, decorators) {
  11439. if (this.match(75) && this.isLookaheadContextual("enum")) {
  11440. const node = this.startNode();
  11441. this.expect(75);
  11442. return this.tsParseEnumDeclaration(node, {
  11443. const: true
  11444. });
  11445. }
  11446. if (this.isContextual(126)) {
  11447. return this.tsParseEnumDeclaration(this.startNode());
  11448. }
  11449. if (this.isContextual(129)) {
  11450. const result = this.tsParseInterfaceDeclaration(this.startNode());
  11451. if (result) return result;
  11452. }
  11453. return super.parseStatementContent(flags, decorators);
  11454. }
  11455. parseAccessModifier() {
  11456. return this.tsParseModifier(["public", "protected", "private"]);
  11457. }
  11458. tsHasSomeModifiers(member, modifiers) {
  11459. return modifiers.some(modifier => {
  11460. if (tsIsAccessModifier(modifier)) {
  11461. return member.accessibility === modifier;
  11462. }
  11463. return !!member[modifier];
  11464. });
  11465. }
  11466. tsIsStartOfStaticBlocks() {
  11467. return this.isContextual(106) && this.lookaheadCharCode() === 123;
  11468. }
  11469. parseClassMember(classBody, member, state) {
  11470. const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"];
  11471. this.tsParseModifiers({
  11472. allowedModifiers: modifiers,
  11473. disallowedModifiers: ["in", "out"],
  11474. stopOnStartOfClassStaticBlock: true,
  11475. errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
  11476. }, member);
  11477. const callParseClassMemberWithIsStatic = () => {
  11478. if (this.tsIsStartOfStaticBlocks()) {
  11479. this.next();
  11480. this.next();
  11481. if (this.tsHasSomeModifiers(member, modifiers)) {
  11482. this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition());
  11483. }
  11484. super.parseClassStaticBlock(classBody, member);
  11485. } else {
  11486. this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static);
  11487. }
  11488. };
  11489. if (member.declare) {
  11490. this.tsInAmbientContext(callParseClassMemberWithIsStatic);
  11491. } else {
  11492. callParseClassMemberWithIsStatic();
  11493. }
  11494. }
  11495. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  11496. const idx = this.tsTryParseIndexSignature(member);
  11497. if (idx) {
  11498. classBody.body.push(idx);
  11499. if (member.abstract) {
  11500. this.raise(TSErrors.IndexSignatureHasAbstract, member);
  11501. }
  11502. if (member.accessibility) {
  11503. this.raise(TSErrors.IndexSignatureHasAccessibility, member, {
  11504. modifier: member.accessibility
  11505. });
  11506. }
  11507. if (member.declare) {
  11508. this.raise(TSErrors.IndexSignatureHasDeclare, member);
  11509. }
  11510. if (member.override) {
  11511. this.raise(TSErrors.IndexSignatureHasOverride, member);
  11512. }
  11513. return;
  11514. }
  11515. if (!this.state.inAbstractClass && member.abstract) {
  11516. this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member);
  11517. }
  11518. if (member.override) {
  11519. if (!state.hadSuperClass) {
  11520. this.raise(TSErrors.OverrideNotInSubClass, member);
  11521. }
  11522. }
  11523. super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  11524. }
  11525. parsePostMemberNameModifiers(methodOrProp) {
  11526. const optional = this.eat(17);
  11527. if (optional) methodOrProp.optional = true;
  11528. if (methodOrProp.readonly && this.match(10)) {
  11529. this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp);
  11530. }
  11531. if (methodOrProp.declare && this.match(10)) {
  11532. this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
  11533. }
  11534. }
  11535. parseExpressionStatement(node, expr, decorators) {
  11536. const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined;
  11537. return decl || super.parseExpressionStatement(node, expr, decorators);
  11538. }
  11539. shouldParseExportDeclaration() {
  11540. if (this.tsIsDeclarationStart()) return true;
  11541. return super.shouldParseExportDeclaration();
  11542. }
  11543. parseConditional(expr, startLoc, refExpressionErrors) {
  11544. if (!this.state.maybeInArrowParameters || !this.match(17)) {
  11545. return super.parseConditional(expr, startLoc, refExpressionErrors);
  11546. }
  11547. const result = this.tryParse(() => super.parseConditional(expr, startLoc));
  11548. if (!result.node) {
  11549. if (result.error) {
  11550. super.setOptionalParametersError(refExpressionErrors, result.error);
  11551. }
  11552. return expr;
  11553. }
  11554. if (result.error) this.state = result.failState;
  11555. return result.node;
  11556. }
  11557. parseParenItem(node, startLoc) {
  11558. const newNode = super.parseParenItem(node, startLoc);
  11559. if (this.eat(17)) {
  11560. newNode.optional = true;
  11561. this.resetEndLocation(node);
  11562. }
  11563. if (this.match(14)) {
  11564. const typeCastNode = this.startNodeAt(startLoc);
  11565. typeCastNode.expression = node;
  11566. typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
  11567. return this.finishNode(typeCastNode, "TSTypeCastExpression");
  11568. }
  11569. return node;
  11570. }
  11571. parseExportDeclaration(node) {
  11572. if (!this.state.isAmbientContext && this.isContextual(125)) {
  11573. return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
  11574. }
  11575. const startLoc = this.state.startLoc;
  11576. const isDeclare = this.eatContextual(125);
  11577. if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) {
  11578. throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
  11579. }
  11580. const isIdentifier = tokenIsIdentifier(this.state.type);
  11581. const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node);
  11582. if (!declaration) return null;
  11583. if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) {
  11584. node.exportKind = "type";
  11585. }
  11586. if (isDeclare) {
  11587. this.resetStartLocation(declaration, startLoc);
  11588. declaration.declare = true;
  11589. }
  11590. return declaration;
  11591. }
  11592. parseClassId(node, isStatement, optionalId, bindingType) {
  11593. if ((!isStatement || optionalId) && this.isContextual(113)) {
  11594. return;
  11595. }
  11596. super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331);
  11597. const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);
  11598. if (typeParameters) node.typeParameters = typeParameters;
  11599. }
  11600. parseClassPropertyAnnotation(node) {
  11601. if (!node.optional) {
  11602. if (this.eat(35)) {
  11603. node.definite = true;
  11604. } else if (this.eat(17)) {
  11605. node.optional = true;
  11606. }
  11607. }
  11608. const type = this.tsTryParseTypeAnnotation();
  11609. if (type) node.typeAnnotation = type;
  11610. }
  11611. parseClassProperty(node) {
  11612. this.parseClassPropertyAnnotation(node);
  11613. if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) {
  11614. this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc);
  11615. }
  11616. if (node.abstract && this.match(29)) {
  11617. const {
  11618. key
  11619. } = node;
  11620. this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, {
  11621. propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  11622. });
  11623. }
  11624. return super.parseClassProperty(node);
  11625. }
  11626. parseClassPrivateProperty(node) {
  11627. if (node.abstract) {
  11628. this.raise(TSErrors.PrivateElementHasAbstract, node);
  11629. }
  11630. if (node.accessibility) {
  11631. this.raise(TSErrors.PrivateElementHasAccessibility, node, {
  11632. modifier: node.accessibility
  11633. });
  11634. }
  11635. this.parseClassPropertyAnnotation(node);
  11636. return super.parseClassPrivateProperty(node);
  11637. }
  11638. parseClassAccessorProperty(node) {
  11639. this.parseClassPropertyAnnotation(node);
  11640. if (node.optional) {
  11641. this.raise(TSErrors.AccessorCannotBeOptional, node);
  11642. }
  11643. return super.parseClassAccessorProperty(node);
  11644. }
  11645. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  11646. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11647. if (typeParameters && isConstructor) {
  11648. this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters);
  11649. }
  11650. const {
  11651. declare = false,
  11652. kind
  11653. } = method;
  11654. if (declare && (kind === "get" || kind === "set")) {
  11655. this.raise(TSErrors.DeclareAccessor, method, {
  11656. kind
  11657. });
  11658. }
  11659. if (typeParameters) method.typeParameters = typeParameters;
  11660. super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
  11661. }
  11662. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  11663. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11664. if (typeParameters) method.typeParameters = typeParameters;
  11665. super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
  11666. }
  11667. declareClassPrivateMethodInScope(node, kind) {
  11668. if (node.type === "TSDeclareMethod") return;
  11669. if (node.type === "MethodDefinition" && !hasOwnProperty.call(node.value, "body")) {
  11670. return;
  11671. }
  11672. super.declareClassPrivateMethodInScope(node, kind);
  11673. }
  11674. parseClassSuper(node) {
  11675. super.parseClassSuper(node);
  11676. if (node.superClass && (this.match(47) || this.match(51))) {
  11677. node.superTypeParameters = this.tsParseTypeArgumentsInExpression();
  11678. }
  11679. if (this.eatContextual(113)) {
  11680. node.implements = this.tsParseHeritageClause("implements");
  11681. }
  11682. }
  11683. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  11684. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11685. if (typeParameters) prop.typeParameters = typeParameters;
  11686. return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
  11687. }
  11688. parseFunctionParams(node, isConstructor) {
  11689. const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
  11690. if (typeParameters) node.typeParameters = typeParameters;
  11691. super.parseFunctionParams(node, isConstructor);
  11692. }
  11693. parseVarId(decl, kind) {
  11694. super.parseVarId(decl, kind);
  11695. if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
  11696. decl.definite = true;
  11697. }
  11698. const type = this.tsTryParseTypeAnnotation();
  11699. if (type) {
  11700. decl.id.typeAnnotation = type;
  11701. this.resetEndLocation(decl.id);
  11702. }
  11703. }
  11704. parseAsyncArrowFromCallExpression(node, call) {
  11705. if (this.match(14)) {
  11706. node.returnType = this.tsParseTypeAnnotation();
  11707. }
  11708. return super.parseAsyncArrowFromCallExpression(node, call);
  11709. }
  11710. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  11711. var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
  11712. let state;
  11713. let jsx;
  11714. let typeCast;
  11715. if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
  11716. state = this.state.clone();
  11717. jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11718. if (!jsx.error) return jsx.node;
  11719. const {
  11720. context
  11721. } = this.state;
  11722. const currentContext = context[context.length - 1];
  11723. if (currentContext === types$1.j_oTag || currentContext === types$1.j_expr) {
  11724. context.pop();
  11725. }
  11726. }
  11727. if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) {
  11728. return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11729. }
  11730. if (!state || state === this.state) state = this.state.clone();
  11731. let typeParameters;
  11732. const arrow = this.tryParse(abort => {
  11733. var _expr$extra, _typeParameters;
  11734. typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
  11735. const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
  11736. if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  11737. abort();
  11738. }
  11739. if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
  11740. this.resetStartLocationFromNode(expr, typeParameters);
  11741. }
  11742. expr.typeParameters = typeParameters;
  11743. return expr;
  11744. }, state);
  11745. if (!arrow.error && !arrow.aborted) {
  11746. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11747. return arrow.node;
  11748. }
  11749. if (!jsx) {
  11750. assert$1(!this.hasPlugin("jsx"));
  11751. typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
  11752. if (!typeCast.error) return typeCast.node;
  11753. }
  11754. if ((_jsx2 = jsx) != null && _jsx2.node) {
  11755. this.state = jsx.failState;
  11756. return jsx.node;
  11757. }
  11758. if (arrow.node) {
  11759. this.state = arrow.failState;
  11760. if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
  11761. return arrow.node;
  11762. }
  11763. if ((_typeCast = typeCast) != null && _typeCast.node) {
  11764. this.state = typeCast.failState;
  11765. return typeCast.node;
  11766. }
  11767. throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
  11768. }
  11769. reportReservedArrowTypeParam(node) {
  11770. var _node$extra;
  11771. if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
  11772. this.raise(TSErrors.ReservedArrowTypeParam, node);
  11773. }
  11774. }
  11775. parseMaybeUnary(refExpressionErrors, sawUnary) {
  11776. if (!this.hasPlugin("jsx") && this.match(47)) {
  11777. return this.tsParseTypeAssertion();
  11778. }
  11779. return super.parseMaybeUnary(refExpressionErrors, sawUnary);
  11780. }
  11781. parseArrow(node) {
  11782. if (this.match(14)) {
  11783. const result = this.tryParse(abort => {
  11784. const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
  11785. if (this.canInsertSemicolon() || !this.match(19)) abort();
  11786. return returnType;
  11787. });
  11788. if (result.aborted) return;
  11789. if (!result.thrown) {
  11790. if (result.error) this.state = result.failState;
  11791. node.returnType = result.node;
  11792. }
  11793. }
  11794. return super.parseArrow(node);
  11795. }
  11796. parseAssignableListItemTypes(param, flags) {
  11797. if (!(flags & 2)) return param;
  11798. if (this.eat(17)) {
  11799. param.optional = true;
  11800. }
  11801. const type = this.tsTryParseTypeAnnotation();
  11802. if (type) param.typeAnnotation = type;
  11803. this.resetEndLocation(param);
  11804. return param;
  11805. }
  11806. isAssignable(node, isBinding) {
  11807. switch (node.type) {
  11808. case "TSTypeCastExpression":
  11809. return this.isAssignable(node.expression, isBinding);
  11810. case "TSParameterProperty":
  11811. return true;
  11812. default:
  11813. return super.isAssignable(node, isBinding);
  11814. }
  11815. }
  11816. toAssignable(node, isLHS = false) {
  11817. switch (node.type) {
  11818. case "ParenthesizedExpression":
  11819. this.toAssignableParenthesizedExpression(node, isLHS);
  11820. break;
  11821. case "TSAsExpression":
  11822. case "TSSatisfiesExpression":
  11823. case "TSNonNullExpression":
  11824. case "TSTypeAssertion":
  11825. if (isLHS) {
  11826. this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
  11827. } else {
  11828. this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
  11829. }
  11830. this.toAssignable(node.expression, isLHS);
  11831. break;
  11832. case "AssignmentExpression":
  11833. if (!isLHS && node.left.type === "TSTypeCastExpression") {
  11834. node.left = this.typeCastToParameter(node.left);
  11835. }
  11836. default:
  11837. super.toAssignable(node, isLHS);
  11838. }
  11839. }
  11840. toAssignableParenthesizedExpression(node, isLHS) {
  11841. switch (node.expression.type) {
  11842. case "TSAsExpression":
  11843. case "TSSatisfiesExpression":
  11844. case "TSNonNullExpression":
  11845. case "TSTypeAssertion":
  11846. case "ParenthesizedExpression":
  11847. this.toAssignable(node.expression, isLHS);
  11848. break;
  11849. default:
  11850. super.toAssignable(node, isLHS);
  11851. }
  11852. }
  11853. checkToRestConversion(node, allowPattern) {
  11854. switch (node.type) {
  11855. case "TSAsExpression":
  11856. case "TSSatisfiesExpression":
  11857. case "TSTypeAssertion":
  11858. case "TSNonNullExpression":
  11859. this.checkToRestConversion(node.expression, false);
  11860. break;
  11861. default:
  11862. super.checkToRestConversion(node, allowPattern);
  11863. }
  11864. }
  11865. isValidLVal(type, isUnparenthesizedInAssign, binding) {
  11866. return getOwn({
  11867. TSTypeCastExpression: true,
  11868. TSParameterProperty: "parameter",
  11869. TSNonNullExpression: "expression",
  11870. TSInstantiationExpression: "expression",
  11871. TSAsExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true],
  11872. TSSatisfiesExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true],
  11873. TSTypeAssertion: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true]
  11874. }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
  11875. }
  11876. parseBindingAtom() {
  11877. if (this.state.type === 78) {
  11878. return this.parseIdentifier(true);
  11879. }
  11880. return super.parseBindingAtom();
  11881. }
  11882. parseMaybeDecoratorArguments(expr) {
  11883. if (this.match(47) || this.match(51)) {
  11884. const typeArguments = this.tsParseTypeArgumentsInExpression();
  11885. if (this.match(10)) {
  11886. const call = super.parseMaybeDecoratorArguments(expr);
  11887. call.typeParameters = typeArguments;
  11888. return call;
  11889. }
  11890. this.unexpected(null, 10);
  11891. }
  11892. return super.parseMaybeDecoratorArguments(expr);
  11893. }
  11894. checkCommaAfterRest(close) {
  11895. if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
  11896. this.next();
  11897. return false;
  11898. }
  11899. return super.checkCommaAfterRest(close);
  11900. }
  11901. isClassMethod() {
  11902. return this.match(47) || super.isClassMethod();
  11903. }
  11904. isClassProperty() {
  11905. return this.match(35) || this.match(14) || super.isClassProperty();
  11906. }
  11907. parseMaybeDefault(startLoc, left) {
  11908. const node = super.parseMaybeDefault(startLoc, left);
  11909. if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
  11910. this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation);
  11911. }
  11912. return node;
  11913. }
  11914. getTokenFromCode(code) {
  11915. if (this.state.inType) {
  11916. if (code === 62) {
  11917. this.finishOp(48, 1);
  11918. return;
  11919. }
  11920. if (code === 60) {
  11921. this.finishOp(47, 1);
  11922. return;
  11923. }
  11924. }
  11925. super.getTokenFromCode(code);
  11926. }
  11927. reScan_lt_gt() {
  11928. const {
  11929. type
  11930. } = this.state;
  11931. if (type === 47) {
  11932. this.state.pos -= 1;
  11933. this.readToken_lt();
  11934. } else if (type === 48) {
  11935. this.state.pos -= 1;
  11936. this.readToken_gt();
  11937. }
  11938. }
  11939. reScan_lt() {
  11940. const {
  11941. type
  11942. } = this.state;
  11943. if (type === 51) {
  11944. this.state.pos -= 2;
  11945. this.finishOp(47, 1);
  11946. return 47;
  11947. }
  11948. return type;
  11949. }
  11950. toAssignableList(exprList, trailingCommaLoc, isLHS) {
  11951. for (let i = 0; i < exprList.length; i++) {
  11952. const expr = exprList[i];
  11953. if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
  11954. exprList[i] = this.typeCastToParameter(expr);
  11955. }
  11956. }
  11957. super.toAssignableList(exprList, trailingCommaLoc, isLHS);
  11958. }
  11959. typeCastToParameter(node) {
  11960. node.expression.typeAnnotation = node.typeAnnotation;
  11961. this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
  11962. return node.expression;
  11963. }
  11964. shouldParseArrow(params) {
  11965. if (this.match(14)) {
  11966. return params.every(expr => this.isAssignable(expr, true));
  11967. }
  11968. return super.shouldParseArrow(params);
  11969. }
  11970. shouldParseAsyncArrow() {
  11971. return this.match(14) || super.shouldParseAsyncArrow();
  11972. }
  11973. canHaveLeadingDecorator() {
  11974. return super.canHaveLeadingDecorator() || this.isAbstractClass();
  11975. }
  11976. jsxParseOpeningElementAfterName(node) {
  11977. if (this.match(47) || this.match(51)) {
  11978. const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression());
  11979. if (typeArguments) node.typeParameters = typeArguments;
  11980. }
  11981. return super.jsxParseOpeningElementAfterName(node);
  11982. }
  11983. getGetterSetterExpectedParamCount(method) {
  11984. const baseCount = super.getGetterSetterExpectedParamCount(method);
  11985. const params = this.getObjectOrClassMethodParams(method);
  11986. const firstParam = params[0];
  11987. const hasContextParam = firstParam && this.isThisParam(firstParam);
  11988. return hasContextParam ? baseCount + 1 : baseCount;
  11989. }
  11990. parseCatchClauseParam() {
  11991. const param = super.parseCatchClauseParam();
  11992. const type = this.tsTryParseTypeAnnotation();
  11993. if (type) {
  11994. param.typeAnnotation = type;
  11995. this.resetEndLocation(param);
  11996. }
  11997. return param;
  11998. }
  11999. tsInAmbientContext(cb) {
  12000. const oldIsAmbientContext = this.state.isAmbientContext;
  12001. this.state.isAmbientContext = true;
  12002. try {
  12003. return cb();
  12004. } finally {
  12005. this.state.isAmbientContext = oldIsAmbientContext;
  12006. }
  12007. }
  12008. parseClass(node, isStatement, optionalId) {
  12009. const oldInAbstractClass = this.state.inAbstractClass;
  12010. this.state.inAbstractClass = !!node.abstract;
  12011. try {
  12012. return super.parseClass(node, isStatement, optionalId);
  12013. } finally {
  12014. this.state.inAbstractClass = oldInAbstractClass;
  12015. }
  12016. }
  12017. tsParseAbstractDeclaration(node, decorators) {
  12018. if (this.match(80)) {
  12019. node.abstract = true;
  12020. return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
  12021. } else if (this.isContextual(129)) {
  12022. if (!this.hasFollowingLineBreak()) {
  12023. node.abstract = true;
  12024. this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, node);
  12025. return this.tsParseInterfaceDeclaration(node);
  12026. }
  12027. } else {
  12028. this.unexpected(null, 80);
  12029. }
  12030. }
  12031. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) {
  12032. const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
  12033. if (method.abstract) {
  12034. const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body;
  12035. if (hasBody) {
  12036. const {
  12037. key
  12038. } = method;
  12039. this.raise(TSErrors.AbstractMethodHasImplementation, method, {
  12040. methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]`
  12041. });
  12042. }
  12043. }
  12044. return method;
  12045. }
  12046. tsParseTypeParameterName() {
  12047. const typeName = this.parseIdentifier();
  12048. return typeName.name;
  12049. }
  12050. shouldParseAsAmbientContext() {
  12051. return !!this.getPluginOption("typescript", "dts");
  12052. }
  12053. parse() {
  12054. if (this.shouldParseAsAmbientContext()) {
  12055. this.state.isAmbientContext = true;
  12056. }
  12057. return super.parse();
  12058. }
  12059. getExpression() {
  12060. if (this.shouldParseAsAmbientContext()) {
  12061. this.state.isAmbientContext = true;
  12062. }
  12063. return super.getExpression();
  12064. }
  12065. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  12066. if (!isString && isMaybeTypeOnly) {
  12067. this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport);
  12068. return this.finishNode(node, "ExportSpecifier");
  12069. }
  12070. node.exportKind = "value";
  12071. return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
  12072. }
  12073. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  12074. if (!importedIsString && isMaybeTypeOnly) {
  12075. this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport);
  12076. return this.finishNode(specifier, "ImportSpecifier");
  12077. }
  12078. specifier.importKind = "value";
  12079. return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096);
  12080. }
  12081. parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) {
  12082. const leftOfAsKey = isImport ? "imported" : "local";
  12083. const rightOfAsKey = isImport ? "local" : "exported";
  12084. let leftOfAs = node[leftOfAsKey];
  12085. let rightOfAs;
  12086. let hasTypeSpecifier = false;
  12087. let canParseAsKeyword = true;
  12088. const loc = leftOfAs.loc.start;
  12089. if (this.isContextual(93)) {
  12090. const firstAs = this.parseIdentifier();
  12091. if (this.isContextual(93)) {
  12092. const secondAs = this.parseIdentifier();
  12093. if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12094. hasTypeSpecifier = true;
  12095. leftOfAs = firstAs;
  12096. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12097. canParseAsKeyword = false;
  12098. } else {
  12099. rightOfAs = secondAs;
  12100. canParseAsKeyword = false;
  12101. }
  12102. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12103. canParseAsKeyword = false;
  12104. rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12105. } else {
  12106. hasTypeSpecifier = true;
  12107. leftOfAs = firstAs;
  12108. }
  12109. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  12110. hasTypeSpecifier = true;
  12111. if (isImport) {
  12112. leftOfAs = this.parseIdentifier(true);
  12113. if (!this.isContextual(93)) {
  12114. this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
  12115. }
  12116. } else {
  12117. leftOfAs = this.parseModuleExportName();
  12118. }
  12119. }
  12120. if (hasTypeSpecifier && isInTypeOnlyImportExport) {
  12121. this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc);
  12122. }
  12123. node[leftOfAsKey] = leftOfAs;
  12124. node[rightOfAsKey] = rightOfAs;
  12125. const kindKey = isImport ? "importKind" : "exportKind";
  12126. node[kindKey] = hasTypeSpecifier ? "type" : "value";
  12127. if (canParseAsKeyword && this.eatContextual(93)) {
  12128. node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
  12129. }
  12130. if (!node[rightOfAsKey]) {
  12131. node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]);
  12132. }
  12133. if (isImport) {
  12134. this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
  12135. }
  12136. }
  12137. };
  12138. function isPossiblyLiteralEnum(expression) {
  12139. if (expression.type !== "MemberExpression") return false;
  12140. const {
  12141. computed,
  12142. property
  12143. } = expression;
  12144. if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) {
  12145. return false;
  12146. }
  12147. return isUncomputedMemberExpressionChain(expression.object);
  12148. }
  12149. function isValidAmbientConstInitializer(expression, estree) {
  12150. var _expression$extra;
  12151. const {
  12152. type
  12153. } = expression;
  12154. if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) {
  12155. return false;
  12156. }
  12157. if (estree) {
  12158. if (type === "Literal") {
  12159. const {
  12160. value
  12161. } = expression;
  12162. if (typeof value === "string" || typeof value === "boolean") {
  12163. return true;
  12164. }
  12165. }
  12166. } else {
  12167. if (type === "StringLiteral" || type === "BooleanLiteral") {
  12168. return true;
  12169. }
  12170. }
  12171. if (isNumber$1(expression, estree) || isNegativeNumber(expression, estree)) {
  12172. return true;
  12173. }
  12174. if (type === "TemplateLiteral" && expression.expressions.length === 0) {
  12175. return true;
  12176. }
  12177. if (isPossiblyLiteralEnum(expression)) {
  12178. return true;
  12179. }
  12180. return false;
  12181. }
  12182. function isNumber$1(expression, estree) {
  12183. if (estree) {
  12184. return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression);
  12185. }
  12186. return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral";
  12187. }
  12188. function isNegativeNumber(expression, estree) {
  12189. if (expression.type === "UnaryExpression") {
  12190. const {
  12191. operator,
  12192. argument
  12193. } = expression;
  12194. if (operator === "-" && isNumber$1(argument, estree)) {
  12195. return true;
  12196. }
  12197. }
  12198. return false;
  12199. }
  12200. function isUncomputedMemberExpressionChain(expression) {
  12201. if (expression.type === "Identifier") return true;
  12202. if (expression.type !== "MemberExpression" || expression.computed) {
  12203. return false;
  12204. }
  12205. return isUncomputedMemberExpressionChain(expression.object);
  12206. }
  12207. const PlaceholderErrors = ParseErrorEnum`placeholders`({
  12208. ClassNameIsRequired: "A class name is required.",
  12209. UnexpectedSpace: "Unexpected space in placeholder."
  12210. });
  12211. var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
  12212. parsePlaceholder(expectedNode) {
  12213. if (this.match(144)) {
  12214. const node = this.startNode();
  12215. this.next();
  12216. this.assertNoSpace();
  12217. node.name = super.parseIdentifier(true);
  12218. this.assertNoSpace();
  12219. this.expect(144);
  12220. return this.finishPlaceholder(node, expectedNode);
  12221. }
  12222. }
  12223. finishPlaceholder(node, expectedNode) {
  12224. let placeholder = node;
  12225. if (!placeholder.expectedNode || !placeholder.type) {
  12226. placeholder = this.finishNode(placeholder, "Placeholder");
  12227. }
  12228. placeholder.expectedNode = expectedNode;
  12229. return placeholder;
  12230. }
  12231. getTokenFromCode(code) {
  12232. if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
  12233. this.finishOp(144, 2);
  12234. } else {
  12235. super.getTokenFromCode(code);
  12236. }
  12237. }
  12238. parseExprAtom(refExpressionErrors) {
  12239. return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors);
  12240. }
  12241. parseIdentifier(liberal) {
  12242. return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal);
  12243. }
  12244. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  12245. if (word !== undefined) {
  12246. super.checkReservedWord(word, startLoc, checkKeywords, isBinding);
  12247. }
  12248. }
  12249. parseBindingAtom() {
  12250. return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
  12251. }
  12252. isValidLVal(type, isParenthesized, binding) {
  12253. return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding);
  12254. }
  12255. toAssignable(node, isLHS) {
  12256. if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
  12257. node.expectedNode = "Pattern";
  12258. } else {
  12259. super.toAssignable(node, isLHS);
  12260. }
  12261. }
  12262. chStartsBindingIdentifier(ch, pos) {
  12263. if (super.chStartsBindingIdentifier(ch, pos)) {
  12264. return true;
  12265. }
  12266. const nextToken = this.lookahead();
  12267. if (nextToken.type === 144) {
  12268. return true;
  12269. }
  12270. return false;
  12271. }
  12272. verifyBreakContinue(node, isBreak) {
  12273. if (node.label && node.label.type === "Placeholder") return;
  12274. super.verifyBreakContinue(node, isBreak);
  12275. }
  12276. parseExpressionStatement(node, expr) {
  12277. var _expr$extra;
  12278. if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
  12279. return super.parseExpressionStatement(node, expr);
  12280. }
  12281. if (this.match(14)) {
  12282. const stmt = node;
  12283. stmt.label = this.finishPlaceholder(expr, "Identifier");
  12284. this.next();
  12285. stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration();
  12286. return this.finishNode(stmt, "LabeledStatement");
  12287. }
  12288. this.semicolon();
  12289. const stmtPlaceholder = node;
  12290. stmtPlaceholder.name = expr.name;
  12291. return this.finishPlaceholder(stmtPlaceholder, "Statement");
  12292. }
  12293. parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) {
  12294. return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse);
  12295. }
  12296. parseFunctionId(requireId) {
  12297. return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId);
  12298. }
  12299. parseClass(node, isStatement, optionalId) {
  12300. const type = isStatement ? "ClassDeclaration" : "ClassExpression";
  12301. this.next();
  12302. const oldStrict = this.state.strict;
  12303. const placeholder = this.parsePlaceholder("Identifier");
  12304. if (placeholder) {
  12305. if (this.match(81) || this.match(144) || this.match(5)) {
  12306. node.id = placeholder;
  12307. } else if (optionalId || !isStatement) {
  12308. node.id = null;
  12309. node.body = this.finishPlaceholder(placeholder, "ClassBody");
  12310. return this.finishNode(node, type);
  12311. } else {
  12312. throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc);
  12313. }
  12314. } else {
  12315. this.parseClassId(node, isStatement, optionalId);
  12316. }
  12317. super.parseClassSuper(node);
  12318. node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict);
  12319. return this.finishNode(node, type);
  12320. }
  12321. parseExport(node, decorators) {
  12322. const placeholder = this.parsePlaceholder("Identifier");
  12323. if (!placeholder) return super.parseExport(node, decorators);
  12324. const node2 = node;
  12325. if (!this.isContextual(98) && !this.match(12)) {
  12326. node2.specifiers = [];
  12327. node2.source = null;
  12328. node2.declaration = this.finishPlaceholder(placeholder, "Declaration");
  12329. return this.finishNode(node2, "ExportNamedDeclaration");
  12330. }
  12331. this.expectPlugin("exportDefaultFrom");
  12332. const specifier = this.startNode();
  12333. specifier.exported = placeholder;
  12334. node2.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  12335. return super.parseExport(node2, decorators);
  12336. }
  12337. isExportDefaultSpecifier() {
  12338. if (this.match(65)) {
  12339. const next = this.nextTokenStart();
  12340. if (this.isUnparsedContextual(next, "from")) {
  12341. if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) {
  12342. return true;
  12343. }
  12344. }
  12345. }
  12346. return super.isExportDefaultSpecifier();
  12347. }
  12348. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  12349. var _specifiers;
  12350. if ((_specifiers = node.specifiers) != null && _specifiers.length) {
  12351. return true;
  12352. }
  12353. return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  12354. }
  12355. checkExport(node) {
  12356. const {
  12357. specifiers
  12358. } = node;
  12359. if (specifiers != null && specifiers.length) {
  12360. node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
  12361. }
  12362. super.checkExport(node);
  12363. node.specifiers = specifiers;
  12364. }
  12365. parseImport(node) {
  12366. const placeholder = this.parsePlaceholder("Identifier");
  12367. if (!placeholder) return super.parseImport(node);
  12368. node.specifiers = [];
  12369. if (!this.isContextual(98) && !this.match(12)) {
  12370. node.source = this.finishPlaceholder(placeholder, "StringLiteral");
  12371. this.semicolon();
  12372. return this.finishNode(node, "ImportDeclaration");
  12373. }
  12374. const specifier = this.startNodeAtNode(placeholder);
  12375. specifier.local = placeholder;
  12376. node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
  12377. if (this.eat(12)) {
  12378. const hasStarImport = this.maybeParseStarImportSpecifier(node);
  12379. if (!hasStarImport) this.parseNamedImportSpecifiers(node);
  12380. }
  12381. this.expectContextual(98);
  12382. node.source = this.parseImportSource();
  12383. this.semicolon();
  12384. return this.finishNode(node, "ImportDeclaration");
  12385. }
  12386. parseImportSource() {
  12387. return this.parsePlaceholder("StringLiteral") || super.parseImportSource();
  12388. }
  12389. assertNoSpace() {
  12390. if (this.state.start > this.state.lastTokEndLoc.index) {
  12391. this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc);
  12392. }
  12393. }
  12394. };
  12395. var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
  12396. parseV8Intrinsic() {
  12397. if (this.match(54)) {
  12398. const v8IntrinsicStartLoc = this.state.startLoc;
  12399. const node = this.startNode();
  12400. this.next();
  12401. if (tokenIsIdentifier(this.state.type)) {
  12402. const name = this.parseIdentifierName();
  12403. const identifier = this.createIdentifier(node, name);
  12404. identifier.type = "V8IntrinsicIdentifier";
  12405. if (this.match(10)) {
  12406. return identifier;
  12407. }
  12408. }
  12409. this.unexpected(v8IntrinsicStartLoc);
  12410. }
  12411. }
  12412. parseExprAtom(refExpressionErrors) {
  12413. return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
  12414. }
  12415. };
  12416. function hasPlugin(plugins, expectedConfig) {
  12417. const [expectedName, expectedOptions] = typeof expectedConfig === "string" ? [expectedConfig, {}] : expectedConfig;
  12418. const expectedKeys = Object.keys(expectedOptions);
  12419. const expectedOptionsIsEmpty = expectedKeys.length === 0;
  12420. return plugins.some(p => {
  12421. if (typeof p === "string") {
  12422. return expectedOptionsIsEmpty && p === expectedName;
  12423. } else {
  12424. const [pluginName, pluginOptions] = p;
  12425. if (pluginName !== expectedName) {
  12426. return false;
  12427. }
  12428. for (const key of expectedKeys) {
  12429. if (pluginOptions[key] !== expectedOptions[key]) {
  12430. return false;
  12431. }
  12432. }
  12433. return true;
  12434. }
  12435. });
  12436. }
  12437. function getPluginOption(plugins, name, option) {
  12438. const plugin = plugins.find(plugin => {
  12439. if (Array.isArray(plugin)) {
  12440. return plugin[0] === name;
  12441. } else {
  12442. return plugin === name;
  12443. }
  12444. });
  12445. if (plugin && Array.isArray(plugin) && plugin.length > 1) {
  12446. return plugin[1][option];
  12447. }
  12448. return null;
  12449. }
  12450. const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
  12451. const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
  12452. function validatePlugins(plugins) {
  12453. if (hasPlugin(plugins, "decorators")) {
  12454. if (hasPlugin(plugins, "decorators-legacy")) {
  12455. throw new Error("Cannot use the decorators and decorators-legacy plugin together");
  12456. }
  12457. const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
  12458. if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
  12459. throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");
  12460. }
  12461. const allowCallParenthesized = getPluginOption(plugins, "decorators", "allowCallParenthesized");
  12462. if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
  12463. throw new Error("'allowCallParenthesized' must be a boolean.");
  12464. }
  12465. }
  12466. if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
  12467. throw new Error("Cannot combine flow and typescript plugins.");
  12468. }
  12469. if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
  12470. throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
  12471. }
  12472. if (hasPlugin(plugins, "pipelineOperator")) {
  12473. const proposal = getPluginOption(plugins, "pipelineOperator", "proposal");
  12474. if (!PIPELINE_PROPOSALS.includes(proposal)) {
  12475. const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
  12476. throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
  12477. }
  12478. const recordAndTupleConfigItem = ["recordAndTuple", {
  12479. syntaxType: "hash"
  12480. }];
  12481. const tupleSyntaxIsHash = hasPlugin(plugins, recordAndTupleConfigItem);
  12482. if (proposal === "hack") {
  12483. if (hasPlugin(plugins, "placeholders")) {
  12484. throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
  12485. }
  12486. if (hasPlugin(plugins, "v8intrinsic")) {
  12487. throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
  12488. }
  12489. const topicToken = getPluginOption(plugins, "pipelineOperator", "topicToken");
  12490. if (!TOPIC_TOKENS.includes(topicToken)) {
  12491. const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
  12492. throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
  12493. }
  12494. if (topicToken === "#" && tupleSyntaxIsHash) {
  12495. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "hack", topicToken: "#" }]\` and \`${JSON.stringify(recordAndTupleConfigItem)}\`.`);
  12496. }
  12497. } else if (proposal === "smart" && tupleSyntaxIsHash) {
  12498. throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "smart" }]\` and \`${JSON.stringify(recordAndTupleConfigItem)}\`.`);
  12499. }
  12500. }
  12501. if (hasPlugin(plugins, "moduleAttributes")) {
  12502. {
  12503. if (hasPlugin(plugins, "importAssertions") || hasPlugin(plugins, "importAttributes")) {
  12504. throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");
  12505. }
  12506. const moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
  12507. if (moduleAttributesVersionPluginOption !== "may-2020") {
  12508. throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
  12509. }
  12510. }
  12511. }
  12512. if (hasPlugin(plugins, "importAssertions") && hasPlugin(plugins, "importAttributes")) {
  12513. throw new Error("Cannot combine importAssertions and importAttributes plugins.");
  12514. }
  12515. if (hasPlugin(plugins, "recordAndTuple")) {
  12516. const syntaxType = getPluginOption(plugins, "recordAndTuple", "syntaxType");
  12517. if (syntaxType != null) {
  12518. {
  12519. const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
  12520. if (!RECORD_AND_TUPLE_SYNTAX_TYPES.includes(syntaxType)) {
  12521. throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
  12522. }
  12523. }
  12524. }
  12525. }
  12526. if (hasPlugin(plugins, "asyncDoExpressions") && !hasPlugin(plugins, "doExpressions")) {
  12527. const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
  12528. error.missingPlugins = "doExpressions";
  12529. throw error;
  12530. }
  12531. if (hasPlugin(plugins, "optionalChainingAssign") && getPluginOption(plugins, "optionalChainingAssign", "version") !== "2023-07") {
  12532. throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'.");
  12533. }
  12534. }
  12535. const mixinPlugins = {
  12536. estree,
  12537. jsx,
  12538. flow,
  12539. typescript,
  12540. v8intrinsic,
  12541. placeholders
  12542. };
  12543. const mixinPluginNames = Object.keys(mixinPlugins);
  12544. const defaultOptions = {
  12545. sourceType: "script",
  12546. sourceFilename: undefined,
  12547. startColumn: 0,
  12548. startLine: 1,
  12549. allowAwaitOutsideFunction: false,
  12550. allowReturnOutsideFunction: false,
  12551. allowNewTargetOutsideFunction: false,
  12552. allowImportExportEverywhere: false,
  12553. allowSuperOutsideMethod: false,
  12554. allowUndeclaredExports: false,
  12555. plugins: [],
  12556. strictMode: null,
  12557. ranges: false,
  12558. tokens: false,
  12559. createImportExpressions: false,
  12560. createParenthesizedExpressions: false,
  12561. errorRecovery: false,
  12562. attachComment: true,
  12563. annexB: true
  12564. };
  12565. function getOptions(opts) {
  12566. if (opts == null) {
  12567. return Object.assign({}, defaultOptions);
  12568. }
  12569. if (opts.annexB != null && opts.annexB !== false) {
  12570. throw new Error("The `annexB` option can only be set to `false`.");
  12571. }
  12572. const options = {};
  12573. for (const key of Object.keys(defaultOptions)) {
  12574. var _opts$key;
  12575. options[key] = (_opts$key = opts[key]) != null ? _opts$key : defaultOptions[key];
  12576. }
  12577. return options;
  12578. }
  12579. class ExpressionParser extends LValParser {
  12580. checkProto(prop, isRecord, protoRef, refExpressionErrors) {
  12581. if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
  12582. return;
  12583. }
  12584. const key = prop.key;
  12585. const name = key.type === "Identifier" ? key.name : key.value;
  12586. if (name === "__proto__") {
  12587. if (isRecord) {
  12588. this.raise(Errors.RecordNoProto, key);
  12589. return;
  12590. }
  12591. if (protoRef.used) {
  12592. if (refExpressionErrors) {
  12593. if (refExpressionErrors.doubleProtoLoc === null) {
  12594. refExpressionErrors.doubleProtoLoc = key.loc.start;
  12595. }
  12596. } else {
  12597. this.raise(Errors.DuplicateProto, key);
  12598. }
  12599. }
  12600. protoRef.used = true;
  12601. }
  12602. }
  12603. shouldExitDescending(expr, potentialArrowAt) {
  12604. return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
  12605. }
  12606. getExpression() {
  12607. this.enterInitialScopes();
  12608. this.nextToken();
  12609. const expr = this.parseExpression();
  12610. if (!this.match(139)) {
  12611. this.unexpected();
  12612. }
  12613. this.finalizeRemainingComments();
  12614. expr.comments = this.comments;
  12615. expr.errors = this.state.errors;
  12616. if (this.options.tokens) {
  12617. expr.tokens = this.tokens;
  12618. }
  12619. return expr;
  12620. }
  12621. parseExpression(disallowIn, refExpressionErrors) {
  12622. if (disallowIn) {
  12623. return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12624. }
  12625. return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
  12626. }
  12627. parseExpressionBase(refExpressionErrors) {
  12628. const startLoc = this.state.startLoc;
  12629. const expr = this.parseMaybeAssign(refExpressionErrors);
  12630. if (this.match(12)) {
  12631. const node = this.startNodeAt(startLoc);
  12632. node.expressions = [expr];
  12633. while (this.eat(12)) {
  12634. node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
  12635. }
  12636. this.toReferencedList(node.expressions);
  12637. return this.finishNode(node, "SequenceExpression");
  12638. }
  12639. return expr;
  12640. }
  12641. parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) {
  12642. return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12643. }
  12644. parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) {
  12645. return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse));
  12646. }
  12647. setOptionalParametersError(refExpressionErrors, resultError) {
  12648. var _resultError$loc;
  12649. refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
  12650. }
  12651. parseMaybeAssign(refExpressionErrors, afterLeftParse) {
  12652. const startLoc = this.state.startLoc;
  12653. if (this.isContextual(108)) {
  12654. if (this.prodParam.hasYield) {
  12655. let left = this.parseYield();
  12656. if (afterLeftParse) {
  12657. left = afterLeftParse.call(this, left, startLoc);
  12658. }
  12659. return left;
  12660. }
  12661. }
  12662. let ownExpressionErrors;
  12663. if (refExpressionErrors) {
  12664. ownExpressionErrors = false;
  12665. } else {
  12666. refExpressionErrors = new ExpressionErrors();
  12667. ownExpressionErrors = true;
  12668. }
  12669. const {
  12670. type
  12671. } = this.state;
  12672. if (type === 10 || tokenIsIdentifier(type)) {
  12673. this.state.potentialArrowAt = this.state.start;
  12674. }
  12675. let left = this.parseMaybeConditional(refExpressionErrors);
  12676. if (afterLeftParse) {
  12677. left = afterLeftParse.call(this, left, startLoc);
  12678. }
  12679. if (tokenIsAssignment(this.state.type)) {
  12680. const node = this.startNodeAt(startLoc);
  12681. const operator = this.state.value;
  12682. node.operator = operator;
  12683. if (this.match(29)) {
  12684. this.toAssignable(left, true);
  12685. node.left = left;
  12686. const startIndex = startLoc.index;
  12687. if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) {
  12688. refExpressionErrors.doubleProtoLoc = null;
  12689. }
  12690. if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) {
  12691. refExpressionErrors.shorthandAssignLoc = null;
  12692. }
  12693. if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) {
  12694. this.checkDestructuringPrivate(refExpressionErrors);
  12695. refExpressionErrors.privateKeyLoc = null;
  12696. }
  12697. } else {
  12698. node.left = left;
  12699. }
  12700. this.next();
  12701. node.right = this.parseMaybeAssign();
  12702. this.checkLVal(left, {
  12703. in: this.finishNode(node, "AssignmentExpression")
  12704. });
  12705. return node;
  12706. } else if (ownExpressionErrors) {
  12707. this.checkExpressionErrors(refExpressionErrors, true);
  12708. }
  12709. return left;
  12710. }
  12711. parseMaybeConditional(refExpressionErrors) {
  12712. const startLoc = this.state.startLoc;
  12713. const potentialArrowAt = this.state.potentialArrowAt;
  12714. const expr = this.parseExprOps(refExpressionErrors);
  12715. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12716. return expr;
  12717. }
  12718. return this.parseConditional(expr, startLoc, refExpressionErrors);
  12719. }
  12720. parseConditional(expr, startLoc, refExpressionErrors) {
  12721. if (this.eat(17)) {
  12722. const node = this.startNodeAt(startLoc);
  12723. node.test = expr;
  12724. node.consequent = this.parseMaybeAssignAllowIn();
  12725. this.expect(14);
  12726. node.alternate = this.parseMaybeAssign();
  12727. return this.finishNode(node, "ConditionalExpression");
  12728. }
  12729. return expr;
  12730. }
  12731. parseMaybeUnaryOrPrivate(refExpressionErrors) {
  12732. return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
  12733. }
  12734. parseExprOps(refExpressionErrors) {
  12735. const startLoc = this.state.startLoc;
  12736. const potentialArrowAt = this.state.potentialArrowAt;
  12737. const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors);
  12738. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12739. return expr;
  12740. }
  12741. return this.parseExprOp(expr, startLoc, -1);
  12742. }
  12743. parseExprOp(left, leftStartLoc, minPrec) {
  12744. if (this.isPrivateName(left)) {
  12745. const value = this.getPrivateNameSV(left);
  12746. if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) {
  12747. this.raise(Errors.PrivateInExpectedIn, left, {
  12748. identifierName: value
  12749. });
  12750. }
  12751. this.classScope.usePrivateName(value, left.loc.start);
  12752. }
  12753. const op = this.state.type;
  12754. if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) {
  12755. let prec = tokenOperatorPrecedence(op);
  12756. if (prec > minPrec) {
  12757. if (op === 39) {
  12758. this.expectPlugin("pipelineOperator");
  12759. if (this.state.inFSharpPipelineDirectBody) {
  12760. return left;
  12761. }
  12762. this.checkPipelineAtInfixOperator(left, leftStartLoc);
  12763. }
  12764. const node = this.startNodeAt(leftStartLoc);
  12765. node.left = left;
  12766. node.operator = this.state.value;
  12767. const logical = op === 41 || op === 42;
  12768. const coalesce = op === 40;
  12769. if (coalesce) {
  12770. prec = tokenOperatorPrecedence(42);
  12771. }
  12772. this.next();
  12773. if (op === 39 && this.hasPlugin(["pipelineOperator", {
  12774. proposal: "minimal"
  12775. }])) {
  12776. if (this.state.type === 96 && this.prodParam.hasAwait) {
  12777. throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc);
  12778. }
  12779. }
  12780. node.right = this.parseExprOpRightExpr(op, prec);
  12781. const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
  12782. const nextOp = this.state.type;
  12783. if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) {
  12784. throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc);
  12785. }
  12786. return this.parseExprOp(finishedNode, leftStartLoc, minPrec);
  12787. }
  12788. }
  12789. return left;
  12790. }
  12791. parseExprOpRightExpr(op, prec) {
  12792. const startLoc = this.state.startLoc;
  12793. switch (op) {
  12794. case 39:
  12795. switch (this.getPluginOption("pipelineOperator", "proposal")) {
  12796. case "hack":
  12797. return this.withTopicBindingContext(() => {
  12798. return this.parseHackPipeBody();
  12799. });
  12800. case "smart":
  12801. return this.withTopicBindingContext(() => {
  12802. if (this.prodParam.hasYield && this.isContextual(108)) {
  12803. throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
  12804. }
  12805. return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
  12806. });
  12807. case "fsharp":
  12808. return this.withSoloAwaitPermittingContext(() => {
  12809. return this.parseFSharpPipelineBody(prec);
  12810. });
  12811. }
  12812. default:
  12813. return this.parseExprOpBaseRightExpr(op, prec);
  12814. }
  12815. }
  12816. parseExprOpBaseRightExpr(op, prec) {
  12817. const startLoc = this.state.startLoc;
  12818. return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
  12819. }
  12820. parseHackPipeBody() {
  12821. var _body$extra;
  12822. const {
  12823. startLoc
  12824. } = this.state;
  12825. const body = this.parseMaybeAssign();
  12826. const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type);
  12827. if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
  12828. this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
  12829. type: body.type
  12830. });
  12831. }
  12832. if (!this.topicReferenceWasUsedInCurrentContext()) {
  12833. this.raise(Errors.PipeTopicUnused, startLoc);
  12834. }
  12835. return body;
  12836. }
  12837. checkExponentialAfterUnary(node) {
  12838. if (this.match(57)) {
  12839. this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument);
  12840. }
  12841. }
  12842. parseMaybeUnary(refExpressionErrors, sawUnary) {
  12843. const startLoc = this.state.startLoc;
  12844. const isAwait = this.isContextual(96);
  12845. if (isAwait && this.isAwaitAllowed()) {
  12846. this.next();
  12847. const expr = this.parseAwait(startLoc);
  12848. if (!sawUnary) this.checkExponentialAfterUnary(expr);
  12849. return expr;
  12850. }
  12851. const update = this.match(34);
  12852. const node = this.startNode();
  12853. if (tokenIsPrefix(this.state.type)) {
  12854. node.operator = this.state.value;
  12855. node.prefix = true;
  12856. if (this.match(72)) {
  12857. this.expectPlugin("throwExpressions");
  12858. }
  12859. const isDelete = this.match(89);
  12860. this.next();
  12861. node.argument = this.parseMaybeUnary(null, true);
  12862. this.checkExpressionErrors(refExpressionErrors, true);
  12863. if (this.state.strict && isDelete) {
  12864. const arg = node.argument;
  12865. if (arg.type === "Identifier") {
  12866. this.raise(Errors.StrictDelete, node);
  12867. } else if (this.hasPropertyAsPrivateName(arg)) {
  12868. this.raise(Errors.DeletePrivateField, node);
  12869. }
  12870. }
  12871. if (!update) {
  12872. if (!sawUnary) {
  12873. this.checkExponentialAfterUnary(node);
  12874. }
  12875. return this.finishNode(node, "UnaryExpression");
  12876. }
  12877. }
  12878. const expr = this.parseUpdate(node, update, refExpressionErrors);
  12879. if (isAwait) {
  12880. const {
  12881. type
  12882. } = this.state;
  12883. const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54);
  12884. if (startsExpr && !this.isAmbiguousAwait()) {
  12885. this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc);
  12886. return this.parseAwait(startLoc);
  12887. }
  12888. }
  12889. return expr;
  12890. }
  12891. parseUpdate(node, update, refExpressionErrors) {
  12892. if (update) {
  12893. const updateExpressionNode = node;
  12894. this.checkLVal(updateExpressionNode.argument, {
  12895. in: this.finishNode(updateExpressionNode, "UpdateExpression")
  12896. });
  12897. return node;
  12898. }
  12899. const startLoc = this.state.startLoc;
  12900. let expr = this.parseExprSubscripts(refExpressionErrors);
  12901. if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
  12902. while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
  12903. const node = this.startNodeAt(startLoc);
  12904. node.operator = this.state.value;
  12905. node.prefix = false;
  12906. node.argument = expr;
  12907. this.next();
  12908. this.checkLVal(expr, {
  12909. in: expr = this.finishNode(node, "UpdateExpression")
  12910. });
  12911. }
  12912. return expr;
  12913. }
  12914. parseExprSubscripts(refExpressionErrors) {
  12915. const startLoc = this.state.startLoc;
  12916. const potentialArrowAt = this.state.potentialArrowAt;
  12917. const expr = this.parseExprAtom(refExpressionErrors);
  12918. if (this.shouldExitDescending(expr, potentialArrowAt)) {
  12919. return expr;
  12920. }
  12921. return this.parseSubscripts(expr, startLoc);
  12922. }
  12923. parseSubscripts(base, startLoc, noCalls) {
  12924. const state = {
  12925. optionalChainMember: false,
  12926. maybeAsyncArrow: this.atPossibleAsyncArrow(base),
  12927. stop: false
  12928. };
  12929. do {
  12930. base = this.parseSubscript(base, startLoc, noCalls, state);
  12931. state.maybeAsyncArrow = false;
  12932. } while (!state.stop);
  12933. return base;
  12934. }
  12935. parseSubscript(base, startLoc, noCalls, state) {
  12936. const {
  12937. type
  12938. } = this.state;
  12939. if (!noCalls && type === 15) {
  12940. return this.parseBind(base, startLoc, noCalls, state);
  12941. } else if (tokenIsTemplate(type)) {
  12942. return this.parseTaggedTemplateExpression(base, startLoc, state);
  12943. }
  12944. let optional = false;
  12945. if (type === 18) {
  12946. if (noCalls) {
  12947. this.raise(Errors.OptionalChainingNoNew, this.state.startLoc);
  12948. if (this.lookaheadCharCode() === 40) {
  12949. state.stop = true;
  12950. return base;
  12951. }
  12952. }
  12953. state.optionalChainMember = optional = true;
  12954. this.next();
  12955. }
  12956. if (!noCalls && this.match(10)) {
  12957. return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional);
  12958. } else {
  12959. const computed = this.eat(0);
  12960. if (computed || optional || this.eat(16)) {
  12961. return this.parseMember(base, startLoc, state, computed, optional);
  12962. } else {
  12963. state.stop = true;
  12964. return base;
  12965. }
  12966. }
  12967. }
  12968. parseMember(base, startLoc, state, computed, optional) {
  12969. const node = this.startNodeAt(startLoc);
  12970. node.object = base;
  12971. node.computed = computed;
  12972. if (computed) {
  12973. node.property = this.parseExpression();
  12974. this.expect(3);
  12975. } else if (this.match(138)) {
  12976. if (base.type === "Super") {
  12977. this.raise(Errors.SuperPrivateField, startLoc);
  12978. }
  12979. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  12980. node.property = this.parsePrivateName();
  12981. } else {
  12982. node.property = this.parseIdentifier(true);
  12983. }
  12984. if (state.optionalChainMember) {
  12985. node.optional = optional;
  12986. return this.finishNode(node, "OptionalMemberExpression");
  12987. } else {
  12988. return this.finishNode(node, "MemberExpression");
  12989. }
  12990. }
  12991. parseBind(base, startLoc, noCalls, state) {
  12992. const node = this.startNodeAt(startLoc);
  12993. node.object = base;
  12994. this.next();
  12995. node.callee = this.parseNoCallExpr();
  12996. state.stop = true;
  12997. return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls);
  12998. }
  12999. parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
  13000. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13001. let refExpressionErrors = null;
  13002. this.state.maybeInArrowParameters = true;
  13003. this.next();
  13004. const node = this.startNodeAt(startLoc);
  13005. node.callee = base;
  13006. const {
  13007. maybeAsyncArrow,
  13008. optionalChainMember
  13009. } = state;
  13010. if (maybeAsyncArrow) {
  13011. this.expressionScope.enter(newAsyncArrowScope());
  13012. refExpressionErrors = new ExpressionErrors();
  13013. }
  13014. if (optionalChainMember) {
  13015. node.optional = optional;
  13016. }
  13017. if (optional) {
  13018. node.arguments = this.parseCallExpressionArguments(11);
  13019. } else {
  13020. node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors);
  13021. }
  13022. let finishedNode = this.finishCallExpression(node, optionalChainMember);
  13023. if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
  13024. state.stop = true;
  13025. this.checkDestructuringPrivate(refExpressionErrors);
  13026. this.expressionScope.validateAsPattern();
  13027. this.expressionScope.exit();
  13028. finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
  13029. } else {
  13030. if (maybeAsyncArrow) {
  13031. this.checkExpressionErrors(refExpressionErrors, true);
  13032. this.expressionScope.exit();
  13033. }
  13034. this.toReferencedArguments(finishedNode);
  13035. }
  13036. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13037. return finishedNode;
  13038. }
  13039. toReferencedArguments(node, isParenthesizedExpr) {
  13040. this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
  13041. }
  13042. parseTaggedTemplateExpression(base, startLoc, state) {
  13043. const node = this.startNodeAt(startLoc);
  13044. node.tag = base;
  13045. node.quasi = this.parseTemplate(true);
  13046. if (state.optionalChainMember) {
  13047. this.raise(Errors.OptionalChainingNoTemplate, startLoc);
  13048. }
  13049. return this.finishNode(node, "TaggedTemplateExpression");
  13050. }
  13051. atPossibleAsyncArrow(base) {
  13052. 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;
  13053. }
  13054. expectImportAttributesPlugin() {
  13055. if (!this.hasPlugin("importAssertions")) {
  13056. this.expectPlugin("importAttributes");
  13057. }
  13058. }
  13059. finishCallExpression(node, optional) {
  13060. if (node.callee.type === "Import") {
  13061. if (node.arguments.length === 2) {
  13062. {
  13063. if (!this.hasPlugin("moduleAttributes")) {
  13064. this.expectImportAttributesPlugin();
  13065. }
  13066. }
  13067. }
  13068. if (node.arguments.length === 0 || node.arguments.length > 2) {
  13069. this.raise(Errors.ImportCallArity, node, {
  13070. maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1
  13071. });
  13072. } else {
  13073. for (const arg of node.arguments) {
  13074. if (arg.type === "SpreadElement") {
  13075. this.raise(Errors.ImportCallSpreadArgument, arg);
  13076. }
  13077. }
  13078. }
  13079. }
  13080. return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
  13081. }
  13082. parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) {
  13083. const elts = [];
  13084. let first = true;
  13085. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13086. this.state.inFSharpPipelineDirectBody = false;
  13087. while (!this.eat(close)) {
  13088. if (first) {
  13089. first = false;
  13090. } else {
  13091. this.expect(12);
  13092. if (this.match(close)) {
  13093. if (dynamicImport && !this.hasPlugin("importAttributes") && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
  13094. this.raise(Errors.ImportCallArgumentTrailingComma, this.state.lastTokStartLoc);
  13095. }
  13096. if (nodeForExtra) {
  13097. this.addTrailingCommaExtraToNode(nodeForExtra);
  13098. }
  13099. this.next();
  13100. break;
  13101. }
  13102. }
  13103. elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder));
  13104. }
  13105. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13106. return elts;
  13107. }
  13108. shouldParseAsyncArrow() {
  13109. return this.match(19) && !this.canInsertSemicolon();
  13110. }
  13111. parseAsyncArrowFromCallExpression(node, call) {
  13112. var _call$extra;
  13113. this.resetPreviousNodeTrailingComments(call);
  13114. this.expect(19);
  13115. this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
  13116. if (call.innerComments) {
  13117. setInnerComments(node, call.innerComments);
  13118. }
  13119. if (call.callee.trailingComments) {
  13120. setInnerComments(node, call.callee.trailingComments);
  13121. }
  13122. return node;
  13123. }
  13124. parseNoCallExpr() {
  13125. const startLoc = this.state.startLoc;
  13126. return this.parseSubscripts(this.parseExprAtom(), startLoc, true);
  13127. }
  13128. parseExprAtom(refExpressionErrors) {
  13129. let node;
  13130. let decorators = null;
  13131. const {
  13132. type
  13133. } = this.state;
  13134. switch (type) {
  13135. case 79:
  13136. return this.parseSuper();
  13137. case 83:
  13138. node = this.startNode();
  13139. this.next();
  13140. if (this.match(16)) {
  13141. return this.parseImportMetaProperty(node);
  13142. }
  13143. if (this.match(10)) {
  13144. if (this.options.createImportExpressions) {
  13145. return this.parseImportCall(node);
  13146. } else {
  13147. return this.finishNode(node, "Import");
  13148. }
  13149. } else {
  13150. this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc);
  13151. return this.finishNode(node, "Import");
  13152. }
  13153. case 78:
  13154. node = this.startNode();
  13155. this.next();
  13156. return this.finishNode(node, "ThisExpression");
  13157. case 90:
  13158. {
  13159. return this.parseDo(this.startNode(), false);
  13160. }
  13161. case 56:
  13162. case 31:
  13163. {
  13164. this.readRegexp();
  13165. return this.parseRegExpLiteral(this.state.value);
  13166. }
  13167. case 134:
  13168. return this.parseNumericLiteral(this.state.value);
  13169. case 135:
  13170. return this.parseBigIntLiteral(this.state.value);
  13171. case 136:
  13172. return this.parseDecimalLiteral(this.state.value);
  13173. case 133:
  13174. return this.parseStringLiteral(this.state.value);
  13175. case 84:
  13176. return this.parseNullLiteral();
  13177. case 85:
  13178. return this.parseBooleanLiteral(true);
  13179. case 86:
  13180. return this.parseBooleanLiteral(false);
  13181. case 10:
  13182. {
  13183. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13184. return this.parseParenAndDistinguishExpression(canBeArrow);
  13185. }
  13186. case 2:
  13187. case 1:
  13188. {
  13189. return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true);
  13190. }
  13191. case 0:
  13192. {
  13193. return this.parseArrayLike(3, true, false, refExpressionErrors);
  13194. }
  13195. case 6:
  13196. case 7:
  13197. {
  13198. return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
  13199. }
  13200. case 5:
  13201. {
  13202. return this.parseObjectLike(8, false, false, refExpressionErrors);
  13203. }
  13204. case 68:
  13205. return this.parseFunctionOrFunctionSent();
  13206. case 26:
  13207. decorators = this.parseDecorators();
  13208. case 80:
  13209. return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false);
  13210. case 77:
  13211. return this.parseNewOrNewTarget();
  13212. case 25:
  13213. case 24:
  13214. return this.parseTemplate(false);
  13215. case 15:
  13216. {
  13217. node = this.startNode();
  13218. this.next();
  13219. node.object = null;
  13220. const callee = node.callee = this.parseNoCallExpr();
  13221. if (callee.type === "MemberExpression") {
  13222. return this.finishNode(node, "BindExpression");
  13223. } else {
  13224. throw this.raise(Errors.UnsupportedBind, callee);
  13225. }
  13226. }
  13227. case 138:
  13228. {
  13229. this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
  13230. identifierName: this.state.value
  13231. });
  13232. return this.parsePrivateName();
  13233. }
  13234. case 33:
  13235. {
  13236. return this.parseTopicReferenceThenEqualsSign(54, "%");
  13237. }
  13238. case 32:
  13239. {
  13240. return this.parseTopicReferenceThenEqualsSign(44, "^");
  13241. }
  13242. case 37:
  13243. case 38:
  13244. {
  13245. return this.parseTopicReference("hack");
  13246. }
  13247. case 44:
  13248. case 54:
  13249. case 27:
  13250. {
  13251. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13252. if (pipeProposal) {
  13253. return this.parseTopicReference(pipeProposal);
  13254. }
  13255. this.unexpected();
  13256. break;
  13257. }
  13258. case 47:
  13259. {
  13260. const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
  13261. if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
  13262. this.expectOnePlugin(["jsx", "flow", "typescript"]);
  13263. } else {
  13264. this.unexpected();
  13265. }
  13266. break;
  13267. }
  13268. default:
  13269. if (tokenIsIdentifier(type)) {
  13270. if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) {
  13271. return this.parseModuleExpression();
  13272. }
  13273. const canBeArrow = this.state.potentialArrowAt === this.state.start;
  13274. const containsEsc = this.state.containsEsc;
  13275. const id = this.parseIdentifier();
  13276. if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
  13277. const {
  13278. type
  13279. } = this.state;
  13280. if (type === 68) {
  13281. this.resetPreviousNodeTrailingComments(id);
  13282. this.next();
  13283. return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
  13284. } else if (tokenIsIdentifier(type)) {
  13285. if (this.lookaheadCharCode() === 61) {
  13286. return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
  13287. } else {
  13288. return id;
  13289. }
  13290. } else if (type === 90) {
  13291. this.resetPreviousNodeTrailingComments(id);
  13292. return this.parseDo(this.startNodeAtNode(id), true);
  13293. }
  13294. }
  13295. if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) {
  13296. this.next();
  13297. return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
  13298. }
  13299. return id;
  13300. } else {
  13301. this.unexpected();
  13302. }
  13303. }
  13304. }
  13305. parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) {
  13306. const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
  13307. if (pipeProposal) {
  13308. this.state.type = topicTokenType;
  13309. this.state.value = topicTokenValue;
  13310. this.state.pos--;
  13311. this.state.end--;
  13312. this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
  13313. return this.parseTopicReference(pipeProposal);
  13314. } else {
  13315. this.unexpected();
  13316. }
  13317. }
  13318. parseTopicReference(pipeProposal) {
  13319. const node = this.startNode();
  13320. const startLoc = this.state.startLoc;
  13321. const tokenType = this.state.type;
  13322. this.next();
  13323. return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
  13324. }
  13325. finishTopicReference(node, startLoc, pipeProposal, tokenType) {
  13326. if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
  13327. const nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
  13328. if (!this.topicReferenceIsAllowedInCurrentContext()) {
  13329. this.raise(pipeProposal === "smart" ? Errors.PrimaryTopicNotAllowed : Errors.PipeTopicUnbound, startLoc);
  13330. }
  13331. this.registerTopicReference();
  13332. return this.finishNode(node, nodeType);
  13333. } else {
  13334. throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
  13335. token: tokenLabelName(tokenType)
  13336. });
  13337. }
  13338. }
  13339. testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
  13340. switch (pipeProposal) {
  13341. case "hack":
  13342. {
  13343. return this.hasPlugin(["pipelineOperator", {
  13344. topicToken: tokenLabelName(tokenType)
  13345. }]);
  13346. }
  13347. case "smart":
  13348. return tokenType === 27;
  13349. default:
  13350. throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc);
  13351. }
  13352. }
  13353. parseAsyncArrowUnaryFunction(node) {
  13354. this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
  13355. const params = [this.parseIdentifier()];
  13356. this.prodParam.exit();
  13357. if (this.hasPrecedingLineBreak()) {
  13358. this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition());
  13359. }
  13360. this.expect(19);
  13361. return this.parseArrowExpression(node, params, true);
  13362. }
  13363. parseDo(node, isAsync) {
  13364. this.expectPlugin("doExpressions");
  13365. if (isAsync) {
  13366. this.expectPlugin("asyncDoExpressions");
  13367. }
  13368. node.async = isAsync;
  13369. this.next();
  13370. const oldLabels = this.state.labels;
  13371. this.state.labels = [];
  13372. if (isAsync) {
  13373. this.prodParam.enter(2);
  13374. node.body = this.parseBlock();
  13375. this.prodParam.exit();
  13376. } else {
  13377. node.body = this.parseBlock();
  13378. }
  13379. this.state.labels = oldLabels;
  13380. return this.finishNode(node, "DoExpression");
  13381. }
  13382. parseSuper() {
  13383. const node = this.startNode();
  13384. this.next();
  13385. if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
  13386. this.raise(Errors.SuperNotAllowed, node);
  13387. } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
  13388. this.raise(Errors.UnexpectedSuper, node);
  13389. }
  13390. if (!this.match(10) && !this.match(0) && !this.match(16)) {
  13391. this.raise(Errors.UnsupportedSuper, node);
  13392. }
  13393. return this.finishNode(node, "Super");
  13394. }
  13395. parsePrivateName() {
  13396. const node = this.startNode();
  13397. const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1));
  13398. const name = this.state.value;
  13399. this.next();
  13400. node.id = this.createIdentifier(id, name);
  13401. return this.finishNode(node, "PrivateName");
  13402. }
  13403. parseFunctionOrFunctionSent() {
  13404. const node = this.startNode();
  13405. this.next();
  13406. if (this.prodParam.hasYield && this.match(16)) {
  13407. const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
  13408. this.next();
  13409. if (this.match(103)) {
  13410. this.expectPlugin("functionSent");
  13411. } else if (!this.hasPlugin("functionSent")) {
  13412. this.unexpected();
  13413. }
  13414. return this.parseMetaProperty(node, meta, "sent");
  13415. }
  13416. return this.parseFunction(node);
  13417. }
  13418. parseMetaProperty(node, meta, propertyName) {
  13419. node.meta = meta;
  13420. const containsEsc = this.state.containsEsc;
  13421. node.property = this.parseIdentifier(true);
  13422. if (node.property.name !== propertyName || containsEsc) {
  13423. this.raise(Errors.UnsupportedMetaProperty, node.property, {
  13424. target: meta.name,
  13425. onlyValidPropertyName: propertyName
  13426. });
  13427. }
  13428. return this.finishNode(node, "MetaProperty");
  13429. }
  13430. parseImportMetaProperty(node) {
  13431. const id = this.createIdentifier(this.startNodeAtNode(node), "import");
  13432. this.next();
  13433. if (this.isContextual(101)) {
  13434. if (!this.inModule) {
  13435. this.raise(Errors.ImportMetaOutsideModule, id);
  13436. }
  13437. this.sawUnambiguousESM = true;
  13438. } else if (this.isContextual(105) || this.isContextual(97)) {
  13439. const isSource = this.isContextual(105);
  13440. if (!isSource) this.unexpected();
  13441. this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
  13442. if (!this.options.createImportExpressions) {
  13443. throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, {
  13444. phase: this.state.value
  13445. });
  13446. }
  13447. this.next();
  13448. node.phase = isSource ? "source" : "defer";
  13449. return this.parseImportCall(node);
  13450. }
  13451. return this.parseMetaProperty(node, id, "meta");
  13452. }
  13453. parseLiteralAtNode(value, type, node) {
  13454. this.addExtra(node, "rawValue", value);
  13455. this.addExtra(node, "raw", this.input.slice(node.start, this.state.end));
  13456. node.value = value;
  13457. this.next();
  13458. return this.finishNode(node, type);
  13459. }
  13460. parseLiteral(value, type) {
  13461. const node = this.startNode();
  13462. return this.parseLiteralAtNode(value, type, node);
  13463. }
  13464. parseStringLiteral(value) {
  13465. return this.parseLiteral(value, "StringLiteral");
  13466. }
  13467. parseNumericLiteral(value) {
  13468. return this.parseLiteral(value, "NumericLiteral");
  13469. }
  13470. parseBigIntLiteral(value) {
  13471. return this.parseLiteral(value, "BigIntLiteral");
  13472. }
  13473. parseDecimalLiteral(value) {
  13474. return this.parseLiteral(value, "DecimalLiteral");
  13475. }
  13476. parseRegExpLiteral(value) {
  13477. const node = this.parseLiteral(value.value, "RegExpLiteral");
  13478. node.pattern = value.pattern;
  13479. node.flags = value.flags;
  13480. return node;
  13481. }
  13482. parseBooleanLiteral(value) {
  13483. const node = this.startNode();
  13484. node.value = value;
  13485. this.next();
  13486. return this.finishNode(node, "BooleanLiteral");
  13487. }
  13488. parseNullLiteral() {
  13489. const node = this.startNode();
  13490. this.next();
  13491. return this.finishNode(node, "NullLiteral");
  13492. }
  13493. parseParenAndDistinguishExpression(canBeArrow) {
  13494. const startLoc = this.state.startLoc;
  13495. let val;
  13496. this.next();
  13497. this.expressionScope.enter(newArrowHeadScope());
  13498. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13499. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13500. this.state.maybeInArrowParameters = true;
  13501. this.state.inFSharpPipelineDirectBody = false;
  13502. const innerStartLoc = this.state.startLoc;
  13503. const exprList = [];
  13504. const refExpressionErrors = new ExpressionErrors();
  13505. let first = true;
  13506. let spreadStartLoc;
  13507. let optionalCommaStartLoc;
  13508. while (!this.match(11)) {
  13509. if (first) {
  13510. first = false;
  13511. } else {
  13512. this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
  13513. if (this.match(11)) {
  13514. optionalCommaStartLoc = this.state.startLoc;
  13515. break;
  13516. }
  13517. }
  13518. if (this.match(21)) {
  13519. const spreadNodeStartLoc = this.state.startLoc;
  13520. spreadStartLoc = this.state.startLoc;
  13521. exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc));
  13522. if (!this.checkCommaAfterRest(41)) {
  13523. break;
  13524. }
  13525. } else {
  13526. exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
  13527. }
  13528. }
  13529. const innerEndLoc = this.state.lastTokEndLoc;
  13530. this.expect(11);
  13531. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13532. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13533. let arrowNode = this.startNodeAt(startLoc);
  13534. if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
  13535. this.checkDestructuringPrivate(refExpressionErrors);
  13536. this.expressionScope.validateAsPattern();
  13537. this.expressionScope.exit();
  13538. this.parseArrowExpression(arrowNode, exprList, false);
  13539. return arrowNode;
  13540. }
  13541. this.expressionScope.exit();
  13542. if (!exprList.length) {
  13543. this.unexpected(this.state.lastTokStartLoc);
  13544. }
  13545. if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
  13546. if (spreadStartLoc) this.unexpected(spreadStartLoc);
  13547. this.checkExpressionErrors(refExpressionErrors, true);
  13548. this.toReferencedListDeep(exprList, true);
  13549. if (exprList.length > 1) {
  13550. val = this.startNodeAt(innerStartLoc);
  13551. val.expressions = exprList;
  13552. this.finishNode(val, "SequenceExpression");
  13553. this.resetEndLocation(val, innerEndLoc);
  13554. } else {
  13555. val = exprList[0];
  13556. }
  13557. return this.wrapParenthesis(startLoc, val);
  13558. }
  13559. wrapParenthesis(startLoc, expression) {
  13560. if (!this.options.createParenthesizedExpressions) {
  13561. this.addExtra(expression, "parenthesized", true);
  13562. this.addExtra(expression, "parenStart", startLoc.index);
  13563. this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index);
  13564. return expression;
  13565. }
  13566. const parenExpression = this.startNodeAt(startLoc);
  13567. parenExpression.expression = expression;
  13568. return this.finishNode(parenExpression, "ParenthesizedExpression");
  13569. }
  13570. shouldParseArrow(params) {
  13571. return !this.canInsertSemicolon();
  13572. }
  13573. parseArrow(node) {
  13574. if (this.eat(19)) {
  13575. return node;
  13576. }
  13577. }
  13578. parseParenItem(node, startLoc) {
  13579. return node;
  13580. }
  13581. parseNewOrNewTarget() {
  13582. const node = this.startNode();
  13583. this.next();
  13584. if (this.match(16)) {
  13585. const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
  13586. this.next();
  13587. const metaProp = this.parseMetaProperty(node, meta, "target");
  13588. if (!this.scope.inNonArrowFunction && !this.scope.inClass && !this.options.allowNewTargetOutsideFunction) {
  13589. this.raise(Errors.UnexpectedNewTarget, metaProp);
  13590. }
  13591. return metaProp;
  13592. }
  13593. return this.parseNew(node);
  13594. }
  13595. parseNew(node) {
  13596. this.parseNewCallee(node);
  13597. if (this.eat(10)) {
  13598. const args = this.parseExprList(11);
  13599. this.toReferencedList(args);
  13600. node.arguments = args;
  13601. } else {
  13602. node.arguments = [];
  13603. }
  13604. return this.finishNode(node, "NewExpression");
  13605. }
  13606. parseNewCallee(node) {
  13607. const isImport = this.match(83);
  13608. const callee = this.parseNoCallExpr();
  13609. node.callee = callee;
  13610. if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) {
  13611. this.raise(Errors.ImportCallNotNewExpression, callee);
  13612. }
  13613. }
  13614. parseTemplateElement(isTagged) {
  13615. const {
  13616. start,
  13617. startLoc,
  13618. end,
  13619. value
  13620. } = this.state;
  13621. const elemStart = start + 1;
  13622. const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1));
  13623. if (value === null) {
  13624. if (!isTagged) {
  13625. this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1));
  13626. }
  13627. }
  13628. const isTail = this.match(24);
  13629. const endOffset = isTail ? -1 : -2;
  13630. const elemEnd = end + endOffset;
  13631. elem.value = {
  13632. raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"),
  13633. cooked: value === null ? null : value.slice(1, endOffset)
  13634. };
  13635. elem.tail = isTail;
  13636. this.next();
  13637. const finishedNode = this.finishNode(elem, "TemplateElement");
  13638. this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
  13639. return finishedNode;
  13640. }
  13641. parseTemplate(isTagged) {
  13642. const node = this.startNode();
  13643. let curElt = this.parseTemplateElement(isTagged);
  13644. const quasis = [curElt];
  13645. const substitutions = [];
  13646. while (!curElt.tail) {
  13647. substitutions.push(this.parseTemplateSubstitution());
  13648. this.readTemplateContinuation();
  13649. quasis.push(curElt = this.parseTemplateElement(isTagged));
  13650. }
  13651. node.expressions = substitutions;
  13652. node.quasis = quasis;
  13653. return this.finishNode(node, "TemplateLiteral");
  13654. }
  13655. parseTemplateSubstitution() {
  13656. return this.parseExpression();
  13657. }
  13658. parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
  13659. if (isRecord) {
  13660. this.expectPlugin("recordAndTuple");
  13661. }
  13662. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13663. this.state.inFSharpPipelineDirectBody = false;
  13664. const propHash = Object.create(null);
  13665. let first = true;
  13666. const node = this.startNode();
  13667. node.properties = [];
  13668. this.next();
  13669. while (!this.match(close)) {
  13670. if (first) {
  13671. first = false;
  13672. } else {
  13673. this.expect(12);
  13674. if (this.match(close)) {
  13675. this.addTrailingCommaExtraToNode(node);
  13676. break;
  13677. }
  13678. }
  13679. let prop;
  13680. if (isPattern) {
  13681. prop = this.parseBindingProperty();
  13682. } else {
  13683. prop = this.parsePropertyDefinition(refExpressionErrors);
  13684. this.checkProto(prop, isRecord, propHash, refExpressionErrors);
  13685. }
  13686. if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
  13687. this.raise(Errors.InvalidRecordProperty, prop);
  13688. }
  13689. {
  13690. if (prop.shorthand) {
  13691. this.addExtra(prop, "shorthand", true);
  13692. }
  13693. }
  13694. node.properties.push(prop);
  13695. }
  13696. this.next();
  13697. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13698. let type = "ObjectExpression";
  13699. if (isPattern) {
  13700. type = "ObjectPattern";
  13701. } else if (isRecord) {
  13702. type = "RecordExpression";
  13703. }
  13704. return this.finishNode(node, type);
  13705. }
  13706. addTrailingCommaExtraToNode(node) {
  13707. this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index);
  13708. this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
  13709. }
  13710. maybeAsyncOrAccessorProp(prop) {
  13711. return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55));
  13712. }
  13713. parsePropertyDefinition(refExpressionErrors) {
  13714. let decorators = [];
  13715. if (this.match(26)) {
  13716. if (this.hasPlugin("decorators")) {
  13717. this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
  13718. }
  13719. while (this.match(26)) {
  13720. decorators.push(this.parseDecorator());
  13721. }
  13722. }
  13723. const prop = this.startNode();
  13724. let isAsync = false;
  13725. let isAccessor = false;
  13726. let startLoc;
  13727. if (this.match(21)) {
  13728. if (decorators.length) this.unexpected();
  13729. return this.parseSpread();
  13730. }
  13731. if (decorators.length) {
  13732. prop.decorators = decorators;
  13733. decorators = [];
  13734. }
  13735. prop.method = false;
  13736. if (refExpressionErrors) {
  13737. startLoc = this.state.startLoc;
  13738. }
  13739. let isGenerator = this.eat(55);
  13740. this.parsePropertyNamePrefixOperator(prop);
  13741. const containsEsc = this.state.containsEsc;
  13742. this.parsePropertyName(prop, refExpressionErrors);
  13743. if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
  13744. const {
  13745. key
  13746. } = prop;
  13747. const keyName = key.name;
  13748. if (keyName === "async" && !this.hasPrecedingLineBreak()) {
  13749. isAsync = true;
  13750. this.resetPreviousNodeTrailingComments(key);
  13751. isGenerator = this.eat(55);
  13752. this.parsePropertyName(prop);
  13753. }
  13754. if (keyName === "get" || keyName === "set") {
  13755. isAccessor = true;
  13756. this.resetPreviousNodeTrailingComments(key);
  13757. prop.kind = keyName;
  13758. if (this.match(55)) {
  13759. isGenerator = true;
  13760. this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), {
  13761. kind: keyName
  13762. });
  13763. this.next();
  13764. }
  13765. this.parsePropertyName(prop);
  13766. }
  13767. }
  13768. return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors);
  13769. }
  13770. getGetterSetterExpectedParamCount(method) {
  13771. return method.kind === "get" ? 0 : 1;
  13772. }
  13773. getObjectOrClassMethodParams(method) {
  13774. return method.params;
  13775. }
  13776. checkGetterSetterParams(method) {
  13777. var _params;
  13778. const paramCount = this.getGetterSetterExpectedParamCount(method);
  13779. const params = this.getObjectOrClassMethodParams(method);
  13780. if (params.length !== paramCount) {
  13781. this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method);
  13782. }
  13783. if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
  13784. this.raise(Errors.BadSetterRestParameter, method);
  13785. }
  13786. }
  13787. parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
  13788. if (isAccessor) {
  13789. const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
  13790. this.checkGetterSetterParams(finishedProp);
  13791. return finishedProp;
  13792. }
  13793. if (isAsync || isGenerator || this.match(10)) {
  13794. if (isPattern) this.unexpected();
  13795. prop.kind = "method";
  13796. prop.method = true;
  13797. return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
  13798. }
  13799. }
  13800. parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
  13801. prop.shorthand = false;
  13802. if (this.eat(14)) {
  13803. prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
  13804. return this.finishNode(prop, "ObjectProperty");
  13805. }
  13806. if (!prop.computed && prop.key.type === "Identifier") {
  13807. this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
  13808. if (isPattern) {
  13809. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13810. } else if (this.match(29)) {
  13811. const shorthandAssignLoc = this.state.startLoc;
  13812. if (refExpressionErrors != null) {
  13813. if (refExpressionErrors.shorthandAssignLoc === null) {
  13814. refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
  13815. }
  13816. } else {
  13817. this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc);
  13818. }
  13819. prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key));
  13820. } else {
  13821. prop.value = cloneIdentifier(prop.key);
  13822. }
  13823. prop.shorthand = true;
  13824. return this.finishNode(prop, "ObjectProperty");
  13825. }
  13826. }
  13827. parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
  13828. const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
  13829. if (!node) this.unexpected();
  13830. return node;
  13831. }
  13832. parsePropertyName(prop, refExpressionErrors) {
  13833. if (this.eat(0)) {
  13834. prop.computed = true;
  13835. prop.key = this.parseMaybeAssignAllowIn();
  13836. this.expect(3);
  13837. } else {
  13838. const {
  13839. type,
  13840. value
  13841. } = this.state;
  13842. let key;
  13843. if (tokenIsKeywordOrIdentifier(type)) {
  13844. key = this.parseIdentifier(true);
  13845. } else {
  13846. switch (type) {
  13847. case 134:
  13848. key = this.parseNumericLiteral(value);
  13849. break;
  13850. case 133:
  13851. key = this.parseStringLiteral(value);
  13852. break;
  13853. case 135:
  13854. key = this.parseBigIntLiteral(value);
  13855. break;
  13856. case 136:
  13857. key = this.parseDecimalLiteral(value);
  13858. break;
  13859. case 138:
  13860. {
  13861. const privateKeyLoc = this.state.startLoc;
  13862. if (refExpressionErrors != null) {
  13863. if (refExpressionErrors.privateKeyLoc === null) {
  13864. refExpressionErrors.privateKeyLoc = privateKeyLoc;
  13865. }
  13866. } else {
  13867. this.raise(Errors.UnexpectedPrivateField, privateKeyLoc);
  13868. }
  13869. key = this.parsePrivateName();
  13870. break;
  13871. }
  13872. default:
  13873. this.unexpected();
  13874. }
  13875. }
  13876. prop.key = key;
  13877. if (type !== 138) {
  13878. prop.computed = false;
  13879. }
  13880. }
  13881. }
  13882. initFunction(node, isAsync) {
  13883. node.id = null;
  13884. node.generator = false;
  13885. node.async = isAsync;
  13886. }
  13887. parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
  13888. this.initFunction(node, isAsync);
  13889. node.generator = isGenerator;
  13890. this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0));
  13891. this.prodParam.enter(functionFlags(isAsync, node.generator));
  13892. this.parseFunctionParams(node, isConstructor);
  13893. const finishedNode = this.parseFunctionBodyAndFinish(node, type, true);
  13894. this.prodParam.exit();
  13895. this.scope.exit();
  13896. return finishedNode;
  13897. }
  13898. parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
  13899. if (isTuple) {
  13900. this.expectPlugin("recordAndTuple");
  13901. }
  13902. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  13903. this.state.inFSharpPipelineDirectBody = false;
  13904. const node = this.startNode();
  13905. this.next();
  13906. node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
  13907. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  13908. return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
  13909. }
  13910. parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
  13911. this.scope.enter(2 | 4);
  13912. let flags = functionFlags(isAsync, false);
  13913. if (!this.match(5) && this.prodParam.hasIn) {
  13914. flags |= 8;
  13915. }
  13916. this.prodParam.enter(flags);
  13917. this.initFunction(node, isAsync);
  13918. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  13919. if (params) {
  13920. this.state.maybeInArrowParameters = true;
  13921. this.setArrowFunctionParameters(node, params, trailingCommaLoc);
  13922. }
  13923. this.state.maybeInArrowParameters = false;
  13924. this.parseFunctionBody(node, true);
  13925. this.prodParam.exit();
  13926. this.scope.exit();
  13927. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  13928. return this.finishNode(node, "ArrowFunctionExpression");
  13929. }
  13930. setArrowFunctionParameters(node, params, trailingCommaLoc) {
  13931. this.toAssignableList(params, trailingCommaLoc, false);
  13932. node.params = params;
  13933. }
  13934. parseFunctionBodyAndFinish(node, type, isMethod = false) {
  13935. this.parseFunctionBody(node, false, isMethod);
  13936. return this.finishNode(node, type);
  13937. }
  13938. parseFunctionBody(node, allowExpression, isMethod = false) {
  13939. const isExpression = allowExpression && !this.match(5);
  13940. this.expressionScope.enter(newExpressionScope());
  13941. if (isExpression) {
  13942. node.body = this.parseMaybeAssign();
  13943. this.checkParams(node, false, allowExpression, false);
  13944. } else {
  13945. const oldStrict = this.state.strict;
  13946. const oldLabels = this.state.labels;
  13947. this.state.labels = [];
  13948. this.prodParam.enter(this.prodParam.currentFlags() | 4);
  13949. node.body = this.parseBlock(true, false, hasStrictModeDirective => {
  13950. const nonSimple = !this.isSimpleParamList(node.params);
  13951. if (hasStrictModeDirective && nonSimple) {
  13952. this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node);
  13953. }
  13954. const strictModeChanged = !oldStrict && this.state.strict;
  13955. this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
  13956. if (this.state.strict && node.id) {
  13957. this.checkIdentifier(node.id, 65, strictModeChanged);
  13958. }
  13959. });
  13960. this.prodParam.exit();
  13961. this.state.labels = oldLabels;
  13962. }
  13963. this.expressionScope.exit();
  13964. }
  13965. isSimpleParameter(node) {
  13966. return node.type === "Identifier";
  13967. }
  13968. isSimpleParamList(params) {
  13969. for (let i = 0, len = params.length; i < len; i++) {
  13970. if (!this.isSimpleParameter(params[i])) return false;
  13971. }
  13972. return true;
  13973. }
  13974. checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
  13975. const checkClashes = !allowDuplicates && new Set();
  13976. const formalParameters = {
  13977. type: "FormalParameters"
  13978. };
  13979. for (const param of node.params) {
  13980. this.checkLVal(param, {
  13981. in: formalParameters,
  13982. binding: 5,
  13983. checkClashes,
  13984. strictModeChanged
  13985. });
  13986. }
  13987. }
  13988. parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
  13989. const elts = [];
  13990. let first = true;
  13991. while (!this.eat(close)) {
  13992. if (first) {
  13993. first = false;
  13994. } else {
  13995. this.expect(12);
  13996. if (this.match(close)) {
  13997. if (nodeForExtra) {
  13998. this.addTrailingCommaExtraToNode(nodeForExtra);
  13999. }
  14000. this.next();
  14001. break;
  14002. }
  14003. }
  14004. elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
  14005. }
  14006. return elts;
  14007. }
  14008. parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) {
  14009. let elt;
  14010. if (this.match(12)) {
  14011. if (!allowEmpty) {
  14012. this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
  14013. unexpected: ","
  14014. });
  14015. }
  14016. elt = null;
  14017. } else if (this.match(21)) {
  14018. const spreadNodeStartLoc = this.state.startLoc;
  14019. elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc);
  14020. } else if (this.match(17)) {
  14021. this.expectPlugin("partialApplication");
  14022. if (!allowPlaceholder) {
  14023. this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
  14024. }
  14025. const node = this.startNode();
  14026. this.next();
  14027. elt = this.finishNode(node, "ArgumentPlaceholder");
  14028. } else {
  14029. elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem);
  14030. }
  14031. return elt;
  14032. }
  14033. parseIdentifier(liberal) {
  14034. const node = this.startNode();
  14035. const name = this.parseIdentifierName(liberal);
  14036. return this.createIdentifier(node, name);
  14037. }
  14038. createIdentifier(node, name) {
  14039. node.name = name;
  14040. node.loc.identifierName = name;
  14041. return this.finishNode(node, "Identifier");
  14042. }
  14043. parseIdentifierName(liberal) {
  14044. let name;
  14045. const {
  14046. startLoc,
  14047. type
  14048. } = this.state;
  14049. if (tokenIsKeywordOrIdentifier(type)) {
  14050. name = this.state.value;
  14051. } else {
  14052. this.unexpected();
  14053. }
  14054. const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
  14055. if (liberal) {
  14056. if (tokenIsKeyword) {
  14057. this.replaceToken(132);
  14058. }
  14059. } else {
  14060. this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
  14061. }
  14062. this.next();
  14063. return name;
  14064. }
  14065. checkReservedWord(word, startLoc, checkKeywords, isBinding) {
  14066. if (word.length > 10) {
  14067. return;
  14068. }
  14069. if (!canBeReservedWord(word)) {
  14070. return;
  14071. }
  14072. if (checkKeywords && isKeyword(word)) {
  14073. this.raise(Errors.UnexpectedKeyword, startLoc, {
  14074. keyword: word
  14075. });
  14076. return;
  14077. }
  14078. const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
  14079. if (reservedTest(word, this.inModule)) {
  14080. this.raise(Errors.UnexpectedReservedWord, startLoc, {
  14081. reservedWord: word
  14082. });
  14083. return;
  14084. } else if (word === "yield") {
  14085. if (this.prodParam.hasYield) {
  14086. this.raise(Errors.YieldBindingIdentifier, startLoc);
  14087. return;
  14088. }
  14089. } else if (word === "await") {
  14090. if (this.prodParam.hasAwait) {
  14091. this.raise(Errors.AwaitBindingIdentifier, startLoc);
  14092. return;
  14093. }
  14094. if (this.scope.inStaticBlock) {
  14095. this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc);
  14096. return;
  14097. }
  14098. this.expressionScope.recordAsyncArrowParametersError(startLoc);
  14099. } else if (word === "arguments") {
  14100. if (this.scope.inClassAndNotInNonArrowFunction) {
  14101. this.raise(Errors.ArgumentsInClass, startLoc);
  14102. return;
  14103. }
  14104. }
  14105. }
  14106. isAwaitAllowed() {
  14107. if (this.prodParam.hasAwait) return true;
  14108. if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
  14109. return true;
  14110. }
  14111. return false;
  14112. }
  14113. parseAwait(startLoc) {
  14114. const node = this.startNodeAt(startLoc);
  14115. this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node);
  14116. if (this.eat(55)) {
  14117. this.raise(Errors.ObsoleteAwaitStar, node);
  14118. }
  14119. if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
  14120. if (this.isAmbiguousAwait()) {
  14121. this.ambiguousScriptDifferentAst = true;
  14122. } else {
  14123. this.sawUnambiguousESM = true;
  14124. }
  14125. }
  14126. if (!this.state.soloAwait) {
  14127. node.argument = this.parseMaybeUnary(null, true);
  14128. }
  14129. return this.finishNode(node, "AwaitExpression");
  14130. }
  14131. isAmbiguousAwait() {
  14132. if (this.hasPrecedingLineBreak()) return true;
  14133. const {
  14134. type
  14135. } = this.state;
  14136. return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
  14137. }
  14138. parseYield() {
  14139. const node = this.startNode();
  14140. this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node);
  14141. this.next();
  14142. let delegating = false;
  14143. let argument = null;
  14144. if (!this.hasPrecedingLineBreak()) {
  14145. delegating = this.eat(55);
  14146. switch (this.state.type) {
  14147. case 13:
  14148. case 139:
  14149. case 8:
  14150. case 11:
  14151. case 3:
  14152. case 9:
  14153. case 14:
  14154. case 12:
  14155. if (!delegating) break;
  14156. default:
  14157. argument = this.parseMaybeAssign();
  14158. }
  14159. }
  14160. node.delegate = delegating;
  14161. node.argument = argument;
  14162. return this.finishNode(node, "YieldExpression");
  14163. }
  14164. parseImportCall(node) {
  14165. this.next();
  14166. node.source = this.parseMaybeAssignAllowIn();
  14167. if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  14168. node.options = null;
  14169. }
  14170. if (this.eat(12)) {
  14171. this.expectImportAttributesPlugin();
  14172. if (!this.match(11)) {
  14173. node.options = this.parseMaybeAssignAllowIn();
  14174. this.eat(12);
  14175. }
  14176. }
  14177. this.expect(11);
  14178. return this.finishNode(node, "ImportExpression");
  14179. }
  14180. checkPipelineAtInfixOperator(left, leftStartLoc) {
  14181. if (this.hasPlugin(["pipelineOperator", {
  14182. proposal: "smart"
  14183. }])) {
  14184. if (left.type === "SequenceExpression") {
  14185. this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc);
  14186. }
  14187. }
  14188. }
  14189. parseSmartPipelineBodyInStyle(childExpr, startLoc) {
  14190. if (this.isSimpleReference(childExpr)) {
  14191. const bodyNode = this.startNodeAt(startLoc);
  14192. bodyNode.callee = childExpr;
  14193. return this.finishNode(bodyNode, "PipelineBareFunction");
  14194. } else {
  14195. const bodyNode = this.startNodeAt(startLoc);
  14196. this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
  14197. bodyNode.expression = childExpr;
  14198. return this.finishNode(bodyNode, "PipelineTopicExpression");
  14199. }
  14200. }
  14201. isSimpleReference(expression) {
  14202. switch (expression.type) {
  14203. case "MemberExpression":
  14204. return !expression.computed && this.isSimpleReference(expression.object);
  14205. case "Identifier":
  14206. return true;
  14207. default:
  14208. return false;
  14209. }
  14210. }
  14211. checkSmartPipeTopicBodyEarlyErrors(startLoc) {
  14212. if (this.match(19)) {
  14213. throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc);
  14214. }
  14215. if (!this.topicReferenceWasUsedInCurrentContext()) {
  14216. this.raise(Errors.PipelineTopicUnused, startLoc);
  14217. }
  14218. }
  14219. withTopicBindingContext(callback) {
  14220. const outerContextTopicState = this.state.topicContext;
  14221. this.state.topicContext = {
  14222. maxNumOfResolvableTopics: 1,
  14223. maxTopicIndex: null
  14224. };
  14225. try {
  14226. return callback();
  14227. } finally {
  14228. this.state.topicContext = outerContextTopicState;
  14229. }
  14230. }
  14231. withSmartMixTopicForbiddingContext(callback) {
  14232. if (this.hasPlugin(["pipelineOperator", {
  14233. proposal: "smart"
  14234. }])) {
  14235. const outerContextTopicState = this.state.topicContext;
  14236. this.state.topicContext = {
  14237. maxNumOfResolvableTopics: 0,
  14238. maxTopicIndex: null
  14239. };
  14240. try {
  14241. return callback();
  14242. } finally {
  14243. this.state.topicContext = outerContextTopicState;
  14244. }
  14245. } else {
  14246. return callback();
  14247. }
  14248. }
  14249. withSoloAwaitPermittingContext(callback) {
  14250. const outerContextSoloAwaitState = this.state.soloAwait;
  14251. this.state.soloAwait = true;
  14252. try {
  14253. return callback();
  14254. } finally {
  14255. this.state.soloAwait = outerContextSoloAwaitState;
  14256. }
  14257. }
  14258. allowInAnd(callback) {
  14259. const flags = this.prodParam.currentFlags();
  14260. const prodParamToSet = 8 & ~flags;
  14261. if (prodParamToSet) {
  14262. this.prodParam.enter(flags | 8);
  14263. try {
  14264. return callback();
  14265. } finally {
  14266. this.prodParam.exit();
  14267. }
  14268. }
  14269. return callback();
  14270. }
  14271. disallowInAnd(callback) {
  14272. const flags = this.prodParam.currentFlags();
  14273. const prodParamToClear = 8 & flags;
  14274. if (prodParamToClear) {
  14275. this.prodParam.enter(flags & ~8);
  14276. try {
  14277. return callback();
  14278. } finally {
  14279. this.prodParam.exit();
  14280. }
  14281. }
  14282. return callback();
  14283. }
  14284. registerTopicReference() {
  14285. this.state.topicContext.maxTopicIndex = 0;
  14286. }
  14287. topicReferenceIsAllowedInCurrentContext() {
  14288. return this.state.topicContext.maxNumOfResolvableTopics >= 1;
  14289. }
  14290. topicReferenceWasUsedInCurrentContext() {
  14291. return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
  14292. }
  14293. parseFSharpPipelineBody(prec) {
  14294. const startLoc = this.state.startLoc;
  14295. this.state.potentialArrowAt = this.state.start;
  14296. const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
  14297. this.state.inFSharpPipelineDirectBody = true;
  14298. const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec);
  14299. this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
  14300. return ret;
  14301. }
  14302. parseModuleExpression() {
  14303. this.expectPlugin("moduleBlocks");
  14304. const node = this.startNode();
  14305. this.next();
  14306. if (!this.match(5)) {
  14307. this.unexpected(null, 5);
  14308. }
  14309. const program = this.startNodeAt(this.state.endLoc);
  14310. this.next();
  14311. const revertScopes = this.initializeScopes(true);
  14312. this.enterInitialScopes();
  14313. try {
  14314. node.body = this.parseProgram(program, 8, "module");
  14315. } finally {
  14316. revertScopes();
  14317. }
  14318. return this.finishNode(node, "ModuleExpression");
  14319. }
  14320. parsePropertyNamePrefixOperator(prop) {}
  14321. }
  14322. const loopLabel = {
  14323. kind: 1
  14324. },
  14325. switchLabel = {
  14326. kind: 2
  14327. };
  14328. const loneSurrogate = /[\uD800-\uDFFF]/u;
  14329. const keywordRelationalOperator = /in(?:stanceof)?/y;
  14330. function babel7CompatTokens(tokens, input) {
  14331. for (let i = 0; i < tokens.length; i++) {
  14332. const token = tokens[i];
  14333. const {
  14334. type
  14335. } = token;
  14336. if (typeof type === "number") {
  14337. {
  14338. if (type === 138) {
  14339. const {
  14340. loc,
  14341. start,
  14342. value,
  14343. end
  14344. } = token;
  14345. const hashEndPos = start + 1;
  14346. const hashEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14347. tokens.splice(i, 1, new Token({
  14348. type: getExportedToken(27),
  14349. value: "#",
  14350. start: start,
  14351. end: hashEndPos,
  14352. startLoc: loc.start,
  14353. endLoc: hashEndLoc
  14354. }), new Token({
  14355. type: getExportedToken(132),
  14356. value: value,
  14357. start: hashEndPos,
  14358. end: end,
  14359. startLoc: hashEndLoc,
  14360. endLoc: loc.end
  14361. }));
  14362. i++;
  14363. continue;
  14364. }
  14365. if (tokenIsTemplate(type)) {
  14366. const {
  14367. loc,
  14368. start,
  14369. value,
  14370. end
  14371. } = token;
  14372. const backquoteEnd = start + 1;
  14373. const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
  14374. let startToken;
  14375. if (input.charCodeAt(start) === 96) {
  14376. startToken = new Token({
  14377. type: getExportedToken(22),
  14378. value: "`",
  14379. start: start,
  14380. end: backquoteEnd,
  14381. startLoc: loc.start,
  14382. endLoc: backquoteEndLoc
  14383. });
  14384. } else {
  14385. startToken = new Token({
  14386. type: getExportedToken(8),
  14387. value: "}",
  14388. start: start,
  14389. end: backquoteEnd,
  14390. startLoc: loc.start,
  14391. endLoc: backquoteEndLoc
  14392. });
  14393. }
  14394. let templateValue, templateElementEnd, templateElementEndLoc, endToken;
  14395. if (type === 24) {
  14396. templateElementEnd = end - 1;
  14397. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1);
  14398. templateValue = value === null ? null : value.slice(1, -1);
  14399. endToken = new Token({
  14400. type: getExportedToken(22),
  14401. value: "`",
  14402. start: templateElementEnd,
  14403. end: end,
  14404. startLoc: templateElementEndLoc,
  14405. endLoc: loc.end
  14406. });
  14407. } else {
  14408. templateElementEnd = end - 2;
  14409. templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2);
  14410. templateValue = value === null ? null : value.slice(1, -2);
  14411. endToken = new Token({
  14412. type: getExportedToken(23),
  14413. value: "${",
  14414. start: templateElementEnd,
  14415. end: end,
  14416. startLoc: templateElementEndLoc,
  14417. endLoc: loc.end
  14418. });
  14419. }
  14420. tokens.splice(i, 1, startToken, new Token({
  14421. type: getExportedToken(20),
  14422. value: templateValue,
  14423. start: backquoteEnd,
  14424. end: templateElementEnd,
  14425. startLoc: backquoteEndLoc,
  14426. endLoc: templateElementEndLoc
  14427. }), endToken);
  14428. i += 2;
  14429. continue;
  14430. }
  14431. }
  14432. token.type = getExportedToken(type);
  14433. }
  14434. }
  14435. return tokens;
  14436. }
  14437. class StatementParser extends ExpressionParser {
  14438. parseTopLevel(file, program) {
  14439. file.program = this.parseProgram(program);
  14440. file.comments = this.comments;
  14441. if (this.options.tokens) {
  14442. file.tokens = babel7CompatTokens(this.tokens, this.input);
  14443. }
  14444. return this.finishNode(file, "File");
  14445. }
  14446. parseProgram(program, end = 139, sourceType = this.options.sourceType) {
  14447. program.sourceType = sourceType;
  14448. program.interpreter = this.parseInterpreterDirective();
  14449. this.parseBlockBody(program, true, true, end);
  14450. if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
  14451. for (const [localName, at] of Array.from(this.scope.undefinedExports)) {
  14452. this.raise(Errors.ModuleExportUndefined, at, {
  14453. localName
  14454. });
  14455. }
  14456. }
  14457. let finishedProgram;
  14458. if (end === 139) {
  14459. finishedProgram = this.finishNode(program, "Program");
  14460. } else {
  14461. finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
  14462. }
  14463. return finishedProgram;
  14464. }
  14465. stmtToDirective(stmt) {
  14466. const directive = stmt;
  14467. directive.type = "Directive";
  14468. directive.value = directive.expression;
  14469. delete directive.expression;
  14470. const directiveLiteral = directive.value;
  14471. const expressionValue = directiveLiteral.value;
  14472. const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end);
  14473. const val = directiveLiteral.value = raw.slice(1, -1);
  14474. this.addExtra(directiveLiteral, "raw", raw);
  14475. this.addExtra(directiveLiteral, "rawValue", val);
  14476. this.addExtra(directiveLiteral, "expressionValue", expressionValue);
  14477. directiveLiteral.type = "DirectiveLiteral";
  14478. return directive;
  14479. }
  14480. parseInterpreterDirective() {
  14481. if (!this.match(28)) {
  14482. return null;
  14483. }
  14484. const node = this.startNode();
  14485. node.value = this.state.value;
  14486. this.next();
  14487. return this.finishNode(node, "InterpreterDirective");
  14488. }
  14489. isLet() {
  14490. if (!this.isContextual(100)) {
  14491. return false;
  14492. }
  14493. return this.hasFollowingBindingAtom();
  14494. }
  14495. chStartsBindingIdentifier(ch, pos) {
  14496. if (isIdentifierStart(ch)) {
  14497. keywordRelationalOperator.lastIndex = pos;
  14498. if (keywordRelationalOperator.test(this.input)) {
  14499. const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
  14500. if (!isIdentifierChar(endCh) && endCh !== 92) {
  14501. return false;
  14502. }
  14503. }
  14504. return true;
  14505. } else if (ch === 92) {
  14506. return true;
  14507. } else {
  14508. return false;
  14509. }
  14510. }
  14511. chStartsBindingPattern(ch) {
  14512. return ch === 91 || ch === 123;
  14513. }
  14514. hasFollowingBindingAtom() {
  14515. const next = this.nextTokenStart();
  14516. const nextCh = this.codePointAtPos(next);
  14517. return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
  14518. }
  14519. hasInLineFollowingBindingIdentifier() {
  14520. const next = this.nextTokenInLineStart();
  14521. const nextCh = this.codePointAtPos(next);
  14522. return this.chStartsBindingIdentifier(nextCh, next);
  14523. }
  14524. startsUsingForOf() {
  14525. const {
  14526. type,
  14527. containsEsc
  14528. } = this.lookahead();
  14529. if (type === 102 && !containsEsc) {
  14530. return false;
  14531. } else if (tokenIsIdentifier(type) && !this.hasFollowingLineBreak()) {
  14532. this.expectPlugin("explicitResourceManagement");
  14533. return true;
  14534. }
  14535. }
  14536. startsAwaitUsing() {
  14537. let next = this.nextTokenInLineStart();
  14538. if (this.isUnparsedContextual(next, "using")) {
  14539. next = this.nextTokenInLineStartSince(next + 5);
  14540. const nextCh = this.codePointAtPos(next);
  14541. if (this.chStartsBindingIdentifier(nextCh, next)) {
  14542. this.expectPlugin("explicitResourceManagement");
  14543. return true;
  14544. }
  14545. }
  14546. return false;
  14547. }
  14548. parseModuleItem() {
  14549. return this.parseStatementLike(1 | 2 | 4 | 8);
  14550. }
  14551. parseStatementListItem() {
  14552. return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8));
  14553. }
  14554. parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) {
  14555. let flags = 0;
  14556. if (this.options.annexB && !this.state.strict) {
  14557. flags |= 4;
  14558. if (allowLabeledFunction) {
  14559. flags |= 8;
  14560. }
  14561. }
  14562. return this.parseStatementLike(flags);
  14563. }
  14564. parseStatement() {
  14565. return this.parseStatementLike(0);
  14566. }
  14567. parseStatementLike(flags) {
  14568. let decorators = null;
  14569. if (this.match(26)) {
  14570. decorators = this.parseDecorators(true);
  14571. }
  14572. return this.parseStatementContent(flags, decorators);
  14573. }
  14574. parseStatementContent(flags, decorators) {
  14575. const starttype = this.state.type;
  14576. const node = this.startNode();
  14577. const allowDeclaration = !!(flags & 2);
  14578. const allowFunctionDeclaration = !!(flags & 4);
  14579. const topLevel = flags & 1;
  14580. switch (starttype) {
  14581. case 60:
  14582. return this.parseBreakContinueStatement(node, true);
  14583. case 63:
  14584. return this.parseBreakContinueStatement(node, false);
  14585. case 64:
  14586. return this.parseDebuggerStatement(node);
  14587. case 90:
  14588. return this.parseDoWhileStatement(node);
  14589. case 91:
  14590. return this.parseForStatement(node);
  14591. case 68:
  14592. if (this.lookaheadCharCode() === 46) break;
  14593. if (!allowFunctionDeclaration) {
  14594. this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc);
  14595. }
  14596. return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
  14597. case 80:
  14598. if (!allowDeclaration) this.unexpected();
  14599. return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
  14600. case 69:
  14601. return this.parseIfStatement(node);
  14602. case 70:
  14603. return this.parseReturnStatement(node);
  14604. case 71:
  14605. return this.parseSwitchStatement(node);
  14606. case 72:
  14607. return this.parseThrowStatement(node);
  14608. case 73:
  14609. return this.parseTryStatement(node);
  14610. case 96:
  14611. if (!this.state.containsEsc && this.startsAwaitUsing()) {
  14612. if (!this.isAwaitAllowed()) {
  14613. this.raise(Errors.AwaitUsingNotInAsyncContext, node);
  14614. } else if (!allowDeclaration) {
  14615. this.raise(Errors.UnexpectedLexicalDeclaration, node);
  14616. }
  14617. this.next();
  14618. return this.parseVarStatement(node, "await using");
  14619. }
  14620. break;
  14621. case 107:
  14622. if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifier()) {
  14623. break;
  14624. }
  14625. this.expectPlugin("explicitResourceManagement");
  14626. if (!this.scope.inModule && this.scope.inTopLevel) {
  14627. this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc);
  14628. } else if (!allowDeclaration) {
  14629. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14630. }
  14631. return this.parseVarStatement(node, "using");
  14632. case 100:
  14633. {
  14634. if (this.state.containsEsc) {
  14635. break;
  14636. }
  14637. const next = this.nextTokenStart();
  14638. const nextCh = this.codePointAtPos(next);
  14639. if (nextCh !== 91) {
  14640. if (!allowDeclaration && this.hasFollowingLineBreak()) break;
  14641. if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
  14642. break;
  14643. }
  14644. }
  14645. }
  14646. case 75:
  14647. {
  14648. if (!allowDeclaration) {
  14649. this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc);
  14650. }
  14651. }
  14652. case 74:
  14653. {
  14654. const kind = this.state.value;
  14655. return this.parseVarStatement(node, kind);
  14656. }
  14657. case 92:
  14658. return this.parseWhileStatement(node);
  14659. case 76:
  14660. return this.parseWithStatement(node);
  14661. case 5:
  14662. return this.parseBlock();
  14663. case 13:
  14664. return this.parseEmptyStatement(node);
  14665. case 83:
  14666. {
  14667. const nextTokenCharCode = this.lookaheadCharCode();
  14668. if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
  14669. break;
  14670. }
  14671. }
  14672. case 82:
  14673. {
  14674. if (!this.options.allowImportExportEverywhere && !topLevel) {
  14675. this.raise(Errors.UnexpectedImportExport, this.state.startLoc);
  14676. }
  14677. this.next();
  14678. let result;
  14679. if (starttype === 83) {
  14680. result = this.parseImport(node);
  14681. if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
  14682. this.sawUnambiguousESM = true;
  14683. }
  14684. } else {
  14685. result = this.parseExport(node, decorators);
  14686. if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
  14687. this.sawUnambiguousESM = true;
  14688. }
  14689. }
  14690. this.assertModuleNodeAllowed(result);
  14691. return result;
  14692. }
  14693. default:
  14694. {
  14695. if (this.isAsyncFunction()) {
  14696. if (!allowDeclaration) {
  14697. this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc);
  14698. }
  14699. this.next();
  14700. return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
  14701. }
  14702. }
  14703. }
  14704. const maybeName = this.state.value;
  14705. const expr = this.parseExpression();
  14706. if (tokenIsIdentifier(starttype) && expr.type === "Identifier" && this.eat(14)) {
  14707. return this.parseLabeledStatement(node, maybeName, expr, flags);
  14708. } else {
  14709. return this.parseExpressionStatement(node, expr, decorators);
  14710. }
  14711. }
  14712. assertModuleNodeAllowed(node) {
  14713. if (!this.options.allowImportExportEverywhere && !this.inModule) {
  14714. this.raise(Errors.ImportOutsideModule, node);
  14715. }
  14716. }
  14717. decoratorsEnabledBeforeExport() {
  14718. if (this.hasPlugin("decorators-legacy")) return true;
  14719. return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false;
  14720. }
  14721. maybeTakeDecorators(maybeDecorators, classNode, exportNode) {
  14722. if (maybeDecorators) {
  14723. if (classNode.decorators && classNode.decorators.length > 0) {
  14724. if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") {
  14725. this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]);
  14726. }
  14727. classNode.decorators.unshift(...maybeDecorators);
  14728. } else {
  14729. classNode.decorators = maybeDecorators;
  14730. }
  14731. this.resetStartLocationFromNode(classNode, maybeDecorators[0]);
  14732. if (exportNode) this.resetStartLocationFromNode(exportNode, classNode);
  14733. }
  14734. return classNode;
  14735. }
  14736. canHaveLeadingDecorator() {
  14737. return this.match(80);
  14738. }
  14739. parseDecorators(allowExport) {
  14740. const decorators = [];
  14741. do {
  14742. decorators.push(this.parseDecorator());
  14743. } while (this.match(26));
  14744. if (this.match(82)) {
  14745. if (!allowExport) {
  14746. this.unexpected();
  14747. }
  14748. if (!this.decoratorsEnabledBeforeExport()) {
  14749. this.raise(Errors.DecoratorExportClass, this.state.startLoc);
  14750. }
  14751. } else if (!this.canHaveLeadingDecorator()) {
  14752. throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc);
  14753. }
  14754. return decorators;
  14755. }
  14756. parseDecorator() {
  14757. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  14758. const node = this.startNode();
  14759. this.next();
  14760. if (this.hasPlugin("decorators")) {
  14761. const startLoc = this.state.startLoc;
  14762. let expr;
  14763. if (this.match(10)) {
  14764. const startLoc = this.state.startLoc;
  14765. this.next();
  14766. expr = this.parseExpression();
  14767. this.expect(11);
  14768. expr = this.wrapParenthesis(startLoc, expr);
  14769. const paramsStartLoc = this.state.startLoc;
  14770. node.expression = this.parseMaybeDecoratorArguments(expr);
  14771. if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) {
  14772. this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc);
  14773. }
  14774. } else {
  14775. expr = this.parseIdentifier(false);
  14776. while (this.eat(16)) {
  14777. const node = this.startNodeAt(startLoc);
  14778. node.object = expr;
  14779. if (this.match(138)) {
  14780. this.classScope.usePrivateName(this.state.value, this.state.startLoc);
  14781. node.property = this.parsePrivateName();
  14782. } else {
  14783. node.property = this.parseIdentifier(true);
  14784. }
  14785. node.computed = false;
  14786. expr = this.finishNode(node, "MemberExpression");
  14787. }
  14788. node.expression = this.parseMaybeDecoratorArguments(expr);
  14789. }
  14790. } else {
  14791. node.expression = this.parseExprSubscripts();
  14792. }
  14793. return this.finishNode(node, "Decorator");
  14794. }
  14795. parseMaybeDecoratorArguments(expr) {
  14796. if (this.eat(10)) {
  14797. const node = this.startNodeAtNode(expr);
  14798. node.callee = expr;
  14799. node.arguments = this.parseCallExpressionArguments(11, false);
  14800. this.toReferencedList(node.arguments);
  14801. return this.finishNode(node, "CallExpression");
  14802. }
  14803. return expr;
  14804. }
  14805. parseBreakContinueStatement(node, isBreak) {
  14806. this.next();
  14807. if (this.isLineTerminator()) {
  14808. node.label = null;
  14809. } else {
  14810. node.label = this.parseIdentifier();
  14811. this.semicolon();
  14812. }
  14813. this.verifyBreakContinue(node, isBreak);
  14814. return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
  14815. }
  14816. verifyBreakContinue(node, isBreak) {
  14817. let i;
  14818. for (i = 0; i < this.state.labels.length; ++i) {
  14819. const lab = this.state.labels[i];
  14820. if (node.label == null || lab.name === node.label.name) {
  14821. if (lab.kind != null && (isBreak || lab.kind === 1)) {
  14822. break;
  14823. }
  14824. if (node.label && isBreak) break;
  14825. }
  14826. }
  14827. if (i === this.state.labels.length) {
  14828. const type = isBreak ? "BreakStatement" : "ContinueStatement";
  14829. this.raise(Errors.IllegalBreakContinue, node, {
  14830. type
  14831. });
  14832. }
  14833. }
  14834. parseDebuggerStatement(node) {
  14835. this.next();
  14836. this.semicolon();
  14837. return this.finishNode(node, "DebuggerStatement");
  14838. }
  14839. parseHeaderExpression() {
  14840. this.expect(10);
  14841. const val = this.parseExpression();
  14842. this.expect(11);
  14843. return val;
  14844. }
  14845. parseDoWhileStatement(node) {
  14846. this.next();
  14847. this.state.labels.push(loopLabel);
  14848. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  14849. this.state.labels.pop();
  14850. this.expect(92);
  14851. node.test = this.parseHeaderExpression();
  14852. this.eat(13);
  14853. return this.finishNode(node, "DoWhileStatement");
  14854. }
  14855. parseForStatement(node) {
  14856. this.next();
  14857. this.state.labels.push(loopLabel);
  14858. let awaitAt = null;
  14859. if (this.isAwaitAllowed() && this.eatContextual(96)) {
  14860. awaitAt = this.state.lastTokStartLoc;
  14861. }
  14862. this.scope.enter(0);
  14863. this.expect(10);
  14864. if (this.match(13)) {
  14865. if (awaitAt !== null) {
  14866. this.unexpected(awaitAt);
  14867. }
  14868. return this.parseFor(node, null);
  14869. }
  14870. const startsWithLet = this.isContextual(100);
  14871. {
  14872. const startsWithAwaitUsing = this.isContextual(96) && this.startsAwaitUsing();
  14873. const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.startsUsingForOf();
  14874. const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration;
  14875. if (this.match(74) || this.match(75) || isLetOrUsing) {
  14876. const initNode = this.startNode();
  14877. let kind;
  14878. if (startsWithAwaitUsing) {
  14879. kind = "await using";
  14880. if (!this.isAwaitAllowed()) {
  14881. this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc);
  14882. }
  14883. this.next();
  14884. } else {
  14885. kind = this.state.value;
  14886. }
  14887. this.next();
  14888. this.parseVar(initNode, true, kind);
  14889. const init = this.finishNode(initNode, "VariableDeclaration");
  14890. const isForIn = this.match(58);
  14891. if (isForIn && starsWithUsingDeclaration) {
  14892. this.raise(Errors.ForInUsing, init);
  14893. }
  14894. if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) {
  14895. return this.parseForIn(node, init, awaitAt);
  14896. }
  14897. if (awaitAt !== null) {
  14898. this.unexpected(awaitAt);
  14899. }
  14900. return this.parseFor(node, init);
  14901. }
  14902. }
  14903. const startsWithAsync = this.isContextual(95);
  14904. const refExpressionErrors = new ExpressionErrors();
  14905. const init = this.parseExpression(true, refExpressionErrors);
  14906. const isForOf = this.isContextual(102);
  14907. if (isForOf) {
  14908. if (startsWithLet) {
  14909. this.raise(Errors.ForOfLet, init);
  14910. }
  14911. if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
  14912. this.raise(Errors.ForOfAsync, init);
  14913. }
  14914. }
  14915. if (isForOf || this.match(58)) {
  14916. this.checkDestructuringPrivate(refExpressionErrors);
  14917. this.toAssignable(init, true);
  14918. const type = isForOf ? "ForOfStatement" : "ForInStatement";
  14919. this.checkLVal(init, {
  14920. in: {
  14921. type
  14922. }
  14923. });
  14924. return this.parseForIn(node, init, awaitAt);
  14925. } else {
  14926. this.checkExpressionErrors(refExpressionErrors, true);
  14927. }
  14928. if (awaitAt !== null) {
  14929. this.unexpected(awaitAt);
  14930. }
  14931. return this.parseFor(node, init);
  14932. }
  14933. parseFunctionStatement(node, isAsync, isHangingDeclaration) {
  14934. this.next();
  14935. return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0));
  14936. }
  14937. parseIfStatement(node) {
  14938. this.next();
  14939. node.test = this.parseHeaderExpression();
  14940. node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration();
  14941. node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null;
  14942. return this.finishNode(node, "IfStatement");
  14943. }
  14944. parseReturnStatement(node) {
  14945. if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
  14946. this.raise(Errors.IllegalReturn, this.state.startLoc);
  14947. }
  14948. this.next();
  14949. if (this.isLineTerminator()) {
  14950. node.argument = null;
  14951. } else {
  14952. node.argument = this.parseExpression();
  14953. this.semicolon();
  14954. }
  14955. return this.finishNode(node, "ReturnStatement");
  14956. }
  14957. parseSwitchStatement(node) {
  14958. this.next();
  14959. node.discriminant = this.parseHeaderExpression();
  14960. const cases = node.cases = [];
  14961. this.expect(5);
  14962. this.state.labels.push(switchLabel);
  14963. this.scope.enter(0);
  14964. let cur;
  14965. for (let sawDefault; !this.match(8);) {
  14966. if (this.match(61) || this.match(65)) {
  14967. const isCase = this.match(61);
  14968. if (cur) this.finishNode(cur, "SwitchCase");
  14969. cases.push(cur = this.startNode());
  14970. cur.consequent = [];
  14971. this.next();
  14972. if (isCase) {
  14973. cur.test = this.parseExpression();
  14974. } else {
  14975. if (sawDefault) {
  14976. this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc);
  14977. }
  14978. sawDefault = true;
  14979. cur.test = null;
  14980. }
  14981. this.expect(14);
  14982. } else {
  14983. if (cur) {
  14984. cur.consequent.push(this.parseStatementListItem());
  14985. } else {
  14986. this.unexpected();
  14987. }
  14988. }
  14989. }
  14990. this.scope.exit();
  14991. if (cur) this.finishNode(cur, "SwitchCase");
  14992. this.next();
  14993. this.state.labels.pop();
  14994. return this.finishNode(node, "SwitchStatement");
  14995. }
  14996. parseThrowStatement(node) {
  14997. this.next();
  14998. if (this.hasPrecedingLineBreak()) {
  14999. this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc);
  15000. }
  15001. node.argument = this.parseExpression();
  15002. this.semicolon();
  15003. return this.finishNode(node, "ThrowStatement");
  15004. }
  15005. parseCatchClauseParam() {
  15006. const param = this.parseBindingAtom();
  15007. this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0);
  15008. this.checkLVal(param, {
  15009. in: {
  15010. type: "CatchClause"
  15011. },
  15012. binding: 9
  15013. });
  15014. return param;
  15015. }
  15016. parseTryStatement(node) {
  15017. this.next();
  15018. node.block = this.parseBlock();
  15019. node.handler = null;
  15020. if (this.match(62)) {
  15021. const clause = this.startNode();
  15022. this.next();
  15023. if (this.match(10)) {
  15024. this.expect(10);
  15025. clause.param = this.parseCatchClauseParam();
  15026. this.expect(11);
  15027. } else {
  15028. clause.param = null;
  15029. this.scope.enter(0);
  15030. }
  15031. clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false));
  15032. this.scope.exit();
  15033. node.handler = this.finishNode(clause, "CatchClause");
  15034. }
  15035. node.finalizer = this.eat(67) ? this.parseBlock() : null;
  15036. if (!node.handler && !node.finalizer) {
  15037. this.raise(Errors.NoCatchOrFinally, node);
  15038. }
  15039. return this.finishNode(node, "TryStatement");
  15040. }
  15041. parseVarStatement(node, kind, allowMissingInitializer = false) {
  15042. this.next();
  15043. this.parseVar(node, false, kind, allowMissingInitializer);
  15044. this.semicolon();
  15045. return this.finishNode(node, "VariableDeclaration");
  15046. }
  15047. parseWhileStatement(node) {
  15048. this.next();
  15049. node.test = this.parseHeaderExpression();
  15050. this.state.labels.push(loopLabel);
  15051. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15052. this.state.labels.pop();
  15053. return this.finishNode(node, "WhileStatement");
  15054. }
  15055. parseWithStatement(node) {
  15056. if (this.state.strict) {
  15057. this.raise(Errors.StrictWith, this.state.startLoc);
  15058. }
  15059. this.next();
  15060. node.object = this.parseHeaderExpression();
  15061. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15062. return this.finishNode(node, "WithStatement");
  15063. }
  15064. parseEmptyStatement(node) {
  15065. this.next();
  15066. return this.finishNode(node, "EmptyStatement");
  15067. }
  15068. parseLabeledStatement(node, maybeName, expr, flags) {
  15069. for (const label of this.state.labels) {
  15070. if (label.name === maybeName) {
  15071. this.raise(Errors.LabelRedeclaration, expr, {
  15072. labelName: maybeName
  15073. });
  15074. }
  15075. }
  15076. const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
  15077. for (let i = this.state.labels.length - 1; i >= 0; i--) {
  15078. const label = this.state.labels[i];
  15079. if (label.statementStart === node.start) {
  15080. label.statementStart = this.state.start;
  15081. label.kind = kind;
  15082. } else {
  15083. break;
  15084. }
  15085. }
  15086. this.state.labels.push({
  15087. name: maybeName,
  15088. kind: kind,
  15089. statementStart: this.state.start
  15090. });
  15091. node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement();
  15092. this.state.labels.pop();
  15093. node.label = expr;
  15094. return this.finishNode(node, "LabeledStatement");
  15095. }
  15096. parseExpressionStatement(node, expr, decorators) {
  15097. node.expression = expr;
  15098. this.semicolon();
  15099. return this.finishNode(node, "ExpressionStatement");
  15100. }
  15101. parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
  15102. const node = this.startNode();
  15103. if (allowDirectives) {
  15104. this.state.strictErrors.clear();
  15105. }
  15106. this.expect(5);
  15107. if (createNewLexicalScope) {
  15108. this.scope.enter(0);
  15109. }
  15110. this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse);
  15111. if (createNewLexicalScope) {
  15112. this.scope.exit();
  15113. }
  15114. return this.finishNode(node, "BlockStatement");
  15115. }
  15116. isValidDirective(stmt) {
  15117. return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
  15118. }
  15119. parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
  15120. const body = node.body = [];
  15121. const directives = node.directives = [];
  15122. this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
  15123. }
  15124. parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
  15125. const oldStrict = this.state.strict;
  15126. let hasStrictModeDirective = false;
  15127. let parsedNonDirective = false;
  15128. while (!this.match(end)) {
  15129. const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
  15130. if (directives && !parsedNonDirective) {
  15131. if (this.isValidDirective(stmt)) {
  15132. const directive = this.stmtToDirective(stmt);
  15133. directives.push(directive);
  15134. if (!hasStrictModeDirective && directive.value.value === "use strict") {
  15135. hasStrictModeDirective = true;
  15136. this.setStrict(true);
  15137. }
  15138. continue;
  15139. }
  15140. parsedNonDirective = true;
  15141. this.state.strictErrors.clear();
  15142. }
  15143. body.push(stmt);
  15144. }
  15145. afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective);
  15146. if (!oldStrict) {
  15147. this.setStrict(false);
  15148. }
  15149. this.next();
  15150. }
  15151. parseFor(node, init) {
  15152. node.init = init;
  15153. this.semicolon(false);
  15154. node.test = this.match(13) ? null : this.parseExpression();
  15155. this.semicolon(false);
  15156. node.update = this.match(11) ? null : this.parseExpression();
  15157. this.expect(11);
  15158. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15159. this.scope.exit();
  15160. this.state.labels.pop();
  15161. return this.finishNode(node, "ForStatement");
  15162. }
  15163. parseForIn(node, init, awaitAt) {
  15164. const isForIn = this.match(58);
  15165. this.next();
  15166. if (isForIn) {
  15167. if (awaitAt !== null) this.unexpected(awaitAt);
  15168. } else {
  15169. node.await = awaitAt !== null;
  15170. }
  15171. 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")) {
  15172. this.raise(Errors.ForInOfLoopInitializer, init, {
  15173. type: isForIn ? "ForInStatement" : "ForOfStatement"
  15174. });
  15175. }
  15176. if (init.type === "AssignmentPattern") {
  15177. this.raise(Errors.InvalidLhs, init, {
  15178. ancestor: {
  15179. type: "ForStatement"
  15180. }
  15181. });
  15182. }
  15183. node.left = init;
  15184. node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
  15185. this.expect(11);
  15186. node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement());
  15187. this.scope.exit();
  15188. this.state.labels.pop();
  15189. return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
  15190. }
  15191. parseVar(node, isFor, kind, allowMissingInitializer = false) {
  15192. const declarations = node.declarations = [];
  15193. node.kind = kind;
  15194. for (;;) {
  15195. const decl = this.startNode();
  15196. this.parseVarId(decl, kind);
  15197. decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
  15198. if (decl.init === null && !allowMissingInitializer) {
  15199. if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) {
  15200. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15201. kind: "destructuring"
  15202. });
  15203. } else if ((kind === "const" || kind === "using" || kind === "await using") && !(this.match(58) || this.isContextual(102))) {
  15204. this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, {
  15205. kind
  15206. });
  15207. }
  15208. }
  15209. declarations.push(this.finishNode(decl, "VariableDeclarator"));
  15210. if (!this.eat(12)) break;
  15211. }
  15212. return node;
  15213. }
  15214. parseVarId(decl, kind) {
  15215. const id = this.parseBindingAtom();
  15216. this.checkLVal(id, {
  15217. in: {
  15218. type: "VariableDeclarator"
  15219. },
  15220. binding: kind === "var" ? 5 : 8201
  15221. });
  15222. decl.id = id;
  15223. }
  15224. parseAsyncFunctionExpression(node) {
  15225. return this.parseFunction(node, 8);
  15226. }
  15227. parseFunction(node, flags = 0) {
  15228. const hangingDeclaration = flags & 2;
  15229. const isDeclaration = !!(flags & 1);
  15230. const requireId = isDeclaration && !(flags & 4);
  15231. const isAsync = !!(flags & 8);
  15232. this.initFunction(node, isAsync);
  15233. if (this.match(55)) {
  15234. if (hangingDeclaration) {
  15235. this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc);
  15236. }
  15237. this.next();
  15238. node.generator = true;
  15239. }
  15240. if (isDeclaration) {
  15241. node.id = this.parseFunctionId(requireId);
  15242. }
  15243. const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
  15244. this.state.maybeInArrowParameters = false;
  15245. this.scope.enter(2);
  15246. this.prodParam.enter(functionFlags(isAsync, node.generator));
  15247. if (!isDeclaration) {
  15248. node.id = this.parseFunctionId();
  15249. }
  15250. this.parseFunctionParams(node, false);
  15251. this.withSmartMixTopicForbiddingContext(() => {
  15252. this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
  15253. });
  15254. this.prodParam.exit();
  15255. this.scope.exit();
  15256. if (isDeclaration && !hangingDeclaration) {
  15257. this.registerFunctionStatementId(node);
  15258. }
  15259. this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
  15260. return node;
  15261. }
  15262. parseFunctionId(requireId) {
  15263. return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null;
  15264. }
  15265. parseFunctionParams(node, isConstructor) {
  15266. this.expect(10);
  15267. this.expressionScope.enter(newParameterDeclarationScope());
  15268. node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0));
  15269. this.expressionScope.exit();
  15270. }
  15271. registerFunctionStatementId(node) {
  15272. if (!node.id) return;
  15273. 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);
  15274. }
  15275. parseClass(node, isStatement, optionalId) {
  15276. this.next();
  15277. const oldStrict = this.state.strict;
  15278. this.state.strict = true;
  15279. this.parseClassId(node, isStatement, optionalId);
  15280. this.parseClassSuper(node);
  15281. node.body = this.parseClassBody(!!node.superClass, oldStrict);
  15282. return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
  15283. }
  15284. isClassProperty() {
  15285. return this.match(29) || this.match(13) || this.match(8);
  15286. }
  15287. isClassMethod() {
  15288. return this.match(10);
  15289. }
  15290. nameIsConstructor(key) {
  15291. return key.type === "Identifier" && key.name === "constructor" || key.type === "StringLiteral" && key.value === "constructor";
  15292. }
  15293. isNonstaticConstructor(method) {
  15294. return !method.computed && !method.static && this.nameIsConstructor(method.key);
  15295. }
  15296. parseClassBody(hadSuperClass, oldStrict) {
  15297. this.classScope.enter();
  15298. const state = {
  15299. hadConstructor: false,
  15300. hadSuperClass
  15301. };
  15302. let decorators = [];
  15303. const classBody = this.startNode();
  15304. classBody.body = [];
  15305. this.expect(5);
  15306. this.withSmartMixTopicForbiddingContext(() => {
  15307. while (!this.match(8)) {
  15308. if (this.eat(13)) {
  15309. if (decorators.length > 0) {
  15310. throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc);
  15311. }
  15312. continue;
  15313. }
  15314. if (this.match(26)) {
  15315. decorators.push(this.parseDecorator());
  15316. continue;
  15317. }
  15318. const member = this.startNode();
  15319. if (decorators.length) {
  15320. member.decorators = decorators;
  15321. this.resetStartLocationFromNode(member, decorators[0]);
  15322. decorators = [];
  15323. }
  15324. this.parseClassMember(classBody, member, state);
  15325. if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
  15326. this.raise(Errors.DecoratorConstructor, member);
  15327. }
  15328. }
  15329. });
  15330. this.state.strict = oldStrict;
  15331. this.next();
  15332. if (decorators.length) {
  15333. throw this.raise(Errors.TrailingDecorator, this.state.startLoc);
  15334. }
  15335. this.classScope.exit();
  15336. return this.finishNode(classBody, "ClassBody");
  15337. }
  15338. parseClassMemberFromModifier(classBody, member) {
  15339. const key = this.parseIdentifier(true);
  15340. if (this.isClassMethod()) {
  15341. const method = member;
  15342. method.kind = "method";
  15343. method.computed = false;
  15344. method.key = key;
  15345. method.static = false;
  15346. this.pushClassMethod(classBody, method, false, false, false, false);
  15347. return true;
  15348. } else if (this.isClassProperty()) {
  15349. const prop = member;
  15350. prop.computed = false;
  15351. prop.key = key;
  15352. prop.static = false;
  15353. classBody.body.push(this.parseClassProperty(prop));
  15354. return true;
  15355. }
  15356. this.resetPreviousNodeTrailingComments(key);
  15357. return false;
  15358. }
  15359. parseClassMember(classBody, member, state) {
  15360. const isStatic = this.isContextual(106);
  15361. if (isStatic) {
  15362. if (this.parseClassMemberFromModifier(classBody, member)) {
  15363. return;
  15364. }
  15365. if (this.eat(5)) {
  15366. this.parseClassStaticBlock(classBody, member);
  15367. return;
  15368. }
  15369. }
  15370. this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
  15371. }
  15372. parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
  15373. const publicMethod = member;
  15374. const privateMethod = member;
  15375. const publicProp = member;
  15376. const privateProp = member;
  15377. const accessorProp = member;
  15378. const method = publicMethod;
  15379. const publicMember = publicMethod;
  15380. member.static = isStatic;
  15381. this.parsePropertyNamePrefixOperator(member);
  15382. if (this.eat(55)) {
  15383. method.kind = "method";
  15384. const isPrivateName = this.match(138);
  15385. this.parseClassElementName(method);
  15386. if (isPrivateName) {
  15387. this.pushClassPrivateMethod(classBody, privateMethod, true, false);
  15388. return;
  15389. }
  15390. if (this.isNonstaticConstructor(publicMethod)) {
  15391. this.raise(Errors.ConstructorIsGenerator, publicMethod.key);
  15392. }
  15393. this.pushClassMethod(classBody, publicMethod, true, false, false, false);
  15394. return;
  15395. }
  15396. const isContextual = !this.state.containsEsc && tokenIsIdentifier(this.state.type);
  15397. const key = this.parseClassElementName(member);
  15398. const maybeContextualKw = isContextual ? key.name : null;
  15399. const isPrivate = this.isPrivateName(key);
  15400. const maybeQuestionTokenStartLoc = this.state.startLoc;
  15401. this.parsePostMemberNameModifiers(publicMember);
  15402. if (this.isClassMethod()) {
  15403. method.kind = "method";
  15404. if (isPrivate) {
  15405. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15406. return;
  15407. }
  15408. const isConstructor = this.isNonstaticConstructor(publicMethod);
  15409. let allowsDirectSuper = false;
  15410. if (isConstructor) {
  15411. publicMethod.kind = "constructor";
  15412. if (state.hadConstructor && !this.hasPlugin("typescript")) {
  15413. this.raise(Errors.DuplicateConstructor, key);
  15414. }
  15415. if (isConstructor && this.hasPlugin("typescript") && member.override) {
  15416. this.raise(Errors.OverrideOnConstructor, key);
  15417. }
  15418. state.hadConstructor = true;
  15419. allowsDirectSuper = state.hadSuperClass;
  15420. }
  15421. this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
  15422. } else if (this.isClassProperty()) {
  15423. if (isPrivate) {
  15424. this.pushClassPrivateProperty(classBody, privateProp);
  15425. } else {
  15426. this.pushClassProperty(classBody, publicProp);
  15427. }
  15428. } else if (maybeContextualKw === "async" && !this.isLineTerminator()) {
  15429. this.resetPreviousNodeTrailingComments(key);
  15430. const isGenerator = this.eat(55);
  15431. if (publicMember.optional) {
  15432. this.unexpected(maybeQuestionTokenStartLoc);
  15433. }
  15434. method.kind = "method";
  15435. const isPrivate = this.match(138);
  15436. this.parseClassElementName(method);
  15437. this.parsePostMemberNameModifiers(publicMember);
  15438. if (isPrivate) {
  15439. this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
  15440. } else {
  15441. if (this.isNonstaticConstructor(publicMethod)) {
  15442. this.raise(Errors.ConstructorIsAsync, publicMethod.key);
  15443. }
  15444. this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
  15445. }
  15446. } else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(55) && this.isLineTerminator())) {
  15447. this.resetPreviousNodeTrailingComments(key);
  15448. method.kind = maybeContextualKw;
  15449. const isPrivate = this.match(138);
  15450. this.parseClassElementName(publicMethod);
  15451. if (isPrivate) {
  15452. this.pushClassPrivateMethod(classBody, privateMethod, false, false);
  15453. } else {
  15454. if (this.isNonstaticConstructor(publicMethod)) {
  15455. this.raise(Errors.ConstructorIsAccessor, publicMethod.key);
  15456. }
  15457. this.pushClassMethod(classBody, publicMethod, false, false, false, false);
  15458. }
  15459. this.checkGetterSetterParams(publicMethod);
  15460. } else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
  15461. this.expectPlugin("decoratorAutoAccessors");
  15462. this.resetPreviousNodeTrailingComments(key);
  15463. const isPrivate = this.match(138);
  15464. this.parseClassElementName(publicProp);
  15465. this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
  15466. } else if (this.isLineTerminator()) {
  15467. if (isPrivate) {
  15468. this.pushClassPrivateProperty(classBody, privateProp);
  15469. } else {
  15470. this.pushClassProperty(classBody, publicProp);
  15471. }
  15472. } else {
  15473. this.unexpected();
  15474. }
  15475. }
  15476. parseClassElementName(member) {
  15477. const {
  15478. type,
  15479. value
  15480. } = this.state;
  15481. if ((type === 132 || type === 133) && member.static && value === "prototype") {
  15482. this.raise(Errors.StaticPrototype, this.state.startLoc);
  15483. }
  15484. if (type === 138) {
  15485. if (value === "constructor") {
  15486. this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
  15487. }
  15488. const key = this.parsePrivateName();
  15489. member.key = key;
  15490. return key;
  15491. }
  15492. this.parsePropertyName(member);
  15493. return member.key;
  15494. }
  15495. parseClassStaticBlock(classBody, member) {
  15496. var _member$decorators;
  15497. this.scope.enter(64 | 128 | 16);
  15498. const oldLabels = this.state.labels;
  15499. this.state.labels = [];
  15500. this.prodParam.enter(0);
  15501. const body = member.body = [];
  15502. this.parseBlockOrModuleBlockBody(body, undefined, false, 8);
  15503. this.prodParam.exit();
  15504. this.scope.exit();
  15505. this.state.labels = oldLabels;
  15506. classBody.body.push(this.finishNode(member, "StaticBlock"));
  15507. if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
  15508. this.raise(Errors.DecoratorStaticBlock, member);
  15509. }
  15510. }
  15511. pushClassProperty(classBody, prop) {
  15512. if (!prop.computed && this.nameIsConstructor(prop.key)) {
  15513. this.raise(Errors.ConstructorClassField, prop.key);
  15514. }
  15515. classBody.body.push(this.parseClassProperty(prop));
  15516. }
  15517. pushClassPrivateProperty(classBody, prop) {
  15518. const node = this.parseClassPrivateProperty(prop);
  15519. classBody.body.push(node);
  15520. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15521. }
  15522. pushClassAccessorProperty(classBody, prop, isPrivate) {
  15523. if (!isPrivate && !prop.computed && this.nameIsConstructor(prop.key)) {
  15524. this.raise(Errors.ConstructorClassField, prop.key);
  15525. }
  15526. const node = this.parseClassAccessorProperty(prop);
  15527. classBody.body.push(node);
  15528. if (isPrivate) {
  15529. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start);
  15530. }
  15531. }
  15532. pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
  15533. classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
  15534. }
  15535. pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
  15536. const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
  15537. classBody.body.push(node);
  15538. const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0;
  15539. this.declareClassPrivateMethodInScope(node, kind);
  15540. }
  15541. declareClassPrivateMethodInScope(node, kind) {
  15542. this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
  15543. }
  15544. parsePostMemberNameModifiers(methodOrProp) {}
  15545. parseClassPrivateProperty(node) {
  15546. this.parseInitializer(node);
  15547. this.semicolon();
  15548. return this.finishNode(node, "ClassPrivateProperty");
  15549. }
  15550. parseClassProperty(node) {
  15551. this.parseInitializer(node);
  15552. this.semicolon();
  15553. return this.finishNode(node, "ClassProperty");
  15554. }
  15555. parseClassAccessorProperty(node) {
  15556. this.parseInitializer(node);
  15557. this.semicolon();
  15558. return this.finishNode(node, "ClassAccessorProperty");
  15559. }
  15560. parseInitializer(node) {
  15561. this.scope.enter(64 | 16);
  15562. this.expressionScope.enter(newExpressionScope());
  15563. this.prodParam.enter(0);
  15564. node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null;
  15565. this.expressionScope.exit();
  15566. this.prodParam.exit();
  15567. this.scope.exit();
  15568. }
  15569. parseClassId(node, isStatement, optionalId, bindingType = 8331) {
  15570. if (tokenIsIdentifier(this.state.type)) {
  15571. node.id = this.parseIdentifier();
  15572. if (isStatement) {
  15573. this.declareNameFromIdentifier(node.id, bindingType);
  15574. }
  15575. } else {
  15576. if (optionalId || !isStatement) {
  15577. node.id = null;
  15578. } else {
  15579. throw this.raise(Errors.MissingClassName, this.state.startLoc);
  15580. }
  15581. }
  15582. }
  15583. parseClassSuper(node) {
  15584. node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
  15585. }
  15586. parseExport(node, decorators) {
  15587. const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
  15588. const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
  15589. const parseAfterDefault = !hasDefault || this.eat(12);
  15590. const hasStar = parseAfterDefault && this.eatExportStar(node);
  15591. const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
  15592. const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12));
  15593. const isFromRequired = hasDefault || hasStar;
  15594. if (hasStar && !hasNamespace) {
  15595. if (hasDefault) this.unexpected();
  15596. if (decorators) {
  15597. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15598. }
  15599. this.parseExportFrom(node, true);
  15600. return this.finishNode(node, "ExportAllDeclaration");
  15601. }
  15602. const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
  15603. if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
  15604. this.unexpected(null, 5);
  15605. }
  15606. if (hasNamespace && parseAfterNamespace) {
  15607. this.unexpected(null, 98);
  15608. }
  15609. let hasDeclaration;
  15610. if (isFromRequired || hasSpecifiers) {
  15611. hasDeclaration = false;
  15612. if (decorators) {
  15613. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15614. }
  15615. this.parseExportFrom(node, isFromRequired);
  15616. } else {
  15617. hasDeclaration = this.maybeParseExportDeclaration(node);
  15618. }
  15619. if (isFromRequired || hasSpecifiers || hasDeclaration) {
  15620. var _node2$declaration;
  15621. const node2 = node;
  15622. this.checkExport(node2, true, false, !!node2.source);
  15623. if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") {
  15624. this.maybeTakeDecorators(decorators, node2.declaration, node2);
  15625. } else if (decorators) {
  15626. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15627. }
  15628. return this.finishNode(node2, "ExportNamedDeclaration");
  15629. }
  15630. if (this.eat(65)) {
  15631. const node2 = node;
  15632. const decl = this.parseExportDefaultExpression();
  15633. node2.declaration = decl;
  15634. if (decl.type === "ClassDeclaration") {
  15635. this.maybeTakeDecorators(decorators, decl, node2);
  15636. } else if (decorators) {
  15637. throw this.raise(Errors.UnsupportedDecoratorExport, node);
  15638. }
  15639. this.checkExport(node2, true, true);
  15640. return this.finishNode(node2, "ExportDefaultDeclaration");
  15641. }
  15642. this.unexpected(null, 5);
  15643. }
  15644. eatExportStar(node) {
  15645. return this.eat(55);
  15646. }
  15647. maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) {
  15648. if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) {
  15649. this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start);
  15650. const id = maybeDefaultIdentifier || this.parseIdentifier(true);
  15651. const specifier = this.startNodeAtNode(id);
  15652. specifier.exported = id;
  15653. node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
  15654. return true;
  15655. }
  15656. return false;
  15657. }
  15658. maybeParseExportNamespaceSpecifier(node) {
  15659. if (this.isContextual(93)) {
  15660. var _ref, _ref$specifiers;
  15661. (_ref$specifiers = (_ref = node).specifiers) != null ? _ref$specifiers : _ref.specifiers = [];
  15662. const specifier = this.startNodeAt(this.state.lastTokStartLoc);
  15663. this.next();
  15664. specifier.exported = this.parseModuleExportName();
  15665. node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
  15666. return true;
  15667. }
  15668. return false;
  15669. }
  15670. maybeParseExportNamedSpecifiers(node) {
  15671. if (this.match(5)) {
  15672. const node2 = node;
  15673. if (!node2.specifiers) node2.specifiers = [];
  15674. const isTypeExport = node2.exportKind === "type";
  15675. node2.specifiers.push(...this.parseExportSpecifiers(isTypeExport));
  15676. node2.source = null;
  15677. node2.declaration = null;
  15678. if (this.hasPlugin("importAssertions")) {
  15679. node2.assertions = [];
  15680. }
  15681. return true;
  15682. }
  15683. return false;
  15684. }
  15685. maybeParseExportDeclaration(node) {
  15686. if (this.shouldParseExportDeclaration()) {
  15687. node.specifiers = [];
  15688. node.source = null;
  15689. if (this.hasPlugin("importAssertions")) {
  15690. node.assertions = [];
  15691. }
  15692. node.declaration = this.parseExportDeclaration(node);
  15693. return true;
  15694. }
  15695. return false;
  15696. }
  15697. isAsyncFunction() {
  15698. if (!this.isContextual(95)) return false;
  15699. const next = this.nextTokenInLineStart();
  15700. return this.isUnparsedContextual(next, "function");
  15701. }
  15702. parseExportDefaultExpression() {
  15703. const expr = this.startNode();
  15704. if (this.match(68)) {
  15705. this.next();
  15706. return this.parseFunction(expr, 1 | 4);
  15707. } else if (this.isAsyncFunction()) {
  15708. this.next();
  15709. this.next();
  15710. return this.parseFunction(expr, 1 | 4 | 8);
  15711. }
  15712. if (this.match(80)) {
  15713. return this.parseClass(expr, true, true);
  15714. }
  15715. if (this.match(26)) {
  15716. if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15717. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15718. }
  15719. return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
  15720. }
  15721. if (this.match(75) || this.match(74) || this.isLet()) {
  15722. throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
  15723. }
  15724. const res = this.parseMaybeAssignAllowIn();
  15725. this.semicolon();
  15726. return res;
  15727. }
  15728. parseExportDeclaration(node) {
  15729. if (this.match(80)) {
  15730. const node = this.parseClass(this.startNode(), true, false);
  15731. return node;
  15732. }
  15733. return this.parseStatementListItem();
  15734. }
  15735. isExportDefaultSpecifier() {
  15736. const {
  15737. type
  15738. } = this.state;
  15739. if (tokenIsIdentifier(type)) {
  15740. if (type === 95 && !this.state.containsEsc || type === 100) {
  15741. return false;
  15742. }
  15743. if ((type === 130 || type === 129) && !this.state.containsEsc) {
  15744. const {
  15745. type: nextType
  15746. } = this.lookahead();
  15747. if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) {
  15748. this.expectOnePlugin(["flow", "typescript"]);
  15749. return false;
  15750. }
  15751. }
  15752. } else if (!this.match(65)) {
  15753. return false;
  15754. }
  15755. const next = this.nextTokenStart();
  15756. const hasFrom = this.isUnparsedContextual(next, "from");
  15757. if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) {
  15758. return true;
  15759. }
  15760. if (this.match(65) && hasFrom) {
  15761. const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
  15762. return nextAfterFrom === 34 || nextAfterFrom === 39;
  15763. }
  15764. return false;
  15765. }
  15766. parseExportFrom(node, expect) {
  15767. if (this.eatContextual(98)) {
  15768. node.source = this.parseImportSource();
  15769. this.checkExport(node);
  15770. this.maybeParseImportAttributes(node);
  15771. this.checkJSONModuleImport(node);
  15772. } else if (expect) {
  15773. this.unexpected();
  15774. }
  15775. this.semicolon();
  15776. }
  15777. shouldParseExportDeclaration() {
  15778. const {
  15779. type
  15780. } = this.state;
  15781. if (type === 26) {
  15782. this.expectOnePlugin(["decorators", "decorators-legacy"]);
  15783. if (this.hasPlugin("decorators")) {
  15784. if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) {
  15785. this.raise(Errors.DecoratorBeforeExport, this.state.startLoc);
  15786. }
  15787. return true;
  15788. }
  15789. }
  15790. if (this.isContextual(107)) {
  15791. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  15792. return true;
  15793. }
  15794. if (this.isContextual(96) && this.startsAwaitUsing()) {
  15795. this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
  15796. return true;
  15797. }
  15798. return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction();
  15799. }
  15800. checkExport(node, checkNames, isDefault, isFrom) {
  15801. if (checkNames) {
  15802. var _node$specifiers;
  15803. if (isDefault) {
  15804. this.checkDuplicateExports(node, "default");
  15805. if (this.hasPlugin("exportDefaultFrom")) {
  15806. var _declaration$extra;
  15807. const declaration = node.declaration;
  15808. if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
  15809. this.raise(Errors.ExportDefaultFromAsIdentifier, declaration);
  15810. }
  15811. }
  15812. } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) {
  15813. for (const specifier of node.specifiers) {
  15814. const {
  15815. exported
  15816. } = specifier;
  15817. const exportName = exported.type === "Identifier" ? exported.name : exported.value;
  15818. this.checkDuplicateExports(specifier, exportName);
  15819. if (!isFrom && specifier.local) {
  15820. const {
  15821. local
  15822. } = specifier;
  15823. if (local.type !== "Identifier") {
  15824. this.raise(Errors.ExportBindingIsString, specifier, {
  15825. localName: local.value,
  15826. exportName
  15827. });
  15828. } else {
  15829. this.checkReservedWord(local.name, local.loc.start, true, false);
  15830. this.scope.checkLocalExport(local);
  15831. }
  15832. }
  15833. }
  15834. } else if (node.declaration) {
  15835. const decl = node.declaration;
  15836. if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") {
  15837. const {
  15838. id
  15839. } = decl;
  15840. if (!id) throw new Error("Assertion failure");
  15841. this.checkDuplicateExports(node, id.name);
  15842. } else if (decl.type === "VariableDeclaration") {
  15843. for (const declaration of decl.declarations) {
  15844. this.checkDeclaration(declaration.id);
  15845. }
  15846. }
  15847. }
  15848. }
  15849. }
  15850. checkDeclaration(node) {
  15851. if (node.type === "Identifier") {
  15852. this.checkDuplicateExports(node, node.name);
  15853. } else if (node.type === "ObjectPattern") {
  15854. for (const prop of node.properties) {
  15855. this.checkDeclaration(prop);
  15856. }
  15857. } else if (node.type === "ArrayPattern") {
  15858. for (const elem of node.elements) {
  15859. if (elem) {
  15860. this.checkDeclaration(elem);
  15861. }
  15862. }
  15863. } else if (node.type === "ObjectProperty") {
  15864. this.checkDeclaration(node.value);
  15865. } else if (node.type === "RestElement") {
  15866. this.checkDeclaration(node.argument);
  15867. } else if (node.type === "AssignmentPattern") {
  15868. this.checkDeclaration(node.left);
  15869. }
  15870. }
  15871. checkDuplicateExports(node, exportName) {
  15872. if (this.exportedIdentifiers.has(exportName)) {
  15873. if (exportName === "default") {
  15874. this.raise(Errors.DuplicateDefaultExport, node);
  15875. } else {
  15876. this.raise(Errors.DuplicateExport, node, {
  15877. exportName
  15878. });
  15879. }
  15880. }
  15881. this.exportedIdentifiers.add(exportName);
  15882. }
  15883. parseExportSpecifiers(isInTypeExport) {
  15884. const nodes = [];
  15885. let first = true;
  15886. this.expect(5);
  15887. while (!this.eat(8)) {
  15888. if (first) {
  15889. first = false;
  15890. } else {
  15891. this.expect(12);
  15892. if (this.eat(8)) break;
  15893. }
  15894. const isMaybeTypeOnly = this.isContextual(130);
  15895. const isString = this.match(133);
  15896. const node = this.startNode();
  15897. node.local = this.parseModuleExportName();
  15898. nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
  15899. }
  15900. return nodes;
  15901. }
  15902. parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) {
  15903. if (this.eatContextual(93)) {
  15904. node.exported = this.parseModuleExportName();
  15905. } else if (isString) {
  15906. node.exported = cloneStringLiteral(node.local);
  15907. } else if (!node.exported) {
  15908. node.exported = cloneIdentifier(node.local);
  15909. }
  15910. return this.finishNode(node, "ExportSpecifier");
  15911. }
  15912. parseModuleExportName() {
  15913. if (this.match(133)) {
  15914. const result = this.parseStringLiteral(this.state.value);
  15915. const surrogate = result.value.match(loneSurrogate);
  15916. if (surrogate) {
  15917. this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, {
  15918. surrogateCharCode: surrogate[0].charCodeAt(0)
  15919. });
  15920. }
  15921. return result;
  15922. }
  15923. return this.parseIdentifier(true);
  15924. }
  15925. isJSONModuleImport(node) {
  15926. if (node.assertions != null) {
  15927. return node.assertions.some(({
  15928. key,
  15929. value
  15930. }) => {
  15931. return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
  15932. });
  15933. }
  15934. return false;
  15935. }
  15936. checkImportReflection(node) {
  15937. const {
  15938. specifiers
  15939. } = node;
  15940. const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
  15941. if (node.phase === "source") {
  15942. if (singleBindingType !== "ImportDefaultSpecifier") {
  15943. this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start);
  15944. }
  15945. } else if (node.phase === "defer") {
  15946. if (singleBindingType !== "ImportNamespaceSpecifier") {
  15947. this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start);
  15948. }
  15949. } else if (node.module) {
  15950. var _node$assertions;
  15951. if (singleBindingType !== "ImportDefaultSpecifier") {
  15952. this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start);
  15953. }
  15954. if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) {
  15955. this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start);
  15956. }
  15957. }
  15958. }
  15959. checkJSONModuleImport(node) {
  15960. if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
  15961. const {
  15962. specifiers
  15963. } = node;
  15964. if (specifiers != null) {
  15965. const nonDefaultNamedSpecifier = specifiers.find(specifier => {
  15966. let imported;
  15967. if (specifier.type === "ExportSpecifier") {
  15968. imported = specifier.local;
  15969. } else if (specifier.type === "ImportSpecifier") {
  15970. imported = specifier.imported;
  15971. }
  15972. if (imported !== undefined) {
  15973. return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
  15974. }
  15975. });
  15976. if (nonDefaultNamedSpecifier !== undefined) {
  15977. this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start);
  15978. }
  15979. }
  15980. }
  15981. }
  15982. isPotentialImportPhase(isExport) {
  15983. if (isExport) return false;
  15984. return this.isContextual(105) || this.isContextual(97) || this.isContextual(127);
  15985. }
  15986. applyImportPhase(node, isExport, phase, loc) {
  15987. if (isExport) {
  15988. return;
  15989. }
  15990. if (phase === "module") {
  15991. this.expectPlugin("importReflection", loc);
  15992. node.module = true;
  15993. } else if (this.hasPlugin("importReflection")) {
  15994. node.module = false;
  15995. }
  15996. if (phase === "source") {
  15997. this.expectPlugin("sourcePhaseImports", loc);
  15998. node.phase = "source";
  15999. } else if (phase === "defer") {
  16000. this.expectPlugin("deferredImportEvaluation", loc);
  16001. node.phase = "defer";
  16002. } else if (this.hasPlugin("sourcePhaseImports")) {
  16003. node.phase = null;
  16004. }
  16005. }
  16006. parseMaybeImportPhase(node, isExport) {
  16007. if (!this.isPotentialImportPhase(isExport)) {
  16008. this.applyImportPhase(node, isExport, null);
  16009. return null;
  16010. }
  16011. const phaseIdentifier = this.parseIdentifier(true);
  16012. const {
  16013. type
  16014. } = this.state;
  16015. const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16016. if (isImportPhase) {
  16017. this.resetPreviousIdentifierLeadingComments(phaseIdentifier);
  16018. this.applyImportPhase(node, isExport, phaseIdentifier.name, phaseIdentifier.loc.start);
  16019. return null;
  16020. } else {
  16021. this.applyImportPhase(node, isExport, null);
  16022. return phaseIdentifier;
  16023. }
  16024. }
  16025. isPrecedingIdImportPhase(phase) {
  16026. const {
  16027. type
  16028. } = this.state;
  16029. return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
  16030. }
  16031. parseImport(node) {
  16032. if (this.match(133)) {
  16033. return this.parseImportSourceAndAttributes(node);
  16034. }
  16035. return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
  16036. }
  16037. parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) {
  16038. node.specifiers = [];
  16039. const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
  16040. const parseNext = !hasDefault || this.eat(12);
  16041. const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
  16042. if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
  16043. this.expectContextual(98);
  16044. return this.parseImportSourceAndAttributes(node);
  16045. }
  16046. parseImportSourceAndAttributes(node) {
  16047. var _node$specifiers2;
  16048. (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = [];
  16049. node.source = this.parseImportSource();
  16050. this.maybeParseImportAttributes(node);
  16051. this.checkImportReflection(node);
  16052. this.checkJSONModuleImport(node);
  16053. this.semicolon();
  16054. return this.finishNode(node, "ImportDeclaration");
  16055. }
  16056. parseImportSource() {
  16057. if (!this.match(133)) this.unexpected();
  16058. return this.parseExprAtom();
  16059. }
  16060. parseImportSpecifierLocal(node, specifier, type) {
  16061. specifier.local = this.parseIdentifier();
  16062. node.specifiers.push(this.finishImportSpecifier(specifier, type));
  16063. }
  16064. finishImportSpecifier(specifier, type, bindingType = 8201) {
  16065. this.checkLVal(specifier.local, {
  16066. in: {
  16067. type
  16068. },
  16069. binding: bindingType
  16070. });
  16071. return this.finishNode(specifier, type);
  16072. }
  16073. parseImportAttributes() {
  16074. this.expect(5);
  16075. const attrs = [];
  16076. const attrNames = new Set();
  16077. do {
  16078. if (this.match(8)) {
  16079. break;
  16080. }
  16081. const node = this.startNode();
  16082. const keyName = this.state.value;
  16083. if (attrNames.has(keyName)) {
  16084. this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, {
  16085. key: keyName
  16086. });
  16087. }
  16088. attrNames.add(keyName);
  16089. if (this.match(133)) {
  16090. node.key = this.parseStringLiteral(keyName);
  16091. } else {
  16092. node.key = this.parseIdentifier(true);
  16093. }
  16094. this.expect(14);
  16095. if (!this.match(133)) {
  16096. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16097. }
  16098. node.value = this.parseStringLiteral(this.state.value);
  16099. attrs.push(this.finishNode(node, "ImportAttribute"));
  16100. } while (this.eat(12));
  16101. this.expect(8);
  16102. return attrs;
  16103. }
  16104. parseModuleAttributes() {
  16105. const attrs = [];
  16106. const attributes = new Set();
  16107. do {
  16108. const node = this.startNode();
  16109. node.key = this.parseIdentifier(true);
  16110. if (node.key.name !== "type") {
  16111. this.raise(Errors.ModuleAttributeDifferentFromType, node.key);
  16112. }
  16113. if (attributes.has(node.key.name)) {
  16114. this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, {
  16115. key: node.key.name
  16116. });
  16117. }
  16118. attributes.add(node.key.name);
  16119. this.expect(14);
  16120. if (!this.match(133)) {
  16121. throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
  16122. }
  16123. node.value = this.parseStringLiteral(this.state.value);
  16124. attrs.push(this.finishNode(node, "ImportAttribute"));
  16125. } while (this.eat(12));
  16126. return attrs;
  16127. }
  16128. maybeParseImportAttributes(node) {
  16129. let attributes;
  16130. let useWith = false;
  16131. if (this.match(76)) {
  16132. if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) {
  16133. return;
  16134. }
  16135. this.next();
  16136. {
  16137. if (this.hasPlugin("moduleAttributes")) {
  16138. attributes = this.parseModuleAttributes();
  16139. } else {
  16140. this.expectImportAttributesPlugin();
  16141. attributes = this.parseImportAttributes();
  16142. }
  16143. }
  16144. useWith = true;
  16145. } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) {
  16146. if (this.hasPlugin("importAttributes")) {
  16147. if (this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== true) {
  16148. this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc);
  16149. }
  16150. this.addExtra(node, "deprecatedAssertSyntax", true);
  16151. } else {
  16152. this.expectOnePlugin(["importAttributes", "importAssertions"]);
  16153. }
  16154. this.next();
  16155. attributes = this.parseImportAttributes();
  16156. } else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) {
  16157. attributes = [];
  16158. } else {
  16159. if (this.hasPlugin("moduleAttributes")) {
  16160. attributes = [];
  16161. } else return;
  16162. }
  16163. if (!useWith && this.hasPlugin("importAssertions")) {
  16164. node.assertions = attributes;
  16165. } else {
  16166. node.attributes = attributes;
  16167. }
  16168. }
  16169. maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) {
  16170. if (maybeDefaultIdentifier) {
  16171. const specifier = this.startNodeAtNode(maybeDefaultIdentifier);
  16172. specifier.local = maybeDefaultIdentifier;
  16173. node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier"));
  16174. return true;
  16175. } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
  16176. this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier");
  16177. return true;
  16178. }
  16179. return false;
  16180. }
  16181. maybeParseStarImportSpecifier(node) {
  16182. if (this.match(55)) {
  16183. const specifier = this.startNode();
  16184. this.next();
  16185. this.expectContextual(93);
  16186. this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
  16187. return true;
  16188. }
  16189. return false;
  16190. }
  16191. parseNamedImportSpecifiers(node) {
  16192. let first = true;
  16193. this.expect(5);
  16194. while (!this.eat(8)) {
  16195. if (first) {
  16196. first = false;
  16197. } else {
  16198. if (this.eat(14)) {
  16199. throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
  16200. }
  16201. this.expect(12);
  16202. if (this.eat(8)) break;
  16203. }
  16204. const specifier = this.startNode();
  16205. const importedIsString = this.match(133);
  16206. const isMaybeTypeOnly = this.isContextual(130);
  16207. specifier.imported = this.parseModuleExportName();
  16208. const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
  16209. node.specifiers.push(importSpecifier);
  16210. }
  16211. }
  16212. parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) {
  16213. if (this.eatContextual(93)) {
  16214. specifier.local = this.parseIdentifier();
  16215. } else {
  16216. const {
  16217. imported
  16218. } = specifier;
  16219. if (importedIsString) {
  16220. throw this.raise(Errors.ImportBindingIsString, specifier, {
  16221. importName: imported.value
  16222. });
  16223. }
  16224. this.checkReservedWord(imported.name, specifier.loc.start, true, true);
  16225. if (!specifier.local) {
  16226. specifier.local = cloneIdentifier(imported);
  16227. }
  16228. }
  16229. return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType);
  16230. }
  16231. isThisParam(param) {
  16232. return param.type === "Identifier" && param.name === "this";
  16233. }
  16234. }
  16235. let Parser$2 = class Parser extends StatementParser {
  16236. constructor(options, input) {
  16237. options = getOptions(options);
  16238. super(options, input);
  16239. this.options = options;
  16240. this.initializeScopes();
  16241. this.plugins = pluginsMap(this.options.plugins);
  16242. this.filename = options.sourceFilename;
  16243. }
  16244. getScopeHandler() {
  16245. return ScopeHandler;
  16246. }
  16247. parse() {
  16248. this.enterInitialScopes();
  16249. const file = this.startNode();
  16250. const program = this.startNode();
  16251. this.nextToken();
  16252. file.errors = null;
  16253. this.parseTopLevel(file, program);
  16254. file.errors = this.state.errors;
  16255. file.comments.length = this.state.commentsLen;
  16256. return file;
  16257. }
  16258. };
  16259. function pluginsMap(plugins) {
  16260. const pluginMap = new Map();
  16261. for (const plugin of plugins) {
  16262. const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
  16263. if (!pluginMap.has(name)) pluginMap.set(name, options || {});
  16264. }
  16265. return pluginMap;
  16266. }
  16267. function parse$9(input, options) {
  16268. var _options;
  16269. if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
  16270. options = Object.assign({}, options);
  16271. try {
  16272. options.sourceType = "module";
  16273. const parser = getParser(options, input);
  16274. const ast = parser.parse();
  16275. if (parser.sawUnambiguousESM) {
  16276. return ast;
  16277. }
  16278. if (parser.ambiguousScriptDifferentAst) {
  16279. try {
  16280. options.sourceType = "script";
  16281. return getParser(options, input).parse();
  16282. } catch (_unused) {}
  16283. } else {
  16284. ast.program.sourceType = "script";
  16285. }
  16286. return ast;
  16287. } catch (moduleError) {
  16288. try {
  16289. options.sourceType = "script";
  16290. return getParser(options, input).parse();
  16291. } catch (_unused2) {}
  16292. throw moduleError;
  16293. }
  16294. } else {
  16295. return getParser(options, input).parse();
  16296. }
  16297. }
  16298. function parseExpression(input, options) {
  16299. const parser = getParser(options, input);
  16300. if (parser.options.strictMode) {
  16301. parser.state.strict = true;
  16302. }
  16303. return parser.getExpression();
  16304. }
  16305. function generateExportedTokenTypes(internalTokenTypes) {
  16306. const tokenTypes = {};
  16307. for (const typeName of Object.keys(internalTokenTypes)) {
  16308. tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
  16309. }
  16310. return tokenTypes;
  16311. }
  16312. const tokTypes = generateExportedTokenTypes(tt);
  16313. function getParser(options, input) {
  16314. let cls = Parser$2;
  16315. if (options != null && options.plugins) {
  16316. validatePlugins(options.plugins);
  16317. cls = getParserClass(options.plugins);
  16318. }
  16319. return new cls(options, input);
  16320. }
  16321. const parserClassCache = {};
  16322. function getParserClass(pluginsFromOptions) {
  16323. const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name));
  16324. const key = pluginList.join("/");
  16325. let cls = parserClassCache[key];
  16326. if (!cls) {
  16327. cls = Parser$2;
  16328. for (const plugin of pluginList) {
  16329. cls = mixinPlugins[plugin](cls);
  16330. }
  16331. parserClassCache[key] = cls;
  16332. }
  16333. return cls;
  16334. }
  16335. var parse_1$1 = lib.parse = parse$9;
  16336. var parseExpression_1 = lib.parseExpression = parseExpression;
  16337. lib.tokTypes = tokTypes;
  16338. // @ts-check
  16339. /** @typedef { import('estree').BaseNode} BaseNode */
  16340. /** @typedef {{
  16341. skip: () => void;
  16342. remove: () => void;
  16343. replace: (node: BaseNode) => void;
  16344. }} WalkerContext */
  16345. class WalkerBase {
  16346. constructor() {
  16347. /** @type {boolean} */
  16348. this.should_skip = false;
  16349. /** @type {boolean} */
  16350. this.should_remove = false;
  16351. /** @type {BaseNode | null} */
  16352. this.replacement = null;
  16353. /** @type {WalkerContext} */
  16354. this.context = {
  16355. skip: () => (this.should_skip = true),
  16356. remove: () => (this.should_remove = true),
  16357. replace: (node) => (this.replacement = node)
  16358. };
  16359. }
  16360. /**
  16361. *
  16362. * @param {any} parent
  16363. * @param {string} prop
  16364. * @param {number} index
  16365. * @param {BaseNode} node
  16366. */
  16367. replace(parent, prop, index, node) {
  16368. if (parent) {
  16369. if (index !== null) {
  16370. parent[prop][index] = node;
  16371. } else {
  16372. parent[prop] = node;
  16373. }
  16374. }
  16375. }
  16376. /**
  16377. *
  16378. * @param {any} parent
  16379. * @param {string} prop
  16380. * @param {number} index
  16381. */
  16382. remove(parent, prop, index) {
  16383. if (parent) {
  16384. if (index !== null) {
  16385. parent[prop].splice(index, 1);
  16386. } else {
  16387. delete parent[prop];
  16388. }
  16389. }
  16390. }
  16391. }
  16392. // @ts-check
  16393. /** @typedef { import('estree').BaseNode} BaseNode */
  16394. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  16395. /** @typedef {(
  16396. * this: WalkerContext,
  16397. * node: BaseNode,
  16398. * parent: BaseNode,
  16399. * key: string,
  16400. * index: number
  16401. * ) => void} SyncHandler */
  16402. class SyncWalker extends WalkerBase {
  16403. /**
  16404. *
  16405. * @param {SyncHandler} enter
  16406. * @param {SyncHandler} leave
  16407. */
  16408. constructor(enter, leave) {
  16409. super();
  16410. /** @type {SyncHandler} */
  16411. this.enter = enter;
  16412. /** @type {SyncHandler} */
  16413. this.leave = leave;
  16414. }
  16415. /**
  16416. *
  16417. * @param {BaseNode} node
  16418. * @param {BaseNode} parent
  16419. * @param {string} [prop]
  16420. * @param {number} [index]
  16421. * @returns {BaseNode}
  16422. */
  16423. visit(node, parent, prop, index) {
  16424. if (node) {
  16425. if (this.enter) {
  16426. const _should_skip = this.should_skip;
  16427. const _should_remove = this.should_remove;
  16428. const _replacement = this.replacement;
  16429. this.should_skip = false;
  16430. this.should_remove = false;
  16431. this.replacement = null;
  16432. this.enter.call(this.context, node, parent, prop, index);
  16433. if (this.replacement) {
  16434. node = this.replacement;
  16435. this.replace(parent, prop, index, node);
  16436. }
  16437. if (this.should_remove) {
  16438. this.remove(parent, prop, index);
  16439. }
  16440. const skipped = this.should_skip;
  16441. const removed = this.should_remove;
  16442. this.should_skip = _should_skip;
  16443. this.should_remove = _should_remove;
  16444. this.replacement = _replacement;
  16445. if (skipped) return node;
  16446. if (removed) return null;
  16447. }
  16448. for (const key in node) {
  16449. const value = node[key];
  16450. if (typeof value !== "object") {
  16451. continue;
  16452. } else if (Array.isArray(value)) {
  16453. for (let i = 0; i < value.length; i += 1) {
  16454. if (value[i] !== null && typeof value[i].type === 'string') {
  16455. if (!this.visit(value[i], node, key, i)) {
  16456. // removed
  16457. i--;
  16458. }
  16459. }
  16460. }
  16461. } else if (value !== null && typeof value.type === "string") {
  16462. this.visit(value, node, key, null);
  16463. }
  16464. }
  16465. if (this.leave) {
  16466. const _replacement = this.replacement;
  16467. const _should_remove = this.should_remove;
  16468. this.replacement = null;
  16469. this.should_remove = false;
  16470. this.leave.call(this.context, node, parent, prop, index);
  16471. if (this.replacement) {
  16472. node = this.replacement;
  16473. this.replace(parent, prop, index, node);
  16474. }
  16475. if (this.should_remove) {
  16476. this.remove(parent, prop, index);
  16477. }
  16478. const removed = this.should_remove;
  16479. this.replacement = _replacement;
  16480. this.should_remove = _should_remove;
  16481. if (removed) return null;
  16482. }
  16483. }
  16484. return node;
  16485. }
  16486. }
  16487. // @ts-check
  16488. /** @typedef { import('estree').BaseNode} BaseNode */
  16489. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  16490. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  16491. /**
  16492. *
  16493. * @param {BaseNode} ast
  16494. * @param {{
  16495. * enter?: SyncHandler
  16496. * leave?: SyncHandler
  16497. * }} walker
  16498. * @returns {BaseNode}
  16499. */
  16500. function walk$2(ast, { enter, leave }) {
  16501. const instance = new SyncWalker(enter, leave);
  16502. return instance.visit(ast, null);
  16503. }
  16504. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  16505. const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
  16506. walk$2(root, {
  16507. enter(node, parent) {
  16508. parent && parentStack.push(parent);
  16509. if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
  16510. return this.skip();
  16511. }
  16512. if (node.type === "Identifier") {
  16513. const isLocal = !!knownIds[node.name];
  16514. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  16515. if (includeAll || isRefed && !isLocal) {
  16516. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  16517. }
  16518. } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
  16519. (parent == null ? void 0 : parent.type) === "ObjectPattern") {
  16520. node.inPattern = true;
  16521. } else if (isFunctionType(node)) {
  16522. if (node.scopeIds) {
  16523. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16524. } else {
  16525. walkFunctionParams(
  16526. node,
  16527. (id) => markScopeIdentifier(node, id, knownIds)
  16528. );
  16529. }
  16530. } else if (node.type === "BlockStatement") {
  16531. if (node.scopeIds) {
  16532. node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
  16533. } else {
  16534. walkBlockDeclarations(
  16535. node,
  16536. (id) => markScopeIdentifier(node, id, knownIds)
  16537. );
  16538. }
  16539. } else if (node.type === "CatchClause" && node.param) {
  16540. for (const id of extractIdentifiers$1(node.param)) {
  16541. markScopeIdentifier(node, id, knownIds);
  16542. }
  16543. } else if (isForStatement(node)) {
  16544. walkForStatement(
  16545. node,
  16546. false,
  16547. (id) => markScopeIdentifier(node, id, knownIds)
  16548. );
  16549. }
  16550. },
  16551. leave(node, parent) {
  16552. parent && parentStack.pop();
  16553. if (node !== rootExp && node.scopeIds) {
  16554. for (const id of node.scopeIds) {
  16555. knownIds[id]--;
  16556. if (knownIds[id] === 0) {
  16557. delete knownIds[id];
  16558. }
  16559. }
  16560. }
  16561. }
  16562. });
  16563. }
  16564. function isReferencedIdentifier(id, parent, parentStack) {
  16565. if (!parent) {
  16566. return true;
  16567. }
  16568. if (id.name === "arguments") {
  16569. return false;
  16570. }
  16571. if (isReferenced(id, parent)) {
  16572. return true;
  16573. }
  16574. switch (parent.type) {
  16575. case "AssignmentExpression":
  16576. case "AssignmentPattern":
  16577. return true;
  16578. case "ObjectPattern":
  16579. case "ArrayPattern":
  16580. return isInDestructureAssignment(parent, parentStack);
  16581. }
  16582. return false;
  16583. }
  16584. function isInDestructureAssignment(parent, parentStack) {
  16585. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  16586. let i = parentStack.length;
  16587. while (i--) {
  16588. const p = parentStack[i];
  16589. if (p.type === "AssignmentExpression") {
  16590. return true;
  16591. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  16592. break;
  16593. }
  16594. }
  16595. }
  16596. return false;
  16597. }
  16598. function isInNewExpression(parentStack) {
  16599. let i = parentStack.length;
  16600. while (i--) {
  16601. const p = parentStack[i];
  16602. if (p.type === "NewExpression") {
  16603. return true;
  16604. } else if (p.type !== "MemberExpression") {
  16605. break;
  16606. }
  16607. }
  16608. return false;
  16609. }
  16610. function walkFunctionParams(node, onIdent) {
  16611. for (const p of node.params) {
  16612. for (const id of extractIdentifiers$1(p)) {
  16613. onIdent(id);
  16614. }
  16615. }
  16616. }
  16617. function walkBlockDeclarations(block, onIdent) {
  16618. for (const stmt of block.body) {
  16619. if (stmt.type === "VariableDeclaration") {
  16620. if (stmt.declare) continue;
  16621. for (const decl of stmt.declarations) {
  16622. for (const id of extractIdentifiers$1(decl.id)) {
  16623. onIdent(id);
  16624. }
  16625. }
  16626. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  16627. if (stmt.declare || !stmt.id) continue;
  16628. onIdent(stmt.id);
  16629. } else if (isForStatement(stmt)) {
  16630. walkForStatement(stmt, true, onIdent);
  16631. }
  16632. }
  16633. }
  16634. function isForStatement(stmt) {
  16635. return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
  16636. }
  16637. function walkForStatement(stmt, isVar, onIdent) {
  16638. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  16639. if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) {
  16640. for (const decl of variable.declarations) {
  16641. for (const id of extractIdentifiers$1(decl.id)) {
  16642. onIdent(id);
  16643. }
  16644. }
  16645. }
  16646. }
  16647. function extractIdentifiers$1(param, nodes = []) {
  16648. switch (param.type) {
  16649. case "Identifier":
  16650. nodes.push(param);
  16651. break;
  16652. case "MemberExpression":
  16653. let object = param;
  16654. while (object.type === "MemberExpression") {
  16655. object = object.object;
  16656. }
  16657. nodes.push(object);
  16658. break;
  16659. case "ObjectPattern":
  16660. for (const prop of param.properties) {
  16661. if (prop.type === "RestElement") {
  16662. extractIdentifiers$1(prop.argument, nodes);
  16663. } else {
  16664. extractIdentifiers$1(prop.value, nodes);
  16665. }
  16666. }
  16667. break;
  16668. case "ArrayPattern":
  16669. param.elements.forEach((element) => {
  16670. if (element) extractIdentifiers$1(element, nodes);
  16671. });
  16672. break;
  16673. case "RestElement":
  16674. extractIdentifiers$1(param.argument, nodes);
  16675. break;
  16676. case "AssignmentPattern":
  16677. extractIdentifiers$1(param.left, nodes);
  16678. break;
  16679. }
  16680. return nodes;
  16681. }
  16682. function markKnownIds(name, knownIds) {
  16683. if (name in knownIds) {
  16684. knownIds[name]++;
  16685. } else {
  16686. knownIds[name] = 1;
  16687. }
  16688. }
  16689. function markScopeIdentifier(node, child, knownIds) {
  16690. const { name } = child;
  16691. if (node.scopeIds && node.scopeIds.has(name)) {
  16692. return;
  16693. }
  16694. markKnownIds(name, knownIds);
  16695. (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
  16696. }
  16697. const isFunctionType = (node) => {
  16698. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  16699. };
  16700. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  16701. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  16702. function isReferenced(node, parent, grandparent) {
  16703. switch (parent.type) {
  16704. case "MemberExpression":
  16705. case "OptionalMemberExpression":
  16706. if (parent.property === node) {
  16707. return !!parent.computed;
  16708. }
  16709. return parent.object === node;
  16710. case "JSXMemberExpression":
  16711. return parent.object === node;
  16712. case "VariableDeclarator":
  16713. return parent.init === node;
  16714. case "ArrowFunctionExpression":
  16715. return parent.body === node;
  16716. case "PrivateName":
  16717. return false;
  16718. case "ClassMethod":
  16719. case "ClassPrivateMethod":
  16720. case "ObjectMethod":
  16721. if (parent.key === node) {
  16722. return !!parent.computed;
  16723. }
  16724. return false;
  16725. case "ObjectProperty":
  16726. if (parent.key === node) {
  16727. return !!parent.computed;
  16728. }
  16729. return !grandparent;
  16730. case "ClassProperty":
  16731. if (parent.key === node) {
  16732. return !!parent.computed;
  16733. }
  16734. return true;
  16735. case "ClassPrivateProperty":
  16736. return parent.key !== node;
  16737. case "ClassDeclaration":
  16738. case "ClassExpression":
  16739. return parent.superClass === node;
  16740. case "AssignmentExpression":
  16741. return parent.right === node;
  16742. case "AssignmentPattern":
  16743. return parent.right === node;
  16744. case "LabeledStatement":
  16745. return false;
  16746. case "CatchClause":
  16747. return false;
  16748. case "RestElement":
  16749. return false;
  16750. case "BreakStatement":
  16751. case "ContinueStatement":
  16752. return false;
  16753. case "FunctionDeclaration":
  16754. case "FunctionExpression":
  16755. return false;
  16756. case "ExportNamespaceSpecifier":
  16757. case "ExportDefaultSpecifier":
  16758. return false;
  16759. case "ExportSpecifier":
  16760. return parent.local === node;
  16761. case "ImportDefaultSpecifier":
  16762. case "ImportNamespaceSpecifier":
  16763. case "ImportSpecifier":
  16764. return false;
  16765. case "ImportAttribute":
  16766. return false;
  16767. case "JSXAttribute":
  16768. return false;
  16769. case "ObjectPattern":
  16770. case "ArrayPattern":
  16771. return false;
  16772. case "MetaProperty":
  16773. return false;
  16774. case "ObjectTypeProperty":
  16775. return parent.key !== node;
  16776. case "TSEnumMember":
  16777. return parent.id !== node;
  16778. case "TSPropertySignature":
  16779. if (parent.key === node) {
  16780. return !!parent.computed;
  16781. }
  16782. return true;
  16783. }
  16784. return true;
  16785. }
  16786. const TS_NODE_TYPES = [
  16787. "TSAsExpression",
  16788. // foo as number
  16789. "TSTypeAssertion",
  16790. // (<number>foo)
  16791. "TSNonNullExpression",
  16792. // foo!
  16793. "TSInstantiationExpression",
  16794. // foo<string>
  16795. "TSSatisfiesExpression"
  16796. // foo satisfies T
  16797. ];
  16798. function unwrapTSNode(node) {
  16799. if (TS_NODE_TYPES.includes(node.type)) {
  16800. return unwrapTSNode(node.expression);
  16801. } else {
  16802. return node;
  16803. }
  16804. }
  16805. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  16806. function isCoreComponent(tag) {
  16807. switch (tag) {
  16808. case "Teleport":
  16809. case "teleport":
  16810. return TELEPORT;
  16811. case "Suspense":
  16812. case "suspense":
  16813. return SUSPENSE;
  16814. case "KeepAlive":
  16815. case "keep-alive":
  16816. return KEEP_ALIVE;
  16817. case "BaseTransition":
  16818. case "base-transition":
  16819. return BASE_TRANSITION;
  16820. }
  16821. }
  16822. const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
  16823. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  16824. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  16825. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  16826. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  16827. const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
  16828. const isMemberExpressionBrowser = (exp) => {
  16829. const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
  16830. let state = 0 /* inMemberExp */;
  16831. let stateStack = [];
  16832. let currentOpenBracketCount = 0;
  16833. let currentOpenParensCount = 0;
  16834. let currentStringType = null;
  16835. for (let i = 0; i < path.length; i++) {
  16836. const char = path.charAt(i);
  16837. switch (state) {
  16838. case 0 /* inMemberExp */:
  16839. if (char === "[") {
  16840. stateStack.push(state);
  16841. state = 1 /* inBrackets */;
  16842. currentOpenBracketCount++;
  16843. } else if (char === "(") {
  16844. stateStack.push(state);
  16845. state = 2 /* inParens */;
  16846. currentOpenParensCount++;
  16847. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  16848. return false;
  16849. }
  16850. break;
  16851. case 1 /* inBrackets */:
  16852. if (char === `'` || char === `"` || char === "`") {
  16853. stateStack.push(state);
  16854. state = 3 /* inString */;
  16855. currentStringType = char;
  16856. } else if (char === `[`) {
  16857. currentOpenBracketCount++;
  16858. } else if (char === `]`) {
  16859. if (!--currentOpenBracketCount) {
  16860. state = stateStack.pop();
  16861. }
  16862. }
  16863. break;
  16864. case 2 /* inParens */:
  16865. if (char === `'` || char === `"` || char === "`") {
  16866. stateStack.push(state);
  16867. state = 3 /* inString */;
  16868. currentStringType = char;
  16869. } else if (char === `(`) {
  16870. currentOpenParensCount++;
  16871. } else if (char === `)`) {
  16872. if (i === path.length - 1) {
  16873. return false;
  16874. }
  16875. if (!--currentOpenParensCount) {
  16876. state = stateStack.pop();
  16877. }
  16878. }
  16879. break;
  16880. case 3 /* inString */:
  16881. if (char === currentStringType) {
  16882. state = stateStack.pop();
  16883. currentStringType = null;
  16884. }
  16885. break;
  16886. }
  16887. }
  16888. return !currentOpenBracketCount && !currentOpenParensCount;
  16889. };
  16890. const isMemberExpressionNode = (exp, context) => {
  16891. try {
  16892. let ret = exp.ast || parseExpression_1(getExpSource(exp), {
  16893. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  16894. });
  16895. ret = unwrapTSNode(ret);
  16896. return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
  16897. } catch (e) {
  16898. return false;
  16899. }
  16900. };
  16901. const isMemberExpression = isMemberExpressionNode;
  16902. const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  16903. const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
  16904. const isFnExpressionNode = (exp, context) => {
  16905. try {
  16906. let ret = exp.ast || parseExpression_1(getExpSource(exp), {
  16907. plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
  16908. });
  16909. if (ret.type === "Program") {
  16910. ret = ret.body[0];
  16911. if (ret.type === "ExpressionStatement") {
  16912. ret = ret.expression;
  16913. }
  16914. }
  16915. ret = unwrapTSNode(ret);
  16916. return ret.type === "FunctionExpression" || ret.type === "ArrowFunctionExpression";
  16917. } catch (e) {
  16918. return false;
  16919. }
  16920. };
  16921. const isFnExpression = isFnExpressionNode;
  16922. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  16923. return advancePositionWithMutation(
  16924. {
  16925. offset: pos.offset,
  16926. line: pos.line,
  16927. column: pos.column
  16928. },
  16929. source,
  16930. numberOfCharacters
  16931. );
  16932. }
  16933. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  16934. let linesCount = 0;
  16935. let lastNewLinePos = -1;
  16936. for (let i = 0; i < numberOfCharacters; i++) {
  16937. if (source.charCodeAt(i) === 10) {
  16938. linesCount++;
  16939. lastNewLinePos = i;
  16940. }
  16941. }
  16942. pos.offset += numberOfCharacters;
  16943. pos.line += linesCount;
  16944. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  16945. return pos;
  16946. }
  16947. function assert(condition, msg) {
  16948. if (!condition) {
  16949. throw new Error(msg || `unexpected compiler condition`);
  16950. }
  16951. }
  16952. function findDir(node, name, allowEmpty = false) {
  16953. for (let i = 0; i < node.props.length; i++) {
  16954. const p = node.props[i];
  16955. if (p.type === 7 && (allowEmpty || p.exp) && (isString$2(name) ? p.name === name : name.test(p.name))) {
  16956. return p;
  16957. }
  16958. }
  16959. }
  16960. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  16961. for (let i = 0; i < node.props.length; i++) {
  16962. const p = node.props[i];
  16963. if (p.type === 6) {
  16964. if (dynamicOnly) continue;
  16965. if (p.name === name && (p.value || allowEmpty)) {
  16966. return p;
  16967. }
  16968. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  16969. return p;
  16970. }
  16971. }
  16972. }
  16973. function isStaticArgOf(arg, name) {
  16974. return !!(arg && isStaticExp(arg) && arg.content === name);
  16975. }
  16976. function hasDynamicKeyVBind(node) {
  16977. return node.props.some(
  16978. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  16979. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  16980. !p.arg.isStatic)
  16981. // v-bind:[foo]
  16982. );
  16983. }
  16984. function isText$1(node) {
  16985. return node.type === 5 || node.type === 2;
  16986. }
  16987. function isVSlot(p) {
  16988. return p.type === 7 && p.name === "slot";
  16989. }
  16990. function isTemplateNode(node) {
  16991. return node.type === 1 && node.tagType === 3;
  16992. }
  16993. function isSlotOutlet(node) {
  16994. return node.type === 1 && node.tagType === 2;
  16995. }
  16996. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  16997. function getUnnormalizedProps(props, callPath = []) {
  16998. if (props && !isString$2(props) && props.type === 14) {
  16999. const callee = props.callee;
  17000. if (!isString$2(callee) && propsHelperSet.has(callee)) {
  17001. return getUnnormalizedProps(
  17002. props.arguments[0],
  17003. callPath.concat(props)
  17004. );
  17005. }
  17006. }
  17007. return [props, callPath];
  17008. }
  17009. function injectProp(node, prop, context) {
  17010. let propsWithInjection;
  17011. let props = node.type === 13 ? node.props : node.arguments[2];
  17012. let callPath = [];
  17013. let parentCall;
  17014. if (props && !isString$2(props) && props.type === 14) {
  17015. const ret = getUnnormalizedProps(props);
  17016. props = ret[0];
  17017. callPath = ret[1];
  17018. parentCall = callPath[callPath.length - 1];
  17019. }
  17020. if (props == null || isString$2(props)) {
  17021. propsWithInjection = createObjectExpression([prop]);
  17022. } else if (props.type === 14) {
  17023. const first = props.arguments[0];
  17024. if (!isString$2(first) && first.type === 15) {
  17025. if (!hasProp(prop, first)) {
  17026. first.properties.unshift(prop);
  17027. }
  17028. } else {
  17029. if (props.callee === TO_HANDLERS) {
  17030. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17031. createObjectExpression([prop]),
  17032. props
  17033. ]);
  17034. } else {
  17035. props.arguments.unshift(createObjectExpression([prop]));
  17036. }
  17037. }
  17038. !propsWithInjection && (propsWithInjection = props);
  17039. } else if (props.type === 15) {
  17040. if (!hasProp(prop, props)) {
  17041. props.properties.unshift(prop);
  17042. }
  17043. propsWithInjection = props;
  17044. } else {
  17045. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  17046. createObjectExpression([prop]),
  17047. props
  17048. ]);
  17049. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  17050. parentCall = callPath[callPath.length - 2];
  17051. }
  17052. }
  17053. if (node.type === 13) {
  17054. if (parentCall) {
  17055. parentCall.arguments[0] = propsWithInjection;
  17056. } else {
  17057. node.props = propsWithInjection;
  17058. }
  17059. } else {
  17060. if (parentCall) {
  17061. parentCall.arguments[0] = propsWithInjection;
  17062. } else {
  17063. node.arguments[2] = propsWithInjection;
  17064. }
  17065. }
  17066. }
  17067. function hasProp(prop, props) {
  17068. let result = false;
  17069. if (prop.key.type === 4) {
  17070. const propKeyName = prop.key.content;
  17071. result = props.properties.some(
  17072. (p) => p.key.type === 4 && p.key.content === propKeyName
  17073. );
  17074. }
  17075. return result;
  17076. }
  17077. function toValidAssetId(name, type) {
  17078. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  17079. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  17080. })}`;
  17081. }
  17082. function hasScopeRef(node, ids) {
  17083. if (!node || Object.keys(ids).length === 0) {
  17084. return false;
  17085. }
  17086. switch (node.type) {
  17087. case 1:
  17088. for (let i = 0; i < node.props.length; i++) {
  17089. const p = node.props[i];
  17090. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  17091. return true;
  17092. }
  17093. }
  17094. return node.children.some((c) => hasScopeRef(c, ids));
  17095. case 11:
  17096. if (hasScopeRef(node.source, ids)) {
  17097. return true;
  17098. }
  17099. return node.children.some((c) => hasScopeRef(c, ids));
  17100. case 9:
  17101. return node.branches.some((b) => hasScopeRef(b, ids));
  17102. case 10:
  17103. if (hasScopeRef(node.condition, ids)) {
  17104. return true;
  17105. }
  17106. return node.children.some((c) => hasScopeRef(c, ids));
  17107. case 4:
  17108. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  17109. case 8:
  17110. return node.children.some((c) => isObject$2(c) && hasScopeRef(c, ids));
  17111. case 5:
  17112. case 12:
  17113. return hasScopeRef(node.content, ids);
  17114. case 2:
  17115. case 3:
  17116. return false;
  17117. default:
  17118. return false;
  17119. }
  17120. }
  17121. function getMemoedVNodeCall(node) {
  17122. if (node.type === 14 && node.callee === WITH_MEMO) {
  17123. return node.arguments[1].returns;
  17124. } else {
  17125. return node;
  17126. }
  17127. }
  17128. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
  17129. const defaultParserOptions = {
  17130. parseMode: "base",
  17131. ns: 0,
  17132. delimiters: [`{{`, `}}`],
  17133. getNamespace: () => 0,
  17134. isVoidTag: NO,
  17135. isPreTag: NO,
  17136. isCustomElement: NO,
  17137. onError: defaultOnError,
  17138. onWarn: defaultOnWarn,
  17139. comments: true,
  17140. prefixIdentifiers: false
  17141. };
  17142. let currentOptions = defaultParserOptions;
  17143. let currentRoot = null;
  17144. let currentInput = "";
  17145. let currentOpenTag = null;
  17146. let currentProp = null;
  17147. let currentAttrValue = "";
  17148. let currentAttrStartIndex = -1;
  17149. let currentAttrEndIndex = -1;
  17150. let inPre = 0;
  17151. let inVPre = false;
  17152. let currentVPreBoundary = null;
  17153. const stack = [];
  17154. const tokenizer$2 = new Tokenizer$1(stack, {
  17155. onerr: emitError,
  17156. ontext(start, end) {
  17157. onText(getSlice(start, end), start, end);
  17158. },
  17159. ontextentity(char, start, end) {
  17160. onText(char, start, end);
  17161. },
  17162. oninterpolation(start, end) {
  17163. if (inVPre) {
  17164. return onText(getSlice(start, end), start, end);
  17165. }
  17166. let innerStart = start + tokenizer$2.delimiterOpen.length;
  17167. let innerEnd = end - tokenizer$2.delimiterClose.length;
  17168. while (isWhitespace$1(currentInput.charCodeAt(innerStart))) {
  17169. innerStart++;
  17170. }
  17171. while (isWhitespace$1(currentInput.charCodeAt(innerEnd - 1))) {
  17172. innerEnd--;
  17173. }
  17174. let exp = getSlice(innerStart, innerEnd);
  17175. if (exp.includes("&")) {
  17176. {
  17177. exp = decodeHTML(exp);
  17178. }
  17179. }
  17180. addNode({
  17181. type: 5,
  17182. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  17183. loc: getLoc(start, end)
  17184. });
  17185. },
  17186. onopentagname(start, end) {
  17187. const name = getSlice(start, end);
  17188. currentOpenTag = {
  17189. type: 1,
  17190. tag: name,
  17191. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  17192. tagType: 0,
  17193. // will be refined on tag close
  17194. props: [],
  17195. children: [],
  17196. loc: getLoc(start - 1, end),
  17197. codegenNode: void 0
  17198. };
  17199. },
  17200. onopentagend(end) {
  17201. endOpenTag(end);
  17202. },
  17203. onclosetag(start, end) {
  17204. const name = getSlice(start, end);
  17205. if (!currentOptions.isVoidTag(name)) {
  17206. let found = false;
  17207. for (let i = 0; i < stack.length; i++) {
  17208. const e = stack[i];
  17209. if (e.tag.toLowerCase() === name.toLowerCase()) {
  17210. found = true;
  17211. if (i > 0) {
  17212. emitError(24, stack[0].loc.start.offset);
  17213. }
  17214. for (let j = 0; j <= i; j++) {
  17215. const el = stack.shift();
  17216. onCloseTag(el, end, j < i);
  17217. }
  17218. break;
  17219. }
  17220. }
  17221. if (!found) {
  17222. emitError(23, backTrack(start, 60));
  17223. }
  17224. }
  17225. },
  17226. onselfclosingtag(end) {
  17227. const name = currentOpenTag.tag;
  17228. currentOpenTag.isSelfClosing = true;
  17229. endOpenTag(end);
  17230. if (stack[0] && stack[0].tag === name) {
  17231. onCloseTag(stack.shift(), end);
  17232. }
  17233. },
  17234. onattribname(start, end) {
  17235. currentProp = {
  17236. type: 6,
  17237. name: getSlice(start, end),
  17238. nameLoc: getLoc(start, end),
  17239. value: void 0,
  17240. loc: getLoc(start)
  17241. };
  17242. },
  17243. ondirname(start, end) {
  17244. const raw = getSlice(start, end);
  17245. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  17246. if (!inVPre && name === "") {
  17247. emitError(26, start);
  17248. }
  17249. if (inVPre || name === "") {
  17250. currentProp = {
  17251. type: 6,
  17252. name: raw,
  17253. nameLoc: getLoc(start, end),
  17254. value: void 0,
  17255. loc: getLoc(start)
  17256. };
  17257. } else {
  17258. currentProp = {
  17259. type: 7,
  17260. name,
  17261. rawName: raw,
  17262. exp: void 0,
  17263. arg: void 0,
  17264. modifiers: raw === "." ? ["prop"] : [],
  17265. loc: getLoc(start)
  17266. };
  17267. if (name === "pre") {
  17268. inVPre = tokenizer$2.inVPre = true;
  17269. currentVPreBoundary = currentOpenTag;
  17270. const props = currentOpenTag.props;
  17271. for (let i = 0; i < props.length; i++) {
  17272. if (props[i].type === 7) {
  17273. props[i] = dirToAttr(props[i]);
  17274. }
  17275. }
  17276. }
  17277. }
  17278. },
  17279. ondirarg(start, end) {
  17280. if (start === end) return;
  17281. const arg = getSlice(start, end);
  17282. if (inVPre) {
  17283. currentProp.name += arg;
  17284. setLocEnd(currentProp.nameLoc, end);
  17285. } else {
  17286. const isStatic = arg[0] !== `[`;
  17287. currentProp.arg = createExp(
  17288. isStatic ? arg : arg.slice(1, -1),
  17289. isStatic,
  17290. getLoc(start, end),
  17291. isStatic ? 3 : 0
  17292. );
  17293. }
  17294. },
  17295. ondirmodifier(start, end) {
  17296. const mod = getSlice(start, end);
  17297. if (inVPre) {
  17298. currentProp.name += "." + mod;
  17299. setLocEnd(currentProp.nameLoc, end);
  17300. } else if (currentProp.name === "slot") {
  17301. const arg = currentProp.arg;
  17302. if (arg) {
  17303. arg.content += "." + mod;
  17304. setLocEnd(arg.loc, end);
  17305. }
  17306. } else {
  17307. currentProp.modifiers.push(mod);
  17308. }
  17309. },
  17310. onattribdata(start, end) {
  17311. currentAttrValue += getSlice(start, end);
  17312. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  17313. currentAttrEndIndex = end;
  17314. },
  17315. onattribentity(char, start, end) {
  17316. currentAttrValue += char;
  17317. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  17318. currentAttrEndIndex = end;
  17319. },
  17320. onattribnameend(end) {
  17321. const start = currentProp.loc.start.offset;
  17322. const name = getSlice(start, end);
  17323. if (currentProp.type === 7) {
  17324. currentProp.rawName = name;
  17325. }
  17326. if (currentOpenTag.props.some(
  17327. (p) => (p.type === 7 ? p.rawName : p.name) === name
  17328. )) {
  17329. emitError(2, start);
  17330. }
  17331. },
  17332. onattribend(quote, end) {
  17333. if (currentOpenTag && currentProp) {
  17334. setLocEnd(currentProp.loc, end);
  17335. if (quote !== 0) {
  17336. if (currentProp.type === 6) {
  17337. if (currentProp.name === "class") {
  17338. currentAttrValue = condense(currentAttrValue).trim();
  17339. }
  17340. if (quote === 1 && !currentAttrValue) {
  17341. emitError(13, end);
  17342. }
  17343. currentProp.value = {
  17344. type: 2,
  17345. content: currentAttrValue,
  17346. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  17347. };
  17348. if (tokenizer$2.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  17349. tokenizer$2.enterRCDATA(toCharCodes(`</template`), 0);
  17350. }
  17351. } else {
  17352. let expParseMode = 0 /* Normal */;
  17353. {
  17354. if (currentProp.name === "for") {
  17355. expParseMode = 3 /* Skip */;
  17356. } else if (currentProp.name === "slot") {
  17357. expParseMode = 1 /* Params */;
  17358. } else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
  17359. expParseMode = 2 /* Statements */;
  17360. }
  17361. }
  17362. currentProp.exp = createExp(
  17363. currentAttrValue,
  17364. false,
  17365. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  17366. 0,
  17367. expParseMode
  17368. );
  17369. if (currentProp.name === "for") {
  17370. currentProp.forParseResult = parseForExpression(currentProp.exp);
  17371. }
  17372. }
  17373. }
  17374. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  17375. currentOpenTag.props.push(currentProp);
  17376. }
  17377. }
  17378. currentAttrValue = "";
  17379. currentAttrStartIndex = currentAttrEndIndex = -1;
  17380. },
  17381. oncomment(start, end) {
  17382. if (currentOptions.comments) {
  17383. addNode({
  17384. type: 3,
  17385. content: getSlice(start, end),
  17386. loc: getLoc(start - 4, end + 3)
  17387. });
  17388. }
  17389. },
  17390. onend() {
  17391. const end = currentInput.length;
  17392. if (tokenizer$2.state !== 1) {
  17393. switch (tokenizer$2.state) {
  17394. case 5:
  17395. case 8:
  17396. emitError(5, end);
  17397. break;
  17398. case 3:
  17399. case 4:
  17400. emitError(
  17401. 25,
  17402. tokenizer$2.sectionStart
  17403. );
  17404. break;
  17405. case 28:
  17406. if (tokenizer$2.currentSequence === Sequences.CdataEnd) {
  17407. emitError(6, end);
  17408. } else {
  17409. emitError(7, end);
  17410. }
  17411. break;
  17412. case 6:
  17413. case 7:
  17414. case 9:
  17415. case 11:
  17416. case 12:
  17417. case 13:
  17418. case 14:
  17419. case 15:
  17420. case 16:
  17421. case 17:
  17422. case 18:
  17423. case 19:
  17424. case 20:
  17425. case 21:
  17426. emitError(9, end);
  17427. break;
  17428. }
  17429. }
  17430. for (let index = 0; index < stack.length; index++) {
  17431. onCloseTag(stack[index], end - 1);
  17432. emitError(24, stack[index].loc.start.offset);
  17433. }
  17434. },
  17435. oncdata(start, end) {
  17436. if (stack[0].ns !== 0) {
  17437. onText(getSlice(start, end), start, end);
  17438. } else {
  17439. emitError(1, start - 9);
  17440. }
  17441. },
  17442. onprocessinginstruction(start) {
  17443. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17444. emitError(
  17445. 21,
  17446. start - 1
  17447. );
  17448. }
  17449. }
  17450. });
  17451. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  17452. const stripParensRE = /^\(|\)$/g;
  17453. function parseForExpression(input) {
  17454. const loc = input.loc;
  17455. const exp = input.content;
  17456. const inMatch = exp.match(forAliasRE);
  17457. if (!inMatch) return;
  17458. const [, LHS, RHS] = inMatch;
  17459. const createAliasExpression = (content, offset, asParam = false) => {
  17460. const start = loc.start.offset + offset;
  17461. const end = start + content.length;
  17462. return createExp(
  17463. content,
  17464. false,
  17465. getLoc(start, end),
  17466. 0,
  17467. asParam ? 1 /* Params */ : 0 /* Normal */
  17468. );
  17469. };
  17470. const result = {
  17471. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  17472. value: void 0,
  17473. key: void 0,
  17474. index: void 0,
  17475. finalized: false
  17476. };
  17477. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  17478. const trimmedOffset = LHS.indexOf(valueContent);
  17479. const iteratorMatch = valueContent.match(forIteratorRE);
  17480. if (iteratorMatch) {
  17481. valueContent = valueContent.replace(forIteratorRE, "").trim();
  17482. const keyContent = iteratorMatch[1].trim();
  17483. let keyOffset;
  17484. if (keyContent) {
  17485. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  17486. result.key = createAliasExpression(keyContent, keyOffset, true);
  17487. }
  17488. if (iteratorMatch[2]) {
  17489. const indexContent = iteratorMatch[2].trim();
  17490. if (indexContent) {
  17491. result.index = createAliasExpression(
  17492. indexContent,
  17493. exp.indexOf(
  17494. indexContent,
  17495. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  17496. ),
  17497. true
  17498. );
  17499. }
  17500. }
  17501. }
  17502. if (valueContent) {
  17503. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  17504. }
  17505. return result;
  17506. }
  17507. function getSlice(start, end) {
  17508. return currentInput.slice(start, end);
  17509. }
  17510. function endOpenTag(end) {
  17511. if (tokenizer$2.inSFCRoot) {
  17512. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  17513. }
  17514. addNode(currentOpenTag);
  17515. const { tag, ns } = currentOpenTag;
  17516. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17517. inPre++;
  17518. }
  17519. if (currentOptions.isVoidTag(tag)) {
  17520. onCloseTag(currentOpenTag, end);
  17521. } else {
  17522. stack.unshift(currentOpenTag);
  17523. if (ns === 1 || ns === 2) {
  17524. tokenizer$2.inXML = true;
  17525. }
  17526. }
  17527. currentOpenTag = null;
  17528. }
  17529. function onText(content, start, end) {
  17530. const parent = stack[0] || currentRoot;
  17531. const lastNode = parent.children[parent.children.length - 1];
  17532. if (lastNode && lastNode.type === 2) {
  17533. lastNode.content += content;
  17534. setLocEnd(lastNode.loc, end);
  17535. } else {
  17536. parent.children.push({
  17537. type: 2,
  17538. content,
  17539. loc: getLoc(start, end)
  17540. });
  17541. }
  17542. }
  17543. function onCloseTag(el, end, isImplied = false) {
  17544. if (isImplied) {
  17545. setLocEnd(el.loc, backTrack(end, 60));
  17546. } else {
  17547. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  17548. }
  17549. if (tokenizer$2.inSFCRoot) {
  17550. if (el.children.length) {
  17551. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  17552. } else {
  17553. el.innerLoc.end = extend({}, el.innerLoc.start);
  17554. }
  17555. el.innerLoc.source = getSlice(
  17556. el.innerLoc.start.offset,
  17557. el.innerLoc.end.offset
  17558. );
  17559. }
  17560. const { tag, ns } = el;
  17561. if (!inVPre) {
  17562. if (tag === "slot") {
  17563. el.tagType = 2;
  17564. } else if (isFragmentTemplate(el)) {
  17565. el.tagType = 3;
  17566. } else if (isComponent(el)) {
  17567. el.tagType = 1;
  17568. }
  17569. }
  17570. if (!tokenizer$2.inRCDATA) {
  17571. el.children = condenseWhitespace(el.children, el.tag);
  17572. }
  17573. if (ns === 0 && currentOptions.isPreTag(tag)) {
  17574. inPre--;
  17575. }
  17576. if (currentVPreBoundary === el) {
  17577. inVPre = tokenizer$2.inVPre = false;
  17578. currentVPreBoundary = null;
  17579. }
  17580. if (tokenizer$2.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  17581. tokenizer$2.inXML = false;
  17582. }
  17583. }
  17584. function lookAhead(index, c) {
  17585. let i = index;
  17586. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
  17587. return i;
  17588. }
  17589. function backTrack(index, c) {
  17590. let i = index;
  17591. while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
  17592. return i;
  17593. }
  17594. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  17595. function isFragmentTemplate({ tag, props }) {
  17596. if (tag === "template") {
  17597. for (let i = 0; i < props.length; i++) {
  17598. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  17599. return true;
  17600. }
  17601. }
  17602. }
  17603. return false;
  17604. }
  17605. function isComponent({ tag, props }) {
  17606. if (currentOptions.isCustomElement(tag)) {
  17607. return false;
  17608. }
  17609. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  17610. return true;
  17611. }
  17612. for (let i = 0; i < props.length; i++) {
  17613. const p = props[i];
  17614. if (p.type === 6) {
  17615. if (p.name === "is" && p.value) {
  17616. if (p.value.content.startsWith("vue:")) {
  17617. return true;
  17618. }
  17619. }
  17620. }
  17621. }
  17622. return false;
  17623. }
  17624. function isUpperCase(c) {
  17625. return c > 64 && c < 91;
  17626. }
  17627. const windowsNewlineRE = /\r\n/g;
  17628. function condenseWhitespace(nodes, tag) {
  17629. const shouldCondense = currentOptions.whitespace !== "preserve";
  17630. let removedWhitespace = false;
  17631. for (let i = 0; i < nodes.length; i++) {
  17632. const node = nodes[i];
  17633. if (node.type === 2) {
  17634. if (!inPre) {
  17635. if (isAllWhitespace(node.content)) {
  17636. const prev = nodes[i - 1] && nodes[i - 1].type;
  17637. const next = nodes[i + 1] && nodes[i + 1].type;
  17638. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  17639. removedWhitespace = true;
  17640. nodes[i] = null;
  17641. } else {
  17642. node.content = " ";
  17643. }
  17644. } else if (shouldCondense) {
  17645. node.content = condense(node.content);
  17646. }
  17647. } else {
  17648. node.content = node.content.replace(windowsNewlineRE, "\n");
  17649. }
  17650. }
  17651. }
  17652. if (inPre && tag && currentOptions.isPreTag(tag)) {
  17653. const first = nodes[0];
  17654. if (first && first.type === 2) {
  17655. first.content = first.content.replace(/^\r?\n/, "");
  17656. }
  17657. }
  17658. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  17659. }
  17660. function isAllWhitespace(str) {
  17661. for (let i = 0; i < str.length; i++) {
  17662. if (!isWhitespace$1(str.charCodeAt(i))) {
  17663. return false;
  17664. }
  17665. }
  17666. return true;
  17667. }
  17668. function hasNewlineChar(str) {
  17669. for (let i = 0; i < str.length; i++) {
  17670. const c = str.charCodeAt(i);
  17671. if (c === 10 || c === 13) {
  17672. return true;
  17673. }
  17674. }
  17675. return false;
  17676. }
  17677. function condense(str) {
  17678. let ret = "";
  17679. let prevCharIsWhitespace = false;
  17680. for (let i = 0; i < str.length; i++) {
  17681. if (isWhitespace$1(str.charCodeAt(i))) {
  17682. if (!prevCharIsWhitespace) {
  17683. ret += " ";
  17684. prevCharIsWhitespace = true;
  17685. }
  17686. } else {
  17687. ret += str[i];
  17688. prevCharIsWhitespace = false;
  17689. }
  17690. }
  17691. return ret;
  17692. }
  17693. function addNode(node) {
  17694. (stack[0] || currentRoot).children.push(node);
  17695. }
  17696. function getLoc(start, end) {
  17697. return {
  17698. start: tokenizer$2.getPos(start),
  17699. // @ts-expect-error allow late attachment
  17700. end: end == null ? end : tokenizer$2.getPos(end),
  17701. // @ts-expect-error allow late attachment
  17702. source: end == null ? end : getSlice(start, end)
  17703. };
  17704. }
  17705. function setLocEnd(loc, end) {
  17706. loc.end = tokenizer$2.getPos(end);
  17707. loc.source = getSlice(loc.start.offset, end);
  17708. }
  17709. function dirToAttr(dir) {
  17710. const attr = {
  17711. type: 6,
  17712. name: dir.rawName,
  17713. nameLoc: getLoc(
  17714. dir.loc.start.offset,
  17715. dir.loc.start.offset + dir.rawName.length
  17716. ),
  17717. value: void 0,
  17718. loc: dir.loc
  17719. };
  17720. if (dir.exp) {
  17721. const loc = dir.exp.loc;
  17722. if (loc.end.offset < dir.loc.end.offset) {
  17723. loc.start.offset--;
  17724. loc.start.column--;
  17725. loc.end.offset++;
  17726. loc.end.column++;
  17727. }
  17728. attr.value = {
  17729. type: 2,
  17730. content: dir.exp.content,
  17731. loc
  17732. };
  17733. }
  17734. return attr;
  17735. }
  17736. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  17737. const exp = createSimpleExpression(content, isStatic, loc, constType);
  17738. if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
  17739. if (isSimpleIdentifier(content)) {
  17740. exp.ast = null;
  17741. return exp;
  17742. }
  17743. try {
  17744. const plugins = currentOptions.expressionPlugins;
  17745. const options = {
  17746. plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
  17747. };
  17748. if (parseMode === 2 /* Statements */) {
  17749. exp.ast = parse_1$1(` ${content} `, options).program;
  17750. } else if (parseMode === 1 /* Params */) {
  17751. exp.ast = parseExpression_1(`(${content})=>{}`, options);
  17752. } else {
  17753. exp.ast = parseExpression_1(`(${content})`, options);
  17754. }
  17755. } catch (e) {
  17756. exp.ast = false;
  17757. emitError(45, loc.start.offset, e.message);
  17758. }
  17759. }
  17760. return exp;
  17761. }
  17762. function emitError(code, index, message) {
  17763. currentOptions.onError(
  17764. createCompilerError(code, getLoc(index, index), void 0, message)
  17765. );
  17766. }
  17767. function reset() {
  17768. tokenizer$2.reset();
  17769. currentOpenTag = null;
  17770. currentProp = null;
  17771. currentAttrValue = "";
  17772. currentAttrStartIndex = -1;
  17773. currentAttrEndIndex = -1;
  17774. stack.length = 0;
  17775. }
  17776. function baseParse(input, options) {
  17777. reset();
  17778. currentInput = input;
  17779. currentOptions = extend({}, defaultParserOptions);
  17780. if (options) {
  17781. let key;
  17782. for (key in options) {
  17783. if (options[key] != null) {
  17784. currentOptions[key] = options[key];
  17785. }
  17786. }
  17787. }
  17788. {
  17789. if (currentOptions.decodeEntities) {
  17790. console.warn(
  17791. `[@vue/compiler-core] decodeEntities option is passed but will be ignored in non-browser builds.`
  17792. );
  17793. }
  17794. }
  17795. tokenizer$2.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  17796. tokenizer$2.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  17797. const delimiters = options && options.delimiters;
  17798. if (delimiters) {
  17799. tokenizer$2.delimiterOpen = toCharCodes(delimiters[0]);
  17800. tokenizer$2.delimiterClose = toCharCodes(delimiters[1]);
  17801. }
  17802. const root = currentRoot = createRoot([], input);
  17803. tokenizer$2.parse(currentInput);
  17804. root.loc = getLoc(0, input.length);
  17805. root.children = condenseWhitespace(root.children);
  17806. currentRoot = null;
  17807. return root;
  17808. }
  17809. function hoistStatic(root, context) {
  17810. walk$1(
  17811. root,
  17812. context,
  17813. // Root node is unfortunately non-hoistable due to potential parent
  17814. // fallthrough attributes.
  17815. isSingleElementRoot(root, root.children[0])
  17816. );
  17817. }
  17818. function isSingleElementRoot(root, child) {
  17819. const { children } = root;
  17820. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  17821. }
  17822. function walk$1(node, context, doNotHoistNode = false) {
  17823. const { children } = node;
  17824. const originalCount = children.length;
  17825. let hoistedCount = 0;
  17826. for (let i = 0; i < children.length; i++) {
  17827. const child = children[i];
  17828. if (child.type === 1 && child.tagType === 0) {
  17829. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  17830. if (constantType > 0) {
  17831. if (constantType >= 2) {
  17832. child.codegenNode.patchFlag = -1;
  17833. child.codegenNode = context.hoist(child.codegenNode);
  17834. hoistedCount++;
  17835. continue;
  17836. }
  17837. } else {
  17838. const codegenNode = child.codegenNode;
  17839. if (codegenNode.type === 13) {
  17840. const flag = codegenNode.patchFlag;
  17841. if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  17842. const props = getNodeProps(child);
  17843. if (props) {
  17844. codegenNode.props = context.hoist(props);
  17845. }
  17846. }
  17847. if (codegenNode.dynamicProps) {
  17848. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  17849. }
  17850. }
  17851. }
  17852. }
  17853. if (child.type === 1) {
  17854. const isComponent = child.tagType === 1;
  17855. if (isComponent) {
  17856. context.scopes.vSlot++;
  17857. }
  17858. walk$1(child, context);
  17859. if (isComponent) {
  17860. context.scopes.vSlot--;
  17861. }
  17862. } else if (child.type === 11) {
  17863. walk$1(child, context, child.children.length === 1);
  17864. } else if (child.type === 9) {
  17865. for (let i2 = 0; i2 < child.branches.length; i2++) {
  17866. walk$1(
  17867. child.branches[i2],
  17868. context,
  17869. child.branches[i2].children.length === 1
  17870. );
  17871. }
  17872. }
  17873. }
  17874. if (hoistedCount && context.transformHoist) {
  17875. context.transformHoist(children, context, node);
  17876. }
  17877. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray$3(node.codegenNode.children)) {
  17878. const hoisted = context.hoist(
  17879. createArrayExpression(node.codegenNode.children)
  17880. );
  17881. if (context.hmr) {
  17882. hoisted.content = `[...${hoisted.content}]`;
  17883. }
  17884. node.codegenNode.children = hoisted;
  17885. }
  17886. }
  17887. function getConstantType(node, context) {
  17888. const { constantCache } = context;
  17889. switch (node.type) {
  17890. case 1:
  17891. if (node.tagType !== 0) {
  17892. return 0;
  17893. }
  17894. const cached = constantCache.get(node);
  17895. if (cached !== void 0) {
  17896. return cached;
  17897. }
  17898. const codegenNode = node.codegenNode;
  17899. if (codegenNode.type !== 13) {
  17900. return 0;
  17901. }
  17902. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
  17903. return 0;
  17904. }
  17905. if (codegenNode.patchFlag === void 0) {
  17906. let returnType2 = 3;
  17907. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  17908. if (generatedPropsType === 0) {
  17909. constantCache.set(node, 0);
  17910. return 0;
  17911. }
  17912. if (generatedPropsType < returnType2) {
  17913. returnType2 = generatedPropsType;
  17914. }
  17915. for (let i = 0; i < node.children.length; i++) {
  17916. const childType = getConstantType(node.children[i], context);
  17917. if (childType === 0) {
  17918. constantCache.set(node, 0);
  17919. return 0;
  17920. }
  17921. if (childType < returnType2) {
  17922. returnType2 = childType;
  17923. }
  17924. }
  17925. if (returnType2 > 1) {
  17926. for (let i = 0; i < node.props.length; i++) {
  17927. const p = node.props[i];
  17928. if (p.type === 7 && p.name === "bind" && p.exp) {
  17929. const expType = getConstantType(p.exp, context);
  17930. if (expType === 0) {
  17931. constantCache.set(node, 0);
  17932. return 0;
  17933. }
  17934. if (expType < returnType2) {
  17935. returnType2 = expType;
  17936. }
  17937. }
  17938. }
  17939. }
  17940. if (codegenNode.isBlock) {
  17941. for (let i = 0; i < node.props.length; i++) {
  17942. const p = node.props[i];
  17943. if (p.type === 7) {
  17944. constantCache.set(node, 0);
  17945. return 0;
  17946. }
  17947. }
  17948. context.removeHelper(OPEN_BLOCK);
  17949. context.removeHelper(
  17950. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  17951. );
  17952. codegenNode.isBlock = false;
  17953. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  17954. }
  17955. constantCache.set(node, returnType2);
  17956. return returnType2;
  17957. } else {
  17958. constantCache.set(node, 0);
  17959. return 0;
  17960. }
  17961. case 2:
  17962. case 3:
  17963. return 3;
  17964. case 9:
  17965. case 11:
  17966. case 10:
  17967. return 0;
  17968. case 5:
  17969. case 12:
  17970. return getConstantType(node.content, context);
  17971. case 4:
  17972. return node.constType;
  17973. case 8:
  17974. let returnType = 3;
  17975. for (let i = 0; i < node.children.length; i++) {
  17976. const child = node.children[i];
  17977. if (isString$2(child) || isSymbol$1(child)) {
  17978. continue;
  17979. }
  17980. const childType = getConstantType(child, context);
  17981. if (childType === 0) {
  17982. return 0;
  17983. } else if (childType < returnType) {
  17984. returnType = childType;
  17985. }
  17986. }
  17987. return returnType;
  17988. default:
  17989. return 0;
  17990. }
  17991. }
  17992. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  17993. NORMALIZE_CLASS,
  17994. NORMALIZE_STYLE,
  17995. NORMALIZE_PROPS,
  17996. GUARD_REACTIVE_PROPS
  17997. ]);
  17998. function getConstantTypeOfHelperCall(value, context) {
  17999. if (value.type === 14 && !isString$2(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  18000. const arg = value.arguments[0];
  18001. if (arg.type === 4) {
  18002. return getConstantType(arg, context);
  18003. } else if (arg.type === 14) {
  18004. return getConstantTypeOfHelperCall(arg, context);
  18005. }
  18006. }
  18007. return 0;
  18008. }
  18009. function getGeneratedPropsConstantType(node, context) {
  18010. let returnType = 3;
  18011. const props = getNodeProps(node);
  18012. if (props && props.type === 15) {
  18013. const { properties } = props;
  18014. for (let i = 0; i < properties.length; i++) {
  18015. const { key, value } = properties[i];
  18016. const keyType = getConstantType(key, context);
  18017. if (keyType === 0) {
  18018. return keyType;
  18019. }
  18020. if (keyType < returnType) {
  18021. returnType = keyType;
  18022. }
  18023. let valueType;
  18024. if (value.type === 4) {
  18025. valueType = getConstantType(value, context);
  18026. } else if (value.type === 14) {
  18027. valueType = getConstantTypeOfHelperCall(value, context);
  18028. } else {
  18029. valueType = 0;
  18030. }
  18031. if (valueType === 0) {
  18032. return valueType;
  18033. }
  18034. if (valueType < returnType) {
  18035. returnType = valueType;
  18036. }
  18037. }
  18038. }
  18039. return returnType;
  18040. }
  18041. function getNodeProps(node) {
  18042. const codegenNode = node.codegenNode;
  18043. if (codegenNode.type === 13) {
  18044. return codegenNode.props;
  18045. }
  18046. }
  18047. function createTransformContext(root, {
  18048. filename = "",
  18049. prefixIdentifiers = false,
  18050. hoistStatic: hoistStatic2 = false,
  18051. hmr = false,
  18052. cacheHandlers = false,
  18053. nodeTransforms = [],
  18054. directiveTransforms = {},
  18055. transformHoist = null,
  18056. isBuiltInComponent = NOOP,
  18057. isCustomElement = NOOP,
  18058. expressionPlugins = [],
  18059. scopeId = null,
  18060. slotted = true,
  18061. ssr = false,
  18062. inSSR = false,
  18063. ssrCssVars = ``,
  18064. bindingMetadata = EMPTY_OBJ,
  18065. inline = false,
  18066. isTS = false,
  18067. onError = defaultOnError,
  18068. onWarn = defaultOnWarn,
  18069. compatConfig
  18070. }) {
  18071. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  18072. const context = {
  18073. // options
  18074. filename,
  18075. selfName: nameMatch && capitalize$1(camelize(nameMatch[1])),
  18076. prefixIdentifiers,
  18077. hoistStatic: hoistStatic2,
  18078. hmr,
  18079. cacheHandlers,
  18080. nodeTransforms,
  18081. directiveTransforms,
  18082. transformHoist,
  18083. isBuiltInComponent,
  18084. isCustomElement,
  18085. expressionPlugins,
  18086. scopeId,
  18087. slotted,
  18088. ssr,
  18089. inSSR,
  18090. ssrCssVars,
  18091. bindingMetadata,
  18092. inline,
  18093. isTS,
  18094. onError,
  18095. onWarn,
  18096. compatConfig,
  18097. // state
  18098. root,
  18099. helpers: /* @__PURE__ */ new Map(),
  18100. components: /* @__PURE__ */ new Set(),
  18101. directives: /* @__PURE__ */ new Set(),
  18102. hoists: [],
  18103. imports: [],
  18104. constantCache: /* @__PURE__ */ new WeakMap(),
  18105. temps: 0,
  18106. cached: 0,
  18107. identifiers: /* @__PURE__ */ Object.create(null),
  18108. scopes: {
  18109. vFor: 0,
  18110. vSlot: 0,
  18111. vPre: 0,
  18112. vOnce: 0
  18113. },
  18114. parent: null,
  18115. grandParent: null,
  18116. currentNode: root,
  18117. childIndex: 0,
  18118. inVOnce: false,
  18119. // methods
  18120. helper(name) {
  18121. const count = context.helpers.get(name) || 0;
  18122. context.helpers.set(name, count + 1);
  18123. return name;
  18124. },
  18125. removeHelper(name) {
  18126. const count = context.helpers.get(name);
  18127. if (count) {
  18128. const currentCount = count - 1;
  18129. if (!currentCount) {
  18130. context.helpers.delete(name);
  18131. } else {
  18132. context.helpers.set(name, currentCount);
  18133. }
  18134. }
  18135. },
  18136. helperString(name) {
  18137. return `_${helperNameMap[context.helper(name)]}`;
  18138. },
  18139. replaceNode(node) {
  18140. {
  18141. if (!context.currentNode) {
  18142. throw new Error(`Node being replaced is already removed.`);
  18143. }
  18144. if (!context.parent) {
  18145. throw new Error(`Cannot replace root node.`);
  18146. }
  18147. }
  18148. context.parent.children[context.childIndex] = context.currentNode = node;
  18149. },
  18150. removeNode(node) {
  18151. if (!context.parent) {
  18152. throw new Error(`Cannot remove root node.`);
  18153. }
  18154. const list = context.parent.children;
  18155. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  18156. if (removalIndex < 0) {
  18157. throw new Error(`node being removed is not a child of current parent`);
  18158. }
  18159. if (!node || node === context.currentNode) {
  18160. context.currentNode = null;
  18161. context.onNodeRemoved();
  18162. } else {
  18163. if (context.childIndex > removalIndex) {
  18164. context.childIndex--;
  18165. context.onNodeRemoved();
  18166. }
  18167. }
  18168. context.parent.children.splice(removalIndex, 1);
  18169. },
  18170. onNodeRemoved: NOOP,
  18171. addIdentifiers(exp) {
  18172. {
  18173. if (isString$2(exp)) {
  18174. addId(exp);
  18175. } else if (exp.identifiers) {
  18176. exp.identifiers.forEach(addId);
  18177. } else if (exp.type === 4) {
  18178. addId(exp.content);
  18179. }
  18180. }
  18181. },
  18182. removeIdentifiers(exp) {
  18183. {
  18184. if (isString$2(exp)) {
  18185. removeId(exp);
  18186. } else if (exp.identifiers) {
  18187. exp.identifiers.forEach(removeId);
  18188. } else if (exp.type === 4) {
  18189. removeId(exp.content);
  18190. }
  18191. }
  18192. },
  18193. hoist(exp) {
  18194. if (isString$2(exp)) exp = createSimpleExpression(exp);
  18195. context.hoists.push(exp);
  18196. const identifier = createSimpleExpression(
  18197. `_hoisted_${context.hoists.length}`,
  18198. false,
  18199. exp.loc,
  18200. 2
  18201. );
  18202. identifier.hoisted = exp;
  18203. return identifier;
  18204. },
  18205. cache(exp, isVNode = false) {
  18206. return createCacheExpression(context.cached++, exp, isVNode);
  18207. }
  18208. };
  18209. function addId(id) {
  18210. const { identifiers } = context;
  18211. if (identifiers[id] === void 0) {
  18212. identifiers[id] = 0;
  18213. }
  18214. identifiers[id]++;
  18215. }
  18216. function removeId(id) {
  18217. context.identifiers[id]--;
  18218. }
  18219. return context;
  18220. }
  18221. function transform(root, options) {
  18222. const context = createTransformContext(root, options);
  18223. traverseNode(root, context);
  18224. if (options.hoistStatic) {
  18225. hoistStatic(root, context);
  18226. }
  18227. if (!options.ssr) {
  18228. createRootCodegen(root, context);
  18229. }
  18230. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  18231. root.components = [...context.components];
  18232. root.directives = [...context.directives];
  18233. root.imports = context.imports;
  18234. root.hoists = context.hoists;
  18235. root.temps = context.temps;
  18236. root.cached = context.cached;
  18237. root.transformed = true;
  18238. }
  18239. function createRootCodegen(root, context) {
  18240. const { helper } = context;
  18241. const { children } = root;
  18242. if (children.length === 1) {
  18243. const child = children[0];
  18244. if (isSingleElementRoot(root, child) && child.codegenNode) {
  18245. const codegenNode = child.codegenNode;
  18246. if (codegenNode.type === 13) {
  18247. convertToBlock(codegenNode, context);
  18248. }
  18249. root.codegenNode = codegenNode;
  18250. } else {
  18251. root.codegenNode = child;
  18252. }
  18253. } else if (children.length > 1) {
  18254. let patchFlag = 64;
  18255. let patchFlagText = PatchFlagNames[64];
  18256. if (children.filter((c) => c.type !== 3).length === 1) {
  18257. patchFlag |= 2048;
  18258. patchFlagText += `, ${PatchFlagNames[2048]}`;
  18259. }
  18260. root.codegenNode = createVNodeCall(
  18261. context,
  18262. helper(FRAGMENT),
  18263. void 0,
  18264. root.children,
  18265. patchFlag,
  18266. void 0,
  18267. void 0,
  18268. true,
  18269. void 0,
  18270. false
  18271. );
  18272. } else ;
  18273. }
  18274. function traverseChildren(parent, context) {
  18275. let i = 0;
  18276. const nodeRemoved = () => {
  18277. i--;
  18278. };
  18279. for (; i < parent.children.length; i++) {
  18280. const child = parent.children[i];
  18281. if (isString$2(child)) continue;
  18282. context.grandParent = context.parent;
  18283. context.parent = parent;
  18284. context.childIndex = i;
  18285. context.onNodeRemoved = nodeRemoved;
  18286. traverseNode(child, context);
  18287. }
  18288. }
  18289. function traverseNode(node, context) {
  18290. context.currentNode = node;
  18291. const { nodeTransforms } = context;
  18292. const exitFns = [];
  18293. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  18294. const onExit = nodeTransforms[i2](node, context);
  18295. if (onExit) {
  18296. if (isArray$3(onExit)) {
  18297. exitFns.push(...onExit);
  18298. } else {
  18299. exitFns.push(onExit);
  18300. }
  18301. }
  18302. if (!context.currentNode) {
  18303. return;
  18304. } else {
  18305. node = context.currentNode;
  18306. }
  18307. }
  18308. switch (node.type) {
  18309. case 3:
  18310. if (!context.ssr) {
  18311. context.helper(CREATE_COMMENT);
  18312. }
  18313. break;
  18314. case 5:
  18315. if (!context.ssr) {
  18316. context.helper(TO_DISPLAY_STRING);
  18317. }
  18318. break;
  18319. case 9:
  18320. for (let i2 = 0; i2 < node.branches.length; i2++) {
  18321. traverseNode(node.branches[i2], context);
  18322. }
  18323. break;
  18324. case 10:
  18325. case 11:
  18326. case 1:
  18327. case 0:
  18328. traverseChildren(node, context);
  18329. break;
  18330. }
  18331. context.currentNode = node;
  18332. let i = exitFns.length;
  18333. while (i--) {
  18334. exitFns[i]();
  18335. }
  18336. }
  18337. function createStructuralDirectiveTransform(name, fn) {
  18338. const matches = isString$2(name) ? (n) => n === name : (n) => name.test(n);
  18339. return (node, context) => {
  18340. if (node.type === 1) {
  18341. const { props } = node;
  18342. if (node.tagType === 3 && props.some(isVSlot)) {
  18343. return;
  18344. }
  18345. const exitFns = [];
  18346. for (let i = 0; i < props.length; i++) {
  18347. const prop = props[i];
  18348. if (prop.type === 7 && matches(prop.name)) {
  18349. props.splice(i, 1);
  18350. i--;
  18351. const onExit = fn(node, prop, context);
  18352. if (onExit) exitFns.push(onExit);
  18353. }
  18354. }
  18355. return exitFns;
  18356. }
  18357. };
  18358. }
  18359. var sourceMap$2 = {};
  18360. var sourceMapGenerator$1 = {};
  18361. var base64Vlq$1 = {};
  18362. var base64$3 = {};
  18363. /* -*- Mode: js; js-indent-level: 2; -*- */
  18364. /*
  18365. * Copyright 2011 Mozilla Foundation and contributors
  18366. * Licensed under the New BSD license. See LICENSE or:
  18367. * http://opensource.org/licenses/BSD-3-Clause
  18368. */
  18369. var intToCharMap$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  18370. /**
  18371. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  18372. */
  18373. base64$3.encode = function (number) {
  18374. if (0 <= number && number < intToCharMap$1.length) {
  18375. return intToCharMap$1[number];
  18376. }
  18377. throw new TypeError("Must be between 0 and 63: " + number);
  18378. };
  18379. /**
  18380. * Decode a single base 64 character code digit to an integer. Returns -1 on
  18381. * failure.
  18382. */
  18383. base64$3.decode = function (charCode) {
  18384. var bigA = 65; // 'A'
  18385. var bigZ = 90; // 'Z'
  18386. var littleA = 97; // 'a'
  18387. var littleZ = 122; // 'z'
  18388. var zero = 48; // '0'
  18389. var nine = 57; // '9'
  18390. var plus = 43; // '+'
  18391. var slash = 47; // '/'
  18392. var littleOffset = 26;
  18393. var numberOffset = 52;
  18394. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  18395. if (bigA <= charCode && charCode <= bigZ) {
  18396. return (charCode - bigA);
  18397. }
  18398. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  18399. if (littleA <= charCode && charCode <= littleZ) {
  18400. return (charCode - littleA + littleOffset);
  18401. }
  18402. // 52 - 61: 0123456789
  18403. if (zero <= charCode && charCode <= nine) {
  18404. return (charCode - zero + numberOffset);
  18405. }
  18406. // 62: +
  18407. if (charCode == plus) {
  18408. return 62;
  18409. }
  18410. // 63: /
  18411. if (charCode == slash) {
  18412. return 63;
  18413. }
  18414. // Invalid base64 digit.
  18415. return -1;
  18416. };
  18417. /* -*- Mode: js; js-indent-level: 2; -*- */
  18418. /*
  18419. * Copyright 2011 Mozilla Foundation and contributors
  18420. * Licensed under the New BSD license. See LICENSE or:
  18421. * http://opensource.org/licenses/BSD-3-Clause
  18422. *
  18423. * Based on the Base 64 VLQ implementation in Closure Compiler:
  18424. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  18425. *
  18426. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  18427. * Redistribution and use in source and binary forms, with or without
  18428. * modification, are permitted provided that the following conditions are
  18429. * met:
  18430. *
  18431. * * Redistributions of source code must retain the above copyright
  18432. * notice, this list of conditions and the following disclaimer.
  18433. * * Redistributions in binary form must reproduce the above
  18434. * copyright notice, this list of conditions and the following
  18435. * disclaimer in the documentation and/or other materials provided
  18436. * with the distribution.
  18437. * * Neither the name of Google Inc. nor the names of its
  18438. * contributors may be used to endorse or promote products derived
  18439. * from this software without specific prior written permission.
  18440. *
  18441. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18442. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18443. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18444. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18445. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18446. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18447. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18448. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  18449. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18450. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18451. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18452. */
  18453. var base64$2 = base64$3;
  18454. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  18455. // length quantities we use in the source map spec, the first bit is the sign,
  18456. // the next four bits are the actual value, and the 6th bit is the
  18457. // continuation bit. The continuation bit tells us whether there are more
  18458. // digits in this value following this digit.
  18459. //
  18460. // Continuation
  18461. // | Sign
  18462. // | |
  18463. // V V
  18464. // 101011
  18465. var VLQ_BASE_SHIFT$1 = 5;
  18466. // binary: 100000
  18467. var VLQ_BASE$1 = 1 << VLQ_BASE_SHIFT$1;
  18468. // binary: 011111
  18469. var VLQ_BASE_MASK$1 = VLQ_BASE$1 - 1;
  18470. // binary: 100000
  18471. var VLQ_CONTINUATION_BIT$1 = VLQ_BASE$1;
  18472. /**
  18473. * Converts from a two-complement value to a value where the sign bit is
  18474. * placed in the least significant bit. For example, as decimals:
  18475. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  18476. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  18477. */
  18478. function toVLQSigned$1(aValue) {
  18479. return aValue < 0
  18480. ? ((-aValue) << 1) + 1
  18481. : (aValue << 1) + 0;
  18482. }
  18483. /**
  18484. * Converts to a two-complement value from a value where the sign bit is
  18485. * placed in the least significant bit. For example, as decimals:
  18486. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  18487. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  18488. */
  18489. function fromVLQSigned$1(aValue) {
  18490. var isNegative = (aValue & 1) === 1;
  18491. var shifted = aValue >> 1;
  18492. return isNegative
  18493. ? -shifted
  18494. : shifted;
  18495. }
  18496. /**
  18497. * Returns the base 64 VLQ encoded value.
  18498. */
  18499. base64Vlq$1.encode = function base64VLQ_encode(aValue) {
  18500. var encoded = "";
  18501. var digit;
  18502. var vlq = toVLQSigned$1(aValue);
  18503. do {
  18504. digit = vlq & VLQ_BASE_MASK$1;
  18505. vlq >>>= VLQ_BASE_SHIFT$1;
  18506. if (vlq > 0) {
  18507. // There are still more digits in this value, so we must make sure the
  18508. // continuation bit is marked.
  18509. digit |= VLQ_CONTINUATION_BIT$1;
  18510. }
  18511. encoded += base64$2.encode(digit);
  18512. } while (vlq > 0);
  18513. return encoded;
  18514. };
  18515. /**
  18516. * Decodes the next base 64 VLQ value from the given string and returns the
  18517. * value and the rest of the string via the out parameter.
  18518. */
  18519. base64Vlq$1.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  18520. var strLen = aStr.length;
  18521. var result = 0;
  18522. var shift = 0;
  18523. var continuation, digit;
  18524. do {
  18525. if (aIndex >= strLen) {
  18526. throw new Error("Expected more digits in base 64 VLQ value.");
  18527. }
  18528. digit = base64$2.decode(aStr.charCodeAt(aIndex++));
  18529. if (digit === -1) {
  18530. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  18531. }
  18532. continuation = !!(digit & VLQ_CONTINUATION_BIT$1);
  18533. digit &= VLQ_BASE_MASK$1;
  18534. result = result + (digit << shift);
  18535. shift += VLQ_BASE_SHIFT$1;
  18536. } while (continuation);
  18537. aOutParam.value = fromVLQSigned$1(result);
  18538. aOutParam.rest = aIndex;
  18539. };
  18540. var util$c = {};
  18541. /* -*- Mode: js; js-indent-level: 2; -*- */
  18542. (function (exports) {
  18543. /*
  18544. * Copyright 2011 Mozilla Foundation and contributors
  18545. * Licensed under the New BSD license. See LICENSE or:
  18546. * http://opensource.org/licenses/BSD-3-Clause
  18547. */
  18548. /**
  18549. * This is a helper function for getting values from parameter/options
  18550. * objects.
  18551. *
  18552. * @param args The object we are extracting values from
  18553. * @param name The name of the property we are getting.
  18554. * @param defaultValue An optional value to return if the property is missing
  18555. * from the object. If this is not specified and the property is missing, an
  18556. * error will be thrown.
  18557. */
  18558. function getArg(aArgs, aName, aDefaultValue) {
  18559. if (aName in aArgs) {
  18560. return aArgs[aName];
  18561. } else if (arguments.length === 3) {
  18562. return aDefaultValue;
  18563. } else {
  18564. throw new Error('"' + aName + '" is a required argument.');
  18565. }
  18566. }
  18567. exports.getArg = getArg;
  18568. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  18569. var dataUrlRegexp = /^data:.+\,.+$/;
  18570. function urlParse(aUrl) {
  18571. var match = aUrl.match(urlRegexp);
  18572. if (!match) {
  18573. return null;
  18574. }
  18575. return {
  18576. scheme: match[1],
  18577. auth: match[2],
  18578. host: match[3],
  18579. port: match[4],
  18580. path: match[5]
  18581. };
  18582. }
  18583. exports.urlParse = urlParse;
  18584. function urlGenerate(aParsedUrl) {
  18585. var url = '';
  18586. if (aParsedUrl.scheme) {
  18587. url += aParsedUrl.scheme + ':';
  18588. }
  18589. url += '//';
  18590. if (aParsedUrl.auth) {
  18591. url += aParsedUrl.auth + '@';
  18592. }
  18593. if (aParsedUrl.host) {
  18594. url += aParsedUrl.host;
  18595. }
  18596. if (aParsedUrl.port) {
  18597. url += ":" + aParsedUrl.port;
  18598. }
  18599. if (aParsedUrl.path) {
  18600. url += aParsedUrl.path;
  18601. }
  18602. return url;
  18603. }
  18604. exports.urlGenerate = urlGenerate;
  18605. var MAX_CACHED_INPUTS = 32;
  18606. /**
  18607. * Takes some function `f(input) -> result` and returns a memoized version of
  18608. * `f`.
  18609. *
  18610. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  18611. * memoization is a dumb-simple, linear least-recently-used cache.
  18612. */
  18613. function lruMemoize(f) {
  18614. var cache = [];
  18615. return function(input) {
  18616. for (var i = 0; i < cache.length; i++) {
  18617. if (cache[i].input === input) {
  18618. var temp = cache[0];
  18619. cache[0] = cache[i];
  18620. cache[i] = temp;
  18621. return cache[0].result;
  18622. }
  18623. }
  18624. var result = f(input);
  18625. cache.unshift({
  18626. input,
  18627. result,
  18628. });
  18629. if (cache.length > MAX_CACHED_INPUTS) {
  18630. cache.pop();
  18631. }
  18632. return result;
  18633. };
  18634. }
  18635. /**
  18636. * Normalizes a path, or the path portion of a URL:
  18637. *
  18638. * - Replaces consecutive slashes with one slash.
  18639. * - Removes unnecessary '.' parts.
  18640. * - Removes unnecessary '<dir>/..' parts.
  18641. *
  18642. * Based on code in the Node.js 'path' core module.
  18643. *
  18644. * @param aPath The path or url to normalize.
  18645. */
  18646. var normalize = lruMemoize(function normalize(aPath) {
  18647. var path = aPath;
  18648. var url = urlParse(aPath);
  18649. if (url) {
  18650. if (!url.path) {
  18651. return aPath;
  18652. }
  18653. path = url.path;
  18654. }
  18655. var isAbsolute = exports.isAbsolute(path);
  18656. // Split the path into parts between `/` characters. This is much faster than
  18657. // using `.split(/\/+/g)`.
  18658. var parts = [];
  18659. var start = 0;
  18660. var i = 0;
  18661. while (true) {
  18662. start = i;
  18663. i = path.indexOf("/", start);
  18664. if (i === -1) {
  18665. parts.push(path.slice(start));
  18666. break;
  18667. } else {
  18668. parts.push(path.slice(start, i));
  18669. while (i < path.length && path[i] === "/") {
  18670. i++;
  18671. }
  18672. }
  18673. }
  18674. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  18675. part = parts[i];
  18676. if (part === '.') {
  18677. parts.splice(i, 1);
  18678. } else if (part === '..') {
  18679. up++;
  18680. } else if (up > 0) {
  18681. if (part === '') {
  18682. // The first part is blank if the path is absolute. Trying to go
  18683. // above the root is a no-op. Therefore we can remove all '..' parts
  18684. // directly after the root.
  18685. parts.splice(i + 1, up);
  18686. up = 0;
  18687. } else {
  18688. parts.splice(i, 2);
  18689. up--;
  18690. }
  18691. }
  18692. }
  18693. path = parts.join('/');
  18694. if (path === '') {
  18695. path = isAbsolute ? '/' : '.';
  18696. }
  18697. if (url) {
  18698. url.path = path;
  18699. return urlGenerate(url);
  18700. }
  18701. return path;
  18702. });
  18703. exports.normalize = normalize;
  18704. /**
  18705. * Joins two paths/URLs.
  18706. *
  18707. * @param aRoot The root path or URL.
  18708. * @param aPath The path or URL to be joined with the root.
  18709. *
  18710. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  18711. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  18712. * first.
  18713. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  18714. * is updated with the result and aRoot is returned. Otherwise the result
  18715. * is returned.
  18716. * - If aPath is absolute, the result is aPath.
  18717. * - Otherwise the two paths are joined with a slash.
  18718. * - Joining for example 'http://' and 'www.example.com' is also supported.
  18719. */
  18720. function join(aRoot, aPath) {
  18721. if (aRoot === "") {
  18722. aRoot = ".";
  18723. }
  18724. if (aPath === "") {
  18725. aPath = ".";
  18726. }
  18727. var aPathUrl = urlParse(aPath);
  18728. var aRootUrl = urlParse(aRoot);
  18729. if (aRootUrl) {
  18730. aRoot = aRootUrl.path || '/';
  18731. }
  18732. // `join(foo, '//www.example.org')`
  18733. if (aPathUrl && !aPathUrl.scheme) {
  18734. if (aRootUrl) {
  18735. aPathUrl.scheme = aRootUrl.scheme;
  18736. }
  18737. return urlGenerate(aPathUrl);
  18738. }
  18739. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  18740. return aPath;
  18741. }
  18742. // `join('http://', 'www.example.com')`
  18743. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  18744. aRootUrl.host = aPath;
  18745. return urlGenerate(aRootUrl);
  18746. }
  18747. var joined = aPath.charAt(0) === '/'
  18748. ? aPath
  18749. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  18750. if (aRootUrl) {
  18751. aRootUrl.path = joined;
  18752. return urlGenerate(aRootUrl);
  18753. }
  18754. return joined;
  18755. }
  18756. exports.join = join;
  18757. exports.isAbsolute = function (aPath) {
  18758. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  18759. };
  18760. /**
  18761. * Make a path relative to a URL or another path.
  18762. *
  18763. * @param aRoot The root path or URL.
  18764. * @param aPath The path or URL to be made relative to aRoot.
  18765. */
  18766. function relative(aRoot, aPath) {
  18767. if (aRoot === "") {
  18768. aRoot = ".";
  18769. }
  18770. aRoot = aRoot.replace(/\/$/, '');
  18771. // It is possible for the path to be above the root. In this case, simply
  18772. // checking whether the root is a prefix of the path won't work. Instead, we
  18773. // need to remove components from the root one by one, until either we find
  18774. // a prefix that fits, or we run out of components to remove.
  18775. var level = 0;
  18776. while (aPath.indexOf(aRoot + '/') !== 0) {
  18777. var index = aRoot.lastIndexOf("/");
  18778. if (index < 0) {
  18779. return aPath;
  18780. }
  18781. // If the only part of the root that is left is the scheme (i.e. http://,
  18782. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  18783. // have exhausted all components, so the path is not relative to the root.
  18784. aRoot = aRoot.slice(0, index);
  18785. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  18786. return aPath;
  18787. }
  18788. ++level;
  18789. }
  18790. // Make sure we add a "../" for each component we removed from the root.
  18791. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  18792. }
  18793. exports.relative = relative;
  18794. var supportsNullProto = (function () {
  18795. var obj = Object.create(null);
  18796. return !('__proto__' in obj);
  18797. }());
  18798. function identity (s) {
  18799. return s;
  18800. }
  18801. /**
  18802. * Because behavior goes wacky when you set `__proto__` on objects, we
  18803. * have to prefix all the strings in our set with an arbitrary character.
  18804. *
  18805. * See https://github.com/mozilla/source-map/pull/31 and
  18806. * https://github.com/mozilla/source-map/issues/30
  18807. *
  18808. * @param String aStr
  18809. */
  18810. function toSetString(aStr) {
  18811. if (isProtoString(aStr)) {
  18812. return '$' + aStr;
  18813. }
  18814. return aStr;
  18815. }
  18816. exports.toSetString = supportsNullProto ? identity : toSetString;
  18817. function fromSetString(aStr) {
  18818. if (isProtoString(aStr)) {
  18819. return aStr.slice(1);
  18820. }
  18821. return aStr;
  18822. }
  18823. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  18824. function isProtoString(s) {
  18825. if (!s) {
  18826. return false;
  18827. }
  18828. var length = s.length;
  18829. if (length < 9 /* "__proto__".length */) {
  18830. return false;
  18831. }
  18832. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  18833. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  18834. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  18835. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  18836. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  18837. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  18838. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  18839. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  18840. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  18841. return false;
  18842. }
  18843. for (var i = length - 10; i >= 0; i--) {
  18844. if (s.charCodeAt(i) !== 36 /* '$' */) {
  18845. return false;
  18846. }
  18847. }
  18848. return true;
  18849. }
  18850. /**
  18851. * Comparator between two mappings where the original positions are compared.
  18852. *
  18853. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  18854. * mappings with the same original source/line/column, but different generated
  18855. * line and column the same. Useful when searching for a mapping with a
  18856. * stubbed out mapping.
  18857. */
  18858. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  18859. var cmp = strcmp(mappingA.source, mappingB.source);
  18860. if (cmp !== 0) {
  18861. return cmp;
  18862. }
  18863. cmp = mappingA.originalLine - mappingB.originalLine;
  18864. if (cmp !== 0) {
  18865. return cmp;
  18866. }
  18867. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18868. if (cmp !== 0 || onlyCompareOriginal) {
  18869. return cmp;
  18870. }
  18871. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18872. if (cmp !== 0) {
  18873. return cmp;
  18874. }
  18875. cmp = mappingA.generatedLine - mappingB.generatedLine;
  18876. if (cmp !== 0) {
  18877. return cmp;
  18878. }
  18879. return strcmp(mappingA.name, mappingB.name);
  18880. }
  18881. exports.compareByOriginalPositions = compareByOriginalPositions;
  18882. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  18883. var cmp;
  18884. cmp = mappingA.originalLine - mappingB.originalLine;
  18885. if (cmp !== 0) {
  18886. return cmp;
  18887. }
  18888. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18889. if (cmp !== 0 || onlyCompareOriginal) {
  18890. return cmp;
  18891. }
  18892. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18893. if (cmp !== 0) {
  18894. return cmp;
  18895. }
  18896. cmp = mappingA.generatedLine - mappingB.generatedLine;
  18897. if (cmp !== 0) {
  18898. return cmp;
  18899. }
  18900. return strcmp(mappingA.name, mappingB.name);
  18901. }
  18902. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  18903. /**
  18904. * Comparator between two mappings with deflated source and name indices where
  18905. * the generated positions are compared.
  18906. *
  18907. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  18908. * mappings with the same generated line and column, but different
  18909. * source/name/original line and column the same. Useful when searching for a
  18910. * mapping with a stubbed out mapping.
  18911. */
  18912. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  18913. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  18914. if (cmp !== 0) {
  18915. return cmp;
  18916. }
  18917. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18918. if (cmp !== 0 || onlyCompareGenerated) {
  18919. return cmp;
  18920. }
  18921. cmp = strcmp(mappingA.source, mappingB.source);
  18922. if (cmp !== 0) {
  18923. return cmp;
  18924. }
  18925. cmp = mappingA.originalLine - mappingB.originalLine;
  18926. if (cmp !== 0) {
  18927. return cmp;
  18928. }
  18929. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18930. if (cmp !== 0) {
  18931. return cmp;
  18932. }
  18933. return strcmp(mappingA.name, mappingB.name);
  18934. }
  18935. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  18936. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  18937. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18938. if (cmp !== 0 || onlyCompareGenerated) {
  18939. return cmp;
  18940. }
  18941. cmp = strcmp(mappingA.source, mappingB.source);
  18942. if (cmp !== 0) {
  18943. return cmp;
  18944. }
  18945. cmp = mappingA.originalLine - mappingB.originalLine;
  18946. if (cmp !== 0) {
  18947. return cmp;
  18948. }
  18949. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18950. if (cmp !== 0) {
  18951. return cmp;
  18952. }
  18953. return strcmp(mappingA.name, mappingB.name);
  18954. }
  18955. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  18956. function strcmp(aStr1, aStr2) {
  18957. if (aStr1 === aStr2) {
  18958. return 0;
  18959. }
  18960. if (aStr1 === null) {
  18961. return 1; // aStr2 !== null
  18962. }
  18963. if (aStr2 === null) {
  18964. return -1; // aStr1 !== null
  18965. }
  18966. if (aStr1 > aStr2) {
  18967. return 1;
  18968. }
  18969. return -1;
  18970. }
  18971. /**
  18972. * Comparator between two mappings with inflated source and name strings where
  18973. * the generated positions are compared.
  18974. */
  18975. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  18976. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  18977. if (cmp !== 0) {
  18978. return cmp;
  18979. }
  18980. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  18981. if (cmp !== 0) {
  18982. return cmp;
  18983. }
  18984. cmp = strcmp(mappingA.source, mappingB.source);
  18985. if (cmp !== 0) {
  18986. return cmp;
  18987. }
  18988. cmp = mappingA.originalLine - mappingB.originalLine;
  18989. if (cmp !== 0) {
  18990. return cmp;
  18991. }
  18992. cmp = mappingA.originalColumn - mappingB.originalColumn;
  18993. if (cmp !== 0) {
  18994. return cmp;
  18995. }
  18996. return strcmp(mappingA.name, mappingB.name);
  18997. }
  18998. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  18999. /**
  19000. * Strip any JSON XSSI avoidance prefix from the string (as documented
  19001. * in the source maps specification), and then parse the string as
  19002. * JSON.
  19003. */
  19004. function parseSourceMapInput(str) {
  19005. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  19006. }
  19007. exports.parseSourceMapInput = parseSourceMapInput;
  19008. /**
  19009. * Compute the URL of a source given the the source root, the source's
  19010. * URL, and the source map's URL.
  19011. */
  19012. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  19013. sourceURL = sourceURL || '';
  19014. if (sourceRoot) {
  19015. // This follows what Chrome does.
  19016. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  19017. sourceRoot += '/';
  19018. }
  19019. // The spec says:
  19020. // Line 4: An optional source root, useful for relocating source
  19021. // files on a server or removing repeated values in the
  19022. // “sources” entry. This value is prepended to the individual
  19023. // entries in the “source” field.
  19024. sourceURL = sourceRoot + sourceURL;
  19025. }
  19026. // Historically, SourceMapConsumer did not take the sourceMapURL as
  19027. // a parameter. This mode is still somewhat supported, which is why
  19028. // this code block is conditional. However, it's preferable to pass
  19029. // the source map URL to SourceMapConsumer, so that this function
  19030. // can implement the source URL resolution algorithm as outlined in
  19031. // the spec. This block is basically the equivalent of:
  19032. // new URL(sourceURL, sourceMapURL).toString()
  19033. // ... except it avoids using URL, which wasn't available in the
  19034. // older releases of node still supported by this library.
  19035. //
  19036. // The spec says:
  19037. // If the sources are not absolute URLs after prepending of the
  19038. // “sourceRoot”, the sources are resolved relative to the
  19039. // SourceMap (like resolving script src in a html document).
  19040. if (sourceMapURL) {
  19041. var parsed = urlParse(sourceMapURL);
  19042. if (!parsed) {
  19043. throw new Error("sourceMapURL could not be parsed");
  19044. }
  19045. if (parsed.path) {
  19046. // Strip the last path component, but keep the "/".
  19047. var index = parsed.path.lastIndexOf('/');
  19048. if (index >= 0) {
  19049. parsed.path = parsed.path.substring(0, index + 1);
  19050. }
  19051. }
  19052. sourceURL = join(urlGenerate(parsed), sourceURL);
  19053. }
  19054. return normalize(sourceURL);
  19055. }
  19056. exports.computeSourceURL = computeSourceURL;
  19057. } (util$c));
  19058. var arraySet$1 = {};
  19059. /* -*- Mode: js; js-indent-level: 2; -*- */
  19060. /*
  19061. * Copyright 2011 Mozilla Foundation and contributors
  19062. * Licensed under the New BSD license. See LICENSE or:
  19063. * http://opensource.org/licenses/BSD-3-Clause
  19064. */
  19065. var util$b = util$c;
  19066. var has$1 = Object.prototype.hasOwnProperty;
  19067. var hasNativeMap$1 = typeof Map !== "undefined";
  19068. /**
  19069. * A data structure which is a combination of an array and a set. Adding a new
  19070. * member is O(1), testing for membership is O(1), and finding the index of an
  19071. * element is O(1). Removing elements from the set is not supported. Only
  19072. * strings are supported for membership.
  19073. */
  19074. function ArraySet$5() {
  19075. this._array = [];
  19076. this._set = hasNativeMap$1 ? new Map() : Object.create(null);
  19077. }
  19078. /**
  19079. * Static method for creating ArraySet instances from an existing array.
  19080. */
  19081. ArraySet$5.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  19082. var set = new ArraySet$5();
  19083. for (var i = 0, len = aArray.length; i < len; i++) {
  19084. set.add(aArray[i], aAllowDuplicates);
  19085. }
  19086. return set;
  19087. };
  19088. /**
  19089. * Return how many unique items are in this ArraySet. If duplicates have been
  19090. * added, than those do not count towards the size.
  19091. *
  19092. * @returns Number
  19093. */
  19094. ArraySet$5.prototype.size = function ArraySet_size() {
  19095. return hasNativeMap$1 ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  19096. };
  19097. /**
  19098. * Add the given string to this set.
  19099. *
  19100. * @param String aStr
  19101. */
  19102. ArraySet$5.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  19103. var sStr = hasNativeMap$1 ? aStr : util$b.toSetString(aStr);
  19104. var isDuplicate = hasNativeMap$1 ? this.has(aStr) : has$1.call(this._set, sStr);
  19105. var idx = this._array.length;
  19106. if (!isDuplicate || aAllowDuplicates) {
  19107. this._array.push(aStr);
  19108. }
  19109. if (!isDuplicate) {
  19110. if (hasNativeMap$1) {
  19111. this._set.set(aStr, idx);
  19112. } else {
  19113. this._set[sStr] = idx;
  19114. }
  19115. }
  19116. };
  19117. /**
  19118. * Is the given string a member of this set?
  19119. *
  19120. * @param String aStr
  19121. */
  19122. ArraySet$5.prototype.has = function ArraySet_has(aStr) {
  19123. if (hasNativeMap$1) {
  19124. return this._set.has(aStr);
  19125. } else {
  19126. var sStr = util$b.toSetString(aStr);
  19127. return has$1.call(this._set, sStr);
  19128. }
  19129. };
  19130. /**
  19131. * What is the index of the given string in the array?
  19132. *
  19133. * @param String aStr
  19134. */
  19135. ArraySet$5.prototype.indexOf = function ArraySet_indexOf(aStr) {
  19136. if (hasNativeMap$1) {
  19137. var idx = this._set.get(aStr);
  19138. if (idx >= 0) {
  19139. return idx;
  19140. }
  19141. } else {
  19142. var sStr = util$b.toSetString(aStr);
  19143. if (has$1.call(this._set, sStr)) {
  19144. return this._set[sStr];
  19145. }
  19146. }
  19147. throw new Error('"' + aStr + '" is not in the set.');
  19148. };
  19149. /**
  19150. * What is the element at the given index?
  19151. *
  19152. * @param Number aIdx
  19153. */
  19154. ArraySet$5.prototype.at = function ArraySet_at(aIdx) {
  19155. if (aIdx >= 0 && aIdx < this._array.length) {
  19156. return this._array[aIdx];
  19157. }
  19158. throw new Error('No element indexed by ' + aIdx);
  19159. };
  19160. /**
  19161. * Returns the array representation of this set (which has the proper indices
  19162. * indicated by indexOf). Note that this is a copy of the internal array used
  19163. * for storing the members so that no one can mess with internal state.
  19164. */
  19165. ArraySet$5.prototype.toArray = function ArraySet_toArray() {
  19166. return this._array.slice();
  19167. };
  19168. arraySet$1.ArraySet = ArraySet$5;
  19169. var mappingList$1 = {};
  19170. /* -*- Mode: js; js-indent-level: 2; -*- */
  19171. /*
  19172. * Copyright 2014 Mozilla Foundation and contributors
  19173. * Licensed under the New BSD license. See LICENSE or:
  19174. * http://opensource.org/licenses/BSD-3-Clause
  19175. */
  19176. var util$a = util$c;
  19177. /**
  19178. * Determine whether mappingB is after mappingA with respect to generated
  19179. * position.
  19180. */
  19181. function generatedPositionAfter$1(mappingA, mappingB) {
  19182. // Optimized for most common case
  19183. var lineA = mappingA.generatedLine;
  19184. var lineB = mappingB.generatedLine;
  19185. var columnA = mappingA.generatedColumn;
  19186. var columnB = mappingB.generatedColumn;
  19187. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  19188. util$a.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  19189. }
  19190. /**
  19191. * A data structure to provide a sorted view of accumulated mappings in a
  19192. * performance conscious manner. It trades a neglibable overhead in general
  19193. * case for a large speedup in case of mappings being added in order.
  19194. */
  19195. function MappingList$3() {
  19196. this._array = [];
  19197. this._sorted = true;
  19198. // Serves as infimum
  19199. this._last = {generatedLine: -1, generatedColumn: 0};
  19200. }
  19201. /**
  19202. * Iterate through internal items. This method takes the same arguments that
  19203. * `Array.prototype.forEach` takes.
  19204. *
  19205. * NOTE: The order of the mappings is NOT guaranteed.
  19206. */
  19207. MappingList$3.prototype.unsortedForEach =
  19208. function MappingList_forEach(aCallback, aThisArg) {
  19209. this._array.forEach(aCallback, aThisArg);
  19210. };
  19211. /**
  19212. * Add the given source mapping.
  19213. *
  19214. * @param Object aMapping
  19215. */
  19216. MappingList$3.prototype.add = function MappingList_add(aMapping) {
  19217. if (generatedPositionAfter$1(this._last, aMapping)) {
  19218. this._last = aMapping;
  19219. this._array.push(aMapping);
  19220. } else {
  19221. this._sorted = false;
  19222. this._array.push(aMapping);
  19223. }
  19224. };
  19225. /**
  19226. * Returns the flat, sorted array of mappings. The mappings are sorted by
  19227. * generated position.
  19228. *
  19229. * WARNING: This method returns internal data without copying, for
  19230. * performance. The return value must NOT be mutated, and should be treated as
  19231. * an immutable borrow. If you want to take ownership, you must make your own
  19232. * copy.
  19233. */
  19234. MappingList$3.prototype.toArray = function MappingList_toArray() {
  19235. if (!this._sorted) {
  19236. this._array.sort(util$a.compareByGeneratedPositionsInflated);
  19237. this._sorted = true;
  19238. }
  19239. return this._array;
  19240. };
  19241. mappingList$1.MappingList = MappingList$3;
  19242. /* -*- Mode: js; js-indent-level: 2; -*- */
  19243. /*
  19244. * Copyright 2011 Mozilla Foundation and contributors
  19245. * Licensed under the New BSD license. See LICENSE or:
  19246. * http://opensource.org/licenses/BSD-3-Clause
  19247. */
  19248. var base64VLQ$3 = base64Vlq$1;
  19249. var util$9 = util$c;
  19250. var ArraySet$4 = arraySet$1.ArraySet;
  19251. var MappingList$2 = mappingList$1.MappingList;
  19252. /**
  19253. * An instance of the SourceMapGenerator represents a source map which is
  19254. * being built incrementally. You may pass an object with the following
  19255. * properties:
  19256. *
  19257. * - file: The filename of the generated source.
  19258. * - sourceRoot: A root for all relative URLs in this source map.
  19259. */
  19260. function SourceMapGenerator$8(aArgs) {
  19261. if (!aArgs) {
  19262. aArgs = {};
  19263. }
  19264. this._file = util$9.getArg(aArgs, 'file', null);
  19265. this._sourceRoot = util$9.getArg(aArgs, 'sourceRoot', null);
  19266. this._skipValidation = util$9.getArg(aArgs, 'skipValidation', false);
  19267. this._ignoreInvalidMapping = util$9.getArg(aArgs, 'ignoreInvalidMapping', false);
  19268. this._sources = new ArraySet$4();
  19269. this._names = new ArraySet$4();
  19270. this._mappings = new MappingList$2();
  19271. this._sourcesContents = null;
  19272. }
  19273. SourceMapGenerator$8.prototype._version = 3;
  19274. /**
  19275. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  19276. *
  19277. * @param aSourceMapConsumer The SourceMap.
  19278. */
  19279. SourceMapGenerator$8.fromSourceMap =
  19280. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
  19281. var sourceRoot = aSourceMapConsumer.sourceRoot;
  19282. var generator = new SourceMapGenerator$8(Object.assign(generatorOps || {}, {
  19283. file: aSourceMapConsumer.file,
  19284. sourceRoot: sourceRoot
  19285. }));
  19286. aSourceMapConsumer.eachMapping(function (mapping) {
  19287. var newMapping = {
  19288. generated: {
  19289. line: mapping.generatedLine,
  19290. column: mapping.generatedColumn
  19291. }
  19292. };
  19293. if (mapping.source != null) {
  19294. newMapping.source = mapping.source;
  19295. if (sourceRoot != null) {
  19296. newMapping.source = util$9.relative(sourceRoot, newMapping.source);
  19297. }
  19298. newMapping.original = {
  19299. line: mapping.originalLine,
  19300. column: mapping.originalColumn
  19301. };
  19302. if (mapping.name != null) {
  19303. newMapping.name = mapping.name;
  19304. }
  19305. }
  19306. generator.addMapping(newMapping);
  19307. });
  19308. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19309. var sourceRelative = sourceFile;
  19310. if (sourceRoot !== null) {
  19311. sourceRelative = util$9.relative(sourceRoot, sourceFile);
  19312. }
  19313. if (!generator._sources.has(sourceRelative)) {
  19314. generator._sources.add(sourceRelative);
  19315. }
  19316. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19317. if (content != null) {
  19318. generator.setSourceContent(sourceFile, content);
  19319. }
  19320. });
  19321. return generator;
  19322. };
  19323. /**
  19324. * Add a single mapping from original source line and column to the generated
  19325. * source's line and column for this source map being created. The mapping
  19326. * object should have the following properties:
  19327. *
  19328. * - generated: An object with the generated line and column positions.
  19329. * - original: An object with the original line and column positions.
  19330. * - source: The original source file (relative to the sourceRoot).
  19331. * - name: An optional original token name for this mapping.
  19332. */
  19333. SourceMapGenerator$8.prototype.addMapping =
  19334. function SourceMapGenerator_addMapping(aArgs) {
  19335. var generated = util$9.getArg(aArgs, 'generated');
  19336. var original = util$9.getArg(aArgs, 'original', null);
  19337. var source = util$9.getArg(aArgs, 'source', null);
  19338. var name = util$9.getArg(aArgs, 'name', null);
  19339. if (!this._skipValidation) {
  19340. if (this._validateMapping(generated, original, source, name) === false) {
  19341. return;
  19342. }
  19343. }
  19344. if (source != null) {
  19345. source = String(source);
  19346. if (!this._sources.has(source)) {
  19347. this._sources.add(source);
  19348. }
  19349. }
  19350. if (name != null) {
  19351. name = String(name);
  19352. if (!this._names.has(name)) {
  19353. this._names.add(name);
  19354. }
  19355. }
  19356. this._mappings.add({
  19357. generatedLine: generated.line,
  19358. generatedColumn: generated.column,
  19359. originalLine: original != null && original.line,
  19360. originalColumn: original != null && original.column,
  19361. source: source,
  19362. name: name
  19363. });
  19364. };
  19365. /**
  19366. * Set the source content for a source file.
  19367. */
  19368. SourceMapGenerator$8.prototype.setSourceContent =
  19369. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  19370. var source = aSourceFile;
  19371. if (this._sourceRoot != null) {
  19372. source = util$9.relative(this._sourceRoot, source);
  19373. }
  19374. if (aSourceContent != null) {
  19375. // Add the source content to the _sourcesContents map.
  19376. // Create a new _sourcesContents map if the property is null.
  19377. if (!this._sourcesContents) {
  19378. this._sourcesContents = Object.create(null);
  19379. }
  19380. this._sourcesContents[util$9.toSetString(source)] = aSourceContent;
  19381. } else if (this._sourcesContents) {
  19382. // Remove the source file from the _sourcesContents map.
  19383. // If the _sourcesContents map is empty, set the property to null.
  19384. delete this._sourcesContents[util$9.toSetString(source)];
  19385. if (Object.keys(this._sourcesContents).length === 0) {
  19386. this._sourcesContents = null;
  19387. }
  19388. }
  19389. };
  19390. /**
  19391. * Applies the mappings of a sub-source-map for a specific source file to the
  19392. * source map being generated. Each mapping to the supplied source file is
  19393. * rewritten using the supplied source map. Note: The resolution for the
  19394. * resulting mappings is the minimium of this map and the supplied map.
  19395. *
  19396. * @param aSourceMapConsumer The source map to be applied.
  19397. * @param aSourceFile Optional. The filename of the source file.
  19398. * If omitted, SourceMapConsumer's file property will be used.
  19399. * @param aSourceMapPath Optional. The dirname of the path to the source map
  19400. * to be applied. If relative, it is relative to the SourceMapConsumer.
  19401. * This parameter is needed when the two source maps aren't in the same
  19402. * directory, and the source map to be applied contains relative source
  19403. * paths. If so, those relative source paths need to be rewritten
  19404. * relative to the SourceMapGenerator.
  19405. */
  19406. SourceMapGenerator$8.prototype.applySourceMap =
  19407. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  19408. var sourceFile = aSourceFile;
  19409. // If aSourceFile is omitted, we will use the file property of the SourceMap
  19410. if (aSourceFile == null) {
  19411. if (aSourceMapConsumer.file == null) {
  19412. throw new Error(
  19413. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  19414. 'or the source map\'s "file" property. Both were omitted.'
  19415. );
  19416. }
  19417. sourceFile = aSourceMapConsumer.file;
  19418. }
  19419. var sourceRoot = this._sourceRoot;
  19420. // Make "sourceFile" relative if an absolute Url is passed.
  19421. if (sourceRoot != null) {
  19422. sourceFile = util$9.relative(sourceRoot, sourceFile);
  19423. }
  19424. // Applying the SourceMap can add and remove items from the sources and
  19425. // the names array.
  19426. var newSources = new ArraySet$4();
  19427. var newNames = new ArraySet$4();
  19428. // Find mappings for the "sourceFile"
  19429. this._mappings.unsortedForEach(function (mapping) {
  19430. if (mapping.source === sourceFile && mapping.originalLine != null) {
  19431. // Check if it can be mapped by the source map, then update the mapping.
  19432. var original = aSourceMapConsumer.originalPositionFor({
  19433. line: mapping.originalLine,
  19434. column: mapping.originalColumn
  19435. });
  19436. if (original.source != null) {
  19437. // Copy mapping
  19438. mapping.source = original.source;
  19439. if (aSourceMapPath != null) {
  19440. mapping.source = util$9.join(aSourceMapPath, mapping.source);
  19441. }
  19442. if (sourceRoot != null) {
  19443. mapping.source = util$9.relative(sourceRoot, mapping.source);
  19444. }
  19445. mapping.originalLine = original.line;
  19446. mapping.originalColumn = original.column;
  19447. if (original.name != null) {
  19448. mapping.name = original.name;
  19449. }
  19450. }
  19451. }
  19452. var source = mapping.source;
  19453. if (source != null && !newSources.has(source)) {
  19454. newSources.add(source);
  19455. }
  19456. var name = mapping.name;
  19457. if (name != null && !newNames.has(name)) {
  19458. newNames.add(name);
  19459. }
  19460. }, this);
  19461. this._sources = newSources;
  19462. this._names = newNames;
  19463. // Copy sourcesContents of applied map.
  19464. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  19465. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  19466. if (content != null) {
  19467. if (aSourceMapPath != null) {
  19468. sourceFile = util$9.join(aSourceMapPath, sourceFile);
  19469. }
  19470. if (sourceRoot != null) {
  19471. sourceFile = util$9.relative(sourceRoot, sourceFile);
  19472. }
  19473. this.setSourceContent(sourceFile, content);
  19474. }
  19475. }, this);
  19476. };
  19477. /**
  19478. * A mapping can have one of the three levels of data:
  19479. *
  19480. * 1. Just the generated position.
  19481. * 2. The Generated position, original position, and original source.
  19482. * 3. Generated and original position, original source, as well as a name
  19483. * token.
  19484. *
  19485. * To maintain consistency, we validate that any new mapping being added falls
  19486. * in to one of these categories.
  19487. */
  19488. SourceMapGenerator$8.prototype._validateMapping =
  19489. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  19490. aName) {
  19491. // When aOriginal is truthy but has empty values for .line and .column,
  19492. // it is most likely a programmer error. In this case we throw a very
  19493. // specific error message to try to guide them the right way.
  19494. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  19495. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  19496. var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
  19497. 'the original mapping entirely and only map the generated position. If so, pass ' +
  19498. 'null for the original mapping instead of an object with empty or null values.';
  19499. if (this._ignoreInvalidMapping) {
  19500. if (typeof console !== 'undefined' && console.warn) {
  19501. console.warn(message);
  19502. }
  19503. return false;
  19504. } else {
  19505. throw new Error(message);
  19506. }
  19507. }
  19508. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19509. && aGenerated.line > 0 && aGenerated.column >= 0
  19510. && !aOriginal && !aSource && !aName) {
  19511. // Case 1.
  19512. return;
  19513. }
  19514. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  19515. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  19516. && aGenerated.line > 0 && aGenerated.column >= 0
  19517. && aOriginal.line > 0 && aOriginal.column >= 0
  19518. && aSource) {
  19519. // Cases 2 and 3.
  19520. return;
  19521. }
  19522. else {
  19523. var message = 'Invalid mapping: ' + JSON.stringify({
  19524. generated: aGenerated,
  19525. source: aSource,
  19526. original: aOriginal,
  19527. name: aName
  19528. });
  19529. if (this._ignoreInvalidMapping) {
  19530. if (typeof console !== 'undefined' && console.warn) {
  19531. console.warn(message);
  19532. }
  19533. return false;
  19534. } else {
  19535. throw new Error(message)
  19536. }
  19537. }
  19538. };
  19539. /**
  19540. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  19541. * specified by the source map format.
  19542. */
  19543. SourceMapGenerator$8.prototype._serializeMappings =
  19544. function SourceMapGenerator_serializeMappings() {
  19545. var previousGeneratedColumn = 0;
  19546. var previousGeneratedLine = 1;
  19547. var previousOriginalColumn = 0;
  19548. var previousOriginalLine = 0;
  19549. var previousName = 0;
  19550. var previousSource = 0;
  19551. var result = '';
  19552. var next;
  19553. var mapping;
  19554. var nameIdx;
  19555. var sourceIdx;
  19556. var mappings = this._mappings.toArray();
  19557. for (var i = 0, len = mappings.length; i < len; i++) {
  19558. mapping = mappings[i];
  19559. next = '';
  19560. if (mapping.generatedLine !== previousGeneratedLine) {
  19561. previousGeneratedColumn = 0;
  19562. while (mapping.generatedLine !== previousGeneratedLine) {
  19563. next += ';';
  19564. previousGeneratedLine++;
  19565. }
  19566. }
  19567. else {
  19568. if (i > 0) {
  19569. if (!util$9.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  19570. continue;
  19571. }
  19572. next += ',';
  19573. }
  19574. }
  19575. next += base64VLQ$3.encode(mapping.generatedColumn
  19576. - previousGeneratedColumn);
  19577. previousGeneratedColumn = mapping.generatedColumn;
  19578. if (mapping.source != null) {
  19579. sourceIdx = this._sources.indexOf(mapping.source);
  19580. next += base64VLQ$3.encode(sourceIdx - previousSource);
  19581. previousSource = sourceIdx;
  19582. // lines are stored 0-based in SourceMap spec version 3
  19583. next += base64VLQ$3.encode(mapping.originalLine - 1
  19584. - previousOriginalLine);
  19585. previousOriginalLine = mapping.originalLine - 1;
  19586. next += base64VLQ$3.encode(mapping.originalColumn
  19587. - previousOriginalColumn);
  19588. previousOriginalColumn = mapping.originalColumn;
  19589. if (mapping.name != null) {
  19590. nameIdx = this._names.indexOf(mapping.name);
  19591. next += base64VLQ$3.encode(nameIdx - previousName);
  19592. previousName = nameIdx;
  19593. }
  19594. }
  19595. result += next;
  19596. }
  19597. return result;
  19598. };
  19599. SourceMapGenerator$8.prototype._generateSourcesContent =
  19600. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  19601. return aSources.map(function (source) {
  19602. if (!this._sourcesContents) {
  19603. return null;
  19604. }
  19605. if (aSourceRoot != null) {
  19606. source = util$9.relative(aSourceRoot, source);
  19607. }
  19608. var key = util$9.toSetString(source);
  19609. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  19610. ? this._sourcesContents[key]
  19611. : null;
  19612. }, this);
  19613. };
  19614. /**
  19615. * Externalize the source map.
  19616. */
  19617. SourceMapGenerator$8.prototype.toJSON =
  19618. function SourceMapGenerator_toJSON() {
  19619. var map = {
  19620. version: this._version,
  19621. sources: this._sources.toArray(),
  19622. names: this._names.toArray(),
  19623. mappings: this._serializeMappings()
  19624. };
  19625. if (this._file != null) {
  19626. map.file = this._file;
  19627. }
  19628. if (this._sourceRoot != null) {
  19629. map.sourceRoot = this._sourceRoot;
  19630. }
  19631. if (this._sourcesContents) {
  19632. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  19633. }
  19634. return map;
  19635. };
  19636. /**
  19637. * Render the source map being generated to a string.
  19638. */
  19639. SourceMapGenerator$8.prototype.toString =
  19640. function SourceMapGenerator_toString() {
  19641. return JSON.stringify(this.toJSON());
  19642. };
  19643. sourceMapGenerator$1.SourceMapGenerator = SourceMapGenerator$8;
  19644. var sourceMapConsumer$1 = {};
  19645. var binarySearch$3 = {};
  19646. /* -*- Mode: js; js-indent-level: 2; -*- */
  19647. (function (exports) {
  19648. /*
  19649. * Copyright 2011 Mozilla Foundation and contributors
  19650. * Licensed under the New BSD license. See LICENSE or:
  19651. * http://opensource.org/licenses/BSD-3-Clause
  19652. */
  19653. exports.GREATEST_LOWER_BOUND = 1;
  19654. exports.LEAST_UPPER_BOUND = 2;
  19655. /**
  19656. * Recursive implementation of binary search.
  19657. *
  19658. * @param aLow Indices here and lower do not contain the needle.
  19659. * @param aHigh Indices here and higher do not contain the needle.
  19660. * @param aNeedle The element being searched for.
  19661. * @param aHaystack The non-empty array being searched.
  19662. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  19663. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19664. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19665. * closest element that is smaller than or greater than the one we are
  19666. * searching for, respectively, if the exact element cannot be found.
  19667. */
  19668. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  19669. // This function terminates when one of the following is true:
  19670. //
  19671. // 1. We find the exact element we are looking for.
  19672. //
  19673. // 2. We did not find the exact element, but we can return the index of
  19674. // the next-closest element.
  19675. //
  19676. // 3. We did not find the exact element, and there is no next-closest
  19677. // element than the one we are searching for, so we return -1.
  19678. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  19679. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  19680. if (cmp === 0) {
  19681. // Found the element we are looking for.
  19682. return mid;
  19683. }
  19684. else if (cmp > 0) {
  19685. // Our needle is greater than aHaystack[mid].
  19686. if (aHigh - mid > 1) {
  19687. // The element is in the upper half.
  19688. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  19689. }
  19690. // The exact needle element was not found in this haystack. Determine if
  19691. // we are in termination case (3) or (2) and return the appropriate thing.
  19692. if (aBias == exports.LEAST_UPPER_BOUND) {
  19693. return aHigh < aHaystack.length ? aHigh : -1;
  19694. } else {
  19695. return mid;
  19696. }
  19697. }
  19698. else {
  19699. // Our needle is less than aHaystack[mid].
  19700. if (mid - aLow > 1) {
  19701. // The element is in the lower half.
  19702. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  19703. }
  19704. // we are in termination case (3) or (2) and return the appropriate thing.
  19705. if (aBias == exports.LEAST_UPPER_BOUND) {
  19706. return mid;
  19707. } else {
  19708. return aLow < 0 ? -1 : aLow;
  19709. }
  19710. }
  19711. }
  19712. /**
  19713. * This is an implementation of binary search which will always try and return
  19714. * the index of the closest element if there is no exact hit. This is because
  19715. * mappings between original and generated line/col pairs are single points,
  19716. * and there is an implicit region between each of them, so a miss just means
  19717. * that you aren't on the very start of a region.
  19718. *
  19719. * @param aNeedle The element you are looking for.
  19720. * @param aHaystack The array that is being searched.
  19721. * @param aCompare A function which takes the needle and an element in the
  19722. * array and returns -1, 0, or 1 depending on whether the needle is less
  19723. * than, equal to, or greater than the element, respectively.
  19724. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  19725. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  19726. * closest element that is smaller than or greater than the one we are
  19727. * searching for, respectively, if the exact element cannot be found.
  19728. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  19729. */
  19730. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  19731. if (aHaystack.length === 0) {
  19732. return -1;
  19733. }
  19734. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  19735. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  19736. if (index < 0) {
  19737. return -1;
  19738. }
  19739. // We have found either the exact element, or the next-closest element than
  19740. // the one we are searching for. However, there may be more than one such
  19741. // element. Make sure we always return the smallest of these.
  19742. while (index - 1 >= 0) {
  19743. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  19744. break;
  19745. }
  19746. --index;
  19747. }
  19748. return index;
  19749. };
  19750. } (binarySearch$3));
  19751. var quickSort$3 = {};
  19752. /* -*- Mode: js; js-indent-level: 2; -*- */
  19753. /*
  19754. * Copyright 2011 Mozilla Foundation and contributors
  19755. * Licensed under the New BSD license. See LICENSE or:
  19756. * http://opensource.org/licenses/BSD-3-Clause
  19757. */
  19758. // It turns out that some (most?) JavaScript engines don't self-host
  19759. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  19760. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  19761. // custom comparator function, calling back and forth between the VM's C++ and
  19762. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  19763. // worse generated code for the comparator function than would be optimal. In
  19764. // fact, when sorting with a comparator, these costs outweigh the benefits of
  19765. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  19766. // a ~3500ms mean speed-up in `bench/bench.html`.
  19767. function SortTemplate(comparator) {
  19768. /**
  19769. * Swap the elements indexed by `x` and `y` in the array `ary`.
  19770. *
  19771. * @param {Array} ary
  19772. * The array.
  19773. * @param {Number} x
  19774. * The index of the first item.
  19775. * @param {Number} y
  19776. * The index of the second item.
  19777. */
  19778. function swap(ary, x, y) {
  19779. var temp = ary[x];
  19780. ary[x] = ary[y];
  19781. ary[y] = temp;
  19782. }
  19783. /**
  19784. * Returns a random integer within the range `low .. high` inclusive.
  19785. *
  19786. * @param {Number} low
  19787. * The lower bound on the range.
  19788. * @param {Number} high
  19789. * The upper bound on the range.
  19790. */
  19791. function randomIntInRange(low, high) {
  19792. return Math.round(low + (Math.random() * (high - low)));
  19793. }
  19794. /**
  19795. * The Quick Sort algorithm.
  19796. *
  19797. * @param {Array} ary
  19798. * An array to sort.
  19799. * @param {function} comparator
  19800. * Function to use to compare two items.
  19801. * @param {Number} p
  19802. * Start index of the array
  19803. * @param {Number} r
  19804. * End index of the array
  19805. */
  19806. function doQuickSort(ary, comparator, p, r) {
  19807. // If our lower bound is less than our upper bound, we (1) partition the
  19808. // array into two pieces and (2) recurse on each half. If it is not, this is
  19809. // the empty array and our base case.
  19810. if (p < r) {
  19811. // (1) Partitioning.
  19812. //
  19813. // The partitioning chooses a pivot between `p` and `r` and moves all
  19814. // elements that are less than or equal to the pivot to the before it, and
  19815. // all the elements that are greater than it after it. The effect is that
  19816. // once partition is done, the pivot is in the exact place it will be when
  19817. // the array is put in sorted order, and it will not need to be moved
  19818. // again. This runs in O(n) time.
  19819. // Always choose a random pivot so that an input array which is reverse
  19820. // sorted does not cause O(n^2) running time.
  19821. var pivotIndex = randomIntInRange(p, r);
  19822. var i = p - 1;
  19823. swap(ary, pivotIndex, r);
  19824. var pivot = ary[r];
  19825. // Immediately after `j` is incremented in this loop, the following hold
  19826. // true:
  19827. //
  19828. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  19829. //
  19830. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  19831. for (var j = p; j < r; j++) {
  19832. if (comparator(ary[j], pivot, false) <= 0) {
  19833. i += 1;
  19834. swap(ary, i, j);
  19835. }
  19836. }
  19837. swap(ary, i + 1, j);
  19838. var q = i + 1;
  19839. // (2) Recurse on each half.
  19840. doQuickSort(ary, comparator, p, q - 1);
  19841. doQuickSort(ary, comparator, q + 1, r);
  19842. }
  19843. }
  19844. return doQuickSort;
  19845. }
  19846. function cloneSort(comparator) {
  19847. let template = SortTemplate.toString();
  19848. let templateFn = new Function(`return ${template}`)();
  19849. return templateFn(comparator);
  19850. }
  19851. /**
  19852. * Sort the given array in-place with the given comparator function.
  19853. *
  19854. * @param {Array} ary
  19855. * An array to sort.
  19856. * @param {function} comparator
  19857. * Function to use to compare two items.
  19858. */
  19859. let sortCache = new WeakMap();
  19860. quickSort$3.quickSort = function (ary, comparator, start = 0) {
  19861. let doQuickSort = sortCache.get(comparator);
  19862. if (doQuickSort === void 0) {
  19863. doQuickSort = cloneSort(comparator);
  19864. sortCache.set(comparator, doQuickSort);
  19865. }
  19866. doQuickSort(ary, comparator, start, ary.length - 1);
  19867. };
  19868. /* -*- Mode: js; js-indent-level: 2; -*- */
  19869. /*
  19870. * Copyright 2011 Mozilla Foundation and contributors
  19871. * Licensed under the New BSD license. See LICENSE or:
  19872. * http://opensource.org/licenses/BSD-3-Clause
  19873. */
  19874. var util$8 = util$c;
  19875. var binarySearch$2 = binarySearch$3;
  19876. var ArraySet$3 = arraySet$1.ArraySet;
  19877. var base64VLQ$2 = base64Vlq$1;
  19878. var quickSort$2 = quickSort$3.quickSort;
  19879. function SourceMapConsumer$6(aSourceMap, aSourceMapURL) {
  19880. var sourceMap = aSourceMap;
  19881. if (typeof aSourceMap === 'string') {
  19882. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  19883. }
  19884. return sourceMap.sections != null
  19885. ? new IndexedSourceMapConsumer$1(sourceMap, aSourceMapURL)
  19886. : new BasicSourceMapConsumer$1(sourceMap, aSourceMapURL);
  19887. }
  19888. SourceMapConsumer$6.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  19889. return BasicSourceMapConsumer$1.fromSourceMap(aSourceMap, aSourceMapURL);
  19890. };
  19891. /**
  19892. * The version of the source mapping spec that we are consuming.
  19893. */
  19894. SourceMapConsumer$6.prototype._version = 3;
  19895. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  19896. // parsed mapping coordinates from the source map's "mappings" attribute. They
  19897. // are lazily instantiated, accessed via the `_generatedMappings` and
  19898. // `_originalMappings` getters respectively, and we only parse the mappings
  19899. // and create these arrays once queried for a source location. We jump through
  19900. // these hoops because there can be many thousands of mappings, and parsing
  19901. // them is expensive, so we only want to do it if we must.
  19902. //
  19903. // Each object in the arrays is of the form:
  19904. //
  19905. // {
  19906. // generatedLine: The line number in the generated code,
  19907. // generatedColumn: The column number in the generated code,
  19908. // source: The path to the original source file that generated this
  19909. // chunk of code,
  19910. // originalLine: The line number in the original source that
  19911. // corresponds to this chunk of generated code,
  19912. // originalColumn: The column number in the original source that
  19913. // corresponds to this chunk of generated code,
  19914. // name: The name of the original symbol which generated this chunk of
  19915. // code.
  19916. // }
  19917. //
  19918. // All properties except for `generatedLine` and `generatedColumn` can be
  19919. // `null`.
  19920. //
  19921. // `_generatedMappings` is ordered by the generated positions.
  19922. //
  19923. // `_originalMappings` is ordered by the original positions.
  19924. SourceMapConsumer$6.prototype.__generatedMappings = null;
  19925. Object.defineProperty(SourceMapConsumer$6.prototype, '_generatedMappings', {
  19926. configurable: true,
  19927. enumerable: true,
  19928. get: function () {
  19929. if (!this.__generatedMappings) {
  19930. this._parseMappings(this._mappings, this.sourceRoot);
  19931. }
  19932. return this.__generatedMappings;
  19933. }
  19934. });
  19935. SourceMapConsumer$6.prototype.__originalMappings = null;
  19936. Object.defineProperty(SourceMapConsumer$6.prototype, '_originalMappings', {
  19937. configurable: true,
  19938. enumerable: true,
  19939. get: function () {
  19940. if (!this.__originalMappings) {
  19941. this._parseMappings(this._mappings, this.sourceRoot);
  19942. }
  19943. return this.__originalMappings;
  19944. }
  19945. });
  19946. SourceMapConsumer$6.prototype._charIsMappingSeparator =
  19947. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  19948. var c = aStr.charAt(index);
  19949. return c === ";" || c === ",";
  19950. };
  19951. /**
  19952. * Parse the mappings in a string in to a data structure which we can easily
  19953. * query (the ordered arrays in the `this.__generatedMappings` and
  19954. * `this.__originalMappings` properties).
  19955. */
  19956. SourceMapConsumer$6.prototype._parseMappings =
  19957. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  19958. throw new Error("Subclasses must implement _parseMappings");
  19959. };
  19960. SourceMapConsumer$6.GENERATED_ORDER = 1;
  19961. SourceMapConsumer$6.ORIGINAL_ORDER = 2;
  19962. SourceMapConsumer$6.GREATEST_LOWER_BOUND = 1;
  19963. SourceMapConsumer$6.LEAST_UPPER_BOUND = 2;
  19964. /**
  19965. * Iterate over each mapping between an original source/line/column and a
  19966. * generated line/column in this source map.
  19967. *
  19968. * @param Function aCallback
  19969. * The function that is called with each mapping.
  19970. * @param Object aContext
  19971. * Optional. If specified, this object will be the value of `this` every
  19972. * time that `aCallback` is called.
  19973. * @param aOrder
  19974. * Either `SourceMapConsumer.GENERATED_ORDER` or
  19975. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  19976. * iterate over the mappings sorted by the generated file's line/column
  19977. * order or the original's source/line/column order, respectively. Defaults to
  19978. * `SourceMapConsumer.GENERATED_ORDER`.
  19979. */
  19980. SourceMapConsumer$6.prototype.eachMapping =
  19981. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  19982. var context = aContext || null;
  19983. var order = aOrder || SourceMapConsumer$6.GENERATED_ORDER;
  19984. var mappings;
  19985. switch (order) {
  19986. case SourceMapConsumer$6.GENERATED_ORDER:
  19987. mappings = this._generatedMappings;
  19988. break;
  19989. case SourceMapConsumer$6.ORIGINAL_ORDER:
  19990. mappings = this._originalMappings;
  19991. break;
  19992. default:
  19993. throw new Error("Unknown order of iteration.");
  19994. }
  19995. var sourceRoot = this.sourceRoot;
  19996. var boundCallback = aCallback.bind(context);
  19997. var names = this._names;
  19998. var sources = this._sources;
  19999. var sourceMapURL = this._sourceMapURL;
  20000. for (var i = 0, n = mappings.length; i < n; i++) {
  20001. var mapping = mappings[i];
  20002. var source = mapping.source === null ? null : sources.at(mapping.source);
  20003. source = util$8.computeSourceURL(sourceRoot, source, sourceMapURL);
  20004. boundCallback({
  20005. source: source,
  20006. generatedLine: mapping.generatedLine,
  20007. generatedColumn: mapping.generatedColumn,
  20008. originalLine: mapping.originalLine,
  20009. originalColumn: mapping.originalColumn,
  20010. name: mapping.name === null ? null : names.at(mapping.name)
  20011. });
  20012. }
  20013. };
  20014. /**
  20015. * Returns all generated line and column information for the original source,
  20016. * line, and column provided. If no column is provided, returns all mappings
  20017. * corresponding to a either the line we are searching for or the next
  20018. * closest line that has any mappings. Otherwise, returns all mappings
  20019. * corresponding to the given line and either the column we are searching for
  20020. * or the next closest column that has any offsets.
  20021. *
  20022. * The only argument is an object with the following properties:
  20023. *
  20024. * - source: The filename of the original source.
  20025. * - line: The line number in the original source. The line number is 1-based.
  20026. * - column: Optional. the column number in the original source.
  20027. * The column number is 0-based.
  20028. *
  20029. * and an array of objects is returned, each with the following properties:
  20030. *
  20031. * - line: The line number in the generated source, or null. The
  20032. * line number is 1-based.
  20033. * - column: The column number in the generated source, or null.
  20034. * The column number is 0-based.
  20035. */
  20036. SourceMapConsumer$6.prototype.allGeneratedPositionsFor =
  20037. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  20038. var line = util$8.getArg(aArgs, 'line');
  20039. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  20040. // returns the index of the closest mapping less than the needle. By
  20041. // setting needle.originalColumn to 0, we thus find the last mapping for
  20042. // the given line, provided such a mapping exists.
  20043. var needle = {
  20044. source: util$8.getArg(aArgs, 'source'),
  20045. originalLine: line,
  20046. originalColumn: util$8.getArg(aArgs, 'column', 0)
  20047. };
  20048. needle.source = this._findSourceIndex(needle.source);
  20049. if (needle.source < 0) {
  20050. return [];
  20051. }
  20052. var mappings = [];
  20053. var index = this._findMapping(needle,
  20054. this._originalMappings,
  20055. "originalLine",
  20056. "originalColumn",
  20057. util$8.compareByOriginalPositions,
  20058. binarySearch$2.LEAST_UPPER_BOUND);
  20059. if (index >= 0) {
  20060. var mapping = this._originalMappings[index];
  20061. if (aArgs.column === undefined) {
  20062. var originalLine = mapping.originalLine;
  20063. // Iterate until either we run out of mappings, or we run into
  20064. // a mapping for a different line than the one we found. Since
  20065. // mappings are sorted, this is guaranteed to find all mappings for
  20066. // the line we found.
  20067. while (mapping && mapping.originalLine === originalLine) {
  20068. mappings.push({
  20069. line: util$8.getArg(mapping, 'generatedLine', null),
  20070. column: util$8.getArg(mapping, 'generatedColumn', null),
  20071. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20072. });
  20073. mapping = this._originalMappings[++index];
  20074. }
  20075. } else {
  20076. var originalColumn = mapping.originalColumn;
  20077. // Iterate until either we run out of mappings, or we run into
  20078. // a mapping for a different line than the one we were searching for.
  20079. // Since mappings are sorted, this is guaranteed to find all mappings for
  20080. // the line we are searching for.
  20081. while (mapping &&
  20082. mapping.originalLine === line &&
  20083. mapping.originalColumn == originalColumn) {
  20084. mappings.push({
  20085. line: util$8.getArg(mapping, 'generatedLine', null),
  20086. column: util$8.getArg(mapping, 'generatedColumn', null),
  20087. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20088. });
  20089. mapping = this._originalMappings[++index];
  20090. }
  20091. }
  20092. }
  20093. return mappings;
  20094. };
  20095. sourceMapConsumer$1.SourceMapConsumer = SourceMapConsumer$6;
  20096. /**
  20097. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  20098. * query for information about the original file positions by giving it a file
  20099. * position in the generated source.
  20100. *
  20101. * The first parameter is the raw source map (either as a JSON string, or
  20102. * already parsed to an object). According to the spec, source maps have the
  20103. * following attributes:
  20104. *
  20105. * - version: Which version of the source map spec this map is following.
  20106. * - sources: An array of URLs to the original source files.
  20107. * - names: An array of identifiers which can be referrenced by individual mappings.
  20108. * - sourceRoot: Optional. The URL root from which all sources are relative.
  20109. * - sourcesContent: Optional. An array of contents of the original source files.
  20110. * - mappings: A string of base64 VLQs which contain the actual mappings.
  20111. * - file: Optional. The generated file this source map is associated with.
  20112. *
  20113. * Here is an example source map, taken from the source map spec[0]:
  20114. *
  20115. * {
  20116. * version : 3,
  20117. * file: "out.js",
  20118. * sourceRoot : "",
  20119. * sources: ["foo.js", "bar.js"],
  20120. * names: ["src", "maps", "are", "fun"],
  20121. * mappings: "AA,AB;;ABCDE;"
  20122. * }
  20123. *
  20124. * The second parameter, if given, is a string whose value is the URL
  20125. * at which the source map was found. This URL is used to compute the
  20126. * sources array.
  20127. *
  20128. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  20129. */
  20130. function BasicSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  20131. var sourceMap = aSourceMap;
  20132. if (typeof aSourceMap === 'string') {
  20133. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  20134. }
  20135. var version = util$8.getArg(sourceMap, 'version');
  20136. var sources = util$8.getArg(sourceMap, 'sources');
  20137. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  20138. // requires the array) to play nice here.
  20139. var names = util$8.getArg(sourceMap, 'names', []);
  20140. var sourceRoot = util$8.getArg(sourceMap, 'sourceRoot', null);
  20141. var sourcesContent = util$8.getArg(sourceMap, 'sourcesContent', null);
  20142. var mappings = util$8.getArg(sourceMap, 'mappings');
  20143. var file = util$8.getArg(sourceMap, 'file', null);
  20144. // Once again, Sass deviates from the spec and supplies the version as a
  20145. // string rather than a number, so we use loose equality checking here.
  20146. if (version != this._version) {
  20147. throw new Error('Unsupported version: ' + version);
  20148. }
  20149. if (sourceRoot) {
  20150. sourceRoot = util$8.normalize(sourceRoot);
  20151. }
  20152. sources = sources
  20153. .map(String)
  20154. // Some source maps produce relative source paths like "./foo.js" instead of
  20155. // "foo.js". Normalize these first so that future comparisons will succeed.
  20156. // See bugzil.la/1090768.
  20157. .map(util$8.normalize)
  20158. // Always ensure that absolute sources are internally stored relative to
  20159. // the source root, if the source root is absolute. Not doing this would
  20160. // be particularly problematic when the source root is a prefix of the
  20161. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  20162. .map(function (source) {
  20163. return sourceRoot && util$8.isAbsolute(sourceRoot) && util$8.isAbsolute(source)
  20164. ? util$8.relative(sourceRoot, source)
  20165. : source;
  20166. });
  20167. // Pass `true` below to allow duplicate names and sources. While source maps
  20168. // are intended to be compressed and deduplicated, the TypeScript compiler
  20169. // sometimes generates source maps with duplicates in them. See Github issue
  20170. // #72 and bugzil.la/889492.
  20171. this._names = ArraySet$3.fromArray(names.map(String), true);
  20172. this._sources = ArraySet$3.fromArray(sources, true);
  20173. this._absoluteSources = this._sources.toArray().map(function (s) {
  20174. return util$8.computeSourceURL(sourceRoot, s, aSourceMapURL);
  20175. });
  20176. this.sourceRoot = sourceRoot;
  20177. this.sourcesContent = sourcesContent;
  20178. this._mappings = mappings;
  20179. this._sourceMapURL = aSourceMapURL;
  20180. this.file = file;
  20181. }
  20182. BasicSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$6.prototype);
  20183. BasicSourceMapConsumer$1.prototype.consumer = SourceMapConsumer$6;
  20184. /**
  20185. * Utility function to find the index of a source. Returns -1 if not
  20186. * found.
  20187. */
  20188. BasicSourceMapConsumer$1.prototype._findSourceIndex = function(aSource) {
  20189. var relativeSource = aSource;
  20190. if (this.sourceRoot != null) {
  20191. relativeSource = util$8.relative(this.sourceRoot, relativeSource);
  20192. }
  20193. if (this._sources.has(relativeSource)) {
  20194. return this._sources.indexOf(relativeSource);
  20195. }
  20196. // Maybe aSource is an absolute URL as returned by |sources|. In
  20197. // this case we can't simply undo the transform.
  20198. var i;
  20199. for (i = 0; i < this._absoluteSources.length; ++i) {
  20200. if (this._absoluteSources[i] == aSource) {
  20201. return i;
  20202. }
  20203. }
  20204. return -1;
  20205. };
  20206. /**
  20207. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  20208. *
  20209. * @param SourceMapGenerator aSourceMap
  20210. * The source map that will be consumed.
  20211. * @param String aSourceMapURL
  20212. * The URL at which the source map can be found (optional)
  20213. * @returns BasicSourceMapConsumer
  20214. */
  20215. BasicSourceMapConsumer$1.fromSourceMap =
  20216. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  20217. var smc = Object.create(BasicSourceMapConsumer$1.prototype);
  20218. var names = smc._names = ArraySet$3.fromArray(aSourceMap._names.toArray(), true);
  20219. var sources = smc._sources = ArraySet$3.fromArray(aSourceMap._sources.toArray(), true);
  20220. smc.sourceRoot = aSourceMap._sourceRoot;
  20221. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  20222. smc.sourceRoot);
  20223. smc.file = aSourceMap._file;
  20224. smc._sourceMapURL = aSourceMapURL;
  20225. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  20226. return util$8.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  20227. });
  20228. // Because we are modifying the entries (by converting string sources and
  20229. // names to indices into the sources and names ArraySets), we have to make
  20230. // a copy of the entry or else bad things happen. Shared mutable state
  20231. // strikes again! See github issue #191.
  20232. var generatedMappings = aSourceMap._mappings.toArray().slice();
  20233. var destGeneratedMappings = smc.__generatedMappings = [];
  20234. var destOriginalMappings = smc.__originalMappings = [];
  20235. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  20236. var srcMapping = generatedMappings[i];
  20237. var destMapping = new Mapping$1;
  20238. destMapping.generatedLine = srcMapping.generatedLine;
  20239. destMapping.generatedColumn = srcMapping.generatedColumn;
  20240. if (srcMapping.source) {
  20241. destMapping.source = sources.indexOf(srcMapping.source);
  20242. destMapping.originalLine = srcMapping.originalLine;
  20243. destMapping.originalColumn = srcMapping.originalColumn;
  20244. if (srcMapping.name) {
  20245. destMapping.name = names.indexOf(srcMapping.name);
  20246. }
  20247. destOriginalMappings.push(destMapping);
  20248. }
  20249. destGeneratedMappings.push(destMapping);
  20250. }
  20251. quickSort$2(smc.__originalMappings, util$8.compareByOriginalPositions);
  20252. return smc;
  20253. };
  20254. /**
  20255. * The version of the source mapping spec that we are consuming.
  20256. */
  20257. BasicSourceMapConsumer$1.prototype._version = 3;
  20258. /**
  20259. * The list of original sources.
  20260. */
  20261. Object.defineProperty(BasicSourceMapConsumer$1.prototype, 'sources', {
  20262. get: function () {
  20263. return this._absoluteSources.slice();
  20264. }
  20265. });
  20266. /**
  20267. * Provide the JIT with a nice shape / hidden class.
  20268. */
  20269. function Mapping$1() {
  20270. this.generatedLine = 0;
  20271. this.generatedColumn = 0;
  20272. this.source = null;
  20273. this.originalLine = null;
  20274. this.originalColumn = null;
  20275. this.name = null;
  20276. }
  20277. /**
  20278. * Parse the mappings in a string in to a data structure which we can easily
  20279. * query (the ordered arrays in the `this.__generatedMappings` and
  20280. * `this.__originalMappings` properties).
  20281. */
  20282. const compareGenerated = util$8.compareByGeneratedPositionsDeflatedNoLine;
  20283. function sortGenerated(array, start) {
  20284. let l = array.length;
  20285. let n = array.length - start;
  20286. if (n <= 1) {
  20287. return;
  20288. } else if (n == 2) {
  20289. let a = array[start];
  20290. let b = array[start + 1];
  20291. if (compareGenerated(a, b) > 0) {
  20292. array[start] = b;
  20293. array[start + 1] = a;
  20294. }
  20295. } else if (n < 20) {
  20296. for (let i = start; i < l; i++) {
  20297. for (let j = i; j > start; j--) {
  20298. let a = array[j - 1];
  20299. let b = array[j];
  20300. if (compareGenerated(a, b) <= 0) {
  20301. break;
  20302. }
  20303. array[j - 1] = b;
  20304. array[j] = a;
  20305. }
  20306. }
  20307. } else {
  20308. quickSort$2(array, compareGenerated, start);
  20309. }
  20310. }
  20311. BasicSourceMapConsumer$1.prototype._parseMappings =
  20312. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20313. var generatedLine = 1;
  20314. var previousGeneratedColumn = 0;
  20315. var previousOriginalLine = 0;
  20316. var previousOriginalColumn = 0;
  20317. var previousSource = 0;
  20318. var previousName = 0;
  20319. var length = aStr.length;
  20320. var index = 0;
  20321. var temp = {};
  20322. var originalMappings = [];
  20323. var generatedMappings = [];
  20324. var mapping, segment, end, value;
  20325. let subarrayStart = 0;
  20326. while (index < length) {
  20327. if (aStr.charAt(index) === ';') {
  20328. generatedLine++;
  20329. index++;
  20330. previousGeneratedColumn = 0;
  20331. sortGenerated(generatedMappings, subarrayStart);
  20332. subarrayStart = generatedMappings.length;
  20333. }
  20334. else if (aStr.charAt(index) === ',') {
  20335. index++;
  20336. }
  20337. else {
  20338. mapping = new Mapping$1();
  20339. mapping.generatedLine = generatedLine;
  20340. for (end = index; end < length; end++) {
  20341. if (this._charIsMappingSeparator(aStr, end)) {
  20342. break;
  20343. }
  20344. }
  20345. aStr.slice(index, end);
  20346. segment = [];
  20347. while (index < end) {
  20348. base64VLQ$2.decode(aStr, index, temp);
  20349. value = temp.value;
  20350. index = temp.rest;
  20351. segment.push(value);
  20352. }
  20353. if (segment.length === 2) {
  20354. throw new Error('Found a source, but no line and column');
  20355. }
  20356. if (segment.length === 3) {
  20357. throw new Error('Found a source and line, but no column');
  20358. }
  20359. // Generated column.
  20360. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  20361. previousGeneratedColumn = mapping.generatedColumn;
  20362. if (segment.length > 1) {
  20363. // Original source.
  20364. mapping.source = previousSource + segment[1];
  20365. previousSource += segment[1];
  20366. // Original line.
  20367. mapping.originalLine = previousOriginalLine + segment[2];
  20368. previousOriginalLine = mapping.originalLine;
  20369. // Lines are stored 0-based
  20370. mapping.originalLine += 1;
  20371. // Original column.
  20372. mapping.originalColumn = previousOriginalColumn + segment[3];
  20373. previousOriginalColumn = mapping.originalColumn;
  20374. if (segment.length > 4) {
  20375. // Original name.
  20376. mapping.name = previousName + segment[4];
  20377. previousName += segment[4];
  20378. }
  20379. }
  20380. generatedMappings.push(mapping);
  20381. if (typeof mapping.originalLine === 'number') {
  20382. let currentSource = mapping.source;
  20383. while (originalMappings.length <= currentSource) {
  20384. originalMappings.push(null);
  20385. }
  20386. if (originalMappings[currentSource] === null) {
  20387. originalMappings[currentSource] = [];
  20388. }
  20389. originalMappings[currentSource].push(mapping);
  20390. }
  20391. }
  20392. }
  20393. sortGenerated(generatedMappings, subarrayStart);
  20394. this.__generatedMappings = generatedMappings;
  20395. for (var i = 0; i < originalMappings.length; i++) {
  20396. if (originalMappings[i] != null) {
  20397. quickSort$2(originalMappings[i], util$8.compareByOriginalPositionsNoSource);
  20398. }
  20399. }
  20400. this.__originalMappings = [].concat(...originalMappings);
  20401. };
  20402. /**
  20403. * Find the mapping that best matches the hypothetical "needle" mapping that
  20404. * we are searching for in the given "haystack" of mappings.
  20405. */
  20406. BasicSourceMapConsumer$1.prototype._findMapping =
  20407. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  20408. aColumnName, aComparator, aBias) {
  20409. // To return the position we are searching for, we must first find the
  20410. // mapping for the given position and then return the opposite position it
  20411. // points to. Because the mappings are sorted, we can use binary search to
  20412. // find the best mapping.
  20413. if (aNeedle[aLineName] <= 0) {
  20414. throw new TypeError('Line must be greater than or equal to 1, got '
  20415. + aNeedle[aLineName]);
  20416. }
  20417. if (aNeedle[aColumnName] < 0) {
  20418. throw new TypeError('Column must be greater than or equal to 0, got '
  20419. + aNeedle[aColumnName]);
  20420. }
  20421. return binarySearch$2.search(aNeedle, aMappings, aComparator, aBias);
  20422. };
  20423. /**
  20424. * Compute the last column for each generated mapping. The last column is
  20425. * inclusive.
  20426. */
  20427. BasicSourceMapConsumer$1.prototype.computeColumnSpans =
  20428. function SourceMapConsumer_computeColumnSpans() {
  20429. for (var index = 0; index < this._generatedMappings.length; ++index) {
  20430. var mapping = this._generatedMappings[index];
  20431. // Mappings do not contain a field for the last generated columnt. We
  20432. // can come up with an optimistic estimate, however, by assuming that
  20433. // mappings are contiguous (i.e. given two consecutive mappings, the
  20434. // first mapping ends where the second one starts).
  20435. if (index + 1 < this._generatedMappings.length) {
  20436. var nextMapping = this._generatedMappings[index + 1];
  20437. if (mapping.generatedLine === nextMapping.generatedLine) {
  20438. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  20439. continue;
  20440. }
  20441. }
  20442. // The last mapping for each line spans the entire line.
  20443. mapping.lastGeneratedColumn = Infinity;
  20444. }
  20445. };
  20446. /**
  20447. * Returns the original source, line, and column information for the generated
  20448. * source's line and column positions provided. The only argument is an object
  20449. * with the following properties:
  20450. *
  20451. * - line: The line number in the generated source. The line number
  20452. * is 1-based.
  20453. * - column: The column number in the generated source. The column
  20454. * number is 0-based.
  20455. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20456. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20457. * closest element that is smaller than or greater than the one we are
  20458. * searching for, respectively, if the exact element cannot be found.
  20459. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20460. *
  20461. * and an object is returned with the following properties:
  20462. *
  20463. * - source: The original source file, or null.
  20464. * - line: The line number in the original source, or null. The
  20465. * line number is 1-based.
  20466. * - column: The column number in the original source, or null. The
  20467. * column number is 0-based.
  20468. * - name: The original identifier, or null.
  20469. */
  20470. BasicSourceMapConsumer$1.prototype.originalPositionFor =
  20471. function SourceMapConsumer_originalPositionFor(aArgs) {
  20472. var needle = {
  20473. generatedLine: util$8.getArg(aArgs, 'line'),
  20474. generatedColumn: util$8.getArg(aArgs, 'column')
  20475. };
  20476. var index = this._findMapping(
  20477. needle,
  20478. this._generatedMappings,
  20479. "generatedLine",
  20480. "generatedColumn",
  20481. util$8.compareByGeneratedPositionsDeflated,
  20482. util$8.getArg(aArgs, 'bias', SourceMapConsumer$6.GREATEST_LOWER_BOUND)
  20483. );
  20484. if (index >= 0) {
  20485. var mapping = this._generatedMappings[index];
  20486. if (mapping.generatedLine === needle.generatedLine) {
  20487. var source = util$8.getArg(mapping, 'source', null);
  20488. if (source !== null) {
  20489. source = this._sources.at(source);
  20490. source = util$8.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  20491. }
  20492. var name = util$8.getArg(mapping, 'name', null);
  20493. if (name !== null) {
  20494. name = this._names.at(name);
  20495. }
  20496. return {
  20497. source: source,
  20498. line: util$8.getArg(mapping, 'originalLine', null),
  20499. column: util$8.getArg(mapping, 'originalColumn', null),
  20500. name: name
  20501. };
  20502. }
  20503. }
  20504. return {
  20505. source: null,
  20506. line: null,
  20507. column: null,
  20508. name: null
  20509. };
  20510. };
  20511. /**
  20512. * Return true if we have the source content for every source in the source
  20513. * map, false otherwise.
  20514. */
  20515. BasicSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  20516. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  20517. if (!this.sourcesContent) {
  20518. return false;
  20519. }
  20520. return this.sourcesContent.length >= this._sources.size() &&
  20521. !this.sourcesContent.some(function (sc) { return sc == null; });
  20522. };
  20523. /**
  20524. * Returns the original source content. The only argument is the url of the
  20525. * original source file. Returns null if no original source content is
  20526. * available.
  20527. */
  20528. BasicSourceMapConsumer$1.prototype.sourceContentFor =
  20529. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20530. if (!this.sourcesContent) {
  20531. return null;
  20532. }
  20533. var index = this._findSourceIndex(aSource);
  20534. if (index >= 0) {
  20535. return this.sourcesContent[index];
  20536. }
  20537. var relativeSource = aSource;
  20538. if (this.sourceRoot != null) {
  20539. relativeSource = util$8.relative(this.sourceRoot, relativeSource);
  20540. }
  20541. var url;
  20542. if (this.sourceRoot != null
  20543. && (url = util$8.urlParse(this.sourceRoot))) {
  20544. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  20545. // many users. We can help them out when they expect file:// URIs to
  20546. // behave like it would if they were running a local HTTP server. See
  20547. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  20548. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  20549. if (url.scheme == "file"
  20550. && this._sources.has(fileUriAbsPath)) {
  20551. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  20552. }
  20553. if ((!url.path || url.path == "/")
  20554. && this._sources.has("/" + relativeSource)) {
  20555. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  20556. }
  20557. }
  20558. // This function is used recursively from
  20559. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  20560. // don't want to throw if we can't find the source - we just want to
  20561. // return null, so we provide a flag to exit gracefully.
  20562. if (nullOnMissing) {
  20563. return null;
  20564. }
  20565. else {
  20566. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  20567. }
  20568. };
  20569. /**
  20570. * Returns the generated line and column information for the original source,
  20571. * line, and column positions provided. The only argument is an object with
  20572. * the following properties:
  20573. *
  20574. * - source: The filename of the original source.
  20575. * - line: The line number in the original source. The line number
  20576. * is 1-based.
  20577. * - column: The column number in the original source. The column
  20578. * number is 0-based.
  20579. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  20580. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  20581. * closest element that is smaller than or greater than the one we are
  20582. * searching for, respectively, if the exact element cannot be found.
  20583. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  20584. *
  20585. * and an object is returned with the following properties:
  20586. *
  20587. * - line: The line number in the generated source, or null. The
  20588. * line number is 1-based.
  20589. * - column: The column number in the generated source, or null.
  20590. * The column number is 0-based.
  20591. */
  20592. BasicSourceMapConsumer$1.prototype.generatedPositionFor =
  20593. function SourceMapConsumer_generatedPositionFor(aArgs) {
  20594. var source = util$8.getArg(aArgs, 'source');
  20595. source = this._findSourceIndex(source);
  20596. if (source < 0) {
  20597. return {
  20598. line: null,
  20599. column: null,
  20600. lastColumn: null
  20601. };
  20602. }
  20603. var needle = {
  20604. source: source,
  20605. originalLine: util$8.getArg(aArgs, 'line'),
  20606. originalColumn: util$8.getArg(aArgs, 'column')
  20607. };
  20608. var index = this._findMapping(
  20609. needle,
  20610. this._originalMappings,
  20611. "originalLine",
  20612. "originalColumn",
  20613. util$8.compareByOriginalPositions,
  20614. util$8.getArg(aArgs, 'bias', SourceMapConsumer$6.GREATEST_LOWER_BOUND)
  20615. );
  20616. if (index >= 0) {
  20617. var mapping = this._originalMappings[index];
  20618. if (mapping.source === needle.source) {
  20619. return {
  20620. line: util$8.getArg(mapping, 'generatedLine', null),
  20621. column: util$8.getArg(mapping, 'generatedColumn', null),
  20622. lastColumn: util$8.getArg(mapping, 'lastGeneratedColumn', null)
  20623. };
  20624. }
  20625. }
  20626. return {
  20627. line: null,
  20628. column: null,
  20629. lastColumn: null
  20630. };
  20631. };
  20632. sourceMapConsumer$1.BasicSourceMapConsumer = BasicSourceMapConsumer$1;
  20633. /**
  20634. * An IndexedSourceMapConsumer instance represents a parsed source map which
  20635. * we can query for information. It differs from BasicSourceMapConsumer in
  20636. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  20637. * input.
  20638. *
  20639. * The first parameter is a raw source map (either as a JSON string, or already
  20640. * parsed to an object). According to the spec for indexed source maps, they
  20641. * have the following attributes:
  20642. *
  20643. * - version: Which version of the source map spec this map is following.
  20644. * - file: Optional. The generated file this source map is associated with.
  20645. * - sections: A list of section definitions.
  20646. *
  20647. * Each value under the "sections" field has two fields:
  20648. * - offset: The offset into the original specified at which this section
  20649. * begins to apply, defined as an object with a "line" and "column"
  20650. * field.
  20651. * - map: A source map definition. This source map could also be indexed,
  20652. * but doesn't have to be.
  20653. *
  20654. * Instead of the "map" field, it's also possible to have a "url" field
  20655. * specifying a URL to retrieve a source map from, but that's currently
  20656. * unsupported.
  20657. *
  20658. * Here's an example source map, taken from the source map spec[0], but
  20659. * modified to omit a section which uses the "url" field.
  20660. *
  20661. * {
  20662. * version : 3,
  20663. * file: "app.js",
  20664. * sections: [{
  20665. * offset: {line:100, column:10},
  20666. * map: {
  20667. * version : 3,
  20668. * file: "section.js",
  20669. * sources: ["foo.js", "bar.js"],
  20670. * names: ["src", "maps", "are", "fun"],
  20671. * mappings: "AAAA,E;;ABCDE;"
  20672. * }
  20673. * }],
  20674. * }
  20675. *
  20676. * The second parameter, if given, is a string whose value is the URL
  20677. * at which the source map was found. This URL is used to compute the
  20678. * sources array.
  20679. *
  20680. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  20681. */
  20682. function IndexedSourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  20683. var sourceMap = aSourceMap;
  20684. if (typeof aSourceMap === 'string') {
  20685. sourceMap = util$8.parseSourceMapInput(aSourceMap);
  20686. }
  20687. var version = util$8.getArg(sourceMap, 'version');
  20688. var sections = util$8.getArg(sourceMap, 'sections');
  20689. if (version != this._version) {
  20690. throw new Error('Unsupported version: ' + version);
  20691. }
  20692. this._sources = new ArraySet$3();
  20693. this._names = new ArraySet$3();
  20694. var lastOffset = {
  20695. line: -1,
  20696. column: 0
  20697. };
  20698. this._sections = sections.map(function (s) {
  20699. if (s.url) {
  20700. // The url field will require support for asynchronicity.
  20701. // See https://github.com/mozilla/source-map/issues/16
  20702. throw new Error('Support for url field in sections not implemented.');
  20703. }
  20704. var offset = util$8.getArg(s, 'offset');
  20705. var offsetLine = util$8.getArg(offset, 'line');
  20706. var offsetColumn = util$8.getArg(offset, 'column');
  20707. if (offsetLine < lastOffset.line ||
  20708. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  20709. throw new Error('Section offsets must be ordered and non-overlapping.');
  20710. }
  20711. lastOffset = offset;
  20712. return {
  20713. generatedOffset: {
  20714. // The offset fields are 0-based, but we use 1-based indices when
  20715. // encoding/decoding from VLQ.
  20716. generatedLine: offsetLine + 1,
  20717. generatedColumn: offsetColumn + 1
  20718. },
  20719. consumer: new SourceMapConsumer$6(util$8.getArg(s, 'map'), aSourceMapURL)
  20720. }
  20721. });
  20722. }
  20723. IndexedSourceMapConsumer$1.prototype = Object.create(SourceMapConsumer$6.prototype);
  20724. IndexedSourceMapConsumer$1.prototype.constructor = SourceMapConsumer$6;
  20725. /**
  20726. * The version of the source mapping spec that we are consuming.
  20727. */
  20728. IndexedSourceMapConsumer$1.prototype._version = 3;
  20729. /**
  20730. * The list of original sources.
  20731. */
  20732. Object.defineProperty(IndexedSourceMapConsumer$1.prototype, 'sources', {
  20733. get: function () {
  20734. var sources = [];
  20735. for (var i = 0; i < this._sections.length; i++) {
  20736. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  20737. sources.push(this._sections[i].consumer.sources[j]);
  20738. }
  20739. }
  20740. return sources;
  20741. }
  20742. });
  20743. /**
  20744. * Returns the original source, line, and column information for the generated
  20745. * source's line and column positions provided. The only argument is an object
  20746. * with the following properties:
  20747. *
  20748. * - line: The line number in the generated source. The line number
  20749. * is 1-based.
  20750. * - column: The column number in the generated source. The column
  20751. * number is 0-based.
  20752. *
  20753. * and an object is returned with the following properties:
  20754. *
  20755. * - source: The original source file, or null.
  20756. * - line: The line number in the original source, or null. The
  20757. * line number is 1-based.
  20758. * - column: The column number in the original source, or null. The
  20759. * column number is 0-based.
  20760. * - name: The original identifier, or null.
  20761. */
  20762. IndexedSourceMapConsumer$1.prototype.originalPositionFor =
  20763. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  20764. var needle = {
  20765. generatedLine: util$8.getArg(aArgs, 'line'),
  20766. generatedColumn: util$8.getArg(aArgs, 'column')
  20767. };
  20768. // Find the section containing the generated position we're trying to map
  20769. // to an original position.
  20770. var sectionIndex = binarySearch$2.search(needle, this._sections,
  20771. function(needle, section) {
  20772. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  20773. if (cmp) {
  20774. return cmp;
  20775. }
  20776. return (needle.generatedColumn -
  20777. section.generatedOffset.generatedColumn);
  20778. });
  20779. var section = this._sections[sectionIndex];
  20780. if (!section) {
  20781. return {
  20782. source: null,
  20783. line: null,
  20784. column: null,
  20785. name: null
  20786. };
  20787. }
  20788. return section.consumer.originalPositionFor({
  20789. line: needle.generatedLine -
  20790. (section.generatedOffset.generatedLine - 1),
  20791. column: needle.generatedColumn -
  20792. (section.generatedOffset.generatedLine === needle.generatedLine
  20793. ? section.generatedOffset.generatedColumn - 1
  20794. : 0),
  20795. bias: aArgs.bias
  20796. });
  20797. };
  20798. /**
  20799. * Return true if we have the source content for every source in the source
  20800. * map, false otherwise.
  20801. */
  20802. IndexedSourceMapConsumer$1.prototype.hasContentsOfAllSources =
  20803. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  20804. return this._sections.every(function (s) {
  20805. return s.consumer.hasContentsOfAllSources();
  20806. });
  20807. };
  20808. /**
  20809. * Returns the original source content. The only argument is the url of the
  20810. * original source file. Returns null if no original source content is
  20811. * available.
  20812. */
  20813. IndexedSourceMapConsumer$1.prototype.sourceContentFor =
  20814. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  20815. for (var i = 0; i < this._sections.length; i++) {
  20816. var section = this._sections[i];
  20817. var content = section.consumer.sourceContentFor(aSource, true);
  20818. if (content || content === '') {
  20819. return content;
  20820. }
  20821. }
  20822. if (nullOnMissing) {
  20823. return null;
  20824. }
  20825. else {
  20826. throw new Error('"' + aSource + '" is not in the SourceMap.');
  20827. }
  20828. };
  20829. /**
  20830. * Returns the generated line and column information for the original source,
  20831. * line, and column positions provided. The only argument is an object with
  20832. * the following properties:
  20833. *
  20834. * - source: The filename of the original source.
  20835. * - line: The line number in the original source. The line number
  20836. * is 1-based.
  20837. * - column: The column number in the original source. The column
  20838. * number is 0-based.
  20839. *
  20840. * and an object is returned with the following properties:
  20841. *
  20842. * - line: The line number in the generated source, or null. The
  20843. * line number is 1-based.
  20844. * - column: The column number in the generated source, or null.
  20845. * The column number is 0-based.
  20846. */
  20847. IndexedSourceMapConsumer$1.prototype.generatedPositionFor =
  20848. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  20849. for (var i = 0; i < this._sections.length; i++) {
  20850. var section = this._sections[i];
  20851. // Only consider this section if the requested source is in the list of
  20852. // sources of the consumer.
  20853. if (section.consumer._findSourceIndex(util$8.getArg(aArgs, 'source')) === -1) {
  20854. continue;
  20855. }
  20856. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  20857. if (generatedPosition) {
  20858. var ret = {
  20859. line: generatedPosition.line +
  20860. (section.generatedOffset.generatedLine - 1),
  20861. column: generatedPosition.column +
  20862. (section.generatedOffset.generatedLine === generatedPosition.line
  20863. ? section.generatedOffset.generatedColumn - 1
  20864. : 0)
  20865. };
  20866. return ret;
  20867. }
  20868. }
  20869. return {
  20870. line: null,
  20871. column: null
  20872. };
  20873. };
  20874. /**
  20875. * Parse the mappings in a string in to a data structure which we can easily
  20876. * query (the ordered arrays in the `this.__generatedMappings` and
  20877. * `this.__originalMappings` properties).
  20878. */
  20879. IndexedSourceMapConsumer$1.prototype._parseMappings =
  20880. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  20881. this.__generatedMappings = [];
  20882. this.__originalMappings = [];
  20883. for (var i = 0; i < this._sections.length; i++) {
  20884. var section = this._sections[i];
  20885. var sectionMappings = section.consumer._generatedMappings;
  20886. for (var j = 0; j < sectionMappings.length; j++) {
  20887. var mapping = sectionMappings[j];
  20888. var source = section.consumer._sources.at(mapping.source);
  20889. source = util$8.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  20890. this._sources.add(source);
  20891. source = this._sources.indexOf(source);
  20892. var name = null;
  20893. if (mapping.name) {
  20894. name = section.consumer._names.at(mapping.name);
  20895. this._names.add(name);
  20896. name = this._names.indexOf(name);
  20897. }
  20898. // The mappings coming from the consumer for the section have
  20899. // generated positions relative to the start of the section, so we
  20900. // need to offset them to be relative to the start of the concatenated
  20901. // generated file.
  20902. var adjustedMapping = {
  20903. source: source,
  20904. generatedLine: mapping.generatedLine +
  20905. (section.generatedOffset.generatedLine - 1),
  20906. generatedColumn: mapping.generatedColumn +
  20907. (section.generatedOffset.generatedLine === mapping.generatedLine
  20908. ? section.generatedOffset.generatedColumn - 1
  20909. : 0),
  20910. originalLine: mapping.originalLine,
  20911. originalColumn: mapping.originalColumn,
  20912. name: name
  20913. };
  20914. this.__generatedMappings.push(adjustedMapping);
  20915. if (typeof adjustedMapping.originalLine === 'number') {
  20916. this.__originalMappings.push(adjustedMapping);
  20917. }
  20918. }
  20919. }
  20920. quickSort$2(this.__generatedMappings, util$8.compareByGeneratedPositionsDeflated);
  20921. quickSort$2(this.__originalMappings, util$8.compareByOriginalPositions);
  20922. };
  20923. sourceMapConsumer$1.IndexedSourceMapConsumer = IndexedSourceMapConsumer$1;
  20924. var sourceNode$1 = {};
  20925. /* -*- Mode: js; js-indent-level: 2; -*- */
  20926. /*
  20927. * Copyright 2011 Mozilla Foundation and contributors
  20928. * Licensed under the New BSD license. See LICENSE or:
  20929. * http://opensource.org/licenses/BSD-3-Clause
  20930. */
  20931. var SourceMapGenerator$7 = sourceMapGenerator$1.SourceMapGenerator;
  20932. var util$7 = util$c;
  20933. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  20934. // operating systems these days (capturing the result).
  20935. var REGEX_NEWLINE$1 = /(\r?\n)/;
  20936. // Newline character code for charCodeAt() comparisons
  20937. var NEWLINE_CODE$1 = 10;
  20938. // Private symbol for identifying `SourceNode`s when multiple versions of
  20939. // the source-map library are loaded. This MUST NOT CHANGE across
  20940. // versions!
  20941. var isSourceNode$1 = "$$$isSourceNode$$$";
  20942. /**
  20943. * SourceNodes provide a way to abstract over interpolating/concatenating
  20944. * snippets of generated JavaScript source code while maintaining the line and
  20945. * column information associated with the original source code.
  20946. *
  20947. * @param aLine The original line number.
  20948. * @param aColumn The original column number.
  20949. * @param aSource The original source's filename.
  20950. * @param aChunks Optional. An array of strings which are snippets of
  20951. * generated JS, or other SourceNodes.
  20952. * @param aName The original identifier.
  20953. */
  20954. function SourceNode$1(aLine, aColumn, aSource, aChunks, aName) {
  20955. this.children = [];
  20956. this.sourceContents = {};
  20957. this.line = aLine == null ? null : aLine;
  20958. this.column = aColumn == null ? null : aColumn;
  20959. this.source = aSource == null ? null : aSource;
  20960. this.name = aName == null ? null : aName;
  20961. this[isSourceNode$1] = true;
  20962. if (aChunks != null) this.add(aChunks);
  20963. }
  20964. /**
  20965. * Creates a SourceNode from generated code and a SourceMapConsumer.
  20966. *
  20967. * @param aGeneratedCode The generated code
  20968. * @param aSourceMapConsumer The SourceMap for the generated code
  20969. * @param aRelativePath Optional. The path that relative sources in the
  20970. * SourceMapConsumer should be relative to.
  20971. */
  20972. SourceNode$1.fromStringWithSourceMap =
  20973. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  20974. // The SourceNode we want to fill with the generated code
  20975. // and the SourceMap
  20976. var node = new SourceNode$1();
  20977. // All even indices of this array are one line of the generated code,
  20978. // while all odd indices are the newlines between two adjacent lines
  20979. // (since `REGEX_NEWLINE` captures its match).
  20980. // Processed fragments are accessed by calling `shiftNextLine`.
  20981. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE$1);
  20982. var remainingLinesIndex = 0;
  20983. var shiftNextLine = function() {
  20984. var lineContents = getNextLine();
  20985. // The last line of a file might not have a newline.
  20986. var newLine = getNextLine() || "";
  20987. return lineContents + newLine;
  20988. function getNextLine() {
  20989. return remainingLinesIndex < remainingLines.length ?
  20990. remainingLines[remainingLinesIndex++] : undefined;
  20991. }
  20992. };
  20993. // We need to remember the position of "remainingLines"
  20994. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  20995. // The generate SourceNodes we need a code range.
  20996. // To extract it current and last mapping is used.
  20997. // Here we store the last mapping.
  20998. var lastMapping = null;
  20999. aSourceMapConsumer.eachMapping(function (mapping) {
  21000. if (lastMapping !== null) {
  21001. // We add the code from "lastMapping" to "mapping":
  21002. // First check if there is a new line in between.
  21003. if (lastGeneratedLine < mapping.generatedLine) {
  21004. // Associate first line with "lastMapping"
  21005. addMappingWithCode(lastMapping, shiftNextLine());
  21006. lastGeneratedLine++;
  21007. lastGeneratedColumn = 0;
  21008. // The remaining code is added without mapping
  21009. } else {
  21010. // There is no new line in between.
  21011. // Associate the code between "lastGeneratedColumn" and
  21012. // "mapping.generatedColumn" with "lastMapping"
  21013. var nextLine = remainingLines[remainingLinesIndex] || '';
  21014. var code = nextLine.substr(0, mapping.generatedColumn -
  21015. lastGeneratedColumn);
  21016. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  21017. lastGeneratedColumn);
  21018. lastGeneratedColumn = mapping.generatedColumn;
  21019. addMappingWithCode(lastMapping, code);
  21020. // No more remaining code, continue
  21021. lastMapping = mapping;
  21022. return;
  21023. }
  21024. }
  21025. // We add the generated code until the first mapping
  21026. // to the SourceNode without any mapping.
  21027. // Each line is added as separate string.
  21028. while (lastGeneratedLine < mapping.generatedLine) {
  21029. node.add(shiftNextLine());
  21030. lastGeneratedLine++;
  21031. }
  21032. if (lastGeneratedColumn < mapping.generatedColumn) {
  21033. var nextLine = remainingLines[remainingLinesIndex] || '';
  21034. node.add(nextLine.substr(0, mapping.generatedColumn));
  21035. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  21036. lastGeneratedColumn = mapping.generatedColumn;
  21037. }
  21038. lastMapping = mapping;
  21039. }, this);
  21040. // We have processed all mappings.
  21041. if (remainingLinesIndex < remainingLines.length) {
  21042. if (lastMapping) {
  21043. // Associate the remaining code in the current line with "lastMapping"
  21044. addMappingWithCode(lastMapping, shiftNextLine());
  21045. }
  21046. // and add the remaining lines without any mapping
  21047. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  21048. }
  21049. // Copy sourcesContent into SourceNode
  21050. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  21051. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  21052. if (content != null) {
  21053. if (aRelativePath != null) {
  21054. sourceFile = util$7.join(aRelativePath, sourceFile);
  21055. }
  21056. node.setSourceContent(sourceFile, content);
  21057. }
  21058. });
  21059. return node;
  21060. function addMappingWithCode(mapping, code) {
  21061. if (mapping === null || mapping.source === undefined) {
  21062. node.add(code);
  21063. } else {
  21064. var source = aRelativePath
  21065. ? util$7.join(aRelativePath, mapping.source)
  21066. : mapping.source;
  21067. node.add(new SourceNode$1(mapping.originalLine,
  21068. mapping.originalColumn,
  21069. source,
  21070. code,
  21071. mapping.name));
  21072. }
  21073. }
  21074. };
  21075. /**
  21076. * Add a chunk of generated JS to this source node.
  21077. *
  21078. * @param aChunk A string snippet of generated JS code, another instance of
  21079. * SourceNode, or an array where each member is one of those things.
  21080. */
  21081. SourceNode$1.prototype.add = function SourceNode_add(aChunk) {
  21082. if (Array.isArray(aChunk)) {
  21083. aChunk.forEach(function (chunk) {
  21084. this.add(chunk);
  21085. }, this);
  21086. }
  21087. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  21088. if (aChunk) {
  21089. this.children.push(aChunk);
  21090. }
  21091. }
  21092. else {
  21093. throw new TypeError(
  21094. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21095. );
  21096. }
  21097. return this;
  21098. };
  21099. /**
  21100. * Add a chunk of generated JS to the beginning of this source node.
  21101. *
  21102. * @param aChunk A string snippet of generated JS code, another instance of
  21103. * SourceNode, or an array where each member is one of those things.
  21104. */
  21105. SourceNode$1.prototype.prepend = function SourceNode_prepend(aChunk) {
  21106. if (Array.isArray(aChunk)) {
  21107. for (var i = aChunk.length-1; i >= 0; i--) {
  21108. this.prepend(aChunk[i]);
  21109. }
  21110. }
  21111. else if (aChunk[isSourceNode$1] || typeof aChunk === "string") {
  21112. this.children.unshift(aChunk);
  21113. }
  21114. else {
  21115. throw new TypeError(
  21116. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  21117. );
  21118. }
  21119. return this;
  21120. };
  21121. /**
  21122. * Walk over the tree of JS snippets in this node and its children. The
  21123. * walking function is called once for each snippet of JS and is passed that
  21124. * snippet and the its original associated source's line/column location.
  21125. *
  21126. * @param aFn The traversal function.
  21127. */
  21128. SourceNode$1.prototype.walk = function SourceNode_walk(aFn) {
  21129. var chunk;
  21130. for (var i = 0, len = this.children.length; i < len; i++) {
  21131. chunk = this.children[i];
  21132. if (chunk[isSourceNode$1]) {
  21133. chunk.walk(aFn);
  21134. }
  21135. else {
  21136. if (chunk !== '') {
  21137. aFn(chunk, { source: this.source,
  21138. line: this.line,
  21139. column: this.column,
  21140. name: this.name });
  21141. }
  21142. }
  21143. }
  21144. };
  21145. /**
  21146. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  21147. * each of `this.children`.
  21148. *
  21149. * @param aSep The separator.
  21150. */
  21151. SourceNode$1.prototype.join = function SourceNode_join(aSep) {
  21152. var newChildren;
  21153. var i;
  21154. var len = this.children.length;
  21155. if (len > 0) {
  21156. newChildren = [];
  21157. for (i = 0; i < len-1; i++) {
  21158. newChildren.push(this.children[i]);
  21159. newChildren.push(aSep);
  21160. }
  21161. newChildren.push(this.children[i]);
  21162. this.children = newChildren;
  21163. }
  21164. return this;
  21165. };
  21166. /**
  21167. * Call String.prototype.replace on the very right-most source snippet. Useful
  21168. * for trimming whitespace from the end of a source node, etc.
  21169. *
  21170. * @param aPattern The pattern to replace.
  21171. * @param aReplacement The thing to replace the pattern with.
  21172. */
  21173. SourceNode$1.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  21174. var lastChild = this.children[this.children.length - 1];
  21175. if (lastChild[isSourceNode$1]) {
  21176. lastChild.replaceRight(aPattern, aReplacement);
  21177. }
  21178. else if (typeof lastChild === 'string') {
  21179. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  21180. }
  21181. else {
  21182. this.children.push(''.replace(aPattern, aReplacement));
  21183. }
  21184. return this;
  21185. };
  21186. /**
  21187. * Set the source content for a source file. This will be added to the SourceMapGenerator
  21188. * in the sourcesContent field.
  21189. *
  21190. * @param aSourceFile The filename of the source file
  21191. * @param aSourceContent The content of the source file
  21192. */
  21193. SourceNode$1.prototype.setSourceContent =
  21194. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  21195. this.sourceContents[util$7.toSetString(aSourceFile)] = aSourceContent;
  21196. };
  21197. /**
  21198. * Walk over the tree of SourceNodes. The walking function is called for each
  21199. * source file content and is passed the filename and source content.
  21200. *
  21201. * @param aFn The traversal function.
  21202. */
  21203. SourceNode$1.prototype.walkSourceContents =
  21204. function SourceNode_walkSourceContents(aFn) {
  21205. for (var i = 0, len = this.children.length; i < len; i++) {
  21206. if (this.children[i][isSourceNode$1]) {
  21207. this.children[i].walkSourceContents(aFn);
  21208. }
  21209. }
  21210. var sources = Object.keys(this.sourceContents);
  21211. for (var i = 0, len = sources.length; i < len; i++) {
  21212. aFn(util$7.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  21213. }
  21214. };
  21215. /**
  21216. * Return the string representation of this source node. Walks over the tree
  21217. * and concatenates all the various snippets together to one string.
  21218. */
  21219. SourceNode$1.prototype.toString = function SourceNode_toString() {
  21220. var str = "";
  21221. this.walk(function (chunk) {
  21222. str += chunk;
  21223. });
  21224. return str;
  21225. };
  21226. /**
  21227. * Returns the string representation of this source node along with a source
  21228. * map.
  21229. */
  21230. SourceNode$1.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  21231. var generated = {
  21232. code: "",
  21233. line: 1,
  21234. column: 0
  21235. };
  21236. var map = new SourceMapGenerator$7(aArgs);
  21237. var sourceMappingActive = false;
  21238. var lastOriginalSource = null;
  21239. var lastOriginalLine = null;
  21240. var lastOriginalColumn = null;
  21241. var lastOriginalName = null;
  21242. this.walk(function (chunk, original) {
  21243. generated.code += chunk;
  21244. if (original.source !== null
  21245. && original.line !== null
  21246. && original.column !== null) {
  21247. if(lastOriginalSource !== original.source
  21248. || lastOriginalLine !== original.line
  21249. || lastOriginalColumn !== original.column
  21250. || lastOriginalName !== original.name) {
  21251. map.addMapping({
  21252. source: original.source,
  21253. original: {
  21254. line: original.line,
  21255. column: original.column
  21256. },
  21257. generated: {
  21258. line: generated.line,
  21259. column: generated.column
  21260. },
  21261. name: original.name
  21262. });
  21263. }
  21264. lastOriginalSource = original.source;
  21265. lastOriginalLine = original.line;
  21266. lastOriginalColumn = original.column;
  21267. lastOriginalName = original.name;
  21268. sourceMappingActive = true;
  21269. } else if (sourceMappingActive) {
  21270. map.addMapping({
  21271. generated: {
  21272. line: generated.line,
  21273. column: generated.column
  21274. }
  21275. });
  21276. lastOriginalSource = null;
  21277. sourceMappingActive = false;
  21278. }
  21279. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  21280. if (chunk.charCodeAt(idx) === NEWLINE_CODE$1) {
  21281. generated.line++;
  21282. generated.column = 0;
  21283. // Mappings end at eol
  21284. if (idx + 1 === length) {
  21285. lastOriginalSource = null;
  21286. sourceMappingActive = false;
  21287. } else if (sourceMappingActive) {
  21288. map.addMapping({
  21289. source: original.source,
  21290. original: {
  21291. line: original.line,
  21292. column: original.column
  21293. },
  21294. generated: {
  21295. line: generated.line,
  21296. column: generated.column
  21297. },
  21298. name: original.name
  21299. });
  21300. }
  21301. } else {
  21302. generated.column++;
  21303. }
  21304. }
  21305. });
  21306. this.walkSourceContents(function (sourceFile, sourceContent) {
  21307. map.setSourceContent(sourceFile, sourceContent);
  21308. });
  21309. return { code: generated.code, map: map };
  21310. };
  21311. sourceNode$1.SourceNode = SourceNode$1;
  21312. /*
  21313. * Copyright 2009-2011 Mozilla Foundation and contributors
  21314. * Licensed under the New BSD license. See LICENSE.txt or:
  21315. * http://opensource.org/licenses/BSD-3-Clause
  21316. */
  21317. var SourceMapGenerator$6 = sourceMap$2.SourceMapGenerator = sourceMapGenerator$1.SourceMapGenerator;
  21318. var SourceMapConsumer$5 = sourceMap$2.SourceMapConsumer = sourceMapConsumer$1.SourceMapConsumer;
  21319. sourceMap$2.SourceNode = sourceNode$1.SourceNode;
  21320. const PURE_ANNOTATION = `/*#__PURE__*/`;
  21321. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  21322. function createCodegenContext(ast, {
  21323. mode = "function",
  21324. prefixIdentifiers = mode === "module",
  21325. sourceMap = false,
  21326. filename = `template.vue.html`,
  21327. scopeId = null,
  21328. optimizeImports = false,
  21329. runtimeGlobalName = `Vue`,
  21330. runtimeModuleName = `vue`,
  21331. ssrRuntimeModuleName = "vue/server-renderer",
  21332. ssr = false,
  21333. isTS = false,
  21334. inSSR = false
  21335. }) {
  21336. const context = {
  21337. mode,
  21338. prefixIdentifiers,
  21339. sourceMap,
  21340. filename,
  21341. scopeId,
  21342. optimizeImports,
  21343. runtimeGlobalName,
  21344. runtimeModuleName,
  21345. ssrRuntimeModuleName,
  21346. ssr,
  21347. isTS,
  21348. inSSR,
  21349. source: ast.source,
  21350. code: ``,
  21351. column: 1,
  21352. line: 1,
  21353. offset: 0,
  21354. indentLevel: 0,
  21355. pure: false,
  21356. map: void 0,
  21357. helper(key) {
  21358. return `_${helperNameMap[key]}`;
  21359. },
  21360. push(code, newlineIndex = -2 /* None */, node) {
  21361. context.code += code;
  21362. if (context.map) {
  21363. if (node) {
  21364. let name;
  21365. if (node.type === 4 && !node.isStatic) {
  21366. const content = node.content.replace(/^_ctx\./, "");
  21367. if (content !== node.content && isSimpleIdentifier(content)) {
  21368. name = content;
  21369. }
  21370. }
  21371. addMapping(node.loc.start, name);
  21372. }
  21373. if (newlineIndex === -3 /* Unknown */) {
  21374. advancePositionWithMutation(context, code);
  21375. } else {
  21376. context.offset += code.length;
  21377. if (newlineIndex === -2 /* None */) {
  21378. context.column += code.length;
  21379. } else {
  21380. if (newlineIndex === -1 /* End */) {
  21381. newlineIndex = code.length - 1;
  21382. }
  21383. context.line++;
  21384. context.column = code.length - newlineIndex;
  21385. }
  21386. }
  21387. if (node && node.loc !== locStub) {
  21388. addMapping(node.loc.end);
  21389. }
  21390. }
  21391. },
  21392. indent() {
  21393. newline(++context.indentLevel);
  21394. },
  21395. deindent(withoutNewLine = false) {
  21396. if (withoutNewLine) {
  21397. --context.indentLevel;
  21398. } else {
  21399. newline(--context.indentLevel);
  21400. }
  21401. },
  21402. newline() {
  21403. newline(context.indentLevel);
  21404. }
  21405. };
  21406. function newline(n) {
  21407. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  21408. }
  21409. function addMapping(loc, name = null) {
  21410. const { _names, _mappings } = context.map;
  21411. if (name !== null && !_names.has(name)) _names.add(name);
  21412. _mappings.add({
  21413. originalLine: loc.line,
  21414. originalColumn: loc.column - 1,
  21415. // source-map column is 0 based
  21416. generatedLine: context.line,
  21417. generatedColumn: context.column - 1,
  21418. source: filename,
  21419. name
  21420. });
  21421. }
  21422. if (sourceMap) {
  21423. context.map = new SourceMapGenerator$6();
  21424. context.map.setSourceContent(filename, context.source);
  21425. context.map._sources.add(filename);
  21426. }
  21427. return context;
  21428. }
  21429. function generate(ast, options = {}) {
  21430. const context = createCodegenContext(ast, options);
  21431. if (options.onContextCreated) options.onContextCreated(context);
  21432. const {
  21433. mode,
  21434. push,
  21435. prefixIdentifiers,
  21436. indent,
  21437. deindent,
  21438. newline,
  21439. scopeId,
  21440. ssr
  21441. } = context;
  21442. const helpers = Array.from(ast.helpers);
  21443. const hasHelpers = helpers.length > 0;
  21444. const useWithBlock = !prefixIdentifiers && mode !== "module";
  21445. const genScopeId = scopeId != null && mode === "module";
  21446. const isSetupInlined = !!options.inline;
  21447. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  21448. if (mode === "module") {
  21449. genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
  21450. } else {
  21451. genFunctionPreamble(ast, preambleContext);
  21452. }
  21453. const functionName = ssr ? `ssrRender` : `render`;
  21454. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  21455. if (options.bindingMetadata && !options.inline) {
  21456. args.push("$props", "$setup", "$data", "$options");
  21457. }
  21458. const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
  21459. if (isSetupInlined) {
  21460. push(`(${signature}) => {`);
  21461. } else {
  21462. push(`function ${functionName}(${signature}) {`);
  21463. }
  21464. indent();
  21465. if (useWithBlock) {
  21466. push(`with (_ctx) {`);
  21467. indent();
  21468. if (hasHelpers) {
  21469. push(
  21470. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  21471. `,
  21472. -1 /* End */
  21473. );
  21474. newline();
  21475. }
  21476. }
  21477. if (ast.components.length) {
  21478. genAssets(ast.components, "component", context);
  21479. if (ast.directives.length || ast.temps > 0) {
  21480. newline();
  21481. }
  21482. }
  21483. if (ast.directives.length) {
  21484. genAssets(ast.directives, "directive", context);
  21485. if (ast.temps > 0) {
  21486. newline();
  21487. }
  21488. }
  21489. if (ast.temps > 0) {
  21490. push(`let `);
  21491. for (let i = 0; i < ast.temps; i++) {
  21492. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  21493. }
  21494. }
  21495. if (ast.components.length || ast.directives.length || ast.temps) {
  21496. push(`
  21497. `, 0 /* Start */);
  21498. newline();
  21499. }
  21500. if (!ssr) {
  21501. push(`return `);
  21502. }
  21503. if (ast.codegenNode) {
  21504. genNode(ast.codegenNode, context);
  21505. } else {
  21506. push(`null`);
  21507. }
  21508. if (useWithBlock) {
  21509. deindent();
  21510. push(`}`);
  21511. }
  21512. deindent();
  21513. push(`}`);
  21514. return {
  21515. ast,
  21516. code: context.code,
  21517. preamble: isSetupInlined ? preambleContext.code : ``,
  21518. map: context.map ? context.map.toJSON() : void 0
  21519. };
  21520. }
  21521. function genFunctionPreamble(ast, context) {
  21522. const {
  21523. ssr,
  21524. prefixIdentifiers,
  21525. push,
  21526. newline,
  21527. runtimeModuleName,
  21528. runtimeGlobalName,
  21529. ssrRuntimeModuleName
  21530. } = context;
  21531. const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
  21532. const helpers = Array.from(ast.helpers);
  21533. if (helpers.length > 0) {
  21534. if (prefixIdentifiers) {
  21535. push(
  21536. `const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
  21537. `,
  21538. -1 /* End */
  21539. );
  21540. } else {
  21541. push(`const _Vue = ${VueBinding}
  21542. `, -1 /* End */);
  21543. if (ast.hoists.length) {
  21544. const staticHelpers = [
  21545. CREATE_VNODE,
  21546. CREATE_ELEMENT_VNODE,
  21547. CREATE_COMMENT,
  21548. CREATE_TEXT,
  21549. CREATE_STATIC
  21550. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  21551. push(`const { ${staticHelpers} } = _Vue
  21552. `, -1 /* End */);
  21553. }
  21554. }
  21555. }
  21556. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21557. push(
  21558. `const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
  21559. `,
  21560. -1 /* End */
  21561. );
  21562. }
  21563. genHoists(ast.hoists, context);
  21564. newline();
  21565. push(`return `);
  21566. }
  21567. function genModulePreamble(ast, context, genScopeId, inline) {
  21568. const {
  21569. push,
  21570. newline,
  21571. optimizeImports,
  21572. runtimeModuleName,
  21573. ssrRuntimeModuleName
  21574. } = context;
  21575. if (genScopeId && ast.hoists.length) {
  21576. ast.helpers.add(PUSH_SCOPE_ID);
  21577. ast.helpers.add(POP_SCOPE_ID);
  21578. }
  21579. if (ast.helpers.size) {
  21580. const helpers = Array.from(ast.helpers);
  21581. if (optimizeImports) {
  21582. push(
  21583. `import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21584. `,
  21585. -1 /* End */
  21586. );
  21587. push(
  21588. `
  21589. // Binding optimization for webpack code-split
  21590. const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
  21591. `,
  21592. -1 /* End */
  21593. );
  21594. } else {
  21595. push(
  21596. `import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
  21597. `,
  21598. -1 /* End */
  21599. );
  21600. }
  21601. }
  21602. if (ast.ssrHelpers && ast.ssrHelpers.length) {
  21603. push(
  21604. `import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
  21605. `,
  21606. -1 /* End */
  21607. );
  21608. }
  21609. if (ast.imports.length) {
  21610. genImports(ast.imports, context);
  21611. newline();
  21612. }
  21613. genHoists(ast.hoists, context);
  21614. newline();
  21615. if (!inline) {
  21616. push(`export `);
  21617. }
  21618. }
  21619. function genAssets(assets, type, { helper, push, newline, isTS }) {
  21620. const resolver = helper(
  21621. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  21622. );
  21623. for (let i = 0; i < assets.length; i++) {
  21624. let id = assets[i];
  21625. const maybeSelfReference = id.endsWith("__self");
  21626. if (maybeSelfReference) {
  21627. id = id.slice(0, -6);
  21628. }
  21629. push(
  21630. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  21631. );
  21632. if (i < assets.length - 1) {
  21633. newline();
  21634. }
  21635. }
  21636. }
  21637. function genHoists(hoists, context) {
  21638. if (!hoists.length) {
  21639. return;
  21640. }
  21641. context.pure = true;
  21642. const { push, newline, helper, scopeId, mode } = context;
  21643. const genScopeId = scopeId != null && mode !== "function";
  21644. newline();
  21645. if (genScopeId) {
  21646. const param = context.isTS ? "(n: any)" : "n";
  21647. push(
  21648. `const _withScopeId = ${param} => (${helper(
  21649. PUSH_SCOPE_ID
  21650. )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
  21651. );
  21652. newline();
  21653. }
  21654. for (let i = 0; i < hoists.length; i++) {
  21655. const exp = hoists[i];
  21656. if (exp) {
  21657. const needScopeIdWrapper = genScopeId && exp.type === 13;
  21658. push(
  21659. `const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
  21660. );
  21661. genNode(exp, context);
  21662. if (needScopeIdWrapper) {
  21663. push(`)`);
  21664. }
  21665. newline();
  21666. }
  21667. }
  21668. context.pure = false;
  21669. }
  21670. function genImports(importsOptions, context) {
  21671. if (!importsOptions.length) {
  21672. return;
  21673. }
  21674. importsOptions.forEach((imports) => {
  21675. context.push(`import `);
  21676. genNode(imports.exp, context);
  21677. context.push(` from '${imports.path}'`);
  21678. context.newline();
  21679. });
  21680. }
  21681. function isText(n) {
  21682. return isString$2(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  21683. }
  21684. function genNodeListAsArray(nodes, context) {
  21685. const multilines = nodes.length > 3 || nodes.some((n) => isArray$3(n) || !isText(n));
  21686. context.push(`[`);
  21687. multilines && context.indent();
  21688. genNodeList(nodes, context, multilines);
  21689. multilines && context.deindent();
  21690. context.push(`]`);
  21691. }
  21692. function genNodeList(nodes, context, multilines = false, comma = true) {
  21693. const { push, newline } = context;
  21694. for (let i = 0; i < nodes.length; i++) {
  21695. const node = nodes[i];
  21696. if (isString$2(node)) {
  21697. push(node, -3 /* Unknown */);
  21698. } else if (isArray$3(node)) {
  21699. genNodeListAsArray(node, context);
  21700. } else {
  21701. genNode(node, context);
  21702. }
  21703. if (i < nodes.length - 1) {
  21704. if (multilines) {
  21705. comma && push(",");
  21706. newline();
  21707. } else {
  21708. comma && push(", ");
  21709. }
  21710. }
  21711. }
  21712. }
  21713. function genNode(node, context) {
  21714. if (isString$2(node)) {
  21715. context.push(node, -3 /* Unknown */);
  21716. return;
  21717. }
  21718. if (isSymbol$1(node)) {
  21719. context.push(context.helper(node));
  21720. return;
  21721. }
  21722. switch (node.type) {
  21723. case 1:
  21724. case 9:
  21725. case 11:
  21726. assert(
  21727. node.codegenNode != null,
  21728. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  21729. );
  21730. genNode(node.codegenNode, context);
  21731. break;
  21732. case 2:
  21733. genText(node, context);
  21734. break;
  21735. case 4:
  21736. genExpression(node, context);
  21737. break;
  21738. case 5:
  21739. genInterpolation(node, context);
  21740. break;
  21741. case 12:
  21742. genNode(node.codegenNode, context);
  21743. break;
  21744. case 8:
  21745. genCompoundExpression(node, context);
  21746. break;
  21747. case 3:
  21748. genComment(node, context);
  21749. break;
  21750. case 13:
  21751. genVNodeCall(node, context);
  21752. break;
  21753. case 14:
  21754. genCallExpression(node, context);
  21755. break;
  21756. case 15:
  21757. genObjectExpression(node, context);
  21758. break;
  21759. case 17:
  21760. genArrayExpression(node, context);
  21761. break;
  21762. case 18:
  21763. genFunctionExpression(node, context);
  21764. break;
  21765. case 19:
  21766. genConditionalExpression(node, context);
  21767. break;
  21768. case 20:
  21769. genCacheExpression(node, context);
  21770. break;
  21771. case 21:
  21772. genNodeList(node.body, context, true, false);
  21773. break;
  21774. case 22:
  21775. genTemplateLiteral(node, context);
  21776. break;
  21777. case 23:
  21778. genIfStatement(node, context);
  21779. break;
  21780. case 24:
  21781. genAssignmentExpression(node, context);
  21782. break;
  21783. case 25:
  21784. genSequenceExpression(node, context);
  21785. break;
  21786. case 26:
  21787. genReturnStatement(node, context);
  21788. break;
  21789. case 10:
  21790. break;
  21791. default:
  21792. {
  21793. assert(false, `unhandled codegen node type: ${node.type}`);
  21794. const exhaustiveCheck = node;
  21795. return exhaustiveCheck;
  21796. }
  21797. }
  21798. }
  21799. function genText(node, context) {
  21800. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  21801. }
  21802. function genExpression(node, context) {
  21803. const { content, isStatic } = node;
  21804. context.push(
  21805. isStatic ? JSON.stringify(content) : content,
  21806. -3 /* Unknown */,
  21807. node
  21808. );
  21809. }
  21810. function genInterpolation(node, context) {
  21811. const { push, helper, pure } = context;
  21812. if (pure) push(PURE_ANNOTATION);
  21813. push(`${helper(TO_DISPLAY_STRING)}(`);
  21814. genNode(node.content, context);
  21815. push(`)`);
  21816. }
  21817. function genCompoundExpression(node, context) {
  21818. for (let i = 0; i < node.children.length; i++) {
  21819. const child = node.children[i];
  21820. if (isString$2(child)) {
  21821. context.push(child, -3 /* Unknown */);
  21822. } else {
  21823. genNode(child, context);
  21824. }
  21825. }
  21826. }
  21827. function genExpressionAsPropertyKey(node, context) {
  21828. const { push } = context;
  21829. if (node.type === 8) {
  21830. push(`[`);
  21831. genCompoundExpression(node, context);
  21832. push(`]`);
  21833. } else if (node.isStatic) {
  21834. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  21835. push(text, -2 /* None */, node);
  21836. } else {
  21837. push(`[${node.content}]`, -3 /* Unknown */, node);
  21838. }
  21839. }
  21840. function genComment(node, context) {
  21841. const { push, helper, pure } = context;
  21842. if (pure) {
  21843. push(PURE_ANNOTATION);
  21844. }
  21845. push(
  21846. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  21847. -3 /* Unknown */,
  21848. node
  21849. );
  21850. }
  21851. function genVNodeCall(node, context) {
  21852. const { push, helper, pure } = context;
  21853. const {
  21854. tag,
  21855. props,
  21856. children,
  21857. patchFlag,
  21858. dynamicProps,
  21859. directives,
  21860. isBlock,
  21861. disableTracking,
  21862. isComponent
  21863. } = node;
  21864. let patchFlagString;
  21865. if (patchFlag) {
  21866. {
  21867. if (patchFlag < 0) {
  21868. patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  21869. } else {
  21870. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  21871. patchFlagString = patchFlag + ` /* ${flagNames} */`;
  21872. }
  21873. }
  21874. }
  21875. if (directives) {
  21876. push(helper(WITH_DIRECTIVES) + `(`);
  21877. }
  21878. if (isBlock) {
  21879. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  21880. }
  21881. if (pure) {
  21882. push(PURE_ANNOTATION);
  21883. }
  21884. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  21885. push(helper(callHelper) + `(`, -2 /* None */, node);
  21886. genNodeList(
  21887. genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
  21888. context
  21889. );
  21890. push(`)`);
  21891. if (isBlock) {
  21892. push(`)`);
  21893. }
  21894. if (directives) {
  21895. push(`, `);
  21896. genNode(directives, context);
  21897. push(`)`);
  21898. }
  21899. }
  21900. function genNullableArgs(args) {
  21901. let i = args.length;
  21902. while (i--) {
  21903. if (args[i] != null) break;
  21904. }
  21905. return args.slice(0, i + 1).map((arg) => arg || `null`);
  21906. }
  21907. function genCallExpression(node, context) {
  21908. const { push, helper, pure } = context;
  21909. const callee = isString$2(node.callee) ? node.callee : helper(node.callee);
  21910. if (pure) {
  21911. push(PURE_ANNOTATION);
  21912. }
  21913. push(callee + `(`, -2 /* None */, node);
  21914. genNodeList(node.arguments, context);
  21915. push(`)`);
  21916. }
  21917. function genObjectExpression(node, context) {
  21918. const { push, indent, deindent, newline } = context;
  21919. const { properties } = node;
  21920. if (!properties.length) {
  21921. push(`{}`, -2 /* None */, node);
  21922. return;
  21923. }
  21924. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  21925. push(multilines ? `{` : `{ `);
  21926. multilines && indent();
  21927. for (let i = 0; i < properties.length; i++) {
  21928. const { key, value } = properties[i];
  21929. genExpressionAsPropertyKey(key, context);
  21930. push(`: `);
  21931. genNode(value, context);
  21932. if (i < properties.length - 1) {
  21933. push(`,`);
  21934. newline();
  21935. }
  21936. }
  21937. multilines && deindent();
  21938. push(multilines ? `}` : ` }`);
  21939. }
  21940. function genArrayExpression(node, context) {
  21941. genNodeListAsArray(node.elements, context);
  21942. }
  21943. function genFunctionExpression(node, context) {
  21944. const { push, indent, deindent } = context;
  21945. const { params, returns, body, newline, isSlot } = node;
  21946. if (isSlot) {
  21947. push(`_${helperNameMap[WITH_CTX]}(`);
  21948. }
  21949. push(`(`, -2 /* None */, node);
  21950. if (isArray$3(params)) {
  21951. genNodeList(params, context);
  21952. } else if (params) {
  21953. genNode(params, context);
  21954. }
  21955. push(`) => `);
  21956. if (newline || body) {
  21957. push(`{`);
  21958. indent();
  21959. }
  21960. if (returns) {
  21961. if (newline) {
  21962. push(`return `);
  21963. }
  21964. if (isArray$3(returns)) {
  21965. genNodeListAsArray(returns, context);
  21966. } else {
  21967. genNode(returns, context);
  21968. }
  21969. } else if (body) {
  21970. genNode(body, context);
  21971. }
  21972. if (newline || body) {
  21973. deindent();
  21974. push(`}`);
  21975. }
  21976. if (isSlot) {
  21977. push(`)`);
  21978. }
  21979. }
  21980. function genConditionalExpression(node, context) {
  21981. const { test, consequent, alternate, newline: needNewline } = node;
  21982. const { push, indent, deindent, newline } = context;
  21983. if (test.type === 4) {
  21984. const needsParens = !isSimpleIdentifier(test.content);
  21985. needsParens && push(`(`);
  21986. genExpression(test, context);
  21987. needsParens && push(`)`);
  21988. } else {
  21989. push(`(`);
  21990. genNode(test, context);
  21991. push(`)`);
  21992. }
  21993. needNewline && indent();
  21994. context.indentLevel++;
  21995. needNewline || push(` `);
  21996. push(`? `);
  21997. genNode(consequent, context);
  21998. context.indentLevel--;
  21999. needNewline && newline();
  22000. needNewline || push(` `);
  22001. push(`: `);
  22002. const isNested = alternate.type === 19;
  22003. if (!isNested) {
  22004. context.indentLevel++;
  22005. }
  22006. genNode(alternate, context);
  22007. if (!isNested) {
  22008. context.indentLevel--;
  22009. }
  22010. needNewline && deindent(
  22011. true
  22012. /* without newline */
  22013. );
  22014. }
  22015. function genCacheExpression(node, context) {
  22016. const { push, helper, indent, deindent, newline } = context;
  22017. push(`_cache[${node.index}] || (`);
  22018. if (node.isVOnce) {
  22019. indent();
  22020. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  22021. newline();
  22022. push(`(`);
  22023. }
  22024. push(`_cache[${node.index}] = `);
  22025. genNode(node.value, context);
  22026. if (node.isVOnce) {
  22027. push(`).cacheIndex = ${node.index},`);
  22028. newline();
  22029. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  22030. newline();
  22031. push(`_cache[${node.index}]`);
  22032. deindent();
  22033. }
  22034. push(`)`);
  22035. }
  22036. function genTemplateLiteral(node, context) {
  22037. const { push, indent, deindent } = context;
  22038. push("`");
  22039. const l = node.elements.length;
  22040. const multilines = l > 3;
  22041. for (let i = 0; i < l; i++) {
  22042. const e = node.elements[i];
  22043. if (isString$2(e)) {
  22044. push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
  22045. } else {
  22046. push("${");
  22047. if (multilines) indent();
  22048. genNode(e, context);
  22049. if (multilines) deindent();
  22050. push("}");
  22051. }
  22052. }
  22053. push("`");
  22054. }
  22055. function genIfStatement(node, context) {
  22056. const { push, indent, deindent } = context;
  22057. const { test, consequent, alternate } = node;
  22058. push(`if (`);
  22059. genNode(test, context);
  22060. push(`) {`);
  22061. indent();
  22062. genNode(consequent, context);
  22063. deindent();
  22064. push(`}`);
  22065. if (alternate) {
  22066. push(` else `);
  22067. if (alternate.type === 23) {
  22068. genIfStatement(alternate, context);
  22069. } else {
  22070. push(`{`);
  22071. indent();
  22072. genNode(alternate, context);
  22073. deindent();
  22074. push(`}`);
  22075. }
  22076. }
  22077. }
  22078. function genAssignmentExpression(node, context) {
  22079. genNode(node.left, context);
  22080. context.push(` = `);
  22081. genNode(node.right, context);
  22082. }
  22083. function genSequenceExpression(node, context) {
  22084. context.push(`(`);
  22085. genNodeList(node.expressions, context);
  22086. context.push(`)`);
  22087. }
  22088. function genReturnStatement({ returns }, context) {
  22089. context.push(`return `);
  22090. if (isArray$3(returns)) {
  22091. genNodeListAsArray(returns, context);
  22092. } else {
  22093. genNode(returns, context);
  22094. }
  22095. }
  22096. const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
  22097. const transformExpression = (node, context) => {
  22098. if (node.type === 5) {
  22099. node.content = processExpression(
  22100. node.content,
  22101. context
  22102. );
  22103. } else if (node.type === 1) {
  22104. for (let i = 0; i < node.props.length; i++) {
  22105. const dir = node.props[i];
  22106. if (dir.type === 7 && dir.name !== "for") {
  22107. const exp = dir.exp;
  22108. const arg = dir.arg;
  22109. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  22110. dir.exp = processExpression(
  22111. exp,
  22112. context,
  22113. // slot args must be processed as function params
  22114. dir.name === "slot"
  22115. );
  22116. }
  22117. if (arg && arg.type === 4 && !arg.isStatic) {
  22118. dir.arg = processExpression(arg, context);
  22119. }
  22120. }
  22121. }
  22122. }
  22123. };
  22124. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  22125. if (!context.prefixIdentifiers || !node.content.trim()) {
  22126. return node;
  22127. }
  22128. const { inline, bindingMetadata } = context;
  22129. const rewriteIdentifier = (raw, parent, id) => {
  22130. const type = hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
  22131. if (inline) {
  22132. const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
  22133. const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
  22134. const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
  22135. const isNewExpression = parent && isInNewExpression(parentStack);
  22136. const wrapWithUnref = (raw2) => {
  22137. const wrapped = `${context.helperString(UNREF)}(${raw2})`;
  22138. return isNewExpression ? `(${wrapped})` : wrapped;
  22139. };
  22140. if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
  22141. return raw;
  22142. } else if (type === "setup-ref") {
  22143. return `${raw}.value`;
  22144. } else if (type === "setup-maybe-ref") {
  22145. return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
  22146. } else if (type === "setup-let") {
  22147. if (isAssignmentLVal) {
  22148. const { right: rVal, operator } = parent;
  22149. const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
  22150. const rExpString = stringifyExpression(
  22151. processExpression(
  22152. createSimpleExpression(rExp, false),
  22153. context,
  22154. false,
  22155. false,
  22156. knownIds
  22157. )
  22158. );
  22159. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22160. ` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
  22161. } else if (isUpdateArg) {
  22162. id.start = parent.start;
  22163. id.end = parent.end;
  22164. const { prefix: isPrefix, operator } = parent;
  22165. const prefix = isPrefix ? operator : ``;
  22166. const postfix = isPrefix ? `` : operator;
  22167. return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
  22168. ` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
  22169. } else if (isDestructureAssignment) {
  22170. return raw;
  22171. } else {
  22172. return wrapWithUnref(raw);
  22173. }
  22174. } else if (type === "props") {
  22175. return genPropsAccessExp(raw);
  22176. } else if (type === "props-aliased") {
  22177. return genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
  22178. }
  22179. } else {
  22180. if (type && type.startsWith("setup") || type === "literal-const") {
  22181. return `$setup.${raw}`;
  22182. } else if (type === "props-aliased") {
  22183. return `$props['${bindingMetadata.__propsAliases[raw]}']`;
  22184. } else if (type) {
  22185. return `$${type}.${raw}`;
  22186. }
  22187. }
  22188. return `_ctx.${raw}`;
  22189. };
  22190. const rawExp = node.content;
  22191. let ast = node.ast;
  22192. if (ast === false) {
  22193. return node;
  22194. }
  22195. if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
  22196. const isScopeVarReference = context.identifiers[rawExp];
  22197. const isAllowedGlobal = isGloballyAllowed(rawExp);
  22198. const isLiteral = isLiteralWhitelisted(rawExp);
  22199. if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
  22200. if (isConst(bindingMetadata[rawExp])) {
  22201. node.constType = 1;
  22202. }
  22203. node.content = rewriteIdentifier(rawExp);
  22204. } else if (!isScopeVarReference) {
  22205. if (isLiteral) {
  22206. node.constType = 3;
  22207. } else {
  22208. node.constType = 2;
  22209. }
  22210. }
  22211. return node;
  22212. }
  22213. if (!ast) {
  22214. const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
  22215. try {
  22216. ast = parseExpression_1(source, {
  22217. sourceType: "module",
  22218. plugins: context.expressionPlugins
  22219. });
  22220. } catch (e) {
  22221. context.onError(
  22222. createCompilerError(
  22223. 45,
  22224. node.loc,
  22225. void 0,
  22226. e.message
  22227. )
  22228. );
  22229. return node;
  22230. }
  22231. }
  22232. const ids = [];
  22233. const parentStack = [];
  22234. const knownIds = Object.create(context.identifiers);
  22235. walkIdentifiers(
  22236. ast,
  22237. (node2, parent, _, isReferenced, isLocal) => {
  22238. if (isStaticPropertyKey(node2, parent)) {
  22239. return;
  22240. }
  22241. const needPrefix = isReferenced && canPrefix(node2);
  22242. if (needPrefix && !isLocal) {
  22243. if (isStaticProperty(parent) && parent.shorthand) {
  22244. node2.prefix = `${node2.name}: `;
  22245. }
  22246. node2.name = rewriteIdentifier(node2.name, parent, node2);
  22247. ids.push(node2);
  22248. } else {
  22249. if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) {
  22250. node2.isConstant = true;
  22251. }
  22252. ids.push(node2);
  22253. }
  22254. },
  22255. true,
  22256. // invoke on ALL identifiers
  22257. parentStack,
  22258. knownIds
  22259. );
  22260. const children = [];
  22261. ids.sort((a, b) => a.start - b.start);
  22262. ids.forEach((id, i) => {
  22263. const start = id.start - 1;
  22264. const end = id.end - 1;
  22265. const last = ids[i - 1];
  22266. const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
  22267. if (leadingText.length || id.prefix) {
  22268. children.push(leadingText + (id.prefix || ``));
  22269. }
  22270. const source = rawExp.slice(start, end);
  22271. children.push(
  22272. createSimpleExpression(
  22273. id.name,
  22274. false,
  22275. {
  22276. start: advancePositionWithClone(node.loc.start, source, start),
  22277. end: advancePositionWithClone(node.loc.start, source, end),
  22278. source
  22279. },
  22280. id.isConstant ? 3 : 0
  22281. )
  22282. );
  22283. if (i === ids.length - 1 && end < rawExp.length) {
  22284. children.push(rawExp.slice(end));
  22285. }
  22286. });
  22287. let ret;
  22288. if (children.length) {
  22289. ret = createCompoundExpression(children, node.loc);
  22290. ret.ast = ast;
  22291. } else {
  22292. ret = node;
  22293. ret.constType = 3;
  22294. }
  22295. ret.identifiers = Object.keys(knownIds);
  22296. return ret;
  22297. }
  22298. function canPrefix(id) {
  22299. if (isGloballyAllowed(id.name)) {
  22300. return false;
  22301. }
  22302. if (id.name === "require") {
  22303. return false;
  22304. }
  22305. return true;
  22306. }
  22307. function stringifyExpression(exp) {
  22308. if (isString$2(exp)) {
  22309. return exp;
  22310. } else if (exp.type === 4) {
  22311. return exp.content;
  22312. } else {
  22313. return exp.children.map(stringifyExpression).join("");
  22314. }
  22315. }
  22316. function isConst(type) {
  22317. return type === "setup-const" || type === "literal-const";
  22318. }
  22319. const transformIf = createStructuralDirectiveTransform(
  22320. /^(if|else|else-if)$/,
  22321. (node, dir, context) => {
  22322. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  22323. const siblings = context.parent.children;
  22324. let i = siblings.indexOf(ifNode);
  22325. let key = 0;
  22326. while (i-- >= 0) {
  22327. const sibling = siblings[i];
  22328. if (sibling && sibling.type === 9) {
  22329. key += sibling.branches.length;
  22330. }
  22331. }
  22332. return () => {
  22333. if (isRoot) {
  22334. ifNode.codegenNode = createCodegenNodeForBranch(
  22335. branch,
  22336. key,
  22337. context
  22338. );
  22339. } else {
  22340. const parentCondition = getParentCondition(ifNode.codegenNode);
  22341. parentCondition.alternate = createCodegenNodeForBranch(
  22342. branch,
  22343. key + ifNode.branches.length - 1,
  22344. context
  22345. );
  22346. }
  22347. };
  22348. });
  22349. }
  22350. );
  22351. function processIf(node, dir, context, processCodegen) {
  22352. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  22353. const loc = dir.exp ? dir.exp.loc : node.loc;
  22354. context.onError(
  22355. createCompilerError(28, dir.loc)
  22356. );
  22357. dir.exp = createSimpleExpression(`true`, false, loc);
  22358. }
  22359. if (context.prefixIdentifiers && dir.exp) {
  22360. dir.exp = processExpression(dir.exp, context);
  22361. }
  22362. if (dir.name === "if") {
  22363. const branch = createIfBranch(node, dir);
  22364. const ifNode = {
  22365. type: 9,
  22366. loc: node.loc,
  22367. branches: [branch]
  22368. };
  22369. context.replaceNode(ifNode);
  22370. if (processCodegen) {
  22371. return processCodegen(ifNode, branch, true);
  22372. }
  22373. } else {
  22374. const siblings = context.parent.children;
  22375. const comments = [];
  22376. let i = siblings.indexOf(node);
  22377. while (i-- >= -1) {
  22378. const sibling = siblings[i];
  22379. if (sibling && sibling.type === 3) {
  22380. context.removeNode(sibling);
  22381. comments.unshift(sibling);
  22382. continue;
  22383. }
  22384. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  22385. context.removeNode(sibling);
  22386. continue;
  22387. }
  22388. if (sibling && sibling.type === 9) {
  22389. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  22390. context.onError(
  22391. createCompilerError(30, node.loc)
  22392. );
  22393. }
  22394. context.removeNode();
  22395. const branch = createIfBranch(node, dir);
  22396. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  22397. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  22398. branch.children = [...comments, ...branch.children];
  22399. }
  22400. {
  22401. const key = branch.userKey;
  22402. if (key) {
  22403. sibling.branches.forEach(({ userKey }) => {
  22404. if (isSameKey(userKey, key)) {
  22405. context.onError(
  22406. createCompilerError(
  22407. 29,
  22408. branch.userKey.loc
  22409. )
  22410. );
  22411. }
  22412. });
  22413. }
  22414. }
  22415. sibling.branches.push(branch);
  22416. const onExit = processCodegen && processCodegen(sibling, branch, false);
  22417. traverseNode(branch, context);
  22418. if (onExit) onExit();
  22419. context.currentNode = null;
  22420. } else {
  22421. context.onError(
  22422. createCompilerError(30, node.loc)
  22423. );
  22424. }
  22425. break;
  22426. }
  22427. }
  22428. }
  22429. function createIfBranch(node, dir) {
  22430. const isTemplateIf = node.tagType === 3;
  22431. return {
  22432. type: 10,
  22433. loc: node.loc,
  22434. condition: dir.name === "else" ? void 0 : dir.exp,
  22435. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  22436. userKey: findProp(node, `key`),
  22437. isTemplateIf
  22438. };
  22439. }
  22440. function createCodegenNodeForBranch(branch, keyIndex, context) {
  22441. if (branch.condition) {
  22442. return createConditionalExpression(
  22443. branch.condition,
  22444. createChildrenCodegenNode(branch, keyIndex, context),
  22445. // make sure to pass in asBlock: true so that the comment node call
  22446. // closes the current block.
  22447. createCallExpression(context.helper(CREATE_COMMENT), [
  22448. '"v-if"' ,
  22449. "true"
  22450. ])
  22451. );
  22452. } else {
  22453. return createChildrenCodegenNode(branch, keyIndex, context);
  22454. }
  22455. }
  22456. function createChildrenCodegenNode(branch, keyIndex, context) {
  22457. const { helper } = context;
  22458. const keyProperty = createObjectProperty(
  22459. `key`,
  22460. createSimpleExpression(
  22461. `${keyIndex}`,
  22462. false,
  22463. locStub,
  22464. 2
  22465. )
  22466. );
  22467. const { children } = branch;
  22468. const firstChild = children[0];
  22469. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  22470. if (needFragmentWrapper) {
  22471. if (children.length === 1 && firstChild.type === 11) {
  22472. const vnodeCall = firstChild.codegenNode;
  22473. injectProp(vnodeCall, keyProperty, context);
  22474. return vnodeCall;
  22475. } else {
  22476. let patchFlag = 64;
  22477. let patchFlagText = PatchFlagNames[64];
  22478. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  22479. patchFlag |= 2048;
  22480. patchFlagText += `, ${PatchFlagNames[2048]}`;
  22481. }
  22482. return createVNodeCall(
  22483. context,
  22484. helper(FRAGMENT),
  22485. createObjectExpression([keyProperty]),
  22486. children,
  22487. patchFlag,
  22488. void 0,
  22489. void 0,
  22490. true,
  22491. false,
  22492. false,
  22493. branch.loc
  22494. );
  22495. }
  22496. } else {
  22497. const ret = firstChild.codegenNode;
  22498. const vnodeCall = getMemoedVNodeCall(ret);
  22499. if (vnodeCall.type === 13) {
  22500. convertToBlock(vnodeCall, context);
  22501. }
  22502. injectProp(vnodeCall, keyProperty, context);
  22503. return ret;
  22504. }
  22505. }
  22506. function isSameKey(a, b) {
  22507. if (!a || a.type !== b.type) {
  22508. return false;
  22509. }
  22510. if (a.type === 6) {
  22511. if (a.value.content !== b.value.content) {
  22512. return false;
  22513. }
  22514. } else {
  22515. const exp = a.exp;
  22516. const branchExp = b.exp;
  22517. if (exp.type !== branchExp.type) {
  22518. return false;
  22519. }
  22520. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  22521. return false;
  22522. }
  22523. }
  22524. return true;
  22525. }
  22526. function getParentCondition(node) {
  22527. while (true) {
  22528. if (node.type === 19) {
  22529. if (node.alternate.type === 19) {
  22530. node = node.alternate;
  22531. } else {
  22532. return node;
  22533. }
  22534. } else if (node.type === 20) {
  22535. node = node.value;
  22536. }
  22537. }
  22538. }
  22539. const transformBind = (dir, _node, context) => {
  22540. const { modifiers, loc } = dir;
  22541. const arg = dir.arg;
  22542. let { exp } = dir;
  22543. if (exp && exp.type === 4 && !exp.content.trim()) {
  22544. {
  22545. context.onError(
  22546. createCompilerError(34, loc)
  22547. );
  22548. return {
  22549. props: [
  22550. createObjectProperty(arg, createSimpleExpression("", true, loc))
  22551. ]
  22552. };
  22553. }
  22554. }
  22555. if (!exp) {
  22556. if (arg.type !== 4 || !arg.isStatic) {
  22557. context.onError(
  22558. createCompilerError(
  22559. 52,
  22560. arg.loc
  22561. )
  22562. );
  22563. return {
  22564. props: [
  22565. createObjectProperty(arg, createSimpleExpression("", true, loc))
  22566. ]
  22567. };
  22568. }
  22569. transformBindShorthand(dir, context);
  22570. exp = dir.exp;
  22571. }
  22572. if (arg.type !== 4) {
  22573. arg.children.unshift(`(`);
  22574. arg.children.push(`) || ""`);
  22575. } else if (!arg.isStatic) {
  22576. arg.content = `${arg.content} || ""`;
  22577. }
  22578. if (modifiers.includes("camel")) {
  22579. if (arg.type === 4) {
  22580. if (arg.isStatic) {
  22581. arg.content = camelize(arg.content);
  22582. } else {
  22583. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  22584. }
  22585. } else {
  22586. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  22587. arg.children.push(`)`);
  22588. }
  22589. }
  22590. if (!context.inSSR) {
  22591. if (modifiers.includes("prop")) {
  22592. injectPrefix(arg, ".");
  22593. }
  22594. if (modifiers.includes("attr")) {
  22595. injectPrefix(arg, "^");
  22596. }
  22597. }
  22598. return {
  22599. props: [createObjectProperty(arg, exp)]
  22600. };
  22601. };
  22602. const transformBindShorthand = (dir, context) => {
  22603. const arg = dir.arg;
  22604. const propName = camelize(arg.content);
  22605. dir.exp = createSimpleExpression(propName, false, arg.loc);
  22606. {
  22607. dir.exp = processExpression(dir.exp, context);
  22608. }
  22609. };
  22610. const injectPrefix = (arg, prefix) => {
  22611. if (arg.type === 4) {
  22612. if (arg.isStatic) {
  22613. arg.content = prefix + arg.content;
  22614. } else {
  22615. arg.content = `\`${prefix}\${${arg.content}}\``;
  22616. }
  22617. } else {
  22618. arg.children.unshift(`'${prefix}' + (`);
  22619. arg.children.push(`)`);
  22620. }
  22621. };
  22622. const transformFor = createStructuralDirectiveTransform(
  22623. "for",
  22624. (node, dir, context) => {
  22625. const { helper, removeHelper } = context;
  22626. return processFor(node, dir, context, (forNode) => {
  22627. const renderExp = createCallExpression(helper(RENDER_LIST), [
  22628. forNode.source
  22629. ]);
  22630. const isTemplate = isTemplateNode(node);
  22631. const memo = findDir(node, "memo");
  22632. const keyProp = findProp(node, `key`, false, true);
  22633. if (keyProp && keyProp.type === 7 && !keyProp.exp) {
  22634. transformBindShorthand(keyProp, context);
  22635. }
  22636. const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
  22637. const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
  22638. if (isTemplate) {
  22639. if (memo) {
  22640. memo.exp = processExpression(
  22641. memo.exp,
  22642. context
  22643. );
  22644. }
  22645. if (keyProperty && keyProp.type !== 6) {
  22646. keyProperty.value = processExpression(
  22647. keyProperty.value,
  22648. context
  22649. );
  22650. }
  22651. }
  22652. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  22653. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  22654. forNode.codegenNode = createVNodeCall(
  22655. context,
  22656. helper(FRAGMENT),
  22657. void 0,
  22658. renderExp,
  22659. fragmentFlag,
  22660. void 0,
  22661. void 0,
  22662. true,
  22663. !isStableFragment,
  22664. false,
  22665. node.loc
  22666. );
  22667. return () => {
  22668. let childBlock;
  22669. const { children } = forNode;
  22670. if (isTemplate) {
  22671. node.children.some((c) => {
  22672. if (c.type === 1) {
  22673. const key = findProp(c, "key");
  22674. if (key) {
  22675. context.onError(
  22676. createCompilerError(
  22677. 33,
  22678. key.loc
  22679. )
  22680. );
  22681. return true;
  22682. }
  22683. }
  22684. });
  22685. }
  22686. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  22687. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  22688. if (slotOutlet) {
  22689. childBlock = slotOutlet.codegenNode;
  22690. if (isTemplate && keyProperty) {
  22691. injectProp(childBlock, keyProperty, context);
  22692. }
  22693. } else if (needFragmentWrapper) {
  22694. childBlock = createVNodeCall(
  22695. context,
  22696. helper(FRAGMENT),
  22697. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  22698. node.children,
  22699. 64,
  22700. void 0,
  22701. void 0,
  22702. true,
  22703. void 0,
  22704. false
  22705. );
  22706. } else {
  22707. childBlock = children[0].codegenNode;
  22708. if (isTemplate && keyProperty) {
  22709. injectProp(childBlock, keyProperty, context);
  22710. }
  22711. if (childBlock.isBlock !== !isStableFragment) {
  22712. if (childBlock.isBlock) {
  22713. removeHelper(OPEN_BLOCK);
  22714. removeHelper(
  22715. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  22716. );
  22717. } else {
  22718. removeHelper(
  22719. getVNodeHelper(context.inSSR, childBlock.isComponent)
  22720. );
  22721. }
  22722. }
  22723. childBlock.isBlock = !isStableFragment;
  22724. if (childBlock.isBlock) {
  22725. helper(OPEN_BLOCK);
  22726. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  22727. } else {
  22728. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  22729. }
  22730. }
  22731. if (memo) {
  22732. const loop = createFunctionExpression(
  22733. createForLoopParams(forNode.parseResult, [
  22734. createSimpleExpression(`_cached`)
  22735. ])
  22736. );
  22737. loop.body = createBlockStatement([
  22738. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  22739. createCompoundExpression([
  22740. `if (_cached`,
  22741. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  22742. ` && ${context.helperString(
  22743. IS_MEMO_SAME
  22744. )}(_cached, _memo)) return _cached`
  22745. ]),
  22746. createCompoundExpression([`const _item = `, childBlock]),
  22747. createSimpleExpression(`_item.memo = _memo`),
  22748. createSimpleExpression(`return _item`)
  22749. ]);
  22750. renderExp.arguments.push(
  22751. loop,
  22752. createSimpleExpression(`_cache`),
  22753. createSimpleExpression(String(context.cached++))
  22754. );
  22755. } else {
  22756. renderExp.arguments.push(
  22757. createFunctionExpression(
  22758. createForLoopParams(forNode.parseResult),
  22759. childBlock,
  22760. true
  22761. )
  22762. );
  22763. }
  22764. };
  22765. });
  22766. }
  22767. );
  22768. function processFor(node, dir, context, processCodegen) {
  22769. if (!dir.exp) {
  22770. context.onError(
  22771. createCompilerError(31, dir.loc)
  22772. );
  22773. return;
  22774. }
  22775. const parseResult = dir.forParseResult;
  22776. if (!parseResult) {
  22777. context.onError(
  22778. createCompilerError(32, dir.loc)
  22779. );
  22780. return;
  22781. }
  22782. finalizeForParseResult(parseResult, context);
  22783. const { addIdentifiers, removeIdentifiers, scopes } = context;
  22784. const { source, value, key, index } = parseResult;
  22785. const forNode = {
  22786. type: 11,
  22787. loc: dir.loc,
  22788. source,
  22789. valueAlias: value,
  22790. keyAlias: key,
  22791. objectIndexAlias: index,
  22792. parseResult,
  22793. children: isTemplateNode(node) ? node.children : [node]
  22794. };
  22795. context.replaceNode(forNode);
  22796. scopes.vFor++;
  22797. if (context.prefixIdentifiers) {
  22798. value && addIdentifiers(value);
  22799. key && addIdentifiers(key);
  22800. index && addIdentifiers(index);
  22801. }
  22802. const onExit = processCodegen && processCodegen(forNode);
  22803. return () => {
  22804. scopes.vFor--;
  22805. if (context.prefixIdentifiers) {
  22806. value && removeIdentifiers(value);
  22807. key && removeIdentifiers(key);
  22808. index && removeIdentifiers(index);
  22809. }
  22810. if (onExit) onExit();
  22811. };
  22812. }
  22813. function finalizeForParseResult(result, context) {
  22814. if (result.finalized) return;
  22815. if (context.prefixIdentifiers) {
  22816. result.source = processExpression(
  22817. result.source,
  22818. context
  22819. );
  22820. if (result.key) {
  22821. result.key = processExpression(
  22822. result.key,
  22823. context,
  22824. true
  22825. );
  22826. }
  22827. if (result.index) {
  22828. result.index = processExpression(
  22829. result.index,
  22830. context,
  22831. true
  22832. );
  22833. }
  22834. if (result.value) {
  22835. result.value = processExpression(
  22836. result.value,
  22837. context,
  22838. true
  22839. );
  22840. }
  22841. }
  22842. result.finalized = true;
  22843. }
  22844. function createForLoopParams({ value, key, index }, memoArgs = []) {
  22845. return createParamsList([value, key, index, ...memoArgs]);
  22846. }
  22847. function createParamsList(args) {
  22848. let i = args.length;
  22849. while (i--) {
  22850. if (args[i]) break;
  22851. }
  22852. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  22853. }
  22854. const defaultFallback = createSimpleExpression(`undefined`, false);
  22855. const trackSlotScopes = (node, context) => {
  22856. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  22857. const vSlot = findDir(node, "slot");
  22858. if (vSlot) {
  22859. const slotProps = vSlot.exp;
  22860. if (context.prefixIdentifiers) {
  22861. slotProps && context.addIdentifiers(slotProps);
  22862. }
  22863. context.scopes.vSlot++;
  22864. return () => {
  22865. if (context.prefixIdentifiers) {
  22866. slotProps && context.removeIdentifiers(slotProps);
  22867. }
  22868. context.scopes.vSlot--;
  22869. };
  22870. }
  22871. }
  22872. };
  22873. const trackVForSlotScopes = (node, context) => {
  22874. let vFor;
  22875. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  22876. const result = vFor.forParseResult;
  22877. if (result) {
  22878. finalizeForParseResult(result, context);
  22879. const { value, key, index } = result;
  22880. const { addIdentifiers, removeIdentifiers } = context;
  22881. value && addIdentifiers(value);
  22882. key && addIdentifiers(key);
  22883. index && addIdentifiers(index);
  22884. return () => {
  22885. value && removeIdentifiers(value);
  22886. key && removeIdentifiers(key);
  22887. index && removeIdentifiers(index);
  22888. };
  22889. }
  22890. }
  22891. };
  22892. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  22893. props,
  22894. children,
  22895. false,
  22896. true,
  22897. children.length ? children[0].loc : loc
  22898. );
  22899. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  22900. context.helper(WITH_CTX);
  22901. const { children, loc } = node;
  22902. const slotsProperties = [];
  22903. const dynamicSlots = [];
  22904. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  22905. if (!context.ssr && context.prefixIdentifiers) {
  22906. hasDynamicSlots = hasScopeRef(node, context.identifiers);
  22907. }
  22908. const onComponentSlot = findDir(node, "slot", true);
  22909. if (onComponentSlot) {
  22910. const { arg, exp } = onComponentSlot;
  22911. if (arg && !isStaticExp(arg)) {
  22912. hasDynamicSlots = true;
  22913. }
  22914. slotsProperties.push(
  22915. createObjectProperty(
  22916. arg || createSimpleExpression("default", true),
  22917. buildSlotFn(exp, void 0, children, loc)
  22918. )
  22919. );
  22920. }
  22921. let hasTemplateSlots = false;
  22922. let hasNamedDefaultSlot = false;
  22923. const implicitDefaultChildren = [];
  22924. const seenSlotNames = /* @__PURE__ */ new Set();
  22925. let conditionalBranchIndex = 0;
  22926. for (let i = 0; i < children.length; i++) {
  22927. const slotElement = children[i];
  22928. let slotDir;
  22929. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  22930. if (slotElement.type !== 3) {
  22931. implicitDefaultChildren.push(slotElement);
  22932. }
  22933. continue;
  22934. }
  22935. if (onComponentSlot) {
  22936. context.onError(
  22937. createCompilerError(37, slotDir.loc)
  22938. );
  22939. break;
  22940. }
  22941. hasTemplateSlots = true;
  22942. const { children: slotChildren, loc: slotLoc } = slotElement;
  22943. const {
  22944. arg: slotName = createSimpleExpression(`default`, true),
  22945. exp: slotProps,
  22946. loc: dirLoc
  22947. } = slotDir;
  22948. let staticSlotName;
  22949. if (isStaticExp(slotName)) {
  22950. staticSlotName = slotName ? slotName.content : `default`;
  22951. } else {
  22952. hasDynamicSlots = true;
  22953. }
  22954. const vFor = findDir(slotElement, "for");
  22955. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  22956. let vIf;
  22957. let vElse;
  22958. if (vIf = findDir(slotElement, "if")) {
  22959. hasDynamicSlots = true;
  22960. dynamicSlots.push(
  22961. createConditionalExpression(
  22962. vIf.exp,
  22963. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  22964. defaultFallback
  22965. )
  22966. );
  22967. } else if (vElse = findDir(
  22968. slotElement,
  22969. /^else(-if)?$/,
  22970. true
  22971. /* allowEmpty */
  22972. )) {
  22973. let j = i;
  22974. let prev;
  22975. while (j--) {
  22976. prev = children[j];
  22977. if (prev.type !== 3) {
  22978. break;
  22979. }
  22980. }
  22981. if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
  22982. let conditional = dynamicSlots[dynamicSlots.length - 1];
  22983. while (conditional.alternate.type === 19) {
  22984. conditional = conditional.alternate;
  22985. }
  22986. conditional.alternate = vElse.exp ? createConditionalExpression(
  22987. vElse.exp,
  22988. buildDynamicSlot(
  22989. slotName,
  22990. slotFunction,
  22991. conditionalBranchIndex++
  22992. ),
  22993. defaultFallback
  22994. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  22995. } else {
  22996. context.onError(
  22997. createCompilerError(30, vElse.loc)
  22998. );
  22999. }
  23000. } else if (vFor) {
  23001. hasDynamicSlots = true;
  23002. const parseResult = vFor.forParseResult;
  23003. if (parseResult) {
  23004. finalizeForParseResult(parseResult, context);
  23005. dynamicSlots.push(
  23006. createCallExpression(context.helper(RENDER_LIST), [
  23007. parseResult.source,
  23008. createFunctionExpression(
  23009. createForLoopParams(parseResult),
  23010. buildDynamicSlot(slotName, slotFunction),
  23011. true
  23012. )
  23013. ])
  23014. );
  23015. } else {
  23016. context.onError(
  23017. createCompilerError(
  23018. 32,
  23019. vFor.loc
  23020. )
  23021. );
  23022. }
  23023. } else {
  23024. if (staticSlotName) {
  23025. if (seenSlotNames.has(staticSlotName)) {
  23026. context.onError(
  23027. createCompilerError(
  23028. 38,
  23029. dirLoc
  23030. )
  23031. );
  23032. continue;
  23033. }
  23034. seenSlotNames.add(staticSlotName);
  23035. if (staticSlotName === "default") {
  23036. hasNamedDefaultSlot = true;
  23037. }
  23038. }
  23039. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  23040. }
  23041. }
  23042. if (!onComponentSlot) {
  23043. const buildDefaultSlotProperty = (props, children2) => {
  23044. const fn = buildSlotFn(props, void 0, children2, loc);
  23045. return createObjectProperty(`default`, fn);
  23046. };
  23047. if (!hasTemplateSlots) {
  23048. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  23049. } else if (implicitDefaultChildren.length && // #3766
  23050. // with whitespace: 'preserve', whitespaces between slots will end up in
  23051. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  23052. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  23053. if (hasNamedDefaultSlot) {
  23054. context.onError(
  23055. createCompilerError(
  23056. 39,
  23057. implicitDefaultChildren[0].loc
  23058. )
  23059. );
  23060. } else {
  23061. slotsProperties.push(
  23062. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  23063. );
  23064. }
  23065. }
  23066. }
  23067. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  23068. let slots = createObjectExpression(
  23069. slotsProperties.concat(
  23070. createObjectProperty(
  23071. `_`,
  23072. // 2 = compiled but dynamic = can skip normalization, but must run diff
  23073. // 1 = compiled and static = can skip normalization AND diff as optimized
  23074. createSimpleExpression(
  23075. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  23076. false
  23077. )
  23078. )
  23079. ),
  23080. loc
  23081. );
  23082. if (dynamicSlots.length) {
  23083. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  23084. slots,
  23085. createArrayExpression(dynamicSlots)
  23086. ]);
  23087. }
  23088. return {
  23089. slots,
  23090. hasDynamicSlots
  23091. };
  23092. }
  23093. function buildDynamicSlot(name, fn, index) {
  23094. const props = [
  23095. createObjectProperty(`name`, name),
  23096. createObjectProperty(`fn`, fn)
  23097. ];
  23098. if (index != null) {
  23099. props.push(
  23100. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  23101. );
  23102. }
  23103. return createObjectExpression(props);
  23104. }
  23105. function hasForwardedSlots(children) {
  23106. for (let i = 0; i < children.length; i++) {
  23107. const child = children[i];
  23108. switch (child.type) {
  23109. case 1:
  23110. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  23111. return true;
  23112. }
  23113. break;
  23114. case 9:
  23115. if (hasForwardedSlots(child.branches)) return true;
  23116. break;
  23117. case 10:
  23118. case 11:
  23119. if (hasForwardedSlots(child.children)) return true;
  23120. break;
  23121. }
  23122. }
  23123. return false;
  23124. }
  23125. function isNonWhitespaceContent(node) {
  23126. if (node.type !== 2 && node.type !== 12)
  23127. return true;
  23128. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  23129. }
  23130. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  23131. const transformElement = (node, context) => {
  23132. return function postTransformElement() {
  23133. node = context.currentNode;
  23134. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  23135. return;
  23136. }
  23137. const { tag, props } = node;
  23138. const isComponent = node.tagType === 1;
  23139. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  23140. const isDynamicComponent = isObject$2(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  23141. let vnodeProps;
  23142. let vnodeChildren;
  23143. let patchFlag = 0;
  23144. let vnodeDynamicProps;
  23145. let dynamicPropNames;
  23146. let vnodeDirectives;
  23147. let shouldUseBlock = (
  23148. // dynamic component may resolve to plain elements
  23149. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  23150. // updates inside get proper isSVG flag at runtime. (#639, #643)
  23151. // This is technically web-specific, but splitting the logic out of core
  23152. // leads to too much unnecessary complexity.
  23153. (tag === "svg" || tag === "foreignObject" || tag === "math")
  23154. );
  23155. if (props.length > 0) {
  23156. const propsBuildResult = buildProps(
  23157. node,
  23158. context,
  23159. void 0,
  23160. isComponent,
  23161. isDynamicComponent
  23162. );
  23163. vnodeProps = propsBuildResult.props;
  23164. patchFlag = propsBuildResult.patchFlag;
  23165. dynamicPropNames = propsBuildResult.dynamicPropNames;
  23166. const directives = propsBuildResult.directives;
  23167. vnodeDirectives = directives && directives.length ? createArrayExpression(
  23168. directives.map((dir) => buildDirectiveArgs(dir, context))
  23169. ) : void 0;
  23170. if (propsBuildResult.shouldUseBlock) {
  23171. shouldUseBlock = true;
  23172. }
  23173. }
  23174. if (node.children.length > 0) {
  23175. if (vnodeTag === KEEP_ALIVE) {
  23176. shouldUseBlock = true;
  23177. patchFlag |= 1024;
  23178. if (node.children.length > 1) {
  23179. context.onError(
  23180. createCompilerError(46, {
  23181. start: node.children[0].loc.start,
  23182. end: node.children[node.children.length - 1].loc.end,
  23183. source: ""
  23184. })
  23185. );
  23186. }
  23187. }
  23188. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  23189. vnodeTag !== TELEPORT && // explained above.
  23190. vnodeTag !== KEEP_ALIVE;
  23191. if (shouldBuildAsSlots) {
  23192. const { slots, hasDynamicSlots } = buildSlots(node, context);
  23193. vnodeChildren = slots;
  23194. if (hasDynamicSlots) {
  23195. patchFlag |= 1024;
  23196. }
  23197. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  23198. const child = node.children[0];
  23199. const type = child.type;
  23200. const hasDynamicTextChild = type === 5 || type === 8;
  23201. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  23202. patchFlag |= 1;
  23203. }
  23204. if (hasDynamicTextChild || type === 2) {
  23205. vnodeChildren = child;
  23206. } else {
  23207. vnodeChildren = node.children;
  23208. }
  23209. } else {
  23210. vnodeChildren = node.children;
  23211. }
  23212. }
  23213. if (dynamicPropNames && dynamicPropNames.length) {
  23214. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  23215. }
  23216. node.codegenNode = createVNodeCall(
  23217. context,
  23218. vnodeTag,
  23219. vnodeProps,
  23220. vnodeChildren,
  23221. patchFlag === 0 ? void 0 : patchFlag,
  23222. vnodeDynamicProps,
  23223. vnodeDirectives,
  23224. !!shouldUseBlock,
  23225. false,
  23226. isComponent,
  23227. node.loc
  23228. );
  23229. };
  23230. };
  23231. function resolveComponentType(node, context, ssr = false) {
  23232. let { tag } = node;
  23233. const isExplicitDynamic = isComponentTag(tag);
  23234. const isProp = findProp(
  23235. node,
  23236. "is",
  23237. false,
  23238. true
  23239. /* allow empty */
  23240. );
  23241. if (isProp) {
  23242. if (isExplicitDynamic || false) {
  23243. let exp;
  23244. if (isProp.type === 6) {
  23245. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  23246. } else {
  23247. exp = isProp.exp;
  23248. if (!exp) {
  23249. exp = createSimpleExpression(`is`, false, isProp.arg.loc);
  23250. {
  23251. exp = isProp.exp = processExpression(exp, context);
  23252. }
  23253. }
  23254. }
  23255. if (exp) {
  23256. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  23257. exp
  23258. ]);
  23259. }
  23260. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  23261. tag = isProp.value.content.slice(4);
  23262. }
  23263. }
  23264. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  23265. if (builtIn) {
  23266. if (!ssr) context.helper(builtIn);
  23267. return builtIn;
  23268. }
  23269. {
  23270. const fromSetup = resolveSetupReference(tag, context);
  23271. if (fromSetup) {
  23272. return fromSetup;
  23273. }
  23274. const dotIndex = tag.indexOf(".");
  23275. if (dotIndex > 0) {
  23276. const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
  23277. if (ns) {
  23278. return ns + tag.slice(dotIndex);
  23279. }
  23280. }
  23281. }
  23282. if (context.selfName && capitalize$1(camelize(tag)) === context.selfName) {
  23283. context.helper(RESOLVE_COMPONENT);
  23284. context.components.add(tag + `__self`);
  23285. return toValidAssetId(tag, `component`);
  23286. }
  23287. context.helper(RESOLVE_COMPONENT);
  23288. context.components.add(tag);
  23289. return toValidAssetId(tag, `component`);
  23290. }
  23291. function resolveSetupReference(name, context) {
  23292. const bindings = context.bindingMetadata;
  23293. if (!bindings || bindings.__isScriptSetup === false) {
  23294. return;
  23295. }
  23296. const camelName = camelize(name);
  23297. const PascalName = capitalize$1(camelName);
  23298. const checkType = (type) => {
  23299. if (bindings[name] === type) {
  23300. return name;
  23301. }
  23302. if (bindings[camelName] === type) {
  23303. return camelName;
  23304. }
  23305. if (bindings[PascalName] === type) {
  23306. return PascalName;
  23307. }
  23308. };
  23309. const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
  23310. if (fromConst) {
  23311. return context.inline ? (
  23312. // in inline mode, const setup bindings (e.g. imports) can be used as-is
  23313. fromConst
  23314. ) : `$setup[${JSON.stringify(fromConst)}]`;
  23315. }
  23316. const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
  23317. if (fromMaybeRef) {
  23318. return context.inline ? (
  23319. // setup scope bindings that may be refs need to be unrefed
  23320. `${context.helperString(UNREF)}(${fromMaybeRef})`
  23321. ) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
  23322. }
  23323. const fromProps = checkType("props");
  23324. if (fromProps) {
  23325. return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
  23326. }
  23327. }
  23328. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  23329. const { tag, loc: elementLoc, children } = node;
  23330. let properties = [];
  23331. const mergeArgs = [];
  23332. const runtimeDirectives = [];
  23333. const hasChildren = children.length > 0;
  23334. let shouldUseBlock = false;
  23335. let patchFlag = 0;
  23336. let hasRef = false;
  23337. let hasClassBinding = false;
  23338. let hasStyleBinding = false;
  23339. let hasHydrationEventBinding = false;
  23340. let hasDynamicKeys = false;
  23341. let hasVnodeHook = false;
  23342. const dynamicPropNames = [];
  23343. const pushMergeArg = (arg) => {
  23344. if (properties.length) {
  23345. mergeArgs.push(
  23346. createObjectExpression(dedupeProperties(properties), elementLoc)
  23347. );
  23348. properties = [];
  23349. }
  23350. if (arg) mergeArgs.push(arg);
  23351. };
  23352. const pushRefVForMarker = () => {
  23353. if (context.scopes.vFor > 0) {
  23354. properties.push(
  23355. createObjectProperty(
  23356. createSimpleExpression("ref_for", true),
  23357. createSimpleExpression("true")
  23358. )
  23359. );
  23360. }
  23361. };
  23362. const analyzePatchFlag = ({ key, value }) => {
  23363. if (isStaticExp(key)) {
  23364. const name = key.content;
  23365. const isEventHandler = isOn(name);
  23366. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  23367. // dedicated fast path.
  23368. name.toLowerCase() !== "onclick" && // omit v-model handlers
  23369. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  23370. !isReservedProp(name)) {
  23371. hasHydrationEventBinding = true;
  23372. }
  23373. if (isEventHandler && isReservedProp(name)) {
  23374. hasVnodeHook = true;
  23375. }
  23376. if (isEventHandler && value.type === 14) {
  23377. value = value.arguments[0];
  23378. }
  23379. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  23380. return;
  23381. }
  23382. if (name === "ref") {
  23383. hasRef = true;
  23384. } else if (name === "class") {
  23385. hasClassBinding = true;
  23386. } else if (name === "style") {
  23387. hasStyleBinding = true;
  23388. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  23389. dynamicPropNames.push(name);
  23390. }
  23391. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  23392. dynamicPropNames.push(name);
  23393. }
  23394. } else {
  23395. hasDynamicKeys = true;
  23396. }
  23397. };
  23398. for (let i = 0; i < props.length; i++) {
  23399. const prop = props[i];
  23400. if (prop.type === 6) {
  23401. const { loc, name, nameLoc, value } = prop;
  23402. let isStatic = true;
  23403. if (name === "ref") {
  23404. hasRef = true;
  23405. pushRefVForMarker();
  23406. if (value && context.inline) {
  23407. const binding = context.bindingMetadata[value.content];
  23408. if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
  23409. isStatic = false;
  23410. properties.push(
  23411. createObjectProperty(
  23412. createSimpleExpression("ref_key", true),
  23413. createSimpleExpression(value.content, true, value.loc)
  23414. )
  23415. );
  23416. }
  23417. }
  23418. }
  23419. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  23420. continue;
  23421. }
  23422. properties.push(
  23423. createObjectProperty(
  23424. createSimpleExpression(name, true, nameLoc),
  23425. createSimpleExpression(
  23426. value ? value.content : "",
  23427. isStatic,
  23428. value ? value.loc : loc
  23429. )
  23430. )
  23431. );
  23432. } else {
  23433. const { name, arg, exp, loc, modifiers } = prop;
  23434. const isVBind = name === "bind";
  23435. const isVOn = name === "on";
  23436. if (name === "slot") {
  23437. if (!isComponent) {
  23438. context.onError(
  23439. createCompilerError(40, loc)
  23440. );
  23441. }
  23442. continue;
  23443. }
  23444. if (name === "once" || name === "memo") {
  23445. continue;
  23446. }
  23447. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  23448. continue;
  23449. }
  23450. if (isVOn && ssr) {
  23451. continue;
  23452. }
  23453. if (
  23454. // #938: elements with dynamic keys should be forced into blocks
  23455. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  23456. // before children
  23457. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  23458. ) {
  23459. shouldUseBlock = true;
  23460. }
  23461. if (isVBind && isStaticArgOf(arg, "ref")) {
  23462. pushRefVForMarker();
  23463. }
  23464. if (!arg && (isVBind || isVOn)) {
  23465. hasDynamicKeys = true;
  23466. if (exp) {
  23467. if (isVBind) {
  23468. pushRefVForMarker();
  23469. pushMergeArg();
  23470. mergeArgs.push(exp);
  23471. } else {
  23472. pushMergeArg({
  23473. type: 14,
  23474. loc,
  23475. callee: context.helper(TO_HANDLERS),
  23476. arguments: isComponent ? [exp] : [exp, `true`]
  23477. });
  23478. }
  23479. } else {
  23480. context.onError(
  23481. createCompilerError(
  23482. isVBind ? 34 : 35,
  23483. loc
  23484. )
  23485. );
  23486. }
  23487. continue;
  23488. }
  23489. if (isVBind && modifiers.includes("prop")) {
  23490. patchFlag |= 32;
  23491. }
  23492. const directiveTransform = context.directiveTransforms[name];
  23493. if (directiveTransform) {
  23494. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  23495. !ssr && props2.forEach(analyzePatchFlag);
  23496. if (isVOn && arg && !isStaticExp(arg)) {
  23497. pushMergeArg(createObjectExpression(props2, elementLoc));
  23498. } else {
  23499. properties.push(...props2);
  23500. }
  23501. if (needRuntime) {
  23502. runtimeDirectives.push(prop);
  23503. if (isSymbol$1(needRuntime)) {
  23504. directiveImportMap.set(prop, needRuntime);
  23505. }
  23506. }
  23507. } else if (!isBuiltInDirective(name)) {
  23508. runtimeDirectives.push(prop);
  23509. if (hasChildren) {
  23510. shouldUseBlock = true;
  23511. }
  23512. }
  23513. }
  23514. }
  23515. let propsExpression = void 0;
  23516. if (mergeArgs.length) {
  23517. pushMergeArg();
  23518. if (mergeArgs.length > 1) {
  23519. propsExpression = createCallExpression(
  23520. context.helper(MERGE_PROPS),
  23521. mergeArgs,
  23522. elementLoc
  23523. );
  23524. } else {
  23525. propsExpression = mergeArgs[0];
  23526. }
  23527. } else if (properties.length) {
  23528. propsExpression = createObjectExpression(
  23529. dedupeProperties(properties),
  23530. elementLoc
  23531. );
  23532. }
  23533. if (hasDynamicKeys) {
  23534. patchFlag |= 16;
  23535. } else {
  23536. if (hasClassBinding && !isComponent) {
  23537. patchFlag |= 2;
  23538. }
  23539. if (hasStyleBinding && !isComponent) {
  23540. patchFlag |= 4;
  23541. }
  23542. if (dynamicPropNames.length) {
  23543. patchFlag |= 8;
  23544. }
  23545. if (hasHydrationEventBinding) {
  23546. patchFlag |= 32;
  23547. }
  23548. }
  23549. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  23550. patchFlag |= 512;
  23551. }
  23552. if (!context.inSSR && propsExpression) {
  23553. switch (propsExpression.type) {
  23554. case 15:
  23555. let classKeyIndex = -1;
  23556. let styleKeyIndex = -1;
  23557. let hasDynamicKey = false;
  23558. for (let i = 0; i < propsExpression.properties.length; i++) {
  23559. const key = propsExpression.properties[i].key;
  23560. if (isStaticExp(key)) {
  23561. if (key.content === "class") {
  23562. classKeyIndex = i;
  23563. } else if (key.content === "style") {
  23564. styleKeyIndex = i;
  23565. }
  23566. } else if (!key.isHandlerKey) {
  23567. hasDynamicKey = true;
  23568. }
  23569. }
  23570. const classProp = propsExpression.properties[classKeyIndex];
  23571. const styleProp = propsExpression.properties[styleKeyIndex];
  23572. if (!hasDynamicKey) {
  23573. if (classProp && !isStaticExp(classProp.value)) {
  23574. classProp.value = createCallExpression(
  23575. context.helper(NORMALIZE_CLASS),
  23576. [classProp.value]
  23577. );
  23578. }
  23579. if (styleProp && // the static style is compiled into an object,
  23580. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  23581. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  23582. // v-bind:style with static literal object
  23583. styleProp.value.type === 17)) {
  23584. styleProp.value = createCallExpression(
  23585. context.helper(NORMALIZE_STYLE),
  23586. [styleProp.value]
  23587. );
  23588. }
  23589. } else {
  23590. propsExpression = createCallExpression(
  23591. context.helper(NORMALIZE_PROPS),
  23592. [propsExpression]
  23593. );
  23594. }
  23595. break;
  23596. case 14:
  23597. break;
  23598. default:
  23599. propsExpression = createCallExpression(
  23600. context.helper(NORMALIZE_PROPS),
  23601. [
  23602. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  23603. propsExpression
  23604. ])
  23605. ]
  23606. );
  23607. break;
  23608. }
  23609. }
  23610. return {
  23611. props: propsExpression,
  23612. directives: runtimeDirectives,
  23613. patchFlag,
  23614. dynamicPropNames,
  23615. shouldUseBlock
  23616. };
  23617. }
  23618. function dedupeProperties(properties) {
  23619. const knownProps = /* @__PURE__ */ new Map();
  23620. const deduped = [];
  23621. for (let i = 0; i < properties.length; i++) {
  23622. const prop = properties[i];
  23623. if (prop.key.type === 8 || !prop.key.isStatic) {
  23624. deduped.push(prop);
  23625. continue;
  23626. }
  23627. const name = prop.key.content;
  23628. const existing = knownProps.get(name);
  23629. if (existing) {
  23630. if (name === "style" || name === "class" || isOn(name)) {
  23631. mergeAsArray(existing, prop);
  23632. }
  23633. } else {
  23634. knownProps.set(name, prop);
  23635. deduped.push(prop);
  23636. }
  23637. }
  23638. return deduped;
  23639. }
  23640. function mergeAsArray(existing, incoming) {
  23641. if (existing.value.type === 17) {
  23642. existing.value.elements.push(incoming.value);
  23643. } else {
  23644. existing.value = createArrayExpression(
  23645. [existing.value, incoming.value],
  23646. existing.loc
  23647. );
  23648. }
  23649. }
  23650. function buildDirectiveArgs(dir, context) {
  23651. const dirArgs = [];
  23652. const runtime = directiveImportMap.get(dir);
  23653. if (runtime) {
  23654. dirArgs.push(context.helperString(runtime));
  23655. } else {
  23656. const fromSetup = resolveSetupReference("v-" + dir.name, context);
  23657. if (fromSetup) {
  23658. dirArgs.push(fromSetup);
  23659. } else {
  23660. context.helper(RESOLVE_DIRECTIVE);
  23661. context.directives.add(dir.name);
  23662. dirArgs.push(toValidAssetId(dir.name, `directive`));
  23663. }
  23664. }
  23665. const { loc } = dir;
  23666. if (dir.exp) dirArgs.push(dir.exp);
  23667. if (dir.arg) {
  23668. if (!dir.exp) {
  23669. dirArgs.push(`void 0`);
  23670. }
  23671. dirArgs.push(dir.arg);
  23672. }
  23673. if (Object.keys(dir.modifiers).length) {
  23674. if (!dir.arg) {
  23675. if (!dir.exp) {
  23676. dirArgs.push(`void 0`);
  23677. }
  23678. dirArgs.push(`void 0`);
  23679. }
  23680. const trueExpression = createSimpleExpression(`true`, false, loc);
  23681. dirArgs.push(
  23682. createObjectExpression(
  23683. dir.modifiers.map(
  23684. (modifier) => createObjectProperty(modifier, trueExpression)
  23685. ),
  23686. loc
  23687. )
  23688. );
  23689. }
  23690. return createArrayExpression(dirArgs, dir.loc);
  23691. }
  23692. function stringifyDynamicPropNames(props) {
  23693. let propsNamesString = `[`;
  23694. for (let i = 0, l = props.length; i < l; i++) {
  23695. propsNamesString += JSON.stringify(props[i]);
  23696. if (i < l - 1) propsNamesString += ", ";
  23697. }
  23698. return propsNamesString + `]`;
  23699. }
  23700. function isComponentTag(tag) {
  23701. return tag === "component" || tag === "Component";
  23702. }
  23703. const transformSlotOutlet = (node, context) => {
  23704. if (isSlotOutlet(node)) {
  23705. const { children, loc } = node;
  23706. const { slotName, slotProps } = processSlotOutlet(node, context);
  23707. const slotArgs = [
  23708. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  23709. slotName,
  23710. "{}",
  23711. "undefined",
  23712. "true"
  23713. ];
  23714. let expectedLen = 2;
  23715. if (slotProps) {
  23716. slotArgs[2] = slotProps;
  23717. expectedLen = 3;
  23718. }
  23719. if (children.length) {
  23720. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  23721. expectedLen = 4;
  23722. }
  23723. if (context.scopeId && !context.slotted) {
  23724. expectedLen = 5;
  23725. }
  23726. slotArgs.splice(expectedLen);
  23727. node.codegenNode = createCallExpression(
  23728. context.helper(RENDER_SLOT),
  23729. slotArgs,
  23730. loc
  23731. );
  23732. }
  23733. };
  23734. function processSlotOutlet(node, context) {
  23735. let slotName = `"default"`;
  23736. let slotProps = void 0;
  23737. const nonNameProps = [];
  23738. for (let i = 0; i < node.props.length; i++) {
  23739. const p = node.props[i];
  23740. if (p.type === 6) {
  23741. if (p.value) {
  23742. if (p.name === "name") {
  23743. slotName = JSON.stringify(p.value.content);
  23744. } else {
  23745. p.name = camelize(p.name);
  23746. nonNameProps.push(p);
  23747. }
  23748. }
  23749. } else {
  23750. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  23751. if (p.exp) {
  23752. slotName = p.exp;
  23753. } else if (p.arg && p.arg.type === 4) {
  23754. const name = camelize(p.arg.content);
  23755. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  23756. {
  23757. slotName = p.exp = processExpression(p.exp, context);
  23758. }
  23759. }
  23760. } else {
  23761. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  23762. p.arg.content = camelize(p.arg.content);
  23763. }
  23764. nonNameProps.push(p);
  23765. }
  23766. }
  23767. }
  23768. if (nonNameProps.length > 0) {
  23769. const { props, directives } = buildProps(
  23770. node,
  23771. context,
  23772. nonNameProps,
  23773. false,
  23774. false
  23775. );
  23776. slotProps = props;
  23777. if (directives.length) {
  23778. context.onError(
  23779. createCompilerError(
  23780. 36,
  23781. directives[0].loc
  23782. )
  23783. );
  23784. }
  23785. }
  23786. return {
  23787. slotName,
  23788. slotProps
  23789. };
  23790. }
  23791. const transformOn$1 = (dir, node, context, augmentor) => {
  23792. const { loc, modifiers, arg } = dir;
  23793. if (!dir.exp && !modifiers.length) {
  23794. context.onError(createCompilerError(35, loc));
  23795. }
  23796. let eventName;
  23797. if (arg.type === 4) {
  23798. if (arg.isStatic) {
  23799. let rawName = arg.content;
  23800. if (rawName.startsWith("vnode")) {
  23801. context.onError(createCompilerError(51, arg.loc));
  23802. }
  23803. if (rawName.startsWith("vue:")) {
  23804. rawName = `vnode-${rawName.slice(4)}`;
  23805. }
  23806. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  23807. // for non-element and vnode lifecycle event listeners, auto convert
  23808. // it to camelCase. See issue #2249
  23809. toHandlerKey(camelize(rawName))
  23810. ) : (
  23811. // preserve case for plain element listeners that have uppercase
  23812. // letters, as these may be custom elements' custom events
  23813. `on:${rawName}`
  23814. );
  23815. eventName = createSimpleExpression(eventString, true, arg.loc);
  23816. } else {
  23817. eventName = createCompoundExpression([
  23818. `${context.helperString(TO_HANDLER_KEY)}(`,
  23819. arg,
  23820. `)`
  23821. ]);
  23822. }
  23823. } else {
  23824. eventName = arg;
  23825. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  23826. eventName.children.push(`)`);
  23827. }
  23828. let exp = dir.exp;
  23829. if (exp && !exp.content.trim()) {
  23830. exp = void 0;
  23831. }
  23832. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  23833. if (exp) {
  23834. const isMemberExp = isMemberExpression(exp, context);
  23835. const isInlineStatement = !(isMemberExp || isFnExpression(exp, context));
  23836. const hasMultipleStatements = exp.content.includes(`;`);
  23837. if (context.prefixIdentifiers) {
  23838. isInlineStatement && context.addIdentifiers(`$event`);
  23839. exp = dir.exp = processExpression(
  23840. exp,
  23841. context,
  23842. false,
  23843. hasMultipleStatements
  23844. );
  23845. isInlineStatement && context.removeIdentifiers(`$event`);
  23846. shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
  23847. !context.inVOnce && // runtime constants don't need to be cached
  23848. // (this is analyzed by compileScript in SFC <script setup>)
  23849. !(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
  23850. // we need to use the original function to preserve arity,
  23851. // e.g. <transition> relies on checking cb.length to determine
  23852. // transition end handling. Inline function is ok since its arity
  23853. // is preserved even when cached.
  23854. !(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
  23855. // it must be passed fresh to avoid stale values.
  23856. !hasScopeRef(exp, context.identifiers);
  23857. if (shouldCache && isMemberExp) {
  23858. if (exp.type === 4) {
  23859. exp.content = `${exp.content} && ${exp.content}(...args)`;
  23860. } else {
  23861. exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
  23862. }
  23863. }
  23864. }
  23865. if (isInlineStatement || shouldCache && isMemberExp) {
  23866. exp = createCompoundExpression([
  23867. `${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
  23868. //@ts-ignore
  23869. ` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  23870. exp,
  23871. hasMultipleStatements ? `}` : `)`
  23872. ]);
  23873. }
  23874. }
  23875. let ret = {
  23876. props: [
  23877. createObjectProperty(
  23878. eventName,
  23879. exp || createSimpleExpression(`() => {}`, false, loc)
  23880. )
  23881. ]
  23882. };
  23883. if (augmentor) {
  23884. ret = augmentor(ret);
  23885. }
  23886. if (shouldCache) {
  23887. ret.props[0].value = context.cache(ret.props[0].value);
  23888. }
  23889. ret.props.forEach((p) => p.key.isHandlerKey = true);
  23890. return ret;
  23891. };
  23892. const transformText = (node, context) => {
  23893. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  23894. return () => {
  23895. const children = node.children;
  23896. let currentContainer = void 0;
  23897. let hasText = false;
  23898. for (let i = 0; i < children.length; i++) {
  23899. const child = children[i];
  23900. if (isText$1(child)) {
  23901. hasText = true;
  23902. for (let j = i + 1; j < children.length; j++) {
  23903. const next = children[j];
  23904. if (isText$1(next)) {
  23905. if (!currentContainer) {
  23906. currentContainer = children[i] = createCompoundExpression(
  23907. [child],
  23908. child.loc
  23909. );
  23910. }
  23911. currentContainer.children.push(` + `, next);
  23912. children.splice(j, 1);
  23913. j--;
  23914. } else {
  23915. currentContainer = void 0;
  23916. break;
  23917. }
  23918. }
  23919. }
  23920. }
  23921. if (!hasText || // if this is a plain element with a single text child, leave it
  23922. // as-is since the runtime has dedicated fast path for this by directly
  23923. // setting textContent of the element.
  23924. // for component root it's always normalized anyway.
  23925. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  23926. // custom directives can potentially add DOM elements arbitrarily,
  23927. // we need to avoid setting textContent of the element at runtime
  23928. // to avoid accidentally overwriting the DOM elements added
  23929. // by the user through custom directives.
  23930. !node.props.find(
  23931. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  23932. ) && // in compat mode, <template> tags with no special directives
  23933. // will be rendered as a fragment so its children must be
  23934. // converted into vnodes.
  23935. true)) {
  23936. return;
  23937. }
  23938. for (let i = 0; i < children.length; i++) {
  23939. const child = children[i];
  23940. if (isText$1(child) || child.type === 8) {
  23941. const callArgs = [];
  23942. if (child.type !== 2 || child.content !== " ") {
  23943. callArgs.push(child);
  23944. }
  23945. if (!context.ssr && getConstantType(child, context) === 0) {
  23946. callArgs.push(
  23947. 1 + (` /* ${PatchFlagNames[1]} */` )
  23948. );
  23949. }
  23950. children[i] = {
  23951. type: 12,
  23952. content: child,
  23953. loc: child.loc,
  23954. codegenNode: createCallExpression(
  23955. context.helper(CREATE_TEXT),
  23956. callArgs
  23957. )
  23958. };
  23959. }
  23960. }
  23961. };
  23962. }
  23963. };
  23964. const seen$1 = /* @__PURE__ */ new WeakSet();
  23965. const transformOnce = (node, context) => {
  23966. if (node.type === 1 && findDir(node, "once", true)) {
  23967. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  23968. return;
  23969. }
  23970. seen$1.add(node);
  23971. context.inVOnce = true;
  23972. context.helper(SET_BLOCK_TRACKING);
  23973. return () => {
  23974. context.inVOnce = false;
  23975. const cur = context.currentNode;
  23976. if (cur.codegenNode) {
  23977. cur.codegenNode = context.cache(
  23978. cur.codegenNode,
  23979. true
  23980. /* isVNode */
  23981. );
  23982. }
  23983. };
  23984. }
  23985. };
  23986. const transformModel$1 = (dir, node, context) => {
  23987. const { exp, arg } = dir;
  23988. if (!exp) {
  23989. context.onError(
  23990. createCompilerError(41, dir.loc)
  23991. );
  23992. return createTransformProps();
  23993. }
  23994. const rawExp = exp.loc.source;
  23995. const expString = exp.type === 4 ? exp.content : rawExp;
  23996. const bindingType = context.bindingMetadata[rawExp];
  23997. if (bindingType === "props" || bindingType === "props-aliased") {
  23998. context.onError(createCompilerError(44, exp.loc));
  23999. return createTransformProps();
  24000. }
  24001. const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
  24002. if (!expString.trim() || !isMemberExpression(exp, context) && !maybeRef) {
  24003. context.onError(
  24004. createCompilerError(42, exp.loc)
  24005. );
  24006. return createTransformProps();
  24007. }
  24008. if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
  24009. context.onError(
  24010. createCompilerError(43, exp.loc)
  24011. );
  24012. return createTransformProps();
  24013. }
  24014. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  24015. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  24016. let assignmentExp;
  24017. const eventArg = context.isTS ? `($event: any)` : `$event`;
  24018. if (maybeRef) {
  24019. if (bindingType === "setup-ref") {
  24020. assignmentExp = createCompoundExpression([
  24021. `${eventArg} => ((`,
  24022. createSimpleExpression(rawExp, false, exp.loc),
  24023. `).value = $event)`
  24024. ]);
  24025. } else {
  24026. const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
  24027. assignmentExp = createCompoundExpression([
  24028. `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
  24029. createSimpleExpression(rawExp, false, exp.loc),
  24030. `).value = $event : ${altAssignment})`
  24031. ]);
  24032. }
  24033. } else {
  24034. assignmentExp = createCompoundExpression([
  24035. `${eventArg} => ((`,
  24036. exp,
  24037. `) = $event)`
  24038. ]);
  24039. }
  24040. const props = [
  24041. // modelValue: foo
  24042. createObjectProperty(propName, dir.exp),
  24043. // "onUpdate:modelValue": $event => (foo = $event)
  24044. createObjectProperty(eventName, assignmentExp)
  24045. ];
  24046. if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
  24047. props[1].value = context.cache(props[1].value);
  24048. }
  24049. if (dir.modifiers.length && node.tagType === 1) {
  24050. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  24051. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  24052. props.push(
  24053. createObjectProperty(
  24054. modifiersKey,
  24055. createSimpleExpression(
  24056. `{ ${modifiers} }`,
  24057. false,
  24058. dir.loc,
  24059. 2
  24060. )
  24061. )
  24062. );
  24063. }
  24064. return createTransformProps(props);
  24065. };
  24066. function createTransformProps(props = []) {
  24067. return { props };
  24068. }
  24069. const seen = /* @__PURE__ */ new WeakSet();
  24070. const transformMemo = (node, context) => {
  24071. if (node.type === 1) {
  24072. const dir = findDir(node, "memo");
  24073. if (!dir || seen.has(node)) {
  24074. return;
  24075. }
  24076. seen.add(node);
  24077. return () => {
  24078. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  24079. if (codegenNode && codegenNode.type === 13) {
  24080. if (node.tagType !== 1) {
  24081. convertToBlock(codegenNode, context);
  24082. }
  24083. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  24084. dir.exp,
  24085. createFunctionExpression(void 0, codegenNode),
  24086. `_cache`,
  24087. String(context.cached++)
  24088. ]);
  24089. }
  24090. };
  24091. }
  24092. };
  24093. function getBaseTransformPreset(prefixIdentifiers) {
  24094. return [
  24095. [
  24096. transformOnce,
  24097. transformIf,
  24098. transformMemo,
  24099. transformFor,
  24100. ...[],
  24101. ...prefixIdentifiers ? [
  24102. // order is important
  24103. trackVForSlotScopes,
  24104. transformExpression
  24105. ] : [],
  24106. transformSlotOutlet,
  24107. transformElement,
  24108. trackSlotScopes,
  24109. transformText
  24110. ],
  24111. {
  24112. on: transformOn$1,
  24113. bind: transformBind,
  24114. model: transformModel$1
  24115. }
  24116. ];
  24117. }
  24118. function baseCompile(source, options = {}) {
  24119. const onError = options.onError || defaultOnError;
  24120. const isModuleMode = options.mode === "module";
  24121. const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
  24122. if (!prefixIdentifiers && options.cacheHandlers) {
  24123. onError(createCompilerError(49));
  24124. }
  24125. if (options.scopeId && !isModuleMode) {
  24126. onError(createCompilerError(50));
  24127. }
  24128. const resolvedOptions = extend({}, options, {
  24129. prefixIdentifiers
  24130. });
  24131. const ast = isString$2(source) ? baseParse(source, resolvedOptions) : source;
  24132. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
  24133. if (options.isTS) {
  24134. const { expressionPlugins } = options;
  24135. if (!expressionPlugins || !expressionPlugins.includes("typescript")) {
  24136. options.expressionPlugins = [...expressionPlugins || [], "typescript"];
  24137. }
  24138. }
  24139. transform(
  24140. ast,
  24141. extend({}, resolvedOptions, {
  24142. nodeTransforms: [
  24143. ...nodeTransforms,
  24144. ...options.nodeTransforms || []
  24145. // user transforms
  24146. ],
  24147. directiveTransforms: extend(
  24148. {},
  24149. directiveTransforms,
  24150. options.directiveTransforms || {}
  24151. // user transforms
  24152. )
  24153. })
  24154. );
  24155. return generate(ast, resolvedOptions);
  24156. }
  24157. const BindingTypes = {
  24158. "DATA": "data",
  24159. "PROPS": "props",
  24160. "PROPS_ALIASED": "props-aliased",
  24161. "SETUP_LET": "setup-let",
  24162. "SETUP_CONST": "setup-const",
  24163. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  24164. "SETUP_MAYBE_REF": "setup-maybe-ref",
  24165. "SETUP_REF": "setup-ref",
  24166. "OPTIONS": "options",
  24167. "LITERAL_CONST": "literal-const"
  24168. };
  24169. const noopDirectiveTransform = () => ({ props: [] });
  24170. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  24171. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  24172. const V_MODEL_TEXT = Symbol(`vModelText` );
  24173. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  24174. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  24175. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  24176. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  24177. const V_SHOW = Symbol(`vShow` );
  24178. const TRANSITION = Symbol(`Transition` );
  24179. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  24180. registerRuntimeHelpers({
  24181. [V_MODEL_RADIO]: `vModelRadio`,
  24182. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  24183. [V_MODEL_TEXT]: `vModelText`,
  24184. [V_MODEL_SELECT]: `vModelSelect`,
  24185. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  24186. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  24187. [V_ON_WITH_KEYS]: `withKeys`,
  24188. [V_SHOW]: `vShow`,
  24189. [TRANSITION]: `Transition`,
  24190. [TRANSITION_GROUP]: `TransitionGroup`
  24191. });
  24192. const parserOptions = {
  24193. parseMode: "html",
  24194. isVoidTag,
  24195. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  24196. isPreTag: (tag) => tag === "pre",
  24197. decodeEntities: void 0,
  24198. isBuiltInComponent: (tag) => {
  24199. if (tag === "Transition" || tag === "transition") {
  24200. return TRANSITION;
  24201. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  24202. return TRANSITION_GROUP;
  24203. }
  24204. },
  24205. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  24206. getNamespace(tag, parent, rootNamespace) {
  24207. let ns = parent ? parent.ns : rootNamespace;
  24208. if (parent && ns === 2) {
  24209. if (parent.tag === "annotation-xml") {
  24210. if (tag === "svg") {
  24211. return 1;
  24212. }
  24213. if (parent.props.some(
  24214. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  24215. )) {
  24216. ns = 0;
  24217. }
  24218. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  24219. ns = 0;
  24220. }
  24221. } else if (parent && ns === 1) {
  24222. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  24223. ns = 0;
  24224. }
  24225. }
  24226. if (ns === 0) {
  24227. if (tag === "svg") {
  24228. return 1;
  24229. }
  24230. if (tag === "math") {
  24231. return 2;
  24232. }
  24233. }
  24234. return ns;
  24235. }
  24236. };
  24237. const transformStyle = (node) => {
  24238. if (node.type === 1) {
  24239. node.props.forEach((p, i) => {
  24240. if (p.type === 6 && p.name === "style" && p.value) {
  24241. node.props[i] = {
  24242. type: 7,
  24243. name: `bind`,
  24244. arg: createSimpleExpression(`style`, true, p.loc),
  24245. exp: parseInlineCSS(p.value.content, p.loc),
  24246. modifiers: [],
  24247. loc: p.loc
  24248. };
  24249. }
  24250. });
  24251. }
  24252. };
  24253. const parseInlineCSS = (cssText, loc) => {
  24254. const normalized = parseStringStyle(cssText);
  24255. return createSimpleExpression(
  24256. JSON.stringify(normalized),
  24257. false,
  24258. loc,
  24259. 3
  24260. );
  24261. };
  24262. function createDOMCompilerError(code, loc) {
  24263. return createCompilerError(
  24264. code,
  24265. loc,
  24266. DOMErrorMessages
  24267. );
  24268. }
  24269. const DOMErrorCodes = {
  24270. "X_V_HTML_NO_EXPRESSION": 53,
  24271. "53": "X_V_HTML_NO_EXPRESSION",
  24272. "X_V_HTML_WITH_CHILDREN": 54,
  24273. "54": "X_V_HTML_WITH_CHILDREN",
  24274. "X_V_TEXT_NO_EXPRESSION": 55,
  24275. "55": "X_V_TEXT_NO_EXPRESSION",
  24276. "X_V_TEXT_WITH_CHILDREN": 56,
  24277. "56": "X_V_TEXT_WITH_CHILDREN",
  24278. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  24279. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  24280. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  24281. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  24282. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  24283. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  24284. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  24285. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  24286. "X_V_SHOW_NO_EXPRESSION": 61,
  24287. "61": "X_V_SHOW_NO_EXPRESSION",
  24288. "X_TRANSITION_INVALID_CHILDREN": 62,
  24289. "62": "X_TRANSITION_INVALID_CHILDREN",
  24290. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  24291. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  24292. "__EXTEND_POINT__": 64,
  24293. "64": "__EXTEND_POINT__"
  24294. };
  24295. const DOMErrorMessages = {
  24296. [53]: `v-html is missing expression.`,
  24297. [54]: `v-html will override element children.`,
  24298. [55]: `v-text is missing expression.`,
  24299. [56]: `v-text will override element children.`,
  24300. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  24301. [58]: `v-model argument is not supported on plain elements.`,
  24302. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  24303. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  24304. [61]: `v-show is missing expression.`,
  24305. [62]: `<Transition> expects exactly one child element or component.`,
  24306. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  24307. };
  24308. const transformVHtml = (dir, node, context) => {
  24309. const { exp, loc } = dir;
  24310. if (!exp) {
  24311. context.onError(
  24312. createDOMCompilerError(53, loc)
  24313. );
  24314. }
  24315. if (node.children.length) {
  24316. context.onError(
  24317. createDOMCompilerError(54, loc)
  24318. );
  24319. node.children.length = 0;
  24320. }
  24321. return {
  24322. props: [
  24323. createObjectProperty(
  24324. createSimpleExpression(`innerHTML`, true, loc),
  24325. exp || createSimpleExpression("", true)
  24326. )
  24327. ]
  24328. };
  24329. };
  24330. const transformVText = (dir, node, context) => {
  24331. const { exp, loc } = dir;
  24332. if (!exp) {
  24333. context.onError(
  24334. createDOMCompilerError(55, loc)
  24335. );
  24336. }
  24337. if (node.children.length) {
  24338. context.onError(
  24339. createDOMCompilerError(56, loc)
  24340. );
  24341. node.children.length = 0;
  24342. }
  24343. return {
  24344. props: [
  24345. createObjectProperty(
  24346. createSimpleExpression(`textContent`, true),
  24347. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  24348. context.helperString(TO_DISPLAY_STRING),
  24349. [exp],
  24350. loc
  24351. ) : createSimpleExpression("", true)
  24352. )
  24353. ]
  24354. };
  24355. };
  24356. const transformModel = (dir, node, context) => {
  24357. const baseResult = transformModel$1(dir, node, context);
  24358. if (!baseResult.props.length || node.tagType === 1) {
  24359. return baseResult;
  24360. }
  24361. if (dir.arg) {
  24362. context.onError(
  24363. createDOMCompilerError(
  24364. 58,
  24365. dir.arg.loc
  24366. )
  24367. );
  24368. }
  24369. function checkDuplicatedValue() {
  24370. const value = findDir(node, "bind");
  24371. if (value && isStaticArgOf(value.arg, "value")) {
  24372. context.onError(
  24373. createDOMCompilerError(
  24374. 60,
  24375. value.loc
  24376. )
  24377. );
  24378. }
  24379. }
  24380. const { tag } = node;
  24381. const isCustomElement = context.isCustomElement(tag);
  24382. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  24383. let directiveToUse = V_MODEL_TEXT;
  24384. let isInvalidType = false;
  24385. if (tag === "input" || isCustomElement) {
  24386. const type = findProp(node, `type`);
  24387. if (type) {
  24388. if (type.type === 7) {
  24389. directiveToUse = V_MODEL_DYNAMIC;
  24390. } else if (type.value) {
  24391. switch (type.value.content) {
  24392. case "radio":
  24393. directiveToUse = V_MODEL_RADIO;
  24394. break;
  24395. case "checkbox":
  24396. directiveToUse = V_MODEL_CHECKBOX;
  24397. break;
  24398. case "file":
  24399. isInvalidType = true;
  24400. context.onError(
  24401. createDOMCompilerError(
  24402. 59,
  24403. dir.loc
  24404. )
  24405. );
  24406. break;
  24407. default:
  24408. checkDuplicatedValue();
  24409. break;
  24410. }
  24411. }
  24412. } else if (hasDynamicKeyVBind(node)) {
  24413. directiveToUse = V_MODEL_DYNAMIC;
  24414. } else {
  24415. checkDuplicatedValue();
  24416. }
  24417. } else if (tag === "select") {
  24418. directiveToUse = V_MODEL_SELECT;
  24419. } else {
  24420. checkDuplicatedValue();
  24421. }
  24422. if (!isInvalidType) {
  24423. baseResult.needRuntime = context.helper(directiveToUse);
  24424. }
  24425. } else {
  24426. context.onError(
  24427. createDOMCompilerError(
  24428. 57,
  24429. dir.loc
  24430. )
  24431. );
  24432. }
  24433. baseResult.props = baseResult.props.filter(
  24434. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  24435. );
  24436. return baseResult;
  24437. };
  24438. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  24439. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  24440. // event propagation management
  24441. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  24442. );
  24443. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  24444. const isKeyboardEvent = /* @__PURE__ */ makeMap(
  24445. `onkeyup,onkeydown,onkeypress`,
  24446. true
  24447. );
  24448. const resolveModifiers = (key, modifiers, context, loc) => {
  24449. const keyModifiers = [];
  24450. const nonKeyModifiers = [];
  24451. const eventOptionModifiers = [];
  24452. for (let i = 0; i < modifiers.length; i++) {
  24453. const modifier = modifiers[i];
  24454. if (isEventOptionModifier(modifier)) {
  24455. eventOptionModifiers.push(modifier);
  24456. } else {
  24457. if (maybeKeyModifier(modifier)) {
  24458. if (isStaticExp(key)) {
  24459. if (isKeyboardEvent(key.content)) {
  24460. keyModifiers.push(modifier);
  24461. } else {
  24462. nonKeyModifiers.push(modifier);
  24463. }
  24464. } else {
  24465. keyModifiers.push(modifier);
  24466. nonKeyModifiers.push(modifier);
  24467. }
  24468. } else {
  24469. if (isNonKeyModifier(modifier)) {
  24470. nonKeyModifiers.push(modifier);
  24471. } else {
  24472. keyModifiers.push(modifier);
  24473. }
  24474. }
  24475. }
  24476. }
  24477. return {
  24478. keyModifiers,
  24479. nonKeyModifiers,
  24480. eventOptionModifiers
  24481. };
  24482. };
  24483. const transformClick = (key, event) => {
  24484. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  24485. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  24486. `(`,
  24487. key,
  24488. `) === "onClick" ? "${event}" : (`,
  24489. key,
  24490. `)`
  24491. ]) : key;
  24492. };
  24493. const transformOn = (dir, node, context) => {
  24494. return transformOn$1(dir, node, context, (baseResult) => {
  24495. const { modifiers } = dir;
  24496. if (!modifiers.length) return baseResult;
  24497. let { key, value: handlerExp } = baseResult.props[0];
  24498. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  24499. if (nonKeyModifiers.includes("right")) {
  24500. key = transformClick(key, `onContextmenu`);
  24501. }
  24502. if (nonKeyModifiers.includes("middle")) {
  24503. key = transformClick(key, `onMouseup`);
  24504. }
  24505. if (nonKeyModifiers.length) {
  24506. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  24507. handlerExp,
  24508. JSON.stringify(nonKeyModifiers)
  24509. ]);
  24510. }
  24511. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  24512. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  24513. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  24514. handlerExp,
  24515. JSON.stringify(keyModifiers)
  24516. ]);
  24517. }
  24518. if (eventOptionModifiers.length) {
  24519. const modifierPostfix = eventOptionModifiers.map(capitalize$1).join("");
  24520. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  24521. }
  24522. return {
  24523. props: [createObjectProperty(key, handlerExp)]
  24524. };
  24525. });
  24526. };
  24527. const transformShow = (dir, node, context) => {
  24528. const { exp, loc } = dir;
  24529. if (!exp) {
  24530. context.onError(
  24531. createDOMCompilerError(61, loc)
  24532. );
  24533. }
  24534. return {
  24535. props: [],
  24536. needRuntime: context.helper(V_SHOW)
  24537. };
  24538. };
  24539. const transformTransition = (node, context) => {
  24540. if (node.type === 1 && node.tagType === 1) {
  24541. const component = context.isBuiltInComponent(node.tag);
  24542. if (component === TRANSITION) {
  24543. return () => {
  24544. if (!node.children.length) {
  24545. return;
  24546. }
  24547. if (hasMultipleChildren(node)) {
  24548. context.onError(
  24549. createDOMCompilerError(
  24550. 62,
  24551. {
  24552. start: node.children[0].loc.start,
  24553. end: node.children[node.children.length - 1].loc.end,
  24554. source: ""
  24555. }
  24556. )
  24557. );
  24558. }
  24559. const child = node.children[0];
  24560. if (child.type === 1) {
  24561. for (const p of child.props) {
  24562. if (p.type === 7 && p.name === "show") {
  24563. node.props.push({
  24564. type: 6,
  24565. name: "persisted",
  24566. nameLoc: node.loc,
  24567. value: void 0,
  24568. loc: node.loc
  24569. });
  24570. }
  24571. }
  24572. }
  24573. };
  24574. }
  24575. }
  24576. };
  24577. function hasMultipleChildren(node) {
  24578. const children = node.children = node.children.filter(
  24579. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  24580. );
  24581. const child = children[0];
  24582. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  24583. }
  24584. const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
  24585. const stringifyStatic = (children, context, parent) => {
  24586. if (context.scopes.vSlot > 0) {
  24587. return;
  24588. }
  24589. let nc = 0;
  24590. let ec = 0;
  24591. const currentChunk = [];
  24592. const stringifyCurrentChunk = (currentIndex) => {
  24593. if (nc >= 20 || ec >= 5) {
  24594. const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
  24595. JSON.stringify(
  24596. currentChunk.map((node) => stringifyNode(node, context)).join("")
  24597. ).replace(expReplaceRE, `" + $1 + "`),
  24598. // the 2nd argument indicates the number of DOM nodes this static vnode
  24599. // will insert / hydrate
  24600. String(currentChunk.length)
  24601. ]);
  24602. replaceHoist(currentChunk[0], staticCall, context);
  24603. if (currentChunk.length > 1) {
  24604. for (let i2 = 1; i2 < currentChunk.length; i2++) {
  24605. replaceHoist(currentChunk[i2], null, context);
  24606. }
  24607. const deleteCount = currentChunk.length - 1;
  24608. children.splice(currentIndex - currentChunk.length + 1, deleteCount);
  24609. return deleteCount;
  24610. }
  24611. }
  24612. return 0;
  24613. };
  24614. let i = 0;
  24615. for (; i < children.length; i++) {
  24616. const child = children[i];
  24617. const hoisted = getHoistedNode(child);
  24618. if (hoisted) {
  24619. const node = child;
  24620. const result = analyzeNode(node);
  24621. if (result) {
  24622. nc += result[0];
  24623. ec += result[1];
  24624. currentChunk.push(node);
  24625. continue;
  24626. }
  24627. }
  24628. i -= stringifyCurrentChunk(i);
  24629. nc = 0;
  24630. ec = 0;
  24631. currentChunk.length = 0;
  24632. }
  24633. stringifyCurrentChunk(i);
  24634. };
  24635. const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
  24636. const dataAriaRE = /^(data|aria)-/;
  24637. const isStringifiableAttr = (name, ns) => {
  24638. return (ns === 0 ? isKnownHtmlAttr(name) : ns === 1 ? isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
  24639. };
  24640. const replaceHoist = (node, replacement, context) => {
  24641. const hoistToReplace = node.codegenNode.hoisted;
  24642. context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
  24643. };
  24644. const isNonStringifiable = /* @__PURE__ */ makeMap(
  24645. `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
  24646. );
  24647. function analyzeNode(node) {
  24648. if (node.type === 1 && isNonStringifiable(node.tag)) {
  24649. return false;
  24650. }
  24651. if (node.type === 12) {
  24652. return [1, 0];
  24653. }
  24654. let nc = 1;
  24655. let ec = node.props.length > 0 ? 1 : 0;
  24656. let bailed = false;
  24657. const bail = () => {
  24658. bailed = true;
  24659. return false;
  24660. };
  24661. function walk(node2) {
  24662. const isOptionTag = node2.tag === "option" && node2.ns === 0;
  24663. for (let i = 0; i < node2.props.length; i++) {
  24664. const p = node2.props[i];
  24665. if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
  24666. return bail();
  24667. }
  24668. if (p.type === 7 && p.name === "bind") {
  24669. if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
  24670. return bail();
  24671. }
  24672. if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
  24673. return bail();
  24674. }
  24675. if (isOptionTag && isStaticArgOf(p.arg, "value") && p.exp && p.exp.ast && p.exp.ast.type !== "StringLiteral") {
  24676. return bail();
  24677. }
  24678. }
  24679. }
  24680. for (let i = 0; i < node2.children.length; i++) {
  24681. nc++;
  24682. const child = node2.children[i];
  24683. if (child.type === 1) {
  24684. if (child.props.length > 0) {
  24685. ec++;
  24686. }
  24687. walk(child);
  24688. if (bailed) {
  24689. return false;
  24690. }
  24691. }
  24692. }
  24693. return true;
  24694. }
  24695. return walk(node) ? [nc, ec] : false;
  24696. }
  24697. function stringifyNode(node, context) {
  24698. if (isString$2(node)) {
  24699. return node;
  24700. }
  24701. if (isSymbol$1(node)) {
  24702. return ``;
  24703. }
  24704. switch (node.type) {
  24705. case 1:
  24706. return stringifyElement(node, context);
  24707. case 2:
  24708. return escapeHtml(node.content);
  24709. case 3:
  24710. return `<!--${escapeHtml(node.content)}-->`;
  24711. case 5:
  24712. return escapeHtml(toDisplayString(evaluateConstant(node.content)));
  24713. case 8:
  24714. return escapeHtml(evaluateConstant(node));
  24715. case 12:
  24716. return stringifyNode(node.content, context);
  24717. default:
  24718. return "";
  24719. }
  24720. }
  24721. function stringifyElement(node, context) {
  24722. let res = `<${node.tag}`;
  24723. let innerHTML = "";
  24724. for (let i = 0; i < node.props.length; i++) {
  24725. const p = node.props[i];
  24726. if (p.type === 6) {
  24727. res += ` ${p.name}`;
  24728. if (p.value) {
  24729. res += `="${escapeHtml(p.value.content)}"`;
  24730. }
  24731. } else if (p.type === 7) {
  24732. if (p.name === "bind") {
  24733. const exp = p.exp;
  24734. if (exp.content[0] === "_") {
  24735. res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
  24736. continue;
  24737. }
  24738. if (isBooleanAttr(p.arg.content) && exp.content === "false") {
  24739. continue;
  24740. }
  24741. let evaluated = evaluateConstant(exp);
  24742. if (evaluated != null) {
  24743. const arg = p.arg && p.arg.content;
  24744. if (arg === "class") {
  24745. evaluated = normalizeClass(evaluated);
  24746. } else if (arg === "style") {
  24747. evaluated = stringifyStyle(normalizeStyle(evaluated));
  24748. }
  24749. res += ` ${p.arg.content}="${escapeHtml(
  24750. evaluated
  24751. )}"`;
  24752. }
  24753. } else if (p.name === "html") {
  24754. innerHTML = evaluateConstant(p.exp);
  24755. } else if (p.name === "text") {
  24756. innerHTML = escapeHtml(
  24757. toDisplayString(evaluateConstant(p.exp))
  24758. );
  24759. }
  24760. }
  24761. }
  24762. if (context.scopeId) {
  24763. res += ` ${context.scopeId}`;
  24764. }
  24765. res += `>`;
  24766. if (innerHTML) {
  24767. res += innerHTML;
  24768. } else {
  24769. for (let i = 0; i < node.children.length; i++) {
  24770. res += stringifyNode(node.children[i], context);
  24771. }
  24772. }
  24773. if (!isVoidTag(node.tag)) {
  24774. res += `</${node.tag}>`;
  24775. }
  24776. return res;
  24777. }
  24778. function evaluateConstant(exp) {
  24779. if (exp.type === 4) {
  24780. return new Function(`return (${exp.content})`)();
  24781. } else {
  24782. let res = ``;
  24783. exp.children.forEach((c) => {
  24784. if (isString$2(c) || isSymbol$1(c)) {
  24785. return;
  24786. }
  24787. if (c.type === 2) {
  24788. res += c.content;
  24789. } else if (c.type === 5) {
  24790. res += toDisplayString(evaluateConstant(c.content));
  24791. } else {
  24792. res += evaluateConstant(c);
  24793. }
  24794. });
  24795. return res;
  24796. }
  24797. }
  24798. const ignoreSideEffectTags = (node, context) => {
  24799. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  24800. context.onError(
  24801. createDOMCompilerError(
  24802. 63,
  24803. node.loc
  24804. )
  24805. );
  24806. context.removeNode();
  24807. }
  24808. };
  24809. const DOMNodeTransforms = [
  24810. transformStyle,
  24811. ...[transformTransition]
  24812. ];
  24813. const DOMDirectiveTransforms = {
  24814. cloak: noopDirectiveTransform,
  24815. html: transformVHtml,
  24816. text: transformVText,
  24817. model: transformModel,
  24818. // override compiler-core
  24819. on: transformOn,
  24820. // override compiler-core
  24821. show: transformShow
  24822. };
  24823. function compile$1(src, options = {}) {
  24824. return baseCompile(
  24825. src,
  24826. extend({}, parserOptions, options, {
  24827. nodeTransforms: [
  24828. // ignore <script> and <tag>
  24829. // this is not put inside DOMNodeTransforms because that list is used
  24830. // by compiler-ssr to generate vnode fallback branches
  24831. ignoreSideEffectTags,
  24832. ...DOMNodeTransforms,
  24833. ...options.nodeTransforms || []
  24834. ],
  24835. directiveTransforms: extend(
  24836. {},
  24837. DOMDirectiveTransforms,
  24838. options.directiveTransforms || {}
  24839. ),
  24840. transformHoist: stringifyStatic
  24841. })
  24842. );
  24843. }
  24844. function parse$8(template, options = {}) {
  24845. return baseParse(template, extend({}, parserOptions, options));
  24846. }
  24847. var CompilerDOM = /*#__PURE__*/Object.freeze({
  24848. __proto__: null,
  24849. BASE_TRANSITION: BASE_TRANSITION,
  24850. BindingTypes: BindingTypes,
  24851. CAMELIZE: CAMELIZE,
  24852. CAPITALIZE: CAPITALIZE,
  24853. CREATE_BLOCK: CREATE_BLOCK,
  24854. CREATE_COMMENT: CREATE_COMMENT,
  24855. CREATE_ELEMENT_BLOCK: CREATE_ELEMENT_BLOCK,
  24856. CREATE_ELEMENT_VNODE: CREATE_ELEMENT_VNODE,
  24857. CREATE_SLOTS: CREATE_SLOTS,
  24858. CREATE_STATIC: CREATE_STATIC,
  24859. CREATE_TEXT: CREATE_TEXT,
  24860. CREATE_VNODE: CREATE_VNODE,
  24861. CompilerDeprecationTypes: CompilerDeprecationTypes,
  24862. ConstantTypes: ConstantTypes,
  24863. DOMDirectiveTransforms: DOMDirectiveTransforms,
  24864. DOMErrorCodes: DOMErrorCodes,
  24865. DOMErrorMessages: DOMErrorMessages,
  24866. DOMNodeTransforms: DOMNodeTransforms,
  24867. ElementTypes: ElementTypes,
  24868. ErrorCodes: ErrorCodes,
  24869. FRAGMENT: FRAGMENT,
  24870. GUARD_REACTIVE_PROPS: GUARD_REACTIVE_PROPS,
  24871. IS_MEMO_SAME: IS_MEMO_SAME,
  24872. IS_REF: IS_REF,
  24873. KEEP_ALIVE: KEEP_ALIVE,
  24874. MERGE_PROPS: MERGE_PROPS,
  24875. NORMALIZE_CLASS: NORMALIZE_CLASS,
  24876. NORMALIZE_PROPS: NORMALIZE_PROPS,
  24877. NORMALIZE_STYLE: NORMALIZE_STYLE,
  24878. Namespaces: Namespaces,
  24879. NodeTypes: NodeTypes,
  24880. OPEN_BLOCK: OPEN_BLOCK,
  24881. POP_SCOPE_ID: POP_SCOPE_ID,
  24882. PUSH_SCOPE_ID: PUSH_SCOPE_ID,
  24883. RENDER_LIST: RENDER_LIST,
  24884. RENDER_SLOT: RENDER_SLOT,
  24885. RESOLVE_COMPONENT: RESOLVE_COMPONENT,
  24886. RESOLVE_DIRECTIVE: RESOLVE_DIRECTIVE,
  24887. RESOLVE_DYNAMIC_COMPONENT: RESOLVE_DYNAMIC_COMPONENT,
  24888. RESOLVE_FILTER: RESOLVE_FILTER,
  24889. SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
  24890. SUSPENSE: SUSPENSE,
  24891. TELEPORT: TELEPORT,
  24892. TO_DISPLAY_STRING: TO_DISPLAY_STRING,
  24893. TO_HANDLERS: TO_HANDLERS,
  24894. TO_HANDLER_KEY: TO_HANDLER_KEY,
  24895. TRANSITION: TRANSITION,
  24896. TRANSITION_GROUP: TRANSITION_GROUP,
  24897. TS_NODE_TYPES: TS_NODE_TYPES,
  24898. UNREF: UNREF,
  24899. V_MODEL_CHECKBOX: V_MODEL_CHECKBOX,
  24900. V_MODEL_DYNAMIC: V_MODEL_DYNAMIC,
  24901. V_MODEL_RADIO: V_MODEL_RADIO,
  24902. V_MODEL_SELECT: V_MODEL_SELECT,
  24903. V_MODEL_TEXT: V_MODEL_TEXT,
  24904. V_ON_WITH_KEYS: V_ON_WITH_KEYS,
  24905. V_ON_WITH_MODIFIERS: V_ON_WITH_MODIFIERS,
  24906. V_SHOW: V_SHOW,
  24907. WITH_CTX: WITH_CTX,
  24908. WITH_DIRECTIVES: WITH_DIRECTIVES,
  24909. WITH_MEMO: WITH_MEMO,
  24910. advancePositionWithClone: advancePositionWithClone,
  24911. advancePositionWithMutation: advancePositionWithMutation,
  24912. assert: assert,
  24913. baseCompile: baseCompile,
  24914. baseParse: baseParse,
  24915. buildDirectiveArgs: buildDirectiveArgs,
  24916. buildProps: buildProps,
  24917. buildSlots: buildSlots,
  24918. checkCompatEnabled: checkCompatEnabled,
  24919. compile: compile$1,
  24920. convertToBlock: convertToBlock,
  24921. createArrayExpression: createArrayExpression,
  24922. createAssignmentExpression: createAssignmentExpression,
  24923. createBlockStatement: createBlockStatement,
  24924. createCacheExpression: createCacheExpression,
  24925. createCallExpression: createCallExpression,
  24926. createCompilerError: createCompilerError,
  24927. createCompoundExpression: createCompoundExpression,
  24928. createConditionalExpression: createConditionalExpression,
  24929. createDOMCompilerError: createDOMCompilerError,
  24930. createForLoopParams: createForLoopParams,
  24931. createFunctionExpression: createFunctionExpression,
  24932. createIfStatement: createIfStatement,
  24933. createInterpolation: createInterpolation,
  24934. createObjectExpression: createObjectExpression,
  24935. createObjectProperty: createObjectProperty,
  24936. createReturnStatement: createReturnStatement,
  24937. createRoot: createRoot,
  24938. createSequenceExpression: createSequenceExpression,
  24939. createSimpleExpression: createSimpleExpression,
  24940. createStructuralDirectiveTransform: createStructuralDirectiveTransform,
  24941. createTemplateLiteral: createTemplateLiteral,
  24942. createTransformContext: createTransformContext,
  24943. createVNodeCall: createVNodeCall,
  24944. errorMessages: errorMessages$1,
  24945. extractIdentifiers: extractIdentifiers$1,
  24946. findDir: findDir,
  24947. findProp: findProp,
  24948. forAliasRE: forAliasRE,
  24949. generate: generate,
  24950. generateCodeFrame: generateCodeFrame,
  24951. getBaseTransformPreset: getBaseTransformPreset,
  24952. getConstantType: getConstantType,
  24953. getMemoedVNodeCall: getMemoedVNodeCall,
  24954. getVNodeBlockHelper: getVNodeBlockHelper,
  24955. getVNodeHelper: getVNodeHelper,
  24956. hasDynamicKeyVBind: hasDynamicKeyVBind,
  24957. hasScopeRef: hasScopeRef,
  24958. helperNameMap: helperNameMap,
  24959. injectProp: injectProp,
  24960. isCoreComponent: isCoreComponent,
  24961. isFnExpression: isFnExpression,
  24962. isFnExpressionBrowser: isFnExpressionBrowser,
  24963. isFnExpressionNode: isFnExpressionNode,
  24964. isFunctionType: isFunctionType,
  24965. isInDestructureAssignment: isInDestructureAssignment,
  24966. isInNewExpression: isInNewExpression,
  24967. isMemberExpression: isMemberExpression,
  24968. isMemberExpressionBrowser: isMemberExpressionBrowser,
  24969. isMemberExpressionNode: isMemberExpressionNode,
  24970. isReferencedIdentifier: isReferencedIdentifier,
  24971. isSimpleIdentifier: isSimpleIdentifier,
  24972. isSlotOutlet: isSlotOutlet,
  24973. isStaticArgOf: isStaticArgOf,
  24974. isStaticExp: isStaticExp,
  24975. isStaticProperty: isStaticProperty,
  24976. isStaticPropertyKey: isStaticPropertyKey,
  24977. isTemplateNode: isTemplateNode,
  24978. isText: isText$1,
  24979. isVSlot: isVSlot,
  24980. locStub: locStub,
  24981. noopDirectiveTransform: noopDirectiveTransform,
  24982. parse: parse$8,
  24983. parserOptions: parserOptions,
  24984. processExpression: processExpression,
  24985. processFor: processFor,
  24986. processIf: processIf,
  24987. processSlotOutlet: processSlotOutlet,
  24988. registerRuntimeHelpers: registerRuntimeHelpers,
  24989. resolveComponentType: resolveComponentType,
  24990. stringifyExpression: stringifyExpression,
  24991. toValidAssetId: toValidAssetId,
  24992. trackSlotScopes: trackSlotScopes,
  24993. trackVForSlotScopes: trackVForSlotScopes,
  24994. transform: transform,
  24995. transformBind: transformBind,
  24996. transformElement: transformElement,
  24997. transformExpression: transformExpression,
  24998. transformModel: transformModel$1,
  24999. transformOn: transformOn$1,
  25000. transformStyle: transformStyle,
  25001. traverseNode: traverseNode,
  25002. unwrapTSNode: unwrapTSNode,
  25003. walkBlockDeclarations: walkBlockDeclarations,
  25004. walkFunctionParams: walkFunctionParams,
  25005. walkIdentifiers: walkIdentifiers,
  25006. warnDeprecation: warnDeprecation
  25007. });
  25008. // Copyright Joyent, Inc. and other Node contributors.
  25009. //
  25010. // Permission is hereby granted, free of charge, to any person obtaining a
  25011. // copy of this software and associated documentation files (the
  25012. // "Software"), to deal in the Software without restriction, including
  25013. // without limitation the rights to use, copy, modify, merge, publish,
  25014. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25015. // persons to whom the Software is furnished to do so, subject to the
  25016. // following conditions:
  25017. //
  25018. // The above copyright notice and this permission notice shall be included
  25019. // in all copies or substantial portions of the Software.
  25020. //
  25021. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25022. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25023. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25024. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25025. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25026. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25027. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25028. // resolves . and .. elements in a path array with directory names there
  25029. // must be no slashes, empty elements, or device names (c:\) in the array
  25030. // (so also no leading and trailing slashes - it does not distinguish
  25031. // relative and absolute paths)
  25032. function normalizeArray(parts, allowAboveRoot) {
  25033. // if the path tries to go above the root, `up` ends up > 0
  25034. var up = 0;
  25035. for (var i = parts.length - 1; i >= 0; i--) {
  25036. var last = parts[i];
  25037. if (last === '.') {
  25038. parts.splice(i, 1);
  25039. } else if (last === '..') {
  25040. parts.splice(i, 1);
  25041. up++;
  25042. } else if (up) {
  25043. parts.splice(i, 1);
  25044. up--;
  25045. }
  25046. }
  25047. // if the path is allowed to go above the root, restore leading ..s
  25048. if (allowAboveRoot) {
  25049. for (; up--; up) {
  25050. parts.unshift('..');
  25051. }
  25052. }
  25053. return parts;
  25054. }
  25055. // Split a filename into [root, dir, basename, ext], unix version
  25056. // 'root' is just a slash, or nothing.
  25057. var splitPathRe =
  25058. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  25059. var splitPath = function(filename) {
  25060. return splitPathRe.exec(filename).slice(1);
  25061. };
  25062. // path.resolve([from ...], to)
  25063. // posix version
  25064. function resolve$2() {
  25065. var resolvedPath = '',
  25066. resolvedAbsolute = false;
  25067. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  25068. var path = (i >= 0) ? arguments[i] : '/';
  25069. // Skip empty and invalid entries
  25070. if (typeof path !== 'string') {
  25071. throw new TypeError('Arguments to path.resolve must be strings');
  25072. } else if (!path) {
  25073. continue;
  25074. }
  25075. resolvedPath = path + '/' + resolvedPath;
  25076. resolvedAbsolute = path.charAt(0) === '/';
  25077. }
  25078. // At this point the path should be resolved to a full absolute path, but
  25079. // handle relative paths to be safe (might happen when process.cwd() fails)
  25080. // Normalize the path
  25081. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  25082. return !!p;
  25083. }), !resolvedAbsolute).join('/');
  25084. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  25085. }
  25086. // path.normalize(path)
  25087. // posix version
  25088. function normalize$1(path) {
  25089. var isPathAbsolute = isAbsolute$1(path),
  25090. trailingSlash = substr(path, -1) === '/';
  25091. // Normalize the path
  25092. path = normalizeArray(filter(path.split('/'), function(p) {
  25093. return !!p;
  25094. }), !isPathAbsolute).join('/');
  25095. if (!path && !isPathAbsolute) {
  25096. path = '.';
  25097. }
  25098. if (path && trailingSlash) {
  25099. path += '/';
  25100. }
  25101. return (isPathAbsolute ? '/' : '') + path;
  25102. }
  25103. // posix version
  25104. function isAbsolute$1(path) {
  25105. return path.charAt(0) === '/';
  25106. }
  25107. // posix version
  25108. function join$1() {
  25109. var paths = Array.prototype.slice.call(arguments, 0);
  25110. return normalize$1(filter(paths, function(p, index) {
  25111. if (typeof p !== 'string') {
  25112. throw new TypeError('Arguments to path.join must be strings');
  25113. }
  25114. return p;
  25115. }).join('/'));
  25116. }
  25117. // path.relative(from, to)
  25118. // posix version
  25119. function relative$1(from, to) {
  25120. from = resolve$2(from).substr(1);
  25121. to = resolve$2(to).substr(1);
  25122. function trim(arr) {
  25123. var start = 0;
  25124. for (; start < arr.length; start++) {
  25125. if (arr[start] !== '') break;
  25126. }
  25127. var end = arr.length - 1;
  25128. for (; end >= 0; end--) {
  25129. if (arr[end] !== '') break;
  25130. }
  25131. if (start > end) return [];
  25132. return arr.slice(start, end - start + 1);
  25133. }
  25134. var fromParts = trim(from.split('/'));
  25135. var toParts = trim(to.split('/'));
  25136. var length = Math.min(fromParts.length, toParts.length);
  25137. var samePartsLength = length;
  25138. for (var i = 0; i < length; i++) {
  25139. if (fromParts[i] !== toParts[i]) {
  25140. samePartsLength = i;
  25141. break;
  25142. }
  25143. }
  25144. var outputParts = [];
  25145. for (var i = samePartsLength; i < fromParts.length; i++) {
  25146. outputParts.push('..');
  25147. }
  25148. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  25149. return outputParts.join('/');
  25150. }
  25151. var sep$1 = '/';
  25152. var delimiter$1 = ':';
  25153. function dirname$2(path) {
  25154. var result = splitPath(path),
  25155. root = result[0],
  25156. dir = result[1];
  25157. if (!root && !dir) {
  25158. // No dirname whatsoever
  25159. return '.';
  25160. }
  25161. if (dir) {
  25162. // It has a dirname, strip trailing slash
  25163. dir = dir.substr(0, dir.length - 1);
  25164. }
  25165. return root + dir;
  25166. }
  25167. function basename(path, ext) {
  25168. var f = splitPath(path)[2];
  25169. // TODO: make this comparison case-insensitive on windows?
  25170. if (ext && f.substr(-1 * ext.length) === ext) {
  25171. f = f.substr(0, f.length - ext.length);
  25172. }
  25173. return f;
  25174. }
  25175. function extname(path) {
  25176. return splitPath(path)[3];
  25177. }
  25178. var path = {
  25179. extname: extname,
  25180. basename: basename,
  25181. dirname: dirname$2,
  25182. sep: sep$1,
  25183. delimiter: delimiter$1,
  25184. relative: relative$1,
  25185. join: join$1,
  25186. isAbsolute: isAbsolute$1,
  25187. normalize: normalize$1,
  25188. resolve: resolve$2
  25189. };
  25190. function filter (xs, f) {
  25191. if (xs.filter) return xs.filter(f);
  25192. var res = [];
  25193. for (var i = 0; i < xs.length; i++) {
  25194. if (f(xs[i], i, xs)) res.push(xs[i]);
  25195. }
  25196. return res;
  25197. }
  25198. // String.prototype.substr - negative index don't work in IE8
  25199. var substr = 'ab'.substr(-1) === 'b' ?
  25200. function (str, start, len) { return str.substr(start, len) } :
  25201. function (str, start, len) {
  25202. if (start < 0) start = str.length + start;
  25203. return str.substr(start, len);
  25204. }
  25205. ;
  25206. var _polyfillNode_path = /*#__PURE__*/Object.freeze({
  25207. __proto__: null,
  25208. basename: basename,
  25209. default: path,
  25210. delimiter: delimiter$1,
  25211. dirname: dirname$2,
  25212. extname: extname,
  25213. isAbsolute: isAbsolute$1,
  25214. join: join$1,
  25215. normalize: normalize$1,
  25216. relative: relative$1,
  25217. resolve: resolve$2,
  25218. sep: sep$1
  25219. });
  25220. const UNKNOWN_TYPE = "Unknown";
  25221. function resolveObjectKey(node, computed) {
  25222. switch (node.type) {
  25223. case "StringLiteral":
  25224. case "NumericLiteral":
  25225. return String(node.value);
  25226. case "Identifier":
  25227. if (!computed) return node.name;
  25228. }
  25229. return void 0;
  25230. }
  25231. function concatStrings(strs) {
  25232. return strs.filter((s) => !!s).join(", ");
  25233. }
  25234. function isLiteralNode(node) {
  25235. return node.type.endsWith("Literal");
  25236. }
  25237. function isCallOf(node, test) {
  25238. return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
  25239. }
  25240. function toRuntimeTypeString(types) {
  25241. return types.length > 1 ? `[${types.join(", ")}]` : types[0];
  25242. }
  25243. function getImportedName(specifier) {
  25244. if (specifier.type === "ImportSpecifier")
  25245. return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
  25246. else if (specifier.type === "ImportNamespaceSpecifier") return "*";
  25247. return "default";
  25248. }
  25249. function getId(node) {
  25250. return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
  25251. }
  25252. const normalize = (path.posix || path).normalize;
  25253. const windowsSlashRE = /\\/g;
  25254. function normalizePath(p) {
  25255. return normalize(p.replace(windowsSlashRE, "/"));
  25256. }
  25257. const joinPaths = (path.posix || path).join;
  25258. const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
  25259. function getEscapedPropName(key) {
  25260. return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
  25261. }
  25262. const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
  25263. function getEscapedCssVarName(key, doubleEscape) {
  25264. return key.replace(
  25265. cssVarNameEscapeSymbolsRE,
  25266. (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
  25267. );
  25268. }
  25269. function pad$1 (hash, len) {
  25270. while (hash.length < len) {
  25271. hash = '0' + hash;
  25272. }
  25273. return hash;
  25274. }
  25275. function fold (hash, text) {
  25276. var i;
  25277. var chr;
  25278. var len;
  25279. if (text.length === 0) {
  25280. return hash;
  25281. }
  25282. for (i = 0, len = text.length; i < len; i++) {
  25283. chr = text.charCodeAt(i);
  25284. hash = ((hash << 5) - hash) + chr;
  25285. hash |= 0;
  25286. }
  25287. return hash < 0 ? hash * -2 : hash;
  25288. }
  25289. function foldObject (hash, o, seen) {
  25290. return Object.keys(o).sort().reduce(foldKey, hash);
  25291. function foldKey (hash, key) {
  25292. return foldValue(hash, o[key], key, seen);
  25293. }
  25294. }
  25295. function foldValue (input, value, key, seen) {
  25296. var hash = fold(fold(fold(input, key), toString$2(value)), typeof value);
  25297. if (value === null) {
  25298. return fold(hash, 'null');
  25299. }
  25300. if (value === undefined) {
  25301. return fold(hash, 'undefined');
  25302. }
  25303. if (typeof value === 'object' || typeof value === 'function') {
  25304. if (seen.indexOf(value) !== -1) {
  25305. return fold(hash, '[Circular]' + key);
  25306. }
  25307. seen.push(value);
  25308. var objHash = foldObject(hash, value, seen);
  25309. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  25310. return objHash;
  25311. }
  25312. try {
  25313. return fold(objHash, String(value.valueOf()))
  25314. } catch (err) {
  25315. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  25316. }
  25317. }
  25318. return fold(hash, value.toString());
  25319. }
  25320. function toString$2 (o) {
  25321. return Object.prototype.toString.call(o);
  25322. }
  25323. function sum (o) {
  25324. return pad$1(foldValue(0, o, '', []).toString(16), 8);
  25325. }
  25326. var hashSum = sum;
  25327. var hash = /*@__PURE__*/getDefaultExportFromCjs(hashSum);
  25328. const CSS_VARS_HELPER = `useCssVars`;
  25329. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  25330. return `{
  25331. ${vars.map(
  25332. (key) => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
  25333. ).join(",\n ")}
  25334. }`;
  25335. }
  25336. function genVarName(id, raw, isProd, isSSR = false) {
  25337. if (isProd) {
  25338. return hash(id + raw);
  25339. } else {
  25340. return `${id}-${getEscapedCssVarName(raw, isSSR)}`;
  25341. }
  25342. }
  25343. function normalizeExpression(exp) {
  25344. exp = exp.trim();
  25345. if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) {
  25346. return exp.slice(1, -1);
  25347. }
  25348. return exp;
  25349. }
  25350. const vBindRE = /v-bind\s*\(/g;
  25351. function parseCssVars(sfc) {
  25352. const vars = [];
  25353. sfc.styles.forEach((style) => {
  25354. let match;
  25355. const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, "");
  25356. while (match = vBindRE.exec(content)) {
  25357. const start = match.index + match[0].length;
  25358. const end = lexBinding(content, start);
  25359. if (end !== null) {
  25360. const variable = normalizeExpression(content.slice(start, end));
  25361. if (!vars.includes(variable)) {
  25362. vars.push(variable);
  25363. }
  25364. }
  25365. }
  25366. });
  25367. return vars;
  25368. }
  25369. function lexBinding(content, start) {
  25370. let state = 0 /* inParens */;
  25371. let parenDepth = 0;
  25372. for (let i = start; i < content.length; i++) {
  25373. const char = content.charAt(i);
  25374. switch (state) {
  25375. case 0 /* inParens */:
  25376. if (char === `'`) {
  25377. state = 1 /* inSingleQuoteString */;
  25378. } else if (char === `"`) {
  25379. state = 2 /* inDoubleQuoteString */;
  25380. } else if (char === `(`) {
  25381. parenDepth++;
  25382. } else if (char === `)`) {
  25383. if (parenDepth > 0) {
  25384. parenDepth--;
  25385. } else {
  25386. return i;
  25387. }
  25388. }
  25389. break;
  25390. case 1 /* inSingleQuoteString */:
  25391. if (char === `'`) {
  25392. state = 0 /* inParens */;
  25393. }
  25394. break;
  25395. case 2 /* inDoubleQuoteString */:
  25396. if (char === `"`) {
  25397. state = 0 /* inParens */;
  25398. }
  25399. break;
  25400. }
  25401. }
  25402. return null;
  25403. }
  25404. const cssVarsPlugin = (opts) => {
  25405. const { id, isProd } = opts;
  25406. return {
  25407. postcssPlugin: "vue-sfc-vars",
  25408. Declaration(decl) {
  25409. const value = decl.value;
  25410. if (vBindRE.test(value)) {
  25411. vBindRE.lastIndex = 0;
  25412. let transformed = "";
  25413. let lastIndex = 0;
  25414. let match;
  25415. while (match = vBindRE.exec(value)) {
  25416. const start = match.index + match[0].length;
  25417. const end = lexBinding(value, start);
  25418. if (end !== null) {
  25419. const variable = normalizeExpression(value.slice(start, end));
  25420. transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`;
  25421. lastIndex = end + 1;
  25422. }
  25423. }
  25424. decl.value = transformed + value.slice(lastIndex);
  25425. }
  25426. }
  25427. };
  25428. };
  25429. cssVarsPlugin.postcss = true;
  25430. function genCssVarsCode(vars, bindings, id, isProd) {
  25431. const varsExp = genCssVarsFromList(vars, id, isProd);
  25432. const exp = createSimpleExpression(varsExp, false);
  25433. const context = createTransformContext(createRoot([]), {
  25434. prefixIdentifiers: true,
  25435. inline: true,
  25436. bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings
  25437. });
  25438. const transformed = processExpression(exp, context);
  25439. const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => {
  25440. return typeof c === "string" ? c : c.content;
  25441. }).join("");
  25442. return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))`;
  25443. }
  25444. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
  25445. return `
  25446. import { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'
  25447. const __injectCSSVars__ = () => {
  25448. ${genCssVarsCode(
  25449. cssVars,
  25450. bindings,
  25451. id,
  25452. isProd
  25453. )}}
  25454. const __setup__ = ${defaultVar}.setup
  25455. ${defaultVar}.setup = __setup__
  25456. ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }
  25457. : __injectCSSVars__
  25458. `;
  25459. }
  25460. var global$1 = (typeof global !== "undefined" ? global :
  25461. typeof self !== "undefined" ? self :
  25462. typeof window !== "undefined" ? window : {});
  25463. // shim for using process in browser
  25464. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  25465. function defaultSetTimout() {
  25466. throw new Error('setTimeout has not been defined');
  25467. }
  25468. function defaultClearTimeout () {
  25469. throw new Error('clearTimeout has not been defined');
  25470. }
  25471. var cachedSetTimeout = defaultSetTimout;
  25472. var cachedClearTimeout = defaultClearTimeout;
  25473. if (typeof global$1.setTimeout === 'function') {
  25474. cachedSetTimeout = setTimeout;
  25475. }
  25476. if (typeof global$1.clearTimeout === 'function') {
  25477. cachedClearTimeout = clearTimeout;
  25478. }
  25479. function runTimeout(fun) {
  25480. if (cachedSetTimeout === setTimeout) {
  25481. //normal enviroments in sane situations
  25482. return setTimeout(fun, 0);
  25483. }
  25484. // if setTimeout wasn't available but was latter defined
  25485. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  25486. cachedSetTimeout = setTimeout;
  25487. return setTimeout(fun, 0);
  25488. }
  25489. try {
  25490. // when when somebody has screwed with setTimeout but no I.E. maddness
  25491. return cachedSetTimeout(fun, 0);
  25492. } catch(e){
  25493. try {
  25494. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25495. return cachedSetTimeout.call(null, fun, 0);
  25496. } catch(e){
  25497. // 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
  25498. return cachedSetTimeout.call(this, fun, 0);
  25499. }
  25500. }
  25501. }
  25502. function runClearTimeout(marker) {
  25503. if (cachedClearTimeout === clearTimeout) {
  25504. //normal enviroments in sane situations
  25505. return clearTimeout(marker);
  25506. }
  25507. // if clearTimeout wasn't available but was latter defined
  25508. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  25509. cachedClearTimeout = clearTimeout;
  25510. return clearTimeout(marker);
  25511. }
  25512. try {
  25513. // when when somebody has screwed with setTimeout but no I.E. maddness
  25514. return cachedClearTimeout(marker);
  25515. } catch (e){
  25516. try {
  25517. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  25518. return cachedClearTimeout.call(null, marker);
  25519. } catch (e){
  25520. // 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.
  25521. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  25522. return cachedClearTimeout.call(this, marker);
  25523. }
  25524. }
  25525. }
  25526. var queue = [];
  25527. var draining = false;
  25528. var currentQueue;
  25529. var queueIndex = -1;
  25530. function cleanUpNextTick() {
  25531. if (!draining || !currentQueue) {
  25532. return;
  25533. }
  25534. draining = false;
  25535. if (currentQueue.length) {
  25536. queue = currentQueue.concat(queue);
  25537. } else {
  25538. queueIndex = -1;
  25539. }
  25540. if (queue.length) {
  25541. drainQueue();
  25542. }
  25543. }
  25544. function drainQueue() {
  25545. if (draining) {
  25546. return;
  25547. }
  25548. var timeout = runTimeout(cleanUpNextTick);
  25549. draining = true;
  25550. var len = queue.length;
  25551. while(len) {
  25552. currentQueue = queue;
  25553. queue = [];
  25554. while (++queueIndex < len) {
  25555. if (currentQueue) {
  25556. currentQueue[queueIndex].run();
  25557. }
  25558. }
  25559. queueIndex = -1;
  25560. len = queue.length;
  25561. }
  25562. currentQueue = null;
  25563. draining = false;
  25564. runClearTimeout(timeout);
  25565. }
  25566. function nextTick(fun) {
  25567. var args = new Array(arguments.length - 1);
  25568. if (arguments.length > 1) {
  25569. for (var i = 1; i < arguments.length; i++) {
  25570. args[i - 1] = arguments[i];
  25571. }
  25572. }
  25573. queue.push(new Item(fun, args));
  25574. if (queue.length === 1 && !draining) {
  25575. runTimeout(drainQueue);
  25576. }
  25577. }
  25578. // v8 likes predictible objects
  25579. function Item(fun, array) {
  25580. this.fun = fun;
  25581. this.array = array;
  25582. }
  25583. Item.prototype.run = function () {
  25584. this.fun.apply(null, this.array);
  25585. };
  25586. var title = 'browser';
  25587. var platform = 'browser';
  25588. var browser = true;
  25589. var env$1 = {};
  25590. var argv$1 = [];
  25591. var version$1 = ''; // empty string to avoid regexp issues
  25592. var versions = {};
  25593. var release = {};
  25594. var config = {};
  25595. function noop() {}
  25596. var on = noop;
  25597. var addListener = noop;
  25598. var once = noop;
  25599. var off = noop;
  25600. var removeListener = noop;
  25601. var removeAllListeners = noop;
  25602. var emit = noop;
  25603. function binding(name) {
  25604. throw new Error('process.binding is not supported');
  25605. }
  25606. function cwd () { return '/' }
  25607. function chdir (dir) {
  25608. throw new Error('process.chdir is not supported');
  25609. }function umask() { return 0; }
  25610. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  25611. var performance = global$1.performance || {};
  25612. var performanceNow =
  25613. performance.now ||
  25614. performance.mozNow ||
  25615. performance.msNow ||
  25616. performance.oNow ||
  25617. performance.webkitNow ||
  25618. function(){ return (new Date()).getTime() };
  25619. // generate timestamp or delta
  25620. // see http://nodejs.org/api/process.html#process_process_hrtime
  25621. function hrtime(previousTimestamp){
  25622. var clocktime = performanceNow.call(performance)*1e-3;
  25623. var seconds = Math.floor(clocktime);
  25624. var nanoseconds = Math.floor((clocktime%1)*1e9);
  25625. if (previousTimestamp) {
  25626. seconds = seconds - previousTimestamp[0];
  25627. nanoseconds = nanoseconds - previousTimestamp[1];
  25628. if (nanoseconds<0) {
  25629. seconds--;
  25630. nanoseconds += 1e9;
  25631. }
  25632. }
  25633. return [seconds,nanoseconds]
  25634. }
  25635. var startTime = new Date();
  25636. function uptime() {
  25637. var currentTime = new Date();
  25638. var dif = currentTime - startTime;
  25639. return dif / 1000;
  25640. }
  25641. var browser$1 = {
  25642. nextTick: nextTick,
  25643. title: title,
  25644. browser: browser,
  25645. env: env$1,
  25646. argv: argv$1,
  25647. version: version$1,
  25648. versions: versions,
  25649. on: on,
  25650. addListener: addListener,
  25651. once: once,
  25652. off: off,
  25653. removeListener: removeListener,
  25654. removeAllListeners: removeAllListeners,
  25655. emit: emit,
  25656. binding: binding,
  25657. cwd: cwd,
  25658. chdir: chdir,
  25659. umask: umask,
  25660. hrtime: hrtime,
  25661. platform: platform,
  25662. release: release,
  25663. config: config,
  25664. uptime: uptime
  25665. };
  25666. function createCache(max = 500) {
  25667. {
  25668. return /* @__PURE__ */ new Map();
  25669. }
  25670. }
  25671. function isImportUsed(local, sfc) {
  25672. return resolveTemplateUsedIdentifiers(sfc).has(local);
  25673. }
  25674. const templateUsageCheckCache = createCache();
  25675. function resolveTemplateUsedIdentifiers(sfc) {
  25676. const { content, ast } = sfc.template;
  25677. const cached = templateUsageCheckCache.get(content);
  25678. if (cached) {
  25679. return cached;
  25680. }
  25681. const ids = /* @__PURE__ */ new Set();
  25682. ast.children.forEach(walk);
  25683. function walk(node) {
  25684. var _a;
  25685. switch (node.type) {
  25686. case 1:
  25687. let tag = node.tag;
  25688. if (tag.includes(".")) tag = tag.split(".")[0].trim();
  25689. if (!parserOptions.isNativeTag(tag) && !parserOptions.isBuiltInComponent(tag)) {
  25690. ids.add(camelize(tag));
  25691. ids.add(capitalize$1(camelize(tag)));
  25692. }
  25693. for (let i = 0; i < node.props.length; i++) {
  25694. const prop = node.props[i];
  25695. if (prop.type === 7) {
  25696. if (!isBuiltInDirective(prop.name)) {
  25697. ids.add(`v${capitalize$1(camelize(prop.name))}`);
  25698. }
  25699. if (prop.arg && !prop.arg.isStatic) {
  25700. extractIdentifiers(ids, prop.arg);
  25701. }
  25702. if (prop.name === "for") {
  25703. extractIdentifiers(ids, prop.forParseResult.source);
  25704. } else if (prop.exp) {
  25705. extractIdentifiers(ids, prop.exp);
  25706. } else if (prop.name === "bind" && !prop.exp) {
  25707. ids.add(prop.arg.content);
  25708. }
  25709. }
  25710. if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
  25711. ids.add(prop.value.content);
  25712. }
  25713. }
  25714. node.children.forEach(walk);
  25715. break;
  25716. case 5:
  25717. extractIdentifiers(ids, node.content);
  25718. break;
  25719. }
  25720. }
  25721. templateUsageCheckCache.set(content, ids);
  25722. return ids;
  25723. }
  25724. function extractIdentifiers(ids, node) {
  25725. if (node.ast) {
  25726. walkIdentifiers(node.ast, (n) => ids.add(n.name));
  25727. } else if (node.ast === null) {
  25728. ids.add(node.content);
  25729. }
  25730. }
  25731. var __defProp$a = Object.defineProperty;
  25732. var __defProps$9 = Object.defineProperties;
  25733. var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
  25734. var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
  25735. var __hasOwnProp$a = Object.prototype.hasOwnProperty;
  25736. var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
  25737. var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  25738. var __spreadValues$a = (a, b) => {
  25739. for (var prop in b || (b = {}))
  25740. if (__hasOwnProp$a.call(b, prop))
  25741. __defNormalProp$a(a, prop, b[prop]);
  25742. if (__getOwnPropSymbols$a)
  25743. for (var prop of __getOwnPropSymbols$a(b)) {
  25744. if (__propIsEnum$a.call(b, prop))
  25745. __defNormalProp$a(a, prop, b[prop]);
  25746. }
  25747. return a;
  25748. };
  25749. var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
  25750. const DEFAULT_FILENAME = "anonymous.vue";
  25751. const parseCache$1 = createCache();
  25752. function genCacheKey(source, options) {
  25753. var _a;
  25754. return source + JSON.stringify(
  25755. __spreadProps$9(__spreadValues$a({}, options), {
  25756. compiler: { parse: (_a = options.compiler) == null ? void 0 : _a.parse }
  25757. }),
  25758. (_, val) => typeof val === "function" ? val.toString() : val
  25759. );
  25760. }
  25761. function parse$7(source, options = {}) {
  25762. const sourceKey = genCacheKey(source, options);
  25763. const cache = parseCache$1.get(sourceKey);
  25764. if (cache) {
  25765. return cache;
  25766. }
  25767. const {
  25768. sourceMap = true,
  25769. filename = DEFAULT_FILENAME,
  25770. sourceRoot = "",
  25771. pad = false,
  25772. ignoreEmpty = true,
  25773. compiler = CompilerDOM,
  25774. templateParseOptions = {},
  25775. parseExpressions = true
  25776. } = options;
  25777. const descriptor = {
  25778. filename,
  25779. source,
  25780. template: null,
  25781. script: null,
  25782. scriptSetup: null,
  25783. styles: [],
  25784. customBlocks: [],
  25785. cssVars: [],
  25786. slotted: false,
  25787. shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor)
  25788. };
  25789. const errors = [];
  25790. const ast = compiler.parse(source, __spreadProps$9(__spreadValues$a({
  25791. parseMode: "sfc",
  25792. prefixIdentifiers: parseExpressions
  25793. }, templateParseOptions), {
  25794. onError: (e) => {
  25795. errors.push(e);
  25796. }
  25797. }));
  25798. ast.children.forEach((node) => {
  25799. if (node.type !== 1) {
  25800. return;
  25801. }
  25802. if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasSrc(node)) {
  25803. return;
  25804. }
  25805. switch (node.tag) {
  25806. case "template":
  25807. if (!descriptor.template) {
  25808. const templateBlock = descriptor.template = createBlock(
  25809. node,
  25810. source,
  25811. false
  25812. );
  25813. if (!templateBlock.attrs.src) {
  25814. templateBlock.ast = createRoot(node.children, source);
  25815. }
  25816. if (templateBlock.attrs.functional) {
  25817. const err = new SyntaxError(
  25818. `<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.`
  25819. );
  25820. err.loc = node.props.find(
  25821. (p) => p.type === 6 && p.name === "functional"
  25822. ).loc;
  25823. errors.push(err);
  25824. }
  25825. } else {
  25826. errors.push(createDuplicateBlockError(node));
  25827. }
  25828. break;
  25829. case "script":
  25830. const scriptBlock = createBlock(node, source, pad);
  25831. const isSetup = !!scriptBlock.attrs.setup;
  25832. if (isSetup && !descriptor.scriptSetup) {
  25833. descriptor.scriptSetup = scriptBlock;
  25834. break;
  25835. }
  25836. if (!isSetup && !descriptor.script) {
  25837. descriptor.script = scriptBlock;
  25838. break;
  25839. }
  25840. errors.push(createDuplicateBlockError(node, isSetup));
  25841. break;
  25842. case "style":
  25843. const styleBlock = createBlock(node, source, pad);
  25844. if (styleBlock.attrs.vars) {
  25845. errors.push(
  25846. new SyntaxError(
  25847. `<style vars> has been replaced by a new proposal: https://github.com/vuejs/rfcs/pull/231`
  25848. )
  25849. );
  25850. }
  25851. descriptor.styles.push(styleBlock);
  25852. break;
  25853. default:
  25854. descriptor.customBlocks.push(createBlock(node, source, pad));
  25855. break;
  25856. }
  25857. });
  25858. if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
  25859. errors.push(
  25860. new SyntaxError(
  25861. `At least one <template> or <script> is required in a single file component.`
  25862. )
  25863. );
  25864. }
  25865. if (descriptor.scriptSetup) {
  25866. if (descriptor.scriptSetup.src) {
  25867. errors.push(
  25868. new SyntaxError(
  25869. `<script setup> cannot use the "src" attribute because its syntax will be ambiguous outside of the component.`
  25870. )
  25871. );
  25872. descriptor.scriptSetup = null;
  25873. }
  25874. if (descriptor.script && descriptor.script.src) {
  25875. errors.push(
  25876. new SyntaxError(
  25877. `<script> cannot use the "src" attribute when <script setup> is also present because they must be processed together.`
  25878. )
  25879. );
  25880. descriptor.script = null;
  25881. }
  25882. }
  25883. let templateColumnOffset = 0;
  25884. if (descriptor.template && (descriptor.template.lang === "pug" || descriptor.template.lang === "jade")) {
  25885. [descriptor.template.content, templateColumnOffset] = dedent(
  25886. descriptor.template.content
  25887. );
  25888. }
  25889. if (sourceMap) {
  25890. const genMap = (block, columnOffset = 0) => {
  25891. if (block && !block.src) {
  25892. block.map = generateSourceMap(
  25893. filename,
  25894. source,
  25895. block.content,
  25896. sourceRoot,
  25897. !pad || block.type === "template" ? block.loc.start.line - 1 : 0,
  25898. columnOffset
  25899. );
  25900. }
  25901. };
  25902. genMap(descriptor.template, templateColumnOffset);
  25903. genMap(descriptor.script);
  25904. descriptor.styles.forEach((s) => genMap(s));
  25905. descriptor.customBlocks.forEach((s) => genMap(s));
  25906. }
  25907. descriptor.cssVars = parseCssVars(descriptor);
  25908. const slottedRE = /(?:::v-|:)slotted\(/;
  25909. descriptor.slotted = descriptor.styles.some(
  25910. (s) => s.scoped && slottedRE.test(s.content)
  25911. );
  25912. const result = {
  25913. descriptor,
  25914. errors
  25915. };
  25916. parseCache$1.set(sourceKey, result);
  25917. return result;
  25918. }
  25919. function createDuplicateBlockError(node, isScriptSetup = false) {
  25920. const err = new SyntaxError(
  25921. `Single file component can contain only one <${node.tag}${isScriptSetup ? ` setup` : ``}> element`
  25922. );
  25923. err.loc = node.loc;
  25924. return err;
  25925. }
  25926. function createBlock(node, source, pad) {
  25927. const type = node.tag;
  25928. const loc = node.innerLoc;
  25929. const attrs = {};
  25930. const block = {
  25931. type,
  25932. content: source.slice(loc.start.offset, loc.end.offset),
  25933. loc,
  25934. attrs
  25935. };
  25936. if (pad) {
  25937. block.content = padContent(source, block, pad) + block.content;
  25938. }
  25939. node.props.forEach((p) => {
  25940. if (p.type === 6) {
  25941. const name = p.name;
  25942. attrs[name] = p.value ? p.value.content || true : true;
  25943. if (name === "lang") {
  25944. block.lang = p.value && p.value.content;
  25945. } else if (name === "src") {
  25946. block.src = p.value && p.value.content;
  25947. } else if (type === "style") {
  25948. if (name === "scoped") {
  25949. block.scoped = true;
  25950. } else if (name === "module") {
  25951. block.module = attrs[name];
  25952. }
  25953. } else if (type === "script" && name === "setup") {
  25954. block.setup = attrs.setup;
  25955. }
  25956. }
  25957. });
  25958. return block;
  25959. }
  25960. const splitRE = /\r?\n/g;
  25961. const emptyRE = /^(?:\/\/)?\s*$/;
  25962. const replaceRE = /./g;
  25963. function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
  25964. const map = new SourceMapGenerator$6({
  25965. file: filename.replace(/\\/g, "/"),
  25966. sourceRoot: sourceRoot.replace(/\\/g, "/")
  25967. });
  25968. map.setSourceContent(filename, source);
  25969. map._sources.add(filename);
  25970. generated.split(splitRE).forEach((line, index) => {
  25971. if (!emptyRE.test(line)) {
  25972. const originalLine = index + 1 + lineOffset;
  25973. const generatedLine = index + 1;
  25974. for (let i = 0; i < line.length; i++) {
  25975. if (!/\s/.test(line[i])) {
  25976. map._mappings.add({
  25977. originalLine,
  25978. originalColumn: i + columnOffset,
  25979. generatedLine,
  25980. generatedColumn: i,
  25981. source: filename,
  25982. name: null
  25983. });
  25984. }
  25985. }
  25986. }
  25987. });
  25988. return map.toJSON();
  25989. }
  25990. function padContent(content, block, pad) {
  25991. content = content.slice(0, block.loc.start.offset);
  25992. if (pad === "space") {
  25993. return content.replace(replaceRE, " ");
  25994. } else {
  25995. const offset = content.split(splitRE).length;
  25996. const padChar = block.type === "script" && !block.lang ? "//\n" : "\n";
  25997. return Array(offset).join(padChar);
  25998. }
  25999. }
  26000. function hasSrc(node) {
  26001. return node.props.some((p) => {
  26002. if (p.type !== 6) {
  26003. return false;
  26004. }
  26005. return p.name === "src";
  26006. });
  26007. }
  26008. function isEmpty(node) {
  26009. for (let i = 0; i < node.children.length; i++) {
  26010. const child = node.children[i];
  26011. if (child.type !== 2 || child.content.trim() !== "") {
  26012. return false;
  26013. }
  26014. }
  26015. return true;
  26016. }
  26017. function hmrShouldReload(prevImports, next) {
  26018. if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
  26019. return false;
  26020. }
  26021. for (const key in prevImports) {
  26022. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) {
  26023. return true;
  26024. }
  26025. }
  26026. return false;
  26027. }
  26028. function dedent(s) {
  26029. const lines = s.split("\n");
  26030. const minIndent = lines.reduce(function(minIndent2, line) {
  26031. var _a, _b;
  26032. if (line.trim() === "") {
  26033. return minIndent2;
  26034. }
  26035. const indent = ((_b = (_a = line.match(/^\s*/)) == null ? void 0 : _a[0]) == null ? void 0 : _b.length) || 0;
  26036. return Math.min(indent, minIndent2);
  26037. }, Infinity);
  26038. if (minIndent === 0) {
  26039. return [s, minIndent];
  26040. }
  26041. return [
  26042. lines.map(function(line) {
  26043. return line.slice(minIndent);
  26044. }).join("\n"),
  26045. minIndent
  26046. ];
  26047. }
  26048. /*! https://mths.be/punycode v1.4.1 by @mathias */
  26049. /** Highest positive signed 32-bit float value */
  26050. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  26051. /** Bootstring parameters */
  26052. var base = 36;
  26053. var tMin = 1;
  26054. var tMax = 26;
  26055. var skew = 38;
  26056. var damp = 700;
  26057. var initialBias = 72;
  26058. var initialN = 128; // 0x80
  26059. var delimiter = '-'; // '\x2D'
  26060. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  26061. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  26062. /** Error messages */
  26063. var errors = {
  26064. 'overflow': 'Overflow: input needs wider integers to process',
  26065. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  26066. 'invalid-input': 'Invalid input'
  26067. };
  26068. /** Convenience shortcuts */
  26069. var baseMinusTMin = base - tMin;
  26070. var floor = Math.floor;
  26071. var stringFromCharCode = String.fromCharCode;
  26072. /*--------------------------------------------------------------------------*/
  26073. /**
  26074. * A generic error utility function.
  26075. * @private
  26076. * @param {String} type The error type.
  26077. * @returns {Error} Throws a `RangeError` with the applicable error message.
  26078. */
  26079. function error(type) {
  26080. throw new RangeError(errors[type]);
  26081. }
  26082. /**
  26083. * A generic `Array#map` utility function.
  26084. * @private
  26085. * @param {Array} array The array to iterate over.
  26086. * @param {Function} callback The function that gets called for every array
  26087. * item.
  26088. * @returns {Array} A new array of values returned by the callback function.
  26089. */
  26090. function map$1(array, fn) {
  26091. var length = array.length;
  26092. var result = [];
  26093. while (length--) {
  26094. result[length] = fn(array[length]);
  26095. }
  26096. return result;
  26097. }
  26098. /**
  26099. * A simple `Array#map`-like wrapper to work with domain name strings or email
  26100. * addresses.
  26101. * @private
  26102. * @param {String} domain The domain name or email address.
  26103. * @param {Function} callback The function that gets called for every
  26104. * character.
  26105. * @returns {Array} A new string of characters returned by the callback
  26106. * function.
  26107. */
  26108. function mapDomain(string, fn) {
  26109. var parts = string.split('@');
  26110. var result = '';
  26111. if (parts.length > 1) {
  26112. // In email addresses, only the domain name should be punycoded. Leave
  26113. // the local part (i.e. everything up to `@`) intact.
  26114. result = parts[0] + '@';
  26115. string = parts[1];
  26116. }
  26117. // Avoid `split(regex)` for IE8 compatibility. See #17.
  26118. string = string.replace(regexSeparators, '\x2E');
  26119. var labels = string.split('.');
  26120. var encoded = map$1(labels, fn).join('.');
  26121. return result + encoded;
  26122. }
  26123. /**
  26124. * Creates an array containing the numeric code points of each Unicode
  26125. * character in the string. While JavaScript uses UCS-2 internally,
  26126. * this function will convert a pair of surrogate halves (each of which
  26127. * UCS-2 exposes as separate characters) into a single code point,
  26128. * matching UTF-16.
  26129. * @see `punycode.ucs2.encode`
  26130. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  26131. * @memberOf punycode.ucs2
  26132. * @name decode
  26133. * @param {String} string The Unicode input string (UCS-2).
  26134. * @returns {Array} The new array of code points.
  26135. */
  26136. function ucs2decode(string) {
  26137. var output = [],
  26138. counter = 0,
  26139. length = string.length,
  26140. value,
  26141. extra;
  26142. while (counter < length) {
  26143. value = string.charCodeAt(counter++);
  26144. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  26145. // high surrogate, and there is a next character
  26146. extra = string.charCodeAt(counter++);
  26147. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  26148. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  26149. } else {
  26150. // unmatched surrogate; only append this code unit, in case the next
  26151. // code unit is the high surrogate of a surrogate pair
  26152. output.push(value);
  26153. counter--;
  26154. }
  26155. } else {
  26156. output.push(value);
  26157. }
  26158. }
  26159. return output;
  26160. }
  26161. /**
  26162. * Converts a digit/integer into a basic code point.
  26163. * @see `basicToDigit()`
  26164. * @private
  26165. * @param {Number} digit The numeric value of a basic code point.
  26166. * @returns {Number} The basic code point whose value (when used for
  26167. * representing integers) is `digit`, which needs to be in the range
  26168. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  26169. * used; else, the lowercase form is used. The behavior is undefined
  26170. * if `flag` is non-zero and `digit` has no uppercase form.
  26171. */
  26172. function digitToBasic(digit, flag) {
  26173. // 0..25 map to ASCII a..z or A..Z
  26174. // 26..35 map to ASCII 0..9
  26175. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  26176. }
  26177. /**
  26178. * Bias adaptation function as per section 3.4 of RFC 3492.
  26179. * https://tools.ietf.org/html/rfc3492#section-3.4
  26180. * @private
  26181. */
  26182. function adapt(delta, numPoints, firstTime) {
  26183. var k = 0;
  26184. delta = firstTime ? floor(delta / damp) : delta >> 1;
  26185. delta += floor(delta / numPoints);
  26186. for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
  26187. delta = floor(delta / baseMinusTMin);
  26188. }
  26189. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  26190. }
  26191. /**
  26192. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  26193. * Punycode string of ASCII-only symbols.
  26194. * @memberOf punycode
  26195. * @param {String} input The string of Unicode symbols.
  26196. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  26197. */
  26198. function encode$1(input) {
  26199. var n,
  26200. delta,
  26201. handledCPCount,
  26202. basicLength,
  26203. bias,
  26204. j,
  26205. m,
  26206. q,
  26207. k,
  26208. t,
  26209. currentValue,
  26210. output = [],
  26211. /** `inputLength` will hold the number of code points in `input`. */
  26212. inputLength,
  26213. /** Cached calculation results */
  26214. handledCPCountPlusOne,
  26215. baseMinusT,
  26216. qMinusT;
  26217. // Convert the input in UCS-2 to Unicode
  26218. input = ucs2decode(input);
  26219. // Cache the length
  26220. inputLength = input.length;
  26221. // Initialize the state
  26222. n = initialN;
  26223. delta = 0;
  26224. bias = initialBias;
  26225. // Handle the basic code points
  26226. for (j = 0; j < inputLength; ++j) {
  26227. currentValue = input[j];
  26228. if (currentValue < 0x80) {
  26229. output.push(stringFromCharCode(currentValue));
  26230. }
  26231. }
  26232. handledCPCount = basicLength = output.length;
  26233. // `handledCPCount` is the number of code points that have been handled;
  26234. // `basicLength` is the number of basic code points.
  26235. // Finish the basic string - if it is not empty - with a delimiter
  26236. if (basicLength) {
  26237. output.push(delimiter);
  26238. }
  26239. // Main encoding loop:
  26240. while (handledCPCount < inputLength) {
  26241. // All non-basic code points < n have been handled already. Find the next
  26242. // larger one:
  26243. for (m = maxInt, j = 0; j < inputLength; ++j) {
  26244. currentValue = input[j];
  26245. if (currentValue >= n && currentValue < m) {
  26246. m = currentValue;
  26247. }
  26248. }
  26249. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  26250. // but guard against overflow
  26251. handledCPCountPlusOne = handledCPCount + 1;
  26252. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  26253. error('overflow');
  26254. }
  26255. delta += (m - n) * handledCPCountPlusOne;
  26256. n = m;
  26257. for (j = 0; j < inputLength; ++j) {
  26258. currentValue = input[j];
  26259. if (currentValue < n && ++delta > maxInt) {
  26260. error('overflow');
  26261. }
  26262. if (currentValue == n) {
  26263. // Represent delta as a generalized variable-length integer
  26264. for (q = delta, k = base; /* no condition */ ; k += base) {
  26265. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  26266. if (q < t) {
  26267. break;
  26268. }
  26269. qMinusT = q - t;
  26270. baseMinusT = base - t;
  26271. output.push(
  26272. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  26273. );
  26274. q = floor(qMinusT / baseMinusT);
  26275. }
  26276. output.push(stringFromCharCode(digitToBasic(q, 0)));
  26277. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  26278. delta = 0;
  26279. ++handledCPCount;
  26280. }
  26281. }
  26282. ++delta;
  26283. ++n;
  26284. }
  26285. return output.join('');
  26286. }
  26287. /**
  26288. * Converts a Unicode string representing a domain name or an email address to
  26289. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  26290. * i.e. it doesn't matter if you call it with a domain that's already in
  26291. * ASCII.
  26292. * @memberOf punycode
  26293. * @param {String} input The domain name or email address to convert, as a
  26294. * Unicode string.
  26295. * @returns {String} The Punycode representation of the given domain name or
  26296. * email address.
  26297. */
  26298. function toASCII(input) {
  26299. return mapDomain(input, function(string) {
  26300. return regexNonASCII.test(string) ?
  26301. 'xn--' + encode$1(string) :
  26302. string;
  26303. });
  26304. }
  26305. var lookup = [];
  26306. var revLookup = [];
  26307. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  26308. var inited = false;
  26309. function init () {
  26310. inited = true;
  26311. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  26312. for (var i = 0, len = code.length; i < len; ++i) {
  26313. lookup[i] = code[i];
  26314. revLookup[code.charCodeAt(i)] = i;
  26315. }
  26316. revLookup['-'.charCodeAt(0)] = 62;
  26317. revLookup['_'.charCodeAt(0)] = 63;
  26318. }
  26319. function toByteArray (b64) {
  26320. if (!inited) {
  26321. init();
  26322. }
  26323. var i, j, l, tmp, placeHolders, arr;
  26324. var len = b64.length;
  26325. if (len % 4 > 0) {
  26326. throw new Error('Invalid string. Length must be a multiple of 4')
  26327. }
  26328. // the number of equal signs (place holders)
  26329. // if there are two placeholders, than the two characters before it
  26330. // represent one byte
  26331. // if there is only one, then the three characters before it represent 2 bytes
  26332. // this is just a cheap hack to not do indexOf twice
  26333. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
  26334. // base64 is 4/3 + up to two characters of the original data
  26335. arr = new Arr(len * 3 / 4 - placeHolders);
  26336. // if there are placeholders, only get up to the last complete 4 chars
  26337. l = placeHolders > 0 ? len - 4 : len;
  26338. var L = 0;
  26339. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  26340. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
  26341. arr[L++] = (tmp >> 16) & 0xFF;
  26342. arr[L++] = (tmp >> 8) & 0xFF;
  26343. arr[L++] = tmp & 0xFF;
  26344. }
  26345. if (placeHolders === 2) {
  26346. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
  26347. arr[L++] = tmp & 0xFF;
  26348. } else if (placeHolders === 1) {
  26349. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
  26350. arr[L++] = (tmp >> 8) & 0xFF;
  26351. arr[L++] = tmp & 0xFF;
  26352. }
  26353. return arr
  26354. }
  26355. function tripletToBase64 (num) {
  26356. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  26357. }
  26358. function encodeChunk (uint8, start, end) {
  26359. var tmp;
  26360. var output = [];
  26361. for (var i = start; i < end; i += 3) {
  26362. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
  26363. output.push(tripletToBase64(tmp));
  26364. }
  26365. return output.join('')
  26366. }
  26367. function fromByteArray (uint8) {
  26368. if (!inited) {
  26369. init();
  26370. }
  26371. var tmp;
  26372. var len = uint8.length;
  26373. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  26374. var output = '';
  26375. var parts = [];
  26376. var maxChunkLength = 16383; // must be multiple of 3
  26377. // go through the array every three bytes, we'll deal with trailing stuff later
  26378. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  26379. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
  26380. }
  26381. // pad the end with zeros, but make sure to not forget the extra bytes
  26382. if (extraBytes === 1) {
  26383. tmp = uint8[len - 1];
  26384. output += lookup[tmp >> 2];
  26385. output += lookup[(tmp << 4) & 0x3F];
  26386. output += '==';
  26387. } else if (extraBytes === 2) {
  26388. tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
  26389. output += lookup[tmp >> 10];
  26390. output += lookup[(tmp >> 4) & 0x3F];
  26391. output += lookup[(tmp << 2) & 0x3F];
  26392. output += '=';
  26393. }
  26394. parts.push(output);
  26395. return parts.join('')
  26396. }
  26397. function read (buffer, offset, isLE, mLen, nBytes) {
  26398. var e, m;
  26399. var eLen = nBytes * 8 - mLen - 1;
  26400. var eMax = (1 << eLen) - 1;
  26401. var eBias = eMax >> 1;
  26402. var nBits = -7;
  26403. var i = isLE ? (nBytes - 1) : 0;
  26404. var d = isLE ? -1 : 1;
  26405. var s = buffer[offset + i];
  26406. i += d;
  26407. e = s & ((1 << (-nBits)) - 1);
  26408. s >>= (-nBits);
  26409. nBits += eLen;
  26410. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26411. m = e & ((1 << (-nBits)) - 1);
  26412. e >>= (-nBits);
  26413. nBits += mLen;
  26414. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  26415. if (e === 0) {
  26416. e = 1 - eBias;
  26417. } else if (e === eMax) {
  26418. return m ? NaN : ((s ? -1 : 1) * Infinity)
  26419. } else {
  26420. m = m + Math.pow(2, mLen);
  26421. e = e - eBias;
  26422. }
  26423. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  26424. }
  26425. function write (buffer, value, offset, isLE, mLen, nBytes) {
  26426. var e, m, c;
  26427. var eLen = nBytes * 8 - mLen - 1;
  26428. var eMax = (1 << eLen) - 1;
  26429. var eBias = eMax >> 1;
  26430. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
  26431. var i = isLE ? 0 : (nBytes - 1);
  26432. var d = isLE ? 1 : -1;
  26433. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
  26434. value = Math.abs(value);
  26435. if (isNaN(value) || value === Infinity) {
  26436. m = isNaN(value) ? 1 : 0;
  26437. e = eMax;
  26438. } else {
  26439. e = Math.floor(Math.log(value) / Math.LN2);
  26440. if (value * (c = Math.pow(2, -e)) < 1) {
  26441. e--;
  26442. c *= 2;
  26443. }
  26444. if (e + eBias >= 1) {
  26445. value += rt / c;
  26446. } else {
  26447. value += rt * Math.pow(2, 1 - eBias);
  26448. }
  26449. if (value * c >= 2) {
  26450. e++;
  26451. c /= 2;
  26452. }
  26453. if (e + eBias >= eMax) {
  26454. m = 0;
  26455. e = eMax;
  26456. } else if (e + eBias >= 1) {
  26457. m = (value * c - 1) * Math.pow(2, mLen);
  26458. e = e + eBias;
  26459. } else {
  26460. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  26461. e = 0;
  26462. }
  26463. }
  26464. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  26465. e = (e << mLen) | m;
  26466. eLen += mLen;
  26467. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  26468. buffer[offset + i - d] |= s * 128;
  26469. }
  26470. var toString$1 = {}.toString;
  26471. var isArray$2 = Array.isArray || function (arr) {
  26472. return toString$1.call(arr) == '[object Array]';
  26473. };
  26474. /*!
  26475. * The buffer module from node.js, for the browser.
  26476. *
  26477. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  26478. * @license MIT
  26479. */
  26480. /* eslint-disable no-proto */
  26481. var INSPECT_MAX_BYTES = 50;
  26482. /**
  26483. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  26484. * === true Use Uint8Array implementation (fastest)
  26485. * === false Use Object implementation (most compatible, even IE6)
  26486. *
  26487. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  26488. * Opera 11.6+, iOS 4.2+.
  26489. *
  26490. * Due to various browser bugs, sometimes the Object implementation will be used even
  26491. * when the browser supports typed arrays.
  26492. *
  26493. * Note:
  26494. *
  26495. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  26496. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  26497. *
  26498. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  26499. *
  26500. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  26501. * incorrect length in some situations.
  26502. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  26503. * get the Object implementation, which is slower but behaves correctly.
  26504. */
  26505. Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
  26506. ? global$1.TYPED_ARRAY_SUPPORT
  26507. : true;
  26508. /*
  26509. * Export kMaxLength after typed array support is determined.
  26510. */
  26511. kMaxLength();
  26512. function kMaxLength () {
  26513. return Buffer$1.TYPED_ARRAY_SUPPORT
  26514. ? 0x7fffffff
  26515. : 0x3fffffff
  26516. }
  26517. function createBuffer (that, length) {
  26518. if (kMaxLength() < length) {
  26519. throw new RangeError('Invalid typed array length')
  26520. }
  26521. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26522. // Return an augmented `Uint8Array` instance, for best performance
  26523. that = new Uint8Array(length);
  26524. that.__proto__ = Buffer$1.prototype;
  26525. } else {
  26526. // Fallback: Return an object instance of the Buffer class
  26527. if (that === null) {
  26528. that = new Buffer$1(length);
  26529. }
  26530. that.length = length;
  26531. }
  26532. return that
  26533. }
  26534. /**
  26535. * The Buffer constructor returns instances of `Uint8Array` that have their
  26536. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  26537. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  26538. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  26539. * returns a single octet.
  26540. *
  26541. * The `Uint8Array` prototype remains unmodified.
  26542. */
  26543. function Buffer$1 (arg, encodingOrOffset, length) {
  26544. if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
  26545. return new Buffer$1(arg, encodingOrOffset, length)
  26546. }
  26547. // Common case.
  26548. if (typeof arg === 'number') {
  26549. if (typeof encodingOrOffset === 'string') {
  26550. throw new Error(
  26551. 'If encoding is specified then the first argument must be a string'
  26552. )
  26553. }
  26554. return allocUnsafe(this, arg)
  26555. }
  26556. return from(this, arg, encodingOrOffset, length)
  26557. }
  26558. Buffer$1.poolSize = 8192; // not used by this implementation
  26559. // TODO: Legacy, not needed anymore. Remove in next major version.
  26560. Buffer$1._augment = function (arr) {
  26561. arr.__proto__ = Buffer$1.prototype;
  26562. return arr
  26563. };
  26564. function from (that, value, encodingOrOffset, length) {
  26565. if (typeof value === 'number') {
  26566. throw new TypeError('"value" argument must not be a number')
  26567. }
  26568. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  26569. return fromArrayBuffer(that, value, encodingOrOffset, length)
  26570. }
  26571. if (typeof value === 'string') {
  26572. return fromString(that, value, encodingOrOffset)
  26573. }
  26574. return fromObject(that, value)
  26575. }
  26576. /**
  26577. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  26578. * if value is a number.
  26579. * Buffer.from(str[, encoding])
  26580. * Buffer.from(array)
  26581. * Buffer.from(buffer)
  26582. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  26583. **/
  26584. Buffer$1.from = function (value, encodingOrOffset, length) {
  26585. return from(null, value, encodingOrOffset, length)
  26586. };
  26587. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26588. Buffer$1.prototype.__proto__ = Uint8Array.prototype;
  26589. Buffer$1.__proto__ = Uint8Array;
  26590. if (typeof Symbol !== 'undefined' && Symbol.species &&
  26591. Buffer$1[Symbol.species] === Buffer$1) ;
  26592. }
  26593. function assertSize (size) {
  26594. if (typeof size !== 'number') {
  26595. throw new TypeError('"size" argument must be a number')
  26596. } else if (size < 0) {
  26597. throw new RangeError('"size" argument must not be negative')
  26598. }
  26599. }
  26600. function alloc (that, size, fill, encoding) {
  26601. assertSize(size);
  26602. if (size <= 0) {
  26603. return createBuffer(that, size)
  26604. }
  26605. if (fill !== undefined) {
  26606. // Only pay attention to encoding if it's a string. This
  26607. // prevents accidentally sending in a number that would
  26608. // be interpretted as a start offset.
  26609. return typeof encoding === 'string'
  26610. ? createBuffer(that, size).fill(fill, encoding)
  26611. : createBuffer(that, size).fill(fill)
  26612. }
  26613. return createBuffer(that, size)
  26614. }
  26615. /**
  26616. * Creates a new filled Buffer instance.
  26617. * alloc(size[, fill[, encoding]])
  26618. **/
  26619. Buffer$1.alloc = function (size, fill, encoding) {
  26620. return alloc(null, size, fill, encoding)
  26621. };
  26622. function allocUnsafe (that, size) {
  26623. assertSize(size);
  26624. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  26625. if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
  26626. for (var i = 0; i < size; ++i) {
  26627. that[i] = 0;
  26628. }
  26629. }
  26630. return that
  26631. }
  26632. /**
  26633. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  26634. * */
  26635. Buffer$1.allocUnsafe = function (size) {
  26636. return allocUnsafe(null, size)
  26637. };
  26638. /**
  26639. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  26640. */
  26641. Buffer$1.allocUnsafeSlow = function (size) {
  26642. return allocUnsafe(null, size)
  26643. };
  26644. function fromString (that, string, encoding) {
  26645. if (typeof encoding !== 'string' || encoding === '') {
  26646. encoding = 'utf8';
  26647. }
  26648. if (!Buffer$1.isEncoding(encoding)) {
  26649. throw new TypeError('"encoding" must be a valid string encoding')
  26650. }
  26651. var length = byteLength(string, encoding) | 0;
  26652. that = createBuffer(that, length);
  26653. var actual = that.write(string, encoding);
  26654. if (actual !== length) {
  26655. // Writing a hex string, for example, that contains invalid characters will
  26656. // cause everything after the first invalid character to be ignored. (e.g.
  26657. // 'abxxcd' will be treated as 'ab')
  26658. that = that.slice(0, actual);
  26659. }
  26660. return that
  26661. }
  26662. function fromArrayLike (that, array) {
  26663. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  26664. that = createBuffer(that, length);
  26665. for (var i = 0; i < length; i += 1) {
  26666. that[i] = array[i] & 255;
  26667. }
  26668. return that
  26669. }
  26670. function fromArrayBuffer (that, array, byteOffset, length) {
  26671. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  26672. if (byteOffset < 0 || array.byteLength < byteOffset) {
  26673. throw new RangeError('\'offset\' is out of bounds')
  26674. }
  26675. if (array.byteLength < byteOffset + (length || 0)) {
  26676. throw new RangeError('\'length\' is out of bounds')
  26677. }
  26678. if (byteOffset === undefined && length === undefined) {
  26679. array = new Uint8Array(array);
  26680. } else if (length === undefined) {
  26681. array = new Uint8Array(array, byteOffset);
  26682. } else {
  26683. array = new Uint8Array(array, byteOffset, length);
  26684. }
  26685. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  26686. // Return an augmented `Uint8Array` instance, for best performance
  26687. that = array;
  26688. that.__proto__ = Buffer$1.prototype;
  26689. } else {
  26690. // Fallback: Return an object instance of the Buffer class
  26691. that = fromArrayLike(that, array);
  26692. }
  26693. return that
  26694. }
  26695. function fromObject (that, obj) {
  26696. if (internalIsBuffer(obj)) {
  26697. var len = checked(obj.length) | 0;
  26698. that = createBuffer(that, len);
  26699. if (that.length === 0) {
  26700. return that
  26701. }
  26702. obj.copy(that, 0, 0, len);
  26703. return that
  26704. }
  26705. if (obj) {
  26706. if ((typeof ArrayBuffer !== 'undefined' &&
  26707. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  26708. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  26709. return createBuffer(that, 0)
  26710. }
  26711. return fromArrayLike(that, obj)
  26712. }
  26713. if (obj.type === 'Buffer' && isArray$2(obj.data)) {
  26714. return fromArrayLike(that, obj.data)
  26715. }
  26716. }
  26717. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  26718. }
  26719. function checked (length) {
  26720. // Note: cannot use `length < kMaxLength()` here because that fails when
  26721. // length is NaN (which is otherwise coerced to zero.)
  26722. if (length >= kMaxLength()) {
  26723. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  26724. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  26725. }
  26726. return length | 0
  26727. }
  26728. Buffer$1.isBuffer = isBuffer$1;
  26729. function internalIsBuffer (b) {
  26730. return !!(b != null && b._isBuffer)
  26731. }
  26732. Buffer$1.compare = function compare (a, b) {
  26733. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  26734. throw new TypeError('Arguments must be Buffers')
  26735. }
  26736. if (a === b) return 0
  26737. var x = a.length;
  26738. var y = b.length;
  26739. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  26740. if (a[i] !== b[i]) {
  26741. x = a[i];
  26742. y = b[i];
  26743. break
  26744. }
  26745. }
  26746. if (x < y) return -1
  26747. if (y < x) return 1
  26748. return 0
  26749. };
  26750. Buffer$1.isEncoding = function isEncoding (encoding) {
  26751. switch (String(encoding).toLowerCase()) {
  26752. case 'hex':
  26753. case 'utf8':
  26754. case 'utf-8':
  26755. case 'ascii':
  26756. case 'latin1':
  26757. case 'binary':
  26758. case 'base64':
  26759. case 'ucs2':
  26760. case 'ucs-2':
  26761. case 'utf16le':
  26762. case 'utf-16le':
  26763. return true
  26764. default:
  26765. return false
  26766. }
  26767. };
  26768. Buffer$1.concat = function concat (list, length) {
  26769. if (!isArray$2(list)) {
  26770. throw new TypeError('"list" argument must be an Array of Buffers')
  26771. }
  26772. if (list.length === 0) {
  26773. return Buffer$1.alloc(0)
  26774. }
  26775. var i;
  26776. if (length === undefined) {
  26777. length = 0;
  26778. for (i = 0; i < list.length; ++i) {
  26779. length += list[i].length;
  26780. }
  26781. }
  26782. var buffer = Buffer$1.allocUnsafe(length);
  26783. var pos = 0;
  26784. for (i = 0; i < list.length; ++i) {
  26785. var buf = list[i];
  26786. if (!internalIsBuffer(buf)) {
  26787. throw new TypeError('"list" argument must be an Array of Buffers')
  26788. }
  26789. buf.copy(buffer, pos);
  26790. pos += buf.length;
  26791. }
  26792. return buffer
  26793. };
  26794. function byteLength (string, encoding) {
  26795. if (internalIsBuffer(string)) {
  26796. return string.length
  26797. }
  26798. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  26799. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  26800. return string.byteLength
  26801. }
  26802. if (typeof string !== 'string') {
  26803. string = '' + string;
  26804. }
  26805. var len = string.length;
  26806. if (len === 0) return 0
  26807. // Use a for loop to avoid recursion
  26808. var loweredCase = false;
  26809. for (;;) {
  26810. switch (encoding) {
  26811. case 'ascii':
  26812. case 'latin1':
  26813. case 'binary':
  26814. return len
  26815. case 'utf8':
  26816. case 'utf-8':
  26817. case undefined:
  26818. return utf8ToBytes(string).length
  26819. case 'ucs2':
  26820. case 'ucs-2':
  26821. case 'utf16le':
  26822. case 'utf-16le':
  26823. return len * 2
  26824. case 'hex':
  26825. return len >>> 1
  26826. case 'base64':
  26827. return base64ToBytes(string).length
  26828. default:
  26829. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  26830. encoding = ('' + encoding).toLowerCase();
  26831. loweredCase = true;
  26832. }
  26833. }
  26834. }
  26835. Buffer$1.byteLength = byteLength;
  26836. function slowToString (encoding, start, end) {
  26837. var loweredCase = false;
  26838. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  26839. // property of a typed array.
  26840. // This behaves neither like String nor Uint8Array in that we set start/end
  26841. // to their upper/lower bounds if the value passed is out of range.
  26842. // undefined is handled specially as per ECMA-262 6th Edition,
  26843. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  26844. if (start === undefined || start < 0) {
  26845. start = 0;
  26846. }
  26847. // Return early if start > this.length. Done here to prevent potential uint32
  26848. // coercion fail below.
  26849. if (start > this.length) {
  26850. return ''
  26851. }
  26852. if (end === undefined || end > this.length) {
  26853. end = this.length;
  26854. }
  26855. if (end <= 0) {
  26856. return ''
  26857. }
  26858. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  26859. end >>>= 0;
  26860. start >>>= 0;
  26861. if (end <= start) {
  26862. return ''
  26863. }
  26864. if (!encoding) encoding = 'utf8';
  26865. while (true) {
  26866. switch (encoding) {
  26867. case 'hex':
  26868. return hexSlice(this, start, end)
  26869. case 'utf8':
  26870. case 'utf-8':
  26871. return utf8Slice(this, start, end)
  26872. case 'ascii':
  26873. return asciiSlice(this, start, end)
  26874. case 'latin1':
  26875. case 'binary':
  26876. return latin1Slice(this, start, end)
  26877. case 'base64':
  26878. return base64Slice(this, start, end)
  26879. case 'ucs2':
  26880. case 'ucs-2':
  26881. case 'utf16le':
  26882. case 'utf-16le':
  26883. return utf16leSlice(this, start, end)
  26884. default:
  26885. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  26886. encoding = (encoding + '').toLowerCase();
  26887. loweredCase = true;
  26888. }
  26889. }
  26890. }
  26891. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  26892. // Buffer instances.
  26893. Buffer$1.prototype._isBuffer = true;
  26894. function swap$1 (b, n, m) {
  26895. var i = b[n];
  26896. b[n] = b[m];
  26897. b[m] = i;
  26898. }
  26899. Buffer$1.prototype.swap16 = function swap16 () {
  26900. var len = this.length;
  26901. if (len % 2 !== 0) {
  26902. throw new RangeError('Buffer size must be a multiple of 16-bits')
  26903. }
  26904. for (var i = 0; i < len; i += 2) {
  26905. swap$1(this, i, i + 1);
  26906. }
  26907. return this
  26908. };
  26909. Buffer$1.prototype.swap32 = function swap32 () {
  26910. var len = this.length;
  26911. if (len % 4 !== 0) {
  26912. throw new RangeError('Buffer size must be a multiple of 32-bits')
  26913. }
  26914. for (var i = 0; i < len; i += 4) {
  26915. swap$1(this, i, i + 3);
  26916. swap$1(this, i + 1, i + 2);
  26917. }
  26918. return this
  26919. };
  26920. Buffer$1.prototype.swap64 = function swap64 () {
  26921. var len = this.length;
  26922. if (len % 8 !== 0) {
  26923. throw new RangeError('Buffer size must be a multiple of 64-bits')
  26924. }
  26925. for (var i = 0; i < len; i += 8) {
  26926. swap$1(this, i, i + 7);
  26927. swap$1(this, i + 1, i + 6);
  26928. swap$1(this, i + 2, i + 5);
  26929. swap$1(this, i + 3, i + 4);
  26930. }
  26931. return this
  26932. };
  26933. Buffer$1.prototype.toString = function toString () {
  26934. var length = this.length | 0;
  26935. if (length === 0) return ''
  26936. if (arguments.length === 0) return utf8Slice(this, 0, length)
  26937. return slowToString.apply(this, arguments)
  26938. };
  26939. Buffer$1.prototype.equals = function equals (b) {
  26940. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
  26941. if (this === b) return true
  26942. return Buffer$1.compare(this, b) === 0
  26943. };
  26944. Buffer$1.prototype.inspect = function inspect () {
  26945. var str = '';
  26946. var max = INSPECT_MAX_BYTES;
  26947. if (this.length > 0) {
  26948. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  26949. if (this.length > max) str += ' ... ';
  26950. }
  26951. return '<Buffer ' + str + '>'
  26952. };
  26953. Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  26954. if (!internalIsBuffer(target)) {
  26955. throw new TypeError('Argument must be a Buffer')
  26956. }
  26957. if (start === undefined) {
  26958. start = 0;
  26959. }
  26960. if (end === undefined) {
  26961. end = target ? target.length : 0;
  26962. }
  26963. if (thisStart === undefined) {
  26964. thisStart = 0;
  26965. }
  26966. if (thisEnd === undefined) {
  26967. thisEnd = this.length;
  26968. }
  26969. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  26970. throw new RangeError('out of range index')
  26971. }
  26972. if (thisStart >= thisEnd && start >= end) {
  26973. return 0
  26974. }
  26975. if (thisStart >= thisEnd) {
  26976. return -1
  26977. }
  26978. if (start >= end) {
  26979. return 1
  26980. }
  26981. start >>>= 0;
  26982. end >>>= 0;
  26983. thisStart >>>= 0;
  26984. thisEnd >>>= 0;
  26985. if (this === target) return 0
  26986. var x = thisEnd - thisStart;
  26987. var y = end - start;
  26988. var len = Math.min(x, y);
  26989. var thisCopy = this.slice(thisStart, thisEnd);
  26990. var targetCopy = target.slice(start, end);
  26991. for (var i = 0; i < len; ++i) {
  26992. if (thisCopy[i] !== targetCopy[i]) {
  26993. x = thisCopy[i];
  26994. y = targetCopy[i];
  26995. break
  26996. }
  26997. }
  26998. if (x < y) return -1
  26999. if (y < x) return 1
  27000. return 0
  27001. };
  27002. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  27003. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  27004. //
  27005. // Arguments:
  27006. // - buffer - a Buffer to search
  27007. // - val - a string, Buffer, or number
  27008. // - byteOffset - an index into `buffer`; will be clamped to an int32
  27009. // - encoding - an optional encoding, relevant is val is a string
  27010. // - dir - true for indexOf, false for lastIndexOf
  27011. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  27012. // Empty buffer means no match
  27013. if (buffer.length === 0) return -1
  27014. // Normalize byteOffset
  27015. if (typeof byteOffset === 'string') {
  27016. encoding = byteOffset;
  27017. byteOffset = 0;
  27018. } else if (byteOffset > 0x7fffffff) {
  27019. byteOffset = 0x7fffffff;
  27020. } else if (byteOffset < -0x80000000) {
  27021. byteOffset = -0x80000000;
  27022. }
  27023. byteOffset = +byteOffset; // Coerce to Number.
  27024. if (isNaN(byteOffset)) {
  27025. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  27026. byteOffset = dir ? 0 : (buffer.length - 1);
  27027. }
  27028. // Normalize byteOffset: negative offsets start from the end of the buffer
  27029. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  27030. if (byteOffset >= buffer.length) {
  27031. if (dir) return -1
  27032. else byteOffset = buffer.length - 1;
  27033. } else if (byteOffset < 0) {
  27034. if (dir) byteOffset = 0;
  27035. else return -1
  27036. }
  27037. // Normalize val
  27038. if (typeof val === 'string') {
  27039. val = Buffer$1.from(val, encoding);
  27040. }
  27041. // Finally, search either indexOf (if dir is true) or lastIndexOf
  27042. if (internalIsBuffer(val)) {
  27043. // Special case: looking for empty string/buffer always fails
  27044. if (val.length === 0) {
  27045. return -1
  27046. }
  27047. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  27048. } else if (typeof val === 'number') {
  27049. val = val & 0xFF; // Search for a byte value [0-255]
  27050. if (Buffer$1.TYPED_ARRAY_SUPPORT &&
  27051. typeof Uint8Array.prototype.indexOf === 'function') {
  27052. if (dir) {
  27053. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  27054. } else {
  27055. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  27056. }
  27057. }
  27058. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  27059. }
  27060. throw new TypeError('val must be string, number or Buffer')
  27061. }
  27062. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  27063. var indexSize = 1;
  27064. var arrLength = arr.length;
  27065. var valLength = val.length;
  27066. if (encoding !== undefined) {
  27067. encoding = String(encoding).toLowerCase();
  27068. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  27069. encoding === 'utf16le' || encoding === 'utf-16le') {
  27070. if (arr.length < 2 || val.length < 2) {
  27071. return -1
  27072. }
  27073. indexSize = 2;
  27074. arrLength /= 2;
  27075. valLength /= 2;
  27076. byteOffset /= 2;
  27077. }
  27078. }
  27079. function read (buf, i) {
  27080. if (indexSize === 1) {
  27081. return buf[i]
  27082. } else {
  27083. return buf.readUInt16BE(i * indexSize)
  27084. }
  27085. }
  27086. var i;
  27087. if (dir) {
  27088. var foundIndex = -1;
  27089. for (i = byteOffset; i < arrLength; i++) {
  27090. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  27091. if (foundIndex === -1) foundIndex = i;
  27092. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  27093. } else {
  27094. if (foundIndex !== -1) i -= i - foundIndex;
  27095. foundIndex = -1;
  27096. }
  27097. }
  27098. } else {
  27099. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  27100. for (i = byteOffset; i >= 0; i--) {
  27101. var found = true;
  27102. for (var j = 0; j < valLength; j++) {
  27103. if (read(arr, i + j) !== read(val, j)) {
  27104. found = false;
  27105. break
  27106. }
  27107. }
  27108. if (found) return i
  27109. }
  27110. }
  27111. return -1
  27112. }
  27113. Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
  27114. return this.indexOf(val, byteOffset, encoding) !== -1
  27115. };
  27116. Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  27117. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  27118. };
  27119. Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  27120. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  27121. };
  27122. function hexWrite (buf, string, offset, length) {
  27123. offset = Number(offset) || 0;
  27124. var remaining = buf.length - offset;
  27125. if (!length) {
  27126. length = remaining;
  27127. } else {
  27128. length = Number(length);
  27129. if (length > remaining) {
  27130. length = remaining;
  27131. }
  27132. }
  27133. // must be an even number of digits
  27134. var strLen = string.length;
  27135. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  27136. if (length > strLen / 2) {
  27137. length = strLen / 2;
  27138. }
  27139. for (var i = 0; i < length; ++i) {
  27140. var parsed = parseInt(string.substr(i * 2, 2), 16);
  27141. if (isNaN(parsed)) return i
  27142. buf[offset + i] = parsed;
  27143. }
  27144. return i
  27145. }
  27146. function utf8Write (buf, string, offset, length) {
  27147. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  27148. }
  27149. function asciiWrite (buf, string, offset, length) {
  27150. return blitBuffer(asciiToBytes(string), buf, offset, length)
  27151. }
  27152. function latin1Write (buf, string, offset, length) {
  27153. return asciiWrite(buf, string, offset, length)
  27154. }
  27155. function base64Write (buf, string, offset, length) {
  27156. return blitBuffer(base64ToBytes(string), buf, offset, length)
  27157. }
  27158. function ucs2Write (buf, string, offset, length) {
  27159. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  27160. }
  27161. Buffer$1.prototype.write = function write (string, offset, length, encoding) {
  27162. // Buffer#write(string)
  27163. if (offset === undefined) {
  27164. encoding = 'utf8';
  27165. length = this.length;
  27166. offset = 0;
  27167. // Buffer#write(string, encoding)
  27168. } else if (length === undefined && typeof offset === 'string') {
  27169. encoding = offset;
  27170. length = this.length;
  27171. offset = 0;
  27172. // Buffer#write(string, offset[, length][, encoding])
  27173. } else if (isFinite(offset)) {
  27174. offset = offset | 0;
  27175. if (isFinite(length)) {
  27176. length = length | 0;
  27177. if (encoding === undefined) encoding = 'utf8';
  27178. } else {
  27179. encoding = length;
  27180. length = undefined;
  27181. }
  27182. // legacy write(string, encoding, offset, length) - remove in v0.13
  27183. } else {
  27184. throw new Error(
  27185. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  27186. )
  27187. }
  27188. var remaining = this.length - offset;
  27189. if (length === undefined || length > remaining) length = remaining;
  27190. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  27191. throw new RangeError('Attempt to write outside buffer bounds')
  27192. }
  27193. if (!encoding) encoding = 'utf8';
  27194. var loweredCase = false;
  27195. for (;;) {
  27196. switch (encoding) {
  27197. case 'hex':
  27198. return hexWrite(this, string, offset, length)
  27199. case 'utf8':
  27200. case 'utf-8':
  27201. return utf8Write(this, string, offset, length)
  27202. case 'ascii':
  27203. return asciiWrite(this, string, offset, length)
  27204. case 'latin1':
  27205. case 'binary':
  27206. return latin1Write(this, string, offset, length)
  27207. case 'base64':
  27208. // Warning: maxLength not taken into account in base64Write
  27209. return base64Write(this, string, offset, length)
  27210. case 'ucs2':
  27211. case 'ucs-2':
  27212. case 'utf16le':
  27213. case 'utf-16le':
  27214. return ucs2Write(this, string, offset, length)
  27215. default:
  27216. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  27217. encoding = ('' + encoding).toLowerCase();
  27218. loweredCase = true;
  27219. }
  27220. }
  27221. };
  27222. Buffer$1.prototype.toJSON = function toJSON () {
  27223. return {
  27224. type: 'Buffer',
  27225. data: Array.prototype.slice.call(this._arr || this, 0)
  27226. }
  27227. };
  27228. function base64Slice (buf, start, end) {
  27229. if (start === 0 && end === buf.length) {
  27230. return fromByteArray(buf)
  27231. } else {
  27232. return fromByteArray(buf.slice(start, end))
  27233. }
  27234. }
  27235. function utf8Slice (buf, start, end) {
  27236. end = Math.min(buf.length, end);
  27237. var res = [];
  27238. var i = start;
  27239. while (i < end) {
  27240. var firstByte = buf[i];
  27241. var codePoint = null;
  27242. var bytesPerSequence = (firstByte > 0xEF) ? 4
  27243. : (firstByte > 0xDF) ? 3
  27244. : (firstByte > 0xBF) ? 2
  27245. : 1;
  27246. if (i + bytesPerSequence <= end) {
  27247. var secondByte, thirdByte, fourthByte, tempCodePoint;
  27248. switch (bytesPerSequence) {
  27249. case 1:
  27250. if (firstByte < 0x80) {
  27251. codePoint = firstByte;
  27252. }
  27253. break
  27254. case 2:
  27255. secondByte = buf[i + 1];
  27256. if ((secondByte & 0xC0) === 0x80) {
  27257. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  27258. if (tempCodePoint > 0x7F) {
  27259. codePoint = tempCodePoint;
  27260. }
  27261. }
  27262. break
  27263. case 3:
  27264. secondByte = buf[i + 1];
  27265. thirdByte = buf[i + 2];
  27266. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  27267. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  27268. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  27269. codePoint = tempCodePoint;
  27270. }
  27271. }
  27272. break
  27273. case 4:
  27274. secondByte = buf[i + 1];
  27275. thirdByte = buf[i + 2];
  27276. fourthByte = buf[i + 3];
  27277. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  27278. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  27279. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  27280. codePoint = tempCodePoint;
  27281. }
  27282. }
  27283. }
  27284. }
  27285. if (codePoint === null) {
  27286. // we did not generate a valid codePoint so insert a
  27287. // replacement char (U+FFFD) and advance only 1 byte
  27288. codePoint = 0xFFFD;
  27289. bytesPerSequence = 1;
  27290. } else if (codePoint > 0xFFFF) {
  27291. // encode to utf16 (surrogate pair dance)
  27292. codePoint -= 0x10000;
  27293. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  27294. codePoint = 0xDC00 | codePoint & 0x3FF;
  27295. }
  27296. res.push(codePoint);
  27297. i += bytesPerSequence;
  27298. }
  27299. return decodeCodePointsArray(res)
  27300. }
  27301. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  27302. // the lowest limit is Chrome, with 0x10000 args.
  27303. // We go 1 magnitude less, for safety
  27304. var MAX_ARGUMENTS_LENGTH = 0x1000;
  27305. function decodeCodePointsArray (codePoints) {
  27306. var len = codePoints.length;
  27307. if (len <= MAX_ARGUMENTS_LENGTH) {
  27308. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  27309. }
  27310. // Decode in chunks to avoid "call stack size exceeded".
  27311. var res = '';
  27312. var i = 0;
  27313. while (i < len) {
  27314. res += String.fromCharCode.apply(
  27315. String,
  27316. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  27317. );
  27318. }
  27319. return res
  27320. }
  27321. function asciiSlice (buf, start, end) {
  27322. var ret = '';
  27323. end = Math.min(buf.length, end);
  27324. for (var i = start; i < end; ++i) {
  27325. ret += String.fromCharCode(buf[i] & 0x7F);
  27326. }
  27327. return ret
  27328. }
  27329. function latin1Slice (buf, start, end) {
  27330. var ret = '';
  27331. end = Math.min(buf.length, end);
  27332. for (var i = start; i < end; ++i) {
  27333. ret += String.fromCharCode(buf[i]);
  27334. }
  27335. return ret
  27336. }
  27337. function hexSlice (buf, start, end) {
  27338. var len = buf.length;
  27339. if (!start || start < 0) start = 0;
  27340. if (!end || end < 0 || end > len) end = len;
  27341. var out = '';
  27342. for (var i = start; i < end; ++i) {
  27343. out += toHex(buf[i]);
  27344. }
  27345. return out
  27346. }
  27347. function utf16leSlice (buf, start, end) {
  27348. var bytes = buf.slice(start, end);
  27349. var res = '';
  27350. for (var i = 0; i < bytes.length; i += 2) {
  27351. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  27352. }
  27353. return res
  27354. }
  27355. Buffer$1.prototype.slice = function slice (start, end) {
  27356. var len = this.length;
  27357. start = ~~start;
  27358. end = end === undefined ? len : ~~end;
  27359. if (start < 0) {
  27360. start += len;
  27361. if (start < 0) start = 0;
  27362. } else if (start > len) {
  27363. start = len;
  27364. }
  27365. if (end < 0) {
  27366. end += len;
  27367. if (end < 0) end = 0;
  27368. } else if (end > len) {
  27369. end = len;
  27370. }
  27371. if (end < start) end = start;
  27372. var newBuf;
  27373. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27374. newBuf = this.subarray(start, end);
  27375. newBuf.__proto__ = Buffer$1.prototype;
  27376. } else {
  27377. var sliceLen = end - start;
  27378. newBuf = new Buffer$1(sliceLen, undefined);
  27379. for (var i = 0; i < sliceLen; ++i) {
  27380. newBuf[i] = this[i + start];
  27381. }
  27382. }
  27383. return newBuf
  27384. };
  27385. /*
  27386. * Need to make sure that buffer isn't trying to write out of bounds.
  27387. */
  27388. function checkOffset (offset, ext, length) {
  27389. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  27390. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  27391. }
  27392. Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  27393. offset = offset | 0;
  27394. byteLength = byteLength | 0;
  27395. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27396. var val = this[offset];
  27397. var mul = 1;
  27398. var i = 0;
  27399. while (++i < byteLength && (mul *= 0x100)) {
  27400. val += this[offset + i] * mul;
  27401. }
  27402. return val
  27403. };
  27404. Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  27405. offset = offset | 0;
  27406. byteLength = byteLength | 0;
  27407. if (!noAssert) {
  27408. checkOffset(offset, byteLength, this.length);
  27409. }
  27410. var val = this[offset + --byteLength];
  27411. var mul = 1;
  27412. while (byteLength > 0 && (mul *= 0x100)) {
  27413. val += this[offset + --byteLength] * mul;
  27414. }
  27415. return val
  27416. };
  27417. Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  27418. if (!noAssert) checkOffset(offset, 1, this.length);
  27419. return this[offset]
  27420. };
  27421. Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  27422. if (!noAssert) checkOffset(offset, 2, this.length);
  27423. return this[offset] | (this[offset + 1] << 8)
  27424. };
  27425. Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  27426. if (!noAssert) checkOffset(offset, 2, this.length);
  27427. return (this[offset] << 8) | this[offset + 1]
  27428. };
  27429. Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  27430. if (!noAssert) checkOffset(offset, 4, this.length);
  27431. return ((this[offset]) |
  27432. (this[offset + 1] << 8) |
  27433. (this[offset + 2] << 16)) +
  27434. (this[offset + 3] * 0x1000000)
  27435. };
  27436. Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  27437. if (!noAssert) checkOffset(offset, 4, this.length);
  27438. return (this[offset] * 0x1000000) +
  27439. ((this[offset + 1] << 16) |
  27440. (this[offset + 2] << 8) |
  27441. this[offset + 3])
  27442. };
  27443. Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  27444. offset = offset | 0;
  27445. byteLength = byteLength | 0;
  27446. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27447. var val = this[offset];
  27448. var mul = 1;
  27449. var i = 0;
  27450. while (++i < byteLength && (mul *= 0x100)) {
  27451. val += this[offset + i] * mul;
  27452. }
  27453. mul *= 0x80;
  27454. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27455. return val
  27456. };
  27457. Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  27458. offset = offset | 0;
  27459. byteLength = byteLength | 0;
  27460. if (!noAssert) checkOffset(offset, byteLength, this.length);
  27461. var i = byteLength;
  27462. var mul = 1;
  27463. var val = this[offset + --i];
  27464. while (i > 0 && (mul *= 0x100)) {
  27465. val += this[offset + --i] * mul;
  27466. }
  27467. mul *= 0x80;
  27468. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  27469. return val
  27470. };
  27471. Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
  27472. if (!noAssert) checkOffset(offset, 1, this.length);
  27473. if (!(this[offset] & 0x80)) return (this[offset])
  27474. return ((0xff - this[offset] + 1) * -1)
  27475. };
  27476. Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  27477. if (!noAssert) checkOffset(offset, 2, this.length);
  27478. var val = this[offset] | (this[offset + 1] << 8);
  27479. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27480. };
  27481. Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  27482. if (!noAssert) checkOffset(offset, 2, this.length);
  27483. var val = this[offset + 1] | (this[offset] << 8);
  27484. return (val & 0x8000) ? val | 0xFFFF0000 : val
  27485. };
  27486. Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  27487. if (!noAssert) checkOffset(offset, 4, this.length);
  27488. return (this[offset]) |
  27489. (this[offset + 1] << 8) |
  27490. (this[offset + 2] << 16) |
  27491. (this[offset + 3] << 24)
  27492. };
  27493. Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  27494. if (!noAssert) checkOffset(offset, 4, this.length);
  27495. return (this[offset] << 24) |
  27496. (this[offset + 1] << 16) |
  27497. (this[offset + 2] << 8) |
  27498. (this[offset + 3])
  27499. };
  27500. Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  27501. if (!noAssert) checkOffset(offset, 4, this.length);
  27502. return read(this, offset, true, 23, 4)
  27503. };
  27504. Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  27505. if (!noAssert) checkOffset(offset, 4, this.length);
  27506. return read(this, offset, false, 23, 4)
  27507. };
  27508. Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  27509. if (!noAssert) checkOffset(offset, 8, this.length);
  27510. return read(this, offset, true, 52, 8)
  27511. };
  27512. Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  27513. if (!noAssert) checkOffset(offset, 8, this.length);
  27514. return read(this, offset, false, 52, 8)
  27515. };
  27516. function checkInt (buf, value, offset, ext, max, min) {
  27517. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  27518. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  27519. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27520. }
  27521. Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  27522. value = +value;
  27523. offset = offset | 0;
  27524. byteLength = byteLength | 0;
  27525. if (!noAssert) {
  27526. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27527. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27528. }
  27529. var mul = 1;
  27530. var i = 0;
  27531. this[offset] = value & 0xFF;
  27532. while (++i < byteLength && (mul *= 0x100)) {
  27533. this[offset + i] = (value / mul) & 0xFF;
  27534. }
  27535. return offset + byteLength
  27536. };
  27537. Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  27538. value = +value;
  27539. offset = offset | 0;
  27540. byteLength = byteLength | 0;
  27541. if (!noAssert) {
  27542. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  27543. checkInt(this, value, offset, byteLength, maxBytes, 0);
  27544. }
  27545. var i = byteLength - 1;
  27546. var mul = 1;
  27547. this[offset + i] = value & 0xFF;
  27548. while (--i >= 0 && (mul *= 0x100)) {
  27549. this[offset + i] = (value / mul) & 0xFF;
  27550. }
  27551. return offset + byteLength
  27552. };
  27553. Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  27554. value = +value;
  27555. offset = offset | 0;
  27556. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  27557. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27558. this[offset] = (value & 0xff);
  27559. return offset + 1
  27560. };
  27561. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  27562. if (value < 0) value = 0xffff + value + 1;
  27563. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  27564. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  27565. (littleEndian ? i : 1 - i) * 8;
  27566. }
  27567. }
  27568. Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  27569. value = +value;
  27570. offset = offset | 0;
  27571. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27572. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27573. this[offset] = (value & 0xff);
  27574. this[offset + 1] = (value >>> 8);
  27575. } else {
  27576. objectWriteUInt16(this, value, offset, true);
  27577. }
  27578. return offset + 2
  27579. };
  27580. Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  27581. value = +value;
  27582. offset = offset | 0;
  27583. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  27584. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27585. this[offset] = (value >>> 8);
  27586. this[offset + 1] = (value & 0xff);
  27587. } else {
  27588. objectWriteUInt16(this, value, offset, false);
  27589. }
  27590. return offset + 2
  27591. };
  27592. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  27593. if (value < 0) value = 0xffffffff + value + 1;
  27594. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  27595. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
  27596. }
  27597. }
  27598. Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  27599. value = +value;
  27600. offset = offset | 0;
  27601. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27602. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27603. this[offset + 3] = (value >>> 24);
  27604. this[offset + 2] = (value >>> 16);
  27605. this[offset + 1] = (value >>> 8);
  27606. this[offset] = (value & 0xff);
  27607. } else {
  27608. objectWriteUInt32(this, value, offset, true);
  27609. }
  27610. return offset + 4
  27611. };
  27612. Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  27613. value = +value;
  27614. offset = offset | 0;
  27615. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  27616. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27617. this[offset] = (value >>> 24);
  27618. this[offset + 1] = (value >>> 16);
  27619. this[offset + 2] = (value >>> 8);
  27620. this[offset + 3] = (value & 0xff);
  27621. } else {
  27622. objectWriteUInt32(this, value, offset, false);
  27623. }
  27624. return offset + 4
  27625. };
  27626. Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  27627. value = +value;
  27628. offset = offset | 0;
  27629. if (!noAssert) {
  27630. var limit = Math.pow(2, 8 * byteLength - 1);
  27631. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  27632. }
  27633. var i = 0;
  27634. var mul = 1;
  27635. var sub = 0;
  27636. this[offset] = value & 0xFF;
  27637. while (++i < byteLength && (mul *= 0x100)) {
  27638. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  27639. sub = 1;
  27640. }
  27641. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  27642. }
  27643. return offset + byteLength
  27644. };
  27645. Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  27646. value = +value;
  27647. offset = offset | 0;
  27648. if (!noAssert) {
  27649. var limit = Math.pow(2, 8 * byteLength - 1);
  27650. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  27651. }
  27652. var i = byteLength - 1;
  27653. var mul = 1;
  27654. var sub = 0;
  27655. this[offset + i] = value & 0xFF;
  27656. while (--i >= 0 && (mul *= 0x100)) {
  27657. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  27658. sub = 1;
  27659. }
  27660. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  27661. }
  27662. return offset + byteLength
  27663. };
  27664. Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  27665. value = +value;
  27666. offset = offset | 0;
  27667. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  27668. if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  27669. if (value < 0) value = 0xff + value + 1;
  27670. this[offset] = (value & 0xff);
  27671. return offset + 1
  27672. };
  27673. Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  27674. value = +value;
  27675. offset = offset | 0;
  27676. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  27677. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27678. this[offset] = (value & 0xff);
  27679. this[offset + 1] = (value >>> 8);
  27680. } else {
  27681. objectWriteUInt16(this, value, offset, true);
  27682. }
  27683. return offset + 2
  27684. };
  27685. Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  27686. value = +value;
  27687. offset = offset | 0;
  27688. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  27689. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27690. this[offset] = (value >>> 8);
  27691. this[offset + 1] = (value & 0xff);
  27692. } else {
  27693. objectWriteUInt16(this, value, offset, false);
  27694. }
  27695. return offset + 2
  27696. };
  27697. Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  27698. value = +value;
  27699. offset = offset | 0;
  27700. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  27701. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27702. this[offset] = (value & 0xff);
  27703. this[offset + 1] = (value >>> 8);
  27704. this[offset + 2] = (value >>> 16);
  27705. this[offset + 3] = (value >>> 24);
  27706. } else {
  27707. objectWriteUInt32(this, value, offset, true);
  27708. }
  27709. return offset + 4
  27710. };
  27711. Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  27712. value = +value;
  27713. offset = offset | 0;
  27714. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  27715. if (value < 0) value = 0xffffffff + value + 1;
  27716. if (Buffer$1.TYPED_ARRAY_SUPPORT) {
  27717. this[offset] = (value >>> 24);
  27718. this[offset + 1] = (value >>> 16);
  27719. this[offset + 2] = (value >>> 8);
  27720. this[offset + 3] = (value & 0xff);
  27721. } else {
  27722. objectWriteUInt32(this, value, offset, false);
  27723. }
  27724. return offset + 4
  27725. };
  27726. function checkIEEE754 (buf, value, offset, ext, max, min) {
  27727. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  27728. if (offset < 0) throw new RangeError('Index out of range')
  27729. }
  27730. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  27731. if (!noAssert) {
  27732. checkIEEE754(buf, value, offset, 4);
  27733. }
  27734. write(buf, value, offset, littleEndian, 23, 4);
  27735. return offset + 4
  27736. }
  27737. Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  27738. return writeFloat(this, value, offset, true, noAssert)
  27739. };
  27740. Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  27741. return writeFloat(this, value, offset, false, noAssert)
  27742. };
  27743. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  27744. if (!noAssert) {
  27745. checkIEEE754(buf, value, offset, 8);
  27746. }
  27747. write(buf, value, offset, littleEndian, 52, 8);
  27748. return offset + 8
  27749. }
  27750. Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  27751. return writeDouble(this, value, offset, true, noAssert)
  27752. };
  27753. Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  27754. return writeDouble(this, value, offset, false, noAssert)
  27755. };
  27756. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  27757. Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
  27758. if (!start) start = 0;
  27759. if (!end && end !== 0) end = this.length;
  27760. if (targetStart >= target.length) targetStart = target.length;
  27761. if (!targetStart) targetStart = 0;
  27762. if (end > 0 && end < start) end = start;
  27763. // Copy 0 bytes; we're done
  27764. if (end === start) return 0
  27765. if (target.length === 0 || this.length === 0) return 0
  27766. // Fatal error conditions
  27767. if (targetStart < 0) {
  27768. throw new RangeError('targetStart out of bounds')
  27769. }
  27770. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  27771. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  27772. // Are we oob?
  27773. if (end > this.length) end = this.length;
  27774. if (target.length - targetStart < end - start) {
  27775. end = target.length - targetStart + start;
  27776. }
  27777. var len = end - start;
  27778. var i;
  27779. if (this === target && start < targetStart && targetStart < end) {
  27780. // descending copy from end
  27781. for (i = len - 1; i >= 0; --i) {
  27782. target[i + targetStart] = this[i + start];
  27783. }
  27784. } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
  27785. // ascending copy from start
  27786. for (i = 0; i < len; ++i) {
  27787. target[i + targetStart] = this[i + start];
  27788. }
  27789. } else {
  27790. Uint8Array.prototype.set.call(
  27791. target,
  27792. this.subarray(start, start + len),
  27793. targetStart
  27794. );
  27795. }
  27796. return len
  27797. };
  27798. // Usage:
  27799. // buffer.fill(number[, offset[, end]])
  27800. // buffer.fill(buffer[, offset[, end]])
  27801. // buffer.fill(string[, offset[, end]][, encoding])
  27802. Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
  27803. // Handle string cases:
  27804. if (typeof val === 'string') {
  27805. if (typeof start === 'string') {
  27806. encoding = start;
  27807. start = 0;
  27808. end = this.length;
  27809. } else if (typeof end === 'string') {
  27810. encoding = end;
  27811. end = this.length;
  27812. }
  27813. if (val.length === 1) {
  27814. var code = val.charCodeAt(0);
  27815. if (code < 256) {
  27816. val = code;
  27817. }
  27818. }
  27819. if (encoding !== undefined && typeof encoding !== 'string') {
  27820. throw new TypeError('encoding must be a string')
  27821. }
  27822. if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
  27823. throw new TypeError('Unknown encoding: ' + encoding)
  27824. }
  27825. } else if (typeof val === 'number') {
  27826. val = val & 255;
  27827. }
  27828. // Invalid ranges are not set to a default, so can range check early.
  27829. if (start < 0 || this.length < start || this.length < end) {
  27830. throw new RangeError('Out of range index')
  27831. }
  27832. if (end <= start) {
  27833. return this
  27834. }
  27835. start = start >>> 0;
  27836. end = end === undefined ? this.length : end >>> 0;
  27837. if (!val) val = 0;
  27838. var i;
  27839. if (typeof val === 'number') {
  27840. for (i = start; i < end; ++i) {
  27841. this[i] = val;
  27842. }
  27843. } else {
  27844. var bytes = internalIsBuffer(val)
  27845. ? val
  27846. : utf8ToBytes(new Buffer$1(val, encoding).toString());
  27847. var len = bytes.length;
  27848. for (i = 0; i < end - start; ++i) {
  27849. this[i + start] = bytes[i % len];
  27850. }
  27851. }
  27852. return this
  27853. };
  27854. // HELPER FUNCTIONS
  27855. // ================
  27856. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  27857. function base64clean (str) {
  27858. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  27859. str = stringtrim(str).replace(INVALID_BASE64_RE, '');
  27860. // Node converts strings with length < 2 to ''
  27861. if (str.length < 2) return ''
  27862. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  27863. while (str.length % 4 !== 0) {
  27864. str = str + '=';
  27865. }
  27866. return str
  27867. }
  27868. function stringtrim (str) {
  27869. if (str.trim) return str.trim()
  27870. return str.replace(/^\s+|\s+$/g, '')
  27871. }
  27872. function toHex (n) {
  27873. if (n < 16) return '0' + n.toString(16)
  27874. return n.toString(16)
  27875. }
  27876. function utf8ToBytes (string, units) {
  27877. units = units || Infinity;
  27878. var codePoint;
  27879. var length = string.length;
  27880. var leadSurrogate = null;
  27881. var bytes = [];
  27882. for (var i = 0; i < length; ++i) {
  27883. codePoint = string.charCodeAt(i);
  27884. // is surrogate component
  27885. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  27886. // last char was a lead
  27887. if (!leadSurrogate) {
  27888. // no lead yet
  27889. if (codePoint > 0xDBFF) {
  27890. // unexpected trail
  27891. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27892. continue
  27893. } else if (i + 1 === length) {
  27894. // unpaired lead
  27895. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27896. continue
  27897. }
  27898. // valid lead
  27899. leadSurrogate = codePoint;
  27900. continue
  27901. }
  27902. // 2 leads in a row
  27903. if (codePoint < 0xDC00) {
  27904. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27905. leadSurrogate = codePoint;
  27906. continue
  27907. }
  27908. // valid surrogate pair
  27909. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  27910. } else if (leadSurrogate) {
  27911. // valid bmp char, but last char was a lead
  27912. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  27913. }
  27914. leadSurrogate = null;
  27915. // encode utf8
  27916. if (codePoint < 0x80) {
  27917. if ((units -= 1) < 0) break
  27918. bytes.push(codePoint);
  27919. } else if (codePoint < 0x800) {
  27920. if ((units -= 2) < 0) break
  27921. bytes.push(
  27922. codePoint >> 0x6 | 0xC0,
  27923. codePoint & 0x3F | 0x80
  27924. );
  27925. } else if (codePoint < 0x10000) {
  27926. if ((units -= 3) < 0) break
  27927. bytes.push(
  27928. codePoint >> 0xC | 0xE0,
  27929. codePoint >> 0x6 & 0x3F | 0x80,
  27930. codePoint & 0x3F | 0x80
  27931. );
  27932. } else if (codePoint < 0x110000) {
  27933. if ((units -= 4) < 0) break
  27934. bytes.push(
  27935. codePoint >> 0x12 | 0xF0,
  27936. codePoint >> 0xC & 0x3F | 0x80,
  27937. codePoint >> 0x6 & 0x3F | 0x80,
  27938. codePoint & 0x3F | 0x80
  27939. );
  27940. } else {
  27941. throw new Error('Invalid code point')
  27942. }
  27943. }
  27944. return bytes
  27945. }
  27946. function asciiToBytes (str) {
  27947. var byteArray = [];
  27948. for (var i = 0; i < str.length; ++i) {
  27949. // Node's code seems to be doing this and not & 0x7F..
  27950. byteArray.push(str.charCodeAt(i) & 0xFF);
  27951. }
  27952. return byteArray
  27953. }
  27954. function utf16leToBytes (str, units) {
  27955. var c, hi, lo;
  27956. var byteArray = [];
  27957. for (var i = 0; i < str.length; ++i) {
  27958. if ((units -= 2) < 0) break
  27959. c = str.charCodeAt(i);
  27960. hi = c >> 8;
  27961. lo = c % 256;
  27962. byteArray.push(lo);
  27963. byteArray.push(hi);
  27964. }
  27965. return byteArray
  27966. }
  27967. function base64ToBytes (str) {
  27968. return toByteArray(base64clean(str))
  27969. }
  27970. function blitBuffer (src, dst, offset, length) {
  27971. for (var i = 0; i < length; ++i) {
  27972. if ((i + offset >= dst.length) || (i >= src.length)) break
  27973. dst[i + offset] = src[i];
  27974. }
  27975. return i
  27976. }
  27977. function isnan (val) {
  27978. return val !== val // eslint-disable-line no-self-compare
  27979. }
  27980. // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  27981. // The _isBuffer check is for Safari 5-7 support, because it's missing
  27982. // Object.prototype.constructor. Remove this eventually
  27983. function isBuffer$1(obj) {
  27984. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
  27985. }
  27986. function isFastBuffer (obj) {
  27987. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  27988. }
  27989. // For Node v0.10 support. Remove this eventually.
  27990. function isSlowBuffer (obj) {
  27991. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
  27992. }
  27993. var inherits;
  27994. if (typeof Object.create === 'function'){
  27995. inherits = function inherits(ctor, superCtor) {
  27996. // implementation from standard node.js 'util' module
  27997. ctor.super_ = superCtor;
  27998. ctor.prototype = Object.create(superCtor.prototype, {
  27999. constructor: {
  28000. value: ctor,
  28001. enumerable: false,
  28002. writable: true,
  28003. configurable: true
  28004. }
  28005. });
  28006. };
  28007. } else {
  28008. inherits = function inherits(ctor, superCtor) {
  28009. ctor.super_ = superCtor;
  28010. var TempCtor = function () {};
  28011. TempCtor.prototype = superCtor.prototype;
  28012. ctor.prototype = new TempCtor();
  28013. ctor.prototype.constructor = ctor;
  28014. };
  28015. }
  28016. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  28017. function getOwnPropertyDescriptors(obj) {
  28018. var keys = Object.keys(obj);
  28019. var descriptors = {};
  28020. for (var i = 0; i < keys.length; i++) {
  28021. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  28022. }
  28023. return descriptors;
  28024. };
  28025. var formatRegExp = /%[sdj%]/g;
  28026. function format$1(f) {
  28027. if (!isString$1(f)) {
  28028. var objects = [];
  28029. for (var i = 0; i < arguments.length; i++) {
  28030. objects.push(inspect(arguments[i]));
  28031. }
  28032. return objects.join(' ');
  28033. }
  28034. var i = 1;
  28035. var args = arguments;
  28036. var len = args.length;
  28037. var str = String(f).replace(formatRegExp, function(x) {
  28038. if (x === '%%') return '%';
  28039. if (i >= len) return x;
  28040. switch (x) {
  28041. case '%s': return String(args[i++]);
  28042. case '%d': return Number(args[i++]);
  28043. case '%j':
  28044. try {
  28045. return JSON.stringify(args[i++]);
  28046. } catch (_) {
  28047. return '[Circular]';
  28048. }
  28049. default:
  28050. return x;
  28051. }
  28052. });
  28053. for (var x = args[i]; i < len; x = args[++i]) {
  28054. if (isNull(x) || !isObject$1(x)) {
  28055. str += ' ' + x;
  28056. } else {
  28057. str += ' ' + inspect(x);
  28058. }
  28059. }
  28060. return str;
  28061. }
  28062. // Mark that a method should not be used.
  28063. // Returns a modified function which warns once by default.
  28064. // If --no-deprecation is set, then it is a no-op.
  28065. function deprecate(fn, msg) {
  28066. // Allow for deprecating things in the process of starting up.
  28067. if (isUndefined(global$1.process)) {
  28068. return function() {
  28069. return deprecate(fn, msg).apply(this, arguments);
  28070. };
  28071. }
  28072. if (browser$1.noDeprecation === true) {
  28073. return fn;
  28074. }
  28075. var warned = false;
  28076. function deprecated() {
  28077. if (!warned) {
  28078. if (browser$1.throwDeprecation) {
  28079. throw new Error(msg);
  28080. } else if (browser$1.traceDeprecation) {
  28081. console.trace(msg);
  28082. } else {
  28083. console.error(msg);
  28084. }
  28085. warned = true;
  28086. }
  28087. return fn.apply(this, arguments);
  28088. }
  28089. return deprecated;
  28090. }
  28091. var debugs = {};
  28092. var debugEnviron;
  28093. function debuglog(set) {
  28094. if (isUndefined(debugEnviron))
  28095. debugEnviron = browser$1.env.NODE_DEBUG || '';
  28096. set = set.toUpperCase();
  28097. if (!debugs[set]) {
  28098. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  28099. var pid = 0;
  28100. debugs[set] = function() {
  28101. var msg = format$1.apply(null, arguments);
  28102. console.error('%s %d: %s', set, pid, msg);
  28103. };
  28104. } else {
  28105. debugs[set] = function() {};
  28106. }
  28107. }
  28108. return debugs[set];
  28109. }
  28110. /**
  28111. * Echos the value of a value. Trys to print the value out
  28112. * in the best way possible given the different types.
  28113. *
  28114. * @param {Object} obj The object to print out.
  28115. * @param {Object} opts Optional options object that alters the output.
  28116. */
  28117. /* legacy: obj, showHidden, depth, colors*/
  28118. function inspect(obj, opts) {
  28119. // default options
  28120. var ctx = {
  28121. seen: [],
  28122. stylize: stylizeNoColor
  28123. };
  28124. // legacy...
  28125. if (arguments.length >= 3) ctx.depth = arguments[2];
  28126. if (arguments.length >= 4) ctx.colors = arguments[3];
  28127. if (isBoolean(opts)) {
  28128. // legacy...
  28129. ctx.showHidden = opts;
  28130. } else if (opts) {
  28131. // got an "options" object
  28132. _extend(ctx, opts);
  28133. }
  28134. // set default options
  28135. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  28136. if (isUndefined(ctx.depth)) ctx.depth = 2;
  28137. if (isUndefined(ctx.colors)) ctx.colors = false;
  28138. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  28139. if (ctx.colors) ctx.stylize = stylizeWithColor;
  28140. return formatValue(ctx, obj, ctx.depth);
  28141. }
  28142. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  28143. inspect.colors = {
  28144. 'bold' : [1, 22],
  28145. 'italic' : [3, 23],
  28146. 'underline' : [4, 24],
  28147. 'inverse' : [7, 27],
  28148. 'white' : [37, 39],
  28149. 'grey' : [90, 39],
  28150. 'black' : [30, 39],
  28151. 'blue' : [34, 39],
  28152. 'cyan' : [36, 39],
  28153. 'green' : [32, 39],
  28154. 'magenta' : [35, 39],
  28155. 'red' : [31, 39],
  28156. 'yellow' : [33, 39]
  28157. };
  28158. // Don't use 'blue' not visible on cmd.exe
  28159. inspect.styles = {
  28160. 'special': 'cyan',
  28161. 'number': 'yellow',
  28162. 'boolean': 'yellow',
  28163. 'undefined': 'grey',
  28164. 'null': 'bold',
  28165. 'string': 'green',
  28166. 'date': 'magenta',
  28167. // "name": intentionally not styling
  28168. 'regexp': 'red'
  28169. };
  28170. function stylizeWithColor(str, styleType) {
  28171. var style = inspect.styles[styleType];
  28172. if (style) {
  28173. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  28174. '\u001b[' + inspect.colors[style][1] + 'm';
  28175. } else {
  28176. return str;
  28177. }
  28178. }
  28179. function stylizeNoColor(str, styleType) {
  28180. return str;
  28181. }
  28182. function arrayToHash(array) {
  28183. var hash = {};
  28184. array.forEach(function(val, idx) {
  28185. hash[val] = true;
  28186. });
  28187. return hash;
  28188. }
  28189. function formatValue(ctx, value, recurseTimes) {
  28190. // Provide a hook for user-specified inspect functions.
  28191. // Check that value is an object with an inspect function on it
  28192. if (ctx.customInspect &&
  28193. value &&
  28194. isFunction(value.inspect) &&
  28195. // Filter out the util module, it's inspect function is special
  28196. value.inspect !== inspect &&
  28197. // Also filter out any prototype objects using the circular check.
  28198. !(value.constructor && value.constructor.prototype === value)) {
  28199. var ret = value.inspect(recurseTimes, ctx);
  28200. if (!isString$1(ret)) {
  28201. ret = formatValue(ctx, ret, recurseTimes);
  28202. }
  28203. return ret;
  28204. }
  28205. // Primitive types cannot have properties
  28206. var primitive = formatPrimitive(ctx, value);
  28207. if (primitive) {
  28208. return primitive;
  28209. }
  28210. // Look up the keys of the object.
  28211. var keys = Object.keys(value);
  28212. var visibleKeys = arrayToHash(keys);
  28213. if (ctx.showHidden) {
  28214. keys = Object.getOwnPropertyNames(value);
  28215. }
  28216. // IE doesn't make error fields non-enumerable
  28217. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  28218. if (isError(value)
  28219. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  28220. return formatError(value);
  28221. }
  28222. // Some type of object without properties can be shortcutted.
  28223. if (keys.length === 0) {
  28224. if (isFunction(value)) {
  28225. var name = value.name ? ': ' + value.name : '';
  28226. return ctx.stylize('[Function' + name + ']', 'special');
  28227. }
  28228. if (isRegExp(value)) {
  28229. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28230. }
  28231. if (isDate(value)) {
  28232. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  28233. }
  28234. if (isError(value)) {
  28235. return formatError(value);
  28236. }
  28237. }
  28238. var base = '', array = false, braces = ['{', '}'];
  28239. // Make Array say that they are Array
  28240. if (isArray$1(value)) {
  28241. array = true;
  28242. braces = ['[', ']'];
  28243. }
  28244. // Make functions say that they are functions
  28245. if (isFunction(value)) {
  28246. var n = value.name ? ': ' + value.name : '';
  28247. base = ' [Function' + n + ']';
  28248. }
  28249. // Make RegExps say that they are RegExps
  28250. if (isRegExp(value)) {
  28251. base = ' ' + RegExp.prototype.toString.call(value);
  28252. }
  28253. // Make dates with properties first say the date
  28254. if (isDate(value)) {
  28255. base = ' ' + Date.prototype.toUTCString.call(value);
  28256. }
  28257. // Make error with message first say the error
  28258. if (isError(value)) {
  28259. base = ' ' + formatError(value);
  28260. }
  28261. if (keys.length === 0 && (!array || value.length == 0)) {
  28262. return braces[0] + base + braces[1];
  28263. }
  28264. if (recurseTimes < 0) {
  28265. if (isRegExp(value)) {
  28266. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  28267. } else {
  28268. return ctx.stylize('[Object]', 'special');
  28269. }
  28270. }
  28271. ctx.seen.push(value);
  28272. var output;
  28273. if (array) {
  28274. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  28275. } else {
  28276. output = keys.map(function(key) {
  28277. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  28278. });
  28279. }
  28280. ctx.seen.pop();
  28281. return reduceToSingleString(output, base, braces);
  28282. }
  28283. function formatPrimitive(ctx, value) {
  28284. if (isUndefined(value))
  28285. return ctx.stylize('undefined', 'undefined');
  28286. if (isString$1(value)) {
  28287. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  28288. .replace(/'/g, "\\'")
  28289. .replace(/\\"/g, '"') + '\'';
  28290. return ctx.stylize(simple, 'string');
  28291. }
  28292. if (isNumber(value))
  28293. return ctx.stylize('' + value, 'number');
  28294. if (isBoolean(value))
  28295. return ctx.stylize('' + value, 'boolean');
  28296. // For some reason typeof null is "object", so special case here.
  28297. if (isNull(value))
  28298. return ctx.stylize('null', 'null');
  28299. }
  28300. function formatError(value) {
  28301. return '[' + Error.prototype.toString.call(value) + ']';
  28302. }
  28303. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  28304. var output = [];
  28305. for (var i = 0, l = value.length; i < l; ++i) {
  28306. if (hasOwnProperty$3(value, String(i))) {
  28307. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28308. String(i), true));
  28309. } else {
  28310. output.push('');
  28311. }
  28312. }
  28313. keys.forEach(function(key) {
  28314. if (!key.match(/^\d+$/)) {
  28315. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  28316. key, true));
  28317. }
  28318. });
  28319. return output;
  28320. }
  28321. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  28322. var name, str, desc;
  28323. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  28324. if (desc.get) {
  28325. if (desc.set) {
  28326. str = ctx.stylize('[Getter/Setter]', 'special');
  28327. } else {
  28328. str = ctx.stylize('[Getter]', 'special');
  28329. }
  28330. } else {
  28331. if (desc.set) {
  28332. str = ctx.stylize('[Setter]', 'special');
  28333. }
  28334. }
  28335. if (!hasOwnProperty$3(visibleKeys, key)) {
  28336. name = '[' + key + ']';
  28337. }
  28338. if (!str) {
  28339. if (ctx.seen.indexOf(desc.value) < 0) {
  28340. if (isNull(recurseTimes)) {
  28341. str = formatValue(ctx, desc.value, null);
  28342. } else {
  28343. str = formatValue(ctx, desc.value, recurseTimes - 1);
  28344. }
  28345. if (str.indexOf('\n') > -1) {
  28346. if (array) {
  28347. str = str.split('\n').map(function(line) {
  28348. return ' ' + line;
  28349. }).join('\n').substr(2);
  28350. } else {
  28351. str = '\n' + str.split('\n').map(function(line) {
  28352. return ' ' + line;
  28353. }).join('\n');
  28354. }
  28355. }
  28356. } else {
  28357. str = ctx.stylize('[Circular]', 'special');
  28358. }
  28359. }
  28360. if (isUndefined(name)) {
  28361. if (array && key.match(/^\d+$/)) {
  28362. return str;
  28363. }
  28364. name = JSON.stringify('' + key);
  28365. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  28366. name = name.substr(1, name.length - 2);
  28367. name = ctx.stylize(name, 'name');
  28368. } else {
  28369. name = name.replace(/'/g, "\\'")
  28370. .replace(/\\"/g, '"')
  28371. .replace(/(^"|"$)/g, "'");
  28372. name = ctx.stylize(name, 'string');
  28373. }
  28374. }
  28375. return name + ': ' + str;
  28376. }
  28377. function reduceToSingleString(output, base, braces) {
  28378. var length = output.reduce(function(prev, cur) {
  28379. if (cur.indexOf('\n') >= 0) ;
  28380. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  28381. }, 0);
  28382. if (length > 60) {
  28383. return braces[0] +
  28384. (base === '' ? '' : base + '\n ') +
  28385. ' ' +
  28386. output.join(',\n ') +
  28387. ' ' +
  28388. braces[1];
  28389. }
  28390. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  28391. }
  28392. // NOTE: These type checking functions intentionally don't use `instanceof`
  28393. // because it is fragile and can be easily faked with `Object.create()`.
  28394. function isArray$1(ar) {
  28395. return Array.isArray(ar);
  28396. }
  28397. function isBoolean(arg) {
  28398. return typeof arg === 'boolean';
  28399. }
  28400. function isNull(arg) {
  28401. return arg === null;
  28402. }
  28403. function isNullOrUndefined(arg) {
  28404. return arg == null;
  28405. }
  28406. function isNumber(arg) {
  28407. return typeof arg === 'number';
  28408. }
  28409. function isString$1(arg) {
  28410. return typeof arg === 'string';
  28411. }
  28412. function isSymbol(arg) {
  28413. return typeof arg === 'symbol';
  28414. }
  28415. function isUndefined(arg) {
  28416. return arg === void 0;
  28417. }
  28418. function isRegExp(re) {
  28419. return isObject$1(re) && objectToString(re) === '[object RegExp]';
  28420. }
  28421. function isObject$1(arg) {
  28422. return typeof arg === 'object' && arg !== null;
  28423. }
  28424. function isDate(d) {
  28425. return isObject$1(d) && objectToString(d) === '[object Date]';
  28426. }
  28427. function isError(e) {
  28428. return isObject$1(e) &&
  28429. (objectToString(e) === '[object Error]' || e instanceof Error);
  28430. }
  28431. function isFunction(arg) {
  28432. return typeof arg === 'function';
  28433. }
  28434. function isPrimitive(arg) {
  28435. return arg === null ||
  28436. typeof arg === 'boolean' ||
  28437. typeof arg === 'number' ||
  28438. typeof arg === 'string' ||
  28439. typeof arg === 'symbol' || // ES6 symbol
  28440. typeof arg === 'undefined';
  28441. }
  28442. function isBuffer(maybeBuf) {
  28443. return Buffer$1.isBuffer(maybeBuf);
  28444. }
  28445. function objectToString(o) {
  28446. return Object.prototype.toString.call(o);
  28447. }
  28448. function pad(n) {
  28449. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  28450. }
  28451. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  28452. 'Oct', 'Nov', 'Dec'];
  28453. // 26 Feb 16:19:34
  28454. function timestamp() {
  28455. var d = new Date();
  28456. var time = [pad(d.getHours()),
  28457. pad(d.getMinutes()),
  28458. pad(d.getSeconds())].join(':');
  28459. return [d.getDate(), months[d.getMonth()], time].join(' ');
  28460. }
  28461. // log is just a thin wrapper to console.log that prepends a timestamp
  28462. function log() {
  28463. console.log('%s - %s', timestamp(), format$1.apply(null, arguments));
  28464. }
  28465. function _extend(origin, add) {
  28466. // Don't do anything if add isn't an object
  28467. if (!add || !isObject$1(add)) return origin;
  28468. var keys = Object.keys(add);
  28469. var i = keys.length;
  28470. while (i--) {
  28471. origin[keys[i]] = add[keys[i]];
  28472. }
  28473. return origin;
  28474. }
  28475. function hasOwnProperty$3(obj, prop) {
  28476. return Object.prototype.hasOwnProperty.call(obj, prop);
  28477. }
  28478. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  28479. function promisify(original) {
  28480. if (typeof original !== 'function')
  28481. throw new TypeError('The "original" argument must be of type Function');
  28482. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  28483. var fn = original[kCustomPromisifiedSymbol];
  28484. if (typeof fn !== 'function') {
  28485. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  28486. }
  28487. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28488. value: fn, enumerable: false, writable: false, configurable: true
  28489. });
  28490. return fn;
  28491. }
  28492. function fn() {
  28493. var promiseResolve, promiseReject;
  28494. var promise = new Promise(function (resolve, reject) {
  28495. promiseResolve = resolve;
  28496. promiseReject = reject;
  28497. });
  28498. var args = [];
  28499. for (var i = 0; i < arguments.length; i++) {
  28500. args.push(arguments[i]);
  28501. }
  28502. args.push(function (err, value) {
  28503. if (err) {
  28504. promiseReject(err);
  28505. } else {
  28506. promiseResolve(value);
  28507. }
  28508. });
  28509. try {
  28510. original.apply(this, args);
  28511. } catch (err) {
  28512. promiseReject(err);
  28513. }
  28514. return promise;
  28515. }
  28516. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  28517. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  28518. value: fn, enumerable: false, writable: false, configurable: true
  28519. });
  28520. return Object.defineProperties(
  28521. fn,
  28522. getOwnPropertyDescriptors(original)
  28523. );
  28524. }
  28525. promisify.custom = kCustomPromisifiedSymbol;
  28526. function callbackifyOnRejected(reason, cb) {
  28527. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  28528. // Because `null` is a special error value in callbacks which means "no error
  28529. // occurred", we error-wrap so the callback consumer can distinguish between
  28530. // "the promise rejected with null" or "the promise fulfilled with undefined".
  28531. if (!reason) {
  28532. var newReason = new Error('Promise was rejected with a falsy value');
  28533. newReason.reason = reason;
  28534. reason = newReason;
  28535. }
  28536. return cb(reason);
  28537. }
  28538. function callbackify(original) {
  28539. if (typeof original !== 'function') {
  28540. throw new TypeError('The "original" argument must be of type Function');
  28541. }
  28542. // We DO NOT return the promise as it gives the user a false sense that
  28543. // the promise is actually somehow related to the callback's execution
  28544. // and that the callback throwing will reject the promise.
  28545. function callbackified() {
  28546. var args = [];
  28547. for (var i = 0; i < arguments.length; i++) {
  28548. args.push(arguments[i]);
  28549. }
  28550. var maybeCb = args.pop();
  28551. if (typeof maybeCb !== 'function') {
  28552. throw new TypeError('The last argument must be of type Function');
  28553. }
  28554. var self = this;
  28555. var cb = function() {
  28556. return maybeCb.apply(self, arguments);
  28557. };
  28558. // In true node style we process the callback on `nextTick` with all the
  28559. // implications (stack, `uncaughtException`, `async_hooks`)
  28560. original.apply(this, args)
  28561. .then(function(ret) { browser$1.nextTick(cb.bind(null, null, ret)); },
  28562. function(rej) { browser$1.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
  28563. }
  28564. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  28565. Object.defineProperties(callbackified, getOwnPropertyDescriptors(original));
  28566. return callbackified;
  28567. }
  28568. var _polyfillNode_util = {
  28569. inherits: inherits,
  28570. _extend: _extend,
  28571. log: log,
  28572. isBuffer: isBuffer,
  28573. isPrimitive: isPrimitive,
  28574. isFunction: isFunction,
  28575. isError: isError,
  28576. isDate: isDate,
  28577. isObject: isObject$1,
  28578. isRegExp: isRegExp,
  28579. isUndefined: isUndefined,
  28580. isSymbol: isSymbol,
  28581. isString: isString$1,
  28582. isNumber: isNumber,
  28583. isNullOrUndefined: isNullOrUndefined,
  28584. isNull: isNull,
  28585. isBoolean: isBoolean,
  28586. isArray: isArray$1,
  28587. inspect: inspect,
  28588. deprecate: deprecate,
  28589. format: format$1,
  28590. debuglog: debuglog,
  28591. promisify: promisify,
  28592. callbackify: callbackify,
  28593. };
  28594. var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
  28595. __proto__: null,
  28596. _extend: _extend,
  28597. callbackify: callbackify,
  28598. debuglog: debuglog,
  28599. default: _polyfillNode_util,
  28600. deprecate: deprecate,
  28601. format: format$1,
  28602. inherits: inherits,
  28603. inspect: inspect,
  28604. isArray: isArray$1,
  28605. isBoolean: isBoolean,
  28606. isBuffer: isBuffer,
  28607. isDate: isDate,
  28608. isError: isError,
  28609. isFunction: isFunction,
  28610. isNull: isNull,
  28611. isNullOrUndefined: isNullOrUndefined,
  28612. isNumber: isNumber,
  28613. isObject: isObject$1,
  28614. isPrimitive: isPrimitive,
  28615. isRegExp: isRegExp,
  28616. isString: isString$1,
  28617. isSymbol: isSymbol,
  28618. isUndefined: isUndefined,
  28619. log: log,
  28620. promisify: promisify
  28621. });
  28622. // Copyright Joyent, Inc. and other Node contributors.
  28623. //
  28624. // Permission is hereby granted, free of charge, to any person obtaining a
  28625. // copy of this software and associated documentation files (the
  28626. // "Software"), to deal in the Software without restriction, including
  28627. // without limitation the rights to use, copy, modify, merge, publish,
  28628. // distribute, sublicense, and/or sell copies of the Software, and to permit
  28629. // persons to whom the Software is furnished to do so, subject to the
  28630. // following conditions:
  28631. //
  28632. // The above copyright notice and this permission notice shall be included
  28633. // in all copies or substantial portions of the Software.
  28634. //
  28635. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  28636. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28637. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  28638. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  28639. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  28640. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  28641. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  28642. // If obj.hasOwnProperty has been overridden, then calling
  28643. // obj.hasOwnProperty(prop) will break.
  28644. // See: https://github.com/joyent/node/issues/1707
  28645. function hasOwnProperty$2(obj, prop) {
  28646. return Object.prototype.hasOwnProperty.call(obj, prop);
  28647. }
  28648. var isArray = Array.isArray || function (xs) {
  28649. return Object.prototype.toString.call(xs) === '[object Array]';
  28650. };
  28651. function stringifyPrimitive(v) {
  28652. switch (typeof v) {
  28653. case 'string':
  28654. return v;
  28655. case 'boolean':
  28656. return v ? 'true' : 'false';
  28657. case 'number':
  28658. return isFinite(v) ? v : '';
  28659. default:
  28660. return '';
  28661. }
  28662. }
  28663. function stringify$5 (obj, sep, eq, name) {
  28664. sep = sep || '&';
  28665. eq = eq || '=';
  28666. if (obj === null) {
  28667. obj = undefined;
  28668. }
  28669. if (typeof obj === 'object') {
  28670. return map(objectKeys(obj), function(k) {
  28671. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  28672. if (isArray(obj[k])) {
  28673. return map(obj[k], function(v) {
  28674. return ks + encodeURIComponent(stringifyPrimitive(v));
  28675. }).join(sep);
  28676. } else {
  28677. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  28678. }
  28679. }).join(sep);
  28680. }
  28681. if (!name) return '';
  28682. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  28683. encodeURIComponent(stringifyPrimitive(obj));
  28684. }
  28685. function map (xs, f) {
  28686. if (xs.map) return xs.map(f);
  28687. var res = [];
  28688. for (var i = 0; i < xs.length; i++) {
  28689. res.push(f(xs[i], i));
  28690. }
  28691. return res;
  28692. }
  28693. var objectKeys = Object.keys || function (obj) {
  28694. var res = [];
  28695. for (var key in obj) {
  28696. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  28697. }
  28698. return res;
  28699. };
  28700. function parse$6(qs, sep, eq, options) {
  28701. sep = sep || '&';
  28702. eq = eq || '=';
  28703. var obj = {};
  28704. if (typeof qs !== 'string' || qs.length === 0) {
  28705. return obj;
  28706. }
  28707. var regexp = /\+/g;
  28708. qs = qs.split(sep);
  28709. var maxKeys = 1000;
  28710. if (options && typeof options.maxKeys === 'number') {
  28711. maxKeys = options.maxKeys;
  28712. }
  28713. var len = qs.length;
  28714. // maxKeys <= 0 means that we should not limit keys count
  28715. if (maxKeys > 0 && len > maxKeys) {
  28716. len = maxKeys;
  28717. }
  28718. for (var i = 0; i < len; ++i) {
  28719. var x = qs[i].replace(regexp, '%20'),
  28720. idx = x.indexOf(eq),
  28721. kstr, vstr, k, v;
  28722. if (idx >= 0) {
  28723. kstr = x.substr(0, idx);
  28724. vstr = x.substr(idx + 1);
  28725. } else {
  28726. kstr = x;
  28727. vstr = '';
  28728. }
  28729. k = decodeURIComponent(kstr);
  28730. v = decodeURIComponent(vstr);
  28731. if (!hasOwnProperty$2(obj, k)) {
  28732. obj[k] = v;
  28733. } else if (isArray(obj[k])) {
  28734. obj[k].push(v);
  28735. } else {
  28736. obj[k] = [obj[k], v];
  28737. }
  28738. }
  28739. return obj;
  28740. }
  28741. // WHATWG API
  28742. const URL$1 = global$1.URL;
  28743. const URLSearchParams = global$1.URLSearchParams;
  28744. var _polyfillNode_url = {
  28745. parse: urlParse,
  28746. resolve: urlResolve,
  28747. resolveObject: urlResolveObject,
  28748. fileURLToPath: urlFileURLToPath,
  28749. format: urlFormat,
  28750. Url: Url,
  28751. // WHATWG API
  28752. URL: URL$1,
  28753. URLSearchParams,
  28754. };
  28755. function Url() {
  28756. this.protocol = null;
  28757. this.slashes = null;
  28758. this.auth = null;
  28759. this.host = null;
  28760. this.port = null;
  28761. this.hostname = null;
  28762. this.hash = null;
  28763. this.search = null;
  28764. this.query = null;
  28765. this.pathname = null;
  28766. this.path = null;
  28767. this.href = null;
  28768. }
  28769. // Reference: RFC 3986, RFC 1808, RFC 2396
  28770. // define these here so at least they only have to be
  28771. // compiled once on the first module load.
  28772. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  28773. portPattern = /:[0-9]*$/,
  28774. // Special case for a simple path URL
  28775. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  28776. // RFC 2396: characters reserved for delimiting URLs.
  28777. // We actually just auto-escape these.
  28778. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  28779. // RFC 2396: characters not allowed for various reasons.
  28780. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  28781. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  28782. autoEscape = ['\''].concat(unwise),
  28783. // Characters that are never ever allowed in a hostname.
  28784. // Note that any invalid chars are also handled, but these
  28785. // are the ones that are *expected* to be seen, so we fast-path
  28786. // them.
  28787. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  28788. hostEndingChars = ['/', '?', '#'],
  28789. hostnameMaxLen = 255,
  28790. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  28791. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  28792. // protocols that can allow "unsafe" and "unwise" chars.
  28793. unsafeProtocol = {
  28794. 'javascript': true,
  28795. 'javascript:': true
  28796. },
  28797. // protocols that never have a hostname.
  28798. hostlessProtocol = {
  28799. 'javascript': true,
  28800. 'javascript:': true
  28801. },
  28802. // protocols that always contain a // bit.
  28803. slashedProtocol = {
  28804. 'http': true,
  28805. 'https': true,
  28806. 'ftp': true,
  28807. 'gopher': true,
  28808. 'file': true,
  28809. 'http:': true,
  28810. 'https:': true,
  28811. 'ftp:': true,
  28812. 'gopher:': true,
  28813. 'file:': true
  28814. };
  28815. function urlParse(url, parseQueryString, slashesDenoteHost) {
  28816. if (url && isObject$1(url) && url instanceof Url) return url;
  28817. var u = new Url;
  28818. u.parse(url, parseQueryString, slashesDenoteHost);
  28819. return u;
  28820. }
  28821. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  28822. return parse$5(this, url, parseQueryString, slashesDenoteHost);
  28823. };
  28824. function parse$5(self, url, parseQueryString, slashesDenoteHost) {
  28825. if (!isString$1(url)) {
  28826. throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
  28827. }
  28828. // Copy chrome, IE, opera backslash-handling behavior.
  28829. // Back slashes before the query string get converted to forward slashes
  28830. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  28831. var queryIndex = url.indexOf('?'),
  28832. splitter =
  28833. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  28834. uSplit = url.split(splitter),
  28835. slashRegex = /\\/g;
  28836. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  28837. url = uSplit.join(splitter);
  28838. var rest = url;
  28839. // trim before proceeding.
  28840. // This is to support parse stuff like " http://foo.com \n"
  28841. rest = rest.trim();
  28842. if (!slashesDenoteHost && url.split('#').length === 1) {
  28843. // Try fast path regexp
  28844. var simplePath = simplePathPattern.exec(rest);
  28845. if (simplePath) {
  28846. self.path = rest;
  28847. self.href = rest;
  28848. self.pathname = simplePath[1];
  28849. if (simplePath[2]) {
  28850. self.search = simplePath[2];
  28851. if (parseQueryString) {
  28852. self.query = parse$6(self.search.substr(1));
  28853. } else {
  28854. self.query = self.search.substr(1);
  28855. }
  28856. } else if (parseQueryString) {
  28857. self.search = '';
  28858. self.query = {};
  28859. }
  28860. return self;
  28861. }
  28862. }
  28863. var proto = protocolPattern.exec(rest);
  28864. if (proto) {
  28865. proto = proto[0];
  28866. var lowerProto = proto.toLowerCase();
  28867. self.protocol = lowerProto;
  28868. rest = rest.substr(proto.length);
  28869. }
  28870. // figure out if it's got a host
  28871. // user@server is *always* interpreted as a hostname, and url
  28872. // resolution will treat //foo/bar as host=foo,path=bar because that's
  28873. // how the browser resolves relative URLs.
  28874. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  28875. var slashes = rest.substr(0, 2) === '//';
  28876. if (slashes && !(proto && hostlessProtocol[proto])) {
  28877. rest = rest.substr(2);
  28878. self.slashes = true;
  28879. }
  28880. }
  28881. var i, hec, l, p;
  28882. if (!hostlessProtocol[proto] &&
  28883. (slashes || (proto && !slashedProtocol[proto]))) {
  28884. // there's a hostname.
  28885. // the first instance of /, ?, ;, or # ends the host.
  28886. //
  28887. // If there is an @ in the hostname, then non-host chars *are* allowed
  28888. // to the left of the last @ sign, unless some host-ending character
  28889. // comes *before* the @-sign.
  28890. // URLs are obnoxious.
  28891. //
  28892. // ex:
  28893. // http://a@b@c/ => user:a@b host:c
  28894. // http://a@b?@c => user:a host:c path:/?@c
  28895. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  28896. // Review our test case against browsers more comprehensively.
  28897. // find the first instance of any hostEndingChars
  28898. var hostEnd = -1;
  28899. for (i = 0; i < hostEndingChars.length; i++) {
  28900. hec = rest.indexOf(hostEndingChars[i]);
  28901. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  28902. hostEnd = hec;
  28903. }
  28904. // at this point, either we have an explicit point where the
  28905. // auth portion cannot go past, or the last @ char is the decider.
  28906. var auth, atSign;
  28907. if (hostEnd === -1) {
  28908. // atSign can be anywhere.
  28909. atSign = rest.lastIndexOf('@');
  28910. } else {
  28911. // atSign must be in auth portion.
  28912. // http://a@b/c@d => host:b auth:a path:/c@d
  28913. atSign = rest.lastIndexOf('@', hostEnd);
  28914. }
  28915. // Now we have a portion which is definitely the auth.
  28916. // Pull that off.
  28917. if (atSign !== -1) {
  28918. auth = rest.slice(0, atSign);
  28919. rest = rest.slice(atSign + 1);
  28920. self.auth = decodeURIComponent(auth);
  28921. }
  28922. // the host is the remaining to the left of the first non-host char
  28923. hostEnd = -1;
  28924. for (i = 0; i < nonHostChars.length; i++) {
  28925. hec = rest.indexOf(nonHostChars[i]);
  28926. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  28927. hostEnd = hec;
  28928. }
  28929. // if we still have not hit it, then the entire thing is a host.
  28930. if (hostEnd === -1)
  28931. hostEnd = rest.length;
  28932. self.host = rest.slice(0, hostEnd);
  28933. rest = rest.slice(hostEnd);
  28934. // pull out port.
  28935. parseHost(self);
  28936. // we've indicated that there is a hostname,
  28937. // so even if it's empty, it has to be present.
  28938. self.hostname = self.hostname || '';
  28939. // if hostname begins with [ and ends with ]
  28940. // assume that it's an IPv6 address.
  28941. var ipv6Hostname = self.hostname[0] === '[' &&
  28942. self.hostname[self.hostname.length - 1] === ']';
  28943. // validate a little.
  28944. if (!ipv6Hostname) {
  28945. var hostparts = self.hostname.split(/\./);
  28946. for (i = 0, l = hostparts.length; i < l; i++) {
  28947. var part = hostparts[i];
  28948. if (!part) continue;
  28949. if (!part.match(hostnamePartPattern)) {
  28950. var newpart = '';
  28951. for (var j = 0, k = part.length; j < k; j++) {
  28952. if (part.charCodeAt(j) > 127) {
  28953. // we replace non-ASCII char with a temporary placeholder
  28954. // we need this to make sure size of hostname is not
  28955. // broken by replacing non-ASCII by nothing
  28956. newpart += 'x';
  28957. } else {
  28958. newpart += part[j];
  28959. }
  28960. }
  28961. // we test again with ASCII char only
  28962. if (!newpart.match(hostnamePartPattern)) {
  28963. var validParts = hostparts.slice(0, i);
  28964. var notHost = hostparts.slice(i + 1);
  28965. var bit = part.match(hostnamePartStart);
  28966. if (bit) {
  28967. validParts.push(bit[1]);
  28968. notHost.unshift(bit[2]);
  28969. }
  28970. if (notHost.length) {
  28971. rest = '/' + notHost.join('.') + rest;
  28972. }
  28973. self.hostname = validParts.join('.');
  28974. break;
  28975. }
  28976. }
  28977. }
  28978. }
  28979. if (self.hostname.length > hostnameMaxLen) {
  28980. self.hostname = '';
  28981. } else {
  28982. // hostnames are always lower case.
  28983. self.hostname = self.hostname.toLowerCase();
  28984. }
  28985. if (!ipv6Hostname) {
  28986. // IDNA Support: Returns a punycoded representation of "domain".
  28987. // It only converts parts of the domain name that
  28988. // have non-ASCII characters, i.e. it doesn't matter if
  28989. // you call it with a domain that already is ASCII-only.
  28990. self.hostname = toASCII(self.hostname);
  28991. }
  28992. p = self.port ? ':' + self.port : '';
  28993. var h = self.hostname || '';
  28994. self.host = h + p;
  28995. self.href += self.host;
  28996. // strip [ and ] from the hostname
  28997. // the host field still retains them, though
  28998. if (ipv6Hostname) {
  28999. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  29000. if (rest[0] !== '/') {
  29001. rest = '/' + rest;
  29002. }
  29003. }
  29004. }
  29005. // now rest is set to the post-host stuff.
  29006. // chop off any delim chars.
  29007. if (!unsafeProtocol[lowerProto]) {
  29008. // First, make 100% sure that any "autoEscape" chars get
  29009. // escaped, even if encodeURIComponent doesn't think they
  29010. // need to be.
  29011. for (i = 0, l = autoEscape.length; i < l; i++) {
  29012. var ae = autoEscape[i];
  29013. if (rest.indexOf(ae) === -1)
  29014. continue;
  29015. var esc = encodeURIComponent(ae);
  29016. if (esc === ae) {
  29017. esc = escape(ae);
  29018. }
  29019. rest = rest.split(ae).join(esc);
  29020. }
  29021. }
  29022. // chop off from the tail first.
  29023. var hash = rest.indexOf('#');
  29024. if (hash !== -1) {
  29025. // got a fragment string.
  29026. self.hash = rest.substr(hash);
  29027. rest = rest.slice(0, hash);
  29028. }
  29029. var qm = rest.indexOf('?');
  29030. if (qm !== -1) {
  29031. self.search = rest.substr(qm);
  29032. self.query = rest.substr(qm + 1);
  29033. if (parseQueryString) {
  29034. self.query = parse$6(self.query);
  29035. }
  29036. rest = rest.slice(0, qm);
  29037. } else if (parseQueryString) {
  29038. // no query string, but parseQueryString still requested
  29039. self.search = '';
  29040. self.query = {};
  29041. }
  29042. if (rest) self.pathname = rest;
  29043. if (slashedProtocol[lowerProto] &&
  29044. self.hostname && !self.pathname) {
  29045. self.pathname = '/';
  29046. }
  29047. //to support http.request
  29048. if (self.pathname || self.search) {
  29049. p = self.pathname || '';
  29050. var s = self.search || '';
  29051. self.path = p + s;
  29052. }
  29053. // finally, reconstruct the href based on what has been validated.
  29054. self.href = format(self);
  29055. return self;
  29056. }
  29057. function urlFileURLToPath(path) {
  29058. if (typeof path === 'string')
  29059. path = new Url().parse(path);
  29060. else if (!(path instanceof Url))
  29061. throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type ' + (typeof path) + String(path));
  29062. if (path.protocol !== 'file:')
  29063. throw new TypeError('The URL must be of scheme file');
  29064. return getPathFromURLPosix(path);
  29065. }
  29066. function getPathFromURLPosix(url) {
  29067. const pathname = url.pathname;
  29068. for (let n = 0; n < pathname.length; n++) {
  29069. if (pathname[n] === '%') {
  29070. const third = pathname.codePointAt(n + 2) | 0x20;
  29071. if (pathname[n + 1] === '2' && third === 102) {
  29072. throw new TypeError(
  29073. 'must not include encoded / characters'
  29074. );
  29075. }
  29076. }
  29077. }
  29078. return decodeURIComponent(pathname);
  29079. }
  29080. // format a parsed object into a url string
  29081. function urlFormat(obj) {
  29082. // ensure it's an object, and not a string url.
  29083. // If it's an obj, this is a no-op.
  29084. // this way, you can call url_format() on strings
  29085. // to clean up potentially wonky urls.
  29086. if (isString$1(obj)) obj = parse$5({}, obj);
  29087. return format(obj);
  29088. }
  29089. function format(self) {
  29090. var auth = self.auth || '';
  29091. if (auth) {
  29092. auth = encodeURIComponent(auth);
  29093. auth = auth.replace(/%3A/i, ':');
  29094. auth += '@';
  29095. }
  29096. var protocol = self.protocol || '',
  29097. pathname = self.pathname || '',
  29098. hash = self.hash || '',
  29099. host = false,
  29100. query = '';
  29101. if (self.host) {
  29102. host = auth + self.host;
  29103. } else if (self.hostname) {
  29104. host = auth + (self.hostname.indexOf(':') === -1 ?
  29105. self.hostname :
  29106. '[' + this.hostname + ']');
  29107. if (self.port) {
  29108. host += ':' + self.port;
  29109. }
  29110. }
  29111. if (self.query &&
  29112. isObject$1(self.query) &&
  29113. Object.keys(self.query).length) {
  29114. query = stringify$5(self.query);
  29115. }
  29116. var search = self.search || (query && ('?' + query)) || '';
  29117. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  29118. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  29119. // unless they had them to begin with.
  29120. if (self.slashes ||
  29121. (!protocol || slashedProtocol[protocol]) && host !== false) {
  29122. host = '//' + (host || '');
  29123. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  29124. } else if (!host) {
  29125. host = '';
  29126. }
  29127. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  29128. if (search && search.charAt(0) !== '?') search = '?' + search;
  29129. pathname = pathname.replace(/[?#]/g, function(match) {
  29130. return encodeURIComponent(match);
  29131. });
  29132. search = search.replace('#', '%23');
  29133. return protocol + host + pathname + search + hash;
  29134. }
  29135. Url.prototype.format = function() {
  29136. return format(this);
  29137. };
  29138. function urlResolve(source, relative) {
  29139. return urlParse(source, false, true).resolve(relative);
  29140. }
  29141. Url.prototype.resolve = function(relative) {
  29142. return this.resolveObject(urlParse(relative, false, true)).format();
  29143. };
  29144. function urlResolveObject(source, relative) {
  29145. if (!source) return relative;
  29146. return urlParse(source, false, true).resolveObject(relative);
  29147. }
  29148. Url.prototype.resolveObject = function(relative) {
  29149. if (isString$1(relative)) {
  29150. var rel = new Url();
  29151. rel.parse(relative, false, true);
  29152. relative = rel;
  29153. }
  29154. var result = new Url();
  29155. var tkeys = Object.keys(this);
  29156. for (var tk = 0; tk < tkeys.length; tk++) {
  29157. var tkey = tkeys[tk];
  29158. result[tkey] = this[tkey];
  29159. }
  29160. // hash is always overridden, no matter what.
  29161. // even href="" will remove it.
  29162. result.hash = relative.hash;
  29163. // if the relative url is empty, then there's nothing left to do here.
  29164. if (relative.href === '') {
  29165. result.href = result.format();
  29166. return result;
  29167. }
  29168. // hrefs like //foo/bar always cut to the protocol.
  29169. if (relative.slashes && !relative.protocol) {
  29170. // take everything except the protocol from relative
  29171. var rkeys = Object.keys(relative);
  29172. for (var rk = 0; rk < rkeys.length; rk++) {
  29173. var rkey = rkeys[rk];
  29174. if (rkey !== 'protocol')
  29175. result[rkey] = relative[rkey];
  29176. }
  29177. //urlParse appends trailing / to urls like http://www.example.com
  29178. if (slashedProtocol[result.protocol] &&
  29179. result.hostname && !result.pathname) {
  29180. result.path = result.pathname = '/';
  29181. }
  29182. result.href = result.format();
  29183. return result;
  29184. }
  29185. var relPath;
  29186. if (relative.protocol && relative.protocol !== result.protocol) {
  29187. // if it's a known url protocol, then changing
  29188. // the protocol does weird things
  29189. // first, if it's not file:, then we MUST have a host,
  29190. // and if there was a path
  29191. // to begin with, then we MUST have a path.
  29192. // if it is file:, then the host is dropped,
  29193. // because that's known to be hostless.
  29194. // anything else is assumed to be absolute.
  29195. if (!slashedProtocol[relative.protocol]) {
  29196. var keys = Object.keys(relative);
  29197. for (var v = 0; v < keys.length; v++) {
  29198. var k = keys[v];
  29199. result[k] = relative[k];
  29200. }
  29201. result.href = result.format();
  29202. return result;
  29203. }
  29204. result.protocol = relative.protocol;
  29205. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  29206. relPath = (relative.pathname || '').split('/');
  29207. while (relPath.length && !(relative.host = relPath.shift()));
  29208. if (!relative.host) relative.host = '';
  29209. if (!relative.hostname) relative.hostname = '';
  29210. if (relPath[0] !== '') relPath.unshift('');
  29211. if (relPath.length < 2) relPath.unshift('');
  29212. result.pathname = relPath.join('/');
  29213. } else {
  29214. result.pathname = relative.pathname;
  29215. }
  29216. result.search = relative.search;
  29217. result.query = relative.query;
  29218. result.host = relative.host || '';
  29219. result.auth = relative.auth;
  29220. result.hostname = relative.hostname || relative.host;
  29221. result.port = relative.port;
  29222. // to support http.request
  29223. if (result.pathname || result.search) {
  29224. var p = result.pathname || '';
  29225. var s = result.search || '';
  29226. result.path = p + s;
  29227. }
  29228. result.slashes = result.slashes || relative.slashes;
  29229. result.href = result.format();
  29230. return result;
  29231. }
  29232. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  29233. isRelAbs = (
  29234. relative.host ||
  29235. relative.pathname && relative.pathname.charAt(0) === '/'
  29236. ),
  29237. mustEndAbs = (isRelAbs || isSourceAbs ||
  29238. (result.host && relative.pathname)),
  29239. removeAllDots = mustEndAbs,
  29240. srcPath = result.pathname && result.pathname.split('/') || [],
  29241. psychotic = result.protocol && !slashedProtocol[result.protocol];
  29242. relPath = relative.pathname && relative.pathname.split('/') || [];
  29243. // if the url is a non-slashed url, then relative
  29244. // links like ../.. should be able
  29245. // to crawl up to the hostname, as well. This is strange.
  29246. // result.protocol has already been set by now.
  29247. // Later on, put the first path part into the host field.
  29248. if (psychotic) {
  29249. result.hostname = '';
  29250. result.port = null;
  29251. if (result.host) {
  29252. if (srcPath[0] === '') srcPath[0] = result.host;
  29253. else srcPath.unshift(result.host);
  29254. }
  29255. result.host = '';
  29256. if (relative.protocol) {
  29257. relative.hostname = null;
  29258. relative.port = null;
  29259. if (relative.host) {
  29260. if (relPath[0] === '') relPath[0] = relative.host;
  29261. else relPath.unshift(relative.host);
  29262. }
  29263. relative.host = null;
  29264. }
  29265. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  29266. }
  29267. var authInHost;
  29268. if (isRelAbs) {
  29269. // it's absolute.
  29270. result.host = (relative.host || relative.host === '') ?
  29271. relative.host : result.host;
  29272. result.hostname = (relative.hostname || relative.hostname === '') ?
  29273. relative.hostname : result.hostname;
  29274. result.search = relative.search;
  29275. result.query = relative.query;
  29276. srcPath = relPath;
  29277. // fall through to the dot-handling below.
  29278. } else if (relPath.length) {
  29279. // it's relative
  29280. // throw away the existing file, and take the new path instead.
  29281. if (!srcPath) srcPath = [];
  29282. srcPath.pop();
  29283. srcPath = srcPath.concat(relPath);
  29284. result.search = relative.search;
  29285. result.query = relative.query;
  29286. } else if (!isNullOrUndefined(relative.search)) {
  29287. // just pull out the search.
  29288. // like href='?foo'.
  29289. // Put this after the other two cases because it simplifies the booleans
  29290. if (psychotic) {
  29291. result.hostname = result.host = srcPath.shift();
  29292. //occationaly the auth can get stuck only in host
  29293. //this especially happens in cases like
  29294. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29295. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29296. result.host.split('@') : false;
  29297. if (authInHost) {
  29298. result.auth = authInHost.shift();
  29299. result.host = result.hostname = authInHost.shift();
  29300. }
  29301. }
  29302. result.search = relative.search;
  29303. result.query = relative.query;
  29304. //to support http.request
  29305. if (!isNull(result.pathname) || !isNull(result.search)) {
  29306. result.path = (result.pathname ? result.pathname : '') +
  29307. (result.search ? result.search : '');
  29308. }
  29309. result.href = result.format();
  29310. return result;
  29311. }
  29312. if (!srcPath.length) {
  29313. // no path at all. easy.
  29314. // we've already handled the other stuff above.
  29315. result.pathname = null;
  29316. //to support http.request
  29317. if (result.search) {
  29318. result.path = '/' + result.search;
  29319. } else {
  29320. result.path = null;
  29321. }
  29322. result.href = result.format();
  29323. return result;
  29324. }
  29325. // if a url ENDs in . or .., then it must get a trailing slash.
  29326. // however, if it ends in anything else non-slashy,
  29327. // then it must NOT get a trailing slash.
  29328. var last = srcPath.slice(-1)[0];
  29329. var hasTrailingSlash = (
  29330. (result.host || relative.host || srcPath.length > 1) &&
  29331. (last === '.' || last === '..') || last === '');
  29332. // strip single dots, resolve double dots to parent dir
  29333. // if the path tries to go above the root, `up` ends up > 0
  29334. var up = 0;
  29335. for (var i = srcPath.length; i >= 0; i--) {
  29336. last = srcPath[i];
  29337. if (last === '.') {
  29338. srcPath.splice(i, 1);
  29339. } else if (last === '..') {
  29340. srcPath.splice(i, 1);
  29341. up++;
  29342. } else if (up) {
  29343. srcPath.splice(i, 1);
  29344. up--;
  29345. }
  29346. }
  29347. // if the path is allowed to go above the root, restore leading ..s
  29348. if (!mustEndAbs && !removeAllDots) {
  29349. for (; up--; up) {
  29350. srcPath.unshift('..');
  29351. }
  29352. }
  29353. if (mustEndAbs && srcPath[0] !== '' &&
  29354. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  29355. srcPath.unshift('');
  29356. }
  29357. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  29358. srcPath.push('');
  29359. }
  29360. var isAbsolute = srcPath[0] === '' ||
  29361. (srcPath[0] && srcPath[0].charAt(0) === '/');
  29362. // put the host back
  29363. if (psychotic) {
  29364. result.hostname = result.host = isAbsolute ? '' :
  29365. srcPath.length ? srcPath.shift() : '';
  29366. //occationaly the auth can get stuck only in host
  29367. //this especially happens in cases like
  29368. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  29369. authInHost = result.host && result.host.indexOf('@') > 0 ?
  29370. result.host.split('@') : false;
  29371. if (authInHost) {
  29372. result.auth = authInHost.shift();
  29373. result.host = result.hostname = authInHost.shift();
  29374. }
  29375. }
  29376. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  29377. if (mustEndAbs && !isAbsolute) {
  29378. srcPath.unshift('');
  29379. }
  29380. if (!srcPath.length) {
  29381. result.pathname = null;
  29382. result.path = null;
  29383. } else {
  29384. result.pathname = srcPath.join('/');
  29385. }
  29386. //to support request.http
  29387. if (!isNull(result.pathname) || !isNull(result.search)) {
  29388. result.path = (result.pathname ? result.pathname : '') +
  29389. (result.search ? result.search : '');
  29390. }
  29391. result.auth = relative.auth || result.auth;
  29392. result.slashes = result.slashes || relative.slashes;
  29393. result.href = result.format();
  29394. return result;
  29395. };
  29396. Url.prototype.parseHost = function() {
  29397. return parseHost(this);
  29398. };
  29399. function parseHost(self) {
  29400. var host = self.host;
  29401. var port = portPattern.exec(host);
  29402. if (port) {
  29403. port = port[0];
  29404. if (port !== ':') {
  29405. self.port = port.substr(1);
  29406. }
  29407. host = host.substr(0, host.length - port.length);
  29408. }
  29409. if (host) self.hostname = host;
  29410. }
  29411. var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
  29412. __proto__: null,
  29413. URL: URL$1,
  29414. URLSearchParams: URLSearchParams,
  29415. Url: Url,
  29416. default: _polyfillNode_url,
  29417. fileURLToPath: urlFileURLToPath,
  29418. format: urlFormat,
  29419. parse: urlParse,
  29420. resolve: urlResolve,
  29421. resolveObject: urlResolveObject
  29422. });
  29423. function isRelativeUrl(url) {
  29424. const firstChar = url.charAt(0);
  29425. return firstChar === "." || firstChar === "~" || firstChar === "@";
  29426. }
  29427. const externalRE = /^(https?:)?\/\//;
  29428. function isExternalUrl(url) {
  29429. return externalRE.test(url);
  29430. }
  29431. const dataUrlRE = /^\s*data:/i;
  29432. function isDataUrl(url) {
  29433. return dataUrlRE.test(url);
  29434. }
  29435. function parseUrl(url) {
  29436. const firstChar = url.charAt(0);
  29437. if (firstChar === "~") {
  29438. const secondChar = url.charAt(1);
  29439. url = url.slice(secondChar === "/" ? 2 : 1);
  29440. }
  29441. return parseUriParts(url);
  29442. }
  29443. function parseUriParts(urlString) {
  29444. return urlParse(isString$2(urlString) ? urlString : "", false, true);
  29445. }
  29446. var __defProp$9 = Object.defineProperty;
  29447. var __defProps$8 = Object.defineProperties;
  29448. var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
  29449. var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
  29450. var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
  29451. var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
  29452. var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  29453. var __spreadValues$9 = (a, b) => {
  29454. for (var prop in b || (b = {}))
  29455. if (__hasOwnProp$9.call(b, prop))
  29456. __defNormalProp$9(a, prop, b[prop]);
  29457. if (__getOwnPropSymbols$9)
  29458. for (var prop of __getOwnPropSymbols$9(b)) {
  29459. if (__propIsEnum$9.call(b, prop))
  29460. __defNormalProp$9(a, prop, b[prop]);
  29461. }
  29462. return a;
  29463. };
  29464. var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
  29465. const defaultAssetUrlOptions = {
  29466. base: null,
  29467. includeAbsolute: false,
  29468. tags: {
  29469. video: ["src", "poster"],
  29470. source: ["src"],
  29471. img: ["src"],
  29472. image: ["xlink:href", "href"],
  29473. use: ["xlink:href", "href"]
  29474. }
  29475. };
  29476. const normalizeOptions = (options) => {
  29477. if (Object.keys(options).some((key) => isArray$3(options[key]))) {
  29478. return __spreadProps$8(__spreadValues$9({}, defaultAssetUrlOptions), {
  29479. tags: options
  29480. });
  29481. }
  29482. return __spreadValues$9(__spreadValues$9({}, defaultAssetUrlOptions), options);
  29483. };
  29484. const createAssetUrlTransformWithOptions = (options) => {
  29485. return (node, context) => transformAssetUrl(node, context, options);
  29486. };
  29487. const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
  29488. if (node.type === 1) {
  29489. if (!node.props.length) {
  29490. return;
  29491. }
  29492. const tags = options.tags || defaultAssetUrlOptions.tags;
  29493. const attrs = tags[node.tag];
  29494. const wildCardAttrs = tags["*"];
  29495. if (!attrs && !wildCardAttrs) {
  29496. return;
  29497. }
  29498. const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
  29499. node.props.forEach((attr, index) => {
  29500. 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)) {
  29501. return;
  29502. }
  29503. const url = parseUrl(attr.value.content);
  29504. if (options.base && attr.value.content[0] === ".") {
  29505. const base = parseUrl(options.base);
  29506. const protocol = base.protocol || "";
  29507. const host = base.host ? protocol + "//" + base.host : "";
  29508. const basePath = base.path || "/";
  29509. attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
  29510. return;
  29511. }
  29512. const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
  29513. node.props[index] = {
  29514. type: 7,
  29515. name: "bind",
  29516. arg: createSimpleExpression(attr.name, true, attr.loc),
  29517. exp,
  29518. modifiers: [],
  29519. loc: attr.loc
  29520. };
  29521. });
  29522. }
  29523. };
  29524. function getImportsExpressionExp(path2, hash, loc, context) {
  29525. if (path2) {
  29526. let name;
  29527. let exp;
  29528. const existingIndex = context.imports.findIndex((i) => i.path === path2);
  29529. if (existingIndex > -1) {
  29530. name = `_imports_${existingIndex}`;
  29531. exp = context.imports[existingIndex].exp;
  29532. } else {
  29533. name = `_imports_${context.imports.length}`;
  29534. exp = createSimpleExpression(
  29535. name,
  29536. false,
  29537. loc,
  29538. 3
  29539. );
  29540. context.imports.push({
  29541. exp,
  29542. path: decodeURIComponent(path2)
  29543. });
  29544. }
  29545. if (!hash) {
  29546. return exp;
  29547. }
  29548. const hashExp = `${name} + '${hash}'`;
  29549. const finalExp = createSimpleExpression(
  29550. hashExp,
  29551. false,
  29552. loc,
  29553. 3
  29554. );
  29555. if (!context.hoistStatic) {
  29556. return finalExp;
  29557. }
  29558. const existingHoistIndex = context.hoists.findIndex((h) => {
  29559. return h && h.type === 4 && !h.isStatic && h.content === hashExp;
  29560. });
  29561. if (existingHoistIndex > -1) {
  29562. return createSimpleExpression(
  29563. `_hoisted_${existingHoistIndex + 1}`,
  29564. false,
  29565. loc,
  29566. 3
  29567. );
  29568. }
  29569. return context.hoist(finalExp);
  29570. } else {
  29571. return createSimpleExpression(`''`, false, loc, 3);
  29572. }
  29573. }
  29574. const srcsetTags = ["img", "source"];
  29575. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  29576. const createSrcsetTransformWithOptions = (options) => {
  29577. return (node, context) => transformSrcset(node, context, options);
  29578. };
  29579. const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
  29580. if (node.type === 1) {
  29581. if (srcsetTags.includes(node.tag) && node.props.length) {
  29582. node.props.forEach((attr, index) => {
  29583. if (attr.name === "srcset" && attr.type === 6) {
  29584. if (!attr.value) return;
  29585. const value = attr.value.content;
  29586. if (!value) return;
  29587. const imageCandidates = value.split(",").map((s) => {
  29588. const [url, descriptor] = s.replace(escapedSpaceCharacters, " ").trim().split(" ", 2);
  29589. return { url, descriptor };
  29590. });
  29591. for (let i = 0; i < imageCandidates.length; i++) {
  29592. const { url } = imageCandidates[i];
  29593. if (isDataUrl(url)) {
  29594. imageCandidates[i + 1].url = url + "," + imageCandidates[i + 1].url;
  29595. imageCandidates.splice(i, 1);
  29596. }
  29597. }
  29598. const shouldProcessUrl = (url) => {
  29599. return !isExternalUrl(url) && !isDataUrl(url) && (options.includeAbsolute || isRelativeUrl(url));
  29600. };
  29601. if (!imageCandidates.some(({ url }) => shouldProcessUrl(url))) {
  29602. return;
  29603. }
  29604. if (options.base) {
  29605. const base = options.base;
  29606. const set = [];
  29607. let needImportTransform = false;
  29608. imageCandidates.forEach((candidate) => {
  29609. let { url, descriptor } = candidate;
  29610. descriptor = descriptor ? ` ${descriptor}` : ``;
  29611. if (url[0] === ".") {
  29612. candidate.url = (path.posix || path).join(base, url);
  29613. set.push(candidate.url + descriptor);
  29614. } else if (shouldProcessUrl(url)) {
  29615. needImportTransform = true;
  29616. } else {
  29617. set.push(url + descriptor);
  29618. }
  29619. });
  29620. if (!needImportTransform) {
  29621. attr.value.content = set.join(", ");
  29622. return;
  29623. }
  29624. }
  29625. const compoundExpression = createCompoundExpression([], attr.loc);
  29626. imageCandidates.forEach(({ url, descriptor }, index2) => {
  29627. if (shouldProcessUrl(url)) {
  29628. const { path: path2 } = parseUrl(url);
  29629. let exp2;
  29630. if (path2) {
  29631. const existingImportsIndex = context.imports.findIndex(
  29632. (i) => i.path === path2
  29633. );
  29634. if (existingImportsIndex > -1) {
  29635. exp2 = createSimpleExpression(
  29636. `_imports_${existingImportsIndex}`,
  29637. false,
  29638. attr.loc,
  29639. 3
  29640. );
  29641. } else {
  29642. exp2 = createSimpleExpression(
  29643. `_imports_${context.imports.length}`,
  29644. false,
  29645. attr.loc,
  29646. 3
  29647. );
  29648. context.imports.push({ exp: exp2, path: path2 });
  29649. }
  29650. compoundExpression.children.push(exp2);
  29651. }
  29652. } else {
  29653. const exp2 = createSimpleExpression(
  29654. `"${url}"`,
  29655. false,
  29656. attr.loc,
  29657. 3
  29658. );
  29659. compoundExpression.children.push(exp2);
  29660. }
  29661. const isNotLast = imageCandidates.length - 1 > index2;
  29662. if (descriptor && isNotLast) {
  29663. compoundExpression.children.push(` + ' ${descriptor}, ' + `);
  29664. } else if (descriptor) {
  29665. compoundExpression.children.push(` + ' ${descriptor}'`);
  29666. } else if (isNotLast) {
  29667. compoundExpression.children.push(` + ', ' + `);
  29668. }
  29669. });
  29670. let exp = compoundExpression;
  29671. if (context.hoistStatic) {
  29672. exp = context.hoist(compoundExpression);
  29673. exp.constType = 3;
  29674. }
  29675. node.props[index] = {
  29676. type: 7,
  29677. name: "bind",
  29678. arg: createSimpleExpression("srcset", true, attr.loc),
  29679. exp,
  29680. modifiers: [],
  29681. loc: attr.loc
  29682. };
  29683. }
  29684. });
  29685. }
  29686. }
  29687. };
  29688. const SSR_INTERPOLATE = Symbol(`ssrInterpolate`);
  29689. const SSR_RENDER_VNODE = Symbol(`ssrRenderVNode`);
  29690. const SSR_RENDER_COMPONENT = Symbol(`ssrRenderComponent`);
  29691. const SSR_RENDER_SLOT = Symbol(`ssrRenderSlot`);
  29692. const SSR_RENDER_SLOT_INNER = Symbol(`ssrRenderSlotInner`);
  29693. const SSR_RENDER_CLASS = Symbol(`ssrRenderClass`);
  29694. const SSR_RENDER_STYLE = Symbol(`ssrRenderStyle`);
  29695. const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
  29696. const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
  29697. const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
  29698. const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
  29699. const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(`ssrIncludeBooleanAttr`);
  29700. const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
  29701. const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
  29702. const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
  29703. const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
  29704. const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
  29705. const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
  29706. const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
  29707. const ssrHelpers = {
  29708. [SSR_INTERPOLATE]: `ssrInterpolate`,
  29709. [SSR_RENDER_VNODE]: `ssrRenderVNode`,
  29710. [SSR_RENDER_COMPONENT]: `ssrRenderComponent`,
  29711. [SSR_RENDER_SLOT]: `ssrRenderSlot`,
  29712. [SSR_RENDER_SLOT_INNER]: `ssrRenderSlotInner`,
  29713. [SSR_RENDER_CLASS]: `ssrRenderClass`,
  29714. [SSR_RENDER_STYLE]: `ssrRenderStyle`,
  29715. [SSR_RENDER_ATTRS]: `ssrRenderAttrs`,
  29716. [SSR_RENDER_ATTR]: `ssrRenderAttr`,
  29717. [SSR_RENDER_DYNAMIC_ATTR]: `ssrRenderDynamicAttr`,
  29718. [SSR_RENDER_LIST]: `ssrRenderList`,
  29719. [SSR_INCLUDE_BOOLEAN_ATTR]: `ssrIncludeBooleanAttr`,
  29720. [SSR_LOOSE_EQUAL]: `ssrLooseEqual`,
  29721. [SSR_LOOSE_CONTAIN]: `ssrLooseContain`,
  29722. [SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
  29723. [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
  29724. [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
  29725. [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
  29726. [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
  29727. };
  29728. registerRuntimeHelpers(ssrHelpers);
  29729. const ssrTransformIf = createStructuralDirectiveTransform(
  29730. /^(if|else|else-if)$/,
  29731. processIf
  29732. );
  29733. function ssrProcessIf(node, context, disableNestedFragments = false, disableCommentAsIfAlternate = false) {
  29734. const [rootBranch] = node.branches;
  29735. const ifStatement = createIfStatement(
  29736. rootBranch.condition,
  29737. processIfBranch(rootBranch, context, disableNestedFragments)
  29738. );
  29739. context.pushStatement(ifStatement);
  29740. let currentIf = ifStatement;
  29741. for (let i = 1; i < node.branches.length; i++) {
  29742. const branch = node.branches[i];
  29743. const branchBlockStatement = processIfBranch(
  29744. branch,
  29745. context,
  29746. disableNestedFragments
  29747. );
  29748. if (branch.condition) {
  29749. currentIf = currentIf.alternate = createIfStatement(
  29750. branch.condition,
  29751. branchBlockStatement
  29752. );
  29753. } else {
  29754. currentIf.alternate = branchBlockStatement;
  29755. }
  29756. }
  29757. if (!currentIf.alternate && !disableCommentAsIfAlternate) {
  29758. currentIf.alternate = createBlockStatement([
  29759. createCallExpression(`_push`, ["`<!---->`"])
  29760. ]);
  29761. }
  29762. }
  29763. function processIfBranch(branch, context, disableNestedFragments = false) {
  29764. const { children } = branch;
  29765. const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && // optimize away nested fragments when the only child is a ForNode
  29766. !(children.length === 1 && children[0].type === 11);
  29767. return processChildrenAsStatement(branch, context, needFragmentWrapper);
  29768. }
  29769. const ssrTransformFor = createStructuralDirectiveTransform(
  29770. "for",
  29771. processFor
  29772. );
  29773. function ssrProcessFor(node, context, disableNestedFragments = false) {
  29774. const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
  29775. const renderLoop = createFunctionExpression(
  29776. createForLoopParams(node.parseResult)
  29777. );
  29778. renderLoop.body = processChildrenAsStatement(
  29779. node,
  29780. context,
  29781. needFragmentWrapper
  29782. );
  29783. if (!disableNestedFragments) {
  29784. context.pushStringPart(`<!--[-->`);
  29785. }
  29786. context.pushStatement(
  29787. createCallExpression(context.helper(SSR_RENDER_LIST), [
  29788. node.source,
  29789. renderLoop
  29790. ])
  29791. );
  29792. if (!disableNestedFragments) {
  29793. context.pushStringPart(`<!--]-->`);
  29794. }
  29795. }
  29796. const ssrTransformSlotOutlet = (node, context) => {
  29797. if (isSlotOutlet(node)) {
  29798. const { slotName, slotProps } = processSlotOutlet(node, context);
  29799. const args = [
  29800. `_ctx.$slots`,
  29801. slotName,
  29802. slotProps || `{}`,
  29803. // fallback content placeholder. will be replaced in the process phase
  29804. `null`,
  29805. `_push`,
  29806. `_parent`
  29807. ];
  29808. if (context.scopeId && context.slotted !== false) {
  29809. args.push(`"${context.scopeId}-s"`);
  29810. }
  29811. let method = SSR_RENDER_SLOT;
  29812. let parent = context.parent;
  29813. if (parent) {
  29814. const children = parent.children;
  29815. if (parent.type === 10) {
  29816. parent = context.grandParent;
  29817. }
  29818. let componentType;
  29819. if (parent.type === 1 && parent.tagType === 1 && ((componentType = resolveComponentType(parent, context, true)) === TRANSITION || componentType === TRANSITION_GROUP) && children.filter((c) => c.type === 1).length === 1) {
  29820. method = SSR_RENDER_SLOT_INNER;
  29821. if (!(context.scopeId && context.slotted !== false)) {
  29822. args.push("null");
  29823. }
  29824. args.push("true");
  29825. }
  29826. }
  29827. node.ssrCodegenNode = createCallExpression(context.helper(method), args);
  29828. }
  29829. };
  29830. function ssrProcessSlotOutlet(node, context) {
  29831. const renderCall = node.ssrCodegenNode;
  29832. if (node.children.length) {
  29833. const fallbackRenderFn = createFunctionExpression([]);
  29834. fallbackRenderFn.body = processChildrenAsStatement(node, context);
  29835. renderCall.arguments[3] = fallbackRenderFn;
  29836. }
  29837. if (context.withSlotScopeId) {
  29838. const slotScopeId = renderCall.arguments[6];
  29839. renderCall.arguments[6] = slotScopeId ? `${slotScopeId} + _scopeId` : `_scopeId`;
  29840. }
  29841. context.pushStatement(node.ssrCodegenNode);
  29842. }
  29843. function createSSRCompilerError(code, loc) {
  29844. return createCompilerError(code, loc, SSRErrorMessages);
  29845. }
  29846. const SSRErrorMessages = {
  29847. [65]: `Unsafe attribute name for SSR.`,
  29848. [66]: `Missing the 'to' prop on teleport element.`,
  29849. [67]: `Invalid AST node during SSR transform.`
  29850. };
  29851. function ssrProcessTeleport(node, context) {
  29852. const targetProp = findProp(node, "to");
  29853. if (!targetProp) {
  29854. context.onError(
  29855. createSSRCompilerError(66, node.loc)
  29856. );
  29857. return;
  29858. }
  29859. let target;
  29860. if (targetProp.type === 6) {
  29861. target = targetProp.value && createSimpleExpression(targetProp.value.content, true);
  29862. } else {
  29863. target = targetProp.exp;
  29864. }
  29865. if (!target) {
  29866. context.onError(
  29867. createSSRCompilerError(
  29868. 66,
  29869. targetProp.loc
  29870. )
  29871. );
  29872. return;
  29873. }
  29874. const disabledProp = findProp(
  29875. node,
  29876. "disabled",
  29877. false,
  29878. true
  29879. /* allow empty */
  29880. );
  29881. const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
  29882. const contentRenderFn = createFunctionExpression(
  29883. [`_push`],
  29884. void 0,
  29885. // Body is added later
  29886. true,
  29887. // newline
  29888. false,
  29889. // isSlot
  29890. node.loc
  29891. );
  29892. contentRenderFn.body = processChildrenAsStatement(node, context);
  29893. context.pushStatement(
  29894. createCallExpression(context.helper(SSR_RENDER_TELEPORT), [
  29895. `_push`,
  29896. contentRenderFn,
  29897. target,
  29898. disabled,
  29899. `_parent`
  29900. ])
  29901. );
  29902. }
  29903. const wipMap$3 = /* @__PURE__ */ new WeakMap();
  29904. function ssrTransformSuspense(node, context) {
  29905. return () => {
  29906. if (node.children.length) {
  29907. const wipEntry = {
  29908. slotsExp: null,
  29909. // to be immediately set
  29910. wipSlots: []
  29911. };
  29912. wipMap$3.set(node, wipEntry);
  29913. wipEntry.slotsExp = buildSlots(
  29914. node,
  29915. context,
  29916. (_props, _vForExp, children, loc) => {
  29917. const fn = createFunctionExpression(
  29918. [],
  29919. void 0,
  29920. // no return, assign body later
  29921. true,
  29922. // newline
  29923. false,
  29924. // suspense slots are not treated as normal slots
  29925. loc
  29926. );
  29927. wipEntry.wipSlots.push({
  29928. fn,
  29929. children
  29930. });
  29931. return fn;
  29932. }
  29933. ).slots;
  29934. }
  29935. };
  29936. }
  29937. function ssrProcessSuspense(node, context) {
  29938. const wipEntry = wipMap$3.get(node);
  29939. if (!wipEntry) {
  29940. return;
  29941. }
  29942. const { slotsExp, wipSlots } = wipEntry;
  29943. for (let i = 0; i < wipSlots.length; i++) {
  29944. const slot = wipSlots[i];
  29945. slot.fn.body = processChildrenAsStatement(slot, context);
  29946. }
  29947. context.pushStatement(
  29948. createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
  29949. `_push`,
  29950. slotsExp
  29951. ])
  29952. );
  29953. }
  29954. const rawChildrenMap = /* @__PURE__ */ new WeakMap();
  29955. const ssrTransformElement = (node, context) => {
  29956. if (node.type !== 1 || node.tagType !== 0) {
  29957. return;
  29958. }
  29959. return function ssrPostTransformElement() {
  29960. const openTag = [`<${node.tag}`];
  29961. const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
  29962. const hasDynamicVBind = hasDynamicKeyVBind(node);
  29963. const hasCustomDir = node.props.some(
  29964. (p) => p.type === 7 && !isBuiltInDirective(p.name)
  29965. );
  29966. const needMergeProps = hasDynamicVBind || hasCustomDir;
  29967. if (needMergeProps) {
  29968. const { props, directives } = buildProps(
  29969. node,
  29970. context,
  29971. node.props,
  29972. false,
  29973. false,
  29974. true
  29975. );
  29976. if (props || directives.length) {
  29977. const mergedProps = buildSSRProps(props, directives, context);
  29978. const propsExp = createCallExpression(
  29979. context.helper(SSR_RENDER_ATTRS),
  29980. [mergedProps]
  29981. );
  29982. if (node.tag === "textarea") {
  29983. const existingText = node.children[0];
  29984. if (!existingText || existingText.type !== 5) {
  29985. const tempId = `_temp${context.temps++}`;
  29986. propsExp.arguments = [
  29987. createAssignmentExpression(
  29988. createSimpleExpression(tempId, false),
  29989. mergedProps
  29990. )
  29991. ];
  29992. rawChildrenMap.set(
  29993. node,
  29994. createCallExpression(context.helper(SSR_INTERPOLATE), [
  29995. createConditionalExpression(
  29996. createSimpleExpression(`"value" in ${tempId}`, false),
  29997. createSimpleExpression(`${tempId}.value`, false),
  29998. createSimpleExpression(
  29999. existingText ? existingText.content : ``,
  30000. true
  30001. ),
  30002. false
  30003. )
  30004. ])
  30005. );
  30006. }
  30007. } else if (node.tag === "input") {
  30008. const vModel = findVModel(node);
  30009. if (vModel) {
  30010. const tempId = `_temp${context.temps++}`;
  30011. const tempExp = createSimpleExpression(tempId, false);
  30012. propsExp.arguments = [
  30013. createSequenceExpression([
  30014. createAssignmentExpression(tempExp, mergedProps),
  30015. createCallExpression(context.helper(MERGE_PROPS), [
  30016. tempExp,
  30017. createCallExpression(
  30018. context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
  30019. [
  30020. tempExp,
  30021. // existing props
  30022. vModel.exp
  30023. // model
  30024. ]
  30025. )
  30026. ])
  30027. ])
  30028. ];
  30029. }
  30030. } else if (directives.length && !node.children.length) {
  30031. const tempId = `_temp${context.temps++}`;
  30032. propsExp.arguments = [
  30033. createAssignmentExpression(
  30034. createSimpleExpression(tempId, false),
  30035. mergedProps
  30036. )
  30037. ];
  30038. rawChildrenMap.set(
  30039. node,
  30040. createConditionalExpression(
  30041. createSimpleExpression(`"textContent" in ${tempId}`, false),
  30042. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30043. createSimpleExpression(`${tempId}.textContent`, false)
  30044. ]),
  30045. createSimpleExpression(`${tempId}.innerHTML ?? ''`, false),
  30046. false
  30047. )
  30048. );
  30049. }
  30050. if (needTagForRuntime) {
  30051. propsExp.arguments.push(`"${node.tag}"`);
  30052. }
  30053. openTag.push(propsExp);
  30054. }
  30055. }
  30056. let dynamicClassBinding = void 0;
  30057. let staticClassBinding = void 0;
  30058. let dynamicStyleBinding = void 0;
  30059. for (let i = 0; i < node.props.length; i++) {
  30060. const prop = node.props[i];
  30061. if (node.tag === "input" && isTrueFalseValue(prop)) {
  30062. continue;
  30063. }
  30064. if (prop.type === 7) {
  30065. if (prop.name === "html" && prop.exp) {
  30066. rawChildrenMap.set(
  30067. node,
  30068. createCompoundExpression([`(`, prop.exp, `) ?? ''`])
  30069. );
  30070. } else if (prop.name === "text" && prop.exp) {
  30071. node.children = [createInterpolation(prop.exp, prop.loc)];
  30072. } else if (prop.name === "slot") {
  30073. context.onError(
  30074. createCompilerError(40, prop.loc)
  30075. );
  30076. } else if (isTextareaWithValue(node, prop) && prop.exp) {
  30077. if (!needMergeProps) {
  30078. node.children = [createInterpolation(prop.exp, prop.loc)];
  30079. }
  30080. } else if (!needMergeProps && prop.name !== "on") {
  30081. const directiveTransform = context.directiveTransforms[prop.name];
  30082. if (directiveTransform) {
  30083. const { props, ssrTagParts } = directiveTransform(
  30084. prop,
  30085. node,
  30086. context
  30087. );
  30088. if (ssrTagParts) {
  30089. openTag.push(...ssrTagParts);
  30090. }
  30091. for (let j = 0; j < props.length; j++) {
  30092. const { key, value } = props[j];
  30093. if (isStaticExp(key)) {
  30094. let attrName = key.content;
  30095. if (attrName === "key" || attrName === "ref") {
  30096. continue;
  30097. }
  30098. if (attrName === "class") {
  30099. openTag.push(
  30100. ` class="`,
  30101. dynamicClassBinding = createCallExpression(
  30102. context.helper(SSR_RENDER_CLASS),
  30103. [value]
  30104. ),
  30105. `"`
  30106. );
  30107. } else if (attrName === "style") {
  30108. if (dynamicStyleBinding) {
  30109. mergeCall(dynamicStyleBinding, value);
  30110. } else {
  30111. openTag.push(
  30112. ` style="`,
  30113. dynamicStyleBinding = createCallExpression(
  30114. context.helper(SSR_RENDER_STYLE),
  30115. [value]
  30116. ),
  30117. `"`
  30118. );
  30119. }
  30120. } else {
  30121. attrName = node.tag.indexOf("-") > 0 ? attrName : propsToAttrMap[attrName] || attrName.toLowerCase();
  30122. if (isBooleanAttr(attrName)) {
  30123. openTag.push(
  30124. createConditionalExpression(
  30125. createCallExpression(
  30126. context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
  30127. [value]
  30128. ),
  30129. createSimpleExpression(" " + attrName, true),
  30130. createSimpleExpression("", true),
  30131. false
  30132. )
  30133. );
  30134. } else if (isSSRSafeAttrName(attrName)) {
  30135. openTag.push(
  30136. createCallExpression(context.helper(SSR_RENDER_ATTR), [
  30137. key,
  30138. value
  30139. ])
  30140. );
  30141. } else {
  30142. context.onError(
  30143. createSSRCompilerError(
  30144. 65,
  30145. key.loc
  30146. )
  30147. );
  30148. }
  30149. }
  30150. } else {
  30151. const args = [key, value];
  30152. if (needTagForRuntime) {
  30153. args.push(`"${node.tag}"`);
  30154. }
  30155. openTag.push(
  30156. createCallExpression(
  30157. context.helper(SSR_RENDER_DYNAMIC_ATTR),
  30158. args
  30159. )
  30160. );
  30161. }
  30162. }
  30163. }
  30164. }
  30165. } else {
  30166. const name = prop.name;
  30167. if (node.tag === "textarea" && name === "value" && prop.value) {
  30168. rawChildrenMap.set(node, escapeHtml(prop.value.content));
  30169. } else if (!needMergeProps) {
  30170. if (name === "key" || name === "ref") {
  30171. continue;
  30172. }
  30173. if (name === "class" && prop.value) {
  30174. staticClassBinding = JSON.stringify(prop.value.content);
  30175. }
  30176. openTag.push(
  30177. ` ${prop.name}` + (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
  30178. );
  30179. }
  30180. }
  30181. }
  30182. if (dynamicClassBinding && staticClassBinding) {
  30183. mergeCall(dynamicClassBinding, staticClassBinding);
  30184. removeStaticBinding(openTag, "class");
  30185. }
  30186. if (context.scopeId) {
  30187. openTag.push(` ${context.scopeId}`);
  30188. }
  30189. node.ssrCodegenNode = createTemplateLiteral(openTag);
  30190. };
  30191. };
  30192. function buildSSRProps(props, directives, context) {
  30193. let mergePropsArgs = [];
  30194. if (props) {
  30195. if (props.type === 14) {
  30196. mergePropsArgs = props.arguments;
  30197. } else {
  30198. mergePropsArgs.push(props);
  30199. }
  30200. }
  30201. if (directives.length) {
  30202. for (const dir of directives) {
  30203. mergePropsArgs.push(
  30204. createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
  30205. `_ctx`,
  30206. ...buildDirectiveArgs(dir, context).elements
  30207. ])
  30208. );
  30209. }
  30210. }
  30211. return mergePropsArgs.length > 1 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
  30212. }
  30213. function isTrueFalseValue(prop) {
  30214. if (prop.type === 7) {
  30215. return prop.name === "bind" && prop.arg && isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
  30216. } else {
  30217. return prop.name === "true-value" || prop.name === "false-value";
  30218. }
  30219. }
  30220. function isTextareaWithValue(node, prop) {
  30221. return !!(node.tag === "textarea" && prop.name === "bind" && isStaticArgOf(prop.arg, "value"));
  30222. }
  30223. function mergeCall(call, arg) {
  30224. const existing = call.arguments[0];
  30225. if (existing.type === 17) {
  30226. existing.elements.push(arg);
  30227. } else {
  30228. call.arguments[0] = createArrayExpression([existing, arg]);
  30229. }
  30230. }
  30231. function removeStaticBinding(tag, binding) {
  30232. const regExp = new RegExp(`^ ${binding}=".+"$`);
  30233. const i = tag.findIndex((e) => typeof e === "string" && regExp.test(e));
  30234. if (i > -1) {
  30235. tag.splice(i, 1);
  30236. }
  30237. }
  30238. function findVModel(node) {
  30239. return node.props.find(
  30240. (p) => p.type === 7 && p.name === "model" && p.exp
  30241. );
  30242. }
  30243. function ssrProcessElement(node, context) {
  30244. const isVoidTag = context.options.isVoidTag || NO;
  30245. const elementsToAdd = node.ssrCodegenNode.elements;
  30246. for (let j = 0; j < elementsToAdd.length; j++) {
  30247. context.pushStringPart(elementsToAdd[j]);
  30248. }
  30249. if (context.withSlotScopeId) {
  30250. context.pushStringPart(createSimpleExpression(`_scopeId`, false));
  30251. }
  30252. context.pushStringPart(`>`);
  30253. const rawChildren = rawChildrenMap.get(node);
  30254. if (rawChildren) {
  30255. context.pushStringPart(rawChildren);
  30256. } else if (node.children.length) {
  30257. processChildren(node, context);
  30258. }
  30259. if (!isVoidTag(node.tag)) {
  30260. context.pushStringPart(`</${node.tag}>`);
  30261. }
  30262. }
  30263. const wipMap$2 = /* @__PURE__ */ new WeakMap();
  30264. function ssrTransformTransitionGroup(node, context) {
  30265. return () => {
  30266. const tag = findProp(node, "tag");
  30267. if (tag) {
  30268. const otherProps = node.props.filter((p) => p !== tag);
  30269. const { props, directives } = buildProps(
  30270. node,
  30271. context,
  30272. otherProps,
  30273. true,
  30274. false,
  30275. true
  30276. );
  30277. let propsExp = null;
  30278. if (props || directives.length) {
  30279. propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
  30280. buildSSRProps(props, directives, context)
  30281. ]);
  30282. }
  30283. wipMap$2.set(node, {
  30284. tag,
  30285. propsExp,
  30286. scopeId: context.scopeId || null
  30287. });
  30288. }
  30289. };
  30290. }
  30291. function ssrProcessTransitionGroup(node, context) {
  30292. const entry = wipMap$2.get(node);
  30293. if (entry) {
  30294. const { tag, propsExp, scopeId } = entry;
  30295. if (tag.type === 7) {
  30296. context.pushStringPart(`<`);
  30297. context.pushStringPart(tag.exp);
  30298. if (propsExp) {
  30299. context.pushStringPart(propsExp);
  30300. }
  30301. if (scopeId) {
  30302. context.pushStringPart(` ${scopeId}`);
  30303. }
  30304. context.pushStringPart(`>`);
  30305. processChildren(
  30306. node,
  30307. context,
  30308. false,
  30309. /**
  30310. * TransitionGroup has the special runtime behavior of flattening and
  30311. * concatenating all children into a single fragment (in order for them to
  30312. * be patched using the same key map) so we need to account for that here
  30313. * by disabling nested fragment wrappers from being generated.
  30314. */
  30315. true,
  30316. /**
  30317. * TransitionGroup filters out comment children at runtime and thus
  30318. * doesn't expect comments to be present during hydration. We need to
  30319. * account for that by disabling the empty comment that is otherwise
  30320. * rendered for a falsy v-if that has no v-else specified. (#6715)
  30321. */
  30322. true
  30323. );
  30324. context.pushStringPart(`</`);
  30325. context.pushStringPart(tag.exp);
  30326. context.pushStringPart(`>`);
  30327. } else {
  30328. context.pushStringPart(`<${tag.value.content}`);
  30329. if (propsExp) {
  30330. context.pushStringPart(propsExp);
  30331. }
  30332. if (scopeId) {
  30333. context.pushStringPart(` ${scopeId}`);
  30334. }
  30335. context.pushStringPart(`>`);
  30336. processChildren(node, context, false, true, true);
  30337. context.pushStringPart(`</${tag.value.content}>`);
  30338. }
  30339. } else {
  30340. processChildren(node, context, true, true, true);
  30341. }
  30342. }
  30343. const wipMap$1 = /* @__PURE__ */ new WeakMap();
  30344. function ssrTransformTransition(node, context) {
  30345. return () => {
  30346. const appear = findProp(node, "appear", false, true);
  30347. wipMap$1.set(node, !!appear);
  30348. };
  30349. }
  30350. function ssrProcessTransition(node, context) {
  30351. node.children = node.children.filter((c) => c.type !== 3);
  30352. const appear = wipMap$1.get(node);
  30353. if (appear) {
  30354. context.pushStringPart(`<template>`);
  30355. processChildren(node, context, false, true);
  30356. context.pushStringPart(`</template>`);
  30357. } else {
  30358. processChildren(node, context, false, true);
  30359. }
  30360. }
  30361. var __defProp$8 = Object.defineProperty;
  30362. var __defProps$7 = Object.defineProperties;
  30363. var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
  30364. var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
  30365. var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
  30366. var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
  30367. var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30368. var __spreadValues$8 = (a, b) => {
  30369. for (var prop in b || (b = {}))
  30370. if (__hasOwnProp$8.call(b, prop))
  30371. __defNormalProp$8(a, prop, b[prop]);
  30372. if (__getOwnPropSymbols$8)
  30373. for (var prop of __getOwnPropSymbols$8(b)) {
  30374. if (__propIsEnum$8.call(b, prop))
  30375. __defNormalProp$8(a, prop, b[prop]);
  30376. }
  30377. return a;
  30378. };
  30379. var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
  30380. const wipMap = /* @__PURE__ */ new WeakMap();
  30381. const WIP_SLOT = Symbol();
  30382. const componentTypeMap = /* @__PURE__ */ new WeakMap();
  30383. const ssrTransformComponent = (node, context) => {
  30384. if (node.type !== 1 || node.tagType !== 1) {
  30385. return;
  30386. }
  30387. const component = resolveComponentType(
  30388. node,
  30389. context,
  30390. true
  30391. /* ssr */
  30392. );
  30393. const isDynamicComponent = isObject$2(component) && component.callee === RESOLVE_DYNAMIC_COMPONENT;
  30394. componentTypeMap.set(node, component);
  30395. if (isSymbol$1(component)) {
  30396. if (component === SUSPENSE) {
  30397. return ssrTransformSuspense(node, context);
  30398. } else if (component === TRANSITION_GROUP) {
  30399. return ssrTransformTransitionGroup(node, context);
  30400. } else if (component === TRANSITION) {
  30401. return ssrTransformTransition(node);
  30402. }
  30403. return;
  30404. }
  30405. const vnodeBranches = [];
  30406. const clonedNode = clone(node);
  30407. return function ssrPostTransformComponent() {
  30408. if (clonedNode.children.length) {
  30409. buildSlots(clonedNode, context, (props, vFor, children) => {
  30410. vnodeBranches.push(
  30411. createVNodeSlotBranch(props, vFor, children, context)
  30412. );
  30413. return createFunctionExpression(void 0);
  30414. });
  30415. }
  30416. let propsExp = `null`;
  30417. if (node.props.length) {
  30418. const { props, directives } = buildProps(
  30419. node,
  30420. context,
  30421. void 0,
  30422. true,
  30423. isDynamicComponent
  30424. );
  30425. if (props || directives.length) {
  30426. propsExp = buildSSRProps(props, directives, context);
  30427. }
  30428. }
  30429. const wipEntries = [];
  30430. wipMap.set(node, wipEntries);
  30431. const buildSSRSlotFn = (props, _vForExp, children, loc) => {
  30432. const param0 = props && stringifyExpression(props) || `_`;
  30433. const fn = createFunctionExpression(
  30434. [param0, `_push`, `_parent`, `_scopeId`],
  30435. void 0,
  30436. // no return, assign body later
  30437. true,
  30438. // newline
  30439. true,
  30440. // isSlot
  30441. loc
  30442. );
  30443. wipEntries.push({
  30444. type: WIP_SLOT,
  30445. fn,
  30446. children,
  30447. // also collect the corresponding vnode branch built earlier
  30448. vnodeBranch: vnodeBranches[wipEntries.length]
  30449. });
  30450. return fn;
  30451. };
  30452. const slots = node.children.length ? buildSlots(node, context, buildSSRSlotFn).slots : `null`;
  30453. if (typeof component !== "string") {
  30454. node.ssrCodegenNode = createCallExpression(
  30455. context.helper(SSR_RENDER_VNODE),
  30456. [
  30457. `_push`,
  30458. createCallExpression(context.helper(CREATE_VNODE), [
  30459. component,
  30460. propsExp,
  30461. slots
  30462. ]),
  30463. `_parent`
  30464. ]
  30465. );
  30466. } else {
  30467. node.ssrCodegenNode = createCallExpression(
  30468. context.helper(SSR_RENDER_COMPONENT),
  30469. [component, propsExp, slots, `_parent`]
  30470. );
  30471. }
  30472. };
  30473. };
  30474. function ssrProcessComponent(node, context, parent) {
  30475. const component = componentTypeMap.get(node);
  30476. if (!node.ssrCodegenNode) {
  30477. if (component === TELEPORT) {
  30478. return ssrProcessTeleport(node, context);
  30479. } else if (component === SUSPENSE) {
  30480. return ssrProcessSuspense(node, context);
  30481. } else if (component === TRANSITION_GROUP) {
  30482. return ssrProcessTransitionGroup(node, context);
  30483. } else {
  30484. if (parent.type === WIP_SLOT) {
  30485. context.pushStringPart(``);
  30486. }
  30487. if (component === TRANSITION) {
  30488. return ssrProcessTransition(node, context);
  30489. }
  30490. processChildren(node, context);
  30491. }
  30492. } else {
  30493. const wipEntries = wipMap.get(node) || [];
  30494. for (let i = 0; i < wipEntries.length; i++) {
  30495. const { fn, vnodeBranch } = wipEntries[i];
  30496. fn.body = createIfStatement(
  30497. createSimpleExpression(`_push`, false),
  30498. processChildrenAsStatement(
  30499. wipEntries[i],
  30500. context,
  30501. false,
  30502. true
  30503. ),
  30504. vnodeBranch
  30505. );
  30506. }
  30507. if (context.withSlotScopeId) {
  30508. node.ssrCodegenNode.arguments.push(`_scopeId`);
  30509. }
  30510. if (typeof component === "string") {
  30511. context.pushStatement(
  30512. createCallExpression(`_push`, [node.ssrCodegenNode])
  30513. );
  30514. } else {
  30515. context.pushStatement(node.ssrCodegenNode);
  30516. }
  30517. }
  30518. }
  30519. const rawOptionsMap = /* @__PURE__ */ new WeakMap();
  30520. const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(true);
  30521. const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms];
  30522. const vnodeDirectiveTransforms = __spreadValues$8(__spreadValues$8({}, baseDirectiveTransforms), DOMDirectiveTransforms);
  30523. function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
  30524. const rawOptions = rawOptionsMap.get(parentContext.root);
  30525. const subOptions = __spreadProps$7(__spreadValues$8({}, rawOptions), {
  30526. // overwrite with vnode-based transforms
  30527. nodeTransforms: [
  30528. ...vnodeNodeTransforms,
  30529. ...rawOptions.nodeTransforms || []
  30530. ],
  30531. directiveTransforms: __spreadValues$8(__spreadValues$8({}, vnodeDirectiveTransforms), rawOptions.directiveTransforms || {})
  30532. });
  30533. const wrapperProps = [];
  30534. if (slotProps) {
  30535. wrapperProps.push({
  30536. type: 7,
  30537. name: "slot",
  30538. exp: slotProps,
  30539. arg: void 0,
  30540. modifiers: [],
  30541. loc: locStub
  30542. });
  30543. }
  30544. if (vFor) {
  30545. wrapperProps.push(extend({}, vFor));
  30546. }
  30547. const wrapperNode = {
  30548. type: 1,
  30549. ns: 0,
  30550. tag: "template",
  30551. tagType: 3,
  30552. props: wrapperProps,
  30553. children,
  30554. loc: locStub,
  30555. codegenNode: void 0
  30556. };
  30557. subTransform(wrapperNode, subOptions, parentContext);
  30558. return createReturnStatement(children);
  30559. }
  30560. function subTransform(node, options, parentContext) {
  30561. const childRoot = createRoot([node]);
  30562. const childContext = createTransformContext(childRoot, options);
  30563. childContext.ssr = false;
  30564. childContext.scopes = __spreadValues$8({}, parentContext.scopes);
  30565. childContext.identifiers = __spreadValues$8({}, parentContext.identifiers);
  30566. childContext.imports = parentContext.imports;
  30567. traverseNode(childRoot, childContext);
  30568. ["helpers", "components", "directives"].forEach((key) => {
  30569. childContext[key].forEach((value, helperKey) => {
  30570. if (key === "helpers") {
  30571. const parentCount = parentContext.helpers.get(helperKey);
  30572. if (parentCount === void 0) {
  30573. parentContext.helpers.set(helperKey, value);
  30574. } else {
  30575. parentContext.helpers.set(helperKey, value + parentCount);
  30576. }
  30577. } else {
  30578. parentContext[key].add(value);
  30579. }
  30580. });
  30581. });
  30582. }
  30583. function clone(v) {
  30584. if (isArray$3(v)) {
  30585. return v.map(clone);
  30586. } else if (isPlainObject(v)) {
  30587. const res = {};
  30588. for (const key in v) {
  30589. res[key] = clone(v[key]);
  30590. }
  30591. return res;
  30592. } else {
  30593. return v;
  30594. }
  30595. }
  30596. function ssrCodegenTransform(ast, options) {
  30597. const context = createSSRTransformContext(ast, options);
  30598. if (options.ssrCssVars) {
  30599. const cssContext = createTransformContext(createRoot([]), options);
  30600. const varsExp = processExpression(
  30601. createSimpleExpression(options.ssrCssVars, false),
  30602. cssContext
  30603. );
  30604. context.body.push(
  30605. createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
  30606. );
  30607. Array.from(cssContext.helpers.keys()).forEach((helper) => {
  30608. ast.helpers.add(helper);
  30609. });
  30610. }
  30611. const isFragment = ast.children.length > 1 && ast.children.some((c) => !isText$1(c));
  30612. processChildren(ast, context, isFragment);
  30613. ast.codegenNode = createBlockStatement(context.body);
  30614. ast.ssrHelpers = Array.from(
  30615. /* @__PURE__ */ new Set([
  30616. ...Array.from(ast.helpers).filter((h) => h in ssrHelpers),
  30617. ...context.helpers
  30618. ])
  30619. );
  30620. ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
  30621. }
  30622. function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new Set(), withSlotScopeId = false) {
  30623. const body = [];
  30624. let currentString = null;
  30625. return {
  30626. root,
  30627. options,
  30628. body,
  30629. helpers,
  30630. withSlotScopeId,
  30631. onError: options.onError || ((e) => {
  30632. throw e;
  30633. }),
  30634. helper(name) {
  30635. helpers.add(name);
  30636. return name;
  30637. },
  30638. pushStringPart(part) {
  30639. if (!currentString) {
  30640. const currentCall = createCallExpression(`_push`);
  30641. body.push(currentCall);
  30642. currentString = createTemplateLiteral([]);
  30643. currentCall.arguments.push(currentString);
  30644. }
  30645. const bufferedElements = currentString.elements;
  30646. const lastItem = bufferedElements[bufferedElements.length - 1];
  30647. if (isString$2(part) && isString$2(lastItem)) {
  30648. bufferedElements[bufferedElements.length - 1] += part;
  30649. } else {
  30650. bufferedElements.push(part);
  30651. }
  30652. },
  30653. pushStatement(statement) {
  30654. currentString = null;
  30655. body.push(statement);
  30656. }
  30657. };
  30658. }
  30659. function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
  30660. return createSSRTransformContext(
  30661. parent.root,
  30662. parent.options,
  30663. parent.helpers,
  30664. withSlotScopeId
  30665. );
  30666. }
  30667. function processChildren(parent, context, asFragment = false, disableNestedFragments = false, disableCommentAsIfAlternate = false) {
  30668. if (asFragment) {
  30669. context.pushStringPart(`<!--[-->`);
  30670. }
  30671. const { children } = parent;
  30672. for (let i = 0; i < children.length; i++) {
  30673. const child = children[i];
  30674. switch (child.type) {
  30675. case 1:
  30676. switch (child.tagType) {
  30677. case 0:
  30678. ssrProcessElement(child, context);
  30679. break;
  30680. case 1:
  30681. ssrProcessComponent(child, context, parent);
  30682. break;
  30683. case 2:
  30684. ssrProcessSlotOutlet(child, context);
  30685. break;
  30686. case 3:
  30687. break;
  30688. default:
  30689. context.onError(
  30690. createSSRCompilerError(
  30691. 67,
  30692. child.loc
  30693. )
  30694. );
  30695. const exhaustiveCheck2 = child;
  30696. return exhaustiveCheck2;
  30697. }
  30698. break;
  30699. case 2:
  30700. context.pushStringPart(escapeHtml(child.content));
  30701. break;
  30702. case 3:
  30703. context.pushStringPart(`<!--${child.content}-->`);
  30704. break;
  30705. case 5:
  30706. context.pushStringPart(
  30707. createCallExpression(context.helper(SSR_INTERPOLATE), [
  30708. child.content
  30709. ])
  30710. );
  30711. break;
  30712. case 9:
  30713. ssrProcessIf(
  30714. child,
  30715. context,
  30716. disableNestedFragments,
  30717. disableCommentAsIfAlternate
  30718. );
  30719. break;
  30720. case 11:
  30721. ssrProcessFor(child, context, disableNestedFragments);
  30722. break;
  30723. case 10:
  30724. break;
  30725. case 12:
  30726. case 8:
  30727. break;
  30728. default:
  30729. context.onError(
  30730. createSSRCompilerError(
  30731. 67,
  30732. child.loc
  30733. )
  30734. );
  30735. const exhaustiveCheck = child;
  30736. return exhaustiveCheck;
  30737. }
  30738. }
  30739. if (asFragment) {
  30740. context.pushStringPart(`<!--]-->`);
  30741. }
  30742. }
  30743. function processChildrenAsStatement(parent, parentContext, asFragment = false, withSlotScopeId = parentContext.withSlotScopeId) {
  30744. const childContext = createChildContext(parentContext, withSlotScopeId);
  30745. processChildren(parent, childContext, asFragment);
  30746. return createBlockStatement(childContext.body);
  30747. }
  30748. const ssrTransformModel = (dir, node, context) => {
  30749. const model = dir.exp;
  30750. function checkDuplicatedValue() {
  30751. const value = findProp(node, "value");
  30752. if (value) {
  30753. context.onError(
  30754. createDOMCompilerError(
  30755. 60,
  30756. value.loc
  30757. )
  30758. );
  30759. }
  30760. }
  30761. function processOption(plainNode) {
  30762. if (plainNode.tag === "option") {
  30763. if (plainNode.props.findIndex((p) => p.name === "selected") === -1) {
  30764. const value = findValueBinding(plainNode);
  30765. plainNode.ssrCodegenNode.elements.push(
  30766. createConditionalExpression(
  30767. createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [
  30768. createConditionalExpression(
  30769. createCallExpression(`Array.isArray`, [model]),
  30770. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  30771. model,
  30772. value
  30773. ]),
  30774. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30775. model,
  30776. value
  30777. ])
  30778. )
  30779. ]),
  30780. createSimpleExpression(" selected", true),
  30781. createSimpleExpression("", true),
  30782. false
  30783. )
  30784. );
  30785. }
  30786. } else if (plainNode.tag === "optgroup") {
  30787. plainNode.children.forEach(
  30788. (option) => processOption(option)
  30789. );
  30790. }
  30791. }
  30792. if (node.tagType === 0) {
  30793. const res = { props: [] };
  30794. const defaultProps = [
  30795. // default value binding for text type inputs
  30796. createObjectProperty(`value`, model)
  30797. ];
  30798. if (node.tag === "input") {
  30799. const type = findProp(node, "type");
  30800. if (type) {
  30801. const value = findValueBinding(node);
  30802. if (type.type === 7) {
  30803. res.ssrTagParts = [
  30804. createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
  30805. type.exp,
  30806. model,
  30807. value
  30808. ])
  30809. ];
  30810. } else if (type.value) {
  30811. switch (type.value.content) {
  30812. case "radio":
  30813. res.props = [
  30814. createObjectProperty(
  30815. `checked`,
  30816. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30817. model,
  30818. value
  30819. ])
  30820. )
  30821. ];
  30822. break;
  30823. case "checkbox":
  30824. const trueValueBinding = findProp(node, "true-value");
  30825. if (trueValueBinding) {
  30826. const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
  30827. res.props = [
  30828. createObjectProperty(
  30829. `checked`,
  30830. createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
  30831. model,
  30832. trueValue
  30833. ])
  30834. )
  30835. ];
  30836. } else {
  30837. res.props = [
  30838. createObjectProperty(
  30839. `checked`,
  30840. createConditionalExpression(
  30841. createCallExpression(`Array.isArray`, [model]),
  30842. createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
  30843. model,
  30844. value
  30845. ]),
  30846. model
  30847. )
  30848. )
  30849. ];
  30850. }
  30851. break;
  30852. case "file":
  30853. context.onError(
  30854. createDOMCompilerError(
  30855. 59,
  30856. dir.loc
  30857. )
  30858. );
  30859. break;
  30860. default:
  30861. checkDuplicatedValue();
  30862. res.props = defaultProps;
  30863. break;
  30864. }
  30865. }
  30866. } else if (hasDynamicKeyVBind(node)) ; else {
  30867. checkDuplicatedValue();
  30868. res.props = defaultProps;
  30869. }
  30870. } else if (node.tag === "textarea") {
  30871. checkDuplicatedValue();
  30872. node.children = [createInterpolation(model, model.loc)];
  30873. } else if (node.tag === "select") {
  30874. node.children.forEach((child) => {
  30875. if (child.type === 1) {
  30876. processOption(child);
  30877. }
  30878. });
  30879. } else {
  30880. context.onError(
  30881. createDOMCompilerError(
  30882. 57,
  30883. dir.loc
  30884. )
  30885. );
  30886. }
  30887. return res;
  30888. } else {
  30889. return transformModel$1(dir, node, context);
  30890. }
  30891. };
  30892. function findValueBinding(node) {
  30893. const valueBinding = findProp(node, "value");
  30894. return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : createSimpleExpression(valueBinding.value.content, true) : createSimpleExpression(`null`, false);
  30895. }
  30896. const ssrTransformShow = (dir, node, context) => {
  30897. if (!dir.exp) {
  30898. context.onError(
  30899. createDOMCompilerError(61)
  30900. );
  30901. }
  30902. return {
  30903. props: [
  30904. createObjectProperty(
  30905. `style`,
  30906. createConditionalExpression(
  30907. dir.exp,
  30908. createSimpleExpression(`null`, false),
  30909. createObjectExpression([
  30910. createObjectProperty(
  30911. `display`,
  30912. createSimpleExpression(`none`, true)
  30913. )
  30914. ]),
  30915. false
  30916. )
  30917. )
  30918. ]
  30919. };
  30920. };
  30921. const filterChild = (node) => node.children.filter((n) => n.type !== 3);
  30922. const hasSingleChild = (node) => filterChild(node).length === 1;
  30923. const ssrInjectFallthroughAttrs = (node, context) => {
  30924. if (node.type === 0) {
  30925. context.identifiers._attrs = 1;
  30926. }
  30927. if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
  30928. const rootChildren = filterChild(context.root);
  30929. if (rootChildren.length === 1 && rootChildren[0] === node) {
  30930. if (hasSingleChild(node)) {
  30931. injectFallthroughAttrs(node.children[0]);
  30932. }
  30933. return;
  30934. }
  30935. }
  30936. const parent = context.parent;
  30937. if (!parent || parent.type !== 0) {
  30938. return;
  30939. }
  30940. if (node.type === 10 && hasSingleChild(node)) {
  30941. let hasEncounteredIf = false;
  30942. for (const c of filterChild(parent)) {
  30943. if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
  30944. if (hasEncounteredIf) return;
  30945. hasEncounteredIf = true;
  30946. } else if (
  30947. // node before v-if
  30948. !hasEncounteredIf || // non else nodes
  30949. !(c.type === 1 && findDir(c, /else/, true))
  30950. ) {
  30951. return;
  30952. }
  30953. }
  30954. injectFallthroughAttrs(node.children[0]);
  30955. } else if (hasSingleChild(parent)) {
  30956. injectFallthroughAttrs(node);
  30957. }
  30958. };
  30959. function injectFallthroughAttrs(node) {
  30960. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  30961. node.props.push({
  30962. type: 7,
  30963. name: "bind",
  30964. arg: void 0,
  30965. exp: createSimpleExpression(`_attrs`, false),
  30966. modifiers: [],
  30967. loc: locStub
  30968. });
  30969. }
  30970. }
  30971. const ssrInjectCssVars = (node, context) => {
  30972. if (!context.ssrCssVars) {
  30973. return;
  30974. }
  30975. if (node.type === 0) {
  30976. context.identifiers._cssVars = 1;
  30977. }
  30978. const parent = context.parent;
  30979. if (!parent || parent.type !== 0) {
  30980. return;
  30981. }
  30982. if (node.type === 10) {
  30983. for (const child of node.children) {
  30984. injectCssVars(child);
  30985. }
  30986. } else {
  30987. injectCssVars(node);
  30988. }
  30989. };
  30990. function injectCssVars(node) {
  30991. if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !findDir(node, "for")) {
  30992. if (node.tag === "suspense" || node.tag === "Suspense") {
  30993. for (const child of node.children) {
  30994. if (child.type === 1 && child.tagType === 3) {
  30995. child.children.forEach(injectCssVars);
  30996. } else {
  30997. injectCssVars(child);
  30998. }
  30999. }
  31000. } else {
  31001. node.props.push({
  31002. type: 7,
  31003. name: "bind",
  31004. arg: void 0,
  31005. exp: createSimpleExpression(`_cssVars`, false),
  31006. modifiers: [],
  31007. loc: locStub
  31008. });
  31009. }
  31010. }
  31011. }
  31012. var __defProp$7 = Object.defineProperty;
  31013. var __defProps$6 = Object.defineProperties;
  31014. var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
  31015. var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
  31016. var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
  31017. var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
  31018. var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31019. var __spreadValues$7 = (a, b) => {
  31020. for (var prop in b || (b = {}))
  31021. if (__hasOwnProp$7.call(b, prop))
  31022. __defNormalProp$7(a, prop, b[prop]);
  31023. if (__getOwnPropSymbols$7)
  31024. for (var prop of __getOwnPropSymbols$7(b)) {
  31025. if (__propIsEnum$7.call(b, prop))
  31026. __defNormalProp$7(a, prop, b[prop]);
  31027. }
  31028. return a;
  31029. };
  31030. var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
  31031. function compile(source, options = {}) {
  31032. options = __spreadProps$6(__spreadValues$7(__spreadValues$7({}, options), parserOptions), {
  31033. ssr: true,
  31034. inSSR: true,
  31035. scopeId: options.mode === "function" ? null : options.scopeId,
  31036. // always prefix since compiler-ssr doesn't have size concern
  31037. prefixIdentifiers: true,
  31038. // disable optimizations that are unnecessary for ssr
  31039. cacheHandlers: false,
  31040. hoistStatic: false
  31041. });
  31042. const ast = typeof source === "string" ? baseParse(source, options) : source;
  31043. rawOptionsMap.set(ast, options);
  31044. transform(ast, __spreadProps$6(__spreadValues$7({}, options), {
  31045. hoistStatic: false,
  31046. nodeTransforms: [
  31047. ssrTransformIf,
  31048. ssrTransformFor,
  31049. trackVForSlotScopes,
  31050. transformExpression,
  31051. ssrTransformSlotOutlet,
  31052. ssrInjectFallthroughAttrs,
  31053. ssrInjectCssVars,
  31054. ssrTransformElement,
  31055. ssrTransformComponent,
  31056. trackSlotScopes,
  31057. transformStyle,
  31058. ...options.nodeTransforms || []
  31059. // user transforms
  31060. ],
  31061. directiveTransforms: __spreadValues$7({
  31062. // reusing core v-bind
  31063. bind: transformBind,
  31064. on: transformOn$1,
  31065. // model and show have dedicated SSR handling
  31066. model: ssrTransformModel,
  31067. show: ssrTransformShow,
  31068. // the following are ignored during SSR
  31069. // on: noopDirectiveTransform,
  31070. cloak: noopDirectiveTransform,
  31071. once: noopDirectiveTransform,
  31072. memo: noopDirectiveTransform
  31073. }, options.directiveTransforms || {})
  31074. }));
  31075. ssrCodegenTransform(ast, options);
  31076. return generate(ast, options);
  31077. }
  31078. var CompilerSSR = /*#__PURE__*/Object.freeze({
  31079. __proto__: null,
  31080. compile: compile
  31081. });
  31082. function commonjsRequire(path) {
  31083. 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.');
  31084. }
  31085. var _polyfillNode_fs = {};
  31086. var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
  31087. __proto__: null,
  31088. default: _polyfillNode_fs
  31089. });
  31090. var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
  31091. var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path);
  31092. var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
  31093. const hasWarned = {};
  31094. function warnOnce$3(msg) {
  31095. const isNodeProd = typeof process !== "undefined" && process.env.NODE_ENV === "production";
  31096. if (!isNodeProd && true && !hasWarned[msg]) {
  31097. hasWarned[msg] = true;
  31098. warn(msg);
  31099. }
  31100. }
  31101. function warn(msg) {
  31102. console.warn(
  31103. `\x1B[1m\x1B[33m[@vue/compiler-sfc]\x1B[0m\x1B[33m ${msg}\x1B[0m
  31104. `
  31105. );
  31106. }
  31107. var __defProp$6 = Object.defineProperty;
  31108. var __defProps$5 = Object.defineProperties;
  31109. var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
  31110. var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
  31111. var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
  31112. var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
  31113. var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  31114. var __spreadValues$6 = (a, b) => {
  31115. for (var prop in b || (b = {}))
  31116. if (__hasOwnProp$6.call(b, prop))
  31117. __defNormalProp$6(a, prop, b[prop]);
  31118. if (__getOwnPropSymbols$6)
  31119. for (var prop of __getOwnPropSymbols$6(b)) {
  31120. if (__propIsEnum$6.call(b, prop))
  31121. __defNormalProp$6(a, prop, b[prop]);
  31122. }
  31123. return a;
  31124. };
  31125. var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
  31126. function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
  31127. let res = "";
  31128. let err = null;
  31129. preprocessor.render(
  31130. source,
  31131. __spreadValues$6({ filename }, preprocessOptions),
  31132. (_err, _res) => {
  31133. if (_err) err = _err;
  31134. res = _res;
  31135. }
  31136. );
  31137. if (err) throw err;
  31138. return res;
  31139. }
  31140. function compileTemplate(options) {
  31141. const { preprocessLang, preprocessCustomRequire } = options;
  31142. if (preprocessLang && !preprocessCustomRequire) {
  31143. throw new Error(
  31144. `[@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 }.`
  31145. );
  31146. }
  31147. const preprocessor = preprocessLang ? preprocessCustomRequire ? preprocessCustomRequire(preprocessLang) : void 0 : false;
  31148. if (preprocessor) {
  31149. try {
  31150. return doCompileTemplate(__spreadProps$5(__spreadValues$6({}, options), {
  31151. source: preprocess$1(options, preprocessor),
  31152. ast: void 0
  31153. // invalidate AST if template goes through preprocessor
  31154. }));
  31155. } catch (e) {
  31156. return {
  31157. code: `export default function render() {}`,
  31158. source: options.source,
  31159. tips: [],
  31160. errors: [e]
  31161. };
  31162. }
  31163. } else if (preprocessLang) {
  31164. return {
  31165. code: `export default function render() {}`,
  31166. source: options.source,
  31167. tips: [
  31168. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  31169. ],
  31170. errors: [
  31171. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  31172. ]
  31173. };
  31174. } else {
  31175. return doCompileTemplate(options);
  31176. }
  31177. }
  31178. function doCompileTemplate({
  31179. filename,
  31180. id,
  31181. scoped,
  31182. slotted,
  31183. inMap,
  31184. source,
  31185. ast: inAST,
  31186. ssr = false,
  31187. ssrCssVars,
  31188. isProd = false,
  31189. compiler,
  31190. compilerOptions = {},
  31191. transformAssetUrls
  31192. }) {
  31193. const errors = [];
  31194. const warnings = [];
  31195. let nodeTransforms = [];
  31196. if (isObject$2(transformAssetUrls)) {
  31197. const assetOptions = normalizeOptions(transformAssetUrls);
  31198. nodeTransforms = [
  31199. createAssetUrlTransformWithOptions(assetOptions),
  31200. createSrcsetTransformWithOptions(assetOptions)
  31201. ];
  31202. } else if (transformAssetUrls !== false) {
  31203. nodeTransforms = [transformAssetUrl, transformSrcset];
  31204. }
  31205. if (ssr && !ssrCssVars) {
  31206. warnOnce$3(
  31207. `compileTemplate is called with \`ssr: true\` but no corresponding \`cssVars\` option.`
  31208. );
  31209. }
  31210. if (!id) {
  31211. warnOnce$3(`compileTemplate now requires the \`id\` option.`);
  31212. id = "";
  31213. }
  31214. const shortId = id.replace(/^data-v-/, "");
  31215. const longId = `data-v-${shortId}`;
  31216. const defaultCompiler = ssr ? CompilerSSR : CompilerDOM;
  31217. compiler = compiler || defaultCompiler;
  31218. if (compiler !== defaultCompiler) {
  31219. inAST = void 0;
  31220. }
  31221. if (inAST == null ? void 0 : inAST.transformed) {
  31222. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
  31223. prefixIdentifiers: true
  31224. }, compilerOptions), {
  31225. parseMode: "sfc",
  31226. onError: (e) => errors.push(e)
  31227. }));
  31228. const template = newAST.children.find(
  31229. (node) => node.type === 1 && node.tag === "template"
  31230. );
  31231. inAST = createRoot(template.children, inAST.source);
  31232. }
  31233. let { code, ast, preamble, map } = compiler.compile(inAST || source, __spreadProps$5(__spreadValues$6({
  31234. mode: "module",
  31235. prefixIdentifiers: true,
  31236. hoistStatic: true,
  31237. cacheHandlers: true,
  31238. ssrCssVars: ssr && ssrCssVars && ssrCssVars.length ? genCssVarsFromList(ssrCssVars, shortId, isProd, true) : "",
  31239. scopeId: scoped ? longId : void 0,
  31240. slotted,
  31241. sourceMap: true
  31242. }, compilerOptions), {
  31243. hmr: !isProd,
  31244. nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
  31245. filename,
  31246. onError: (e) => errors.push(e),
  31247. onWarn: (w) => warnings.push(w)
  31248. }));
  31249. if (inMap && !inAST) {
  31250. if (map) {
  31251. map = mapLines(inMap, map);
  31252. }
  31253. if (errors.length) {
  31254. patchErrors(errors, source, inMap);
  31255. }
  31256. }
  31257. const tips = warnings.map((w) => {
  31258. let msg = w.message;
  31259. if (w.loc) {
  31260. msg += `
  31261. ${generateCodeFrame(
  31262. (inAST == null ? void 0 : inAST.source) || source,
  31263. w.loc.start.offset,
  31264. w.loc.end.offset
  31265. )}`;
  31266. }
  31267. return msg;
  31268. });
  31269. return { code, ast, preamble, source, errors, tips, map };
  31270. }
  31271. function mapLines(oldMap, newMap) {
  31272. if (!oldMap) return newMap;
  31273. if (!newMap) return oldMap;
  31274. const oldMapConsumer = new SourceMapConsumer$5(oldMap);
  31275. const newMapConsumer = new SourceMapConsumer$5(newMap);
  31276. const mergedMapGenerator = new SourceMapGenerator$6();
  31277. newMapConsumer.eachMapping((m) => {
  31278. if (m.originalLine == null) {
  31279. return;
  31280. }
  31281. const origPosInOldMap = oldMapConsumer.originalPositionFor({
  31282. line: m.originalLine,
  31283. column: m.originalColumn
  31284. });
  31285. if (origPosInOldMap.source == null) {
  31286. return;
  31287. }
  31288. mergedMapGenerator.addMapping({
  31289. generated: {
  31290. line: m.generatedLine,
  31291. column: m.generatedColumn
  31292. },
  31293. original: {
  31294. line: origPosInOldMap.line,
  31295. // map line
  31296. // use current column, since the oldMap produced by @vue/compiler-sfc
  31297. // does not
  31298. column: m.originalColumn
  31299. },
  31300. source: origPosInOldMap.source,
  31301. name: origPosInOldMap.name
  31302. });
  31303. });
  31304. const generator = mergedMapGenerator;
  31305. oldMapConsumer.sources.forEach((sourceFile) => {
  31306. generator._sources.add(sourceFile);
  31307. const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
  31308. if (sourceContent != null) {
  31309. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  31310. }
  31311. });
  31312. generator._sourceRoot = oldMap.sourceRoot;
  31313. generator._file = oldMap.file;
  31314. return generator.toJSON();
  31315. }
  31316. function patchErrors(errors, source, inMap) {
  31317. const originalSource = inMap.sourcesContent[0];
  31318. const offset = originalSource.indexOf(source);
  31319. const lineOffset = originalSource.slice(0, offset).split(/\r?\n/).length - 1;
  31320. errors.forEach((err) => {
  31321. if (err.loc) {
  31322. err.loc.start.line += lineOffset;
  31323. err.loc.start.offset += offset;
  31324. if (err.loc.end !== err.loc.start) {
  31325. err.loc.end.line += lineOffset;
  31326. err.loc.end.offset += offset;
  31327. }
  31328. }
  31329. });
  31330. }
  31331. var picocolors = {exports: {}};
  31332. // MIT lisence
  31333. // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
  31334. function isatty() {
  31335. return false;
  31336. }
  31337. function ReadStream() {
  31338. throw new Error('tty.ReadStream is not implemented');
  31339. }
  31340. function WriteStream() {
  31341. throw new Error('tty.ReadStream is not implemented');
  31342. }
  31343. var _polyfillNode_tty = {
  31344. isatty: isatty,
  31345. ReadStream: ReadStream,
  31346. WriteStream: WriteStream
  31347. };
  31348. var _polyfillNode_tty$1 = /*#__PURE__*/Object.freeze({
  31349. __proto__: null,
  31350. ReadStream: ReadStream,
  31351. WriteStream: WriteStream,
  31352. default: _polyfillNode_tty,
  31353. isatty: isatty
  31354. });
  31355. var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_tty$1);
  31356. let argv = browser$1.argv || [],
  31357. env = ({});
  31358. let isColorSupported =
  31359. !("NO_COLOR" in env || argv.includes("--no-color")) &&
  31360. ("FORCE_COLOR" in env ||
  31361. argv.includes("--color") ||
  31362. "" === "win32" ||
  31363. (commonjsRequire != null && require$$0.isatty(1) && env.TERM !== "dumb") ||
  31364. "CI" in env);
  31365. let formatter =
  31366. (open, close, replace = open) =>
  31367. input => {
  31368. let string = "" + input;
  31369. let index = string.indexOf(close, open.length);
  31370. return ~index
  31371. ? open + replaceClose(string, close, replace, index) + close
  31372. : open + string + close
  31373. };
  31374. let replaceClose = (string, close, replace, index) => {
  31375. let result = "";
  31376. let cursor = 0;
  31377. do {
  31378. result += string.substring(cursor, index) + replace;
  31379. cursor = index + close.length;
  31380. index = string.indexOf(close, cursor);
  31381. } while (~index)
  31382. return result + string.substring(cursor)
  31383. };
  31384. let createColors = (enabled = isColorSupported) => {
  31385. let init = enabled ? formatter : () => String;
  31386. return {
  31387. isColorSupported: enabled,
  31388. reset: init("\x1b[0m", "\x1b[0m"),
  31389. bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
  31390. dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
  31391. italic: init("\x1b[3m", "\x1b[23m"),
  31392. underline: init("\x1b[4m", "\x1b[24m"),
  31393. inverse: init("\x1b[7m", "\x1b[27m"),
  31394. hidden: init("\x1b[8m", "\x1b[28m"),
  31395. strikethrough: init("\x1b[9m", "\x1b[29m"),
  31396. black: init("\x1b[30m", "\x1b[39m"),
  31397. red: init("\x1b[31m", "\x1b[39m"),
  31398. green: init("\x1b[32m", "\x1b[39m"),
  31399. yellow: init("\x1b[33m", "\x1b[39m"),
  31400. blue: init("\x1b[34m", "\x1b[39m"),
  31401. magenta: init("\x1b[35m", "\x1b[39m"),
  31402. cyan: init("\x1b[36m", "\x1b[39m"),
  31403. white: init("\x1b[37m", "\x1b[39m"),
  31404. gray: init("\x1b[90m", "\x1b[39m"),
  31405. bgBlack: init("\x1b[40m", "\x1b[49m"),
  31406. bgRed: init("\x1b[41m", "\x1b[49m"),
  31407. bgGreen: init("\x1b[42m", "\x1b[49m"),
  31408. bgYellow: init("\x1b[43m", "\x1b[49m"),
  31409. bgBlue: init("\x1b[44m", "\x1b[49m"),
  31410. bgMagenta: init("\x1b[45m", "\x1b[49m"),
  31411. bgCyan: init("\x1b[46m", "\x1b[49m"),
  31412. bgWhite: init("\x1b[47m", "\x1b[49m"),
  31413. }
  31414. };
  31415. picocolors.exports = createColors();
  31416. picocolors.exports.createColors = createColors;
  31417. var picocolorsExports = picocolors.exports;
  31418. const SINGLE_QUOTE = "'".charCodeAt(0);
  31419. const DOUBLE_QUOTE = '"'.charCodeAt(0);
  31420. const BACKSLASH = '\\'.charCodeAt(0);
  31421. const SLASH = '/'.charCodeAt(0);
  31422. const NEWLINE = '\n'.charCodeAt(0);
  31423. const SPACE = ' '.charCodeAt(0);
  31424. const FEED = '\f'.charCodeAt(0);
  31425. const TAB = '\t'.charCodeAt(0);
  31426. const CR = '\r'.charCodeAt(0);
  31427. const OPEN_SQUARE = '['.charCodeAt(0);
  31428. const CLOSE_SQUARE = ']'.charCodeAt(0);
  31429. const OPEN_PARENTHESES = '('.charCodeAt(0);
  31430. const CLOSE_PARENTHESES = ')'.charCodeAt(0);
  31431. const OPEN_CURLY = '{'.charCodeAt(0);
  31432. const CLOSE_CURLY = '}'.charCodeAt(0);
  31433. const SEMICOLON = ';'.charCodeAt(0);
  31434. const ASTERISK = '*'.charCodeAt(0);
  31435. const COLON = ':'.charCodeAt(0);
  31436. const AT = '@'.charCodeAt(0);
  31437. const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
  31438. const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
  31439. const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
  31440. const RE_HEX_ESCAPE = /[\da-f]/i;
  31441. var tokenize$1 = function tokenizer(input, options = {}) {
  31442. let css = input.css.valueOf();
  31443. let ignore = options.ignoreErrors;
  31444. let code, next, quote, content, escape;
  31445. let escaped, escapePos, prev, n, currentToken;
  31446. let length = css.length;
  31447. let pos = 0;
  31448. let buffer = [];
  31449. let returned = [];
  31450. function position() {
  31451. return pos
  31452. }
  31453. function unclosed(what) {
  31454. throw input.error('Unclosed ' + what, pos)
  31455. }
  31456. function endOfFile() {
  31457. return returned.length === 0 && pos >= length
  31458. }
  31459. function nextToken(opts) {
  31460. if (returned.length) return returned.pop()
  31461. if (pos >= length) return
  31462. let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  31463. code = css.charCodeAt(pos);
  31464. switch (code) {
  31465. case NEWLINE:
  31466. case SPACE:
  31467. case TAB:
  31468. case CR:
  31469. case FEED: {
  31470. next = pos;
  31471. do {
  31472. next += 1;
  31473. code = css.charCodeAt(next);
  31474. } while (
  31475. code === SPACE ||
  31476. code === NEWLINE ||
  31477. code === TAB ||
  31478. code === CR ||
  31479. code === FEED
  31480. )
  31481. currentToken = ['space', css.slice(pos, next)];
  31482. pos = next - 1;
  31483. break
  31484. }
  31485. case OPEN_SQUARE:
  31486. case CLOSE_SQUARE:
  31487. case OPEN_CURLY:
  31488. case CLOSE_CURLY:
  31489. case COLON:
  31490. case SEMICOLON:
  31491. case CLOSE_PARENTHESES: {
  31492. let controlChar = String.fromCharCode(code);
  31493. currentToken = [controlChar, controlChar, pos];
  31494. break
  31495. }
  31496. case OPEN_PARENTHESES: {
  31497. prev = buffer.length ? buffer.pop()[1] : '';
  31498. n = css.charCodeAt(pos + 1);
  31499. if (
  31500. prev === 'url' &&
  31501. n !== SINGLE_QUOTE &&
  31502. n !== DOUBLE_QUOTE &&
  31503. n !== SPACE &&
  31504. n !== NEWLINE &&
  31505. n !== TAB &&
  31506. n !== FEED &&
  31507. n !== CR
  31508. ) {
  31509. next = pos;
  31510. do {
  31511. escaped = false;
  31512. next = css.indexOf(')', next + 1);
  31513. if (next === -1) {
  31514. if (ignore || ignoreUnclosed) {
  31515. next = pos;
  31516. break
  31517. } else {
  31518. unclosed('bracket');
  31519. }
  31520. }
  31521. escapePos = next;
  31522. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31523. escapePos -= 1;
  31524. escaped = !escaped;
  31525. }
  31526. } while (escaped)
  31527. currentToken = ['brackets', css.slice(pos, next + 1), pos, next];
  31528. pos = next;
  31529. } else {
  31530. next = css.indexOf(')', pos + 1);
  31531. content = css.slice(pos, next + 1);
  31532. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  31533. currentToken = ['(', '(', pos];
  31534. } else {
  31535. currentToken = ['brackets', content, pos, next];
  31536. pos = next;
  31537. }
  31538. }
  31539. break
  31540. }
  31541. case SINGLE_QUOTE:
  31542. case DOUBLE_QUOTE: {
  31543. quote = code === SINGLE_QUOTE ? "'" : '"';
  31544. next = pos;
  31545. do {
  31546. escaped = false;
  31547. next = css.indexOf(quote, next + 1);
  31548. if (next === -1) {
  31549. if (ignore || ignoreUnclosed) {
  31550. next = pos + 1;
  31551. break
  31552. } else {
  31553. unclosed('string');
  31554. }
  31555. }
  31556. escapePos = next;
  31557. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  31558. escapePos -= 1;
  31559. escaped = !escaped;
  31560. }
  31561. } while (escaped)
  31562. currentToken = ['string', css.slice(pos, next + 1), pos, next];
  31563. pos = next;
  31564. break
  31565. }
  31566. case AT: {
  31567. RE_AT_END.lastIndex = pos + 1;
  31568. RE_AT_END.test(css);
  31569. if (RE_AT_END.lastIndex === 0) {
  31570. next = css.length - 1;
  31571. } else {
  31572. next = RE_AT_END.lastIndex - 2;
  31573. }
  31574. currentToken = ['at-word', css.slice(pos, next + 1), pos, next];
  31575. pos = next;
  31576. break
  31577. }
  31578. case BACKSLASH: {
  31579. next = pos;
  31580. escape = true;
  31581. while (css.charCodeAt(next + 1) === BACKSLASH) {
  31582. next += 1;
  31583. escape = !escape;
  31584. }
  31585. code = css.charCodeAt(next + 1);
  31586. if (
  31587. escape &&
  31588. code !== SLASH &&
  31589. code !== SPACE &&
  31590. code !== NEWLINE &&
  31591. code !== TAB &&
  31592. code !== CR &&
  31593. code !== FEED
  31594. ) {
  31595. next += 1;
  31596. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  31597. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  31598. next += 1;
  31599. }
  31600. if (css.charCodeAt(next + 1) === SPACE) {
  31601. next += 1;
  31602. }
  31603. }
  31604. }
  31605. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31606. pos = next;
  31607. break
  31608. }
  31609. default: {
  31610. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  31611. next = css.indexOf('*/', pos + 2) + 1;
  31612. if (next === 0) {
  31613. if (ignore || ignoreUnclosed) {
  31614. next = css.length;
  31615. } else {
  31616. unclosed('comment');
  31617. }
  31618. }
  31619. currentToken = ['comment', css.slice(pos, next + 1), pos, next];
  31620. pos = next;
  31621. } else {
  31622. RE_WORD_END.lastIndex = pos + 1;
  31623. RE_WORD_END.test(css);
  31624. if (RE_WORD_END.lastIndex === 0) {
  31625. next = css.length - 1;
  31626. } else {
  31627. next = RE_WORD_END.lastIndex - 2;
  31628. }
  31629. currentToken = ['word', css.slice(pos, next + 1), pos, next];
  31630. buffer.push(currentToken);
  31631. pos = next;
  31632. }
  31633. break
  31634. }
  31635. }
  31636. pos++;
  31637. return currentToken
  31638. }
  31639. function back(token) {
  31640. returned.push(token);
  31641. }
  31642. return {
  31643. back,
  31644. endOfFile,
  31645. nextToken,
  31646. position
  31647. }
  31648. };
  31649. let pico$1 = picocolorsExports;
  31650. let tokenizer$1 = tokenize$1;
  31651. let Input$5;
  31652. function registerInput(dependant) {
  31653. Input$5 = dependant;
  31654. }
  31655. const HIGHLIGHT_THEME = {
  31656. ';': pico$1.yellow,
  31657. ':': pico$1.yellow,
  31658. '(': pico$1.cyan,
  31659. ')': pico$1.cyan,
  31660. '[': pico$1.yellow,
  31661. ']': pico$1.yellow,
  31662. '{': pico$1.yellow,
  31663. '}': pico$1.yellow,
  31664. 'at-word': pico$1.cyan,
  31665. 'brackets': pico$1.cyan,
  31666. 'call': pico$1.cyan,
  31667. 'class': pico$1.yellow,
  31668. 'comment': pico$1.gray,
  31669. 'hash': pico$1.magenta,
  31670. 'string': pico$1.green
  31671. };
  31672. function getTokenType([type, value], processor) {
  31673. if (type === 'word') {
  31674. if (value[0] === '.') {
  31675. return 'class'
  31676. }
  31677. if (value[0] === '#') {
  31678. return 'hash'
  31679. }
  31680. }
  31681. if (!processor.endOfFile()) {
  31682. let next = processor.nextToken();
  31683. processor.back(next);
  31684. if (next[0] === 'brackets' || next[0] === '(') return 'call'
  31685. }
  31686. return type
  31687. }
  31688. function terminalHighlight$2(css) {
  31689. let processor = tokenizer$1(new Input$5(css), { ignoreErrors: true });
  31690. let result = '';
  31691. while (!processor.endOfFile()) {
  31692. let token = processor.nextToken();
  31693. let color = HIGHLIGHT_THEME[getTokenType(token, processor)];
  31694. if (color) {
  31695. result += token[1]
  31696. .split(/\r?\n/)
  31697. .map(i => color(i))
  31698. .join('\n');
  31699. } else {
  31700. result += token[1];
  31701. }
  31702. }
  31703. return result
  31704. }
  31705. terminalHighlight$2.registerInput = registerInput;
  31706. var terminalHighlight_1 = terminalHighlight$2;
  31707. let pico = picocolorsExports;
  31708. let terminalHighlight$1 = terminalHighlight_1;
  31709. let CssSyntaxError$3 = class CssSyntaxError extends Error {
  31710. constructor(message, line, column, source, file, plugin) {
  31711. super(message);
  31712. this.name = 'CssSyntaxError';
  31713. this.reason = message;
  31714. if (file) {
  31715. this.file = file;
  31716. }
  31717. if (source) {
  31718. this.source = source;
  31719. }
  31720. if (plugin) {
  31721. this.plugin = plugin;
  31722. }
  31723. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  31724. if (typeof line === 'number') {
  31725. this.line = line;
  31726. this.column = column;
  31727. } else {
  31728. this.line = line.line;
  31729. this.column = line.column;
  31730. this.endLine = column.line;
  31731. this.endColumn = column.column;
  31732. }
  31733. }
  31734. this.setMessage();
  31735. if (Error.captureStackTrace) {
  31736. Error.captureStackTrace(this, CssSyntaxError);
  31737. }
  31738. }
  31739. setMessage() {
  31740. this.message = this.plugin ? this.plugin + ': ' : '';
  31741. this.message += this.file ? this.file : '<css input>';
  31742. if (typeof this.line !== 'undefined') {
  31743. this.message += ':' + this.line + ':' + this.column;
  31744. }
  31745. this.message += ': ' + this.reason;
  31746. }
  31747. showSourceCode(color) {
  31748. if (!this.source) return ''
  31749. let css = this.source;
  31750. if (color == null) color = pico.isColorSupported;
  31751. if (terminalHighlight$1) {
  31752. if (color) css = terminalHighlight$1(css);
  31753. }
  31754. let lines = css.split(/\r?\n/);
  31755. let start = Math.max(this.line - 3, 0);
  31756. let end = Math.min(this.line + 2, lines.length);
  31757. let maxWidth = String(end).length;
  31758. let mark, aside;
  31759. if (color) {
  31760. let { bold, gray, red } = pico.createColors(true);
  31761. mark = text => bold(red(text));
  31762. aside = text => gray(text);
  31763. } else {
  31764. mark = aside = str => str;
  31765. }
  31766. return lines
  31767. .slice(start, end)
  31768. .map((line, index) => {
  31769. let number = start + 1 + index;
  31770. let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  31771. if (number === this.line) {
  31772. let spacing =
  31773. aside(gutter.replace(/\d/g, ' ')) +
  31774. line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
  31775. return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
  31776. }
  31777. return ' ' + aside(gutter) + line
  31778. })
  31779. .join('\n')
  31780. }
  31781. toString() {
  31782. let code = this.showSourceCode();
  31783. if (code) {
  31784. code = '\n\n' + code + '\n';
  31785. }
  31786. return this.name + ': ' + this.message + code
  31787. }
  31788. };
  31789. var cssSyntaxError = CssSyntaxError$3;
  31790. CssSyntaxError$3.default = CssSyntaxError$3;
  31791. var symbols = {};
  31792. symbols.isClean = Symbol('isClean');
  31793. symbols.my = Symbol('my');
  31794. const DEFAULT_RAW = {
  31795. after: '\n',
  31796. beforeClose: '\n',
  31797. beforeComment: '\n',
  31798. beforeDecl: '\n',
  31799. beforeOpen: ' ',
  31800. beforeRule: '\n',
  31801. colon: ': ',
  31802. commentLeft: ' ',
  31803. commentRight: ' ',
  31804. emptyBody: '',
  31805. indent: ' ',
  31806. semicolon: false
  31807. };
  31808. function capitalize(str) {
  31809. return str[0].toUpperCase() + str.slice(1)
  31810. }
  31811. let Stringifier$2 = class Stringifier {
  31812. constructor(builder) {
  31813. this.builder = builder;
  31814. }
  31815. atrule(node, semicolon) {
  31816. let name = '@' + node.name;
  31817. let params = node.params ? this.rawValue(node, 'params') : '';
  31818. if (typeof node.raws.afterName !== 'undefined') {
  31819. name += node.raws.afterName;
  31820. } else if (params) {
  31821. name += ' ';
  31822. }
  31823. if (node.nodes) {
  31824. this.block(node, name + params);
  31825. } else {
  31826. let end = (node.raws.between || '') + (semicolon ? ';' : '');
  31827. this.builder(name + params + end, node);
  31828. }
  31829. }
  31830. beforeAfter(node, detect) {
  31831. let value;
  31832. if (node.type === 'decl') {
  31833. value = this.raw(node, null, 'beforeDecl');
  31834. } else if (node.type === 'comment') {
  31835. value = this.raw(node, null, 'beforeComment');
  31836. } else if (detect === 'before') {
  31837. value = this.raw(node, null, 'beforeRule');
  31838. } else {
  31839. value = this.raw(node, null, 'beforeClose');
  31840. }
  31841. let buf = node.parent;
  31842. let depth = 0;
  31843. while (buf && buf.type !== 'root') {
  31844. depth += 1;
  31845. buf = buf.parent;
  31846. }
  31847. if (value.includes('\n')) {
  31848. let indent = this.raw(node, null, 'indent');
  31849. if (indent.length) {
  31850. for (let step = 0; step < depth; step++) value += indent;
  31851. }
  31852. }
  31853. return value
  31854. }
  31855. block(node, start) {
  31856. let between = this.raw(node, 'between', 'beforeOpen');
  31857. this.builder(start + between + '{', node, 'start');
  31858. let after;
  31859. if (node.nodes && node.nodes.length) {
  31860. this.body(node);
  31861. after = this.raw(node, 'after');
  31862. } else {
  31863. after = this.raw(node, 'after', 'emptyBody');
  31864. }
  31865. if (after) this.builder(after);
  31866. this.builder('}', node, 'end');
  31867. }
  31868. body(node) {
  31869. let last = node.nodes.length - 1;
  31870. while (last > 0) {
  31871. if (node.nodes[last].type !== 'comment') break
  31872. last -= 1;
  31873. }
  31874. let semicolon = this.raw(node, 'semicolon');
  31875. for (let i = 0; i < node.nodes.length; i++) {
  31876. let child = node.nodes[i];
  31877. let before = this.raw(child, 'before');
  31878. if (before) this.builder(before);
  31879. this.stringify(child, last !== i || semicolon);
  31880. }
  31881. }
  31882. comment(node) {
  31883. let left = this.raw(node, 'left', 'commentLeft');
  31884. let right = this.raw(node, 'right', 'commentRight');
  31885. this.builder('/*' + left + node.text + right + '*/', node);
  31886. }
  31887. decl(node, semicolon) {
  31888. let between = this.raw(node, 'between', 'colon');
  31889. let string = node.prop + between + this.rawValue(node, 'value');
  31890. if (node.important) {
  31891. string += node.raws.important || ' !important';
  31892. }
  31893. if (semicolon) string += ';';
  31894. this.builder(string, node);
  31895. }
  31896. document(node) {
  31897. this.body(node);
  31898. }
  31899. raw(node, own, detect) {
  31900. let value;
  31901. if (!detect) detect = own;
  31902. // Already had
  31903. if (own) {
  31904. value = node.raws[own];
  31905. if (typeof value !== 'undefined') return value
  31906. }
  31907. let parent = node.parent;
  31908. if (detect === 'before') {
  31909. // Hack for first rule in CSS
  31910. if (!parent || (parent.type === 'root' && parent.first === node)) {
  31911. return ''
  31912. }
  31913. // `root` nodes in `document` should use only their own raws
  31914. if (parent && parent.type === 'document') {
  31915. return ''
  31916. }
  31917. }
  31918. // Floating child without parent
  31919. if (!parent) return DEFAULT_RAW[detect]
  31920. // Detect style by other nodes
  31921. let root = node.root();
  31922. if (!root.rawCache) root.rawCache = {};
  31923. if (typeof root.rawCache[detect] !== 'undefined') {
  31924. return root.rawCache[detect]
  31925. }
  31926. if (detect === 'before' || detect === 'after') {
  31927. return this.beforeAfter(node, detect)
  31928. } else {
  31929. let method = 'raw' + capitalize(detect);
  31930. if (this[method]) {
  31931. value = this[method](root, node);
  31932. } else {
  31933. root.walk(i => {
  31934. value = i.raws[own];
  31935. if (typeof value !== 'undefined') return false
  31936. });
  31937. }
  31938. }
  31939. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  31940. root.rawCache[detect] = value;
  31941. return value
  31942. }
  31943. rawBeforeClose(root) {
  31944. let value;
  31945. root.walk(i => {
  31946. if (i.nodes && i.nodes.length > 0) {
  31947. if (typeof i.raws.after !== 'undefined') {
  31948. value = i.raws.after;
  31949. if (value.includes('\n')) {
  31950. value = value.replace(/[^\n]+$/, '');
  31951. }
  31952. return false
  31953. }
  31954. }
  31955. });
  31956. if (value) value = value.replace(/\S/g, '');
  31957. return value
  31958. }
  31959. rawBeforeComment(root, node) {
  31960. let value;
  31961. root.walkComments(i => {
  31962. if (typeof i.raws.before !== 'undefined') {
  31963. value = i.raws.before;
  31964. if (value.includes('\n')) {
  31965. value = value.replace(/[^\n]+$/, '');
  31966. }
  31967. return false
  31968. }
  31969. });
  31970. if (typeof value === 'undefined') {
  31971. value = this.raw(node, null, 'beforeDecl');
  31972. } else if (value) {
  31973. value = value.replace(/\S/g, '');
  31974. }
  31975. return value
  31976. }
  31977. rawBeforeDecl(root, node) {
  31978. let value;
  31979. root.walkDecls(i => {
  31980. if (typeof i.raws.before !== 'undefined') {
  31981. value = i.raws.before;
  31982. if (value.includes('\n')) {
  31983. value = value.replace(/[^\n]+$/, '');
  31984. }
  31985. return false
  31986. }
  31987. });
  31988. if (typeof value === 'undefined') {
  31989. value = this.raw(node, null, 'beforeRule');
  31990. } else if (value) {
  31991. value = value.replace(/\S/g, '');
  31992. }
  31993. return value
  31994. }
  31995. rawBeforeOpen(root) {
  31996. let value;
  31997. root.walk(i => {
  31998. if (i.type !== 'decl') {
  31999. value = i.raws.between;
  32000. if (typeof value !== 'undefined') return false
  32001. }
  32002. });
  32003. return value
  32004. }
  32005. rawBeforeRule(root) {
  32006. let value;
  32007. root.walk(i => {
  32008. if (i.nodes && (i.parent !== root || root.first !== i)) {
  32009. if (typeof i.raws.before !== 'undefined') {
  32010. value = i.raws.before;
  32011. if (value.includes('\n')) {
  32012. value = value.replace(/[^\n]+$/, '');
  32013. }
  32014. return false
  32015. }
  32016. }
  32017. });
  32018. if (value) value = value.replace(/\S/g, '');
  32019. return value
  32020. }
  32021. rawColon(root) {
  32022. let value;
  32023. root.walkDecls(i => {
  32024. if (typeof i.raws.between !== 'undefined') {
  32025. value = i.raws.between.replace(/[^\s:]/g, '');
  32026. return false
  32027. }
  32028. });
  32029. return value
  32030. }
  32031. rawEmptyBody(root) {
  32032. let value;
  32033. root.walk(i => {
  32034. if (i.nodes && i.nodes.length === 0) {
  32035. value = i.raws.after;
  32036. if (typeof value !== 'undefined') return false
  32037. }
  32038. });
  32039. return value
  32040. }
  32041. rawIndent(root) {
  32042. if (root.raws.indent) return root.raws.indent
  32043. let value;
  32044. root.walk(i => {
  32045. let p = i.parent;
  32046. if (p && p !== root && p.parent && p.parent === root) {
  32047. if (typeof i.raws.before !== 'undefined') {
  32048. let parts = i.raws.before.split('\n');
  32049. value = parts[parts.length - 1];
  32050. value = value.replace(/\S/g, '');
  32051. return false
  32052. }
  32053. }
  32054. });
  32055. return value
  32056. }
  32057. rawSemicolon(root) {
  32058. let value;
  32059. root.walk(i => {
  32060. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  32061. value = i.raws.semicolon;
  32062. if (typeof value !== 'undefined') return false
  32063. }
  32064. });
  32065. return value
  32066. }
  32067. rawValue(node, prop) {
  32068. let value = node[prop];
  32069. let raw = node.raws[prop];
  32070. if (raw && raw.value === value) {
  32071. return raw.raw
  32072. }
  32073. return value
  32074. }
  32075. root(node) {
  32076. this.body(node);
  32077. if (node.raws.after) this.builder(node.raws.after);
  32078. }
  32079. rule(node) {
  32080. this.block(node, this.rawValue(node, 'selector'));
  32081. if (node.raws.ownSemicolon) {
  32082. this.builder(node.raws.ownSemicolon, node, 'end');
  32083. }
  32084. }
  32085. stringify(node, semicolon) {
  32086. /* c8 ignore start */
  32087. if (!this[node.type]) {
  32088. throw new Error(
  32089. 'Unknown AST node type ' +
  32090. node.type +
  32091. '. ' +
  32092. 'Maybe you need to change PostCSS stringifier.'
  32093. )
  32094. }
  32095. /* c8 ignore stop */
  32096. this[node.type](node, semicolon);
  32097. }
  32098. };
  32099. var stringifier = Stringifier$2;
  32100. Stringifier$2.default = Stringifier$2;
  32101. let Stringifier$1 = stringifier;
  32102. function stringify$4(node, builder) {
  32103. let str = new Stringifier$1(builder);
  32104. str.stringify(node);
  32105. }
  32106. var stringify_1 = stringify$4;
  32107. stringify$4.default = stringify$4;
  32108. let { isClean: isClean$2, my: my$2 } = symbols;
  32109. let CssSyntaxError$2 = cssSyntaxError;
  32110. let Stringifier = stringifier;
  32111. let stringify$3 = stringify_1;
  32112. function cloneNode(obj, parent) {
  32113. let cloned = new obj.constructor();
  32114. for (let i in obj) {
  32115. if (!Object.prototype.hasOwnProperty.call(obj, i)) {
  32116. /* c8 ignore next 2 */
  32117. continue
  32118. }
  32119. if (i === 'proxyCache') continue
  32120. let value = obj[i];
  32121. let type = typeof value;
  32122. if (i === 'parent' && type === 'object') {
  32123. if (parent) cloned[i] = parent;
  32124. } else if (i === 'source') {
  32125. cloned[i] = value;
  32126. } else if (Array.isArray(value)) {
  32127. cloned[i] = value.map(j => cloneNode(j, cloned));
  32128. } else {
  32129. if (type === 'object' && value !== null) value = cloneNode(value);
  32130. cloned[i] = value;
  32131. }
  32132. }
  32133. return cloned
  32134. }
  32135. let Node$4 = class Node {
  32136. constructor(defaults = {}) {
  32137. this.raws = {};
  32138. this[isClean$2] = false;
  32139. this[my$2] = true;
  32140. for (let name in defaults) {
  32141. if (name === 'nodes') {
  32142. this.nodes = [];
  32143. for (let node of defaults[name]) {
  32144. if (typeof node.clone === 'function') {
  32145. this.append(node.clone());
  32146. } else {
  32147. this.append(node);
  32148. }
  32149. }
  32150. } else {
  32151. this[name] = defaults[name];
  32152. }
  32153. }
  32154. }
  32155. addToError(error) {
  32156. error.postcssNode = this;
  32157. if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
  32158. let s = this.source;
  32159. error.stack = error.stack.replace(
  32160. /\n\s{4}at /,
  32161. `$&${s.input.from}:${s.start.line}:${s.start.column}$&`
  32162. );
  32163. }
  32164. return error
  32165. }
  32166. after(add) {
  32167. this.parent.insertAfter(this, add);
  32168. return this
  32169. }
  32170. assign(overrides = {}) {
  32171. for (let name in overrides) {
  32172. this[name] = overrides[name];
  32173. }
  32174. return this
  32175. }
  32176. before(add) {
  32177. this.parent.insertBefore(this, add);
  32178. return this
  32179. }
  32180. cleanRaws(keepBetween) {
  32181. delete this.raws.before;
  32182. delete this.raws.after;
  32183. if (!keepBetween) delete this.raws.between;
  32184. }
  32185. clone(overrides = {}) {
  32186. let cloned = cloneNode(this);
  32187. for (let name in overrides) {
  32188. cloned[name] = overrides[name];
  32189. }
  32190. return cloned
  32191. }
  32192. cloneAfter(overrides = {}) {
  32193. let cloned = this.clone(overrides);
  32194. this.parent.insertAfter(this, cloned);
  32195. return cloned
  32196. }
  32197. cloneBefore(overrides = {}) {
  32198. let cloned = this.clone(overrides);
  32199. this.parent.insertBefore(this, cloned);
  32200. return cloned
  32201. }
  32202. error(message, opts = {}) {
  32203. if (this.source) {
  32204. let { end, start } = this.rangeBy(opts);
  32205. return this.source.input.error(
  32206. message,
  32207. { column: start.column, line: start.line },
  32208. { column: end.column, line: end.line },
  32209. opts
  32210. )
  32211. }
  32212. return new CssSyntaxError$2(message)
  32213. }
  32214. getProxyProcessor() {
  32215. return {
  32216. get(node, prop) {
  32217. if (prop === 'proxyOf') {
  32218. return node
  32219. } else if (prop === 'root') {
  32220. return () => node.root().toProxy()
  32221. } else {
  32222. return node[prop]
  32223. }
  32224. },
  32225. set(node, prop, value) {
  32226. if (node[prop] === value) return true
  32227. node[prop] = value;
  32228. if (
  32229. prop === 'prop' ||
  32230. prop === 'value' ||
  32231. prop === 'name' ||
  32232. prop === 'params' ||
  32233. prop === 'important' ||
  32234. /* c8 ignore next */
  32235. prop === 'text'
  32236. ) {
  32237. node.markDirty();
  32238. }
  32239. return true
  32240. }
  32241. }
  32242. }
  32243. markDirty() {
  32244. if (this[isClean$2]) {
  32245. this[isClean$2] = false;
  32246. let next = this;
  32247. while ((next = next.parent)) {
  32248. next[isClean$2] = false;
  32249. }
  32250. }
  32251. }
  32252. next() {
  32253. if (!this.parent) return undefined
  32254. let index = this.parent.index(this);
  32255. return this.parent.nodes[index + 1]
  32256. }
  32257. positionBy(opts, stringRepresentation) {
  32258. let pos = this.source.start;
  32259. if (opts.index) {
  32260. pos = this.positionInside(opts.index, stringRepresentation);
  32261. } else if (opts.word) {
  32262. stringRepresentation = this.toString();
  32263. let index = stringRepresentation.indexOf(opts.word);
  32264. if (index !== -1) pos = this.positionInside(index, stringRepresentation);
  32265. }
  32266. return pos
  32267. }
  32268. positionInside(index, stringRepresentation) {
  32269. let string = stringRepresentation || this.toString();
  32270. let column = this.source.start.column;
  32271. let line = this.source.start.line;
  32272. for (let i = 0; i < index; i++) {
  32273. if (string[i] === '\n') {
  32274. column = 1;
  32275. line += 1;
  32276. } else {
  32277. column += 1;
  32278. }
  32279. }
  32280. return { column, line }
  32281. }
  32282. prev() {
  32283. if (!this.parent) return undefined
  32284. let index = this.parent.index(this);
  32285. return this.parent.nodes[index - 1]
  32286. }
  32287. rangeBy(opts) {
  32288. let start = {
  32289. column: this.source.start.column,
  32290. line: this.source.start.line
  32291. };
  32292. let end = this.source.end
  32293. ? {
  32294. column: this.source.end.column + 1,
  32295. line: this.source.end.line
  32296. }
  32297. : {
  32298. column: start.column + 1,
  32299. line: start.line
  32300. };
  32301. if (opts.word) {
  32302. let stringRepresentation = this.toString();
  32303. let index = stringRepresentation.indexOf(opts.word);
  32304. if (index !== -1) {
  32305. start = this.positionInside(index, stringRepresentation);
  32306. end = this.positionInside(index + opts.word.length, stringRepresentation);
  32307. }
  32308. } else {
  32309. if (opts.start) {
  32310. start = {
  32311. column: opts.start.column,
  32312. line: opts.start.line
  32313. };
  32314. } else if (opts.index) {
  32315. start = this.positionInside(opts.index);
  32316. }
  32317. if (opts.end) {
  32318. end = {
  32319. column: opts.end.column,
  32320. line: opts.end.line
  32321. };
  32322. } else if (typeof opts.endIndex === 'number') {
  32323. end = this.positionInside(opts.endIndex);
  32324. } else if (opts.index) {
  32325. end = this.positionInside(opts.index + 1);
  32326. }
  32327. }
  32328. if (
  32329. end.line < start.line ||
  32330. (end.line === start.line && end.column <= start.column)
  32331. ) {
  32332. end = { column: start.column + 1, line: start.line };
  32333. }
  32334. return { end, start }
  32335. }
  32336. raw(prop, defaultType) {
  32337. let str = new Stringifier();
  32338. return str.raw(this, prop, defaultType)
  32339. }
  32340. remove() {
  32341. if (this.parent) {
  32342. this.parent.removeChild(this);
  32343. }
  32344. this.parent = undefined;
  32345. return this
  32346. }
  32347. replaceWith(...nodes) {
  32348. if (this.parent) {
  32349. let bookmark = this;
  32350. let foundSelf = false;
  32351. for (let node of nodes) {
  32352. if (node === this) {
  32353. foundSelf = true;
  32354. } else if (foundSelf) {
  32355. this.parent.insertAfter(bookmark, node);
  32356. bookmark = node;
  32357. } else {
  32358. this.parent.insertBefore(bookmark, node);
  32359. }
  32360. }
  32361. if (!foundSelf) {
  32362. this.remove();
  32363. }
  32364. }
  32365. return this
  32366. }
  32367. root() {
  32368. let result = this;
  32369. while (result.parent && result.parent.type !== 'document') {
  32370. result = result.parent;
  32371. }
  32372. return result
  32373. }
  32374. toJSON(_, inputs) {
  32375. let fixed = {};
  32376. let emitInputs = inputs == null;
  32377. inputs = inputs || new Map();
  32378. let inputsNextIndex = 0;
  32379. for (let name in this) {
  32380. if (!Object.prototype.hasOwnProperty.call(this, name)) {
  32381. /* c8 ignore next 2 */
  32382. continue
  32383. }
  32384. if (name === 'parent' || name === 'proxyCache') continue
  32385. let value = this[name];
  32386. if (Array.isArray(value)) {
  32387. fixed[name] = value.map(i => {
  32388. if (typeof i === 'object' && i.toJSON) {
  32389. return i.toJSON(null, inputs)
  32390. } else {
  32391. return i
  32392. }
  32393. });
  32394. } else if (typeof value === 'object' && value.toJSON) {
  32395. fixed[name] = value.toJSON(null, inputs);
  32396. } else if (name === 'source') {
  32397. let inputId = inputs.get(value.input);
  32398. if (inputId == null) {
  32399. inputId = inputsNextIndex;
  32400. inputs.set(value.input, inputsNextIndex);
  32401. inputsNextIndex++;
  32402. }
  32403. fixed[name] = {
  32404. end: value.end,
  32405. inputId,
  32406. start: value.start
  32407. };
  32408. } else {
  32409. fixed[name] = value;
  32410. }
  32411. }
  32412. if (emitInputs) {
  32413. fixed.inputs = [...inputs.keys()].map(input => input.toJSON());
  32414. }
  32415. return fixed
  32416. }
  32417. toProxy() {
  32418. if (!this.proxyCache) {
  32419. this.proxyCache = new Proxy(this, this.getProxyProcessor());
  32420. }
  32421. return this.proxyCache
  32422. }
  32423. toString(stringifier = stringify$3) {
  32424. if (stringifier.stringify) stringifier = stringifier.stringify;
  32425. let result = '';
  32426. stringifier(this, i => {
  32427. result += i;
  32428. });
  32429. return result
  32430. }
  32431. warn(result, text, opts) {
  32432. let data = { node: this };
  32433. for (let i in opts) data[i] = opts[i];
  32434. return result.warn(text, data)
  32435. }
  32436. get proxyOf() {
  32437. return this
  32438. }
  32439. };
  32440. var node$2 = Node$4;
  32441. Node$4.default = Node$4;
  32442. let Node$3 = node$2;
  32443. let Declaration$4 = class Declaration extends Node$3 {
  32444. constructor(defaults) {
  32445. if (
  32446. defaults &&
  32447. typeof defaults.value !== 'undefined' &&
  32448. typeof defaults.value !== 'string'
  32449. ) {
  32450. defaults = { ...defaults, value: String(defaults.value) };
  32451. }
  32452. super(defaults);
  32453. this.type = 'decl';
  32454. }
  32455. get variable() {
  32456. return this.prop.startsWith('--') || this.prop[0] === '$'
  32457. }
  32458. };
  32459. var declaration = Declaration$4;
  32460. Declaration$4.default = Declaration$4;
  32461. var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
  32462. let urlAlphabet =
  32463. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
  32464. let customAlphabet = (alphabet, defaultSize = 21) => {
  32465. return (size = defaultSize) => {
  32466. let id = '';
  32467. let i = size;
  32468. while (i--) {
  32469. id += alphabet[(Math.random() * alphabet.length) | 0];
  32470. }
  32471. return id
  32472. }
  32473. };
  32474. let nanoid$1 = (size = 21) => {
  32475. let id = '';
  32476. let i = size;
  32477. while (i--) {
  32478. id += urlAlphabet[(Math.random() * 64) | 0];
  32479. }
  32480. return id
  32481. };
  32482. var nonSecure = { nanoid: nanoid$1, customAlphabet };
  32483. let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
  32484. let { existsSync, readFileSync } = require$$0$2;
  32485. let { dirname: dirname$1, join } = require$$1;
  32486. function fromBase64(str) {
  32487. if (Buffer$1) {
  32488. return Buffer$1.from(str, 'base64').toString()
  32489. } else {
  32490. /* c8 ignore next 2 */
  32491. return window.atob(str)
  32492. }
  32493. }
  32494. let PreviousMap$2 = class PreviousMap {
  32495. constructor(css, opts) {
  32496. if (opts.map === false) return
  32497. this.loadAnnotation(css);
  32498. this.inline = this.startWith(this.annotation, 'data:');
  32499. let prev = opts.map ? opts.map.prev : undefined;
  32500. let text = this.loadMap(opts.from, prev);
  32501. if (!this.mapFile && opts.from) {
  32502. this.mapFile = opts.from;
  32503. }
  32504. if (this.mapFile) this.root = dirname$1(this.mapFile);
  32505. if (text) this.text = text;
  32506. }
  32507. consumer() {
  32508. if (!this.consumerCache) {
  32509. this.consumerCache = new SourceMapConsumer$4(this.text);
  32510. }
  32511. return this.consumerCache
  32512. }
  32513. decodeInline(text) {
  32514. let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  32515. let baseUri = /^data:application\/json;base64,/;
  32516. let charsetUri = /^data:application\/json;charset=utf-?8,/;
  32517. let uri = /^data:application\/json,/;
  32518. if (charsetUri.test(text) || uri.test(text)) {
  32519. return decodeURIComponent(text.substr(RegExp.lastMatch.length))
  32520. }
  32521. if (baseCharsetUri.test(text) || baseUri.test(text)) {
  32522. return fromBase64(text.substr(RegExp.lastMatch.length))
  32523. }
  32524. let encoding = text.match(/data:application\/json;([^,]+),/)[1];
  32525. throw new Error('Unsupported source map encoding ' + encoding)
  32526. }
  32527. getAnnotationURL(sourceMapString) {
  32528. return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
  32529. }
  32530. isMap(map) {
  32531. if (typeof map !== 'object') return false
  32532. return (
  32533. typeof map.mappings === 'string' ||
  32534. typeof map._mappings === 'string' ||
  32535. Array.isArray(map.sections)
  32536. )
  32537. }
  32538. loadAnnotation(css) {
  32539. let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
  32540. if (!comments) return
  32541. // sourceMappingURLs from comments, strings, etc.
  32542. let start = css.lastIndexOf(comments.pop());
  32543. let end = css.indexOf('*/', start);
  32544. if (start > -1 && end > -1) {
  32545. // Locate the last sourceMappingURL to avoid pickin
  32546. this.annotation = this.getAnnotationURL(css.substring(start, end));
  32547. }
  32548. }
  32549. loadFile(path) {
  32550. this.root = dirname$1(path);
  32551. if (existsSync(path)) {
  32552. this.mapFile = path;
  32553. return readFileSync(path, 'utf-8').toString().trim()
  32554. }
  32555. }
  32556. loadMap(file, prev) {
  32557. if (prev === false) return false
  32558. if (prev) {
  32559. if (typeof prev === 'string') {
  32560. return prev
  32561. } else if (typeof prev === 'function') {
  32562. let prevPath = prev(file);
  32563. if (prevPath) {
  32564. let map = this.loadFile(prevPath);
  32565. if (!map) {
  32566. throw new Error(
  32567. 'Unable to load previous source map: ' + prevPath.toString()
  32568. )
  32569. }
  32570. return map
  32571. }
  32572. } else if (prev instanceof SourceMapConsumer$4) {
  32573. return SourceMapGenerator$5.fromSourceMap(prev).toString()
  32574. } else if (prev instanceof SourceMapGenerator$5) {
  32575. return prev.toString()
  32576. } else if (this.isMap(prev)) {
  32577. return JSON.stringify(prev)
  32578. } else {
  32579. throw new Error(
  32580. 'Unsupported previous source map format: ' + prev.toString()
  32581. )
  32582. }
  32583. } else if (this.inline) {
  32584. return this.decodeInline(this.annotation)
  32585. } else if (this.annotation) {
  32586. let map = this.annotation;
  32587. if (file) map = join(dirname$1(file), map);
  32588. return this.loadFile(map)
  32589. }
  32590. }
  32591. startWith(string, start) {
  32592. if (!string) return false
  32593. return string.substr(0, start.length) === start
  32594. }
  32595. withContent() {
  32596. return !!(
  32597. this.consumer().sourcesContent &&
  32598. this.consumer().sourcesContent.length > 0
  32599. )
  32600. }
  32601. };
  32602. var previousMap = PreviousMap$2;
  32603. PreviousMap$2.default = PreviousMap$2;
  32604. let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
  32605. let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
  32606. let { isAbsolute, resolve: resolve$1 } = require$$1;
  32607. let { nanoid } = nonSecure;
  32608. let terminalHighlight = terminalHighlight_1;
  32609. let CssSyntaxError$1 = cssSyntaxError;
  32610. let PreviousMap$1 = previousMap;
  32611. let fromOffsetCache = Symbol('fromOffsetCache');
  32612. let sourceMapAvailable$1 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$4);
  32613. let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
  32614. let Input$4 = class Input {
  32615. constructor(css, opts = {}) {
  32616. if (
  32617. css === null ||
  32618. typeof css === 'undefined' ||
  32619. (typeof css === 'object' && !css.toString)
  32620. ) {
  32621. throw new Error(`PostCSS received ${css} instead of CSS string`)
  32622. }
  32623. this.css = css.toString();
  32624. if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
  32625. this.hasBOM = true;
  32626. this.css = this.css.slice(1);
  32627. } else {
  32628. this.hasBOM = false;
  32629. }
  32630. if (opts.from) {
  32631. if (
  32632. !pathAvailable$1 ||
  32633. /^\w+:\/\//.test(opts.from) ||
  32634. isAbsolute(opts.from)
  32635. ) {
  32636. this.file = opts.from;
  32637. } else {
  32638. this.file = resolve$1(opts.from);
  32639. }
  32640. }
  32641. if (pathAvailable$1 && sourceMapAvailable$1) {
  32642. let map = new PreviousMap$1(this.css, opts);
  32643. if (map.text) {
  32644. this.map = map;
  32645. let file = map.consumer().file;
  32646. if (!this.file && file) this.file = this.mapResolve(file);
  32647. }
  32648. }
  32649. if (!this.file) {
  32650. this.id = '<input css ' + nanoid(6) + '>';
  32651. }
  32652. if (this.map) this.map.file = this.from;
  32653. }
  32654. error(message, line, column, opts = {}) {
  32655. let result, endLine, endColumn;
  32656. if (line && typeof line === 'object') {
  32657. let start = line;
  32658. let end = column;
  32659. if (typeof start.offset === 'number') {
  32660. let pos = this.fromOffset(start.offset);
  32661. line = pos.line;
  32662. column = pos.col;
  32663. } else {
  32664. line = start.line;
  32665. column = start.column;
  32666. }
  32667. if (typeof end.offset === 'number') {
  32668. let pos = this.fromOffset(end.offset);
  32669. endLine = pos.line;
  32670. endColumn = pos.col;
  32671. } else {
  32672. endLine = end.line;
  32673. endColumn = end.column;
  32674. }
  32675. } else if (!column) {
  32676. let pos = this.fromOffset(line);
  32677. line = pos.line;
  32678. column = pos.col;
  32679. }
  32680. let origin = this.origin(line, column, endLine, endColumn);
  32681. if (origin) {
  32682. result = new CssSyntaxError$1(
  32683. message,
  32684. origin.endLine === undefined
  32685. ? origin.line
  32686. : { column: origin.column, line: origin.line },
  32687. origin.endLine === undefined
  32688. ? origin.column
  32689. : { column: origin.endColumn, line: origin.endLine },
  32690. origin.source,
  32691. origin.file,
  32692. opts.plugin
  32693. );
  32694. } else {
  32695. result = new CssSyntaxError$1(
  32696. message,
  32697. endLine === undefined ? line : { column, line },
  32698. endLine === undefined ? column : { column: endColumn, line: endLine },
  32699. this.css,
  32700. this.file,
  32701. opts.plugin
  32702. );
  32703. }
  32704. result.input = { column, endColumn, endLine, line, source: this.css };
  32705. if (this.file) {
  32706. if (pathToFileURL$1) {
  32707. result.input.url = pathToFileURL$1(this.file).toString();
  32708. }
  32709. result.input.file = this.file;
  32710. }
  32711. return result
  32712. }
  32713. fromOffset(offset) {
  32714. let lastLine, lineToIndex;
  32715. if (!this[fromOffsetCache]) {
  32716. let lines = this.css.split('\n');
  32717. lineToIndex = new Array(lines.length);
  32718. let prevIndex = 0;
  32719. for (let i = 0, l = lines.length; i < l; i++) {
  32720. lineToIndex[i] = prevIndex;
  32721. prevIndex += lines[i].length + 1;
  32722. }
  32723. this[fromOffsetCache] = lineToIndex;
  32724. } else {
  32725. lineToIndex = this[fromOffsetCache];
  32726. }
  32727. lastLine = lineToIndex[lineToIndex.length - 1];
  32728. let min = 0;
  32729. if (offset >= lastLine) {
  32730. min = lineToIndex.length - 1;
  32731. } else {
  32732. let max = lineToIndex.length - 2;
  32733. let mid;
  32734. while (min < max) {
  32735. mid = min + ((max - min) >> 1);
  32736. if (offset < lineToIndex[mid]) {
  32737. max = mid - 1;
  32738. } else if (offset >= lineToIndex[mid + 1]) {
  32739. min = mid + 1;
  32740. } else {
  32741. min = mid;
  32742. break
  32743. }
  32744. }
  32745. }
  32746. return {
  32747. col: offset - lineToIndex[min] + 1,
  32748. line: min + 1
  32749. }
  32750. }
  32751. mapResolve(file) {
  32752. if (/^\w+:\/\//.test(file)) {
  32753. return file
  32754. }
  32755. return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
  32756. }
  32757. origin(line, column, endLine, endColumn) {
  32758. if (!this.map) return false
  32759. let consumer = this.map.consumer();
  32760. let from = consumer.originalPositionFor({ column, line });
  32761. if (!from.source) return false
  32762. let to;
  32763. if (typeof endLine === 'number') {
  32764. to = consumer.originalPositionFor({ column: endColumn, line: endLine });
  32765. }
  32766. let fromUrl;
  32767. if (isAbsolute(from.source)) {
  32768. fromUrl = pathToFileURL$1(from.source);
  32769. } else {
  32770. fromUrl = new URL(
  32771. from.source,
  32772. this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
  32773. );
  32774. }
  32775. let result = {
  32776. column: from.column,
  32777. endColumn: to && to.column,
  32778. endLine: to && to.line,
  32779. line: from.line,
  32780. url: fromUrl.toString()
  32781. };
  32782. if (fromUrl.protocol === 'file:') {
  32783. if (fileURLToPath) {
  32784. result.file = fileURLToPath(fromUrl);
  32785. } else {
  32786. /* c8 ignore next 2 */
  32787. throw new Error(`file: protocol is not available in this PostCSS build`)
  32788. }
  32789. }
  32790. let source = consumer.sourceContentFor(from.source);
  32791. if (source) result.source = source;
  32792. return result
  32793. }
  32794. toJSON() {
  32795. let json = {};
  32796. for (let name of ['hasBOM', 'css', 'file', 'id']) {
  32797. if (this[name] != null) {
  32798. json[name] = this[name];
  32799. }
  32800. }
  32801. if (this.map) {
  32802. json.map = { ...this.map };
  32803. if (json.map.consumerCache) {
  32804. json.map.consumerCache = undefined;
  32805. }
  32806. }
  32807. return json
  32808. }
  32809. get from() {
  32810. return this.file || this.id
  32811. }
  32812. };
  32813. var input = Input$4;
  32814. Input$4.default = Input$4;
  32815. if (terminalHighlight && terminalHighlight.registerInput) {
  32816. terminalHighlight.registerInput(Input$4);
  32817. }
  32818. let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
  32819. let { dirname, relative, resolve, sep } = require$$1;
  32820. let { pathToFileURL } = require$$2;
  32821. let Input$3 = input;
  32822. let sourceMapAvailable = Boolean(SourceMapConsumer$2 && SourceMapGenerator$3);
  32823. let pathAvailable = Boolean(dirname && resolve && relative && sep);
  32824. let MapGenerator$2 = class MapGenerator {
  32825. constructor(stringify, root, opts, cssString) {
  32826. this.stringify = stringify;
  32827. this.mapOpts = opts.map || {};
  32828. this.root = root;
  32829. this.opts = opts;
  32830. this.css = cssString;
  32831. this.originalCSS = cssString;
  32832. this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
  32833. this.memoizedFileURLs = new Map();
  32834. this.memoizedPaths = new Map();
  32835. this.memoizedURLs = new Map();
  32836. }
  32837. addAnnotation() {
  32838. let content;
  32839. if (this.isInline()) {
  32840. content =
  32841. 'data:application/json;base64,' + this.toBase64(this.map.toString());
  32842. } else if (typeof this.mapOpts.annotation === 'string') {
  32843. content = this.mapOpts.annotation;
  32844. } else if (typeof this.mapOpts.annotation === 'function') {
  32845. content = this.mapOpts.annotation(this.opts.to, this.root);
  32846. } else {
  32847. content = this.outputFile() + '.map';
  32848. }
  32849. let eol = '\n';
  32850. if (this.css.includes('\r\n')) eol = '\r\n';
  32851. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  32852. }
  32853. applyPrevMaps() {
  32854. for (let prev of this.previous()) {
  32855. let from = this.toUrl(this.path(prev.file));
  32856. let root = prev.root || dirname(prev.file);
  32857. let map;
  32858. if (this.mapOpts.sourcesContent === false) {
  32859. map = new SourceMapConsumer$2(prev.text);
  32860. if (map.sourcesContent) {
  32861. map.sourcesContent = null;
  32862. }
  32863. } else {
  32864. map = prev.consumer();
  32865. }
  32866. this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
  32867. }
  32868. }
  32869. clearAnnotation() {
  32870. if (this.mapOpts.annotation === false) return
  32871. if (this.root) {
  32872. let node;
  32873. for (let i = this.root.nodes.length - 1; i >= 0; i--) {
  32874. node = this.root.nodes[i];
  32875. if (node.type !== 'comment') continue
  32876. if (node.text.indexOf('# sourceMappingURL=') === 0) {
  32877. this.root.removeChild(i);
  32878. }
  32879. }
  32880. } else if (this.css) {
  32881. this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, '');
  32882. }
  32883. }
  32884. generate() {
  32885. this.clearAnnotation();
  32886. if (pathAvailable && sourceMapAvailable && this.isMap()) {
  32887. return this.generateMap()
  32888. } else {
  32889. let result = '';
  32890. this.stringify(this.root, i => {
  32891. result += i;
  32892. });
  32893. return [result]
  32894. }
  32895. }
  32896. generateMap() {
  32897. if (this.root) {
  32898. this.generateString();
  32899. } else if (this.previous().length === 1) {
  32900. let prev = this.previous()[0].consumer();
  32901. prev.file = this.outputFile();
  32902. this.map = SourceMapGenerator$3.fromSourceMap(prev, {
  32903. ignoreInvalidMapping: true
  32904. });
  32905. } else {
  32906. this.map = new SourceMapGenerator$3({
  32907. file: this.outputFile(),
  32908. ignoreInvalidMapping: true
  32909. });
  32910. this.map.addMapping({
  32911. generated: { column: 0, line: 1 },
  32912. original: { column: 0, line: 1 },
  32913. source: this.opts.from
  32914. ? this.toUrl(this.path(this.opts.from))
  32915. : '<no source>'
  32916. });
  32917. }
  32918. if (this.isSourcesContent()) this.setSourcesContent();
  32919. if (this.root && this.previous().length > 0) this.applyPrevMaps();
  32920. if (this.isAnnotation()) this.addAnnotation();
  32921. if (this.isInline()) {
  32922. return [this.css]
  32923. } else {
  32924. return [this.css, this.map]
  32925. }
  32926. }
  32927. generateString() {
  32928. this.css = '';
  32929. this.map = new SourceMapGenerator$3({
  32930. file: this.outputFile(),
  32931. ignoreInvalidMapping: true
  32932. });
  32933. let line = 1;
  32934. let column = 1;
  32935. let noSource = '<no source>';
  32936. let mapping = {
  32937. generated: { column: 0, line: 0 },
  32938. original: { column: 0, line: 0 },
  32939. source: ''
  32940. };
  32941. let lines, last;
  32942. this.stringify(this.root, (str, node, type) => {
  32943. this.css += str;
  32944. if (node && type !== 'end') {
  32945. mapping.generated.line = line;
  32946. mapping.generated.column = column - 1;
  32947. if (node.source && node.source.start) {
  32948. mapping.source = this.sourcePath(node);
  32949. mapping.original.line = node.source.start.line;
  32950. mapping.original.column = node.source.start.column - 1;
  32951. this.map.addMapping(mapping);
  32952. } else {
  32953. mapping.source = noSource;
  32954. mapping.original.line = 1;
  32955. mapping.original.column = 0;
  32956. this.map.addMapping(mapping);
  32957. }
  32958. }
  32959. lines = str.match(/\n/g);
  32960. if (lines) {
  32961. line += lines.length;
  32962. last = str.lastIndexOf('\n');
  32963. column = str.length - last;
  32964. } else {
  32965. column += str.length;
  32966. }
  32967. if (node && type !== 'start') {
  32968. let p = node.parent || { raws: {} };
  32969. let childless =
  32970. node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
  32971. if (!childless || node !== p.last || p.raws.semicolon) {
  32972. if (node.source && node.source.end) {
  32973. mapping.source = this.sourcePath(node);
  32974. mapping.original.line = node.source.end.line;
  32975. mapping.original.column = node.source.end.column - 1;
  32976. mapping.generated.line = line;
  32977. mapping.generated.column = column - 2;
  32978. this.map.addMapping(mapping);
  32979. } else {
  32980. mapping.source = noSource;
  32981. mapping.original.line = 1;
  32982. mapping.original.column = 0;
  32983. mapping.generated.line = line;
  32984. mapping.generated.column = column - 1;
  32985. this.map.addMapping(mapping);
  32986. }
  32987. }
  32988. }
  32989. });
  32990. }
  32991. isAnnotation() {
  32992. if (this.isInline()) {
  32993. return true
  32994. }
  32995. if (typeof this.mapOpts.annotation !== 'undefined') {
  32996. return this.mapOpts.annotation
  32997. }
  32998. if (this.previous().length) {
  32999. return this.previous().some(i => i.annotation)
  33000. }
  33001. return true
  33002. }
  33003. isInline() {
  33004. if (typeof this.mapOpts.inline !== 'undefined') {
  33005. return this.mapOpts.inline
  33006. }
  33007. let annotation = this.mapOpts.annotation;
  33008. if (typeof annotation !== 'undefined' && annotation !== true) {
  33009. return false
  33010. }
  33011. if (this.previous().length) {
  33012. return this.previous().some(i => i.inline)
  33013. }
  33014. return true
  33015. }
  33016. isMap() {
  33017. if (typeof this.opts.map !== 'undefined') {
  33018. return !!this.opts.map
  33019. }
  33020. return this.previous().length > 0
  33021. }
  33022. isSourcesContent() {
  33023. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  33024. return this.mapOpts.sourcesContent
  33025. }
  33026. if (this.previous().length) {
  33027. return this.previous().some(i => i.withContent())
  33028. }
  33029. return true
  33030. }
  33031. outputFile() {
  33032. if (this.opts.to) {
  33033. return this.path(this.opts.to)
  33034. } else if (this.opts.from) {
  33035. return this.path(this.opts.from)
  33036. } else {
  33037. return 'to.css'
  33038. }
  33039. }
  33040. path(file) {
  33041. if (this.mapOpts.absolute) return file
  33042. if (file.charCodeAt(0) === 60 /* `<` */) return file
  33043. if (/^\w+:\/\//.test(file)) return file
  33044. let cached = this.memoizedPaths.get(file);
  33045. if (cached) return cached
  33046. let from = this.opts.to ? dirname(this.opts.to) : '.';
  33047. if (typeof this.mapOpts.annotation === 'string') {
  33048. from = dirname(resolve(from, this.mapOpts.annotation));
  33049. }
  33050. let path = relative(from, file);
  33051. this.memoizedPaths.set(file, path);
  33052. return path
  33053. }
  33054. previous() {
  33055. if (!this.previousMaps) {
  33056. this.previousMaps = [];
  33057. if (this.root) {
  33058. this.root.walk(node => {
  33059. if (node.source && node.source.input.map) {
  33060. let map = node.source.input.map;
  33061. if (!this.previousMaps.includes(map)) {
  33062. this.previousMaps.push(map);
  33063. }
  33064. }
  33065. });
  33066. } else {
  33067. let input = new Input$3(this.originalCSS, this.opts);
  33068. if (input.map) this.previousMaps.push(input.map);
  33069. }
  33070. }
  33071. return this.previousMaps
  33072. }
  33073. setSourcesContent() {
  33074. let already = {};
  33075. if (this.root) {
  33076. this.root.walk(node => {
  33077. if (node.source) {
  33078. let from = node.source.input.from;
  33079. if (from && !already[from]) {
  33080. already[from] = true;
  33081. let fromUrl = this.usesFileUrls
  33082. ? this.toFileUrl(from)
  33083. : this.toUrl(this.path(from));
  33084. this.map.setSourceContent(fromUrl, node.source.input.css);
  33085. }
  33086. }
  33087. });
  33088. } else if (this.css) {
  33089. let from = this.opts.from
  33090. ? this.toUrl(this.path(this.opts.from))
  33091. : '<no source>';
  33092. this.map.setSourceContent(from, this.css);
  33093. }
  33094. }
  33095. sourcePath(node) {
  33096. if (this.mapOpts.from) {
  33097. return this.toUrl(this.mapOpts.from)
  33098. } else if (this.usesFileUrls) {
  33099. return this.toFileUrl(node.source.input.from)
  33100. } else {
  33101. return this.toUrl(this.path(node.source.input.from))
  33102. }
  33103. }
  33104. toBase64(str) {
  33105. if (Buffer$1) {
  33106. return Buffer$1.from(str).toString('base64')
  33107. } else {
  33108. return window.btoa(unescape(encodeURIComponent(str)))
  33109. }
  33110. }
  33111. toFileUrl(path) {
  33112. let cached = this.memoizedFileURLs.get(path);
  33113. if (cached) return cached
  33114. if (pathToFileURL) {
  33115. let fileURL = pathToFileURL(path).toString();
  33116. this.memoizedFileURLs.set(path, fileURL);
  33117. return fileURL
  33118. } else {
  33119. throw new Error(
  33120. '`map.absolute` option is not available in this PostCSS build'
  33121. )
  33122. }
  33123. }
  33124. toUrl(path) {
  33125. let cached = this.memoizedURLs.get(path);
  33126. if (cached) return cached
  33127. if (sep === '\\') {
  33128. path = path.replace(/\\/g, '/');
  33129. }
  33130. let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
  33131. this.memoizedURLs.set(path, url);
  33132. return url
  33133. }
  33134. };
  33135. var mapGenerator = MapGenerator$2;
  33136. let Node$2 = node$2;
  33137. let Comment$4 = class Comment extends Node$2 {
  33138. constructor(defaults) {
  33139. super(defaults);
  33140. this.type = 'comment';
  33141. }
  33142. };
  33143. var comment$3 = Comment$4;
  33144. Comment$4.default = Comment$4;
  33145. let { isClean: isClean$1, my: my$1 } = symbols;
  33146. let Declaration$3 = declaration;
  33147. let Comment$3 = comment$3;
  33148. let Node$1 = node$2;
  33149. let parse$4, Rule$4, AtRule$4, Root$6;
  33150. function cleanSource(nodes) {
  33151. return nodes.map(i => {
  33152. if (i.nodes) i.nodes = cleanSource(i.nodes);
  33153. delete i.source;
  33154. return i
  33155. })
  33156. }
  33157. function markTreeDirty(node) {
  33158. node[isClean$1] = false;
  33159. if (node.proxyOf.nodes) {
  33160. for (let i of node.proxyOf.nodes) {
  33161. markTreeDirty(i);
  33162. }
  33163. }
  33164. }
  33165. let Container$7 = class Container extends Node$1 {
  33166. append(...children) {
  33167. for (let child of children) {
  33168. let nodes = this.normalize(child, this.last);
  33169. for (let node of nodes) this.proxyOf.nodes.push(node);
  33170. }
  33171. this.markDirty();
  33172. return this
  33173. }
  33174. cleanRaws(keepBetween) {
  33175. super.cleanRaws(keepBetween);
  33176. if (this.nodes) {
  33177. for (let node of this.nodes) node.cleanRaws(keepBetween);
  33178. }
  33179. }
  33180. each(callback) {
  33181. if (!this.proxyOf.nodes) return undefined
  33182. let iterator = this.getIterator();
  33183. let index, result;
  33184. while (this.indexes[iterator] < this.proxyOf.nodes.length) {
  33185. index = this.indexes[iterator];
  33186. result = callback(this.proxyOf.nodes[index], index);
  33187. if (result === false) break
  33188. this.indexes[iterator] += 1;
  33189. }
  33190. delete this.indexes[iterator];
  33191. return result
  33192. }
  33193. every(condition) {
  33194. return this.nodes.every(condition)
  33195. }
  33196. getIterator() {
  33197. if (!this.lastEach) this.lastEach = 0;
  33198. if (!this.indexes) this.indexes = {};
  33199. this.lastEach += 1;
  33200. let iterator = this.lastEach;
  33201. this.indexes[iterator] = 0;
  33202. return iterator
  33203. }
  33204. getProxyProcessor() {
  33205. return {
  33206. get(node, prop) {
  33207. if (prop === 'proxyOf') {
  33208. return node
  33209. } else if (!node[prop]) {
  33210. return node[prop]
  33211. } else if (
  33212. prop === 'each' ||
  33213. (typeof prop === 'string' && prop.startsWith('walk'))
  33214. ) {
  33215. return (...args) => {
  33216. return node[prop](
  33217. ...args.map(i => {
  33218. if (typeof i === 'function') {
  33219. return (child, index) => i(child.toProxy(), index)
  33220. } else {
  33221. return i
  33222. }
  33223. })
  33224. )
  33225. }
  33226. } else if (prop === 'every' || prop === 'some') {
  33227. return cb => {
  33228. return node[prop]((child, ...other) =>
  33229. cb(child.toProxy(), ...other)
  33230. )
  33231. }
  33232. } else if (prop === 'root') {
  33233. return () => node.root().toProxy()
  33234. } else if (prop === 'nodes') {
  33235. return node.nodes.map(i => i.toProxy())
  33236. } else if (prop === 'first' || prop === 'last') {
  33237. return node[prop].toProxy()
  33238. } else {
  33239. return node[prop]
  33240. }
  33241. },
  33242. set(node, prop, value) {
  33243. if (node[prop] === value) return true
  33244. node[prop] = value;
  33245. if (prop === 'name' || prop === 'params' || prop === 'selector') {
  33246. node.markDirty();
  33247. }
  33248. return true
  33249. }
  33250. }
  33251. }
  33252. index(child) {
  33253. if (typeof child === 'number') return child
  33254. if (child.proxyOf) child = child.proxyOf;
  33255. return this.proxyOf.nodes.indexOf(child)
  33256. }
  33257. insertAfter(exist, add) {
  33258. let existIndex = this.index(exist);
  33259. let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
  33260. existIndex = this.index(exist);
  33261. for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
  33262. let index;
  33263. for (let id in this.indexes) {
  33264. index = this.indexes[id];
  33265. if (existIndex < index) {
  33266. this.indexes[id] = index + nodes.length;
  33267. }
  33268. }
  33269. this.markDirty();
  33270. return this
  33271. }
  33272. insertBefore(exist, add) {
  33273. let existIndex = this.index(exist);
  33274. let type = existIndex === 0 ? 'prepend' : false;
  33275. let nodes = this.normalize(
  33276. add,
  33277. this.proxyOf.nodes[existIndex],
  33278. type
  33279. ).reverse();
  33280. existIndex = this.index(exist);
  33281. for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
  33282. let index;
  33283. for (let id in this.indexes) {
  33284. index = this.indexes[id];
  33285. if (existIndex <= index) {
  33286. this.indexes[id] = index + nodes.length;
  33287. }
  33288. }
  33289. this.markDirty();
  33290. return this
  33291. }
  33292. normalize(nodes, sample) {
  33293. if (typeof nodes === 'string') {
  33294. nodes = cleanSource(parse$4(nodes).nodes);
  33295. } else if (typeof nodes === 'undefined') {
  33296. nodes = [];
  33297. } else if (Array.isArray(nodes)) {
  33298. nodes = nodes.slice(0);
  33299. for (let i of nodes) {
  33300. if (i.parent) i.parent.removeChild(i, 'ignore');
  33301. }
  33302. } else if (nodes.type === 'root' && this.type !== 'document') {
  33303. nodes = nodes.nodes.slice(0);
  33304. for (let i of nodes) {
  33305. if (i.parent) i.parent.removeChild(i, 'ignore');
  33306. }
  33307. } else if (nodes.type) {
  33308. nodes = [nodes];
  33309. } else if (nodes.prop) {
  33310. if (typeof nodes.value === 'undefined') {
  33311. throw new Error('Value field is missed in node creation')
  33312. } else if (typeof nodes.value !== 'string') {
  33313. nodes.value = String(nodes.value);
  33314. }
  33315. nodes = [new Declaration$3(nodes)];
  33316. } else if (nodes.selector) {
  33317. nodes = [new Rule$4(nodes)];
  33318. } else if (nodes.name) {
  33319. nodes = [new AtRule$4(nodes)];
  33320. } else if (nodes.text) {
  33321. nodes = [new Comment$3(nodes)];
  33322. } else {
  33323. throw new Error('Unknown node type in node creation')
  33324. }
  33325. let processed = nodes.map(i => {
  33326. /* c8 ignore next */
  33327. if (!i[my$1]) Container.rebuild(i);
  33328. i = i.proxyOf;
  33329. if (i.parent) i.parent.removeChild(i);
  33330. if (i[isClean$1]) markTreeDirty(i);
  33331. if (typeof i.raws.before === 'undefined') {
  33332. if (sample && typeof sample.raws.before !== 'undefined') {
  33333. i.raws.before = sample.raws.before.replace(/\S/g, '');
  33334. }
  33335. }
  33336. i.parent = this.proxyOf;
  33337. return i
  33338. });
  33339. return processed
  33340. }
  33341. prepend(...children) {
  33342. children = children.reverse();
  33343. for (let child of children) {
  33344. let nodes = this.normalize(child, this.first, 'prepend').reverse();
  33345. for (let node of nodes) this.proxyOf.nodes.unshift(node);
  33346. for (let id in this.indexes) {
  33347. this.indexes[id] = this.indexes[id] + nodes.length;
  33348. }
  33349. }
  33350. this.markDirty();
  33351. return this
  33352. }
  33353. push(child) {
  33354. child.parent = this;
  33355. this.proxyOf.nodes.push(child);
  33356. return this
  33357. }
  33358. removeAll() {
  33359. for (let node of this.proxyOf.nodes) node.parent = undefined;
  33360. this.proxyOf.nodes = [];
  33361. this.markDirty();
  33362. return this
  33363. }
  33364. removeChild(child) {
  33365. child = this.index(child);
  33366. this.proxyOf.nodes[child].parent = undefined;
  33367. this.proxyOf.nodes.splice(child, 1);
  33368. let index;
  33369. for (let id in this.indexes) {
  33370. index = this.indexes[id];
  33371. if (index >= child) {
  33372. this.indexes[id] = index - 1;
  33373. }
  33374. }
  33375. this.markDirty();
  33376. return this
  33377. }
  33378. replaceValues(pattern, opts, callback) {
  33379. if (!callback) {
  33380. callback = opts;
  33381. opts = {};
  33382. }
  33383. this.walkDecls(decl => {
  33384. if (opts.props && !opts.props.includes(decl.prop)) return
  33385. if (opts.fast && !decl.value.includes(opts.fast)) return
  33386. decl.value = decl.value.replace(pattern, callback);
  33387. });
  33388. this.markDirty();
  33389. return this
  33390. }
  33391. some(condition) {
  33392. return this.nodes.some(condition)
  33393. }
  33394. walk(callback) {
  33395. return this.each((child, i) => {
  33396. let result;
  33397. try {
  33398. result = callback(child, i);
  33399. } catch (e) {
  33400. throw child.addToError(e)
  33401. }
  33402. if (result !== false && child.walk) {
  33403. result = child.walk(callback);
  33404. }
  33405. return result
  33406. })
  33407. }
  33408. walkAtRules(name, callback) {
  33409. if (!callback) {
  33410. callback = name;
  33411. return this.walk((child, i) => {
  33412. if (child.type === 'atrule') {
  33413. return callback(child, i)
  33414. }
  33415. })
  33416. }
  33417. if (name instanceof RegExp) {
  33418. return this.walk((child, i) => {
  33419. if (child.type === 'atrule' && name.test(child.name)) {
  33420. return callback(child, i)
  33421. }
  33422. })
  33423. }
  33424. return this.walk((child, i) => {
  33425. if (child.type === 'atrule' && child.name === name) {
  33426. return callback(child, i)
  33427. }
  33428. })
  33429. }
  33430. walkComments(callback) {
  33431. return this.walk((child, i) => {
  33432. if (child.type === 'comment') {
  33433. return callback(child, i)
  33434. }
  33435. })
  33436. }
  33437. walkDecls(prop, callback) {
  33438. if (!callback) {
  33439. callback = prop;
  33440. return this.walk((child, i) => {
  33441. if (child.type === 'decl') {
  33442. return callback(child, i)
  33443. }
  33444. })
  33445. }
  33446. if (prop instanceof RegExp) {
  33447. return this.walk((child, i) => {
  33448. if (child.type === 'decl' && prop.test(child.prop)) {
  33449. return callback(child, i)
  33450. }
  33451. })
  33452. }
  33453. return this.walk((child, i) => {
  33454. if (child.type === 'decl' && child.prop === prop) {
  33455. return callback(child, i)
  33456. }
  33457. })
  33458. }
  33459. walkRules(selector, callback) {
  33460. if (!callback) {
  33461. callback = selector;
  33462. return this.walk((child, i) => {
  33463. if (child.type === 'rule') {
  33464. return callback(child, i)
  33465. }
  33466. })
  33467. }
  33468. if (selector instanceof RegExp) {
  33469. return this.walk((child, i) => {
  33470. if (child.type === 'rule' && selector.test(child.selector)) {
  33471. return callback(child, i)
  33472. }
  33473. })
  33474. }
  33475. return this.walk((child, i) => {
  33476. if (child.type === 'rule' && child.selector === selector) {
  33477. return callback(child, i)
  33478. }
  33479. })
  33480. }
  33481. get first() {
  33482. if (!this.proxyOf.nodes) return undefined
  33483. return this.proxyOf.nodes[0]
  33484. }
  33485. get last() {
  33486. if (!this.proxyOf.nodes) return undefined
  33487. return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
  33488. }
  33489. };
  33490. Container$7.registerParse = dependant => {
  33491. parse$4 = dependant;
  33492. };
  33493. Container$7.registerRule = dependant => {
  33494. Rule$4 = dependant;
  33495. };
  33496. Container$7.registerAtRule = dependant => {
  33497. AtRule$4 = dependant;
  33498. };
  33499. Container$7.registerRoot = dependant => {
  33500. Root$6 = dependant;
  33501. };
  33502. var container$1 = Container$7;
  33503. Container$7.default = Container$7;
  33504. /* c8 ignore start */
  33505. Container$7.rebuild = node => {
  33506. if (node.type === 'atrule') {
  33507. Object.setPrototypeOf(node, AtRule$4.prototype);
  33508. } else if (node.type === 'rule') {
  33509. Object.setPrototypeOf(node, Rule$4.prototype);
  33510. } else if (node.type === 'decl') {
  33511. Object.setPrototypeOf(node, Declaration$3.prototype);
  33512. } else if (node.type === 'comment') {
  33513. Object.setPrototypeOf(node, Comment$3.prototype);
  33514. } else if (node.type === 'root') {
  33515. Object.setPrototypeOf(node, Root$6.prototype);
  33516. }
  33517. node[my$1] = true;
  33518. if (node.nodes) {
  33519. node.nodes.forEach(child => {
  33520. Container$7.rebuild(child);
  33521. });
  33522. }
  33523. };
  33524. let Container$6 = container$1;
  33525. let LazyResult$4, Processor$3;
  33526. let Document$3 = class Document extends Container$6 {
  33527. constructor(defaults) {
  33528. // type needs to be passed to super, otherwise child roots won't be normalized correctly
  33529. super({ type: 'document', ...defaults });
  33530. if (!this.nodes) {
  33531. this.nodes = [];
  33532. }
  33533. }
  33534. toResult(opts = {}) {
  33535. let lazy = new LazyResult$4(new Processor$3(), this, opts);
  33536. return lazy.stringify()
  33537. }
  33538. };
  33539. Document$3.registerLazyResult = dependant => {
  33540. LazyResult$4 = dependant;
  33541. };
  33542. Document$3.registerProcessor = dependant => {
  33543. Processor$3 = dependant;
  33544. };
  33545. var document = Document$3;
  33546. Document$3.default = Document$3;
  33547. /* eslint-disable no-console */
  33548. let printed = {};
  33549. var warnOnce$2 = function warnOnce(message) {
  33550. if (printed[message]) return
  33551. printed[message] = true;
  33552. if (typeof console !== 'undefined' && console.warn) {
  33553. console.warn(message);
  33554. }
  33555. };
  33556. let Warning$2 = class Warning {
  33557. constructor(text, opts = {}) {
  33558. this.type = 'warning';
  33559. this.text = text;
  33560. if (opts.node && opts.node.source) {
  33561. let range = opts.node.rangeBy(opts);
  33562. this.line = range.start.line;
  33563. this.column = range.start.column;
  33564. this.endLine = range.end.line;
  33565. this.endColumn = range.end.column;
  33566. }
  33567. for (let opt in opts) this[opt] = opts[opt];
  33568. }
  33569. toString() {
  33570. if (this.node) {
  33571. return this.node.error(this.text, {
  33572. index: this.index,
  33573. plugin: this.plugin,
  33574. word: this.word
  33575. }).message
  33576. }
  33577. if (this.plugin) {
  33578. return this.plugin + ': ' + this.text
  33579. }
  33580. return this.text
  33581. }
  33582. };
  33583. var warning = Warning$2;
  33584. Warning$2.default = Warning$2;
  33585. let Warning$1 = warning;
  33586. let Result$3 = class Result {
  33587. constructor(processor, root, opts) {
  33588. this.processor = processor;
  33589. this.messages = [];
  33590. this.root = root;
  33591. this.opts = opts;
  33592. this.css = undefined;
  33593. this.map = undefined;
  33594. }
  33595. toString() {
  33596. return this.css
  33597. }
  33598. warn(text, opts = {}) {
  33599. if (!opts.plugin) {
  33600. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  33601. opts.plugin = this.lastPlugin.postcssPlugin;
  33602. }
  33603. }
  33604. let warning = new Warning$1(text, opts);
  33605. this.messages.push(warning);
  33606. return warning
  33607. }
  33608. warnings() {
  33609. return this.messages.filter(i => i.type === 'warning')
  33610. }
  33611. get content() {
  33612. return this.css
  33613. }
  33614. };
  33615. var result = Result$3;
  33616. Result$3.default = Result$3;
  33617. let Container$5 = container$1;
  33618. let AtRule$3 = class AtRule extends Container$5 {
  33619. constructor(defaults) {
  33620. super(defaults);
  33621. this.type = 'atrule';
  33622. }
  33623. append(...children) {
  33624. if (!this.proxyOf.nodes) this.nodes = [];
  33625. return super.append(...children)
  33626. }
  33627. prepend(...children) {
  33628. if (!this.proxyOf.nodes) this.nodes = [];
  33629. return super.prepend(...children)
  33630. }
  33631. };
  33632. var atRule = AtRule$3;
  33633. AtRule$3.default = AtRule$3;
  33634. Container$5.registerAtRule(AtRule$3);
  33635. let Container$4 = container$1;
  33636. let LazyResult$3, Processor$2;
  33637. let Root$5 = class Root extends Container$4 {
  33638. constructor(defaults) {
  33639. super(defaults);
  33640. this.type = 'root';
  33641. if (!this.nodes) this.nodes = [];
  33642. }
  33643. normalize(child, sample, type) {
  33644. let nodes = super.normalize(child);
  33645. if (sample) {
  33646. if (type === 'prepend') {
  33647. if (this.nodes.length > 1) {
  33648. sample.raws.before = this.nodes[1].raws.before;
  33649. } else {
  33650. delete sample.raws.before;
  33651. }
  33652. } else if (this.first !== sample) {
  33653. for (let node of nodes) {
  33654. node.raws.before = sample.raws.before;
  33655. }
  33656. }
  33657. }
  33658. return nodes
  33659. }
  33660. removeChild(child, ignore) {
  33661. let index = this.index(child);
  33662. if (!ignore && index === 0 && this.nodes.length > 1) {
  33663. this.nodes[1].raws.before = this.nodes[index].raws.before;
  33664. }
  33665. return super.removeChild(child)
  33666. }
  33667. toResult(opts = {}) {
  33668. let lazy = new LazyResult$3(new Processor$2(), this, opts);
  33669. return lazy.stringify()
  33670. }
  33671. };
  33672. Root$5.registerLazyResult = dependant => {
  33673. LazyResult$3 = dependant;
  33674. };
  33675. Root$5.registerProcessor = dependant => {
  33676. Processor$2 = dependant;
  33677. };
  33678. var root$2 = Root$5;
  33679. Root$5.default = Root$5;
  33680. Container$4.registerRoot(Root$5);
  33681. let list$2 = {
  33682. comma(string) {
  33683. return list$2.split(string, [','], true)
  33684. },
  33685. space(string) {
  33686. let spaces = [' ', '\n', '\t'];
  33687. return list$2.split(string, spaces)
  33688. },
  33689. split(string, separators, last) {
  33690. let array = [];
  33691. let current = '';
  33692. let split = false;
  33693. let func = 0;
  33694. let inQuote = false;
  33695. let prevQuote = '';
  33696. let escape = false;
  33697. for (let letter of string) {
  33698. if (escape) {
  33699. escape = false;
  33700. } else if (letter === '\\') {
  33701. escape = true;
  33702. } else if (inQuote) {
  33703. if (letter === prevQuote) {
  33704. inQuote = false;
  33705. }
  33706. } else if (letter === '"' || letter === "'") {
  33707. inQuote = true;
  33708. prevQuote = letter;
  33709. } else if (letter === '(') {
  33710. func += 1;
  33711. } else if (letter === ')') {
  33712. if (func > 0) func -= 1;
  33713. } else if (func === 0) {
  33714. if (separators.includes(letter)) split = true;
  33715. }
  33716. if (split) {
  33717. if (current !== '') array.push(current.trim());
  33718. current = '';
  33719. split = false;
  33720. } else {
  33721. current += letter;
  33722. }
  33723. }
  33724. if (last || current !== '') array.push(current.trim());
  33725. return array
  33726. }
  33727. };
  33728. var list_1 = list$2;
  33729. list$2.default = list$2;
  33730. let Container$3 = container$1;
  33731. let list$1 = list_1;
  33732. let Rule$3 = class Rule extends Container$3 {
  33733. constructor(defaults) {
  33734. super(defaults);
  33735. this.type = 'rule';
  33736. if (!this.nodes) this.nodes = [];
  33737. }
  33738. get selectors() {
  33739. return list$1.comma(this.selector)
  33740. }
  33741. set selectors(values) {
  33742. let match = this.selector ? this.selector.match(/,\s*/) : null;
  33743. let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  33744. this.selector = values.join(sep);
  33745. }
  33746. };
  33747. var rule = Rule$3;
  33748. Rule$3.default = Rule$3;
  33749. Container$3.registerRule(Rule$3);
  33750. let Declaration$2 = declaration;
  33751. let tokenizer = tokenize$1;
  33752. let Comment$2 = comment$3;
  33753. let AtRule$2 = atRule;
  33754. let Root$4 = root$2;
  33755. let Rule$2 = rule;
  33756. const SAFE_COMMENT_NEIGHBOR = {
  33757. empty: true,
  33758. space: true
  33759. };
  33760. function findLastWithPosition(tokens) {
  33761. for (let i = tokens.length - 1; i >= 0; i--) {
  33762. let token = tokens[i];
  33763. let pos = token[3] || token[2];
  33764. if (pos) return pos
  33765. }
  33766. }
  33767. let Parser$1 = class Parser {
  33768. constructor(input) {
  33769. this.input = input;
  33770. this.root = new Root$4();
  33771. this.current = this.root;
  33772. this.spaces = '';
  33773. this.semicolon = false;
  33774. this.createTokenizer();
  33775. this.root.source = { input, start: { column: 1, line: 1, offset: 0 } };
  33776. }
  33777. atrule(token) {
  33778. let node = new AtRule$2();
  33779. node.name = token[1].slice(1);
  33780. if (node.name === '') {
  33781. this.unnamedAtrule(node, token);
  33782. }
  33783. this.init(node, token[2]);
  33784. let type;
  33785. let prev;
  33786. let shift;
  33787. let last = false;
  33788. let open = false;
  33789. let params = [];
  33790. let brackets = [];
  33791. while (!this.tokenizer.endOfFile()) {
  33792. token = this.tokenizer.nextToken();
  33793. type = token[0];
  33794. if (type === '(' || type === '[') {
  33795. brackets.push(type === '(' ? ')' : ']');
  33796. } else if (type === '{' && brackets.length > 0) {
  33797. brackets.push('}');
  33798. } else if (type === brackets[brackets.length - 1]) {
  33799. brackets.pop();
  33800. }
  33801. if (brackets.length === 0) {
  33802. if (type === ';') {
  33803. node.source.end = this.getPosition(token[2]);
  33804. node.source.end.offset++;
  33805. this.semicolon = true;
  33806. break
  33807. } else if (type === '{') {
  33808. open = true;
  33809. break
  33810. } else if (type === '}') {
  33811. if (params.length > 0) {
  33812. shift = params.length - 1;
  33813. prev = params[shift];
  33814. while (prev && prev[0] === 'space') {
  33815. prev = params[--shift];
  33816. }
  33817. if (prev) {
  33818. node.source.end = this.getPosition(prev[3] || prev[2]);
  33819. node.source.end.offset++;
  33820. }
  33821. }
  33822. this.end(token);
  33823. break
  33824. } else {
  33825. params.push(token);
  33826. }
  33827. } else {
  33828. params.push(token);
  33829. }
  33830. if (this.tokenizer.endOfFile()) {
  33831. last = true;
  33832. break
  33833. }
  33834. }
  33835. node.raws.between = this.spacesAndCommentsFromEnd(params);
  33836. if (params.length) {
  33837. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  33838. this.raw(node, 'params', params);
  33839. if (last) {
  33840. token = params[params.length - 1];
  33841. node.source.end = this.getPosition(token[3] || token[2]);
  33842. node.source.end.offset++;
  33843. this.spaces = node.raws.between;
  33844. node.raws.between = '';
  33845. }
  33846. } else {
  33847. node.raws.afterName = '';
  33848. node.params = '';
  33849. }
  33850. if (open) {
  33851. node.nodes = [];
  33852. this.current = node;
  33853. }
  33854. }
  33855. checkMissedSemicolon(tokens) {
  33856. let colon = this.colon(tokens);
  33857. if (colon === false) return
  33858. let founded = 0;
  33859. let token;
  33860. for (let j = colon - 1; j >= 0; j--) {
  33861. token = tokens[j];
  33862. if (token[0] !== 'space') {
  33863. founded += 1;
  33864. if (founded === 2) break
  33865. }
  33866. }
  33867. // If the token is a word, e.g. `!important`, `red` or any other valid property's value.
  33868. // Then we need to return the colon after that word token. [3] is the "end" colon of that word.
  33869. // And because we need it after that one we do +1 to get the next one.
  33870. throw this.input.error(
  33871. 'Missed semicolon',
  33872. token[0] === 'word' ? token[3] + 1 : token[2]
  33873. )
  33874. }
  33875. colon(tokens) {
  33876. let brackets = 0;
  33877. let token, type, prev;
  33878. for (let [i, element] of tokens.entries()) {
  33879. token = element;
  33880. type = token[0];
  33881. if (type === '(') {
  33882. brackets += 1;
  33883. }
  33884. if (type === ')') {
  33885. brackets -= 1;
  33886. }
  33887. if (brackets === 0 && type === ':') {
  33888. if (!prev) {
  33889. this.doubleColon(token);
  33890. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  33891. continue
  33892. } else {
  33893. return i
  33894. }
  33895. }
  33896. prev = token;
  33897. }
  33898. return false
  33899. }
  33900. comment(token) {
  33901. let node = new Comment$2();
  33902. this.init(node, token[2]);
  33903. node.source.end = this.getPosition(token[3] || token[2]);
  33904. node.source.end.offset++;
  33905. let text = token[1].slice(2, -2);
  33906. if (/^\s*$/.test(text)) {
  33907. node.text = '';
  33908. node.raws.left = text;
  33909. node.raws.right = '';
  33910. } else {
  33911. let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
  33912. node.text = match[2];
  33913. node.raws.left = match[1];
  33914. node.raws.right = match[3];
  33915. }
  33916. }
  33917. createTokenizer() {
  33918. this.tokenizer = tokenizer(this.input);
  33919. }
  33920. decl(tokens, customProperty) {
  33921. let node = new Declaration$2();
  33922. this.init(node, tokens[0][2]);
  33923. let last = tokens[tokens.length - 1];
  33924. if (last[0] === ';') {
  33925. this.semicolon = true;
  33926. tokens.pop();
  33927. }
  33928. node.source.end = this.getPosition(
  33929. last[3] || last[2] || findLastWithPosition(tokens)
  33930. );
  33931. node.source.end.offset++;
  33932. while (tokens[0][0] !== 'word') {
  33933. if (tokens.length === 1) this.unknownWord(tokens);
  33934. node.raws.before += tokens.shift()[1];
  33935. }
  33936. node.source.start = this.getPosition(tokens[0][2]);
  33937. node.prop = '';
  33938. while (tokens.length) {
  33939. let type = tokens[0][0];
  33940. if (type === ':' || type === 'space' || type === 'comment') {
  33941. break
  33942. }
  33943. node.prop += tokens.shift()[1];
  33944. }
  33945. node.raws.between = '';
  33946. let token;
  33947. while (tokens.length) {
  33948. token = tokens.shift();
  33949. if (token[0] === ':') {
  33950. node.raws.between += token[1];
  33951. break
  33952. } else {
  33953. if (token[0] === 'word' && /\w/.test(token[1])) {
  33954. this.unknownWord([token]);
  33955. }
  33956. node.raws.between += token[1];
  33957. }
  33958. }
  33959. if (node.prop[0] === '_' || node.prop[0] === '*') {
  33960. node.raws.before += node.prop[0];
  33961. node.prop = node.prop.slice(1);
  33962. }
  33963. let firstSpaces = [];
  33964. let next;
  33965. while (tokens.length) {
  33966. next = tokens[0][0];
  33967. if (next !== 'space' && next !== 'comment') break
  33968. firstSpaces.push(tokens.shift());
  33969. }
  33970. this.precheckMissedSemicolon(tokens);
  33971. for (let i = tokens.length - 1; i >= 0; i--) {
  33972. token = tokens[i];
  33973. if (token[1].toLowerCase() === '!important') {
  33974. node.important = true;
  33975. let string = this.stringFrom(tokens, i);
  33976. string = this.spacesFromEnd(tokens) + string;
  33977. if (string !== ' !important') node.raws.important = string;
  33978. break
  33979. } else if (token[1].toLowerCase() === 'important') {
  33980. let cache = tokens.slice(0);
  33981. let str = '';
  33982. for (let j = i; j > 0; j--) {
  33983. let type = cache[j][0];
  33984. if (str.trim().indexOf('!') === 0 && type !== 'space') {
  33985. break
  33986. }
  33987. str = cache.pop()[1] + str;
  33988. }
  33989. if (str.trim().indexOf('!') === 0) {
  33990. node.important = true;
  33991. node.raws.important = str;
  33992. tokens = cache;
  33993. }
  33994. }
  33995. if (token[0] !== 'space' && token[0] !== 'comment') {
  33996. break
  33997. }
  33998. }
  33999. let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment');
  34000. if (hasWord) {
  34001. node.raws.between += firstSpaces.map(i => i[1]).join('');
  34002. firstSpaces = [];
  34003. }
  34004. this.raw(node, 'value', firstSpaces.concat(tokens), customProperty);
  34005. if (node.value.includes(':') && !customProperty) {
  34006. this.checkMissedSemicolon(tokens);
  34007. }
  34008. }
  34009. doubleColon(token) {
  34010. throw this.input.error(
  34011. 'Double colon',
  34012. { offset: token[2] },
  34013. { offset: token[2] + token[1].length }
  34014. )
  34015. }
  34016. emptyRule(token) {
  34017. let node = new Rule$2();
  34018. this.init(node, token[2]);
  34019. node.selector = '';
  34020. node.raws.between = '';
  34021. this.current = node;
  34022. }
  34023. end(token) {
  34024. if (this.current.nodes && this.current.nodes.length) {
  34025. this.current.raws.semicolon = this.semicolon;
  34026. }
  34027. this.semicolon = false;
  34028. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  34029. this.spaces = '';
  34030. if (this.current.parent) {
  34031. this.current.source.end = this.getPosition(token[2]);
  34032. this.current.source.end.offset++;
  34033. this.current = this.current.parent;
  34034. } else {
  34035. this.unexpectedClose(token);
  34036. }
  34037. }
  34038. endFile() {
  34039. if (this.current.parent) this.unclosedBlock();
  34040. if (this.current.nodes && this.current.nodes.length) {
  34041. this.current.raws.semicolon = this.semicolon;
  34042. }
  34043. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  34044. this.root.source.end = this.getPosition(this.tokenizer.position());
  34045. }
  34046. freeSemicolon(token) {
  34047. this.spaces += token[1];
  34048. if (this.current.nodes) {
  34049. let prev = this.current.nodes[this.current.nodes.length - 1];
  34050. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  34051. prev.raws.ownSemicolon = this.spaces;
  34052. this.spaces = '';
  34053. }
  34054. }
  34055. }
  34056. // Helpers
  34057. getPosition(offset) {
  34058. let pos = this.input.fromOffset(offset);
  34059. return {
  34060. column: pos.col,
  34061. line: pos.line,
  34062. offset
  34063. }
  34064. }
  34065. init(node, offset) {
  34066. this.current.push(node);
  34067. node.source = {
  34068. input: this.input,
  34069. start: this.getPosition(offset)
  34070. };
  34071. node.raws.before = this.spaces;
  34072. this.spaces = '';
  34073. if (node.type !== 'comment') this.semicolon = false;
  34074. }
  34075. other(start) {
  34076. let end = false;
  34077. let type = null;
  34078. let colon = false;
  34079. let bracket = null;
  34080. let brackets = [];
  34081. let customProperty = start[1].startsWith('--');
  34082. let tokens = [];
  34083. let token = start;
  34084. while (token) {
  34085. type = token[0];
  34086. tokens.push(token);
  34087. if (type === '(' || type === '[') {
  34088. if (!bracket) bracket = token;
  34089. brackets.push(type === '(' ? ')' : ']');
  34090. } else if (customProperty && colon && type === '{') {
  34091. if (!bracket) bracket = token;
  34092. brackets.push('}');
  34093. } else if (brackets.length === 0) {
  34094. if (type === ';') {
  34095. if (colon) {
  34096. this.decl(tokens, customProperty);
  34097. return
  34098. } else {
  34099. break
  34100. }
  34101. } else if (type === '{') {
  34102. this.rule(tokens);
  34103. return
  34104. } else if (type === '}') {
  34105. this.tokenizer.back(tokens.pop());
  34106. end = true;
  34107. break
  34108. } else if (type === ':') {
  34109. colon = true;
  34110. }
  34111. } else if (type === brackets[brackets.length - 1]) {
  34112. brackets.pop();
  34113. if (brackets.length === 0) bracket = null;
  34114. }
  34115. token = this.tokenizer.nextToken();
  34116. }
  34117. if (this.tokenizer.endOfFile()) end = true;
  34118. if (brackets.length > 0) this.unclosedBracket(bracket);
  34119. if (end && colon) {
  34120. if (!customProperty) {
  34121. while (tokens.length) {
  34122. token = tokens[tokens.length - 1][0];
  34123. if (token !== 'space' && token !== 'comment') break
  34124. this.tokenizer.back(tokens.pop());
  34125. }
  34126. }
  34127. this.decl(tokens, customProperty);
  34128. } else {
  34129. this.unknownWord(tokens);
  34130. }
  34131. }
  34132. parse() {
  34133. let token;
  34134. while (!this.tokenizer.endOfFile()) {
  34135. token = this.tokenizer.nextToken();
  34136. switch (token[0]) {
  34137. case 'space':
  34138. this.spaces += token[1];
  34139. break
  34140. case ';':
  34141. this.freeSemicolon(token);
  34142. break
  34143. case '}':
  34144. this.end(token);
  34145. break
  34146. case 'comment':
  34147. this.comment(token);
  34148. break
  34149. case 'at-word':
  34150. this.atrule(token);
  34151. break
  34152. case '{':
  34153. this.emptyRule(token);
  34154. break
  34155. default:
  34156. this.other(token);
  34157. break
  34158. }
  34159. }
  34160. this.endFile();
  34161. }
  34162. precheckMissedSemicolon(/* tokens */) {
  34163. // Hook for Safe Parser
  34164. }
  34165. raw(node, prop, tokens, customProperty) {
  34166. let token, type;
  34167. let length = tokens.length;
  34168. let value = '';
  34169. let clean = true;
  34170. let next, prev;
  34171. for (let i = 0; i < length; i += 1) {
  34172. token = tokens[i];
  34173. type = token[0];
  34174. if (type === 'space' && i === length - 1 && !customProperty) {
  34175. clean = false;
  34176. } else if (type === 'comment') {
  34177. prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty';
  34178. next = tokens[i + 1] ? tokens[i + 1][0] : 'empty';
  34179. if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
  34180. if (value.slice(-1) === ',') {
  34181. clean = false;
  34182. } else {
  34183. value += token[1];
  34184. }
  34185. } else {
  34186. clean = false;
  34187. }
  34188. } else {
  34189. value += token[1];
  34190. }
  34191. }
  34192. if (!clean) {
  34193. let raw = tokens.reduce((all, i) => all + i[1], '');
  34194. node.raws[prop] = { raw, value };
  34195. }
  34196. node[prop] = value;
  34197. }
  34198. rule(tokens) {
  34199. tokens.pop();
  34200. let node = new Rule$2();
  34201. this.init(node, tokens[0][2]);
  34202. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  34203. this.raw(node, 'selector', tokens);
  34204. this.current = node;
  34205. }
  34206. spacesAndCommentsFromEnd(tokens) {
  34207. let lastTokenType;
  34208. let spaces = '';
  34209. while (tokens.length) {
  34210. lastTokenType = tokens[tokens.length - 1][0];
  34211. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break
  34212. spaces = tokens.pop()[1] + spaces;
  34213. }
  34214. return spaces
  34215. }
  34216. // Errors
  34217. spacesAndCommentsFromStart(tokens) {
  34218. let next;
  34219. let spaces = '';
  34220. while (tokens.length) {
  34221. next = tokens[0][0];
  34222. if (next !== 'space' && next !== 'comment') break
  34223. spaces += tokens.shift()[1];
  34224. }
  34225. return spaces
  34226. }
  34227. spacesFromEnd(tokens) {
  34228. let lastTokenType;
  34229. let spaces = '';
  34230. while (tokens.length) {
  34231. lastTokenType = tokens[tokens.length - 1][0];
  34232. if (lastTokenType !== 'space') break
  34233. spaces = tokens.pop()[1] + spaces;
  34234. }
  34235. return spaces
  34236. }
  34237. stringFrom(tokens, from) {
  34238. let result = '';
  34239. for (let i = from; i < tokens.length; i++) {
  34240. result += tokens[i][1];
  34241. }
  34242. tokens.splice(from, tokens.length - from);
  34243. return result
  34244. }
  34245. unclosedBlock() {
  34246. let pos = this.current.source.start;
  34247. throw this.input.error('Unclosed block', pos.line, pos.column)
  34248. }
  34249. unclosedBracket(bracket) {
  34250. throw this.input.error(
  34251. 'Unclosed bracket',
  34252. { offset: bracket[2] },
  34253. { offset: bracket[2] + 1 }
  34254. )
  34255. }
  34256. unexpectedClose(token) {
  34257. throw this.input.error(
  34258. 'Unexpected }',
  34259. { offset: token[2] },
  34260. { offset: token[2] + 1 }
  34261. )
  34262. }
  34263. unknownWord(tokens) {
  34264. throw this.input.error(
  34265. 'Unknown word',
  34266. { offset: tokens[0][2] },
  34267. { offset: tokens[0][2] + tokens[0][1].length }
  34268. )
  34269. }
  34270. unnamedAtrule(node, token) {
  34271. throw this.input.error(
  34272. 'At-rule without name',
  34273. { offset: token[2] },
  34274. { offset: token[2] + token[1].length }
  34275. )
  34276. }
  34277. };
  34278. var parser$1 = Parser$1;
  34279. let Container$2 = container$1;
  34280. let Parser = parser$1;
  34281. let Input$2 = input;
  34282. function parse$3(css, opts) {
  34283. let input = new Input$2(css, opts);
  34284. let parser = new Parser(input);
  34285. try {
  34286. parser.parse();
  34287. } catch (e) {
  34288. if (browser$1.env.NODE_ENV !== 'production') {
  34289. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  34290. if (/\.scss$/i.test(opts.from)) {
  34291. e.message +=
  34292. '\nYou tried to parse SCSS with ' +
  34293. 'the standard CSS parser; ' +
  34294. 'try again with the postcss-scss parser';
  34295. } else if (/\.sass/i.test(opts.from)) {
  34296. e.message +=
  34297. '\nYou tried to parse Sass with ' +
  34298. 'the standard CSS parser; ' +
  34299. 'try again with the postcss-sass parser';
  34300. } else if (/\.less$/i.test(opts.from)) {
  34301. e.message +=
  34302. '\nYou tried to parse Less with ' +
  34303. 'the standard CSS parser; ' +
  34304. 'try again with the postcss-less parser';
  34305. }
  34306. }
  34307. }
  34308. throw e
  34309. }
  34310. return parser.root
  34311. }
  34312. var parse_1 = parse$3;
  34313. parse$3.default = parse$3;
  34314. Container$2.registerParse(parse$3);
  34315. let { isClean, my } = symbols;
  34316. let MapGenerator$1 = mapGenerator;
  34317. let stringify$2 = stringify_1;
  34318. let Container$1 = container$1;
  34319. let Document$2 = document;
  34320. let warnOnce$1 = warnOnce$2;
  34321. let Result$2 = result;
  34322. let parse$2 = parse_1;
  34323. let Root$3 = root$2;
  34324. const TYPE_TO_CLASS_NAME = {
  34325. atrule: 'AtRule',
  34326. comment: 'Comment',
  34327. decl: 'Declaration',
  34328. document: 'Document',
  34329. root: 'Root',
  34330. rule: 'Rule'
  34331. };
  34332. const PLUGIN_PROPS = {
  34333. AtRule: true,
  34334. AtRuleExit: true,
  34335. Comment: true,
  34336. CommentExit: true,
  34337. Declaration: true,
  34338. DeclarationExit: true,
  34339. Document: true,
  34340. DocumentExit: true,
  34341. Once: true,
  34342. OnceExit: true,
  34343. postcssPlugin: true,
  34344. prepare: true,
  34345. Root: true,
  34346. RootExit: true,
  34347. Rule: true,
  34348. RuleExit: true
  34349. };
  34350. const NOT_VISITORS = {
  34351. Once: true,
  34352. postcssPlugin: true,
  34353. prepare: true
  34354. };
  34355. const CHILDREN = 0;
  34356. function isPromise(obj) {
  34357. return typeof obj === 'object' && typeof obj.then === 'function'
  34358. }
  34359. function getEvents(node) {
  34360. let key = false;
  34361. let type = TYPE_TO_CLASS_NAME[node.type];
  34362. if (node.type === 'decl') {
  34363. key = node.prop.toLowerCase();
  34364. } else if (node.type === 'atrule') {
  34365. key = node.name.toLowerCase();
  34366. }
  34367. if (key && node.append) {
  34368. return [
  34369. type,
  34370. type + '-' + key,
  34371. CHILDREN,
  34372. type + 'Exit',
  34373. type + 'Exit-' + key
  34374. ]
  34375. } else if (key) {
  34376. return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
  34377. } else if (node.append) {
  34378. return [type, CHILDREN, type + 'Exit']
  34379. } else {
  34380. return [type, type + 'Exit']
  34381. }
  34382. }
  34383. function toStack(node) {
  34384. let events;
  34385. if (node.type === 'document') {
  34386. events = ['Document', CHILDREN, 'DocumentExit'];
  34387. } else if (node.type === 'root') {
  34388. events = ['Root', CHILDREN, 'RootExit'];
  34389. } else {
  34390. events = getEvents(node);
  34391. }
  34392. return {
  34393. eventIndex: 0,
  34394. events,
  34395. iterator: 0,
  34396. node,
  34397. visitorIndex: 0,
  34398. visitors: []
  34399. }
  34400. }
  34401. function cleanMarks(node) {
  34402. node[isClean] = false;
  34403. if (node.nodes) node.nodes.forEach(i => cleanMarks(i));
  34404. return node
  34405. }
  34406. let postcss$2 = {};
  34407. let LazyResult$2 = class LazyResult {
  34408. constructor(processor, css, opts) {
  34409. this.stringified = false;
  34410. this.processed = false;
  34411. let root;
  34412. if (
  34413. typeof css === 'object' &&
  34414. css !== null &&
  34415. (css.type === 'root' || css.type === 'document')
  34416. ) {
  34417. root = cleanMarks(css);
  34418. } else if (css instanceof LazyResult || css instanceof Result$2) {
  34419. root = cleanMarks(css.root);
  34420. if (css.map) {
  34421. if (typeof opts.map === 'undefined') opts.map = {};
  34422. if (!opts.map.inline) opts.map.inline = false;
  34423. opts.map.prev = css.map;
  34424. }
  34425. } else {
  34426. let parser = parse$2;
  34427. if (opts.syntax) parser = opts.syntax.parse;
  34428. if (opts.parser) parser = opts.parser;
  34429. if (parser.parse) parser = parser.parse;
  34430. try {
  34431. root = parser(css, opts);
  34432. } catch (error) {
  34433. this.processed = true;
  34434. this.error = error;
  34435. }
  34436. if (root && !root[my]) {
  34437. /* c8 ignore next 2 */
  34438. Container$1.rebuild(root);
  34439. }
  34440. }
  34441. this.result = new Result$2(processor, root, opts);
  34442. this.helpers = { ...postcss$2, postcss: postcss$2, result: this.result };
  34443. this.plugins = this.processor.plugins.map(plugin => {
  34444. if (typeof plugin === 'object' && plugin.prepare) {
  34445. return { ...plugin, ...plugin.prepare(this.result) }
  34446. } else {
  34447. return plugin
  34448. }
  34449. });
  34450. }
  34451. async() {
  34452. if (this.error) return Promise.reject(this.error)
  34453. if (this.processed) return Promise.resolve(this.result)
  34454. if (!this.processing) {
  34455. this.processing = this.runAsync();
  34456. }
  34457. return this.processing
  34458. }
  34459. catch(onRejected) {
  34460. return this.async().catch(onRejected)
  34461. }
  34462. finally(onFinally) {
  34463. return this.async().then(onFinally, onFinally)
  34464. }
  34465. getAsyncError() {
  34466. throw new Error('Use process(css).then(cb) to work with async plugins')
  34467. }
  34468. handleError(error, node) {
  34469. let plugin = this.result.lastPlugin;
  34470. try {
  34471. if (node) node.addToError(error);
  34472. this.error = error;
  34473. if (error.name === 'CssSyntaxError' && !error.plugin) {
  34474. error.plugin = plugin.postcssPlugin;
  34475. error.setMessage();
  34476. } else if (plugin.postcssVersion) {
  34477. if (browser$1.env.NODE_ENV !== 'production') {
  34478. let pluginName = plugin.postcssPlugin;
  34479. let pluginVer = plugin.postcssVersion;
  34480. let runtimeVer = this.result.processor.version;
  34481. let a = pluginVer.split('.');
  34482. let b = runtimeVer.split('.');
  34483. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  34484. // eslint-disable-next-line no-console
  34485. console.error(
  34486. 'Unknown error from PostCSS plugin. Your current PostCSS ' +
  34487. 'version is ' +
  34488. runtimeVer +
  34489. ', but ' +
  34490. pluginName +
  34491. ' uses ' +
  34492. pluginVer +
  34493. '. Perhaps this is the source of the error below.'
  34494. );
  34495. }
  34496. }
  34497. }
  34498. } catch (err) {
  34499. /* c8 ignore next 3 */
  34500. // eslint-disable-next-line no-console
  34501. if (console && console.error) console.error(err);
  34502. }
  34503. return error
  34504. }
  34505. prepareVisitors() {
  34506. this.listeners = {};
  34507. let add = (plugin, type, cb) => {
  34508. if (!this.listeners[type]) this.listeners[type] = [];
  34509. this.listeners[type].push([plugin, cb]);
  34510. };
  34511. for (let plugin of this.plugins) {
  34512. if (typeof plugin === 'object') {
  34513. for (let event in plugin) {
  34514. if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
  34515. throw new Error(
  34516. `Unknown event ${event} in ${plugin.postcssPlugin}. ` +
  34517. `Try to update PostCSS (${this.processor.version} now).`
  34518. )
  34519. }
  34520. if (!NOT_VISITORS[event]) {
  34521. if (typeof plugin[event] === 'object') {
  34522. for (let filter in plugin[event]) {
  34523. if (filter === '*') {
  34524. add(plugin, event, plugin[event][filter]);
  34525. } else {
  34526. add(
  34527. plugin,
  34528. event + '-' + filter.toLowerCase(),
  34529. plugin[event][filter]
  34530. );
  34531. }
  34532. }
  34533. } else if (typeof plugin[event] === 'function') {
  34534. add(plugin, event, plugin[event]);
  34535. }
  34536. }
  34537. }
  34538. }
  34539. }
  34540. this.hasListener = Object.keys(this.listeners).length > 0;
  34541. }
  34542. async runAsync() {
  34543. this.plugin = 0;
  34544. for (let i = 0; i < this.plugins.length; i++) {
  34545. let plugin = this.plugins[i];
  34546. let promise = this.runOnRoot(plugin);
  34547. if (isPromise(promise)) {
  34548. try {
  34549. await promise;
  34550. } catch (error) {
  34551. throw this.handleError(error)
  34552. }
  34553. }
  34554. }
  34555. this.prepareVisitors();
  34556. if (this.hasListener) {
  34557. let root = this.result.root;
  34558. while (!root[isClean]) {
  34559. root[isClean] = true;
  34560. let stack = [toStack(root)];
  34561. while (stack.length > 0) {
  34562. let promise = this.visitTick(stack);
  34563. if (isPromise(promise)) {
  34564. try {
  34565. await promise;
  34566. } catch (e) {
  34567. let node = stack[stack.length - 1].node;
  34568. throw this.handleError(e, node)
  34569. }
  34570. }
  34571. }
  34572. }
  34573. if (this.listeners.OnceExit) {
  34574. for (let [plugin, visitor] of this.listeners.OnceExit) {
  34575. this.result.lastPlugin = plugin;
  34576. try {
  34577. if (root.type === 'document') {
  34578. let roots = root.nodes.map(subRoot =>
  34579. visitor(subRoot, this.helpers)
  34580. );
  34581. await Promise.all(roots);
  34582. } else {
  34583. await visitor(root, this.helpers);
  34584. }
  34585. } catch (e) {
  34586. throw this.handleError(e)
  34587. }
  34588. }
  34589. }
  34590. }
  34591. this.processed = true;
  34592. return this.stringify()
  34593. }
  34594. runOnRoot(plugin) {
  34595. this.result.lastPlugin = plugin;
  34596. try {
  34597. if (typeof plugin === 'object' && plugin.Once) {
  34598. if (this.result.root.type === 'document') {
  34599. let roots = this.result.root.nodes.map(root =>
  34600. plugin.Once(root, this.helpers)
  34601. );
  34602. if (isPromise(roots[0])) {
  34603. return Promise.all(roots)
  34604. }
  34605. return roots
  34606. }
  34607. return plugin.Once(this.result.root, this.helpers)
  34608. } else if (typeof plugin === 'function') {
  34609. return plugin(this.result.root, this.result)
  34610. }
  34611. } catch (error) {
  34612. throw this.handleError(error)
  34613. }
  34614. }
  34615. stringify() {
  34616. if (this.error) throw this.error
  34617. if (this.stringified) return this.result
  34618. this.stringified = true;
  34619. this.sync();
  34620. let opts = this.result.opts;
  34621. let str = stringify$2;
  34622. if (opts.syntax) str = opts.syntax.stringify;
  34623. if (opts.stringifier) str = opts.stringifier;
  34624. if (str.stringify) str = str.stringify;
  34625. let map = new MapGenerator$1(str, this.result.root, this.result.opts);
  34626. let data = map.generate();
  34627. this.result.css = data[0];
  34628. this.result.map = data[1];
  34629. return this.result
  34630. }
  34631. sync() {
  34632. if (this.error) throw this.error
  34633. if (this.processed) return this.result
  34634. this.processed = true;
  34635. if (this.processing) {
  34636. throw this.getAsyncError()
  34637. }
  34638. for (let plugin of this.plugins) {
  34639. let promise = this.runOnRoot(plugin);
  34640. if (isPromise(promise)) {
  34641. throw this.getAsyncError()
  34642. }
  34643. }
  34644. this.prepareVisitors();
  34645. if (this.hasListener) {
  34646. let root = this.result.root;
  34647. while (!root[isClean]) {
  34648. root[isClean] = true;
  34649. this.walkSync(root);
  34650. }
  34651. if (this.listeners.OnceExit) {
  34652. if (root.type === 'document') {
  34653. for (let subRoot of root.nodes) {
  34654. this.visitSync(this.listeners.OnceExit, subRoot);
  34655. }
  34656. } else {
  34657. this.visitSync(this.listeners.OnceExit, root);
  34658. }
  34659. }
  34660. }
  34661. return this.result
  34662. }
  34663. then(onFulfilled, onRejected) {
  34664. if (browser$1.env.NODE_ENV !== 'production') {
  34665. if (!('from' in this.opts)) {
  34666. warnOnce$1(
  34667. 'Without `from` option PostCSS could generate wrong source map ' +
  34668. 'and will not find Browserslist config. Set it to CSS file path ' +
  34669. 'or to `undefined` to prevent this warning.'
  34670. );
  34671. }
  34672. }
  34673. return this.async().then(onFulfilled, onRejected)
  34674. }
  34675. toString() {
  34676. return this.css
  34677. }
  34678. visitSync(visitors, node) {
  34679. for (let [plugin, visitor] of visitors) {
  34680. this.result.lastPlugin = plugin;
  34681. let promise;
  34682. try {
  34683. promise = visitor(node, this.helpers);
  34684. } catch (e) {
  34685. throw this.handleError(e, node.proxyOf)
  34686. }
  34687. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  34688. return true
  34689. }
  34690. if (isPromise(promise)) {
  34691. throw this.getAsyncError()
  34692. }
  34693. }
  34694. }
  34695. visitTick(stack) {
  34696. let visit = stack[stack.length - 1];
  34697. let { node, visitors } = visit;
  34698. if (node.type !== 'root' && node.type !== 'document' && !node.parent) {
  34699. stack.pop();
  34700. return
  34701. }
  34702. if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
  34703. let [plugin, visitor] = visitors[visit.visitorIndex];
  34704. visit.visitorIndex += 1;
  34705. if (visit.visitorIndex === visitors.length) {
  34706. visit.visitors = [];
  34707. visit.visitorIndex = 0;
  34708. }
  34709. this.result.lastPlugin = plugin;
  34710. try {
  34711. return visitor(node.toProxy(), this.helpers)
  34712. } catch (e) {
  34713. throw this.handleError(e, node)
  34714. }
  34715. }
  34716. if (visit.iterator !== 0) {
  34717. let iterator = visit.iterator;
  34718. let child;
  34719. while ((child = node.nodes[node.indexes[iterator]])) {
  34720. node.indexes[iterator] += 1;
  34721. if (!child[isClean]) {
  34722. child[isClean] = true;
  34723. stack.push(toStack(child));
  34724. return
  34725. }
  34726. }
  34727. visit.iterator = 0;
  34728. delete node.indexes[iterator];
  34729. }
  34730. let events = visit.events;
  34731. while (visit.eventIndex < events.length) {
  34732. let event = events[visit.eventIndex];
  34733. visit.eventIndex += 1;
  34734. if (event === CHILDREN) {
  34735. if (node.nodes && node.nodes.length) {
  34736. node[isClean] = true;
  34737. visit.iterator = node.getIterator();
  34738. }
  34739. return
  34740. } else if (this.listeners[event]) {
  34741. visit.visitors = this.listeners[event];
  34742. return
  34743. }
  34744. }
  34745. stack.pop();
  34746. }
  34747. walkSync(node) {
  34748. node[isClean] = true;
  34749. let events = getEvents(node);
  34750. for (let event of events) {
  34751. if (event === CHILDREN) {
  34752. if (node.nodes) {
  34753. node.each(child => {
  34754. if (!child[isClean]) this.walkSync(child);
  34755. });
  34756. }
  34757. } else {
  34758. let visitors = this.listeners[event];
  34759. if (visitors) {
  34760. if (this.visitSync(visitors, node.toProxy())) return
  34761. }
  34762. }
  34763. }
  34764. }
  34765. warnings() {
  34766. return this.sync().warnings()
  34767. }
  34768. get content() {
  34769. return this.stringify().content
  34770. }
  34771. get css() {
  34772. return this.stringify().css
  34773. }
  34774. get map() {
  34775. return this.stringify().map
  34776. }
  34777. get messages() {
  34778. return this.sync().messages
  34779. }
  34780. get opts() {
  34781. return this.result.opts
  34782. }
  34783. get processor() {
  34784. return this.result.processor
  34785. }
  34786. get root() {
  34787. return this.sync().root
  34788. }
  34789. get [Symbol.toStringTag]() {
  34790. return 'LazyResult'
  34791. }
  34792. };
  34793. LazyResult$2.registerPostcss = dependant => {
  34794. postcss$2 = dependant;
  34795. };
  34796. var lazyResult = LazyResult$2;
  34797. LazyResult$2.default = LazyResult$2;
  34798. Root$3.registerLazyResult(LazyResult$2);
  34799. Document$2.registerLazyResult(LazyResult$2);
  34800. let MapGenerator = mapGenerator;
  34801. let stringify$1 = stringify_1;
  34802. let warnOnce = warnOnce$2;
  34803. let parse$1 = parse_1;
  34804. const Result$1 = result;
  34805. let NoWorkResult$1 = class NoWorkResult {
  34806. constructor(processor, css, opts) {
  34807. css = css.toString();
  34808. this.stringified = false;
  34809. this._processor = processor;
  34810. this._css = css;
  34811. this._opts = opts;
  34812. this._map = undefined;
  34813. let root;
  34814. let str = stringify$1;
  34815. this.result = new Result$1(this._processor, root, this._opts);
  34816. this.result.css = css;
  34817. let self = this;
  34818. Object.defineProperty(this.result, 'root', {
  34819. get() {
  34820. return self.root
  34821. }
  34822. });
  34823. let map = new MapGenerator(str, root, this._opts, css);
  34824. if (map.isMap()) {
  34825. let [generatedCSS, generatedMap] = map.generate();
  34826. if (generatedCSS) {
  34827. this.result.css = generatedCSS;
  34828. }
  34829. if (generatedMap) {
  34830. this.result.map = generatedMap;
  34831. }
  34832. } else {
  34833. map.clearAnnotation();
  34834. this.result.css = map.css;
  34835. }
  34836. }
  34837. async() {
  34838. if (this.error) return Promise.reject(this.error)
  34839. return Promise.resolve(this.result)
  34840. }
  34841. catch(onRejected) {
  34842. return this.async().catch(onRejected)
  34843. }
  34844. finally(onFinally) {
  34845. return this.async().then(onFinally, onFinally)
  34846. }
  34847. sync() {
  34848. if (this.error) throw this.error
  34849. return this.result
  34850. }
  34851. then(onFulfilled, onRejected) {
  34852. if (browser$1.env.NODE_ENV !== 'production') {
  34853. if (!('from' in this._opts)) {
  34854. warnOnce(
  34855. 'Without `from` option PostCSS could generate wrong source map ' +
  34856. 'and will not find Browserslist config. Set it to CSS file path ' +
  34857. 'or to `undefined` to prevent this warning.'
  34858. );
  34859. }
  34860. }
  34861. return this.async().then(onFulfilled, onRejected)
  34862. }
  34863. toString() {
  34864. return this._css
  34865. }
  34866. warnings() {
  34867. return []
  34868. }
  34869. get content() {
  34870. return this.result.css
  34871. }
  34872. get css() {
  34873. return this.result.css
  34874. }
  34875. get map() {
  34876. return this.result.map
  34877. }
  34878. get messages() {
  34879. return []
  34880. }
  34881. get opts() {
  34882. return this.result.opts
  34883. }
  34884. get processor() {
  34885. return this.result.processor
  34886. }
  34887. get root() {
  34888. if (this._root) {
  34889. return this._root
  34890. }
  34891. let root;
  34892. let parser = parse$1;
  34893. try {
  34894. root = parser(this._css, this._opts);
  34895. } catch (error) {
  34896. this.error = error;
  34897. }
  34898. if (this.error) {
  34899. throw this.error
  34900. } else {
  34901. this._root = root;
  34902. return root
  34903. }
  34904. }
  34905. get [Symbol.toStringTag]() {
  34906. return 'NoWorkResult'
  34907. }
  34908. };
  34909. var noWorkResult = NoWorkResult$1;
  34910. NoWorkResult$1.default = NoWorkResult$1;
  34911. let NoWorkResult = noWorkResult;
  34912. let LazyResult$1 = lazyResult;
  34913. let Document$1 = document;
  34914. let Root$2 = root$2;
  34915. let Processor$1 = class Processor {
  34916. constructor(plugins = []) {
  34917. this.version = '8.4.40';
  34918. this.plugins = this.normalize(plugins);
  34919. }
  34920. normalize(plugins) {
  34921. let normalized = [];
  34922. for (let i of plugins) {
  34923. if (i.postcss === true) {
  34924. i = i();
  34925. } else if (i.postcss) {
  34926. i = i.postcss;
  34927. }
  34928. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  34929. normalized = normalized.concat(i.plugins);
  34930. } else if (typeof i === 'object' && i.postcssPlugin) {
  34931. normalized.push(i);
  34932. } else if (typeof i === 'function') {
  34933. normalized.push(i);
  34934. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  34935. if (browser$1.env.NODE_ENV !== 'production') {
  34936. throw new Error(
  34937. 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
  34938. 'one of the syntax/parser/stringifier options as outlined ' +
  34939. 'in your PostCSS runner documentation.'
  34940. )
  34941. }
  34942. } else {
  34943. throw new Error(i + ' is not a PostCSS plugin')
  34944. }
  34945. }
  34946. return normalized
  34947. }
  34948. process(css, opts = {}) {
  34949. if (
  34950. !this.plugins.length &&
  34951. !opts.parser &&
  34952. !opts.stringifier &&
  34953. !opts.syntax
  34954. ) {
  34955. return new NoWorkResult(this, css, opts)
  34956. } else {
  34957. return new LazyResult$1(this, css, opts)
  34958. }
  34959. }
  34960. use(plugin) {
  34961. this.plugins = this.plugins.concat(this.normalize([plugin]));
  34962. return this
  34963. }
  34964. };
  34965. var processor$1 = Processor$1;
  34966. Processor$1.default = Processor$1;
  34967. Root$2.registerProcessor(Processor$1);
  34968. Document$1.registerProcessor(Processor$1);
  34969. let Declaration$1 = declaration;
  34970. let PreviousMap = previousMap;
  34971. let Comment$1 = comment$3;
  34972. let AtRule$1 = atRule;
  34973. let Input$1 = input;
  34974. let Root$1 = root$2;
  34975. let Rule$1 = rule;
  34976. function fromJSON$1(json, inputs) {
  34977. if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
  34978. let { inputs: ownInputs, ...defaults } = json;
  34979. if (ownInputs) {
  34980. inputs = [];
  34981. for (let input of ownInputs) {
  34982. let inputHydrated = { ...input, __proto__: Input$1.prototype };
  34983. if (inputHydrated.map) {
  34984. inputHydrated.map = {
  34985. ...inputHydrated.map,
  34986. __proto__: PreviousMap.prototype
  34987. };
  34988. }
  34989. inputs.push(inputHydrated);
  34990. }
  34991. }
  34992. if (defaults.nodes) {
  34993. defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
  34994. }
  34995. if (defaults.source) {
  34996. let { inputId, ...source } = defaults.source;
  34997. defaults.source = source;
  34998. if (inputId != null) {
  34999. defaults.source.input = inputs[inputId];
  35000. }
  35001. }
  35002. if (defaults.type === 'root') {
  35003. return new Root$1(defaults)
  35004. } else if (defaults.type === 'decl') {
  35005. return new Declaration$1(defaults)
  35006. } else if (defaults.type === 'rule') {
  35007. return new Rule$1(defaults)
  35008. } else if (defaults.type === 'comment') {
  35009. return new Comment$1(defaults)
  35010. } else if (defaults.type === 'atrule') {
  35011. return new AtRule$1(defaults)
  35012. } else {
  35013. throw new Error('Unknown node type: ' + json.type)
  35014. }
  35015. }
  35016. var fromJSON_1 = fromJSON$1;
  35017. fromJSON$1.default = fromJSON$1;
  35018. let CssSyntaxError = cssSyntaxError;
  35019. let Declaration = declaration;
  35020. let LazyResult = lazyResult;
  35021. let Container = container$1;
  35022. let Processor = processor$1;
  35023. let stringify = stringify_1;
  35024. let fromJSON = fromJSON_1;
  35025. let Document = document;
  35026. let Warning = warning;
  35027. let Comment = comment$3;
  35028. let AtRule = atRule;
  35029. let Result = result;
  35030. let Input = input;
  35031. let parse = parse_1;
  35032. let list = list_1;
  35033. let Rule = rule;
  35034. let Root = root$2;
  35035. let Node = node$2;
  35036. function postcss(...plugins) {
  35037. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  35038. plugins = plugins[0];
  35039. }
  35040. return new Processor(plugins)
  35041. }
  35042. postcss.plugin = function plugin(name, initializer) {
  35043. let warningPrinted = false;
  35044. function creator(...args) {
  35045. // eslint-disable-next-line no-console
  35046. if (console && console.warn && !warningPrinted) {
  35047. warningPrinted = true;
  35048. // eslint-disable-next-line no-console
  35049. console.warn(
  35050. name +
  35051. ': postcss.plugin was deprecated. Migration guide:\n' +
  35052. 'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
  35053. );
  35054. if (browser$1.env.LANG && browser$1.env.LANG.startsWith('cn')) {
  35055. /* c8 ignore next 7 */
  35056. // eslint-disable-next-line no-console
  35057. console.warn(
  35058. name +
  35059. ': 里面 postcss.plugin 被弃用. 迁移指南:\n' +
  35060. 'https://www.w3ctech.com/topic/2226'
  35061. );
  35062. }
  35063. }
  35064. let transformer = initializer(...args);
  35065. transformer.postcssPlugin = name;
  35066. transformer.postcssVersion = new Processor().version;
  35067. return transformer
  35068. }
  35069. let cache;
  35070. Object.defineProperty(creator, 'postcss', {
  35071. get() {
  35072. if (!cache) cache = creator();
  35073. return cache
  35074. }
  35075. });
  35076. creator.process = function (css, processOpts, pluginOpts) {
  35077. return postcss([creator(pluginOpts)]).process(css, processOpts)
  35078. };
  35079. return creator
  35080. };
  35081. postcss.stringify = stringify;
  35082. postcss.parse = parse;
  35083. postcss.fromJSON = fromJSON;
  35084. postcss.list = list;
  35085. postcss.comment = defaults => new Comment(defaults);
  35086. postcss.atRule = defaults => new AtRule(defaults);
  35087. postcss.decl = defaults => new Declaration(defaults);
  35088. postcss.rule = defaults => new Rule(defaults);
  35089. postcss.root = defaults => new Root(defaults);
  35090. postcss.document = defaults => new Document(defaults);
  35091. postcss.CssSyntaxError = CssSyntaxError;
  35092. postcss.Declaration = Declaration;
  35093. postcss.Container = Container;
  35094. postcss.Processor = Processor;
  35095. postcss.Document = Document;
  35096. postcss.Comment = Comment;
  35097. postcss.Warning = Warning;
  35098. postcss.AtRule = AtRule;
  35099. postcss.Result = Result;
  35100. postcss.Input = Input;
  35101. postcss.Rule = Rule;
  35102. postcss.Root = Root;
  35103. postcss.Node = Node;
  35104. LazyResult.registerPostcss(postcss);
  35105. var postcss_1 = postcss;
  35106. postcss.default = postcss;
  35107. var postcss$1 = /*@__PURE__*/getDefaultExportFromCjs(postcss_1);
  35108. postcss$1.stringify;
  35109. postcss$1.fromJSON;
  35110. postcss$1.plugin;
  35111. postcss$1.parse;
  35112. postcss$1.list;
  35113. postcss$1.document;
  35114. postcss$1.comment;
  35115. postcss$1.atRule;
  35116. postcss$1.rule;
  35117. postcss$1.decl;
  35118. postcss$1.root;
  35119. postcss$1.CssSyntaxError;
  35120. postcss$1.Declaration;
  35121. postcss$1.Container;
  35122. postcss$1.Processor;
  35123. postcss$1.Document;
  35124. postcss$1.Comment;
  35125. postcss$1.Warning;
  35126. postcss$1.AtRule;
  35127. postcss$1.Result;
  35128. postcss$1.Input;
  35129. postcss$1.Rule;
  35130. postcss$1.Root;
  35131. postcss$1.Node;
  35132. const trimPlugin = () => {
  35133. return {
  35134. postcssPlugin: "vue-sfc-trim",
  35135. Once(root) {
  35136. root.walk(({ type, raws }) => {
  35137. if (type === "rule" || type === "atrule") {
  35138. if (raws.before) raws.before = "\n";
  35139. if ("after" in raws && raws.after) raws.after = "\n";
  35140. }
  35141. });
  35142. }
  35143. };
  35144. };
  35145. trimPlugin.postcss = true;
  35146. var dist = {exports: {}};
  35147. var processor = {exports: {}};
  35148. var parser = {exports: {}};
  35149. var root$1 = {exports: {}};
  35150. var container = {exports: {}};
  35151. var node$1 = {exports: {}};
  35152. var util$6 = {};
  35153. var unesc = {exports: {}};
  35154. (function (module, exports) {
  35155. exports.__esModule = true;
  35156. exports["default"] = unesc;
  35157. // Many thanks for this post which made this migration much easier.
  35158. // https://mathiasbynens.be/notes/css-escapes
  35159. /**
  35160. *
  35161. * @param {string} str
  35162. * @returns {[string, number]|undefined}
  35163. */
  35164. function gobbleHex(str) {
  35165. var lower = str.toLowerCase();
  35166. var hex = '';
  35167. var spaceTerminated = false;
  35168. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  35169. var code = lower.charCodeAt(i);
  35170. // check to see if we are dealing with a valid hex char [a-f|0-9]
  35171. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57;
  35172. // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  35173. spaceTerminated = code === 32;
  35174. if (!valid) {
  35175. break;
  35176. }
  35177. hex += lower[i];
  35178. }
  35179. if (hex.length === 0) {
  35180. return undefined;
  35181. }
  35182. var codePoint = parseInt(hex, 16);
  35183. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF;
  35184. // Add special case for
  35185. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  35186. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  35187. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  35188. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  35189. }
  35190. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  35191. }
  35192. var CONTAINS_ESCAPE = /\\/;
  35193. function unesc(str) {
  35194. var needToProcess = CONTAINS_ESCAPE.test(str);
  35195. if (!needToProcess) {
  35196. return str;
  35197. }
  35198. var ret = "";
  35199. for (var i = 0; i < str.length; i++) {
  35200. if (str[i] === "\\") {
  35201. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  35202. if (gobbled !== undefined) {
  35203. ret += gobbled[0];
  35204. i += gobbled[1];
  35205. continue;
  35206. }
  35207. // Retain a pair of \\ if double escaped `\\\\`
  35208. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  35209. if (str[i + 1] === "\\") {
  35210. ret += "\\";
  35211. i++;
  35212. continue;
  35213. }
  35214. // if \\ is at the end of the string retain it
  35215. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  35216. if (str.length === i + 1) {
  35217. ret += str[i];
  35218. }
  35219. continue;
  35220. }
  35221. ret += str[i];
  35222. }
  35223. return ret;
  35224. }
  35225. module.exports = exports.default;
  35226. } (unesc, unesc.exports));
  35227. var unescExports = unesc.exports;
  35228. var getProp = {exports: {}};
  35229. (function (module, exports) {
  35230. exports.__esModule = true;
  35231. exports["default"] = getProp;
  35232. function getProp(obj) {
  35233. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35234. props[_key - 1] = arguments[_key];
  35235. }
  35236. while (props.length > 0) {
  35237. var prop = props.shift();
  35238. if (!obj[prop]) {
  35239. return undefined;
  35240. }
  35241. obj = obj[prop];
  35242. }
  35243. return obj;
  35244. }
  35245. module.exports = exports.default;
  35246. } (getProp, getProp.exports));
  35247. var getPropExports = getProp.exports;
  35248. var ensureObject = {exports: {}};
  35249. (function (module, exports) {
  35250. exports.__esModule = true;
  35251. exports["default"] = ensureObject;
  35252. function ensureObject(obj) {
  35253. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  35254. props[_key - 1] = arguments[_key];
  35255. }
  35256. while (props.length > 0) {
  35257. var prop = props.shift();
  35258. if (!obj[prop]) {
  35259. obj[prop] = {};
  35260. }
  35261. obj = obj[prop];
  35262. }
  35263. }
  35264. module.exports = exports.default;
  35265. } (ensureObject, ensureObject.exports));
  35266. var ensureObjectExports = ensureObject.exports;
  35267. var stripComments = {exports: {}};
  35268. (function (module, exports) {
  35269. exports.__esModule = true;
  35270. exports["default"] = stripComments;
  35271. function stripComments(str) {
  35272. var s = "";
  35273. var commentStart = str.indexOf("/*");
  35274. var lastEnd = 0;
  35275. while (commentStart >= 0) {
  35276. s = s + str.slice(lastEnd, commentStart);
  35277. var commentEnd = str.indexOf("*/", commentStart + 2);
  35278. if (commentEnd < 0) {
  35279. return s;
  35280. }
  35281. lastEnd = commentEnd + 2;
  35282. commentStart = str.indexOf("/*", lastEnd);
  35283. }
  35284. s = s + str.slice(lastEnd);
  35285. return s;
  35286. }
  35287. module.exports = exports.default;
  35288. } (stripComments, stripComments.exports));
  35289. var stripCommentsExports = stripComments.exports;
  35290. util$6.__esModule = true;
  35291. util$6.unesc = util$6.stripComments = util$6.getProp = util$6.ensureObject = void 0;
  35292. var _unesc = _interopRequireDefault$1(unescExports);
  35293. util$6.unesc = _unesc["default"];
  35294. var _getProp = _interopRequireDefault$1(getPropExports);
  35295. util$6.getProp = _getProp["default"];
  35296. var _ensureObject = _interopRequireDefault$1(ensureObjectExports);
  35297. util$6.ensureObject = _ensureObject["default"];
  35298. var _stripComments = _interopRequireDefault$1(stripCommentsExports);
  35299. util$6.stripComments = _stripComments["default"];
  35300. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35301. (function (module, exports) {
  35302. exports.__esModule = true;
  35303. exports["default"] = void 0;
  35304. var _util = util$6;
  35305. 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); } }
  35306. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35307. var cloneNode = function cloneNode(obj, parent) {
  35308. if (typeof obj !== 'object' || obj === null) {
  35309. return obj;
  35310. }
  35311. var cloned = new obj.constructor();
  35312. for (var i in obj) {
  35313. if (!obj.hasOwnProperty(i)) {
  35314. continue;
  35315. }
  35316. var value = obj[i];
  35317. var type = typeof value;
  35318. if (i === 'parent' && type === 'object') {
  35319. if (parent) {
  35320. cloned[i] = parent;
  35321. }
  35322. } else if (value instanceof Array) {
  35323. cloned[i] = value.map(function (j) {
  35324. return cloneNode(j, cloned);
  35325. });
  35326. } else {
  35327. cloned[i] = cloneNode(value, cloned);
  35328. }
  35329. }
  35330. return cloned;
  35331. };
  35332. var Node = /*#__PURE__*/function () {
  35333. function Node(opts) {
  35334. if (opts === void 0) {
  35335. opts = {};
  35336. }
  35337. Object.assign(this, opts);
  35338. this.spaces = this.spaces || {};
  35339. this.spaces.before = this.spaces.before || '';
  35340. this.spaces.after = this.spaces.after || '';
  35341. }
  35342. var _proto = Node.prototype;
  35343. _proto.remove = function remove() {
  35344. if (this.parent) {
  35345. this.parent.removeChild(this);
  35346. }
  35347. this.parent = undefined;
  35348. return this;
  35349. };
  35350. _proto.replaceWith = function replaceWith() {
  35351. if (this.parent) {
  35352. for (var index in arguments) {
  35353. this.parent.insertBefore(this, arguments[index]);
  35354. }
  35355. this.remove();
  35356. }
  35357. return this;
  35358. };
  35359. _proto.next = function next() {
  35360. return this.parent.at(this.parent.index(this) + 1);
  35361. };
  35362. _proto.prev = function prev() {
  35363. return this.parent.at(this.parent.index(this) - 1);
  35364. };
  35365. _proto.clone = function clone(overrides) {
  35366. if (overrides === void 0) {
  35367. overrides = {};
  35368. }
  35369. var cloned = cloneNode(this);
  35370. for (var name in overrides) {
  35371. cloned[name] = overrides[name];
  35372. }
  35373. return cloned;
  35374. }
  35375. /**
  35376. * Some non-standard syntax doesn't follow normal escaping rules for css.
  35377. * This allows non standard syntax to be appended to an existing property
  35378. * by specifying the escaped value. By specifying the escaped value,
  35379. * illegal characters are allowed to be directly inserted into css output.
  35380. * @param {string} name the property to set
  35381. * @param {any} value the unescaped value of the property
  35382. * @param {string} valueEscaped optional. the escaped value of the property.
  35383. */;
  35384. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  35385. if (!this.raws) {
  35386. this.raws = {};
  35387. }
  35388. var originalValue = this[name];
  35389. var originalEscaped = this.raws[name];
  35390. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  35391. if (originalEscaped || valueEscaped !== value) {
  35392. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  35393. } else {
  35394. delete this.raws[name]; // delete any escaped value that was created by the setter.
  35395. }
  35396. }
  35397. /**
  35398. * Some non-standard syntax doesn't follow normal escaping rules for css.
  35399. * This allows the escaped value to be specified directly, allowing illegal
  35400. * characters to be directly inserted into css output.
  35401. * @param {string} name the property to set
  35402. * @param {any} value the unescaped value of the property
  35403. * @param {string} valueEscaped the escaped value of the property.
  35404. */;
  35405. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  35406. if (!this.raws) {
  35407. this.raws = {};
  35408. }
  35409. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  35410. this.raws[name] = valueEscaped;
  35411. }
  35412. /**
  35413. * When you want a value to passed through to CSS directly. This method
  35414. * deletes the corresponding raw value causing the stringifier to fallback
  35415. * to the unescaped value.
  35416. * @param {string} name the property to set.
  35417. * @param {any} value The value that is both escaped and unescaped.
  35418. */;
  35419. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  35420. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  35421. if (this.raws) {
  35422. delete this.raws[name];
  35423. }
  35424. }
  35425. /**
  35426. *
  35427. * @param {number} line The number (starting with 1)
  35428. * @param {number} column The column number (starting with 1)
  35429. */;
  35430. _proto.isAtPosition = function isAtPosition(line, column) {
  35431. if (this.source && this.source.start && this.source.end) {
  35432. if (this.source.start.line > line) {
  35433. return false;
  35434. }
  35435. if (this.source.end.line < line) {
  35436. return false;
  35437. }
  35438. if (this.source.start.line === line && this.source.start.column > column) {
  35439. return false;
  35440. }
  35441. if (this.source.end.line === line && this.source.end.column < column) {
  35442. return false;
  35443. }
  35444. return true;
  35445. }
  35446. return undefined;
  35447. };
  35448. _proto.stringifyProperty = function stringifyProperty(name) {
  35449. return this.raws && this.raws[name] || this[name];
  35450. };
  35451. _proto.valueToString = function valueToString() {
  35452. return String(this.stringifyProperty("value"));
  35453. };
  35454. _proto.toString = function toString() {
  35455. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  35456. };
  35457. _createClass(Node, [{
  35458. key: "rawSpaceBefore",
  35459. get: function get() {
  35460. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  35461. if (rawSpace === undefined) {
  35462. rawSpace = this.spaces && this.spaces.before;
  35463. }
  35464. return rawSpace || "";
  35465. },
  35466. set: function set(raw) {
  35467. (0, _util.ensureObject)(this, "raws", "spaces");
  35468. this.raws.spaces.before = raw;
  35469. }
  35470. }, {
  35471. key: "rawSpaceAfter",
  35472. get: function get() {
  35473. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  35474. if (rawSpace === undefined) {
  35475. rawSpace = this.spaces.after;
  35476. }
  35477. return rawSpace || "";
  35478. },
  35479. set: function set(raw) {
  35480. (0, _util.ensureObject)(this, "raws", "spaces");
  35481. this.raws.spaces.after = raw;
  35482. }
  35483. }]);
  35484. return Node;
  35485. }();
  35486. exports["default"] = Node;
  35487. module.exports = exports.default;
  35488. } (node$1, node$1.exports));
  35489. var nodeExports = node$1.exports;
  35490. var types = {};
  35491. types.__esModule = true;
  35492. 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;
  35493. var TAG = 'tag';
  35494. types.TAG = TAG;
  35495. var STRING = 'string';
  35496. types.STRING = STRING;
  35497. var SELECTOR = 'selector';
  35498. types.SELECTOR = SELECTOR;
  35499. var ROOT = 'root';
  35500. types.ROOT = ROOT;
  35501. var PSEUDO = 'pseudo';
  35502. types.PSEUDO = PSEUDO;
  35503. var NESTING = 'nesting';
  35504. types.NESTING = NESTING;
  35505. var ID = 'id';
  35506. types.ID = ID;
  35507. var COMMENT = 'comment';
  35508. types.COMMENT = COMMENT;
  35509. var COMBINATOR = 'combinator';
  35510. types.COMBINATOR = COMBINATOR;
  35511. var CLASS = 'class';
  35512. types.CLASS = CLASS;
  35513. var ATTRIBUTE = 'attribute';
  35514. types.ATTRIBUTE = ATTRIBUTE;
  35515. var UNIVERSAL = 'universal';
  35516. types.UNIVERSAL = UNIVERSAL;
  35517. (function (module, exports) {
  35518. exports.__esModule = true;
  35519. exports["default"] = void 0;
  35520. var _node = _interopRequireDefault(nodeExports);
  35521. var types$1 = _interopRequireWildcard(types);
  35522. 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); }
  35523. 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; }
  35524. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35525. 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."); }
  35526. 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); }
  35527. 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; }
  35528. 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); } }
  35529. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35530. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35531. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35532. var Container = /*#__PURE__*/function (_Node) {
  35533. _inheritsLoose(Container, _Node);
  35534. function Container(opts) {
  35535. var _this;
  35536. _this = _Node.call(this, opts) || this;
  35537. if (!_this.nodes) {
  35538. _this.nodes = [];
  35539. }
  35540. return _this;
  35541. }
  35542. var _proto = Container.prototype;
  35543. _proto.append = function append(selector) {
  35544. selector.parent = this;
  35545. this.nodes.push(selector);
  35546. return this;
  35547. };
  35548. _proto.prepend = function prepend(selector) {
  35549. selector.parent = this;
  35550. this.nodes.unshift(selector);
  35551. return this;
  35552. };
  35553. _proto.at = function at(index) {
  35554. return this.nodes[index];
  35555. };
  35556. _proto.index = function index(child) {
  35557. if (typeof child === 'number') {
  35558. return child;
  35559. }
  35560. return this.nodes.indexOf(child);
  35561. };
  35562. _proto.removeChild = function removeChild(child) {
  35563. child = this.index(child);
  35564. this.at(child).parent = undefined;
  35565. this.nodes.splice(child, 1);
  35566. var index;
  35567. for (var id in this.indexes) {
  35568. index = this.indexes[id];
  35569. if (index >= child) {
  35570. this.indexes[id] = index - 1;
  35571. }
  35572. }
  35573. return this;
  35574. };
  35575. _proto.removeAll = function removeAll() {
  35576. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  35577. var node = _step.value;
  35578. node.parent = undefined;
  35579. }
  35580. this.nodes = [];
  35581. return this;
  35582. };
  35583. _proto.empty = function empty() {
  35584. return this.removeAll();
  35585. };
  35586. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  35587. newNode.parent = this;
  35588. var oldIndex = this.index(oldNode);
  35589. this.nodes.splice(oldIndex + 1, 0, newNode);
  35590. newNode.parent = this;
  35591. var index;
  35592. for (var id in this.indexes) {
  35593. index = this.indexes[id];
  35594. if (oldIndex <= index) {
  35595. this.indexes[id] = index + 1;
  35596. }
  35597. }
  35598. return this;
  35599. };
  35600. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  35601. newNode.parent = this;
  35602. var oldIndex = this.index(oldNode);
  35603. this.nodes.splice(oldIndex, 0, newNode);
  35604. newNode.parent = this;
  35605. var index;
  35606. for (var id in this.indexes) {
  35607. index = this.indexes[id];
  35608. if (index <= oldIndex) {
  35609. this.indexes[id] = index + 1;
  35610. }
  35611. }
  35612. return this;
  35613. };
  35614. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  35615. var found = undefined;
  35616. this.each(function (node) {
  35617. if (node.atPosition) {
  35618. var foundChild = node.atPosition(line, col);
  35619. if (foundChild) {
  35620. found = foundChild;
  35621. return false;
  35622. }
  35623. } else if (node.isAtPosition(line, col)) {
  35624. found = node;
  35625. return false;
  35626. }
  35627. });
  35628. return found;
  35629. }
  35630. /**
  35631. * Return the most specific node at the line and column number given.
  35632. * The source location is based on the original parsed location, locations aren't
  35633. * updated as selector nodes are mutated.
  35634. *
  35635. * Note that this location is relative to the location of the first character
  35636. * of the selector, and not the location of the selector in the overall document
  35637. * when used in conjunction with postcss.
  35638. *
  35639. * If not found, returns undefined.
  35640. * @param {number} line The line number of the node to find. (1-based index)
  35641. * @param {number} col The column number of the node to find. (1-based index)
  35642. */;
  35643. _proto.atPosition = function atPosition(line, col) {
  35644. if (this.isAtPosition(line, col)) {
  35645. return this._findChildAtPosition(line, col) || this;
  35646. } else {
  35647. return undefined;
  35648. }
  35649. };
  35650. _proto._inferEndPosition = function _inferEndPosition() {
  35651. if (this.last && this.last.source && this.last.source.end) {
  35652. this.source = this.source || {};
  35653. this.source.end = this.source.end || {};
  35654. Object.assign(this.source.end, this.last.source.end);
  35655. }
  35656. };
  35657. _proto.each = function each(callback) {
  35658. if (!this.lastEach) {
  35659. this.lastEach = 0;
  35660. }
  35661. if (!this.indexes) {
  35662. this.indexes = {};
  35663. }
  35664. this.lastEach++;
  35665. var id = this.lastEach;
  35666. this.indexes[id] = 0;
  35667. if (!this.length) {
  35668. return undefined;
  35669. }
  35670. var index, result;
  35671. while (this.indexes[id] < this.length) {
  35672. index = this.indexes[id];
  35673. result = callback(this.at(index), index);
  35674. if (result === false) {
  35675. break;
  35676. }
  35677. this.indexes[id] += 1;
  35678. }
  35679. delete this.indexes[id];
  35680. if (result === false) {
  35681. return false;
  35682. }
  35683. };
  35684. _proto.walk = function walk(callback) {
  35685. return this.each(function (node, i) {
  35686. var result = callback(node, i);
  35687. if (result !== false && node.length) {
  35688. result = node.walk(callback);
  35689. }
  35690. if (result === false) {
  35691. return false;
  35692. }
  35693. });
  35694. };
  35695. _proto.walkAttributes = function walkAttributes(callback) {
  35696. var _this2 = this;
  35697. return this.walk(function (selector) {
  35698. if (selector.type === types$1.ATTRIBUTE) {
  35699. return callback.call(_this2, selector);
  35700. }
  35701. });
  35702. };
  35703. _proto.walkClasses = function walkClasses(callback) {
  35704. var _this3 = this;
  35705. return this.walk(function (selector) {
  35706. if (selector.type === types$1.CLASS) {
  35707. return callback.call(_this3, selector);
  35708. }
  35709. });
  35710. };
  35711. _proto.walkCombinators = function walkCombinators(callback) {
  35712. var _this4 = this;
  35713. return this.walk(function (selector) {
  35714. if (selector.type === types$1.COMBINATOR) {
  35715. return callback.call(_this4, selector);
  35716. }
  35717. });
  35718. };
  35719. _proto.walkComments = function walkComments(callback) {
  35720. var _this5 = this;
  35721. return this.walk(function (selector) {
  35722. if (selector.type === types$1.COMMENT) {
  35723. return callback.call(_this5, selector);
  35724. }
  35725. });
  35726. };
  35727. _proto.walkIds = function walkIds(callback) {
  35728. var _this6 = this;
  35729. return this.walk(function (selector) {
  35730. if (selector.type === types$1.ID) {
  35731. return callback.call(_this6, selector);
  35732. }
  35733. });
  35734. };
  35735. _proto.walkNesting = function walkNesting(callback) {
  35736. var _this7 = this;
  35737. return this.walk(function (selector) {
  35738. if (selector.type === types$1.NESTING) {
  35739. return callback.call(_this7, selector);
  35740. }
  35741. });
  35742. };
  35743. _proto.walkPseudos = function walkPseudos(callback) {
  35744. var _this8 = this;
  35745. return this.walk(function (selector) {
  35746. if (selector.type === types$1.PSEUDO) {
  35747. return callback.call(_this8, selector);
  35748. }
  35749. });
  35750. };
  35751. _proto.walkTags = function walkTags(callback) {
  35752. var _this9 = this;
  35753. return this.walk(function (selector) {
  35754. if (selector.type === types$1.TAG) {
  35755. return callback.call(_this9, selector);
  35756. }
  35757. });
  35758. };
  35759. _proto.walkUniversals = function walkUniversals(callback) {
  35760. var _this10 = this;
  35761. return this.walk(function (selector) {
  35762. if (selector.type === types$1.UNIVERSAL) {
  35763. return callback.call(_this10, selector);
  35764. }
  35765. });
  35766. };
  35767. _proto.split = function split(callback) {
  35768. var _this11 = this;
  35769. var current = [];
  35770. return this.reduce(function (memo, node, index) {
  35771. var split = callback.call(_this11, node);
  35772. current.push(node);
  35773. if (split) {
  35774. memo.push(current);
  35775. current = [];
  35776. } else if (index === _this11.length - 1) {
  35777. memo.push(current);
  35778. }
  35779. return memo;
  35780. }, []);
  35781. };
  35782. _proto.map = function map(callback) {
  35783. return this.nodes.map(callback);
  35784. };
  35785. _proto.reduce = function reduce(callback, memo) {
  35786. return this.nodes.reduce(callback, memo);
  35787. };
  35788. _proto.every = function every(callback) {
  35789. return this.nodes.every(callback);
  35790. };
  35791. _proto.some = function some(callback) {
  35792. return this.nodes.some(callback);
  35793. };
  35794. _proto.filter = function filter(callback) {
  35795. return this.nodes.filter(callback);
  35796. };
  35797. _proto.sort = function sort(callback) {
  35798. return this.nodes.sort(callback);
  35799. };
  35800. _proto.toString = function toString() {
  35801. return this.map(String).join('');
  35802. };
  35803. _createClass(Container, [{
  35804. key: "first",
  35805. get: function get() {
  35806. return this.at(0);
  35807. }
  35808. }, {
  35809. key: "last",
  35810. get: function get() {
  35811. return this.at(this.length - 1);
  35812. }
  35813. }, {
  35814. key: "length",
  35815. get: function get() {
  35816. return this.nodes.length;
  35817. }
  35818. }]);
  35819. return Container;
  35820. }(_node["default"]);
  35821. exports["default"] = Container;
  35822. module.exports = exports.default;
  35823. } (container, container.exports));
  35824. var containerExports = container.exports;
  35825. (function (module, exports) {
  35826. exports.__esModule = true;
  35827. exports["default"] = void 0;
  35828. var _container = _interopRequireDefault(containerExports);
  35829. var _types = types;
  35830. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35831. 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); } }
  35832. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  35833. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35834. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35835. var Root = /*#__PURE__*/function (_Container) {
  35836. _inheritsLoose(Root, _Container);
  35837. function Root(opts) {
  35838. var _this;
  35839. _this = _Container.call(this, opts) || this;
  35840. _this.type = _types.ROOT;
  35841. return _this;
  35842. }
  35843. var _proto = Root.prototype;
  35844. _proto.toString = function toString() {
  35845. var str = this.reduce(function (memo, selector) {
  35846. memo.push(String(selector));
  35847. return memo;
  35848. }, []).join(',');
  35849. return this.trailingComma ? str + ',' : str;
  35850. };
  35851. _proto.error = function error(message, options) {
  35852. if (this._error) {
  35853. return this._error(message, options);
  35854. } else {
  35855. return new Error(message);
  35856. }
  35857. };
  35858. _createClass(Root, [{
  35859. key: "errorGenerator",
  35860. set: function set(handler) {
  35861. this._error = handler;
  35862. }
  35863. }]);
  35864. return Root;
  35865. }(_container["default"]);
  35866. exports["default"] = Root;
  35867. module.exports = exports.default;
  35868. } (root$1, root$1.exports));
  35869. var rootExports = root$1.exports;
  35870. var selector$1 = {exports: {}};
  35871. (function (module, exports) {
  35872. exports.__esModule = true;
  35873. exports["default"] = void 0;
  35874. var _container = _interopRequireDefault(containerExports);
  35875. var _types = types;
  35876. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  35877. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  35878. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  35879. var Selector = /*#__PURE__*/function (_Container) {
  35880. _inheritsLoose(Selector, _Container);
  35881. function Selector(opts) {
  35882. var _this;
  35883. _this = _Container.call(this, opts) || this;
  35884. _this.type = _types.SELECTOR;
  35885. return _this;
  35886. }
  35887. return Selector;
  35888. }(_container["default"]);
  35889. exports["default"] = Selector;
  35890. module.exports = exports.default;
  35891. } (selector$1, selector$1.exports));
  35892. var selectorExports = selector$1.exports;
  35893. var className$1 = {exports: {}};
  35894. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  35895. var object = {};
  35896. var hasOwnProperty$1 = object.hasOwnProperty;
  35897. var merge$2 = function merge(options, defaults) {
  35898. if (!options) {
  35899. return defaults;
  35900. }
  35901. var result = {};
  35902. for (var key in defaults) {
  35903. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  35904. // only recognized option names are used.
  35905. result[key] = hasOwnProperty$1.call(options, key) ? options[key] : defaults[key];
  35906. }
  35907. return result;
  35908. };
  35909. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  35910. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  35911. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  35912. // https://mathiasbynens.be/notes/css-escapes#css
  35913. var cssesc = function cssesc(string, options) {
  35914. options = merge$2(options, cssesc.options);
  35915. if (options.quotes != 'single' && options.quotes != 'double') {
  35916. options.quotes = 'single';
  35917. }
  35918. var quote = options.quotes == 'double' ? '"' : '\'';
  35919. var isIdentifier = options.isIdentifier;
  35920. var firstChar = string.charAt(0);
  35921. var output = '';
  35922. var counter = 0;
  35923. var length = string.length;
  35924. while (counter < length) {
  35925. var character = string.charAt(counter++);
  35926. var codePoint = character.charCodeAt();
  35927. var value = void 0;
  35928. // If it’s not a printable ASCII character…
  35929. if (codePoint < 0x20 || codePoint > 0x7E) {
  35930. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  35931. // It’s a high surrogate, and there is a next character.
  35932. var extra = string.charCodeAt(counter++);
  35933. if ((extra & 0xFC00) == 0xDC00) {
  35934. // next character is low surrogate
  35935. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  35936. } else {
  35937. // It’s an unmatched surrogate; only append this code unit, in case
  35938. // the next code unit is the high surrogate of a surrogate pair.
  35939. counter--;
  35940. }
  35941. }
  35942. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35943. } else {
  35944. if (options.escapeEverything) {
  35945. if (regexAnySingleEscape.test(character)) {
  35946. value = '\\' + character;
  35947. } else {
  35948. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35949. }
  35950. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  35951. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  35952. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  35953. value = '\\' + character;
  35954. } else {
  35955. value = character;
  35956. }
  35957. }
  35958. output += value;
  35959. }
  35960. if (isIdentifier) {
  35961. if (/^-[-\d]/.test(output)) {
  35962. output = '\\-' + output.slice(1);
  35963. } else if (/\d/.test(firstChar)) {
  35964. output = '\\3' + firstChar + ' ' + output.slice(1);
  35965. }
  35966. }
  35967. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  35968. // since they’re redundant. Note that this is only possible if the escape
  35969. // sequence isn’t preceded by an odd number of backslashes.
  35970. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  35971. if ($1 && $1.length % 2) {
  35972. // It’s not safe to remove the space, so don’t.
  35973. return $0;
  35974. }
  35975. // Strip the space.
  35976. return ($1 || '') + $2;
  35977. });
  35978. if (!isIdentifier && options.wrap) {
  35979. return quote + output + quote;
  35980. }
  35981. return output;
  35982. };
  35983. // Expose default options (so they can be overridden globally).
  35984. cssesc.options = {
  35985. 'escapeEverything': false,
  35986. 'isIdentifier': false,
  35987. 'quotes': 'single',
  35988. 'wrap': false
  35989. };
  35990. cssesc.version = '3.0.0';
  35991. var cssesc_1 = cssesc;
  35992. (function (module, exports) {
  35993. exports.__esModule = true;
  35994. exports["default"] = void 0;
  35995. var _cssesc = _interopRequireDefault(cssesc_1);
  35996. var _util = util$6;
  35997. var _node = _interopRequireDefault(nodeExports);
  35998. var _types = types;
  35999. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36000. 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); } }
  36001. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36002. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36003. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36004. var ClassName = /*#__PURE__*/function (_Node) {
  36005. _inheritsLoose(ClassName, _Node);
  36006. function ClassName(opts) {
  36007. var _this;
  36008. _this = _Node.call(this, opts) || this;
  36009. _this.type = _types.CLASS;
  36010. _this._constructed = true;
  36011. return _this;
  36012. }
  36013. var _proto = ClassName.prototype;
  36014. _proto.valueToString = function valueToString() {
  36015. return '.' + _Node.prototype.valueToString.call(this);
  36016. };
  36017. _createClass(ClassName, [{
  36018. key: "value",
  36019. get: function get() {
  36020. return this._value;
  36021. },
  36022. set: function set(v) {
  36023. if (this._constructed) {
  36024. var escaped = (0, _cssesc["default"])(v, {
  36025. isIdentifier: true
  36026. });
  36027. if (escaped !== v) {
  36028. (0, _util.ensureObject)(this, "raws");
  36029. this.raws.value = escaped;
  36030. } else if (this.raws) {
  36031. delete this.raws.value;
  36032. }
  36033. }
  36034. this._value = v;
  36035. }
  36036. }]);
  36037. return ClassName;
  36038. }(_node["default"]);
  36039. exports["default"] = ClassName;
  36040. module.exports = exports.default;
  36041. } (className$1, className$1.exports));
  36042. var classNameExports = className$1.exports;
  36043. var comment$2 = {exports: {}};
  36044. (function (module, exports) {
  36045. exports.__esModule = true;
  36046. exports["default"] = void 0;
  36047. var _node = _interopRequireDefault(nodeExports);
  36048. var _types = types;
  36049. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36050. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36051. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36052. var Comment = /*#__PURE__*/function (_Node) {
  36053. _inheritsLoose(Comment, _Node);
  36054. function Comment(opts) {
  36055. var _this;
  36056. _this = _Node.call(this, opts) || this;
  36057. _this.type = _types.COMMENT;
  36058. return _this;
  36059. }
  36060. return Comment;
  36061. }(_node["default"]);
  36062. exports["default"] = Comment;
  36063. module.exports = exports.default;
  36064. } (comment$2, comment$2.exports));
  36065. var commentExports = comment$2.exports;
  36066. var id$1 = {exports: {}};
  36067. (function (module, exports) {
  36068. exports.__esModule = true;
  36069. exports["default"] = void 0;
  36070. var _node = _interopRequireDefault(nodeExports);
  36071. var _types = types;
  36072. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36073. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36074. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36075. var ID = /*#__PURE__*/function (_Node) {
  36076. _inheritsLoose(ID, _Node);
  36077. function ID(opts) {
  36078. var _this;
  36079. _this = _Node.call(this, opts) || this;
  36080. _this.type = _types.ID;
  36081. return _this;
  36082. }
  36083. var _proto = ID.prototype;
  36084. _proto.valueToString = function valueToString() {
  36085. return '#' + _Node.prototype.valueToString.call(this);
  36086. };
  36087. return ID;
  36088. }(_node["default"]);
  36089. exports["default"] = ID;
  36090. module.exports = exports.default;
  36091. } (id$1, id$1.exports));
  36092. var idExports = id$1.exports;
  36093. var tag$1 = {exports: {}};
  36094. var namespace = {exports: {}};
  36095. (function (module, exports) {
  36096. exports.__esModule = true;
  36097. exports["default"] = void 0;
  36098. var _cssesc = _interopRequireDefault(cssesc_1);
  36099. var _util = util$6;
  36100. var _node = _interopRequireDefault(nodeExports);
  36101. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36102. 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); } }
  36103. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36104. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36105. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36106. var Namespace = /*#__PURE__*/function (_Node) {
  36107. _inheritsLoose(Namespace, _Node);
  36108. function Namespace() {
  36109. return _Node.apply(this, arguments) || this;
  36110. }
  36111. var _proto = Namespace.prototype;
  36112. _proto.qualifiedName = function qualifiedName(value) {
  36113. if (this.namespace) {
  36114. return this.namespaceString + "|" + value;
  36115. } else {
  36116. return value;
  36117. }
  36118. };
  36119. _proto.valueToString = function valueToString() {
  36120. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  36121. };
  36122. _createClass(Namespace, [{
  36123. key: "namespace",
  36124. get: function get() {
  36125. return this._namespace;
  36126. },
  36127. set: function set(namespace) {
  36128. if (namespace === true || namespace === "*" || namespace === "&") {
  36129. this._namespace = namespace;
  36130. if (this.raws) {
  36131. delete this.raws.namespace;
  36132. }
  36133. return;
  36134. }
  36135. var escaped = (0, _cssesc["default"])(namespace, {
  36136. isIdentifier: true
  36137. });
  36138. this._namespace = namespace;
  36139. if (escaped !== namespace) {
  36140. (0, _util.ensureObject)(this, "raws");
  36141. this.raws.namespace = escaped;
  36142. } else if (this.raws) {
  36143. delete this.raws.namespace;
  36144. }
  36145. }
  36146. }, {
  36147. key: "ns",
  36148. get: function get() {
  36149. return this._namespace;
  36150. },
  36151. set: function set(namespace) {
  36152. this.namespace = namespace;
  36153. }
  36154. }, {
  36155. key: "namespaceString",
  36156. get: function get() {
  36157. if (this.namespace) {
  36158. var ns = this.stringifyProperty("namespace");
  36159. if (ns === true) {
  36160. return '';
  36161. } else {
  36162. return ns;
  36163. }
  36164. } else {
  36165. return '';
  36166. }
  36167. }
  36168. }]);
  36169. return Namespace;
  36170. }(_node["default"]);
  36171. exports["default"] = Namespace;
  36172. module.exports = exports.default;
  36173. } (namespace, namespace.exports));
  36174. var namespaceExports = namespace.exports;
  36175. (function (module, exports) {
  36176. exports.__esModule = true;
  36177. exports["default"] = void 0;
  36178. var _namespace = _interopRequireDefault(namespaceExports);
  36179. var _types = types;
  36180. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36181. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36182. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36183. var Tag = /*#__PURE__*/function (_Namespace) {
  36184. _inheritsLoose(Tag, _Namespace);
  36185. function Tag(opts) {
  36186. var _this;
  36187. _this = _Namespace.call(this, opts) || this;
  36188. _this.type = _types.TAG;
  36189. return _this;
  36190. }
  36191. return Tag;
  36192. }(_namespace["default"]);
  36193. exports["default"] = Tag;
  36194. module.exports = exports.default;
  36195. } (tag$1, tag$1.exports));
  36196. var tagExports = tag$1.exports;
  36197. var string$1 = {exports: {}};
  36198. (function (module, exports) {
  36199. exports.__esModule = true;
  36200. exports["default"] = void 0;
  36201. var _node = _interopRequireDefault(nodeExports);
  36202. var _types = types;
  36203. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36204. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36205. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36206. var String = /*#__PURE__*/function (_Node) {
  36207. _inheritsLoose(String, _Node);
  36208. function String(opts) {
  36209. var _this;
  36210. _this = _Node.call(this, opts) || this;
  36211. _this.type = _types.STRING;
  36212. return _this;
  36213. }
  36214. return String;
  36215. }(_node["default"]);
  36216. exports["default"] = String;
  36217. module.exports = exports.default;
  36218. } (string$1, string$1.exports));
  36219. var stringExports = string$1.exports;
  36220. var pseudo$1 = {exports: {}};
  36221. (function (module, exports) {
  36222. exports.__esModule = true;
  36223. exports["default"] = void 0;
  36224. var _container = _interopRequireDefault(containerExports);
  36225. var _types = types;
  36226. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36227. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36228. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36229. var Pseudo = /*#__PURE__*/function (_Container) {
  36230. _inheritsLoose(Pseudo, _Container);
  36231. function Pseudo(opts) {
  36232. var _this;
  36233. _this = _Container.call(this, opts) || this;
  36234. _this.type = _types.PSEUDO;
  36235. return _this;
  36236. }
  36237. var _proto = Pseudo.prototype;
  36238. _proto.toString = function toString() {
  36239. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  36240. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  36241. };
  36242. return Pseudo;
  36243. }(_container["default"]);
  36244. exports["default"] = Pseudo;
  36245. module.exports = exports.default;
  36246. } (pseudo$1, pseudo$1.exports));
  36247. var pseudoExports = pseudo$1.exports;
  36248. var attribute$1 = {};
  36249. /**
  36250. * For Node.js, simply re-export the core `util.deprecate` function.
  36251. */
  36252. var node = require$$0$1.deprecate;
  36253. (function (exports) {
  36254. exports.__esModule = true;
  36255. exports["default"] = void 0;
  36256. exports.unescapeValue = unescapeValue;
  36257. var _cssesc = _interopRequireDefault(cssesc_1);
  36258. var _unesc = _interopRequireDefault(unescExports);
  36259. var _namespace = _interopRequireDefault(namespaceExports);
  36260. var _types = types;
  36261. var _CSSESC_QUOTE_OPTIONS;
  36262. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36263. 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); } }
  36264. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  36265. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36266. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36267. var deprecate = node;
  36268. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  36269. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  36270. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  36271. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  36272. function unescapeValue(value) {
  36273. var deprecatedUsage = false;
  36274. var quoteMark = null;
  36275. var unescaped = value;
  36276. var m = unescaped.match(WRAPPED_IN_QUOTES);
  36277. if (m) {
  36278. quoteMark = m[1];
  36279. unescaped = m[2];
  36280. }
  36281. unescaped = (0, _unesc["default"])(unescaped);
  36282. if (unescaped !== value) {
  36283. deprecatedUsage = true;
  36284. }
  36285. return {
  36286. deprecatedUsage: deprecatedUsage,
  36287. unescaped: unescaped,
  36288. quoteMark: quoteMark
  36289. };
  36290. }
  36291. function handleDeprecatedContructorOpts(opts) {
  36292. if (opts.quoteMark !== undefined) {
  36293. return opts;
  36294. }
  36295. if (opts.value === undefined) {
  36296. return opts;
  36297. }
  36298. warnOfDeprecatedConstructor();
  36299. var _unescapeValue = unescapeValue(opts.value),
  36300. quoteMark = _unescapeValue.quoteMark,
  36301. unescaped = _unescapeValue.unescaped;
  36302. if (!opts.raws) {
  36303. opts.raws = {};
  36304. }
  36305. if (opts.raws.value === undefined) {
  36306. opts.raws.value = opts.value;
  36307. }
  36308. opts.value = unescaped;
  36309. opts.quoteMark = quoteMark;
  36310. return opts;
  36311. }
  36312. var Attribute = /*#__PURE__*/function (_Namespace) {
  36313. _inheritsLoose(Attribute, _Namespace);
  36314. function Attribute(opts) {
  36315. var _this;
  36316. if (opts === void 0) {
  36317. opts = {};
  36318. }
  36319. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  36320. _this.type = _types.ATTRIBUTE;
  36321. _this.raws = _this.raws || {};
  36322. Object.defineProperty(_this.raws, 'unquoted', {
  36323. get: deprecate(function () {
  36324. return _this.value;
  36325. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  36326. set: deprecate(function () {
  36327. return _this.value;
  36328. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  36329. });
  36330. _this._constructed = true;
  36331. return _this;
  36332. }
  36333. /**
  36334. * Returns the Attribute's value quoted such that it would be legal to use
  36335. * in the value of a css file. The original value's quotation setting
  36336. * used for stringification is left unchanged. See `setValue(value, options)`
  36337. * if you want to control the quote settings of a new value for the attribute.
  36338. *
  36339. * You can also change the quotation used for the current value by setting quoteMark.
  36340. *
  36341. * Options:
  36342. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  36343. * option is not set, the original value for quoteMark will be used. If
  36344. * indeterminate, a double quote is used. The legal values are:
  36345. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  36346. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  36347. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  36348. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  36349. * over the quoteMark option value.
  36350. * * smart {boolean} - if true, will select a quote mark based on the value
  36351. * and the other options specified here. See the `smartQuoteMark()`
  36352. * method.
  36353. **/
  36354. var _proto = Attribute.prototype;
  36355. _proto.getQuotedValue = function getQuotedValue(options) {
  36356. if (options === void 0) {
  36357. options = {};
  36358. }
  36359. var quoteMark = this._determineQuoteMark(options);
  36360. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  36361. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  36362. return escaped;
  36363. };
  36364. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  36365. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  36366. }
  36367. /**
  36368. * Set the unescaped value with the specified quotation options. The value
  36369. * provided must not include any wrapping quote marks -- those quotes will
  36370. * be interpreted as part of the value and escaped accordingly.
  36371. */;
  36372. _proto.setValue = function setValue(value, options) {
  36373. if (options === void 0) {
  36374. options = {};
  36375. }
  36376. this._value = value;
  36377. this._quoteMark = this._determineQuoteMark(options);
  36378. this._syncRawValue();
  36379. }
  36380. /**
  36381. * Intelligently select a quoteMark value based on the value's contents. If
  36382. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  36383. * mark will be picked that minimizes the number of escapes.
  36384. *
  36385. * If there's no clear winner, the quote mark from these options is used,
  36386. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  36387. * true). If the quoteMark is unspecified, a double quote is used.
  36388. *
  36389. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  36390. * from the quoteValue method.
  36391. */;
  36392. _proto.smartQuoteMark = function smartQuoteMark(options) {
  36393. var v = this.value;
  36394. var numSingleQuotes = v.replace(/[^']/g, '').length;
  36395. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  36396. if (numSingleQuotes + numDoubleQuotes === 0) {
  36397. var escaped = (0, _cssesc["default"])(v, {
  36398. isIdentifier: true
  36399. });
  36400. if (escaped === v) {
  36401. return Attribute.NO_QUOTE;
  36402. } else {
  36403. var pref = this.preferredQuoteMark(options);
  36404. if (pref === Attribute.NO_QUOTE) {
  36405. // pick a quote mark that isn't none and see if it's smaller
  36406. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  36407. var opts = CSSESC_QUOTE_OPTIONS[quote];
  36408. var quoteValue = (0, _cssesc["default"])(v, opts);
  36409. if (quoteValue.length < escaped.length) {
  36410. return quote;
  36411. }
  36412. }
  36413. return pref;
  36414. }
  36415. } else if (numDoubleQuotes === numSingleQuotes) {
  36416. return this.preferredQuoteMark(options);
  36417. } else if (numDoubleQuotes < numSingleQuotes) {
  36418. return Attribute.DOUBLE_QUOTE;
  36419. } else {
  36420. return Attribute.SINGLE_QUOTE;
  36421. }
  36422. }
  36423. /**
  36424. * Selects the preferred quote mark based on the options and the current quote mark value.
  36425. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  36426. * instead.
  36427. */;
  36428. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  36429. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  36430. if (quoteMark === undefined) {
  36431. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  36432. }
  36433. if (quoteMark === undefined) {
  36434. quoteMark = Attribute.DOUBLE_QUOTE;
  36435. }
  36436. return quoteMark;
  36437. };
  36438. _proto._syncRawValue = function _syncRawValue() {
  36439. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  36440. if (rawValue === this._value) {
  36441. if (this.raws) {
  36442. delete this.raws.value;
  36443. }
  36444. } else {
  36445. this.raws.value = rawValue;
  36446. }
  36447. };
  36448. _proto._handleEscapes = function _handleEscapes(prop, value) {
  36449. if (this._constructed) {
  36450. var escaped = (0, _cssesc["default"])(value, {
  36451. isIdentifier: true
  36452. });
  36453. if (escaped !== value) {
  36454. this.raws[prop] = escaped;
  36455. } else {
  36456. delete this.raws[prop];
  36457. }
  36458. }
  36459. };
  36460. _proto._spacesFor = function _spacesFor(name) {
  36461. var attrSpaces = {
  36462. before: '',
  36463. after: ''
  36464. };
  36465. var spaces = this.spaces[name] || {};
  36466. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  36467. return Object.assign(attrSpaces, spaces, rawSpaces);
  36468. };
  36469. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  36470. if (spaceName === void 0) {
  36471. spaceName = name;
  36472. }
  36473. if (concat === void 0) {
  36474. concat = defaultAttrConcat;
  36475. }
  36476. var attrSpaces = this._spacesFor(spaceName);
  36477. return concat(this.stringifyProperty(name), attrSpaces);
  36478. }
  36479. /**
  36480. * returns the offset of the attribute part specified relative to the
  36481. * start of the node of the output string.
  36482. *
  36483. * * "ns" - alias for "namespace"
  36484. * * "namespace" - the namespace if it exists.
  36485. * * "attribute" - the attribute name
  36486. * * "attributeNS" - the start of the attribute or its namespace
  36487. * * "operator" - the match operator of the attribute
  36488. * * "value" - The value (string or identifier)
  36489. * * "insensitive" - the case insensitivity flag;
  36490. * @param part One of the possible values inside an attribute.
  36491. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  36492. */;
  36493. _proto.offsetOf = function offsetOf(name) {
  36494. var count = 1;
  36495. var attributeSpaces = this._spacesFor("attribute");
  36496. count += attributeSpaces.before.length;
  36497. if (name === "namespace" || name === "ns") {
  36498. return this.namespace ? count : -1;
  36499. }
  36500. if (name === "attributeNS") {
  36501. return count;
  36502. }
  36503. count += this.namespaceString.length;
  36504. if (this.namespace) {
  36505. count += 1;
  36506. }
  36507. if (name === "attribute") {
  36508. return count;
  36509. }
  36510. count += this.stringifyProperty("attribute").length;
  36511. count += attributeSpaces.after.length;
  36512. var operatorSpaces = this._spacesFor("operator");
  36513. count += operatorSpaces.before.length;
  36514. var operator = this.stringifyProperty("operator");
  36515. if (name === "operator") {
  36516. return operator ? count : -1;
  36517. }
  36518. count += operator.length;
  36519. count += operatorSpaces.after.length;
  36520. var valueSpaces = this._spacesFor("value");
  36521. count += valueSpaces.before.length;
  36522. var value = this.stringifyProperty("value");
  36523. if (name === "value") {
  36524. return value ? count : -1;
  36525. }
  36526. count += value.length;
  36527. count += valueSpaces.after.length;
  36528. var insensitiveSpaces = this._spacesFor("insensitive");
  36529. count += insensitiveSpaces.before.length;
  36530. if (name === "insensitive") {
  36531. return this.insensitive ? count : -1;
  36532. }
  36533. return -1;
  36534. };
  36535. _proto.toString = function toString() {
  36536. var _this2 = this;
  36537. var selector = [this.rawSpaceBefore, '['];
  36538. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  36539. if (this.operator && (this.value || this.value === '')) {
  36540. selector.push(this._stringFor('operator'));
  36541. selector.push(this._stringFor('value'));
  36542. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  36543. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  36544. attrSpaces.before = " ";
  36545. }
  36546. return defaultAttrConcat(attrValue, attrSpaces);
  36547. }));
  36548. }
  36549. selector.push(']');
  36550. selector.push(this.rawSpaceAfter);
  36551. return selector.join('');
  36552. };
  36553. _createClass(Attribute, [{
  36554. key: "quoted",
  36555. get: function get() {
  36556. var qm = this.quoteMark;
  36557. return qm === "'" || qm === '"';
  36558. },
  36559. set: function set(value) {
  36560. warnOfDeprecatedQuotedAssignment();
  36561. }
  36562. /**
  36563. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  36564. * returns `null` if the value is not quoted.
  36565. * returns `undefined` if the quotation state is unknown (this can happen when
  36566. * the attribute is constructed without specifying a quote mark.)
  36567. */
  36568. }, {
  36569. key: "quoteMark",
  36570. get: function get() {
  36571. return this._quoteMark;
  36572. }
  36573. /**
  36574. * Set the quote mark to be used by this attribute's value.
  36575. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  36576. * value is updated accordingly.
  36577. *
  36578. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  36579. */,
  36580. set: function set(quoteMark) {
  36581. if (!this._constructed) {
  36582. this._quoteMark = quoteMark;
  36583. return;
  36584. }
  36585. if (this._quoteMark !== quoteMark) {
  36586. this._quoteMark = quoteMark;
  36587. this._syncRawValue();
  36588. }
  36589. }
  36590. }, {
  36591. key: "qualifiedAttribute",
  36592. get: function get() {
  36593. return this.qualifiedName(this.raws.attribute || this.attribute);
  36594. }
  36595. }, {
  36596. key: "insensitiveFlag",
  36597. get: function get() {
  36598. return this.insensitive ? 'i' : '';
  36599. }
  36600. }, {
  36601. key: "value",
  36602. get: function get() {
  36603. return this._value;
  36604. },
  36605. set:
  36606. /**
  36607. * Before 3.0, the value had to be set to an escaped value including any wrapped
  36608. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  36609. * is unescaped during parsing and any quote marks are removed.
  36610. *
  36611. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  36612. * a deprecation warning is raised when the new value contains any characters that would
  36613. * require escaping (including if it contains wrapped quotes).
  36614. *
  36615. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  36616. * how the new value is quoted.
  36617. */
  36618. function set(v) {
  36619. if (this._constructed) {
  36620. var _unescapeValue2 = unescapeValue(v),
  36621. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  36622. unescaped = _unescapeValue2.unescaped,
  36623. quoteMark = _unescapeValue2.quoteMark;
  36624. if (deprecatedUsage) {
  36625. warnOfDeprecatedValueAssignment();
  36626. }
  36627. if (unescaped === this._value && quoteMark === this._quoteMark) {
  36628. return;
  36629. }
  36630. this._value = unescaped;
  36631. this._quoteMark = quoteMark;
  36632. this._syncRawValue();
  36633. } else {
  36634. this._value = v;
  36635. }
  36636. }
  36637. }, {
  36638. key: "insensitive",
  36639. get: function get() {
  36640. return this._insensitive;
  36641. }
  36642. /**
  36643. * Set the case insensitive flag.
  36644. * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
  36645. * of the attribute is updated accordingly.
  36646. *
  36647. * @param {true | false} insensitive true if the attribute should match case-insensitively.
  36648. */,
  36649. set: function set(insensitive) {
  36650. if (!insensitive) {
  36651. this._insensitive = false;
  36652. // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
  36653. // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
  36654. if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
  36655. this.raws.insensitiveFlag = undefined;
  36656. }
  36657. }
  36658. this._insensitive = insensitive;
  36659. }
  36660. }, {
  36661. key: "attribute",
  36662. get: function get() {
  36663. return this._attribute;
  36664. },
  36665. set: function set(name) {
  36666. this._handleEscapes("attribute", name);
  36667. this._attribute = name;
  36668. }
  36669. }]);
  36670. return Attribute;
  36671. }(_namespace["default"]);
  36672. exports["default"] = Attribute;
  36673. Attribute.NO_QUOTE = null;
  36674. Attribute.SINGLE_QUOTE = "'";
  36675. Attribute.DOUBLE_QUOTE = '"';
  36676. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  36677. "'": {
  36678. quotes: 'single',
  36679. wrap: true
  36680. },
  36681. '"': {
  36682. quotes: 'double',
  36683. wrap: true
  36684. }
  36685. }, _CSSESC_QUOTE_OPTIONS[null] = {
  36686. isIdentifier: true
  36687. }, _CSSESC_QUOTE_OPTIONS);
  36688. function defaultAttrConcat(attrValue, attrSpaces) {
  36689. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  36690. }
  36691. } (attribute$1));
  36692. var universal$1 = {exports: {}};
  36693. (function (module, exports) {
  36694. exports.__esModule = true;
  36695. exports["default"] = void 0;
  36696. var _namespace = _interopRequireDefault(namespaceExports);
  36697. var _types = types;
  36698. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36699. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36700. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36701. var Universal = /*#__PURE__*/function (_Namespace) {
  36702. _inheritsLoose(Universal, _Namespace);
  36703. function Universal(opts) {
  36704. var _this;
  36705. _this = _Namespace.call(this, opts) || this;
  36706. _this.type = _types.UNIVERSAL;
  36707. _this.value = '*';
  36708. return _this;
  36709. }
  36710. return Universal;
  36711. }(_namespace["default"]);
  36712. exports["default"] = Universal;
  36713. module.exports = exports.default;
  36714. } (universal$1, universal$1.exports));
  36715. var universalExports = universal$1.exports;
  36716. var combinator$2 = {exports: {}};
  36717. (function (module, exports) {
  36718. exports.__esModule = true;
  36719. exports["default"] = void 0;
  36720. var _node = _interopRequireDefault(nodeExports);
  36721. var _types = types;
  36722. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36723. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36724. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36725. var Combinator = /*#__PURE__*/function (_Node) {
  36726. _inheritsLoose(Combinator, _Node);
  36727. function Combinator(opts) {
  36728. var _this;
  36729. _this = _Node.call(this, opts) || this;
  36730. _this.type = _types.COMBINATOR;
  36731. return _this;
  36732. }
  36733. return Combinator;
  36734. }(_node["default"]);
  36735. exports["default"] = Combinator;
  36736. module.exports = exports.default;
  36737. } (combinator$2, combinator$2.exports));
  36738. var combinatorExports = combinator$2.exports;
  36739. var nesting$1 = {exports: {}};
  36740. (function (module, exports) {
  36741. exports.__esModule = true;
  36742. exports["default"] = void 0;
  36743. var _node = _interopRequireDefault(nodeExports);
  36744. var _types = types;
  36745. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  36746. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  36747. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  36748. var Nesting = /*#__PURE__*/function (_Node) {
  36749. _inheritsLoose(Nesting, _Node);
  36750. function Nesting(opts) {
  36751. var _this;
  36752. _this = _Node.call(this, opts) || this;
  36753. _this.type = _types.NESTING;
  36754. _this.value = '&';
  36755. return _this;
  36756. }
  36757. return Nesting;
  36758. }(_node["default"]);
  36759. exports["default"] = Nesting;
  36760. module.exports = exports.default;
  36761. } (nesting$1, nesting$1.exports));
  36762. var nestingExports = nesting$1.exports;
  36763. var sortAscending = {exports: {}};
  36764. (function (module, exports) {
  36765. exports.__esModule = true;
  36766. exports["default"] = sortAscending;
  36767. function sortAscending(list) {
  36768. return list.sort(function (a, b) {
  36769. return a - b;
  36770. });
  36771. }
  36772. module.exports = exports.default;
  36773. } (sortAscending, sortAscending.exports));
  36774. var sortAscendingExports = sortAscending.exports;
  36775. var tokenize = {};
  36776. var tokenTypes = {};
  36777. tokenTypes.__esModule = true;
  36778. 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;
  36779. var ampersand = 38; // `&`.charCodeAt(0);
  36780. tokenTypes.ampersand = ampersand;
  36781. var asterisk = 42; // `*`.charCodeAt(0);
  36782. tokenTypes.asterisk = asterisk;
  36783. var at = 64; // `@`.charCodeAt(0);
  36784. tokenTypes.at = at;
  36785. var comma$1 = 44; // `,`.charCodeAt(0);
  36786. tokenTypes.comma = comma$1;
  36787. var colon = 58; // `:`.charCodeAt(0);
  36788. tokenTypes.colon = colon;
  36789. var semicolon$1 = 59; // `;`.charCodeAt(0);
  36790. tokenTypes.semicolon = semicolon$1;
  36791. var openParenthesis = 40; // `(`.charCodeAt(0);
  36792. tokenTypes.openParenthesis = openParenthesis;
  36793. var closeParenthesis = 41; // `)`.charCodeAt(0);
  36794. tokenTypes.closeParenthesis = closeParenthesis;
  36795. var openSquare = 91; // `[`.charCodeAt(0);
  36796. tokenTypes.openSquare = openSquare;
  36797. var closeSquare = 93; // `]`.charCodeAt(0);
  36798. tokenTypes.closeSquare = closeSquare;
  36799. var dollar = 36; // `$`.charCodeAt(0);
  36800. tokenTypes.dollar = dollar;
  36801. var tilde = 126; // `~`.charCodeAt(0);
  36802. tokenTypes.tilde = tilde;
  36803. var caret = 94; // `^`.charCodeAt(0);
  36804. tokenTypes.caret = caret;
  36805. var plus = 43; // `+`.charCodeAt(0);
  36806. tokenTypes.plus = plus;
  36807. var equals = 61; // `=`.charCodeAt(0);
  36808. tokenTypes.equals = equals;
  36809. var pipe = 124; // `|`.charCodeAt(0);
  36810. tokenTypes.pipe = pipe;
  36811. var greaterThan = 62; // `>`.charCodeAt(0);
  36812. tokenTypes.greaterThan = greaterThan;
  36813. var space = 32; // ` `.charCodeAt(0);
  36814. tokenTypes.space = space;
  36815. var singleQuote = 39; // `'`.charCodeAt(0);
  36816. tokenTypes.singleQuote = singleQuote;
  36817. var doubleQuote = 34; // `"`.charCodeAt(0);
  36818. tokenTypes.doubleQuote = doubleQuote;
  36819. var slash = 47; // `/`.charCodeAt(0);
  36820. tokenTypes.slash = slash;
  36821. var bang = 33; // `!`.charCodeAt(0);
  36822. tokenTypes.bang = bang;
  36823. var backslash = 92; // '\\'.charCodeAt(0);
  36824. tokenTypes.backslash = backslash;
  36825. var cr = 13; // '\r'.charCodeAt(0);
  36826. tokenTypes.cr = cr;
  36827. var feed = 12; // '\f'.charCodeAt(0);
  36828. tokenTypes.feed = feed;
  36829. var newline = 10; // '\n'.charCodeAt(0);
  36830. tokenTypes.newline = newline;
  36831. var tab = 9; // '\t'.charCodeAt(0);
  36832. // Expose aliases primarily for readability.
  36833. tokenTypes.tab = tab;
  36834. var str = singleQuote;
  36835. // No good single character representation!
  36836. tokenTypes.str = str;
  36837. var comment$1 = -1;
  36838. tokenTypes.comment = comment$1;
  36839. var word = -2;
  36840. tokenTypes.word = word;
  36841. var combinator$1 = -3;
  36842. tokenTypes.combinator = combinator$1;
  36843. (function (exports) {
  36844. exports.__esModule = true;
  36845. exports.FIELDS = void 0;
  36846. exports["default"] = tokenize;
  36847. var t = _interopRequireWildcard(tokenTypes);
  36848. var _unescapable, _wordDelimiters;
  36849. 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); }
  36850. 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; }
  36851. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  36852. 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);
  36853. var hex = {};
  36854. var hexChars = "0123456789abcdefABCDEF";
  36855. for (var i = 0; i < hexChars.length; i++) {
  36856. hex[hexChars.charCodeAt(i)] = true;
  36857. }
  36858. /**
  36859. * Returns the last index of the bar css word
  36860. * @param {string} css The string in which the word begins
  36861. * @param {number} start The index into the string where word's first letter occurs
  36862. */
  36863. function consumeWord(css, start) {
  36864. var next = start;
  36865. var code;
  36866. do {
  36867. code = css.charCodeAt(next);
  36868. if (wordDelimiters[code]) {
  36869. return next - 1;
  36870. } else if (code === t.backslash) {
  36871. next = consumeEscape(css, next) + 1;
  36872. } else {
  36873. // All other characters are part of the word
  36874. next++;
  36875. }
  36876. } while (next < css.length);
  36877. return next - 1;
  36878. }
  36879. /**
  36880. * Returns the last index of the escape sequence
  36881. * @param {string} css The string in which the sequence begins
  36882. * @param {number} start The index into the string where escape character (`\`) occurs.
  36883. */
  36884. function consumeEscape(css, start) {
  36885. var next = start;
  36886. var code = css.charCodeAt(next + 1);
  36887. if (unescapable[code]) ; else if (hex[code]) {
  36888. var hexDigits = 0;
  36889. // consume up to 6 hex chars
  36890. do {
  36891. next++;
  36892. hexDigits++;
  36893. code = css.charCodeAt(next + 1);
  36894. } while (hex[code] && hexDigits < 6);
  36895. // if fewer than 6 hex chars, a trailing space ends the escape
  36896. if (hexDigits < 6 && code === t.space) {
  36897. next++;
  36898. }
  36899. } else {
  36900. // the next char is part of the current word
  36901. next++;
  36902. }
  36903. return next;
  36904. }
  36905. var FIELDS = {
  36906. TYPE: 0,
  36907. START_LINE: 1,
  36908. START_COL: 2,
  36909. END_LINE: 3,
  36910. END_COL: 4,
  36911. START_POS: 5,
  36912. END_POS: 6
  36913. };
  36914. exports.FIELDS = FIELDS;
  36915. function tokenize(input) {
  36916. var tokens = [];
  36917. var css = input.css.valueOf();
  36918. var _css = css,
  36919. length = _css.length;
  36920. var offset = -1;
  36921. var line = 1;
  36922. var start = 0;
  36923. var end = 0;
  36924. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  36925. function unclosed(what, fix) {
  36926. if (input.safe) {
  36927. // fyi: this is never set to true.
  36928. css += fix;
  36929. next = css.length - 1;
  36930. } else {
  36931. throw input.error('Unclosed ' + what, line, start - offset, start);
  36932. }
  36933. }
  36934. while (start < length) {
  36935. code = css.charCodeAt(start);
  36936. if (code === t.newline) {
  36937. offset = start;
  36938. line += 1;
  36939. }
  36940. switch (code) {
  36941. case t.space:
  36942. case t.tab:
  36943. case t.newline:
  36944. case t.cr:
  36945. case t.feed:
  36946. next = start;
  36947. do {
  36948. next += 1;
  36949. code = css.charCodeAt(next);
  36950. if (code === t.newline) {
  36951. offset = next;
  36952. line += 1;
  36953. }
  36954. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  36955. tokenType = t.space;
  36956. endLine = line;
  36957. endColumn = next - offset - 1;
  36958. end = next;
  36959. break;
  36960. case t.plus:
  36961. case t.greaterThan:
  36962. case t.tilde:
  36963. case t.pipe:
  36964. next = start;
  36965. do {
  36966. next += 1;
  36967. code = css.charCodeAt(next);
  36968. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  36969. tokenType = t.combinator;
  36970. endLine = line;
  36971. endColumn = start - offset;
  36972. end = next;
  36973. break;
  36974. // Consume these characters as single tokens.
  36975. case t.asterisk:
  36976. case t.ampersand:
  36977. case t.bang:
  36978. case t.comma:
  36979. case t.equals:
  36980. case t.dollar:
  36981. case t.caret:
  36982. case t.openSquare:
  36983. case t.closeSquare:
  36984. case t.colon:
  36985. case t.semicolon:
  36986. case t.openParenthesis:
  36987. case t.closeParenthesis:
  36988. next = start;
  36989. tokenType = code;
  36990. endLine = line;
  36991. endColumn = start - offset;
  36992. end = next + 1;
  36993. break;
  36994. case t.singleQuote:
  36995. case t.doubleQuote:
  36996. quote = code === t.singleQuote ? "'" : '"';
  36997. next = start;
  36998. do {
  36999. escaped = false;
  37000. next = css.indexOf(quote, next + 1);
  37001. if (next === -1) {
  37002. unclosed('quote', quote);
  37003. }
  37004. escapePos = next;
  37005. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  37006. escapePos -= 1;
  37007. escaped = !escaped;
  37008. }
  37009. } while (escaped);
  37010. tokenType = t.str;
  37011. endLine = line;
  37012. endColumn = start - offset;
  37013. end = next + 1;
  37014. break;
  37015. default:
  37016. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  37017. next = css.indexOf('*/', start + 2) + 1;
  37018. if (next === 0) {
  37019. unclosed('comment', '*/');
  37020. }
  37021. content = css.slice(start, next + 1);
  37022. lines = content.split('\n');
  37023. last = lines.length - 1;
  37024. if (last > 0) {
  37025. nextLine = line + last;
  37026. nextOffset = next - lines[last].length;
  37027. } else {
  37028. nextLine = line;
  37029. nextOffset = offset;
  37030. }
  37031. tokenType = t.comment;
  37032. line = nextLine;
  37033. endLine = nextLine;
  37034. endColumn = next - nextOffset;
  37035. } else if (code === t.slash) {
  37036. next = start;
  37037. tokenType = code;
  37038. endLine = line;
  37039. endColumn = start - offset;
  37040. end = next + 1;
  37041. } else {
  37042. next = consumeWord(css, start);
  37043. tokenType = t.word;
  37044. endLine = line;
  37045. endColumn = next - offset;
  37046. }
  37047. end = next + 1;
  37048. break;
  37049. }
  37050. // Ensure that the token structure remains consistent
  37051. tokens.push([tokenType,
  37052. // [0] Token type
  37053. line,
  37054. // [1] Starting line
  37055. start - offset,
  37056. // [2] Starting column
  37057. endLine,
  37058. // [3] Ending line
  37059. endColumn,
  37060. // [4] Ending column
  37061. start,
  37062. // [5] Start position / Source index
  37063. end // [6] End position
  37064. ]);
  37065. // Reset offset for the next token
  37066. if (nextOffset) {
  37067. offset = nextOffset;
  37068. nextOffset = null;
  37069. }
  37070. start = end;
  37071. }
  37072. return tokens;
  37073. }
  37074. } (tokenize));
  37075. (function (module, exports) {
  37076. exports.__esModule = true;
  37077. exports["default"] = void 0;
  37078. var _root = _interopRequireDefault(rootExports);
  37079. var _selector = _interopRequireDefault(selectorExports);
  37080. var _className = _interopRequireDefault(classNameExports);
  37081. var _comment = _interopRequireDefault(commentExports);
  37082. var _id = _interopRequireDefault(idExports);
  37083. var _tag = _interopRequireDefault(tagExports);
  37084. var _string = _interopRequireDefault(stringExports);
  37085. var _pseudo = _interopRequireDefault(pseudoExports);
  37086. var _attribute = _interopRequireWildcard(attribute$1);
  37087. var _universal = _interopRequireDefault(universalExports);
  37088. var _combinator = _interopRequireDefault(combinatorExports);
  37089. var _nesting = _interopRequireDefault(nestingExports);
  37090. var _sortAscending = _interopRequireDefault(sortAscendingExports);
  37091. var _tokenize = _interopRequireWildcard(tokenize);
  37092. var tokens = _interopRequireWildcard(tokenTypes);
  37093. var types$1 = _interopRequireWildcard(types);
  37094. var _util = util$6;
  37095. var _WHITESPACE_TOKENS, _Object$assign;
  37096. 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); }
  37097. 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; }
  37098. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  37099. 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); } }
  37100. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  37101. 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);
  37102. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  37103. function tokenStart(token) {
  37104. return {
  37105. line: token[_tokenize.FIELDS.START_LINE],
  37106. column: token[_tokenize.FIELDS.START_COL]
  37107. };
  37108. }
  37109. function tokenEnd(token) {
  37110. return {
  37111. line: token[_tokenize.FIELDS.END_LINE],
  37112. column: token[_tokenize.FIELDS.END_COL]
  37113. };
  37114. }
  37115. function getSource(startLine, startColumn, endLine, endColumn) {
  37116. return {
  37117. start: {
  37118. line: startLine,
  37119. column: startColumn
  37120. },
  37121. end: {
  37122. line: endLine,
  37123. column: endColumn
  37124. }
  37125. };
  37126. }
  37127. function getTokenSource(token) {
  37128. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  37129. }
  37130. function getTokenSourceSpan(startToken, endToken) {
  37131. if (!startToken) {
  37132. return undefined;
  37133. }
  37134. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  37135. }
  37136. function unescapeProp(node, prop) {
  37137. var value = node[prop];
  37138. if (typeof value !== "string") {
  37139. return;
  37140. }
  37141. if (value.indexOf("\\") !== -1) {
  37142. (0, _util.ensureObject)(node, 'raws');
  37143. node[prop] = (0, _util.unesc)(value);
  37144. if (node.raws[prop] === undefined) {
  37145. node.raws[prop] = value;
  37146. }
  37147. }
  37148. return node;
  37149. }
  37150. function indexesOf(array, item) {
  37151. var i = -1;
  37152. var indexes = [];
  37153. while ((i = array.indexOf(item, i + 1)) !== -1) {
  37154. indexes.push(i);
  37155. }
  37156. return indexes;
  37157. }
  37158. function uniqs() {
  37159. var list = Array.prototype.concat.apply([], arguments);
  37160. return list.filter(function (item, i) {
  37161. return i === list.indexOf(item);
  37162. });
  37163. }
  37164. var Parser = /*#__PURE__*/function () {
  37165. function Parser(rule, options) {
  37166. if (options === void 0) {
  37167. options = {};
  37168. }
  37169. this.rule = rule;
  37170. this.options = Object.assign({
  37171. lossy: false,
  37172. safe: false
  37173. }, options);
  37174. this.position = 0;
  37175. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  37176. this.tokens = (0, _tokenize["default"])({
  37177. css: this.css,
  37178. error: this._errorGenerator(),
  37179. safe: this.options.safe
  37180. });
  37181. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  37182. this.root = new _root["default"]({
  37183. source: rootSource
  37184. });
  37185. this.root.errorGenerator = this._errorGenerator();
  37186. var selector = new _selector["default"]({
  37187. source: {
  37188. start: {
  37189. line: 1,
  37190. column: 1
  37191. }
  37192. },
  37193. sourceIndex: 0
  37194. });
  37195. this.root.append(selector);
  37196. this.current = selector;
  37197. this.loop();
  37198. }
  37199. var _proto = Parser.prototype;
  37200. _proto._errorGenerator = function _errorGenerator() {
  37201. var _this = this;
  37202. return function (message, errorOptions) {
  37203. if (typeof _this.rule === 'string') {
  37204. return new Error(message);
  37205. }
  37206. return _this.rule.error(message, errorOptions);
  37207. };
  37208. };
  37209. _proto.attribute = function attribute() {
  37210. var attr = [];
  37211. var startingToken = this.currToken;
  37212. this.position++;
  37213. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  37214. attr.push(this.currToken);
  37215. this.position++;
  37216. }
  37217. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  37218. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  37219. }
  37220. var len = attr.length;
  37221. var node = {
  37222. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  37223. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  37224. };
  37225. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  37226. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  37227. }
  37228. var pos = 0;
  37229. var spaceBefore = '';
  37230. var commentBefore = '';
  37231. var lastAdded = null;
  37232. var spaceAfterMeaningfulToken = false;
  37233. while (pos < len) {
  37234. var token = attr[pos];
  37235. var content = this.content(token);
  37236. var next = attr[pos + 1];
  37237. switch (token[_tokenize.FIELDS.TYPE]) {
  37238. case tokens.space:
  37239. // if (
  37240. // len === 1 ||
  37241. // pos === 0 && this.content(next) === '|'
  37242. // ) {
  37243. // return this.expected('attribute', token[TOKEN.START_POS], content);
  37244. // }
  37245. spaceAfterMeaningfulToken = true;
  37246. if (this.options.lossy) {
  37247. break;
  37248. }
  37249. if (lastAdded) {
  37250. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  37251. var prevContent = node.spaces[lastAdded].after || '';
  37252. node.spaces[lastAdded].after = prevContent + content;
  37253. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  37254. if (existingComment) {
  37255. node.raws.spaces[lastAdded].after = existingComment + content;
  37256. }
  37257. } else {
  37258. spaceBefore = spaceBefore + content;
  37259. commentBefore = commentBefore + content;
  37260. }
  37261. break;
  37262. case tokens.asterisk:
  37263. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37264. node.operator = content;
  37265. lastAdded = 'operator';
  37266. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  37267. if (spaceBefore) {
  37268. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  37269. node.spaces.attribute.before = spaceBefore;
  37270. spaceBefore = '';
  37271. }
  37272. if (commentBefore) {
  37273. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  37274. node.raws.spaces.attribute.before = spaceBefore;
  37275. commentBefore = '';
  37276. }
  37277. node.namespace = (node.namespace || "") + content;
  37278. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  37279. if (rawValue) {
  37280. node.raws.namespace += content;
  37281. }
  37282. lastAdded = 'namespace';
  37283. }
  37284. spaceAfterMeaningfulToken = false;
  37285. break;
  37286. case tokens.dollar:
  37287. if (lastAdded === "value") {
  37288. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  37289. node.value += "$";
  37290. if (oldRawValue) {
  37291. node.raws.value = oldRawValue + "$";
  37292. }
  37293. break;
  37294. }
  37295. // Falls through
  37296. case tokens.caret:
  37297. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37298. node.operator = content;
  37299. lastAdded = 'operator';
  37300. }
  37301. spaceAfterMeaningfulToken = false;
  37302. break;
  37303. case tokens.combinator:
  37304. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37305. node.operator = content;
  37306. lastAdded = 'operator';
  37307. }
  37308. if (content !== '|') {
  37309. spaceAfterMeaningfulToken = false;
  37310. break;
  37311. }
  37312. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  37313. node.operator = content;
  37314. lastAdded = 'operator';
  37315. } else if (!node.namespace && !node.attribute) {
  37316. node.namespace = true;
  37317. }
  37318. spaceAfterMeaningfulToken = false;
  37319. break;
  37320. case tokens.word:
  37321. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals &&
  37322. // this look-ahead probably fails with comment nodes involved.
  37323. !node.operator && !node.namespace) {
  37324. node.namespace = content;
  37325. lastAdded = 'namespace';
  37326. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  37327. if (spaceBefore) {
  37328. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  37329. node.spaces.attribute.before = spaceBefore;
  37330. spaceBefore = '';
  37331. }
  37332. if (commentBefore) {
  37333. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  37334. node.raws.spaces.attribute.before = commentBefore;
  37335. commentBefore = '';
  37336. }
  37337. node.attribute = (node.attribute || "") + content;
  37338. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  37339. if (_rawValue) {
  37340. node.raws.attribute += content;
  37341. }
  37342. lastAdded = 'attribute';
  37343. } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
  37344. var _unescaped = (0, _util.unesc)(content);
  37345. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  37346. var oldValue = node.value || '';
  37347. node.value = oldValue + _unescaped;
  37348. node.quoteMark = null;
  37349. if (_unescaped !== content || _oldRawValue) {
  37350. (0, _util.ensureObject)(node, 'raws');
  37351. node.raws.value = (_oldRawValue || oldValue) + content;
  37352. }
  37353. lastAdded = 'value';
  37354. } else {
  37355. var insensitive = content === 'i' || content === "I";
  37356. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  37357. node.insensitive = insensitive;
  37358. if (!insensitive || content === "I") {
  37359. (0, _util.ensureObject)(node, 'raws');
  37360. node.raws.insensitiveFlag = content;
  37361. }
  37362. lastAdded = 'insensitive';
  37363. if (spaceBefore) {
  37364. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  37365. node.spaces.insensitive.before = spaceBefore;
  37366. spaceBefore = '';
  37367. }
  37368. if (commentBefore) {
  37369. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  37370. node.raws.spaces.insensitive.before = commentBefore;
  37371. commentBefore = '';
  37372. }
  37373. } else if (node.value || node.value === '') {
  37374. lastAdded = 'value';
  37375. node.value += content;
  37376. if (node.raws.value) {
  37377. node.raws.value += content;
  37378. }
  37379. }
  37380. }
  37381. spaceAfterMeaningfulToken = false;
  37382. break;
  37383. case tokens.str:
  37384. if (!node.attribute || !node.operator) {
  37385. return this.error("Expected an attribute followed by an operator preceding the string.", {
  37386. index: token[_tokenize.FIELDS.START_POS]
  37387. });
  37388. }
  37389. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  37390. unescaped = _unescapeValue.unescaped,
  37391. quoteMark = _unescapeValue.quoteMark;
  37392. node.value = unescaped;
  37393. node.quoteMark = quoteMark;
  37394. lastAdded = 'value';
  37395. (0, _util.ensureObject)(node, 'raws');
  37396. node.raws.value = content;
  37397. spaceAfterMeaningfulToken = false;
  37398. break;
  37399. case tokens.equals:
  37400. if (!node.attribute) {
  37401. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  37402. }
  37403. if (node.value) {
  37404. return this.error('Unexpected "=" found; an operator was already defined.', {
  37405. index: token[_tokenize.FIELDS.START_POS]
  37406. });
  37407. }
  37408. node.operator = node.operator ? node.operator + content : content;
  37409. lastAdded = 'operator';
  37410. spaceAfterMeaningfulToken = false;
  37411. break;
  37412. case tokens.comment:
  37413. if (lastAdded) {
  37414. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  37415. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  37416. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  37417. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  37418. node.raws.spaces[lastAdded].after = rawLastComment + content;
  37419. } else {
  37420. var lastValue = node[lastAdded] || '';
  37421. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  37422. (0, _util.ensureObject)(node, 'raws');
  37423. node.raws[lastAdded] = rawLastValue + content;
  37424. }
  37425. } else {
  37426. commentBefore = commentBefore + content;
  37427. }
  37428. break;
  37429. default:
  37430. return this.error("Unexpected \"" + content + "\" found.", {
  37431. index: token[_tokenize.FIELDS.START_POS]
  37432. });
  37433. }
  37434. pos++;
  37435. }
  37436. unescapeProp(node, "attribute");
  37437. unescapeProp(node, "namespace");
  37438. this.newNode(new _attribute["default"](node));
  37439. this.position++;
  37440. }
  37441. /**
  37442. * return a node containing meaningless garbage up to (but not including) the specified token position.
  37443. * if the token position is negative, all remaining tokens are consumed.
  37444. *
  37445. * This returns an array containing a single string node if all whitespace,
  37446. * otherwise an array of comment nodes with space before and after.
  37447. *
  37448. * These tokens are not added to the current selector, the caller can add them or use them to amend
  37449. * a previous node's space metadata.
  37450. *
  37451. * In lossy mode, this returns only comments.
  37452. */;
  37453. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  37454. if (stopPosition < 0) {
  37455. stopPosition = this.tokens.length;
  37456. }
  37457. var startPosition = this.position;
  37458. var nodes = [];
  37459. var space = "";
  37460. var lastComment = undefined;
  37461. do {
  37462. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  37463. if (!this.options.lossy) {
  37464. space += this.content();
  37465. }
  37466. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  37467. var spaces = {};
  37468. if (space) {
  37469. spaces.before = space;
  37470. space = "";
  37471. }
  37472. lastComment = new _comment["default"]({
  37473. value: this.content(),
  37474. source: getTokenSource(this.currToken),
  37475. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  37476. spaces: spaces
  37477. });
  37478. nodes.push(lastComment);
  37479. }
  37480. } while (++this.position < stopPosition);
  37481. if (space) {
  37482. if (lastComment) {
  37483. lastComment.spaces.after = space;
  37484. } else if (!this.options.lossy) {
  37485. var firstToken = this.tokens[startPosition];
  37486. var lastToken = this.tokens[this.position - 1];
  37487. nodes.push(new _string["default"]({
  37488. value: '',
  37489. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  37490. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  37491. spaces: {
  37492. before: space,
  37493. after: ''
  37494. }
  37495. }));
  37496. }
  37497. }
  37498. return nodes;
  37499. }
  37500. /**
  37501. *
  37502. * @param {*} nodes
  37503. */;
  37504. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  37505. var _this2 = this;
  37506. if (requiredSpace === void 0) {
  37507. requiredSpace = false;
  37508. }
  37509. var space = "";
  37510. var rawSpace = "";
  37511. nodes.forEach(function (n) {
  37512. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  37513. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  37514. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  37515. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  37516. });
  37517. if (rawSpace === space) {
  37518. rawSpace = undefined;
  37519. }
  37520. var result = {
  37521. space: space,
  37522. rawSpace: rawSpace
  37523. };
  37524. return result;
  37525. };
  37526. _proto.isNamedCombinator = function isNamedCombinator(position) {
  37527. if (position === void 0) {
  37528. position = this.position;
  37529. }
  37530. 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;
  37531. };
  37532. _proto.namedCombinator = function namedCombinator() {
  37533. if (this.isNamedCombinator()) {
  37534. var nameRaw = this.content(this.tokens[this.position + 1]);
  37535. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  37536. var raws = {};
  37537. if (name !== nameRaw) {
  37538. raws.value = "/" + nameRaw + "/";
  37539. }
  37540. var node = new _combinator["default"]({
  37541. value: "/" + name + "/",
  37542. 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]),
  37543. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  37544. raws: raws
  37545. });
  37546. this.position = this.position + 3;
  37547. return node;
  37548. } else {
  37549. this.unexpected();
  37550. }
  37551. };
  37552. _proto.combinator = function combinator() {
  37553. var _this3 = this;
  37554. if (this.content() === '|') {
  37555. return this.namespace();
  37556. }
  37557. // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  37558. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  37559. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  37560. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  37561. if (nodes.length > 0) {
  37562. var last = this.current.last;
  37563. if (last) {
  37564. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  37565. space = _this$convertWhitespa.space,
  37566. rawSpace = _this$convertWhitespa.rawSpace;
  37567. if (rawSpace !== undefined) {
  37568. last.rawSpaceAfter += rawSpace;
  37569. }
  37570. last.spaces.after += space;
  37571. } else {
  37572. nodes.forEach(function (n) {
  37573. return _this3.newNode(n);
  37574. });
  37575. }
  37576. }
  37577. return;
  37578. }
  37579. var firstToken = this.currToken;
  37580. var spaceOrDescendantSelectorNodes = undefined;
  37581. if (nextSigTokenPos > this.position) {
  37582. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  37583. }
  37584. var node;
  37585. if (this.isNamedCombinator()) {
  37586. node = this.namedCombinator();
  37587. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  37588. node = new _combinator["default"]({
  37589. value: this.content(),
  37590. source: getTokenSource(this.currToken),
  37591. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  37592. });
  37593. this.position++;
  37594. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  37595. this.unexpected();
  37596. }
  37597. if (node) {
  37598. if (spaceOrDescendantSelectorNodes) {
  37599. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  37600. _space = _this$convertWhitespa2.space,
  37601. _rawSpace = _this$convertWhitespa2.rawSpace;
  37602. node.spaces.before = _space;
  37603. node.rawSpaceBefore = _rawSpace;
  37604. }
  37605. } else {
  37606. // descendant combinator
  37607. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  37608. _space2 = _this$convertWhitespa3.space,
  37609. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  37610. if (!_rawSpace2) {
  37611. _rawSpace2 = _space2;
  37612. }
  37613. var spaces = {};
  37614. var raws = {
  37615. spaces: {}
  37616. };
  37617. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  37618. spaces.before = _space2.slice(0, _space2.length - 1);
  37619. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  37620. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  37621. spaces.after = _space2.slice(1);
  37622. raws.spaces.after = _rawSpace2.slice(1);
  37623. } else {
  37624. raws.value = _rawSpace2;
  37625. }
  37626. node = new _combinator["default"]({
  37627. value: ' ',
  37628. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  37629. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  37630. spaces: spaces,
  37631. raws: raws
  37632. });
  37633. }
  37634. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  37635. node.spaces.after = this.optionalSpace(this.content());
  37636. this.position++;
  37637. }
  37638. return this.newNode(node);
  37639. };
  37640. _proto.comma = function comma() {
  37641. if (this.position === this.tokens.length - 1) {
  37642. this.root.trailingComma = true;
  37643. this.position++;
  37644. return;
  37645. }
  37646. this.current._inferEndPosition();
  37647. var selector = new _selector["default"]({
  37648. source: {
  37649. start: tokenStart(this.tokens[this.position + 1])
  37650. },
  37651. sourceIndex: this.tokens[this.position + 1][_tokenize.FIELDS.START_POS]
  37652. });
  37653. this.current.parent.append(selector);
  37654. this.current = selector;
  37655. this.position++;
  37656. };
  37657. _proto.comment = function comment() {
  37658. var current = this.currToken;
  37659. this.newNode(new _comment["default"]({
  37660. value: this.content(),
  37661. source: getTokenSource(current),
  37662. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37663. }));
  37664. this.position++;
  37665. };
  37666. _proto.error = function error(message, opts) {
  37667. throw this.root.error(message, opts);
  37668. };
  37669. _proto.missingBackslash = function missingBackslash() {
  37670. return this.error('Expected a backslash preceding the semicolon.', {
  37671. index: this.currToken[_tokenize.FIELDS.START_POS]
  37672. });
  37673. };
  37674. _proto.missingParenthesis = function missingParenthesis() {
  37675. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  37676. };
  37677. _proto.missingSquareBracket = function missingSquareBracket() {
  37678. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  37679. };
  37680. _proto.unexpected = function unexpected() {
  37681. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  37682. };
  37683. _proto.unexpectedPipe = function unexpectedPipe() {
  37684. return this.error("Unexpected '|'.", this.currToken[_tokenize.FIELDS.START_POS]);
  37685. };
  37686. _proto.namespace = function namespace() {
  37687. var before = this.prevToken && this.content(this.prevToken) || true;
  37688. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  37689. this.position++;
  37690. return this.word(before);
  37691. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  37692. this.position++;
  37693. return this.universal(before);
  37694. }
  37695. this.unexpectedPipe();
  37696. };
  37697. _proto.nesting = function nesting() {
  37698. if (this.nextToken) {
  37699. var nextContent = this.content(this.nextToken);
  37700. if (nextContent === "|") {
  37701. this.position++;
  37702. return;
  37703. }
  37704. }
  37705. var current = this.currToken;
  37706. this.newNode(new _nesting["default"]({
  37707. value: this.content(),
  37708. source: getTokenSource(current),
  37709. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37710. }));
  37711. this.position++;
  37712. };
  37713. _proto.parentheses = function parentheses() {
  37714. var last = this.current.last;
  37715. var unbalanced = 1;
  37716. this.position++;
  37717. if (last && last.type === types$1.PSEUDO) {
  37718. var selector = new _selector["default"]({
  37719. source: {
  37720. start: tokenStart(this.tokens[this.position])
  37721. },
  37722. sourceIndex: this.tokens[this.position][_tokenize.FIELDS.START_POS]
  37723. });
  37724. var cache = this.current;
  37725. last.append(selector);
  37726. this.current = selector;
  37727. while (this.position < this.tokens.length && unbalanced) {
  37728. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37729. unbalanced++;
  37730. }
  37731. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37732. unbalanced--;
  37733. }
  37734. if (unbalanced) {
  37735. this.parse();
  37736. } else {
  37737. this.current.source.end = tokenEnd(this.currToken);
  37738. this.current.parent.source.end = tokenEnd(this.currToken);
  37739. this.position++;
  37740. }
  37741. }
  37742. this.current = cache;
  37743. } else {
  37744. // I think this case should be an error. It's used to implement a basic parse of media queries
  37745. // but I don't think it's a good idea.
  37746. var parenStart = this.currToken;
  37747. var parenValue = "(";
  37748. var parenEnd;
  37749. while (this.position < this.tokens.length && unbalanced) {
  37750. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37751. unbalanced++;
  37752. }
  37753. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37754. unbalanced--;
  37755. }
  37756. parenEnd = this.currToken;
  37757. parenValue += this.parseParenthesisToken(this.currToken);
  37758. this.position++;
  37759. }
  37760. if (last) {
  37761. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  37762. } else {
  37763. this.newNode(new _string["default"]({
  37764. value: parenValue,
  37765. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  37766. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  37767. }));
  37768. }
  37769. }
  37770. if (unbalanced) {
  37771. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  37772. }
  37773. };
  37774. _proto.pseudo = function pseudo() {
  37775. var _this4 = this;
  37776. var pseudoStr = '';
  37777. var startingToken = this.currToken;
  37778. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  37779. pseudoStr += this.content();
  37780. this.position++;
  37781. }
  37782. if (!this.currToken) {
  37783. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  37784. }
  37785. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  37786. this.splitWord(false, function (first, length) {
  37787. pseudoStr += first;
  37788. _this4.newNode(new _pseudo["default"]({
  37789. value: pseudoStr,
  37790. source: getTokenSourceSpan(startingToken, _this4.currToken),
  37791. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  37792. }));
  37793. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  37794. _this4.error('Misplaced parenthesis.', {
  37795. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  37796. });
  37797. }
  37798. });
  37799. } else {
  37800. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  37801. }
  37802. };
  37803. _proto.space = function space() {
  37804. var content = this.content();
  37805. // Handle space before and after the selector
  37806. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  37807. return node.type === 'comment';
  37808. })) {
  37809. this.spaces = this.optionalSpace(content);
  37810. this.position++;
  37811. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  37812. this.current.last.spaces.after = this.optionalSpace(content);
  37813. this.position++;
  37814. } else {
  37815. this.combinator();
  37816. }
  37817. };
  37818. _proto.string = function string() {
  37819. var current = this.currToken;
  37820. this.newNode(new _string["default"]({
  37821. value: this.content(),
  37822. source: getTokenSource(current),
  37823. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37824. }));
  37825. this.position++;
  37826. };
  37827. _proto.universal = function universal(namespace) {
  37828. var nextToken = this.nextToken;
  37829. if (nextToken && this.content(nextToken) === '|') {
  37830. this.position++;
  37831. return this.namespace();
  37832. }
  37833. var current = this.currToken;
  37834. this.newNode(new _universal["default"]({
  37835. value: this.content(),
  37836. source: getTokenSource(current),
  37837. sourceIndex: current[_tokenize.FIELDS.START_POS]
  37838. }), namespace);
  37839. this.position++;
  37840. };
  37841. _proto.splitWord = function splitWord(namespace, firstCallback) {
  37842. var _this5 = this;
  37843. var nextToken = this.nextToken;
  37844. var word = this.content();
  37845. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  37846. this.position++;
  37847. var current = this.content();
  37848. word += current;
  37849. if (current.lastIndexOf('\\') === current.length - 1) {
  37850. var next = this.nextToken;
  37851. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  37852. word += this.requiredSpace(this.content(next));
  37853. this.position++;
  37854. }
  37855. }
  37856. nextToken = this.nextToken;
  37857. }
  37858. var hasClass = indexesOf(word, '.').filter(function (i) {
  37859. // Allow escaped dot within class name
  37860. var escapedDot = word[i - 1] === '\\';
  37861. // Allow decimal numbers percent in @keyframes
  37862. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  37863. return !escapedDot && !isKeyframesPercent;
  37864. });
  37865. var hasId = indexesOf(word, '#').filter(function (i) {
  37866. return word[i - 1] !== '\\';
  37867. });
  37868. // Eliminate Sass interpolations from the list of id indexes
  37869. var interpolations = indexesOf(word, '#{');
  37870. if (interpolations.length) {
  37871. hasId = hasId.filter(function (hashIndex) {
  37872. return !~interpolations.indexOf(hashIndex);
  37873. });
  37874. }
  37875. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  37876. indices.forEach(function (ind, i) {
  37877. var index = indices[i + 1] || word.length;
  37878. var value = word.slice(ind, index);
  37879. if (i === 0 && firstCallback) {
  37880. return firstCallback.call(_this5, value, indices.length);
  37881. }
  37882. var node;
  37883. var current = _this5.currToken;
  37884. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  37885. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  37886. if (~hasClass.indexOf(ind)) {
  37887. var classNameOpts = {
  37888. value: value.slice(1),
  37889. source: source,
  37890. sourceIndex: sourceIndex
  37891. };
  37892. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  37893. } else if (~hasId.indexOf(ind)) {
  37894. var idOpts = {
  37895. value: value.slice(1),
  37896. source: source,
  37897. sourceIndex: sourceIndex
  37898. };
  37899. node = new _id["default"](unescapeProp(idOpts, "value"));
  37900. } else {
  37901. var tagOpts = {
  37902. value: value,
  37903. source: source,
  37904. sourceIndex: sourceIndex
  37905. };
  37906. unescapeProp(tagOpts, "value");
  37907. node = new _tag["default"](tagOpts);
  37908. }
  37909. _this5.newNode(node, namespace);
  37910. // Ensure that the namespace is used only once
  37911. namespace = null;
  37912. });
  37913. this.position++;
  37914. };
  37915. _proto.word = function word(namespace) {
  37916. var nextToken = this.nextToken;
  37917. if (nextToken && this.content(nextToken) === '|') {
  37918. this.position++;
  37919. return this.namespace();
  37920. }
  37921. return this.splitWord(namespace);
  37922. };
  37923. _proto.loop = function loop() {
  37924. while (this.position < this.tokens.length) {
  37925. this.parse(true);
  37926. }
  37927. this.current._inferEndPosition();
  37928. return this.root;
  37929. };
  37930. _proto.parse = function parse(throwOnParenthesis) {
  37931. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  37932. case tokens.space:
  37933. this.space();
  37934. break;
  37935. case tokens.comment:
  37936. this.comment();
  37937. break;
  37938. case tokens.openParenthesis:
  37939. this.parentheses();
  37940. break;
  37941. case tokens.closeParenthesis:
  37942. if (throwOnParenthesis) {
  37943. this.missingParenthesis();
  37944. }
  37945. break;
  37946. case tokens.openSquare:
  37947. this.attribute();
  37948. break;
  37949. case tokens.dollar:
  37950. case tokens.caret:
  37951. case tokens.equals:
  37952. case tokens.word:
  37953. this.word();
  37954. break;
  37955. case tokens.colon:
  37956. this.pseudo();
  37957. break;
  37958. case tokens.comma:
  37959. this.comma();
  37960. break;
  37961. case tokens.asterisk:
  37962. this.universal();
  37963. break;
  37964. case tokens.ampersand:
  37965. this.nesting();
  37966. break;
  37967. case tokens.slash:
  37968. case tokens.combinator:
  37969. this.combinator();
  37970. break;
  37971. case tokens.str:
  37972. this.string();
  37973. break;
  37974. // These cases throw; no break needed.
  37975. case tokens.closeSquare:
  37976. this.missingSquareBracket();
  37977. case tokens.semicolon:
  37978. this.missingBackslash();
  37979. default:
  37980. this.unexpected();
  37981. }
  37982. }
  37983. /**
  37984. * Helpers
  37985. */;
  37986. _proto.expected = function expected(description, index, found) {
  37987. if (Array.isArray(description)) {
  37988. var last = description.pop();
  37989. description = description.join(', ') + " or " + last;
  37990. }
  37991. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  37992. if (!found) {
  37993. return this.error("Expected " + an + " " + description + ".", {
  37994. index: index
  37995. });
  37996. }
  37997. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  37998. index: index
  37999. });
  38000. };
  38001. _proto.requiredSpace = function requiredSpace(space) {
  38002. return this.options.lossy ? ' ' : space;
  38003. };
  38004. _proto.optionalSpace = function optionalSpace(space) {
  38005. return this.options.lossy ? '' : space;
  38006. };
  38007. _proto.lossySpace = function lossySpace(space, required) {
  38008. if (this.options.lossy) {
  38009. return required ? ' ' : '';
  38010. } else {
  38011. return space;
  38012. }
  38013. };
  38014. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  38015. var content = this.content(token);
  38016. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  38017. return this.requiredSpace(content);
  38018. } else {
  38019. return content;
  38020. }
  38021. };
  38022. _proto.newNode = function newNode(node, namespace) {
  38023. if (namespace) {
  38024. if (/^ +$/.test(namespace)) {
  38025. if (!this.options.lossy) {
  38026. this.spaces = (this.spaces || '') + namespace;
  38027. }
  38028. namespace = true;
  38029. }
  38030. node.namespace = namespace;
  38031. unescapeProp(node, "namespace");
  38032. }
  38033. if (this.spaces) {
  38034. node.spaces.before = this.spaces;
  38035. this.spaces = '';
  38036. }
  38037. return this.current.append(node);
  38038. };
  38039. _proto.content = function content(token) {
  38040. if (token === void 0) {
  38041. token = this.currToken;
  38042. }
  38043. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  38044. };
  38045. /**
  38046. * returns the index of the next non-whitespace, non-comment token.
  38047. * returns -1 if no meaningful token is found.
  38048. */
  38049. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  38050. if (startPosition === void 0) {
  38051. startPosition = this.position + 1;
  38052. }
  38053. var searchPosition = startPosition;
  38054. while (searchPosition < this.tokens.length) {
  38055. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  38056. searchPosition++;
  38057. continue;
  38058. } else {
  38059. return searchPosition;
  38060. }
  38061. }
  38062. return -1;
  38063. };
  38064. _createClass(Parser, [{
  38065. key: "currToken",
  38066. get: function get() {
  38067. return this.tokens[this.position];
  38068. }
  38069. }, {
  38070. key: "nextToken",
  38071. get: function get() {
  38072. return this.tokens[this.position + 1];
  38073. }
  38074. }, {
  38075. key: "prevToken",
  38076. get: function get() {
  38077. return this.tokens[this.position - 1];
  38078. }
  38079. }]);
  38080. return Parser;
  38081. }();
  38082. exports["default"] = Parser;
  38083. module.exports = exports.default;
  38084. } (parser, parser.exports));
  38085. var parserExports = parser.exports;
  38086. (function (module, exports) {
  38087. exports.__esModule = true;
  38088. exports["default"] = void 0;
  38089. var _parser = _interopRequireDefault(parserExports);
  38090. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38091. var Processor = /*#__PURE__*/function () {
  38092. function Processor(func, options) {
  38093. this.func = func || function noop() {};
  38094. this.funcRes = null;
  38095. this.options = options;
  38096. }
  38097. var _proto = Processor.prototype;
  38098. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  38099. if (options === void 0) {
  38100. options = {};
  38101. }
  38102. var merged = Object.assign({}, this.options, options);
  38103. if (merged.updateSelector === false) {
  38104. return false;
  38105. } else {
  38106. return typeof rule !== "string";
  38107. }
  38108. };
  38109. _proto._isLossy = function _isLossy(options) {
  38110. if (options === void 0) {
  38111. options = {};
  38112. }
  38113. var merged = Object.assign({}, this.options, options);
  38114. if (merged.lossless === false) {
  38115. return true;
  38116. } else {
  38117. return false;
  38118. }
  38119. };
  38120. _proto._root = function _root(rule, options) {
  38121. if (options === void 0) {
  38122. options = {};
  38123. }
  38124. var parser = new _parser["default"](rule, this._parseOptions(options));
  38125. return parser.root;
  38126. };
  38127. _proto._parseOptions = function _parseOptions(options) {
  38128. return {
  38129. lossy: this._isLossy(options)
  38130. };
  38131. };
  38132. _proto._run = function _run(rule, options) {
  38133. var _this = this;
  38134. if (options === void 0) {
  38135. options = {};
  38136. }
  38137. return new Promise(function (resolve, reject) {
  38138. try {
  38139. var root = _this._root(rule, options);
  38140. Promise.resolve(_this.func(root)).then(function (transform) {
  38141. var string = undefined;
  38142. if (_this._shouldUpdateSelector(rule, options)) {
  38143. string = root.toString();
  38144. rule.selector = string;
  38145. }
  38146. return {
  38147. transform: transform,
  38148. root: root,
  38149. string: string
  38150. };
  38151. }).then(resolve, reject);
  38152. } catch (e) {
  38153. reject(e);
  38154. return;
  38155. }
  38156. });
  38157. };
  38158. _proto._runSync = function _runSync(rule, options) {
  38159. if (options === void 0) {
  38160. options = {};
  38161. }
  38162. var root = this._root(rule, options);
  38163. var transform = this.func(root);
  38164. if (transform && typeof transform.then === "function") {
  38165. throw new Error("Selector processor returned a promise to a synchronous call.");
  38166. }
  38167. var string = undefined;
  38168. if (options.updateSelector && typeof rule !== "string") {
  38169. string = root.toString();
  38170. rule.selector = string;
  38171. }
  38172. return {
  38173. transform: transform,
  38174. root: root,
  38175. string: string
  38176. };
  38177. }
  38178. /**
  38179. * Process rule into a selector AST.
  38180. *
  38181. * @param rule {postcss.Rule | string} The css selector to be processed
  38182. * @param options The options for processing
  38183. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  38184. */;
  38185. _proto.ast = function ast(rule, options) {
  38186. return this._run(rule, options).then(function (result) {
  38187. return result.root;
  38188. });
  38189. }
  38190. /**
  38191. * Process rule into a selector AST synchronously.
  38192. *
  38193. * @param rule {postcss.Rule | string} The css selector to be processed
  38194. * @param options The options for processing
  38195. * @returns {parser.Root} The AST of the selector after processing it.
  38196. */;
  38197. _proto.astSync = function astSync(rule, options) {
  38198. return this._runSync(rule, options).root;
  38199. }
  38200. /**
  38201. * Process a selector into a transformed value asynchronously
  38202. *
  38203. * @param rule {postcss.Rule | string} The css selector to be processed
  38204. * @param options The options for processing
  38205. * @returns {Promise<any>} The value returned by the processor.
  38206. */;
  38207. _proto.transform = function transform(rule, options) {
  38208. return this._run(rule, options).then(function (result) {
  38209. return result.transform;
  38210. });
  38211. }
  38212. /**
  38213. * Process a selector into a transformed value synchronously.
  38214. *
  38215. * @param rule {postcss.Rule | string} The css selector to be processed
  38216. * @param options The options for processing
  38217. * @returns {any} The value returned by the processor.
  38218. */;
  38219. _proto.transformSync = function transformSync(rule, options) {
  38220. return this._runSync(rule, options).transform;
  38221. }
  38222. /**
  38223. * Process a selector into a new selector string asynchronously.
  38224. *
  38225. * @param rule {postcss.Rule | string} The css selector to be processed
  38226. * @param options The options for processing
  38227. * @returns {string} the selector after processing.
  38228. */;
  38229. _proto.process = function process(rule, options) {
  38230. return this._run(rule, options).then(function (result) {
  38231. return result.string || result.root.toString();
  38232. });
  38233. }
  38234. /**
  38235. * Process a selector into a new selector string synchronously.
  38236. *
  38237. * @param rule {postcss.Rule | string} The css selector to be processed
  38238. * @param options The options for processing
  38239. * @returns {string} the selector after processing.
  38240. */;
  38241. _proto.processSync = function processSync(rule, options) {
  38242. var result = this._runSync(rule, options);
  38243. return result.string || result.root.toString();
  38244. };
  38245. return Processor;
  38246. }();
  38247. exports["default"] = Processor;
  38248. module.exports = exports.default;
  38249. } (processor, processor.exports));
  38250. var processorExports = processor.exports;
  38251. var selectors = {};
  38252. var constructors = {};
  38253. constructors.__esModule = true;
  38254. 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;
  38255. var _attribute = _interopRequireDefault(attribute$1);
  38256. var _className = _interopRequireDefault(classNameExports);
  38257. var _combinator = _interopRequireDefault(combinatorExports);
  38258. var _comment = _interopRequireDefault(commentExports);
  38259. var _id = _interopRequireDefault(idExports);
  38260. var _nesting = _interopRequireDefault(nestingExports);
  38261. var _pseudo = _interopRequireDefault(pseudoExports);
  38262. var _root = _interopRequireDefault(rootExports);
  38263. var _selector = _interopRequireDefault(selectorExports);
  38264. var _string = _interopRequireDefault(stringExports);
  38265. var _tag = _interopRequireDefault(tagExports);
  38266. var _universal = _interopRequireDefault(universalExports);
  38267. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38268. var attribute = function attribute(opts) {
  38269. return new _attribute["default"](opts);
  38270. };
  38271. constructors.attribute = attribute;
  38272. var className = function className(opts) {
  38273. return new _className["default"](opts);
  38274. };
  38275. constructors.className = className;
  38276. var combinator = function combinator(opts) {
  38277. return new _combinator["default"](opts);
  38278. };
  38279. constructors.combinator = combinator;
  38280. var comment = function comment(opts) {
  38281. return new _comment["default"](opts);
  38282. };
  38283. constructors.comment = comment;
  38284. var id = function id(opts) {
  38285. return new _id["default"](opts);
  38286. };
  38287. constructors.id = id;
  38288. var nesting = function nesting(opts) {
  38289. return new _nesting["default"](opts);
  38290. };
  38291. constructors.nesting = nesting;
  38292. var pseudo = function pseudo(opts) {
  38293. return new _pseudo["default"](opts);
  38294. };
  38295. constructors.pseudo = pseudo;
  38296. var root = function root(opts) {
  38297. return new _root["default"](opts);
  38298. };
  38299. constructors.root = root;
  38300. var selector = function selector(opts) {
  38301. return new _selector["default"](opts);
  38302. };
  38303. constructors.selector = selector;
  38304. var string = function string(opts) {
  38305. return new _string["default"](opts);
  38306. };
  38307. constructors.string = string;
  38308. var tag = function tag(opts) {
  38309. return new _tag["default"](opts);
  38310. };
  38311. constructors.tag = tag;
  38312. var universal = function universal(opts) {
  38313. return new _universal["default"](opts);
  38314. };
  38315. constructors.universal = universal;
  38316. var guards = {};
  38317. guards.__esModule = true;
  38318. guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  38319. guards.isContainer = isContainer;
  38320. guards.isIdentifier = void 0;
  38321. guards.isNamespace = isNamespace;
  38322. guards.isNesting = void 0;
  38323. guards.isNode = isNode;
  38324. guards.isPseudo = void 0;
  38325. guards.isPseudoClass = isPseudoClass;
  38326. guards.isPseudoElement = isPseudoElement;
  38327. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = void 0;
  38328. var _types = types;
  38329. var _IS_TYPE;
  38330. 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);
  38331. function isNode(node) {
  38332. return typeof node === "object" && IS_TYPE[node.type];
  38333. }
  38334. function isNodeType(type, node) {
  38335. return isNode(node) && node.type === type;
  38336. }
  38337. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  38338. guards.isAttribute = isAttribute;
  38339. var isClassName = isNodeType.bind(null, _types.CLASS);
  38340. guards.isClassName = isClassName;
  38341. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  38342. guards.isCombinator = isCombinator;
  38343. var isComment = isNodeType.bind(null, _types.COMMENT);
  38344. guards.isComment = isComment;
  38345. var isIdentifier = isNodeType.bind(null, _types.ID);
  38346. guards.isIdentifier = isIdentifier;
  38347. var isNesting = isNodeType.bind(null, _types.NESTING);
  38348. guards.isNesting = isNesting;
  38349. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  38350. guards.isPseudo = isPseudo;
  38351. var isRoot = isNodeType.bind(null, _types.ROOT);
  38352. guards.isRoot = isRoot;
  38353. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  38354. guards.isSelector = isSelector;
  38355. var isString = isNodeType.bind(null, _types.STRING);
  38356. guards.isString = isString;
  38357. var isTag = isNodeType.bind(null, _types.TAG);
  38358. guards.isTag = isTag;
  38359. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  38360. guards.isUniversal = isUniversal;
  38361. function isPseudoElement(node) {
  38362. 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");
  38363. }
  38364. function isPseudoClass(node) {
  38365. return isPseudo(node) && !isPseudoElement(node);
  38366. }
  38367. function isContainer(node) {
  38368. return !!(isNode(node) && node.walk);
  38369. }
  38370. function isNamespace(node) {
  38371. return isAttribute(node) || isTag(node);
  38372. }
  38373. (function (exports) {
  38374. exports.__esModule = true;
  38375. var _types = types;
  38376. Object.keys(_types).forEach(function (key) {
  38377. if (key === "default" || key === "__esModule") return;
  38378. if (key in exports && exports[key] === _types[key]) return;
  38379. exports[key] = _types[key];
  38380. });
  38381. var _constructors = constructors;
  38382. Object.keys(_constructors).forEach(function (key) {
  38383. if (key === "default" || key === "__esModule") return;
  38384. if (key in exports && exports[key] === _constructors[key]) return;
  38385. exports[key] = _constructors[key];
  38386. });
  38387. var _guards = guards;
  38388. Object.keys(_guards).forEach(function (key) {
  38389. if (key === "default" || key === "__esModule") return;
  38390. if (key in exports && exports[key] === _guards[key]) return;
  38391. exports[key] = _guards[key];
  38392. });
  38393. } (selectors));
  38394. (function (module, exports) {
  38395. exports.__esModule = true;
  38396. exports["default"] = void 0;
  38397. var _processor = _interopRequireDefault(processorExports);
  38398. var selectors$1 = _interopRequireWildcard(selectors);
  38399. 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); }
  38400. 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; }
  38401. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  38402. var parser = function parser(processor) {
  38403. return new _processor["default"](processor);
  38404. };
  38405. Object.assign(parser, selectors$1);
  38406. delete parser.__esModule;
  38407. var _default = parser;
  38408. exports["default"] = _default;
  38409. module.exports = exports.default;
  38410. } (dist, dist.exports));
  38411. var distExports = dist.exports;
  38412. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(distExports);
  38413. const animationNameRE = /^(-\w+-)?animation-name$/;
  38414. const animationRE = /^(-\w+-)?animation$/;
  38415. const scopedPlugin = (id = "") => {
  38416. const keyframes = /* @__PURE__ */ Object.create(null);
  38417. const shortId = id.replace(/^data-v-/, "");
  38418. return {
  38419. postcssPlugin: "vue-sfc-scoped",
  38420. Rule(rule) {
  38421. processRule(id, rule);
  38422. },
  38423. AtRule(node) {
  38424. if (/-?keyframes$/.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
  38425. keyframes[node.params] = node.params = node.params + "-" + shortId;
  38426. }
  38427. },
  38428. OnceExit(root) {
  38429. if (Object.keys(keyframes).length) {
  38430. root.walkDecls((decl) => {
  38431. if (animationNameRE.test(decl.prop)) {
  38432. decl.value = decl.value.split(",").map((v) => keyframes[v.trim()] || v.trim()).join(",");
  38433. }
  38434. if (animationRE.test(decl.prop)) {
  38435. decl.value = decl.value.split(",").map((v) => {
  38436. const vals = v.trim().split(/\s+/);
  38437. const i = vals.findIndex((val) => keyframes[val]);
  38438. if (i !== -1) {
  38439. vals.splice(i, 1, keyframes[vals[i]]);
  38440. return vals.join(" ");
  38441. } else {
  38442. return v;
  38443. }
  38444. }).join(",");
  38445. }
  38446. });
  38447. }
  38448. }
  38449. };
  38450. };
  38451. const processedRules = /* @__PURE__ */ new WeakSet();
  38452. function processRule(id, rule) {
  38453. if (processedRules.has(rule) || rule.parent && rule.parent.type === "atrule" && /-?keyframes$/.test(rule.parent.name)) {
  38454. return;
  38455. }
  38456. processedRules.add(rule);
  38457. rule.selector = selectorParser((selectorRoot) => {
  38458. selectorRoot.each((selector) => {
  38459. rewriteSelector(id, selector, selectorRoot);
  38460. });
  38461. }).processSync(rule.selector);
  38462. }
  38463. function rewriteSelector(id, selector, selectorRoot, slotted = false) {
  38464. let node = null;
  38465. let shouldInject = true;
  38466. selector.each((n) => {
  38467. if (n.type === "combinator" && (n.value === ">>>" || n.value === "/deep/")) {
  38468. n.value = " ";
  38469. n.spaces.before = n.spaces.after = "";
  38470. warn(
  38471. `the >>> and /deep/ combinators have been deprecated. Use :deep() instead.`
  38472. );
  38473. return false;
  38474. }
  38475. if (n.type === "pseudo") {
  38476. const { value } = n;
  38477. if (value === ":deep" || value === "::v-deep") {
  38478. if (n.nodes.length) {
  38479. let last = n;
  38480. n.nodes[0].each((ss) => {
  38481. selector.insertAfter(last, ss);
  38482. last = ss;
  38483. });
  38484. const prev = selector.at(selector.index(n) - 1);
  38485. if (!prev || !isSpaceCombinator(prev)) {
  38486. selector.insertAfter(
  38487. n,
  38488. selectorParser.combinator({
  38489. value: " "
  38490. })
  38491. );
  38492. }
  38493. selector.removeChild(n);
  38494. } else {
  38495. warn(
  38496. `${value} usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
  38497. );
  38498. const prev = selector.at(selector.index(n) - 1);
  38499. if (prev && isSpaceCombinator(prev)) {
  38500. selector.removeChild(prev);
  38501. }
  38502. selector.removeChild(n);
  38503. }
  38504. return false;
  38505. }
  38506. if (value === ":slotted" || value === "::v-slotted") {
  38507. rewriteSelector(
  38508. id,
  38509. n.nodes[0],
  38510. selectorRoot,
  38511. true
  38512. /* slotted */
  38513. );
  38514. let last = n;
  38515. n.nodes[0].each((ss) => {
  38516. selector.insertAfter(last, ss);
  38517. last = ss;
  38518. });
  38519. selector.removeChild(n);
  38520. shouldInject = false;
  38521. return false;
  38522. }
  38523. if (value === ":global" || value === "::v-global") {
  38524. selectorRoot.insertAfter(selector, n.nodes[0]);
  38525. selectorRoot.removeChild(selector);
  38526. return false;
  38527. }
  38528. }
  38529. if (n.type === "universal") {
  38530. const prev = selector.at(selector.index(n) - 1);
  38531. const next = selector.at(selector.index(n) + 1);
  38532. if (!prev) {
  38533. if (next) {
  38534. if (next.type === "combinator" && next.value === " ") {
  38535. selector.removeChild(next);
  38536. }
  38537. selector.removeChild(n);
  38538. return;
  38539. } else {
  38540. node = selectorParser.combinator({
  38541. value: ""
  38542. });
  38543. selector.insertBefore(n, node);
  38544. selector.removeChild(n);
  38545. return false;
  38546. }
  38547. }
  38548. if (node) return;
  38549. }
  38550. if (n.type !== "pseudo" && n.type !== "combinator" || n.type === "pseudo" && (n.value === ":is" || n.value === ":where") && !node) {
  38551. node = n;
  38552. }
  38553. });
  38554. if (node) {
  38555. const { type, value } = node;
  38556. if (type === "pseudo" && (value === ":is" || value === ":where")) {
  38557. node.nodes.forEach(
  38558. (value2) => rewriteSelector(id, value2, selectorRoot, slotted)
  38559. );
  38560. shouldInject = false;
  38561. }
  38562. }
  38563. if (node) {
  38564. node.spaces.after = "";
  38565. } else {
  38566. selector.first.spaces.before = "";
  38567. }
  38568. if (shouldInject) {
  38569. const idToAdd = slotted ? id + "-s" : id;
  38570. selector.insertAfter(
  38571. // If node is null it means we need to inject [id] at the start
  38572. // insertAfter can handle `null` here
  38573. node,
  38574. selectorParser.attribute({
  38575. attribute: idToAdd,
  38576. value: idToAdd,
  38577. raws: {},
  38578. quoteMark: `"`
  38579. })
  38580. );
  38581. }
  38582. }
  38583. function isSpaceCombinator(node) {
  38584. return node.type === "combinator" && /^\s+$/.test(node.value);
  38585. }
  38586. scopedPlugin.postcss = true;
  38587. var sourceMap$1 = {};
  38588. var sourceMapGenerator = {};
  38589. var base64Vlq = {};
  38590. var base64$1 = {};
  38591. /* -*- Mode: js; js-indent-level: 2; -*- */
  38592. /*
  38593. * Copyright 2011 Mozilla Foundation and contributors
  38594. * Licensed under the New BSD license. See LICENSE or:
  38595. * http://opensource.org/licenses/BSD-3-Clause
  38596. */
  38597. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  38598. /**
  38599. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  38600. */
  38601. base64$1.encode = function (number) {
  38602. if (0 <= number && number < intToCharMap.length) {
  38603. return intToCharMap[number];
  38604. }
  38605. throw new TypeError("Must be between 0 and 63: " + number);
  38606. };
  38607. /**
  38608. * Decode a single base 64 character code digit to an integer. Returns -1 on
  38609. * failure.
  38610. */
  38611. base64$1.decode = function (charCode) {
  38612. var bigA = 65; // 'A'
  38613. var bigZ = 90; // 'Z'
  38614. var littleA = 97; // 'a'
  38615. var littleZ = 122; // 'z'
  38616. var zero = 48; // '0'
  38617. var nine = 57; // '9'
  38618. var plus = 43; // '+'
  38619. var slash = 47; // '/'
  38620. var littleOffset = 26;
  38621. var numberOffset = 52;
  38622. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  38623. if (bigA <= charCode && charCode <= bigZ) {
  38624. return (charCode - bigA);
  38625. }
  38626. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  38627. if (littleA <= charCode && charCode <= littleZ) {
  38628. return (charCode - littleA + littleOffset);
  38629. }
  38630. // 52 - 61: 0123456789
  38631. if (zero <= charCode && charCode <= nine) {
  38632. return (charCode - zero + numberOffset);
  38633. }
  38634. // 62: +
  38635. if (charCode == plus) {
  38636. return 62;
  38637. }
  38638. // 63: /
  38639. if (charCode == slash) {
  38640. return 63;
  38641. }
  38642. // Invalid base64 digit.
  38643. return -1;
  38644. };
  38645. /* -*- Mode: js; js-indent-level: 2; -*- */
  38646. /*
  38647. * Copyright 2011 Mozilla Foundation and contributors
  38648. * Licensed under the New BSD license. See LICENSE or:
  38649. * http://opensource.org/licenses/BSD-3-Clause
  38650. *
  38651. * Based on the Base 64 VLQ implementation in Closure Compiler:
  38652. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  38653. *
  38654. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  38655. * Redistribution and use in source and binary forms, with or without
  38656. * modification, are permitted provided that the following conditions are
  38657. * met:
  38658. *
  38659. * * Redistributions of source code must retain the above copyright
  38660. * notice, this list of conditions and the following disclaimer.
  38661. * * Redistributions in binary form must reproduce the above
  38662. * copyright notice, this list of conditions and the following
  38663. * disclaimer in the documentation and/or other materials provided
  38664. * with the distribution.
  38665. * * Neither the name of Google Inc. nor the names of its
  38666. * contributors may be used to endorse or promote products derived
  38667. * from this software without specific prior written permission.
  38668. *
  38669. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  38670. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38671. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  38672. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  38673. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  38674. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  38675. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  38676. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  38677. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38678. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38679. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38680. */
  38681. var base64 = base64$1;
  38682. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  38683. // length quantities we use in the source map spec, the first bit is the sign,
  38684. // the next four bits are the actual value, and the 6th bit is the
  38685. // continuation bit. The continuation bit tells us whether there are more
  38686. // digits in this value following this digit.
  38687. //
  38688. // Continuation
  38689. // | Sign
  38690. // | |
  38691. // V V
  38692. // 101011
  38693. var VLQ_BASE_SHIFT = 5;
  38694. // binary: 100000
  38695. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  38696. // binary: 011111
  38697. var VLQ_BASE_MASK = VLQ_BASE - 1;
  38698. // binary: 100000
  38699. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  38700. /**
  38701. * Converts from a two-complement value to a value where the sign bit is
  38702. * placed in the least significant bit. For example, as decimals:
  38703. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  38704. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  38705. */
  38706. function toVLQSigned(aValue) {
  38707. return aValue < 0
  38708. ? ((-aValue) << 1) + 1
  38709. : (aValue << 1) + 0;
  38710. }
  38711. /**
  38712. * Converts to a two-complement value from a value where the sign bit is
  38713. * placed in the least significant bit. For example, as decimals:
  38714. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  38715. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  38716. */
  38717. function fromVLQSigned(aValue) {
  38718. var isNegative = (aValue & 1) === 1;
  38719. var shifted = aValue >> 1;
  38720. return isNegative
  38721. ? -shifted
  38722. : shifted;
  38723. }
  38724. /**
  38725. * Returns the base 64 VLQ encoded value.
  38726. */
  38727. base64Vlq.encode = function base64VLQ_encode(aValue) {
  38728. var encoded = "";
  38729. var digit;
  38730. var vlq = toVLQSigned(aValue);
  38731. do {
  38732. digit = vlq & VLQ_BASE_MASK;
  38733. vlq >>>= VLQ_BASE_SHIFT;
  38734. if (vlq > 0) {
  38735. // There are still more digits in this value, so we must make sure the
  38736. // continuation bit is marked.
  38737. digit |= VLQ_CONTINUATION_BIT;
  38738. }
  38739. encoded += base64.encode(digit);
  38740. } while (vlq > 0);
  38741. return encoded;
  38742. };
  38743. /**
  38744. * Decodes the next base 64 VLQ value from the given string and returns the
  38745. * value and the rest of the string via the out parameter.
  38746. */
  38747. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  38748. var strLen = aStr.length;
  38749. var result = 0;
  38750. var shift = 0;
  38751. var continuation, digit;
  38752. do {
  38753. if (aIndex >= strLen) {
  38754. throw new Error("Expected more digits in base 64 VLQ value.");
  38755. }
  38756. digit = base64.decode(aStr.charCodeAt(aIndex++));
  38757. if (digit === -1) {
  38758. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  38759. }
  38760. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  38761. digit &= VLQ_BASE_MASK;
  38762. result = result + (digit << shift);
  38763. shift += VLQ_BASE_SHIFT;
  38764. } while (continuation);
  38765. aOutParam.value = fromVLQSigned(result);
  38766. aOutParam.rest = aIndex;
  38767. };
  38768. var util$5 = {};
  38769. /* -*- Mode: js; js-indent-level: 2; -*- */
  38770. (function (exports) {
  38771. /*
  38772. * Copyright 2011 Mozilla Foundation and contributors
  38773. * Licensed under the New BSD license. See LICENSE or:
  38774. * http://opensource.org/licenses/BSD-3-Clause
  38775. */
  38776. /**
  38777. * This is a helper function for getting values from parameter/options
  38778. * objects.
  38779. *
  38780. * @param args The object we are extracting values from
  38781. * @param name The name of the property we are getting.
  38782. * @param defaultValue An optional value to return if the property is missing
  38783. * from the object. If this is not specified and the property is missing, an
  38784. * error will be thrown.
  38785. */
  38786. function getArg(aArgs, aName, aDefaultValue) {
  38787. if (aName in aArgs) {
  38788. return aArgs[aName];
  38789. } else if (arguments.length === 3) {
  38790. return aDefaultValue;
  38791. } else {
  38792. throw new Error('"' + aName + '" is a required argument.');
  38793. }
  38794. }
  38795. exports.getArg = getArg;
  38796. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  38797. var dataUrlRegexp = /^data:.+\,.+$/;
  38798. function urlParse(aUrl) {
  38799. var match = aUrl.match(urlRegexp);
  38800. if (!match) {
  38801. return null;
  38802. }
  38803. return {
  38804. scheme: match[1],
  38805. auth: match[2],
  38806. host: match[3],
  38807. port: match[4],
  38808. path: match[5]
  38809. };
  38810. }
  38811. exports.urlParse = urlParse;
  38812. function urlGenerate(aParsedUrl) {
  38813. var url = '';
  38814. if (aParsedUrl.scheme) {
  38815. url += aParsedUrl.scheme + ':';
  38816. }
  38817. url += '//';
  38818. if (aParsedUrl.auth) {
  38819. url += aParsedUrl.auth + '@';
  38820. }
  38821. if (aParsedUrl.host) {
  38822. url += aParsedUrl.host;
  38823. }
  38824. if (aParsedUrl.port) {
  38825. url += ":" + aParsedUrl.port;
  38826. }
  38827. if (aParsedUrl.path) {
  38828. url += aParsedUrl.path;
  38829. }
  38830. return url;
  38831. }
  38832. exports.urlGenerate = urlGenerate;
  38833. /**
  38834. * Normalizes a path, or the path portion of a URL:
  38835. *
  38836. * - Replaces consecutive slashes with one slash.
  38837. * - Removes unnecessary '.' parts.
  38838. * - Removes unnecessary '<dir>/..' parts.
  38839. *
  38840. * Based on code in the Node.js 'path' core module.
  38841. *
  38842. * @param aPath The path or url to normalize.
  38843. */
  38844. function normalize(aPath) {
  38845. var path = aPath;
  38846. var url = urlParse(aPath);
  38847. if (url) {
  38848. if (!url.path) {
  38849. return aPath;
  38850. }
  38851. path = url.path;
  38852. }
  38853. var isAbsolute = exports.isAbsolute(path);
  38854. var parts = path.split(/\/+/);
  38855. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  38856. part = parts[i];
  38857. if (part === '.') {
  38858. parts.splice(i, 1);
  38859. } else if (part === '..') {
  38860. up++;
  38861. } else if (up > 0) {
  38862. if (part === '') {
  38863. // The first part is blank if the path is absolute. Trying to go
  38864. // above the root is a no-op. Therefore we can remove all '..' parts
  38865. // directly after the root.
  38866. parts.splice(i + 1, up);
  38867. up = 0;
  38868. } else {
  38869. parts.splice(i, 2);
  38870. up--;
  38871. }
  38872. }
  38873. }
  38874. path = parts.join('/');
  38875. if (path === '') {
  38876. path = isAbsolute ? '/' : '.';
  38877. }
  38878. if (url) {
  38879. url.path = path;
  38880. return urlGenerate(url);
  38881. }
  38882. return path;
  38883. }
  38884. exports.normalize = normalize;
  38885. /**
  38886. * Joins two paths/URLs.
  38887. *
  38888. * @param aRoot The root path or URL.
  38889. * @param aPath The path or URL to be joined with the root.
  38890. *
  38891. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  38892. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  38893. * first.
  38894. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  38895. * is updated with the result and aRoot is returned. Otherwise the result
  38896. * is returned.
  38897. * - If aPath is absolute, the result is aPath.
  38898. * - Otherwise the two paths are joined with a slash.
  38899. * - Joining for example 'http://' and 'www.example.com' is also supported.
  38900. */
  38901. function join(aRoot, aPath) {
  38902. if (aRoot === "") {
  38903. aRoot = ".";
  38904. }
  38905. if (aPath === "") {
  38906. aPath = ".";
  38907. }
  38908. var aPathUrl = urlParse(aPath);
  38909. var aRootUrl = urlParse(aRoot);
  38910. if (aRootUrl) {
  38911. aRoot = aRootUrl.path || '/';
  38912. }
  38913. // `join(foo, '//www.example.org')`
  38914. if (aPathUrl && !aPathUrl.scheme) {
  38915. if (aRootUrl) {
  38916. aPathUrl.scheme = aRootUrl.scheme;
  38917. }
  38918. return urlGenerate(aPathUrl);
  38919. }
  38920. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  38921. return aPath;
  38922. }
  38923. // `join('http://', 'www.example.com')`
  38924. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  38925. aRootUrl.host = aPath;
  38926. return urlGenerate(aRootUrl);
  38927. }
  38928. var joined = aPath.charAt(0) === '/'
  38929. ? aPath
  38930. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  38931. if (aRootUrl) {
  38932. aRootUrl.path = joined;
  38933. return urlGenerate(aRootUrl);
  38934. }
  38935. return joined;
  38936. }
  38937. exports.join = join;
  38938. exports.isAbsolute = function (aPath) {
  38939. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  38940. };
  38941. /**
  38942. * Make a path relative to a URL or another path.
  38943. *
  38944. * @param aRoot The root path or URL.
  38945. * @param aPath The path or URL to be made relative to aRoot.
  38946. */
  38947. function relative(aRoot, aPath) {
  38948. if (aRoot === "") {
  38949. aRoot = ".";
  38950. }
  38951. aRoot = aRoot.replace(/\/$/, '');
  38952. // It is possible for the path to be above the root. In this case, simply
  38953. // checking whether the root is a prefix of the path won't work. Instead, we
  38954. // need to remove components from the root one by one, until either we find
  38955. // a prefix that fits, or we run out of components to remove.
  38956. var level = 0;
  38957. while (aPath.indexOf(aRoot + '/') !== 0) {
  38958. var index = aRoot.lastIndexOf("/");
  38959. if (index < 0) {
  38960. return aPath;
  38961. }
  38962. // If the only part of the root that is left is the scheme (i.e. http://,
  38963. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  38964. // have exhausted all components, so the path is not relative to the root.
  38965. aRoot = aRoot.slice(0, index);
  38966. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  38967. return aPath;
  38968. }
  38969. ++level;
  38970. }
  38971. // Make sure we add a "../" for each component we removed from the root.
  38972. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  38973. }
  38974. exports.relative = relative;
  38975. var supportsNullProto = (function () {
  38976. var obj = Object.create(null);
  38977. return !('__proto__' in obj);
  38978. }());
  38979. function identity (s) {
  38980. return s;
  38981. }
  38982. /**
  38983. * Because behavior goes wacky when you set `__proto__` on objects, we
  38984. * have to prefix all the strings in our set with an arbitrary character.
  38985. *
  38986. * See https://github.com/mozilla/source-map/pull/31 and
  38987. * https://github.com/mozilla/source-map/issues/30
  38988. *
  38989. * @param String aStr
  38990. */
  38991. function toSetString(aStr) {
  38992. if (isProtoString(aStr)) {
  38993. return '$' + aStr;
  38994. }
  38995. return aStr;
  38996. }
  38997. exports.toSetString = supportsNullProto ? identity : toSetString;
  38998. function fromSetString(aStr) {
  38999. if (isProtoString(aStr)) {
  39000. return aStr.slice(1);
  39001. }
  39002. return aStr;
  39003. }
  39004. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  39005. function isProtoString(s) {
  39006. if (!s) {
  39007. return false;
  39008. }
  39009. var length = s.length;
  39010. if (length < 9 /* "__proto__".length */) {
  39011. return false;
  39012. }
  39013. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  39014. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  39015. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  39016. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  39017. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  39018. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  39019. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  39020. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  39021. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  39022. return false;
  39023. }
  39024. for (var i = length - 10; i >= 0; i--) {
  39025. if (s.charCodeAt(i) !== 36 /* '$' */) {
  39026. return false;
  39027. }
  39028. }
  39029. return true;
  39030. }
  39031. /**
  39032. * Comparator between two mappings where the original positions are compared.
  39033. *
  39034. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  39035. * mappings with the same original source/line/column, but different generated
  39036. * line and column the same. Useful when searching for a mapping with a
  39037. * stubbed out mapping.
  39038. */
  39039. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  39040. var cmp = strcmp(mappingA.source, mappingB.source);
  39041. if (cmp !== 0) {
  39042. return cmp;
  39043. }
  39044. cmp = mappingA.originalLine - mappingB.originalLine;
  39045. if (cmp !== 0) {
  39046. return cmp;
  39047. }
  39048. cmp = mappingA.originalColumn - mappingB.originalColumn;
  39049. if (cmp !== 0 || onlyCompareOriginal) {
  39050. return cmp;
  39051. }
  39052. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  39053. if (cmp !== 0) {
  39054. return cmp;
  39055. }
  39056. cmp = mappingA.generatedLine - mappingB.generatedLine;
  39057. if (cmp !== 0) {
  39058. return cmp;
  39059. }
  39060. return strcmp(mappingA.name, mappingB.name);
  39061. }
  39062. exports.compareByOriginalPositions = compareByOriginalPositions;
  39063. /**
  39064. * Comparator between two mappings with deflated source and name indices where
  39065. * the generated positions are compared.
  39066. *
  39067. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  39068. * mappings with the same generated line and column, but different
  39069. * source/name/original line and column the same. Useful when searching for a
  39070. * mapping with a stubbed out mapping.
  39071. */
  39072. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  39073. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  39074. if (cmp !== 0) {
  39075. return cmp;
  39076. }
  39077. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  39078. if (cmp !== 0 || onlyCompareGenerated) {
  39079. return cmp;
  39080. }
  39081. cmp = strcmp(mappingA.source, mappingB.source);
  39082. if (cmp !== 0) {
  39083. return cmp;
  39084. }
  39085. cmp = mappingA.originalLine - mappingB.originalLine;
  39086. if (cmp !== 0) {
  39087. return cmp;
  39088. }
  39089. cmp = mappingA.originalColumn - mappingB.originalColumn;
  39090. if (cmp !== 0) {
  39091. return cmp;
  39092. }
  39093. return strcmp(mappingA.name, mappingB.name);
  39094. }
  39095. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  39096. function strcmp(aStr1, aStr2) {
  39097. if (aStr1 === aStr2) {
  39098. return 0;
  39099. }
  39100. if (aStr1 === null) {
  39101. return 1; // aStr2 !== null
  39102. }
  39103. if (aStr2 === null) {
  39104. return -1; // aStr1 !== null
  39105. }
  39106. if (aStr1 > aStr2) {
  39107. return 1;
  39108. }
  39109. return -1;
  39110. }
  39111. /**
  39112. * Comparator between two mappings with inflated source and name strings where
  39113. * the generated positions are compared.
  39114. */
  39115. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  39116. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  39117. if (cmp !== 0) {
  39118. return cmp;
  39119. }
  39120. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  39121. if (cmp !== 0) {
  39122. return cmp;
  39123. }
  39124. cmp = strcmp(mappingA.source, mappingB.source);
  39125. if (cmp !== 0) {
  39126. return cmp;
  39127. }
  39128. cmp = mappingA.originalLine - mappingB.originalLine;
  39129. if (cmp !== 0) {
  39130. return cmp;
  39131. }
  39132. cmp = mappingA.originalColumn - mappingB.originalColumn;
  39133. if (cmp !== 0) {
  39134. return cmp;
  39135. }
  39136. return strcmp(mappingA.name, mappingB.name);
  39137. }
  39138. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  39139. /**
  39140. * Strip any JSON XSSI avoidance prefix from the string (as documented
  39141. * in the source maps specification), and then parse the string as
  39142. * JSON.
  39143. */
  39144. function parseSourceMapInput(str) {
  39145. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  39146. }
  39147. exports.parseSourceMapInput = parseSourceMapInput;
  39148. /**
  39149. * Compute the URL of a source given the the source root, the source's
  39150. * URL, and the source map's URL.
  39151. */
  39152. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  39153. sourceURL = sourceURL || '';
  39154. if (sourceRoot) {
  39155. // This follows what Chrome does.
  39156. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  39157. sourceRoot += '/';
  39158. }
  39159. // The spec says:
  39160. // Line 4: An optional source root, useful for relocating source
  39161. // files on a server or removing repeated values in the
  39162. // “sources” entry. This value is prepended to the individual
  39163. // entries in the “source” field.
  39164. sourceURL = sourceRoot + sourceURL;
  39165. }
  39166. // Historically, SourceMapConsumer did not take the sourceMapURL as
  39167. // a parameter. This mode is still somewhat supported, which is why
  39168. // this code block is conditional. However, it's preferable to pass
  39169. // the source map URL to SourceMapConsumer, so that this function
  39170. // can implement the source URL resolution algorithm as outlined in
  39171. // the spec. This block is basically the equivalent of:
  39172. // new URL(sourceURL, sourceMapURL).toString()
  39173. // ... except it avoids using URL, which wasn't available in the
  39174. // older releases of node still supported by this library.
  39175. //
  39176. // The spec says:
  39177. // If the sources are not absolute URLs after prepending of the
  39178. // “sourceRoot”, the sources are resolved relative to the
  39179. // SourceMap (like resolving script src in a html document).
  39180. if (sourceMapURL) {
  39181. var parsed = urlParse(sourceMapURL);
  39182. if (!parsed) {
  39183. throw new Error("sourceMapURL could not be parsed");
  39184. }
  39185. if (parsed.path) {
  39186. // Strip the last path component, but keep the "/".
  39187. var index = parsed.path.lastIndexOf('/');
  39188. if (index >= 0) {
  39189. parsed.path = parsed.path.substring(0, index + 1);
  39190. }
  39191. }
  39192. sourceURL = join(urlGenerate(parsed), sourceURL);
  39193. }
  39194. return normalize(sourceURL);
  39195. }
  39196. exports.computeSourceURL = computeSourceURL;
  39197. } (util$5));
  39198. var arraySet = {};
  39199. /* -*- Mode: js; js-indent-level: 2; -*- */
  39200. /*
  39201. * Copyright 2011 Mozilla Foundation and contributors
  39202. * Licensed under the New BSD license. See LICENSE or:
  39203. * http://opensource.org/licenses/BSD-3-Clause
  39204. */
  39205. var util$4 = util$5;
  39206. var has = Object.prototype.hasOwnProperty;
  39207. var hasNativeMap = typeof Map !== "undefined";
  39208. /**
  39209. * A data structure which is a combination of an array and a set. Adding a new
  39210. * member is O(1), testing for membership is O(1), and finding the index of an
  39211. * element is O(1). Removing elements from the set is not supported. Only
  39212. * strings are supported for membership.
  39213. */
  39214. function ArraySet$2() {
  39215. this._array = [];
  39216. this._set = hasNativeMap ? new Map() : Object.create(null);
  39217. }
  39218. /**
  39219. * Static method for creating ArraySet instances from an existing array.
  39220. */
  39221. ArraySet$2.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  39222. var set = new ArraySet$2();
  39223. for (var i = 0, len = aArray.length; i < len; i++) {
  39224. set.add(aArray[i], aAllowDuplicates);
  39225. }
  39226. return set;
  39227. };
  39228. /**
  39229. * Return how many unique items are in this ArraySet. If duplicates have been
  39230. * added, than those do not count towards the size.
  39231. *
  39232. * @returns Number
  39233. */
  39234. ArraySet$2.prototype.size = function ArraySet_size() {
  39235. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  39236. };
  39237. /**
  39238. * Add the given string to this set.
  39239. *
  39240. * @param String aStr
  39241. */
  39242. ArraySet$2.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  39243. var sStr = hasNativeMap ? aStr : util$4.toSetString(aStr);
  39244. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  39245. var idx = this._array.length;
  39246. if (!isDuplicate || aAllowDuplicates) {
  39247. this._array.push(aStr);
  39248. }
  39249. if (!isDuplicate) {
  39250. if (hasNativeMap) {
  39251. this._set.set(aStr, idx);
  39252. } else {
  39253. this._set[sStr] = idx;
  39254. }
  39255. }
  39256. };
  39257. /**
  39258. * Is the given string a member of this set?
  39259. *
  39260. * @param String aStr
  39261. */
  39262. ArraySet$2.prototype.has = function ArraySet_has(aStr) {
  39263. if (hasNativeMap) {
  39264. return this._set.has(aStr);
  39265. } else {
  39266. var sStr = util$4.toSetString(aStr);
  39267. return has.call(this._set, sStr);
  39268. }
  39269. };
  39270. /**
  39271. * What is the index of the given string in the array?
  39272. *
  39273. * @param String aStr
  39274. */
  39275. ArraySet$2.prototype.indexOf = function ArraySet_indexOf(aStr) {
  39276. if (hasNativeMap) {
  39277. var idx = this._set.get(aStr);
  39278. if (idx >= 0) {
  39279. return idx;
  39280. }
  39281. } else {
  39282. var sStr = util$4.toSetString(aStr);
  39283. if (has.call(this._set, sStr)) {
  39284. return this._set[sStr];
  39285. }
  39286. }
  39287. throw new Error('"' + aStr + '" is not in the set.');
  39288. };
  39289. /**
  39290. * What is the element at the given index?
  39291. *
  39292. * @param Number aIdx
  39293. */
  39294. ArraySet$2.prototype.at = function ArraySet_at(aIdx) {
  39295. if (aIdx >= 0 && aIdx < this._array.length) {
  39296. return this._array[aIdx];
  39297. }
  39298. throw new Error('No element indexed by ' + aIdx);
  39299. };
  39300. /**
  39301. * Returns the array representation of this set (which has the proper indices
  39302. * indicated by indexOf). Note that this is a copy of the internal array used
  39303. * for storing the members so that no one can mess with internal state.
  39304. */
  39305. ArraySet$2.prototype.toArray = function ArraySet_toArray() {
  39306. return this._array.slice();
  39307. };
  39308. arraySet.ArraySet = ArraySet$2;
  39309. var mappingList = {};
  39310. /* -*- Mode: js; js-indent-level: 2; -*- */
  39311. /*
  39312. * Copyright 2014 Mozilla Foundation and contributors
  39313. * Licensed under the New BSD license. See LICENSE or:
  39314. * http://opensource.org/licenses/BSD-3-Clause
  39315. */
  39316. var util$3 = util$5;
  39317. /**
  39318. * Determine whether mappingB is after mappingA with respect to generated
  39319. * position.
  39320. */
  39321. function generatedPositionAfter(mappingA, mappingB) {
  39322. // Optimized for most common case
  39323. var lineA = mappingA.generatedLine;
  39324. var lineB = mappingB.generatedLine;
  39325. var columnA = mappingA.generatedColumn;
  39326. var columnB = mappingB.generatedColumn;
  39327. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  39328. util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  39329. }
  39330. /**
  39331. * A data structure to provide a sorted view of accumulated mappings in a
  39332. * performance conscious manner. It trades a neglibable overhead in general
  39333. * case for a large speedup in case of mappings being added in order.
  39334. */
  39335. function MappingList$1() {
  39336. this._array = [];
  39337. this._sorted = true;
  39338. // Serves as infimum
  39339. this._last = {generatedLine: -1, generatedColumn: 0};
  39340. }
  39341. /**
  39342. * Iterate through internal items. This method takes the same arguments that
  39343. * `Array.prototype.forEach` takes.
  39344. *
  39345. * NOTE: The order of the mappings is NOT guaranteed.
  39346. */
  39347. MappingList$1.prototype.unsortedForEach =
  39348. function MappingList_forEach(aCallback, aThisArg) {
  39349. this._array.forEach(aCallback, aThisArg);
  39350. };
  39351. /**
  39352. * Add the given source mapping.
  39353. *
  39354. * @param Object aMapping
  39355. */
  39356. MappingList$1.prototype.add = function MappingList_add(aMapping) {
  39357. if (generatedPositionAfter(this._last, aMapping)) {
  39358. this._last = aMapping;
  39359. this._array.push(aMapping);
  39360. } else {
  39361. this._sorted = false;
  39362. this._array.push(aMapping);
  39363. }
  39364. };
  39365. /**
  39366. * Returns the flat, sorted array of mappings. The mappings are sorted by
  39367. * generated position.
  39368. *
  39369. * WARNING: This method returns internal data without copying, for
  39370. * performance. The return value must NOT be mutated, and should be treated as
  39371. * an immutable borrow. If you want to take ownership, you must make your own
  39372. * copy.
  39373. */
  39374. MappingList$1.prototype.toArray = function MappingList_toArray() {
  39375. if (!this._sorted) {
  39376. this._array.sort(util$3.compareByGeneratedPositionsInflated);
  39377. this._sorted = true;
  39378. }
  39379. return this._array;
  39380. };
  39381. mappingList.MappingList = MappingList$1;
  39382. /* -*- Mode: js; js-indent-level: 2; -*- */
  39383. /*
  39384. * Copyright 2011 Mozilla Foundation and contributors
  39385. * Licensed under the New BSD license. See LICENSE or:
  39386. * http://opensource.org/licenses/BSD-3-Clause
  39387. */
  39388. var base64VLQ$1 = base64Vlq;
  39389. var util$2 = util$5;
  39390. var ArraySet$1 = arraySet.ArraySet;
  39391. var MappingList = mappingList.MappingList;
  39392. /**
  39393. * An instance of the SourceMapGenerator represents a source map which is
  39394. * being built incrementally. You may pass an object with the following
  39395. * properties:
  39396. *
  39397. * - file: The filename of the generated source.
  39398. * - sourceRoot: A root for all relative URLs in this source map.
  39399. */
  39400. function SourceMapGenerator$2(aArgs) {
  39401. if (!aArgs) {
  39402. aArgs = {};
  39403. }
  39404. this._file = util$2.getArg(aArgs, 'file', null);
  39405. this._sourceRoot = util$2.getArg(aArgs, 'sourceRoot', null);
  39406. this._skipValidation = util$2.getArg(aArgs, 'skipValidation', false);
  39407. this._sources = new ArraySet$1();
  39408. this._names = new ArraySet$1();
  39409. this._mappings = new MappingList();
  39410. this._sourcesContents = null;
  39411. }
  39412. SourceMapGenerator$2.prototype._version = 3;
  39413. /**
  39414. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  39415. *
  39416. * @param aSourceMapConsumer The SourceMap.
  39417. */
  39418. SourceMapGenerator$2.fromSourceMap =
  39419. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  39420. var sourceRoot = aSourceMapConsumer.sourceRoot;
  39421. var generator = new SourceMapGenerator$2({
  39422. file: aSourceMapConsumer.file,
  39423. sourceRoot: sourceRoot
  39424. });
  39425. aSourceMapConsumer.eachMapping(function (mapping) {
  39426. var newMapping = {
  39427. generated: {
  39428. line: mapping.generatedLine,
  39429. column: mapping.generatedColumn
  39430. }
  39431. };
  39432. if (mapping.source != null) {
  39433. newMapping.source = mapping.source;
  39434. if (sourceRoot != null) {
  39435. newMapping.source = util$2.relative(sourceRoot, newMapping.source);
  39436. }
  39437. newMapping.original = {
  39438. line: mapping.originalLine,
  39439. column: mapping.originalColumn
  39440. };
  39441. if (mapping.name != null) {
  39442. newMapping.name = mapping.name;
  39443. }
  39444. }
  39445. generator.addMapping(newMapping);
  39446. });
  39447. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  39448. var sourceRelative = sourceFile;
  39449. if (sourceRoot !== null) {
  39450. sourceRelative = util$2.relative(sourceRoot, sourceFile);
  39451. }
  39452. if (!generator._sources.has(sourceRelative)) {
  39453. generator._sources.add(sourceRelative);
  39454. }
  39455. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  39456. if (content != null) {
  39457. generator.setSourceContent(sourceFile, content);
  39458. }
  39459. });
  39460. return generator;
  39461. };
  39462. /**
  39463. * Add a single mapping from original source line and column to the generated
  39464. * source's line and column for this source map being created. The mapping
  39465. * object should have the following properties:
  39466. *
  39467. * - generated: An object with the generated line and column positions.
  39468. * - original: An object with the original line and column positions.
  39469. * - source: The original source file (relative to the sourceRoot).
  39470. * - name: An optional original token name for this mapping.
  39471. */
  39472. SourceMapGenerator$2.prototype.addMapping =
  39473. function SourceMapGenerator_addMapping(aArgs) {
  39474. var generated = util$2.getArg(aArgs, 'generated');
  39475. var original = util$2.getArg(aArgs, 'original', null);
  39476. var source = util$2.getArg(aArgs, 'source', null);
  39477. var name = util$2.getArg(aArgs, 'name', null);
  39478. if (!this._skipValidation) {
  39479. this._validateMapping(generated, original, source, name);
  39480. }
  39481. if (source != null) {
  39482. source = String(source);
  39483. if (!this._sources.has(source)) {
  39484. this._sources.add(source);
  39485. }
  39486. }
  39487. if (name != null) {
  39488. name = String(name);
  39489. if (!this._names.has(name)) {
  39490. this._names.add(name);
  39491. }
  39492. }
  39493. this._mappings.add({
  39494. generatedLine: generated.line,
  39495. generatedColumn: generated.column,
  39496. originalLine: original != null && original.line,
  39497. originalColumn: original != null && original.column,
  39498. source: source,
  39499. name: name
  39500. });
  39501. };
  39502. /**
  39503. * Set the source content for a source file.
  39504. */
  39505. SourceMapGenerator$2.prototype.setSourceContent =
  39506. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  39507. var source = aSourceFile;
  39508. if (this._sourceRoot != null) {
  39509. source = util$2.relative(this._sourceRoot, source);
  39510. }
  39511. if (aSourceContent != null) {
  39512. // Add the source content to the _sourcesContents map.
  39513. // Create a new _sourcesContents map if the property is null.
  39514. if (!this._sourcesContents) {
  39515. this._sourcesContents = Object.create(null);
  39516. }
  39517. this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
  39518. } else if (this._sourcesContents) {
  39519. // Remove the source file from the _sourcesContents map.
  39520. // If the _sourcesContents map is empty, set the property to null.
  39521. delete this._sourcesContents[util$2.toSetString(source)];
  39522. if (Object.keys(this._sourcesContents).length === 0) {
  39523. this._sourcesContents = null;
  39524. }
  39525. }
  39526. };
  39527. /**
  39528. * Applies the mappings of a sub-source-map for a specific source file to the
  39529. * source map being generated. Each mapping to the supplied source file is
  39530. * rewritten using the supplied source map. Note: The resolution for the
  39531. * resulting mappings is the minimium of this map and the supplied map.
  39532. *
  39533. * @param aSourceMapConsumer The source map to be applied.
  39534. * @param aSourceFile Optional. The filename of the source file.
  39535. * If omitted, SourceMapConsumer's file property will be used.
  39536. * @param aSourceMapPath Optional. The dirname of the path to the source map
  39537. * to be applied. If relative, it is relative to the SourceMapConsumer.
  39538. * This parameter is needed when the two source maps aren't in the same
  39539. * directory, and the source map to be applied contains relative source
  39540. * paths. If so, those relative source paths need to be rewritten
  39541. * relative to the SourceMapGenerator.
  39542. */
  39543. SourceMapGenerator$2.prototype.applySourceMap =
  39544. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  39545. var sourceFile = aSourceFile;
  39546. // If aSourceFile is omitted, we will use the file property of the SourceMap
  39547. if (aSourceFile == null) {
  39548. if (aSourceMapConsumer.file == null) {
  39549. throw new Error(
  39550. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  39551. 'or the source map\'s "file" property. Both were omitted.'
  39552. );
  39553. }
  39554. sourceFile = aSourceMapConsumer.file;
  39555. }
  39556. var sourceRoot = this._sourceRoot;
  39557. // Make "sourceFile" relative if an absolute Url is passed.
  39558. if (sourceRoot != null) {
  39559. sourceFile = util$2.relative(sourceRoot, sourceFile);
  39560. }
  39561. // Applying the SourceMap can add and remove items from the sources and
  39562. // the names array.
  39563. var newSources = new ArraySet$1();
  39564. var newNames = new ArraySet$1();
  39565. // Find mappings for the "sourceFile"
  39566. this._mappings.unsortedForEach(function (mapping) {
  39567. if (mapping.source === sourceFile && mapping.originalLine != null) {
  39568. // Check if it can be mapped by the source map, then update the mapping.
  39569. var original = aSourceMapConsumer.originalPositionFor({
  39570. line: mapping.originalLine,
  39571. column: mapping.originalColumn
  39572. });
  39573. if (original.source != null) {
  39574. // Copy mapping
  39575. mapping.source = original.source;
  39576. if (aSourceMapPath != null) {
  39577. mapping.source = util$2.join(aSourceMapPath, mapping.source);
  39578. }
  39579. if (sourceRoot != null) {
  39580. mapping.source = util$2.relative(sourceRoot, mapping.source);
  39581. }
  39582. mapping.originalLine = original.line;
  39583. mapping.originalColumn = original.column;
  39584. if (original.name != null) {
  39585. mapping.name = original.name;
  39586. }
  39587. }
  39588. }
  39589. var source = mapping.source;
  39590. if (source != null && !newSources.has(source)) {
  39591. newSources.add(source);
  39592. }
  39593. var name = mapping.name;
  39594. if (name != null && !newNames.has(name)) {
  39595. newNames.add(name);
  39596. }
  39597. }, this);
  39598. this._sources = newSources;
  39599. this._names = newNames;
  39600. // Copy sourcesContents of applied map.
  39601. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  39602. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  39603. if (content != null) {
  39604. if (aSourceMapPath != null) {
  39605. sourceFile = util$2.join(aSourceMapPath, sourceFile);
  39606. }
  39607. if (sourceRoot != null) {
  39608. sourceFile = util$2.relative(sourceRoot, sourceFile);
  39609. }
  39610. this.setSourceContent(sourceFile, content);
  39611. }
  39612. }, this);
  39613. };
  39614. /**
  39615. * A mapping can have one of the three levels of data:
  39616. *
  39617. * 1. Just the generated position.
  39618. * 2. The Generated position, original position, and original source.
  39619. * 3. Generated and original position, original source, as well as a name
  39620. * token.
  39621. *
  39622. * To maintain consistency, we validate that any new mapping being added falls
  39623. * in to one of these categories.
  39624. */
  39625. SourceMapGenerator$2.prototype._validateMapping =
  39626. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  39627. aName) {
  39628. // When aOriginal is truthy but has empty values for .line and .column,
  39629. // it is most likely a programmer error. In this case we throw a very
  39630. // specific error message to try to guide them the right way.
  39631. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  39632. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  39633. throw new Error(
  39634. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  39635. 'the original mapping entirely and only map the generated position. If so, pass ' +
  39636. 'null for the original mapping instead of an object with empty or null values.'
  39637. );
  39638. }
  39639. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  39640. && aGenerated.line > 0 && aGenerated.column >= 0
  39641. && !aOriginal && !aSource && !aName) {
  39642. // Case 1.
  39643. return;
  39644. }
  39645. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  39646. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  39647. && aGenerated.line > 0 && aGenerated.column >= 0
  39648. && aOriginal.line > 0 && aOriginal.column >= 0
  39649. && aSource) {
  39650. // Cases 2 and 3.
  39651. return;
  39652. }
  39653. else {
  39654. throw new Error('Invalid mapping: ' + JSON.stringify({
  39655. generated: aGenerated,
  39656. source: aSource,
  39657. original: aOriginal,
  39658. name: aName
  39659. }));
  39660. }
  39661. };
  39662. /**
  39663. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  39664. * specified by the source map format.
  39665. */
  39666. SourceMapGenerator$2.prototype._serializeMappings =
  39667. function SourceMapGenerator_serializeMappings() {
  39668. var previousGeneratedColumn = 0;
  39669. var previousGeneratedLine = 1;
  39670. var previousOriginalColumn = 0;
  39671. var previousOriginalLine = 0;
  39672. var previousName = 0;
  39673. var previousSource = 0;
  39674. var result = '';
  39675. var next;
  39676. var mapping;
  39677. var nameIdx;
  39678. var sourceIdx;
  39679. var mappings = this._mappings.toArray();
  39680. for (var i = 0, len = mappings.length; i < len; i++) {
  39681. mapping = mappings[i];
  39682. next = '';
  39683. if (mapping.generatedLine !== previousGeneratedLine) {
  39684. previousGeneratedColumn = 0;
  39685. while (mapping.generatedLine !== previousGeneratedLine) {
  39686. next += ';';
  39687. previousGeneratedLine++;
  39688. }
  39689. }
  39690. else {
  39691. if (i > 0) {
  39692. if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  39693. continue;
  39694. }
  39695. next += ',';
  39696. }
  39697. }
  39698. next += base64VLQ$1.encode(mapping.generatedColumn
  39699. - previousGeneratedColumn);
  39700. previousGeneratedColumn = mapping.generatedColumn;
  39701. if (mapping.source != null) {
  39702. sourceIdx = this._sources.indexOf(mapping.source);
  39703. next += base64VLQ$1.encode(sourceIdx - previousSource);
  39704. previousSource = sourceIdx;
  39705. // lines are stored 0-based in SourceMap spec version 3
  39706. next += base64VLQ$1.encode(mapping.originalLine - 1
  39707. - previousOriginalLine);
  39708. previousOriginalLine = mapping.originalLine - 1;
  39709. next += base64VLQ$1.encode(mapping.originalColumn
  39710. - previousOriginalColumn);
  39711. previousOriginalColumn = mapping.originalColumn;
  39712. if (mapping.name != null) {
  39713. nameIdx = this._names.indexOf(mapping.name);
  39714. next += base64VLQ$1.encode(nameIdx - previousName);
  39715. previousName = nameIdx;
  39716. }
  39717. }
  39718. result += next;
  39719. }
  39720. return result;
  39721. };
  39722. SourceMapGenerator$2.prototype._generateSourcesContent =
  39723. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  39724. return aSources.map(function (source) {
  39725. if (!this._sourcesContents) {
  39726. return null;
  39727. }
  39728. if (aSourceRoot != null) {
  39729. source = util$2.relative(aSourceRoot, source);
  39730. }
  39731. var key = util$2.toSetString(source);
  39732. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  39733. ? this._sourcesContents[key]
  39734. : null;
  39735. }, this);
  39736. };
  39737. /**
  39738. * Externalize the source map.
  39739. */
  39740. SourceMapGenerator$2.prototype.toJSON =
  39741. function SourceMapGenerator_toJSON() {
  39742. var map = {
  39743. version: this._version,
  39744. sources: this._sources.toArray(),
  39745. names: this._names.toArray(),
  39746. mappings: this._serializeMappings()
  39747. };
  39748. if (this._file != null) {
  39749. map.file = this._file;
  39750. }
  39751. if (this._sourceRoot != null) {
  39752. map.sourceRoot = this._sourceRoot;
  39753. }
  39754. if (this._sourcesContents) {
  39755. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  39756. }
  39757. return map;
  39758. };
  39759. /**
  39760. * Render the source map being generated to a string.
  39761. */
  39762. SourceMapGenerator$2.prototype.toString =
  39763. function SourceMapGenerator_toString() {
  39764. return JSON.stringify(this.toJSON());
  39765. };
  39766. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$2;
  39767. var sourceMapConsumer = {};
  39768. var binarySearch$1 = {};
  39769. /* -*- Mode: js; js-indent-level: 2; -*- */
  39770. (function (exports) {
  39771. /*
  39772. * Copyright 2011 Mozilla Foundation and contributors
  39773. * Licensed under the New BSD license. See LICENSE or:
  39774. * http://opensource.org/licenses/BSD-3-Clause
  39775. */
  39776. exports.GREATEST_LOWER_BOUND = 1;
  39777. exports.LEAST_UPPER_BOUND = 2;
  39778. /**
  39779. * Recursive implementation of binary search.
  39780. *
  39781. * @param aLow Indices here and lower do not contain the needle.
  39782. * @param aHigh Indices here and higher do not contain the needle.
  39783. * @param aNeedle The element being searched for.
  39784. * @param aHaystack The non-empty array being searched.
  39785. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  39786. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  39787. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  39788. * closest element that is smaller than or greater than the one we are
  39789. * searching for, respectively, if the exact element cannot be found.
  39790. */
  39791. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  39792. // This function terminates when one of the following is true:
  39793. //
  39794. // 1. We find the exact element we are looking for.
  39795. //
  39796. // 2. We did not find the exact element, but we can return the index of
  39797. // the next-closest element.
  39798. //
  39799. // 3. We did not find the exact element, and there is no next-closest
  39800. // element than the one we are searching for, so we return -1.
  39801. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  39802. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  39803. if (cmp === 0) {
  39804. // Found the element we are looking for.
  39805. return mid;
  39806. }
  39807. else if (cmp > 0) {
  39808. // Our needle is greater than aHaystack[mid].
  39809. if (aHigh - mid > 1) {
  39810. // The element is in the upper half.
  39811. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  39812. }
  39813. // The exact needle element was not found in this haystack. Determine if
  39814. // we are in termination case (3) or (2) and return the appropriate thing.
  39815. if (aBias == exports.LEAST_UPPER_BOUND) {
  39816. return aHigh < aHaystack.length ? aHigh : -1;
  39817. } else {
  39818. return mid;
  39819. }
  39820. }
  39821. else {
  39822. // Our needle is less than aHaystack[mid].
  39823. if (mid - aLow > 1) {
  39824. // The element is in the lower half.
  39825. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  39826. }
  39827. // we are in termination case (3) or (2) and return the appropriate thing.
  39828. if (aBias == exports.LEAST_UPPER_BOUND) {
  39829. return mid;
  39830. } else {
  39831. return aLow < 0 ? -1 : aLow;
  39832. }
  39833. }
  39834. }
  39835. /**
  39836. * This is an implementation of binary search which will always try and return
  39837. * the index of the closest element if there is no exact hit. This is because
  39838. * mappings between original and generated line/col pairs are single points,
  39839. * and there is an implicit region between each of them, so a miss just means
  39840. * that you aren't on the very start of a region.
  39841. *
  39842. * @param aNeedle The element you are looking for.
  39843. * @param aHaystack The array that is being searched.
  39844. * @param aCompare A function which takes the needle and an element in the
  39845. * array and returns -1, 0, or 1 depending on whether the needle is less
  39846. * than, equal to, or greater than the element, respectively.
  39847. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  39848. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  39849. * closest element that is smaller than or greater than the one we are
  39850. * searching for, respectively, if the exact element cannot be found.
  39851. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  39852. */
  39853. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  39854. if (aHaystack.length === 0) {
  39855. return -1;
  39856. }
  39857. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  39858. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  39859. if (index < 0) {
  39860. return -1;
  39861. }
  39862. // We have found either the exact element, or the next-closest element than
  39863. // the one we are searching for. However, there may be more than one such
  39864. // element. Make sure we always return the smallest of these.
  39865. while (index - 1 >= 0) {
  39866. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  39867. break;
  39868. }
  39869. --index;
  39870. }
  39871. return index;
  39872. };
  39873. } (binarySearch$1));
  39874. var quickSort$1 = {};
  39875. /* -*- Mode: js; js-indent-level: 2; -*- */
  39876. /*
  39877. * Copyright 2011 Mozilla Foundation and contributors
  39878. * Licensed under the New BSD license. See LICENSE or:
  39879. * http://opensource.org/licenses/BSD-3-Clause
  39880. */
  39881. // It turns out that some (most?) JavaScript engines don't self-host
  39882. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  39883. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  39884. // custom comparator function, calling back and forth between the VM's C++ and
  39885. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  39886. // worse generated code for the comparator function than would be optimal. In
  39887. // fact, when sorting with a comparator, these costs outweigh the benefits of
  39888. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  39889. // a ~3500ms mean speed-up in `bench/bench.html`.
  39890. /**
  39891. * Swap the elements indexed by `x` and `y` in the array `ary`.
  39892. *
  39893. * @param {Array} ary
  39894. * The array.
  39895. * @param {Number} x
  39896. * The index of the first item.
  39897. * @param {Number} y
  39898. * The index of the second item.
  39899. */
  39900. function swap(ary, x, y) {
  39901. var temp = ary[x];
  39902. ary[x] = ary[y];
  39903. ary[y] = temp;
  39904. }
  39905. /**
  39906. * Returns a random integer within the range `low .. high` inclusive.
  39907. *
  39908. * @param {Number} low
  39909. * The lower bound on the range.
  39910. * @param {Number} high
  39911. * The upper bound on the range.
  39912. */
  39913. function randomIntInRange(low, high) {
  39914. return Math.round(low + (Math.random() * (high - low)));
  39915. }
  39916. /**
  39917. * The Quick Sort algorithm.
  39918. *
  39919. * @param {Array} ary
  39920. * An array to sort.
  39921. * @param {function} comparator
  39922. * Function to use to compare two items.
  39923. * @param {Number} p
  39924. * Start index of the array
  39925. * @param {Number} r
  39926. * End index of the array
  39927. */
  39928. function doQuickSort(ary, comparator, p, r) {
  39929. // If our lower bound is less than our upper bound, we (1) partition the
  39930. // array into two pieces and (2) recurse on each half. If it is not, this is
  39931. // the empty array and our base case.
  39932. if (p < r) {
  39933. // (1) Partitioning.
  39934. //
  39935. // The partitioning chooses a pivot between `p` and `r` and moves all
  39936. // elements that are less than or equal to the pivot to the before it, and
  39937. // all the elements that are greater than it after it. The effect is that
  39938. // once partition is done, the pivot is in the exact place it will be when
  39939. // the array is put in sorted order, and it will not need to be moved
  39940. // again. This runs in O(n) time.
  39941. // Always choose a random pivot so that an input array which is reverse
  39942. // sorted does not cause O(n^2) running time.
  39943. var pivotIndex = randomIntInRange(p, r);
  39944. var i = p - 1;
  39945. swap(ary, pivotIndex, r);
  39946. var pivot = ary[r];
  39947. // Immediately after `j` is incremented in this loop, the following hold
  39948. // true:
  39949. //
  39950. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  39951. //
  39952. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  39953. for (var j = p; j < r; j++) {
  39954. if (comparator(ary[j], pivot) <= 0) {
  39955. i += 1;
  39956. swap(ary, i, j);
  39957. }
  39958. }
  39959. swap(ary, i + 1, j);
  39960. var q = i + 1;
  39961. // (2) Recurse on each half.
  39962. doQuickSort(ary, comparator, p, q - 1);
  39963. doQuickSort(ary, comparator, q + 1, r);
  39964. }
  39965. }
  39966. /**
  39967. * Sort the given array in-place with the given comparator function.
  39968. *
  39969. * @param {Array} ary
  39970. * An array to sort.
  39971. * @param {function} comparator
  39972. * Function to use to compare two items.
  39973. */
  39974. quickSort$1.quickSort = function (ary, comparator) {
  39975. doQuickSort(ary, comparator, 0, ary.length - 1);
  39976. };
  39977. /* -*- Mode: js; js-indent-level: 2; -*- */
  39978. /*
  39979. * Copyright 2011 Mozilla Foundation and contributors
  39980. * Licensed under the New BSD license. See LICENSE or:
  39981. * http://opensource.org/licenses/BSD-3-Clause
  39982. */
  39983. var util$1 = util$5;
  39984. var binarySearch = binarySearch$1;
  39985. var ArraySet = arraySet.ArraySet;
  39986. var base64VLQ = base64Vlq;
  39987. var quickSort = quickSort$1.quickSort;
  39988. function SourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  39989. var sourceMap = aSourceMap;
  39990. if (typeof aSourceMap === 'string') {
  39991. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  39992. }
  39993. return sourceMap.sections != null
  39994. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  39995. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  39996. }
  39997. SourceMapConsumer$1.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  39998. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  39999. };
  40000. /**
  40001. * The version of the source mapping spec that we are consuming.
  40002. */
  40003. SourceMapConsumer$1.prototype._version = 3;
  40004. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  40005. // parsed mapping coordinates from the source map's "mappings" attribute. They
  40006. // are lazily instantiated, accessed via the `_generatedMappings` and
  40007. // `_originalMappings` getters respectively, and we only parse the mappings
  40008. // and create these arrays once queried for a source location. We jump through
  40009. // these hoops because there can be many thousands of mappings, and parsing
  40010. // them is expensive, so we only want to do it if we must.
  40011. //
  40012. // Each object in the arrays is of the form:
  40013. //
  40014. // {
  40015. // generatedLine: The line number in the generated code,
  40016. // generatedColumn: The column number in the generated code,
  40017. // source: The path to the original source file that generated this
  40018. // chunk of code,
  40019. // originalLine: The line number in the original source that
  40020. // corresponds to this chunk of generated code,
  40021. // originalColumn: The column number in the original source that
  40022. // corresponds to this chunk of generated code,
  40023. // name: The name of the original symbol which generated this chunk of
  40024. // code.
  40025. // }
  40026. //
  40027. // All properties except for `generatedLine` and `generatedColumn` can be
  40028. // `null`.
  40029. //
  40030. // `_generatedMappings` is ordered by the generated positions.
  40031. //
  40032. // `_originalMappings` is ordered by the original positions.
  40033. SourceMapConsumer$1.prototype.__generatedMappings = null;
  40034. Object.defineProperty(SourceMapConsumer$1.prototype, '_generatedMappings', {
  40035. configurable: true,
  40036. enumerable: true,
  40037. get: function () {
  40038. if (!this.__generatedMappings) {
  40039. this._parseMappings(this._mappings, this.sourceRoot);
  40040. }
  40041. return this.__generatedMappings;
  40042. }
  40043. });
  40044. SourceMapConsumer$1.prototype.__originalMappings = null;
  40045. Object.defineProperty(SourceMapConsumer$1.prototype, '_originalMappings', {
  40046. configurable: true,
  40047. enumerable: true,
  40048. get: function () {
  40049. if (!this.__originalMappings) {
  40050. this._parseMappings(this._mappings, this.sourceRoot);
  40051. }
  40052. return this.__originalMappings;
  40053. }
  40054. });
  40055. SourceMapConsumer$1.prototype._charIsMappingSeparator =
  40056. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  40057. var c = aStr.charAt(index);
  40058. return c === ";" || c === ",";
  40059. };
  40060. /**
  40061. * Parse the mappings in a string in to a data structure which we can easily
  40062. * query (the ordered arrays in the `this.__generatedMappings` and
  40063. * `this.__originalMappings` properties).
  40064. */
  40065. SourceMapConsumer$1.prototype._parseMappings =
  40066. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40067. throw new Error("Subclasses must implement _parseMappings");
  40068. };
  40069. SourceMapConsumer$1.GENERATED_ORDER = 1;
  40070. SourceMapConsumer$1.ORIGINAL_ORDER = 2;
  40071. SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
  40072. SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
  40073. /**
  40074. * Iterate over each mapping between an original source/line/column and a
  40075. * generated line/column in this source map.
  40076. *
  40077. * @param Function aCallback
  40078. * The function that is called with each mapping.
  40079. * @param Object aContext
  40080. * Optional. If specified, this object will be the value of `this` every
  40081. * time that `aCallback` is called.
  40082. * @param aOrder
  40083. * Either `SourceMapConsumer.GENERATED_ORDER` or
  40084. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  40085. * iterate over the mappings sorted by the generated file's line/column
  40086. * order or the original's source/line/column order, respectively. Defaults to
  40087. * `SourceMapConsumer.GENERATED_ORDER`.
  40088. */
  40089. SourceMapConsumer$1.prototype.eachMapping =
  40090. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  40091. var context = aContext || null;
  40092. var order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
  40093. var mappings;
  40094. switch (order) {
  40095. case SourceMapConsumer$1.GENERATED_ORDER:
  40096. mappings = this._generatedMappings;
  40097. break;
  40098. case SourceMapConsumer$1.ORIGINAL_ORDER:
  40099. mappings = this._originalMappings;
  40100. break;
  40101. default:
  40102. throw new Error("Unknown order of iteration.");
  40103. }
  40104. var sourceRoot = this.sourceRoot;
  40105. mappings.map(function (mapping) {
  40106. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  40107. source = util$1.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  40108. return {
  40109. source: source,
  40110. generatedLine: mapping.generatedLine,
  40111. generatedColumn: mapping.generatedColumn,
  40112. originalLine: mapping.originalLine,
  40113. originalColumn: mapping.originalColumn,
  40114. name: mapping.name === null ? null : this._names.at(mapping.name)
  40115. };
  40116. }, this).forEach(aCallback, context);
  40117. };
  40118. /**
  40119. * Returns all generated line and column information for the original source,
  40120. * line, and column provided. If no column is provided, returns all mappings
  40121. * corresponding to a either the line we are searching for or the next
  40122. * closest line that has any mappings. Otherwise, returns all mappings
  40123. * corresponding to the given line and either the column we are searching for
  40124. * or the next closest column that has any offsets.
  40125. *
  40126. * The only argument is an object with the following properties:
  40127. *
  40128. * - source: The filename of the original source.
  40129. * - line: The line number in the original source. The line number is 1-based.
  40130. * - column: Optional. the column number in the original source.
  40131. * The column number is 0-based.
  40132. *
  40133. * and an array of objects is returned, each with the following properties:
  40134. *
  40135. * - line: The line number in the generated source, or null. The
  40136. * line number is 1-based.
  40137. * - column: The column number in the generated source, or null.
  40138. * The column number is 0-based.
  40139. */
  40140. SourceMapConsumer$1.prototype.allGeneratedPositionsFor =
  40141. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  40142. var line = util$1.getArg(aArgs, 'line');
  40143. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  40144. // returns the index of the closest mapping less than the needle. By
  40145. // setting needle.originalColumn to 0, we thus find the last mapping for
  40146. // the given line, provided such a mapping exists.
  40147. var needle = {
  40148. source: util$1.getArg(aArgs, 'source'),
  40149. originalLine: line,
  40150. originalColumn: util$1.getArg(aArgs, 'column', 0)
  40151. };
  40152. needle.source = this._findSourceIndex(needle.source);
  40153. if (needle.source < 0) {
  40154. return [];
  40155. }
  40156. var mappings = [];
  40157. var index = this._findMapping(needle,
  40158. this._originalMappings,
  40159. "originalLine",
  40160. "originalColumn",
  40161. util$1.compareByOriginalPositions,
  40162. binarySearch.LEAST_UPPER_BOUND);
  40163. if (index >= 0) {
  40164. var mapping = this._originalMappings[index];
  40165. if (aArgs.column === undefined) {
  40166. var originalLine = mapping.originalLine;
  40167. // Iterate until either we run out of mappings, or we run into
  40168. // a mapping for a different line than the one we found. Since
  40169. // mappings are sorted, this is guaranteed to find all mappings for
  40170. // the line we found.
  40171. while (mapping && mapping.originalLine === originalLine) {
  40172. mappings.push({
  40173. line: util$1.getArg(mapping, 'generatedLine', null),
  40174. column: util$1.getArg(mapping, 'generatedColumn', null),
  40175. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40176. });
  40177. mapping = this._originalMappings[++index];
  40178. }
  40179. } else {
  40180. var originalColumn = mapping.originalColumn;
  40181. // Iterate until either we run out of mappings, or we run into
  40182. // a mapping for a different line than the one we were searching for.
  40183. // Since mappings are sorted, this is guaranteed to find all mappings for
  40184. // the line we are searching for.
  40185. while (mapping &&
  40186. mapping.originalLine === line &&
  40187. mapping.originalColumn == originalColumn) {
  40188. mappings.push({
  40189. line: util$1.getArg(mapping, 'generatedLine', null),
  40190. column: util$1.getArg(mapping, 'generatedColumn', null),
  40191. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40192. });
  40193. mapping = this._originalMappings[++index];
  40194. }
  40195. }
  40196. }
  40197. return mappings;
  40198. };
  40199. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer$1;
  40200. /**
  40201. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  40202. * query for information about the original file positions by giving it a file
  40203. * position in the generated source.
  40204. *
  40205. * The first parameter is the raw source map (either as a JSON string, or
  40206. * already parsed to an object). According to the spec, source maps have the
  40207. * following attributes:
  40208. *
  40209. * - version: Which version of the source map spec this map is following.
  40210. * - sources: An array of URLs to the original source files.
  40211. * - names: An array of identifiers which can be referrenced by individual mappings.
  40212. * - sourceRoot: Optional. The URL root from which all sources are relative.
  40213. * - sourcesContent: Optional. An array of contents of the original source files.
  40214. * - mappings: A string of base64 VLQs which contain the actual mappings.
  40215. * - file: Optional. The generated file this source map is associated with.
  40216. *
  40217. * Here is an example source map, taken from the source map spec[0]:
  40218. *
  40219. * {
  40220. * version : 3,
  40221. * file: "out.js",
  40222. * sourceRoot : "",
  40223. * sources: ["foo.js", "bar.js"],
  40224. * names: ["src", "maps", "are", "fun"],
  40225. * mappings: "AA,AB;;ABCDE;"
  40226. * }
  40227. *
  40228. * The second parameter, if given, is a string whose value is the URL
  40229. * at which the source map was found. This URL is used to compute the
  40230. * sources array.
  40231. *
  40232. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  40233. */
  40234. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  40235. var sourceMap = aSourceMap;
  40236. if (typeof aSourceMap === 'string') {
  40237. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  40238. }
  40239. var version = util$1.getArg(sourceMap, 'version');
  40240. var sources = util$1.getArg(sourceMap, 'sources');
  40241. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  40242. // requires the array) to play nice here.
  40243. var names = util$1.getArg(sourceMap, 'names', []);
  40244. var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
  40245. var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
  40246. var mappings = util$1.getArg(sourceMap, 'mappings');
  40247. var file = util$1.getArg(sourceMap, 'file', null);
  40248. // Once again, Sass deviates from the spec and supplies the version as a
  40249. // string rather than a number, so we use loose equality checking here.
  40250. if (version != this._version) {
  40251. throw new Error('Unsupported version: ' + version);
  40252. }
  40253. if (sourceRoot) {
  40254. sourceRoot = util$1.normalize(sourceRoot);
  40255. }
  40256. sources = sources
  40257. .map(String)
  40258. // Some source maps produce relative source paths like "./foo.js" instead of
  40259. // "foo.js". Normalize these first so that future comparisons will succeed.
  40260. // See bugzil.la/1090768.
  40261. .map(util$1.normalize)
  40262. // Always ensure that absolute sources are internally stored relative to
  40263. // the source root, if the source root is absolute. Not doing this would
  40264. // be particularly problematic when the source root is a prefix of the
  40265. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  40266. .map(function (source) {
  40267. return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
  40268. ? util$1.relative(sourceRoot, source)
  40269. : source;
  40270. });
  40271. // Pass `true` below to allow duplicate names and sources. While source maps
  40272. // are intended to be compressed and deduplicated, the TypeScript compiler
  40273. // sometimes generates source maps with duplicates in them. See Github issue
  40274. // #72 and bugzil.la/889492.
  40275. this._names = ArraySet.fromArray(names.map(String), true);
  40276. this._sources = ArraySet.fromArray(sources, true);
  40277. this._absoluteSources = this._sources.toArray().map(function (s) {
  40278. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  40279. });
  40280. this.sourceRoot = sourceRoot;
  40281. this.sourcesContent = sourcesContent;
  40282. this._mappings = mappings;
  40283. this._sourceMapURL = aSourceMapURL;
  40284. this.file = file;
  40285. }
  40286. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  40287. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
  40288. /**
  40289. * Utility function to find the index of a source. Returns -1 if not
  40290. * found.
  40291. */
  40292. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  40293. var relativeSource = aSource;
  40294. if (this.sourceRoot != null) {
  40295. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  40296. }
  40297. if (this._sources.has(relativeSource)) {
  40298. return this._sources.indexOf(relativeSource);
  40299. }
  40300. // Maybe aSource is an absolute URL as returned by |sources|. In
  40301. // this case we can't simply undo the transform.
  40302. var i;
  40303. for (i = 0; i < this._absoluteSources.length; ++i) {
  40304. if (this._absoluteSources[i] == aSource) {
  40305. return i;
  40306. }
  40307. }
  40308. return -1;
  40309. };
  40310. /**
  40311. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  40312. *
  40313. * @param SourceMapGenerator aSourceMap
  40314. * The source map that will be consumed.
  40315. * @param String aSourceMapURL
  40316. * The URL at which the source map can be found (optional)
  40317. * @returns BasicSourceMapConsumer
  40318. */
  40319. BasicSourceMapConsumer.fromSourceMap =
  40320. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  40321. var smc = Object.create(BasicSourceMapConsumer.prototype);
  40322. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  40323. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  40324. smc.sourceRoot = aSourceMap._sourceRoot;
  40325. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  40326. smc.sourceRoot);
  40327. smc.file = aSourceMap._file;
  40328. smc._sourceMapURL = aSourceMapURL;
  40329. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  40330. return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  40331. });
  40332. // Because we are modifying the entries (by converting string sources and
  40333. // names to indices into the sources and names ArraySets), we have to make
  40334. // a copy of the entry or else bad things happen. Shared mutable state
  40335. // strikes again! See github issue #191.
  40336. var generatedMappings = aSourceMap._mappings.toArray().slice();
  40337. var destGeneratedMappings = smc.__generatedMappings = [];
  40338. var destOriginalMappings = smc.__originalMappings = [];
  40339. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  40340. var srcMapping = generatedMappings[i];
  40341. var destMapping = new Mapping;
  40342. destMapping.generatedLine = srcMapping.generatedLine;
  40343. destMapping.generatedColumn = srcMapping.generatedColumn;
  40344. if (srcMapping.source) {
  40345. destMapping.source = sources.indexOf(srcMapping.source);
  40346. destMapping.originalLine = srcMapping.originalLine;
  40347. destMapping.originalColumn = srcMapping.originalColumn;
  40348. if (srcMapping.name) {
  40349. destMapping.name = names.indexOf(srcMapping.name);
  40350. }
  40351. destOriginalMappings.push(destMapping);
  40352. }
  40353. destGeneratedMappings.push(destMapping);
  40354. }
  40355. quickSort(smc.__originalMappings, util$1.compareByOriginalPositions);
  40356. return smc;
  40357. };
  40358. /**
  40359. * The version of the source mapping spec that we are consuming.
  40360. */
  40361. BasicSourceMapConsumer.prototype._version = 3;
  40362. /**
  40363. * The list of original sources.
  40364. */
  40365. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  40366. get: function () {
  40367. return this._absoluteSources.slice();
  40368. }
  40369. });
  40370. /**
  40371. * Provide the JIT with a nice shape / hidden class.
  40372. */
  40373. function Mapping() {
  40374. this.generatedLine = 0;
  40375. this.generatedColumn = 0;
  40376. this.source = null;
  40377. this.originalLine = null;
  40378. this.originalColumn = null;
  40379. this.name = null;
  40380. }
  40381. /**
  40382. * Parse the mappings in a string in to a data structure which we can easily
  40383. * query (the ordered arrays in the `this.__generatedMappings` and
  40384. * `this.__originalMappings` properties).
  40385. */
  40386. BasicSourceMapConsumer.prototype._parseMappings =
  40387. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40388. var generatedLine = 1;
  40389. var previousGeneratedColumn = 0;
  40390. var previousOriginalLine = 0;
  40391. var previousOriginalColumn = 0;
  40392. var previousSource = 0;
  40393. var previousName = 0;
  40394. var length = aStr.length;
  40395. var index = 0;
  40396. var cachedSegments = {};
  40397. var temp = {};
  40398. var originalMappings = [];
  40399. var generatedMappings = [];
  40400. var mapping, str, segment, end, value;
  40401. while (index < length) {
  40402. if (aStr.charAt(index) === ';') {
  40403. generatedLine++;
  40404. index++;
  40405. previousGeneratedColumn = 0;
  40406. }
  40407. else if (aStr.charAt(index) === ',') {
  40408. index++;
  40409. }
  40410. else {
  40411. mapping = new Mapping();
  40412. mapping.generatedLine = generatedLine;
  40413. // Because each offset is encoded relative to the previous one,
  40414. // many segments often have the same encoding. We can exploit this
  40415. // fact by caching the parsed variable length fields of each segment,
  40416. // allowing us to avoid a second parse if we encounter the same
  40417. // segment again.
  40418. for (end = index; end < length; end++) {
  40419. if (this._charIsMappingSeparator(aStr, end)) {
  40420. break;
  40421. }
  40422. }
  40423. str = aStr.slice(index, end);
  40424. segment = cachedSegments[str];
  40425. if (segment) {
  40426. index += str.length;
  40427. } else {
  40428. segment = [];
  40429. while (index < end) {
  40430. base64VLQ.decode(aStr, index, temp);
  40431. value = temp.value;
  40432. index = temp.rest;
  40433. segment.push(value);
  40434. }
  40435. if (segment.length === 2) {
  40436. throw new Error('Found a source, but no line and column');
  40437. }
  40438. if (segment.length === 3) {
  40439. throw new Error('Found a source and line, but no column');
  40440. }
  40441. cachedSegments[str] = segment;
  40442. }
  40443. // Generated column.
  40444. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  40445. previousGeneratedColumn = mapping.generatedColumn;
  40446. if (segment.length > 1) {
  40447. // Original source.
  40448. mapping.source = previousSource + segment[1];
  40449. previousSource += segment[1];
  40450. // Original line.
  40451. mapping.originalLine = previousOriginalLine + segment[2];
  40452. previousOriginalLine = mapping.originalLine;
  40453. // Lines are stored 0-based
  40454. mapping.originalLine += 1;
  40455. // Original column.
  40456. mapping.originalColumn = previousOriginalColumn + segment[3];
  40457. previousOriginalColumn = mapping.originalColumn;
  40458. if (segment.length > 4) {
  40459. // Original name.
  40460. mapping.name = previousName + segment[4];
  40461. previousName += segment[4];
  40462. }
  40463. }
  40464. generatedMappings.push(mapping);
  40465. if (typeof mapping.originalLine === 'number') {
  40466. originalMappings.push(mapping);
  40467. }
  40468. }
  40469. }
  40470. quickSort(generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  40471. this.__generatedMappings = generatedMappings;
  40472. quickSort(originalMappings, util$1.compareByOriginalPositions);
  40473. this.__originalMappings = originalMappings;
  40474. };
  40475. /**
  40476. * Find the mapping that best matches the hypothetical "needle" mapping that
  40477. * we are searching for in the given "haystack" of mappings.
  40478. */
  40479. BasicSourceMapConsumer.prototype._findMapping =
  40480. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  40481. aColumnName, aComparator, aBias) {
  40482. // To return the position we are searching for, we must first find the
  40483. // mapping for the given position and then return the opposite position it
  40484. // points to. Because the mappings are sorted, we can use binary search to
  40485. // find the best mapping.
  40486. if (aNeedle[aLineName] <= 0) {
  40487. throw new TypeError('Line must be greater than or equal to 1, got '
  40488. + aNeedle[aLineName]);
  40489. }
  40490. if (aNeedle[aColumnName] < 0) {
  40491. throw new TypeError('Column must be greater than or equal to 0, got '
  40492. + aNeedle[aColumnName]);
  40493. }
  40494. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  40495. };
  40496. /**
  40497. * Compute the last column for each generated mapping. The last column is
  40498. * inclusive.
  40499. */
  40500. BasicSourceMapConsumer.prototype.computeColumnSpans =
  40501. function SourceMapConsumer_computeColumnSpans() {
  40502. for (var index = 0; index < this._generatedMappings.length; ++index) {
  40503. var mapping = this._generatedMappings[index];
  40504. // Mappings do not contain a field for the last generated columnt. We
  40505. // can come up with an optimistic estimate, however, by assuming that
  40506. // mappings are contiguous (i.e. given two consecutive mappings, the
  40507. // first mapping ends where the second one starts).
  40508. if (index + 1 < this._generatedMappings.length) {
  40509. var nextMapping = this._generatedMappings[index + 1];
  40510. if (mapping.generatedLine === nextMapping.generatedLine) {
  40511. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  40512. continue;
  40513. }
  40514. }
  40515. // The last mapping for each line spans the entire line.
  40516. mapping.lastGeneratedColumn = Infinity;
  40517. }
  40518. };
  40519. /**
  40520. * Returns the original source, line, and column information for the generated
  40521. * source's line and column positions provided. The only argument is an object
  40522. * with the following properties:
  40523. *
  40524. * - line: The line number in the generated source. The line number
  40525. * is 1-based.
  40526. * - column: The column number in the generated source. The column
  40527. * number is 0-based.
  40528. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  40529. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  40530. * closest element that is smaller than or greater than the one we are
  40531. * searching for, respectively, if the exact element cannot be found.
  40532. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  40533. *
  40534. * and an object is returned with the following properties:
  40535. *
  40536. * - source: The original source file, or null.
  40537. * - line: The line number in the original source, or null. The
  40538. * line number is 1-based.
  40539. * - column: The column number in the original source, or null. The
  40540. * column number is 0-based.
  40541. * - name: The original identifier, or null.
  40542. */
  40543. BasicSourceMapConsumer.prototype.originalPositionFor =
  40544. function SourceMapConsumer_originalPositionFor(aArgs) {
  40545. var needle = {
  40546. generatedLine: util$1.getArg(aArgs, 'line'),
  40547. generatedColumn: util$1.getArg(aArgs, 'column')
  40548. };
  40549. var index = this._findMapping(
  40550. needle,
  40551. this._generatedMappings,
  40552. "generatedLine",
  40553. "generatedColumn",
  40554. util$1.compareByGeneratedPositionsDeflated,
  40555. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  40556. );
  40557. if (index >= 0) {
  40558. var mapping = this._generatedMappings[index];
  40559. if (mapping.generatedLine === needle.generatedLine) {
  40560. var source = util$1.getArg(mapping, 'source', null);
  40561. if (source !== null) {
  40562. source = this._sources.at(source);
  40563. source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  40564. }
  40565. var name = util$1.getArg(mapping, 'name', null);
  40566. if (name !== null) {
  40567. name = this._names.at(name);
  40568. }
  40569. return {
  40570. source: source,
  40571. line: util$1.getArg(mapping, 'originalLine', null),
  40572. column: util$1.getArg(mapping, 'originalColumn', null),
  40573. name: name
  40574. };
  40575. }
  40576. }
  40577. return {
  40578. source: null,
  40579. line: null,
  40580. column: null,
  40581. name: null
  40582. };
  40583. };
  40584. /**
  40585. * Return true if we have the source content for every source in the source
  40586. * map, false otherwise.
  40587. */
  40588. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  40589. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  40590. if (!this.sourcesContent) {
  40591. return false;
  40592. }
  40593. return this.sourcesContent.length >= this._sources.size() &&
  40594. !this.sourcesContent.some(function (sc) { return sc == null; });
  40595. };
  40596. /**
  40597. * Returns the original source content. The only argument is the url of the
  40598. * original source file. Returns null if no original source content is
  40599. * available.
  40600. */
  40601. BasicSourceMapConsumer.prototype.sourceContentFor =
  40602. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  40603. if (!this.sourcesContent) {
  40604. return null;
  40605. }
  40606. var index = this._findSourceIndex(aSource);
  40607. if (index >= 0) {
  40608. return this.sourcesContent[index];
  40609. }
  40610. var relativeSource = aSource;
  40611. if (this.sourceRoot != null) {
  40612. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  40613. }
  40614. var url;
  40615. if (this.sourceRoot != null
  40616. && (url = util$1.urlParse(this.sourceRoot))) {
  40617. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  40618. // many users. We can help them out when they expect file:// URIs to
  40619. // behave like it would if they were running a local HTTP server. See
  40620. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  40621. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  40622. if (url.scheme == "file"
  40623. && this._sources.has(fileUriAbsPath)) {
  40624. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  40625. }
  40626. if ((!url.path || url.path == "/")
  40627. && this._sources.has("/" + relativeSource)) {
  40628. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  40629. }
  40630. }
  40631. // This function is used recursively from
  40632. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  40633. // don't want to throw if we can't find the source - we just want to
  40634. // return null, so we provide a flag to exit gracefully.
  40635. if (nullOnMissing) {
  40636. return null;
  40637. }
  40638. else {
  40639. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  40640. }
  40641. };
  40642. /**
  40643. * Returns the generated line and column information for the original source,
  40644. * line, and column positions provided. The only argument is an object with
  40645. * the following properties:
  40646. *
  40647. * - source: The filename of the original source.
  40648. * - line: The line number in the original source. The line number
  40649. * is 1-based.
  40650. * - column: The column number in the original source. The column
  40651. * number is 0-based.
  40652. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  40653. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  40654. * closest element that is smaller than or greater than the one we are
  40655. * searching for, respectively, if the exact element cannot be found.
  40656. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  40657. *
  40658. * and an object is returned with the following properties:
  40659. *
  40660. * - line: The line number in the generated source, or null. The
  40661. * line number is 1-based.
  40662. * - column: The column number in the generated source, or null.
  40663. * The column number is 0-based.
  40664. */
  40665. BasicSourceMapConsumer.prototype.generatedPositionFor =
  40666. function SourceMapConsumer_generatedPositionFor(aArgs) {
  40667. var source = util$1.getArg(aArgs, 'source');
  40668. source = this._findSourceIndex(source);
  40669. if (source < 0) {
  40670. return {
  40671. line: null,
  40672. column: null,
  40673. lastColumn: null
  40674. };
  40675. }
  40676. var needle = {
  40677. source: source,
  40678. originalLine: util$1.getArg(aArgs, 'line'),
  40679. originalColumn: util$1.getArg(aArgs, 'column')
  40680. };
  40681. var index = this._findMapping(
  40682. needle,
  40683. this._originalMappings,
  40684. "originalLine",
  40685. "originalColumn",
  40686. util$1.compareByOriginalPositions,
  40687. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  40688. );
  40689. if (index >= 0) {
  40690. var mapping = this._originalMappings[index];
  40691. if (mapping.source === needle.source) {
  40692. return {
  40693. line: util$1.getArg(mapping, 'generatedLine', null),
  40694. column: util$1.getArg(mapping, 'generatedColumn', null),
  40695. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  40696. };
  40697. }
  40698. }
  40699. return {
  40700. line: null,
  40701. column: null,
  40702. lastColumn: null
  40703. };
  40704. };
  40705. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  40706. /**
  40707. * An IndexedSourceMapConsumer instance represents a parsed source map which
  40708. * we can query for information. It differs from BasicSourceMapConsumer in
  40709. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  40710. * input.
  40711. *
  40712. * The first parameter is a raw source map (either as a JSON string, or already
  40713. * parsed to an object). According to the spec for indexed source maps, they
  40714. * have the following attributes:
  40715. *
  40716. * - version: Which version of the source map spec this map is following.
  40717. * - file: Optional. The generated file this source map is associated with.
  40718. * - sections: A list of section definitions.
  40719. *
  40720. * Each value under the "sections" field has two fields:
  40721. * - offset: The offset into the original specified at which this section
  40722. * begins to apply, defined as an object with a "line" and "column"
  40723. * field.
  40724. * - map: A source map definition. This source map could also be indexed,
  40725. * but doesn't have to be.
  40726. *
  40727. * Instead of the "map" field, it's also possible to have a "url" field
  40728. * specifying a URL to retrieve a source map from, but that's currently
  40729. * unsupported.
  40730. *
  40731. * Here's an example source map, taken from the source map spec[0], but
  40732. * modified to omit a section which uses the "url" field.
  40733. *
  40734. * {
  40735. * version : 3,
  40736. * file: "app.js",
  40737. * sections: [{
  40738. * offset: {line:100, column:10},
  40739. * map: {
  40740. * version : 3,
  40741. * file: "section.js",
  40742. * sources: ["foo.js", "bar.js"],
  40743. * names: ["src", "maps", "are", "fun"],
  40744. * mappings: "AAAA,E;;ABCDE;"
  40745. * }
  40746. * }],
  40747. * }
  40748. *
  40749. * The second parameter, if given, is a string whose value is the URL
  40750. * at which the source map was found. This URL is used to compute the
  40751. * sources array.
  40752. *
  40753. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  40754. */
  40755. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  40756. var sourceMap = aSourceMap;
  40757. if (typeof aSourceMap === 'string') {
  40758. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  40759. }
  40760. var version = util$1.getArg(sourceMap, 'version');
  40761. var sections = util$1.getArg(sourceMap, 'sections');
  40762. if (version != this._version) {
  40763. throw new Error('Unsupported version: ' + version);
  40764. }
  40765. this._sources = new ArraySet();
  40766. this._names = new ArraySet();
  40767. var lastOffset = {
  40768. line: -1,
  40769. column: 0
  40770. };
  40771. this._sections = sections.map(function (s) {
  40772. if (s.url) {
  40773. // The url field will require support for asynchronicity.
  40774. // See https://github.com/mozilla/source-map/issues/16
  40775. throw new Error('Support for url field in sections not implemented.');
  40776. }
  40777. var offset = util$1.getArg(s, 'offset');
  40778. var offsetLine = util$1.getArg(offset, 'line');
  40779. var offsetColumn = util$1.getArg(offset, 'column');
  40780. if (offsetLine < lastOffset.line ||
  40781. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  40782. throw new Error('Section offsets must be ordered and non-overlapping.');
  40783. }
  40784. lastOffset = offset;
  40785. return {
  40786. generatedOffset: {
  40787. // The offset fields are 0-based, but we use 1-based indices when
  40788. // encoding/decoding from VLQ.
  40789. generatedLine: offsetLine + 1,
  40790. generatedColumn: offsetColumn + 1
  40791. },
  40792. consumer: new SourceMapConsumer$1(util$1.getArg(s, 'map'), aSourceMapURL)
  40793. }
  40794. });
  40795. }
  40796. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  40797. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer$1;
  40798. /**
  40799. * The version of the source mapping spec that we are consuming.
  40800. */
  40801. IndexedSourceMapConsumer.prototype._version = 3;
  40802. /**
  40803. * The list of original sources.
  40804. */
  40805. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  40806. get: function () {
  40807. var sources = [];
  40808. for (var i = 0; i < this._sections.length; i++) {
  40809. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  40810. sources.push(this._sections[i].consumer.sources[j]);
  40811. }
  40812. }
  40813. return sources;
  40814. }
  40815. });
  40816. /**
  40817. * Returns the original source, line, and column information for the generated
  40818. * source's line and column positions provided. The only argument is an object
  40819. * with the following properties:
  40820. *
  40821. * - line: The line number in the generated source. The line number
  40822. * is 1-based.
  40823. * - column: The column number in the generated source. The column
  40824. * number is 0-based.
  40825. *
  40826. * and an object is returned with the following properties:
  40827. *
  40828. * - source: The original source file, or null.
  40829. * - line: The line number in the original source, or null. The
  40830. * line number is 1-based.
  40831. * - column: The column number in the original source, or null. The
  40832. * column number is 0-based.
  40833. * - name: The original identifier, or null.
  40834. */
  40835. IndexedSourceMapConsumer.prototype.originalPositionFor =
  40836. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  40837. var needle = {
  40838. generatedLine: util$1.getArg(aArgs, 'line'),
  40839. generatedColumn: util$1.getArg(aArgs, 'column')
  40840. };
  40841. // Find the section containing the generated position we're trying to map
  40842. // to an original position.
  40843. var sectionIndex = binarySearch.search(needle, this._sections,
  40844. function(needle, section) {
  40845. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  40846. if (cmp) {
  40847. return cmp;
  40848. }
  40849. return (needle.generatedColumn -
  40850. section.generatedOffset.generatedColumn);
  40851. });
  40852. var section = this._sections[sectionIndex];
  40853. if (!section) {
  40854. return {
  40855. source: null,
  40856. line: null,
  40857. column: null,
  40858. name: null
  40859. };
  40860. }
  40861. return section.consumer.originalPositionFor({
  40862. line: needle.generatedLine -
  40863. (section.generatedOffset.generatedLine - 1),
  40864. column: needle.generatedColumn -
  40865. (section.generatedOffset.generatedLine === needle.generatedLine
  40866. ? section.generatedOffset.generatedColumn - 1
  40867. : 0),
  40868. bias: aArgs.bias
  40869. });
  40870. };
  40871. /**
  40872. * Return true if we have the source content for every source in the source
  40873. * map, false otherwise.
  40874. */
  40875. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  40876. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  40877. return this._sections.every(function (s) {
  40878. return s.consumer.hasContentsOfAllSources();
  40879. });
  40880. };
  40881. /**
  40882. * Returns the original source content. The only argument is the url of the
  40883. * original source file. Returns null if no original source content is
  40884. * available.
  40885. */
  40886. IndexedSourceMapConsumer.prototype.sourceContentFor =
  40887. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  40888. for (var i = 0; i < this._sections.length; i++) {
  40889. var section = this._sections[i];
  40890. var content = section.consumer.sourceContentFor(aSource, true);
  40891. if (content) {
  40892. return content;
  40893. }
  40894. }
  40895. if (nullOnMissing) {
  40896. return null;
  40897. }
  40898. else {
  40899. throw new Error('"' + aSource + '" is not in the SourceMap.');
  40900. }
  40901. };
  40902. /**
  40903. * Returns the generated line and column information for the original source,
  40904. * line, and column positions provided. The only argument is an object with
  40905. * the following properties:
  40906. *
  40907. * - source: The filename of the original source.
  40908. * - line: The line number in the original source. The line number
  40909. * is 1-based.
  40910. * - column: The column number in the original source. The column
  40911. * number is 0-based.
  40912. *
  40913. * and an object is returned with the following properties:
  40914. *
  40915. * - line: The line number in the generated source, or null. The
  40916. * line number is 1-based.
  40917. * - column: The column number in the generated source, or null.
  40918. * The column number is 0-based.
  40919. */
  40920. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  40921. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  40922. for (var i = 0; i < this._sections.length; i++) {
  40923. var section = this._sections[i];
  40924. // Only consider this section if the requested source is in the list of
  40925. // sources of the consumer.
  40926. if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
  40927. continue;
  40928. }
  40929. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  40930. if (generatedPosition) {
  40931. var ret = {
  40932. line: generatedPosition.line +
  40933. (section.generatedOffset.generatedLine - 1),
  40934. column: generatedPosition.column +
  40935. (section.generatedOffset.generatedLine === generatedPosition.line
  40936. ? section.generatedOffset.generatedColumn - 1
  40937. : 0)
  40938. };
  40939. return ret;
  40940. }
  40941. }
  40942. return {
  40943. line: null,
  40944. column: null
  40945. };
  40946. };
  40947. /**
  40948. * Parse the mappings in a string in to a data structure which we can easily
  40949. * query (the ordered arrays in the `this.__generatedMappings` and
  40950. * `this.__originalMappings` properties).
  40951. */
  40952. IndexedSourceMapConsumer.prototype._parseMappings =
  40953. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  40954. this.__generatedMappings = [];
  40955. this.__originalMappings = [];
  40956. for (var i = 0; i < this._sections.length; i++) {
  40957. var section = this._sections[i];
  40958. var sectionMappings = section.consumer._generatedMappings;
  40959. for (var j = 0; j < sectionMappings.length; j++) {
  40960. var mapping = sectionMappings[j];
  40961. var source = section.consumer._sources.at(mapping.source);
  40962. source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  40963. this._sources.add(source);
  40964. source = this._sources.indexOf(source);
  40965. var name = null;
  40966. if (mapping.name) {
  40967. name = section.consumer._names.at(mapping.name);
  40968. this._names.add(name);
  40969. name = this._names.indexOf(name);
  40970. }
  40971. // The mappings coming from the consumer for the section have
  40972. // generated positions relative to the start of the section, so we
  40973. // need to offset them to be relative to the start of the concatenated
  40974. // generated file.
  40975. var adjustedMapping = {
  40976. source: source,
  40977. generatedLine: mapping.generatedLine +
  40978. (section.generatedOffset.generatedLine - 1),
  40979. generatedColumn: mapping.generatedColumn +
  40980. (section.generatedOffset.generatedLine === mapping.generatedLine
  40981. ? section.generatedOffset.generatedColumn - 1
  40982. : 0),
  40983. originalLine: mapping.originalLine,
  40984. originalColumn: mapping.originalColumn,
  40985. name: name
  40986. };
  40987. this.__generatedMappings.push(adjustedMapping);
  40988. if (typeof adjustedMapping.originalLine === 'number') {
  40989. this.__originalMappings.push(adjustedMapping);
  40990. }
  40991. }
  40992. }
  40993. quickSort(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  40994. quickSort(this.__originalMappings, util$1.compareByOriginalPositions);
  40995. };
  40996. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  40997. var sourceNode = {};
  40998. /* -*- Mode: js; js-indent-level: 2; -*- */
  40999. /*
  41000. * Copyright 2011 Mozilla Foundation and contributors
  41001. * Licensed under the New BSD license. See LICENSE or:
  41002. * http://opensource.org/licenses/BSD-3-Clause
  41003. */
  41004. var SourceMapGenerator$1 = sourceMapGenerator.SourceMapGenerator;
  41005. var util = util$5;
  41006. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  41007. // operating systems these days (capturing the result).
  41008. var REGEX_NEWLINE = /(\r?\n)/;
  41009. // Newline character code for charCodeAt() comparisons
  41010. var NEWLINE_CODE = 10;
  41011. // Private symbol for identifying `SourceNode`s when multiple versions of
  41012. // the source-map library are loaded. This MUST NOT CHANGE across
  41013. // versions!
  41014. var isSourceNode = "$$$isSourceNode$$$";
  41015. /**
  41016. * SourceNodes provide a way to abstract over interpolating/concatenating
  41017. * snippets of generated JavaScript source code while maintaining the line and
  41018. * column information associated with the original source code.
  41019. *
  41020. * @param aLine The original line number.
  41021. * @param aColumn The original column number.
  41022. * @param aSource The original source's filename.
  41023. * @param aChunks Optional. An array of strings which are snippets of
  41024. * generated JS, or other SourceNodes.
  41025. * @param aName The original identifier.
  41026. */
  41027. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  41028. this.children = [];
  41029. this.sourceContents = {};
  41030. this.line = aLine == null ? null : aLine;
  41031. this.column = aColumn == null ? null : aColumn;
  41032. this.source = aSource == null ? null : aSource;
  41033. this.name = aName == null ? null : aName;
  41034. this[isSourceNode] = true;
  41035. if (aChunks != null) this.add(aChunks);
  41036. }
  41037. /**
  41038. * Creates a SourceNode from generated code and a SourceMapConsumer.
  41039. *
  41040. * @param aGeneratedCode The generated code
  41041. * @param aSourceMapConsumer The SourceMap for the generated code
  41042. * @param aRelativePath Optional. The path that relative sources in the
  41043. * SourceMapConsumer should be relative to.
  41044. */
  41045. SourceNode.fromStringWithSourceMap =
  41046. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  41047. // The SourceNode we want to fill with the generated code
  41048. // and the SourceMap
  41049. var node = new SourceNode();
  41050. // All even indices of this array are one line of the generated code,
  41051. // while all odd indices are the newlines between two adjacent lines
  41052. // (since `REGEX_NEWLINE` captures its match).
  41053. // Processed fragments are accessed by calling `shiftNextLine`.
  41054. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  41055. var remainingLinesIndex = 0;
  41056. var shiftNextLine = function() {
  41057. var lineContents = getNextLine();
  41058. // The last line of a file might not have a newline.
  41059. var newLine = getNextLine() || "";
  41060. return lineContents + newLine;
  41061. function getNextLine() {
  41062. return remainingLinesIndex < remainingLines.length ?
  41063. remainingLines[remainingLinesIndex++] : undefined;
  41064. }
  41065. };
  41066. // We need to remember the position of "remainingLines"
  41067. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  41068. // The generate SourceNodes we need a code range.
  41069. // To extract it current and last mapping is used.
  41070. // Here we store the last mapping.
  41071. var lastMapping = null;
  41072. aSourceMapConsumer.eachMapping(function (mapping) {
  41073. if (lastMapping !== null) {
  41074. // We add the code from "lastMapping" to "mapping":
  41075. // First check if there is a new line in between.
  41076. if (lastGeneratedLine < mapping.generatedLine) {
  41077. // Associate first line with "lastMapping"
  41078. addMappingWithCode(lastMapping, shiftNextLine());
  41079. lastGeneratedLine++;
  41080. lastGeneratedColumn = 0;
  41081. // The remaining code is added without mapping
  41082. } else {
  41083. // There is no new line in between.
  41084. // Associate the code between "lastGeneratedColumn" and
  41085. // "mapping.generatedColumn" with "lastMapping"
  41086. var nextLine = remainingLines[remainingLinesIndex] || '';
  41087. var code = nextLine.substr(0, mapping.generatedColumn -
  41088. lastGeneratedColumn);
  41089. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  41090. lastGeneratedColumn);
  41091. lastGeneratedColumn = mapping.generatedColumn;
  41092. addMappingWithCode(lastMapping, code);
  41093. // No more remaining code, continue
  41094. lastMapping = mapping;
  41095. return;
  41096. }
  41097. }
  41098. // We add the generated code until the first mapping
  41099. // to the SourceNode without any mapping.
  41100. // Each line is added as separate string.
  41101. while (lastGeneratedLine < mapping.generatedLine) {
  41102. node.add(shiftNextLine());
  41103. lastGeneratedLine++;
  41104. }
  41105. if (lastGeneratedColumn < mapping.generatedColumn) {
  41106. var nextLine = remainingLines[remainingLinesIndex] || '';
  41107. node.add(nextLine.substr(0, mapping.generatedColumn));
  41108. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  41109. lastGeneratedColumn = mapping.generatedColumn;
  41110. }
  41111. lastMapping = mapping;
  41112. }, this);
  41113. // We have processed all mappings.
  41114. if (remainingLinesIndex < remainingLines.length) {
  41115. if (lastMapping) {
  41116. // Associate the remaining code in the current line with "lastMapping"
  41117. addMappingWithCode(lastMapping, shiftNextLine());
  41118. }
  41119. // and add the remaining lines without any mapping
  41120. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  41121. }
  41122. // Copy sourcesContent into SourceNode
  41123. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  41124. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  41125. if (content != null) {
  41126. if (aRelativePath != null) {
  41127. sourceFile = util.join(aRelativePath, sourceFile);
  41128. }
  41129. node.setSourceContent(sourceFile, content);
  41130. }
  41131. });
  41132. return node;
  41133. function addMappingWithCode(mapping, code) {
  41134. if (mapping === null || mapping.source === undefined) {
  41135. node.add(code);
  41136. } else {
  41137. var source = aRelativePath
  41138. ? util.join(aRelativePath, mapping.source)
  41139. : mapping.source;
  41140. node.add(new SourceNode(mapping.originalLine,
  41141. mapping.originalColumn,
  41142. source,
  41143. code,
  41144. mapping.name));
  41145. }
  41146. }
  41147. };
  41148. /**
  41149. * Add a chunk of generated JS to this source node.
  41150. *
  41151. * @param aChunk A string snippet of generated JS code, another instance of
  41152. * SourceNode, or an array where each member is one of those things.
  41153. */
  41154. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  41155. if (Array.isArray(aChunk)) {
  41156. aChunk.forEach(function (chunk) {
  41157. this.add(chunk);
  41158. }, this);
  41159. }
  41160. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  41161. if (aChunk) {
  41162. this.children.push(aChunk);
  41163. }
  41164. }
  41165. else {
  41166. throw new TypeError(
  41167. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  41168. );
  41169. }
  41170. return this;
  41171. };
  41172. /**
  41173. * Add a chunk of generated JS to the beginning of this source node.
  41174. *
  41175. * @param aChunk A string snippet of generated JS code, another instance of
  41176. * SourceNode, or an array where each member is one of those things.
  41177. */
  41178. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  41179. if (Array.isArray(aChunk)) {
  41180. for (var i = aChunk.length-1; i >= 0; i--) {
  41181. this.prepend(aChunk[i]);
  41182. }
  41183. }
  41184. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  41185. this.children.unshift(aChunk);
  41186. }
  41187. else {
  41188. throw new TypeError(
  41189. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  41190. );
  41191. }
  41192. return this;
  41193. };
  41194. /**
  41195. * Walk over the tree of JS snippets in this node and its children. The
  41196. * walking function is called once for each snippet of JS and is passed that
  41197. * snippet and the its original associated source's line/column location.
  41198. *
  41199. * @param aFn The traversal function.
  41200. */
  41201. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  41202. var chunk;
  41203. for (var i = 0, len = this.children.length; i < len; i++) {
  41204. chunk = this.children[i];
  41205. if (chunk[isSourceNode]) {
  41206. chunk.walk(aFn);
  41207. }
  41208. else {
  41209. if (chunk !== '') {
  41210. aFn(chunk, { source: this.source,
  41211. line: this.line,
  41212. column: this.column,
  41213. name: this.name });
  41214. }
  41215. }
  41216. }
  41217. };
  41218. /**
  41219. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  41220. * each of `this.children`.
  41221. *
  41222. * @param aSep The separator.
  41223. */
  41224. SourceNode.prototype.join = function SourceNode_join(aSep) {
  41225. var newChildren;
  41226. var i;
  41227. var len = this.children.length;
  41228. if (len > 0) {
  41229. newChildren = [];
  41230. for (i = 0; i < len-1; i++) {
  41231. newChildren.push(this.children[i]);
  41232. newChildren.push(aSep);
  41233. }
  41234. newChildren.push(this.children[i]);
  41235. this.children = newChildren;
  41236. }
  41237. return this;
  41238. };
  41239. /**
  41240. * Call String.prototype.replace on the very right-most source snippet. Useful
  41241. * for trimming whitespace from the end of a source node, etc.
  41242. *
  41243. * @param aPattern The pattern to replace.
  41244. * @param aReplacement The thing to replace the pattern with.
  41245. */
  41246. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  41247. var lastChild = this.children[this.children.length - 1];
  41248. if (lastChild[isSourceNode]) {
  41249. lastChild.replaceRight(aPattern, aReplacement);
  41250. }
  41251. else if (typeof lastChild === 'string') {
  41252. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  41253. }
  41254. else {
  41255. this.children.push(''.replace(aPattern, aReplacement));
  41256. }
  41257. return this;
  41258. };
  41259. /**
  41260. * Set the source content for a source file. This will be added to the SourceMapGenerator
  41261. * in the sourcesContent field.
  41262. *
  41263. * @param aSourceFile The filename of the source file
  41264. * @param aSourceContent The content of the source file
  41265. */
  41266. SourceNode.prototype.setSourceContent =
  41267. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  41268. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  41269. };
  41270. /**
  41271. * Walk over the tree of SourceNodes. The walking function is called for each
  41272. * source file content and is passed the filename and source content.
  41273. *
  41274. * @param aFn The traversal function.
  41275. */
  41276. SourceNode.prototype.walkSourceContents =
  41277. function SourceNode_walkSourceContents(aFn) {
  41278. for (var i = 0, len = this.children.length; i < len; i++) {
  41279. if (this.children[i][isSourceNode]) {
  41280. this.children[i].walkSourceContents(aFn);
  41281. }
  41282. }
  41283. var sources = Object.keys(this.sourceContents);
  41284. for (var i = 0, len = sources.length; i < len; i++) {
  41285. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  41286. }
  41287. };
  41288. /**
  41289. * Return the string representation of this source node. Walks over the tree
  41290. * and concatenates all the various snippets together to one string.
  41291. */
  41292. SourceNode.prototype.toString = function SourceNode_toString() {
  41293. var str = "";
  41294. this.walk(function (chunk) {
  41295. str += chunk;
  41296. });
  41297. return str;
  41298. };
  41299. /**
  41300. * Returns the string representation of this source node along with a source
  41301. * map.
  41302. */
  41303. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  41304. var generated = {
  41305. code: "",
  41306. line: 1,
  41307. column: 0
  41308. };
  41309. var map = new SourceMapGenerator$1(aArgs);
  41310. var sourceMappingActive = false;
  41311. var lastOriginalSource = null;
  41312. var lastOriginalLine = null;
  41313. var lastOriginalColumn = null;
  41314. var lastOriginalName = null;
  41315. this.walk(function (chunk, original) {
  41316. generated.code += chunk;
  41317. if (original.source !== null
  41318. && original.line !== null
  41319. && original.column !== null) {
  41320. if(lastOriginalSource !== original.source
  41321. || lastOriginalLine !== original.line
  41322. || lastOriginalColumn !== original.column
  41323. || lastOriginalName !== original.name) {
  41324. map.addMapping({
  41325. source: original.source,
  41326. original: {
  41327. line: original.line,
  41328. column: original.column
  41329. },
  41330. generated: {
  41331. line: generated.line,
  41332. column: generated.column
  41333. },
  41334. name: original.name
  41335. });
  41336. }
  41337. lastOriginalSource = original.source;
  41338. lastOriginalLine = original.line;
  41339. lastOriginalColumn = original.column;
  41340. lastOriginalName = original.name;
  41341. sourceMappingActive = true;
  41342. } else if (sourceMappingActive) {
  41343. map.addMapping({
  41344. generated: {
  41345. line: generated.line,
  41346. column: generated.column
  41347. }
  41348. });
  41349. lastOriginalSource = null;
  41350. sourceMappingActive = false;
  41351. }
  41352. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  41353. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  41354. generated.line++;
  41355. generated.column = 0;
  41356. // Mappings end at eol
  41357. if (idx + 1 === length) {
  41358. lastOriginalSource = null;
  41359. sourceMappingActive = false;
  41360. } else if (sourceMappingActive) {
  41361. map.addMapping({
  41362. source: original.source,
  41363. original: {
  41364. line: original.line,
  41365. column: original.column
  41366. },
  41367. generated: {
  41368. line: generated.line,
  41369. column: generated.column
  41370. },
  41371. name: original.name
  41372. });
  41373. }
  41374. } else {
  41375. generated.column++;
  41376. }
  41377. }
  41378. });
  41379. this.walkSourceContents(function (sourceFile, sourceContent) {
  41380. map.setSourceContent(sourceFile, sourceContent);
  41381. });
  41382. return { code: generated.code, map: map };
  41383. };
  41384. sourceNode.SourceNode = SourceNode;
  41385. /*
  41386. * Copyright 2009-2011 Mozilla Foundation and contributors
  41387. * Licensed under the New BSD license. See LICENSE.txt or:
  41388. * http://opensource.org/licenses/BSD-3-Clause
  41389. */
  41390. sourceMap$1.SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  41391. sourceMap$1.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
  41392. sourceMap$1.SourceNode = sourceNode.SourceNode;
  41393. var sourceMap = sourceMap$1;
  41394. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  41395. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  41396. var mergeSourceMap = merge;
  41397. /**
  41398. * Merge old source map and new source map and return merged.
  41399. * If old or new source map value is falsy, return another one as it is.
  41400. *
  41401. * @param {object|string} [oldMap] old source map object
  41402. * @param {object|string} [newmap] new source map object
  41403. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  41404. */
  41405. function merge(oldMap, newMap) {
  41406. if (!oldMap) return newMap
  41407. if (!newMap) return oldMap
  41408. var oldMapConsumer = new SourceMapConsumer(oldMap);
  41409. var newMapConsumer = new SourceMapConsumer(newMap);
  41410. var mergedMapGenerator = new SourceMapGenerator();
  41411. // iterate on new map and overwrite original position of new map with one of old map
  41412. newMapConsumer.eachMapping(function(m) {
  41413. // pass when `originalLine` is null.
  41414. // It occurs in case that the node does not have origin in original code.
  41415. if (m.originalLine == null) return
  41416. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  41417. line: m.originalLine,
  41418. column: m.originalColumn
  41419. });
  41420. if (origPosInOldMap.source == null) return
  41421. mergedMapGenerator.addMapping({
  41422. original: {
  41423. line: origPosInOldMap.line,
  41424. column: origPosInOldMap.column
  41425. },
  41426. generated: {
  41427. line: m.generatedLine,
  41428. column: m.generatedColumn
  41429. },
  41430. source: origPosInOldMap.source,
  41431. name: origPosInOldMap.name
  41432. });
  41433. });
  41434. var consumers = [oldMapConsumer, newMapConsumer];
  41435. consumers.forEach(function(consumer) {
  41436. consumer.sources.forEach(function(sourceFile) {
  41437. mergedMapGenerator._sources.add(sourceFile);
  41438. var sourceContent = consumer.sourceContentFor(sourceFile);
  41439. if (sourceContent != null) {
  41440. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  41441. }
  41442. });
  41443. });
  41444. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  41445. mergedMapGenerator._file = oldMap.file;
  41446. return JSON.parse(mergedMapGenerator.toString())
  41447. }
  41448. var merge$1 = /*@__PURE__*/getDefaultExportFromCjs(mergeSourceMap);
  41449. var __defProp$5 = Object.defineProperty;
  41450. var __defProps$4 = Object.defineProperties;
  41451. var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
  41452. var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
  41453. var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
  41454. var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
  41455. var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  41456. var __spreadValues$5 = (a, b) => {
  41457. for (var prop in b || (b = {}))
  41458. if (__hasOwnProp$5.call(b, prop))
  41459. __defNormalProp$5(a, prop, b[prop]);
  41460. if (__getOwnPropSymbols$5)
  41461. for (var prop of __getOwnPropSymbols$5(b)) {
  41462. if (__propIsEnum$5.call(b, prop))
  41463. __defNormalProp$5(a, prop, b[prop]);
  41464. }
  41465. return a;
  41466. };
  41467. var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
  41468. const scss = (source, map, options, load = require) => {
  41469. const nodeSass = load("sass");
  41470. const finalOptions = __spreadProps$4(__spreadValues$5({}, options), {
  41471. data: getSource(source, options.filename, options.additionalData),
  41472. file: options.filename,
  41473. outFile: options.filename,
  41474. sourceMap: !!map
  41475. });
  41476. try {
  41477. const result = nodeSass.renderSync(finalOptions);
  41478. const dependencies = result.stats.includedFiles;
  41479. if (map) {
  41480. return {
  41481. code: result.css.toString(),
  41482. map: merge$1(map, JSON.parse(result.map.toString())),
  41483. errors: [],
  41484. dependencies
  41485. };
  41486. }
  41487. return { code: result.css.toString(), errors: [], dependencies };
  41488. } catch (e) {
  41489. return { code: "", errors: [e], dependencies: [] };
  41490. }
  41491. };
  41492. const sass = (source, map, options, load) => scss(
  41493. source,
  41494. map,
  41495. __spreadProps$4(__spreadValues$5({}, options), {
  41496. indentedSyntax: true
  41497. }),
  41498. load
  41499. );
  41500. const less = (source, map, options, load = require) => {
  41501. const nodeLess = load("less");
  41502. let result;
  41503. let error = null;
  41504. nodeLess.render(
  41505. getSource(source, options.filename, options.additionalData),
  41506. __spreadProps$4(__spreadValues$5({}, options), { syncImport: true }),
  41507. (err, output) => {
  41508. error = err;
  41509. result = output;
  41510. }
  41511. );
  41512. if (error) return { code: "", errors: [error], dependencies: [] };
  41513. const dependencies = result.imports;
  41514. if (map) {
  41515. return {
  41516. code: result.css.toString(),
  41517. map: merge$1(map, result.map),
  41518. errors: [],
  41519. dependencies
  41520. };
  41521. }
  41522. return {
  41523. code: result.css.toString(),
  41524. errors: [],
  41525. dependencies
  41526. };
  41527. };
  41528. const styl = (source, map, options, load = require) => {
  41529. const nodeStylus = load("stylus");
  41530. try {
  41531. const ref = nodeStylus(source, options);
  41532. if (map) ref.set("sourcemap", { inline: false, comment: false });
  41533. const result = ref.render();
  41534. const dependencies = ref.deps();
  41535. if (map) {
  41536. return {
  41537. code: result,
  41538. map: merge$1(map, ref.sourcemap),
  41539. errors: [],
  41540. dependencies
  41541. };
  41542. }
  41543. return { code: result, errors: [], dependencies };
  41544. } catch (e) {
  41545. return { code: "", errors: [e], dependencies: [] };
  41546. }
  41547. };
  41548. function getSource(source, filename, additionalData) {
  41549. if (!additionalData) return source;
  41550. if (isFunction$1(additionalData)) {
  41551. return additionalData(source, filename);
  41552. }
  41553. return additionalData + source;
  41554. }
  41555. const processors = {
  41556. less,
  41557. sass,
  41558. scss,
  41559. styl,
  41560. stylus: styl
  41561. };
  41562. var __defProp$4 = Object.defineProperty;
  41563. var __defProps$3 = Object.defineProperties;
  41564. var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
  41565. var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
  41566. var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
  41567. var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
  41568. var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  41569. var __spreadValues$4 = (a, b) => {
  41570. for (var prop in b || (b = {}))
  41571. if (__hasOwnProp$4.call(b, prop))
  41572. __defNormalProp$4(a, prop, b[prop]);
  41573. if (__getOwnPropSymbols$4)
  41574. for (var prop of __getOwnPropSymbols$4(b)) {
  41575. if (__propIsEnum$4.call(b, prop))
  41576. __defNormalProp$4(a, prop, b[prop]);
  41577. }
  41578. return a;
  41579. };
  41580. var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
  41581. function compileStyle(options) {
  41582. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  41583. isAsync: false
  41584. }));
  41585. }
  41586. function compileStyleAsync(options) {
  41587. return doCompileStyle(__spreadProps$3(__spreadValues$4({}, options), {
  41588. isAsync: true
  41589. }));
  41590. }
  41591. function doCompileStyle(options) {
  41592. const {
  41593. filename,
  41594. id,
  41595. scoped = false,
  41596. trim = true,
  41597. isProd = false,
  41598. modules = false,
  41599. modulesOptions = {},
  41600. preprocessLang,
  41601. postcssOptions,
  41602. postcssPlugins
  41603. } = options;
  41604. const preprocessor = preprocessLang && processors[preprocessLang];
  41605. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  41606. const map = preProcessedSource ? preProcessedSource.map : options.inMap || options.map;
  41607. const source = preProcessedSource ? preProcessedSource.code : options.source;
  41608. const shortId = id.replace(/^data-v-/, "");
  41609. const longId = `data-v-${shortId}`;
  41610. const plugins = (postcssPlugins || []).slice();
  41611. plugins.unshift(cssVarsPlugin({ id: shortId, isProd }));
  41612. if (trim) {
  41613. plugins.push(trimPlugin());
  41614. }
  41615. if (scoped) {
  41616. plugins.push(scopedPlugin(longId));
  41617. }
  41618. let cssModules;
  41619. if (modules) {
  41620. {
  41621. throw new Error(
  41622. "[@vue/compiler-sfc] `modules` option is not supported in the browser build."
  41623. );
  41624. }
  41625. }
  41626. const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
  41627. to: filename,
  41628. from: filename
  41629. });
  41630. if (map) {
  41631. postCSSOptions.map = {
  41632. inline: false,
  41633. annotation: false,
  41634. prev: map
  41635. };
  41636. }
  41637. let result;
  41638. let code;
  41639. let outMap;
  41640. const dependencies = new Set(
  41641. preProcessedSource ? preProcessedSource.dependencies : []
  41642. );
  41643. dependencies.delete(filename);
  41644. const errors = [];
  41645. if (preProcessedSource && preProcessedSource.errors.length) {
  41646. errors.push(...preProcessedSource.errors);
  41647. }
  41648. const recordPlainCssDependencies = (messages) => {
  41649. messages.forEach((msg) => {
  41650. if (msg.type === "dependency") {
  41651. dependencies.add(msg.file);
  41652. }
  41653. });
  41654. return dependencies;
  41655. };
  41656. try {
  41657. result = postcss$1(plugins).process(source, postCSSOptions);
  41658. if (options.isAsync) {
  41659. return result.then((result2) => ({
  41660. code: result2.css || "",
  41661. map: result2.map && result2.map.toJSON(),
  41662. errors,
  41663. modules: cssModules,
  41664. rawResult: result2,
  41665. dependencies: recordPlainCssDependencies(result2.messages)
  41666. })).catch((error) => ({
  41667. code: "",
  41668. map: void 0,
  41669. errors: [...errors, error],
  41670. rawResult: void 0,
  41671. dependencies
  41672. }));
  41673. }
  41674. recordPlainCssDependencies(result.messages);
  41675. code = result.css;
  41676. outMap = result.map;
  41677. } catch (e) {
  41678. errors.push(e);
  41679. }
  41680. return {
  41681. code: code || ``,
  41682. map: outMap && outMap.toJSON(),
  41683. errors,
  41684. rawResult: result,
  41685. dependencies
  41686. };
  41687. }
  41688. function preprocess(options, preprocessor) {
  41689. if (!options.preprocessCustomRequire) {
  41690. throw new Error(
  41691. `[@vue/compiler-sfc] Style preprocessing in the browser build must provide the \`preprocessCustomRequire\` option to return the in-browser version of the preprocessor.`
  41692. );
  41693. }
  41694. return preprocessor(
  41695. options.source,
  41696. options.inMap || options.map,
  41697. __spreadValues$4({
  41698. filename: options.filename
  41699. }, options.preprocessOptions),
  41700. options.preprocessCustomRequire
  41701. );
  41702. }
  41703. function analyzeScriptBindings(ast) {
  41704. for (const node of ast) {
  41705. if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
  41706. return analyzeBindingsFromOptions(node.declaration);
  41707. }
  41708. }
  41709. return {};
  41710. }
  41711. function analyzeBindingsFromOptions(node) {
  41712. const bindings = {};
  41713. Object.defineProperty(bindings, "__isScriptSetup", {
  41714. enumerable: false,
  41715. value: false
  41716. });
  41717. for (const property of node.properties) {
  41718. if (property.type === "ObjectProperty" && !property.computed && property.key.type === "Identifier") {
  41719. if (property.key.name === "props") {
  41720. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  41721. bindings[key] = "props";
  41722. }
  41723. } else if (property.key.name === "inject") {
  41724. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  41725. bindings[key] = "options";
  41726. }
  41727. } else if (property.value.type === "ObjectExpression" && (property.key.name === "computed" || property.key.name === "methods")) {
  41728. for (const key of getObjectExpressionKeys(property.value)) {
  41729. bindings[key] = "options";
  41730. }
  41731. }
  41732. } else if (property.type === "ObjectMethod" && property.key.type === "Identifier" && (property.key.name === "setup" || property.key.name === "data")) {
  41733. for (const bodyItem of property.body.body) {
  41734. if (bodyItem.type === "ReturnStatement" && bodyItem.argument && bodyItem.argument.type === "ObjectExpression") {
  41735. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  41736. bindings[key] = property.key.name === "setup" ? "setup-maybe-ref" : "data";
  41737. }
  41738. }
  41739. }
  41740. }
  41741. }
  41742. return bindings;
  41743. }
  41744. function getObjectExpressionKeys(node) {
  41745. const keys = [];
  41746. for (const prop of node.properties) {
  41747. if (prop.type === "SpreadElement") continue;
  41748. const key = resolveObjectKey(prop.key, prop.computed);
  41749. if (key) keys.push(String(key));
  41750. }
  41751. return keys;
  41752. }
  41753. function getArrayExpressionKeys(node) {
  41754. const keys = [];
  41755. for (const element of node.elements) {
  41756. if (element && element.type === "StringLiteral") {
  41757. keys.push(element.value);
  41758. }
  41759. }
  41760. return keys;
  41761. }
  41762. function getObjectOrArrayExpressionKeys(value) {
  41763. if (value.type === "ArrayExpression") {
  41764. return getArrayExpressionKeys(value);
  41765. }
  41766. if (value.type === "ObjectExpression") {
  41767. return getObjectExpressionKeys(value);
  41768. }
  41769. return [];
  41770. }
  41771. const comma = ','.charCodeAt(0);
  41772. const semicolon = ';'.charCodeAt(0);
  41773. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  41774. const intToChar = new Uint8Array(64); // 64 possible chars.
  41775. const charToInt = new Uint8Array(128); // z is 122 in ASCII
  41776. for (let i = 0; i < chars.length; i++) {
  41777. const c = chars.charCodeAt(i);
  41778. intToChar[i] = c;
  41779. charToInt[c] = i;
  41780. }
  41781. function encodeInteger(builder, num, relative) {
  41782. let delta = num - relative;
  41783. delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
  41784. do {
  41785. let clamped = delta & 0b011111;
  41786. delta >>>= 5;
  41787. if (delta > 0)
  41788. clamped |= 0b100000;
  41789. builder.write(intToChar[clamped]);
  41790. } while (delta > 0);
  41791. return num;
  41792. }
  41793. const bufLength = 1024 * 16;
  41794. // Provide a fallback for older environments.
  41795. const td = typeof TextDecoder !== 'undefined'
  41796. ? /* #__PURE__ */ new TextDecoder()
  41797. : typeof Buffer !== 'undefined'
  41798. ? {
  41799. decode(buf) {
  41800. const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
  41801. return out.toString();
  41802. },
  41803. }
  41804. : {
  41805. decode(buf) {
  41806. let out = '';
  41807. for (let i = 0; i < buf.length; i++) {
  41808. out += String.fromCharCode(buf[i]);
  41809. }
  41810. return out;
  41811. },
  41812. };
  41813. class StringWriter {
  41814. constructor() {
  41815. this.pos = 0;
  41816. this.out = '';
  41817. this.buffer = new Uint8Array(bufLength);
  41818. }
  41819. write(v) {
  41820. const { buffer } = this;
  41821. buffer[this.pos++] = v;
  41822. if (this.pos === bufLength) {
  41823. this.out += td.decode(buffer);
  41824. this.pos = 0;
  41825. }
  41826. }
  41827. flush() {
  41828. const { buffer, out, pos } = this;
  41829. return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
  41830. }
  41831. }
  41832. function encode(decoded) {
  41833. const writer = new StringWriter();
  41834. let sourcesIndex = 0;
  41835. let sourceLine = 0;
  41836. let sourceColumn = 0;
  41837. let namesIndex = 0;
  41838. for (let i = 0; i < decoded.length; i++) {
  41839. const line = decoded[i];
  41840. if (i > 0)
  41841. writer.write(semicolon);
  41842. if (line.length === 0)
  41843. continue;
  41844. let genColumn = 0;
  41845. for (let j = 0; j < line.length; j++) {
  41846. const segment = line[j];
  41847. if (j > 0)
  41848. writer.write(comma);
  41849. genColumn = encodeInteger(writer, segment[0], genColumn);
  41850. if (segment.length === 1)
  41851. continue;
  41852. sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
  41853. sourceLine = encodeInteger(writer, segment[2], sourceLine);
  41854. sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
  41855. if (segment.length === 4)
  41856. continue;
  41857. namesIndex = encodeInteger(writer, segment[4], namesIndex);
  41858. }
  41859. }
  41860. return writer.flush();
  41861. }
  41862. class BitSet {
  41863. constructor(arg) {
  41864. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  41865. }
  41866. add(n) {
  41867. this.bits[n >> 5] |= 1 << (n & 31);
  41868. }
  41869. has(n) {
  41870. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  41871. }
  41872. }
  41873. class Chunk {
  41874. constructor(start, end, content) {
  41875. this.start = start;
  41876. this.end = end;
  41877. this.original = content;
  41878. this.intro = '';
  41879. this.outro = '';
  41880. this.content = content;
  41881. this.storeName = false;
  41882. this.edited = false;
  41883. {
  41884. this.previous = null;
  41885. this.next = null;
  41886. }
  41887. }
  41888. appendLeft(content) {
  41889. this.outro += content;
  41890. }
  41891. appendRight(content) {
  41892. this.intro = this.intro + content;
  41893. }
  41894. clone() {
  41895. const chunk = new Chunk(this.start, this.end, this.original);
  41896. chunk.intro = this.intro;
  41897. chunk.outro = this.outro;
  41898. chunk.content = this.content;
  41899. chunk.storeName = this.storeName;
  41900. chunk.edited = this.edited;
  41901. return chunk;
  41902. }
  41903. contains(index) {
  41904. return this.start < index && index < this.end;
  41905. }
  41906. eachNext(fn) {
  41907. let chunk = this;
  41908. while (chunk) {
  41909. fn(chunk);
  41910. chunk = chunk.next;
  41911. }
  41912. }
  41913. eachPrevious(fn) {
  41914. let chunk = this;
  41915. while (chunk) {
  41916. fn(chunk);
  41917. chunk = chunk.previous;
  41918. }
  41919. }
  41920. edit(content, storeName, contentOnly) {
  41921. this.content = content;
  41922. if (!contentOnly) {
  41923. this.intro = '';
  41924. this.outro = '';
  41925. }
  41926. this.storeName = storeName;
  41927. this.edited = true;
  41928. return this;
  41929. }
  41930. prependLeft(content) {
  41931. this.outro = content + this.outro;
  41932. }
  41933. prependRight(content) {
  41934. this.intro = content + this.intro;
  41935. }
  41936. reset() {
  41937. this.intro = '';
  41938. this.outro = '';
  41939. if (this.edited) {
  41940. this.content = this.original;
  41941. this.storeName = false;
  41942. this.edited = false;
  41943. }
  41944. }
  41945. split(index) {
  41946. const sliceIndex = index - this.start;
  41947. const originalBefore = this.original.slice(0, sliceIndex);
  41948. const originalAfter = this.original.slice(sliceIndex);
  41949. this.original = originalBefore;
  41950. const newChunk = new Chunk(index, this.end, originalAfter);
  41951. newChunk.outro = this.outro;
  41952. this.outro = '';
  41953. this.end = index;
  41954. if (this.edited) {
  41955. // after split we should save the edit content record into the correct chunk
  41956. // to make sure sourcemap correct
  41957. // For example:
  41958. // ' test'.trim()
  41959. // split -> ' ' + 'test'
  41960. // ✔️ edit -> '' + 'test'
  41961. // ✖️ edit -> 'test' + ''
  41962. // TODO is this block necessary?...
  41963. newChunk.edit('', false);
  41964. this.content = '';
  41965. } else {
  41966. this.content = originalBefore;
  41967. }
  41968. newChunk.next = this.next;
  41969. if (newChunk.next) newChunk.next.previous = newChunk;
  41970. newChunk.previous = this;
  41971. this.next = newChunk;
  41972. return newChunk;
  41973. }
  41974. toString() {
  41975. return this.intro + this.content + this.outro;
  41976. }
  41977. trimEnd(rx) {
  41978. this.outro = this.outro.replace(rx, '');
  41979. if (this.outro.length) return true;
  41980. const trimmed = this.content.replace(rx, '');
  41981. if (trimmed.length) {
  41982. if (trimmed !== this.content) {
  41983. this.split(this.start + trimmed.length).edit('', undefined, true);
  41984. if (this.edited) {
  41985. // save the change, if it has been edited
  41986. this.edit(trimmed, this.storeName, true);
  41987. }
  41988. }
  41989. return true;
  41990. } else {
  41991. this.edit('', undefined, true);
  41992. this.intro = this.intro.replace(rx, '');
  41993. if (this.intro.length) return true;
  41994. }
  41995. }
  41996. trimStart(rx) {
  41997. this.intro = this.intro.replace(rx, '');
  41998. if (this.intro.length) return true;
  41999. const trimmed = this.content.replace(rx, '');
  42000. if (trimmed.length) {
  42001. if (trimmed !== this.content) {
  42002. const newChunk = this.split(this.end - trimmed.length);
  42003. if (this.edited) {
  42004. // save the change, if it has been edited
  42005. newChunk.edit(trimmed, this.storeName, true);
  42006. }
  42007. this.edit('', undefined, true);
  42008. }
  42009. return true;
  42010. } else {
  42011. this.edit('', undefined, true);
  42012. this.outro = this.outro.replace(rx, '');
  42013. if (this.outro.length) return true;
  42014. }
  42015. }
  42016. }
  42017. function getBtoa() {
  42018. if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
  42019. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  42020. } else if (typeof Buffer === 'function') {
  42021. return (str) => Buffer.from(str, 'utf-8').toString('base64');
  42022. } else {
  42023. return () => {
  42024. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  42025. };
  42026. }
  42027. }
  42028. const btoa = /*#__PURE__*/ getBtoa();
  42029. class SourceMap {
  42030. constructor(properties) {
  42031. this.version = 3;
  42032. this.file = properties.file;
  42033. this.sources = properties.sources;
  42034. this.sourcesContent = properties.sourcesContent;
  42035. this.names = properties.names;
  42036. this.mappings = encode(properties.mappings);
  42037. if (typeof properties.x_google_ignoreList !== 'undefined') {
  42038. this.x_google_ignoreList = properties.x_google_ignoreList;
  42039. }
  42040. }
  42041. toString() {
  42042. return JSON.stringify(this);
  42043. }
  42044. toUrl() {
  42045. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  42046. }
  42047. }
  42048. function guessIndent(code) {
  42049. const lines = code.split('\n');
  42050. const tabbed = lines.filter((line) => /^\t+/.test(line));
  42051. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  42052. if (tabbed.length === 0 && spaced.length === 0) {
  42053. return null;
  42054. }
  42055. // More lines tabbed than spaced? Assume tabs, and
  42056. // default to tabs in the case of a tie (or nothing
  42057. // to go on)
  42058. if (tabbed.length >= spaced.length) {
  42059. return '\t';
  42060. }
  42061. // Otherwise, we need to guess the multiple
  42062. const min = spaced.reduce((previous, current) => {
  42063. const numSpaces = /^ +/.exec(current)[0].length;
  42064. return Math.min(numSpaces, previous);
  42065. }, Infinity);
  42066. return new Array(min + 1).join(' ');
  42067. }
  42068. function getRelativePath(from, to) {
  42069. const fromParts = from.split(/[/\\]/);
  42070. const toParts = to.split(/[/\\]/);
  42071. fromParts.pop(); // get dirname
  42072. while (fromParts[0] === toParts[0]) {
  42073. fromParts.shift();
  42074. toParts.shift();
  42075. }
  42076. if (fromParts.length) {
  42077. let i = fromParts.length;
  42078. while (i--) fromParts[i] = '..';
  42079. }
  42080. return fromParts.concat(toParts).join('/');
  42081. }
  42082. const toString = Object.prototype.toString;
  42083. function isObject(thing) {
  42084. return toString.call(thing) === '[object Object]';
  42085. }
  42086. function getLocator(source) {
  42087. const originalLines = source.split('\n');
  42088. const lineOffsets = [];
  42089. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  42090. lineOffsets.push(pos);
  42091. pos += originalLines[i].length + 1;
  42092. }
  42093. return function locate(index) {
  42094. let i = 0;
  42095. let j = lineOffsets.length;
  42096. while (i < j) {
  42097. const m = (i + j) >> 1;
  42098. if (index < lineOffsets[m]) {
  42099. j = m;
  42100. } else {
  42101. i = m + 1;
  42102. }
  42103. }
  42104. const line = i - 1;
  42105. const column = index - lineOffsets[line];
  42106. return { line, column };
  42107. };
  42108. }
  42109. const wordRegex = /\w/;
  42110. class Mappings {
  42111. constructor(hires) {
  42112. this.hires = hires;
  42113. this.generatedCodeLine = 0;
  42114. this.generatedCodeColumn = 0;
  42115. this.raw = [];
  42116. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  42117. this.pending = null;
  42118. }
  42119. addEdit(sourceIndex, content, loc, nameIndex) {
  42120. if (content.length) {
  42121. const contentLengthMinusOne = content.length - 1;
  42122. let contentLineEnd = content.indexOf('\n', 0);
  42123. let previousContentLineEnd = -1;
  42124. // Loop through each line in the content and add a segment, but stop if the last line is empty,
  42125. // else code afterwards would fill one line too many
  42126. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  42127. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42128. if (nameIndex >= 0) {
  42129. segment.push(nameIndex);
  42130. }
  42131. this.rawSegments.push(segment);
  42132. this.generatedCodeLine += 1;
  42133. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42134. this.generatedCodeColumn = 0;
  42135. previousContentLineEnd = contentLineEnd;
  42136. contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
  42137. }
  42138. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42139. if (nameIndex >= 0) {
  42140. segment.push(nameIndex);
  42141. }
  42142. this.rawSegments.push(segment);
  42143. this.advance(content.slice(previousContentLineEnd + 1));
  42144. } else if (this.pending) {
  42145. this.rawSegments.push(this.pending);
  42146. this.advance(content);
  42147. }
  42148. this.pending = null;
  42149. }
  42150. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  42151. let originalCharIndex = chunk.start;
  42152. let first = true;
  42153. // when iterating each char, check if it's in a word boundary
  42154. let charInHiresBoundary = false;
  42155. while (originalCharIndex < chunk.end) {
  42156. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  42157. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  42158. if (this.hires === 'boundary') {
  42159. // in hires "boundary", group segments per word boundary than per char
  42160. if (wordRegex.test(original[originalCharIndex])) {
  42161. // for first char in the boundary found, start the boundary by pushing a segment
  42162. if (!charInHiresBoundary) {
  42163. this.rawSegments.push(segment);
  42164. charInHiresBoundary = true;
  42165. }
  42166. } else {
  42167. // for non-word char, end the boundary by pushing a segment
  42168. this.rawSegments.push(segment);
  42169. charInHiresBoundary = false;
  42170. }
  42171. } else {
  42172. this.rawSegments.push(segment);
  42173. }
  42174. }
  42175. if (original[originalCharIndex] === '\n') {
  42176. loc.line += 1;
  42177. loc.column = 0;
  42178. this.generatedCodeLine += 1;
  42179. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42180. this.generatedCodeColumn = 0;
  42181. first = true;
  42182. } else {
  42183. loc.column += 1;
  42184. this.generatedCodeColumn += 1;
  42185. first = false;
  42186. }
  42187. originalCharIndex += 1;
  42188. }
  42189. this.pending = null;
  42190. }
  42191. advance(str) {
  42192. if (!str) return;
  42193. const lines = str.split('\n');
  42194. if (lines.length > 1) {
  42195. for (let i = 0; i < lines.length - 1; i++) {
  42196. this.generatedCodeLine++;
  42197. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  42198. }
  42199. this.generatedCodeColumn = 0;
  42200. }
  42201. this.generatedCodeColumn += lines[lines.length - 1].length;
  42202. }
  42203. }
  42204. const n = '\n';
  42205. const warned = {
  42206. insertLeft: false,
  42207. insertRight: false,
  42208. storeName: false,
  42209. };
  42210. class MagicString {
  42211. constructor(string, options = {}) {
  42212. const chunk = new Chunk(0, string.length, string);
  42213. Object.defineProperties(this, {
  42214. original: { writable: true, value: string },
  42215. outro: { writable: true, value: '' },
  42216. intro: { writable: true, value: '' },
  42217. firstChunk: { writable: true, value: chunk },
  42218. lastChunk: { writable: true, value: chunk },
  42219. lastSearchedChunk: { writable: true, value: chunk },
  42220. byStart: { writable: true, value: {} },
  42221. byEnd: { writable: true, value: {} },
  42222. filename: { writable: true, value: options.filename },
  42223. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  42224. sourcemapLocations: { writable: true, value: new BitSet() },
  42225. storedNames: { writable: true, value: {} },
  42226. indentStr: { writable: true, value: undefined },
  42227. ignoreList: { writable: true, value: options.ignoreList },
  42228. });
  42229. this.byStart[0] = chunk;
  42230. this.byEnd[string.length] = chunk;
  42231. }
  42232. addSourcemapLocation(char) {
  42233. this.sourcemapLocations.add(char);
  42234. }
  42235. append(content) {
  42236. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  42237. this.outro += content;
  42238. return this;
  42239. }
  42240. appendLeft(index, content) {
  42241. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42242. this._split(index);
  42243. const chunk = this.byEnd[index];
  42244. if (chunk) {
  42245. chunk.appendLeft(content);
  42246. } else {
  42247. this.intro += content;
  42248. }
  42249. return this;
  42250. }
  42251. appendRight(index, content) {
  42252. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42253. this._split(index);
  42254. const chunk = this.byStart[index];
  42255. if (chunk) {
  42256. chunk.appendRight(content);
  42257. } else {
  42258. this.outro += content;
  42259. }
  42260. return this;
  42261. }
  42262. clone() {
  42263. const cloned = new MagicString(this.original, { filename: this.filename });
  42264. let originalChunk = this.firstChunk;
  42265. let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  42266. while (originalChunk) {
  42267. cloned.byStart[clonedChunk.start] = clonedChunk;
  42268. cloned.byEnd[clonedChunk.end] = clonedChunk;
  42269. const nextOriginalChunk = originalChunk.next;
  42270. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  42271. if (nextClonedChunk) {
  42272. clonedChunk.next = nextClonedChunk;
  42273. nextClonedChunk.previous = clonedChunk;
  42274. clonedChunk = nextClonedChunk;
  42275. }
  42276. originalChunk = nextOriginalChunk;
  42277. }
  42278. cloned.lastChunk = clonedChunk;
  42279. if (this.indentExclusionRanges) {
  42280. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  42281. }
  42282. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  42283. cloned.intro = this.intro;
  42284. cloned.outro = this.outro;
  42285. return cloned;
  42286. }
  42287. generateDecodedMap(options) {
  42288. options = options || {};
  42289. const sourceIndex = 0;
  42290. const names = Object.keys(this.storedNames);
  42291. const mappings = new Mappings(options.hires);
  42292. const locate = getLocator(this.original);
  42293. if (this.intro) {
  42294. mappings.advance(this.intro);
  42295. }
  42296. this.firstChunk.eachNext((chunk) => {
  42297. const loc = locate(chunk.start);
  42298. if (chunk.intro.length) mappings.advance(chunk.intro);
  42299. if (chunk.edited) {
  42300. mappings.addEdit(
  42301. sourceIndex,
  42302. chunk.content,
  42303. loc,
  42304. chunk.storeName ? names.indexOf(chunk.original) : -1,
  42305. );
  42306. } else {
  42307. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  42308. }
  42309. if (chunk.outro.length) mappings.advance(chunk.outro);
  42310. });
  42311. return {
  42312. file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
  42313. sources: [
  42314. options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
  42315. ],
  42316. sourcesContent: options.includeContent ? [this.original] : undefined,
  42317. names,
  42318. mappings: mappings.raw,
  42319. x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
  42320. };
  42321. }
  42322. generateMap(options) {
  42323. return new SourceMap(this.generateDecodedMap(options));
  42324. }
  42325. _ensureindentStr() {
  42326. if (this.indentStr === undefined) {
  42327. this.indentStr = guessIndent(this.original);
  42328. }
  42329. }
  42330. _getRawIndentString() {
  42331. this._ensureindentStr();
  42332. return this.indentStr;
  42333. }
  42334. getIndentString() {
  42335. this._ensureindentStr();
  42336. return this.indentStr === null ? '\t' : this.indentStr;
  42337. }
  42338. indent(indentStr, options) {
  42339. const pattern = /^[^\r\n]/gm;
  42340. if (isObject(indentStr)) {
  42341. options = indentStr;
  42342. indentStr = undefined;
  42343. }
  42344. if (indentStr === undefined) {
  42345. this._ensureindentStr();
  42346. indentStr = this.indentStr || '\t';
  42347. }
  42348. if (indentStr === '') return this; // noop
  42349. options = options || {};
  42350. // Process exclusion ranges
  42351. const isExcluded = {};
  42352. if (options.exclude) {
  42353. const exclusions =
  42354. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  42355. exclusions.forEach((exclusion) => {
  42356. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  42357. isExcluded[i] = true;
  42358. }
  42359. });
  42360. }
  42361. let shouldIndentNextCharacter = options.indentStart !== false;
  42362. const replacer = (match) => {
  42363. if (shouldIndentNextCharacter) return `${indentStr}${match}`;
  42364. shouldIndentNextCharacter = true;
  42365. return match;
  42366. };
  42367. this.intro = this.intro.replace(pattern, replacer);
  42368. let charIndex = 0;
  42369. let chunk = this.firstChunk;
  42370. while (chunk) {
  42371. const end = chunk.end;
  42372. if (chunk.edited) {
  42373. if (!isExcluded[charIndex]) {
  42374. chunk.content = chunk.content.replace(pattern, replacer);
  42375. if (chunk.content.length) {
  42376. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  42377. }
  42378. }
  42379. } else {
  42380. charIndex = chunk.start;
  42381. while (charIndex < end) {
  42382. if (!isExcluded[charIndex]) {
  42383. const char = this.original[charIndex];
  42384. if (char === '\n') {
  42385. shouldIndentNextCharacter = true;
  42386. } else if (char !== '\r' && shouldIndentNextCharacter) {
  42387. shouldIndentNextCharacter = false;
  42388. if (charIndex === chunk.start) {
  42389. chunk.prependRight(indentStr);
  42390. } else {
  42391. this._splitChunk(chunk, charIndex);
  42392. chunk = chunk.next;
  42393. chunk.prependRight(indentStr);
  42394. }
  42395. }
  42396. }
  42397. charIndex += 1;
  42398. }
  42399. }
  42400. charIndex = chunk.end;
  42401. chunk = chunk.next;
  42402. }
  42403. this.outro = this.outro.replace(pattern, replacer);
  42404. return this;
  42405. }
  42406. insert() {
  42407. throw new Error(
  42408. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
  42409. );
  42410. }
  42411. insertLeft(index, content) {
  42412. if (!warned.insertLeft) {
  42413. console.warn(
  42414. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
  42415. ); // eslint-disable-line no-console
  42416. warned.insertLeft = true;
  42417. }
  42418. return this.appendLeft(index, content);
  42419. }
  42420. insertRight(index, content) {
  42421. if (!warned.insertRight) {
  42422. console.warn(
  42423. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
  42424. ); // eslint-disable-line no-console
  42425. warned.insertRight = true;
  42426. }
  42427. return this.prependRight(index, content);
  42428. }
  42429. move(start, end, index) {
  42430. if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
  42431. this._split(start);
  42432. this._split(end);
  42433. this._split(index);
  42434. const first = this.byStart[start];
  42435. const last = this.byEnd[end];
  42436. const oldLeft = first.previous;
  42437. const oldRight = last.next;
  42438. const newRight = this.byStart[index];
  42439. if (!newRight && last === this.lastChunk) return this;
  42440. const newLeft = newRight ? newRight.previous : this.lastChunk;
  42441. if (oldLeft) oldLeft.next = oldRight;
  42442. if (oldRight) oldRight.previous = oldLeft;
  42443. if (newLeft) newLeft.next = first;
  42444. if (newRight) newRight.previous = last;
  42445. if (!first.previous) this.firstChunk = last.next;
  42446. if (!last.next) {
  42447. this.lastChunk = first.previous;
  42448. this.lastChunk.next = null;
  42449. }
  42450. first.previous = newLeft;
  42451. last.next = newRight || null;
  42452. if (!newLeft) this.firstChunk = first;
  42453. if (!newRight) this.lastChunk = last;
  42454. return this;
  42455. }
  42456. overwrite(start, end, content, options) {
  42457. options = options || {};
  42458. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  42459. }
  42460. update(start, end, content, options) {
  42461. if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
  42462. if (this.original.length !== 0) {
  42463. while (start < 0) start += this.original.length;
  42464. while (end < 0) end += this.original.length;
  42465. }
  42466. if (end > this.original.length) throw new Error('end is out of bounds');
  42467. if (start === end)
  42468. throw new Error(
  42469. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
  42470. );
  42471. this._split(start);
  42472. this._split(end);
  42473. if (options === true) {
  42474. if (!warned.storeName) {
  42475. console.warn(
  42476. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
  42477. ); // eslint-disable-line no-console
  42478. warned.storeName = true;
  42479. }
  42480. options = { storeName: true };
  42481. }
  42482. const storeName = options !== undefined ? options.storeName : false;
  42483. const overwrite = options !== undefined ? options.overwrite : false;
  42484. if (storeName) {
  42485. const original = this.original.slice(start, end);
  42486. Object.defineProperty(this.storedNames, original, {
  42487. writable: true,
  42488. value: true,
  42489. enumerable: true,
  42490. });
  42491. }
  42492. const first = this.byStart[start];
  42493. const last = this.byEnd[end];
  42494. if (first) {
  42495. let chunk = first;
  42496. while (chunk !== last) {
  42497. if (chunk.next !== this.byStart[chunk.end]) {
  42498. throw new Error('Cannot overwrite across a split point');
  42499. }
  42500. chunk = chunk.next;
  42501. chunk.edit('', false);
  42502. }
  42503. first.edit(content, storeName, !overwrite);
  42504. } else {
  42505. // must be inserting at the end
  42506. const newChunk = new Chunk(start, end, '').edit(content, storeName);
  42507. // TODO last chunk in the array may not be the last chunk, if it's moved...
  42508. last.next = newChunk;
  42509. newChunk.previous = last;
  42510. }
  42511. return this;
  42512. }
  42513. prepend(content) {
  42514. if (typeof content !== 'string') throw new TypeError('outro content must be a string');
  42515. this.intro = content + this.intro;
  42516. return this;
  42517. }
  42518. prependLeft(index, content) {
  42519. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42520. this._split(index);
  42521. const chunk = this.byEnd[index];
  42522. if (chunk) {
  42523. chunk.prependLeft(content);
  42524. } else {
  42525. this.intro = content + this.intro;
  42526. }
  42527. return this;
  42528. }
  42529. prependRight(index, content) {
  42530. if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
  42531. this._split(index);
  42532. const chunk = this.byStart[index];
  42533. if (chunk) {
  42534. chunk.prependRight(content);
  42535. } else {
  42536. this.outro = content + this.outro;
  42537. }
  42538. return this;
  42539. }
  42540. remove(start, end) {
  42541. if (this.original.length !== 0) {
  42542. while (start < 0) start += this.original.length;
  42543. while (end < 0) end += this.original.length;
  42544. }
  42545. if (start === end) return this;
  42546. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  42547. if (start > end) throw new Error('end must be greater than start');
  42548. this._split(start);
  42549. this._split(end);
  42550. let chunk = this.byStart[start];
  42551. while (chunk) {
  42552. chunk.intro = '';
  42553. chunk.outro = '';
  42554. chunk.edit('');
  42555. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  42556. }
  42557. return this;
  42558. }
  42559. reset(start, end) {
  42560. if (this.original.length !== 0) {
  42561. while (start < 0) start += this.original.length;
  42562. while (end < 0) end += this.original.length;
  42563. }
  42564. if (start === end) return this;
  42565. if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
  42566. if (start > end) throw new Error('end must be greater than start');
  42567. this._split(start);
  42568. this._split(end);
  42569. let chunk = this.byStart[start];
  42570. while (chunk) {
  42571. chunk.reset();
  42572. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  42573. }
  42574. return this;
  42575. }
  42576. lastChar() {
  42577. if (this.outro.length) return this.outro[this.outro.length - 1];
  42578. let chunk = this.lastChunk;
  42579. do {
  42580. if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
  42581. if (chunk.content.length) return chunk.content[chunk.content.length - 1];
  42582. if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
  42583. } while ((chunk = chunk.previous));
  42584. if (this.intro.length) return this.intro[this.intro.length - 1];
  42585. return '';
  42586. }
  42587. lastLine() {
  42588. let lineIndex = this.outro.lastIndexOf(n);
  42589. if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
  42590. let lineStr = this.outro;
  42591. let chunk = this.lastChunk;
  42592. do {
  42593. if (chunk.outro.length > 0) {
  42594. lineIndex = chunk.outro.lastIndexOf(n);
  42595. if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
  42596. lineStr = chunk.outro + lineStr;
  42597. }
  42598. if (chunk.content.length > 0) {
  42599. lineIndex = chunk.content.lastIndexOf(n);
  42600. if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
  42601. lineStr = chunk.content + lineStr;
  42602. }
  42603. if (chunk.intro.length > 0) {
  42604. lineIndex = chunk.intro.lastIndexOf(n);
  42605. if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
  42606. lineStr = chunk.intro + lineStr;
  42607. }
  42608. } while ((chunk = chunk.previous));
  42609. lineIndex = this.intro.lastIndexOf(n);
  42610. if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
  42611. return this.intro + lineStr;
  42612. }
  42613. slice(start = 0, end = this.original.length) {
  42614. if (this.original.length !== 0) {
  42615. while (start < 0) start += this.original.length;
  42616. while (end < 0) end += this.original.length;
  42617. }
  42618. let result = '';
  42619. // find start chunk
  42620. let chunk = this.firstChunk;
  42621. while (chunk && (chunk.start > start || chunk.end <= start)) {
  42622. // found end chunk before start
  42623. if (chunk.start < end && chunk.end >= end) {
  42624. return result;
  42625. }
  42626. chunk = chunk.next;
  42627. }
  42628. if (chunk && chunk.edited && chunk.start !== start)
  42629. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  42630. const startChunk = chunk;
  42631. while (chunk) {
  42632. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  42633. result += chunk.intro;
  42634. }
  42635. const containsEnd = chunk.start < end && chunk.end >= end;
  42636. if (containsEnd && chunk.edited && chunk.end !== end)
  42637. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  42638. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  42639. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  42640. result += chunk.content.slice(sliceStart, sliceEnd);
  42641. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  42642. result += chunk.outro;
  42643. }
  42644. if (containsEnd) {
  42645. break;
  42646. }
  42647. chunk = chunk.next;
  42648. }
  42649. return result;
  42650. }
  42651. // TODO deprecate this? not really very useful
  42652. snip(start, end) {
  42653. const clone = this.clone();
  42654. clone.remove(0, start);
  42655. clone.remove(end, clone.original.length);
  42656. return clone;
  42657. }
  42658. _split(index) {
  42659. if (this.byStart[index] || this.byEnd[index]) return;
  42660. let chunk = this.lastSearchedChunk;
  42661. const searchForward = index > chunk.end;
  42662. while (chunk) {
  42663. if (chunk.contains(index)) return this._splitChunk(chunk, index);
  42664. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  42665. }
  42666. }
  42667. _splitChunk(chunk, index) {
  42668. if (chunk.edited && chunk.content.length) {
  42669. // zero-length edited chunks are a special case (overlapping replacements)
  42670. const loc = getLocator(this.original)(index);
  42671. throw new Error(
  42672. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
  42673. );
  42674. }
  42675. const newChunk = chunk.split(index);
  42676. this.byEnd[index] = chunk;
  42677. this.byStart[index] = newChunk;
  42678. this.byEnd[newChunk.end] = newChunk;
  42679. if (chunk === this.lastChunk) this.lastChunk = newChunk;
  42680. this.lastSearchedChunk = chunk;
  42681. return true;
  42682. }
  42683. toString() {
  42684. let str = this.intro;
  42685. let chunk = this.firstChunk;
  42686. while (chunk) {
  42687. str += chunk.toString();
  42688. chunk = chunk.next;
  42689. }
  42690. return str + this.outro;
  42691. }
  42692. isEmpty() {
  42693. let chunk = this.firstChunk;
  42694. do {
  42695. if (
  42696. (chunk.intro.length && chunk.intro.trim()) ||
  42697. (chunk.content.length && chunk.content.trim()) ||
  42698. (chunk.outro.length && chunk.outro.trim())
  42699. )
  42700. return false;
  42701. } while ((chunk = chunk.next));
  42702. return true;
  42703. }
  42704. length() {
  42705. let chunk = this.firstChunk;
  42706. let length = 0;
  42707. do {
  42708. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  42709. } while ((chunk = chunk.next));
  42710. return length;
  42711. }
  42712. trimLines() {
  42713. return this.trim('[\\r\\n]');
  42714. }
  42715. trim(charType) {
  42716. return this.trimStart(charType).trimEnd(charType);
  42717. }
  42718. trimEndAborted(charType) {
  42719. const rx = new RegExp((charType || '\\s') + '+$');
  42720. this.outro = this.outro.replace(rx, '');
  42721. if (this.outro.length) return true;
  42722. let chunk = this.lastChunk;
  42723. do {
  42724. const end = chunk.end;
  42725. const aborted = chunk.trimEnd(rx);
  42726. // if chunk was trimmed, we have a new lastChunk
  42727. if (chunk.end !== end) {
  42728. if (this.lastChunk === chunk) {
  42729. this.lastChunk = chunk.next;
  42730. }
  42731. this.byEnd[chunk.end] = chunk;
  42732. this.byStart[chunk.next.start] = chunk.next;
  42733. this.byEnd[chunk.next.end] = chunk.next;
  42734. }
  42735. if (aborted) return true;
  42736. chunk = chunk.previous;
  42737. } while (chunk);
  42738. return false;
  42739. }
  42740. trimEnd(charType) {
  42741. this.trimEndAborted(charType);
  42742. return this;
  42743. }
  42744. trimStartAborted(charType) {
  42745. const rx = new RegExp('^' + (charType || '\\s') + '+');
  42746. this.intro = this.intro.replace(rx, '');
  42747. if (this.intro.length) return true;
  42748. let chunk = this.firstChunk;
  42749. do {
  42750. const end = chunk.end;
  42751. const aborted = chunk.trimStart(rx);
  42752. if (chunk.end !== end) {
  42753. // special case...
  42754. if (chunk === this.lastChunk) this.lastChunk = chunk.next;
  42755. this.byEnd[chunk.end] = chunk;
  42756. this.byStart[chunk.next.start] = chunk.next;
  42757. this.byEnd[chunk.next.end] = chunk.next;
  42758. }
  42759. if (aborted) return true;
  42760. chunk = chunk.next;
  42761. } while (chunk);
  42762. return false;
  42763. }
  42764. trimStart(charType) {
  42765. this.trimStartAborted(charType);
  42766. return this;
  42767. }
  42768. hasChanged() {
  42769. return this.original !== this.toString();
  42770. }
  42771. _replaceRegexp(searchValue, replacement) {
  42772. function getReplacement(match, str) {
  42773. if (typeof replacement === 'string') {
  42774. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  42775. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
  42776. if (i === '$') return '$';
  42777. if (i === '&') return match[0];
  42778. const num = +i;
  42779. if (num < match.length) return match[+i];
  42780. return `$${i}`;
  42781. });
  42782. } else {
  42783. return replacement(...match, match.index, str, match.groups);
  42784. }
  42785. }
  42786. function matchAll(re, str) {
  42787. let match;
  42788. const matches = [];
  42789. while ((match = re.exec(str))) {
  42790. matches.push(match);
  42791. }
  42792. return matches;
  42793. }
  42794. if (searchValue.global) {
  42795. const matches = matchAll(searchValue, this.original);
  42796. matches.forEach((match) => {
  42797. if (match.index != null) {
  42798. const replacement = getReplacement(match, this.original);
  42799. if (replacement !== match[0]) {
  42800. this.overwrite(
  42801. match.index,
  42802. match.index + match[0].length,
  42803. replacement
  42804. );
  42805. }
  42806. }
  42807. });
  42808. } else {
  42809. const match = this.original.match(searchValue);
  42810. if (match && match.index != null) {
  42811. const replacement = getReplacement(match, this.original);
  42812. if (replacement !== match[0]) {
  42813. this.overwrite(
  42814. match.index,
  42815. match.index + match[0].length,
  42816. replacement
  42817. );
  42818. }
  42819. }
  42820. }
  42821. return this;
  42822. }
  42823. _replaceString(string, replacement) {
  42824. const { original } = this;
  42825. const index = original.indexOf(string);
  42826. if (index !== -1) {
  42827. this.overwrite(index, index + string.length, replacement);
  42828. }
  42829. return this;
  42830. }
  42831. replace(searchValue, replacement) {
  42832. if (typeof searchValue === 'string') {
  42833. return this._replaceString(searchValue, replacement);
  42834. }
  42835. return this._replaceRegexp(searchValue, replacement);
  42836. }
  42837. _replaceAllString(string, replacement) {
  42838. const { original } = this;
  42839. const stringLength = string.length;
  42840. for (
  42841. let index = original.indexOf(string);
  42842. index !== -1;
  42843. index = original.indexOf(string, index + stringLength)
  42844. ) {
  42845. const previous = original.slice(index, index + stringLength);
  42846. if (previous !== replacement)
  42847. this.overwrite(index, index + stringLength, replacement);
  42848. }
  42849. return this;
  42850. }
  42851. replaceAll(searchValue, replacement) {
  42852. if (typeof searchValue === 'string') {
  42853. return this._replaceAllString(searchValue, replacement);
  42854. }
  42855. if (!searchValue.global) {
  42856. throw new TypeError(
  42857. 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
  42858. );
  42859. }
  42860. return this._replaceRegexp(searchValue, replacement);
  42861. }
  42862. }
  42863. var _a, _b;
  42864. class ScriptCompileContext {
  42865. constructor(descriptor, options) {
  42866. this.descriptor = descriptor;
  42867. this.options = options;
  42868. this.isCE = false;
  42869. this.source = this.descriptor.source;
  42870. this.filename = this.descriptor.filename;
  42871. this.s = new MagicString(this.source);
  42872. this.startOffset = (_a = this.descriptor.scriptSetup) == null ? void 0 : _a.loc.start.offset;
  42873. this.endOffset = (_b = this.descriptor.scriptSetup) == null ? void 0 : _b.loc.end.offset;
  42874. this.userImports = /* @__PURE__ */ Object.create(null);
  42875. // macros presence check
  42876. this.hasDefinePropsCall = false;
  42877. this.hasDefineEmitCall = false;
  42878. this.hasDefineExposeCall = false;
  42879. this.hasDefaultExportName = false;
  42880. this.hasDefaultExportRender = false;
  42881. this.hasDefineOptionsCall = false;
  42882. this.hasDefineSlotsCall = false;
  42883. this.hasDefineModelCall = false;
  42884. this.propsDestructuredBindings = /* @__PURE__ */ Object.create(null);
  42885. // defineModel
  42886. this.modelDecls = /* @__PURE__ */ Object.create(null);
  42887. // codegen
  42888. this.bindingMetadata = {};
  42889. this.helperImports = /* @__PURE__ */ new Set();
  42890. const { script, scriptSetup } = descriptor;
  42891. const scriptLang = script && script.lang;
  42892. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  42893. this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
  42894. this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
  42895. const customElement = options.customElement;
  42896. const filename = this.descriptor.filename;
  42897. if (customElement) {
  42898. this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
  42899. }
  42900. const plugins = resolveParserPlugins(
  42901. scriptLang || scriptSetupLang,
  42902. options.babelParserPlugins
  42903. );
  42904. function parse(input, offset) {
  42905. try {
  42906. return parse_1$1(input, {
  42907. plugins,
  42908. sourceType: "module"
  42909. }).program;
  42910. } catch (e) {
  42911. e.message = `[vue/compiler-sfc] ${e.message}
  42912. ${descriptor.filename}
  42913. ${generateCodeFrame(
  42914. descriptor.source,
  42915. e.pos + offset,
  42916. e.pos + offset + 1
  42917. )}`;
  42918. throw e;
  42919. }
  42920. }
  42921. this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
  42922. this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
  42923. }
  42924. helper(key) {
  42925. this.helperImports.add(key);
  42926. return `_${key}`;
  42927. }
  42928. getString(node, scriptSetup = true) {
  42929. const block = scriptSetup ? this.descriptor.scriptSetup : this.descriptor.script;
  42930. return block.content.slice(node.start, node.end);
  42931. }
  42932. error(msg, node, scope) {
  42933. const offset = scope ? scope.offset : this.startOffset;
  42934. throw new Error(
  42935. `[@vue/compiler-sfc] ${msg}
  42936. ${(scope || this.descriptor).filename}
  42937. ${generateCodeFrame(
  42938. (scope || this.descriptor).source,
  42939. node.start + offset,
  42940. node.end + offset
  42941. )}`
  42942. );
  42943. }
  42944. }
  42945. function resolveParserPlugins(lang, userPlugins, dts = false) {
  42946. const plugins = [];
  42947. if (!userPlugins || !userPlugins.some(
  42948. (p) => p === "importAssertions" || p === "importAttributes" || isArray$3(p) && p[0] === "importAttributes"
  42949. )) {
  42950. plugins.push("importAttributes");
  42951. }
  42952. if (lang === "jsx" || lang === "tsx" || lang === "mtsx") {
  42953. plugins.push("jsx");
  42954. } else if (userPlugins) {
  42955. userPlugins = userPlugins.filter((p) => p !== "jsx");
  42956. }
  42957. if (lang === "ts" || lang === "mts" || lang === "tsx" || lang === "mtsx") {
  42958. plugins.push(["typescript", { dts }], "explicitResourceManagement");
  42959. if (!userPlugins || !userPlugins.includes("decorators")) {
  42960. plugins.push("decorators-legacy");
  42961. }
  42962. }
  42963. if (userPlugins) {
  42964. plugins.push(...userPlugins);
  42965. }
  42966. return plugins;
  42967. }
  42968. function rewriteDefault(input, as, parserPlugins) {
  42969. const ast = parse_1$1(input, {
  42970. sourceType: "module",
  42971. plugins: resolveParserPlugins("js", parserPlugins)
  42972. }).program.body;
  42973. const s = new MagicString(input);
  42974. rewriteDefaultAST(ast, s, as);
  42975. return s.toString();
  42976. }
  42977. function rewriteDefaultAST(ast, s, as) {
  42978. if (!hasDefaultExport(ast)) {
  42979. s.append(`
  42980. const ${as} = {}`);
  42981. return;
  42982. }
  42983. ast.forEach((node) => {
  42984. if (node.type === "ExportDefaultDeclaration") {
  42985. if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
  42986. let start = node.declaration.decorators && node.declaration.decorators.length > 0 ? node.declaration.decorators[node.declaration.decorators.length - 1].end : node.start;
  42987. s.overwrite(start, node.declaration.id.start, ` class `);
  42988. s.append(`
  42989. const ${as} = ${node.declaration.id.name}`);
  42990. } else {
  42991. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  42992. }
  42993. } else if (node.type === "ExportNamedDeclaration") {
  42994. for (const specifier of node.specifiers) {
  42995. if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier" && specifier.exported.name === "default") {
  42996. if (node.source) {
  42997. if (specifier.local.name === "default") {
  42998. s.prepend(
  42999. `import { default as __VUE_DEFAULT__ } from '${node.source.value}'
  43000. `
  43001. );
  43002. const end2 = specifierEnd(s, specifier.local.end, node.end);
  43003. s.remove(specifier.start, end2);
  43004. s.append(`
  43005. const ${as} = __VUE_DEFAULT__`);
  43006. continue;
  43007. } else {
  43008. s.prepend(
  43009. `import { ${s.slice(
  43010. specifier.local.start,
  43011. specifier.local.end
  43012. )} as __VUE_DEFAULT__ } from '${node.source.value}'
  43013. `
  43014. );
  43015. const end2 = specifierEnd(s, specifier.exported.end, node.end);
  43016. s.remove(specifier.start, end2);
  43017. s.append(`
  43018. const ${as} = __VUE_DEFAULT__`);
  43019. continue;
  43020. }
  43021. }
  43022. const end = specifierEnd(s, specifier.end, node.end);
  43023. s.remove(specifier.start, end);
  43024. s.append(`
  43025. const ${as} = ${specifier.local.name}`);
  43026. }
  43027. }
  43028. }
  43029. });
  43030. }
  43031. function hasDefaultExport(ast) {
  43032. for (const stmt of ast) {
  43033. if (stmt.type === "ExportDefaultDeclaration") {
  43034. return true;
  43035. } else if (stmt.type === "ExportNamedDeclaration" && stmt.specifiers.some(
  43036. (spec) => spec.exported.name === "default"
  43037. )) {
  43038. return true;
  43039. }
  43040. }
  43041. return false;
  43042. }
  43043. function specifierEnd(s, end, nodeEnd) {
  43044. let hasCommas = false;
  43045. let oldEnd = end;
  43046. while (end < nodeEnd) {
  43047. if (/\s/.test(s.slice(end, end + 1))) {
  43048. end++;
  43049. } else if (s.slice(end, end + 1) === ",") {
  43050. end++;
  43051. hasCommas = true;
  43052. break;
  43053. } else if (s.slice(end, end + 1) === "}") {
  43054. break;
  43055. }
  43056. }
  43057. return hasCommas ? end : oldEnd;
  43058. }
  43059. var __defProp$3 = Object.defineProperty;
  43060. var __defProps$2 = Object.defineProperties;
  43061. var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
  43062. var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
  43063. var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
  43064. var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
  43065. var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  43066. var __spreadValues$3 = (a, b) => {
  43067. for (var prop in b || (b = {}))
  43068. if (__hasOwnProp$3.call(b, prop))
  43069. __defNormalProp$3(a, prop, b[prop]);
  43070. if (__getOwnPropSymbols$3)
  43071. for (var prop of __getOwnPropSymbols$3(b)) {
  43072. if (__propIsEnum$3.call(b, prop))
  43073. __defNormalProp$3(a, prop, b[prop]);
  43074. }
  43075. return a;
  43076. };
  43077. var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
  43078. const normalScriptDefaultVar = `__default__`;
  43079. function processNormalScript(ctx, scopeId) {
  43080. var _a;
  43081. const script = ctx.descriptor.script;
  43082. if (script.lang && !ctx.isJS && !ctx.isTS) {
  43083. return script;
  43084. }
  43085. try {
  43086. let content = script.content;
  43087. let map = script.map;
  43088. const scriptAst = ctx.scriptAst;
  43089. const bindings = analyzeScriptBindings(scriptAst.body);
  43090. const { cssVars } = ctx.descriptor;
  43091. const { genDefaultAs, isProd } = ctx.options;
  43092. if (cssVars.length || genDefaultAs) {
  43093. const defaultVar = genDefaultAs || normalScriptDefaultVar;
  43094. const s = new MagicString(content);
  43095. rewriteDefaultAST(scriptAst.body, s, defaultVar);
  43096. content = s.toString();
  43097. if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
  43098. content += genNormalScriptCssVarsCode(
  43099. cssVars,
  43100. bindings,
  43101. scopeId,
  43102. !!isProd,
  43103. defaultVar
  43104. );
  43105. }
  43106. if (!genDefaultAs) {
  43107. content += `
  43108. export default ${defaultVar}`;
  43109. }
  43110. }
  43111. return __spreadProps$2(__spreadValues$3({}, script), {
  43112. content,
  43113. map,
  43114. bindings,
  43115. scriptAst: scriptAst.body
  43116. });
  43117. } catch (e) {
  43118. return script;
  43119. }
  43120. }
  43121. var __defProp$2 = Object.defineProperty;
  43122. var __defProps$1 = Object.defineProperties;
  43123. var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
  43124. var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
  43125. var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
  43126. var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
  43127. var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  43128. var __spreadValues$2 = (a, b) => {
  43129. for (var prop in b || (b = {}))
  43130. if (__hasOwnProp$2.call(b, prop))
  43131. __defNormalProp$2(a, prop, b[prop]);
  43132. if (__getOwnPropSymbols$2)
  43133. for (var prop of __getOwnPropSymbols$2(b)) {
  43134. if (__propIsEnum$2.call(b, prop))
  43135. __defNormalProp$2(a, prop, b[prop]);
  43136. }
  43137. return a;
  43138. };
  43139. var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
  43140. class TypeScope {
  43141. constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
  43142. this.filename = filename;
  43143. this.source = source;
  43144. this.offset = offset;
  43145. this.imports = imports;
  43146. this.types = types;
  43147. this.declares = declares;
  43148. this.isGenericScope = false;
  43149. this.resolvedImportSources = /* @__PURE__ */ Object.create(null);
  43150. this.exportedTypes = /* @__PURE__ */ Object.create(null);
  43151. this.exportedDeclares = /* @__PURE__ */ Object.create(null);
  43152. }
  43153. }
  43154. function resolveTypeElements(ctx, node, scope, typeParameters) {
  43155. const canCache = !typeParameters;
  43156. if (canCache && node._resolvedElements) {
  43157. return node._resolvedElements;
  43158. }
  43159. const resolved = innerResolveTypeElements(
  43160. ctx,
  43161. node,
  43162. node._ownerScope || scope || ctxToScope(ctx),
  43163. typeParameters
  43164. );
  43165. return canCache ? node._resolvedElements = resolved : resolved;
  43166. }
  43167. function innerResolveTypeElements(ctx, node, scope, typeParameters) {
  43168. var _a, _b;
  43169. if (node.leadingComments && node.leadingComments.some((c) => c.value.includes("@vue-ignore"))) {
  43170. return { props: {} };
  43171. }
  43172. switch (node.type) {
  43173. case "TSTypeLiteral":
  43174. return typeElementsToMap(ctx, node.members, scope, typeParameters);
  43175. case "TSInterfaceDeclaration":
  43176. return resolveInterfaceMembers(ctx, node, scope, typeParameters);
  43177. case "TSTypeAliasDeclaration":
  43178. case "TSTypeAnnotation":
  43179. case "TSParenthesizedType":
  43180. return resolveTypeElements(
  43181. ctx,
  43182. node.typeAnnotation,
  43183. scope,
  43184. typeParameters
  43185. );
  43186. case "TSFunctionType": {
  43187. return { props: {}, calls: [node] };
  43188. }
  43189. case "TSUnionType":
  43190. case "TSIntersectionType":
  43191. return mergeElements(
  43192. node.types.map((t) => resolveTypeElements(ctx, t, scope, typeParameters)),
  43193. node.type
  43194. );
  43195. case "TSMappedType":
  43196. return resolveMappedType(ctx, node, scope, typeParameters);
  43197. case "TSIndexedAccessType": {
  43198. const types = resolveIndexType(ctx, node, scope);
  43199. return mergeElements(
  43200. types.map((t) => resolveTypeElements(ctx, t, t._ownerScope)),
  43201. "TSUnionType"
  43202. );
  43203. }
  43204. case "TSExpressionWithTypeArguments":
  43205. case "TSTypeReference": {
  43206. const typeName = getReferenceName(node);
  43207. if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
  43208. return resolveExtractPropTypes(
  43209. resolveTypeElements(
  43210. ctx,
  43211. node.typeParameters.params[0],
  43212. scope,
  43213. typeParameters
  43214. ),
  43215. scope
  43216. );
  43217. }
  43218. const resolved = resolveTypeReference(ctx, node, scope);
  43219. if (resolved) {
  43220. let typeParams;
  43221. if ((resolved.type === "TSTypeAliasDeclaration" || resolved.type === "TSInterfaceDeclaration") && resolved.typeParameters && node.typeParameters) {
  43222. typeParams = /* @__PURE__ */ Object.create(null);
  43223. resolved.typeParameters.params.forEach((p, i) => {
  43224. let param = typeParameters && typeParameters[p.name];
  43225. if (!param) param = node.typeParameters.params[i];
  43226. typeParams[p.name] = param;
  43227. });
  43228. }
  43229. return resolveTypeElements(
  43230. ctx,
  43231. resolved,
  43232. resolved._ownerScope,
  43233. typeParams
  43234. );
  43235. } else {
  43236. if (typeof typeName === "string") {
  43237. if (typeParameters && typeParameters[typeName]) {
  43238. return resolveTypeElements(
  43239. ctx,
  43240. typeParameters[typeName],
  43241. scope,
  43242. typeParameters
  43243. );
  43244. }
  43245. if (
  43246. // @ts-expect-error
  43247. SupportedBuiltinsSet.has(typeName)
  43248. ) {
  43249. return resolveBuiltin(
  43250. ctx,
  43251. node,
  43252. typeName,
  43253. scope,
  43254. typeParameters
  43255. );
  43256. } else if (typeName === "ReturnType" && node.typeParameters) {
  43257. const ret = resolveReturnType(
  43258. ctx,
  43259. node.typeParameters.params[0],
  43260. scope
  43261. );
  43262. if (ret) {
  43263. return resolveTypeElements(ctx, ret, scope);
  43264. }
  43265. }
  43266. }
  43267. return ctx.error(
  43268. `Unresolvable type reference or unsupported built-in utility type`,
  43269. node,
  43270. scope
  43271. );
  43272. }
  43273. }
  43274. case "TSImportType": {
  43275. if (getId(node.argument) === "vue" && ((_b = node.qualifier) == null ? void 0 : _b.type) === "Identifier" && node.qualifier.name === "ExtractPropTypes" && node.typeParameters) {
  43276. return resolveExtractPropTypes(
  43277. resolveTypeElements(ctx, node.typeParameters.params[0], scope),
  43278. scope
  43279. );
  43280. }
  43281. const sourceScope = importSourceToScope(
  43282. ctx,
  43283. node.argument,
  43284. scope,
  43285. node.argument.value
  43286. );
  43287. const resolved = resolveTypeReference(ctx, node, sourceScope);
  43288. if (resolved) {
  43289. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  43290. }
  43291. break;
  43292. }
  43293. case "TSTypeQuery":
  43294. {
  43295. const resolved = resolveTypeReference(ctx, node, scope);
  43296. if (resolved) {
  43297. return resolveTypeElements(ctx, resolved, resolved._ownerScope);
  43298. }
  43299. }
  43300. break;
  43301. }
  43302. return ctx.error(`Unresolvable type: ${node.type}`, node, scope);
  43303. }
  43304. function typeElementsToMap(ctx, elements, scope = ctxToScope(ctx), typeParameters) {
  43305. const res = { props: {} };
  43306. for (const e of elements) {
  43307. if (e.type === "TSPropertySignature" || e.type === "TSMethodSignature") {
  43308. if (typeParameters) {
  43309. scope = createChildScope(scope);
  43310. scope.isGenericScope = true;
  43311. Object.assign(scope.types, typeParameters);
  43312. }
  43313. e._ownerScope = scope;
  43314. const name = getId(e.key);
  43315. if (name && !e.computed) {
  43316. res.props[name] = e;
  43317. } else if (e.key.type === "TemplateLiteral") {
  43318. for (const key of resolveTemplateKeys(ctx, e.key, scope)) {
  43319. res.props[key] = e;
  43320. }
  43321. } else {
  43322. ctx.error(
  43323. `Unsupported computed key in type referenced by a macro`,
  43324. e.key,
  43325. scope
  43326. );
  43327. }
  43328. } else if (e.type === "TSCallSignatureDeclaration") {
  43329. (res.calls || (res.calls = [])).push(e);
  43330. }
  43331. }
  43332. return res;
  43333. }
  43334. function mergeElements(maps, type) {
  43335. if (maps.length === 1) return maps[0];
  43336. const res = { props: {} };
  43337. const { props: baseProps } = res;
  43338. for (const { props, calls } of maps) {
  43339. for (const key in props) {
  43340. if (!hasOwn(baseProps, key)) {
  43341. baseProps[key] = props[key];
  43342. } else {
  43343. baseProps[key] = createProperty(
  43344. baseProps[key].key,
  43345. {
  43346. type,
  43347. // @ts-expect-error
  43348. types: [baseProps[key], props[key]]
  43349. },
  43350. baseProps[key]._ownerScope,
  43351. baseProps[key].optional || props[key].optional
  43352. );
  43353. }
  43354. }
  43355. if (calls) {
  43356. (res.calls || (res.calls = [])).push(...calls);
  43357. }
  43358. }
  43359. return res;
  43360. }
  43361. function createProperty(key, typeAnnotation, scope, optional) {
  43362. return {
  43363. type: "TSPropertySignature",
  43364. key,
  43365. kind: "get",
  43366. optional,
  43367. typeAnnotation: {
  43368. type: "TSTypeAnnotation",
  43369. typeAnnotation
  43370. },
  43371. _ownerScope: scope
  43372. };
  43373. }
  43374. function resolveInterfaceMembers(ctx, node, scope, typeParameters) {
  43375. const base = typeElementsToMap(
  43376. ctx,
  43377. node.body.body,
  43378. node._ownerScope,
  43379. typeParameters
  43380. );
  43381. if (node.extends) {
  43382. for (const ext of node.extends) {
  43383. try {
  43384. const { props, calls } = resolveTypeElements(ctx, ext, scope);
  43385. for (const key in props) {
  43386. if (!hasOwn(base.props, key)) {
  43387. base.props[key] = props[key];
  43388. }
  43389. }
  43390. if (calls) {
  43391. ;
  43392. (base.calls || (base.calls = [])).push(...calls);
  43393. }
  43394. } catch (e) {
  43395. ctx.error(
  43396. `Failed to resolve extends base type.
  43397. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:
  43398. interface Props extends /* @vue-ignore */ Base {}
  43399. Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.`,
  43400. ext,
  43401. scope
  43402. );
  43403. }
  43404. }
  43405. }
  43406. return base;
  43407. }
  43408. function resolveMappedType(ctx, node, scope, typeParameters) {
  43409. const res = { props: {} };
  43410. let keys;
  43411. if (node.nameType) {
  43412. const { name, constraint } = node.typeParameter;
  43413. scope = createChildScope(scope);
  43414. Object.assign(scope.types, __spreadProps$1(__spreadValues$2({}, typeParameters), { [name]: constraint }));
  43415. keys = resolveStringType(ctx, node.nameType, scope);
  43416. } else {
  43417. keys = resolveStringType(ctx, node.typeParameter.constraint, scope);
  43418. }
  43419. for (const key of keys) {
  43420. res.props[key] = createProperty(
  43421. {
  43422. type: "Identifier",
  43423. name: key
  43424. },
  43425. node.typeAnnotation,
  43426. scope,
  43427. !!node.optional
  43428. );
  43429. }
  43430. return res;
  43431. }
  43432. function resolveIndexType(ctx, node, scope) {
  43433. var _a, _b;
  43434. if (node.indexType.type === "TSNumberKeyword") {
  43435. return resolveArrayElementType(ctx, node.objectType, scope);
  43436. }
  43437. const { indexType, objectType } = node;
  43438. const types = [];
  43439. let keys;
  43440. let resolved;
  43441. if (indexType.type === "TSStringKeyword") {
  43442. resolved = resolveTypeElements(ctx, objectType, scope);
  43443. keys = Object.keys(resolved.props);
  43444. } else {
  43445. keys = resolveStringType(ctx, indexType, scope);
  43446. resolved = resolveTypeElements(ctx, objectType, scope);
  43447. }
  43448. for (const key of keys) {
  43449. const targetType = (_b = (_a = resolved.props[key]) == null ? void 0 : _a.typeAnnotation) == null ? void 0 : _b.typeAnnotation;
  43450. if (targetType) {
  43451. targetType._ownerScope = resolved.props[key]._ownerScope;
  43452. types.push(targetType);
  43453. }
  43454. }
  43455. return types;
  43456. }
  43457. function resolveArrayElementType(ctx, node, scope) {
  43458. if (node.type === "TSArrayType") {
  43459. return [node.elementType];
  43460. }
  43461. if (node.type === "TSTupleType") {
  43462. return node.elementTypes.map(
  43463. (t) => t.type === "TSNamedTupleMember" ? t.elementType : t
  43464. );
  43465. }
  43466. if (node.type === "TSTypeReference") {
  43467. if (getReferenceName(node) === "Array" && node.typeParameters) {
  43468. return node.typeParameters.params;
  43469. } else {
  43470. const resolved = resolveTypeReference(ctx, node, scope);
  43471. if (resolved) {
  43472. return resolveArrayElementType(ctx, resolved, scope);
  43473. }
  43474. }
  43475. }
  43476. return ctx.error(
  43477. "Failed to resolve element type from target type",
  43478. node,
  43479. scope
  43480. );
  43481. }
  43482. function resolveStringType(ctx, node, scope) {
  43483. switch (node.type) {
  43484. case "StringLiteral":
  43485. return [node.value];
  43486. case "TSLiteralType":
  43487. return resolveStringType(ctx, node.literal, scope);
  43488. case "TSUnionType":
  43489. return node.types.map((t) => resolveStringType(ctx, t, scope)).flat();
  43490. case "TemplateLiteral": {
  43491. return resolveTemplateKeys(ctx, node, scope);
  43492. }
  43493. case "TSTypeReference": {
  43494. const resolved = resolveTypeReference(ctx, node, scope);
  43495. if (resolved) {
  43496. return resolveStringType(ctx, resolved, scope);
  43497. }
  43498. if (node.typeName.type === "Identifier") {
  43499. const getParam = (index = 0) => resolveStringType(ctx, node.typeParameters.params[index], scope);
  43500. switch (node.typeName.name) {
  43501. case "Extract":
  43502. return getParam(1);
  43503. case "Exclude": {
  43504. const excluded = getParam(1);
  43505. return getParam().filter((s) => !excluded.includes(s));
  43506. }
  43507. case "Uppercase":
  43508. return getParam().map((s) => s.toUpperCase());
  43509. case "Lowercase":
  43510. return getParam().map((s) => s.toLowerCase());
  43511. case "Capitalize":
  43512. return getParam().map(capitalize$1);
  43513. case "Uncapitalize":
  43514. return getParam().map((s) => s[0].toLowerCase() + s.slice(1));
  43515. default:
  43516. ctx.error(
  43517. "Unsupported type when resolving index type",
  43518. node.typeName,
  43519. scope
  43520. );
  43521. }
  43522. }
  43523. }
  43524. }
  43525. return ctx.error("Failed to resolve index type into finite keys", node, scope);
  43526. }
  43527. function resolveTemplateKeys(ctx, node, scope) {
  43528. if (!node.expressions.length) {
  43529. return [node.quasis[0].value.raw];
  43530. }
  43531. const res = [];
  43532. const e = node.expressions[0];
  43533. const q = node.quasis[0];
  43534. const leading = q ? q.value.raw : ``;
  43535. const resolved = resolveStringType(ctx, e, scope);
  43536. const restResolved = resolveTemplateKeys(
  43537. ctx,
  43538. __spreadProps$1(__spreadValues$2({}, node), {
  43539. expressions: node.expressions.slice(1),
  43540. quasis: q ? node.quasis.slice(1) : node.quasis
  43541. }),
  43542. scope
  43543. );
  43544. for (const r of resolved) {
  43545. for (const rr of restResolved) {
  43546. res.push(leading + r + rr);
  43547. }
  43548. }
  43549. return res;
  43550. }
  43551. const SupportedBuiltinsSet = /* @__PURE__ */ new Set([
  43552. "Partial",
  43553. "Required",
  43554. "Readonly",
  43555. "Pick",
  43556. "Omit"
  43557. ]);
  43558. function resolveBuiltin(ctx, node, name, scope, typeParameters) {
  43559. const t = resolveTypeElements(
  43560. ctx,
  43561. node.typeParameters.params[0],
  43562. scope,
  43563. typeParameters
  43564. );
  43565. switch (name) {
  43566. case "Partial": {
  43567. const res2 = { props: {}, calls: t.calls };
  43568. Object.keys(t.props).forEach((key) => {
  43569. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: true });
  43570. });
  43571. return res2;
  43572. }
  43573. case "Required": {
  43574. const res2 = { props: {}, calls: t.calls };
  43575. Object.keys(t.props).forEach((key) => {
  43576. res2.props[key] = __spreadProps$1(__spreadValues$2({}, t.props[key]), { optional: false });
  43577. });
  43578. return res2;
  43579. }
  43580. case "Readonly":
  43581. return t;
  43582. case "Pick": {
  43583. const picked = resolveStringType(
  43584. ctx,
  43585. node.typeParameters.params[1],
  43586. scope
  43587. );
  43588. const res2 = { props: {}, calls: t.calls };
  43589. for (const key of picked) {
  43590. res2.props[key] = t.props[key];
  43591. }
  43592. return res2;
  43593. }
  43594. case "Omit":
  43595. const omitted = resolveStringType(
  43596. ctx,
  43597. node.typeParameters.params[1],
  43598. scope
  43599. );
  43600. const res = { props: {}, calls: t.calls };
  43601. for (const key in t.props) {
  43602. if (!omitted.includes(key)) {
  43603. res.props[key] = t.props[key];
  43604. }
  43605. }
  43606. return res;
  43607. }
  43608. }
  43609. function resolveTypeReference(ctx, node, scope, name, onlyExported = false) {
  43610. const canCache = !(scope == null ? void 0 : scope.isGenericScope);
  43611. if (canCache && node._resolvedReference) {
  43612. return node._resolvedReference;
  43613. }
  43614. const resolved = innerResolveTypeReference(
  43615. ctx,
  43616. scope || ctxToScope(ctx),
  43617. name || getReferenceName(node),
  43618. node,
  43619. onlyExported
  43620. );
  43621. return canCache ? node._resolvedReference = resolved : resolved;
  43622. }
  43623. function innerResolveTypeReference(ctx, scope, name, node, onlyExported) {
  43624. if (typeof name === "string") {
  43625. if (scope.imports[name]) {
  43626. return resolveTypeFromImport(ctx, node, name, scope);
  43627. } else {
  43628. const lookupSource = node.type === "TSTypeQuery" ? onlyExported ? scope.exportedDeclares : scope.declares : onlyExported ? scope.exportedTypes : scope.types;
  43629. if (lookupSource[name]) {
  43630. return lookupSource[name];
  43631. } else {
  43632. const globalScopes = resolveGlobalScope(ctx);
  43633. if (globalScopes) {
  43634. for (const s of globalScopes) {
  43635. const src = node.type === "TSTypeQuery" ? s.declares : s.types;
  43636. if (src[name]) {
  43637. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(s.filename);
  43638. return src[name];
  43639. }
  43640. }
  43641. }
  43642. }
  43643. }
  43644. } else {
  43645. let ns = innerResolveTypeReference(ctx, scope, name[0], node, onlyExported);
  43646. if (ns) {
  43647. if (ns.type !== "TSModuleDeclaration") {
  43648. ns = ns._ns;
  43649. }
  43650. if (ns) {
  43651. const childScope = moduleDeclToScope(ctx, ns, ns._ownerScope || scope);
  43652. return innerResolveTypeReference(
  43653. ctx,
  43654. childScope,
  43655. name.length > 2 ? name.slice(1) : name[name.length - 1],
  43656. node,
  43657. !ns.declare
  43658. );
  43659. }
  43660. }
  43661. }
  43662. }
  43663. function getReferenceName(node) {
  43664. const ref = node.type === "TSTypeReference" ? node.typeName : node.type === "TSExpressionWithTypeArguments" ? node.expression : node.type === "TSImportType" ? node.qualifier : node.exprName;
  43665. if ((ref == null ? void 0 : ref.type) === "Identifier") {
  43666. return ref.name;
  43667. } else if ((ref == null ? void 0 : ref.type) === "TSQualifiedName") {
  43668. return qualifiedNameToPath(ref);
  43669. } else {
  43670. return "default";
  43671. }
  43672. }
  43673. function qualifiedNameToPath(node) {
  43674. if (node.type === "Identifier") {
  43675. return [node.name];
  43676. } else {
  43677. return [...qualifiedNameToPath(node.left), node.right.name];
  43678. }
  43679. }
  43680. function resolveGlobalScope(ctx) {
  43681. if (ctx.options.globalTypeFiles) {
  43682. const fs = resolveFS(ctx);
  43683. if (!fs) {
  43684. throw new Error("[vue/compiler-sfc] globalTypeFiles requires fs access.");
  43685. }
  43686. return ctx.options.globalTypeFiles.map(
  43687. (file) => fileToScope(ctx, normalizePath(file), true)
  43688. );
  43689. }
  43690. }
  43691. let ts;
  43692. let loadTS;
  43693. function registerTS(_loadTS) {
  43694. loadTS = () => {
  43695. try {
  43696. return _loadTS();
  43697. } catch (err) {
  43698. if (typeof err.message === "string" && err.message.includes("Cannot find module")) {
  43699. throw new Error(
  43700. 'Failed to load TypeScript, which is required for resolving imported types. Please make sure "typescript" is installed as a project dependency.'
  43701. );
  43702. } else {
  43703. throw new Error(
  43704. "Failed to load TypeScript for resolving imported types."
  43705. );
  43706. }
  43707. }
  43708. };
  43709. }
  43710. function resolveFS(ctx) {
  43711. if (ctx.fs) {
  43712. return ctx.fs;
  43713. }
  43714. if (!ts && loadTS) {
  43715. ts = loadTS();
  43716. }
  43717. const fs = ctx.options.fs || (ts == null ? void 0 : ts.sys);
  43718. if (!fs) {
  43719. return;
  43720. }
  43721. return ctx.fs = {
  43722. fileExists(file) {
  43723. if (file.endsWith(".vue.ts")) {
  43724. file = file.replace(/\.ts$/, "");
  43725. }
  43726. return fs.fileExists(file);
  43727. },
  43728. readFile(file) {
  43729. if (file.endsWith(".vue.ts")) {
  43730. file = file.replace(/\.ts$/, "");
  43731. }
  43732. return fs.readFile(file);
  43733. },
  43734. realpath: fs.realpath
  43735. };
  43736. }
  43737. function resolveTypeFromImport(ctx, node, name, scope) {
  43738. const { source, imported } = scope.imports[name];
  43739. const sourceScope = importSourceToScope(ctx, node, scope, source);
  43740. return resolveTypeReference(ctx, node, sourceScope, imported, true);
  43741. }
  43742. function importSourceToScope(ctx, node, scope, source) {
  43743. let fs;
  43744. try {
  43745. fs = resolveFS(ctx);
  43746. } catch (err) {
  43747. return ctx.error(err.message, node, scope);
  43748. }
  43749. if (!fs) {
  43750. return ctx.error(
  43751. `No fs option provided to \`compileScript\` in non-Node environment. File system access is required for resolving imported types.`,
  43752. node,
  43753. scope
  43754. );
  43755. }
  43756. let resolved = scope.resolvedImportSources[source];
  43757. if (!resolved) {
  43758. if (source.startsWith("..")) {
  43759. const osSpecificJoinFn = joinPaths;
  43760. const filename = osSpecificJoinFn(dirname$2(scope.filename), source);
  43761. resolved = resolveExt(filename, fs);
  43762. } else if (source[0] === ".") {
  43763. const filename = joinPaths(dirname$2(scope.filename), source);
  43764. resolved = resolveExt(filename, fs);
  43765. } else {
  43766. {
  43767. return ctx.error(
  43768. `Type import from non-relative sources is not supported in the browser build.`,
  43769. node,
  43770. scope
  43771. );
  43772. }
  43773. }
  43774. if (resolved) {
  43775. resolved = scope.resolvedImportSources[source] = normalizePath(resolved);
  43776. }
  43777. }
  43778. if (resolved) {
  43779. (ctx.deps || (ctx.deps = /* @__PURE__ */ new Set())).add(resolved);
  43780. return fileToScope(ctx, resolved);
  43781. } else {
  43782. return ctx.error(
  43783. `Failed to resolve import source ${JSON.stringify(source)}.`,
  43784. node,
  43785. scope
  43786. );
  43787. }
  43788. }
  43789. function resolveExt(filename, fs) {
  43790. filename = filename.replace(/\.js$/, "");
  43791. const tryResolve = (filename2) => {
  43792. if (fs.fileExists(filename2)) return filename2;
  43793. };
  43794. 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`));
  43795. }
  43796. const tsConfigCache = createCache();
  43797. const tsConfigRefMap = /* @__PURE__ */ new Map();
  43798. const fileToScopeCache = createCache();
  43799. function invalidateTypeCache(filename) {
  43800. filename = normalizePath(filename);
  43801. fileToScopeCache.delete(filename);
  43802. tsConfigCache.delete(filename);
  43803. const affectedConfig = tsConfigRefMap.get(filename);
  43804. if (affectedConfig) tsConfigCache.delete(affectedConfig);
  43805. }
  43806. function fileToScope(ctx, filename, asGlobal = false) {
  43807. const cached = fileToScopeCache.get(filename);
  43808. if (cached) {
  43809. return cached;
  43810. }
  43811. const fs = resolveFS(ctx);
  43812. const source = fs.readFile(filename) || "";
  43813. const body = parseFile(filename, source, ctx.options.babelParserPlugins);
  43814. const scope = new TypeScope(filename, source, 0, recordImports(body));
  43815. recordTypes(ctx, body, scope, asGlobal);
  43816. fileToScopeCache.set(filename, scope);
  43817. return scope;
  43818. }
  43819. function parseFile(filename, content, parserPlugins) {
  43820. const ext = extname(filename);
  43821. if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
  43822. return parse_1$1(content, {
  43823. plugins: resolveParserPlugins(
  43824. ext.slice(1),
  43825. parserPlugins,
  43826. /\.d\.m?ts$/.test(filename)
  43827. ),
  43828. sourceType: "module"
  43829. }).program.body;
  43830. } else if (ext === ".vue") {
  43831. const {
  43832. descriptor: { script, scriptSetup }
  43833. } = parse$7(content);
  43834. if (!script && !scriptSetup) {
  43835. return [];
  43836. }
  43837. const scriptOffset = script ? script.loc.start.offset : Infinity;
  43838. const scriptSetupOffset = scriptSetup ? scriptSetup.loc.start.offset : Infinity;
  43839. const firstBlock = scriptOffset < scriptSetupOffset ? script : scriptSetup;
  43840. const secondBlock = scriptOffset < scriptSetupOffset ? scriptSetup : script;
  43841. let scriptContent = " ".repeat(Math.min(scriptOffset, scriptSetupOffset)) + firstBlock.content;
  43842. if (secondBlock) {
  43843. scriptContent += " ".repeat(secondBlock.loc.start.offset - script.loc.end.offset) + secondBlock.content;
  43844. }
  43845. const lang = (script == null ? void 0 : script.lang) || (scriptSetup == null ? void 0 : scriptSetup.lang);
  43846. return parse_1$1(scriptContent, {
  43847. plugins: resolveParserPlugins(lang, parserPlugins),
  43848. sourceType: "module"
  43849. }).program.body;
  43850. }
  43851. return [];
  43852. }
  43853. function ctxToScope(ctx) {
  43854. if (ctx.scope) {
  43855. return ctx.scope;
  43856. }
  43857. const body = "ast" in ctx ? ctx.ast : ctx.scriptAst ? [...ctx.scriptAst.body, ...ctx.scriptSetupAst.body] : ctx.scriptSetupAst.body;
  43858. const scope = new TypeScope(
  43859. ctx.filename,
  43860. ctx.source,
  43861. "startOffset" in ctx ? ctx.startOffset : 0,
  43862. "userImports" in ctx ? Object.create(ctx.userImports) : recordImports(body)
  43863. );
  43864. recordTypes(ctx, body, scope);
  43865. return ctx.scope = scope;
  43866. }
  43867. function moduleDeclToScope(ctx, node, parentScope) {
  43868. if (node._resolvedChildScope) {
  43869. return node._resolvedChildScope;
  43870. }
  43871. const scope = createChildScope(parentScope);
  43872. if (node.body.type === "TSModuleDeclaration") {
  43873. const decl = node.body;
  43874. decl._ownerScope = scope;
  43875. const id = getId(decl.id);
  43876. scope.types[id] = scope.exportedTypes[id] = decl;
  43877. } else {
  43878. recordTypes(ctx, node.body.body, scope);
  43879. }
  43880. return node._resolvedChildScope = scope;
  43881. }
  43882. function createChildScope(parentScope) {
  43883. return new TypeScope(
  43884. parentScope.filename,
  43885. parentScope.source,
  43886. parentScope.offset,
  43887. Object.create(parentScope.imports),
  43888. Object.create(parentScope.types),
  43889. Object.create(parentScope.declares)
  43890. );
  43891. }
  43892. const importExportRE = /^Import|^Export/;
  43893. function recordTypes(ctx, body, scope, asGlobal = false) {
  43894. const { types, declares, exportedTypes, exportedDeclares, imports } = scope;
  43895. const isAmbient = asGlobal ? !body.some((s) => importExportRE.test(s.type)) : false;
  43896. for (const stmt of body) {
  43897. if (asGlobal) {
  43898. if (isAmbient) {
  43899. if (stmt.declare) {
  43900. recordType(stmt, types, declares);
  43901. }
  43902. } else if (stmt.type === "TSModuleDeclaration" && stmt.global) {
  43903. for (const s of stmt.body.body) {
  43904. recordType(s, types, declares);
  43905. }
  43906. }
  43907. } else {
  43908. recordType(stmt, types, declares);
  43909. }
  43910. }
  43911. if (!asGlobal) {
  43912. for (const stmt of body) {
  43913. if (stmt.type === "ExportNamedDeclaration") {
  43914. if (stmt.declaration) {
  43915. recordType(stmt.declaration, types, declares);
  43916. recordType(stmt.declaration, exportedTypes, exportedDeclares);
  43917. } else {
  43918. for (const spec of stmt.specifiers) {
  43919. if (spec.type === "ExportSpecifier") {
  43920. const local = spec.local.name;
  43921. const exported = getId(spec.exported);
  43922. if (stmt.source) {
  43923. imports[exported] = {
  43924. source: stmt.source.value,
  43925. imported: local
  43926. };
  43927. exportedTypes[exported] = {
  43928. type: "TSTypeReference",
  43929. typeName: {
  43930. type: "Identifier",
  43931. name: local
  43932. },
  43933. _ownerScope: scope
  43934. };
  43935. } else if (types[local]) {
  43936. exportedTypes[exported] = types[local];
  43937. }
  43938. }
  43939. }
  43940. }
  43941. } else if (stmt.type === "ExportAllDeclaration") {
  43942. const sourceScope = importSourceToScope(
  43943. ctx,
  43944. stmt.source,
  43945. scope,
  43946. stmt.source.value
  43947. );
  43948. Object.assign(scope.exportedTypes, sourceScope.exportedTypes);
  43949. } else if (stmt.type === "ExportDefaultDeclaration" && stmt.declaration) {
  43950. if (stmt.declaration.type !== "Identifier") {
  43951. recordType(stmt.declaration, types, declares, "default");
  43952. recordType(
  43953. stmt.declaration,
  43954. exportedTypes,
  43955. exportedDeclares,
  43956. "default"
  43957. );
  43958. } else if (types[stmt.declaration.name]) {
  43959. exportedTypes["default"] = types[stmt.declaration.name];
  43960. }
  43961. }
  43962. }
  43963. }
  43964. for (const key of Object.keys(types)) {
  43965. const node = types[key];
  43966. node._ownerScope = scope;
  43967. if (node._ns) node._ns._ownerScope = scope;
  43968. }
  43969. for (const key of Object.keys(declares)) {
  43970. declares[key]._ownerScope = scope;
  43971. }
  43972. }
  43973. function recordType(node, types, declares, overwriteId) {
  43974. switch (node.type) {
  43975. case "TSInterfaceDeclaration":
  43976. case "TSEnumDeclaration":
  43977. case "TSModuleDeclaration": {
  43978. const id = overwriteId || getId(node.id);
  43979. let existing = types[id];
  43980. if (existing) {
  43981. if (node.type === "TSModuleDeclaration") {
  43982. if (existing.type === "TSModuleDeclaration") {
  43983. mergeNamespaces(existing, node);
  43984. } else {
  43985. attachNamespace(existing, node);
  43986. }
  43987. break;
  43988. }
  43989. if (existing.type === "TSModuleDeclaration") {
  43990. types[id] = node;
  43991. attachNamespace(node, existing);
  43992. break;
  43993. }
  43994. if (existing.type !== node.type) {
  43995. break;
  43996. }
  43997. if (node.type === "TSInterfaceDeclaration") {
  43998. existing.body.body.push(...node.body.body);
  43999. } else {
  44000. existing.members.push(...node.members);
  44001. }
  44002. } else {
  44003. types[id] = node;
  44004. }
  44005. break;
  44006. }
  44007. case "ClassDeclaration":
  44008. if (overwriteId || node.id) types[overwriteId || getId(node.id)] = node;
  44009. break;
  44010. case "TSTypeAliasDeclaration":
  44011. types[node.id.name] = node.typeParameters ? node : node.typeAnnotation;
  44012. break;
  44013. case "TSDeclareFunction":
  44014. if (node.id) declares[node.id.name] = node;
  44015. break;
  44016. case "VariableDeclaration": {
  44017. if (node.declare) {
  44018. for (const decl of node.declarations) {
  44019. if (decl.id.type === "Identifier" && decl.id.typeAnnotation) {
  44020. declares[decl.id.name] = decl.id.typeAnnotation.typeAnnotation;
  44021. }
  44022. }
  44023. }
  44024. break;
  44025. }
  44026. }
  44027. }
  44028. function mergeNamespaces(to, from) {
  44029. const toBody = to.body;
  44030. const fromBody = from.body;
  44031. if (toBody.type === "TSModuleDeclaration") {
  44032. if (fromBody.type === "TSModuleDeclaration") {
  44033. mergeNamespaces(toBody, fromBody);
  44034. } else {
  44035. fromBody.body.push({
  44036. type: "ExportNamedDeclaration",
  44037. declaration: toBody,
  44038. exportKind: "type",
  44039. specifiers: []
  44040. });
  44041. }
  44042. } else if (fromBody.type === "TSModuleDeclaration") {
  44043. toBody.body.push({
  44044. type: "ExportNamedDeclaration",
  44045. declaration: fromBody,
  44046. exportKind: "type",
  44047. specifiers: []
  44048. });
  44049. } else {
  44050. toBody.body.push(...fromBody.body);
  44051. }
  44052. }
  44053. function attachNamespace(to, ns) {
  44054. if (!to._ns) {
  44055. to._ns = ns;
  44056. } else {
  44057. mergeNamespaces(to._ns, ns);
  44058. }
  44059. }
  44060. function recordImports(body) {
  44061. const imports = /* @__PURE__ */ Object.create(null);
  44062. for (const s of body) {
  44063. recordImport(s, imports);
  44064. }
  44065. return imports;
  44066. }
  44067. function recordImport(node, imports) {
  44068. if (node.type !== "ImportDeclaration") {
  44069. return;
  44070. }
  44071. for (const s of node.specifiers) {
  44072. imports[s.local.name] = {
  44073. imported: getImportedName(s),
  44074. source: node.source.value
  44075. };
  44076. }
  44077. }
  44078. function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx), isKeyOf = false) {
  44079. try {
  44080. switch (node.type) {
  44081. case "TSStringKeyword":
  44082. return ["String"];
  44083. case "TSNumberKeyword":
  44084. return ["Number"];
  44085. case "TSBooleanKeyword":
  44086. return ["Boolean"];
  44087. case "TSObjectKeyword":
  44088. return ["Object"];
  44089. case "TSNullKeyword":
  44090. return ["null"];
  44091. case "TSTypeLiteral":
  44092. case "TSInterfaceDeclaration": {
  44093. const types = /* @__PURE__ */ new Set();
  44094. const members = node.type === "TSTypeLiteral" ? node.members : node.body.body;
  44095. for (const m of members) {
  44096. if (isKeyOf) {
  44097. if (m.type === "TSPropertySignature" && m.key.type === "NumericLiteral") {
  44098. types.add("Number");
  44099. } else if (m.type === "TSIndexSignature") {
  44100. const annotation = m.parameters[0].typeAnnotation;
  44101. if (annotation && annotation.type !== "Noop") {
  44102. const type = inferRuntimeType(
  44103. ctx,
  44104. annotation.typeAnnotation,
  44105. scope
  44106. )[0];
  44107. if (type === UNKNOWN_TYPE) return [UNKNOWN_TYPE];
  44108. types.add(type);
  44109. }
  44110. } else {
  44111. types.add("String");
  44112. }
  44113. } else if (m.type === "TSCallSignatureDeclaration" || m.type === "TSConstructSignatureDeclaration") {
  44114. types.add("Function");
  44115. } else {
  44116. types.add("Object");
  44117. }
  44118. }
  44119. return types.size ? Array.from(types) : [isKeyOf ? UNKNOWN_TYPE : "Object"];
  44120. }
  44121. case "TSPropertySignature":
  44122. if (node.typeAnnotation) {
  44123. return inferRuntimeType(
  44124. ctx,
  44125. node.typeAnnotation.typeAnnotation,
  44126. scope
  44127. );
  44128. }
  44129. break;
  44130. case "TSMethodSignature":
  44131. case "TSFunctionType":
  44132. return ["Function"];
  44133. case "TSArrayType":
  44134. case "TSTupleType":
  44135. return ["Array"];
  44136. case "TSLiteralType":
  44137. switch (node.literal.type) {
  44138. case "StringLiteral":
  44139. return ["String"];
  44140. case "BooleanLiteral":
  44141. return ["Boolean"];
  44142. case "NumericLiteral":
  44143. case "BigIntLiteral":
  44144. return ["Number"];
  44145. default:
  44146. return [UNKNOWN_TYPE];
  44147. }
  44148. case "TSTypeReference": {
  44149. const resolved = resolveTypeReference(ctx, node, scope);
  44150. if (resolved) {
  44151. return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
  44152. }
  44153. if (node.typeName.type === "Identifier") {
  44154. if (isKeyOf) {
  44155. switch (node.typeName.name) {
  44156. case "String":
  44157. case "Array":
  44158. case "ArrayLike":
  44159. case "Parameters":
  44160. case "ConstructorParameters":
  44161. case "ReadonlyArray":
  44162. return ["String", "Number"];
  44163. case "Record":
  44164. case "Partial":
  44165. case "Required":
  44166. case "Readonly":
  44167. if (node.typeParameters && node.typeParameters.params[0]) {
  44168. return inferRuntimeType(
  44169. ctx,
  44170. node.typeParameters.params[0],
  44171. scope,
  44172. true
  44173. );
  44174. }
  44175. break;
  44176. case "Pick":
  44177. case "Extract":
  44178. if (node.typeParameters && node.typeParameters.params[1]) {
  44179. return inferRuntimeType(
  44180. ctx,
  44181. node.typeParameters.params[1],
  44182. scope
  44183. );
  44184. }
  44185. break;
  44186. case "Function":
  44187. case "Object":
  44188. case "Set":
  44189. case "Map":
  44190. case "WeakSet":
  44191. case "WeakMap":
  44192. case "Date":
  44193. case "Promise":
  44194. case "Error":
  44195. case "Uppercase":
  44196. case "Lowercase":
  44197. case "Capitalize":
  44198. case "Uncapitalize":
  44199. case "ReadonlyMap":
  44200. case "ReadonlySet":
  44201. return ["String"];
  44202. }
  44203. } else {
  44204. switch (node.typeName.name) {
  44205. case "Array":
  44206. case "Function":
  44207. case "Object":
  44208. case "Set":
  44209. case "Map":
  44210. case "WeakSet":
  44211. case "WeakMap":
  44212. case "Date":
  44213. case "Promise":
  44214. case "Error":
  44215. return [node.typeName.name];
  44216. case "Partial":
  44217. case "Required":
  44218. case "Readonly":
  44219. case "Record":
  44220. case "Pick":
  44221. case "Omit":
  44222. case "InstanceType":
  44223. return ["Object"];
  44224. case "Uppercase":
  44225. case "Lowercase":
  44226. case "Capitalize":
  44227. case "Uncapitalize":
  44228. return ["String"];
  44229. case "Parameters":
  44230. case "ConstructorParameters":
  44231. case "ReadonlyArray":
  44232. return ["Array"];
  44233. case "ReadonlyMap":
  44234. return ["Map"];
  44235. case "ReadonlySet":
  44236. return ["Set"];
  44237. case "NonNullable":
  44238. if (node.typeParameters && node.typeParameters.params[0]) {
  44239. return inferRuntimeType(
  44240. ctx,
  44241. node.typeParameters.params[0],
  44242. scope
  44243. ).filter((t) => t !== "null");
  44244. }
  44245. break;
  44246. case "Extract":
  44247. if (node.typeParameters && node.typeParameters.params[1]) {
  44248. return inferRuntimeType(
  44249. ctx,
  44250. node.typeParameters.params[1],
  44251. scope
  44252. );
  44253. }
  44254. break;
  44255. case "Exclude":
  44256. case "OmitThisParameter":
  44257. if (node.typeParameters && node.typeParameters.params[0]) {
  44258. return inferRuntimeType(
  44259. ctx,
  44260. node.typeParameters.params[0],
  44261. scope
  44262. );
  44263. }
  44264. break;
  44265. }
  44266. }
  44267. }
  44268. break;
  44269. }
  44270. case "TSParenthesizedType":
  44271. return inferRuntimeType(ctx, node.typeAnnotation, scope);
  44272. case "TSUnionType":
  44273. return flattenTypes(ctx, node.types, scope, isKeyOf);
  44274. case "TSIntersectionType": {
  44275. return flattenTypes(ctx, node.types, scope, isKeyOf).filter(
  44276. (t) => t !== UNKNOWN_TYPE
  44277. );
  44278. }
  44279. case "TSEnumDeclaration":
  44280. return inferEnumType(node);
  44281. case "TSSymbolKeyword":
  44282. return ["Symbol"];
  44283. case "TSIndexedAccessType": {
  44284. const types = resolveIndexType(ctx, node, scope);
  44285. return flattenTypes(ctx, types, scope, isKeyOf);
  44286. }
  44287. case "ClassDeclaration":
  44288. return ["Object"];
  44289. case "TSImportType": {
  44290. const sourceScope = importSourceToScope(
  44291. ctx,
  44292. node.argument,
  44293. scope,
  44294. node.argument.value
  44295. );
  44296. const resolved = resolveTypeReference(ctx, node, sourceScope);
  44297. if (resolved) {
  44298. return inferRuntimeType(ctx, resolved, resolved._ownerScope);
  44299. }
  44300. break;
  44301. }
  44302. case "TSTypeQuery": {
  44303. const id = node.exprName;
  44304. if (id.type === "Identifier") {
  44305. const matched = scope.declares[id.name];
  44306. if (matched) {
  44307. return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf);
  44308. }
  44309. }
  44310. break;
  44311. }
  44312. case "TSTypeOperator": {
  44313. return inferRuntimeType(
  44314. ctx,
  44315. node.typeAnnotation,
  44316. scope,
  44317. node.operator === "keyof"
  44318. );
  44319. }
  44320. case "TSAnyKeyword": {
  44321. if (isKeyOf) {
  44322. return ["String", "Number", "Symbol"];
  44323. }
  44324. break;
  44325. }
  44326. }
  44327. } catch (e) {
  44328. }
  44329. return [UNKNOWN_TYPE];
  44330. }
  44331. function flattenTypes(ctx, types, scope, isKeyOf = false) {
  44332. if (types.length === 1) {
  44333. return inferRuntimeType(ctx, types[0], scope, isKeyOf);
  44334. }
  44335. return [
  44336. ...new Set(
  44337. [].concat(
  44338. ...types.map((t) => inferRuntimeType(ctx, t, scope, isKeyOf))
  44339. )
  44340. )
  44341. ];
  44342. }
  44343. function inferEnumType(node) {
  44344. const types = /* @__PURE__ */ new Set();
  44345. for (const m of node.members) {
  44346. if (m.initializer) {
  44347. switch (m.initializer.type) {
  44348. case "StringLiteral":
  44349. types.add("String");
  44350. break;
  44351. case "NumericLiteral":
  44352. types.add("Number");
  44353. break;
  44354. }
  44355. }
  44356. }
  44357. return types.size ? [...types] : ["Number"];
  44358. }
  44359. function resolveExtractPropTypes({ props }, scope) {
  44360. const res = { props: {} };
  44361. for (const key in props) {
  44362. const raw = props[key];
  44363. res.props[key] = reverseInferType(
  44364. raw.key,
  44365. raw.typeAnnotation.typeAnnotation,
  44366. scope
  44367. );
  44368. }
  44369. return res;
  44370. }
  44371. function reverseInferType(key, node, scope, optional = true, checkObjectSyntax = true) {
  44372. if (checkObjectSyntax && node.type === "TSTypeLiteral") {
  44373. const typeType = findStaticPropertyType(node, "type");
  44374. if (typeType) {
  44375. const requiredType = findStaticPropertyType(node, "required");
  44376. const optional2 = requiredType && requiredType.type === "TSLiteralType" && requiredType.literal.type === "BooleanLiteral" ? !requiredType.literal.value : true;
  44377. return reverseInferType(key, typeType, scope, optional2, false);
  44378. }
  44379. } else if (node.type === "TSTypeReference" && node.typeName.type === "Identifier") {
  44380. if (node.typeName.name.endsWith("Constructor")) {
  44381. return createProperty(
  44382. key,
  44383. ctorToType(node.typeName.name),
  44384. scope,
  44385. optional
  44386. );
  44387. } else if (node.typeName.name === "PropType" && node.typeParameters) {
  44388. return createProperty(key, node.typeParameters.params[0], scope, optional);
  44389. }
  44390. }
  44391. if ((node.type === "TSTypeReference" || node.type === "TSImportType") && node.typeParameters) {
  44392. for (const t of node.typeParameters.params) {
  44393. const inferred = reverseInferType(key, t, scope, optional);
  44394. if (inferred) return inferred;
  44395. }
  44396. }
  44397. return createProperty(key, { type: `TSNullKeyword` }, scope, optional);
  44398. }
  44399. function ctorToType(ctorType) {
  44400. const ctor = ctorType.slice(0, -11);
  44401. switch (ctor) {
  44402. case "String":
  44403. case "Number":
  44404. case "Boolean":
  44405. return { type: `TS${ctor}Keyword` };
  44406. case "Array":
  44407. case "Function":
  44408. case "Object":
  44409. case "Set":
  44410. case "Map":
  44411. case "WeakSet":
  44412. case "WeakMap":
  44413. case "Date":
  44414. case "Promise":
  44415. return {
  44416. type: "TSTypeReference",
  44417. typeName: { type: "Identifier", name: ctor }
  44418. };
  44419. }
  44420. return { type: `TSNullKeyword` };
  44421. }
  44422. function findStaticPropertyType(node, key) {
  44423. const prop = node.members.find(
  44424. (m) => m.type === "TSPropertySignature" && !m.computed && getId(m.key) === key && m.typeAnnotation
  44425. );
  44426. return prop && prop.typeAnnotation.typeAnnotation;
  44427. }
  44428. function resolveReturnType(ctx, arg, scope) {
  44429. var _a;
  44430. let resolved = arg;
  44431. if (arg.type === "TSTypeReference" || arg.type === "TSTypeQuery" || arg.type === "TSImportType") {
  44432. resolved = resolveTypeReference(ctx, arg, scope);
  44433. }
  44434. if (!resolved) return;
  44435. if (resolved.type === "TSFunctionType") {
  44436. return (_a = resolved.typeAnnotation) == null ? void 0 : _a.typeAnnotation;
  44437. }
  44438. if (resolved.type === "TSDeclareFunction") {
  44439. return resolved.returnType;
  44440. }
  44441. }
  44442. function resolveUnionType(ctx, node, scope) {
  44443. if (node.type === "TSTypeReference") {
  44444. const resolved = resolveTypeReference(ctx, node, scope);
  44445. if (resolved) node = resolved;
  44446. }
  44447. let types;
  44448. if (node.type === "TSUnionType") {
  44449. types = node.types.flatMap((node2) => resolveUnionType(ctx, node2, scope));
  44450. } else {
  44451. types = [node];
  44452. }
  44453. return types;
  44454. }
  44455. const DEFINE_MODEL = "defineModel";
  44456. function processDefineModel(ctx, node, declId) {
  44457. if (!isCallOf(node, DEFINE_MODEL)) {
  44458. return false;
  44459. }
  44460. ctx.hasDefineModelCall = true;
  44461. const type = node.typeParameters && node.typeParameters.params[0] || void 0;
  44462. let modelName;
  44463. let options;
  44464. const arg0 = node.arguments[0] && unwrapTSNode(node.arguments[0]);
  44465. const hasName = arg0 && arg0.type === "StringLiteral";
  44466. if (hasName) {
  44467. modelName = arg0.value;
  44468. options = node.arguments[1];
  44469. } else {
  44470. modelName = "modelValue";
  44471. options = arg0;
  44472. }
  44473. if (ctx.modelDecls[modelName]) {
  44474. ctx.error(`duplicate model name ${JSON.stringify(modelName)}`, node);
  44475. }
  44476. let optionsString = options && ctx.getString(options);
  44477. let optionsRemoved = !options;
  44478. const runtimeOptionNodes = [];
  44479. if (options && options.type === "ObjectExpression" && !options.properties.some((p) => p.type === "SpreadElement" || p.computed)) {
  44480. let removed = 0;
  44481. for (let i = options.properties.length - 1; i >= 0; i--) {
  44482. const p = options.properties[i];
  44483. const next = options.properties[i + 1];
  44484. const start = p.start;
  44485. const end = next ? next.start : options.end - 1;
  44486. 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"))) {
  44487. optionsString = optionsString.slice(0, start - options.start) + optionsString.slice(end - options.start);
  44488. } else {
  44489. removed++;
  44490. ctx.s.remove(ctx.startOffset + start, ctx.startOffset + end);
  44491. runtimeOptionNodes.push(p);
  44492. }
  44493. }
  44494. if (removed === options.properties.length) {
  44495. optionsRemoved = true;
  44496. ctx.s.remove(
  44497. ctx.startOffset + (hasName ? arg0.end : options.start),
  44498. ctx.startOffset + options.end
  44499. );
  44500. }
  44501. }
  44502. ctx.modelDecls[modelName] = {
  44503. type,
  44504. options: optionsString,
  44505. runtimeOptionNodes,
  44506. identifier: declId && declId.type === "Identifier" ? declId.name : void 0
  44507. };
  44508. ctx.bindingMetadata[modelName] = "props";
  44509. ctx.s.overwrite(
  44510. ctx.startOffset + node.callee.start,
  44511. ctx.startOffset + node.callee.end,
  44512. ctx.helper("useModel")
  44513. );
  44514. ctx.s.appendLeft(
  44515. ctx.startOffset + (node.arguments.length ? node.arguments[0].start : node.end - 1),
  44516. `__props, ` + (hasName ? `` : `${JSON.stringify(modelName)}${optionsRemoved ? `` : `, `}`)
  44517. );
  44518. return true;
  44519. }
  44520. function genModelProps(ctx) {
  44521. if (!ctx.hasDefineModelCall) return;
  44522. const isProd = !!ctx.options.isProd;
  44523. let modelPropsDecl = "";
  44524. for (const [name, { type, options: runtimeOptions }] of Object.entries(
  44525. ctx.modelDecls
  44526. )) {
  44527. let skipCheck = false;
  44528. let codegenOptions = ``;
  44529. let runtimeTypes = type && inferRuntimeType(ctx, type);
  44530. if (runtimeTypes) {
  44531. const hasBoolean = runtimeTypes.includes("Boolean");
  44532. const hasFunction = runtimeTypes.includes("Function");
  44533. const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE);
  44534. if (hasUnknownType) {
  44535. if (hasBoolean || hasFunction) {
  44536. runtimeTypes = runtimeTypes.filter((t) => t !== UNKNOWN_TYPE);
  44537. skipCheck = true;
  44538. } else {
  44539. runtimeTypes = ["null"];
  44540. }
  44541. }
  44542. if (!isProd) {
  44543. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}` + (skipCheck ? ", skipCheck: true" : "");
  44544. } else if (hasBoolean || runtimeOptions && hasFunction) {
  44545. codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`;
  44546. } else ;
  44547. }
  44548. let decl;
  44549. if (codegenOptions && runtimeOptions) {
  44550. decl = ctx.isTS ? `{ ${codegenOptions}, ...${runtimeOptions} }` : `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`;
  44551. } else if (codegenOptions) {
  44552. decl = `{ ${codegenOptions} }`;
  44553. } else if (runtimeOptions) {
  44554. decl = runtimeOptions;
  44555. } else {
  44556. decl = `{}`;
  44557. }
  44558. modelPropsDecl += `
  44559. ${JSON.stringify(name)}: ${decl},`;
  44560. const modifierPropName = JSON.stringify(
  44561. name === "modelValue" ? `modelModifiers` : `${name}Modifiers`
  44562. );
  44563. modelPropsDecl += `
  44564. ${modifierPropName}: {},`;
  44565. }
  44566. return `{${modelPropsDecl}
  44567. }`;
  44568. }
  44569. const DEFINE_PROPS = "defineProps";
  44570. const WITH_DEFAULTS = "withDefaults";
  44571. function processDefineProps(ctx, node, declId) {
  44572. if (!isCallOf(node, DEFINE_PROPS)) {
  44573. return processWithDefaults(ctx, node, declId);
  44574. }
  44575. if (ctx.hasDefinePropsCall) {
  44576. ctx.error(`duplicate ${DEFINE_PROPS}() call`, node);
  44577. }
  44578. ctx.hasDefinePropsCall = true;
  44579. ctx.propsRuntimeDecl = node.arguments[0];
  44580. if (ctx.propsRuntimeDecl) {
  44581. for (const key of getObjectOrArrayExpressionKeys(ctx.propsRuntimeDecl)) {
  44582. if (!(key in ctx.bindingMetadata)) {
  44583. ctx.bindingMetadata[key] = "props";
  44584. }
  44585. }
  44586. }
  44587. if (node.typeParameters) {
  44588. if (ctx.propsRuntimeDecl) {
  44589. ctx.error(
  44590. `${DEFINE_PROPS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  44591. node
  44592. );
  44593. }
  44594. ctx.propsTypeDecl = node.typeParameters.params[0];
  44595. }
  44596. if (declId && declId.type === "ObjectPattern") {
  44597. processPropsDestructure(ctx, declId);
  44598. }
  44599. ctx.propsCall = node;
  44600. ctx.propsDecl = declId;
  44601. return true;
  44602. }
  44603. function processWithDefaults(ctx, node, declId) {
  44604. if (!isCallOf(node, WITH_DEFAULTS)) {
  44605. return false;
  44606. }
  44607. if (!processDefineProps(ctx, node.arguments[0], declId)) {
  44608. ctx.error(
  44609. `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
  44610. node.arguments[0] || node
  44611. );
  44612. }
  44613. if (ctx.propsRuntimeDecl) {
  44614. ctx.error(
  44615. `${WITH_DEFAULTS} can only be used with type-based ${DEFINE_PROPS} declaration.`,
  44616. node
  44617. );
  44618. }
  44619. if (ctx.propsDestructureDecl) {
  44620. ctx.error(
  44621. `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().
  44622. Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).`,
  44623. node.callee
  44624. );
  44625. }
  44626. ctx.propsRuntimeDefaults = node.arguments[1];
  44627. if (!ctx.propsRuntimeDefaults) {
  44628. ctx.error(`The 2nd argument of ${WITH_DEFAULTS} is required.`, node);
  44629. }
  44630. ctx.propsCall = node;
  44631. return true;
  44632. }
  44633. function genRuntimeProps(ctx) {
  44634. let propsDecls;
  44635. if (ctx.propsRuntimeDecl) {
  44636. propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim();
  44637. if (ctx.propsDestructureDecl) {
  44638. const defaults = [];
  44639. for (const key in ctx.propsDestructuredBindings) {
  44640. const d = genDestructuredDefaultValue(ctx, key);
  44641. const finalKey = getEscapedPropName(key);
  44642. if (d)
  44643. defaults.push(
  44644. `${finalKey}: ${d.valueString}${d.needSkipFactory ? `, __skip_${finalKey}: true` : ``}`
  44645. );
  44646. }
  44647. if (defaults.length) {
  44648. propsDecls = `/*#__PURE__*/${ctx.helper(
  44649. `mergeDefaults`
  44650. )}(${propsDecls}, {
  44651. ${defaults.join(",\n ")}
  44652. })`;
  44653. }
  44654. }
  44655. } else if (ctx.propsTypeDecl) {
  44656. propsDecls = extractRuntimeProps(ctx);
  44657. }
  44658. const modelsDecls = genModelProps(ctx);
  44659. if (propsDecls && modelsDecls) {
  44660. return `/*#__PURE__*/${ctx.helper(
  44661. "mergeModels"
  44662. )}(${propsDecls}, ${modelsDecls})`;
  44663. } else {
  44664. return modelsDecls || propsDecls;
  44665. }
  44666. }
  44667. function extractRuntimeProps(ctx) {
  44668. const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
  44669. if (!props.length) {
  44670. return;
  44671. }
  44672. const propStrings = [];
  44673. const hasStaticDefaults = hasStaticWithDefaults(ctx);
  44674. for (const prop of props) {
  44675. propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
  44676. if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
  44677. ctx.bindingMetadata[prop.key] = "props";
  44678. }
  44679. }
  44680. let propsDecls = `{
  44681. ${propStrings.join(",\n ")}
  44682. }`;
  44683. if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
  44684. propsDecls = `/*#__PURE__*/${ctx.helper(
  44685. "mergeDefaults"
  44686. )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`;
  44687. }
  44688. return propsDecls;
  44689. }
  44690. function resolveRuntimePropsFromType(ctx, node) {
  44691. const props = [];
  44692. const elements = resolveTypeElements(ctx, node);
  44693. for (const key in elements.props) {
  44694. const e = elements.props[key];
  44695. let type = inferRuntimeType(ctx, e);
  44696. let skipCheck = false;
  44697. if (type.includes(UNKNOWN_TYPE)) {
  44698. if (type.includes("Boolean") || type.includes("Function")) {
  44699. type = type.filter((t) => t !== UNKNOWN_TYPE);
  44700. skipCheck = true;
  44701. } else {
  44702. type = ["null"];
  44703. }
  44704. }
  44705. props.push({
  44706. key,
  44707. required: !e.optional,
  44708. type: type || [`null`],
  44709. skipCheck
  44710. });
  44711. }
  44712. return props;
  44713. }
  44714. function genRuntimePropFromType(ctx, { key, required, type, skipCheck }, hasStaticDefaults) {
  44715. let defaultString;
  44716. const destructured = genDestructuredDefaultValue(ctx, key, type);
  44717. if (destructured) {
  44718. defaultString = `default: ${destructured.valueString}${destructured.needSkipFactory ? `, skipFactory: true` : ``}`;
  44719. } else if (hasStaticDefaults) {
  44720. const prop = ctx.propsRuntimeDefaults.properties.find(
  44721. (node) => {
  44722. if (node.type === "SpreadElement") return false;
  44723. return resolveObjectKey(node.key, node.computed) === key;
  44724. }
  44725. );
  44726. if (prop) {
  44727. if (prop.type === "ObjectProperty") {
  44728. defaultString = `default: ${ctx.getString(prop.value)}`;
  44729. } else {
  44730. defaultString = `${prop.async ? "async " : ""}${prop.kind !== "method" ? `${prop.kind} ` : ""}default() ${ctx.getString(prop.body)}`;
  44731. }
  44732. }
  44733. }
  44734. const finalKey = getEscapedPropName(key);
  44735. if (!ctx.options.isProd) {
  44736. return `${finalKey}: { ${concatStrings([
  44737. `type: ${toRuntimeTypeString(type)}`,
  44738. `required: ${required}`,
  44739. skipCheck && "skipCheck: true",
  44740. defaultString
  44741. ])} }`;
  44742. } else if (type.some(
  44743. (el) => el === "Boolean" || (!hasStaticDefaults || defaultString) && el === "Function"
  44744. )) {
  44745. return `${finalKey}: { ${concatStrings([
  44746. `type: ${toRuntimeTypeString(type)}`,
  44747. defaultString
  44748. ])} }`;
  44749. } else {
  44750. if (ctx.isCE) {
  44751. if (defaultString) {
  44752. return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
  44753. type
  44754. )} }`}`;
  44755. } else {
  44756. return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`;
  44757. }
  44758. }
  44759. return `${finalKey}: ${defaultString ? `{ ${defaultString} }` : `{}`}`;
  44760. }
  44761. }
  44762. function hasStaticWithDefaults(ctx) {
  44763. return !!(ctx.propsRuntimeDefaults && ctx.propsRuntimeDefaults.type === "ObjectExpression" && ctx.propsRuntimeDefaults.properties.every(
  44764. (node) => node.type !== "SpreadElement" && (!node.computed || node.key.type.endsWith("Literal"))
  44765. ));
  44766. }
  44767. function genDestructuredDefaultValue(ctx, key, inferredType) {
  44768. const destructured = ctx.propsDestructuredBindings[key];
  44769. const defaultVal = destructured && destructured.default;
  44770. if (defaultVal) {
  44771. const value = ctx.getString(defaultVal);
  44772. const unwrapped = unwrapTSNode(defaultVal);
  44773. if (inferredType && inferredType.length && !inferredType.includes("null")) {
  44774. const valueType = inferValueType(unwrapped);
  44775. if (valueType && !inferredType.includes(valueType)) {
  44776. ctx.error(
  44777. `Default value of prop "${key}" does not match declared type.`,
  44778. unwrapped
  44779. );
  44780. }
  44781. }
  44782. const needSkipFactory = !inferredType && (isFunctionType(unwrapped) || unwrapped.type === "Identifier");
  44783. const needFactoryWrap = !needSkipFactory && !isLiteralNode(unwrapped) && !(inferredType == null ? void 0 : inferredType.includes("Function"));
  44784. return {
  44785. valueString: needFactoryWrap ? `() => (${value})` : value,
  44786. needSkipFactory
  44787. };
  44788. }
  44789. }
  44790. function inferValueType(node) {
  44791. switch (node.type) {
  44792. case "StringLiteral":
  44793. return "String";
  44794. case "NumericLiteral":
  44795. return "Number";
  44796. case "BooleanLiteral":
  44797. return "Boolean";
  44798. case "ObjectExpression":
  44799. return "Object";
  44800. case "ArrayExpression":
  44801. return "Array";
  44802. case "FunctionExpression":
  44803. case "ArrowFunctionExpression":
  44804. return "Function";
  44805. }
  44806. }
  44807. function processPropsDestructure(ctx, declId) {
  44808. if (!ctx.options.propsDestructure) {
  44809. return;
  44810. }
  44811. warnOnce$3(
  44812. `This project is using reactive props destructure, which is an experimental feature. It may receive breaking changes or be removed in the future, so use at your own risk.
  44813. To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
  44814. );
  44815. ctx.propsDestructureDecl = declId;
  44816. const registerBinding = (key, local, defaultValue) => {
  44817. ctx.propsDestructuredBindings[key] = { local, default: defaultValue };
  44818. if (local !== key) {
  44819. ctx.bindingMetadata[local] = "props-aliased";
  44820. (ctx.bindingMetadata.__propsAliases || (ctx.bindingMetadata.__propsAliases = {}))[local] = key;
  44821. }
  44822. };
  44823. for (const prop of declId.properties) {
  44824. if (prop.type === "ObjectProperty") {
  44825. const propKey = resolveObjectKey(prop.key, prop.computed);
  44826. if (!propKey) {
  44827. ctx.error(
  44828. `${DEFINE_PROPS}() destructure cannot use computed key.`,
  44829. prop.key
  44830. );
  44831. }
  44832. if (prop.value.type === "AssignmentPattern") {
  44833. const { left, right } = prop.value;
  44834. if (left.type !== "Identifier") {
  44835. ctx.error(
  44836. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  44837. left
  44838. );
  44839. }
  44840. registerBinding(propKey, left.name, right);
  44841. } else if (prop.value.type === "Identifier") {
  44842. registerBinding(propKey, prop.value.name);
  44843. } else {
  44844. ctx.error(
  44845. `${DEFINE_PROPS}() destructure does not support nested patterns.`,
  44846. prop.value
  44847. );
  44848. }
  44849. } else {
  44850. ctx.propsDestructureRestId = prop.argument.name;
  44851. ctx.bindingMetadata[ctx.propsDestructureRestId] = "setup-reactive-const";
  44852. }
  44853. }
  44854. }
  44855. function transformDestructuredProps(ctx, vueImportAliases) {
  44856. if (!ctx.options.propsDestructure) {
  44857. return;
  44858. }
  44859. const rootScope = {};
  44860. const scopeStack = [rootScope];
  44861. let currentScope = rootScope;
  44862. const excludedIds = /* @__PURE__ */ new WeakSet();
  44863. const parentStack = [];
  44864. const propsLocalToPublicMap = /* @__PURE__ */ Object.create(null);
  44865. for (const key in ctx.propsDestructuredBindings) {
  44866. const { local } = ctx.propsDestructuredBindings[key];
  44867. rootScope[local] = true;
  44868. propsLocalToPublicMap[local] = key;
  44869. }
  44870. function pushScope() {
  44871. scopeStack.push(currentScope = Object.create(currentScope));
  44872. }
  44873. function popScope() {
  44874. scopeStack.pop();
  44875. currentScope = scopeStack[scopeStack.length - 1] || null;
  44876. }
  44877. function registerLocalBinding(id) {
  44878. excludedIds.add(id);
  44879. if (currentScope) {
  44880. currentScope[id.name] = false;
  44881. } else {
  44882. ctx.error(
  44883. "registerBinding called without active scope, something is wrong.",
  44884. id
  44885. );
  44886. }
  44887. }
  44888. function walkScope(node, isRoot = false) {
  44889. for (const stmt of node.body) {
  44890. if (stmt.type === "VariableDeclaration") {
  44891. walkVariableDeclaration(stmt, isRoot);
  44892. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  44893. if (stmt.declare || !stmt.id) continue;
  44894. registerLocalBinding(stmt.id);
  44895. } else if ((stmt.type === "ForOfStatement" || stmt.type === "ForInStatement") && stmt.left.type === "VariableDeclaration") {
  44896. walkVariableDeclaration(stmt.left);
  44897. } else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration && stmt.declaration.type === "VariableDeclaration") {
  44898. walkVariableDeclaration(stmt.declaration, isRoot);
  44899. } else if (stmt.type === "LabeledStatement" && stmt.body.type === "VariableDeclaration") {
  44900. walkVariableDeclaration(stmt.body, isRoot);
  44901. }
  44902. }
  44903. }
  44904. function walkVariableDeclaration(stmt, isRoot = false) {
  44905. if (stmt.declare) {
  44906. return;
  44907. }
  44908. for (const decl of stmt.declarations) {
  44909. const isDefineProps = isRoot && decl.init && isCallOf(unwrapTSNode(decl.init), "defineProps");
  44910. for (const id of extractIdentifiers$1(decl.id)) {
  44911. if (isDefineProps) {
  44912. excludedIds.add(id);
  44913. } else {
  44914. registerLocalBinding(id);
  44915. }
  44916. }
  44917. }
  44918. }
  44919. function rewriteId(id, parent, parentStack2) {
  44920. if (parent.type === "AssignmentExpression" && id === parent.left || parent.type === "UpdateExpression") {
  44921. ctx.error(`Cannot assign to destructured props as they are readonly.`, id);
  44922. }
  44923. if (isStaticProperty(parent) && parent.shorthand) {
  44924. if (!parent.inPattern || isInDestructureAssignment(parent, parentStack2)) {
  44925. ctx.s.appendLeft(
  44926. id.end + ctx.startOffset,
  44927. `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
  44928. );
  44929. }
  44930. } else {
  44931. ctx.s.overwrite(
  44932. id.start + ctx.startOffset,
  44933. id.end + ctx.startOffset,
  44934. genPropsAccessExp(propsLocalToPublicMap[id.name])
  44935. );
  44936. }
  44937. }
  44938. function checkUsage(node, method, alias = method) {
  44939. if (isCallOf(node, alias)) {
  44940. const arg = unwrapTSNode(node.arguments[0]);
  44941. if (arg.type === "Identifier" && currentScope[arg.name]) {
  44942. ctx.error(
  44943. `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). Pass a getter () => ${arg.name} instead.`,
  44944. arg
  44945. );
  44946. }
  44947. }
  44948. }
  44949. const ast = ctx.scriptSetupAst;
  44950. walkScope(ast, true);
  44951. walk$2(ast, {
  44952. enter(node, parent) {
  44953. parent && parentStack.push(parent);
  44954. if (parent && parent.type.startsWith("TS") && parent.type !== "TSAsExpression" && parent.type !== "TSNonNullExpression" && parent.type !== "TSTypeAssertion") {
  44955. return this.skip();
  44956. }
  44957. checkUsage(node, "watch", vueImportAliases.watch);
  44958. checkUsage(node, "toRef", vueImportAliases.toRef);
  44959. if (isFunctionType(node)) {
  44960. pushScope();
  44961. walkFunctionParams(node, registerLocalBinding);
  44962. if (node.body.type === "BlockStatement") {
  44963. walkScope(node.body);
  44964. }
  44965. return;
  44966. }
  44967. if (node.type === "CatchClause") {
  44968. pushScope();
  44969. if (node.param && node.param.type === "Identifier") {
  44970. registerLocalBinding(node.param);
  44971. }
  44972. walkScope(node.body);
  44973. return;
  44974. }
  44975. if (node.type === "BlockStatement" && !isFunctionType(parent)) {
  44976. pushScope();
  44977. walkScope(node);
  44978. return;
  44979. }
  44980. if (node.type === "Identifier") {
  44981. if (isReferencedIdentifier(node, parent, parentStack) && !excludedIds.has(node)) {
  44982. if (currentScope[node.name]) {
  44983. rewriteId(node, parent, parentStack);
  44984. }
  44985. }
  44986. }
  44987. },
  44988. leave(node, parent) {
  44989. parent && parentStack.pop();
  44990. if (node.type === "BlockStatement" && !isFunctionType(parent) || isFunctionType(node)) {
  44991. popScope();
  44992. }
  44993. }
  44994. });
  44995. }
  44996. const DEFINE_EMITS = "defineEmits";
  44997. function processDefineEmits(ctx, node, declId) {
  44998. if (!isCallOf(node, DEFINE_EMITS)) {
  44999. return false;
  45000. }
  45001. if (ctx.hasDefineEmitCall) {
  45002. ctx.error(`duplicate ${DEFINE_EMITS}() call`, node);
  45003. }
  45004. ctx.hasDefineEmitCall = true;
  45005. ctx.emitsRuntimeDecl = node.arguments[0];
  45006. if (node.typeParameters) {
  45007. if (ctx.emitsRuntimeDecl) {
  45008. ctx.error(
  45009. `${DEFINE_EMITS}() cannot accept both type and non-type arguments at the same time. Use one or the other.`,
  45010. node
  45011. );
  45012. }
  45013. ctx.emitsTypeDecl = node.typeParameters.params[0];
  45014. }
  45015. ctx.emitDecl = declId;
  45016. return true;
  45017. }
  45018. function genRuntimeEmits(ctx) {
  45019. let emitsDecl = "";
  45020. if (ctx.emitsRuntimeDecl) {
  45021. emitsDecl = ctx.getString(ctx.emitsRuntimeDecl).trim();
  45022. } else if (ctx.emitsTypeDecl) {
  45023. const typeDeclaredEmits = extractRuntimeEmits(ctx);
  45024. emitsDecl = typeDeclaredEmits.size ? `[${Array.from(typeDeclaredEmits).map((k) => JSON.stringify(k)).join(", ")}]` : ``;
  45025. }
  45026. if (ctx.hasDefineModelCall) {
  45027. let modelEmitsDecl = `[${Object.keys(ctx.modelDecls).map((n) => JSON.stringify(`update:${n}`)).join(", ")}]`;
  45028. emitsDecl = emitsDecl ? `/*#__PURE__*/${ctx.helper(
  45029. "mergeModels"
  45030. )}(${emitsDecl}, ${modelEmitsDecl})` : modelEmitsDecl;
  45031. }
  45032. return emitsDecl;
  45033. }
  45034. function extractRuntimeEmits(ctx) {
  45035. const emits = /* @__PURE__ */ new Set();
  45036. const node = ctx.emitsTypeDecl;
  45037. if (node.type === "TSFunctionType") {
  45038. extractEventNames(ctx, node.parameters[0], emits);
  45039. return emits;
  45040. }
  45041. const { props, calls } = resolveTypeElements(ctx, node);
  45042. let hasProperty = false;
  45043. for (const key in props) {
  45044. emits.add(key);
  45045. hasProperty = true;
  45046. }
  45047. if (calls) {
  45048. if (hasProperty) {
  45049. ctx.error(
  45050. `defineEmits() type cannot mixed call signature and property syntax.`,
  45051. node
  45052. );
  45053. }
  45054. for (const call of calls) {
  45055. extractEventNames(ctx, call.parameters[0], emits);
  45056. }
  45057. }
  45058. return emits;
  45059. }
  45060. function extractEventNames(ctx, eventName, emits) {
  45061. if (eventName.type === "Identifier" && eventName.typeAnnotation && eventName.typeAnnotation.type === "TSTypeAnnotation") {
  45062. const types = resolveUnionType(ctx, eventName.typeAnnotation.typeAnnotation);
  45063. for (const type of types) {
  45064. if (type.type === "TSLiteralType") {
  45065. if (type.literal.type !== "UnaryExpression" && type.literal.type !== "TemplateLiteral") {
  45066. emits.add(String(type.literal.value));
  45067. }
  45068. }
  45069. }
  45070. }
  45071. }
  45072. const DEFINE_EXPOSE = "defineExpose";
  45073. function processDefineExpose(ctx, node) {
  45074. if (isCallOf(node, DEFINE_EXPOSE)) {
  45075. if (ctx.hasDefineExposeCall) {
  45076. ctx.error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  45077. }
  45078. ctx.hasDefineExposeCall = true;
  45079. return true;
  45080. }
  45081. return false;
  45082. }
  45083. const DEFINE_SLOTS = "defineSlots";
  45084. function processDefineSlots(ctx, node, declId) {
  45085. if (!isCallOf(node, DEFINE_SLOTS)) {
  45086. return false;
  45087. }
  45088. if (ctx.hasDefineSlotsCall) {
  45089. ctx.error(`duplicate ${DEFINE_SLOTS}() call`, node);
  45090. }
  45091. ctx.hasDefineSlotsCall = true;
  45092. if (node.arguments.length > 0) {
  45093. ctx.error(`${DEFINE_SLOTS}() cannot accept arguments`, node);
  45094. }
  45095. if (declId) {
  45096. ctx.s.overwrite(
  45097. ctx.startOffset + node.start,
  45098. ctx.startOffset + node.end,
  45099. `${ctx.helper("useSlots")}()`
  45100. );
  45101. }
  45102. return true;
  45103. }
  45104. const DEFINE_OPTIONS = "defineOptions";
  45105. function processDefineOptions(ctx, node) {
  45106. if (!isCallOf(node, DEFINE_OPTIONS)) {
  45107. return false;
  45108. }
  45109. if (ctx.hasDefineOptionsCall) {
  45110. ctx.error(`duplicate ${DEFINE_OPTIONS}() call`, node);
  45111. }
  45112. if (node.typeParameters) {
  45113. ctx.error(`${DEFINE_OPTIONS}() cannot accept type arguments`, node);
  45114. }
  45115. if (!node.arguments[0]) return true;
  45116. ctx.hasDefineOptionsCall = true;
  45117. ctx.optionsRuntimeDecl = unwrapTSNode(node.arguments[0]);
  45118. let propsOption = void 0;
  45119. let emitsOption = void 0;
  45120. let exposeOption = void 0;
  45121. let slotsOption = void 0;
  45122. if (ctx.optionsRuntimeDecl.type === "ObjectExpression") {
  45123. for (const prop of ctx.optionsRuntimeDecl.properties) {
  45124. if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
  45125. switch (prop.key.name) {
  45126. case "props":
  45127. propsOption = prop;
  45128. break;
  45129. case "emits":
  45130. emitsOption = prop;
  45131. break;
  45132. case "expose":
  45133. exposeOption = prop;
  45134. break;
  45135. case "slots":
  45136. slotsOption = prop;
  45137. break;
  45138. }
  45139. }
  45140. }
  45141. }
  45142. if (propsOption) {
  45143. ctx.error(
  45144. `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
  45145. propsOption
  45146. );
  45147. }
  45148. if (emitsOption) {
  45149. ctx.error(
  45150. `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
  45151. emitsOption
  45152. );
  45153. }
  45154. if (exposeOption) {
  45155. ctx.error(
  45156. `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
  45157. exposeOption
  45158. );
  45159. }
  45160. if (slotsOption) {
  45161. ctx.error(
  45162. `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
  45163. slotsOption
  45164. );
  45165. }
  45166. return true;
  45167. }
  45168. function processAwait(ctx, node, needSemi, isStatement) {
  45169. const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
  45170. const startOffset = ctx.startOffset;
  45171. const argumentStr = ctx.descriptor.source.slice(
  45172. argumentStart + startOffset,
  45173. node.argument.end + startOffset
  45174. );
  45175. const containsNestedAwait = /\bawait\b/.test(argumentStr);
  45176. ctx.s.overwrite(
  45177. node.start + startOffset,
  45178. argumentStart + startOffset,
  45179. `${needSemi ? `;` : ``}(
  45180. ([__temp,__restore] = ${ctx.helper(
  45181. `withAsyncContext`
  45182. )}(${containsNestedAwait ? `async ` : ``}() => `
  45183. );
  45184. ctx.s.appendLeft(
  45185. node.end + startOffset,
  45186. `)),
  45187. ${isStatement ? `` : `__temp = `}await __temp,
  45188. __restore()${isStatement ? `` : `,
  45189. __temp`}
  45190. )`
  45191. );
  45192. }
  45193. var __defProp$1 = Object.defineProperty;
  45194. var __defProps = Object.defineProperties;
  45195. var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
  45196. var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
  45197. var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
  45198. var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
  45199. var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  45200. var __spreadValues$1 = (a, b) => {
  45201. for (var prop in b || (b = {}))
  45202. if (__hasOwnProp$1.call(b, prop))
  45203. __defNormalProp$1(a, prop, b[prop]);
  45204. if (__getOwnPropSymbols$1)
  45205. for (var prop of __getOwnPropSymbols$1(b)) {
  45206. if (__propIsEnum$1.call(b, prop))
  45207. __defNormalProp$1(a, prop, b[prop]);
  45208. }
  45209. return a;
  45210. };
  45211. var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
  45212. const MACROS = [
  45213. DEFINE_PROPS,
  45214. DEFINE_EMITS,
  45215. DEFINE_EXPOSE,
  45216. DEFINE_OPTIONS,
  45217. DEFINE_SLOTS,
  45218. DEFINE_MODEL,
  45219. WITH_DEFAULTS
  45220. ];
  45221. function compileScript(sfc, options) {
  45222. var _a, _b, _c;
  45223. if (!options.id) {
  45224. warnOnce$3(
  45225. `compileScript now requires passing the \`id\` option.
  45226. Upgrade your vite or vue-loader version for compatibility with the latest experimental proposals.`
  45227. );
  45228. }
  45229. const ctx = new ScriptCompileContext(sfc, options);
  45230. const { script, scriptSetup, source, filename } = sfc;
  45231. const hoistStatic = options.hoistStatic !== false && !script;
  45232. const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
  45233. const scriptLang = script && script.lang;
  45234. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  45235. if (!scriptSetup) {
  45236. if (!script) {
  45237. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  45238. }
  45239. return processNormalScript(ctx, scopeId);
  45240. }
  45241. if (script && scriptLang !== scriptSetupLang) {
  45242. throw new Error(
  45243. `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
  45244. );
  45245. }
  45246. if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
  45247. return scriptSetup;
  45248. }
  45249. const scriptBindings = /* @__PURE__ */ Object.create(null);
  45250. const setupBindings = /* @__PURE__ */ Object.create(null);
  45251. let defaultExport;
  45252. let hasAwait = false;
  45253. let hasInlinedSsrRenderFn = false;
  45254. const startOffset = ctx.startOffset;
  45255. const endOffset = ctx.endOffset;
  45256. const scriptStartOffset = script && script.loc.start.offset;
  45257. const scriptEndOffset = script && script.loc.end.offset;
  45258. function hoistNode(node) {
  45259. const start = node.start + startOffset;
  45260. let end = node.end + startOffset;
  45261. if (node.trailingComments && node.trailingComments.length > 0) {
  45262. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  45263. end = lastCommentNode.end + startOffset;
  45264. }
  45265. while (end <= source.length) {
  45266. if (!/\s/.test(source.charAt(end))) {
  45267. break;
  45268. }
  45269. end++;
  45270. }
  45271. ctx.s.move(start, end, 0);
  45272. }
  45273. function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
  45274. let isUsedInTemplate = needTemplateUsageCheck;
  45275. if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
  45276. isUsedInTemplate = isImportUsed(local, sfc);
  45277. }
  45278. ctx.userImports[local] = {
  45279. isType,
  45280. imported,
  45281. local,
  45282. source: source2,
  45283. isFromSetup,
  45284. isUsedInTemplate
  45285. };
  45286. }
  45287. function checkInvalidScopeReference(node, method) {
  45288. if (!node) return;
  45289. walkIdentifiers(node, (id) => {
  45290. const binding = setupBindings[id.name];
  45291. if (binding && binding !== "literal-const") {
  45292. ctx.error(
  45293. `\`${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.`,
  45294. id
  45295. );
  45296. }
  45297. });
  45298. }
  45299. const scriptAst = ctx.scriptAst;
  45300. const scriptSetupAst = ctx.scriptSetupAst;
  45301. if (scriptAst) {
  45302. for (const node of scriptAst.body) {
  45303. if (node.type === "ImportDeclaration") {
  45304. for (const specifier of node.specifiers) {
  45305. const imported = getImportedName(specifier);
  45306. registerUserImport(
  45307. node.source.value,
  45308. specifier.local.name,
  45309. imported,
  45310. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  45311. false,
  45312. !options.inlineTemplate
  45313. );
  45314. }
  45315. }
  45316. }
  45317. }
  45318. for (const node of scriptSetupAst.body) {
  45319. if (node.type === "ImportDeclaration") {
  45320. hoistNode(node);
  45321. let removed = 0;
  45322. const removeSpecifier = (i) => {
  45323. const removeLeft = i > removed;
  45324. removed++;
  45325. const current = node.specifiers[i];
  45326. const next = node.specifiers[i + 1];
  45327. ctx.s.remove(
  45328. removeLeft ? node.specifiers[i - 1].end + startOffset : current.start + startOffset,
  45329. next && !removeLeft ? next.start + startOffset : current.end + startOffset
  45330. );
  45331. };
  45332. for (let i = 0; i < node.specifiers.length; i++) {
  45333. const specifier = node.specifiers[i];
  45334. const local = specifier.local.name;
  45335. const imported = getImportedName(specifier);
  45336. const source2 = node.source.value;
  45337. const existing = ctx.userImports[local];
  45338. if (source2 === "vue" && MACROS.includes(imported)) {
  45339. if (local === imported) {
  45340. warnOnce$3(
  45341. `\`${imported}\` is a compiler macro and no longer needs to be imported.`
  45342. );
  45343. } else {
  45344. ctx.error(
  45345. `\`${imported}\` is a compiler macro and cannot be aliased to a different name.`,
  45346. specifier
  45347. );
  45348. }
  45349. removeSpecifier(i);
  45350. } else if (existing) {
  45351. if (existing.source === source2 && existing.imported === imported) {
  45352. removeSpecifier(i);
  45353. } else {
  45354. ctx.error(
  45355. `different imports aliased to same local name.`,
  45356. specifier
  45357. );
  45358. }
  45359. } else {
  45360. registerUserImport(
  45361. source2,
  45362. local,
  45363. imported,
  45364. node.importKind === "type" || specifier.type === "ImportSpecifier" && specifier.importKind === "type",
  45365. true,
  45366. !options.inlineTemplate
  45367. );
  45368. }
  45369. }
  45370. if (node.specifiers.length && removed === node.specifiers.length) {
  45371. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45372. }
  45373. }
  45374. }
  45375. const vueImportAliases = {};
  45376. for (const key in ctx.userImports) {
  45377. const { source: source2, imported, local } = ctx.userImports[key];
  45378. if (source2 === "vue") vueImportAliases[imported] = local;
  45379. }
  45380. if (script && scriptAst) {
  45381. for (const node of scriptAst.body) {
  45382. if (node.type === "ExportDefaultDeclaration") {
  45383. defaultExport = node;
  45384. let optionProperties;
  45385. if (defaultExport.declaration.type === "ObjectExpression") {
  45386. optionProperties = defaultExport.declaration.properties;
  45387. } else if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.arguments[0] && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
  45388. optionProperties = defaultExport.declaration.arguments[0].properties;
  45389. }
  45390. if (optionProperties) {
  45391. for (const p of optionProperties) {
  45392. if (p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "name") {
  45393. ctx.hasDefaultExportName = true;
  45394. }
  45395. if ((p.type === "ObjectMethod" || p.type === "ObjectProperty") && p.key.type === "Identifier" && p.key.name === "render") {
  45396. ctx.hasDefaultExportRender = true;
  45397. }
  45398. }
  45399. }
  45400. const start = node.start + scriptStartOffset;
  45401. const end = node.declaration.start + scriptStartOffset;
  45402. ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `);
  45403. } else if (node.type === "ExportNamedDeclaration") {
  45404. const defaultSpecifier = node.specifiers.find(
  45405. (s) => s.exported.type === "Identifier" && s.exported.name === "default"
  45406. );
  45407. if (defaultSpecifier) {
  45408. defaultExport = node;
  45409. if (node.specifiers.length > 1) {
  45410. ctx.s.remove(
  45411. defaultSpecifier.start + scriptStartOffset,
  45412. defaultSpecifier.end + scriptStartOffset
  45413. );
  45414. } else {
  45415. ctx.s.remove(
  45416. node.start + scriptStartOffset,
  45417. node.end + scriptStartOffset
  45418. );
  45419. }
  45420. if (node.source) {
  45421. ctx.s.prepend(
  45422. `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'
  45423. `
  45424. );
  45425. } else {
  45426. ctx.s.appendLeft(
  45427. scriptEndOffset,
  45428. `
  45429. const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
  45430. `
  45431. );
  45432. }
  45433. }
  45434. if (node.declaration) {
  45435. walkDeclaration(
  45436. "script",
  45437. node.declaration,
  45438. scriptBindings,
  45439. vueImportAliases,
  45440. hoistStatic
  45441. );
  45442. }
  45443. } else if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  45444. walkDeclaration(
  45445. "script",
  45446. node,
  45447. scriptBindings,
  45448. vueImportAliases,
  45449. hoistStatic
  45450. );
  45451. }
  45452. }
  45453. if (scriptStartOffset > startOffset) {
  45454. if (!/\n$/.test(script.content.trim())) {
  45455. ctx.s.appendLeft(scriptEndOffset, `
  45456. `);
  45457. }
  45458. ctx.s.move(scriptStartOffset, scriptEndOffset, 0);
  45459. }
  45460. }
  45461. for (const node of scriptSetupAst.body) {
  45462. if (node.type === "ExpressionStatement") {
  45463. const expr = unwrapTSNode(node.expression);
  45464. if (processDefineProps(ctx, expr) || processDefineEmits(ctx, expr) || processDefineOptions(ctx, expr) || processDefineSlots(ctx, expr)) {
  45465. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45466. } else if (processDefineExpose(ctx, expr)) {
  45467. const callee = expr.callee;
  45468. ctx.s.overwrite(
  45469. callee.start + startOffset,
  45470. callee.end + startOffset,
  45471. "__expose"
  45472. );
  45473. } else {
  45474. processDefineModel(ctx, expr);
  45475. }
  45476. }
  45477. if (node.type === "VariableDeclaration" && !node.declare) {
  45478. const total = node.declarations.length;
  45479. let left = total;
  45480. let lastNonRemoved;
  45481. for (let i = 0; i < total; i++) {
  45482. const decl = node.declarations[i];
  45483. const init = decl.init && unwrapTSNode(decl.init);
  45484. if (init) {
  45485. if (processDefineOptions(ctx, init)) {
  45486. ctx.error(
  45487. `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
  45488. node
  45489. );
  45490. }
  45491. const isDefineProps = processDefineProps(ctx, init, decl.id);
  45492. if (ctx.propsDestructureRestId) {
  45493. setupBindings[ctx.propsDestructureRestId] = "setup-reactive-const";
  45494. }
  45495. const isDefineEmits = !isDefineProps && processDefineEmits(ctx, init, decl.id);
  45496. !isDefineEmits && (processDefineSlots(ctx, init, decl.id) || processDefineModel(ctx, init, decl.id));
  45497. if (isDefineProps && !ctx.propsDestructureRestId && ctx.propsDestructureDecl) {
  45498. if (left === 1) {
  45499. ctx.s.remove(node.start + startOffset, node.end + startOffset);
  45500. } else {
  45501. let start = decl.start + startOffset;
  45502. let end = decl.end + startOffset;
  45503. if (i === total - 1) {
  45504. start = node.declarations[lastNonRemoved].end + startOffset;
  45505. } else {
  45506. end = node.declarations[i + 1].start + startOffset;
  45507. }
  45508. ctx.s.remove(start, end);
  45509. left--;
  45510. }
  45511. } else if (isDefineEmits) {
  45512. ctx.s.overwrite(
  45513. startOffset + init.start,
  45514. startOffset + init.end,
  45515. "__emit"
  45516. );
  45517. } else {
  45518. lastNonRemoved = i;
  45519. }
  45520. }
  45521. }
  45522. }
  45523. let isAllLiteral = false;
  45524. if ((node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") && !node.declare) {
  45525. isAllLiteral = walkDeclaration(
  45526. "scriptSetup",
  45527. node,
  45528. setupBindings,
  45529. vueImportAliases,
  45530. hoistStatic
  45531. );
  45532. }
  45533. if (hoistStatic && isAllLiteral) {
  45534. hoistNode(node);
  45535. }
  45536. if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
  45537. const scope = [scriptSetupAst.body];
  45538. walk$2(node, {
  45539. enter(child, parent) {
  45540. if (isFunctionType(child)) {
  45541. this.skip();
  45542. }
  45543. if (child.type === "BlockStatement") {
  45544. scope.push(child.body);
  45545. }
  45546. if (child.type === "AwaitExpression") {
  45547. hasAwait = true;
  45548. const currentScope = scope[scope.length - 1];
  45549. const needsSemi = currentScope.some((n, i) => {
  45550. return (scope.length === 1 || i > 0) && n.type === "ExpressionStatement" && n.start === child.start;
  45551. });
  45552. processAwait(
  45553. ctx,
  45554. child,
  45555. needsSemi,
  45556. parent.type === "ExpressionStatement"
  45557. );
  45558. }
  45559. },
  45560. exit(node2) {
  45561. if (node2.type === "BlockStatement") scope.pop();
  45562. }
  45563. });
  45564. }
  45565. if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration") {
  45566. ctx.error(
  45567. `<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.`,
  45568. node
  45569. );
  45570. }
  45571. if (ctx.isTS) {
  45572. if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
  45573. if (node.type !== "TSEnumDeclaration") {
  45574. hoistNode(node);
  45575. }
  45576. }
  45577. }
  45578. }
  45579. if (ctx.propsDestructureDecl) {
  45580. transformDestructuredProps(ctx, vueImportAliases);
  45581. }
  45582. checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
  45583. checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
  45584. checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
  45585. checkInvalidScopeReference(ctx.emitsRuntimeDecl, DEFINE_EMITS);
  45586. checkInvalidScopeReference(ctx.optionsRuntimeDecl, DEFINE_OPTIONS);
  45587. for (const { runtimeOptionNodes } of Object.values(ctx.modelDecls)) {
  45588. for (const node of runtimeOptionNodes) {
  45589. checkInvalidScopeReference(node, DEFINE_MODEL);
  45590. }
  45591. }
  45592. if (script) {
  45593. if (startOffset < scriptStartOffset) {
  45594. ctx.s.remove(0, startOffset);
  45595. ctx.s.remove(endOffset, scriptStartOffset);
  45596. ctx.s.remove(scriptEndOffset, source.length);
  45597. } else {
  45598. ctx.s.remove(0, scriptStartOffset);
  45599. ctx.s.remove(scriptEndOffset, startOffset);
  45600. ctx.s.remove(endOffset, source.length);
  45601. }
  45602. } else {
  45603. ctx.s.remove(0, startOffset);
  45604. ctx.s.remove(endOffset, source.length);
  45605. }
  45606. if (scriptAst) {
  45607. Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body));
  45608. }
  45609. for (const [key, { isType, imported, source: source2 }] of Object.entries(
  45610. ctx.userImports
  45611. )) {
  45612. if (isType) continue;
  45613. ctx.bindingMetadata[key] = imported === "*" || imported === "default" && source2.endsWith(".vue") || source2 === "vue" ? "setup-const" : "setup-maybe-ref";
  45614. }
  45615. for (const key in scriptBindings) {
  45616. ctx.bindingMetadata[key] = scriptBindings[key];
  45617. }
  45618. for (const key in setupBindings) {
  45619. ctx.bindingMetadata[key] = setupBindings[key];
  45620. }
  45621. if (sfc.cssVars.length && // no need to do this when targeting SSR
  45622. !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
  45623. ctx.helperImports.add(CSS_VARS_HELPER);
  45624. ctx.helperImports.add("unref");
  45625. ctx.s.prependLeft(
  45626. startOffset,
  45627. `
  45628. ${genCssVarsCode(
  45629. sfc.cssVars,
  45630. ctx.bindingMetadata,
  45631. scopeId,
  45632. !!options.isProd
  45633. )}
  45634. `
  45635. );
  45636. }
  45637. let args = `__props`;
  45638. if (ctx.propsTypeDecl) {
  45639. args += `: any`;
  45640. }
  45641. if (ctx.propsDecl) {
  45642. if (ctx.propsDestructureRestId) {
  45643. ctx.s.overwrite(
  45644. startOffset + ctx.propsCall.start,
  45645. startOffset + ctx.propsCall.end,
  45646. `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
  45647. Object.keys(ctx.propsDestructuredBindings)
  45648. )})`
  45649. );
  45650. ctx.s.overwrite(
  45651. startOffset + ctx.propsDestructureDecl.start,
  45652. startOffset + ctx.propsDestructureDecl.end,
  45653. ctx.propsDestructureRestId
  45654. );
  45655. } else if (!ctx.propsDestructureDecl) {
  45656. ctx.s.overwrite(
  45657. startOffset + ctx.propsCall.start,
  45658. startOffset + ctx.propsCall.end,
  45659. "__props"
  45660. );
  45661. }
  45662. }
  45663. if (hasAwait) {
  45664. const any = ctx.isTS ? `: any` : ``;
  45665. ctx.s.prependLeft(startOffset, `
  45666. let __temp${any}, __restore${any}
  45667. `);
  45668. }
  45669. const destructureElements = ctx.hasDefineExposeCall || !options.inlineTemplate ? [`expose: __expose`] : [];
  45670. if (ctx.emitDecl) {
  45671. destructureElements.push(`emit: __emit`);
  45672. }
  45673. if (destructureElements.length) {
  45674. args += `, { ${destructureElements.join(", ")} }`;
  45675. }
  45676. let returned;
  45677. if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
  45678. const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
  45679. for (const key in ctx.userImports) {
  45680. if (!ctx.userImports[key].isType && ctx.userImports[key].isUsedInTemplate) {
  45681. allBindings[key] = true;
  45682. }
  45683. }
  45684. returned = `{ `;
  45685. for (const key in allBindings) {
  45686. if (allBindings[key] === true && ctx.userImports[key].source !== "vue" && !ctx.userImports[key].source.endsWith(".vue")) {
  45687. returned += `get ${key}() { return ${key} }, `;
  45688. } else if (ctx.bindingMetadata[key] === "setup-let") {
  45689. const setArg = key === "v" ? `_v` : `v`;
  45690. returned += `get ${key}() { return ${key} }, set ${key}(${setArg}) { ${key} = ${setArg} }, `;
  45691. } else {
  45692. returned += `${key}, `;
  45693. }
  45694. }
  45695. returned = returned.replace(/, $/, "") + ` }`;
  45696. } else {
  45697. if (sfc.template && !sfc.template.src) {
  45698. if (options.templateOptions && options.templateOptions.ssr) {
  45699. hasInlinedSsrRenderFn = true;
  45700. }
  45701. const { code, ast, preamble, tips, errors } = compileTemplate(__spreadProps(__spreadValues$1({
  45702. filename,
  45703. ast: sfc.template.ast,
  45704. source: sfc.template.content,
  45705. inMap: sfc.template.map
  45706. }, options.templateOptions), {
  45707. id: scopeId,
  45708. scoped: sfc.styles.some((s) => s.scoped),
  45709. isProd: options.isProd,
  45710. ssrCssVars: sfc.cssVars,
  45711. compilerOptions: __spreadProps(__spreadValues$1({}, options.templateOptions && options.templateOptions.compilerOptions), {
  45712. inline: true,
  45713. isTS: ctx.isTS,
  45714. bindingMetadata: ctx.bindingMetadata
  45715. })
  45716. }));
  45717. if (tips.length) {
  45718. tips.forEach(warnOnce$3);
  45719. }
  45720. const err = errors[0];
  45721. if (typeof err === "string") {
  45722. throw new Error(err);
  45723. } else if (err) {
  45724. if (err.loc) {
  45725. err.message += `
  45726. ` + sfc.filename + "\n" + generateCodeFrame(
  45727. source,
  45728. err.loc.start.offset,
  45729. err.loc.end.offset
  45730. ) + `
  45731. `;
  45732. }
  45733. throw err;
  45734. }
  45735. if (preamble) {
  45736. ctx.s.prepend(preamble);
  45737. }
  45738. if (ast && ast.helpers.has(UNREF)) {
  45739. ctx.helperImports.delete("unref");
  45740. }
  45741. returned = code;
  45742. } else {
  45743. returned = `() => {}`;
  45744. }
  45745. }
  45746. if (!options.inlineTemplate && true) {
  45747. ctx.s.appendRight(
  45748. endOffset,
  45749. `
  45750. const __returned__ = ${returned}
  45751. Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })
  45752. return __returned__
  45753. }
  45754. `
  45755. );
  45756. } else {
  45757. ctx.s.appendRight(endOffset, `
  45758. return ${returned}
  45759. }
  45760. `);
  45761. }
  45762. const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
  45763. let runtimeOptions = ``;
  45764. if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  45765. const match = filename.match(/([^/\\]+)\.\w+$/);
  45766. if (match) {
  45767. runtimeOptions += `
  45768. __name: '${match[1]}',`;
  45769. }
  45770. }
  45771. if (hasInlinedSsrRenderFn) {
  45772. runtimeOptions += `
  45773. __ssrInlineRender: true,`;
  45774. }
  45775. const propsDecl = genRuntimeProps(ctx);
  45776. if (propsDecl) runtimeOptions += `
  45777. props: ${propsDecl},`;
  45778. const emitsDecl = genRuntimeEmits(ctx);
  45779. if (emitsDecl) runtimeOptions += `
  45780. emits: ${emitsDecl},`;
  45781. let definedOptions = "";
  45782. if (ctx.optionsRuntimeDecl) {
  45783. definedOptions = scriptSetup.content.slice(ctx.optionsRuntimeDecl.start, ctx.optionsRuntimeDecl.end).trim();
  45784. }
  45785. const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
  45786. `;
  45787. if (ctx.isTS) {
  45788. const def = (defaultExport ? `
  45789. ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
  45790. ...${definedOptions},` : "");
  45791. ctx.s.prependLeft(
  45792. startOffset,
  45793. `
  45794. ${genDefaultAs} /*#__PURE__*/${ctx.helper(
  45795. `defineComponent`
  45796. )}({${def}${runtimeOptions}
  45797. ${hasAwait ? `async ` : ``}setup(${args}) {
  45798. ${exposeCall}`
  45799. );
  45800. ctx.s.appendRight(endOffset, `})`);
  45801. } else {
  45802. if (defaultExport || definedOptions) {
  45803. ctx.s.prependLeft(
  45804. startOffset,
  45805. `
  45806. ${genDefaultAs} /*#__PURE__*/Object.assign(${defaultExport ? `${normalScriptDefaultVar}, ` : ""}${definedOptions ? `${definedOptions}, ` : ""}{${runtimeOptions}
  45807. ${hasAwait ? `async ` : ``}setup(${args}) {
  45808. ${exposeCall}`
  45809. );
  45810. ctx.s.appendRight(endOffset, `})`);
  45811. } else {
  45812. ctx.s.prependLeft(
  45813. startOffset,
  45814. `
  45815. ${genDefaultAs} {${runtimeOptions}
  45816. ${hasAwait ? `async ` : ``}setup(${args}) {
  45817. ${exposeCall}`
  45818. );
  45819. ctx.s.appendRight(endOffset, `}`);
  45820. }
  45821. }
  45822. if (ctx.helperImports.size > 0) {
  45823. const runtimeModuleName = (_c = (_b = options.templateOptions) == null ? void 0 : _b.compilerOptions) == null ? void 0 : _c.runtimeModuleName;
  45824. const importSrc = runtimeModuleName ? JSON.stringify(runtimeModuleName) : `'vue'`;
  45825. ctx.s.prepend(
  45826. `import { ${[...ctx.helperImports].map((h) => `${h} as _${h}`).join(", ")} } from ${importSrc}
  45827. `
  45828. );
  45829. }
  45830. return __spreadProps(__spreadValues$1({}, scriptSetup), {
  45831. bindings: ctx.bindingMetadata,
  45832. imports: ctx.userImports,
  45833. content: ctx.s.toString(),
  45834. map: options.sourceMap !== false ? ctx.s.generateMap({
  45835. source: filename,
  45836. hires: true,
  45837. includeContent: true
  45838. }) : void 0,
  45839. scriptAst: scriptAst == null ? void 0 : scriptAst.body,
  45840. scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
  45841. deps: ctx.deps ? [...ctx.deps] : void 0
  45842. });
  45843. }
  45844. function registerBinding(bindings, node, type) {
  45845. bindings[node.name] = type;
  45846. }
  45847. function walkDeclaration(from, node, bindings, userImportAliases, hoistStatic) {
  45848. let isAllLiteral = false;
  45849. if (node.type === "VariableDeclaration") {
  45850. const isConst = node.kind === "const";
  45851. isAllLiteral = isConst && node.declarations.every(
  45852. (decl) => decl.id.type === "Identifier" && isStaticNode(decl.init)
  45853. );
  45854. for (const { id, init: _init } of node.declarations) {
  45855. const init = _init && unwrapTSNode(_init);
  45856. const isConstMacroCall = isConst && isCallOf(
  45857. init,
  45858. (c) => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS || c === DEFINE_SLOTS
  45859. );
  45860. if (id.type === "Identifier") {
  45861. let bindingType;
  45862. const userReactiveBinding = userImportAliases["reactive"];
  45863. if ((hoistStatic || from === "script") && (isAllLiteral || isConst && isStaticNode(init))) {
  45864. bindingType = "literal-const";
  45865. } else if (isCallOf(init, userReactiveBinding)) {
  45866. bindingType = isConst ? "setup-reactive-const" : "setup-let";
  45867. } else if (
  45868. // if a declaration is a const literal, we can mark it so that
  45869. // the generated render fn code doesn't need to unref() it
  45870. isConstMacroCall || isConst && canNeverBeRef(init, userReactiveBinding)
  45871. ) {
  45872. bindingType = isCallOf(init, DEFINE_PROPS) ? "setup-reactive-const" : "setup-const";
  45873. } else if (isConst) {
  45874. if (isCallOf(
  45875. init,
  45876. (m) => m === userImportAliases["ref"] || m === userImportAliases["computed"] || m === userImportAliases["shallowRef"] || m === userImportAliases["customRef"] || m === userImportAliases["toRef"] || m === DEFINE_MODEL
  45877. )) {
  45878. bindingType = "setup-ref";
  45879. } else {
  45880. bindingType = "setup-maybe-ref";
  45881. }
  45882. } else {
  45883. bindingType = "setup-let";
  45884. }
  45885. registerBinding(bindings, id, bindingType);
  45886. } else {
  45887. if (isCallOf(init, DEFINE_PROPS)) {
  45888. continue;
  45889. }
  45890. if (id.type === "ObjectPattern") {
  45891. walkObjectPattern(id, bindings, isConst, isConstMacroCall);
  45892. } else if (id.type === "ArrayPattern") {
  45893. walkArrayPattern(id, bindings, isConst, isConstMacroCall);
  45894. }
  45895. }
  45896. }
  45897. } else if (node.type === "TSEnumDeclaration") {
  45898. isAllLiteral = node.members.every(
  45899. (member) => !member.initializer || isStaticNode(member.initializer)
  45900. );
  45901. bindings[node.id.name] = isAllLiteral ? "literal-const" : "setup-const";
  45902. } else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
  45903. bindings[node.id.name] = "setup-const";
  45904. }
  45905. return isAllLiteral;
  45906. }
  45907. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  45908. for (const p of node.properties) {
  45909. if (p.type === "ObjectProperty") {
  45910. if (p.key.type === "Identifier" && p.key === p.value) {
  45911. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45912. registerBinding(bindings, p.key, type);
  45913. } else {
  45914. walkPattern(p.value, bindings, isConst, isDefineCall);
  45915. }
  45916. } else {
  45917. const type = isConst ? "setup-const" : "setup-let";
  45918. registerBinding(bindings, p.argument, type);
  45919. }
  45920. }
  45921. }
  45922. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  45923. for (const e of node.elements) {
  45924. e && walkPattern(e, bindings, isConst, isDefineCall);
  45925. }
  45926. }
  45927. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  45928. if (node.type === "Identifier") {
  45929. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45930. registerBinding(bindings, node, type);
  45931. } else if (node.type === "RestElement") {
  45932. const type = isConst ? "setup-const" : "setup-let";
  45933. registerBinding(bindings, node.argument, type);
  45934. } else if (node.type === "ObjectPattern") {
  45935. walkObjectPattern(node, bindings, isConst);
  45936. } else if (node.type === "ArrayPattern") {
  45937. walkArrayPattern(node, bindings, isConst);
  45938. } else if (node.type === "AssignmentPattern") {
  45939. if (node.left.type === "Identifier") {
  45940. const type = isDefineCall ? "setup-const" : isConst ? "setup-maybe-ref" : "setup-let";
  45941. registerBinding(bindings, node.left, type);
  45942. } else {
  45943. walkPattern(node.left, bindings, isConst);
  45944. }
  45945. }
  45946. }
  45947. function canNeverBeRef(node, userReactiveImport) {
  45948. if (isCallOf(node, userReactiveImport)) {
  45949. return true;
  45950. }
  45951. switch (node.type) {
  45952. case "UnaryExpression":
  45953. case "BinaryExpression":
  45954. case "ArrayExpression":
  45955. case "ObjectExpression":
  45956. case "FunctionExpression":
  45957. case "ArrowFunctionExpression":
  45958. case "UpdateExpression":
  45959. case "ClassExpression":
  45960. case "TaggedTemplateExpression":
  45961. return true;
  45962. case "SequenceExpression":
  45963. return canNeverBeRef(
  45964. node.expressions[node.expressions.length - 1],
  45965. userReactiveImport
  45966. );
  45967. default:
  45968. if (isLiteralNode(node)) {
  45969. return true;
  45970. }
  45971. return false;
  45972. }
  45973. }
  45974. function isStaticNode(node) {
  45975. node = unwrapTSNode(node);
  45976. switch (node.type) {
  45977. case "UnaryExpression":
  45978. return isStaticNode(node.argument);
  45979. case "LogicalExpression":
  45980. case "BinaryExpression":
  45981. return isStaticNode(node.left) && isStaticNode(node.right);
  45982. case "ConditionalExpression": {
  45983. return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
  45984. }
  45985. case "SequenceExpression":
  45986. case "TemplateLiteral":
  45987. return node.expressions.every((expr) => isStaticNode(expr));
  45988. case "ParenthesizedExpression":
  45989. return isStaticNode(node.expression);
  45990. case "StringLiteral":
  45991. case "NumericLiteral":
  45992. case "BooleanLiteral":
  45993. case "NullLiteral":
  45994. case "BigIntLiteral":
  45995. return true;
  45996. }
  45997. return false;
  45998. }
  45999. var __defProp = Object.defineProperty;
  46000. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  46001. var __hasOwnProp = Object.prototype.hasOwnProperty;
  46002. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  46003. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  46004. var __spreadValues = (a, b) => {
  46005. for (var prop in b || (b = {}))
  46006. if (__hasOwnProp.call(b, prop))
  46007. __defNormalProp(a, prop, b[prop]);
  46008. if (__getOwnPropSymbols)
  46009. for (var prop of __getOwnPropSymbols(b)) {
  46010. if (__propIsEnum.call(b, prop))
  46011. __defNormalProp(a, prop, b[prop]);
  46012. }
  46013. return a;
  46014. };
  46015. const version = "3.4.38";
  46016. const parseCache = parseCache$1;
  46017. const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
  46018. const walk = walk$2;
  46019. const shouldTransformRef = () => false;
  46020. export { MagicString, parse_1$1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, errorMessages, extractIdentifiers$1 as extractIdentifiers, extractRuntimeEmits, extractRuntimeProps, generateCodeFrame, inferRuntimeType, invalidateTypeCache, isInDestructureAssignment, isStaticProperty, parse$7 as parse, parseCache, registerTS, resolveTypeElements, rewriteDefault, rewriteDefaultAST, shouldTransformRef, version, walk, walkIdentifiers };